Repository: eFiniLan/xnxpilot Branch: 0.8.9 Commit: 9a3da4199628 Files: 1333 Total size: 168.7 MB Directory structure: gitextract_fiiqppqd/ ├── .gitignore ├── CHANGELOGS-DEV.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── HOWTO-ONEPLUS.md ├── HOWTO-Translate.md ├── Jenkinsfile ├── LICENSE ├── README-openpilot.md ├── README.md ├── RELEASES.md ├── SAFETY.md ├── SConstruct ├── cereal/ │ ├── .gitignore │ ├── SConscript │ ├── __init__.py │ ├── car.capnp │ ├── dp.capnp │ ├── include/ │ │ ├── c++.capnp │ │ └── java.capnp │ ├── legacy.capnp │ ├── log.capnp │ ├── logger/ │ │ └── logger.h │ ├── messaging/ │ │ ├── .gitignore │ │ ├── __init__.py │ │ ├── bridge.cc │ │ ├── impl_msgq.cc │ │ ├── impl_msgq.h │ │ ├── impl_zmq.cc │ │ ├── impl_zmq.h │ │ ├── messaging.cc │ │ ├── messaging.h │ │ ├── messaging.pxd │ │ ├── messaging_pyx.pyx │ │ ├── msgq.cc │ │ ├── msgq.h │ │ └── socketmaster.cc │ ├── services.py │ └── visionipc/ │ ├── .gitignore │ ├── __init__.py │ ├── ipc.cc │ ├── ipc.h │ ├── test_runner.cc │ ├── visionbuf.cc │ ├── visionbuf.h │ ├── visionbuf_cl.cc │ ├── visionbuf_ion.cc │ ├── visionipc.h │ ├── visionipc.pxd │ ├── visionipc_client.cc │ ├── visionipc_client.h │ ├── visionipc_pyx.pyx │ ├── visionipc_server.cc │ ├── visionipc_server.h │ └── visionipc_tests.cc ├── common/ │ ├── .gitignore │ ├── SConscript │ ├── __init__.py │ ├── api/ │ │ └── __init__.py │ ├── basedir.py │ ├── clock.pyx │ ├── cython_hacks.py │ ├── dict_helpers.py │ ├── dp_common.py │ ├── dp_conf.py │ ├── dp_time.py │ ├── ffi_wrapper.py │ ├── file_helpers.py │ ├── filter_simple.py │ ├── gpio.py │ ├── i18n.py │ ├── kalman/ │ │ ├── .gitignore │ │ ├── SConscript │ │ ├── __init__.py │ │ ├── simple_kalman.py │ │ ├── simple_kalman_impl.pxd │ │ ├── simple_kalman_impl.pyx │ │ ├── simple_kalman_old.py │ │ └── tests/ │ │ ├── __init__.py │ │ └── test_simple_kalman.py │ ├── logging_extra.py │ ├── numpy_fast.py │ ├── params.py │ ├── params_pxd.pxd │ ├── params_pyx.pyx │ ├── profiler.py │ ├── realtime.py │ ├── spinner.py │ ├── stat_live.py │ ├── text_window.py │ ├── timeout.py │ ├── transformations/ │ │ ├── SConscript │ │ ├── __init__.py │ │ ├── camera.py │ │ ├── coordinates.cc │ │ ├── coordinates.hpp │ │ ├── coordinates.py │ │ ├── model.py │ │ ├── orientation.cc │ │ ├── orientation.hpp │ │ ├── orientation.py │ │ ├── transformations.pxd │ │ └── transformations.pyx │ └── xattr.py ├── installer/ │ ├── custom/ │ │ ├── install_gfortran.sh │ │ └── termux-elf-cleaner/ │ │ ├── COPYING │ │ ├── Makefile │ │ ├── README.md │ │ ├── elf.h │ │ └── termux-elf-cleaner.cpp │ └── updater/ │ ├── Makefile │ ├── oneplus.json │ ├── update.json │ └── updater ├── jetson/ │ ├── env_installer.sh │ ├── launcher.sh │ ├── openpilot_env.sh │ └── release.py ├── launch_chffrplus.sh ├── launch_env.sh ├── launch_openpilot.sh ├── models/ │ └── supercombo.onnx ├── opendbc/ │ ├── .gitignore │ ├── __init__.py │ ├── acura_ilx_2016_can_generated.dbc │ ├── acura_ilx_2016_nidec.dbc │ ├── acura_rdx_2018_can_generated.dbc │ ├── acura_rdx_2020_can_generated.dbc │ ├── can/ │ │ ├── SConscript │ │ ├── __init__.py │ │ ├── can_define.py │ │ ├── common.cc │ │ ├── common.h │ │ ├── common.pxd │ │ ├── common_dbc.h │ │ ├── dbc.cc │ │ ├── dbc.py │ │ ├── dbc_out/ │ │ │ ├── .gitignore │ │ │ └── .gitkeep │ │ ├── dbc_template.cc │ │ ├── packer.cc │ │ ├── packer.py │ │ ├── packer_pyx.pyx │ │ ├── parser.cc │ │ ├── parser.py │ │ ├── parser_pyx.pyx │ │ └── process_dbc.py │ ├── chrysler_pacifica_2017_hybrid.dbc │ ├── chrysler_pacifica_2017_hybrid_private_fusion.dbc │ ├── ford_fusion_2018_adas.dbc │ ├── ford_fusion_2018_pt.dbc │ ├── gm_global_a_chassis.dbc │ ├── gm_global_a_object.dbc │ ├── gm_global_a_powertrain.dbc │ ├── honda_accord_2018_can_generated.dbc │ ├── honda_civic_hatchback_ex_2017_can_generated.dbc │ ├── honda_civic_sedan_16_diesel_2019_can_generated.dbc │ ├── honda_civic_touring_2016_can_generated.dbc │ ├── honda_crv_ex_2017_body_generated.dbc │ ├── honda_crv_ex_2017_can_generated.dbc │ ├── honda_crv_executive_2016_can_generated.dbc │ ├── honda_crv_hybrid_2019_can_generated.dbc │ ├── honda_crv_touring_2016_can_generated.dbc │ ├── honda_fit_ex_2018_can_generated.dbc │ ├── honda_insight_ex_2019_can_generated.dbc │ ├── honda_odyssey_exl_2018_generated.dbc │ ├── honda_odyssey_extreme_edition_2018_china_can_generated.dbc │ ├── honda_pilot_touring_2017_can_generated.dbc │ ├── honda_ridgeline_black_edition_2017_can_generated.dbc │ ├── hyundai_kia_generic.dbc │ ├── lexus_ct200h_2018_pt_generated.dbc │ ├── lexus_is300h_2017_pt_generated.dbc │ ├── lexus_is_2018_pt_generated.dbc │ ├── lexus_nx300_2018_pt_generated.dbc │ ├── lexus_nx300h_2018_pt_generated.dbc │ ├── lexus_rx_350_2016_pt_generated.dbc │ ├── lexus_rx_hybrid_2017_pt_generated.dbc │ ├── mazda_2017.dbc │ ├── nissan_leaf_2018.dbc │ ├── nissan_x_trail_2017.dbc │ ├── subaru_forester_2017_generated.dbc │ ├── subaru_global_2017_generated.dbc │ ├── subaru_outback_2015_generated.dbc │ ├── subaru_outback_2019_generated.dbc │ ├── tesla_can.dbc │ ├── tesla_radar.dbc │ ├── toyota_adas.dbc │ ├── toyota_avalon_2017_pt_generated.dbc │ ├── toyota_camry_hybrid_2018_pt_generated.dbc │ ├── toyota_corolla_2017_pt_generated.dbc │ ├── toyota_highlander_2017_pt_generated.dbc │ ├── toyota_highlander_hybrid_2018_pt_generated.dbc │ ├── toyota_nodsu_hybrid_pt_generated.dbc │ ├── toyota_nodsu_pt_generated.dbc │ ├── toyota_prius_2017_pt_generated.dbc │ ├── toyota_prius_alpha_2017_pt_generated.dbc │ ├── toyota_rav4_2017_pt_generated.dbc │ ├── toyota_rav4_hybrid_2017_pt_generated.dbc │ ├── toyota_sienna_xle_2018_pt_generated.dbc │ ├── toyota_tss2_adas.dbc │ └── vw_mqb_2010.dbc ├── panda/ │ ├── .gitignore │ ├── __init__.py │ ├── board/ │ │ ├── Makefile │ │ ├── README.md │ │ ├── SConscript │ │ ├── __init__.py │ │ ├── boards/ │ │ │ ├── black.h │ │ │ ├── board_declarations.h │ │ │ ├── dos.h │ │ │ ├── grey.h │ │ │ ├── pedal.h │ │ │ ├── red.h │ │ │ ├── uno.h │ │ │ ├── unused_funcs.h │ │ │ └── white.h │ │ ├── bootstub.c │ │ ├── bootstub_declarations.h │ │ ├── build_all.sh │ │ ├── config.h │ │ ├── crc.h │ │ ├── critical.h │ │ ├── drivers/ │ │ │ ├── bxcan.h │ │ │ ├── can_common.h │ │ │ ├── fan.h │ │ │ ├── fdcan.h │ │ │ ├── gmlan_alt.h │ │ │ ├── gpio.h │ │ │ ├── harness.h │ │ │ ├── interrupts.h │ │ │ ├── kline_init.h │ │ │ ├── pwm.h │ │ │ ├── registers.h │ │ │ ├── rtc.h │ │ │ ├── timers.h │ │ │ ├── uart.h │ │ │ └── usb.h │ │ ├── early_init.h │ │ ├── faults.h │ │ ├── flash.sh │ │ ├── flash_h7.sh │ │ ├── flasher.h │ │ ├── get_sdk.sh │ │ ├── get_sdk_mac.sh │ │ ├── libc.h │ │ ├── main.c │ │ ├── main_declarations.h │ │ ├── obj/ │ │ │ └── .placeholder │ │ ├── pedal/ │ │ │ ├── .gitignore │ │ │ ├── README │ │ │ ├── flash_can.sh │ │ │ ├── main.c │ │ │ ├── main_declarations.h │ │ │ └── recover.sh │ │ ├── power_saving.h │ │ ├── provision.h │ │ ├── recover.sh │ │ ├── recover_h7.sh │ │ ├── safety/ │ │ │ ├── safety_chrysler.h │ │ │ ├── safety_defaults.h │ │ │ ├── safety_elm327.h │ │ │ ├── safety_ford.h │ │ │ ├── safety_gm.h │ │ │ ├── safety_gm_ascm.h │ │ │ ├── safety_honda.h │ │ │ ├── safety_hyundai.h │ │ │ ├── safety_mazda.h │ │ │ ├── safety_nissan.h │ │ │ ├── safety_subaru.h │ │ │ ├── safety_tesla.h │ │ │ ├── safety_toyota.h │ │ │ └── safety_volkswagen.h │ │ ├── safety.h │ │ ├── safety_declarations.h │ │ ├── stm32fx/ │ │ │ ├── board.h │ │ │ ├── clock.h │ │ │ ├── clock_source.h │ │ │ ├── inc/ │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_cm3.h │ │ │ │ ├── core_cm4.h │ │ │ │ ├── mpu_armv7.h │ │ │ │ ├── stm32f205xx.h │ │ │ │ ├── stm32f2xx.h │ │ │ │ ├── stm32f2xx_hal_def.h │ │ │ │ ├── stm32f2xx_hal_gpio_ex.h │ │ │ │ ├── stm32f413xx.h │ │ │ │ ├── stm32f4xx.h │ │ │ │ ├── stm32f4xx_hal_def.h │ │ │ │ ├── stm32f4xx_hal_gpio_ex.h │ │ │ │ ├── system_stm32f2xx.h │ │ │ │ └── system_stm32f4xx.h │ │ │ ├── interrupt_handlers.h │ │ │ ├── lladc.h │ │ │ ├── llbxcan.h │ │ │ ├── lldac.h │ │ │ ├── llfan.h │ │ │ ├── llflash.h │ │ │ ├── llrtc.h │ │ │ ├── llspi.h │ │ │ ├── lluart.h │ │ │ ├── llusb.h │ │ │ ├── peripherals.h │ │ │ ├── startup_stm32f205xx.s │ │ │ ├── startup_stm32f413xx.s │ │ │ ├── stm32fx_config.h │ │ │ └── stm32fx_flash.ld │ │ ├── stm32h7/ │ │ │ ├── board.h │ │ │ ├── clock.h │ │ │ ├── inc/ │ │ │ │ ├── cmsis_compiler.h │ │ │ │ ├── cmsis_gcc.h │ │ │ │ ├── cmsis_version.h │ │ │ │ ├── core_cm7.h │ │ │ │ ├── mpu_armv8.h │ │ │ │ ├── stm32h725xx.h │ │ │ │ ├── stm32h735xx.h │ │ │ │ ├── stm32h7xx.h │ │ │ │ ├── stm32h7xx_hal_def.h │ │ │ │ ├── stm32h7xx_hal_gpio_ex.h │ │ │ │ └── system_stm32h7xx.h │ │ │ ├── interrupt_handlers.h │ │ │ ├── lladc.h │ │ │ ├── llfan.h │ │ │ ├── llfdcan.h │ │ │ ├── llflash.h │ │ │ ├── llrtc.h │ │ │ ├── lluart.h │ │ │ ├── llusb.h │ │ │ ├── peripherals.h │ │ │ ├── startup_stm32h7x5xx.s │ │ │ ├── stm32h7_config.h │ │ │ └── stm32h7x5_flash.ld │ │ └── tests/ │ │ └── test_rsa.c │ ├── certs/ │ │ ├── debug │ │ ├── debug.pub │ │ └── release.pub │ ├── crypto/ │ │ ├── hash-internal.h │ │ ├── rsa.c │ │ ├── rsa.h │ │ ├── sha.c │ │ ├── sha.h │ │ ├── sign.py │ │ └── stdint.h │ ├── examples/ │ │ └── query_fw_versions.py │ └── python/ │ ├── __init__.py │ ├── config.py │ ├── dfu.py │ ├── flash_release.py │ ├── isotp.py │ ├── serial.py │ ├── uds.py │ └── update.py ├── phonelibs/ │ ├── SConscript │ ├── android_frameworks_native/ │ │ ├── get.txt │ │ └── include/ │ │ ├── android/ │ │ │ ├── asset_manager.h │ │ │ ├── asset_manager_jni.h │ │ │ ├── bitmap.h │ │ │ ├── configuration.h │ │ │ ├── input.h │ │ │ ├── keycodes.h │ │ │ ├── looper.h │ │ │ ├── multinetwork.h │ │ │ ├── native_activity.h │ │ │ ├── native_window.h │ │ │ ├── native_window_jni.h │ │ │ ├── obb.h │ │ │ ├── rect.h │ │ │ ├── sensor.h │ │ │ ├── storage_manager.h │ │ │ ├── trace.h │ │ │ └── window.h │ │ ├── binder/ │ │ │ ├── AppOpsManager.h │ │ │ ├── Binder.h │ │ │ ├── BinderService.h │ │ │ ├── BpBinder.h │ │ │ ├── BufferedTextOutput.h │ │ │ ├── Debug.h │ │ │ ├── IAppOpsCallback.h │ │ │ ├── IAppOpsService.h │ │ │ ├── IBatteryStats.h │ │ │ ├── IBinder.h │ │ │ ├── IInterface.h │ │ │ ├── IMemory.h │ │ │ ├── IPCThreadState.h │ │ │ ├── IPermissionController.h │ │ │ ├── IProcessInfoService.h │ │ │ ├── IServiceManager.h │ │ │ ├── MemoryBase.h │ │ │ ├── MemoryDealer.h │ │ │ ├── MemoryHeapBase.h │ │ │ ├── MemoryHeapIon.h │ │ │ ├── Parcel.h │ │ │ ├── PermissionCache.h │ │ │ ├── ProcessInfoService.h │ │ │ ├── ProcessState.h │ │ │ └── TextOutput.h │ │ ├── gui/ │ │ │ ├── BitTube.h │ │ │ ├── BufferItem.h │ │ │ ├── BufferItemConsumer.h │ │ │ ├── BufferQueue.h │ │ │ ├── BufferQueueConsumer.h │ │ │ ├── BufferQueueCore.h │ │ │ ├── BufferQueueDefs.h │ │ │ ├── BufferQueueProducer.h │ │ │ ├── BufferSlot.h │ │ │ ├── ConsumerBase.h │ │ │ ├── CpuConsumer.h │ │ │ ├── DisplayEventReceiver.h │ │ │ ├── GLConsumer.h │ │ │ ├── GraphicBufferAlloc.h │ │ │ ├── GuiConfig.h │ │ │ ├── IConsumerListener.h │ │ │ ├── IDisplayEventConnection.h │ │ │ ├── IGraphicBufferAlloc.h │ │ │ ├── IGraphicBufferConsumer.h │ │ │ ├── IGraphicBufferProducer.h │ │ │ ├── IProducerListener.h │ │ │ ├── ISensorEventConnection.h │ │ │ ├── ISensorServer.h │ │ │ ├── ISurfaceComposer.h │ │ │ ├── ISurfaceComposerClient.h │ │ │ ├── Sensor.h │ │ │ ├── SensorEventQueue.h │ │ │ ├── SensorManager.h │ │ │ ├── StreamSplitter.h │ │ │ ├── Surface.h │ │ │ ├── SurfaceComposerClient.h │ │ │ └── SurfaceControl.h │ │ └── ui/ │ │ ├── ANativeObjectBase.h │ │ ├── DisplayInfo.h │ │ ├── DisplayStatInfo.h │ │ ├── Fence.h │ │ ├── FrameStats.h │ │ ├── FramebufferNativeWindow.h │ │ ├── GraphicBuffer.h │ │ ├── GraphicBufferAllocator.h │ │ ├── GraphicBufferMapper.h │ │ ├── PixelFormat.h │ │ ├── Point.h │ │ ├── Rect.h │ │ ├── Region.h │ │ ├── TMatHelpers.h │ │ ├── TVecHelpers.h │ │ ├── UiConfig.h │ │ ├── mat4.h │ │ ├── vec2.h │ │ ├── vec3.h │ │ └── vec4.h │ ├── android_hardware_libhardware/ │ │ └── include/ │ │ └── hardware/ │ │ ├── activity_recognition.h │ │ ├── audio.h │ │ ├── audio_alsaops.h │ │ ├── audio_amplifier.h │ │ ├── audio_effect.h │ │ ├── audio_policy.h │ │ ├── bluetooth.h │ │ ├── bt_av.h │ │ ├── bt_common_types.h │ │ ├── bt_gatt.h │ │ ├── bt_gatt_client.h │ │ ├── bt_gatt_server.h │ │ ├── bt_gatt_types.h │ │ ├── bt_hd.h │ │ ├── bt_hf.h │ │ ├── bt_hf_client.h │ │ ├── bt_hh.h │ │ ├── bt_hl.h │ │ ├── bt_mce.h │ │ ├── bt_pan.h │ │ ├── bt_rc.h │ │ ├── bt_sdp.h │ │ ├── bt_sock.h │ │ ├── camera.h │ │ ├── camera2.h │ │ ├── camera3.h │ │ ├── camera_common.h │ │ ├── consumerir.h │ │ ├── display_defs.h │ │ ├── fb.h │ │ ├── fingerprint.h │ │ ├── fused_location.h │ │ ├── gatekeeper.h │ │ ├── gps.h │ │ ├── gralloc.h │ │ ├── hardware.h │ │ ├── hdmi_cec.h │ │ ├── hw_auth_token.h │ │ ├── hwcomposer.h │ │ ├── hwcomposer_defs.h │ │ ├── input.h │ │ ├── keymaster0.h │ │ ├── keymaster1.h │ │ ├── keymaster_common.h │ │ ├── keymaster_defs.h │ │ ├── lights.h │ │ ├── local_time_hal.h │ │ ├── memtrack.h │ │ ├── nfc.h │ │ ├── nfc_tag.h │ │ ├── power.h │ │ ├── qemu_pipe.h │ │ ├── qemud.h │ │ ├── radio.h │ │ ├── sensors.h │ │ ├── sound_trigger.h │ │ ├── tv_input.h │ │ ├── vibrator.h │ │ └── wipower.h │ ├── android_system_core/ │ │ └── include/ │ │ ├── cutils/ │ │ │ ├── android_reboot.h │ │ │ ├── aref.h │ │ │ ├── ashmem.h │ │ │ ├── atomic.h │ │ │ ├── bitops.h │ │ │ ├── compiler.h │ │ │ ├── config_utils.h │ │ │ ├── debugger.h │ │ │ ├── fs.h │ │ │ ├── hashmap.h │ │ │ ├── iosched_policy.h │ │ │ ├── jstring.h │ │ │ ├── klog.h │ │ │ ├── list.h │ │ │ ├── log.h │ │ │ ├── memory.h │ │ │ ├── misc.h │ │ │ ├── multiuser.h │ │ │ ├── native_handle.h │ │ │ ├── open_memstream.h │ │ │ ├── partition_utils.h │ │ │ ├── process_name.h │ │ │ ├── properties.h │ │ │ ├── qtaguid.h │ │ │ ├── record_stream.h │ │ │ ├── sched_policy.h │ │ │ ├── sockets.h │ │ │ ├── str_parms.h │ │ │ ├── threads.h │ │ │ ├── trace.h │ │ │ └── uevent.h │ │ ├── log/ │ │ │ ├── event_tag_map.h │ │ │ ├── log.h │ │ │ ├── log_read.h │ │ │ ├── logd.h │ │ │ ├── logger.h │ │ │ ├── logprint.h │ │ │ └── uio.h │ │ ├── system/ │ │ │ ├── camera.h │ │ │ ├── graphics.h │ │ │ ├── radio.h │ │ │ ├── thread_defs.h │ │ │ └── window.h │ │ └── utils/ │ │ ├── AndroidThreads.h │ │ ├── Atomic.h │ │ ├── BasicHashtable.h │ │ ├── BitSet.h │ │ ├── BlobCache.h │ │ ├── ByteOrder.h │ │ ├── CallStack.h │ │ ├── Compat.h │ │ ├── Condition.h │ │ ├── Debug.h │ │ ├── Endian.h │ │ ├── Errors.h │ │ ├── FileMap.h │ │ ├── Flattenable.h │ │ ├── Functor.h │ │ ├── JenkinsHash.h │ │ ├── KeyedVector.h │ │ ├── LinearTransform.h │ │ ├── List.h │ │ ├── Log.h │ │ ├── Looper.h │ │ ├── LruCache.h │ │ ├── Mutex.h │ │ ├── NativeHandle.h │ │ ├── Printer.h │ │ ├── ProcessCallStack.h │ │ ├── PropertyMap.h │ │ ├── RWLock.h │ │ ├── RefBase.h │ │ ├── SharedBuffer.h │ │ ├── Singleton.h │ │ ├── SortedVector.h │ │ ├── StopWatch.h │ │ ├── String16.h │ │ ├── String8.h │ │ ├── StrongPointer.h │ │ ├── SystemClock.h │ │ ├── Thread.h │ │ ├── ThreadDefs.h │ │ ├── Timers.h │ │ ├── Tokenizer.h │ │ ├── Trace.h │ │ ├── TypeHelpers.h │ │ ├── Unicode.h │ │ ├── Vector.h │ │ ├── VectorImpl.h │ │ ├── ashmem.h │ │ ├── misc.h │ │ └── threads.h │ ├── bzip2/ │ │ ├── LICENSE │ │ ├── build.txt │ │ └── bzlib.h │ ├── json11/ │ │ ├── json11.cpp │ │ └── json11.hpp │ ├── kaitai/ │ │ ├── custom_decoder.h │ │ ├── exceptions.h │ │ ├── kaitaistream.cpp │ │ ├── kaitaistream.h │ │ └── kaitaistruct.h │ ├── libgralloc/ │ │ └── include/ │ │ └── gralloc_priv.h │ ├── libyuv/ │ │ └── include/ │ │ ├── libyuv/ │ │ │ ├── basic_types.h │ │ │ ├── compare.h │ │ │ ├── compare_row.h │ │ │ ├── convert.h │ │ │ ├── convert_argb.h │ │ │ ├── convert_from.h │ │ │ ├── convert_from_argb.h │ │ │ ├── cpu_id.h │ │ │ ├── macros_msa.h │ │ │ ├── mjpeg_decoder.h │ │ │ ├── planar_functions.h │ │ │ ├── rotate.h │ │ │ ├── rotate_argb.h │ │ │ ├── rotate_row.h │ │ │ ├── row.h │ │ │ ├── scale.h │ │ │ ├── scale_argb.h │ │ │ ├── scale_row.h │ │ │ ├── version.h │ │ │ └── video_common.h │ │ └── libyuv.h │ ├── linux/ │ │ └── include/ │ │ ├── linux/ │ │ │ └── ion.h │ │ └── msm_ion.h │ ├── mapbox-gl-native-qt/ │ │ └── include/ │ │ ├── QMapbox │ │ ├── QMapboxGL │ │ ├── qmapbox.hpp │ │ └── qmapboxgl.hpp │ ├── nanovg/ │ │ ├── fontstash.h │ │ ├── nanovg.c │ │ ├── nanovg.h │ │ ├── nanovg_gl.h │ │ ├── nanovg_gl_utils.h │ │ ├── stb_image.h │ │ └── stb_truetype.h │ ├── opencl/ │ │ └── include/ │ │ └── CL/ │ │ ├── cl.h │ │ ├── cl_d3d10.h │ │ ├── cl_d3d11.h │ │ ├── cl_dx9_media_sharing.h │ │ ├── cl_egl.h │ │ ├── cl_ext.h │ │ ├── cl_ext_qcom.h │ │ ├── cl_gl.h │ │ ├── cl_gl_ext.h │ │ ├── cl_platform.h │ │ └── opencl.h │ ├── openmax/ │ │ └── include/ │ │ ├── OMX_Audio.h │ │ ├── OMX_Component.h │ │ ├── OMX_ContentPipe.h │ │ ├── OMX_Core.h │ │ ├── OMX_CoreExt.h │ │ ├── OMX_IVCommon.h │ │ ├── OMX_Image.h │ │ ├── OMX_Index.h │ │ ├── OMX_IndexExt.h │ │ ├── OMX_Other.h │ │ ├── OMX_QCOMExtns.h │ │ ├── OMX_Skype_VideoExtensions.h │ │ ├── OMX_Types.h │ │ ├── OMX_Video.h │ │ └── OMX_VideoExt.h │ ├── qpoases/ │ │ ├── EXAMPLES/ │ │ │ ├── example1.cpp │ │ │ └── example1b.cpp │ │ ├── INCLUDE/ │ │ │ ├── Bounds.hpp │ │ │ ├── Constants.hpp │ │ │ ├── Constraints.hpp │ │ │ ├── CyclingManager.hpp │ │ │ ├── EXTRAS/ │ │ │ │ └── SolutionAnalysis.hpp │ │ │ ├── Indexlist.hpp │ │ │ ├── MessageHandling.hpp │ │ │ ├── QProblem.hpp │ │ │ ├── QProblemB.hpp │ │ │ ├── SubjectTo.hpp │ │ │ ├── Types.hpp │ │ │ └── Utils.hpp │ │ ├── LICENSE.txt │ │ ├── README.txt │ │ ├── SConscript │ │ ├── SRC/ │ │ │ ├── Bounds.cpp │ │ │ ├── Bounds.ipp │ │ │ ├── Constraints.cpp │ │ │ ├── Constraints.ipp │ │ │ ├── CyclingManager.cpp │ │ │ ├── CyclingManager.ipp │ │ │ ├── EXTRAS/ │ │ │ │ └── SolutionAnalysis.cpp │ │ │ ├── Indexlist.cpp │ │ │ ├── Indexlist.ipp │ │ │ ├── MessageHandling.cpp │ │ │ ├── MessageHandling.ipp │ │ │ ├── QProblem.cpp │ │ │ ├── QProblem.ipp │ │ │ ├── QProblemB.cpp │ │ │ ├── QProblemB.ipp │ │ │ ├── SubjectTo.cpp │ │ │ ├── SubjectTo.ipp │ │ │ ├── Utils.cpp │ │ │ └── Utils.ipp │ │ └── VERSIONS.txt │ ├── qrcode/ │ │ ├── QrCode.cc │ │ └── QrCode.hpp │ ├── snpe/ │ │ └── include/ │ │ ├── DiagLog/ │ │ │ ├── IDiagLog.hpp │ │ │ └── Options.hpp │ │ ├── DlContainer/ │ │ │ └── IDlContainer.hpp │ │ ├── DlSystem/ │ │ │ ├── DlEnums.hpp │ │ │ ├── DlError.hpp │ │ │ ├── DlOptional.hpp │ │ │ ├── DlVersion.hpp │ │ │ ├── IBufferAttributes.hpp │ │ │ ├── ITensor.hpp │ │ │ ├── ITensorFactory.hpp │ │ │ ├── ITensorItr.hpp │ │ │ ├── ITensorItrImpl.hpp │ │ │ ├── IUDL.hpp │ │ │ ├── IUserBuffer.hpp │ │ │ ├── IUserBufferFactory.hpp │ │ │ ├── PlatformConfig.hpp │ │ │ ├── RuntimeList.hpp │ │ │ ├── String.hpp │ │ │ ├── StringList.hpp │ │ │ ├── TensorMap.hpp │ │ │ ├── TensorShape.hpp │ │ │ ├── TensorShapeMap.hpp │ │ │ ├── UDLContext.hpp │ │ │ ├── UDLFunc.hpp │ │ │ ├── UserBufferMap.hpp │ │ │ └── ZdlExportDefine.hpp │ │ ├── PlatformValidator/ │ │ │ └── PlatformValidator.hpp │ │ ├── SNPE/ │ │ │ ├── ApplicationBufferMap.hpp │ │ │ ├── PSNPE.hpp │ │ │ ├── RuntimeConfigList.hpp │ │ │ ├── SNPE.hpp │ │ │ ├── SNPEBuilder.hpp │ │ │ ├── SNPEFactory.hpp │ │ │ └── UserBufferList.hpp │ │ └── SnpeUdo/ │ │ ├── UdoBase.h │ │ ├── UdoImpl.h │ │ ├── UdoImplCpu.h │ │ ├── UdoImplDsp.h │ │ ├── UdoImplGpu.h │ │ ├── UdoReg.h │ │ └── UdoShared.h │ └── zlib/ │ └── build.txt ├── pyextra/ │ └── .gitignore ├── rednose/ │ ├── SConscript │ ├── helpers/ │ │ ├── __init__.py │ │ ├── chi2_lookup.py │ │ ├── chi2_lookup_table.npy │ │ ├── common_ekf.cc │ │ ├── common_ekf.h │ │ ├── ekf_sym.cc │ │ ├── ekf_sym.h │ │ ├── ekf_sym.py │ │ ├── ekf_sym_pyx.pyx │ │ ├── feature_handler.py │ │ ├── kalmanfilter.py │ │ ├── lst_sq_computer.py │ │ └── sympy_helpers.py │ └── templates/ │ ├── compute_pos.c │ ├── ekf_c.c │ └── feature_handler.c ├── release/ │ ├── build_devel.sh │ ├── build_release2.sh │ ├── build_release3.sh │ ├── check-submodules.sh │ ├── files_common │ ├── files_pc │ ├── files_tici │ └── identity.sh ├── scripts/ │ ├── complete_setup.sh │ ├── installers/ │ │ ├── font_installer.py │ │ ├── language_installer.py │ │ └── sshkey_installer.py │ ├── oneplus_update_neos.sh │ ├── rebuild.sh │ ├── reset_dp.sh │ ├── reset_update.sh │ ├── reset_usb.py │ ├── ssh_key/ │ │ ├── id_rsa │ │ └── setup_keys │ ├── stop_updater.sh │ ├── update_now.sh │ ├── update_panda_firmware.sh │ └── vw.sh ├── selfdrive/ │ ├── __init__.py │ ├── assets/ │ │ ├── .gitignore │ │ ├── assets.qrc │ │ ├── fonts/ │ │ │ ├── NotoSansCJKtc-Bold.otf │ │ │ ├── NotoSansCJKtc-Medium.otf │ │ │ ├── NotoSansCJKtc-Regular.otf │ │ │ └── fonts.xml │ │ ├── locales/ │ │ │ ├── events.pot │ │ │ ├── ja-JP/ │ │ │ │ └── LC_MESSAGES/ │ │ │ │ ├── events.mo │ │ │ │ └── events.po │ │ │ ├── ko-KR/ │ │ │ │ └── LC_MESSAGES/ │ │ │ │ ├── events.mo │ │ │ │ └── events.po │ │ │ ├── zh-CN/ │ │ │ │ └── LC_MESSAGES/ │ │ │ │ ├── events.mo │ │ │ │ └── events.po │ │ │ └── zh-TW/ │ │ │ └── LC_MESSAGES/ │ │ │ ├── events.mo │ │ │ └── events.po │ │ └── offroad/ │ │ ├── fcc.html │ │ └── tc.html │ ├── athena/ │ │ ├── __init__.py │ │ ├── athenad.py │ │ ├── manage_athenad.py │ │ └── registration.py │ ├── camerad/ │ │ ├── SConscript │ │ ├── cameras/ │ │ │ ├── camera_common.cc │ │ │ ├── camera_common.h │ │ │ ├── camera_frame_stream.cc │ │ │ ├── camera_frame_stream.h │ │ │ ├── camera_mipi.cc │ │ │ ├── camera_mipi.h │ │ │ ├── camera_qcom.cc │ │ │ ├── camera_qcom.h │ │ │ ├── camera_qcom2.cc │ │ │ ├── camera_qcom2.h │ │ │ ├── debayer.cl │ │ │ ├── real_debayer.cl │ │ │ ├── sensor2_i2c.h │ │ │ └── sensor_i2c.h │ │ ├── imgproc/ │ │ │ ├── conv.cl │ │ │ ├── pool.cl │ │ │ ├── utils.cc │ │ │ └── utils.h │ │ ├── include/ │ │ │ ├── media/ │ │ │ │ ├── cam_cpas.h │ │ │ │ ├── cam_defs.h │ │ │ │ ├── cam_fd.h │ │ │ │ ├── cam_icp.h │ │ │ │ ├── cam_isp.h │ │ │ │ ├── cam_isp_ife.h │ │ │ │ ├── cam_isp_vfe.h │ │ │ │ ├── cam_jpeg.h │ │ │ │ ├── cam_lrme.h │ │ │ │ ├── cam_req_mgr.h │ │ │ │ ├── cam_sensor.h │ │ │ │ ├── cam_sensor_cmn_header.h │ │ │ │ └── cam_sync.h │ │ │ ├── msm_cam_sensor.h │ │ │ ├── msm_camsensor_sdk.h │ │ │ ├── msmb_camera.h │ │ │ ├── msmb_isp.h │ │ │ └── msmb_ispif.h │ │ ├── main.cc │ │ ├── snapshot/ │ │ │ ├── __init__.py │ │ │ └── snapshot.py │ │ └── transforms/ │ │ ├── rgb_to_yuv.cc │ │ ├── rgb_to_yuv.cl │ │ ├── rgb_to_yuv.h │ │ └── rgb_to_yuv_test.cc │ ├── car/ │ │ ├── __init__.py │ │ ├── car_helpers.py │ │ ├── chrysler/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── chryslercan.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── fingerprints.py │ │ ├── ford/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── fordcan.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── fw_versions.py │ │ ├── gm/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── gmcan.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── honda/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── hondacan.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── hyundai/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── hyundaican.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── interfaces.py │ │ ├── isotp_parallel_query.py │ │ ├── mazda/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── interface.py │ │ │ ├── mazdacan.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── mock/ │ │ │ ├── __init__.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── nissan/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── interface.py │ │ │ ├── nissancan.py │ │ │ ├── radar_interface.py │ │ │ └── values.py │ │ ├── subaru/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ ├── subarucan.py │ │ │ └── values.py │ │ ├── tesla/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ ├── teslacan.py │ │ │ └── values.py │ │ ├── tests/ │ │ │ ├── __init__.py │ │ │ └── test_car_interfaces.py │ │ ├── toyota/ │ │ │ ├── __init__.py │ │ │ ├── carcontroller.py │ │ │ ├── carstate.py │ │ │ ├── interface.py │ │ │ ├── radar_interface.py │ │ │ ├── toyotacan.py │ │ │ └── values.py │ │ ├── vin.py │ │ └── volkswagen/ │ │ ├── __init__.py │ │ ├── carcontroller.py │ │ ├── carstate.py │ │ ├── interface.py │ │ ├── radar_interface.py │ │ ├── values.py │ │ └── volkswagencan.py │ ├── common/ │ │ ├── SConscript │ │ ├── clutil.cc │ │ ├── clutil.h │ │ ├── framebuffer.cc │ │ ├── framebuffer.h │ │ ├── glutil.cc │ │ ├── glutil.h │ │ ├── gpio.cc │ │ ├── gpio.h │ │ ├── i2c.cc │ │ ├── i2c.h │ │ ├── mat.h │ │ ├── modeldata.h │ │ ├── params.cc │ │ ├── params.h │ │ ├── queue.h │ │ ├── swaglog.cc │ │ ├── swaglog.h │ │ ├── timing.h │ │ ├── touch.c │ │ ├── touch.h │ │ ├── util.cc │ │ ├── util.h │ │ ├── version.h │ │ ├── visionimg.cc │ │ ├── visionimg.h │ │ ├── watchdog.cc │ │ └── watchdog.h │ ├── config.py │ ├── controls/ │ │ ├── __init__.py │ │ ├── controlsd.py │ │ ├── lib/ │ │ │ ├── __init__.py │ │ │ ├── alertmanager.py │ │ │ ├── alerts_offroad.json │ │ │ ├── cluster/ │ │ │ │ ├── LICENSE │ │ │ │ ├── README │ │ │ │ ├── SConscript │ │ │ │ ├── __init__.py │ │ │ │ ├── fastcluster.cpp │ │ │ │ ├── fastcluster.h │ │ │ │ ├── fastcluster_R_dm.cpp │ │ │ │ ├── fastcluster_dm.cpp │ │ │ │ ├── fastcluster_py.py │ │ │ │ └── test.cpp │ │ │ ├── drive_helpers.py │ │ │ ├── events.py │ │ │ ├── fcw.py │ │ │ ├── lane_planner.py │ │ │ ├── latcontrol_angle.py │ │ │ ├── latcontrol_indi.py │ │ │ ├── latcontrol_lqr.py │ │ │ ├── latcontrol_pid.py │ │ │ ├── lateral_mpc/ │ │ │ │ ├── .gitignore │ │ │ │ ├── SConscript │ │ │ │ ├── __init__.py │ │ │ │ ├── generator.cpp │ │ │ │ ├── lateral_mpc.c │ │ │ │ ├── lib_mpc_export/ │ │ │ │ │ ├── acado_auxiliary_functions.c │ │ │ │ │ ├── acado_auxiliary_functions.h │ │ │ │ │ ├── acado_common.h │ │ │ │ │ ├── acado_integrator.c │ │ │ │ │ ├── acado_qpoases_interface.cpp │ │ │ │ │ ├── acado_qpoases_interface.hpp │ │ │ │ │ └── acado_solver.c │ │ │ │ └── libmpc_py.py │ │ │ ├── lateral_planner.py │ │ │ ├── lead_mpc.py │ │ │ ├── lead_mpc_lib/ │ │ │ │ ├── .gitignore │ │ │ │ ├── SConscript │ │ │ │ ├── __init__.py │ │ │ │ ├── generator.cpp │ │ │ │ ├── lib_mpc_export/ │ │ │ │ │ ├── acado_auxiliary_functions.c │ │ │ │ │ ├── acado_auxiliary_functions.h │ │ │ │ │ ├── acado_common.h │ │ │ │ │ ├── acado_integrator.c │ │ │ │ │ ├── acado_qpoases_interface.cpp │ │ │ │ │ ├── acado_qpoases_interface.hpp │ │ │ │ │ └── acado_solver.c │ │ │ │ ├── libmpc_py.py │ │ │ │ └── longitudinal_mpc.c │ │ │ ├── limits_long_mpc.py │ │ │ ├── long_mpc.py │ │ │ ├── longcontrol.py │ │ │ ├── longitudinal_mpc_lib/ │ │ │ │ ├── .gitignore │ │ │ │ ├── SConscript │ │ │ │ ├── __init__.py │ │ │ │ ├── generator.cpp │ │ │ │ ├── lib_mpc_export/ │ │ │ │ │ ├── acado_auxiliary_functions.c │ │ │ │ │ ├── acado_auxiliary_functions.h │ │ │ │ │ ├── acado_common.h │ │ │ │ │ ├── acado_integrator.c │ │ │ │ │ ├── acado_qpoases_interface.cpp │ │ │ │ │ ├── acado_qpoases_interface.hpp │ │ │ │ │ └── acado_solver.c │ │ │ │ ├── libmpc_py.py │ │ │ │ └── longitudinal_mpc.c │ │ │ ├── longitudinal_planner.py │ │ │ ├── pid.py │ │ │ ├── radar_helpers.py │ │ │ ├── speed_limit_controller.py │ │ │ ├── turn_speed_controller.py │ │ │ ├── vehicle_model.py │ │ │ └── vision_turn_controller.py │ │ ├── plannerd.py │ │ └── radard.py │ ├── crash.py │ ├── debug/ │ │ ├── __init__.py │ │ ├── can_print_changes.py │ │ ├── can_printer.py │ │ ├── check_freq.py │ │ ├── check_lag.py │ │ ├── check_timings.py │ │ ├── compare_fingerprints.py │ │ ├── count_events.py │ │ ├── cpu_usage_stat.py │ │ ├── cycle_alerts.py │ │ ├── disable_ecu.py │ │ ├── dump.py │ │ ├── filter_log_message.py │ │ ├── fingerprint_from_route.py │ │ ├── get_fingerprint.py │ │ ├── live_cpu_and_temp.py │ │ ├── run_process_on_route.py │ │ ├── set_car_params.py │ │ ├── show_matching_cars.py │ │ ├── test_fw_query_on_routes.py │ │ ├── toyota_eps_factor.py │ │ └── uiview.py │ ├── dragonpilot/ │ │ ├── HOWTO-APPD.md │ │ ├── LICENSE.md │ │ ├── appd.py │ │ ├── appd_example.json │ │ ├── dashcamd.py │ │ ├── fonts.xml │ │ ├── gpx_uploader.py │ │ ├── gpxd.py │ │ ├── otisserv.py │ │ ├── systemd.py │ │ └── tpl/ │ │ ├── addr_input.tpl │ │ ├── app_token_input.tpl │ │ ├── body.tpl │ │ ├── gmap_index.html.tpl │ │ ├── gmap_index.js.tpl │ │ ├── gmap_key_input.tpl │ │ ├── gmap_style.css.tpl │ │ ├── nav_confirmation.tpl │ │ └── public_token_input.tpl │ ├── hardware/ │ │ ├── __init__.py │ │ ├── base.h │ │ ├── base.py │ │ ├── eon/ │ │ │ ├── __init__.py │ │ │ ├── androidd.py │ │ │ ├── hardware.h │ │ │ └── hardware.py │ │ ├── hw.h │ │ ├── jetson/ │ │ │ ├── __init__.py │ │ │ ├── hardware.h │ │ │ └── hardware.py │ │ ├── pc/ │ │ │ ├── __init__.py │ │ │ └── hardware.py │ │ └── tici/ │ │ ├── __init__.py │ │ ├── agnos.json │ │ ├── agnos.py │ │ ├── amplifier.py │ │ ├── hardware.h │ │ ├── hardware.py │ │ ├── iwlist.py │ │ ├── pins.py │ │ └── updater │ ├── logcatd/ │ │ ├── SConscript │ │ ├── logcatd_android.cc │ │ └── logcatd_systemd.cc │ ├── loggerd/ │ │ ├── SConscript │ │ ├── __init__.py │ │ ├── bootlog.cc │ │ ├── config.py │ │ ├── deleter.py │ │ ├── encoder.h │ │ ├── include/ │ │ │ └── msm_media_info.h │ │ ├── logger.cc │ │ ├── logger.h │ │ ├── loggerd.cc │ │ ├── omx_encoder.cc │ │ ├── omx_encoder.h │ │ ├── raw_logger.cc │ │ ├── raw_logger.h │ │ ├── uploader.py │ │ └── xattr_cache.py │ ├── logmessaged.py │ ├── manager/ │ │ ├── __init__.py │ │ ├── build.py │ │ ├── custom_dep.py │ │ ├── helpers.py │ │ ├── manager.py │ │ ├── process.py │ │ ├── process_config.py │ │ └── test/ │ │ ├── __init__.py │ │ └── test_manager.py │ ├── manager.py │ ├── mapd/ │ │ ├── README.md │ │ ├── config.py │ │ ├── lib/ │ │ │ ├── NodesData.py │ │ │ ├── Route.py │ │ │ ├── WayCollection.py │ │ │ ├── WayRelation.py │ │ │ ├── WayRelationIndex.py │ │ │ ├── default_speeds.json │ │ │ ├── geo.py │ │ │ └── osm.py │ │ ├── mapd.py │ │ └── test/ │ │ ├── __init__.py │ │ ├── mock_data.py │ │ ├── mock_osm_response_01.xml │ │ ├── mock_osm_response_02.xml │ │ ├── test_NodesData.py │ │ ├── test_WayRelation.py │ │ └── test_geo.py │ ├── modeld/ │ │ ├── SConscript │ │ ├── constants.py │ │ ├── dmonitoringmodeld │ │ ├── dmonitoringmodeld.cc │ │ ├── modeld │ │ ├── modeld.cc │ │ ├── models/ │ │ │ ├── commonmodel.cc │ │ │ ├── commonmodel.h │ │ │ ├── dmonitoring.cc │ │ │ ├── dmonitoring.h │ │ │ ├── driving.cc │ │ │ └── driving.h │ │ ├── runners/ │ │ │ ├── onnx_runner.py │ │ │ ├── onnxmodel.cc │ │ │ ├── onnxmodel.h │ │ │ ├── run.h │ │ │ ├── runmodel.h │ │ │ ├── snpemodel.cc │ │ │ ├── snpemodel.h │ │ │ ├── thneedmodel.cc │ │ │ └── thneedmodel.h │ │ ├── thneed/ │ │ │ ├── compile.cc │ │ │ ├── include/ │ │ │ │ └── msm_kgsl.h │ │ │ ├── serialize.cc │ │ │ ├── thneed.cc │ │ │ └── thneed.h │ │ └── transforms/ │ │ ├── loadyuv.cc │ │ ├── loadyuv.cl │ │ ├── loadyuv.h │ │ ├── transform.cc │ │ ├── transform.cl │ │ └── transform.h │ ├── monitoring/ │ │ ├── dmonitoringd.py │ │ └── driver_monitor.py │ ├── pandad.py │ ├── proclogd/ │ │ ├── SConscript │ │ ├── main.cc │ │ ├── proclog.cc │ │ └── proclog.h │ ├── rtshield.py │ ├── sensord/ │ │ ├── SConscript │ │ ├── libdiag.h │ │ ├── sensord │ │ ├── sensors/ │ │ │ ├── bmx055_accel.cc │ │ │ ├── bmx055_accel.h │ │ │ ├── bmx055_gyro.cc │ │ │ ├── bmx055_gyro.h │ │ │ ├── bmx055_magn.cc │ │ │ ├── bmx055_magn.h │ │ │ ├── bmx055_temp.cc │ │ │ ├── bmx055_temp.h │ │ │ ├── constants.h │ │ │ ├── file_sensor.cc │ │ │ ├── file_sensor.h │ │ │ ├── i2c_sensor.cc │ │ │ ├── i2c_sensor.h │ │ │ ├── light_sensor.cc │ │ │ ├── light_sensor.h │ │ │ ├── lsm6ds3_accel.cc │ │ │ ├── lsm6ds3_accel.h │ │ │ ├── lsm6ds3_gyro.cc │ │ │ ├── lsm6ds3_gyro.h │ │ │ ├── lsm6ds3_temp.cc │ │ │ ├── lsm6ds3_temp.h │ │ │ ├── mmc5603nj_magn.cc │ │ │ ├── mmc5603nj_magn.h │ │ │ └── sensor.h │ │ ├── sensors_qcom.cc │ │ └── sensors_qcom2.cc │ ├── swaglog.py │ ├── test/ │ │ ├── __init__.py │ │ ├── helpers.py │ │ ├── setup_device_ci.sh │ │ ├── test_fingerprints.py │ │ └── test_onroad.py │ ├── thermald/ │ │ ├── power_monitoring.py │ │ └── thermald.py │ ├── timezoned.py │ ├── tombstoned.py │ ├── ui/ │ │ ├── .gitignore │ │ ├── SConscript │ │ ├── _ui │ │ ├── _ui_dp │ │ ├── main.cc │ │ ├── paint.cc │ │ ├── paint.h │ │ ├── qt/ │ │ │ ├── api.cc │ │ │ ├── api.h │ │ │ ├── home.cc │ │ │ ├── home.h │ │ │ ├── maps/ │ │ │ │ ├── map.cc │ │ │ │ ├── map.h │ │ │ │ ├── map_helpers.cc │ │ │ │ ├── map_helpers.h │ │ │ │ ├── map_settings.cc │ │ │ │ └── map_settings.h │ │ │ ├── offroad/ │ │ │ │ ├── driverview.cc │ │ │ │ ├── driverview.h │ │ │ │ ├── networking.cc │ │ │ │ ├── networking.h │ │ │ │ ├── networkmanager.h │ │ │ │ ├── onboarding.cc │ │ │ │ ├── onboarding.h │ │ │ │ ├── settings.cc │ │ │ │ ├── settings.h │ │ │ │ ├── text_view.qml │ │ │ │ ├── wifiManager.cc │ │ │ │ └── wifiManager.h │ │ │ ├── onroad.cc │ │ │ ├── onroad.h │ │ │ ├── qt_window.h │ │ │ ├── request_repeater.cc │ │ │ ├── request_repeater.h │ │ │ ├── sidebar.cc │ │ │ ├── sidebar.h │ │ │ ├── spinner │ │ │ ├── spinner.cc │ │ │ ├── spinner.h │ │ │ ├── spinner_aarch64 │ │ │ ├── spinner_larch64 │ │ │ ├── text │ │ │ ├── text.cc │ │ │ ├── text_aarch64 │ │ │ ├── text_larch64 │ │ │ ├── util.cc │ │ │ ├── util.h │ │ │ ├── widgets/ │ │ │ │ ├── cameraview.cc │ │ │ │ ├── cameraview.h │ │ │ │ ├── controls.cc │ │ │ │ ├── controls.h │ │ │ │ ├── drive_stats.cc │ │ │ │ ├── drive_stats.h │ │ │ │ ├── input.cc │ │ │ │ ├── input.h │ │ │ │ ├── keyboard.cc │ │ │ │ ├── keyboard.h │ │ │ │ ├── offroad_alerts.cc │ │ │ │ ├── offroad_alerts.h │ │ │ │ ├── prime.cc │ │ │ │ ├── prime.h │ │ │ │ ├── scrollview.cc │ │ │ │ ├── scrollview.h │ │ │ │ ├── ssh_keys.cc │ │ │ │ ├── ssh_keys.h │ │ │ │ ├── toggle.cc │ │ │ │ └── toggle.h │ │ │ ├── window.cc │ │ │ └── window.h │ │ ├── soundd │ │ ├── soundd.cc │ │ ├── spinner │ │ ├── text │ │ ├── translations/ │ │ │ ├── en-US.qm │ │ │ ├── en-US.ts │ │ │ ├── zh-CN.qm │ │ │ ├── zh-CN.ts │ │ │ ├── zh-TW.qm │ │ │ └── zh-TW.ts │ │ ├── ui │ │ ├── ui.cc │ │ ├── ui.h │ │ ├── ui.pro │ │ └── update_translations.sh │ ├── updated.py │ └── version.py ├── site_scons/ │ └── site_tools/ │ └── cython.py └── tools/ └── openpilot_env.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ venv/ .clang-format .DS_Store .tags .ipynb_checkpoints .idea .overlay_init .overlay_consistent .sconsign.dblite .vscode* model2.png a.out .hypothesis *.dylib *.DSYM *.d *.pyc *.pyo .*.swp .*.swo .*.un~ *.tmp *.o *.o-* *.os *.os-* *.so *.a *.clb *.class *.pyxbldc *.vcd config.json clcache compile_commands.json persist board/obj/ selfdrive/boardd/boardd selfdrive/logcatd/logcatd selfdrive/mapd/default_speeds_by_region.json selfdrive/proclogd/proclogd selfdrive/test/longitudinal_maneuvers/out selfdrive/visiond/visiond selfdrive/loggerd/loggerd selfdrive/loggerd/bootlog selfdrive/sensord/_gpsd selfdrive/sensord/_sensord selfdrive/camerad/camerad selfdrive/camerad/test/ae_gray_test selfdrive/modeld/_modeld selfdrive/modeld/_dmonitoringmodeld /src/ one openpilot notebooks xx hyperthneed panda_jungle provisioning .coverage* coverage.xml htmlcov pandaextra .mypy_cache/ flycheck_* cppcheck_report.txt comma*.sh selfdrive/modeld/thneed/compile models/*.thneed *.bz2 !phonelibs/mapbox-gl-native-qt/aarch64/*.so !phonelibs/mapbox-gl-native-qt/jarch64/*.so ================================================ FILE: CHANGELOGS-DEV.md ================================================ dragonpilot 0.8.9-3 ======================== * Bug fixes. * Fixed up auto updater. * Fixed Honda Jade dbc. (Thanks to @lijunhao731) * ADDED: 0.8.10 model. * ADDED: Nav for all device. * ADDED: Support for Nvidia Xavier. dragonpilot 0.8.9-2 ======================== * Bug fixes. * Refactor UI related changes. * Updated Simplified Chinese translation. (Thanks to @CCZ) * WARNING: Due to recent OP change, Device w/ battery recommended setting autoshutdown to 1 min to prevent libusb error. * Re-tuned acceleraton profile. (Thank to @wer5lcy) * ADDED: Car port for Toyota Prius Alpha. (Thanks to @CT921) dragonpilot 0.8.9-1 ======================== * Based on openpilot 0.8.8 devel. * Re-introduce Follow Distance 4th profile (2.2s / 1.8s / 1.5s / 1.2s). * ADDED: New softer sound for c3. * ADDED: Dynamic Lane Profile. (Thanks to @sunnyhaibin) * Bug Fixes. dragonpilot 0.8.8-2 ======================== * ADDED: newer faster and modularized mapd and slow down for curve. (Thanks to @move-fast) * ADDED: Street name on the bottom bar. * ADDED: Now supports 1+3t / C2 / C3 / Jetson Xavier NX. * ADDED: Smoother tune for PRIUS_TSS2. * Bug fixes. dragonpilot 0.8.8-1 ======================== ** BETA TESTING ONLY ** * Based on openpilot 0.8.8 devel. * FIXED: dashcam issue. * FIXED: some VW vehicles issue. (Thanks to @yayism) * FIXED: white panda + j533 acc issue. (Thanks to @lirudy) * ADDED: Auto fake black panda. * ADDED: 2018 chinese camry hybrid fingerprint (Thanks to @stingshen) * WIP: mapd. dragonpilot 0.8.7-4 ======================== * 2017 JADE w/ Added Comma Pedal Support. (Thanks to @lijunhao731) * Fixed toyota / honda brake light display. (Thanks to @loveloveses) * Fixed UI toggle. (Thanks to @鄧育林、@謝聖鴻) * Fixed VW resume/display issue. (Thanks to @SKY) * Fixed CJK font installation issue. dragonpilot 0.8.7-3 ======================== * Bug fixes. * Fixed gpxd. * Added some Chinese support. dragonpilot 0.8.7-2 ======================== * Fixed sound issue. * Changed gpx logs to OSM compatible format. * HONDA: Added BSM support for CRV-Hybrid. * HONDA: Added toggle to force displaying km/h in HUD. * TOYOTA: Add new Toggles under DP - Cars to enable/disable Following Modes / Accel Modes with physical button feature. dragonpilot 0.8.7-1 ======================== * Based on openpilot 0.8.7 devel. * Support 1+3t / C2 / Jetson Xavier NX. * Support White / Grey Panda. * TOYOTA: Can now change Following Modes with physical button from the steering wheel. * TOYOTA: Can now change Acceleration Modes with physical button if your car supports it. * TOYOTA: Added Low speed override toggles. * Dev UI now displays RPM reading. * Added Prebuilt toggle for faster boot. * Lexus RX high RPM fix. (Thanks to @crazysim). * Added toggle to launch Language settings. * Added toggle to launch Volume settings. * Added toggle to launch date/time settings. * Added toggle to flash panda. * Added toggle to recover panda firmware. * Added toggle to delete logging (/sdcard/realdata). * Added GPS Logger. dragonpilot 0.8.6-1 ======================== * Based on openpilot 0.8.6 devel. * Support 1+3t / C2 / Jetson Xavier NX. * Support White / Grey Panda. dragonpilot 0.8.5-4 ======================== * Added multiple toggles. * Code clean up. * Android app support. (see selfdrive/dragonpilot/HOWTO-APPD.md) * Better support for VW MPQ (Thanks to @Saber) dragonpilot 0.8.5-3 ======================== * Added Jetson support toggle. * Added Steering Ratio controller. * Reduce Following Profile to 3 modes only. (1.8s / 1.5s / 1.2s) * Bug fixes. dragonpilot 0.8.5-2 ======================== * Added black panda simulation toggle. * Added No GPS toggle. * Added No Battery Toggle. * Bug fixes. dragonpilot 0.8.5-1 ======================== * Based on openpilot 0.8.5 devel. * 基於 openpilot 0.8.5 devel. * Support 1+3t / C2 / Jetson Xavier NX. * 支持 1+3t / C2 / Jetson Xavier NX. * No White/Grey Panda Support. * 不支持白灰熊. dragonpilot 0.8.4-3 ======================== * 簡化 1+3t 安裝方法. (請查閱 HOWTO-ONEPLUS.md) * Simplied 1+3t installation. (See HOWTO-ONEPLUS.md) * 加回舊 ssh 登錄. * Good old ssh key. * 修復本田錯誤. (感謝 @loveloveses) * Fixed Honda bug. (Thanks to @loveloveses) dragonpilot 0.8.4-2 ======================== * 加回可調整加速/跟車設定. * Added back Accel/Following Profile. * 支持 Headless Jetson Xavier NX (https://github.com/efinilan/xnxpilot.git) * Support Headless Jetson Xavier NX (https://github.com/efinilan/xnxpilot.git) * 支持 1+3t (需額外安裝手續) * Support 1+3t (Require additional install procedure) * 支持白/灰熊 * Support White/Grey Panda. dragonpilot 0.8.4-1 ======================== * 基於 openpilot 0.8.4 devel. * Based on openpilot 0.8.4 devel. dragonpilot 0.8.1 ======================== * 基於最新 openpilot 0.8.1 devel. * Based on latest openpilot 0.8.1 devel. * 加入行車記錄按鈕。(感謝 @toyboxZ 提供) * Added REC screen button. (Thanks to @toyboxZ) dragonpilot 0.8.0 ======================== * 基於最新 openpilot 0.8.0 devel. * Based on latest openpilot 0.8.0 devel. * 加入 git 錯誤修正。(感謝 @toyboxZ 提供) * Added git error fix. (Thanks to @toyboxZ) dragonpilot 0.7.10.1 ======================== * HYUNDAI_GENESIS 使用 INDI 控制器。(感謝 @donfyffe 提供) * HYUNDAI_GENESIS uses INDI controller. (Thanks to @donfyffe) * HYUNDAI_GENESIS 加入 Cruise 按紐 和 lkMode 支援。(感謝 @donfyffe 建議) * HYUNDAI_GENESIS added Cruise button event and lkMode feature. (Thanks to @donfyffe) * 支援台灣版 2018 Huyndai IONIQ + smart MDPS (dp_hkg_smart_mdps) (感謝 @andy741217 提供) * Support 2018 Taiwan Hyundai IONIQ + smart MDPS (dp_hkg_smart_mdps) (Thanks to @andy741217) * 使用 openpilot v0.8 的模型。(感謝 @eisenheim) * Use openpilot v0.8 model. (Thanks to @eisenheim) * 加入 0.8 測試版的部分優化。 * Added optimizations from pre-0.8. * 加入 dp_honda_eps_mod 設定來使用更高的扭力 (需 eps mod)。(感謝 @Wuxl_369 提供) * Added dp_honda_eps_mod setting to enable higher torque (eps mod required). (Thanks to @Wuxl_369) * 修正 VW 對白/灰熊的支援 (感謝 @lirudy 提供) * Fixed issue with white/grey panda support for VW (Thanks to @lirudy) * GENESIS_G70 優化 (感謝 @sebastian4k 提供) * GENESIS_G70 Optimisation (Thanks to @sebastian4k) * HYUNDAI_GENESIS 優化 (感謝 @donfyffe 提供) * HYUNDAI_GENESIS Optimisation (Thanks to @donfyffe) * 加入 Dynamic gas Lite。(感謝 @toyboxZ 提供) * Added Dynamic Gas Lite. (Thanks to @toyboxZ) * 加入來自 afa 的 Honda inspire, accord, crv SnG 優化。(感謝 @menwenliang 提供) * Added Honda inspire, accord, crv SnG optimisation from afa fork. (Thanks to @menwenliang) * 加入 dp_toyota_lowest_cruise_override_vego。(感謝 @toyboxZ 提供) * Added dp_toyota_lowest_cruise_override_vego. (Thanks to @toyboxZ) dragonpilot 0.7.10.0 ======================== * 基於最新 openpilot 0.7.10 devel. * Based on latest openpilot 0.7.10 devel. * 修正 Prius 特定情況下無法操控方向盤的問題。 * Fixed unable to regain Prius steering control under certain condition. * 更新 VW MQB 的支援。(需執行 scripts/vw.sh 腳本) * Updated support of VW MQB. (scripts/vw.sh script required) * 新增 2018 China Toyota CHR 指紋v2。(感謝 @xiaohongcheung 提供) * Added 2018 China Toyota CHR FPv2. (Thanks to @xiaohongcheung) * 加入 Headunit Reloaded Android Auto App 支援。(感謝 @Ninjaa 提供) * Added Headunit Reloaded Android Auto App Support. (Thanks to @Ninjaa) * 優化 nanovg。(感謝 @piggy 提供) * Optomized nanovg. (Thanks to @piggy) * 加入 complete_setup.sh (感謝 @深鲸希西 提供) * Added complete_setup.sh (Thanks to @深鲸希西) * Based on latest openpilot 0.7.10 devel. * 修正 EON 接 PC/USB 充電器時仍會自動關機的錯誤。(感謝 @小愛 回報) * Fixed auto shutdown issue when EON connect to PC/USB Charger. (Thanks to @LOVEChen) * HYUNDAI_GENESIS 使用 INDI 控制器。(感謝 @donfyffe 提供) * HYUNDAI_GENESIS uses INDI controller. (Thanks to @donfyffe) dragonpilot 0.7.8.3 ======================== * VW 加入 6 分鐘時間方向盤控制限制輔助方案。(特別感謝 @actuallylemoncurd 提供代碼) * VW added 6 minutes timebomb assist. (dp_timebomb_assist, special thanks to @actuallylemoncurd) dragonpilot 0.7.8.2 ======================== * 修正在沒網路的情況下,開機超過五分鐘的問題。 * Fixed 5+ minutes boot time issue when there is no internet connection. * 錯誤回傳改使用 dp 的主機。 * Used dp server for error reporting. * 更新服務改使用 gitee 的 IP 檢查連線狀態。 * updated service uses gitee IP address instead. dragonpilot 0.7.8.1 ======================== * 加入 ko-KR 翻譯。 * Added ko-KR translation. * 加入 Honda Jade 支援。(感謝 @李俊灝) * Added Honda Jade support. (Thanks to @lijunhao731) * 修正 ui.cc 內存越界的問題。(感謝 @piggy 提供) * Fixed ui.cc memory out of bound issue. (Thanks to @piggy) * gpxd 記錄改自動存成 zip 格式。 * gpxd now store in zip format. * 強制關閉 panda 檢查 DOS 硬體。 * Force disabled DOS hardware check in panda. dragonpilot 0.7.8.0 ======================== * 基於最新 openpilot 0.7.8 devel. * Based on latest openpilot 0.7.8 devel. * 加入重置 DP 設定按鈕。(感謝 @LOVEChen 建議) * Added "Reset DP Settings" button. (Thanks to @LOVEChen) * 將警示訊息更改為類似於概念 UI 的設計。 * Alert messages changed to concept UI alike design. * 當 manager 出現錯誤後,按 Exit 按鈕會執行 reset_update 腳本。 * Added ability to execute reset_update.sh when press "Exit" button once manager returned errors. dragonpilot 0.7.7.3 ======================== * 修正方向盤監控。 * Fixed steering monitor timer param. * 修正行駛時關閉畫面導致當機的錯誤。(感謝 @salmankhan, @stevej99, @bobbydough 回報) * Fixed screen frozen issue when "screen off while driving" toggle is enabled. (Thanks to @salmankhan, @stevej99, @bobbydough) * 加回 Dev Mini UI 開關。(感謝 @Ninjaa 建議) * Re-added Dev Mini UI. (Thanks to @Ninjaa) * 新增 (dp_reset_live_parameters_on_start) 每次發車重設 LiveParameters 值。(感謝 @eisenheim) * Added ability (dp_reset_live_param_on_start) to reset LiveParameters on each start. (Thanks @eisenheim) * 修正同時開啟 dp_toyota_zss 和 dp_lqr 產生的錯誤。(感謝 @bobbydough) * Fixed error cuased by enabling both dp_toyota_zss and dp_lqr at the same time. (Thanks to @bobbydough) * 新增 (dp_gpxd) 將 GPS 軌跡導出至 GPX 格式 (/sdcard/gpx_logs/)的功能。 (感謝 @mageymoo1) * Added ability (dp_gpxd) to export GPS track into GPX files (/sdcard/gpx_logs/). (Thanks to @mageymoo1) * 使用德國的車道寬度估算值。 (感謝 @arne182) * Used lane width estimate value from Germany. (Thanks to @arne182) dragonpilot 0.7.7.2 ======================== * 加入 d_poly offset。 (感謝 @ShaneSmiskol) * Added d_poly offset. (Thanks to @ShaneSmiskol) * 加入 ZSS 支援。(感謝 @bobbydough, @WilliamPrius 建議, @bobbydough 測試) * Added ZSS support. (Thanks to @bobbydough, @WilliamPrius for recommendation, @bobbydough for testing) * 加入錯誤記錄至 /sdcard/crash_logs/ (感謝 @ShaneSmiskol 提供代碼) * Added error logs to /sdcard/crash_logs/ (Special Thanks to @ShaneSmiskol) * 加入 LQR 控制器開關進設定畫面。 * Added LQR Controller toggle to settings. dragonpilot 0.7.7.1 ======================== * 加入 C2 風扇靜音模式。(感謝 @dingliangxue) * Added C2 quiet fan mode. (Thanks to @dingliangxue) * 加入「輔助換道最低啟動速度」、「自動換道最低啟動速度」設定。 * Added "Assisted Lane Change Min Engage Speed" and "Auto Lane Change Min Engage Speed" settings. * 加入回調校介面。(感謝 @Kent) * Re-added Dev UI. (Thanks to @Kent) * 加入 "dp_lqr" 設定來強制使用 RAV4 的 lqr 調校。(感謝 @eisenheim) * Added "dp_lqr" setting to force enable lqr tuning from RAV4. (Thanks to eisenheim) dragonpilot 0.7.7.0 ======================== * 基於最新 openpilot 0.7.7 devel. * Based on latest openpilot 0.7.7 devel. * 當 Manager 出現錯誤時,顯示 IP 位置。(感謝 @dingliangxue) * When Manager failed, display IP address. (Thanks to @dingliangxue) * 加回 sr learner 開關。 * Re-added sr learner toggle. * 加回 加速模式 開關。 * Re-added Accel Profile toggle. * Toyota 加入改寫最低巡航速度功能。(感謝 @Mojo) * Added Toyota to override lowerest cruise speed. (Thanks to @Mojo) * 介面加入盲點偵測顯示。(感謝 @wabes) * Added BSM indicator to UI. (Thanks to @wabes) * 加回彎道減速功能。(感謝 @Mojo) * re-added Slow On Curve functionality. (Thanks to @Mojo) dragonpilot 0.7.6.2 ======================== * 修正無法正確關閉駕駛監控的問題。 * Fixed unable to properly turn off driver monitor issue. dragonpilot 0.7.6.1 ======================== * 基於最新 openpilot 0.7.6.1 devel. * Based on latest openpilot 0.7.6.1 devel. * 優化並整合 dp 服務。 (所有的設定檔已改名,請重新設定所有的功能) * Optimized and integrated several dp services. (Settings have been renamed, please re-config all settings) * 完全關閉 steer ratio learner。 * Completely disabled steer ratio learner. * 移除「加速模式」。 * Removed Accel Profile. * 加入本田皓影混電版指紋v1。(感謝 @劉駿) * Added Honda Breeze Hybrid FPv1. (Thanks to @劉駿) * 加入台灣版 Toyota Prius 4.5 指紋v1。(感謝 @jeekid) * Added Taiwan Toyota Prius 4.5 FPv1. (Thanks to @jeekid) dragonpilot 0.7.5.4 ======================== * Dynamic Follow 更新模型。(感謝 @ShaneSmiskol 提供代碼、 @cgw1968 測試) * Updated Dynamic Follow model. (Special Thanks to @ShaneSmiskol for the feature and @cgw1968 for testing) dragonpilot 0.7.5.3 ======================== * Dynamic Follow 更新至 ShaneSmiskol:stock_additions 0.7.5 版。(感謝 @ShaneSmiskol 提供代碼、 @Wei 測試) * Updated Dynamic Follow to ShaneSmiskol:stock_additions 0.7.5. (Special Thanks to @ShaneSmiskol for the feature and @Wei for testing) * 優化 Lexus GSH 轉向。(感謝 @簡銘佑 測試) * Optimize Lexus GSH steering. (Thanks to @簡銘佑) * C2 支援自動關機「DragonAutoShutdownAt」參數。(感謝 @cgw1968 建議) * C2 to support auto shutdown "DragonAutoShutDownAt" param. (Thanks to @cgw1968) * 修正出現「pedalPressed」的錯誤。(感謝 @Wei 回報) * Fixed issue showing "pedalPressed" error. (Thanks to @Wei) * 將剎車狀熊顯示於 dp 資訊欄。 * Added brake indicator to dp infobar. * 修正「溫度監控」燈示。 * Fixed "Temp monitor" indicator. * 加入「方向燈取消控制」延遲控制設。(感謝 @wabes 建議) * Added delay config to "Disable Lat Control on Blinker". (Thanks to @wabes) * 加入巴西版 2020 Corolla Hybrid 指紋v2。(感謝 @berno22 提供) * Added Brazil 2020 Corolla Hybrid FPv2. (Thanks to @berno22) dragonpilot 0.7.5.2 ======================== * 加入對 VW MQB/PQ 的支援。(感謝 @dingliangxue 移植) * Added support to VW MQB/PQ platform. (Thanks to @dingliangxue) * 修改成 3 小時後停止供電。(感謝 @Wei 建議) * Updated to stop charging after 3 hrs. (Thanks to @Wei) * 移除行車記錄下的「碰撞偵測」功能。 * Removed Impact Detection in Dashcam. * 修正開啟「Noctua 風扇」模式導致的錯誤。(感謝 @阿濤 回報) * Fixed a bug caused by enabling "Noctua Mod". (Thanks to @阿濤) * 修正「位智模式」無法顯示警示的問題。(感謝 @axandres 回報) * Fixed alert issue in waze mode. (Thanks to @axandres) * 修正無法顯示更新中圖示的問題。 * Fixed unable to display "UPDATING" icon issue. * 加入「允許多次自動換道」功能。(感謝 @阿濤 建議) * Added "Allow Continuous Auto Lane Change" Toggle. (Thanks to @阿濤) * 修正開機後設定頁面有時會錯誤的問題。(感謝 @salmankhan、@Wei 回報) * Fixed setting page crash issue. (Thanks to @salmankhan, @Wei) * 修正熄火後一直出現更新訊息的錯誤。(感謝 @Sky Chang 回報) * Fixed issue that keep showing update prompt. (Thanks to @Sky Chang) dragonpilot 0.7.5.1 ======================== * 修正因同時使用「社群功能」和「自定車型」造成的加減速問題。(特別感謝 @Wei、@Sky Chang、@Han9365、@鄧育林 的測試以及回報。) * Fixed acceleration issue caused by used of both "Community Maintain Feature" and "Custom Car Model". (Special Thanks to @Wei, @Sky Chang, @Han9365, @鄧育林) * 新增 DragonMaxSpeedLimit 設定值 (mph),當如果車速高於此值 op 將會停止操控。(感謝 @Anthony 建議) * Added DragonMaxSpeedLimit parameter (mph), op will stop controlling when car speed is high than the value. (Thanks to @Anthony) * 更新 appd 使用 cnpmjs 來下載 APKs。 * Updated appd to use cnpmjs to download APKs. * 修正更新服務。(感謝 @Wei) * Fixed Update Service. (Thanks to @Wei) * 新增加拿大版 2018 Toyota Sienna LTD 指紋(v2)。(感謝 明峰 提供) * Added Canada 2018 Toyota Sienna LTD fingerprint (v2). (Thanks to 明峰) * 新增「通過移動網路上傳」開關 * Added Upload Over Mobile Network toggle. * 新增「通過熱點上傳」開關 * Added Upload Over Hotspot toggle. * 新增加拿大版 2018 Toyota Sienna LTD 指紋(v1)。(感謝 明峰 提供) * Added Canada 2018 Toyota Sienna LTD fingerprint (v1). (Thanks to 明峰) * 新增大陸版 Volkswagen Golf GTI 指紋 (v1)。(感謝 easyeiji 提供) * Added China Volkswagen Golf GTI fingerprint (v1). (Thanks to easyeiji) dragonpilot 0.7.5.0 ======================== * 基於最新 openpilot 0.7.5 devel-staging. * Based on latest openpilot 0.7.5 devel-staging. * 更新 dp 圖示 (特別感謝 @wabes 的設計與提供)。 * Updated dp logo, special thanks to @wabes for the design. * 簡/繁中文版和 i18n 整合成為單一版本。 * Merged zhs/zht/i18n versions into one. * 新增大陸版 CAMRY HYBRID 指紋v2。(感謝 @杜子腾) * Added China Camery Hybrid FPv2. (Thanks to @杜子腾) * 新增台灣版 Altis HYBRID 指紋v1。(感謝 @Fish) * Added Taiwan Altis Hybrid FPv1. (Thanks to @Fish) * 新增行駛時關閉畫面功能。 * Added Screen off while driving feature. * 新增倒車時關閉畫面功能。 * Added Screen off while reversing feature. * 新增駕駛介面加入「加速模式」切換鈕。 * Added acceleration profile toggle onto driving UI. * 新增自定車型功能,取代指紋暫存功能。 * Replaced fingerprint cache with custom car model selector. * 新增可調亮度。 * Added Brightness changer. * 新增部分德語支持。(特別感謝 @arne182 提供) * Added partial de_DE language support (Thanks to @arne182) * 新增停車碰撞偵測記錄功能。 * Added off road impact detection to dashcam. 2020-05-06 ======================== * 更新 dp 圖示 (特別感謝 @wabes 的設計與提供)。 * 中文版整合進 i18n 版。 * 刪除指紋暫存功能。 * 新增 CAMERY HIBRID 指紋。(感謝 @杜子腾) * 新增行駛時關閉畫面功能。 * 新增倒車時關閉畫面功能。 * 新增駕駛介面加入「加速模式」切換鈕。 * 新增自定義車型。 2020-04-16 ======================== * [DEVEL] 加入台灣版 2016 Lexus IS200t 指紋。(感謝 Philip / Cody Dai) * [DEVEL] 加入台灣版 2016 Toyota Prius 4.5 代指紋。(感謝 Philip) * [DEVEL] 加入台灣版 201x Toyota RAV4 4WD 指紋。(感謝 Philip) * [DEVEL] 加入台灣版 2020 Toyota Auris w/ LTA 指紋。(感謝 Philip) * [DEVEL] 修正 commIssue 錯誤。(感謝 Kent 協助) 2020-04-13 ======================== * [DEVEL] 加入可調整 Toyota Sng 起步反應值 (DragonToyotaSngResponse)。 (特別感謝 @Wei 提供 PR) * [DEVEL] 駕駛介面加入「動態調整車距」按鈕。(感謝 @cgw1968-5779 建議) * [DEVEL] 更新 update script。(感謝 深鯨希西 回報) 2020-04-10 ======================== * [DEVEL] 更新 panda 至最新的 comma:master 分支。 * [DEVEL] 移除所有的第三方應用改為自動下載。 * [DEVEL] 移除「啟用原廠 DSU 模式」、「安全帶檢查」、「車門檢查」開關。 2020-03-31 ======================== * [DEVEL] 更新至 2020-03-31 testing 分支。 2020-03-27 ======================== * [DEVEL] 更新至最新的 testing 分支: * 加入波蘭版 2015 Lexus NX200T 支援。(感謝 wabes 提供) * 調整「啟用原廠 DSU 模式」為不再需要 AHB 。(Enable Stock DSU Mode no longer requires "AHB" toggle) * 加入「安全帶檢查」、「車門檢查」、「檔位檢查」、「溫度檢查」開關。 * 加入曲率學習功能 - Curvature Learner 。(感謝 zorrobyte 提供) * 加入大陸版 2018 Toyota Highlander 支援。(感謝 toyboxZ 提供) * 加入大陸版 2018 Toyota Camry 2.0 支援。(感謝 Rming 提供) * 加入韓文支持。(感謝 crwusiz 提供) * 調整 OFFROAD 主頁翻譯將 "dragonpilot" 改回 "openpilot"。 2020-03-22 ======================== * [DEVEL] 更新至最新的 testing 分支。 2020-03-17 ======================== * [DEVEL] 更新至最新的 testing 分支 (commaai:devel-staging 0.7.4)。 * [DEVEL] 加入動態調整車距功能。(特別感謝 @ShaneSmiskol 提供 PR) 2020-03-14 ======================== * [DEVEL] 更新 pt-Br (葡萄牙語) 翻譯。(感謝 berno22 提供) * [DEVEL] 加入自動關機開關。(感謝 Rzxd 建議) * [DEVEL] 調高 Toyota 扭力容錯值。 * [DEVEL] 優化讀取 dp 設定值。 * [DEVEL] 加入 2019 手動 Civic 指紋。感謝 (AlexNoop 提供) * [DEVEL] dp 功能加入對 Subaru 車系的支援。 2020-03-06 ======================== * [DEVEL] 加入葡萄牙語支持。(感謝 berno22 提供) * [DEVEL] 加入大陸 2018 Camry、2020 RAV4 指紋。(感謝 笨木匠 提供) * [DEVEL] 建立 devel-i18n 取代 devel-en。 * [DEVEL] devel-en is deprecated, please switch to devel-i18n instead. 2020-03-04 ======================== * [DEVEL] 加入顯示駕駛監控畫面。 * [DEVEL] 加入加速模式選項。(特別感謝 @arne182, @cgw1968-5779 提供 PR) * [DEVEL] 修正 shutdownd 在 comma two 可能會不正常關機的錯誤。(感謝 @Wei, @Rzxd 回報) 2020-02-25 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.3)。 2020-02-21 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.3)。 2020-02-14 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.2)。 * [DEVEL] 修正錯誤。 2020-02-08 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.2)。 * [DEVEL] dp 功能加入對現代 (Hyundai) 車系的支援。 * [DEVEL] 加入神盾測速照相自動啟動的開關。 * [DEVEL] 更新高德地圖至 v4.5.0.600053。 * [DEVEL] 使用 0.6.6 版的更新系統。 * [DEVEL] 修正急剎問題。(感謝 kumar 提供) 2020-01-31 ======================== * [DEVEL] 移除行車介面電量、溫度顯示,(修正畫面當機、黑屏問題) 2020-01-29 ======================== * [DEVEL] 修正行車介面錯誤。(感謝 深鲸希西 測試;eisenheim、HeatNation 反應) 2020-01-23 ======================== * [DEVEL] 加入 Steer Ratio Learner 關閉。(感謝 eisenheim 建議) * [DEVEL] 行車介面加入電量、溫度。(感謝 eisenheim 建議) * [DEVEL] 優化 appd。 2020-01-19 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.1)。 * [DEVEL] 調整 appd 和 ALC 邏輯。 2020-01-14 ======================== * [DEVEL] 加入開機啟動個人熱點。(感謝 eisenheim 建議) 2020-01-08 ======================== * [DEVEL] 加入大陸版 2018 Lexus RX300 支援。(感謝 cafe 提供) * [DEVEL] 加入 DragonBTG 設定。(感謝 CloudJ、低調哥、歐姓Altis車主 提供) 2019-12-31 ======================== * [DEVEL-ZHS] 加回第三方應用。 2019-12-29 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.0)。 * [DEVEL] 輔助/自動變道改為可調整參數 (進階用戶)。(DragonAssistedLCMinMPH、DragonAutoLCMinMPH、DragonAutoLCDelay) * [DEVEL-ZHS] 修正無法運行第三方應用錯誤。(感謝 深鲸希西 反應) 2019-12-18 ======================== * [DEVEL] 修正自動換道邏輯。 * [DEVEL] 更新 offroad 翻譯。 * [DEVEL] 錯誤修正。 * [DEVEL] 移除美版 2017 Civic Hatchback 指紋。(與其它車型衝突) 2019-12-17 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.7.0)。 * [DEVEL] 加入輔助換道開關。(24mph / 40kph 以上) * [DEVEL] 加入自動換道開關。(40mph / 65kph 以上) * [DEVEL] 加入大陸版 2019 雷凌汽油版指紋。 (感謝 Shell 提供) * [DEVEL] 加入大陸版 2019 卡羅拉汽油版指紋。 (感謝 Shell 提供) * [DEVEL] 加入美版 2017 Civic Hatchback 指紋。(感謝 CFranHonda 提供) 2019-12-10 ======================== * [DEVEL] 加入位智車機模式。 (Waze Mode) 2019-11-21 ======================== * [DEVEL] 修正 offroad 翻譯。(感謝 鄧育林 回報) * [DEVEL] 調整前車靜止移動偵測參數。 * [DEVEL] 前車靜止移動偵測可在未啟用 dp 時運作。 2019-11-18 ======================== * [DEVEL] 修正 offroad 翻譯。(感謝 Cody、鄧育林 回報) 2019-11-18 ======================== * [DEVEL] 修正 frame 翻譯。 2019-11-15 ======================== * [DEVEL] 修正不會充電的錯誤。 (感謝 袁昊 反應) 2019-11-15 ======================== * [DEVEL] 修正充電控制。 (感謝 KT 反應) * [DEVEL] 更新 frame 翻譯,改為多語言版。 (感謝 深鲸希西、shaoching885、鄧育林 反應) * [DEVEL] 更新至最新的 commaai:devel (0.6.6)。 2019-11-12 ======================== * [DEVEL] 只顯示電量文字 (注意:有時不會更新,需要拔插 USB 線) * [DEVEL] 自動偵測並鎖定硬體 (EON / UNO)。 2019-11-12 ======================== * [DEVEL] 加入鎖定硬體 (EON / UNO) 的程式碼。 2019-11-11 ======================== * [DEVEL] 更新高德地圖至 v4.3.0.600310 R2098NSLAE * [DEVEL] 更新 MiXplorer 至 v6.40.3 * [DEVEL] 更新至最新的 commaai:devel (0.6.6)。 * [DEVEL] 前車靜止移動偵測加入偵測警示。 2019-11-07 ======================== * [DEVEL] 讓 Bosch 系統顯示三角。 (感謝 ching885 回報) * [DEVEL] 更新 offroad 多語言版簡體中文翻譯 (感謝 Rming 提供) 2019-11-06 ======================== * [DEVEL] 修正 0.6.6 appd 和 dashcamd 錯誤。 (感謝 鄧育林 回報) * [DEVEL] 更新至最新的 commaai:devel (0.6.6)。 2019-11-05 ======================== * [DEVEL] 加入台灣 Lexus 2017 GS450h 支援。 (感謝 簡銘佑 提供指紋) 2019-11-01 ======================== * [DEVEL] 新增神盾測速照相。 (感謝 Sky Chang 和 Wei Yi Chen) * [DEVEL] 修正 offroad 翻譯。 (感謝 Leo Hsieh) 2019-11-01 ======================== * [DEVEL] 移除 Miui 字型,縮小 dp 使用空間。 * [DEVEL] 更新 offroad 為多語言版 * [DEVEL] 更新至最新的 commaai:devel (0.6.5)。 2019-10-29 ======================== * [DEVEL] 加入 SnG 補丁。(感謝 楊雅智) 2019-10-28 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.6.5)。 * [DEVEL] 調整 dragon_allow_gas 邏輯 (請回報任何問題,需更新 Panda 韌體) 2019-10-18 ======================== * [DEVEL] 加入前車靜止移動偵測。(測試版,感謝 ucolchen) * [DEVEL] 移除強迫網路連線提示。(感謝 Shell) * [DEVEL] 修正 allow_gas 功能。 2019-10-18 ======================== * [DEVEL] 加入彎道減速功能開關。 * [DEVEL] 強迫使用 dp 版 Panda 韌體。 * [DEVEL] 更新至最新的 commaai:devel (0.6.5)。 2019-10-17 ======================== * [DEVEL] 加入「車型」顯示於 dp 設定畫面。 * [DEVEL] 修正充電控制讀取預設值的錯誤。 * [DEVEL] 修正無法顯示更新記錄的錯誤。 2019-10-16 ======================== * [DEVEL] 刷新 Panda 韌體按鈕將會自動重啟 EON。(感謝 鄧育林 建議) * [DEVEL] 下載更新記錄時使用 "no-cache" 標頭。 * [DEVEL] 更新高德地圖至 v4.3.0 * [DEVEL] 刪除 bs (Branch Switcher) 2019-10-14 ======================== * [DEVEL] 啟用自動更新功能。(感謝 鄧育林 提供) * [DEVEL] 清除不再使用的 dp params。 * [DEVEL] 加入數字電量指示。(感謝 鄧育林 建議) * [DEVEL] 加入刷新 Panda 韌體按鈕。 2019-10-11 ======================== * [DEVEL] 更新至最新的 commaai:devel (0.6.5)。 * [DEVEL] 加入台灣 2019 RAV4 汽油版指紋。 (感謝 Max Duan / CloudJ 提供) 2019-10-09 ======================== * [DEVEL] 加入當 LatCtrl 關閉時,畫面顯示提示訊息。 2019-10-08 ======================== * [DEVEL] 加回駕駛監控開關。 * [DEVEL] 加入 bs (branch switcher) 程式。 2019-10-07 ======================== * [DEVEL] 加入台灣版 2019 RAV4H 油電版指紋。(感謝 Max Duan 提供) 2019-10-05 ======================== * [DEVEL] 移除 curvature learner: 轉角明顯比原廠小。 * [DEVEL] 更新至最新的 commaai:devel (0.6.4)。 2019-09-30 ======================== * [DEVEL] 更新 curvature learner 版本至 v4。 * [DEVEL] Lexus ISH 使用更精確的 EPS Steering Angle Sensor 2019-09-27 ======================== * [DEVEL] 加入 Zorrobyte 的 curvature learner (https://github.com/zorrobyte/openpilot) * [DEVEL] 加入可開關駕駛監控的程式碼。 * [DEVEL] 取消當 steering 出現錯誤時,自動切斷方向控制 2 秒的機制。 * [DEVEL] 讓行車介面的「方向盤」/「轉彎」圖示半透明化。 2019-09-26 ======================== * [DEVEL] 修正當「啟用記錄服務」關閉時,make 會有問題的錯誤。 (感謝 shaoching885 和 afa 回報) 2019-09-24 ======================== * [DEVEL] 行車介面加入可開關的「前車」、「路線」、「車道」設定。 * [DEVEL] 行車介面加入可開關的「方向燈號」提示。 (感謝 CloudJ 建議,程式碼來源: https://github.com/kegman/openpilot) 2019-09-23 ======================== * [DEVEL] 優化讀取 params 的次數。 * [DEVEL] 加入可開關的車道偏移警示。 * [DEVEL] 修正充電控制邏輯。 * [DEVEL] 加入台灣 Prius 4.5 指紋。 (感謝 Lin Hsin Hung 提供) 2019-09-20 ======================== * [DEVEL] 加入充電控制功能。 (感謝 loveloveses 和 KT 建議) 2019-09-16 ======================== * [DEVEL] 加入台灣 CT200h 指紋。 (感謝 CloudJ 提供) * [DEVEL] 加入美版 CT200h 移植。 (感謝 thomaspich 提供) 2019-09-13 ======================== * [DEVEL] 行車介面加入可開關的「速度顯示」設定。 2019-09-09 ======================== * [DEVEL] 加入 GreyPanda 模式。 2019-08-28 ======================== * [DEVEL] 加入可調警示音量。 2019-08-27 ======================== * [DEVEL] 自動關機改為可調時長。 ================================================ FILE: CONTRIBUTING.md ================================================ # How to contribute Our software is open source so you can solve your own problems without needing help from others. And if you solve a problem and are so kind, you can upstream it for the rest of the world to use. Most open source development activity is coordinated through our [GitHub Discussions](https://github.com/commaai/openpilot/discussions) and [Discord](https://discord.comma.ai). A lot of documentation is available on our [blog](https://blog.comma.ai/). ## Getting Started * Join our [Discord](https://discord.comma.ai) * Make sure you have a [GitHub account](https://github.com/signup/free) * Fork [our repositories](https://github.com/commaai) on GitHub ## Testing ### Automated Testing All PRs and commits are automatically checked by GitHub Actions. Check out `.github/workflows/` for what GitHub Actions runs. Any new tests should be added to GitHub Actions. ### Code Style and Linting Code is automatically checked for style by GitHub Actions as part of the automated tests. You can also run these tests yourself by running `pre-commit run --all`. ## Car Ports (openpilot) We've released a [Model Port guide](https://blog.comma.ai/openpilot-port-guide-for-toyota-models/) for porting to Toyota/Lexus models. If you port openpilot to a substantially new car brand, see this more generic [Brand Port guide](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/). ## Pull Requests Pull requests should be against the master branch. Before running master on in-car hardware, you'll need to clone the submodules too. That can be done by recursively cloning the repository: ``` git clone https://github.com/commaai/openpilot.git --recursive ``` Or alternatively, when on the master branch: ``` git submodule update --init ``` The reasons for having submodules on a dedicated repository and our new development philosophy can be found in our [post about externalization](https://blog.comma.ai/a-2020-theme-externalization/). Modules that are in seperate repositories include: * cereal * laika * opendbc * panda * rednose ================================================ FILE: CONTRIBUTORS.md ================================================ # CONTRIBUTORS Due to the way we manage the source code, it is not possible to see all the contributors' info, hence we create a list here. If you have contributed to DP project before and your name is not listed here, feel free to send us a PR to update this! ### TEAM Name | github | Role ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ cafe | [cafe](https://github.com/coffice12) | Resource Provider cgw1968 | [cgw1968](https://github.com/cgw1968-5779) | C2/C3 Toyota Beta Tester kumar | [rav4kumar](https://github.com/rav4kumar) | Release Maintainer loveloveses | [loveloveses](https://github.com/loveloveses) | Wiki Maintainer Rick Lan | [efinilan](https://github.com/efinilan) | Release Maintainer Stupefacient | [Stupefacient](https://github.com/Stupefacient) | C2/C3 Toyota Beta Tester CCZ | [CCZ](https://github.com/czdeee) | UI developer, Simplified Chinese Translator ### CONTRIBUTORS Name | github ------------------------------------------------------------ | ------------------------------------------------------------ andy741217 | [andy741217](https://github.com/andy741217) Arne Schwarck | [arne182](https://github.com/arne182) berno22 | [berno22](https://github.com/berno22) Bobbydough | [Bobbydough](https://github.com/bobbydough) TIM | [TIM](https://github.com/CT921) Curtis Jenkins | [actuallylemoncurd](https://github.com/actuallylemoncurd) DFyffe | [donfyffe](https://github.com/donfyffe) dinglx | [dingliangxue](https://github.com/dingliangxue) eyezenheim | [eyezenheim](https://github.com/eyezenheim) Jason Wen | [sunnyhaibin](https://github.com/sunnyhaibin) kegman | [kegman](https://github.com/kegman) lijunhao731 | [lijunhao731](https://github.com/lijunhao731) lirudy | [lirudy](https://github.com/lirudy) LOVEChen | [LOVEChen](https://github.com/LOVEChen) menwenliang | [menwenliang](https://github.com/menwenliang) move-fast | [move-fast](https://github.com/move-fast) Nelson Chen | [nelsonjchen](https://github.com/nelsonjchen) rming | [Rming](https://github.com/rming) sebastian4k | [sebastian4k](https://github.com/sebastian4k) Shane Smiskol | [sshane](https://github.com/sshane) toyboxZ | [toyboxZ](https://github.com/toyboxZ) ================================================ FILE: HOWTO-ONEPLUS.md ================================================ How to install on Oneplus 3t? ------ 1. clone dragonpilot to /data/ and make sure it's named openpilot: (手動安裝切換至 dp) ``` cd /data/ && rm -fr openpilot ; git clone https://github.com/dragonpilot-community/dragonpilot.git openpilot -b 0.8.8 ``` 2. run command: (在 ssh 畫面下,輸入) ``` cd /data/openpilot/scripts/ && ./oneplus_update_neos.sh ``` 3. Let it download and complete it update, after a couple of reboot, your screen will then stay in fastboot mode. (等待下載並讓它重新開機,沒錯誤的話會進入 Android 機器人更新畫面,等自動重新開機) 4. In fastboot mode, select use volume button to select to `Recovery mode` then press power button. (在 fastboot 模式,用音量鍵上下選到 Recovery mode 再按下電源鍵) 5. In Recovery mode, tap `apply update` -> `Choose from emulated` -> `0/` -> `update.zip` -> `Reboot system now` (在 Recovery mode,點選 `apply update` -> `Choose from emulated` -> `0/` -> `update.zip` -> `Reboot system now`) 6. You should be able to boot into openpilot, if touch screen is not working, try to reboot again. (你現在應該可以進入 openpilot 畫面,如果點擊畫面沒有反應,請再重新開機一次) ================================================ FILE: HOWTO-Translate.md ================================================ HOW TO Translate dragonpilot -- If you would like to help to translate dragonpilot into your native language, please: 1. Contact dragonpilot team to generate language files for translation. 2. Start translation, there will be 2 files: (locale = your language code) * /selfdrive/assets/locales/**locale**/LC_MESSAGES/events.po * This is for alerts messages. (e.g. on road warning messages) * /selfdrive/ui/translations/**locale**.ts * This is for UI. (e.g. settings pages) We recommended to use a proper editor such as TextMate (mac) / notepad++ (win) / Intellij pyCharm. 3. Submit a PR for your translation. 4. dragonpilot team will review your PR and add it in the next release. ================================================ FILE: Jenkinsfile ================================================ def phone(String ip, String step_label, String cmd) { withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) { def ssh_cmd = """ ssh -tt -o StrictHostKeyChecking=no -i ${key_file} -p 8022 'comma@${ip}' /usr/bin/bash <<'EOF' set -e export CI=1 export TEST_DIR=${env.TEST_DIR} export SOURCE_DIR=${env.SOURCE_DIR} export GIT_BRANCH=${env.GIT_BRANCH} export GIT_COMMIT=${env.GIT_COMMIT} source ~/.bash_profile if [ -f /TICI ]; then source /etc/profile fi ln -snf ${env.TEST_DIR} /data/pythonpath if [ -f /EON ]; then echo \$\$ > /dev/cpuset/app/tasks || true echo \$PPID > /dev/cpuset/app/tasks || true mkdir -p /dev/shm chmod 777 /dev/shm fi cd ${env.TEST_DIR} || true ${cmd} exit 0 EOF""" sh script: ssh_cmd, label: step_label } } def phone_steps(String device_type, steps) { lock(resource: "", label: device_type, inversePrecedence: true, variable: 'device_ip', quantity: 1) { timeout(time: 150, unit: 'MINUTES') { phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) steps.each { item -> phone(device_ip, item[0], item[1]) } } } } pipeline { agent none environment { TEST_DIR = "/data/openpilot" SOURCE_DIR = "/data/openpilot_source/" } options { timeout(time: 3, unit: 'HOURS') } stages { stage('Build release2') { agent { docker { image 'python:3.7.3' args '--user=root' } } when { branch 'devel-staging' } steps { phone_steps("eon-build", [ ["build release2-staging & dashcam-staging", "cd release && PUSH=1 ./build_release2.sh"], ]) } } stage('Build release3') { agent { docker { image 'python:3.7.3' args '--user=root' } } when { branch 'devel-staging' } steps { phone_steps("tici", [ ["build release3-staging & dashcam3-staging", "PUSH=1 $SOURCE_DIR/release/build_release3.sh"], ]) } } stage('openpilot tests') { when { not { anyOf { branch 'master-ci'; branch 'devel'; branch 'devel-staging'; branch 'release2'; branch 'release2-staging'; branch 'dashcam'; branch 'dashcam-staging'; branch 'release3'; branch 'release3-staging'; branch 'dashcam3'; branch 'dashcam3-staging'; branch 'testing-closet*'; branch 'hotfix-*' } } } stages { /* stage('PC tests') { agent { dockerfile { filename 'Dockerfile.openpilotci' args '--privileged --shm-size=1G --user=root' } } stages { stage('Build') { steps { sh 'scons -j$(nproc)' } } } post { always { // fix permissions since docker runs as another user sh "chmod -R 777 ." } } } */ stage('On-device Tests') { agent { docker { /* filename 'Dockerfile.ondevice_ci' args "--privileged -v /dev:/dev --shm-size=1G --user=root" */ image 'python:3.7.3' args '--user=root' } } stages { stage('parallel tests') { parallel { stage('Devel Tests') { steps { phone_steps("eon-build", [ ["build devel", "cd $SOURCE_DIR/release && EXTRA_FILES='tools/' ./build_devel.sh"], ["build openpilot", "cd selfdrive/manager && ./build.py"], ["test manager", "python selfdrive/manager/test/test_manager.py"], ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], ["test car interfaces", "cd selfdrive/car/tests/ && ./test_car_interfaces.py"], ]) } } stage('Replay Tests') { steps { phone_steps("eon2", [ ["build", "cd selfdrive/manager && ./build.py"], ["model replay", "cd selfdrive/test/process_replay && ./model_replay.py"], ]) } } stage('HW + Unit Tests') { steps { phone_steps("eon", [ ["build", "cd selfdrive/manager && ./build.py"], ["test athena", "nosetests -s selfdrive/athena/tests/test_athenad_old.py"], ["test sounds", "nosetests -s selfdrive/ui/tests/test_sounds.py"], ["test boardd loopback", "nosetests -s selfdrive/boardd/tests/test_boardd_loopback.py"], ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], ["test encoder", "python selfdrive/loggerd/tests/test_encoder.py"], ["test logcatd", "python selfdrive/logcatd/tests/test_logcatd_android.py"], //["test updater", "python installer/updater/test_updater.py"], ]) } } /* stage('Power Consumption Tests') { steps { lock(resource: "", label: "c2-zookeeper", inversePrecedence: true, variable: 'device_ip', quantity: 1) { timeout(time: 90, unit: 'MINUTES') { sh script: "/home/batman/tools/zookeeper/enable_and_wait.py $device_ip 120", label: "turn on device" phone(device_ip, "git checkout", readFile("selfdrive/test/setup_device_ci.sh"),) phone(device_ip, "build", "scons -j4 && sync") sh script: "/home/batman/tools/zookeeper/disable.py $device_ip", label: "turn off device" sh script: "/home/batman/tools/zookeeper/enable_and_wait.py $device_ip 120", label: "turn on device" sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 3", label: "idle power consumption after boot" sh script: "/home/batman/tools/zookeeper/ignition.py 1", label: "go onroad" sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 10", label: "onroad power consumption" sh script: "/home/batman/tools/zookeeper/ignition.py 0", label: "go offroad" sh script: "/home/batman/tools/zookeeper/check_consumption.py 60 2", label: "idle power consumption offroad" } } } } */ stage('tici Build') { environment { R3_PUSH = "${env.BRANCH_NAME == 'master' ? '1' : ' '}" } steps { phone_steps("tici", [ ["build", "cd selfdrive/manager && ./build.py"], ["onroad tests", "cd selfdrive/test/ && ./test_onroad.py"], ]) } } stage('Unit Tests (tici)') { steps { phone_steps("tici2", [ ["build", "cd selfdrive/manager && ./build.py"], ["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"], ["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"], ]) } } stage('camerad') { steps { phone_steps("eon-party", [ ["build", "cd selfdrive/manager && ./build.py"], ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], ]) } } stage('Tici camerad') { steps { phone_steps("tici-party", [ ["build", "cd selfdrive/manager && ./build.py"], ["test camerad", "python selfdrive/camerad/test/test_camerad.py"], ["test exposure", "python selfdrive/camerad/test/test_exposure.py"], ]) } } } } stage('Push master-ci') { when { branch 'master' } steps { phone_steps("eon-build", [ ["push devel", "cd $SOURCE_DIR/release && PUSH='master-ci' ./build_devel.sh"], ]) } } } post { always { cleanWs() } } } } } } } ================================================ FILE: LICENSE ================================================ Copyright (c) 2018, Comma.ai, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README-openpilot.md ================================================ ![](https://user-images.githubusercontent.com/37757984/127420744-89ca219c-8f8e-46d3-bccf-c1cb53b81bb1.png) Table of Contents ======================= * [What is openpilot?](#what-is-openpilot) * [Integration with Stock Features](#integration-with-stock-features) * [Supported Hardware](#supported-hardware) * [Supported Cars](#supported-cars) * [Community Maintained Cars and Features](#community-maintained-cars-and-features) * [Installation Instructions](#installation-instructions) * [Limitations of openpilot ALC and LDW](#limitations-of-openpilot-alc-and-ldw) * [Limitations of openpilot ACC and FCW](#limitations-of-openpilot-acc-and-fcw) * [Limitations of openpilot DM](#limitations-of-openpilot-dm) * [User Data and comma Account](#user-data-and-comma-account) * [Safety and Testing](#safety-and-testing) * [Testing on PC](#testing-on-pc) * [Community and Contributing](#community-and-contributing) * [Directory Structure](#directory-structure) * [Licensing](#licensing) --- What is openpilot? ------ [openpilot](http://github.com/commaai/openpilot) is an open source driver assistance system. Currently, openpilot performs the functions of Adaptive Cruise Control (ACC), Automated Lane Centering (ALC), Forward Collision Warning (FCW) and Lane Departure Warning (LDW) for a growing variety of supported [car makes, models and model years](#supported-cars). In addition, while openpilot is engaged, a camera based Driver Monitoring (DM) feature alerts distracted and asleep drivers.
Integration with Stock Features ------ In all supported cars: * Stock Lane Keep Assist (LKA) and stock ALC are replaced by openpilot ALC, which only functions when openpilot is engaged by the user. * Stock LDW is replaced by openpilot LDW. Additionally, on specific supported cars (see ACC column in [supported cars](#supported-cars)): * Stock ACC is replaced by openpilot ACC. * openpilot FCW operates in addition to stock FCW. openpilot should preserve all other vehicle's stock features, including, but are not limited to: FCW, Automatic Emergency Braking (AEB), auto high-beam, blind spot warning, and side collision warning. Supported Hardware ------ At the moment, openpilot supports the EON Gold DevKit, [comma two](https://comma.ai/shop/products/two), and [comma three](https://comma.ai/shop/products/three). A [car harness](https://comma.ai/shop/products/car-harness) is recommended to connect your device to the car. For experimental purposes, openpilot can also run on an Ubuntu computer with external [webcams](https://github.com/commaai/openpilot/tree/master/tools/webcam). Supported Cars ------ | Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | | ----------| ------------------------------| ------------------| -----------------| -------------------| ------------------| | Acura | ILX 2016-19 | AcuraWatch Plus | openpilot | 25mph1 | 25mph | | Acura | RDX 2016-18 | AcuraWatch Plus | openpilot | 25mph1 | 12mph | | Acura | RDX 2019-21 | All | Stock | 0mph | 3mph | | Honda | Accord 2018-20 | All | Stock | 0mph | 3mph | | Honda | Accord Hybrid 2018-20 | All | Stock | 0mph | 3mph | | Honda | Civic Hatchback 2017-21 | Honda Sensing | Stock | 0mph | 12mph | | Honda | Civic Coupe 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | | Honda | Civic Coupe 2019-20 | All | Stock | 0mph | 2mph2 | | Honda | Civic Sedan 2016-18 | Honda Sensing | openpilot | 0mph | 12mph | | Honda | Civic Sedan 2019-20 | All | Stock | 0mph | 2mph2 | | Honda | CR-V 2015-16 | Touring | openpilot | 25mph1 | 12mph | | Honda | CR-V 2017-21 | Honda Sensing | Stock | 0mph | 12mph | | Honda | CR-V Hybrid 2017-2019 | Honda Sensing | Stock | 0mph | 12mph | | Honda | e 2020 | All | Stock | 0mph | 3mph | | Honda | Fit 2018-19 | Honda Sensing | openpilot | 25mph1 | 12mph | | Honda | HR-V 2019-20 | Honda Sensing | openpilot | 25mph1 | 12mph | | Honda | Insight 2019-21 | All | Stock | 0mph | 3mph | | Honda | Inspire 2018 | All | Stock | 0mph | 3mph | | Honda | Odyssey 2018-20 | Honda Sensing | openpilot | 25mph1 | 0mph | | Honda | Passport 2019 | All | openpilot | 25mph1 | 12mph | | Honda | Pilot 2016-19 | Honda Sensing | openpilot | 25mph1 | 12mph | | Honda | Ridgeline 2017-21 | Honda Sensing | openpilot | 25mph1 | 12mph | | Hyundai | Palisade 2020-21 | All | Stock | 0mph | 0mph | | Hyundai | Sonata 2020-21 | All | Stock | 0mph | 0mph | | Lexus | CT Hybrid 2017-18 | LSS | Stock3| 0mph | 0mph | | Lexus | ES 2019-21 | All | openpilot | 0mph | 0mph | | Lexus | ES Hybrid 2017-18 | LSS | Stock3| 0mph | 0mph | | Lexus | ES Hybrid 2019-21 | All | openpilot | 0mph | 0mph | | Lexus | IS 2017-2019 | All | Stock | 22mph | 0mph | | Lexus | NX 2018 | All | Stock3| 0mph | 0mph | | Lexus | NX 2020 | All | openpilot | 0mph | 0mph | | Lexus | NX Hybrid 2018-19 | All | Stock3| 0mph | 0mph | | Lexus | RX 2016-18 | All | Stock3| 0mph | 0mph | | Lexus | RX 2020-21 | All | openpilot | 0mph | 0mph | | Lexus | RX Hybrid 2016-19 | All | Stock3| 0mph | 0mph | | Lexus | RX Hybrid 2020-21 | All | openpilot | 0mph | 0mph | | Lexus | UX Hybrid 2019-21 | All | openpilot | 0mph | 0mph | | Toyota | Alphard 2020 | All | openpilot | 0mph | 0mph | | Toyota | Avalon 2016-21 | TSS-P | Stock3| 20mph1 | 0mph | | Toyota | Avalon Hybrid 2019-21 | TSS-P | Stock3| 20mph1 | 0mph | | Toyota | Camry 2018-20 | All | Stock | 0mph4 | 0mph | | Toyota | Camry 2021 | All | openpilot | 0mph4 | 0mph | | Toyota | Camry Hybrid 2018-20 | All | Stock | 0mph4 | 0mph | | Toyota | Camry Hybrid 2021 | All | openpilot | 0mph | 0mph | | Toyota | C-HR 2017-20 | All | Stock | 0mph | 0mph | | Toyota | C-HR Hybrid 2017-19 | All | Stock | 0mph | 0mph | | Toyota | Corolla 2017-19 | All | Stock3| 20mph1 | 0mph | | Toyota | Corolla 2020-22 | All | openpilot | 0mph | 0mph | | Toyota | Corolla Hatchback 2019-21 | All | openpilot | 0mph | 0mph | | Toyota | Corolla Hybrid 2020-21 | All | openpilot | 0mph | 0mph | | Toyota | Highlander 2017-19 | All | Stock3| 0mph | 0mph | | Toyota | Highlander 2020-21 | All | openpilot | 0mph | 0mph | | Toyota | Highlander Hybrid 2017-19 | All | Stock3| 0mph | 0mph | | Toyota | Highlander Hybrid 2020-21 | All | openpilot | 0mph | 0mph | | Toyota | Mirai 2021 | All | openpilot | 0mph | 0mph | | Toyota | Prius 2016-20 | TSS-P | Stock3| 0mph | 0mph | | Toyota | Prius 2021 | All | openpilot | 0mph | 0mph | | Toyota | Prius Prime 2017-20 | All | Stock3| 0mph | 0mph | | Toyota | Prius Prime 2021 | All | openpilot | 0mph | 0mph | | Toyota | Rav4 2016-18 | TSS-P | Stock3| 20mph1 | 0mph | | Toyota | Rav4 2019-21 | All | openpilot | 0mph | 0mph | | Toyota | Rav4 Hybrid 2016-18 | TSS-P | Stock3| 0mph | 0mph | | Toyota | Rav4 Hybrid 2019-21 | All | openpilot | 0mph | 0mph | | Toyota | Sienna 2018-20 | All | Stock3| 0mph | 0mph | 1[Comma Pedal](https://github.com/commaai/openpilot/wiki/comma-pedal) is used to provide stop-and-go capability to some of the openpilot-supported cars that don't currently support stop-and-go. ***NOTE: The Comma Pedal is not officially supported by [comma](https://comma.ai).***
22019 Honda Civic 1.6L Diesel Sedan does not have ALC below 12mph.
3When disconnecting the Driver Support Unit (DSU), openpilot ACC will replace stock ACC. ***NOTE: disconnecting the DSU disables Automatic Emergency Braking (AEB).***
428mph for Camry 4CYL L, 4CYL LE and 4CYL SE which don't have Full-Speed Range Dynamic Radar Cruise Control.
Community Maintained Cars and Features ------ | Make | Model (US Market Reference) | Supported Package | ACC | No ACC accel below | No ALC below | | ----------| ------------------------------| ------------------| -----------------| -------------------| -------------| | Audi | A3 2014-19 | Prestige | Stock | 0mph | 0mph | | Audi | A3 Sportback e-tron 2017-18 | Prestige | Stock | 0mph | 0mph | | Audi | Q2 2018 | Driver Assistance | Stock | 0mph | 0mph | | Buick | Regal 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | | Cadillac | ATS 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | | Chevrolet | Malibu 20171 | Adaptive Cruise | openpilot | 0mph | 7mph | | Chevrolet | Volt 2017-181 | Adaptive Cruise | openpilot | 0mph | 7mph | | Chrysler | Pacifica 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Chrysler | Pacifica 2020 | Adaptive Cruise | Stock | 0mph | 39mph | | Chrysler | Pacifica Hybrid 2017-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Chrysler | Pacifica Hybrid 2019-21 | Adaptive Cruise | Stock | 0mph | 39mph | | Genesis | G70 2018 | All | Stock | 0mph | 0mph | | Genesis | G80 2018 | All | Stock | 0mph | 0mph | | Genesis | G90 2018 | All | Stock | 0mph | 0mph | | GMC | Acadia 20181 | Adaptive Cruise | openpilot | 0mph | 7mph | | Holden | Astra 20171 | Adaptive Cruise | openpilot | 0mph | 7mph | | Hyundai | Elantra 2017-19 | SCC + LKAS | Stock | 19mph | 34mph | | Hyundai | Elantra 2021 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Elantra Hybrid 2021 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Genesis 2015-16 | SCC + LKAS | Stock | 19mph | 37mph | | Hyundai | Ioniq Electric 2019 | SCC + LKAS | Stock | 0mph | 32mph | | Hyundai | Ioniq Electric 2020 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Ioniq PHEV 2020 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Kona 2020 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Kona EV 2018-19 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Kona Hybrid 2020 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Santa Fe 2019-20 | All | Stock | 0mph | 0mph | | Hyundai | Sonata 2018-2019 | SCC + LKAS | Stock | 0mph | 0mph | | Hyundai | Sonata Hybrid 2021 | All | Stock | 0mph | 0mph | | Hyundai | Veloster 2019-20 | SCC + LKAS | Stock | 5mph | 0mph | | Jeep | Grand Cherokee 2016-18 | Adaptive Cruise | Stock | 0mph | 9mph | | Jeep | Grand Cherokee 2019-20 | Adaptive Cruise | Stock | 0mph | 39mph | | Kia | Forte 2018-21 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Niro EV 2019-21 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Niro Hybrid 2021 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Niro PHEV 2019 | SCC + LKAS | Stock | 10mph | 32mph | | Kia | Optima 2017 | SCC + LKAS | Stock | 0mph | 32mph | | Kia | Optima 2019 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Seltos 2021 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Sorento 2018-19 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Stinger 2018 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Ceed 2019 | SCC + LKAS | Stock | 0mph | 0mph | | Kia | Telluride 2020 | SCC + LKAS | Stock | 0mph | 0mph | | Nissan | Altima 2019-20 | ProPILOT | Stock | 0mph | 0mph | | Nissan | Leaf 2018-20 | ProPILOT | Stock | 0mph | 0mph | | Nissan | Rogue 2018-20 | ProPILOT | Stock | 0mph | 0mph | | Nissan | X-Trail 2017 | ProPILOT | Stock | 0mph | 0mph | | SEAT | Ateca 2018 | Driver Assistance | Stock | 0mph | 0mph | | SEAT | Leon 2014-2020 | Driver Assistance | Stock | 0mph | 0mph | | Škoda | Kodiaq 2018-19 | Driver Assistance | Stock | 0mph | 0mph | | Škoda | Octavia 2015, 2018-19 | Driver Assistance | Stock | 0mph | 0mph | | Škoda | Octavia RS 2016 | Driver Assistance | Stock | 0mph | 0mph | | Škoda | Scala 2020 | Driver Assistance | Stock | 0mph | 0mph | | Škoda | Superb 2015-18 | Driver Assistance | Stock | 0mph | 0mph | | Subaru | Ascent 2019 | EyeSight | Stock | 0mph | 0mph | | Subaru | Crosstrek 2018-19 | EyeSight | Stock | 0mph | 0mph | | Subaru | Forester 2019-21 | EyeSight | Stock | 0mph | 0mph | | Subaru | Impreza 2017-19 | EyeSight | Stock | 0mph | 0mph | | Volkswagen| Atlas 2018-19 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| e-Golf 2014, 2019-20 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf 2015-20 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf Alltrack 2017-18 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf GTE 2016 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf GTI 2018-20 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf R 2016-19 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf SportsVan 2016 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Golf SportWagen 2015 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Jetta 2018-20 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Jetta GLI 2021 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Passat 2016-172 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| T-Cross 2021 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Tiguan 2020 | Driver Assistance | Stock | 0mph | 0mph | | Volkswagen| Touran 2017 | Driver Assistance | Stock | 0mph | 0mph | 1Requires an [OBD-II car harness](https://comma.ai/shop/products/comma-car-harness) and [community built ASCM harness](https://github.com/commaai/openpilot/wiki/GM#hardware). ***NOTE: disconnecting the ASCM disables Automatic Emergency Braking (AEB).***
2Only includes the MQB Passat sold outside of North America. The NMS Passat made in Chattanooga TN is not yet supported. Community Maintained Cars and Features are not verified by comma to meet our [safety model](SAFETY.md). Be extra cautious using them. They are only available after enabling the toggle in `Settings->Developer->Enable Community Features`. To promote a car from community maintained, it must meet a few requirements. We must own one from the brand, we must sell the harness for it, has full ISO26262 in both panda and openpilot, there must be a path forward for longitudinal control, it must have AEB still enabled, and it must support fingerprinting 2.0 Although they're not upstream, the community has openpilot running on other makes and models. See the 'Community Supported Models' section of each make [on our wiki](https://wiki.comma.ai/). Installation Instructions ------ Install openpilot on a supported device by entering ``https://openpilot.comma.ai`` during the installer setup. Follow these [video instructions](https://youtu.be/lcjqxCymins) to properly mount the device on the windshield. Note: openpilot features an automatic pose calibration routine and openpilot performance should not be affected by small pitch and yaw misalignments caused by imprecise device mounting. Before placing the device on your windshield, check the state and local laws and ordinances where you drive. Some state laws prohibit or restrict the placement of objects on the windshield of a motor vehicle. You will be able to engage openpilot after reviewing the onboarding screens and finishing the calibration procedure. Limitations of openpilot ALC and LDW ------ openpilot ALC and openpilot LDW do not automatically drive the vehicle or reduce the amount of attention that must be paid to operate your vehicle. The driver must always keep control of the steering wheel and be ready to correct the openpilot ALC action at all times. While changing lanes, openpilot is not capable of looking next to you or checking your blind spot. Only nudge the wheel to initiate a lane change after you have confirmed it's safe to do so. Many factors can impact the performance of openpilot ALC and openpilot LDW, causing them to be unable to function as intended. These include, but are not limited to: * Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. * The road facing camera is obstructed, covered or damaged by mud, ice, snow, etc. * Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. * The device is mounted incorrectly. * When in sharp curves, like on-off ramps, intersections etc...; openpilot is designed to be limited in the amount of steering torque it can produce. * In the presence of restricted lanes or construction zones. * When driving on highly banked roads or in presence of strong cross-wind. * Extremely hot or cold temperatures. * Bright light (due to oncoming headlights, direct sunlight, etc.). * Driving on hills, narrow, or winding roads. The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times. Limitations of openpilot ACC and FCW ------ openpilot ACC and openpilot FCW are not systems that allow careless or inattentive driving. It is still necessary for the driver to pay close attention to the vehicle’s surroundings and to be ready to re-take control of the gas and the brake at all times. Many factors can impact the performance of openpilot ACC and openpilot FCW, causing them to be unable to function as intended. These include, but are not limited to: * Poor visibility (heavy rain, snow, fog, etc.) or weather conditions that may interfere with sensor operation. * The road facing camera or radar are obstructed, covered, or damaged by mud, ice, snow, etc. * Obstruction caused by applying excessive paint or adhesive products (such as wraps, stickers, rubber coating, etc.) onto the vehicle. * The device is mounted incorrectly. * Approaching a toll booth, a bridge or a large metal plate. * When driving on roads with pedestrians, cyclists, etc... * In presence of traffic signs or stop lights, which are not detected by openpilot at this time. * When the posted speed limit is below the user selected set speed. openpilot does not detect speed limits at this time. * In presence of vehicles in the same lane that are not moving. * When abrupt braking maneuvers are required. openpilot is designed to be limited in the amount of deceleration and acceleration that it can produce. * When surrounding vehicles perform close cut-ins from neighbor lanes. * Driving on hills, narrow, or winding roads. * Extremely hot or cold temperatures. * Bright light (due to oncoming headlights, direct sunlight, etc.). * Interference from other equipment that generates radar waves. The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. It is the driver's responsibility to be in control of the vehicle at all times. Limitations of openpilot DM ------ openpilot DM should not be considered an exact measurement of the alertness of the driver. Many factors can impact the performance of openpilot DM, causing it to be unable to function as intended. These include, but are not limited to: * Low light conditions, such as driving at night or in dark tunnels. * Bright light (due to oncoming headlights, direct sunlight, etc.). * The driver's face is partially or completely outside field of view of the driver facing camera. * The driver facing camera is obstructed, covered, or damaged. The list above does not represent an exhaustive list of situations that may interfere with proper operation of openpilot components. A driver should not rely on openpilot DM to assess their level of attention. User Data and comma Account ------ By default, openpilot uploads the driving data to our servers. You can also access your data by pairing with the comma connect app ([iOS](https://apps.apple.com/us/app/comma-connect/id1456551889), [Android](https://play.google.com/store/apps/details?id=ai.comma.connect&hl=en_US)). We use your data to train better models and improve openpilot for everyone. openpilot is open source software: the user is free to disable data collection if they wish to do so. openpilot logs the road facing camera, CAN, GPS, IMU, magnetometer, thermal sensors, crashes, and operating system logs. The driver facing camera is only logged if you explicitly opt-in in settings. The microphone is not recorded. By using openpilot, you agree to [our Privacy Policy](https://connect.comma.ai/privacy). You understand that use of this software or its related services will generate certain types of user data, which may be logged and stored at the sole discretion of comma. By accepting this agreement, you grant an irrevocable, perpetual, worldwide right to comma for the use of this data. Safety and Testing ---- * openpilot observes ISO26262 guidelines, see [SAFETY.md](SAFETY.md) for more details. * openpilot has software in the loop [tests](.github/workflows/selfdrive_tests.yaml) that run on every commit. * The safety model code lives in panda and is written in C, see [code rigor](https://github.com/commaai/panda#code-rigor) for more details. * panda has software in the loop [safety tests](https://github.com/commaai/panda/tree/master/tests/safety). * Internally, we have a hardware in the loop Jenkins test suite that builds and unit tests the various processes. * panda has additional hardware in the loop [tests](https://github.com/commaai/panda/blob/master/Jenkinsfile). * We run the latest openpilot in a testing closet containing 10 comma devices continuously replaying routes. Testing on PC ------ For simplified development and experimentation, openpilot can be run in the CARLA driving simulator, which allows you to develop openpilot without a car. The whole setup should only take a few minutes. Steps: 1) Start the CARLA server on first terminal ``` bash -c "$(curl https://raw.githubusercontent.com/commaai/openpilot/master/tools/sim/start_carla.sh)" ``` 2) Start openpilot on second terminal ``` bash -c "$(curl https://raw.githubusercontent.com/commaai/openpilot/master/tools/sim/start_openpilot_docker.sh)" ``` 3) Press 1 to engage openpilot See the full [README](tools/sim/README.md) You should also take a look at the tools directory in master: lots of tools you can use to replay driving data, test, and develop openpilot from your PC. Community and Contributing ------ openpilot is developed by [comma](https://comma.ai/) and by users like you. We welcome both pull requests and issues on [GitHub](http://github.com/commaai/openpilot). Bug fixes and new car ports are encouraged. You can add support for your car by following guides we have written for [Brand](https://blog.comma.ai/how-to-write-a-car-port-for-openpilot/) and [Model](https://blog.comma.ai/openpilot-port-guide-for-toyota-models/) ports. Generally, a car with adaptive cruise control and lane keep assist is a good candidate. [Join our Discord](https://discord.comma.ai) to discuss car ports: most car makes have a dedicated channel. Want to get paid to work on openpilot? [comma is hiring](https://comma.ai/jobs/). And [follow us on Twitter](https://twitter.com/comma_ai). Directory Structure ------ . ├── cereal # The messaging spec and libs used for all logs ├── common # Library like functionality we've developed here ├── installer/updater # Manages updates of NEOS ├── opendbc # Files showing how to interpret data from cars ├── panda # Code used to communicate on CAN ├── phonelibs # External libraries ├── pyextra # Extra python packages not shipped in NEOS └── selfdrive # Code needed to drive the car ├── assets # Fonts, images, and sounds for UI ├── athena # Allows communication with the app ├── boardd # Daemon to talk to the board ├── camerad # Driver to capture images from the camera sensors ├── car # Car specific code to read states and control actuators ├── common # Shared C/C++ code for the daemons ├── controls # Planning and controls ├── debug # Tools to help you debug and do car ports ├── locationd # Precise localization and vehicle parameter estimation ├── logcatd # Android logcat as a service ├── loggerd # Logger and uploader of car data ├── modeld # Driving and monitoring model runners ├── proclogd # Logs information from proc ├── sensord # IMU interface code ├── test # Unit tests, system tests, and a car simulator └── ui # The UI Licensing ------ openpilot is released under the MIT license. Some parts of the software are released under other licenses as specified. Any user of this software shall indemnify and hold harmless comma.ai, Inc. and its directors, officers, employees, agents, stockholders, affiliates, subcontractors and customers from and against all allegations, claims, actions, suits, demands, damages, liabilities, obligations, losses, settlements, judgments, costs and expenses (including without limitation attorneys’ fees and costs) which arise out of, relate to or result from any use of this software by user. **THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS. NO WARRANTY EXPRESSED OR IMPLIED.** --- [![openpilot tests](https://github.com/commaai/openpilot/workflows/openpilot%20tests/badge.svg?event=push)](https://github.com/commaai/openpilot/actions) [![Total alerts](https://img.shields.io/lgtm/alerts/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/alerts/) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:python) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/commaai/openpilot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/commaai/openpilot/context:cpp) [![codecov](https://codecov.io/gh/commaai/openpilot/branch/master/graph/badge.svg)](https://codecov.io/gh/commaai/openpilot) ================================================ FILE: README.md ================================================ Licensing ------ xnxpilot is released under the MIT license. Some parts of the software are released under other licenses as specified. Any user of this software shall indemnify and hold harmless Rick Lan, dragonpilot, comma.ai, Inc. and its directors, officers, employees, agents, stockholders, affiliates, subcontractors and customers from and against all allegations, claims, actions, suits, demands, damages, liabilities, obligations, losses, settlements, judgments, costs and expenses (including without limitation attorneys’ fees and costs) which arise out of, relate to or result from any use of this software by user. ***THIS IS ALPHA QUALITY SOFTWARE FOR RESEARCH PURPOSES ONLY. THIS IS NOT A PRODUCT. YOU ARE RESPONSIBLE FOR COMPLYING WITH LOCAL LAWS AND REGULATIONS. NO WARRANTY EXPRESSED OR IMPLIED.*** --- Table of Contents ------ * [What is xnxpilot?](#what-is-xnxpilot) * [Showcase](#showcase) * [Checklist](#checklist) * [Hardware requirement](#hardware-requirement) * [Software requirement](#software-requirement) * [Hardware assimbly](#hardware-assembly) * [Installation](#installation) * [Credits](#credits) * [Notes](#notes) --- What is xnxpilot? ------ xnxpilot (Xavier NX Pilot) is an open source driver assistance system based on [dragonpilot](http://github.com/dragonpilot-community/dragonpilot) and [openpilot](http://github.com/commaai/openpilot), running on a NVIDIA Jetson Xavier NX platform instead of a qualcomm 821 mobile phone. If you would like to run it with minimal changes to openpilot, please see the example in "doc" branch, based on openpilot 0.8.4 --- Showcase ------ Simulation:
On road:
Running on dragonpilot 0.8:
--- Checklist ------ - [x] Create build scripts - [x] Add patch samples / tutorials. - [x] On road lateral control tests. - [ ] On road longitudinal control tests. - [ ] Add IMU sensor to improve GPS accuracy. - [ ] Tuning. (WIP) --- Hardware Requirement ------ - [Nvidia Jetson Xavier NX](https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-xavier-nx/) - 32GB+ microsd card (UHS 3 speed minimum) - [Arducam IMX 477](https://www.amazon.com/gp/product/B08F743RGG/) - [comma.ai Black Panda](https://comma.ai/shop/products/panda) (or white/grey panda but require more code customization.) - (Optional) [comma.ai Windshield mount](https://github.com/commaai/neo/tree/master/case/eon) - (Optional) [GoPro flat adhesive mount](https://www.amazon.com/AFAITH-Adhesive-Mounts-GoPro-Camera/dp/B00BUD6LPY/) - (Optional) [Waveshare 4.3" IPS Touchscreen](https://www.amazon.com.au/gp/product/B0852NW9FM/) - (Optional) [DCDZ Jetson Xavier NX Carrier Board NCB00](https://item.taobao.com/item.htm?ft=t&id=613984388047) - (Optional) [CSI to HDMI Extension Module](https://www.amazon.com/gp/product/B06XDNBM63/) - (Optional) Targus notebook charger for car. --- Software Requirement ------ - [NVIDIA JetPack 4.6](https://developer.nvidia.com/jetpack-sdk-46) --- Hardware assembly ------ It is important to know that your camera needs **firmly attached** onto your windshield, any small movement to the camera while driving may result dangerous steering/acceleration. I highly recommended to 3D print those commaai windshield mount (use with gopro mount) and use it to mount your camera, 24 degree one will do the job. --- Installation ------ 1) [Install ubuntu 18.04 / Jetpack 4.6 on to sdcard](https://developer.nvidia.com/embedded/learn/get-started-jetson-xavier-nx-devkit) 2) Insert your sd card to your jetson, have camera connect to CAM0, boot up, use the following configuration (installer will use those values to set up the device): - username: **comma** - password: **comma** - hostname: **tici** - mode: **20W 6 cores** 3) Once installation finished, **SSH into the device** and continue the rest of the processes. 4) run: - `sudo /opt/nvidia/jetson-io/jetson-io.py` - select `Configure Jetson Nano CSI Connector` > `Configure for compatible hardware` > `Camera IMX477 Dual` > `Save pin changes` > `Save and exit without rebooting`. 5) clone this repo to your home directory (e.g. `cd ~/ && git clone https://github.com/efinilan/xnxpilot.git openpilot -b 0.8.9 --single-branch`) 6) run `cd ~/openpilot/jetson/ && sudo bash env_installer.py` 7) Take a rest, this will take around **1.5 hrs** to config your system and another **10 mins** to compile dragonpilot, depends on your internet connection. 8) Congradulations, you have dragonpilot running on your jetson. --- Credits ------ - [Commaai Openpilot](https://github.com/commaai/openpiplot) - [dragonpilot community](https://github.com/dragonpilot-community/dragonpilot/) - [RetroPilot Community](https://discord.gg/fGUuASVZKg) - [Unofficial OpenPilot Community](https://discord.gg/Mrf8FwfWSr) --- Notes ------ #### set_core_affinity #### Jetson Xavier NX has 6 cores running at 1.9 GHz, here is what I've defined: 0 = camerad 1 = modeld 2 = boardd 3 = controlsd 4 = plannerd / radard This will spread processes other CPU cores. ================================================ FILE: RELEASES.md ================================================ Version 0.8.9 (2021-09-14) ======================== * Improved fan control on comma three * AGNOS 1.5: improved stability * Honda e 2020 support Version 0.8.8 (2021-08-27) ======================== * New driving model with improved laneless performance * Trained on 5000+ hours of diverse driving data from 3000+ users in 40+ countries * Better anti-cheating methods during simulator training ensure the model hugs less when in laneless mode * All new desire ground-truthing stack makes the model better at lane changes * New driver monitoring model: improved performance on comma three * NEOS 18 for comma two: update packages * AGNOS 1.3 for comma three: fix display init at high temperatures * Improved auto-exposure on comma three * Improved longitudinal control on Honda Nidec cars * Hyundai Kona Hybrid 2020 support thanks to haram-KONA! * Hyundai Sonata Hybrid 2021 support thanks to Matt-Wash-Burn! * Kia Niro Hybrid 2021 support thanks to tetious! Version 0.8.7 (2021-07-31) ======================== * comma three support! * Navigation alpha for the comma three! * Volkswagen T-Cross 2021 support thanks to jyoung8607! Version 0.8.6 (2021-07-21) ======================== * Revamp lateral and longitudinal planners * Refactor planner output API to be more readable and verbose * Planners now output desired trajectories for speed, acceleration, curvature, and curvature rate * Use MPC for longitudinal planning when no lead car is present, makes accel and decel smoother * Remove "CHECK DRIVER FACE VISIBILITY" warning * Fixed cruise fault on some TSS2.5 Camrys and international Toyotas * Hyundai Elantra Hybrid 2021 support thanks to tecandrew! * Hyundai Ioniq PHEV 2020 support thanks to YawWashout! * Kia Niro Hybrid 2019 support thanks to jyoung8607! * Škoda Octavia RS 2016 support thanks to jyoung8607! * Toyota Alphard 2020 support thanks to belm0! * Volkswagen Golf SportWagen 2015 support thanks to jona96! * Volkswagen Touran 2017 support thanks to jyoung8607! Version 0.8.5 (2021-06-11) ======================== * NEOS update: improved reliability and stability with better voltage regulator configuration * Smart model-based Forward Collision Warning * CAN-based fingerprinting moved behind community features toggle * Improved longitudinal control on Toyotas with a comma pedal * Improved auto-brightness using road-facing camera * Added "Software" settings page with updater controls * Audi Q2 2018 support thanks to jyoung8607! * Hyundai Elantra 2021 support thanks to CruiseBrantley! * Lexus UX Hybrid 2019-2020 support thanks to brianhaugen2! * Toyota Avalon Hybrid 2019 support thanks to jbates9011! * SEAT Leon 2017 & 2020 support thanks to jyoung8607! * Škoda Octavia 2015 & 2019 support thanks to jyoung8607! Version 0.8.4 (2021-05-17) ======================== * Delay controls start until system is ready * Fuzzy car identification, enabled with Community Features toggle * Localizer optimized for increased precision and less CPU usage * Retuned lateral control to be more aggressive when model is confident * Toyota Mirai 2021 support * Lexus NX 300 2020 support thanks to goesreallyfast! * Volkswagen Atlas 2018-19 support thanks to jyoung8607! Version 0.8.3 (2021-04-01) ======================== * New model * Trained on new diverse dataset from 2000+ users from 30+ countries * Trained with improved segnet from the comma-pencil community project * 🥬 Dramatically improved end-to-end lateral performance 🥬 * Toggle added to disable the use of lanelines * NEOS update: update packages and support for new UI * New offroad UI based on Qt * Default SSH key only used for setup * Kia Ceed 2019 support thanks to ZanZaD13! * Kia Seltos 2021 support thanks to speedking456! * Added support for many Volkswagen and Škoda models thanks to jyoung8607! Version 0.8.2 (2021-02-26) ======================== * Use model points directly in MPC (no more polyfits), making lateral planning more accurate * Use model heading prediction for smoother lateral control * Smarter actuator delay compensation * Improve qcamera resolution for improved video in explorer and connect * Adjust maximum engagement speed to better fit the model's training distribution * New driver monitoring model trained with 3x more diverse data * Improved face detection with masks * More predictable DM alerts when visibility is bad * Rewritten video streaming between openpilot processes * Improved longitudinal tuning on TSS2 Corolla and Rav4 thanks to briskspirit! * Audi A3 2015 and 2017 support thanks to keeleysam! * Nissan Altima 2020 support thanks to avolmensky! * Lexus ES Hybrid 2018 support thanks to TheInventorMan! * Toyota Camry Hybrid 2021 support thanks to alancyau! Version 0.8.1 (2020-12-21) ======================== * Original EON is deprecated, upgrade to comma two * Better model performance in heavy rain * Better lane positioning in turns * Fixed bug where model would cut turns on empty roads at night * Fixed issue where some Toyotas would not completely stop thanks to briskspirit! * Toyota Camry 2021 with TSS2.5 support * Hyundai Ioniq Electric 2020 support thanks to baldwalker! Version 0.8.0 (2020-11-30) ======================== * New driving model: fully 3D and improved cut-in detection * UI draws 2 road edges, 4 lanelines and paths in 3D * Major fixes to cut-in detection for openpilot longitudinal * Grey panda is no longer supported, upgrade to comma two or black panda * Lexus NX 2018 support thanks to matt12eagles! * Kia Niro EV 2020 support thanks to nickn17! * Toyota Prius 2021 support thanks to rav4kumar! * Improved lane positioning with uncertain lanelines, wide lanes and exits * Improved lateral control for Prius and Subaru Version 0.7.10 (2020-10-29) ======================== * Grey panda is deprecated, upgrade to comma two or black panda * NEOS update: update to Python 3.8.2 and lower CPU frequency * Improved thermals due to reduced CPU frequency * Update SNPE to 1.41.0 * Reduced offroad power consumption * Various system stability improvements * Acura RDX 2020 support thanks to csouers! Version 0.7.9 (2020-10-09) ======================== * Improved car battery power management * Improved updater robustness * Improved realtime performance * Reduced UI and modeld lags * Increased torque on 2020 Hyundai Sonata and Palisade Version 0.7.8 (2020-08-19) ======================== * New driver monitoring model: improved face detection and better compatibility with sunglasses * Download NEOS operating system updates in the background * Improved updater reliability and responsiveness * Hyundai Kona 2020, Veloster 2019, and Genesis G70 2018 support thanks to xps-genesis! Version 0.7.7 (2020-07-20) ======================== * White panda is no longer supported, upgrade to comma two or black panda * Improved vehicle model estimation using high precision localizer * Improved thermal management on comma two * Improved autofocus for road-facing camera * Improved noise performance for driver-facing camera * Block lane change start using blindspot monitor on select Toyota, Hyundai, and Subaru * Fix GM ignition detection * Code cleanup and smaller release sizes * Hyundai Sonata 2020 promoted to officially supported car * Hyundai Ioniq Electric Limited 2019 and Ioniq SE 2020 support thanks to baldwalker! * Subaru Forester 2019 and Ascent 2019 support thanks to martinl! Version 0.7.6.1 (2020-06-16) ======================== * Hotfix: update kernel on some comma twos (orders #8570-#8680) Version 0.7.6 (2020-06-05) ======================== * White panda is deprecated, upgrade to comma two or black panda * 2017 Nissan X-Trail, 2018-19 Leaf and 2019 Rogue support thanks to avolmensky! * 2017 Mazda CX-5 support in dashcam mode thanks to Jafaral! * Huge CPU savings in modeld by using thneed! * Lots of code cleanup and refactors Version 0.7.5 (2020-05-13) ======================== * Right-Hand Drive support for both driving and driver monitoring! * New driving model: improved at sharp turns and lead speed estimation * New driver monitoring model: overall improvement on comma two * Driver camera preview in settings to improve mounting position * Added support for many Hyundai, Kia, Genesis models thanks to xx979xx! * Improved lateral tuning for 2020 Toyota Rav 4 (hybrid) Version 0.7.4 (2020-03-20) ======================== * New driving model: improved lane changes and lead car detection * Improved driver monitoring model: improve eye detection * Improved calibration stability * Improved lateral control on some 2019 and 2020 Toyota Prius * Improved lateral control on VW Golf: 20% more steering torque * Fixed bug where some 2017 and 2018 Toyota C-HR would use the wrong steering angle sensor * Support for Honda Insight thanks to theantihero! * Code cleanup in car abstraction layers and ui Version 0.7.3 (2020-02-21) ======================== * Support for 2020 Highlander thanks to che220! * Support for 2018 Lexus NX 300h thanks to kengggg! * Speed up ECU firmware query * Fix bug where manager would sometimes hang after shutting down the car Version 0.7.2 (2020-02-07) ======================== * ECU firmware version based fingerprinting for Honda & Toyota * New driving model: improved path prediction during turns and lane changes and better lead speed tracking * Improve driver monitoring under extreme lighting and add low accuracy alert * Support for 2019 Rav4 Hybrid thanks to illumiN8i! * Support for 2016, 2017 and 2020 Lexus RX thanks to illumiN8i! * Support for 2020 Chrysler Pacifica Hybrid thanks to adhintz! Version 0.7.1 (2020-01-20) ======================== * comma two support! * Lane Change Assist above 45 mph! * Replace zmq with custom messaging library, msgq! * Supercombo model: calibration and driving models are combined for better lead estimate * More robust updater thanks to jyoung8607! Requires NEOS update * Improve low speed ACC tuning Version 0.7 (2019-12-13) ======================== * Move to SCons build system! * Add Lane Departure Warning (LDW) for all supported vehicles! * NEOS update: increase wifi speed thanks to jyoung8607! * Adaptive driver monitoring based on scene * New driving model trained end-to-end: improve lane lines and lead detection * Smarter torque limit alerts for all cars * Improve GM longitudinal control: proper computations for 15Hz radar * Move GM port, Toyota with DSU removed, comma pedal in community features; toggle switch required * Remove upload over cellular toggle: only upload qlog and qcamera files if not on wifi * Refactor Panda code towards ISO26262 and SIL2 compliancy * Forward stock FCW for Honda Nidec * Volkswagen port now standard: comma Harness intercepts stock camera Version 0.6.6 (2019-11-05) ======================== * Volkswagen support thanks to jyoung8607! * Toyota Corolla Hybrid with TSS 2.0 support thanks to u8511049! * Lexus ES with TSS 2.0 support thanks to energee! * Fix GM ignition detection and lock safety mode not required anymore * Log panda firmware and dongle ID thanks to martinl! * New driving model: improve path prediction and lead detection * New driver monitoring model, 4x smaller and running on DSP * Display an alert and don't start openpilot if panda has wrong firmware * Fix bug preventing EON from terminating processes after a drive * Remove support for Toyota giraffe without the 120Ohm resistor Version 0.6.5 (2019-10-07) ======================== * NEOS update: upgrade to Python3 and new installer! * comma Harness support! * New driving model: improve path prediction * New driver monitoring model: more accurate face and eye detection * Redesign offroad screen to display updates and alerts * Increase maximum allowed acceleration * Prevent car 12V battery drain by cutting off EON charge after 3 days of no drive * Lexus CT Hybrid support thanks to thomaspich! * Louder chime for critical alerts * Add toggle to switch to dashcam mode * Fix "invalid vehicle params" error on DSU-less Toyota Version 0.6.4 (2019-09-08) ======================== * Forward stock AEB for Honda Nidec * Improve lane centering on banked roads * Always-on forward collision warning * Always-on driver monitoring, except for right hand drive countries * Driver monitoring learns the user's normal driving position * Honda Fit support thanks to energee! * Lexus IS support Version 0.6.3 (2019-08-12) ======================== * Alert sounds from EON: requires NEOS update * Improve driver monitoring: eye tracking and improved awareness logic * Improve path prediction with new driving model * Improve lane positioning with wide lanes and exits * Improve lateral control on RAV4 * Slow down for turns using model * Open sourced regression test to verify outputs against reference logs * Open sourced regression test to sanity check all car models Version 0.6.2 (2019-07-29) ======================== * New driving model! * Improve lane tracking with double lines * Strongly improve stationary vehicle detection * Strongly reduce cases of braking due to false leads * Better lead tracking around turns * Improve cut-in prediction by using neural network * Improve lateral control on Toyota Camry and C-HR thanks to zorrobyte! * Fix unintended openpilot disengagements on Jeep thanks to adhintz! * Fix delayed transition to offroad when car is turned off Version 0.6.1 (2019-07-21) ======================== * Remote SSH with comma prime and [ssh.comma.ai](https://ssh.comma.ai) * Panda code Misra-c2012 compliance, tested against cppcheck coverage * Lockout openpilot after 3 terminal alerts for driver distracted or unresponsive * Toyota Sienna support thanks to wocsor! Version 0.6 (2019-07-01) ======================== * New model, with double the pixels and ten times the temporal context! * Car should not take exits when in the right lane * openpilot uses only ~65% of the CPU (down from 75%) * Routes visible in connect/explorer after only 0.2% is uploaded (qlogs) * loggerd and sensord are open source, every line of openpilot is now open * Panda safety code is MISRA compliant and ships with a signed version on release2 * New NEOS is 500MB smaller and has a reproducible usr/pipenv * Lexus ES Hybrid support thanks to wocsor! * Improve tuning for supported Toyota with TSS 2.0 * Various other stability improvements Version 0.5.13 (2019-05-31) ========================== * Reduce panda power consumption by 70%, down to 80mW, when car is off (not for GM) * Reduce EON power consumption by 40%, down to 1100mW, when car is off * Reduce CPU utilization by 20% and improve stability * Temporarily remove mapd functionalities to improve stability * Add openpilot record-only mode for unsupported cars * Synchronize controlsd to boardd to reduce latency * Remove panda support for Subaru giraffe Version 0.5.12 (2019-05-16) ========================== * Improve lateral control for the Prius and Prius Prime * Compress logs before writing to disk * Remove old driving data when storage reaches 90% full * Fix small offset in following distance * Various small CPU optimizations * Improve offroad power consumption: require NEOS Update * Add default speed limits for Estonia thanks to martinl! * Subaru Crosstrek support thanks to martinl! * Toyota Avalon support thanks to njbrown09! * Toyota Rav4 with TSS 2.0 support thanks to wocsor! * Toyota Corolla with TSS 2.0 support thanks to wocsor! Version 0.5.11 (2019-04-17) ======================== * Add support for Subaru * Reduce panda power consumption by 60% when car is off * Fix controlsd lag every 6 minutes. This would sometimes cause disengagements * Fix bug in controls with new angle-offset learner in MPC * Reduce cpu consumption of ubloxd by rewriting it in C++ * Improve driver monitoring model and face detection * Improve performance of visiond and ui * Honda Passport 2019 support * Lexus RX Hybrid 2019 support thanks to schomems! * Improve road selection heuristic in mapd * Add Lane Departure Warning to dashboard for Toyota thanks to arne182 Version 0.5.10 (2019-03-19) ======================== * Self-tuning vehicle parameters: steering offset, tire stiffness and steering ratio * Improve longitudinal control at low speed when lead vehicle harshly decelerates * Fix panda bug going unexpectedly in DCP mode when EON is connected * Reduce white panda power consumption by 500mW when EON is disconnected by turning off WIFI * New Driver Monitoring Model * Support QR codes for login using comma connect * Refactor comma pedal FW and use CRC-8 checksum algorithm for safety. Reflashing pedal is required. Please see `#hw-pedal` on [discord](discord.comma.ai) for assistance updating comma pedal. * Additional speed limit rules for Germany thanks to arne182 * Allow negative speed limit offsets Version 0.5.9 (2019-02-10) ======================== * Improve calibration using a dedicated neural network * Abstract planner in its own process to remove lags in controls process * Improve speed limits with country/region defaults by road type * Reduce mapd data usage with gzip thanks to eFiniLan * Zip log files in the background to reduce disk usage * Kia Optima support thanks to emmertex! * Buick Regal 2018 support thanks to HOYS! * Comma pedal support for Toyota thanks to wocsor! Note: tuning needed and not maintained by comma * Chrysler Pacifica and Jeep Grand Cherokee support thanks to adhintz! Version 0.5.8 (2019-01-17) ======================== * Open sourced visiond * Auto-slowdown for upcoming turns * Chrysler/Jeep/Fiat support thanks to adhintz! * Honda Civic 2019 support thanks to csouers! * Improve use of car display in Toyota thanks to arne182! * No data upload when connected to Android or iOS hotspots and "Enable Upload Over Cellular" setting is off * EON stops charging when 12V battery drops below 11.8V Version 0.5.7 (2018-12-06) ======================== * Speed limit from OpenStreetMap added to UI * Highlight speed limit when speed exceeds road speed limit plus a delta * Option to limit openpilot max speed to road speed limit plus a delta * Cadillac ATS support thanks to vntarasov! * GMC Acadia support thanks to CryptoKylan! * Decrease GPU power consumption * NEOSv8 autoupdate Version 0.5.6 (2018-11-16) ======================== * Refresh settings layout and add feature descriptions * In Honda, keep stock camera on for logging and extra stock features; new openpilot giraffe setting is 0111! * In Toyota, option to keep stock camera on for logging and extra stock features (e.g. AHB); 120Ohm resistor required on giraffe. * Improve camera calibration stability * More tuning to Honda positive accelerations * Reduce brake pump use on Hondas * Chevrolet Malibu support thanks to tylergets! * Holden Astra support thanks to AlexHill! Version 0.5.5 (2018-10-20) ======================== * Increase allowed Honda positive accelerations * Fix sporadic unexpected braking when passing semi-trucks in Toyota * Fix gear reading bug in Hyundai Elantra thanks to emmertex! Version 0.5.4 (2018-09-25) ======================== * New Driving Model * New Driver Monitoring Model * Improve longitudinal mpc in mid-low speed braking * Honda Accord hybrid support thanks to energee! * Ship mpc binaries and sensibly reduce build time * Calibration more stable * More Hyundai and Kia cars supported thanks to emmertex! * Various GM Volt improvements thanks to vntarasov! Version 0.5.3 (2018-09-03) ======================== * Hyundai Santa Fe support! * Honda Pilot 2019 support thanks to energee! * Toyota Highlander support thanks to daehahn! * Improve steering tuning for Honda Odyssey Version 0.5.2 (2018-08-16) ======================== * New calibration: more accurate, a lot faster, open source! * Enable orbd * Add little endian support to CAN packer * Fix fingerprint for Honda Accord 1.5T * Improve driver monitoring model Version 0.5.1 (2018-08-01) ======================== * Fix radar error on Civic sedan 2018 * Improve thermal management logic * Alpha Toyota C-HR and Camry support! * Auto-switch Driver Monitoring to 3 min counter when inaccurate Version 0.5 (2018-07-11) ======================== * Driver Monitoring (beta) option in settings! * Make visiond, loggerd and UI use less resources * 60 FPS UI * Better car parameters for most cars * New sidebar with stats * Remove Waze and Spotify to free up system resources * Remove rear view mirror option * Calibration 3x faster Version 0.4.7.2 (2018-06-25) ========================== * Fix loggerd lag issue * No longer prompt for updates * Mitigate right lane hugging for properly mounted EON (procedure on wiki) Version 0.4.7.1 (2018-06-18) ========================== * Fix Acura ILX steer faults * Fix bug in mock car Version 0.4.7 (2018-06-15) ========================== * New model! * GM Volt (and CT6 lateral) support! * Honda Bosch lateral support! * Improve actuator modeling to reduce lateral wobble * Minor refactor of car abstraction layer * Hack around orbd startup issue Version 0.4.6 (2018-05-18) ========================== * NEOSv6 required! Will autoupdate * Stability improvements * Fix all memory leaks * Update C++ compiler to clang6 * Improve front camera exposure Version 0.4.5 (2018-04-27) ========================== * Release notes added to the update popup * Improve auto shut-off logic to disallow empty battery * Added onboarding instructions * Include orbd, the first piece of new calibration algorithm * Show remaining upload data instead of file numbers * Fix UI bugs * Fix memory leaks Version 0.4.4 (2018-04-13) ========================== * EON are flipped! Flip your EON's mount! * Alpha Honda Ridgeline support thanks to energee! * Support optional front camera recording * Upload over cellular toggle now applies to all files, not just video * Increase acceleration when closing lead gap * User now prompted for future updates * NEO no longer supported :( Version 0.4.3.2 (2018-03-29) ============================ * Improve autofocus * Improve driving when only one lane line is detected * Added fingerprint for Toyota Corolla LE * Fixed Toyota Corolla steer error * Full-screen driving UI * Improved path drawing Version 0.4.3.1 (2018-03-19) ============================ * Improve autofocus * Add check for MPC solution error * Make first distracted warning visual only Version 0.4.3 (2018-03-13) ========================== * Add HDR and autofocus * Update UI aesthetic * Grey panda works in Waze * Add alpha support for 2017 Honda Pilot * Slight increase in acceleration response from stop * Switch CAN sending to use CANPacker * Fix pulsing acceleration regression on Honda * Fix openpilot bugs when stock system is in use * Change starting logic for chffrplus to use battery voltage Version 0.4.2 (2018-02-05) ========================== * Add alpha support for 2017 Lexus RX Hybrid * Add alpha support for 2018 ACURA RDX * Updated fingerprint to include Toyota Rav4 SE and Prius Prime * Bugfixes for Acura ILX and Honda Odyssey Version 0.4.1 (2018-01-30) ========================== * Add alpha support for 2017 Toyota Corolla * Add alpha support for 2018 Honda Odyssey with Honda Sensing * Add alpha support for Grey Panda * Refactored car abstraction layer to make car ports easier * Increased steering torque limit on Honda CR-V by 30% Version 0.4.0.2 (2018-01-18) ========================== * Add focus adjustment slider * Minor bugfixes Version 0.4.0.1 (2017-12-21) ========================== * New UI to match chffrplus * Improved lateral control tuning to fix oscillations on Civic * Add alpha support for 2017 Toyota Rav4 Hybrid * Reduced CPU usage * Removed unnecessary utilization of fan at max speed * Minor bug fixes Version 0.3.9 (2017-11-21) ========================== * Add alpha support for 2017 Toyota Prius * Improved longitudinal control using model predictive control * Enable Forward Collision Warning * Acura ILX now maintains openpilot engaged at standstill when brakes are applied Version 0.3.8.2 (2017-10-30) ========================== * Add alpha support for 2017 Toyota RAV4 * Smoother lateral control * Stay silent if stock system is connected through giraffe * Minor bug fixes Version 0.3.7 (2017-09-30) ========================== * Improved lateral control using model predictive control * Improved lane centering * Improved GPS * Reduced tendency of path deviation near right side exits * Enable engagement while the accelerator pedal is pressed * Enable engagement while the brake pedal is pressed, when stationary and with lead vehicle within 5m * Disable engagement when park brake or brake hold are active * Fixed sporadic longitudinal pulsing in Civic * Cleanups to vehicle interface Version 0.3.6.1 (2017-08-15) ============================ * Mitigate low speed steering oscillations on some vehicles * Include board steering check for CR-V Version 0.3.6 (2017-08-08) ========================== * Fix alpha CR-V support * Improved GPS * Fix display of target speed not always matching HUD * Increased acceleration after stop * Mitigated some vehicles driving too close to the right line Version 0.3.5 (2017-07-30) ========================== * Fix bug where new devices would not begin calibration * Minor robustness improvements Version 0.3.4 (2017-07-28) ========================== * Improved model trained on more data * Much improved controls tuning * Performance improvements * Bugfixes and improvements to calibration * Driving log can play back video * Acura only: system now stays engaged below 25mph as long as brakes are applied Version 0.3.3 (2017-06-28) =========================== * Improved model trained on more data * Alpha CR-V support thanks to energee and johnnwvs! * Using the opendbc project for DBC files * Minor performance improvements * UI update thanks to pjlao307 * Power off button * 6% more torque on the Civic Version 0.3.2 (2017-05-22) =========================== * Minor stability bugfixes * Added metrics and rear view mirror disable to settings * Update model with more crowdsourced data Version 0.3.1 (2017-05-17) =========================== * visiond stability bugfix * Add logging for angle and flashing Version 0.3.0 (2017-05-12) =========================== * Add CarParams struct to improve the abstraction layer * Refactor visiond IPC to support multiple clients * Add raw GPS and beginning support for navigation * Improve model in visiond using crowdsourced data * Add improved system logging to diagnose instability * Rewrite baseui in React Native * Moved calibration to the cloud Version 0.2.9 (2017-03-01) =========================== * Retain compatibility with NEOS v1 Version 0.2.8 (2017-02-27) =========================== * Fix bug where frames were being dropped in minute 71 Version 0.2.7 (2017-02-08) =========================== * Better performance and pictures at night * Fix ptr alignment issue in boardd * Fix brake error light, fix crash if too cold Version 0.2.6 (2017-01-31) =========================== * Fix bug in visiond model execution Version 0.2.5 (2017-01-30) =========================== * Fix race condition in manager Version 0.2.4 (2017-01-27) =========================== * OnePlus 3T support * Enable installation as NEOS app * Various minor bugfixes Version 0.2.3 (2017-01-11) =========================== * Reduce space usage by 80% * Add better logging * Add Travis CI Version 0.2.2 (2017-01-10) =========================== * Board triggers started signal on CAN messages * Improved autoexposure * Handle out of space, improve upload status Version 0.2.1 (2016-12-14) =========================== * Performance improvements, removal of more numpy * Fix boardd process priority * Make counter timer reset on use of steering wheel Version 0.2 (2016-12-12) ========================= * Car/Radar abstraction layers have shipped, see cereal/car.capnp * controlsd has been refactored * Shipped plant model and testing maneuvers * visiond exits more gracefully now * Hardware encoder in visiond should always init * ui now turns off the screen after 30 seconds * Switch to openpilot release branch for future releases * Added preliminary Docker container to run tests on PC Version 0.1 (2016-11-29) ========================= * Initial release of openpilot * Adaptive cruise control is working * Lane keep assist is working * Support for Acura ILX 2016 with AcuraWatch Plus * Support for Honda Civic 2016 Touring Edition ================================================ FILE: SAFETY.md ================================================ openpilot Safety ====== openpilot is an Adaptive Cruise Control (ACC) and Automated Lane Centering (ALC) system. Like other ACC and ALC systems, openpilot is a failsafe passive system and it requires the driver to be alert and to pay attention at all times. In order to enforce driver alertness, openpilot includes a driver monitoring feature that alerts the driver when distracted. However, even with an attentive driver, we must make further efforts for the system to be safe. We repeat, **driver alertness is necessary, but not sufficient, for openpilot to be used safely** and openpilot is provided with no warranty of fitness for any purpose. openpilot is developed in good faith to be compliant with FMVSS requirements and to follow industry standards of safety for Level 2 Driver Assistance Systems. In particular, we observe ISO26262 guidelines, including those from [pertinent documents](https://www.nhtsa.gov/sites/nhtsa.dot.gov/files/documents/13498a_812_573_alcsystemreport.pdf) released by NHTSA. In addition, we impose strict coding guidelines (like [MISRA C : 2012](https://www.misra.org.uk/what-is-misra/)) on parts of openpilot that are safety relevant. We also perform software-in-the-loop, hardware-in-the-loop and in-vehicle tests before each software release. Following Hazard and Risk Analysis and FMEA, at a very high level, we have designed openpilot ensuring two main safety requirements. 1. The driver must always be capable to immediately retake manual control of the vehicle, by stepping on either pedal or by pressing the cancel button. 2. The vehicle must not alter its trajectory too quickly for the driver to safely react. This means that while the system is engaged, the actuators are constrained to operate within reasonable limits. For additional safety implementation details, refer to [panda safety model](https://github.com/commaai/panda#safety-model). For vehicle specific implementation of the safety concept, refer to [panda/board/safety/](https://github.com/commaai/panda/tree/master/board/safety). **Extra note**: comma.ai strongly discourages the use of openpilot forks with safety code either missing or not fully meeting the above requirements. ================================================ FILE: SConstruct ================================================ import os import shutil import subprocess import sys import sysconfig import platform import numpy as np TICI = os.path.isfile('/TICI') JETSON = os.path.isfile('/JETSON') Decider('MD5-timestamp') AddOption('--test', action='store_true', help='build test files') AddOption('--setup', action='store_true', help='build setup and installer files') AddOption('--kaitai', action='store_true', help='Regenerate kaitai struct parsers') AddOption('--asan', action='store_true', help='turn on ASAN') AddOption('--ubsan', action='store_true', help='turn on UBSan') AddOption('--clazy', action='store_true', help='build with clazy') AddOption('--compile_db', action='store_true', help='build clang compilation database') AddOption('--mpc-generate', action='store_true', help='regenerates the mpc sources') AddOption('--snpe', action='store_true', help='use SNPE on PC') AddOption('--external-sconscript', action='store', metavar='FILE', dest='external_sconscript', help='add an external SConscript to the build') AddOption('--no-thneed', action='store_true', dest='no_thneed', help='avoid using thneed') real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip() if platform.system() == "Darwin": arch = "Darwin" if arch == "aarch64" and TICI: arch = "larch64" USE_WEBCAM = os.getenv("USE_WEBCAM") is not None USE_MIPI = os.getenv("USE_MIPI") is not None if arch == "aarch64" and JETSON: arch = "jarch64" lenv = { "PATH": os.environ['PATH'], } if arch == "aarch64" or arch == "larch64": lenv["LD_LIBRARY_PATH"] = '/data/data/com.termux/files/usr/lib' if arch == "aarch64": # android lenv["ANDROID_DATA"] = os.environ['ANDROID_DATA'] lenv["ANDROID_ROOT"] = os.environ['ANDROID_ROOT'] cpppath = [ "#phonelibs/opencl/include", ] libpath = [ "/usr/local/lib", "/usr/lib", "/system/vendor/lib64", "/system/comma/usr/lib", "#phonelibs/nanovg", ] if arch == "larch64": libpath += [ "#phonelibs/snpe/larch64", "#phonelibs/libyuv/larch64/lib", "/usr/lib/aarch64-linux-gnu" ] cpppath += [ "#selfdrive/camerad/include", ] cflags = ["-DQCOM2", "-mcpu=cortex-a57"] cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"] rpath = ["/usr/local/lib"] else: libpath += [ "#phonelibs/snpe/aarch64", "#phonelibs/libyuv/lib", "/system/vendor/lib64", "#phonelibs/mapbox-gl-native-qt/aarch64", ] cflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] cxxflags = ["-DQCOM", "-D_USING_LIBCXX", "-mcpu=cortex-a57"] rpath = [] else: cflags = [] cxxflags = [] cpppath = [] rpath = [] if arch == "jarch64": libpath = [ "#phonelibs/libyuv/larch64/lib", "/usr/lib/aarch64-linux-gnu", "#selfdrive/common", "/usr/lib", "/usr/local/lib", "/usr/local/pocl/lib", "#phonelibs/mapbox-gl-native-qt/jarch64", ] cflags = ["-DXNX", "-march=armv8.2-a"] cxxflags = ["-DXNX", "-march=armv8.2-a"] rpath += ["/usr/local/lib"] elif arch == "Darwin": yuv_dir = "mac" if real_arch != "arm64" else "mac_arm64" libpath = [ f"#phonelibs/libyuv/{yuv_dir}/lib", "/usr/local/lib", "/opt/homebrew/lib", "/usr/local/opt/openssl/lib", "/opt/homebrew/opt/openssl/lib", "/System/Library/Frameworks/OpenGL.framework/Libraries", ] cflags += ["-DGL_SILENCE_DEPRECATION"] cxxflags += ["-DGL_SILENCE_DEPRECATION"] cpppath += [ "/opt/homebrew/include", "/usr/local/opt/openssl/include", "/opt/homebrew/opt/openssl/include" ] else: libpath = [ "#phonelibs/snpe/x86_64-linux-clang", "#phonelibs/libyuv/x64/lib", "#phonelibs/mapbox-gl-native-qt/x86_64", "#cereal", "#selfdrive/common", "/usr/lib", "/usr/local/lib", ] if arch != "jarch64": rpath += ["phonelibs/snpe/x86_64-linux-clang"] rpath += [ "cereal", "selfdrive/common" ] # allows shared libraries to work globally rpath = [os.path.join(os.getcwd(), x) for x in rpath] if GetOption('asan'): ccflags = ["-fsanitize=address", "-fno-omit-frame-pointer"] ldflags = ["-fsanitize=address"] elif GetOption('ubsan'): ccflags = ["-fsanitize=undefined"] ldflags = ["-fsanitize=undefined"] else: ccflags = [] ldflags = [] # no --as-needed on mac linker if arch != "Darwin": ldflags += ["-Wl,--as-needed"] # Enable swaglog include in submodules cflags += ["-DSWAGLOG"] cxxflags += ["-DSWAGLOG"] # change pythonpath to this lenv["PYTHONPATH"] = Dir("#").path env = Environment( ENV=lenv, CCFLAGS=[ "-g", "-fPIC", "-O2", "-Wunused", "-Werror", "-Wno-unknown-warning-option", "-Wno-deprecated-register", "-Wno-register", "-Wno-inconsistent-missing-override", "-Wno-c99-designator", "-Wno-reorder-init-list", ] + cflags + ccflags, CPPPATH=cpppath + [ "#", "#phonelibs/catch2/include", "#phonelibs/bzip2", "#phonelibs/libyuv/include", "#phonelibs/openmax/include", "#phonelibs/json11", "#phonelibs/curl/include", "#phonelibs/libgralloc/include", "#phonelibs/android_frameworks_native/include", "#phonelibs/android_hardware_libhardware/include", "#phonelibs/android_system_core/include", "#phonelibs/linux/include", "#phonelibs/snpe/include", "#phonelibs/mapbox-gl-native-qt/include", "#phonelibs/nanovg", "#phonelibs/qrcode", "#phonelibs", "#cereal", "#opendbc/can", ], CC='clang', CXX='clang++', LINKFLAGS=ldflags, RPATH=rpath, CFLAGS=["-std=gnu11"] + cflags, CXXFLAGS=["-std=c++1z"] + cxxflags, LIBPATH=libpath + [ "#cereal", "#phonelibs", "#opendbc/can", "#selfdrive/boardd", "#selfdrive/common", ], CYTHONCFILESUFFIX=".cpp", COMPILATIONDB_USE_ABSPATH=True, tools=["default", "cython", "compilation_db"], ) if GetOption('compile_db'): env.CompilationDatabase('compile_commands.json') # Setup cache dir cache_dir = '/data/scons_cache' if TICI else '/tmp/scons_cache' CacheDir(cache_dir) Clean(["."], cache_dir) node_interval = 5 node_count = 0 def progress_function(node): global node_count node_count += node_interval sys.stderr.write("progress: %d\n" % node_count) if os.environ.get('SCONS_PROGRESS'): Progress(progress_function, interval=node_interval) SHARED = False def abspath(x): if arch == 'aarch64': pth = os.path.join("/data/pythonpath", x[0].path) env.Depends(pth, x) return File(pth) else: # rpath works elsewhere return x[0].path.rsplit("/", 1)[1][:-3] # Cython build enviroment py_include = sysconfig.get_paths()['include'] envCython = env.Clone() envCython["CPPPATH"] += [py_include, np.get_include()] envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"] envCython["LIBS"] = [] if arch == "Darwin": envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"] elif arch == "aarch64": envCython["LINKFLAGS"] = ["-shared"] envCython["LIBS"] = [os.path.basename(py_include)] else: envCython["LINKFLAGS"] = ["-pthread", "-shared"] Export('envCython') # Qt build environment qt_env = env.Clone() qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "Multimedia", "Quick", "Qml", "QuickWidgets", "Location", "Positioning"] if arch != "aarch64": qt_modules += ["DBus"] qt_libs = [] if arch == "Darwin": if real_arch == "arm64": qt_env['QTDIR'] = "/opt/homebrew/opt/qt@5" else: qt_env['QTDIR'] = "/usr/local/opt/qt@5" qt_dirs = [ os.path.join(qt_env['QTDIR'], "include"), ] qt_dirs += [f"{qt_env['QTDIR']}/include/Qt{m}" for m in qt_modules] qt_env["LINKFLAGS"] += ["-F" + os.path.join(qt_env['QTDIR'], "lib")] qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"] elif arch == "aarch64": qt_env['QTDIR'] = "/system/comma/usr" qt_dirs = [ f"/system/comma/usr/include/qt", ] qt_dirs += [f"/system/comma/usr/include/qt/Qt{m}" for m in qt_modules] qt_libs = [f"Qt5{m}" for m in qt_modules] qt_libs += ['EGL', 'GLESv3', 'c++_shared'] else: qt_env['QTDIR'] = "/usr" qt_dirs = [ f"/usr/include/{real_arch}-linux-gnu/qt5", f"/usr/include/{real_arch}-linux-gnu/qt5/QtGui/5.12.8/QtGui", ] qt_dirs += [f"/usr/include/{real_arch}-linux-gnu/qt5/Qt{m}" for m in qt_modules] qt_libs = [f"Qt5{m}" for m in qt_modules] if arch == "larch64" or arch == "jarch64": qt_libs += ["GLESv2", "wayland-client"] elif arch != "Darwin": qt_libs += ["GL"] qt_env.Tool('qt') qt_env['CPPPATH'] += qt_dirs + ["#selfdrive/ui/qt/"] qt_flags = [ "-D_REENTRANT", "-DQT_NO_DEBUG", "-DQT_WIDGETS_LIB", "-DQT_GUI_LIB", "-DQT_QUICK_LIB", "-DQT_QUICKWIDGETS_LIB", "-DQT_QML_LIB", "-DQT_CORE_LIB", "-DQT_MESSAGELOGCONTEXT", ] qt_env['CXXFLAGS'] += qt_flags qt_env['LIBPATH'] += ['#selfdrive/ui'] qt_env['LIBS'] = qt_libs if GetOption("clazy"): checks = [ "level0", "level1", "no-range-loop", "no-non-pod-global-static", ] qt_env['CXX'] = 'clazy' qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0] qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks) Export('env', 'qt_env', 'arch', 'real_arch', 'SHARED', 'USE_WEBCAM', 'USE_MIPI') SConscript(['selfdrive/common/SConscript']) Import('_common', '_gpucommon', '_gpu_libs') if SHARED: common, gpucommon = abspath(common), abspath(gpucommon) else: common = [_common, 'json11'] gpucommon = [_gpucommon] + _gpu_libs Export('common', 'gpucommon') # cereal and messaging are shared with the system SConscript(['cereal/SConscript']) if SHARED: cereal = abspath([File('cereal/libcereal_shared.so')]) messaging = abspath([File('cereal/libmessaging_shared.so')]) else: cereal = [File('#cereal/libcereal.a')] messaging = [File('#cereal/libmessaging.a')] visionipc = [File('#cereal/libvisionipc.a')] Export('cereal', 'messaging', 'visionipc') # Build rednose library and ekf models rednose_config = { 'generated_folder': '#selfdrive/locationd/models/generated', 'to_build': { 'live': ('#selfdrive/locationd/models/live_kf.py', True, ['live_kf_constants.h']), 'car': ('#selfdrive/locationd/models/car_kf.py', True, []), }, } if arch != "aarch64": rednose_config['to_build'].update({ 'gnss': ('#selfdrive/locationd/models/gnss_kf.py', True, []), 'loc_4': ('#selfdrive/locationd/models/loc_kf.py', True, []), 'pos_computer_4': ('#rednose/helpers/lst_sq_computer.py', False, []), 'pos_computer_5': ('#rednose/helpers/lst_sq_computer.py', False, []), 'feature_handler_5': ('#rednose/helpers/feature_handler.py', False, []), 'lane': ('#xx/pipeline/lib/ekf/lane_kf.py', True, []), }) Export('rednose_config') SConscript(['rednose/SConscript']) # Build openpilot SConscript(['cereal/SConscript']) SConscript(['panda/board/SConscript']) SConscript(['opendbc/can/SConscript']) SConscript(['phonelibs/SConscript']) SConscript(['common/SConscript']) SConscript(['common/kalman/SConscript']) SConscript(['common/transformations/SConscript']) SConscript(['selfdrive/camerad/SConscript']) SConscript(['selfdrive/modeld/SConscript']) SConscript(['selfdrive/controls/lib/cluster/SConscript']) SConscript(['selfdrive/controls/lib/lateral_mpc/SConscript']) SConscript(['selfdrive/controls/lib/lead_mpc_lib/SConscript']) SConscript(['selfdrive/controls/lib/longitudinal_mpc_lib/SConscript']) SConscript(['selfdrive/boardd/SConscript']) SConscript(['selfdrive/proclogd/SConscript']) SConscript(['selfdrive/clocksd/SConscript']) SConscript(['selfdrive/loggerd/SConscript']) SConscript(['selfdrive/locationd/SConscript']) if not os.path.isfile("/JETSON"): SConscript(['selfdrive/sensord/SConscript']) SConscript(['selfdrive/ui/SConscript']) if arch != "Darwin": SConscript(['selfdrive/logcatd/SConscript']) external_sconscript = GetOption('external_sconscript') if external_sconscript: SConscript([external_sconscript]) ================================================ FILE: cereal/.gitignore ================================================ gen node_modules package-lock.json *.tmp *.pyc __pycache__ .*.swp .*.swo *.os *.o *.a test_runner libmessaging.* libmessaging_shared.* services.h .sconsign.dblite libcereal_shared.* .mypy_cache/ catch2/ ================================================ FILE: cereal/SConscript ================================================ Import('env', 'envCython', 'arch', 'common') import shutil cereal_dir = Dir('.') gen_dir = Dir('gen') messaging_dir = Dir('messaging') # Build cereal schema_files = ['log.capnp', 'car.capnp', 'legacy.capnp', 'dp.capnp'] env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS") env.Command([f'gen/cpp/{s}.c++' for s in schema_files] + [f'gen/cpp/{s}.h' for s in schema_files], schema_files, f"capnpc --src-prefix={cereal_dir.path} $SOURCES -o c++:{gen_dir.path}/cpp/") if shutil.which('capnpc-java'): env.Command(['gen/java/Car.java', 'gen/java/Log.java'], schema_files, f"capnpc $SOURCES --src-prefix={cereal_dir.path} -o java:{gen_dir.path}/java/") # TODO: remove non shared cereal and messaging cereal_objects = env.SharedObject([f'gen/cpp/{s}.c++' for s in schema_files]) env.Library('cereal', cereal_objects) env.SharedLibrary('cereal_shared', cereal_objects) # Build messaging services_h = env.Command(['services.h'], ['services.py'], 'python3 ' + cereal_dir.path + '/services.py > $TARGET') messaging_objects = env.SharedObject([ 'messaging/messaging.cc', 'messaging/impl_zmq.cc', 'messaging/impl_msgq.cc', 'messaging/msgq.cc', 'messaging/socketmaster.cc', ]) messaging_lib = env.Library('messaging', messaging_objects) Depends('messaging/impl_zmq.cc', services_h) env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq', common]) Depends('messaging/bridge.cc', services_h) envCython.Program('messaging/messaging_pyx.so', 'messaging/messaging_pyx.pyx', LIBS=envCython["LIBS"]+[messaging_lib, "zmq", common]) # Build Vision IPC vipc_sources = [ 'visionipc/ipc.cc', 'visionipc/visionipc_server.cc', 'visionipc/visionipc_client.cc', 'visionipc/visionbuf.cc', ] if arch in ["aarch64", "larch64"]: vipc_sources += ['visionipc/visionbuf_ion.cc'] else: vipc_sources += ['visionipc/visionbuf_cl.cc'] vipc_objects = env.SharedObject(vipc_sources) vipc = env.Library('visionipc', vipc_objects) libs = envCython["LIBS"]+["OpenCL", "zmq", vipc, messaging_lib, common] if arch == "aarch64": libs += ["adreno_utils"] if arch == "Darwin": del libs[libs.index('OpenCL')] envCython['FRAMEWORKS'] += ['OpenCL'] envCython.Program('visionipc/visionipc_pyx.so', 'visionipc/visionipc_pyx.pyx', LIBS=libs) if GetOption('test'): env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib, common]) env.Program('visionipc/test_runner', ['visionipc/test_runner.cc', 'visionipc/visionipc_tests.cc'], LIBS=[vipc, messaging_lib, 'zmq', 'pthread', 'OpenCL', common]) ================================================ FILE: cereal/__init__.py ================================================ # pylint: skip-file import os import capnp CEREAL_PATH = os.path.dirname(os.path.abspath(__file__)) capnp.remove_import_hook() log = capnp.load(os.path.join(CEREAL_PATH, "log.capnp")) car = capnp.load(os.path.join(CEREAL_PATH, "car.capnp")) ================================================ FILE: cereal/car.capnp ================================================ using Cxx = import "./include/c++.capnp"; $Cxx.namespace("cereal"); using Java = import "./include/java.capnp"; $Java.package("ai.comma.openpilot.cereal"); $Java.outerClassname("Car"); @0x8e2af1e708af8b8d; # ******* events causing controls state machine transition ******* struct CarEvent @0x9b1657f34caf3ad3 { name @0 :EventName; # event types enable @1 :Bool; noEntry @2 :Bool; warning @3 :Bool; # alerts presented only when enabled or soft disabling userDisable @4 :Bool; softDisable @5 :Bool; immediateDisable @6 :Bool; preEnable @7 :Bool; permanent @8 :Bool; # alerts presented regardless of openpilot state enum EventName @0xbaa8c5d505f727de { canError @0; steerUnavailable @1; brakeUnavailable @2; wrongGear @4; doorOpen @5; seatbeltNotLatched @6; espDisabled @7; wrongCarMode @8; steerTempUnavailable @9; reverseGear @10; buttonCancel @11; buttonEnable @12; pedalPressed @13; cruiseDisabled @14; speedTooLow @17; outOfSpace @18; overheat @19; calibrationIncomplete @20; calibrationInvalid @21; controlsMismatch @22; pcmEnable @23; pcmDisable @24; noTarget @25; radarFault @26; brakeHold @28; parkBrake @29; manualRestart @30; lowSpeedLockout @31; plannerError @32; joystickDebug @34; steerTempUnavailableSilent @35; resumeRequired @36; preDriverDistracted @37; promptDriverDistracted @38; driverDistracted @39; preDriverUnresponsive @43; promptDriverUnresponsive @44; driverUnresponsive @45; belowSteerSpeed @46; lowBattery @48; vehicleModelInvalid @50; accFaulted @51; sensorDataInvalid @52; commIssue @53; tooDistracted @54; posenetInvalid @55; soundsUnavailable @56; preLaneChangeLeft @57; preLaneChangeRight @58; laneChange @59; communityFeatureDisallowed @62; lowMemory @63; stockAeb @64; ldw @65; carUnrecognized @66; invalidLkasSetting @69; speedTooHigh @70; laneChangeBlocked @71; relayMalfunction @72; gasPressed @73; stockFcw @74; startup @75; startupNoCar @76; startupNoControl @77; startupMaster @78; startupFuzzyFingerprint @97; startupNoFw @104; fcw @79; steerSaturated @80; belowEngageSpeed @84; noGps @85; wrongCruiseMode @87; modeldLagging @89; deviceFalling @90; fanMalfunction @91; cameraMalfunction @92; gpsMalfunction @94; processNotRunning @95; dashcamMode @96; controlsInitializing @98; usbError @99; roadCameraError @100; driverCameraError @101; wideRoadCameraError @102; localizerMalfunction @103; highCpuUsage @105; driverMonitorLowAccDEPRECATED @68; radarCanErrorDEPRECATED @15; radarCommIssueDEPRECATED @67; gasUnavailableDEPRECATED @3; dataNeededDEPRECATED @16; modelCommIssueDEPRECATED @27; ipasOverrideDEPRECATED @33; geofenceDEPRECATED @40; driverMonitorOnDEPRECATED @41; driverMonitorOffDEPRECATED @42; calibrationProgressDEPRECATED @47; invalidGiraffeHondaDEPRECATED @49; invalidGiraffeToyotaDEPRECATED @60; internetConnectivityNeededDEPRECATED @61; whitePandaUnsupportedDEPRECATED @81; commIssueWarningDEPRECATED @83; focusRecoverActiveDEPRECATED @86; neosUpdateRequiredDEPRECATED @88; modelLagWarningDEPRECATED @93; startupOneplusDEPRECATED @82; #dp autoLaneChange @106; manualSteeringRequired @107; manualSteeringRequiredBlinkersOn @108; leadCarMoving @109; # timebomb assist timebombWarn @110; timebombBypassing @111; timebombBypassed @112; mapdAlert @113; speedLimitActive @114; speedLimitValueChange @115; } } # ******* main car state @ 100hz ******* # all speeds in m/s struct CarState { events @13 :List(CarEvent); # car speed vEgo @1 :Float32; # best estimate of speed aEgo @16 :Float32; # best estimate of acceleration vEgoRaw @17 :Float32; # unfiltered speed from CAN sensors yawRate @22 :Float32; # best estimate of yaw rate standstill @18 :Bool; wheelSpeeds @2 :WheelSpeeds; # gas pedal, 0.0-1.0 gas @3 :Float32; # this is user + computer gasPressed @4 :Bool; # this is user pedal only # brake pedal, 0.0-1.0 brake @5 :Float32; # this is user pedal only brakePressed @6 :Bool; # this is user pedal only # steering wheel steeringAngleDeg @7 :Float32; steeringAngleOffsetDeg @37 :Float32; # Offset betweens sensors in case there multiple steeringRateDeg @15 :Float32; steeringTorque @8 :Float32; # TODO: standardize units steeringTorqueEps @27 :Float32; # TODO: standardize units steeringPressed @9 :Bool; # if the user is using the steering wheel steeringRateLimited @29 :Bool; # if the torque is limited by the rate limiter steerWarning @35 :Bool; # temporary steer unavailble steerError @36 :Bool; # permanent steer error stockAeb @30 :Bool; stockFcw @31 :Bool; espDisabled @32 :Bool; # cruise state cruiseState @10 :CruiseState; # gear gearShifter @14 :GearShifter; # button presses buttonEvents @11 :List(ButtonEvent); leftBlinker @20 :Bool; rightBlinker @21 :Bool; genericToggle @23 :Bool; # lock info doorOpen @24 :Bool; seatbeltUnlatched @25 :Bool; canValid @26 :Bool; # clutch (manual transmission only) clutchPressed @28 :Bool; # which packets this state came from canMonoTimes @12: List(UInt64); # blindspot sensors leftBlindspot @33 :Bool; # Is there something blocking the left lane change rightBlindspot @34 :Bool; # Is there something blocking the right lane change # dp lkMode @38 :Bool; stopSteering @39 :Bool; # timebomb - stopSteering engineRPM @40 :Float32; cruiseActualEnabled @41 :Bool; struct WheelSpeeds { # optional wheel speeds fl @0 :Float32; fr @1 :Float32; rl @2 :Float32; rr @3 :Float32; } struct CruiseState { enabled @0 :Bool; speed @1 :Float32; available @2 :Bool; speedOffset @3 :Float32; standstill @4 :Bool; nonAdaptive @5 :Bool; speedLimit @6 :Float32; } enum GearShifter { unknown @0; park @1; drive @2; neutral @3; reverse @4; sport @5; low @6; brake @7; eco @8; manumatic @9; } # send on change struct ButtonEvent { pressed @0 :Bool; type @1 :Type; enum Type { unknown @0; leftBlinker @1; rightBlinker @2; accelCruise @3; decelCruise @4; cancel @5; altButton1 @6; altButton2 @7; altButton3 @8; setCruise @9; resumeCruise @10; gapAdjustCruise @11; } } errorsDEPRECATED @0 :List(CarEvent.EventName); brakeLights @19 :Bool; } # ******* radar state @ 20hz ******* struct RadarData @0x888ad6581cf0aacb { errors @0 :List(Error); points @1 :List(RadarPoint); # which packets this state came from canMonoTimes @2 :List(UInt64); enum Error { canError @0; fault @1; wrongConfig @2; } # similar to LiveTracks # is one timestamp valid for all? I think so struct RadarPoint { trackId @0 :UInt64; # no trackId reuse # these 3 are the minimum required dRel @1 :Float32; # m from the front bumper of the car yRel @2 :Float32; # m vRel @3 :Float32; # m/s # these are optional and valid if they are not NaN aRel @4 :Float32; # m/s^2 yvRel @5 :Float32; # m/s # some radars flag measurements VS estimates measured @6 :Bool; } } # ******* car controls @ 100hz ******* struct CarControl { # must be true for any actuator commands to work enabled @0 :Bool; active @7 :Bool; actuators @6 :Actuators; cruiseControl @4 :CruiseControl; hudControl @5 :HUDControl; struct Actuators { # range from 0.0 - 1.0 gasDEPRECATED @0: Float32; brakeDEPRECATED @1: Float32; # range from -1.0 - 1.0 steer @2: Float32; steeringAngleDeg @3: Float32; accel @4: Float32; # m/s^2 longControlState @5: LongControlState; enum LongControlState @0xe40f3a917d908282{ off @0; pid @1; stopping @2; starting @3; } } struct CruiseControl { cancel @0: Bool; override @1: Bool; speedOverride @2: Float32; accelOverride @3: Float32; } struct HUDControl { speedVisible @0: Bool; setSpeed @1: Float32; lanesVisible @2: Bool; leadVisible @3: Bool; visualAlert @4: VisualAlert; audibleAlert @5: AudibleAlert; rightLaneVisible @6: Bool; leftLaneVisible @7: Bool; rightLaneDepart @8: Bool; leftLaneDepart @9: Bool; enum VisualAlert { # these are the choices from the Honda # map as good as you can for your car none @0; fcw @1; steerRequired @2; brakePressed @3; wrongGear @4; seatbeltUnbuckled @5; speedTooHigh @6; ldw @7; } enum AudibleAlert { none @0; chimeEngage @1; chimeDisengage @2; chimeError @3; chimeWarning1 @4; chimeWarning2 @5; chimeWarningRepeat @6; chimePrompt @7; chimeWarning2Repeat @8; } } gasDEPRECATED @1 :Float32; brakeDEPRECATED @2 :Float32; steeringTorqueDEPRECATED @3 :Float32; } # ****** car param ****** struct CarParams { carName @0 :Text; carFingerprint @1 :Text; fuzzyFingerprint @55 :Bool; enableGasInterceptor @2 :Bool; pcmCruise @3 :Bool; # is openpilot's state tied to the PCM's cruise state? enableDsu @5 :Bool; # driving support unit enableApgs @6 :Bool; # advanced parking guidance system enableBsm @56 :Bool; # blind spot monitoring hasStockCamera @57 :Bool; # factory LKAS/LDW camera is present minEnableSpeed @7 :Float32; minSteerSpeed @8 :Float32; maxSteeringAngleDeg @54 :Float32; safetyModel @9 :SafetyModel; safetyModelPassive @42 :SafetyModel = silent; safetyParam @10 :Int16; steerMaxBP @11 :List(Float32); steerMaxV @12 :List(Float32); gasMaxBPDEPRECATED @13 :List(Float32); gasMaxVDEPRECATED @14 :List(Float32); brakeMaxBPDEPRECATED @15 :List(Float32); brakeMaxVDEPRECATED @16 :List(Float32); # things about the car in the manual mass @17 :Float32; # [kg] curb weight: all fluids no cargo wheelbase @18 :Float32; # [m] distance from rear axle to front axle centerToFront @19 :Float32; # [m] distance from center of mass to front axle steerRatio @20 :Float32; # [] ratio of steering wheel angle to front wheel angle steerRatioRear @21 :Float32; # [] ratio of steering wheel angle to rear wheel angle (usually 0) # things we can derive rotationalInertia @22 :Float32; # [kg*m2] body rotational inertia tireStiffnessFront @23 :Float32; # [N/rad] front tire coeff of stiff tireStiffnessRear @24 :Float32; # [N/rad] rear tire coeff of stiff longitudinalTuning @25 :LongitudinalPIDTuning; lateralParams @48 :LateralParams; lateralTuning :union { pid @26 :LateralPIDTuning; indi @27 :LateralINDITuning; lqr @40 :LateralLQRTuning; } steerLimitAlert @28 :Bool; steerLimitTimer @47 :Float32; # time before steerLimitAlert is issued vEgoStopping @29 :Float32; # Speed at which the car goes into stopping state directAccelControl @30 :Bool; # Does the car have direct accel control or just gas/brake stoppingControl @31 :Bool; # Does the car allows full control even at lows speeds when stopping startAccel @32 :Float32; # Required acceleraton to overcome creep braking steerRateCost @33 :Float32; # Lateral MPC cost on steering rate steerControlType @34 :SteerControlType; radarOffCan @35 :Bool; # True when radar objects aren't visible on CAN minSpeedCan @51 :Float32; # Minimum vehicle speed from CAN (below this value drops to 0) stoppingDecelRate @52 :Float32; # m/s^2/s while trying to stop startingAccelRate @53 :Float32; # m/s^2/s while trying to start steerActuatorDelay @36 :Float32; # Steering wheel actuator delay in seconds longitudinalActuatorDelay @58 :Float32; # Gas/Brake actuator delay in seconds openpilotLongitudinalControl @37 :Bool; # is openpilot doing the longitudinal control? carVin @38 :Text; # VIN number queried during fingerprinting dashcamOnly @41: Bool; transmissionType @43 :TransmissionType; carFw @44 :List(CarFw); radarTimeStep @45: Float32 = 0.05; # time delta between radar updates, 20Hz is very standard communityFeature @46: Bool; # true if a community maintained feature is detected fingerprintSource @49: FingerprintSource; networkLocation @50 :NetworkLocation; # Where Panda/C2 is integrated into the car's CAN network struct LateralParams { torqueBP @0 :List(Int32); torqueV @1 :List(Int32); } struct LateralPIDTuning { kpBP @0 :List(Float32); kpV @1 :List(Float32); kiBP @2 :List(Float32); kiV @3 :List(Float32); kf @4 :Float32; } struct LongitudinalPIDTuning { kpBP @0 :List(Float32); kpV @1 :List(Float32); kiBP @2 :List(Float32); kiV @3 :List(Float32); deadzoneBP @4 :List(Float32); deadzoneV @5 :List(Float32); } struct LateralINDITuning { outerLoopGainBP @4 :List(Float32); outerLoopGainV @5 :List(Float32); innerLoopGainBP @6 :List(Float32); innerLoopGainV @7 :List(Float32); timeConstantBP @8 :List(Float32); timeConstantV @9 :List(Float32); actuatorEffectivenessBP @10 :List(Float32); actuatorEffectivenessV @11 :List(Float32); outerLoopGainDEPRECATED @0 :Float32; innerLoopGainDEPRECATED @1 :Float32; timeConstantDEPRECATED @2 :Float32; actuatorEffectivenessDEPRECATED @3 :Float32; } struct LateralLQRTuning { scale @0 :Float32; ki @1 :Float32; dcGain @2 :Float32; # State space system a @3 :List(Float32); b @4 :List(Float32); c @5 :List(Float32); k @6 :List(Float32); # LQR gain l @7 :List(Float32); # Kalman gain } enum SafetyModel { silent @0; hondaNidec @1; toyota @2; elm327 @3; gm @4; hondaBoschGiraffe @5; ford @6; cadillac @7; hyundai @8; chrysler @9; tesla @10; subaru @11; gmPassive @12; mazda @13; nissan @14; volkswagen @15; toyotaIpas @16; allOutput @17; gmAscm @18; noOutput @19; # like silent but without silent CAN TXs hondaBoschHarness @20; volkswagenPq @21; subaruLegacy @22; # pre-Global platform hyundaiLegacy @23; hyundaiCommunity @24; } enum SteerControlType { torque @0; angle @1; } enum TransmissionType { unknown @0; automatic @1; # Traditional auto, including DSG manual @2; # True "stick shift" only direct @3; # Electric vehicle or other direct drive cvt @4; } struct CarFw { ecu @0 :Ecu; fwVersion @1 :Data; address @2: UInt32; subAddress @3: UInt8; } enum Ecu { eps @0; esp @1; fwdRadar @2; fwdCamera @3; engine @4; unknown @5; transmission @8; # Transmission Control Module srs @9; # airbag gateway @10; # can gateway hud @11; # heads up display combinationMeter @12; # instrument cluster # Toyota only dsu @6; apgs @7; # Honda only vsa @13; # Vehicle Stability Assist programmedFuelInjection @14; electricBrakeBooster @15; shiftByWire @16; } enum FingerprintSource { can @0; fw @1; fixed @2; } enum NetworkLocation { fwdCamera @0; # Standard/default integration at LKAS camera gateway @1; # Integration at vehicle's CAN gateway } enableCameraDEPRECATED @4 :Bool; isPandaBlackDEPRECATED @39: Bool; } ================================================ FILE: cereal/dp.capnp ================================================ using Cxx = import "./include/c++.capnp"; $Cxx.namespace("cereal"); using Java = import "./include/java.capnp"; $Java.package("ai.comma.openpilot.cereal"); $Java.outerClassname("Dp"); @0xbfa7e645486440c7; # dp.capnp: a home for deprecated structs # dp struct DragonConf { dpThermalStarted @0 :Bool; dpThermalOverheat @1 :Bool; dpAtl @2 :Bool; dpAtlOpLong @3 :Bool; dpDashcamd @4 :Bool; dpAutoShutdown @5 :Bool; dpAthenad @6 :Bool; dpUploader @7 :Bool; dpLateralMode @8 :UInt8; dpSignalOffDelay @9 :Float32; dpLcMinMph @10 :UInt8; dpLcAutoMinMph @11 :UInt8; dpLcAutoDelay @12 :Float32; dpLaneLessModeCtrl @13 :Bool; dpLaneLessMode @14 :UInt8; dpAllowGas @15 :Bool; dpFollowingProfileCtrl @16 :Bool; dpFollowingProfile @17 :UInt8; dpAccelProfileCtrl @18 :Bool; dpAccelProfile @19 :UInt8; dpGearCheck @20 :Bool; dpSpeedCheck @21 :Bool; dpUiDisplayMode @22 :UInt8; dpUiSpeed @23 :Bool; dpUiEvent @24 :Bool; dpUiMaxSpeed @25 :Bool; dpUiFace @26 :Bool; dpUiLane @27 :Bool; dpUiLead @28 :Bool; dpUiSide @29 :Bool; dpUiTop @30 :Bool; dpUiBlinker @31 :Bool; dpUiBrightness @32 :UInt8; dpUiVolume @33 :Int8; dpToyotaLdw @34 :Bool; dpToyotaSng @35 :Bool; dpToyotaCruiseOverride @36 :Bool; dpToyotaCruiseOverrideVego @37 :Bool; dpToyotaCruiseOverrideAt @38 :Float32; dpToyotaCruiseOverrideSpeed @39 :Float32; dpVwTimebombAssist @40 :Bool; dpIpAddr @41 :Text; dpCameraOffset @42 :Int8; dpPathOffset @43 :Int8; dpLocale @44 :Text; dpSrLearner @45 :Bool; dpSrCustom @46 :Float32; dpAppd @47 :Bool; dpMapd @48 :Bool; } ================================================ FILE: cereal/include/c++.capnp ================================================ # Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors # Licensed under the MIT License: # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. @0xbdf87d7bb8304e81; $namespace("capnp::annotations"); annotation namespace(file): Text; annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text; ================================================ FILE: cereal/include/java.capnp ================================================ # Copyright (c) 2013-2015 Sandstorm Development Group, Inc. and contributors # Licensed under the MIT License: # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. @0xc5f1af96651f70ea; annotation package @0x9ee4c8f803b3b596 (file) : Text; # Name of the package, such as "org.example.foo", in which the generated code will reside. annotation outerClassname @0x9b066bb4881f7cd3 (file) : Text; # Name of the outer class that will wrap the generated code. ================================================ FILE: cereal/legacy.capnp ================================================ using Cxx = import "./include/c++.capnp"; $Cxx.namespace("cereal"); using Java = import "./include/java.capnp"; $Java.package("ai.comma.openpilot.cereal"); $Java.outerClassname("Legacy"); @0x80ef1ec4889c2a63; # legacy.capnp: a home for deprecated structs struct LogRotate @0x9811e1f38f62f2d1 { segmentNum @0 :Int32; path @1 :Text; } struct LiveUI @0xc08240f996aefced { rearViewCam @0 :Bool; alertText1 @1 :Text; alertText2 @2 :Text; awarenessStatus @3 :Float32; } struct UiLayoutState @0x88dcce08ad29dda0 { activeApp @0 :App; sidebarCollapsed @1 :Bool; mapEnabled @2 :Bool; mockEngaged @3 :Bool; enum App @0x9917470acf94d285 { home @0; music @1; nav @2; settings @3; none @4; } } struct OrbslamCorrection @0x8afd33dc9b35e1aa { correctionMonoTime @0 :UInt64; prePositionECEF @1 :List(Float64); postPositionECEF @2 :List(Float64); prePoseQuatECEF @3 :List(Float32); postPoseQuatECEF @4 :List(Float32); numInliers @5 :UInt32; } struct EthernetPacket @0xa99a9d5b33cf5859 { pkt @0 :Data; ts @1 :Float32; } struct CellInfo @0xcff7566681c277ce { timestamp @0 :UInt64; repr @1 :Text; # android toString() for now } struct WifiScan @0xd4df5a192382ba0b { bssid @0 :Text; ssid @1 :Text; capabilities @2 :Text; frequency @3 :Int32; level @4 :Int32; timestamp @5 :Int64; centerFreq0 @6 :Int32; centerFreq1 @7 :Int32; channelWidth @8 :ChannelWidth; operatorFriendlyName @9 :Text; venueName @10 :Text; is80211mcResponder @11 :Bool; passpoint @12 :Bool; distanceCm @13 :Int32; distanceSdCm @14 :Int32; enum ChannelWidth @0xcb6a279f015f6b51 { w20Mhz @0; w40Mhz @1; w80Mhz @2; w160Mhz @3; w80Plus80Mhz @4; } } struct LiveEventData @0x94b7baa90c5c321e { name @0 :Text; value @1 :Int32; } struct ModelData @0xb8aad62cffef28a9 { frameId @0 :UInt32; frameAge @12 :UInt32; frameDropPerc @13 :Float32; timestampEof @9 :UInt64; modelExecutionTime @14 :Float32; gpuExecutionTime @16 :Float32; rawPred @15 :Data; path @1 :PathData; leftLane @2 :PathData; rightLane @3 :PathData; lead @4 :LeadData; freePath @6 :List(Float32); settings @5 :ModelSettings; leadFuture @7 :LeadData; speed @8 :List(Float32); meta @10 :MetaData; longitudinal @11 :LongitudinalData; struct PathData @0x8817eeea389e9f08 { points @0 :List(Float32); prob @1 :Float32; std @2 :Float32; stds @3 :List(Float32); poly @4 :List(Float32); validLen @5 :Float32; } struct LeadData @0xd1c9bef96d26fa91 { dist @0 :Float32; prob @1 :Float32; std @2 :Float32; relVel @3 :Float32; relVelStd @4 :Float32; relY @5 :Float32; relYStd @6 :Float32; relA @7 :Float32; relAStd @8 :Float32; } struct ModelSettings @0xa26e3710efd3e914 { bigBoxX @0 :UInt16; bigBoxY @1 :UInt16; bigBoxWidth @2 :UInt16; bigBoxHeight @3 :UInt16; boxProjection @4 :List(Float32); yuvCorrection @5 :List(Float32); inputTransform @6 :List(Float32); } struct MetaData @0x9744f25fb60f2bf8 { engagedProb @0 :Float32; desirePrediction @1 :List(Float32); brakeDisengageProb @2 :Float32; gasDisengageProb @3 :Float32; steerOverrideProb @4 :Float32; desireState @5 :List(Float32); } struct LongitudinalData @0xf98f999c6a071122 { distances @2 :List(Float32); speeds @0 :List(Float32); accelerations @1 :List(Float32); } } struct ECEFPoint @0xc25bbbd524983447 { x @0 :Float64; y @1 :Float64; z @2 :Float64; } struct ECEFPointDEPRECATED @0xe10e21168db0c7f7 { x @0 :Float32; y @1 :Float32; z @2 :Float32; } struct GPSPlannerPoints @0xab54c59699f8f9f3 { curPosDEPRECATED @0 :ECEFPointDEPRECATED; pointsDEPRECATED @1 :List(ECEFPointDEPRECATED); curPos @6 :ECEFPoint; points @7 :List(ECEFPoint); valid @2 :Bool; trackName @3 :Text; speedLimit @4 :Float32; accelTarget @5 :Float32; } struct GPSPlannerPlan @0xf5ad1d90cdc1dd6b { valid @0 :Bool; poly @1 :List(Float32); trackName @2 :Text; speed @3 :Float32; acceleration @4 :Float32; pointsDEPRECATED @5 :List(ECEFPointDEPRECATED); points @6 :List(ECEFPoint); xLookahead @7 :Float32; } struct UiNavigationEvent @0x90c8426c3eaddd3b { type @0: Type; status @1: Status; distanceTo @2: Float32; endRoadPointDEPRECATED @3: ECEFPointDEPRECATED; endRoadPoint @4: ECEFPoint; enum Type @0xe8db07dcf8fcea05 { none @0; laneChangeLeft @1; laneChangeRight @2; mergeLeft @3; mergeRight @4; turnLeft @5; turnRight @6; } enum Status @0xb9aa88c75ef99a1f { none @0; passive @1; approaching @2; active @3; } } struct LiveLocationData @0xb99b2bc7a57e8128 { status @0 :UInt8; # 3D fix lat @1 :Float64; lon @2 :Float64; alt @3 :Float32; # m # speed speed @4 :Float32; # m/s # NED velocity components vNED @5 :List(Float32); # roll, pitch, heading (x,y,z) roll @6 :Float32; # WRT to center of earth? pitch @7 :Float32; # WRT to center of earth? heading @8 :Float32; # WRT to north? # what are these? wanderAngle @9 :Float32; trackAngle @10 :Float32; # car frame -- https://upload.wikimedia.org/wikipedia/commons/f/f5/RPY_angles_of_cars.png # gyro, in car frame, deg/s gyro @11 :List(Float32); # accel, in car frame, m/s^2 accel @12 :List(Float32); accuracy @13 :Accuracy; source @14 :SensorSource; # if we are fixing a location in the past fixMonoTime @15 :UInt64; gpsWeek @16 :Int32; timeOfWeek @17 :Float64; positionECEF @18 :List(Float64); poseQuatECEF @19 :List(Float32); pitchCalibration @20 :Float32; yawCalibration @21 :Float32; imuFrame @22 :List(Float32); struct Accuracy @0x943dc4625473b03f { pNEDError @0 :List(Float32); vNEDError @1 :List(Float32); rollError @2 :Float32; pitchError @3 :Float32; headingError @4 :Float32; ellipsoidSemiMajorError @5 :Float32; ellipsoidSemiMinorError @6 :Float32; ellipsoidOrientationError @7 :Float32; } enum SensorSource @0xc871d3cc252af657 { applanix @0; kalman @1; orbslam @2; timing @3; dummy @4; } } struct OrbOdometry @0xd7700859ed1f5b76 { # timing first startMonoTime @0 :UInt64; endMonoTime @1 :UInt64; # fundamental matrix and error f @2: List(Float64); err @3: Float64; # number of inlier points inliers @4: Int32; # for debug only # indexed by endMonoTime features # value is startMonoTime feature match # -1 if no match matches @5: List(Int16); } struct OrbFeatures @0xcd60164a8a0159ef { timestampEof @0 :UInt64; # transposed arrays of normalized image coordinates # len(xs) == len(ys) == len(descriptors) * 32 xs @1 :List(Float32); ys @2 :List(Float32); descriptors @3 :Data; octaves @4 :List(Int8); # match index to last OrbFeatures # -1 if no match timestampLastEof @5 :UInt64; matches @6: List(Int16); } struct OrbFeaturesSummary @0xd500d30c5803fa4f { timestampEof @0 :UInt64; timestampLastEof @1 :UInt64; featureCount @2 :UInt16; matchCount @3 :UInt16; computeNs @4 :UInt64; } struct OrbKeyFrame @0xc8233c0345e27e24 { # this is a globally unique id for the KeyFrame id @0: UInt64; # this is the location of the KeyFrame pos @1: ECEFPoint; # these are the features in the world # len(dpos) == len(descriptors) * 32 dpos @2 :List(ECEFPoint); descriptors @3 :Data; } struct KalmanOdometry @0x92e21bb7ea38793a { trans @0 :List(Float32); # m/s in device frame rot @1 :List(Float32); # rad/s in device frame transStd @2 :List(Float32); # std m/s in device frame rotStd @3 :List(Float32); # std rad/s in device frame } struct OrbObservation @0x9b326d4e436afec7 { observationMonoTime @0 :UInt64; normalizedCoordinates @1 :List(Float32); locationECEF @2 :List(Float64); matchDistance @3: UInt32; } struct CalibrationFeatures @0x8fdfadb254ea867a { frameId @0 :UInt32; p0 @1 :List(Float32); p1 @2 :List(Float32); status @3 :List(Int8); } struct NavStatus @0xbd8822120928120c { isNavigating @0 :Bool; currentAddress @1 :Address; struct Address @0xce7cd672cacc7814 { title @0 :Text; lat @1 :Float64; lng @2 :Float64; house @3 :Text; address @4 :Text; street @5 :Text; city @6 :Text; state @7 :Text; country @8 :Text; } } struct NavUpdate @0xdb98be6565516acb { isNavigating @0 :Bool; curSegment @1 :Int32; segments @2 :List(Segment); struct LatLng @0x9eaef9187cadbb9b { lat @0 :Float64; lng @1 :Float64; } struct Segment @0xa5b39b4fc4d7da3f { from @0 :LatLng; to @1 :LatLng; updateTime @2 :Int32; distance @3 :Int32; crossTime @4 :Int32; exitNo @5 :Int32; instruction @6 :Instruction; parts @7 :List(LatLng); enum Instruction @0xc5417a637451246f { turnLeft @0; turnRight @1; keepLeft @2; keepRight @3; straight @4; roundaboutExitNumber @5; roundaboutExit @6; roundaboutTurnLeft @7; unkn8 @8; roundaboutStraight @9; unkn10 @10; roundaboutTurnRight @11; unkn12 @12; roundaboutUturn @13; unkn14 @14; arrive @15; exitLeft @16; exitRight @17; unkn18 @18; uturn @19; # ... } } } struct TrafficEvent @0xacfa74a094e62626 { type @0 :Type; distance @1 :Float32; action @2 :Action; resuming @3 :Bool; enum Type @0xd85d75253435bf4b { stopSign @0; lightRed @1; lightYellow @2; lightGreen @3; stopLight @4; } enum Action @0xa6f6ce72165ccb49 { none @0; yield @1; stop @2; resumeReady @3; } } struct AndroidGnss @0xdfdf30d03fc485bd { union { measurements @0 :Measurements; navigationMessage @1 :NavigationMessage; } struct Measurements @0xa20710d4f428d6cd { clock @0 :Clock; measurements @1 :List(Measurement); struct Clock @0xa0e27b453a38f450 { timeNanos @0 :Int64; hardwareClockDiscontinuityCount @1 :Int32; hasTimeUncertaintyNanos @2 :Bool; timeUncertaintyNanos @3 :Float64; hasLeapSecond @4 :Bool; leapSecond @5 :Int32; hasFullBiasNanos @6 :Bool; fullBiasNanos @7 :Int64; hasBiasNanos @8 :Bool; biasNanos @9 :Float64; hasBiasUncertaintyNanos @10 :Bool; biasUncertaintyNanos @11 :Float64; hasDriftNanosPerSecond @12 :Bool; driftNanosPerSecond @13 :Float64; hasDriftUncertaintyNanosPerSecond @14 :Bool; driftUncertaintyNanosPerSecond @15 :Float64; } struct Measurement @0xd949bf717d77614d { svId @0 :Int32; constellation @1 :Constellation; timeOffsetNanos @2 :Float64; state @3 :Int32; receivedSvTimeNanos @4 :Int64; receivedSvTimeUncertaintyNanos @5 :Int64; cn0DbHz @6 :Float64; pseudorangeRateMetersPerSecond @7 :Float64; pseudorangeRateUncertaintyMetersPerSecond @8 :Float64; accumulatedDeltaRangeState @9 :Int32; accumulatedDeltaRangeMeters @10 :Float64; accumulatedDeltaRangeUncertaintyMeters @11 :Float64; hasCarrierFrequencyHz @12 :Bool; carrierFrequencyHz @13 :Float32; hasCarrierCycles @14 :Bool; carrierCycles @15 :Int64; hasCarrierPhase @16 :Bool; carrierPhase @17 :Float64; hasCarrierPhaseUncertainty @18 :Bool; carrierPhaseUncertainty @19 :Float64; hasSnrInDb @20 :Bool; snrInDb @21 :Float64; multipathIndicator @22 :MultipathIndicator; enum Constellation @0x9ef1f3ff0deb5ffb { unknown @0; gps @1; sbas @2; glonass @3; qzss @4; beidou @5; galileo @6; } enum State @0xcbb9490adce12d72 { unknown @0; codeLock @1; bitSync @2; subframeSync @3; towDecoded @4; msecAmbiguous @5; symbolSync @6; gloStringSync @7; gloTodDecoded @8; bdsD2BitSync @9; bdsD2SubframeSync @10; galE1bcCodeLock @11; galE1c2ndCodeLock @12; galE1bPageSync @13; sbasSync @14; } enum MultipathIndicator @0xc04e7b6231d4caa8 { unknown @0; detected @1; notDetected @2; } } } struct NavigationMessage @0xe2517b083095fd4e { type @0 :Int32; svId @1 :Int32; messageId @2 :Int32; submessageId @3 :Int32; data @4 :Data; status @5 :Status; enum Status @0xec1ff7996b35366f { unknown @0; parityPassed @1; parityRebuilt @2; } } } struct QcomGnss @0xde94674b07ae51c1 { logTs @0 :UInt64; union { measurementReport @1 :MeasurementReport; clockReport @2 :ClockReport; drMeasurementReport @3 :DrMeasurementReport; drSvPoly @4 :DrSvPolyReport; rawLog @5 :Data; } enum MeasurementSource @0xd71a12b6faada7ee { gps @0; glonass @1; beidou @2; } enum SVObservationState @0xe81e829a0d6c83e9 { idle @0; search @1; searchVerify @2; bitEdge @3; trackVerify @4; track @5; restart @6; dpo @7; glo10msBe @8; glo10msAt @9; } struct MeasurementStatus @0xe501010e1bcae83b { subMillisecondIsValid @0 :Bool; subBitTimeIsKnown @1 :Bool; satelliteTimeIsKnown @2 :Bool; bitEdgeConfirmedFromSignal @3 :Bool; measuredVelocity @4 :Bool; fineOrCoarseVelocity @5 :Bool; lockPointValid @6 :Bool; lockPointPositive @7 :Bool; lastUpdateFromDifference @8 :Bool; lastUpdateFromVelocityDifference @9 :Bool; strongIndicationOfCrossCorelation @10 :Bool; tentativeMeasurement @11 :Bool; measurementNotUsable @12 :Bool; sirCheckIsNeeded @13 :Bool; probationMode @14 :Bool; glonassMeanderBitEdgeValid @15 :Bool; glonassTimeMarkValid @16 :Bool; gpsRoundRobinRxDiversity @17 :Bool; gpsRxDiversity @18 :Bool; gpsLowBandwidthRxDiversityCombined @19 :Bool; gpsHighBandwidthNu4 @20 :Bool; gpsHighBandwidthNu8 @21 :Bool; gpsHighBandwidthUniform @22 :Bool; multipathIndicator @23 :Bool; imdJammingIndicator @24 :Bool; lteB13TxJammingIndicator @25 :Bool; freshMeasurementIndicator @26 :Bool; multipathEstimateIsValid @27 :Bool; directionIsValid @28 :Bool; } struct MeasurementReport @0xf580d7d86b7b8692 { source @0 :MeasurementSource; fCount @1 :UInt32; gpsWeek @2 :UInt16; glonassCycleNumber @3 :UInt8; glonassNumberOfDays @4 :UInt16; milliseconds @5 :UInt32; timeBias @6 :Float32; clockTimeUncertainty @7 :Float32; clockFrequencyBias @8 :Float32; clockFrequencyUncertainty @9 :Float32; sv @10 :List(SV); struct SV @0xf10c595ae7bb2c27 { svId @0 :UInt8; observationState @2 :SVObservationState; observations @3 :UInt8; goodObservations @4 :UInt8; gpsParityErrorCount @5 :UInt16; glonassFrequencyIndex @1 :Int8; glonassHemmingErrorCount @6 :UInt8; filterStages @7 :UInt8; carrierNoise @8 :UInt16; latency @9 :Int16; predetectInterval @10 :UInt8; postdetections @11 :UInt16; unfilteredMeasurementIntegral @12 :UInt32; unfilteredMeasurementFraction @13 :Float32; unfilteredTimeUncertainty @14 :Float32; unfilteredSpeed @15 :Float32; unfilteredSpeedUncertainty @16 :Float32; measurementStatus @17 :MeasurementStatus; multipathEstimate @18 :UInt32; azimuth @19 :Float32; elevation @20 :Float32; carrierPhaseCyclesIntegral @21 :Int32; carrierPhaseCyclesFraction @22 :UInt16; fineSpeed @23 :Float32; fineSpeedUncertainty @24 :Float32; cycleSlipCount @25 :UInt8; } } struct ClockReport @0xca965e4add8f4f0b { hasFCount @0 :Bool; fCount @1 :UInt32; hasGpsWeek @2 :Bool; gpsWeek @3 :UInt16; hasGpsMilliseconds @4 :Bool; gpsMilliseconds @5 :UInt32; gpsTimeBias @6 :Float32; gpsClockTimeUncertainty @7 :Float32; gpsClockSource @8 :UInt8; hasGlonassYear @9 :Bool; glonassYear @10 :UInt8; hasGlonassDay @11 :Bool; glonassDay @12 :UInt16; hasGlonassMilliseconds @13 :Bool; glonassMilliseconds @14 :UInt32; glonassTimeBias @15 :Float32; glonassClockTimeUncertainty @16 :Float32; glonassClockSource @17 :UInt8; bdsWeek @18 :UInt16; bdsMilliseconds @19 :UInt32; bdsTimeBias @20 :Float32; bdsClockTimeUncertainty @21 :Float32; bdsClockSource @22 :UInt8; galWeek @23 :UInt16; galMilliseconds @24 :UInt32; galTimeBias @25 :Float32; galClockTimeUncertainty @26 :Float32; galClockSource @27 :UInt8; clockFrequencyBias @28 :Float32; clockFrequencyUncertainty @29 :Float32; frequencySource @30 :UInt8; gpsLeapSeconds @31 :UInt8; gpsLeapSecondsUncertainty @32 :UInt8; gpsLeapSecondsSource @33 :UInt8; gpsToGlonassTimeBiasMilliseconds @34 :Float32; gpsToGlonassTimeBiasMillisecondsUncertainty @35 :Float32; gpsToBdsTimeBiasMilliseconds @36 :Float32; gpsToBdsTimeBiasMillisecondsUncertainty @37 :Float32; bdsToGloTimeBiasMilliseconds @38 :Float32; bdsToGloTimeBiasMillisecondsUncertainty @39 :Float32; gpsToGalTimeBiasMilliseconds @40 :Float32; gpsToGalTimeBiasMillisecondsUncertainty @41 :Float32; galToGloTimeBiasMilliseconds @42 :Float32; galToGloTimeBiasMillisecondsUncertainty @43 :Float32; galToBdsTimeBiasMilliseconds @44 :Float32; galToBdsTimeBiasMillisecondsUncertainty @45 :Float32; hasRtcTime @46 :Bool; systemRtcTime @47 :UInt32; fCountOffset @48 :UInt32; lpmRtcCount @49 :UInt32; clockResets @50 :UInt32; } struct DrMeasurementReport @0x8053c39445c6c75c { reason @0 :UInt8; seqNum @1 :UInt8; seqMax @2 :UInt8; rfLoss @3 :UInt16; systemRtcValid @4 :Bool; fCount @5 :UInt32; clockResets @6 :UInt32; systemRtcTime @7 :UInt64; gpsLeapSeconds @8 :UInt8; gpsLeapSecondsUncertainty @9 :UInt8; gpsToGlonassTimeBiasMilliseconds @10 :Float32; gpsToGlonassTimeBiasMillisecondsUncertainty @11 :Float32; gpsWeek @12 :UInt16; gpsMilliseconds @13 :UInt32; gpsTimeBiasMs @14 :UInt32; gpsClockTimeUncertaintyMs @15 :UInt32; gpsClockSource @16 :UInt8; glonassClockSource @17 :UInt8; glonassYear @18 :UInt8; glonassDay @19 :UInt16; glonassMilliseconds @20 :UInt32; glonassTimeBias @21 :Float32; glonassClockTimeUncertainty @22 :Float32; clockFrequencyBias @23 :Float32; clockFrequencyUncertainty @24 :Float32; frequencySource @25 :UInt8; source @26 :MeasurementSource; sv @27 :List(SV); struct SV @0xf08b81df8cbf459c { svId @0 :UInt8; glonassFrequencyIndex @1 :Int8; observationState @2 :SVObservationState; observations @3 :UInt8; goodObservations @4 :UInt8; filterStages @5 :UInt8; predetectInterval @6 :UInt8; cycleSlipCount @7 :UInt8; postdetections @8 :UInt16; measurementStatus @9 :MeasurementStatus; carrierNoise @10 :UInt16; rfLoss @11 :UInt16; latency @12 :Int16; filteredMeasurementFraction @13 :Float32; filteredMeasurementIntegral @14 :UInt32; filteredTimeUncertainty @15 :Float32; filteredSpeed @16 :Float32; filteredSpeedUncertainty @17 :Float32; unfilteredMeasurementFraction @18 :Float32; unfilteredMeasurementIntegral @19 :UInt32; unfilteredTimeUncertainty @20 :Float32; unfilteredSpeed @21 :Float32; unfilteredSpeedUncertainty @22 :Float32; multipathEstimate @23 :UInt32; azimuth @24 :Float32; elevation @25 :Float32; dopplerAcceleration @26 :Float32; fineSpeed @27 :Float32; fineSpeedUncertainty @28 :Float32; carrierPhase @29 :Float64; fCount @30 :UInt32; parityErrorCount @31 :UInt16; goodParity @32 :Bool; } } struct DrSvPolyReport @0xb1fb80811a673270 { svId @0 :UInt16; frequencyIndex @1 :Int8; hasPosition @2 :Bool; hasIono @3 :Bool; hasTropo @4 :Bool; hasElevation @5 :Bool; polyFromXtra @6 :Bool; hasSbasIono @7 :Bool; iode @8 :UInt16; t0 @9 :Float64; xyz0 @10 :List(Float64); xyzN @11 :List(Float64); other @12 :List(Float32); positionUncertainty @13 :Float32; ionoDelay @14 :Float32; ionoDot @15 :Float32; sbasIonoDelay @16 :Float32; sbasIonoDot @17 :Float32; tropoDelay @18 :Float32; elevation @19 :Float32; elevationDot @20 :Float32; elevationUncertainty @21 :Float32; velocityCoeff @22 :List(Float64); } } struct LidarPts @0xe3d6685d4e9d8f7a { r @0 :List(UInt16); # uint16 m*500.0 theta @1 :List(UInt16); # uint16 deg*100.0 reflect @2 :List(UInt8); # uint8 0-255 # For storing out of file. idx @3 :UInt64; # For storing in file pkt @4 :Data; } ================================================ FILE: cereal/log.capnp ================================================ using Cxx = import "./include/c++.capnp"; $Cxx.namespace("cereal"); using Java = import "./include/java.capnp"; $Java.package("ai.comma.openpilot.cereal"); $Java.outerClassname("Log"); using Car = import "car.capnp"; using Legacy = import "legacy.capnp"; using Dp = import "dp.capnp"; @0xf3b1f17e25a4285b; const logVersion :Int32 = 1; struct Map(Key, Value) { entries @0 :List(Entry); struct Entry { key @0 :Key; value @1 :Value; } } struct InitData { kernelArgs @0 :List(Text); kernelVersion @15 :Text; osVersion @18 :Text; gctx @1 :Text; dongleId @2 :Text; deviceType @3 :DeviceType; version @4 :Text; gitCommit @10 :Text; gitBranch @11 :Text; gitRemote @13 :Text; androidProperties @16 :Map(Text, Text); pandaInfo @8 :PandaInfo; dirty @9 :Bool; passive @12 :Bool; params @17 :Map(Text, Data); enum DeviceType { unknown @0; neo @1; chffrAndroid @2; chffrIos @3; tici @4; pc @5; jetson @6; } struct PandaInfo { hasPanda @0 :Bool; dongleId @1 :Text; stVersion @2 :Text; espVersion @3 :Text; } # ***** deprecated stuff ***** androidBuildInfo @5 :AndroidBuildInfo; androidSensorsDEPRECATED @6 :List(AndroidSensor); chffrAndroidExtraDEPRECATED @7 :ChffrAndroidExtra; iosBuildInfoDEPRECATED @14 :IosBuildInfo; struct AndroidBuildInfo { board @0 :Text; bootloader @1 :Text; brand @2 :Text; device @3 :Text; display @4 :Text; fingerprint @5 :Text; hardware @6 :Text; host @7 :Text; id @8 :Text; manufacturer @9 :Text; model @10 :Text; product @11 :Text; radioVersion @12 :Text; serial @13 :Text; supportedAbis @14 :List(Text); tags @15 :Text; time @16 :Int64; type @17 :Text; user @18 :Text; versionCodename @19 :Text; versionRelease @20 :Text; versionSdk @21 :Int32; versionSecurityPatch @22 :Text; } struct AndroidSensor { id @0 :Int32; name @1 :Text; vendor @2 :Text; version @3 :Int32; handle @4 :Int32; type @5 :Int32; maxRange @6 :Float32; resolution @7 :Float32; power @8 :Float32; minDelay @9 :Int32; fifoReservedEventCount @10 :UInt32; fifoMaxEventCount @11 :UInt32; stringType @12 :Text; maxDelay @13 :Int32; } struct ChffrAndroidExtra { allCameraCharacteristics @0 :Map(Text, Text); } struct IosBuildInfo { appVersion @0 :Text; appBuild @1 :UInt32; osVersion @2 :Text; deviceModel @3 :Text; } } struct FrameData { frameId @0 :UInt32; encodeId @1 :UInt32; # DEPRECATED frameType @7 :FrameType; frameLength @3 :Int32; # Timestamps timestampEof @2 :UInt64; timestampSof @8 :UInt64; # Exposure integLines @4 :Int32; highConversionGain @20 :Bool; gain @15 :Float32; # This includes highConversionGain if enabled measuredGreyFraction @21 :Float32; targetGreyFraction @22 :Float32; # Focus lensPos @11 :Int32; lensSag @12 :Float32; lensErr @13 :Float32; lensTruePos @14 :Float32; focusVal @16 :List(Int16); focusConf @17 :List(UInt8); sharpnessScore @18 :List(UInt16); recoverState @19 :Int32; transform @10 :List(Float32); androidCaptureResult @9 :AndroidCaptureResult; image @6 :Data; globalGainDEPRECATED @5 :Int32; enum FrameType { unknown @0; neo @1; chffrAndroid @2; front @3; } struct AndroidCaptureResult { sensitivity @0 :Int32; frameDuration @1 :Int64; exposureTime @2 :Int64; rollingShutterSkew @3 :UInt64; colorCorrectionTransform @4 :List(Int32); colorCorrectionGains @5 :List(Float32); displayRotation @6 :Int8; } } struct Thumbnail { frameId @0 :UInt32; timestampEof @1 :UInt64; thumbnail @2 :Data; } struct GPSNMEAData { timestamp @0 :Int64; localWallTime @1 :UInt64; nmea @2 :Text; } # android sensor_event_t struct SensorEventData { version @0 :Int32; sensor @1 :Int32; type @2 :Int32; timestamp @3 :Int64; uncalibratedDEPRECATED @10 :Bool; union { acceleration @4 :SensorVec; magnetic @5 :SensorVec; orientation @6 :SensorVec; gyro @7 :SensorVec; pressure @9 :SensorVec; magneticUncalibrated @11 :SensorVec; gyroUncalibrated @12 :SensorVec; proximity @13: Float32; light @14: Float32; temperature @15: Float32; } source @8 :SensorSource; struct SensorVec { v @0 :List(Float32); status @1 :Int8; } enum SensorSource { android @0; iOS @1; fiber @2; velodyne @3; # Velodyne IMU bno055 @4; # Bosch accelerometer lsm6ds3 @5; # accelerometer (c2) bmp280 @6; # barometer (c2) mmc3416x @7; # magnetometer (c2) bmx055 @8; rpr0521 @9; lsm6ds3trc @10; mmc5603nj @11; } } # android struct GpsLocation struct GpsLocationData { # Contains GpsLocationFlags bits. flags @0 :UInt16; # Represents latitude in degrees. latitude @1 :Float64; # Represents longitude in degrees. longitude @2 :Float64; # Represents altitude in meters above the WGS 84 reference ellipsoid. altitude @3 :Float64; # Represents speed in meters per second. speed @4 :Float32; # Represents heading in degrees. bearingDeg @5 :Float32; # Represents expected accuracy in meters. (presumably 1 sigma?) accuracy @6 :Float32; # Timestamp for the location fix. # Milliseconds since January 1, 1970. timestamp @7 :Int64; source @8 :SensorSource; # Represents NED velocity in m/s. vNED @9 :List(Float32); # Represents expected vertical accuracy in meters. (presumably 1 sigma?) verticalAccuracy @10 :Float32; # Represents bearing accuracy in degrees. (presumably 1 sigma?) bearingAccuracyDeg @11 :Float32; # Represents velocity accuracy in m/s. (presumably 1 sigma?) speedAccuracy @12 :Float32; enum SensorSource { android @0; iOS @1; car @2; velodyne @3; # Velodyne IMU fusion @4; external @5; ublox @6; trimble @7; } } struct CanData { address @0 :UInt32; busTime @1 :UInt16; dat @2 :Data; src @3 :UInt8; } struct DeviceState @0xa4d8b5af2aa492eb { usbOnline @12 :Bool; networkType @22 :NetworkType; networkInfo @31 :NetworkInfo; networkStrength @24 :NetworkStrength; offroadPowerUsageUwh @23 :UInt32; carBatteryCapacityUwh @25 :UInt32; fanSpeedPercentDesired @10 :UInt16; started @11 :Bool; startedMonoTime @13 :UInt64; lastAthenaPingTime @32 :UInt64; # system utilization freeSpacePercent @7 :Float32; memoryUsagePercent @19 :Int8; gpuUsagePercent @33 :Int8; cpuUsagePercent @34 :List(Int8); # per-core cpu usage # power batteryPercent @8 :Int16; batteryCurrent @15 :Int32; chargingError @17 :Bool; chargingDisabled @18 :Bool; # device thermals cpuTempC @26 :List(Float32); gpuTempC @27 :List(Float32); memoryTempC @28 :Float32; ambientTempC @30 :Float32; thermalStatus @14 :ThermalStatus; enum ThermalStatus { green @0; yellow @1; red @2; danger @3; } enum NetworkType { none @0; wifi @1; cell2G @2; cell3G @3; cell4G @4; cell5G @5; ethernet @6; } enum NetworkStrength { unknown @0; poor @1; moderate @2; good @3; great @4; } struct NetworkInfo { technology @0 :Text; operator @1 :Text; band @2 :Text; channel @3 :UInt16; extra @4 :Text; state @5 :Text; } # deprecated cpu0DEPRECATED @0 :UInt16; cpu1DEPRECATED @1 :UInt16; cpu2DEPRECATED @2 :UInt16; cpu3DEPRECATED @3 :UInt16; memDEPRECATED @4 :UInt16; gpuDEPRECATED @5 :UInt16; batDEPRECATED @6 :UInt32; pa0DEPRECATED @21 :UInt16; cpuUsagePercentDEPRECATED @20 :Int8; batteryStatusDEPRECATED @9 :Text; batteryVoltageDEPRECATED @16 :Int32; batteryTempCDEPRECATED @29 :Float32; } struct PandaState @0xa7649e2575e4591e { # from can health voltage @0 :UInt32; current @1 :UInt32; ignitionLine @2 :Bool; controlsAllowed @3 :Bool; gasInterceptorDetected @4 :Bool; hasGps @6 :Bool; canSendErrs @7 :UInt32; canFwdErrs @8 :UInt32; canRxErrs @19 :UInt32; gmlanSendErrs @9 :UInt32; pandaType @10 :PandaType; fanSpeedRpm @11 :UInt16; usbPowerMode @12 :UsbPowerMode; ignitionCan @13 :Bool; safetyModel @14 :Car.CarParams.SafetyModel; safetyParam @20 :Int16; faultStatus @15 :FaultStatus; powerSaveEnabled @16 :Bool; uptime @17 :UInt32; faults @18 :List(FaultType); harnessStatus @21 :HarnessStatus; heartbeatLost @22 :Bool; enum FaultStatus { none @0; faultTemp @1; faultPerm @2; } enum FaultType { relayMalfunction @0; unusedInterruptHandled @1; interruptRateCan1 @2; interruptRateCan2 @3; interruptRateCan3 @4; interruptRateTach @5; interruptRateGmlan @6; interruptRateInterrupts @7; interruptRateSpiDma @8; interruptRateSpiCs @9; interruptRateUart1 @10; interruptRateUart2 @11; interruptRateUart3 @12; interruptRateUart5 @13; interruptRateUartDma @14; interruptRateUsb @15; interruptRateTim1 @16; interruptRateTim3 @17; registerDivergent @18; interruptRateKlineInit @19; interruptRateClockSource @20; interruptRateTick @21; # Update max fault type in boardd when adding faults } enum PandaType @0x8a58adf93e5b3751 { unknown @0; whitePanda @1; greyPanda @2; blackPanda @3; pedal @4; uno @5; dos @6; redPanda @7; } enum UsbPowerMode { none @0; client @1; cdp @2; dcp @3; } enum HarnessStatus { notConnected @0; normal @1; flipped @2; } startedSignalDetectedDEPRECATED @5 :Bool; } struct RadarState @0x9a185389d6fdd05f { canMonoTimes @10 :List(UInt64); mdMonoTime @6 :UInt64; carStateMonoTime @11 :UInt64; radarErrors @12 :List(Car.RadarData.Error); leadOne @3 :LeadData; leadTwo @4 :LeadData; cumLagMs @5 :Float32; struct LeadData { dRel @0 :Float32; yRel @1 :Float32; vRel @2 :Float32; aRel @3 :Float32; vLead @4 :Float32; dPath @6 :Float32; vLat @7 :Float32; vLeadK @8 :Float32; aLeadK @9 :Float32; fcw @10 :Bool; status @11 :Bool; aLeadTau @12 :Float32; modelProb @13 :Float32; radar @14 :Bool; aLeadDEPRECATED @5 :Float32; } # deprecated ftMonoTimeDEPRECATED @7 :UInt64; warpMatrixDEPRECATED @0 :List(Float32); angleOffsetDEPRECATED @1 :Float32; calStatusDEPRECATED @2 :Int8; calCycleDEPRECATED @8 :Int32; calPercDEPRECATED @9 :Int8; } struct LiveCalibrationData { calStatus @1 :Int8; calCycle @2 :Int32; calPerc @3 :Int8; validBlocks @9 :Int32; # view_frame_from_road_frame # ui's is inversed needs new extrinsicMatrix @4 :List(Float32); # the direction of travel vector in device frame rpyCalib @7 :List(Float32); rpyCalibSpread @8 :List(Float32); warpMatrixDEPRECATED @0 :List(Float32); warpMatrix2DEPRECATED @5 :List(Float32); warpMatrixBigDEPRECATED @6 :List(Float32); } struct LiveTracks { trackId @0 :Int32; dRel @1 :Float32; yRel @2 :Float32; vRel @3 :Float32; aRel @4 :Float32; timeStamp @5 :Float32; status @6 :Float32; currentTime @7 :Float32; stationary @8 :Bool; oncoming @9 :Bool; } struct ControlsState @0x97ff69c53601abf1 { startMonoTime @48 :UInt64; canMonoTimes @21 :List(UInt64); longitudinalPlanMonoTime @28 :UInt64; lateralPlanMonoTime @50 :UInt64; state @31 :OpenpilotState; enabled @19 :Bool; active @36 :Bool; longControlState @30 :Car.CarControl.Actuators.LongControlState; vPid @2 :Float32; vTargetLead @3 :Float32; vCruise @22 :Float32; upAccelCmd @4 :Float32; uiAccelCmd @5 :Float32; ufAccelCmd @33 :Float32; aTarget @35 :Float32; curvature @37 :Float32; # path curvature from vehicle model forceDecel @51 :Bool; # UI alerts alertText1 @24 :Text; alertText2 @25 :Text; alertStatus @38 :AlertStatus; alertSize @39 :AlertSize; alertBlinkingRate @42 :Float32; alertType @44 :Text; alertSound @56 :Car.CarControl.HUDControl.AudibleAlert; engageable @41 :Bool; # can OP be engaged? cumLagMs @15 :Float32; canErrorCounter @57 :UInt32; lateralControlState :union { indiState @52 :LateralINDIState; pidState @53 :LateralPIDState; lqrState @55 :LateralLQRState; angleState @58 :LateralAngleState; debugState @59 :LateralDebugState; } enum OpenpilotState @0xdbe58b96d2d1ac61 { disabled @0; preEnabled @1; enabled @2; softDisabling @3; } enum AlertStatus { normal @0; # low priority alert for user's convenience userPrompt @1; # mid priority alert that might require user intervention critical @2; # high priority alert that needs immediate user intervention } enum AlertSize { none @0; # don't display the alert small @1; # small box mid @2; # mid screen full @3; # full screen } struct LateralINDIState { active @0 :Bool; steeringAngleDeg @1 :Float32; steeringRateDeg @2 :Float32; steeringAccelDeg @3 :Float32; rateSetPoint @4 :Float32; accelSetPoint @5 :Float32; accelError @6 :Float32; delayedOutput @7 :Float32; delta @8 :Float32; output @9 :Float32; saturated @10 :Bool; } struct LateralPIDState { active @0 :Bool; steeringAngleDeg @1 :Float32; steeringRateDeg @2 :Float32; angleError @3 :Float32; p @4 :Float32; i @5 :Float32; f @6 :Float32; output @7 :Float32; saturated @8 :Bool; } struct LateralLQRState { active @0 :Bool; steeringAngleDeg @1 :Float32; i @2 :Float32; output @3 :Float32; lqrOutput @4 :Float32; saturated @5 :Bool; } struct LateralAngleState { active @0 :Bool; steeringAngleDeg @1 :Float32; output @2 :Float32; saturated @3 :Bool; } struct LateralDebugState { active @0 :Bool; steeringAngleDeg @1 :Float32; output @2 :Float32; saturated @3 :Bool; } # deprecated vEgoDEPRECATED @0 :Float32; vEgoRawDEPRECATED @32 :Float32; aEgoDEPRECATED @1 :Float32; canMonoTimeDEPRECATED @16 :UInt64; radarStateMonoTimeDEPRECATED @17 :UInt64; mdMonoTimeDEPRECATED @18 :UInt64; yActualDEPRECATED @6 :Float32; yDesDEPRECATED @7 :Float32; upSteerDEPRECATED @8 :Float32; uiSteerDEPRECATED @9 :Float32; ufSteerDEPRECATED @34 :Float32; aTargetMinDEPRECATED @10 :Float32; aTargetMaxDEPRECATED @11 :Float32; rearViewCamDEPRECATED @23 :Bool; driverMonitoringOnDEPRECATED @43 :Bool; hudLeadDEPRECATED @14 :Int32; alertSoundDEPRECATED @45 :Text; angleModelBiasDEPRECATED @27 :Float32; gpsPlannerActiveDEPRECATED @40 :Bool; decelForTurnDEPRECATED @47 :Bool; decelForModelDEPRECATED @54 :Bool; awarenessStatusDEPRECATED @26 :Float32; angleSteers @13 :Float32; # dp vCurvatureDEPRECATED @46 :Float32; mapValidDEPRECATED @49 :Bool; jerkFactorDEPRECATED @12 :Float32; steerOverrideDEPRECATED @20 :Bool; steeringAngleDesiredDeg @29 :Float32; # dp } struct ModelDataV2 { frameId @0 :UInt32; frameAge @1 :UInt32; frameDropPerc @2 :Float32; timestampEof @3 :UInt64; modelExecutionTime @15 :Float32; gpuExecutionTime @17 :Float32; rawPredictions @16 :Data; # predicted future position, orientation, etc.. position @4 :XYZTData; orientation @5 :XYZTData; velocity @6 :XYZTData; orientationRate @7 :XYZTData; # prediction lanelines and road edges laneLines @8 :List(XYZTData); laneLineProbs @9 :List(Float32); laneLineStds @13 :List(Float32); roadEdges @10 :List(XYZTData); roadEdgeStds @14 :List(Float32); # predicted lead cars leads @11 :List(LeadDataV2); leadsV3 @18 :List(LeadDataV3); meta @12 :MetaData; # All SI units and in device frame struct XYZTData { x @0 :List(Float32); y @1 :List(Float32); z @2 :List(Float32); t @3 :List(Float32); xStd @4 :List(Float32); yStd @5 :List(Float32); zStd @6 :List(Float32); } struct LeadDataV2 { prob @0 :Float32; # probability that car is your lead at time t t @1 :Float32; # x and y are relative position in device frame # v is norm relative speed # a is norm relative acceleration xyva @2 :List(Float32); xyvaStd @3 :List(Float32); } struct LeadDataV3 { prob @0 :Float32; # probability that car is your lead at time t probTime @1 :Float32; t @2 :List(Float32); # x and y are relative position in device frame # v absolute norm speed # a is derivative of v x @3 :List(Float32); xStd @4 :List(Float32); y @5 :List(Float32); yStd @6 :List(Float32); v @7 :List(Float32); vStd @8 :List(Float32); a @9 :List(Float32); aStd @10 :List(Float32); } struct MetaData { engagedProb @0 :Float32; desirePrediction @1 :List(Float32); desireState @5 :List(Float32); disengagePredictions @6 :DisengagePredictions; hardBrakePredicted @7 :Bool; # deprecated brakeDisengageProbDEPRECATED @2 :Float32; gasDisengageProbDEPRECATED @3 :Float32; steerOverrideProbDEPRECATED @4 :Float32; } struct DisengagePredictions { t @0 :List(Float32); brakeDisengageProbs @1 :List(Float32); gasDisengageProbs @2 :List(Float32); steerOverrideProbs @3 :List(Float32); brake3MetersPerSecondSquaredProbs @4 :List(Float32); brake4MetersPerSecondSquaredProbs @5 :List(Float32); brake5MetersPerSecondSquaredProbs @6 :List(Float32); } } struct EncodeIndex { # picture from camera frameId @0 :UInt32; type @1 :Type; # index of encoder from start of route encodeId @2 :UInt32; # minute long segment this frame is in segmentNum @3 :Int32; # index into camera file in segment in presentation order segmentId @4 :UInt32; # index into camera file in segment in encode order segmentIdEncode @5 :UInt32; timestampSof @6 :UInt64; timestampEof @7 :UInt64; enum Type { bigBoxLossless @0; # rcamera.mkv fullHEVC @1; # fcamera.hevc bigBoxHEVC @2; # bcamera.hevc chffrAndroidH264 @3; # acamera fullLosslessClip @4; # prcamera.mkv front @5; # dcamera.hevc } } struct AndroidLogEntry { id @0 :UInt8; ts @1 :UInt64; priority @2 :UInt8; pid @3 :Int32; tid @4 :Int32; tag @5 :Text; message @6 :Text; } struct LongitudinalPlan @0xe00b5b3eba12876c { modelMonoTime @9 :UInt64; hasLead @7 :Bool; fcw @8 :Bool; longitudinalPlanSource @15 :LongitudinalPlanSource; processingDelay @29 :Float32; # desired speed/accel/jerk over next 2.5s accels @32 :List(Float32); speeds @33 :List(Float32); jerks @34 :List(Float32); visionTurnControllerState @35 :VisionTurnControllerState; visionTurnSpeed @36 :Float32; speedLimitControlState @37 :SpeedLimitControlState; speedLimit @38 :Float32; speedLimitOffset @39 :Float32; distToSpeedLimit @40 :Float32; isMapSpeedLimit @41 :Bool; distToTurn @42 :Float32; turnSpeed @43 :Float32; turnSpeedControlState @44 :SpeedLimitControlState; turnSign @45 :Int16; enum LongitudinalPlanSource { cruise @0; lead0 @1; lead1 @2; lead2 @3; e2e @4; turn @5; limit @6; turnlimit @7; } # deprecated vCruiseDEPRECATED @16 :Float32; aCruiseDEPRECATED @17 :Float32; vTargetDEPRECATED @3 :Float32; vTargetFutureDEPRECATED @14 :Float32; aTargetDEPRECATED @18 :Float32; vStartDEPRECATED @26 :Float32; aStartDEPRECATED @27 :Float32; vMaxDEPRECATED @20 :Float32; radarStateMonoTimeDEPRECATED @10 :UInt64; jerkFactorDEPRECATED @6 :Float32; hasLeftLaneDEPRECATED @23 :Bool; hasRightLaneDEPRECATED @24 :Bool; aTargetMinDEPRECATED @4 :Float32; aTargetMaxDEPRECATED @5 :Float32; lateralValidDEPRECATED @0 :Bool; longitudinalValidDEPRECATED @2 :Bool; dPolyDEPRECATED @1 :List(Float32); laneWidthDEPRECATED @11 :Float32; vCurvatureDEPRECATED @21 :Float32; decelForTurnDEPRECATED @22 :Bool; mapValidDEPRECATED @25 :Bool; radarValidDEPRECATED @28 :Bool; radarCanErrorDEPRECATED @30 :Bool; commIssueDEPRECATED @31 :Bool; eventsDEPRECATED @13 :List(Car.CarEvent); gpsTrajectoryDEPRECATED @12 :GpsTrajectory; gpsPlannerActiveDEPRECATED @19 :Bool; struct GpsTrajectory { x @0 :List(Float32); y @1 :List(Float32); } enum SpeedLimitControlState { inactive @0; # No speed limit set or not enabled by parameter. tempInactive @1; # User wants to ignore speed limit until it changes. adapting @2; # Reducing speed to match new speed limit. active @3; # Cruising at speed limit. } enum VisionTurnControllerState { disabled @0; # No predicted substancial turn on vision range or feature disabled. entering @1; # A subsantial turn is predicted ahead, adapting speed to turn confort levels. turning @2; # Actively turning. Managing acceleration to provide a roll on turn feeling. leaving @3; # Road ahead straightens. Start to allow positive acceleration. } } struct LateralPlan @0xe1e9318e2ae8b51e { laneWidth @0 :Float32; lProb @5 :Float32; rProb @7 :Float32; dPathPoints @20 :List(Float32); dProb @21 :Float32; dPathWLinesX @30 :List(Float32); dPathWLinesY @31 :List(Float32); mpcSolutionValid @9 :Bool; desire @17 :Desire; laneChangeState @18 :LaneChangeState; laneChangeDirection @19 :LaneChangeDirection; # desired curvatures over next 2.5s in rad/m psis @26 :List(Float32); curvatures @27 :List(Float32); curvatureRates @28 :List(Float32); # dp dpALCAStartIn @29 :Float32; # 30~31 are being used in mapd dpLaneLessModeStatus @32 :Bool; enum Desire { none @0; turnLeft @1; turnRight @2; laneChangeLeft @3; laneChangeRight @4; keepLeft @5; keepRight @6; } enum LaneChangeState { off @0; preLaneChange @1; laneChangeStarting @2; laneChangeFinishing @3; } enum LaneChangeDirection { none @0; left @1; right @2; } # deprecated curvatureDEPRECATED @22 :Float32; curvatureRateDEPRECATED @23 :Float32; rawCurvatureDEPRECATED @24 :Float32; rawCurvatureRateDEPRECATED @25 :Float32; cProbDEPRECATED @3 :Float32; dPolyDEPRECATED @1 :List(Float32); cPolyDEPRECATED @2 :List(Float32); lPolyDEPRECATED @4 :List(Float32); rPolyDEPRECATED @6 :List(Float32); modelValidDEPRECATED @12 :Bool; commIssueDEPRECATED @15 :Bool; posenetValidDEPRECATED @16 :Bool; sensorValidDEPRECATED @14 :Bool; paramsValidDEPRECATED @10 :Bool; steeringAngleDegDEPRECATED @8 :Float32; # deg steeringRateDegDEPRECATED @13 :Float32; # deg/s angleOffsetDegDEPRECATED @11 :Float32; } struct LiveLocationKalman { # More info on reference frames: # https://github.com/commaai/openpilot/tree/master/common/transformations positionECEF @0 : Measurement; positionGeodetic @1 : Measurement; velocityECEF @2 : Measurement; velocityNED @3 : Measurement; velocityDevice @4 : Measurement; accelerationDevice @5: Measurement; # These angles are all eulers and roll, pitch, yaw # orientationECEF transforms to rot matrix: ecef_from_device orientationECEF @6 : Measurement; calibratedOrientationECEF @20 : Measurement; orientationNED @7 : Measurement; angularVelocityDevice @8 : Measurement; # orientationNEDCalibrated transforms to rot matrix: NED_from_calibrated calibratedOrientationNED @9 : Measurement; # Calibrated frame is simply device frame # aligned with the vehicle velocityCalibrated @10 : Measurement; accelerationCalibrated @11 : Measurement; angularVelocityCalibrated @12 : Measurement; gpsWeek @13 :Int32; gpsTimeOfWeek @14 :Float64; status @15 :Status; unixTimestampMillis @16 :Int64; inputsOK @17 :Bool = true; posenetOK @18 :Bool = true; gpsOK @19 :Bool = true; sensorsOK @21 :Bool = true; deviceStable @22 :Bool = true; timeSinceReset @23 :Float64; excessiveResets @24 :Bool; enum Status { uninitialized @0; uncalibrated @1; valid @2; } struct Measurement { value @0 : List(Float64); std @1 : List(Float64); valid @2 : Bool; } } struct ProcLog { cpuTimes @0 :List(CPUTimes); mem @1 :Mem; procs @2 :List(Process); struct Process { pid @0 :Int32; name @1 :Text; state @2 :UInt8; ppid @3 :Int32; cpuUser @4 :Float32; cpuSystem @5 :Float32; cpuChildrenUser @6 :Float32; cpuChildrenSystem @7 :Float32; priority @8 :Int64; nice @9 :Int32; numThreads @10 :Int32; startTime @11 :Float64; memVms @12 :UInt64; memRss @13 :UInt64; processor @14 :Int32; cmdline @15 :List(Text); exe @16 :Text; } struct CPUTimes { cpuNum @0 :Int64; user @1 :Float32; nice @2 :Float32; system @3 :Float32; idle @4 :Float32; iowait @5 :Float32; irq @6 :Float32; softirq @7 :Float32; } struct Mem { total @0 :UInt64; free @1 :UInt64; available @2 :UInt64; buffers @3 :UInt64; cached @4 :UInt64; active @5 :UInt64; inactive @6 :UInt64; shared @7 :UInt64; } } struct UbloxGnss { union { measurementReport @0 :MeasurementReport; ephemeris @1 :Ephemeris; ionoData @2 :IonoData; hwStatus @3 :HwStatus; hwStatus2 @4 :HwStatus2; } struct MeasurementReport { #received time of week in gps time in seconds and gps week rcvTow @0 :Float64; gpsWeek @1 :UInt16; # leap seconds in seconds leapSeconds @2 :UInt16; # receiver status receiverStatus @3 :ReceiverStatus; # num of measurements to follow numMeas @4 :UInt8; measurements @5 :List(Measurement); struct ReceiverStatus { # leap seconds have been determined leapSecValid @0 :Bool; # Clock reset applied clkReset @1 :Bool; } struct Measurement { svId @0 :UInt8; trackingStatus @1 :TrackingStatus; # pseudorange in meters pseudorange @2 :Float64; # carrier phase measurement in cycles carrierCycles @3 :Float64; # doppler measurement in Hz doppler @4 :Float32; # GNSS id, 0 is gps gnssId @5 :UInt8; glonassFrequencyIndex @6 :UInt8; # carrier phase locktime counter in ms locktime @7 :UInt16; # Carrier-to-noise density ratio (signal strength) in dBHz cno @8 :UInt8; # pseudorange standard deviation in meters pseudorangeStdev @9 :Float32; # carrier phase standard deviation in cycles carrierPhaseStdev @10 :Float32; # doppler standard deviation in Hz dopplerStdev @11 :Float32; sigId @12 :UInt8; struct TrackingStatus { # pseudorange valid pseudorangeValid @0 :Bool; # carrier phase valid carrierPhaseValid @1 :Bool; # half cycle valid halfCycleValid @2 :Bool; # half sycle subtracted from phase halfCycleSubtracted @3 :Bool; } } } struct Ephemeris { # This is according to the rinex (2?) format svId @0 :UInt16; year @1 :UInt16; month @2 :UInt16; day @3 :UInt16; hour @4 :UInt16; minute @5 :UInt16; second @6 :Float32; af0 @7 :Float64; af1 @8 :Float64; af2 @9 :Float64; iode @10 :Float64; crs @11 :Float64; deltaN @12 :Float64; m0 @13 :Float64; cuc @14 :Float64; ecc @15 :Float64; cus @16 :Float64; a @17 :Float64; # note that this is not the root!! toe @18 :Float64; cic @19 :Float64; omega0 @20 :Float64; cis @21 :Float64; i0 @22 :Float64; crc @23 :Float64; omega @24 :Float64; omegaDot @25 :Float64; iDot @26 :Float64; codesL2 @27 :Float64; gpsWeek @28 :Float64; l2 @29 :Float64; svAcc @30 :Float64; svHealth @31 :Float64; tgd @32 :Float64; iodc @33 :Float64; transmissionTime @34 :Float64; fitInterval @35 :Float64; toc @36 :Float64; ionoCoeffsValid @37 :Bool; ionoAlpha @38 :List(Float64); ionoBeta @39 :List(Float64); } struct IonoData { svHealth @0 :UInt32; tow @1 :Float64; gpsWeek @2 :Float64; ionoAlpha @3 :List(Float64); ionoBeta @4 :List(Float64); healthValid @5 :Bool; ionoCoeffsValid @6 :Bool; } struct HwStatus { noisePerMS @0 :UInt16; agcCnt @1 :UInt16; aStatus @2 :AntennaSupervisorState; aPower @3 :AntennaPowerStatus; jamInd @4 :UInt8; flags @5 :UInt8; enum AntennaSupervisorState { init @0; dontknow @1; ok @2; short @3; open @4; } enum AntennaPowerStatus { off @0; on @1; dontknow @2; } } struct HwStatus2 { ofsI @0 :Int8; magI @1 :UInt8; ofsQ @2 :Int8; magQ @3 :UInt8; cfgSource @4 :ConfigSource; lowLevCfg @5 :UInt32; postStatus @6 :UInt32; enum ConfigSource { undefined @0; rom @1; otp @2; configpins @3; flash @4; } } } struct Clocks { bootTimeNanos @0 :UInt64; monotonicNanos @1 :UInt64; monotonicRawNanos @2 :UInt64; wallTimeNanos @3 :UInt64; modemUptimeMillis @4 :UInt64; } struct LiveMpcData { x @0 :List(Float32); y @1 :List(Float32); psi @2 :List(Float32); curvature @3 :List(Float32); qpIterations @4 :UInt32; calculationTime @5 :UInt64; cost @6 :Float64; } struct LiveLongitudinalMpcData { xEgo @0 :List(Float32); vEgo @1 :List(Float32); aEgo @2 :List(Float32); xLead @3 :List(Float32); vLead @4 :List(Float32); aLead @5 :List(Float32); aLeadTau @6 :Float32; # lead accel time constant qpIterations @7 :UInt32; mpcId @8 :UInt32; calculationTime @9 :UInt64; cost @10 :Float64; } struct Joystick { # convenient for debug and live tuning axes @0: List(Float32); buttons @1: List(Bool); } struct DriverState { frameId @0 :UInt32; modelExecutionTime @14 :Float32; dspExecutionTime @16 :Float32; rawPredictions @15 :Data; faceOrientation @3 :List(Float32); facePosition @4 :List(Float32); faceProb @5 :Float32; leftEyeProb @6 :Float32; rightEyeProb @7 :Float32; leftBlinkProb @8 :Float32; rightBlinkProb @9 :Float32; faceOrientationStd @11 :List(Float32); facePositionStd @12 :List(Float32); sunglassesProb @13 :Float32; poorVision @17 :Float32; partialFace @18 :Float32; distractedPose @19 :Float32; distractedEyes @20 :Float32; eyesOnRoad @21 :Float32; phoneUse @22 :Float32; irPwrDEPRECATED @10 :Float32; descriptorDEPRECATED @1 :List(Float32); stdDEPRECATED @2 :Float32; } struct DriverMonitoringState @0xb83cda094a1da284 { events @0 :List(Car.CarEvent); faceDetected @1 :Bool; isDistracted @2 :Bool; awarenessStatus @3 :Float32; posePitchOffset @6 :Float32; posePitchValidCount @7 :UInt32; poseYawOffset @8 :Float32; poseYawValidCount @9 :UInt32; stepChange @10 :Float32; awarenessActive @11 :Float32; awarenessPassive @12 :Float32; isLowStd @13 :Bool; hiStdCount @14 :UInt32; isActiveMode @16 :Bool; isRHDDEPRECATED @4 :Bool; isPreviewDEPRECATED @15 :Bool; rhdCheckedDEPRECATED @5 :Bool; } struct Boot { wallTimeNanos @0 :UInt64; pstore @4 :Map(Text, Data); launchLog @3 :Text; lastKmsgDEPRECATED @1 :Data; lastPmsgDEPRECATED @2 :Data; } struct LiveParametersData { valid @0 :Bool; gyroBias @1 :Float32; angleOffsetDeg @2 :Float32; angleOffsetAverageDeg @3 :Float32; stiffnessFactor @4 :Float32; steerRatio @5 :Float32; sensorValid @6 :Bool; yawRate @7 :Float32; posenetSpeed @8 :Float32; posenetValid @9 :Bool; } struct LiveMapDataDEPRECATED { speedLimitValid @0 :Bool; speedLimit @1 :Float32; speedAdvisoryValid @12 :Bool; speedAdvisory @13 :Float32; speedLimitAheadValid @14 :Bool; speedLimitAhead @15 :Float32; speedLimitAheadDistance @16 :Float32; curvatureValid @2 :Bool; curvature @3 :Float32; wayId @4 :UInt64; roadX @5 :List(Float32); roadY @6 :List(Float32); lastGps @7: GpsLocationData; roadCurvatureX @8 :List(Float32); roadCurvature @9 :List(Float32); distToTurn @10 :Float32; mapValid @11 :Bool; } struct LiveMapData { speedLimitValid @0 :Bool; speedLimit @1 :Float32; speedLimitAheadValid @2 :Bool; speedLimitAhead @3 :Float32; speedLimitAheadDistance @4 :Float32; turnSpeedLimitValid @5 :Bool; turnSpeedLimit @6 :Float32; turnSpeedLimitEndDistance @7 :Float32; turnSpeedLimitSign @8 :Int16; turnSpeedLimitsAhead @9 :List(Float32); turnSpeedLimitsAheadDistances @10 :List(Float32); turnSpeedLimitsAheadSigns @11 :List(Int16); lastGpsTimestamp @12 :Int64; # Milliseconds since January 1, 1970. currentRoadName @13 :Text; } struct CameraOdometry { frameId @4 :UInt32; timestampEof @5 :UInt64; trans @0 :List(Float32); # m/s in device frame rot @1 :List(Float32); # rad/s in device frame transStd @2 :List(Float32); # std m/s in device frame rotStd @3 :List(Float32); # std rad/s in device frame } struct Sentinel { enum SentinelType { endOfSegment @0; endOfRoute @1; startOfSegment @2; startOfRoute @3; } type @0 :SentinelType; signal @1 :Int32; } struct ManagerState { processes @0 :List(ProcessState); struct ProcessState { name @0 :Text; pid @1 :Int32; running @2 :Bool; exitCode @3 :Int32; } } struct UploaderState { immediateQueueSize @0 :UInt32; immediateQueueCount @1 :UInt32; rawQueueSize @2 :UInt32; rawQueueCount @3 :UInt32; # stats for last successfully uploaded file lastTime @4 :Float32; # s lastSpeed @5 :Float32; # MB/s lastFilename @6 :Text; } struct Event { logMonoTime @0 :UInt64; # nanoseconds valid @67 :Bool = true; union { # *********** log metadata *********** initData @1 :InitData; sentinel @73 :Sentinel; # *********** bootlog *********** boot @60 :Boot; # ********** openpilot daemon msgs ********** gpsNMEA @3 :GPSNMEAData; can @5 :List(CanData); controlsState @7 :ControlsState; sensorEvents @11 :List(SensorEventData); pandaState @12 :PandaState; radarState @13 :RadarState; liveTracks @16 :List(LiveTracks); sendcan @17 :List(CanData); liveCalibration @19 :LiveCalibrationData; carState @22 :Car.CarState; carControl @23 :Car.CarControl; longitudinalPlan @24 :LongitudinalPlan; lateralPlan @64 :LateralPlan; ubloxGnss @34 :UbloxGnss; ubloxRaw @39 :Data; gpsLocationExternal @48 :GpsLocationData; driverState @59 :DriverState; liveParameters @61 :LiveParametersData; cameraOdometry @63 :CameraOdometry; thumbnail @66: Thumbnail; carEvents @68: List(Car.CarEvent); carParams @69: Car.CarParams; driverMonitoringState @71: DriverMonitoringState; liveLocationKalman @72 :LiveLocationKalman; modelV2 @75 :ModelDataV2; # camera stuff, each camera state has a matching encode idx roadCameraState @2 :FrameData; driverCameraState @70: FrameData; wideRoadCameraState @74: FrameData; roadEncodeIdx @15 :EncodeIndex; driverEncodeIdx @76 :EncodeIndex; wideRoadEncodeIdx @77 :EncodeIndex; # systems stuff androidLog @20 :AndroidLogEntry; managerState @78 :ManagerState; uploaderState @79 :UploaderState; procLog @33 :ProcLog; clocks @35 :Clocks; deviceState @6 :DeviceState; logMessage @18 :Text; # *********** debug *********** testJoystick @52 :Joystick; # *********** legacy + deprecated *********** model @9 :Legacy.ModelData; # TODO: rename modelV2 and mark this as deprecated liveMpcDEPRECATED @36 :LiveMpcData; liveLongitudinalMpcDEPRECATED @37 :LiveLongitudinalMpcData; liveLocationKalmanDEPRECATED @51 :Legacy.LiveLocationData; orbslamCorrectionDEPRECATED @45 :Legacy.OrbslamCorrection; liveUIDEPRECATED @14 :Legacy.LiveUI; sensorEventDEPRECATED @4 :SensorEventData; liveEventDEPRECATED @8 :List(Legacy.LiveEventData); liveLocationDEPRECATED @25 :Legacy.LiveLocationData; ethernetDataDEPRECATED @26 :List(Legacy.EthernetPacket); cellInfoDEPRECATED @28 :List(Legacy.CellInfo); wifiScanDEPRECATED @29 :List(Legacy.WifiScan); uiNavigationEventDEPRECATED @50 :Legacy.UiNavigationEvent; liveMapDataDEPRECATED @62 :LiveMapDataDEPRECATED; gpsPlannerPointsDEPRECATED @40 :Legacy.GPSPlannerPoints; gpsPlannerPlanDEPRECATED @41 :Legacy.GPSPlannerPlan; applanixRawDEPRECATED @42 :Data; androidGnssDEPRECATED @30 :Legacy.AndroidGnss; qcomGnssDEPRECATD @31 :Legacy.QcomGnss; lidarPtsDEPRECATED @32 :Legacy.LidarPts; navStatusDEPRECATED @38 :Legacy.NavStatus; trafficEventsDEPRECATED @43 :List(Legacy.TrafficEvent); liveLocationTimingDEPRECATED @44 :Legacy.LiveLocationData; liveLocationCorrectedDEPRECATED @46 :Legacy.LiveLocationData; navUpdateDEPRECATED @27 :Legacy.NavUpdate; orbObservationDEPRECATED @47 :List(Legacy.OrbObservation); locationDEPRECATED @49 :Legacy.LiveLocationData; orbOdometryDEPRECATED @53 :Legacy.OrbOdometry; orbFeaturesDEPRECATED @54 :Legacy.OrbFeatures; applanixLocationDEPRECATED @55 :Legacy.LiveLocationData; orbKeyFrameDEPRECATED @56 :Legacy.OrbKeyFrame; orbFeaturesSummaryDEPRECATED @58 :Legacy.OrbFeaturesSummary; featuresDEPRECATED @10 :Legacy.CalibrationFeatures; kalmanOdometryDEPRECATED @65 :Legacy.KalmanOdometry; gpsLocationDEPRECATED @21 :GpsLocationData; uiLayoutStateDEPRECATED @57 :Legacy.UiLayoutState; dragonConf @80 :Dp.DragonConf; #mapd liveMapData @81: LiveMapData; } } ================================================ FILE: cereal/logger/logger.h ================================================ #pragma once #ifdef SWAGLOG #include "selfdrive/common/swaglog.h" #else #define CLOUDLOG_DEBUG 10 #define CLOUDLOG_INFO 20 #define CLOUDLOG_WARNING 30 #define CLOUDLOG_ERROR 40 #define CLOUDLOG_CRITICAL 50 #define cloudlog(lvl, fmt, ...) printf(fmt "\n", ## __VA_ARGS__) #define LOGD(fmt, ...) cloudlog(CLOUDLOG_DEBUG, fmt, ## __VA_ARGS__) #define LOG(fmt, ...) cloudlog(CLOUDLOG_INFO, fmt, ## __VA_ARGS__) #define LOGW(fmt, ...) cloudlog(CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) #define LOGE(fmt, ...) cloudlog(CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) #endif ================================================ FILE: cereal/messaging/.gitignore ================================================ demo bridge test_runner *.o *.os *.d *.a *.so messaging_pyx.cpp build/ ================================================ FILE: cereal/messaging/__init__.py ================================================ # must be build with scons from .messaging_pyx import Context, Poller, SubSocket, PubSocket # pylint: disable=no-name-in-module, import-error from .messaging_pyx import MultiplePublishersError, MessagingError # pylint: disable=no-name-in-module, import-error import os import capnp from typing import Optional, List, Union from collections import deque from cereal import log from cereal.services import service_list assert MultiplePublishersError assert MessagingError NO_TRAVERSAL_LIMIT = 2**64-1 AVG_FREQ_HISTORY = 100 SIMULATION = "SIMULATION" in os.environ # sec_since_boot is faster, but allow to run standalone too try: from common.realtime import sec_since_boot except ImportError: import time sec_since_boot = time.time print("Warning, using python time.time() instead of faster sec_since_boot") context = Context() def log_from_bytes(dat: bytes) -> capnp.lib.capnp._DynamicStructReader: return log.Event.from_bytes(dat, traversal_limit_in_words=NO_TRAVERSAL_LIMIT) def new_message(service: Optional[str] = None, size: Optional[int] = None) -> capnp.lib.capnp._DynamicStructBuilder: dat = log.Event.new_message() dat.logMonoTime = int(sec_since_boot() * 1e9) dat.valid = True if service is not None: if size is None: dat.init(service) else: dat.init(service, size) return dat def pub_sock(endpoint: str) -> PubSocket: sock = PubSocket() sock.connect(context, endpoint) return sock def sub_sock(endpoint: str, poller: Optional[Poller] = None, addr: str = "127.0.0.1", conflate: bool = False, timeout: Optional[int] = None) -> SubSocket: sock = SubSocket() sock.connect(context, endpoint, addr.encode('utf8'), conflate) if timeout is not None: sock.setTimeout(timeout) if poller is not None: poller.registerSocket(sock) return sock def drain_sock_raw(sock: SubSocket, wait_for_one: bool = False) -> List[bytes]: """Receive all message currently available on the queue""" ret: List[bytes] = [] while 1: if wait_for_one and len(ret) == 0: dat = sock.receive() else: dat = sock.receive(non_blocking=True) if dat is None: break ret.append(dat) return ret def drain_sock(sock: SubSocket, wait_for_one: bool = False) -> List[capnp.lib.capnp._DynamicStructReader]: """Receive all message currently available on the queue""" ret: List[capnp.lib.capnp._DynamicStructReader] = [] while 1: if wait_for_one and len(ret) == 0: dat = sock.receive() else: dat = sock.receive(non_blocking=True) if dat is None: # Timeout hit break dat = log_from_bytes(dat) ret.append(dat) return ret # TODO: print when we drop packets? def recv_sock(sock: SubSocket, wait: bool = False) -> Union[None, capnp.lib.capnp._DynamicStructReader]: """Same as drain sock, but only returns latest message. Consider using conflate instead.""" dat = None while 1: if wait and dat is None: rcv = sock.receive() else: rcv = sock.receive(non_blocking=True) if rcv is None: # Timeout hit break dat = rcv if dat is not None: dat = log_from_bytes(dat) return dat def recv_one(sock: SubSocket) -> Union[None, capnp.lib.capnp._DynamicStructReader]: dat = sock.receive() if dat is not None: dat = log_from_bytes(dat) return dat def recv_one_or_none(sock: SubSocket) -> Union[None, capnp.lib.capnp._DynamicStructReader]: dat = sock.receive(non_blocking=True) if dat is not None: dat = log_from_bytes(dat) return dat def recv_one_retry(sock: SubSocket) -> capnp.lib.capnp._DynamicStructReader: """Keep receiving until we get a message""" while True: dat = sock.receive() if dat is not None: return log_from_bytes(dat) class SubMaster(): def __init__(self, services: List[str], poll: Optional[List[str]] = None, ignore_alive: Optional[List[str]] = None, ignore_avg_freq: Optional[List[str]] = None, addr: str = "127.0.0.1"): self.frame = -1 self.updated = {s: False for s in services} self.rcv_time = {s: 0. for s in services} self.rcv_frame = {s: 0 for s in services} self.alive = {s: False for s in services} self.recv_dts = {s: deque([0.0] * AVG_FREQ_HISTORY, maxlen=AVG_FREQ_HISTORY) for s in services} self.sock = {} self.freq = {} self.data = {} self.valid = {} self.logMonoTime = {} self.poller = Poller() self.non_polled_services = [s for s in services if poll is not None and len(poll) and s not in poll] self.ignore_average_freq = [] if ignore_avg_freq is None else ignore_avg_freq self.ignore_alive = [] if ignore_alive is None else ignore_alive for s in services: if addr is not None: p = self.poller if s not in self.non_polled_services else None self.sock[s] = sub_sock(s, poller=p, addr=addr, conflate=True) self.freq[s] = service_list[s].frequency try: data = new_message(s) except capnp.lib.capnp.KjException: # pylint: disable=c-extension-no-member data = new_message(s, 0) # lists self.data[s] = getattr(data, s) self.logMonoTime[s] = 0 self.valid[s] = data.valid def __getitem__(self, s: str) -> capnp.lib.capnp._DynamicStructReader: return self.data[s] def update(self, timeout: int = 1000) -> None: msgs = [] for sock in self.poller.poll(timeout): msgs.append(recv_one_or_none(sock)) # non-blocking receive for non-polled sockets for s in self.non_polled_services: msgs.append(recv_one_or_none(self.sock[s])) self.update_msgs(sec_since_boot(), msgs) def update_msgs(self, cur_time: float, msgs: List[capnp.lib.capnp._DynamicStructReader]) -> None: self.frame += 1 self.updated = dict.fromkeys(self.updated, False) for msg in msgs: if msg is None: continue s = msg.which() self.updated[s] = True if self.rcv_time[s] > 1e-5 and self.freq[s] > 1e-5 and (s not in self.non_polled_services) \ and (s not in self.ignore_average_freq): self.recv_dts[s].append(cur_time - self.rcv_time[s]) self.rcv_time[s] = cur_time self.rcv_frame[s] = self.frame self.data[s] = getattr(msg, s) self.logMonoTime[s] = msg.logMonoTime self.valid[s] = msg.valid if SIMULATION: self.alive[s] = True if not SIMULATION: for s in self.data: # arbitrary small number to avoid float comparison. If freq is 0, we can skip the check if self.freq[s] > 1e-5: # alive if delay is within 10x the expected frequency self.alive[s] = (cur_time - self.rcv_time[s]) < (10. / self.freq[s]) # alive if average frequency is higher than 90% of expected frequency avg_dt = sum(self.recv_dts[s]) / AVG_FREQ_HISTORY expected_dt = 1 / (self.freq[s] * 0.90) self.alive[s] = self.alive[s] and (avg_dt < expected_dt) else: self.alive[s] = True def all_alive(self, service_list=None) -> bool: if service_list is None: # check all service_list = self.alive.keys() return all(self.alive[s] for s in service_list if s not in self.ignore_alive) def all_valid(self, service_list=None) -> bool: if service_list is None: # check all service_list = self.valid.keys() return all(self.valid[s] for s in service_list) def all_alive_and_valid(self, service_list=None) -> bool: if service_list is None: # check all service_list = self.alive.keys() return self.all_alive(service_list=service_list) and self.all_valid(service_list=service_list) class PubMaster(): def __init__(self, services: List[str]): self.sock = {} for s in services: self.sock[s] = pub_sock(s) def send(self, s: str, dat: Union[bytes, capnp.lib.capnp._DynamicStructBuilder]) -> None: if not isinstance(dat, bytes): dat = dat.to_bytes() self.sock[s].send(dat) def all_readers_updated(self, s: str) -> bool: return self.sock[s].all_readers_updated() ================================================ FILE: cereal/messaging/bridge.cc ================================================ #include #include #include #include #include #include typedef void (*sighandler_t)(int sig); #include "impl_msgq.h" #include "impl_zmq.h" #include "services.h" void sigpipe_handler(int sig) { assert(sig == SIGPIPE); std::cout << "SIGPIPE received" << std::endl; } static std::vector get_services(std::string whitelist_str, bool zmq_to_msgq) { std::vector service_list; for (const auto& it : services) { std::string name = it.name; bool in_whitelist = whitelist_str.find(name) != std::string::npos; if (name == "plusFrame" || name == "uiLayoutState" || (zmq_to_msgq && !in_whitelist)) { continue; } service_list.push_back(name); } return service_list; } int main(int argc, char** argv) { signal(SIGPIPE, (sighandler_t)sigpipe_handler); bool zmq_to_msgq = argc > 2; std::string ip = zmq_to_msgq ? argv[1] : "127.0.0.1"; std::string whitelist_str = zmq_to_msgq ? std::string(argv[2]) : ""; Poller *poller; Context *pub_context; Context *sub_context; if (zmq_to_msgq) { // republishes zmq debugging messages as msgq poller = new ZMQPoller(); pub_context = new MSGQContext(); sub_context = new ZMQContext(); } else { poller = new MSGQPoller(); pub_context = new ZMQContext(); sub_context = new MSGQContext(); } std::map sub2pub; for (auto endpoint: get_services(whitelist_str, zmq_to_msgq)) { PubSocket * pub_sock; SubSocket * sub_sock; if (zmq_to_msgq) { pub_sock = new MSGQPubSocket(); sub_sock = new ZMQSubSocket(); } else { pub_sock = new ZMQPubSocket(); sub_sock = new MSGQSubSocket(); } pub_sock->connect(pub_context, endpoint); sub_sock->connect(sub_context, endpoint, ip, false); poller->registerSocket(sub_sock); sub2pub[sub_sock] = pub_sock; } while (true) { for (auto sub_sock : poller->poll(100)) { Message * msg = sub_sock->receive(); if (msg == NULL) continue; sub2pub[sub_sock]->sendMessage(msg); delete msg; } } return 0; } ================================================ FILE: cereal/messaging/impl_msgq.cc ================================================ #include #include #include #include #include #include #include "services.h" #include "impl_msgq.h" volatile sig_atomic_t msgq_do_exit = 0; void sig_handler(int signal) { assert(signal == SIGINT || signal == SIGTERM); msgq_do_exit = 1; } static bool service_exists(std::string path){ for (const auto& it : services) { if (it.name == path) { return true; } } return false; } static size_t get_size(std::string endpoint){ size_t sz = DEFAULT_SEGMENT_SIZE; if (endpoint == "roadCameraState" || endpoint == "driverCameraState" || endpoint == "wideRoadCameraState"){ sz *= 10; } return sz; } MSGQContext::MSGQContext() { } MSGQContext::~MSGQContext() { } void MSGQMessage::init(size_t sz) { size = sz; data = new char[size]; } void MSGQMessage::init(char * d, size_t sz) { size = sz; data = new char[size]; memcpy(data, d, size); } void MSGQMessage::takeOwnership(char * d, size_t sz) { size = sz; data = d; } void MSGQMessage::close() { if (size > 0){ delete[] data; } size = 0; } MSGQMessage::~MSGQMessage() { this->close(); } int MSGQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){ assert(context); assert(address == "127.0.0.1"); if (check_endpoint && !service_exists(std::string(endpoint))){ std::cout << "Warning, " << std::string(endpoint) << " is not in service list." << std::endl; } q = new msgq_queue_t; int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint)); if (r != 0){ return r; } msgq_init_subscriber(q); if (conflate){ q->read_conflate = true; } timeout = -1; return 0; } Message * MSGQSubSocket::receive(bool non_blocking){ msgq_do_exit = 0; void (*prev_handler_sigint)(int); void (*prev_handler_sigterm)(int); if (!non_blocking){ prev_handler_sigint = std::signal(SIGINT, sig_handler); prev_handler_sigterm = std::signal(SIGTERM, sig_handler); } msgq_msg_t msg; MSGQMessage *r = NULL; int rc = msgq_msg_recv(&msg, q); // Hack to implement blocking read with a poller. Don't use this while (!non_blocking && rc == 0 && msgq_do_exit == 0){ msgq_pollitem_t items[1]; items[0].q = q; int t = (timeout != -1) ? timeout : 100; int n = msgq_poll(items, 1, t); rc = msgq_msg_recv(&msg, q); // The poll indicated a message was ready, but the receive failed. Try again if (n == 1 && rc == 0){ continue; } if (timeout != -1){ break; } } if (!non_blocking){ std::signal(SIGINT, prev_handler_sigint); std::signal(SIGTERM, prev_handler_sigterm); } errno = msgq_do_exit ? EINTR : 0; if (rc > 0){ if (msgq_do_exit){ msgq_msg_close(&msg); // Free unused message on exit } else { r = new MSGQMessage; r->takeOwnership(msg.data, msg.size); } } return (Message*)r; } void MSGQSubSocket::setTimeout(int t){ timeout = t; } MSGQSubSocket::~MSGQSubSocket(){ if (q != NULL){ msgq_close_queue(q); delete q; } } int MSGQPubSocket::connect(Context *context, std::string endpoint, bool check_endpoint){ assert(context); if (check_endpoint && !service_exists(std::string(endpoint))){ std::cout << "Warning, " << std::string(endpoint) << " is not in service list." << std::endl; } q = new msgq_queue_t; int r = msgq_new_queue(q, endpoint.c_str(), get_size(endpoint)); if (r != 0){ return r; } msgq_init_publisher(q); return 0; } int MSGQPubSocket::sendMessage(Message *message){ msgq_msg_t msg; msg.data = message->getData(); msg.size = message->getSize(); return msgq_msg_send(&msg, q); } int MSGQPubSocket::send(char *data, size_t size){ msgq_msg_t msg; msg.data = data; msg.size = size; return msgq_msg_send(&msg, q); } bool MSGQPubSocket::all_readers_updated() { return msgq_all_readers_updated(q); } MSGQPubSocket::~MSGQPubSocket(){ if (q != NULL){ msgq_close_queue(q); delete q; } } void MSGQPoller::registerSocket(SubSocket * socket){ assert(num_polls + 1 < MAX_POLLERS); polls[num_polls].q = (msgq_queue_t*)socket->getRawSocket(); sockets.push_back(socket); num_polls++; } std::vector MSGQPoller::poll(int timeout){ std::vector r; msgq_poll(polls, num_polls, timeout); for (size_t i = 0; i < num_polls; i++){ if (polls[i].revents){ r.push_back(sockets[i]); } } return r; } ================================================ FILE: cereal/messaging/impl_msgq.h ================================================ #pragma once #include "messaging.h" #include "msgq.h" #include #include #define MAX_POLLERS 128 class MSGQContext : public Context { private: void * context = NULL; public: MSGQContext(); void * getRawContext() {return context;} ~MSGQContext(); }; class MSGQMessage : public Message { private: char * data; size_t size; public: void init(size_t size); void init(char *data, size_t size); void takeOwnership(char *data, size_t size); size_t getSize(){return size;} char * getData(){return data;} void close(); ~MSGQMessage(); }; class MSGQSubSocket : public SubSocket { private: msgq_queue_t * q = NULL; int timeout; public: int connect(Context *context, std::string endpoint, std::string address, bool conflate=false, bool check_endpoint=true); void setTimeout(int timeout); void * getRawSocket() {return (void*)q;} Message *receive(bool non_blocking=false); ~MSGQSubSocket(); }; class MSGQPubSocket : public PubSocket { private: msgq_queue_t * q = NULL; public: int connect(Context *context, std::string endpoint, bool check_endpoint=true); int sendMessage(Message *message); int send(char *data, size_t size); bool all_readers_updated(); ~MSGQPubSocket(); }; class MSGQPoller : public Poller { private: std::vector sockets; msgq_pollitem_t polls[MAX_POLLERS]; size_t num_polls = 0; public: void registerSocket(SubSocket *socket); std::vector poll(int timeout); ~MSGQPoller(){}; }; ================================================ FILE: cereal/messaging/impl_zmq.cc ================================================ #include #include #include #include #include #include #include "services.h" #include "impl_zmq.h" static int get_port(std::string endpoint) { int port = -1; for (const auto& it : services) { std::string name = it.name; if (name == endpoint) { port = it.port; break; } } assert(port >= 0); return port; } ZMQContext::ZMQContext() { context = zmq_ctx_new(); } ZMQContext::~ZMQContext() { zmq_ctx_term(context); } void ZMQMessage::init(size_t sz) { size = sz; data = new char[size]; } void ZMQMessage::init(char * d, size_t sz) { size = sz; data = new char[size]; memcpy(data, d, size); } void ZMQMessage::close() { if (size > 0){ delete[] data; } size = 0; } ZMQMessage::~ZMQMessage() { this->close(); } int ZMQSubSocket::connect(Context *context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){ sock = zmq_socket(context->getRawContext(), ZMQ_SUB); if (sock == NULL){ return -1; } zmq_setsockopt(sock, ZMQ_SUBSCRIBE, "", 0); if (conflate){ int arg = 1; zmq_setsockopt(sock, ZMQ_CONFLATE, &arg, sizeof(int)); } int reconnect_ivl = 500; zmq_setsockopt(sock, ZMQ_RECONNECT_IVL_MAX, &reconnect_ivl, sizeof(reconnect_ivl)); full_endpoint = "tcp://" + address + ":"; if (check_endpoint){ full_endpoint += std::to_string(get_port(endpoint)); } else { full_endpoint += endpoint; } return zmq_connect(sock, full_endpoint.c_str()); } Message * ZMQSubSocket::receive(bool non_blocking){ zmq_msg_t msg; assert(zmq_msg_init(&msg) == 0); int flags = non_blocking ? ZMQ_DONTWAIT : 0; int rc = zmq_msg_recv(&msg, sock, flags); Message *r = NULL; if (rc >= 0){ // Make a copy to ensure the data is aligned r = new ZMQMessage; r->init((char*)zmq_msg_data(&msg), zmq_msg_size(&msg)); } zmq_msg_close(&msg); return r; } void ZMQSubSocket::setTimeout(int timeout){ zmq_setsockopt(sock, ZMQ_RCVTIMEO, &timeout, sizeof(int)); } ZMQSubSocket::~ZMQSubSocket(){ zmq_close(sock); } int ZMQPubSocket::connect(Context *context, std::string endpoint, bool check_endpoint){ sock = zmq_socket(context->getRawContext(), ZMQ_PUB); if (sock == NULL){ return -1; } full_endpoint = "tcp://*:"; if (check_endpoint){ full_endpoint += std::to_string(get_port(endpoint)); } else { full_endpoint += endpoint; } return zmq_bind(sock, full_endpoint.c_str()); } int ZMQPubSocket::sendMessage(Message *message){ return zmq_send(sock, message->getData(), message->getSize(), ZMQ_DONTWAIT); } int ZMQPubSocket::send(char *data, size_t size){ return zmq_send(sock, data, size, ZMQ_DONTWAIT); } bool ZMQPubSocket::all_readers_updated() { assert(false); // TODO not implemented return false; } ZMQPubSocket::~ZMQPubSocket(){ zmq_close(sock); } void ZMQPoller::registerSocket(SubSocket * socket){ assert(num_polls + 1 < MAX_POLLERS); polls[num_polls].socket = socket->getRawSocket(); polls[num_polls].events = ZMQ_POLLIN; sockets.push_back(socket); num_polls++; } std::vector ZMQPoller::poll(int timeout){ std::vector r; int rc = zmq_poll(polls, num_polls, timeout); if (rc < 0){ return r; } for (size_t i = 0; i < num_polls; i++){ if (polls[i].revents){ r.push_back(sockets[i]); } } return r; } ================================================ FILE: cereal/messaging/impl_zmq.h ================================================ #pragma once #include "messaging.h" #include #include #define MAX_POLLERS 128 class ZMQContext : public Context { private: void * context = NULL; public: ZMQContext(); void * getRawContext() {return context;} ~ZMQContext(); }; class ZMQMessage : public Message { private: char * data; size_t size; public: void init(size_t size); void init(char *data, size_t size); size_t getSize(){return size;} char * getData(){return data;} void close(); ~ZMQMessage(); }; class ZMQSubSocket : public SubSocket { private: void * sock; std::string full_endpoint; public: int connect(Context *context, std::string endpoint, std::string address, bool conflate=false, bool check_endpoint=true); void setTimeout(int timeout); void * getRawSocket() {return sock;} Message *receive(bool non_blocking=false); ~ZMQSubSocket(); }; class ZMQPubSocket : public PubSocket { private: void * sock; std::string full_endpoint; public: int connect(Context *context, std::string endpoint, bool check_endpoint=true); int sendMessage(Message *message); int send(char *data, size_t size); bool all_readers_updated(); ~ZMQPubSocket(); }; class ZMQPoller : public Poller { private: std::vector sockets; zmq_pollitem_t polls[MAX_POLLERS]; size_t num_polls = 0; public: void registerSocket(SubSocket *socket); std::vector poll(int timeout); ~ZMQPoller(){}; }; ================================================ FILE: cereal/messaging/messaging.cc ================================================ #include "messaging.h" #include "impl_zmq.h" #include "impl_msgq.h" #ifdef __APPLE__ const bool MUST_USE_ZMQ = true; #else const bool MUST_USE_ZMQ = false; #endif bool messaging_use_zmq(){ return std::getenv("ZMQ") || MUST_USE_ZMQ; } Context * Context::create(){ Context * c; if (messaging_use_zmq()){ c = new ZMQContext(); } else { c = new MSGQContext(); } return c; } SubSocket * SubSocket::create(){ SubSocket * s; if (messaging_use_zmq()){ s = new ZMQSubSocket(); } else { s = new MSGQSubSocket(); } return s; } SubSocket * SubSocket::create(Context * context, std::string endpoint, std::string address, bool conflate, bool check_endpoint){ SubSocket *s = SubSocket::create(); int r = s->connect(context, endpoint, address, conflate, check_endpoint); if (r == 0) { return s; } else { delete s; return NULL; } } PubSocket * PubSocket::create(){ PubSocket * s; if (messaging_use_zmq()){ s = new ZMQPubSocket(); } else { s = new MSGQPubSocket(); } return s; } PubSocket * PubSocket::create(Context * context, std::string endpoint, bool check_endpoint){ PubSocket *s = PubSocket::create(); int r = s->connect(context, endpoint, check_endpoint); if (r == 0) { return s; } else { delete s; return NULL; } } Poller * Poller::create(){ Poller * p; if (messaging_use_zmq()){ p = new ZMQPoller(); } else { p = new MSGQPoller(); } return p; } Poller * Poller::create(std::vector sockets){ Poller * p = Poller::create(); for (auto s : sockets){ p->registerSocket(s); } return p; } extern "C" Context * messaging_context_create() { return Context::create(); } extern "C" SubSocket * messaging_subsocket_create(Context* context, const char* endpoint) { return SubSocket::create(context, std::string(endpoint)); } extern "C" PubSocket * messaging_pubsocket_create(Context* context, const char* endpoint) { return PubSocket::create(context, std::string(endpoint)); } extern "C" Poller * messaging_poller_create(SubSocket** sockets, int size) { std::vector socketsVec(sockets, sockets + size); return Poller::create(socketsVec); } ================================================ FILE: cereal/messaging/messaging.h ================================================ #pragma once #include #include #include #include #include #include "../gen/cpp/log.capnp.h" #ifdef __APPLE__ #define CLOCK_BOOTTIME CLOCK_MONOTONIC #endif #define MSG_MULTIPLE_PUBLISHERS 100 bool messaging_use_zmq(); class Context { public: virtual void * getRawContext() = 0; static Context * create(); virtual ~Context(){}; }; class Message { public: virtual void init(size_t size) = 0; virtual void init(char * data, size_t size) = 0; virtual void close() = 0; virtual size_t getSize() = 0; virtual char * getData() = 0; virtual ~Message(){}; }; class SubSocket { public: virtual int connect(Context *context, std::string endpoint, std::string address, bool conflate=false, bool check_endpoint=true) = 0; virtual void setTimeout(int timeout) = 0; virtual Message *receive(bool non_blocking=false) = 0; virtual void * getRawSocket() = 0; static SubSocket * create(); static SubSocket * create(Context * context, std::string endpoint, std::string address="127.0.0.1", bool conflate=false, bool check_endpoint=true); virtual ~SubSocket(){}; }; class PubSocket { public: virtual int connect(Context *context, std::string endpoint, bool check_endpoint=true) = 0; virtual int sendMessage(Message *message) = 0; virtual int send(char *data, size_t size) = 0; virtual bool all_readers_updated() = 0; static PubSocket * create(); static PubSocket * create(Context * context, std::string endpoint, bool check_endpoint=true); static PubSocket * create(Context * context, std::string endpoint, int port, bool check_endpoint=true); virtual ~PubSocket(){}; }; class Poller { public: virtual void registerSocket(SubSocket *socket) = 0; virtual std::vector poll(int timeout) = 0; static Poller * create(); static Poller * create(std::vector sockets); virtual ~Poller(){}; }; class SubMaster { public: SubMaster(const std::vector &service_list, const char *address = nullptr, const std::vector &ignore_alive = {}); void update(int timeout = 1000); void update_msgs(uint64_t current_time, const std::vector> &messages); inline bool allAlive(const std::vector &service_list = {}) { return all_(service_list, false, true); } inline bool allValid(const std::vector &service_list = {}) { return all_(service_list, true, false); } inline bool allAliveAndValid(const std::vector &service_list = {}) { return all_(service_list, true, true); } void drain(); ~SubMaster(); uint64_t frame = 0; bool updated(const char *name) const; bool alive(const char *name) const; bool valid(const char *name) const; uint64_t rcv_frame(const char *name) const; uint64_t rcv_time(const char *name) const; cereal::Event::Reader &operator[](const char *name) const; private: bool all_(const std::vector &service_list, bool valid, bool alive); Poller *poller_ = nullptr; struct SubMessage; std::map messages_; std::map services_; }; class MessageBuilder : public capnp::MallocMessageBuilder { public: MessageBuilder() = default; cereal::Event::Builder initEvent(bool valid = true) { cereal::Event::Builder event = initRoot(); struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); uint64_t current_time = t.tv_sec * 1000000000ULL + t.tv_nsec; event.setLogMonoTime(current_time); event.setValid(valid); return event; } kj::ArrayPtr toBytes() { heapArray_ = capnp::messageToFlatArray(*this); return heapArray_.asBytes(); } private: kj::Array heapArray_; }; class PubMaster { public: PubMaster(const std::vector &service_list); inline int send(const char *name, capnp::byte *data, size_t size) { return sockets_.at(name)->send((char *)data, size); } int send(const char *name, MessageBuilder &msg); ~PubMaster(); private: std::map sockets_; }; class AlignedBuffer { public: kj::ArrayPtr align(const char *data, const size_t size) { words_size = size / sizeof(capnp::word) + 1; if (aligned_buf.size() < words_size) { aligned_buf = kj::heapArray(words_size < 512 ? 512 : words_size); } memcpy(aligned_buf.begin(), data, size); return aligned_buf.slice(0, words_size); } inline kj::ArrayPtr align(Message *m) { return align(m->getData(), m->getSize()); } private: kj::Array aligned_buf; size_t words_size; }; ================================================ FILE: cereal/messaging/messaging.pxd ================================================ # distutils: language = c++ #cython: language_level=3 from libcpp.string cimport string from libcpp.vector cimport vector from libcpp cimport bool cdef extern from "messaging.h": cdef cppclass Context: @staticmethod Context * create() cdef cppclass Message: void init(size_t) void init(char *, size_t) void close() size_t getSize() char *getData() cdef cppclass SubSocket: @staticmethod SubSocket * create() int connect(Context *, string, string, bool) Message * receive(bool) void setTimeout(int) cdef cppclass PubSocket: @staticmethod PubSocket * create() int connect(Context *, string) int sendMessage(Message *) int send(char *, size_t) bool all_readers_updated() cdef cppclass Poller: @staticmethod Poller * create() void registerSocket(SubSocket *) vector[SubSocket*] poll(int) nogil ================================================ FILE: cereal/messaging/messaging_pyx.pyx ================================================ # distutils: language = c++ # cython: c_string_encoding=ascii, language_level=3 import sys from libcpp.string cimport string from libcpp cimport bool from libc cimport errno from .messaging cimport Context as cppContext from .messaging cimport SubSocket as cppSubSocket from .messaging cimport PubSocket as cppPubSocket from .messaging cimport Poller as cppPoller from .messaging cimport Message as cppMessage class MessagingError(Exception): pass class MultiplePublishersError(MessagingError): pass cdef class Context: cdef cppContext * context def __cinit__(self): self.context = cppContext.create() def term(self): del self.context self.context = NULL def __dealloc__(self): pass # Deleting the context will hang if sockets are still active # TODO: Figure out a way to make sure the context is closed last # del self.context cdef class Poller: cdef cppPoller * poller cdef list sub_sockets def __cinit__(self): self.sub_sockets = [] self.poller = cppPoller.create() def __dealloc__(self): del self.poller def registerSocket(self, SubSocket socket): self.sub_sockets.append(socket) self.poller.registerSocket(socket.socket) def poll(self, timeout): sockets = [] cdef int t = timeout with nogil: result = self.poller.poll(t) for s in result: socket = SubSocket() socket.setPtr(s) sockets.append(socket) return sockets cdef class SubSocket: cdef cppSubSocket * socket cdef bool is_owner def __cinit__(self): self.socket = cppSubSocket.create() self.is_owner = True if self.socket == NULL: raise MessagingError def __dealloc__(self): if self.is_owner: del self.socket cdef setPtr(self, cppSubSocket * ptr): if self.is_owner: del self.socket self.is_owner = False self.socket = ptr def connect(self, Context context, string endpoint, string address=b"127.0.0.1", bool conflate=False): r = self.socket.connect(context.context, endpoint, address, conflate) if r != 0: if errno.errno == errno.EADDRINUSE: raise MultiplePublishersError else: raise MessagingError def setTimeout(self, int timeout): self.socket.setTimeout(timeout) def receive(self, bool non_blocking=False): msg = self.socket.receive(non_blocking) if msg == NULL: # If a blocking read returns no message check errno if SIGINT was caught in the C++ code if errno.errno == errno.EINTR: print("SIGINT received, exiting") sys.exit(1) return None else: sz = msg.getSize() m = msg.getData()[:sz] del msg return m cdef class PubSocket: cdef cppPubSocket * socket def __cinit__(self): self.socket = cppPubSocket.create() if self.socket == NULL: raise MessagingError def __dealloc__(self): del self.socket def connect(self, Context context, string endpoint): r = self.socket.connect(context.context, endpoint) if r != 0: if errno.errno == errno.EADDRINUSE: raise MultiplePublishersError else: raise MessagingError def send(self, bytes data): length = len(data) r = self.socket.send(data, length) if r != length: if errno.errno == errno.EADDRINUSE: raise MultiplePublishersError else: raise MessagingError def all_readers_updated(self): return self.socket.all_readers_updated() ================================================ FILE: cereal/messaging/msgq.cc ================================================ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "msgq.h" void sigusr2_handler(int signal) { assert(signal == SIGUSR2); } uint64_t msgq_get_uid(void){ std::random_device rd("/dev/urandom"); std::uniform_int_distribution distribution(0,std::numeric_limits::max()); #ifdef __APPLE__ // TODO: this doesn't work uint64_t uid = distribution(rd) << 32 | getpid(); #else uint64_t uid = distribution(rd) << 32 | syscall(SYS_gettid); #endif return uid; } int msgq_msg_init_size(msgq_msg_t * msg, size_t size){ msg->size = size; msg->data = new(std::nothrow) char[size]; return (msg->data == NULL) ? -1 : 0; } int msgq_msg_init_data(msgq_msg_t * msg, char * data, size_t size) { int r = msgq_msg_init_size(msg, size); if (r == 0) memcpy(msg->data, data, size); return r; } int msgq_msg_close(msgq_msg_t * msg){ if (msg->size > 0) delete[] msg->data; msg->size = 0; return 0; } void msgq_reset_reader(msgq_queue_t * q){ int id = q->reader_id; q->read_valids[id]->store(true); q->read_pointers[id]->store(*q->write_pointer); } void msgq_wait_for_subscriber(msgq_queue_t *q){ while (*q->num_readers == 0){ ; } return; } int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size){ assert(size < 0xFFFFFFFF); // Buffer must be smaller than 2^32 bytes std::signal(SIGUSR2, sigusr2_handler); const char * prefix = "/dev/shm/"; char * full_path = new char[strlen(path) + strlen(prefix) + 1]; strcpy(full_path, prefix); strcat(full_path, path); auto fd = open(full_path, O_RDWR | O_CREAT, 0664); if (fd < 0) { std::cout << "Warning, could not open: " << full_path << std::endl; delete[] full_path; return -1; } delete[] full_path; int rc = ftruncate(fd, size + sizeof(msgq_header_t)); if (rc < 0){ close(fd); return -1; } char * mem = (char*)mmap(NULL, size + sizeof(msgq_header_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); close(fd); if (mem == NULL){ return -1; } q->mmap_p = mem; msgq_header_t *header = (msgq_header_t *)mem; // Setup pointers to header segment q->num_readers = reinterpret_cast*>(&header->num_readers); q->write_pointer = reinterpret_cast*>(&header->write_pointer); q->write_uid = reinterpret_cast*>(&header->write_uid); for (size_t i = 0; i < NUM_READERS; i++){ q->read_pointers[i] = reinterpret_cast*>(&header->read_pointers[i]); q->read_valids[i] = reinterpret_cast*>(&header->read_valids[i]); q->read_uids[i] = reinterpret_cast*>(&header->read_uids[i]); } q->data = mem + sizeof(msgq_header_t); q->size = size; q->reader_id = -1; q->endpoint = path; q->read_conflate = false; return 0; } void msgq_close_queue(msgq_queue_t *q){ if (q->mmap_p != NULL){ munmap(q->mmap_p, q->size + sizeof(msgq_header_t)); } } void msgq_init_publisher(msgq_queue_t * q) { //std::cout << "Starting publisher" << std::endl; uint64_t uid = msgq_get_uid(); *q->write_uid = uid; *q->num_readers = 0; for (size_t i = 0; i < NUM_READERS; i++){ *q->read_valids[i] = false; *q->read_uids[i] = 0; } q->write_uid_local = uid; } static void thread_signal(uint32_t tid) { #ifndef SYS_tkill // TODO: this won't work for multithreaded programs kill(tid, SIGUSR2); #else syscall(SYS_tkill, tid, SIGUSR2); #endif } void msgq_init_subscriber(msgq_queue_t * q) { assert(q != NULL); assert(q->num_readers != NULL); uint64_t uid = msgq_get_uid(); // Get reader id while (true){ uint64_t cur_num_readers = *q->num_readers; uint64_t new_num_readers = cur_num_readers + 1; // No more slots available. Reset all subscribers to kick out inactive ones if (new_num_readers > NUM_READERS){ std::cout << "Warning, evicting all subscribers!" << std::endl; *q->num_readers = 0; for (size_t i = 0; i < NUM_READERS; i++){ *q->read_valids[i] = false; uint64_t old_uid = *q->read_uids[i]; *q->read_uids[i] = 0; // Wake up reader in case they are in a poll thread_signal(old_uid & 0xFFFFFFFF); } continue; } // Use atomic compare and swap to handle race condition // where two subscribers start at the same time if (std::atomic_compare_exchange_strong(q->num_readers, &cur_num_readers, new_num_readers)){ q->reader_id = cur_num_readers; q->read_uid_local = uid; // We start with read_valid = false, // on the first read the read pointer will be synchronized with the write pointer *q->read_valids[cur_num_readers] = false; *q->read_pointers[cur_num_readers] = 0; *q->read_uids[cur_num_readers] = uid; break; } } //std::cout << "New subscriber id: " << q->reader_id << " uid: " << q->read_uid_local << " " << q->endpoint << std::endl; msgq_reset_reader(q); } int msgq_msg_send(msgq_msg_t * msg, msgq_queue_t *q){ // Die if we are no longer the active publisher if (q->write_uid_local != *q->write_uid){ std::cout << "Killing old publisher: " << q->endpoint << std::endl; errno = EADDRINUSE; return -1; } uint64_t total_msg_size = ALIGN(msg->size + sizeof(int64_t)); // We need to fit at least three messages in the queue, // then we can always safely access the last message assert(3 * total_msg_size <= q->size); uint64_t num_readers = *q->num_readers; uint32_t write_cycles, write_pointer; UNPACK64(write_cycles, write_pointer, *q->write_pointer); char *p = q->data + write_pointer; // add base offset // Check remaining space // Always leave space for a wraparound tag for the next message, including alignment int64_t remaining_space = q->size - write_pointer - total_msg_size - sizeof(int64_t); if (remaining_space <= 0){ // Write -1 size tag indicating wraparound *(int64_t*)p = -1; // Invalidate all readers that are beyond the write pointer // TODO: should we handle the case where a new reader shows up while this is running? for (uint64_t i = 0; i < num_readers; i++){ uint64_t read_pointer = *q->read_pointers[i]; uint64_t read_cycles = read_pointer >> 32; read_pointer &= 0xFFFFFFFF; if ((read_pointer > write_pointer) && (read_cycles != write_cycles)) { *q->read_valids[i] = false; } } // Update global and local copies of write pointer and write_cycles write_pointer = 0; write_cycles = write_cycles + 1; PACK64(*q->write_pointer, write_cycles, write_pointer); // Set actual pointer to the beginning of the data segment p = q->data; } // Invalidate readers that are in the area that will be written uint64_t start = write_pointer; uint64_t end = ALIGN(start + sizeof(int64_t) + msg->size); for (uint64_t i = 0; i < num_readers; i++){ uint32_t read_cycles, read_pointer; UNPACK64(read_cycles, read_pointer, *q->read_pointers[i]); if ((read_pointer >= start) && (read_pointer < end) && (read_cycles != write_cycles)) { *q->read_valids[i] = false; } } // Write size tag std::atomic *size_p = reinterpret_cast*>(p); *size_p = msg->size; // Copy data memcpy(p + sizeof(int64_t), msg->data, msg->size); __sync_synchronize(); // Update write pointer uint32_t new_ptr = ALIGN(write_pointer + msg->size + sizeof(int64_t)); PACK64(*q->write_pointer, write_cycles, new_ptr); // Notify readers for (uint64_t i = 0; i < num_readers; i++){ uint64_t reader_uid = *q->read_uids[i]; thread_signal(reader_uid & 0xFFFFFFFF); } return msg->size; } int msgq_msg_ready(msgq_queue_t * q){ start: int id = q->reader_id; assert(id >= 0); // Make sure subscriber is initialized if (q->read_uid_local != *q->read_uids[id]){ std::cout << q->endpoint << ": Reader was evicted, reconnecting" << std::endl; msgq_init_subscriber(q); goto start; } // Check valid if (!*q->read_valids[id]){ msgq_reset_reader(q); goto start; } uint32_t read_cycles, read_pointer; UNPACK64(read_cycles, read_pointer, *q->read_pointers[id]); uint32_t write_cycles, write_pointer; UNPACK64(write_cycles, write_pointer, *q->write_pointer); // Check if new message is available return (read_pointer != write_pointer); } int msgq_msg_recv(msgq_msg_t * msg, msgq_queue_t * q){ start: int id = q->reader_id; assert(id >= 0); // Make sure subscriber is initialized if (q->read_uid_local != *q->read_uids[id]){ std::cout << q->endpoint << ": Reader was evicted, reconnecting" << std::endl; msgq_init_subscriber(q); goto start; } // Check valid if (!*q->read_valids[id]){ msgq_reset_reader(q); goto start; } uint32_t read_cycles, read_pointer; UNPACK64(read_cycles, read_pointer, *q->read_pointers[id]); uint32_t write_cycles, write_pointer; UNPACK64(write_cycles, write_pointer, *q->write_pointer); char * p = q->data + read_pointer; // Check if new message is available if (read_pointer == write_pointer) { msg->size = 0; return 0; } // Read potential message size std::atomic *size_p = reinterpret_cast*>(p); std::int64_t size = *size_p; // Check if the size that was read is valid if (!*q->read_valids[id]){ msgq_reset_reader(q); goto start; } // If size is -1 the buffer was full, and we need to wrap around if (size == -1){ read_cycles++; PACK64(*q->read_pointers[id], read_cycles, 0); goto start; } // crashing is better than passing garbage data to the consumer // the size will have weird value if it was overwritten by data accidentally assert((uint64_t)size < q->size); assert(size > 0); uint32_t new_read_pointer = ALIGN(read_pointer + sizeof(std::int64_t) + size); // If conflate is true, check if this is the latest message, else start over if (q->read_conflate){ if (new_read_pointer != write_pointer){ // Update read pointer PACK64(*q->read_pointers[id], read_cycles, new_read_pointer); goto start; } } // Copy message if (msgq_msg_init_size(msg, size) < 0) return -1; __sync_synchronize(); memcpy(msg->data, p + sizeof(int64_t), size); __sync_synchronize(); // Update read pointer PACK64(*q->read_pointers[id], read_cycles, new_read_pointer); // Check if the actual data that was copied is valid if (!*q->read_valids[id]){ msgq_msg_close(msg); msgq_reset_reader(q); goto start; } return msg->size; } int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout){ int num = 0; // Check if messages ready for (size_t i = 0; i < nitems; i++) { items[i].revents = msgq_msg_ready(items[i].q); if (items[i].revents) num++; } int ms = (timeout == -1) ? 100 : timeout; struct timespec ts; ts.tv_sec = ms / 1000; ts.tv_nsec = (ms % 1000) * 1000 * 1000; while (num == 0) { int ret; ret = nanosleep(&ts, &ts); // Check if messages ready for (size_t i = 0; i < nitems; i++) { if (items[i].revents == 0 && msgq_msg_ready(items[i].q)){ num += 1; items[i].revents = 1; } } // exit if we had a timeout and the sleep finished if (timeout != -1 && ret == 0){ break; } } return num; } bool msgq_all_readers_updated(msgq_queue_t *q) { uint64_t num_readers = *q->num_readers; for (uint64_t i = 0; i < num_readers; i++) { if (*q->read_valids[i] && *q->write_pointer != *q->read_pointers[i]) { return false; } } return num_readers > 0; } ================================================ FILE: cereal/messaging/msgq.h ================================================ #pragma once #include #include #include #include #define DEFAULT_SEGMENT_SIZE (10 * 1024 * 1024) #define NUM_READERS 10 #define ALIGN(n) ((n + (8 - 1)) & -8) #define UNPACK64(higher, lower, input) do {uint64_t tmp = input; higher = tmp >> 32; lower = tmp & 0xFFFFFFFF;} while (0) #define PACK64(output, higher, lower) output = ((uint64_t)higher << 32 ) | ((uint64_t)lower & 0xFFFFFFFF) struct msgq_header_t { uint64_t num_readers; uint64_t write_pointer; uint64_t write_uid; uint64_t read_pointers[NUM_READERS]; uint64_t read_valids[NUM_READERS]; uint64_t read_uids[NUM_READERS]; }; struct msgq_queue_t { std::atomic *num_readers; std::atomic *write_pointer; std::atomic *write_uid; std::atomic *read_pointers[NUM_READERS]; std::atomic *read_valids[NUM_READERS]; std::atomic *read_uids[NUM_READERS]; char * mmap_p; char * data; size_t size; int reader_id; uint64_t read_uid_local; uint64_t write_uid_local; bool read_conflate; std::string endpoint; }; struct msgq_msg_t { size_t size; char * data; }; struct msgq_pollitem_t { msgq_queue_t *q; int revents; }; void msgq_wait_for_subscriber(msgq_queue_t *q); void msgq_reset_reader(msgq_queue_t *q); int msgq_msg_init_size(msgq_msg_t *msg, size_t size); int msgq_msg_init_data(msgq_msg_t *msg, char * data, size_t size); int msgq_msg_close(msgq_msg_t *msg); int msgq_new_queue(msgq_queue_t * q, const char * path, size_t size); void msgq_close_queue(msgq_queue_t *q); void msgq_init_publisher(msgq_queue_t * q); void msgq_init_subscriber(msgq_queue_t * q); int msgq_msg_send(msgq_msg_t *msg, msgq_queue_t *q); int msgq_msg_recv(msgq_msg_t *msg, msgq_queue_t *q); int msgq_msg_ready(msgq_queue_t * q); int msgq_poll(msgq_pollitem_t * items, size_t nitems, int timeout); bool msgq_all_readers_updated(msgq_queue_t *q); ================================================ FILE: cereal/messaging/socketmaster.cc ================================================ #include #include #include #include #include #include "services.h" #include "messaging.h" const bool SIMULATION = (getenv("SIMULATION") != nullptr) && (std::string(getenv("SIMULATION")) == "1"); static inline uint64_t nanos_since_boot() { struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); return t.tv_sec * 1000000000ULL + t.tv_nsec; } static const service *get_service(const char *name) { for (const auto &it : services) { if (strcmp(it.name, name) == 0) return ⁢ } return nullptr; } static inline bool inList(const std::vector &list, const char *value) { for (auto &v : list) { if (strcmp(value, v) == 0) return true; } return false; } class MessageContext { public: MessageContext() : ctx_(nullptr) {}; ~MessageContext() { delete ctx_; } inline Context *context() { std::call_once(init_flag, [=]() { ctx_ = Context::create(); }); return ctx_; } private: Context *ctx_; std::once_flag init_flag; }; MessageContext message_context; struct SubMaster::SubMessage { std::string name; SubSocket *socket = nullptr; int freq = 0; bool updated = false, alive = false, valid = true, ignore_alive; uint64_t rcv_time = 0, rcv_frame = 0; void *allocated_msg_reader = nullptr; capnp::FlatArrayMessageReader *msg_reader = nullptr; AlignedBuffer aligned_buf; cereal::Event::Reader event; }; SubMaster::SubMaster(const std::vector &service_list, const char *address, const std::vector &ignore_alive) { poller_ = Poller::create(); for (auto name : service_list) { const service *serv = get_service(name); assert(serv != nullptr); SubSocket *socket = SubSocket::create(message_context.context(), name, address ? address : "127.0.0.1", true); assert(socket != 0); poller_->registerSocket(socket); SubMessage *m = new SubMessage{ .name = name, .socket = socket, .freq = serv->frequency, .ignore_alive = inList(ignore_alive, name), .allocated_msg_reader = malloc(sizeof(capnp::FlatArrayMessageReader))}; m->msg_reader = new (m->allocated_msg_reader) capnp::FlatArrayMessageReader({}); messages_[socket] = m; services_[name] = m; } } void SubMaster::update(int timeout) { for (auto &kv : messages_) kv.second->updated = false; auto sockets = poller_->poll(timeout); uint64_t current_time = nanos_since_boot(); std::vector> messages; for (auto s : sockets) { Message *msg = s->receive(true); if (msg == nullptr) continue; SubMessage *m = messages_.at(s); m->msg_reader->~FlatArrayMessageReader(); capnp::ReaderOptions options; options.traversalLimitInWords = kj::maxValue; // Don't limit m->msg_reader = new (m->allocated_msg_reader) capnp::FlatArrayMessageReader(m->aligned_buf.align(msg), options); delete msg; messages.push_back({m->name, m->msg_reader->getRoot()}); } update_msgs(current_time, messages); } void SubMaster::update_msgs(uint64_t current_time, const std::vector> &messages){ if (++frame == UINT64_MAX) frame = 1; for(auto &kv : messages) { auto m_find = services_.find(kv.first); if (m_find == services_.end()){ continue; } SubMessage *m = m_find->second; m->event = kv.second; m->updated = true; m->rcv_time = current_time; m->rcv_frame = frame; m->valid = m->event.getValid(); if (SIMULATION) m->alive = true; } if (!SIMULATION) { for (auto &kv : messages_) { SubMessage *m = kv.second; m->alive = (m->freq <= (1e-5) || ((current_time - m->rcv_time) * (1e-9)) < (10.0 / m->freq)); } } } bool SubMaster::all_(const std::vector &service_list, bool valid, bool alive) { int found = 0; for (auto &kv : messages_) { SubMessage *m = kv.second; if (service_list.size() == 0 || inList(service_list, m->name.c_str())) { found += (!valid || m->valid) && (!alive || (m->alive || m->ignore_alive)); } } return service_list.size() == 0 ? found == messages_.size() : found == service_list.size(); } void SubMaster::drain() { while (true) { auto polls = poller_->poll(0); if (polls.size() == 0) break; for (auto sock : polls) { Message *msg = sock->receive(true); delete msg; } } } bool SubMaster::updated(const char *name) const { return services_.at(name)->updated; } bool SubMaster::alive(const char *name) const { return services_.at(name)->alive; } bool SubMaster::valid(const char *name) const { return services_.at(name)->valid; } uint64_t SubMaster::rcv_frame(const char *name) const { return services_.at(name)->rcv_frame; } uint64_t SubMaster::rcv_time(const char *name) const { return services_.at(name)->rcv_time; } cereal::Event::Reader &SubMaster::operator[](const char *name) const { return services_.at(name)->event; }; SubMaster::~SubMaster() { delete poller_; for (auto &kv : messages_) { SubMessage *m = kv.second; m->msg_reader->~FlatArrayMessageReader(); free(m->allocated_msg_reader); delete m->socket; delete m; } } PubMaster::PubMaster(const std::vector &service_list) { for (auto name : service_list) { assert(get_service(name) != nullptr); PubSocket *socket = PubSocket::create(message_context.context(), name); assert(socket); sockets_[name] = socket; } } int PubMaster::send(const char *name, MessageBuilder &msg) { auto bytes = msg.toBytes(); return send(name, bytes.begin(), bytes.size()); } PubMaster::~PubMaster() { for (auto s : sockets_) delete s.second; } ================================================ FILE: cereal/services.py ================================================ #!/usr/bin/env python3 import os from typing import Optional TICI = os.path.isfile('/TICI') RESERVED_PORT = 8022 # sshd STARTING_PORT = 8001 def new_port(port: int): port += STARTING_PORT return port + 1 if port >= RESERVED_PORT else port class Service: def __init__(self, port: int, should_log: bool, frequency: float, decimation: Optional[int] = None): self.port = port self.should_log = should_log self.frequency = frequency self.decimation = decimation DCAM_FREQ = 10. if not TICI else 20. services = { # service: (should_log, frequency, qlog decimation (optional)) "sensorEvents": (True, 100., 100), "gpsNMEA": (True, 9.), "deviceState": (True, 2., 1), "can": (True, 100.), "controlsState": (True, 100., 10), "pandaState": (True, 2., 1), "radarState": (True, 20., 5), "roadEncodeIdx": (True, 20., 1), "liveTracks": (True, 20.), "sendcan": (True, 100.), "logMessage": (True, 0.), "liveCalibration": (True, 4., 4), "androidLog": (True, 0., 1), "carState": (True, 100., 10), "carControl": (True, 100., 10), "longitudinalPlan": (True, 20., 5), "procLog": (True, 0.5), "gpsLocationExternal": (True, 10., 1), "ubloxGnss": (True, 10.), "clocks": (True, 1., 1), "ubloxRaw": (True, 20.), "liveLocationKalman": (True, 20., 2), "liveParameters": (True, 20., 2), "cameraOdometry": (True, 20., 5), "lateralPlan": (True, 20., 5), "thumbnail": (True, 0.2, 1), "carEvents": (True, 1., 1), "carParams": (True, 0.02, 1), "roadCameraState": (True, 20., 20), "driverCameraState": (True, DCAM_FREQ, DCAM_FREQ), "driverEncodeIdx": (True, DCAM_FREQ, 1), "driverState": (True, DCAM_FREQ, DCAM_FREQ / 2), "driverMonitoringState": (True, DCAM_FREQ, DCAM_FREQ / 2), "wideRoadEncodeIdx": (True, 20., 1), "wideRoadCameraState": (True, 20., 20), "modelV2": (True, 20., 40), "managerState": (True, 2., 1), "uploaderState": (True, 0., 1), "liveMapData": (True, 0.), # debug "testJoystick": (False, 0.), # dp "thermal": (True, 2., 1), "dragonConf": (False, 1.), } service_list = {name: Service(new_port(idx), *vals) for # type: ignore idx, (name, vals) in enumerate(services.items())} def build_header(): h = "" h += "/* THIS IS AN AUTOGENERATED FILE, PLEASE EDIT services.py */\n" h += "#ifndef __SERVICES_H\n" h += "#define __SERVICES_H\n" h += "struct service { char name[0x100]; int port; bool should_log; int frequency; int decimation; };\n" h += "static struct service services[] = {\n" for k, v in service_list.items(): should_log = "true" if v.should_log else "false" decimation = -1 if v.decimation is None else v.decimation h += ' { "%s", %d, %s, %d, %d },\n' % \ (k, v.port, should_log, v.frequency, decimation) h += "};\n" h += "#endif\n" return h if __name__ == "__main__": print(build_header()) ================================================ FILE: cereal/visionipc/.gitignore ================================================ visionipc_pyx.cpp *.so ================================================ FILE: cereal/visionipc/__init__.py ================================================ ================================================ FILE: cereal/visionipc/ipc.cc ================================================ #include #include #include #include #include #include #include #include #include #ifdef __APPLE__ #define getsocket() socket(AF_UNIX, SOCK_STREAM, 0) #else #define getsocket() socket(AF_UNIX, SOCK_SEQPACKET, 0) #endif #include "ipc.h" int ipc_connect(const char* socket_path) { int err; int sock = getsocket(); if (sock < 0) return -1; struct sockaddr_un addr = { .sun_family = AF_UNIX, }; snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); err = connect(sock, (struct sockaddr*)&addr, sizeof(addr)); if (err != 0) { close(sock); return -1; } return sock; } int ipc_bind(const char* socket_path) { int err; unlink(socket_path); int sock = getsocket(); struct sockaddr_un addr = { .sun_family = AF_UNIX, }; snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); err = bind(sock, (struct sockaddr *)&addr, sizeof(addr)); assert(err == 0); err = listen(sock, 3); assert(err == 0); return sock; } int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds, int *out_num_fds) { char control_buf[CMSG_SPACE(sizeof(int) * num_fds)]; memset(control_buf, 0, CMSG_SPACE(sizeof(int) * num_fds)); struct iovec iov = { .iov_base = buf, .iov_len = buf_size, }; struct msghdr msg = { .msg_iov = &iov, .msg_iovlen = 1, }; if (num_fds > 0) { assert(fds); msg.msg_control = control_buf; msg.msg_controllen = CMSG_SPACE(sizeof(int) * num_fds); } if (send) { if (num_fds) { struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); assert(cmsg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fds); memcpy(CMSG_DATA(cmsg), fds, sizeof(int) * num_fds); } return sendmsg(fd, &msg, 0); } else { int r = recvmsg(fd, &msg, 0); if (r < 0) return r; int recv_fds = 0; if (msg.msg_controllen > 0) { struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); assert(cmsg); assert(cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS); recv_fds = (cmsg->cmsg_len - CMSG_LEN(0)); assert(recv_fds > 0 && (recv_fds % sizeof(int)) == 0); recv_fds /= sizeof(int); assert(fds && recv_fds <= num_fds); memcpy(fds, CMSG_DATA(cmsg), sizeof(int) * recv_fds); } if (msg.msg_flags) { for (int i=0; i int ipc_connect(const char* socket_path); int ipc_bind(const char* socket_path); int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fds, int num_fds, int *out_num_fds); ================================================ FILE: cereal/visionipc/test_runner.cc ================================================ #define CATCH_CONFIG_MAIN #include "catch2/catch.hpp" ================================================ FILE: cereal/visionipc/visionbuf.cc ================================================ #include "visionbuf.h" #define ALIGN(x, align) (((x) + (align)-1) & ~((align)-1)) #ifdef QCOM // from libadreno_utils.so extern "C" void compute_aligned_width_and_height(int width, int height, int bpp, int tile_mode, int raster_mode, int padding_threshold, int *aligned_w, int *aligned_h); #endif void visionbuf_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h) { #ifdef QCOM compute_aligned_width_and_height(ALIGN(width, 32), ALIGN(height, 32), 3, 0, 0, 512, aligned_w, aligned_h); #else *aligned_w = width; *aligned_h = height; #endif } void VisionBuf::init_rgb(size_t width, size_t height, size_t stride) { this->rgb = true; this->width = width; this->height = height; this->stride = stride; } void VisionBuf::init_yuv(size_t width, size_t height){ this->rgb = false; this->width = width; this->height = height; this->y = (uint8_t *)this->addr; this->u = this->y + (width * height); this->v = this->u + (width / 2 * height / 2); } ================================================ FILE: cereal/visionipc/visionbuf.h ================================================ #pragma once #include "visionipc.h" #define CL_USE_DEPRECATED_OPENCL_1_2_APIS #ifdef __APPLE__ #include #else #include #endif #define VISIONBUF_SYNC_FROM_DEVICE 0 #define VISIONBUF_SYNC_TO_DEVICE 1 enum VisionStreamType { VISION_STREAM_RGB_BACK, VISION_STREAM_RGB_FRONT, VISION_STREAM_RGB_WIDE, VISION_STREAM_YUV_BACK, VISION_STREAM_YUV_FRONT, VISION_STREAM_YUV_WIDE, VISION_STREAM_MAX, }; class VisionBuf { public: size_t len = 0; size_t mmap_len = 0; void * addr = nullptr; int fd = 0; bool rgb = false; size_t width = 0; size_t height = 0; size_t stride = 0; // YUV uint8_t * y = nullptr; uint8_t * u = nullptr; uint8_t * v = nullptr; // Visionipc uint64_t server_id = 0; size_t idx = 0; VisionStreamType type; // OpenCL cl_mem buf_cl = nullptr; cl_command_queue copy_q = nullptr; // ion int handle = 0; void allocate(size_t len); void import(); void init_cl(cl_device_id device_id, cl_context ctx); void init_rgb(size_t width, size_t height, size_t stride); void init_yuv(size_t width, size_t height); int sync(int dir); int free(); }; void visionbuf_compute_aligned_width_and_height(int width, int height, int *aligned_w, int *aligned_h); ================================================ FILE: cereal/visionipc/visionbuf_cl.cc ================================================ #include "visionbuf.h" #include #include #include #include #include #include #include #include std::atomic offset = 0; static void *malloc_with_fd(size_t len, int *fd) { char full_path[0x100]; #ifdef __APPLE__ snprintf(full_path, sizeof(full_path)-1, "/tmp/visionbuf_%d_%d", getpid(), offset++); #else snprintf(full_path, sizeof(full_path)-1, "/dev/shm/visionbuf_%d_%d", getpid(), offset++); #endif *fd = open(full_path, O_RDWR | O_CREAT, 0664); assert(*fd >= 0); unlink(full_path); ftruncate(*fd, len); void *addr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, *fd, 0); assert(addr != MAP_FAILED); return addr; } void VisionBuf::allocate(size_t len) { int fd; void *addr = malloc_with_fd(len, &fd); this->len = len; this->mmap_len = len; this->addr = addr; this->fd = fd; } void VisionBuf::init_cl(cl_device_id device_id, cl_context ctx){ int err; this->copy_q = clCreateCommandQueue(ctx, device_id, 0, &err); assert(err == 0); this->buf_cl = clCreateBuffer(ctx, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, this->len, this->addr, &err); assert(err == 0); } void VisionBuf::import(){ assert(this->fd >= 0); this->addr = mmap(NULL, this->mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED, this->fd, 0); assert(this->addr != MAP_FAILED); } int VisionBuf::sync(int dir) { int err = 0; if (!this->buf_cl) return 0; if (dir == VISIONBUF_SYNC_FROM_DEVICE) { err = clEnqueueReadBuffer(this->copy_q, this->buf_cl, CL_FALSE, 0, this->len, this->addr, 0, NULL, NULL); } else { err = clEnqueueWriteBuffer(this->copy_q, this->buf_cl, CL_FALSE, 0, this->len, this->addr, 0, NULL, NULL); } if (err == 0){ err = clFinish(this->copy_q); } return err; } int VisionBuf::free() { int err = 0; if (this->buf_cl){ err = clReleaseMemObject(this->buf_cl); if (err != 0) return err; err = clReleaseCommandQueue(this->copy_q); if (err != 0) return err; } err = munmap(this->addr, this->len); if (err != 0) return err; err = close(this->fd); return err; } ================================================ FILE: cereal/visionipc/visionbuf_ion.cc ================================================ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "visionbuf.h" // just hard-code these for convenience // size_t device_page_size = 0; // clGetDeviceInfo(device_id, CL_DEVICE_PAGE_SIZE_QCOM, // sizeof(device_page_size), &device_page_size, // NULL); // size_t padding_cl = 0; // clGetDeviceInfo(device_id, CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM, // sizeof(padding_cl), &padding_cl, // NULL); #define DEVICE_PAGE_SIZE_CL 4096 #define PADDING_CL 0 static int ion_fd = -1; static void ion_init() { if (ion_fd == -1) { ion_fd = open("/dev/ion", O_RDWR | O_NONBLOCK); } } void VisionBuf::allocate(size_t len) { int err; ion_init(); struct ion_allocation_data ion_alloc = {0}; ion_alloc.len = len + PADDING_CL; ion_alloc.align = 4096; ion_alloc.heap_id_mask = 1 << ION_IOMMU_HEAP_ID; ion_alloc.flags = ION_FLAG_CACHED; err = ioctl(ion_fd, ION_IOC_ALLOC, &ion_alloc); assert(err == 0); struct ion_fd_data ion_fd_data = {0}; ion_fd_data.handle = ion_alloc.handle; err = ioctl(ion_fd, ION_IOC_SHARE, &ion_fd_data); assert(err == 0); void *addr = mmap(NULL, ion_alloc.len, PROT_READ | PROT_WRITE, MAP_SHARED, ion_fd_data.fd, 0); assert(addr != MAP_FAILED); memset(addr, 0, ion_alloc.len); this->len = len; this->mmap_len = ion_alloc.len; this->addr = addr; this->handle = ion_alloc.handle; this->fd = ion_fd_data.fd; } void VisionBuf::import(){ int err; assert(this->fd >= 0); ion_init(); // Get handle struct ion_fd_data fd_data = {0}; fd_data.fd = this->fd; err = ioctl(ion_fd, ION_IOC_IMPORT, &fd_data); assert(err == 0); this->handle = fd_data.handle; this->addr = mmap(NULL, this->mmap_len, PROT_READ | PROT_WRITE, MAP_SHARED, this->fd, 0); assert(this->addr != MAP_FAILED); } void VisionBuf::init_cl(cl_device_id device_id, cl_context ctx) { int err; assert(((uintptr_t)this->addr % DEVICE_PAGE_SIZE_CL) == 0); cl_mem_ion_host_ptr ion_cl = {0}; ion_cl.ext_host_ptr.allocation_type = CL_MEM_ION_HOST_PTR_QCOM; ion_cl.ext_host_ptr.host_cache_policy = CL_MEM_HOST_UNCACHED_QCOM; ion_cl.ion_filedesc = this->fd; ion_cl.ion_hostptr = this->addr; this->buf_cl = clCreateBuffer(ctx, CL_MEM_USE_HOST_PTR | CL_MEM_EXT_HOST_PTR_QCOM, this->len, &ion_cl, &err); assert(err == 0); } int VisionBuf::sync(int dir) { struct ion_flush_data flush_data = {0}; flush_data.handle = this->handle; flush_data.vaddr = this->addr; flush_data.offset = 0; flush_data.length = this->len; // ION_IOC_INV_CACHES ~= DMA_FROM_DEVICE // ION_IOC_CLEAN_CACHES ~= DMA_TO_DEVICE // ION_IOC_CLEAN_INV_CACHES ~= DMA_BIDIRECTIONAL struct ion_custom_data custom_data = {0}; assert(dir == VISIONBUF_SYNC_FROM_DEVICE || dir == VISIONBUF_SYNC_TO_DEVICE); custom_data.cmd = (dir == VISIONBUF_SYNC_FROM_DEVICE) ? ION_IOC_INV_CACHES : ION_IOC_CLEAN_CACHES; custom_data.arg = (unsigned long)&flush_data; return ioctl(ion_fd, ION_IOC_CUSTOM, &custom_data); } int VisionBuf::free() { int err = 0; if (this->buf_cl){ err = clReleaseMemObject(this->buf_cl); if (err != 0) return err; } err = munmap(this->addr, this->mmap_len); if (err != 0) return err; err = close(this->fd); if (err != 0) return err; struct ion_handle_data handle_data = {.handle = this->handle}; return ioctl(ion_fd, ION_IOC_FREE, &handle_data); } ================================================ FILE: cereal/visionipc/visionipc.h ================================================ #pragma once #include #include constexpr int VISIONIPC_MAX_FDS = 128; struct VisionIpcBufExtra { uint32_t frame_id; uint64_t timestamp_sof; uint64_t timestamp_eof; }; struct VisionIpcPacket { uint64_t server_id; size_t idx; struct VisionIpcBufExtra extra; }; ================================================ FILE: cereal/visionipc/visionipc.pxd ================================================ # distutils: language = c++ #cython: language_level=3 from libcpp.string cimport string from libcpp.vector cimport vector from libc.stdint cimport uint32_t, uint64_t from libcpp cimport bool cdef extern from "visionbuf.h": cdef enum VisionStreamType: pass cdef cppclass VisionBuf: void * addr size_t len size_t width size_t height size_t stride cdef extern from "visionipc.h": struct VisionIpcBufExtra: uint32_t frame_id uint64_t timestamp_sof uint64_t timestamp_eof cdef extern from "visionipc_server.h": cdef cppclass VisionIpcServer: VisionIpcServer(string, void*, void*) void create_buffers(VisionStreamType, size_t, bool, size_t, size_t) VisionBuf * get_buffer(VisionStreamType) void send(VisionBuf *, VisionIpcBufExtra *, bool) void start_listener() cdef extern from "visionipc_client.h": cdef cppclass VisionIpcClient: VisionIpcClient(string, VisionStreamType, bool, void*, void*) VisionBuf * recv(VisionIpcBufExtra *, int) bool connect(bool) ================================================ FILE: cereal/visionipc/visionipc_client.cc ================================================ #include #include #include #include #include "visionipc/ipc.h" #include "visionipc/visionipc_client.h" #include "visionipc/visionipc_server.h" #include "logger/logger.h" VisionIpcClient::VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id, cl_context ctx) : name(name), type(type), device_id(device_id), ctx(ctx) { msg_ctx = Context::create(); sock = SubSocket::create(msg_ctx, get_endpoint_name(name, type), "127.0.0.1", conflate, false); poller = Poller::create(); poller->registerSocket(sock); } // Connect is not thread safe. Do not use the buffers while calling connect bool VisionIpcClient::connect(bool blocking){ connected = false; // Cleanup old buffers on reconnect for (size_t i = 0; i < num_buffers; i++){ if (buffers[i].free() != 0) { LOGE("Failed to free buffer %zu", i); } } num_buffers = 0; // Connect to server socket and ask for all FDs of type std::string path = "/tmp/visionipc_" + name; int socket_fd = -1; while (socket_fd < 0) { socket_fd = ipc_connect(path.c_str()); if (socket_fd < 0) { if (blocking){ std::cout << "VisionIpcClient connecting" << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(100)); } else { return false; } } } // Send stream type to server to request FDs int r = ipc_sendrecv_with_fds(true, socket_fd, &type, sizeof(type), nullptr, 0, nullptr); assert(r == sizeof(type)); // Get FDs int fds[VISIONIPC_MAX_FDS]; VisionBuf bufs[VISIONIPC_MAX_FDS]; r = ipc_sendrecv_with_fds(false, socket_fd, &bufs, sizeof(bufs), fds, VISIONIPC_MAX_FDS, &num_buffers); assert(num_buffers > 0); assert(r == sizeof(VisionBuf) * num_buffers); // Import buffers for (size_t i = 0; i < num_buffers; i++){ buffers[i] = bufs[i]; buffers[i].fd = fds[i]; buffers[i].import(); if (buffers[i].rgb) { buffers[i].init_rgb(buffers[i].width, buffers[i].height, buffers[i].stride); } else { buffers[i].init_yuv(buffers[i].width, buffers[i].height); } if (device_id) buffers[i].init_cl(device_id, ctx); } connected = true; return true; } VisionBuf * VisionIpcClient::recv(VisionIpcBufExtra * extra, const int timeout_ms){ auto p = poller->poll(timeout_ms); if (!p.size()){ return nullptr; } Message * r = sock->receive(true); if (r == nullptr){ return nullptr; } // Get buffer assert(r->getSize() == sizeof(VisionIpcPacket)); VisionIpcPacket *packet = (VisionIpcPacket*)r->getData(); assert(packet->idx < num_buffers); VisionBuf * buf = &buffers[packet->idx]; if (buf->server_id != packet->server_id){ connected = false; delete r; return nullptr; } if (extra) { *extra = packet->extra; } if (buf->sync(VISIONBUF_SYNC_TO_DEVICE) != 0) { LOGE("Failed to sync buffer"); } delete r; return buf; } VisionIpcClient::~VisionIpcClient(){ for (size_t i = 0; i < num_buffers; i++){ if (buffers[i].free() != 0) { LOGE("Failed to free buffer %zu", i); } } delete sock; delete poller; delete msg_ctx; } ================================================ FILE: cereal/visionipc/visionipc_client.h ================================================ #pragma once #include #include #include #include "messaging/messaging.h" #include "visionipc/visionipc.h" #include "visionipc/visionbuf.h" class VisionIpcClient { private: std::string name; Context * msg_ctx; SubSocket * sock; Poller * poller; VisionStreamType type; cl_device_id device_id = nullptr; cl_context ctx = nullptr; void init_msgq(bool conflate); public: bool connected = false; int num_buffers = 0; VisionBuf buffers[VISIONIPC_MAX_FDS]; VisionIpcClient(std::string name, VisionStreamType type, bool conflate, cl_device_id device_id=nullptr, cl_context ctx=nullptr); ~VisionIpcClient(); VisionBuf * recv(VisionIpcBufExtra * extra=nullptr, const int timeout_ms=100); bool connect(bool blocking=true); }; ================================================ FILE: cereal/visionipc/visionipc_pyx.pyx ================================================ # distutils: language = c++ # cython: c_string_encoding=ascii, language_level=3 import sys import numpy as np cimport numpy as cnp from cython.view cimport array from libc.string cimport memcpy from libc.stdint cimport uint32_t, uint64_t from libcpp cimport bool from libcpp.string cimport string from .visionipc cimport VisionIpcServer as cppVisionIpcServer from .visionipc cimport VisionIpcClient as cppVisionIpcClient from .visionipc cimport VisionBuf as cppVisionBuf from .visionipc cimport VisionIpcBufExtra cpdef enum VisionStreamType: VISION_STREAM_RGB_BACK VISION_STREAM_RGB_FRONT VISION_STREAM_RGB_WIDE VISION_STREAM_YUV_BACK VISION_STREAM_YUV_FRONT VISION_STREAM_YUV_WIDE cdef class VisionIpcServer: cdef cppVisionIpcServer * server def __init__(self, string name): self.server = new cppVisionIpcServer(name, NULL, NULL) def create_buffers(self, VisionStreamType tp, size_t num_buffers, bool rgb, size_t width, size_t height): self.server.create_buffers(tp, num_buffers, rgb, width, height) def send(self, VisionStreamType tp, bytes data, uint32_t frame_id=0, uint64_t timestamp_sof=0, uint64_t timestamp_eof=0): cdef cppVisionBuf * buf = self.server.get_buffer(tp) # Populate buffer assert buf.len == len(data) memcpy(buf.addr, data, len(data)) cdef VisionIpcBufExtra extra extra.frame_id = frame_id extra.timestamp_sof = timestamp_sof extra.timestamp_eof = timestamp_eof self.server.send(buf, &extra, False) def start_listener(self): self.server.start_listener() def __dealloc__(self): del self.server cdef class VisionIpcClient: cdef cppVisionBuf * buf cdef cppVisionIpcClient * client def __cinit__(self, string name, VisionStreamType stream, bool conflate): self.client = new cppVisionIpcClient(name, stream, conflate, NULL, NULL) self.buf = NULL def __dealloc__(self): del self.client @property def width(self): return None if not self.buf else self.buf.width @property def height(self): return None if not self.buf else self.buf.height @property def stride(self): return None if not self.buf else self.buf.stride def recv(self, int timeout_ms=100): self.buf = self.client.recv(NULL, timeout_ms) if not self.buf: return None cdef cnp.ndarray dat = np.empty(self.buf.len, dtype=np.uint8) cdef char[:] dat_view = dat memcpy(&dat_view[0], self.buf.addr, self.buf.len) return dat def connect(self, bool blocking): return self.client.connect(blocking) ================================================ FILE: cereal/visionipc/visionipc_server.cc ================================================ #include #include #include #include #include #include #include #include "messaging/messaging.h" #include "visionipc/ipc.h" #include "visionipc/visionipc_server.h" #include "logger/logger.h" std::string get_endpoint_name(std::string name, VisionStreamType type){ if (messaging_use_zmq()){ assert(name == "camerad"); return std::to_string(9000 + static_cast(type)); } else { return "visionipc_" + name + "_" + std::to_string(type); } } VisionIpcServer::VisionIpcServer(std::string name, cl_device_id device_id, cl_context ctx) : name(name), device_id(device_id), ctx(ctx) { msg_ctx = Context::create(); std::random_device rd("/dev/urandom"); std::uniform_int_distribution distribution(0,std::numeric_limits::max()); server_id = distribution(rd); } void VisionIpcServer::create_buffers(VisionStreamType type, size_t num_buffers, bool rgb, size_t width, size_t height){ // TODO: assert that this type is not created yet assert(num_buffers < VISIONIPC_MAX_FDS); int aligned_w = 0, aligned_h = 0; size_t size = 0; size_t stride = 0; // Only used for RGB if (rgb) { visionbuf_compute_aligned_width_and_height(width, height, &aligned_w, &aligned_h); size = (size_t)aligned_w * (size_t)aligned_h * 3; stride = aligned_w * 3; } else { size = width * height * 3 / 2; } // Create map + alloc requested buffers for (size_t i = 0; i < num_buffers; i++){ VisionBuf* buf = new VisionBuf(); buf->allocate(size); buf->idx = i; buf->type = type; if (device_id) buf->init_cl(device_id, ctx); rgb ? buf->init_rgb(width, height, stride) : buf->init_yuv(width, height); buffers[type].push_back(buf); } cur_idx[type] = 0; // Create msgq publisher for each of the `name` + type combos // TODO: compute port number directly if using zmq sockets[type] = PubSocket::create(msg_ctx, get_endpoint_name(name, type), false); } void VisionIpcServer::start_listener(){ listener_thread = std::thread(&VisionIpcServer::listener, this); } void VisionIpcServer::listener(){ std::cout << "Starting listener for: " << name << std::endl; std::string path = "/tmp/visionipc_" + name; int sock = ipc_bind(path.c_str()); assert(sock >= 0); while (!should_exit){ // Wait for incoming connection struct pollfd polls[1] = {{0}}; polls[0].fd = sock; polls[0].events = POLLIN; int ret = poll(polls, 1, 100); if (ret < 0) { if (errno == EINTR || errno == EAGAIN) continue; std::cout << "poll failed, stopping listener" << std::endl; break; } if (should_exit) break; if (!polls[0].revents) { continue; } // Handle incoming request int fd = accept(sock, NULL, NULL); assert(fd >= 0); VisionStreamType type = VisionStreamType::VISION_STREAM_MAX; int r = ipc_sendrecv_with_fds(false, fd, &type, sizeof(type), nullptr, 0, nullptr); assert(r == sizeof(type)); if (buffers.count(type) <= 0) { std::cout << "got request for invalid buffer type: " << type << std::endl; close(fd); continue; } int fds[VISIONIPC_MAX_FDS]; int num_fds = buffers[type].size(); VisionBuf bufs[VISIONIPC_MAX_FDS]; for (int i = 0; i < num_fds; i++){ fds[i] = buffers[type][i]->fd; bufs[i] = *buffers[type][i]; // Remove some private openCL/ion metadata bufs[i].buf_cl = 0; bufs[i].copy_q = 0; bufs[i].handle = 0; bufs[i].server_id = server_id; } r = ipc_sendrecv_with_fds(true, fd, &bufs, sizeof(VisionBuf) * num_fds, fds, num_fds, nullptr); close(fd); } std::cout << "Stopping listener for: " << name << std::endl; close(sock); } VisionBuf * VisionIpcServer::get_buffer(VisionStreamType type){ // Do we want to keep track if the buffer has been sent out yet and warn user? assert(buffers.count(type)); auto b = buffers[type]; return b[cur_idx[type]++ % b.size()]; } void VisionIpcServer::send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync){ if (sync) { if (buf->sync(VISIONBUF_SYNC_FROM_DEVICE) != 0) { LOGE("Failed to sync buffer"); } } assert(buffers.count(buf->type)); assert(buf->idx < buffers[buf->type].size()); // Send over correct msgq socket VisionIpcPacket packet = {0}; packet.server_id = server_id; packet.idx = buf->idx; packet.extra = *extra; sockets[buf->type]->send((char*)&packet, sizeof(packet)); } VisionIpcServer::~VisionIpcServer(){ should_exit = true; listener_thread.join(); // VisionBuf cleanup for( auto const& [type, buf] : buffers ) { for (VisionBuf* b : buf){ if (b->free() != 0) { LOGE("Failed to free buffer"); } delete b; } } // Messaging cleanup for( auto const& [type, sock] : sockets ) { delete sock; } delete msg_ctx; } ================================================ FILE: cereal/visionipc/visionipc_server.h ================================================ #pragma once #include #include #include #include #include #include "messaging/messaging.h" #include "visionipc/visionipc.h" #include "visionipc/visionbuf.h" std::string get_endpoint_name(std::string name, VisionStreamType type); class VisionIpcServer { private: cl_device_id device_id = nullptr; cl_context ctx = nullptr; uint64_t server_id; std::atomic should_exit = false; std::string name; std::thread listener_thread; std::map > cur_idx; std::map > buffers; std::map > idxs; Context * msg_ctx; std::map sockets; void listener(void); public: VisionIpcServer(std::string name, cl_device_id device_id=nullptr, cl_context ctx=nullptr); ~VisionIpcServer(); VisionBuf * get_buffer(VisionStreamType type); void create_buffers(VisionStreamType type, size_t num_buffers, bool rgb, size_t width, size_t height); void send(VisionBuf * buf, VisionIpcBufExtra * extra, bool sync=true); void start_listener(); }; ================================================ FILE: cereal/visionipc/visionipc_tests.cc ================================================ #include #include #include "catch2/catch.hpp" #include "visionipc_server.h" #include "visionipc_client.h" static void zmq_sleep(int milliseconds=1000){ if (messaging_use_zmq()){ std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); } } TEST_CASE("Connecting"){ VisionIpcServer server("camerad"); server.create_buffers(VISION_STREAM_YUV_BACK, 1, false, 100, 100); server.start_listener(); VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false); REQUIRE(client.connect()); REQUIRE(client.connected); } TEST_CASE("Check buffers"){ size_t width = 100, height = 200, num_buffers = 5; VisionIpcServer server("camerad"); server.create_buffers(VISION_STREAM_YUV_BACK, num_buffers, false, width, height); server.start_listener(); VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false); REQUIRE(client.connect()); REQUIRE(client.buffers[0].width == width); REQUIRE(client.buffers[0].height == height); REQUIRE(client.buffers[0].len); REQUIRE(client.num_buffers == num_buffers); } TEST_CASE("Check yuv/rgb"){ VisionIpcServer server("camerad"); server.create_buffers(VISION_STREAM_YUV_BACK, 1, false, 100, 100); server.create_buffers(VISION_STREAM_RGB_BACK, 1, true, 100, 100); server.start_listener(); VisionIpcClient client_yuv = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false); VisionIpcClient client_rgb = VisionIpcClient("camerad", VISION_STREAM_RGB_BACK, false); client_yuv.connect(); client_rgb.connect(); REQUIRE(client_rgb.buffers[0].rgb == true); REQUIRE(client_yuv.buffers[0].rgb == false); } TEST_CASE("Send single buffer"){ VisionIpcServer server("camerad"); server.create_buffers(VISION_STREAM_YUV_BACK, 1, true, 100, 100); server.start_listener(); VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false); REQUIRE(client.connect()); zmq_sleep(); VisionBuf * buf = server.get_buffer(VISION_STREAM_YUV_BACK); REQUIRE(buf != nullptr); *((uint64_t*)buf->addr) = 1234; VisionIpcBufExtra extra = {0}; extra.frame_id = 1337; server.send(buf, &extra); VisionIpcBufExtra extra_recv = {0}; VisionBuf * recv_buf = client.recv(&extra_recv); REQUIRE(recv_buf != nullptr); REQUIRE(*(uint64_t*)recv_buf->addr == 1234); REQUIRE(extra_recv.frame_id == extra.frame_id); } TEST_CASE("Test no conflate"){ VisionIpcServer server("camerad"); server.create_buffers(VISION_STREAM_YUV_BACK, 1, true, 100, 100); server.start_listener(); VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, false); REQUIRE(client.connect()); zmq_sleep(); VisionBuf * buf = server.get_buffer(VISION_STREAM_YUV_BACK); REQUIRE(buf != nullptr); VisionIpcBufExtra extra = {0}; extra.frame_id = 1; server.send(buf, &extra); extra.frame_id = 2; server.send(buf, &extra); VisionIpcBufExtra extra_recv = {0}; VisionBuf * recv_buf = client.recv(&extra_recv); REQUIRE(recv_buf != nullptr); REQUIRE(extra_recv.frame_id == 1); recv_buf = client.recv(&extra_recv); REQUIRE(recv_buf != nullptr); REQUIRE(extra_recv.frame_id == 2); } TEST_CASE("Test conflate"){ VisionIpcServer server("camerad"); server.create_buffers(VISION_STREAM_YUV_BACK, 1, true, 100, 100); server.start_listener(); VisionIpcClient client = VisionIpcClient("camerad", VISION_STREAM_YUV_BACK, true); REQUIRE(client.connect()); zmq_sleep(); VisionBuf * buf = server.get_buffer(VISION_STREAM_YUV_BACK); REQUIRE(buf != nullptr); VisionIpcBufExtra extra = {0}; extra.frame_id = 1; server.send(buf, &extra); extra.frame_id = 2; server.send(buf, &extra); VisionIpcBufExtra extra_recv = {0}; VisionBuf * recv_buf = client.recv(&extra_recv); REQUIRE(recv_buf != nullptr); REQUIRE(extra_recv.frame_id == 2); recv_buf = client.recv(&extra_recv); REQUIRE(recv_buf == nullptr); } ================================================ FILE: common/.gitignore ================================================ *.cpp ================================================ FILE: common/SConscript ================================================ Import('envCython', 'common') envCython.Program('clock.so', 'clock.pyx') envCython.Program('params_pyx.so', 'params_pyx.pyx', LIBS=envCython['LIBS'] + [common, 'zmq']) ================================================ FILE: common/__init__.py ================================================ ================================================ FILE: common/api/__init__.py ================================================ import jwt import os import requests from datetime import datetime, timedelta from common.basedir import PERSIST from selfdrive.version import version from common.params import Params API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com') if not Params().get_bool("dp_api_custom") else Params().get("dp_api_custom_url", encoding='utf-8') class Api(): def __init__(self, dongle_id): if "commadotai" in API_HOST and (Params().get_bool("dp_jetson") or Params().get_bool("dp_atl")): raise RuntimeError("API access is disabled because you are not using custom server and you have jetson enabled.") self.dongle_id = dongle_id with open(PERSIST+'/comma/id_rsa') as f: self.private_key = f.read() def get(self, *args, **kwargs): return self.request('GET', *args, **kwargs) def post(self, *args, **kwargs): return self.request('POST', *args, **kwargs) def request(self, method, endpoint, timeout=None, access_token=None, **params): return api_get(endpoint, method=method, timeout=timeout, access_token=access_token, **params) def get_token(self): now = datetime.utcnow() payload = { 'identity': self.dongle_id, 'nbf': now, 'iat': now, 'exp': now + timedelta(hours=1) } token = jwt.encode(payload, self.private_key, algorithm='RS256') if isinstance(token, bytes): token = token.decode('utf8') return token def api_get(endpoint, method='GET', timeout=None, access_token=None, **params): headers = {} if access_token is not None: headers['Authorization'] = "JWT "+access_token headers['User-Agent'] = "openpilot-" + version return requests.request(method, API_HOST + "/" + endpoint, timeout=timeout, headers=headers, params=params) ================================================ FILE: common/basedir.py ================================================ import os from pathlib import Path from selfdrive.hardware import PC BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../")) if PC: PERSIST = os.path.join(str(Path.home()), ".comma", "persist") else: PERSIST = "/persist" ================================================ FILE: common/clock.pyx ================================================ # distutils: language = c++ # cython: language_level = 3 from posix.time cimport clock_gettime, timespec, CLOCK_MONOTONIC_RAW, clockid_t IF UNAME_SYSNAME == "Darwin": # Darwin doesn't have a CLOCK_BOOTTIME CLOCK_BOOTTIME = CLOCK_MONOTONIC_RAW ELSE: from posix.time cimport CLOCK_BOOTTIME cdef double readclock(clockid_t clock_id): cdef timespec ts cdef double current clock_gettime(clock_id, &ts) current = ts.tv_sec + (ts.tv_nsec / 1000000000.) return current def monotonic_time(): return readclock(CLOCK_MONOTONIC_RAW) def sec_since_boot(): return readclock(CLOCK_BOOTTIME) ================================================ FILE: common/cython_hacks.py ================================================ import os import sysconfig from Cython.Distutils import build_ext def get_ext_filename_without_platform_suffix(filename): name, ext = os.path.splitext(filename) ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') if ext_suffix == ext: return filename ext_suffix = ext_suffix.replace(ext, '') idx = name.find(ext_suffix) if idx == -1: return filename else: return name[:idx] + ext class BuildExtWithoutPlatformSuffix(build_ext): def get_ext_filename(self, ext_name): filename = super().get_ext_filename(ext_name) return get_ext_filename_without_platform_suffix(filename) ================================================ FILE: common/dict_helpers.py ================================================ # remove all keys that end in DEPRECATED def strip_deprecated_keys(d): for k in list(d.keys()): if isinstance(k, str): if k.endswith('DEPRECATED'): d.pop(k) elif isinstance(d[k], dict): strip_deprecated_keys(d[k]) return d ================================================ FILE: common/dp_common.py ================================================ #!/usr/bin/env python3.7 import subprocess from cereal import car from common.params import Params from common.realtime import sec_since_boot import os params = Params() PARAM_PATH = params.get_params_path() + '/d/' LAST_MODIFIED = PARAM_PATH + "dp_last_modified" def is_online(): try: return not subprocess.call(["ping", "-W", "4", "-c", "1", "117.28.245.92"]) except ProcessLookupError: return False def common_controller_ctrl(enabled, dragonconf, blinker_on, steer_req, v_ego): if enabled: if dragonconf.dpLateralMode == 0 and blinker_on: steer_req = 0 if isinstance(steer_req, int) else False return steer_req def common_interface_atl(ret, atl): # dp enable_acc = ret.cruiseState.enabled if atl and ret.cruiseState.available: enable_acc = True if ret.gearShifter in [car.CarState.GearShifter.reverse, car.CarState.GearShifter.park]: enable_acc = False if ret.seatbeltUnlatched or ret.doorOpen: enable_acc = False return enable_acc def common_interface_get_params_lqr(ret): if params.get_bool('dp_lqr'): ret.lateralTuning.init('lqr') ret.lateralTuning.lqr.scale = 1500.0 ret.lateralTuning.lqr.ki = 0.05 ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268] ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05] ret.lateralTuning.lqr.c = [1., 0.] ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255] ret.lateralTuning.lqr.l = [0.3233671, 0.3185757] ret.lateralTuning.lqr.dcGain = 0.002237852961363602 return ret def get_last_modified(delay, old_check, old_modified): new_check = sec_since_boot() if os.path.isfile(LAST_MODIFIED) and old_check is None or new_check - old_check >= delay: return new_check, os.stat(LAST_MODIFIED).st_mtime else: return old_check, old_modified def param_get_if_updated(param, type, old_val, old_modified): try: modified = os.stat(PARAM_PATH + param).st_mtime except OSError: return old_val, old_modified if old_modified != modified: new_val = param_get(param, type, old_val) new_modified = modified else: new_val = old_val new_modified = old_modified return new_val, new_modified def param_get(param_name, type, default): try: val = params.get(param_name, encoding='utf8').rstrip('\x00') if type == 'bool': val = val == '1' elif type == 'int': val = int(val) elif type == 'float': val = float(val) except (TypeError, ValueError): val = default return val ================================================ FILE: common/dp_conf.py ================================================ #!/usr/bin/env python3.7 import os import sys import json import time from math import floor ''' * type: Bool, Int8, UInt8, UInt16, Float32 * conf_type: param, struct * dependencies needs to use struct and loaded prior so we don't have to read the param multiple times. * update_once: True, False (the param will only load up once, need both param and struct defined) ''' confs = [ # thermald data {'name': 'dp_thermal_started', 'default': False, 'type': 'Bool', 'conf_type': ['struct']}, {'name': 'dp_thermal_overheat', 'default': False, 'type': 'Bool', 'conf_type': ['struct']}, # custom api server {'name': 'dp_api_custom', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_api_custom_url', 'default': 'https://api.retropilot.org', 'type': 'Text', 'depends': [{'name': 'dp_api_custom', 'vals': [True]}], 'conf_type': ['param']}, {'name': 'dp_atl', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct'], 'update_once': True}, {'name': 'dp_atl_op_long', 'default': False, 'type': 'Bool', 'depends': [{'name': 'dp_atl', 'vals': [True]}], 'conf_type': ['param', 'struct'], 'update_once': True}, # dashcam related {'name': 'dp_dashcamd', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, # auto shutdown {'name': 'dp_auto_shutdown', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_auto_shutdown_in', 'default': 90, 'type': 'UInt16', 'min': 0, 'max': 600, 'depends': [{'name': 'dp_auto_shutdown', 'vals': [True]}], 'conf_type': ['param']}, # service {'name': 'dp_updated', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_logger', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_athenad', 'default': False, 'type': 'Bool', 'depends': [{'name': 'dp_atl', 'vals': [False]}], 'conf_type': ['param', 'struct'], 'update_once': True}, {'name': 'dp_uploader', 'default': False, 'type': 'Bool', 'depends': [{'name': 'dp_atl', 'vals': [False]}], 'conf_type': ['param', 'struct'], 'update_once': True}, # {'name': 'dp_gpxd', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_hotspot_on_boot', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, # lat ctrl {'name': 'dp_lateral_mode', 'default': 1, 'type': 'UInt8', 'min': 0, 'max': 2, 'conf_type': ['param', 'struct']}, {'name': 'dp_signal_off_delay', 'default': 3., 'type': 'Float32', 'min': 0., 'max': 10., 'depends': [{'name': 'dp_lateral_mode', 'vals': [0]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_lc_min_mph', 'default': 45, 'type': 'UInt8', 'min': 0, 'max': 255, 'depends': [{'name': 'dp_lateral_mode', 'vals': [1,2]}], 'conf_type': ['param', 'struct']}, # {'name': 'dp_lc_auto_cont', 'default': False, 'type': 'Bool', 'depends': [{'name': 'dp_lateral_mode', 'vals': [2]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_lc_auto_min_mph', 'default': 60, 'type': 'UInt8', 'min': 0, 'max': 255, 'depends': [{'name': 'dp_lateral_mode', 'vals': [2]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_lc_auto_delay', 'default': 3., 'type': 'Float32', 'min': 0., 'max': 10., 'depends': [{'name': 'dp_lateral_mode', 'vals': [2]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_lane_less_mode_ctrl', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_lane_less_mode', 'default': 2, 'type': 'UInt8', 'min': 0, 'max': 2, 'depends': [{'name': 'dp_lane_less_mode_ctrl', 'vals': [True]}], 'conf_type': ['param', 'struct']}, # long ctrl {'name': 'dp_allow_gas', 'default': False, 'type': 'Bool', 'depends': [{'name': 'dp_atl', 'vals': [False]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_following_profile_ctrl', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_following_profile', 'default': 0, 'type': 'UInt8', 'min': 0, 'max': 3, 'depends': [{'name': 'dp_following_profile_ctrl', 'vals': [True]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_accel_profile_ctrl', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_accel_profile', 'default': 0, 'type': 'UInt8', 'min': 0, 'max': 2, 'depends': [{'name': 'dp_accel_profile_ctrl', 'vals': [True]}], 'conf_type': ['param', 'struct']}, # safety {'name': 'dp_gear_check', 'default': True, 'type': 'Bool', 'depends': [{'name': 'dp_atl', 'vals': [False]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_speed_check', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_temp_monitor', 'default': True, 'type': 'Bool', 'conf_type': ['param']}, # UIs {'name': 'dp_ui_display_mode', 'default': 0, 'type': 'UInt8', 'min': 0, 'max': 2, 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_speed', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_event', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_max_speed', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_face', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_lane', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_lead', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_side', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_top', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_blinker', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_brightness', 'default': 0, 'type': 'UInt8', 'min': 0, 'max': 100, 'conf_type': ['param', 'struct']}, {'name': 'dp_ui_volume', 'default': -5, 'type': 'Int8', 'min': -5, 'max': 100, 'conf_type': ['param', 'struct']}, # toyota {'name': 'dp_lexus_rx_rpm_fix', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_toyota_ldw', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_toyota_sng', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_toyota_zss', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_toyota_fp_btn_link', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_toyota_ap_btn_link', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_toyota_disable_relay', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_toyota_cruise_override', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_toyota_cruise_override_vego', 'default': False, 'type': 'Bool', 'depends': [{'name': 'dp_toyota_cruise_override', 'vals': [True]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_toyota_cruise_override_at', 'default': 44, 'type': 'Float32', 'depends': [{'name': 'dp_toyota_cruise_override', 'vals': [True]}], 'min': 0, 'max': 50., 'conf_type': ['param', 'struct']}, {'name': 'dp_toyota_cruise_override_speed', 'default': 32, 'type': 'Float32', 'depends': [{'name': 'dp_toyota_cruise_override', 'vals': [True]}], 'min': 0, 'max': 50., 'conf_type': ['param', 'struct']}, # hyundai {'name': 'dp_hkg_smart_mdps', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, # honda {'name': 'dp_honda_eps_mod', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_honda_kmh_display', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, # volkswagen {'name': 'dp_vw_panda', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_vw_timebomb_assist', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, #misc {'name': 'dp_ip_addr', 'default': '', 'type': 'Text', 'conf_type': ['struct']}, {'name': 'dp_fan_mode', 'default': 0, 'type': 'UInt8', 'min': 0, 'max': 2, 'conf_type': ['param']}, {'name': 'dp_last_modified', 'default': str(floor(time.time())), 'type': 'Text', 'conf_type': ['param']}, {'name': 'dp_camera_offset', 'default': 6, 'type': 'Int8', 'min': -100, 'max': 100, 'conf_type': ['param', 'struct']}, {'name': 'dp_path_offset', 'default': 0, 'type': 'Int8', 'min': -100, 'max': 100, 'conf_type': ['param', 'struct']}, {'name': 'dp_locale', 'default': 'en-US', 'type': 'Text', 'conf_type': ['param', 'struct'], 'update_once': True}, {'name': 'dp_reg', 'default': True, 'type': 'Bool', 'conf_type': ['param']}, # sr learner related {'name': 'dp_sr_learner', 'default': True, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_sr_custom', 'default': 9.99, 'min': 9.99, 'max': 30., 'type': 'Float32', 'depends': [{'name': 'dp_sr_learner', 'vals': [False]}], 'conf_type': ['param', 'struct']}, {'name': 'dp_sr_stock', 'default': 9.99, 'min': 9.99, 'max': 100., 'type': 'Float32', 'conf_type': ['param']}, {'name': 'dp_lqr', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_reset_live_param_on_start', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_appd', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_jetson', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_car_assigned', 'default': '', 'type': 'Text', 'conf_type': ['param']}, {'name': 'dp_car_list', 'default': '', 'type': 'Text', 'conf_type': ['param']}, {'name': 'dp_no_batt', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_last_candidate', 'default': '', 'type': 'Text', 'conf_type': ['param']}, {'name': 'dp_prebuilt', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_gpxd', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_mapd', 'default': False, 'type': 'Bool', 'conf_type': ['param', 'struct']}, {'name': 'dp_otisserv', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_mapbox_token_pk', 'default': '', 'type': 'Text', 'conf_type': ['param']}, {'name': 'dp_mapbox_token_sk', 'default': '', 'type': 'Text', 'conf_type': ['param']}, {'name': 'dp_mapbox_full_screen', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_mapbox_traffic', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_mapbox_gmap_enable', 'default': False, 'type': 'Bool', 'conf_type': ['param']}, {'name': 'dp_mapbox_gmap_key', 'default': '', 'type': 'Text', 'conf_type': ['param']}, ] def get_definition(name): for conf in confs: if conf['name'] == name: return conf return None def to_param_val(name, val): conf = get_definition(name) if conf is not None: type = conf['type'].lower() try: if 'bool' in type: val = '1' if val else '0' elif 'int' in type: val = int(val) elif 'float' in type: val = float(val) return str(val) except (ValueError, TypeError): return '' return '' def to_struct_val(name, val): conf = get_definition(name) if conf is not None: try: type = conf['type'].lower() if 'bool' in type: val = True if val == '1' else False elif 'int' in type: val = int(val) elif 'float' in type: val = float(val) return val except (ValueError, TypeError): return None return None ''' function to convert param name into struct name. ''' def get_struct_name(snake_str): components = snake_str.split('_') # We capitalize the first letter of each component except the first one # with the 'title' method and join them together. return components[0] + ''.join(x.title() for x in components[1:]) ''' function to generate struct for log.capnp ''' def gen_log_struct(): count = 0 str = "# dp\n" str += "struct DragonConf {\n" for conf in confs: name = get_struct_name(conf['name']) if 'struct' in conf['conf_type']: str += f" {name} @{count} :{conf['type']};\n" count += 1 str += "}" print(str) ''' function to generate support car list ''' def get_support_car_list(): attrs = ['FINGERPRINTS', 'FW_VERSIONS'] cars = dict({"cars": []}) for car_folder in [x[0] for x in os.walk('/data/openpilot/selfdrive/car')]: try: car_name = car_folder.split('/')[-1] if car_name != "mock": names = [] for attr in attrs: values = __import__('selfdrive.car.%s.values' % car_name, fromlist=[attr]) if hasattr(values, attr): attr_values = getattr(values, attr) else: continue if isinstance(attr_values, dict): for f, v in attr_values.items(): if f not in names: names.append(f) names.sort() brand_models = {"brand": car_name.upper(), "models": names } cars["cars"].append(brand_models) except (ImportError, IOError, ValueError): pass return json.dumps(cars) ''' function to init param value. should add this into manager.py ''' def init_params_vals(params): for conf in confs: if 'param' in conf['conf_type']: if conf['name'] == 'dp_car_list': params.put(conf['name'], get_support_car_list()) elif params.get(conf['name']) is None: params.put(conf['name'], to_param_val(conf['name'], conf['default'])) def gen_params_cc_keys(): for conf in confs: if 'param' in conf['conf_type']: print(" {\"%s\", PERSISTENT}," % conf['name']) if __name__ == "__main__": if (len(sys.argv) > 1) and sys.argv[1] == 'cc': gen_params_cc_keys() else: gen_log_struct() ================================================ FILE: common/dp_time.py ================================================ #!/usr/bin/env python3.7 # delay of reading last modified LAST_MODIFIED_THERMALD = 10. LAST_MODIFIED_SYSTEMD = 1. LAST_MODIFIED_LANE_PLANNER = 3. LAST_MODIFIED_UPLOADER = 10. ================================================ FILE: common/ffi_wrapper.py ================================================ import os import sys import fcntl import hashlib import platform from cffi import FFI def suffix(): if platform.system() == "Darwin": return ".dylib" else: return ".so" def ffi_wrap(name, c_code, c_header, tmpdir="/tmp/ccache", cflags="", libraries=None): if libraries is None: libraries = [] cache = name + "_" + hashlib.sha1(c_code.encode('utf-8')).hexdigest() try: os.mkdir(tmpdir) except OSError: pass fd = os.open(tmpdir, 0) fcntl.flock(fd, fcntl.LOCK_EX) try: sys.path.append(tmpdir) try: mod = __import__(cache) except Exception: print("cache miss {0}".format(cache)) compile_code(cache, c_code, c_header, tmpdir, cflags, libraries) mod = __import__(cache) finally: os.close(fd) return mod.ffi, mod.lib def compile_code(name, c_code, c_header, directory, cflags="", libraries=None): if libraries is None: libraries = [] ffibuilder = FFI() ffibuilder.set_source(name, c_code, source_extension='.cpp', libraries=libraries) ffibuilder.cdef(c_header) os.environ['OPT'] = "-fwrapv -O2 -DNDEBUG -std=c++1z" os.environ['CFLAGS'] = cflags ffibuilder.compile(verbose=True, debug=False, tmpdir=directory) def wrap_compiled(name, directory): sys.path.append(directory) mod = __import__(name) return mod.ffi, mod.lib ================================================ FILE: common/file_helpers.py ================================================ import os import shutil import tempfile from atomicwrites import AtomicWriter def mkdirs_exists_ok(path): if path.startswith('http://') or path.startswith('https://'): raise ValueError('URL path') try: os.makedirs(path) except OSError: if not os.path.isdir(path): raise def rm_not_exists_ok(path): try: os.remove(path) except OSError: if os.path.exists(path): raise def rm_tree_or_link(path): if os.path.islink(path): os.unlink(path) elif os.path.isdir(path): shutil.rmtree(path) def get_tmpdir_on_same_filesystem(path): normpath = os.path.normpath(path) parts = normpath.split("/") if len(parts) > 1 and parts[1] == "scratch": return "/scratch/tmp" elif len(parts) > 2 and parts[2] == "runner": return "/{}/runner/tmp".format(parts[1]) return "/tmp" class NamedTemporaryDir(): def __init__(self, temp_dir=None): self._path = tempfile.mkdtemp(dir=temp_dir) @property def name(self): return self._path def close(self): shutil.rmtree(self._path) def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): self.close() class CallbackReader: """Wraps a file, but overrides the read method to also call a callback function with the number of bytes read so far.""" def __init__(self, f, callback, *args): self.f = f self.callback = callback self.cb_args = args self.total_read = 0 def __getattr__(self, attr): return getattr(self.f, attr) def read(self, *args, **kwargs): chunk = self.f.read(*args, **kwargs) self.total_read += len(chunk) self.callback(*self.cb_args, self.total_read) return chunk def _get_fileobject_func(writer, temp_dir): def _get_fileobject(): return writer.get_fileobject(dir=temp_dir) return _get_fileobject def atomic_write_on_fs_tmp(path, **kwargs): """Creates an atomic writer using a temporary file in a temporary directory on the same filesystem as path. """ # TODO(mgraczyk): This use of AtomicWriter relies on implementation details to set the temp # directory. writer = AtomicWriter(path, **kwargs) return writer._open(_get_fileobject_func(writer, get_tmpdir_on_same_filesystem(path))) def atomic_write_in_dir(path, **kwargs): """Creates an atomic writer using a temporary file in the same directory as the destination file. """ writer = AtomicWriter(path, **kwargs) return writer._open(_get_fileobject_func(writer, os.path.dirname(path))) ================================================ FILE: common/filter_simple.py ================================================ class FirstOrderFilter: # first order filter def __init__(self, x0, rc, dt, initialized=True): self.x = x0 self.dt = dt self.update_alpha(rc) self.initialized = initialized def update_alpha(self, rc): self.alpha = self.dt / (rc + self.dt) def update(self, x): if self.initialized: self.x = (1. - self.alpha) * self.x + self.alpha * x else: self.initialized = True self.x = x return self.x ================================================ FILE: common/gpio.py ================================================ def gpio_init(pin, output): try: with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f: f.write(b"out" if output else b"in") except Exception as e: print(f"Failed to set gpio {pin} direction: {e}") def gpio_set(pin, high): try: with open(f"/sys/class/gpio/gpio{pin}/value", 'wb') as f: f.write(b"1" if high else b"0") except Exception as e: print(f"Failed to set gpio {pin} value: {e}") ================================================ FILE: common/i18n.py ================================================ import gettext from common.params import Params import os locale_dir = "/data/openpilot/selfdrive/assets/locales" supported_language = ["en-US", "zh-TW", "zh-CN", "ja-JP", "ko-KR"] def events(): if os.path.isfile("/EON"): locale = Params().get("dp_locale", encoding='utf8') locale = locale.strip() if locale is not None else "en-US" else: locale = "en-US" i18n = gettext.translation("events", localedir=locale_dir, fallback=True, languages=[locale]) i18n.install() return i18n.gettext ================================================ FILE: common/kalman/.gitignore ================================================ simple_kalman_impl.c ================================================ FILE: common/kalman/SConscript ================================================ Import('envCython') envCython.Program('simple_kalman_impl.so', 'simple_kalman_impl.pyx') ================================================ FILE: common/kalman/__init__.py ================================================ ================================================ FILE: common/kalman/simple_kalman.py ================================================ # pylint: skip-file from common.kalman.simple_kalman_impl import KF1D as KF1D assert KF1D ================================================ FILE: common/kalman/simple_kalman_impl.pxd ================================================ # cython: language_level = 3 cdef class KF1D: cdef public: double x0_0 double x1_0 double K0_0 double K1_0 double A0_0 double A0_1 double A1_0 double A1_1 double C0_0 double C0_1 double A_K_0 double A_K_1 double A_K_2 double A_K_3 ================================================ FILE: common/kalman/simple_kalman_impl.pyx ================================================ # distutils: language = c++ # cython: language_level=3 cdef class KF1D: def __init__(self, x0, A, C, K): self.x0_0 = x0[0][0] self.x1_0 = x0[1][0] self.A0_0 = A[0][0] self.A0_1 = A[0][1] self.A1_0 = A[1][0] self.A1_1 = A[1][1] self.C0_0 = C[0] self.C0_1 = C[1] self.K0_0 = K[0][0] self.K1_0 = K[1][0] self.A_K_0 = self.A0_0 - self.K0_0 * self.C0_0 self.A_K_1 = self.A0_1 - self.K0_0 * self.C0_1 self.A_K_2 = self.A1_0 - self.K1_0 * self.C0_0 self.A_K_3 = self.A1_1 - self.K1_0 * self.C0_1 def update(self, meas): cdef double x0_0 = self.A_K_0 * self.x0_0 + self.A_K_1 * self.x1_0 + self.K0_0 * meas cdef double x1_0 = self.A_K_2 * self.x0_0 + self.A_K_3 * self.x1_0 + self.K1_0 * meas self.x0_0 = x0_0 self.x1_0 = x1_0 return [self.x0_0, self.x1_0] @property def x(self): return [[self.x0_0], [self.x1_0]] @x.setter def x(self, x): self.x0_0 = x[0][0] self.x1_0 = x[1][0] ================================================ FILE: common/kalman/simple_kalman_old.py ================================================ import numpy as np class KF1D: # this EKF assumes constant covariance matrix, so calculations are much simpler # the Kalman gain also needs to be precomputed using the control module def __init__(self, x0, A, C, K): self.x = x0 self.A = A self.C = np.atleast_2d(C) self.K = K self.A_K = self.A - np.dot(self.K, self.C) # K matrix needs to be pre-computed as follow: # import control # (x, l, K) = control.dare(np.transpose(self.A), np.transpose(self.C), Q, R) # self.K = np.transpose(K) def update(self, meas): self.x = np.dot(self.A_K, self.x) + np.dot(self.K, meas) return self.x ================================================ FILE: common/kalman/tests/__init__.py ================================================ ================================================ FILE: common/kalman/tests/test_simple_kalman.py ================================================ import unittest import random import timeit import numpy as np from common.kalman.simple_kalman import KF1D from common.kalman.simple_kalman_old import KF1D as KF1D_old class TestSimpleKalman(unittest.TestCase): def setUp(self): dt = 0.01 x0_0 = 0.0 x1_0 = 0.0 A0_0 = 1.0 A0_1 = dt A1_0 = 0.0 A1_1 = 1.0 C0_0 = 1.0 C0_1 = 0.0 K0_0 = 0.12287673 K1_0 = 0.29666309 self.kf_old = KF1D_old(x0=np.array([[x0_0], [x1_0]]), A=np.array([[A0_0, A0_1], [A1_0, A1_1]]), C=np.array([C0_0, C0_1]), K=np.array([[K0_0], [K1_0]])) self.kf = KF1D(x0=[[x0_0], [x1_0]], A=[[A0_0, A0_1], [A1_0, A1_1]], C=[C0_0, C0_1], K=[[K0_0], [K1_0]]) def test_getter_setter(self): self.kf.x = [[1.0], [1.0]] self.assertEqual(self.kf.x, [[1.0], [1.0]]) def update_returns_state(self): x = self.kf.update(100) self.assertEqual(x, self.kf.x) def test_old_equal_new(self): for _ in range(1000): v_wheel = random.uniform(0, 200) x_old = self.kf_old.update(v_wheel) x = self.kf.update(v_wheel) # Compare the output x, verify that the error is less than 1e-4 np.testing.assert_almost_equal(x_old[0], x[0]) np.testing.assert_almost_equal(x_old[1], x[1]) def test_new_is_faster(self): setup = """ import numpy as np from common.kalman.simple_kalman import KF1D from common.kalman.simple_kalman_old import KF1D as KF1D_old dt = 0.01 x0_0 = 0.0 x1_0 = 0.0 A0_0 = 1.0 A0_1 = dt A1_0 = 0.0 A1_1 = 1.0 C0_0 = 1.0 C0_1 = 0.0 K0_0 = 0.12287673 K1_0 = 0.29666309 kf_old = KF1D_old(x0=np.array([[x0_0], [x1_0]]), A=np.array([[A0_0, A0_1], [A1_0, A1_1]]), C=np.array([C0_0, C0_1]), K=np.array([[K0_0], [K1_0]])) kf = KF1D(x0=[[x0_0], [x1_0]], A=[[A0_0, A0_1], [A1_0, A1_1]], C=[C0_0, C0_1], K=[[K0_0], [K1_0]]) """ kf_speed = timeit.timeit("kf.update(1234)", setup=setup, number=10000) kf_old_speed = timeit.timeit("kf_old.update(1234)", setup=setup, number=10000) self.assertTrue(kf_speed < kf_old_speed / 4) if __name__ == "__main__": unittest.main() ================================================ FILE: common/logging_extra.py ================================================ import io import os import sys import copy import json import uuid import socket import logging import traceback from threading import local from collections import OrderedDict from contextlib import contextmanager def json_handler(obj): # if isinstance(obj, (datetime.date, datetime.time)): # return obj.isoformat() return repr(obj) def json_robust_dumps(obj): return json.dumps(obj, default=json_handler) class NiceOrderedDict(OrderedDict): def __str__(self): return json_robust_dumps(self) class SwagFormatter(logging.Formatter): def __init__(self, swaglogger): logging.Formatter.__init__(self, None, '%a %b %d %H:%M:%S %Z %Y') self.swaglogger = swaglogger self.host = socket.gethostname() def format_dict(self, record): record_dict = NiceOrderedDict() if isinstance(record.msg, dict): record_dict['msg'] = record.msg else: try: record_dict['msg'] = record.getMessage() except (ValueError, TypeError): record_dict['msg'] = [record.msg]+record.args record_dict['ctx'] = self.swaglogger.get_ctx() if record.exc_info: record_dict['exc_info'] = self.formatException(record.exc_info) record_dict['level'] = record.levelname record_dict['levelnum'] = record.levelno record_dict['name'] = record.name record_dict['filename'] = record.filename record_dict['lineno'] = record.lineno record_dict['pathname'] = record.pathname record_dict['module'] = record.module record_dict['funcName'] = record.funcName record_dict['host'] = self.host record_dict['process'] = record.process record_dict['thread'] = record.thread record_dict['threadName'] = record.threadName record_dict['created'] = record.created return record_dict def format(self, record): if self.swaglogger is None: raise Exception("must set swaglogger before calling format()") return json_robust_dumps(self.format_dict(record)) class SwagLogFileFormatter(SwagFormatter): def fix_kv(self, k, v): # append type to names to preserve legacy naming in logs # avoids overlapping key namespaces with different types # e.g. log.info() creates 'msg' -> 'msg$s' # log.event() creates 'msg.health.logMonoTime' -> 'msg.health.logMonoTime$i' # because overlapping namespace 'msg' caused problems if isinstance(v, (str, bytes)): k += "$s" elif isinstance(v, float): k += "$f" elif isinstance(v, bool): k += "$b" elif isinstance(v, int): k += "$i" elif isinstance(v, dict): nv = {} for ik, iv in v.items(): ik, iv = self.fix_kv(ik, iv) nv[ik] = iv v = nv elif isinstance(v, list): k += "$a" return k, v def format(self, record): if isinstance(record, str): v = json.loads(record) else: v = self.format_dict(record) mk, mv = self.fix_kv('msg', v['msg']) del v['msg'] v[mk] = mv v['id'] = uuid.uuid4().hex return json_robust_dumps(v) class SwagErrorFilter(logging.Filter): def filter(self, record): return record.levelno < logging.ERROR def _tmpfunc(): return 0 def _srcfile(): return os.path.normcase(_tmpfunc.__code__.co_filename) class SwagLogger(logging.Logger): def __init__(self): logging.Logger.__init__(self, "swaglog") self.global_ctx = {} self.log_local = local() self.log_local.ctx = {} def local_ctx(self): try: return self.log_local.ctx except AttributeError: self.log_local.ctx = {} return self.log_local.ctx def get_ctx(self): return dict(self.local_ctx(), **self.global_ctx) @contextmanager def ctx(self, **kwargs): old_ctx = self.local_ctx() self.log_local.ctx = copy.copy(old_ctx) or {} self.log_local.ctx.update(kwargs) try: yield finally: self.log_local.ctx = old_ctx def bind(self, **kwargs): self.local_ctx().update(kwargs) def bind_global(self, **kwargs): self.global_ctx.update(kwargs) def event(self, event_name, *args, **kwargs): evt = NiceOrderedDict() evt['event'] = event_name if args: evt['args'] = args evt.update(kwargs) if 'error' in kwargs: self.error(evt) elif 'debug' in kwargs: self.debug(evt) else: self.info(evt) def findCaller(self, stack_info=False, stacklevel=1): """ Find the stack frame of the caller so that we can note the source file name, line number and function name. """ f = sys._getframe(3) #On some versions of IronPython, currentframe() returns None if #IronPython isn't run with -X:Frames. if f is not None: f = f.f_back orig_f = f while f and stacklevel > 1: f = f.f_back stacklevel -= 1 if not f: f = orig_f rv = "(unknown file)", 0, "(unknown function)", None while hasattr(f, "f_code"): co = f.f_code filename = os.path.normcase(co.co_filename) # TODO: is this pylint exception correct? if filename == _srcfile: # pylint: disable=comparison-with-callable f = f.f_back continue sinfo = None if stack_info: sio = io.StringIO() sio.write('Stack (most recent call last):\n') traceback.print_stack(f, file=sio) sinfo = sio.getvalue() if sinfo[-1] == '\n': sinfo = sinfo[:-1] sio.close() rv = (co.co_filename, f.f_lineno, co.co_name, sinfo) break return rv if __name__ == "__main__": log = SwagLogger() stdout_handler = logging.StreamHandler(sys.stdout) stdout_handler.setLevel(logging.INFO) stdout_handler.addFilter(SwagErrorFilter()) log.addHandler(stdout_handler) stderr_handler = logging.StreamHandler(sys.stderr) stderr_handler.setLevel(logging.ERROR) log.addHandler(stderr_handler) log.info("asdasd %s", "a") log.info({'wut': 1}) log.warning("warning") log.error("error") log.critical("critical") log.event("test", x="y") with log.ctx(): stdout_handler.setFormatter(SwagFormatter(log)) stderr_handler.setFormatter(SwagFormatter(log)) log.bind(user="some user") log.info("in req") print("") log.warning("warning") print("") log.error("error") print("") log.critical("critical") print("") log.event("do_req", a=1, b="c") ================================================ FILE: common/numpy_fast.py ================================================ def int_rnd(x): return int(round(x)) def clip(x, lo, hi): return max(lo, min(hi, x)) def interp(x, xp, fp): N = len(xp) def get_interp(xv): hi = 0 while hi < N and xv > xp[hi]: hi += 1 low = hi - 1 return fp[-1] if hi == N and xv > xp[low] else ( fp[0] if hi == 0 else (xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low]) return [get_interp(v) for v in x] if hasattr(x, '__iter__') else get_interp(x) def mean(x): return sum(x) / len(x) ================================================ FILE: common/params.py ================================================ from common.params_pyx import Params, ParamKeyType, UnknownKeyName, put_nonblocking # pylint: disable=no-name-in-module, import-error assert Params assert ParamKeyType assert UnknownKeyName assert put_nonblocking if __name__ == "__main__": import sys from common.params_pyx import keys # pylint: disable=no-name-in-module, import-error params = Params() if len(sys.argv) == 3: name = sys.argv[1] val = sys.argv[2] assert name.encode("utf-8") in keys.keys(), f"unknown param: {name}" print(f"SET: {name} = {val}") params.put(name, val) elif len(sys.argv) == 2: name = sys.argv[1] assert name.encode("utf-8") in keys.keys(), f"unknown param: {name}" print(f"GET: {name} = {params.get(name)}") else: for k in keys.keys(): print(f"GET: {k} = {params.get(k)}") ================================================ FILE: common/params_pxd.pxd ================================================ from libcpp.string cimport string from libcpp cimport bool cdef extern from "selfdrive/common/params.cc": pass cdef extern from "selfdrive/common/util.cc": pass cdef extern from "selfdrive/common/params.h": cpdef enum ParamKeyType: PERSISTENT CLEAR_ON_MANAGER_START CLEAR_ON_PANDA_DISCONNECT CLEAR_ON_IGNITION_ON CLEAR_ON_IGNITION_OFF ALL cdef cppclass Params: Params() nogil Params(string) nogil string get(string, bool) nogil bool getBool(string) nogil int remove(string) nogil int put(string, string) nogil int putBool(string, bool) nogil bool checkKey(string) nogil void clearAll(ParamKeyType) string get_params_path() ================================================ FILE: common/params_pyx.pyx ================================================ # distutils: language = c++ # cython: language_level = 3 from libcpp cimport bool from libcpp.string cimport string from common.params_pxd cimport Params as c_Params, ParamKeyType as c_ParamKeyType import os import threading from common.basedir import BASEDIR cdef class ParamKeyType: PERSISTENT = c_ParamKeyType.PERSISTENT CLEAR_ON_MANAGER_START = c_ParamKeyType.CLEAR_ON_MANAGER_START CLEAR_ON_PANDA_DISCONNECT = c_ParamKeyType.CLEAR_ON_PANDA_DISCONNECT CLEAR_ON_IGNITION_ON = c_ParamKeyType.CLEAR_ON_IGNITION_ON CLEAR_ON_IGNITION_OFF = c_ParamKeyType.CLEAR_ON_IGNITION_OFF ALL = c_ParamKeyType.ALL def ensure_bytes(v): if isinstance(v, str): return v.encode() else: return v class UnknownKeyName(Exception): pass cdef class Params: cdef c_Params* p def __cinit__(self, d=None): cdef string path if d is None: with nogil: self.p = new c_Params() else: path = d.encode() with nogil: self.p = new c_Params(path) def __dealloc__(self): del self.p def clear_all(self, tx_type=None): if tx_type is None: tx_type = ParamKeyType.ALL self.p.clearAll(tx_type) def check_key(self, key): key = ensure_bytes(key) if not self.p.checkKey(key): raise UnknownKeyName(key) return key def get(self, key, bool block=False, encoding=None): cdef string k = self.check_key(key) cdef string val with nogil: val = self.p.get(k, block) if val == b"": if block: # If we got no value while running in blocked mode # it means we got an interrupt while waiting raise KeyboardInterrupt else: return None if encoding is not None: return val.decode(encoding) else: return val def get_bool(self, key): cdef string k = self.check_key(key) cdef bool r with nogil: r = self.p.getBool(k) return r def put(self, key, dat): """ Warning: This function blocks until the param is written to disk! In very rare cases this can take over a second, and your code will hang. Use the put_nonblocking helper function in time sensitive code, but in general try to avoid writing params as much as possible. """ cdef string k = self.check_key(key) cdef string dat_bytes = ensure_bytes(dat) with nogil: self.p.put(k, dat_bytes) def put_bool(self, key, bool val): cdef string k = self.check_key(key) with nogil: self.p.putBool(k, val) def delete(self, key): cdef string k = self.check_key(key) with nogil: self.p.remove(k) def get_params_path(self): return self.p.get_params_path().decode("utf-8") def put_nonblocking(key, val, d=None): def f(key, val): params = Params(d) cdef string k = ensure_bytes(key) params.put(k, val) t = threading.Thread(target=f, args=(key, val)) t.start() return t ================================================ FILE: common/profiler.py ================================================ import time class Profiler(): def __init__(self, enabled=False): self.enabled = enabled self.cp = {} self.cp_ignored = [] self.iter = 0 self.start_time = time.time() self.last_time = self.start_time self.tot = 0. def reset(self, enabled=False): self.enabled = enabled self.cp = {} self.cp_ignored = [] self.iter = 0 self.start_time = time.time() self.last_time = self.start_time def checkpoint(self, name, ignore=False): # ignore flag needed when benchmarking threads with ratekeeper if not self.enabled: return tt = time.time() if name not in self.cp: self.cp[name] = 0. if ignore: self.cp_ignored.append(name) self.cp[name] += tt - self.last_time if not ignore: self.tot += tt - self.last_time self.last_time = tt def display(self): if not self.enabled: return self.iter += 1 print("******* Profiling %d *******" % self.iter) for n, ms in sorted(self.cp.items(), key=lambda x: -x[1]): if n in self.cp_ignored: print("%30s: %9.2f avg: %7.2f percent: %3.0f IGNORED" % (n, ms*1000.0, ms*1000.0/self.iter, ms/self.tot*100)) else: print("%30s: %9.2f avg: %7.2f percent: %3.0f" % (n, ms*1000.0, ms*1000.0/self.iter, ms/self.tot*100)) print("Iter clock: %2.6f TOTAL: %2.2f" % (self.tot/self.iter, self.tot)) ================================================ FILE: common/realtime.py ================================================ """Utilities for reading real time clocks and keeping soft real time constraints.""" import gc import os import time import multiprocessing from typing import Optional from common.clock import sec_since_boot # pylint: disable=no-name-in-module, import-error from selfdrive.hardware import PC, TICI # time step for each process DT_CTRL = 0.01 # controlsd DT_MDL = 0.05 # model DT_TRML = 0.5 # thermald and manager # driver monitoring if TICI: DT_DMON = 0.05 else: DT_DMON = 0.1 class Priority: # CORE 2 # - modeld = 55 # - camerad = 54 CTRL_LOW = 51 # plannerd & radard # CORE 3 # - boardd = 55 CTRL_HIGH = 53 def set_realtime_priority(level: int) -> None: if not PC: os.sched_setscheduler(0, os.SCHED_FIFO, os.sched_param(level)) # type: ignore[attr-defined] def set_core_affinity(core: int) -> None: if not PC: os.sched_setaffinity(0, [core,]) def config_realtime_process(core: int, priority: int) -> None: gc.disable() set_realtime_priority(priority) set_core_affinity(core) class Ratekeeper: def __init__(self, rate: int, print_delay_threshold: Optional[float] = 0.0) -> None: """Rate in Hz for ratekeeping. print_delay_threshold must be nonnegative.""" self._interval = 1. / rate self._next_frame_time = sec_since_boot() + self._interval self._print_delay_threshold = print_delay_threshold self._frame = 0 self._remaining = 0.0 self._process_name = multiprocessing.current_process().name @property def frame(self) -> int: return self._frame @property def remaining(self) -> float: return self._remaining # Maintain loop rate by calling this at the end of each loop def keep_time(self) -> bool: lagged = self.monitor_time() if self._remaining > 0: time.sleep(self._remaining) return lagged # this only monitor the cumulative lag, but does not enforce a rate def monitor_time(self) -> bool: lagged = False remaining = self._next_frame_time - sec_since_boot() self._next_frame_time += self._interval if self._print_delay_threshold is not None and remaining < -self._print_delay_threshold: print("%s lagging by %.2f ms" % (self._process_name, -remaining * 1000)) lagged = True self._frame += 1 self._remaining = remaining return lagged ================================================ FILE: common/spinner.py ================================================ import os import subprocess from common.basedir import BASEDIR class Spinner(): def __init__(self): try: self.spinner_proc = subprocess.Popen(["./spinner"], stdin=subprocess.PIPE, cwd=os.path.join(BASEDIR, "selfdrive", "ui"), close_fds=True) except OSError: self.spinner_proc = None def __enter__(self): return self def update(self, spinner_text: str): if self.spinner_proc is not None: self.spinner_proc.stdin.write(spinner_text.encode('utf8') + b"\n") try: self.spinner_proc.stdin.flush() except BrokenPipeError: pass def update_progress(self, cur: int, total: int): self.update(str(round(100 * cur / total))) def close(self): if self.spinner_proc is not None: try: self.spinner_proc.stdin.close() except BrokenPipeError: pass self.spinner_proc.terminate() self.spinner_proc = None def __del__(self): self.close() def __exit__(self, exc_type, exc_value, traceback): self.close() if __name__ == "__main__": import time with Spinner() as s: s.update("Spinner text") time.sleep(5.0) print("gone") time.sleep(5.0) ================================================ FILE: common/stat_live.py ================================================ import numpy as np class RunningStat(): # tracks realtime mean and standard deviation without storing any data def __init__(self, priors=None, max_trackable=-1): self.max_trackable = max_trackable if priors is not None: # initialize from history self.M = priors[0] self.S = priors[1] self.n = priors[2] self.M_last = self.M self.S_last = self.S else: self.reset() def reset(self): self.M = 0. self.S = 0. self.M_last = 0. self.S_last = 0. self.n = 0 def push_data(self, new_data): # short term memory hack if self.max_trackable < 0 or self.n < self.max_trackable: self.n += 1 if self.n == 0: self.M_last = new_data self.M = self.M_last self.S_last = 0. else: self.M = self.M_last + (new_data - self.M_last) / self.n self.S = self.S_last + (new_data - self.M_last) * (new_data - self.M) self.M_last = self.M self.S_last = self.S def mean(self): return self.M def variance(self): if self.n >= 2: return self.S / (self.n - 1.) else: return 0 def std(self): return np.sqrt(self.variance()) def params_to_save(self): return [self.M, self.S, self.n] class RunningStatFilter(): def __init__(self, raw_priors=None, filtered_priors=None, max_trackable=-1): self.raw_stat = RunningStat(raw_priors, -1) self.filtered_stat = RunningStat(filtered_priors, max_trackable) def reset(self): self.raw_stat.reset() self.filtered_stat.reset() def push_and_update(self, new_data): _std_last = self.raw_stat.std() self.raw_stat.push_data(new_data) _delta_std = self.raw_stat.std() - _std_last if _delta_std <= 0: self.filtered_stat.push_data(new_data) else: pass # self.filtered_stat.push_data(self.filtered_stat.mean()) # class SequentialBayesian(): ================================================ FILE: common/text_window.py ================================================ #!/usr/bin/env python3 import os import time import subprocess from common.basedir import BASEDIR class TextWindow: def __init__(self, text): try: self.text_proc = subprocess.Popen(["./text", text], stdin=subprocess.PIPE, cwd=os.path.join(BASEDIR, "selfdrive", "ui"), close_fds=True) except OSError: self.text_proc = None def get_status(self): if self.text_proc is not None: self.text_proc.poll() return self.text_proc.returncode return None def __enter__(self): return self def close(self): if self.text_proc is not None: self.text_proc.terminate() self.text_proc = None def wait_for_exit(self): if self.text_proc is not None: while True: if self.get_status() == 1: os.system('/data/openpilot/scripts/reset_update.sh') return time.sleep(0.1) def __del__(self): self.close() def __exit__(self, exc_type, exc_value, traceback): self.close() if __name__ == "__main__": text = """Traceback (most recent call last): File "./controlsd.py", line 608, in main() File "./controlsd.py", line 604, in main controlsd_thread(sm, pm, logcan) File "./controlsd.py", line 455, in controlsd_thread 1/0 ZeroDivisionError: division by zero""" print(text) with TextWindow(text) as s: for _ in range(100): if s.get_status() == 1: print("Got exit button") break time.sleep(0.1) print("gone") ================================================ FILE: common/timeout.py ================================================ import signal class TimeoutException(Exception): pass class Timeout: """ Timeout context manager. For example this code will raise a TimeoutException: with Timeout(seconds=5, error_msg="Sleep was too long"): time.sleep(10) """ def __init__(self, seconds, error_msg=None): if error_msg is None: error_msg = 'Timed out after {} seconds'.format(seconds) self.seconds = seconds self.error_msg = error_msg def handle_timeout(self, signume, frame): raise TimeoutException(self.error_msg) def __enter__(self): signal.signal(signal.SIGALRM, self.handle_timeout) signal.alarm(self.seconds) def __exit__(self, exc_type, exc_val, exc_tb): signal.alarm(0) ================================================ FILE: common/transformations/SConscript ================================================ Import('env', 'envCython') transformations = env.Library('transformations', ['orientation.cc', 'coordinates.cc']) Export('transformations') envCython.Program('transformations.so', 'transformations.pyx') ================================================ FILE: common/transformations/__init__.py ================================================ ================================================ FILE: common/transformations/camera.py ================================================ import numpy as np import common.transformations.orientation as orient from selfdrive.hardware import TICI ## -- hardcoded hardware params -- eon_f_focal_length = 910.0 eon_d_focal_length = 860.0 leon_d_focal_length = 650.0 tici_f_focal_length = 2648.0 tici_e_focal_length = tici_d_focal_length = 567.0 # probably wrong? magnification is not consistent across frame eon_f_frame_size = (1164, 874) eon_d_frame_size = (1152, 864) leon_d_frame_size = (816, 612) tici_f_frame_size = tici_e_frame_size = tici_d_frame_size = (1928, 1208) # aka 'K' aka camera_frame_from_view_frame eon_fcam_intrinsics = np.array([ [eon_f_focal_length, 0.0, float(eon_f_frame_size[0])/2], [0.0, eon_f_focal_length, float(eon_f_frame_size[1])/2], [0.0, 0.0, 1.0]]) eon_intrinsics = eon_fcam_intrinsics # xx leon_dcam_intrinsics = np.array([ [leon_d_focal_length, 0.0, float(leon_d_frame_size[0])/2], [0.0, leon_d_focal_length, float(leon_d_frame_size[1])/2], [0.0, 0.0, 1.0]]) eon_dcam_intrinsics = np.array([ [eon_d_focal_length, 0.0, float(eon_d_frame_size[0])/2], [0.0, eon_d_focal_length, float(eon_d_frame_size[1])/2], [0.0, 0.0, 1.0]]) tici_fcam_intrinsics = np.array([ [tici_f_focal_length, 0.0, float(tici_f_frame_size[0])/2], [0.0, tici_f_focal_length, float(tici_f_frame_size[1])/2], [0.0, 0.0, 1.0]]) tici_dcam_intrinsics = np.array([ [tici_d_focal_length, 0.0, float(tici_d_frame_size[0])/2], [0.0, tici_d_focal_length, float(tici_d_frame_size[1])/2], [0.0, 0.0, 1.0]]) tici_ecam_intrinsics = tici_dcam_intrinsics # aka 'K_inv' aka view_frame_from_camera_frame eon_fcam_intrinsics_inv = np.linalg.inv(eon_fcam_intrinsics) eon_intrinsics_inv = eon_fcam_intrinsics_inv # xx tici_fcam_intrinsics_inv = np.linalg.inv(tici_fcam_intrinsics) tici_ecam_intrinsics_inv = np.linalg.inv(tici_ecam_intrinsics) if not TICI: FULL_FRAME_SIZE = eon_f_frame_size FOCAL = eon_f_focal_length fcam_intrinsics = eon_fcam_intrinsics else: FULL_FRAME_SIZE = tici_f_frame_size FOCAL = tici_f_focal_length fcam_intrinsics = tici_fcam_intrinsics W, H = FULL_FRAME_SIZE[0], FULL_FRAME_SIZE[1] # device/mesh : x->forward, y-> right, z->down # view : x->right, y->down, z->forward device_frame_from_view_frame = np.array([ [ 0., 0., 1.], [ 1., 0., 0.], [ 0., 1., 0.] ]) view_frame_from_device_frame = device_frame_from_view_frame.T def get_calib_from_vp(vp): vp_norm = normalize(vp) yaw_calib = np.arctan(vp_norm[0]) pitch_calib = -np.arctan(vp_norm[1]*np.cos(yaw_calib)) roll_calib = 0 return roll_calib, pitch_calib, yaw_calib # aka 'extrinsic_matrix' # road : x->forward, y -> left, z->up def get_view_frame_from_road_frame(roll, pitch, yaw, height): device_from_road = orient.rot_from_euler([roll, pitch, yaw]).dot(np.diag([1, -1, -1])) view_from_road = view_frame_from_device_frame.dot(device_from_road) return np.hstack((view_from_road, [[0], [height], [0]])) # aka 'extrinsic_matrix' def get_view_frame_from_calib_frame(roll, pitch, yaw, height): device_from_calib= orient.rot_from_euler([roll, pitch, yaw]) view_from_calib = view_frame_from_device_frame.dot(device_from_calib) return np.hstack((view_from_calib, [[0], [height], [0]])) def vp_from_ke(m): """ Computes the vanishing point from the product of the intrinsic and extrinsic matrices C = KE. The vanishing point is defined as lim x->infinity C (x, 0, 0, 1).T """ return (m[0, 0]/m[2, 0], m[1, 0]/m[2, 0]) def vp_from_rpy(rpy, intrinsics=fcam_intrinsics): e = get_view_frame_from_road_frame(rpy[0], rpy[1], rpy[2], 1.22) ke = np.dot(intrinsics, e) return vp_from_ke(ke) def roll_from_ke(m): # note: different from calibration.h/RollAnglefromKE: i think that one's just wrong return np.arctan2(-(m[1, 0] - m[1, 1] * m[2, 0] / m[2, 1]), -(m[0, 0] - m[0, 1] * m[2, 0] / m[2, 1])) def normalize(img_pts, intrinsics=fcam_intrinsics): # normalizes image coordinates # accepts single pt or array of pts intrinsics_inv = np.linalg.inv(intrinsics) img_pts = np.array(img_pts) input_shape = img_pts.shape img_pts = np.atleast_2d(img_pts) img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0], 1)))) img_pts_normalized = img_pts.dot(intrinsics_inv.T) img_pts_normalized[(img_pts < 0).any(axis=1)] = np.nan return img_pts_normalized[:, :2].reshape(input_shape) def denormalize(img_pts, intrinsics=fcam_intrinsics, width=W, height=H): # denormalizes image coordinates # accepts single pt or array of pts img_pts = np.array(img_pts) input_shape = img_pts.shape img_pts = np.atleast_2d(img_pts) img_pts = np.hstack((img_pts, np.ones((img_pts.shape[0], 1)))) img_pts_denormalized = img_pts.dot(intrinsics.T) img_pts_denormalized[img_pts_denormalized[:, 0] > width] = np.nan img_pts_denormalized[img_pts_denormalized[:, 0] < 0] = np.nan img_pts_denormalized[img_pts_denormalized[:, 1] > height] = np.nan img_pts_denormalized[img_pts_denormalized[:, 1] < 0] = np.nan return img_pts_denormalized[:, :2].reshape(input_shape) def device_from_ecef(pos_ecef, orientation_ecef, pt_ecef): # device from ecef frame # device frame is x -> forward, y-> right, z -> down # accepts single pt or array of pts input_shape = pt_ecef.shape pt_ecef = np.atleast_2d(pt_ecef) ecef_from_device_rot = orient.rotations_from_quats(orientation_ecef) device_from_ecef_rot = ecef_from_device_rot.T pt_ecef_rel = pt_ecef - pos_ecef pt_device = np.einsum('jk,ik->ij', device_from_ecef_rot, pt_ecef_rel) return pt_device.reshape(input_shape) def img_from_device(pt_device): # img coordinates from pts in device frame # first transforms to view frame, then to img coords # accepts single pt or array of pts input_shape = pt_device.shape pt_device = np.atleast_2d(pt_device) pt_view = np.einsum('jk,ik->ij', view_frame_from_device_frame, pt_device) # This function should never return negative depths pt_view[pt_view[:, 2] < 0] = np.nan pt_img = pt_view/pt_view[:, 2:3] return pt_img.reshape(input_shape)[:, :2] def get_camera_frame_from_calib_frame(camera_frame_from_road_frame, intrinsics=fcam_intrinsics): camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)] calib_frame_from_ground = np.dot(intrinsics, get_view_frame_from_road_frame(0, 0, 0, 1.22))[:, (0, 1, 3)] ground_from_calib_frame = np.linalg.inv(calib_frame_from_ground) camera_frame_from_calib_frame = np.dot(camera_frame_from_ground, ground_from_calib_frame) return camera_frame_from_calib_frame ================================================ FILE: common/transformations/coordinates.cc ================================================ #define _USE_MATH_DEFINES #include #include #include #include "coordinates.hpp" double a = 6378137; // lgtm [cpp/short-global-name] double b = 6356752.3142; // lgtm [cpp/short-global-name] double esq = 6.69437999014 * 0.001; // lgtm [cpp/short-global-name] double e1sq = 6.73949674228 * 0.001; static Geodetic to_degrees(Geodetic geodetic){ geodetic.lat = RAD2DEG(geodetic.lat); geodetic.lon = RAD2DEG(geodetic.lon); return geodetic; } static Geodetic to_radians(Geodetic geodetic){ geodetic.lat = DEG2RAD(geodetic.lat); geodetic.lon = DEG2RAD(geodetic.lon); return geodetic; } ECEF geodetic2ecef(Geodetic g){ g = to_radians(g); double xi = sqrt(1.0 - esq * pow(sin(g.lat), 2)); double x = (a / xi + g.alt) * cos(g.lat) * cos(g.lon); double y = (a / xi + g.alt) * cos(g.lat) * sin(g.lon); double z = (a / xi * (1.0 - esq) + g.alt) * sin(g.lat); return {x, y, z}; } Geodetic ecef2geodetic(ECEF e){ // Convert from ECEF to geodetic using Ferrari's methods // https://en.wikipedia.org/wiki/Geographic_coordinate_conversion#Ferrari.27s_solution double x = e.x; double y = e.y; double z = e.z; double r = sqrt(x * x + y * y); double Esq = a * a - b * b; double F = 54 * b * b * z * z; double G = r * r + (1 - esq) * z * z - esq * Esq; double C = (esq * esq * F * r * r) / (pow(G, 3)); double S = cbrt(1 + C + sqrt(C * C + 2 * C)); double P = F / (3 * pow((S + 1 / S + 1), 2) * G * G); double Q = sqrt(1 + 2 * esq * esq * P); double r_0 = -(P * esq * r) / (1 + Q) + sqrt(0.5 * a * a*(1 + 1.0 / Q) - P * (1 - esq) * z * z / (Q * (1 + Q)) - 0.5 * P * r * r); double U = sqrt(pow((r - esq * r_0), 2) + z * z); double V = sqrt(pow((r - esq * r_0), 2) + (1 - esq) * z * z); double Z_0 = b * b * z / (a * V); double h = U * (1 - b * b / (a * V)); double lat = atan((z + e1sq * Z_0) / r); double lon = atan2(y, x); return to_degrees({lat, lon, h}); } LocalCoord::LocalCoord(Geodetic g, ECEF e){ init_ecef << e.x, e.y, e.z; g = to_radians(g); ned2ecef_matrix << -sin(g.lat)*cos(g.lon), -sin(g.lon), -cos(g.lat)*cos(g.lon), -sin(g.lat)*sin(g.lon), cos(g.lon), -cos(g.lat)*sin(g.lon), cos(g.lat), 0, -sin(g.lat); ecef2ned_matrix = ned2ecef_matrix.transpose(); } NED LocalCoord::ecef2ned(ECEF e) { Eigen::Vector3d ecef; ecef << e.x, e.y, e.z; Eigen::Vector3d ned = (ecef2ned_matrix * (ecef - init_ecef)); return {ned[0], ned[1], ned[2]}; } ECEF LocalCoord::ned2ecef(NED n) { Eigen::Vector3d ned; ned << n.n, n.e, n.d; Eigen::Vector3d ecef = (ned2ecef_matrix * ned) + init_ecef; return {ecef[0], ecef[1], ecef[2]}; } NED LocalCoord::geodetic2ned(Geodetic g) { ECEF e = ::geodetic2ecef(g); return ecef2ned(e); } Geodetic LocalCoord::ned2geodetic(NED n){ ECEF e = ned2ecef(n); return ::ecef2geodetic(e); } ================================================ FILE: common/transformations/coordinates.hpp ================================================ #pragma once #define DEG2RAD(x) ((x) * M_PI / 180.0) #define RAD2DEG(x) ((x) * 180.0 / M_PI) struct ECEF { double x, y, z; Eigen::Vector3d to_vector(){ return Eigen::Vector3d(x, y, z); } }; struct NED { double n, e, d; Eigen::Vector3d to_vector(){ return Eigen::Vector3d(n, e, d); } }; struct Geodetic { double lat, lon, alt; bool radians=false; }; ECEF geodetic2ecef(Geodetic g); Geodetic ecef2geodetic(ECEF e); class LocalCoord { public: Eigen::Matrix3d ned2ecef_matrix; Eigen::Matrix3d ecef2ned_matrix; Eigen::Vector3d init_ecef; LocalCoord(Geodetic g, ECEF e); LocalCoord(Geodetic g) : LocalCoord(g, ::geodetic2ecef(g)) {} LocalCoord(ECEF e) : LocalCoord(::ecef2geodetic(e), e) {} NED ecef2ned(ECEF e); ECEF ned2ecef(NED n); NED geodetic2ned(Geodetic g); Geodetic ned2geodetic(NED n); }; ================================================ FILE: common/transformations/coordinates.py ================================================ # pylint: skip-file from common.transformations.orientation import numpy_wrap from common.transformations.transformations import (ecef2geodetic_single, geodetic2ecef_single) from common.transformations.transformations import LocalCoord as LocalCoord_single class LocalCoord(LocalCoord_single): ecef2ned = numpy_wrap(LocalCoord_single.ecef2ned_single, (3,), (3,)) ned2ecef = numpy_wrap(LocalCoord_single.ned2ecef_single, (3,), (3,)) geodetic2ned = numpy_wrap(LocalCoord_single.geodetic2ned_single, (3,), (3,)) ned2geodetic = numpy_wrap(LocalCoord_single.ned2geodetic_single, (3,), (3,)) geodetic2ecef = numpy_wrap(geodetic2ecef_single, (3,), (3,)) ecef2geodetic = numpy_wrap(ecef2geodetic_single, (3,), (3,)) geodetic_from_ecef = ecef2geodetic ecef_from_geodetic = geodetic2ecef ================================================ FILE: common/transformations/model.py ================================================ import numpy as np from common.transformations.camera import (FULL_FRAME_SIZE, FOCAL, get_view_frame_from_road_frame, get_view_frame_from_calib_frame, vp_from_ke) # segnet SEGNET_SIZE = (512, 384) def get_segnet_frame_from_camera_frame(segnet_size=SEGNET_SIZE, full_frame_size=FULL_FRAME_SIZE): return np.array([[float(segnet_size[0]) / full_frame_size[0], 0.0], [0.0, float(segnet_size[1]) / full_frame_size[1]]]) segnet_frame_from_camera_frame = get_segnet_frame_from_camera_frame() # xx # model MODEL_INPUT_SIZE = (320, 160) MODEL_YUV_SIZE = (MODEL_INPUT_SIZE[0], MODEL_INPUT_SIZE[1] * 3 // 2) MODEL_CX = MODEL_INPUT_SIZE[0] / 2. MODEL_CY = 21. model_fl = 728.0 model_height = 1.22 # canonical model transform model_intrinsics = np.array([ [model_fl, 0.0, MODEL_CX], [0.0, model_fl, MODEL_CY], [0.0, 0.0, 1.0]]) # MED model MEDMODEL_INPUT_SIZE = (512, 256) MEDMODEL_YUV_SIZE = (MEDMODEL_INPUT_SIZE[0], MEDMODEL_INPUT_SIZE[1] * 3 // 2) MEDMODEL_CY = 47.6 medmodel_fl = 910.0 medmodel_intrinsics = np.array([ [medmodel_fl, 0.0, 0.5 * MEDMODEL_INPUT_SIZE[0]], [0.0, medmodel_fl, MEDMODEL_CY], [0.0, 0.0, 1.0]]) # CAL model CALMODEL_INPUT_SIZE = (512, 256) CALMODEL_YUV_SIZE = (CALMODEL_INPUT_SIZE[0], CALMODEL_INPUT_SIZE[1] * 3 // 2) CALMODEL_CY = 47.6 calmodel_fl = 606.7 calmodel_intrinsics = np.array([ [calmodel_fl, 0.0, 0.5 * CALMODEL_INPUT_SIZE[0]], [0.0, calmodel_fl, CALMODEL_CY], [0.0, 0.0, 1.0]]) # BIG model BIGMODEL_INPUT_SIZE = (1024, 512) BIGMODEL_YUV_SIZE = (BIGMODEL_INPUT_SIZE[0], BIGMODEL_INPUT_SIZE[1] * 3 // 2) bigmodel_fl = 910.0 bigmodel_intrinsics = np.array([ [bigmodel_fl, 0.0, 0.5 * BIGMODEL_INPUT_SIZE[0]], [0.0, bigmodel_fl, 256 + MEDMODEL_CY], [0.0, 0.0, 1.0]]) # SBIG model (big model with the size of small model) SBIGMODEL_INPUT_SIZE = (512, 256) SBIGMODEL_YUV_SIZE = (SBIGMODEL_INPUT_SIZE[0], SBIGMODEL_INPUT_SIZE[1] * 3 // 2) sbigmodel_fl = 455.0 sbigmodel_intrinsics = np.array([ [sbigmodel_fl, 0.0, 0.5 * SBIGMODEL_INPUT_SIZE[0]], [0.0, sbigmodel_fl, 0.5 * (256 + MEDMODEL_CY)], [0.0, 0.0, 1.0]]) model_frame_from_road_frame = np.dot(model_intrinsics, get_view_frame_from_road_frame(0, 0, 0, model_height)) bigmodel_frame_from_road_frame = np.dot(bigmodel_intrinsics, get_view_frame_from_road_frame(0, 0, 0, model_height)) medmodel_frame_from_road_frame = np.dot(medmodel_intrinsics, get_view_frame_from_road_frame(0, 0, 0, model_height)) medmodel_frame_from_calib_frame = np.dot(medmodel_intrinsics, get_view_frame_from_calib_frame(0, 0, 0, 0)) model_frame_from_bigmodel_frame = np.dot(model_intrinsics, np.linalg.inv(bigmodel_intrinsics)) medmodel_frame_from_bigmodel_frame = np.dot(medmodel_intrinsics, np.linalg.inv(bigmodel_intrinsics)) # 'camera from model camera' def get_model_height_transform(camera_frame_from_road_frame, height): camera_frame_from_road_ground = np.dot(camera_frame_from_road_frame, np.array([ [1, 0, 0], [0, 1, 0], [0, 0, 0], [0, 0, 1], ])) camera_frame_from_road_high = np.dot(camera_frame_from_road_frame, np.array([ [1, 0, 0], [0, 1, 0], [0, 0, height - model_height], [0, 0, 1], ])) road_high_from_camera_frame = np.linalg.inv(camera_frame_from_road_high) high_camera_from_low_camera = np.dot(camera_frame_from_road_ground, road_high_from_camera_frame) return high_camera_from_low_camera # camera_frame_from_model_frame aka 'warp matrix' # was: calibration.h/CalibrationTransform def get_camera_frame_from_model_frame(camera_frame_from_road_frame, height=model_height, camera_fl=FOCAL): vp = vp_from_ke(camera_frame_from_road_frame) model_zoom = camera_fl / model_fl model_camera_from_model_frame = np.array([ [model_zoom, 0.0, vp[0] - MODEL_CX * model_zoom], [0.0, model_zoom, vp[1] - MODEL_CY * model_zoom], [0.0, 0.0, 1.0], ]) # This function is super slow, so skip it if height is very close to canonical # TODO: speed it up! if abs(height - model_height) > 0.001: camera_from_model_camera = get_model_height_transform(camera_frame_from_road_frame, height) else: camera_from_model_camera = np.eye(3) return np.dot(camera_from_model_camera, model_camera_from_model_frame) def get_camera_frame_from_medmodel_frame(camera_frame_from_road_frame): camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)] medmodel_frame_from_ground = medmodel_frame_from_road_frame[:, (0, 1, 3)] ground_from_medmodel_frame = np.linalg.inv(medmodel_frame_from_ground) camera_frame_from_medmodel_frame = np.dot(camera_frame_from_ground, ground_from_medmodel_frame) return camera_frame_from_medmodel_frame def get_camera_frame_from_bigmodel_frame(camera_frame_from_road_frame): camera_frame_from_ground = camera_frame_from_road_frame[:, (0, 1, 3)] bigmodel_frame_from_ground = bigmodel_frame_from_road_frame[:, (0, 1, 3)] ground_from_bigmodel_frame = np.linalg.inv(bigmodel_frame_from_ground) camera_frame_from_bigmodel_frame = np.dot(camera_frame_from_ground, ground_from_bigmodel_frame) return camera_frame_from_bigmodel_frame def get_model_frame(snu_full, camera_frame_from_model_frame, size): idxs = camera_frame_from_model_frame.dot(np.column_stack([np.tile(np.arange(size[0]), size[1]), np.tile(np.arange(size[1]), (size[0], 1)).T.flatten(), np.ones(size[0] * size[1])]).T).T.astype(int) calib_flat = snu_full[idxs[:, 1], idxs[:, 0]] if len(snu_full.shape) == 3: calib = calib_flat.reshape((size[1], size[0], 3)) elif len(snu_full.shape) == 2: calib = calib_flat.reshape((size[1], size[0])) else: raise ValueError("shape of input img is weird") return calib ================================================ FILE: common/transformations/orientation.cc ================================================ #define _USE_MATH_DEFINES #include #include #include #include "orientation.hpp" #include "coordinates.hpp" Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat){ if (quat.w() > 0){ return quat; } else { return Eigen::Quaterniond(-quat.w(), -quat.x(), -quat.y(), -quat.z()); } } Eigen::Quaterniond euler2quat(Eigen::Vector3d euler){ Eigen::Quaterniond q; q = Eigen::AngleAxisd(euler(2), Eigen::Vector3d::UnitZ()) * Eigen::AngleAxisd(euler(1), Eigen::Vector3d::UnitY()) * Eigen::AngleAxisd(euler(0), Eigen::Vector3d::UnitX()); return ensure_unique(q); } Eigen::Vector3d quat2euler(Eigen::Quaterniond quat){ // TODO: switch to eigen implementation if the range of the Euler angles doesn't matter anymore // Eigen::Vector3d euler = quat.toRotationMatrix().eulerAngles(2, 1, 0); // return {euler(2), euler(1), euler(0)}; double gamma = atan2(2 * (quat.w() * quat.x() + quat.y() * quat.z()), 1 - 2 * (quat.x()*quat.x() + quat.y()*quat.y())); double asin_arg_clipped = std::clamp(2 * (quat.w() * quat.y() - quat.z() * quat.x()), -1.0, 1.0); double theta = asin(asin_arg_clipped); double psi = atan2(2 * (quat.w() * quat.z() + quat.x() * quat.y()), 1 - 2 * (quat.y()*quat.y() + quat.z()*quat.z())); return {gamma, theta, psi}; } Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat){ return quat.toRotationMatrix(); } Eigen::Quaterniond rot2quat(const Eigen::Matrix3d &rot){ return ensure_unique(Eigen::Quaterniond(rot)); } Eigen::Matrix3d euler2rot(Eigen::Vector3d euler){ return quat2rot(euler2quat(euler)); } Eigen::Vector3d rot2euler(const Eigen::Matrix3d &rot){ return quat2euler(rot2quat(rot)); } Eigen::Matrix3d rot_matrix(double roll, double pitch, double yaw){ return euler2rot({roll, pitch, yaw}); } Eigen::Matrix3d rot(Eigen::Vector3d axis, double angle){ Eigen::Quaterniond q; q = Eigen::AngleAxisd(angle, axis); return q.toRotationMatrix(); } Eigen::Vector3d ecef_euler_from_ned(ECEF ecef_init, Eigen::Vector3d ned_pose) { /* Using Rotations to Build Aerospace Coordinate Systems Don Koks https://apps.dtic.mil/dtic/tr/fulltext/u2/a484864.pdf */ LocalCoord converter = LocalCoord(ecef_init); Eigen::Vector3d zero = ecef_init.to_vector(); Eigen::Vector3d x0 = converter.ned2ecef({1, 0, 0}).to_vector() - zero; Eigen::Vector3d y0 = converter.ned2ecef({0, 1, 0}).to_vector() - zero; Eigen::Vector3d z0 = converter.ned2ecef({0, 0, 1}).to_vector() - zero; Eigen::Vector3d x1 = rot(z0, ned_pose(2)) * x0; Eigen::Vector3d y1 = rot(z0, ned_pose(2)) * y0; Eigen::Vector3d z1 = rot(z0, ned_pose(2)) * z0; Eigen::Vector3d x2 = rot(y1, ned_pose(1)) * x1; Eigen::Vector3d y2 = rot(y1, ned_pose(1)) * y1; Eigen::Vector3d z2 = rot(y1, ned_pose(1)) * z1; Eigen::Vector3d x3 = rot(x2, ned_pose(0)) * x2; Eigen::Vector3d y3 = rot(x2, ned_pose(0)) * y2; x0 = Eigen::Vector3d(1, 0, 0); y0 = Eigen::Vector3d(0, 1, 0); z0 = Eigen::Vector3d(0, 0, 1); double psi = atan2(x3.dot(y0), x3.dot(x0)); double theta = atan2(-x3.dot(z0), sqrt(pow(x3.dot(x0), 2) + pow(x3.dot(y0), 2))); y2 = rot(z0, psi) * y0; z2 = rot(y2, theta) * z0; double phi = atan2(y3.dot(z2), y3.dot(y2)); return {phi, theta, psi}; } Eigen::Vector3d ned_euler_from_ecef(ECEF ecef_init, Eigen::Vector3d ecef_pose){ /* Using Rotations to Build Aerospace Coordinate Systems Don Koks https://apps.dtic.mil/dtic/tr/fulltext/u2/a484864.pdf */ LocalCoord converter = LocalCoord(ecef_init); Eigen::Vector3d x0 = Eigen::Vector3d(1, 0, 0); Eigen::Vector3d y0 = Eigen::Vector3d(0, 1, 0); Eigen::Vector3d z0 = Eigen::Vector3d(0, 0, 1); Eigen::Vector3d x1 = rot(z0, ecef_pose(2)) * x0; Eigen::Vector3d y1 = rot(z0, ecef_pose(2)) * y0; Eigen::Vector3d z1 = rot(z0, ecef_pose(2)) * z0; Eigen::Vector3d x2 = rot(y1, ecef_pose(1)) * x1; Eigen::Vector3d y2 = rot(y1, ecef_pose(1)) * y1; Eigen::Vector3d z2 = rot(y1, ecef_pose(1)) * z1; Eigen::Vector3d x3 = rot(x2, ecef_pose(0)) * x2; Eigen::Vector3d y3 = rot(x2, ecef_pose(0)) * y2; Eigen::Vector3d zero = ecef_init.to_vector(); x0 = converter.ned2ecef({1, 0, 0}).to_vector() - zero; y0 = converter.ned2ecef({0, 1, 0}).to_vector() - zero; z0 = converter.ned2ecef({0, 0, 1}).to_vector() - zero; double psi = atan2(x3.dot(y0), x3.dot(x0)); double theta = atan2(-x3.dot(z0), sqrt(pow(x3.dot(x0), 2) + pow(x3.dot(y0), 2))); y2 = rot(z0, psi) * y0; z2 = rot(y2, theta) * z0; double phi = atan2(y3.dot(z2), y3.dot(y2)); return {phi, theta, psi}; } ================================================ FILE: common/transformations/orientation.hpp ================================================ #pragma once #include #include "coordinates.hpp" Eigen::Quaterniond ensure_unique(Eigen::Quaterniond quat); Eigen::Quaterniond euler2quat(Eigen::Vector3d euler); Eigen::Vector3d quat2euler(Eigen::Quaterniond quat); Eigen::Matrix3d quat2rot(Eigen::Quaterniond quat); Eigen::Quaterniond rot2quat(const Eigen::Matrix3d &rot); Eigen::Matrix3d euler2rot(Eigen::Vector3d euler); Eigen::Vector3d rot2euler(const Eigen::Matrix3d &rot); Eigen::Matrix3d rot_matrix(double roll, double pitch, double yaw); Eigen::Matrix3d rot(Eigen::Vector3d axis, double angle); Eigen::Vector3d ecef_euler_from_ned(ECEF ecef_init, Eigen::Vector3d ned_pose); Eigen::Vector3d ned_euler_from_ecef(ECEF ecef_init, Eigen::Vector3d ecef_pose); ================================================ FILE: common/transformations/orientation.py ================================================ # pylint: skip-file import numpy as np from common.transformations.transformations import (ecef_euler_from_ned_single, euler2quat_single, euler2rot_single, ned_euler_from_ecef_single, quat2euler_single, quat2rot_single, rot2euler_single, rot2quat_single) def numpy_wrap(function, input_shape, output_shape): """Wrap a function to take either an input or list of inputs and return the correct shape""" def f(*inps): *args, inp = inps inp = np.array(inp) shape = inp.shape if len(shape) == len(input_shape): out_shape = output_shape else: out_shape = (shape[0],) + output_shape # Add empty dimension if inputs is not a list if len(shape) == len(input_shape): inp.shape = (1, ) + inp.shape result = np.asarray([function(*args, i) for i in inp]) result.shape = out_shape return result return f euler2quat = numpy_wrap(euler2quat_single, (3,), (4,)) quat2euler = numpy_wrap(quat2euler_single, (4,), (3,)) quat2rot = numpy_wrap(quat2rot_single, (4,), (3, 3)) rot2quat = numpy_wrap(rot2quat_single, (3, 3), (4,)) euler2rot = numpy_wrap(euler2rot_single, (3,), (3, 3)) rot2euler = numpy_wrap(rot2euler_single, (3, 3), (3,)) ecef_euler_from_ned = numpy_wrap(ecef_euler_from_ned_single, (3,), (3,)) ned_euler_from_ecef = numpy_wrap(ned_euler_from_ecef_single, (3,), (3,)) quats_from_rotations = rot2quat quat_from_rot = rot2quat rotations_from_quats = quat2rot rot_from_quat = quat2rot euler_from_rot = rot2euler euler_from_quat = quat2euler rot_from_euler = euler2rot quat_from_euler = euler2quat ================================================ FILE: common/transformations/transformations.pxd ================================================ #cython: language_level=3 from libcpp cimport bool cdef extern from "orientation.cc": pass cdef extern from "orientation.hpp": cdef cppclass Quaternion "Eigen::Quaterniond": Quaternion() Quaternion(double, double, double, double) double w() double x() double y() double z() cdef cppclass Vector3 "Eigen::Vector3d": Vector3() Vector3(double, double, double) double operator()(int) cdef cppclass Matrix3 "Eigen::Matrix3d": Matrix3() Matrix3(double*) double operator()(int, int) Quaternion euler2quat(Vector3) Vector3 quat2euler(Quaternion) Matrix3 quat2rot(Quaternion) Quaternion rot2quat(Matrix3) Vector3 rot2euler(Matrix3) Matrix3 euler2rot(Vector3) Matrix3 rot_matrix(double, double, double) Vector3 ecef_euler_from_ned(ECEF, Vector3) Vector3 ned_euler_from_ecef(ECEF, Vector3) cdef extern from "coordinates.cc": cdef struct ECEF: double x double y double z cdef struct NED: double n double e double d cdef struct Geodetic: double lat double lon double alt bool radians ECEF geodetic2ecef(Geodetic) Geodetic ecef2geodetic(ECEF) cdef cppclass LocalCoord_c "LocalCoord": Matrix3 ned2ecef_matrix Matrix3 ecef2ned_matrix LocalCoord_c(Geodetic, ECEF) LocalCoord_c(Geodetic) LocalCoord_c(ECEF) NED ecef2ned(ECEF) ECEF ned2ecef(NED) NED geodetic2ned(Geodetic) Geodetic ned2geodetic(NED) cdef extern from "coordinates.hpp": pass ================================================ FILE: common/transformations/transformations.pyx ================================================ # distutils: language = c++ # cython: language_level = 3 from common.transformations.transformations cimport Matrix3, Vector3, Quaternion from common.transformations.transformations cimport ECEF, NED, Geodetic from common.transformations.transformations cimport euler2quat as euler2quat_c from common.transformations.transformations cimport quat2euler as quat2euler_c from common.transformations.transformations cimport quat2rot as quat2rot_c from common.transformations.transformations cimport rot2quat as rot2quat_c from common.transformations.transformations cimport euler2rot as euler2rot_c from common.transformations.transformations cimport rot2euler as rot2euler_c from common.transformations.transformations cimport rot_matrix as rot_matrix_c from common.transformations.transformations cimport ecef_euler_from_ned as ecef_euler_from_ned_c from common.transformations.transformations cimport ned_euler_from_ecef as ned_euler_from_ecef_c from common.transformations.transformations cimport geodetic2ecef as geodetic2ecef_c from common.transformations.transformations cimport ecef2geodetic as ecef2geodetic_c from common.transformations.transformations cimport LocalCoord_c import cython import numpy as np cimport numpy as np cdef np.ndarray[double, ndim=2] matrix2numpy(Matrix3 m): return np.array([ [m(0, 0), m(0, 1), m(0, 2)], [m(1, 0), m(1, 1), m(1, 2)], [m(2, 0), m(2, 1), m(2, 2)], ]) cdef Matrix3 numpy2matrix(np.ndarray[double, ndim=2, mode="fortran"] m): assert m.shape[0] == 3 assert m.shape[1] == 3 return Matrix3(m.data) cdef ECEF list2ecef(ecef): cdef ECEF e; e.x = ecef[0] e.y = ecef[1] e.z = ecef[2] return e cdef NED list2ned(ned): cdef NED n; n.n = ned[0] n.e = ned[1] n.d = ned[2] return n cdef Geodetic list2geodetic(geodetic): cdef Geodetic g g.lat = geodetic[0] g.lon = geodetic[1] g.alt = geodetic[2] return g def euler2quat_single(euler): cdef Vector3 e = Vector3(euler[0], euler[1], euler[2]) cdef Quaternion q = euler2quat_c(e) return [q.w(), q.x(), q.y(), q.z()] def quat2euler_single(quat): cdef Quaternion q = Quaternion(quat[0], quat[1], quat[2], quat[3]) cdef Vector3 e = quat2euler_c(q); return [e(0), e(1), e(2)] def quat2rot_single(quat): cdef Quaternion q = Quaternion(quat[0], quat[1], quat[2], quat[3]) cdef Matrix3 r = quat2rot_c(q) return matrix2numpy(r) def rot2quat_single(rot): cdef Matrix3 r = numpy2matrix(np.asfortranarray(rot, dtype=np.double)) cdef Quaternion q = rot2quat_c(r) return [q.w(), q.x(), q.y(), q.z()] def euler2rot_single(euler): cdef Vector3 e = Vector3(euler[0], euler[1], euler[2]) cdef Matrix3 r = euler2rot_c(e) return matrix2numpy(r) def rot2euler_single(rot): cdef Matrix3 r = numpy2matrix(np.asfortranarray(rot, dtype=np.double)) cdef Vector3 e = rot2euler_c(r) return [e(0), e(1), e(2)] def rot_matrix(roll, pitch, yaw): return matrix2numpy(rot_matrix_c(roll, pitch, yaw)) def ecef_euler_from_ned_single(ecef_init, ned_pose): cdef ECEF init = list2ecef(ecef_init) cdef Vector3 pose = Vector3(ned_pose[0], ned_pose[1], ned_pose[2]) cdef Vector3 e = ecef_euler_from_ned_c(init, pose) return [e(0), e(1), e(2)] def ned_euler_from_ecef_single(ecef_init, ecef_pose): cdef ECEF init = list2ecef(ecef_init) cdef Vector3 pose = Vector3(ecef_pose[0], ecef_pose[1], ecef_pose[2]) cdef Vector3 e = ned_euler_from_ecef_c(init, pose) return [e(0), e(1), e(2)] def geodetic2ecef_single(geodetic): cdef Geodetic g = list2geodetic(geodetic) cdef ECEF e = geodetic2ecef_c(g) return [e.x, e.y, e.z] def ecef2geodetic_single(ecef): cdef ECEF e = list2ecef(ecef) cdef Geodetic g = ecef2geodetic_c(e) return [g.lat, g.lon, g.alt] cdef class LocalCoord: cdef LocalCoord_c * lc def __init__(self, geodetic=None, ecef=None): assert (geodetic is not None) or (ecef is not None) if geodetic is not None: self.lc = new LocalCoord_c(list2geodetic(geodetic)) elif ecef is not None: self.lc = new LocalCoord_c(list2ecef(ecef)) @property def ned2ecef_matrix(self): return matrix2numpy(self.lc.ned2ecef_matrix) @property def ecef2ned_matrix(self): return matrix2numpy(self.lc.ecef2ned_matrix) @property def ned_from_ecef_matrix(self): return self.ecef2ned_matrix @property def ecef_from_ned_matrix(self): return self.ned2ecef_matrix @classmethod def from_geodetic(cls, geodetic): return cls(geodetic=geodetic) @classmethod def from_ecef(cls, ecef): return cls(ecef=ecef) def ecef2ned_single(self, ecef): assert self.lc cdef ECEF e = list2ecef(ecef) cdef NED n = self.lc.ecef2ned(e) return [n.n, n.e, n.d] def ned2ecef_single(self, ned): assert self.lc cdef NED n = list2ned(ned) cdef ECEF e = self.lc.ned2ecef(n) return [e.x, e.y, e.z] def geodetic2ned_single(self, geodetic): assert self.lc cdef Geodetic g = list2geodetic(geodetic) cdef NED n = self.lc.geodetic2ned(g) return [n.n, n.e, n.d] def ned2geodetic_single(self, ned): assert self.lc cdef NED n = list2ned(ned) cdef Geodetic g = self.lc.ned2geodetic(n) return [g.lat, g.lon, g.alt] def __dealloc__(self): del self.lc ================================================ FILE: common/xattr.py ================================================ import os from cffi import FFI # Workaround for the EON/termux build of Python having os.*xattr removed. ffi = FFI() ffi.cdef(""" int setxattr(const char *path, const char *name, const void *value, size_t size, int flags); ssize_t getxattr(const char *path, const char *name, void *value, size_t size); ssize_t listxattr(const char *path, char *list, size_t size); int removexattr(const char *path, const char *name); """) libc = ffi.dlopen(None) def setxattr(path, name, value, flags=0): path = path.encode() name = name.encode() if libc.setxattr(path, name, value, len(value), flags) == -1: raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: setxattr({path}, {name}, {value}, {flags})") def getxattr(path, name, size=128): path = path.encode() name = name.encode() value = ffi.new(f"char[{size}]") l = libc.getxattr(path, name, value, size) if l == -1: # errno 61 means attribute hasn't been set if ffi.errno == 61: return None raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: getxattr({path}, {name}, {size})") return ffi.buffer(value)[:l] def listxattr(path, size=128): path = path.encode() attrs = ffi.new(f"char[{size}]") l = libc.listxattr(path, attrs, size) if l == -1: raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: listxattr({path}, {size})") # attrs is b'\0' delimited values (so chop off trailing empty item) return [a.decode() for a in ffi.buffer(attrs)[:l].split(b"\0")[0:-1]] def removexattr(path, name): path = path.encode() name = name.encode() if libc.removexattr(path, name) == -1: raise OSError(ffi.errno, f"{os.strerror(ffi.errno)}: removexattr({path}, {name})") ================================================ FILE: installer/custom/install_gfortran.sh ================================================ #!/data/data/com.termux/files/usr/bin/sh # Get some needed tools. coreutils for mkdir command, gnugp for the signing key, and apt-transport-https to actually connect to the repo apt-get update apt-get --assume-yes upgrade apt-get --assume-yes install coreutils gnupg # Make the sources.list.d directory mkdir -p $PREFIX/etc/apt/sources.list.d # Write the needed source file echo "deb https://its-pointless.github.io/files/24 termux extras" > $PREFIX/etc/apt/sources.list.d/pointless.list # Add signing key from https://its-pointless.github.io/pointless.gpg curl -sL https://its-pointless.github.io/pointless.gpg | apt-key add - # Update apt apt update # install gfortran apt install gcc-11 -y setupclang-gfort-11 # Elf cleaner is needed to remove a DT_ENTRY warning that prints out when gfortran -v is called to get # its version number and this breaks the pip installation script when fortran is used. # Build elf cleaner SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" ELFCLEANERPATH=$SCRIPTPATH/termux-elf-cleaner/ cd $ELFCLEANERPATH make # Perform elf cleaner on gfortran ./termux-elf-cleaner $(which gfortran) ================================================ FILE: installer/custom/termux-elf-cleaner/COPYING ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: installer/custom/termux-elf-cleaner/Makefile ================================================ CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic PREFIX ?= /usr/local termux-elf-cleaner: termux-elf-cleaner.cpp clean: rm -f termux-elf-cleaner install: termux-elf-cleaner mkdir -p $(PREFIX)/bin install termux-elf-cleaner $(PREFIX)/bin/termux-elf-cleaner uninstall: rm -f $(PREFIX)/bin/termux-elf-cleaner .PHONY: clean install uninstall ================================================ FILE: installer/custom/termux-elf-cleaner/README.md ================================================ # termux-elf-cleaner Utility for Android ELF files to remove unused parts that the linker warns about. ## Description When loading ELF files, the Android linker warns about unsupported dynamic section entries with warnings such as: WARNING: linker: /data/data/org.kost.nmap.android.networkmapper/bin/nmap: unused DT entry: type 0x6ffffffe arg 0x8a7d4 WARNING: linker: /data/data/org.kost.nmap.android.networkmapper/bin/nmap: unused DT entry: type 0x6fffffff arg 0x3 This utility strips away the following dynamic section entries: - `DT_RPATH` - not supported in any Android version. - `DT_RUNPATH` - supported from Android 7.0. - `DT_VERDEF` - supported from Android 6.0. - `DT_VERDEFNUM` - supported from Android 6.0. - `DT_VERNEEDED` - supported from Android 6.0. - `DT_VERNEEDNUM` - supported from Android 6.0. - `DT_VERSYM` - supported from Android 6.0. It also removes the three ELF sections of type: - `SHT_GNU_verdef` - `SHT_GNU_verneed` - `SHT_GNU_versym` ## Usage ```sh usage: termux-elf-cleaner Processes ELF files to remove unsupported section types and dynamic section entries which the Android linker warns about. ``` ## Author Fredrik Fornwall ([@fornwall](https://github.com/fornwall)). ## License SPDX-License-Identifier: [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) ================================================ FILE: installer/custom/termux-elf-cleaner/elf.h ================================================ #ifndef ELF_H_INCLUDED #define ELF_H_INCLUDED #include /* Type for a 16-bit quantity. */ typedef uint16_t Elf32_Half; typedef uint16_t Elf64_Half; /* Types for signed and unsigned 32-bit quantities. */ typedef uint32_t Elf32_Word; typedef int32_t Elf32_Sword; typedef uint32_t Elf64_Word; typedef int32_t Elf64_Sword; /* Types for signed and unsigned 64-bit quantities. */ typedef uint64_t Elf32_Xword; typedef int64_t Elf32_Sxword; typedef uint64_t Elf64_Xword; typedef int64_t Elf64_Sxword; /* Type of addresses. */ typedef uint32_t Elf32_Addr; typedef uint64_t Elf64_Addr; /* Type of file offsets. */ typedef uint32_t Elf32_Off; typedef uint64_t Elf64_Off; /* Type for section indices, which are 16-bit quantities. */ typedef uint16_t Elf32_Section; typedef uint16_t Elf64_Section; /* Type for version symbol information. */ typedef Elf32_Half Elf32_Versym; typedef Elf64_Half Elf64_Versym; /* The ELF file header. This appears at the start of every ELF file. */ typedef struct { unsigned char e_ident[16]; /* Magic number and other info */ Elf32_Half e_type; /* Object file type */ Elf32_Half e_machine; /* Architecture */ Elf32_Word e_version; /* Object file version */ Elf32_Addr e_entry; /* Entry point virtual address */ Elf32_Off e_phoff; /* Program header table (usually follows elf header directly) file offset */ Elf32_Off e_shoff; /* Section header table (at end of file) file offset */ Elf32_Word e_flags; /* Processor-specific flags */ Elf32_Half e_ehsize; /* ELF header size in bytes */ Elf32_Half e_phentsize; /* Program header table entry size */ Elf32_Half e_phnum; /* Program header table entry count */ Elf32_Half e_shentsize; /* Section header table entry size */ Elf32_Half e_shnum; /* Section header table entry count */ Elf32_Half e_shstrndx; /* Section header string table index */ } Elf32_Ehdr; typedef struct { unsigned char e_ident[16]; /* Magic number and other info */ Elf64_Half e_type; /* Object file type */ Elf64_Half e_machine; /* Architecture */ Elf64_Word e_version; /* Object file version */ Elf64_Addr e_entry; /* Entry point virtual address */ Elf64_Off e_phoff; /* Program header table file offset */ Elf64_Off e_shoff; /* Section header table file offset */ Elf64_Word e_flags; /* Processor-specific flags */ Elf64_Half e_ehsize; /* ELF header size in bytes */ Elf64_Half e_phentsize; /* Program header table entry size */ Elf64_Half e_phnum; /* Program header table entry count */ Elf64_Half e_shentsize; /* Section header table entry size */ Elf64_Half e_shnum; /* Section header table entry count */ Elf64_Half e_shstrndx; /* Section header string table index */ } Elf64_Ehdr; /* Section header entry. The number of section entries in the file are determined by the "e_shnum" field of the ELF header.*/ typedef struct { Elf32_Word sh_name; /* Section name (string tbl index) */ Elf32_Word sh_type; /* Section type */ Elf32_Word sh_flags; /* Section flags */ Elf32_Addr sh_addr; /* Section virtual addr at execution */ Elf32_Off sh_offset; /* Section file offset */ Elf32_Word sh_size; /* Section size in bytes */ Elf32_Word sh_link; /* Link to another section */ Elf32_Word sh_info; /* Additional section information */ Elf32_Word sh_addralign; /* Section alignment */ Elf32_Word sh_entsize; /* Entry size if section holds table */ } Elf32_Shdr; typedef struct { Elf64_Word sh_name; /* Section name (string tbl index) */ Elf64_Word sh_type; /* Section type */ Elf64_Xword sh_flags; /* Section flags */ Elf64_Addr sh_addr; /* Section virtual addr at execution */ Elf64_Off sh_offset; /* Section file offset */ Elf64_Xword sh_size; /* Section size in bytes */ Elf64_Word sh_link; /* Link to another section */ Elf64_Word sh_info; /* Additional section information */ Elf64_Xword sh_addralign; /* Section alignment */ Elf64_Xword sh_entsize; /* Entry size if section holds table */ } Elf64_Shdr; /* Legal values for sh_type (section type). */ #define SHT_NULL 0 /* Section header table entry unused */ #define SHT_PROGBITS 1 /* Program data */ #define SHT_SYMTAB 2 /* Symbol table */ #define SHT_STRTAB 3 /* String table */ #define SHT_RELA 4 /* Relocation entries with addends */ #define SHT_HASH 5 /* Symbol hash table */ #define SHT_DYNAMIC 6 /* Dynamic linking information. Contains Elf32_Dyn/Elf64_Dyn entries. */ #define SHT_NOTE 7 /* Notes */ #define SHT_NOBITS 8 /* Program space with no data (bss) */ #define SHT_REL 9 /* Relocation entries, no addends */ #define SHT_SHLIB 10 /* Reserved */ #define SHT_DYNSYM 11 /* Dynamic linker symbol table */ #define SHT_INIT_ARRAY 14 /* Array of constructors */ #define SHT_FINI_ARRAY 15 /* Array of destructors */ #define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ #define SHT_GROUP 17 /* Section group */ #define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ #define SHT_NUM 19 /* Number of defined types. */ #define SHT_LOOS 0x60000000 /* Start OS-specific. */ #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */ #define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */ #define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ #define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ #define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ #define SHT_SUNW_move 0x6ffffffa #define SHT_SUNW_COMDAT 0x6ffffffb #define SHT_SUNW_syminfo 0x6ffffffc #define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ #define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ #define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ #define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ #define SHT_HIOS 0x6fffffff /* End OS-specific type */ #define SHT_LOPROC 0x70000000 /* Start of processor-specific */ #define SHT_HIPROC 0x7fffffff /* End of processor-specific */ #define SHT_LOUSER 0x80000000 /* Start of application-specific */ #define SHT_HIUSER 0x8fffffff /* End of application-specific */ /* Dynamic section entry. */ typedef struct { Elf32_Sword d_tag; /* Dynamic entry type */ union { Elf32_Word d_val; Elf32_Addr d_ptr; } d_un; /* Integer or address value */ } Elf32_Dyn; typedef struct { Elf64_Sxword d_tag; /* Dynamic entry type */ union { Elf64_Xword d_val; Elf64_Addr d_ptr; } d_un; /* Integer or address value */ } Elf64_Dyn; /* Legal values for d_tag (dynamic entry type). */ #define DT_NULL 0 /* Marks end of dynamic section */ #define DT_NEEDED 1 /* Name of needed library */ #define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ #define DT_PLTGOT 3 /* Processor defined value */ #define DT_HASH 4 /* Address of symbol hash table */ #define DT_STRTAB 5 /* Address of string table */ #define DT_SYMTAB 6 /* Address of symbol table */ #define DT_RELA 7 /* Address of Rela relocs */ #define DT_RELASZ 8 /* Total size of Rela relocs */ #define DT_RELAENT 9 /* Size of one Rela reloc */ #define DT_STRSZ 10 /* Size of string table */ #define DT_SYMENT 11 /* Size of one symbol table entry */ #define DT_INIT 12 /* Address of init function */ #define DT_FINI 13 /* Address of termination function */ #define DT_SONAME 14 /* Name of shared object */ #define DT_RPATH 15 /* Library search path (deprecated) */ #define DT_SYMBOLIC 16 /* Start symbol search here */ #define DT_REL 17 /* Address of Rel relocs */ #define DT_RELSZ 18 /* Total size of Rel relocs */ #define DT_RELENT 19 /* Size of one Rel reloc */ #define DT_PLTREL 20 /* Type of reloc in PLT */ #define DT_DEBUG 21 /* For debugging; unspecified */ #define DT_TEXTREL 22 /* Reloc might modify .text */ #define DT_JMPREL 23 /* Address of PLT relocs */ #define DT_BIND_NOW 24 /* Process relocations of object */ #define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ #define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ #define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ #define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ #define DT_RUNPATH 29 /* Library search path */ #define DT_FLAGS 30 /* Flags for the object being loaded */ #define DT_ENCODING 32 /* Start of encoded range */ #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ #define DT_NUM 34 /* Number used */ #define DT_LOOS 0x6000000d /* Start of OS-specific */ #define DT_HIOS 0x6ffff000 /* End of OS-specific */ #define DT_VERDEF 0x6ffffffc #define DT_VERDEFNUM 0x6ffffffd #define DT_LOPROC 0x70000000 /* Start of processor-specific */ #define DT_HIPROC 0x7fffffff /* End of processor-specific */ /* Symbol table entry. */ typedef struct { Elf32_Word st_name; /* Symbol name (string tbl index) */ Elf32_Addr st_value; /* Symbol value */ Elf32_Word st_size; /* Symbol size */ unsigned char st_info; /* Symbol type and binding */ unsigned char st_other; /* Symbol visibility */ Elf32_Section st_shndx; /* Section index */ } Elf32_Sym; typedef struct { Elf64_Word st_name; /* Symbol name (string tbl index) */ unsigned char st_info; /* Symbol type and binding */ unsigned char st_other; /* Symbol visibility */ Elf64_Section st_shndx; /* Section index */ Elf64_Addr st_value; /* Symbol value */ Elf64_Xword st_size; /* Symbol size */ } Elf64_Sym; #endif ================================================ FILE: installer/custom/termux-elf-cleaner/termux-elf-cleaner.cpp ================================================ #include #include #include #include #include #include #include #include #include #ifndef __ANDROID_API__ #define __ANDROID_API__ 21 #endif // Include a local elf.h copy as not all platforms have it. #include "elf.h" #define DT_GNU_HASH 0x6ffffef5 #define DT_VERSYM 0x6ffffff0 #define DT_FLAGS_1 0x6ffffffb #define DT_VERNEEDED 0x6ffffffe #define DT_VERNEEDNUM 0x6fffffff #define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ #define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ #define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ #if __ANDROID_API__ < 23 #define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL) #else // The supported DT_FLAGS_1 values as of Android 6.0. #define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE) #endif template bool process_elf(uint8_t* bytes, size_t elf_file_size, char const* file_name) { if (sizeof(ElfSectionHeaderType) > elf_file_size) { fprintf(stderr, "termux-elf-cleaner: Elf header for '%s' would end at %zu but file size only %zu\n", file_name, sizeof(ElfSectionHeaderType), elf_file_size); return false; } ElfHeaderType* elf_hdr = reinterpret_cast(bytes); size_t last_section_header_byte = elf_hdr->e_shoff + sizeof(ElfSectionHeaderType) * elf_hdr->e_shnum; if (last_section_header_byte > elf_file_size) { fprintf(stderr, "termux-elf-cleaner: Section header for '%s' would end at %zu but file size only %zu\n", file_name, last_section_header_byte, elf_file_size); return false; } ElfSectionHeaderType* section_header_table = reinterpret_cast(bytes + elf_hdr->e_shoff); for (unsigned int i = 1; i < elf_hdr->e_shnum; i++) { ElfSectionHeaderType* section_header_entry = section_header_table + i; if (section_header_entry->sh_type == SHT_DYNAMIC) { size_t const last_dynamic_section_byte = section_header_entry->sh_offset + section_header_entry->sh_size; if (last_dynamic_section_byte > elf_file_size) { fprintf(stderr, "termux-elf-cleaner: Dynamic section for '%s' would end at %zu but file size only %zu\n", file_name, last_dynamic_section_byte, elf_file_size); return false; } size_t const dynamic_section_entries = section_header_entry->sh_size / sizeof(ElfDynamicSectionEntryType); ElfDynamicSectionEntryType* const dynamic_section = reinterpret_cast(bytes + section_header_entry->sh_offset); unsigned int last_nonnull_entry_idx = 0; for (unsigned int j = dynamic_section_entries - 1; j > 0; j--) { ElfDynamicSectionEntryType* dynamic_section_entry = dynamic_section + j; if (dynamic_section_entry->d_tag != DT_NULL) { last_nonnull_entry_idx = j; break; } } for (unsigned int j = 0; j < dynamic_section_entries; j++) { ElfDynamicSectionEntryType* dynamic_section_entry = dynamic_section + j; char const* removed_name = nullptr; switch (dynamic_section_entry->d_tag) { #if __ANDROID_API__ <= 21 case DT_GNU_HASH: removed_name = "DT_GNU_HASH"; break; #endif #if __ANDROID_API__ < 23 case DT_VERSYM: removed_name = "DT_VERSYM"; break; case DT_VERNEEDED: removed_name = "DT_VERNEEDED"; break; case DT_VERNEEDNUM: removed_name = "DT_VERNEEDNUM"; break; case DT_VERDEF: removed_name = "DT_VERDEF"; break; case DT_VERDEFNUM: removed_name = "DT_VERDEFNUM"; break; #endif case DT_RPATH: removed_name = "DT_RPATH"; break; #if __ANDROID_API__ < 24 case DT_RUNPATH: removed_name = "DT_RUNPATH"; break; #endif } if (removed_name != nullptr) { printf("termux-elf-cleaner: Removing the %s dynamic section entry from '%s'\n", removed_name, file_name); // Tag the entry with DT_NULL and put it last: dynamic_section_entry->d_tag = DT_NULL; // Decrease j to process new entry index: std::swap(dynamic_section[j--], dynamic_section[last_nonnull_entry_idx--]); } else if (dynamic_section_entry->d_tag == DT_FLAGS_1) { // Remove unsupported DF_1_* flags to avoid linker warnings. decltype(dynamic_section_entry->d_un.d_val) orig_d_val = dynamic_section_entry->d_un.d_val; decltype(dynamic_section_entry->d_un.d_val) new_d_val = (orig_d_val & SUPPORTED_DT_FLAGS_1); if (new_d_val != orig_d_val) { printf("termux-elf-cleaner: Replacing unsupported DF_1_* flags %llu with %llu in '%s'\n", (unsigned long long) orig_d_val, (unsigned long long) new_d_val, file_name); dynamic_section_entry->d_un.d_val = new_d_val; } } } } #if __ANDROID_API__ < 23 else if (section_header_entry->sh_type == SHT_GNU_verdef || section_header_entry->sh_type == SHT_GNU_verneed || section_header_entry->sh_type == SHT_GNU_versym) { printf("termux-elf-cleaner: Removing version section from '%s'\n", file_name); section_header_entry->sh_type = SHT_NULL; } #endif } return true; } int main(int argc, char const** argv) { if (argc < 2 || (argc == 2 && strcmp(argv[1], "-h")==0)) { fprintf(stderr, "usage: %s \n", argv[0]); fprintf(stderr, "\nProcesses ELF files to remove unsupported section types\n" "and dynamic section entries which the Android linker (API %d)\nwarns about.\n", __ANDROID_API__); return 1; } for (int i = 1; i < argc; i++) { char const* file_name = argv[i]; int fd = open(file_name, O_RDWR); if (fd < 0) { char* error_message; if (asprintf(&error_message, "open(\"%s\")", file_name) == -1) error_message = (char*) "open()"; perror(error_message); return 1; } struct stat st; if (fstat(fd, &st) < 0) { perror("fstat()"); return 1; } if (st.st_size < (long long) sizeof(Elf32_Ehdr)) { close(fd); continue; } void* mem = mmap(0, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (mem == MAP_FAILED) { perror("mmap()"); return 1; } uint8_t* bytes = reinterpret_cast(mem); if (!(bytes[0] == 0x7F && bytes[1] == 'E' && bytes[2] == 'L' && bytes[3] == 'F')) { // Not the ELF magic number. munmap(mem, st.st_size); close(fd); continue; } if (bytes[/*EI_DATA*/5] != 1) { fprintf(stderr, "termux-elf-cleaner: Not little endianness in '%s'\n", file_name); munmap(mem, st.st_size); close(fd); continue; } uint8_t const bit_value = bytes[/*EI_CLASS*/4]; if (bit_value == 1) { if (!process_elf(bytes, st.st_size, file_name)) return 1; } else if (bit_value == 2) { if (!process_elf(bytes, st.st_size, file_name)) return 1; } else { printf("termux-elf-cleaner: Incorrect bit value %d in '%s'\n", bit_value, file_name); return 1; } if (msync(mem, st.st_size, MS_SYNC) < 0) { perror("msync()"); return 1; } munmap(mem, st.st_size); close(fd); } return 0; } ================================================ FILE: installer/updater/Makefile ================================================ CC = clang CXX = clang++ PHONELIBS = ../../phonelibs WARN_FLAGS = -Werror=implicit-function-declaration \ -Werror=incompatible-pointer-types \ -Werror=int-conversion \ -Werror=return-type \ -Werror=format-extra-args CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS) CXXFLAGS = -std=c++1z -g -fPIC -O2 $(WARN_FLAGS) CURL_FLAGS = -I$(PHONELIBS)/curl/include CURL_LIBS = $(PHONELIBS)/curl/lib/libcurl.a \ $(PHONELIBS)/zlib/lib/libz.a BORINGSSL_FLAGS = -I$(PHONELIBS)/boringssl/include BORINGSSL_LIBS = $(PHONELIBS)/boringssl/lib/libssl_static.a \ $(PHONELIBS)/boringssl/lib/libcrypto_static.a \ NANOVG_FLAGS = -I$(PHONELIBS)/nanovg JSON11_FLAGS = -I$(PHONELIBS)/json11 OPENGL_LIBS = -lGLESv3 FRAMEBUFFER_LIBS = -lutils -lgui -lEGL .PHONY: all all: updater OBJS = opensans_regular.ttf.o \ opensans_semibold.ttf.o \ opensans_bold.ttf.o \ ../../selfdrive/common/util.o \ ../../selfdrive/common/touch.o \ ../../selfdrive/common/framebuffer.o \ $(PHONELIBS)/json11/json11.o \ $(PHONELIBS)/nanovg/nanovg.o DEPS := $(OBJS:.o=.d) updater: updater.o $(OBJS) @echo "[ LINK ] $@" $(CXX) $(CPPFLAGS) -fPIC -o 'updater' $^ \ $(FRAMEBUFFER_LIBS) \ $(CURL_LIBS) \ $(BORINGSSL_LIBS) \ -L/system/vendor/lib64 \ $(OPENGL_LIBS) \ -lcutils -lm -llog strip updater opensans_regular.ttf.o: ../../selfdrive/assets/fonts/opensans_regular.ttf @echo "[ bin2o ] $@" cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' opensans_bold.ttf.o: ../../selfdrive/assets/fonts/opensans_bold.ttf @echo "[ bin2o ] $@" cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' opensans_semibold.ttf.o: ../../selfdrive/assets/fonts/opensans_semibold.ttf @echo "[ bin2o ] $@" cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' %.o: %.c mkdir -p $(@D) @echo "[ CC ] $@" $(CC) $(CPPFLAGS) $(CFLAGS) \ -I../.. \ -I$(PHONELIBS)/android_frameworks_native/include \ -I$(PHONELIBS)/android_system_core/include \ -I$(PHONELIBS)/android_hardware_libhardware/include \ $(NANOVG_FLAGS) \ -c -o '$@' '$<' %.o: %.cc mkdir -p $(@D) @echo "[ CXX ] $@" $(CXX) $(CPPFLAGS) $(CXXFLAGS) \ -I../../selfdrive \ -I../../ \ -I$(PHONELIBS)/android_frameworks_native/include \ -I$(PHONELIBS)/android_system_core/include \ -I$(PHONELIBS)/android_hardware_libhardware/include \ $(NANOVG_FLAGS) \ $(JSON11_FLAGS) \ $(CURL_FLAGS) \ $(BORINGSSL_FLAGS) \ -c -o '$@' '$<' .PHONY: clean clean: rm -f $(OBJS) $(DEPS) -include $(DEPS) ================================================ FILE: installer/updater/oneplus.json ================================================ { "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-5dc2575d713977666a8e14ae1b43a04d7f63123934c80fa10751d949a107653e.zip", "ota_hash": "5dc2575d713977666a8e14ae1b43a04d7f63123934c80fa10751d949a107653e", "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-db31ffe79dfd60be966fba6d1525a5081a920062b883644dc8f5734bcc6806bb.img", "recovery_len": 15926572, "recovery_hash": "db31ffe79dfd60be966fba6d1525a5081a920062b883644dc8f5734bcc6806bb" } ================================================ FILE: installer/updater/update.json ================================================ { "ota_url": "https://commadist.azureedge.net/neosupdate/ota-signed-5dc2575d713977666a8e14ae1b43a04d7f63123934c80fa10751d949a107653e.zip", "ota_hash": "5dc2575d713977666a8e14ae1b43a04d7f63123934c80fa10751d949a107653e", "recovery_url": "https://commadist.azureedge.net/neosupdate/recovery-f01a55c9ba52ca57668d1684c6bf4118efd31916b04f8c1fcd8495013d3677eb.img", "recovery_len": 15222060, "recovery_hash": "f01a55c9ba52ca57668d1684c6bf4118efd31916b04f8c1fcd8495013d3677eb" } ================================================ FILE: jetson/env_installer.sh ================================================ #!/bin/bash -e # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ##################################################################### # Configuration: # * Use IMX 477 Arducam. # * Minimum of 32GB of U3 micro sdcard. # * Work on Nvidia Jetson Xavier NX only. # * Use Jetpack 4.6. # * setup your username / password as: comma / comma # * setup your host name as: tici # * change your camera settings in /opt/nvidia/jetson-io/jetson-io.py ##################################################################### JETSON_ARCH="7.2" PYENV_PYTHON_VERSION="3.8.10" OPENPCV_VERSION="4.5.0" LLVM_VERSION="12.0.1" LLVM_INSTALL_FOLDER="llvm-12" POCL_VERSION="release_1_8" USERNAME="comma" WORKSPACE="workspace" ########################################################################### ############################### BASE SYSTEM ############################### ########################################################################### # Nopasswd sudo echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" | (sudo su -c 'EDITOR="tee -a" visudo -f /etc/sudoers') # setup /bin/sh symlink sudo ln -sf /bin/bash /bin/sh # Disable automatic ondemand switching from ubuntu (cpu auto scaling) sudo systemctl disable ondemand # jetpack 4.6 has mode 8 sudo nvpmodel -m 8 # use performance governor sudo echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor # throttling prevention sudo sh -c 'echo 7000 > /sys/devices/c250000.i2c/i2c-7/7-0040/iio:device0/crit_current_limit_0' # allow max available CPU freq sudo sh -c 'for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; do echo 1907200 > $i; done' # reduce reboot time (when a running job is stall) sudo sed -i -e 's/#DefaultTimeoutStopSec=90s/DefaultTimeoutStopSec=1s/g' /etc/systemd/system.conf #allow user to access USB sudo echo "SUBSYSTEM==\"usb\", MODE=\"0666\", GROUP=\"users\"" > $HOME/openpilot.rules sudo echo "SUBSYSTEM==\"usb_device\", MODE=\"0666\", GROUP=\"users\"" >> $HOME/openpilot.rules sudo mv $HOME/openpilot.rules /etc/udev/rules.d sudo chmod 644 /etc/udev/rules.d/openpilot.rules sudo chown root /etc/udev/rules.d/openpilot.rules sudo chgrp root /etc/udev/rules.d/openpilot.rules # Disable all useless systemctl services, if any, from agnos sudo systemctl mask apt-daily-upgrade.service sudo systemctl mask apt-daily.service sudo systemctl mask apt-daily-upgrade.timer sudo systemctl mask apt-daily.timer sudo systemctl disable nvpmodel.service sudo systemctl mask sys-devices-3100000.serial-tty-ttyTHS0.device sudo systemctl mask sys-devices-3110000.serial-tty-ttyTHS1.device sudo systemctl mask sys-devices-3110000.serial-tty-ttyTHS1.device sudo systemctl mask sys-devices-3140000.serial-tty-ttyTHS4.device sudo systemctl mask sys-devices-platform-serial8250-tty-ttyS0.device sudo systemctl mask sys-devices-platform-serial8250-tty-ttyS1.device sudo systemctl mask sys-devices-platform-serial8250-tty-ttyS2.device sudo systemctl mask sys-devices-platform-serial8250-tty-ttyS3.device sudo systemctl mask sys-kernel-debug.mount sudo systemctl mask motd-news.timer sudo systemctl mask remote-fs.target sudo systemctl disable nvzramconfig sudo systemctl mask plymouth-quit-wait.service # splash screen sudo systemctl mask plymouth-read-write.service # splash screen sudo systemctl mask alsa-restore.service # we dont have speakers, so no need alsa sudo systemctl disable nvphs.service sudo systemctl mask getty.target sudo systemctl disable nv_update_verifier.service sudo systemctl disable nvgetty.service sudo systemctl mask networkd-dispatcher.service sudo systemctl mask speech-dispatcher.service sudo systemctl disable nv-l4t-usb-device-mode.service # setup UI packages sudo apt update sudo apt purge -y gdm3 lightdm sudo apt install -y --no-install-recommends apt-utils lxdm lxde unclutter # install packages in ubuntu_setup.sh # without clang and qt, we need them from focal release (newer) sudo apt-get install -y --no-install-recommends \ autoconf \ build-essential \ bzip2 \ capnproto \ cppcheck \ libcapnp-dev \ cmake \ curl \ ffmpeg \ git \ libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev libavfilter-dev \ libarchive-dev \ libbz2-dev \ libcurl4-openssl-dev \ libeigen3-dev \ libffi-dev \ libglew-dev \ libgles2-mesa-dev \ libglfw3-dev \ libglib2.0-0 \ liblzma-dev \ libomp-dev \ libopencv-dev \ libpng16-16 \ libssl-dev \ libstdc++-arm-none-eabi-newlib \ libsqlite3-dev \ libtool \ libusb-1.0-0-dev \ libzmq3-dev \ libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev \ libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev libfreetype6-dev \ libsystemd-dev \ locales \ ocl-icd-libopencl1 \ ocl-icd-opencl-dev \ opencl-headers \ python-dev \ python3-pip \ screen \ sudo \ vim \ wget \ htop \ gcc-arm-none-eabi \ gir1.2-notify # clean up sudo apt purge -y libreoffice* thunderbird* rhythmbox* transmission* mutter* *visionworks* ubuntu-wallpapers-bionic \ *theme-ubuntu* remmina* branding-ubuntu light-themes pulseaudio packagekit ibus* \ deluge smplayer* onboard* snapd* vpi1* galculator xmms2* youtube-dl unity-* whoopsie* \ apport apparmor rpcbind gpsd isc-dhcp-server firefox printer-driver-* evolution-data-server* \ lxmusic* avahi* yelp* vlc* nfs* ntfs* python-gi samba* docker* chromium-* system-config-printer-* \ geoclue* totem* gnome-* modemmanager sudo apt autoremove -y && sudo apt clean -y # reinstall again making sure clean up didn't delete them. sudo apt install -y --no-install-recommends lxdm lxde # install packages from focal sudo sed -i -e 's#bionic#focal#g' /etc/apt/sources.list sudo apt update sudo apt install -y tmux nano sudo apt install -y --no-install-recommends \ clang \ qt5-default \ qtmultimedia5-dev \ qtwebengine5-dev \ qtdeclarative5-dev \ qtchooser \ libqt5x11extras5-dev \ qtlocation5-dev \ qtpositioning5-dev \ libqt5sql5-sqlite \ libqt5svg5-dev \ libqt5opengl5-dev \ ccache \ qml-module-qtquick2 \ libreadline-dev # libqt5opengl5-dev is for mapbox sudo sed -i -e 's#focal#bionic#g' /etc/apt/sources.list # clean up again sudo apt update sudo apt purge -y mysql-common p7zip* ppp* kerneloops *gvfs* sudo apt autoremove -y # add missing wifi manager sudo apt install -y network-manager-gnome # delete sample files sudo rm -rf /usr/local/cuda/samples \ /usr/src/cudnn_samples_* \ /usr/src/tensorrt/data \ /usr/src/tensorrt/samples \ /usr/share/visionworks* ~/VisionWorks-SFM*Samples \ /opt/nvidia/deepstream/deepstream*/samples #add user to the input device so it can read mouse sudo usermod -aG input ${USERNAME} # common folders sudo mkdir -p /data/ /data/params/d/ /data/media/0/ /persist/ /data/log /data/media/0/realdata/ /data/media/0/fakedata/ # dp will recognize it as jetson sudo touch /JETSON # allow ssh in root because we will give openpilot full root access. sudo sed -i -e 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config sudo sed -i -e 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config sudo sed -i -e 's/#KerberosAuthentication no/KerberosAuthentication no/g' /etc/ssh/sshd_config sudo sed -i -e 's/#GSSAPIAuthentication no/GSSAPIAuthentication no/g' /etc/ssh/sshd_config sudo sed -i -e 's/#UseDNS no/UseDNS no/g' /etc/ssh/sshd_config sudo sed -i -e 's/#UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config # install jtop sudo pip3 install setuptools # breaks after completion, remove for now. #sudo -H pip3 install -U jetson-stats ########################################################################### ############################ OPENPILOT RELATED ############################ ########################################################################### # install git lfs if ! command -v "git-lfs" > /dev/null 2>&1; then curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt-get install git-lfs fi # install pyenv if ! command -v "pyenv" > /dev/null 2>&1; then curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash fi export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" # install bashrc source ~/.bashrc if [ -z "$OPENPILOT_ENV" ]; then echo "export PYENV_ROOT=\"$HOME/.pyenv\"" >> ~/.bashrc echo "export PATH=\"$PYENV_ROOT/bin:$PATH\"" >> ~/.bashrc echo "eval \"$(pyenv init --path)\"" >> ~/.bashrc echo "source /data/openpilot/jetson/openpilot_env.sh" >> ~/.bashrc source $HOME/openpilot/jetson/openpilot_env.sh source ~/.bashrc echo "added openpilot_env to bashrc" fi # install python pyenv install -s ${PYENV_PYTHON_VERSION} pyenv global ${PYENV_PYTHON_VERSION} pyenv rehash eval "$(pyenv init -)" # **** in python env **** pip install --upgrade pip==20.2.4 pip install pipenv==2020.8.13 pip install setuptools pip install wheel pip install pkgconfig # packages pip install atomicwrites pip install casadi pip install cffi pip install crcmod pip install future-fstrings # for acados pip install hexdump # for dump.py pip install libusb1 pip install numpy pip install psutil pip install pycapnp==1.1.0 pip install cryptography pip install pyzmq pip install requests pip install setproctitle pip install smbus2 pip install sympy pip install tqdm pip install cython pip install scons pip install pycryptodome pip install jinja2 pip install pyjwt pip install pyserial pip install sentry-sdk #pip install setuptools-cythonize #pip install logentries # mapd pip install scipy pip install overpy # openpilot tmux echo "unbind C-b" > $HOME/.tmux.conf echo "set -g prefix \`" >> $HOME/.tmux.conf echo "bind-key \` last-window" >> $HOME/.tmux.conf echo "bind-key e send-prefix" >> $HOME/.tmux.conf echo "bind-key S command-prompt -p 'Save log to file:' -I '/tmp/openpilot_log' 'capture-pane -S-7200; save-buffer %1; delete-buffer'" >> $HOME/.tmux.conf echo "set -g status-position bottom" >> $HOME/.tmux.conf echo "set -g status-style bg=colour234,fg=colour137,dim" >> $HOME/.tmux.conf echo "set -g status-left ''" >> $HOME/.tmux.conf echo "set -g status-right '#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M:%S '" >> $HOME/.tmux.conf echo "set -g status-right-length 50" >> $HOME/.tmux.conf echo "set -g status-left-length 20" >> $HOME/.tmux.conf echo "set -g history-limit 7200" >> $HOME/.tmux.conf echo "setw -g window-status-current-style fg=colour81,bg=colour238,bold" >> $HOME/.tmux.conf echo "setw -g window-status-current-format ' #I#[fg=colour250]:#[fg=colour255]#W#[fg=colour50]#F '" >> $HOME/.tmux.conf echo "setw -g window-status-style fg=colour138,bg=colour235" >> $HOME/.tmux.conf echo "setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '" >> $HOME/.tmux.conf echo "setw -g window-status-bell-style fg=colour255,bg=colour1,bold" >> $HOME/.tmux.conf # move to /data/openpilot cd /data mv /home/${USERNAME}/openpilot /data/ # make sure everything goes to the right display echo "export DISPLAY=:0.0" >> $HOME/.bashrc # start openpilot correctly echo "export USE_MIPI=\"1\"" >> $HOME/.bashrc echo "export NOSENSOR=\"1\"" >> $HOME/.bashrc echo "export PASSIVE=\"0\"" >> $HOME/.bashrc # start from /data/openpilot echo "[ -d \"/data/openpilot\" ] && cd /data/openpilot" >> $HOME/.bashrc ########################################################################### ############################ DOWNLOAD PACKAGES ############################ ########################################################################### mkdir -p /data/${WORKSPACE}/ cd /data/${WORKSPACE}/ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz & wget https://nvidia.box.com/shared/static/gjqofg7rkg97z3gc8jeyup6t8n9j8xjw.whl -O onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl & curl -L https://github.com/opencv/opencv/archive/${OPENPCV_VERSION}.zip -o opencv-${OPENPCV_VERSION}.zip & curl -L https://github.com/opencv/opencv_contrib/archive/${OPENPCV_VERSION}.zip -o opencv_contrib-${OPENPCV_VERSION}.zip & wait ########################################################################### ############################### ONNX RUNTIME ############################## ########################################################################### cd /data/${WORKSPACE}/ pip install onnxruntime_gpu-1.8.0-cp38-cp38-linux_aarch64.whl ########################################################################### ################################## LLVM 12 ################################ ########################################################################### # for POCL cd /data/${WORKSPACE}/ tar -xvf clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz sudo mkdir -p /usr/lib/${LLVM_INSTALL_FOLDER}/ sudo mv clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu/* /usr/lib/${LLVM_INSTALL_FOLDER}/ ########################################################################### ################################### POCL ################################## ########################################################################### cd /data/${WORKSPACE}/ git clone --single-branch --branch ${POCL_VERSION} https://github.com/pocl/pocl.git cd /data/${WORKSPACE}/pocl mkdir build cd /data/${WORKSPACE}/pocl/build/ cmake -DCMAKE_BUILD_TYPE=Release -DWITH_LLVM_CONFIG=/usr/lib/${LLVM_INSTALL_FOLDER}/bin/llvm-config -DENABLE_CUDA=ON -DSTATIC_LLVM=ON .. make -j $(nproc) sudo make install mkdir -p /etc/OpenCL/vendors/ echo "/usr/local/lib/libpocl.so" > /etc/OpenCL/vendors/pocl.icd ########################################################################### ################################## OPENCV ################################# ########################################################################### # Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA Corporation and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA Corporation is strictly prohibited. # jetpack opencv doesn't have cuda that's why we compile manually # check jtop for more info. cd /data/${WORKSPACE}/ echo "** Remove other OpenCV first" sudo sudo apt-get purge -y *libopencv* echo "** Install requirement" sudo apt-get update sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp unzip opencv-${OPENPCV_VERSION}.zip unzip opencv_contrib-${OPENPCV_VERSION}.zip cd opencv-${OPENPCV_VERSION}/ echo "** Building..." mkdir release cd release/ cmake -D WITH_CUDA=ON \ -D WITH_CUDNN=OFF \ -D CUDA_ARCH_BIN="${JETSON_ARCH}" \ -D CUDA_ARCH_PTX="" \ -D OPENCV_GENERATE_PKGCONFIG=ON \ -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENPCV_VERSION}/modules \ -D WITH_GSTREAMER=ON \ -D WITH_LIBV4L=ON \ -D BUILD_opencv_python2=OFF \ -D BUILD_opencv_python3=ON \ -D BUILD_TESTS=OFF \ -D BUILD_PERF_TESTS=OFF \ -D BUILD_EXAMPLES=OFF \ -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D WITH_GTK=OFF \ -D ENABLE_FAST_MATH=ON \ -D BUILD_opencv_java=OFF \ -D WITH_QT=OFF \ -D INSTALL_PYTHON_EXAMPLES=OFF \ -D INSTALL_C_EXAMPLES=OFF \ -D WITH_CUFFT=ON \ -D WITH_CUBLAS=ON \ -D WITH_1394=OFF \ -D WITH_ANDROID_MEDIANDK=OFF \ -D BUILD_JAVA=OFF \ -D BUILD_FAT_JAVA_LIB=OFF \ -D BUILD_opencv_python2=OFF \ .. make -j$(nproc) sudo make install ########################################################################### ################################## FINAL ################################## ########################################################################### cd /data && rm -fr /data/${WORKSPACE}/ # creates the necessary links and cache sudo ldconfig -v # delay restart sudo shutdown -r 1 # clean up once last time sudo apt autoremove -y && sudo apt clean -y # lxdm give comma autologin sudo sed -i -e "s/# autologin=dgod/autologin=${USERNAME}/g" /etc/lxdm/default.conf # remove screensaver sudo sed -i -e 's/@xscreensaver -no-splash//g' /etc/xdg/lxsession/LXDE/autostart # auto start openpilot sudo sh -c 'echo "@lxterminal --command tmux new-session -s '${USERNAME}' -d /data/openpilot/jetson/launcher.sh" >> /etc/xdg/lxsession/LXDE/autostart' # comma as root USERNAME="comma" sudo sed -i -e "s#${USERNAME}:x:1000:1000:${USERNAME}#${USERNAME}:x:0:0:${USERNAME}#g" /etc/passwd ================================================ FILE: jetson/launcher.sh ================================================ #!/bin/bash -e cd /data/openpilot && bash -i launch_chffrplus.sh ================================================ FILE: jetson/openpilot_env.sh ================================================ if [ -z "$OPENPILOT_ENV" ]; then export PYTHONPATH="/data/openpilot:$PYTHONPATH" unamestr=`uname` if [[ "$unamestr" == 'Linux' ]]; then export PATH="$HOME/.pyenv/bin:$PATH" # Pyenv suggests we place the below two lines in .profile before we source # .bashrc, but there is no simple way to guarantee we do this correctly # programmatically across heterogeneous systems. For end-user convenience, # we add the lines here as a workaround. # https://github.com/pyenv/pyenv/issues/1906 export PYENV_ROOT="$HOME/.pyenv" eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)" elif [[ "$unamestr" == 'Darwin' ]]; then # msgq doesn't work on mac export ZMQ=1 export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES fi eval "$(pyenv init -)" export OPENPILOT_ENV=1 fi ================================================ FILE: jetson/release.py ================================================ #!/usr/bin/env python3 ''' This script is used to clean up files prior publish to xnxpilot. Run this in jetson device to clean up. Do not run this unless you know what you are doing. -- Rick Lan ''' import os import sys import subprocess PATH = "/data/openpilot" VERSION = "0.8.9" if not os.path.exists("/JETSON"): sys.exit("Please run this in Jetson device.") # make sure we dont use prebuilt os.system("echo -n 0 > /data/params/d/dp_prebuilt") os.system("rm -fr %s/prebuilt" % PATH) # model clean up os.system("rm -fr %s/selfdrive/models/*.dlc" % PATH) # ui clean up subprocess.call(['sed -i -e "s#selfdrive/ui/_ui##g " ' + ('%s/.gitignore' % PATH)], shell=True) subprocess.call(['sed -i -e "s#selfdrive/ui/_soundd##g " ' + ('%s/.gitignore' % PATH)], shell=True) os.system("rm -fr %s/selfdrive/ui/*_aarch64" % PATH) os.system("rm -fr %s/selfdrive/ui/*_larch64" % PATH) os.system("rm -fr %s/selfdrive/ui/*_c3" % PATH) os.system("rm -fr %s/selfdrive/ui/qt/*_aarch64" % PATH) os.system("rm -fr %s/selfdrive/ui/qt/*_larch64" % PATH) os.system("rm -fr %s/selfdrive/ui/qt/*_c3" % PATH) os.system("rm -fr %s/selfdrive/ui/SConscript" % PATH) os.system("rm -fr %s/selfdrive/ui/.gitignore" % PATH) os.system("find %s/selfdrive/ui/ -name '*.a' -delete" % PATH) os.system("find %s/selfdrive/ui/ -name '*.o' -delete" % PATH) os.system("find %s/selfdrive/ui/ -name '*.h' -delete" % PATH) os.system("find %s/selfdrive/ui/ -name '*.cc' -delete" % PATH) # delete panda os.system("rm -fr %s/panda/board/obj/panda.bin" % PATH) os.system("rm -fr %s/panda/board/obj/panda.bin.signed" % PATH) # misc os.system("rm -fr %s/selfdrive/golden" % PATH) os.system("rm -fr %s/installer/updater/updater.cc" % PATH) os.system("rm -fr %s/phonelibs/curl/" % PATH) os.system("rm -fr %s/phonelibs/boringssl/" % PATH) os.system("rm -fr %s/phonelibs/mapbox-gl-native-qt/aarch64" % PATH) os.system("rm -fr %s/phonelibs/snpe/aarch64*" % PATH) # change version string subprocess.call(["sed -i -e 's/.*/#define COMMA_VERSION \"" + ("%s-xnxpilot" % VERSION) + "\"/g' " + ('%s/selfdrive/common/version.h' % PATH)], shell=True) ================================================ FILE: launch_chffrplus.sh ================================================ #!/usr/bin/bash if [ -z "$BASEDIR" ]; then BASEDIR="/data/openpilot" fi source "$BASEDIR/launch_env.sh" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" function two_init { python /data/openpilot/scripts/installers/language_installer.py python /data/openpilot/scripts/installers/sshkey_installer.py python /data/openpilot/scripts/installers/font_installer.py mount -o remount,rw /system if [ ! -f /ONEPLUS ] && ! $(grep -q "letv" /proc/cmdline); then sed -i -e 's#/dev/input/event1#/dev/input/event2#g' ~/.bash_profile touch /ONEPLUS else if [ ! -f /LEECO ]; then touch /LEECO fi fi mount -o remount,r /system # set IO scheduler setprop sys.io.scheduler noop for f in /sys/block/*/queue/scheduler; do echo noop > $f done # *** shield cores 2-3 *** # TODO: should we enable this? # offline cores 2-3 to force recurring timers onto the other cores #echo 0 > /sys/devices/system/cpu/cpu2/online #echo 0 > /sys/devices/system/cpu/cpu3/online #echo 1 > /sys/devices/system/cpu/cpu2/online #echo 1 > /sys/devices/system/cpu/cpu3/online # android gets two cores echo 0-1 > /dev/cpuset/background/cpus echo 0-1 > /dev/cpuset/system-background/cpus echo 0-1 > /dev/cpuset/foreground/cpus echo 0-1 > /dev/cpuset/foreground/boost/cpus echo 0-1 > /dev/cpuset/android/cpus # openpilot gets all the cores echo 0-3 > /dev/cpuset/app/cpus # mask off 2-3 from RPS and XPS - Receive/Transmit Packet Steering echo 3 | tee /sys/class/net/*/queues/*/rps_cpus echo 3 | tee /sys/class/net/*/queues/*/xps_cpus # *** set up governors *** # +50mW offroad, +500mW onroad for 30% more RAM bandwidth echo "performance" > /sys/class/devfreq/soc:qcom,cpubw/governor echo 1056000 > /sys/class/devfreq/soc:qcom,m4m/max_freq echo "performance" > /sys/class/devfreq/soc:qcom,m4m/governor # unclear if these help, but they don't seem to hurt echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu2/governor # GPU echo "performance" > /sys/class/devfreq/b00000.qcom,kgsl-3d0/governor # /sys/class/devfreq/soc:qcom,mincpubw is the only one left at "powersave" # it seems to gain nothing but a wasted 500mW # *** set up IRQ affinities *** # Collect RIL and other possibly long-running I/O interrupts onto CPU 1 echo 1 > /proc/irq/78/smp_affinity_list # qcom,smd-modem (LTE radio) echo 1 > /proc/irq/33/smp_affinity_list # ufshcd (flash storage) echo 1 > /proc/irq/35/smp_affinity_list # wifi (wlan_pci) echo 1 > /proc/irq/6/smp_affinity_list # MDSS # USB traffic needs realtime handling on cpu 3 [ -d "/proc/irq/733" ] && echo 3 > /proc/irq/733/smp_affinity_list if [ -f /ONEPLUS ]; then [ -d "/proc/irq/736" ] && echo 3 > /proc/irq/736/smp_affinity_list # USB for OP3T fi # GPU and camera get cpu 2 CAM_IRQS="177 178 179 180 181 182 183 184 185 186 192" for irq in $CAM_IRQS; do echo 2 > /proc/irq/$irq/smp_affinity_list done echo 2 > /proc/irq/193/smp_affinity_list # GPU # give GPU threads RT priority for pid in $(pgrep "kgsl"); do chrt -f -p 52 $pid done # the flippening! LD_LIBRARY_PATH="" content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1 # disable bluetooth service call bluetooth_manager 8 # wifi scan wpa_cli IFNAME=wlan0 SCAN # Check for NEOS update if [ -f /LEECO ]; then if [ $(< /VERSION) != "$REQUIRED_NEOS_VERSION" ]; then if [ -f "$DIR/scripts/continue.sh" ]; then cp "$DIR/scripts/continue.sh" "/data/data/com.termux/files/continue.sh" fi if [ ! -f "$BASEDIR/prebuilt" ]; then # Clean old build products, but preserve the scons cache cd $DIR git clean -xdf git submodule foreach --recursive git clean -xdf fi "$DIR/installer/updater/updater" "file://$DIR/installer/updater/update.json" fi fi # One-time fix for a subset of OP3T with gyro orientation offsets. # Remove and regenerate qcom sensor registry. Only done on OP3T mainboards. # Performed exactly once. The old registry is preserved just-in-case, and # doubles as a flag denoting we've already done the reset. if [ -f /ONEPLUS ] && [ ! -f "/persist/comma/op3t-sns-reg-backup" ]; then echo "Performing OP3T sensor registry reset" mv /persist/sensors/sns.reg /persist/comma/op3t-sns-reg-backup && rm -f /persist/sensors/sensors_settings /persist/sensors/error_log /persist/sensors/gyro_sensitity_cal && echo "restart" > /sys/kernel/debug/msm_subsys/slpi && sleep 5 # Give Android sensor subsystem a moment to recover fi } function tici_init { # wait longer for weston to come up if [ -f "$BASEDIR/prebuilt" ]; then sleep 3 fi # setup governors sudo su -c 'echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu0/governor' sudo su -c 'echo "performance" > /sys/class/devfreq/soc:qcom,memlat-cpu4/governor' # TODO: move this to agnos # network manager config nmcli connection modify --temporary lte gsm.auto-config yes nmcli connection modify --temporary lte gsm.home-only yes sudo rm -f /data/etc/NetworkManager/system-connections/*.nmmeta # set success flag for current boot slot sudo abctl --set_success # Check if AGNOS update is required if [ $(< /VERSION) != "$AGNOS_VERSION" ]; then AGNOS_PY="$DIR/selfdrive/hardware/tici/agnos.py" MANIFEST="$DIR/selfdrive/hardware/tici/agnos.json" if $AGNOS_PY --verify $MANIFEST; then sudo reboot fi $DIR/selfdrive/hardware/tici/updater $AGNOS_PY $MANIFEST fi } # jetpack 4.6 function jetson_init { # jetpack 4.6 has mode 8 sudo nvpmodel -m 8 # use performance governor sudo echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor # run higher fan speed in case we need compilation sudo echo 200 > /sys/devices/pwm-fan/target_pwm # prevent throttling echo 7000 > /sys/devices/c250000.i2c/i2c-7/7-0040/iio:device0/crit_current_limit_0 # use highest available cpu freq for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; do echo 1907200 > $i; done # gpu min set to highest sudo echo 1109250000 > /sys/devices/17000000.gv11b/devfreq/17000000.gv11b/min_freq # set IO scheduler for f in /sys/block/*/queue/scheduler; do echo noop > $f done # give nvargus-daemon higer priority for pid in $(pgrep "nvargus-daemon"); do chrt -f -p 52 $pid done # scale 4.3" 800x480 to 1920x1080 if [ "$(xdpyinfo | awk '/dimensions/{print $2}')" == "800x480" ]; then xrandr --output HDMI-0 --mode 800x480 --scale 2.4x2.25 fi # enable jetson mode echo -n 1 > /data/params/d/dp_jetson # disable blank screen etc. xset s off xset s noblank xset -dpms # hide mouse cursor unclutter -idle 0 & } function launch { # Remove orphaned git lock if it exists on boot [ -f "$DIR/.git/index.lock" ] && rm -f $DIR/.git/index.lock # Pull time from panda $DIR/selfdrive/boardd/set_time.py # Check to see if there's a valid overlay-based update available. Conditions # are as follows: # # 1. The BASEDIR init file has to exist, with a newer modtime than anything in # the BASEDIR Git repo. This checks for local development work or the user # switching branches/forks, which should not be overwritten. # 2. The FINALIZED consistent file has to exist, indicating there's an update # that completed successfully and synced to disk. if [ -f "${BASEDIR}/.overlay_init" ]; then # find ${BASEDIR}/.git -newer ${BASEDIR}/.overlay_init | grep -q '.' 2> /dev/null # if [ $? -eq 0 ]; then # echo "${BASEDIR} has been modified, skipping overlay update installation" # else if [ -f "${STAGING_ROOT}/finalized/.overlay_consistent" ]; then if [ ! -d /data/safe_staging/old_openpilot ]; then echo "Valid overlay update found, installing" LAUNCHER_LOCATION="${BASH_SOURCE[0]}" mv $BASEDIR /data/safe_staging/old_openpilot mv "${STAGING_ROOT}/finalized" $BASEDIR cd $BASEDIR # Partial mitigation for symlink-related filesystem corruption # Ensure all files match the repo versions after update git reset --hard git submodule foreach --recursive git reset --hard echo "Restarting launch script ${LAUNCHER_LOCATION}" unset REQUIRED_NEOS_VERSION unset AGNOS_VERSION exec "${LAUNCHER_LOCATION}" else echo "openpilot backup found, not updating" # TODO: restore backup? This means the updater didn't start after swapping fi fi # fi fi # handle pythonpath ln -sfn $(pwd) /data/pythonpath export PYTHONPATH="$PWD:$PWD/pyextra" # dp - ignore chmod changes git -C $DIR config core.fileMode false # dp - apply custom patch if [ -f "/data/media/0/dp_patcher.py" ]; then python /data/media/0/dp_patcher.py fi # hardware specific init if [ -f /EON ]; then two_init elif [ -f /TICI ]; then tici_init elif [ -f /JETSON ]; then jetson_init # make sure we have right models if [ ! -f "$DIR/models/supercombo.onnx" ]; then rm -fr $DIR/models/*.dlc wget https://github.com/commaai/openpilot/raw/72a736f90e57a7d5845891ea34b17360b6f684d0/models/supercombo.onnx -O "$DIR/models/supercombo.onnx" fi fi # write tmux scrollback to a file tmux capture-pane -pq -S-1000 > /tmp/launch_log # start manager cd selfdrive/manager if [ -f /EON ]; then if [ ! -f "/system/comma/usr/lib/libgfortran.so.5.0.0" ]; then mount -o remount,rw /system tar -zxvf /data/openpilot/selfdrive/mapd/assets/libgfortran.tar.gz -C /system/comma/usr/lib/ mount -o remount,r /system fi if [ ! -d "/system/comma/usr/lib/python3.8/site-packages/opspline" ]; then mount -o remount,rw /system tar -zxvf /data/openpilot/selfdrive/mapd/assets/opspline.tar.gz -C /system/comma/usr/lib/python3.8/site-packages/ mount -o remount,r /system fi ./build.py && ./manager.py elif [ -f /JETSON ]; then ./build.py && ./manager.py else ./custom_dep.py && ./build.py && ./manager.py fi # if broken, keep on screen error while true; do sleep 1; done } launch ================================================ FILE: launch_env.sh ================================================ #!/usr/bin/bash export OMP_NUM_THREADS=1 export MKL_NUM_THREADS=1 export NUMEXPR_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 export VECLIB_MAXIMUM_THREADS=1 if [ -z "$REQUIRED_NEOS_VERSION" ]; then export REQUIRED_NEOS_VERSION="18" fi if [ -z "$AGNOS_VERSION" ]; then export AGNOS_VERSION="1.5" fi if [ -z "$PASSIVE" ]; then export PASSIVE="1" fi export STAGING_ROOT="/data/safe_staging" ================================================ FILE: launch_openpilot.sh ================================================ #!/usr/bin/bash size=$(du -sb .git/index 2>/dev/null|awk '{print $1}') echo $size|grep -E '^[0-9]+$' >/dev/null || size=0 if [ $size -le 1024 ];then rm .git/index 2>/dev/null git reset fi export PASSIVE="0" exec ./launch_chffrplus.sh ================================================ FILE: models/supercombo.onnx ================================================ [File too large to display: 54.1 MB] ================================================ FILE: opendbc/.gitignore ================================================ .mypy_cache/ *.pyc *.os *.o *.tmp *.dylib .*.swp .DS_Store .sconsign.dblite can/*.so can/build/ can/obj/ can/packer_pyx.cpp can/parser_pyx.cpp can/packer_pyx.html can/parser_pyx.html ================================================ FILE: opendbc/__init__.py ================================================ import os DBC_PATH = os.path.dirname(os.path.abspath(__file__)) ================================================ FILE: opendbc/acura_ilx_2016_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "acura_ilx_2016_can.dbc starts here"; BO_ 145 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON BO_ 228 STEERING_CONTROL: 5 ADAS SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 419 GEARBOX: 8 PCM SG_ GEAR : 7|8@0+ (1,0) [0|256] "" EON SG_ GEAR_SHIFTER : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON CM_ SG_ 419 GEAR "10 = reverse, 11 = transition"; CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 419 GEAR_SHIFTER 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 780 HUD_LEAD 3 "no_car" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/acura_ilx_2016_nidec.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: ADAS RADAR NEO XXX BO_ 768 VEHICLE_STATE: 8 ADAS SG_ SET_ME_XF9 : 7|8@0+ (1,0) [0|255] "" Vector__XXX SG_ VEHICLE_SPEED : 15|8@0+ (1,0) [0|255] "kph" Vector__XXX BO_ 769 VEHICLE_STATE2: 8 ADAS SG_ SET_ME_0F18510 : 7|28@0+ (1,0) [0|268435455] "" Vector__XXX SG_ SET_ME_25A0000 : 27|28@0+ (1,0) [0|268435455] "" Vector__XXX BO_ 1024 RADAR_DIAGNOSTIC: 8 RADAR SG_ RADAR_STATE : 7|8@0+ (1,0) [0|255] "" NEO BO_ 1040 XXX_101: 8 RADAR BO_ 1041 XXX_102: 8 RADAR BO_ 1042 XXX_103: 8 RADAR BO_ 1043 XXX_104: 8 RADAR BO_ 1044 XXX_105: 8 RADAR BO_ 1045 XXX_106: 8 RADAR BO_ 1046 XXX_107: 8 RADAR BO_ 1047 XXX_108: 8 RADAR BO_ 1056 XXX_109: 8 RADAR BO_ 1057 XXX_110: 8 RADAR BO_ 1058 XXX_111: 8 RADAR BO_ 1059 XXX_112: 8 RADAR BO_ 1060 XXX_113: 8 RADAR BO_ 1072 TRACK_0: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1073 TRACK_1: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1074 TRACK_2: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1075 TRACK_3: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1076 TRACK_4: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1077 TRACK_5: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1078 TRACK_6: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1079 TRACK_7: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1080 TRACK_8: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1081 TRACK_9: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1088 TRACK_10: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1089 TRACK_11: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1090 TRACK_12: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1091 TRACK_13: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1092 TRACK_14: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1093 TRACK_15: 8 RADAR SG_ LONG_DIST : 7|12@0+ (0.0625,0) [0|255.5] "m" NEO SG_ NEW_TRACK : 11|1@0+ (1,0) [0|1] "" NEO SG_ LAT_DIST : 9|10@0- (0.0625,0) [0|63.5] "m" NEO SG_ REL_SPEED : 31|12@0- (0.03125,0) [0|127.5] "m/s" NEO BO_ 1279 XXX_114: 8 RADAR BO_ 1280 XXX_115: 8 RADAR BO_ 1296 XXX_116: 8 RADAR BO_ 1297 XXX_117: 8 RADAR BO_TX_BU_ 768 : NEO,ADAS; BO_TX_BU_ 769 : NEO,ADAS; CM_ SG_ 1024 RADAR_STATE "need to find out more diagnostic values"; VAL_ 1024 RADAR_STATE 121 "ok" 110 "faulted" 105 "wrong_config"; ================================================ FILE: opendbc/acura_rdx_2018_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "acura_rdx_2018_can.dbc starts here"; BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 392 GEARBOX: 6 XXX SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" XXX SG_ GEAR_SHIFTER : 27|4@0+ (1,0) [0|15] "" EON SG_ GEAR : 36|5@0+ (1,0) [0|31] "" EON BO_ 399 STEER_STATUS: 6 EPS SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 404 STEERING_CONTROL: 4 EON SG_ STEER_TORQUE : 7|12@0- (1,0) [-768|768] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ PARKING_BRAKE_LIGHT : 2|1@0+ (1,0) [0|1] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 487 BRAKE_PRESSURE: 4 VSA SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON CM_ SG_ 422 PARKING_BRAKE_LIGHT "Believe this is just the dash light for the parking break"; VAL_ 392 GEAR_SHIFTER 0 "S" 1 "P" 2 "R" 4 "N" 8 "D" ; VAL_ 392 GEAR 26 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/acura_rdx_2020_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2020.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "acura_rdx_2020_can.dbc starts here"; BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 446 BRAKE_MODULE: 3 VSA SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX SG_ BOH_2 : 30|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/can/SConscript ================================================ Import('env', 'envCython', 'cereal') import os from opendbc.can.process_dbc import process dbcs = [] for x in sorted(os.listdir('../')): if x.endswith(".dbc"): def compile_dbc(target, source, env): process(source[0].path, target[0].path) in_fn = [os.path.join('../', x), 'dbc_template.cc'] out_fn = os.path.join('dbc_out', x.replace(".dbc", ".cc")) dbc = env.Command(out_fn, in_fn, compile_dbc) dbcs.append(dbc) libdbc = env.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]+dbcs, LIBS=["capnp", "kj"]) # Build packer and parser lenv = envCython.Clone() lenv["LINKFLAGS"] += [libdbc[0].get_labspath()] parser = lenv.Program('parser_pyx.so', 'parser_pyx.pyx') packer = lenv.Program('packer_pyx.so', 'packer_pyx.pyx') lenv.Depends(parser, libdbc) lenv.Depends(packer, libdbc) ================================================ FILE: opendbc/can/__init__.py ================================================ ================================================ FILE: opendbc/can/can_define.py ================================================ from opendbc.can.parser_pyx import CANDefine # pylint: disable=no-name-in-module, import-error assert CANDefine ================================================ FILE: opendbc/can/common.cc ================================================ #include "common.h" unsigned int honda_checksum(unsigned int address, uint64_t d, int l) { d >>= ((8-l)*8); // remove padding d >>= 4; // remove checksum int s = 0; bool extended = address > 0x7FF; // extended can while (address) { s += (address & 0xF); address >>= 4; } while (d) { s += (d & 0xF); d >>= 4; } s = 8-s; if (extended) s += 3; s &= 0xF; return s; } unsigned int toyota_checksum(unsigned int address, uint64_t d, int l) { d >>= ((8-l)*8); // remove padding d >>= 8; // remove checksum unsigned int s = l; while (address) { s += address & 0xFF; address >>= 8; } while (d) { s += d & 0xFF; d >>= 8; } return s & 0xFF; } unsigned int subaru_checksum(unsigned int address, uint64_t d, int l) { d >>= ((8-l)*8); // remove padding unsigned int s = 0; while (address) { s += address & 0xFF; address >>= 8; } l -= 1; // checksum is first byte while (l) { s += d & 0xFF; d >>= 8; l -= 1; } return s & 0xFF; } unsigned int chrysler_checksum(unsigned int address, uint64_t d, int l) { /* This function does not want the checksum byte in the input data. jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf */ uint8_t checksum = 0xFF; for (int j = 0; j < (l - 1); j++) { uint8_t shift = 0x80; uint8_t curr = (d >> 8*j) & 0xFF; for (int i=0; i<8; i++) { uint8_t bit_sum = curr & shift; uint8_t temp_chk = checksum & 0x80U; if (bit_sum != 0U) { bit_sum = 0x1C; if (temp_chk != 0U) { bit_sum = 1; } checksum = checksum << 1; temp_chk = checksum | 1U; bit_sum ^= temp_chk; } else { if (temp_chk != 0U) { bit_sum = 0x1D; } checksum = checksum << 1; bit_sum ^= checksum; } checksum = bit_sum; shift = shift >> 1; } } return ~checksum & 0xFF; } // Static lookup table for fast computation of CRC8 poly 0x2F, aka 8H2F/AUTOSAR uint8_t crc8_lut_8h2f[256]; void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]) { uint8_t crc; int i, j; for (i = 0; i < 256; i++) { crc = i; for (j = 0; j < 8; j++) { if ((crc & 0x80) != 0) crc = (uint8_t)((crc << 1) ^ poly); else crc <<= 1; } crc_lut[i] = crc; } } void init_crc_lookup_tables() { // At init time, set up static lookup tables for fast CRC computation. gen_crc_lookup_table(0x2F, crc8_lut_8h2f); // CRC-8 8H2F/AUTOSAR for Volkswagen } unsigned int volkswagen_crc(unsigned int address, uint64_t d, int l) { // Volkswagen uses standard CRC8 8H2F/AUTOSAR, but they compute it with // a magic variable padding byte tacked onto the end of the payload. // https://www.autosar.org/fileadmin/user_upload/standards/classic/4-3/AUTOSAR_SWS_CRCLibrary.pdf uint8_t crc = 0xFF; // Standard init value for CRC8 8H2F/AUTOSAR // CRC the payload first, skipping over the first byte where the CRC lives. for (int i = 1; i < l; i++) { crc ^= (d >> (i*8)) & 0xFF; crc = crc8_lut_8h2f[crc]; } // Look up and apply the magic final CRC padding byte, which permutes by CAN // address, and additionally (for SOME addresses) by the message counter. uint8_t counter = ((d >> 8) & 0xFF) & 0x0F; switch(address) { case 0x86: // LWI_01 Steering Angle crc ^= (uint8_t[]){0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86,0x86}[counter]; break; case 0x9F: // LH_EPS_03 Electric Power Steering crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter]; break; case 0xAD: // Getriebe_11 Automatic Gearbox crc ^= (uint8_t[]){0x3F,0x69,0x39,0xDC,0x94,0xF9,0x14,0x64,0xD8,0x6A,0x34,0xCE,0xA2,0x55,0xB5,0x2C}[counter]; break; case 0xFD: // ESP_21 Electronic Stability Program crc ^= (uint8_t[]){0xB4,0xEF,0xF8,0x49,0x1E,0xE5,0xC2,0xC0,0x97,0x19,0x3C,0xC9,0xF1,0x98,0xD6,0x61}[counter]; break; case 0x106: // ESP_05 Electronic Stability Program crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter]; break; case 0x117: // ACC_10 Automatic Cruise Control crc ^= (uint8_t[]){0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16}[counter]; break; case 0x120: // TSK_06 Drivetrain Coordinator crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter]; break; case 0x121: // Motor_20 Driver Throttle Inputs crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter]; break; case 0x122: // ACC_06 Automatic Cruise Control crc ^= (uint8_t[]){0x37,0x7D,0xF3,0xA9,0x18,0x46,0x6D,0x4D,0x3D,0x71,0x92,0x9C,0xE5,0x32,0x10,0xB9}[counter]; break; case 0x126: // HCA_01 Heading Control Assist crc ^= (uint8_t[]){0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA,0xDA}[counter]; break; case 0x12B: // GRA_ACC_01 Steering wheel controls for ACC crc ^= (uint8_t[]){0x6A,0x38,0xB4,0x27,0x22,0xEF,0xE1,0xBB,0xF8,0x80,0x84,0x49,0xC7,0x9E,0x1E,0x2B}[counter]; break; case 0x187: // EV_Gearshift "Gear" selection data for EVs with no gearbox crc ^= (uint8_t[]){0x7F,0xED,0x17,0xC2,0x7C,0xEB,0x44,0x21,0x01,0xFA,0xDB,0x15,0x4A,0x6B,0x23,0x05}[counter]; break; case 0x30C: // ACC_02 Automatic Cruise Control crc ^= (uint8_t[]){0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F}[counter]; break; case 0x30F: // SWA_01 Lane Change Assist (SpurWechselAssistent) crc ^= (uint8_t[]){0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C}[counter]; break; case 0x324: // ACC_04 Automatic Cruise Control crc ^= (uint8_t[]){0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27}[counter]; break; case 0x3C0: // Klemmen_Status_01 ignition and starting status crc ^= (uint8_t[]){0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3,0xC3}[counter]; break; case 0x65D: // ESP_20 Electronic Stability Program crc ^= (uint8_t[]){0xAC,0xB3,0xAB,0xEB,0x7A,0xE1,0x3B,0xF7,0x73,0xBA,0x7C,0x9E,0x06,0x5F,0x02,0xD9}[counter]; break; default: // As-yet undefined CAN message, CRC check expected to fail printf("Attempt to CRC check undefined Volkswagen message 0x%02X\n", address); crc ^= (uint8_t[]){0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}[counter]; break; } crc = crc8_lut_8h2f[crc]; return crc ^ 0xFF; // Return after standard final XOR for CRC8 8H2F/AUTOSAR } unsigned int pedal_checksum(uint64_t d, int l) { uint8_t crc = 0xFF; uint8_t poly = 0xD5; // standard crc8 d >>= ((8-l)*8); // remove padding d >>= 8; // remove checksum int i, j; for (i = 0; i < l - 1; i++) { crc ^= (d >> (i*8)) & 0xFF; for (j = 0; j < 8; j++) { if ((crc & 0x80) != 0) { crc = (uint8_t)((crc << 1) ^ poly); } else { crc <<= 1; } } } return crc; } uint64_t read_u64_be(const uint8_t* v) { return (((uint64_t)v[0] << 56) | ((uint64_t)v[1] << 48) | ((uint64_t)v[2] << 40) | ((uint64_t)v[3] << 32) | ((uint64_t)v[4] << 24) | ((uint64_t)v[5] << 16) | ((uint64_t)v[6] << 8) | (uint64_t)v[7]); } uint64_t read_u64_le(const uint8_t* v) { return ((uint64_t)v[0] | ((uint64_t)v[1] << 8) | ((uint64_t)v[2] << 16) | ((uint64_t)v[3] << 24) | ((uint64_t)v[4] << 32) | ((uint64_t)v[5] << 40) | ((uint64_t)v[6] << 48) | ((uint64_t)v[7] << 56)); } ================================================ FILE: opendbc/can/common.h ================================================ #pragma once #include #include #include #include "common_dbc.h" #include #include #ifndef DYNAMIC_CAPNP #include "cereal/gen/cpp/log.capnp.h" #endif #define MAX_BAD_COUNTER 5 // Helper functions unsigned int honda_checksum(unsigned int address, uint64_t d, int l); unsigned int toyota_checksum(unsigned int address, uint64_t d, int l); unsigned int subaru_checksum(unsigned int address, uint64_t d, int l); unsigned int chrysler_checksum(unsigned int address, uint64_t d, int l); void init_crc_lookup_tables(); unsigned int volkswagen_crc(unsigned int address, uint64_t d, int l); unsigned int pedal_checksum(uint64_t d, int l); uint64_t read_u64_be(const uint8_t* v); uint64_t read_u64_le(const uint8_t* v); class MessageState { public: uint32_t address; unsigned int size; std::vector parse_sigs; std::vector vals; uint16_t ts; uint64_t seen; uint64_t check_threshold; uint8_t counter; uint8_t counter_fail; bool ignore_checksum = false; bool ignore_counter = false; bool parse(uint64_t sec, uint16_t ts_, uint8_t * dat); bool update_counter_generic(int64_t v, int cnt_size); }; class CANParser { private: const int bus; kj::Array aligned_buf; const DBC *dbc = NULL; std::unordered_map message_states; public: bool can_valid = false; uint64_t last_sec = 0; CANParser(int abus, const std::string& dbc_name, const std::vector &options, const std::vector &sigoptions); CANParser(int abus, const std::string& dbc_name, bool ignore_checksum, bool ignore_counter); #ifndef DYNAMIC_CAPNP void update_string(const std::string &data, bool sendcan); void UpdateCans(uint64_t sec, const capnp::List::Reader& cans); #endif void UpdateCans(uint64_t sec, const capnp::DynamicStruct::Reader& cans); void UpdateValid(uint64_t sec); std::vector query_latest(); }; class CANPacker { private: const DBC *dbc = NULL; std::map, Signal> signal_lookup; std::map message_lookup; public: CANPacker(const std::string& dbc_name); uint64_t pack(uint32_t address, const std::vector &values, int counter); Msg* lookup_message(uint32_t address); }; ================================================ FILE: opendbc/can/common.pxd ================================================ # distutils: language = c++ #cython: language_level=3 from libc.stdint cimport uint32_t, uint64_t, uint16_t from libcpp.vector cimport vector from libcpp.map cimport map from libcpp.string cimport string from libcpp.unordered_set cimport unordered_set from libcpp cimport bool cdef extern from "common_dbc.h": ctypedef enum SignalType: DEFAULT, HONDA_CHECKSUM, HONDA_COUNTER, TOYOTA_CHECKSUM, PEDAL_CHECKSUM, PEDAL_COUNTER, VOLKSWAGEN_CHECKSUM, VOLKSWAGEN_COUNTER, SUBARU_CHECKSUM, CHRYSLER_CHECKSUM cdef struct Signal: const char* name int b1, b2, bo bool is_signed double factor, offset SignalType type cdef struct Msg: const char* name uint32_t address unsigned int size size_t num_sigs const Signal *sigs cdef struct Val: const char* name uint32_t address const char* def_val const Signal *sigs cdef struct DBC: const char* name size_t num_msgs const Msg *msgs const Val *vals size_t num_vals cdef struct SignalParseOptions: uint32_t address const char* name double default_value cdef struct MessageParseOptions: uint32_t address int check_frequency cdef struct SignalValue: uint32_t address uint16_t ts const char* name double value cdef struct SignalPackValue: string name double value cdef extern from "common.h": cdef const DBC* dbc_lookup(const string); cdef cppclass CANParser: bool can_valid CANParser(int, string, vector[MessageParseOptions], vector[SignalParseOptions]) void update_string(string, bool) vector[SignalValue] query_latest() cdef cppclass CANPacker: CANPacker(string) uint64_t pack(uint32_t, vector[SignalPackValue], int counter) ================================================ FILE: opendbc/can/common_dbc.h ================================================ #pragma once #include #include #include #include #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) struct SignalPackValue { std::string name; double value; }; struct SignalParseOptions { uint32_t address; const char* name; double default_value; }; struct MessageParseOptions { uint32_t address; int check_frequency; }; struct SignalValue { uint32_t address; uint16_t ts; const char* name; double value; }; enum SignalType { DEFAULT, HONDA_CHECKSUM, HONDA_COUNTER, TOYOTA_CHECKSUM, PEDAL_CHECKSUM, PEDAL_COUNTER, VOLKSWAGEN_CHECKSUM, VOLKSWAGEN_COUNTER, SUBARU_CHECKSUM, CHRYSLER_CHECKSUM, }; struct Signal { const char* name; int b1, b2, bo; bool is_signed; double factor, offset; bool is_little_endian; SignalType type; }; struct Msg { const char* name; uint32_t address; unsigned int size; size_t num_sigs; const Signal *sigs; }; struct Val { const char* name; uint32_t address; const char* def_val; const Signal *sigs; }; struct DBC { const char* name; size_t num_msgs; const Msg *msgs; const Val *vals; size_t num_vals; }; std::vector& get_dbcs(); const DBC* dbc_lookup(const std::string& dbc_name); void dbc_register(const DBC* dbc); #define dbc_init(dbc) \ static void __attribute__((constructor)) do_dbc_init_ ## dbc(void) { \ dbc_register(&dbc); \ } ================================================ FILE: opendbc/can/dbc.cc ================================================ #include #include "common_dbc.h" std::vector& get_dbcs() { static std::vector vec; return vec; } const DBC* dbc_lookup(const std::string& dbc_name) { for (const auto& dbci : get_dbcs()) { if (dbc_name == dbci->name) { return dbci; } } return NULL; } void dbc_register(const DBC* dbc) { get_dbcs().push_back(dbc); } extern "C" { const DBC* dbc_lookup(const char* dbc_name) { return dbc_lookup(std::string(dbc_name)); } } ================================================ FILE: opendbc/can/dbc.py ================================================ import re import os import struct import sys import numbers from collections import namedtuple, defaultdict def int_or_float(s): # return number, trying to maintain int format if s.isdigit(): return int(s, 10) else: return float(s) DBCSignal = namedtuple( "DBCSignal", ["name", "start_bit", "size", "is_little_endian", "is_signed", "factor", "offset", "tmin", "tmax", "units"]) class dbc(): def __init__(self, fn): self.name, _ = os.path.splitext(os.path.basename(fn)) with open(fn, encoding="ascii") as f: self.txt = f.readlines() self._warned_addresses = set() # regexps from https://github.com/ebroecker/canmatrix/blob/master/canmatrix/importdbc.py bo_regexp = re.compile(r"^BO\_ (\w+) (\w+) *: (\w+) (\w+)") sg_regexp = re.compile(r"^SG\_ (\w+) : (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*)") sgm_regexp = re.compile(r"^SG\_ (\w+) (\w+) *: (\d+)\|(\d+)@(\d+)([\+|\-]) \(([0-9.+\-eE]+),([0-9.+\-eE]+)\) \[([0-9.+\-eE]+)\|([0-9.+\-eE]+)\] \"(.*)\" (.*)") val_regexp = re.compile(r"VAL\_ (\w+) (\w+) (\s*[-+]?[0-9]+\s+\".+?\"[^;]*)") # A dictionary which maps message ids to tuples ((name, size), signals). # name is the ASCII name of the message. # size is the size of the message in bytes. # signals is a list signals contained in the message. # signals is a list of DBCSignal in order of increasing start_bit. self.msgs = {} # A dictionary which maps message ids to a list of tuples (signal name, definition value pairs) self.def_vals = defaultdict(list) # lookup to bit reverse each byte self.bits_index = [(i & ~0b111) + ((-i - 1) & 0b111) for i in range(64)] for l in self.txt: l = l.strip() if l.startswith("BO_ "): # new group dat = bo_regexp.match(l) if dat is None: print("bad BO {0}".format(l)) name = dat.group(2) size = int(dat.group(3)) ids = int(dat.group(1), 0) # could be hex if ids in self.msgs: sys.exit("Duplicate address detected %d %s" % (ids, self.name)) self.msgs[ids] = ((name, size), []) if l.startswith("SG_ "): # new signal dat = sg_regexp.match(l) go = 0 if dat is None: dat = sgm_regexp.match(l) go = 1 if dat is None: print("bad SG {0}".format(l)) sgname = dat.group(1) start_bit = int(dat.group(go + 2)) signal_size = int(dat.group(go + 3)) is_little_endian = int(dat.group(go + 4)) == 1 is_signed = dat.group(go + 5) == '-' factor = int_or_float(dat.group(go + 6)) offset = int_or_float(dat.group(go + 7)) tmin = int_or_float(dat.group(go + 8)) tmax = int_or_float(dat.group(go + 9)) units = dat.group(go + 10) self.msgs[ids][1].append( DBCSignal(sgname, start_bit, signal_size, is_little_endian, is_signed, factor, offset, tmin, tmax, units)) if l.startswith("VAL_ "): # new signal value/definition dat = val_regexp.match(l) if dat is None: print("bad VAL {0}".format(l)) ids = int(dat.group(1), 0) # could be hex sgname = dat.group(2) defvals = dat.group(3) defvals = defvals.replace("?", r"\?") # escape sequence in C++ defvals = defvals.split('"')[:-1] # convert strings to UPPER_CASE_WITH_UNDERSCORES defvals[1::2] = [d.strip().upper().replace(" ", "_") for d in defvals[1::2]] defvals = '"' + "".join(str(i) for i in defvals) + '"' self.def_vals[ids].append((sgname, defvals)) for msg in self.msgs.values(): msg[1].sort(key=lambda x: x.start_bit) self.msg_name_to_address = {} for address, m in self.msgs.items(): name = m[0][0] self.msg_name_to_address[name] = address def lookup_msg_id(self, msg_id): if not isinstance(msg_id, numbers.Number): msg_id = self.msg_name_to_address[msg_id] return msg_id def reverse_bytes(self, x): return ((x & 0xff00000000000000) >> 56) | \ ((x & 0x00ff000000000000) >> 40) | \ ((x & 0x0000ff0000000000) >> 24) | \ ((x & 0x000000ff00000000) >> 8) | \ ((x & 0x00000000ff000000) << 8) | \ ((x & 0x0000000000ff0000) << 24) | \ ((x & 0x000000000000ff00) << 40) | \ ((x & 0x00000000000000ff) << 56) def encode(self, msg_id, dd): """Encode a CAN message using the dbc. Inputs: msg_id: The message ID. dd: A dictionary mapping signal name to signal data. """ msg_id = self.lookup_msg_id(msg_id) msg_def = self.msgs[msg_id] size = msg_def[0][1] result = 0 for s in msg_def[1]: ival = dd.get(s.name) if ival is not None: ival = (ival / s.factor) - s.offset ival = int(round(ival)) if s.is_signed and ival < 0: ival = (1 << s.size) + ival if s.is_little_endian: shift = s.start_bit else: b1 = (s.start_bit // 8) * 8 + (-s.start_bit - 1) % 8 shift = 64 - (b1 + s.size) mask = ((1 << s.size) - 1) << shift dat = (ival & ((1 << s.size) - 1)) << shift if s.is_little_endian: mask = self.reverse_bytes(mask) dat = self.reverse_bytes(dat) result &= ~mask result |= dat result = struct.pack('>Q', result) return result[:size] def decode(self, x, arr=None, debug=False): """Decode a CAN message using the dbc. Inputs: x: A collection with elements (address, time, data), where address is the CAN address, time is the bus time, and data is the CAN data as a hex string. arr: Optional list of signals which should be decoded and returned. debug: True to print debugging statements. Returns: A tuple (name, data), where name is the name of the CAN message and data is the decoded result. If arr is None, data is a dict of properties. Otherwise data is a list of the same length as arr. Returns (None, None) if the message could not be decoded. """ if arr is None: out = {} else: out = [None] * len(arr) msg = self.msgs.get(x[0]) if msg is None: if x[0] not in self._warned_addresses: # print("WARNING: Unknown message address {}".format(x[0])) self._warned_addresses.add(x[0]) return None, None name = msg[0][0] if debug: print(name) st = x[2].ljust(8, b'\x00') le, be = None, None for s in msg[1]: if arr is not None and s[0] not in arr: continue start_bit = s[1] signal_size = s[2] little_endian = s[3] signed = s[4] factor = s[5] offset = s[6] if little_endian: if le is None: le = struct.unpack("Q", st)[0] tmp = be b1 = (start_bit // 8) * 8 + (-start_bit - 1) % 8 shift_amount = 64 - (b1 + signal_size) if shift_amount < 0: continue tmp = (tmp >> shift_amount) & ((1 << signal_size) - 1) if signed and (tmp >> (signal_size - 1)): tmp -= (1 << signal_size) tmp = tmp * factor + offset # if debug: # print("%40s %2d %2d %7.2f %s" % (s[0], s[1], s[2], tmp, s[-1])) if arr is None: out[s[0]] = tmp else: out[arr.index(s[0])] = tmp return name, out def get_signals(self, msg): msg = self.lookup_msg_id(msg) return [sgs.name for sgs in self.msgs[msg][1]] if __name__ == "__main__": from opendbc import DBC_PATH dbc_test = dbc(os.path.join(DBC_PATH, 'toyota_prius_2017_pt_generated.dbc')) msg = ('STEER_ANGLE_SENSOR', {'STEER_ANGLE': -6.0, 'STEER_RATE': 4, 'STEER_FRACTION': -0.2}) encoded = dbc_test.encode(*msg) decoded = dbc_test.decode((0x25, 0, encoded)) assert decoded == msg dbc_test = dbc(os.path.join(DBC_PATH, 'hyundai_santa_fe_2019_ccan.dbc')) decoded = dbc_test.decode((0x2b0, 0, "\xfa\xfe\x00\x07\x12")) assert abs(decoded[1]['SAS_Angle'] - (-26.2)) < 0.001 msg = ('SAS11', {'SAS_Stat': 7.0, 'MsgCount': 0.0, 'SAS_Angle': -26.200000000000003, 'SAS_Speed': 0.0, 'CheckSum': 0.0}) encoded = dbc_test.encode(*msg) decoded = dbc_test.decode((0x2b0, 0, encoded)) assert decoded == msg ================================================ FILE: opendbc/can/dbc_out/.gitignore ================================================ *.cc ================================================ FILE: opendbc/can/dbc_out/.gitkeep ================================================ ================================================ FILE: opendbc/can/dbc_template.cc ================================================ #include "common_dbc.h" namespace { {% for address, msg_name, msg_size, sigs in msgs %} const Signal sigs_{{address}}[] = { {% for sig in sigs %} { {% if sig.is_little_endian %} {% set b1 = sig.start_bit %} {% else %} {% set b1 = (sig.start_bit//8)*8 + (-sig.start_bit-1) % 8 %} {% endif %} .name = "{{sig.name}}", .b1 = {{b1}}, .b2 = {{sig.size}}, .bo = {{64 - (b1 + sig.size)}}, .is_signed = {{"true" if sig.is_signed else "false"}}, .factor = {{sig.factor}}, .offset = {{sig.offset}}, .is_little_endian = {{"true" if sig.is_little_endian else "false"}}, {% if checksum_type == "honda" and sig.name == "CHECKSUM" %} .type = SignalType::HONDA_CHECKSUM, {% elif checksum_type == "honda" and sig.name == "COUNTER" %} .type = SignalType::HONDA_COUNTER, {% elif checksum_type == "toyota" and sig.name == "CHECKSUM" %} .type = SignalType::TOYOTA_CHECKSUM, {% elif checksum_type == "volkswagen" and sig.name == "CHECKSUM" %} .type = SignalType::VOLKSWAGEN_CHECKSUM, {% elif checksum_type == "volkswagen" and sig.name == "COUNTER" %} .type = SignalType::VOLKSWAGEN_COUNTER, {% elif checksum_type == "subaru" and sig.name == "CHECKSUM" %} .type = SignalType::SUBARU_CHECKSUM, {% elif checksum_type == "chrysler" and sig.name == "CHECKSUM" %} .type = SignalType::CHRYSLER_CHECKSUM, {% elif address in [512, 513] and sig.name == "CHECKSUM_PEDAL" %} .type = SignalType::PEDAL_CHECKSUM, {% elif address in [512, 513] and sig.name == "COUNTER_PEDAL" %} .type = SignalType::PEDAL_COUNTER, {% else %} .type = SignalType::DEFAULT, {% endif %} }, {% endfor %} }; {% endfor %} const Msg msgs[] = { {% for address, msg_name, msg_size, sigs in msgs %} {% set address_hex = "0x%X" % address %} { .name = "{{msg_name}}", .address = {{address_hex}}, .size = {{msg_size}}, .num_sigs = ARRAYSIZE(sigs_{{address}}), .sigs = sigs_{{address}}, }, {% endfor %} }; const Val vals[] = { {% for address, sig in def_vals %} {% for sg_name, def_val in sig %} {% set address_hex = "0x%X" % address %} { .name = "{{sg_name}}", .address = {{address_hex}}, .def_val = {{def_val}}, .sigs = sigs_{{address}}, }, {% endfor %} {% endfor %} }; } const DBC {{dbc.name}} = { .name = "{{dbc.name}}", .num_msgs = ARRAYSIZE(msgs), .msgs = msgs, .vals = vals, .num_vals = ARRAYSIZE(vals), }; dbc_init({{dbc.name}}) ================================================ FILE: opendbc/can/packer.cc ================================================ #include #include #include #include #include #include "common.h" #define WARN printf // this is the same as read_u64_le, but uses uint64_t as in/out uint64_t ReverseBytes(uint64_t x) { return ((x & 0xff00000000000000ull) >> 56) | ((x & 0x00ff000000000000ull) >> 40) | ((x & 0x0000ff0000000000ull) >> 24) | ((x & 0x000000ff00000000ull) >> 8) | ((x & 0x00000000ff000000ull) << 8) | ((x & 0x0000000000ff0000ull) << 24) | ((x & 0x000000000000ff00ull) << 40) | ((x & 0x00000000000000ffull) << 56); } static uint64_t set_value(uint64_t ret, const Signal& sig, int64_t ival) { int shift = sig.is_little_endian? sig.b1 : sig.bo; uint64_t mask = ((1ULL << sig.b2)-1) << shift; uint64_t dat = (ival & ((1ULL << sig.b2)-1)) << shift; if (sig.is_little_endian) { dat = ReverseBytes(dat); mask = ReverseBytes(mask); } ret &= ~mask; ret |= dat; return ret; } CANPacker::CANPacker(const std::string& dbc_name) { dbc = dbc_lookup(dbc_name); assert(dbc); for (int i=0; inum_msgs; i++) { const Msg* msg = &dbc->msgs[i]; message_lookup[msg->address] = *msg; for (int j=0; jnum_sigs; j++) { const Signal* sig = &msg->sigs[j]; signal_lookup[std::make_pair(msg->address, std::string(sig->name))] = *sig; } } init_crc_lookup_tables(); } uint64_t CANPacker::pack(uint32_t address, const std::vector &signals, int counter) { uint64_t ret = 0; for (const auto& sigval : signals) { double value = sigval.value; auto sig_it = signal_lookup.find(std::make_pair(address, sigval.name)); if (sig_it == signal_lookup.end()) { WARN("undefined signal %s - %d\n", sigval.name.c_str(), address); continue; } const auto& sig = sig_it->second; int64_t ival = (int64_t)(round((value - sig.offset) / sig.factor)); if (ival < 0) { ival = (1ULL << sig.b2) + ival; } ret = set_value(ret, sig, ival); } if (counter >= 0){ auto sig_it = signal_lookup.find(std::make_pair(address, "COUNTER")); if (sig_it == signal_lookup.end()) { WARN("COUNTER not defined\n"); return ret; } const auto& sig = sig_it->second; if ((sig.type != SignalType::HONDA_COUNTER) && (sig.type != SignalType::VOLKSWAGEN_COUNTER)) { WARN("COUNTER signal type not valid\n"); } ret = set_value(ret, sig, counter); } auto sig_it_checksum = signal_lookup.find(std::make_pair(address, "CHECKSUM")); if (sig_it_checksum != signal_lookup.end()) { const auto& sig = sig_it_checksum->second; if (sig.type == SignalType::HONDA_CHECKSUM) { unsigned int chksm = honda_checksum(address, ret, message_lookup[address].size); ret = set_value(ret, sig, chksm); } else if (sig.type == SignalType::TOYOTA_CHECKSUM) { unsigned int chksm = toyota_checksum(address, ret, message_lookup[address].size); ret = set_value(ret, sig, chksm); } else if (sig.type == SignalType::VOLKSWAGEN_CHECKSUM) { // FIXME: Hackish fix for an endianness issue. The message is in reverse byte order // until later in the pack process. Checksums can be run backwards, CRCs not so much. // The correct fix is unclear but this works for the moment. unsigned int chksm = volkswagen_crc(address, ReverseBytes(ret), message_lookup[address].size); ret = set_value(ret, sig, chksm); } else if (sig.type == SignalType::SUBARU_CHECKSUM) { unsigned int chksm = subaru_checksum(address, ret, message_lookup[address].size); ret = set_value(ret, sig, chksm); } else if (sig.type == SignalType::CHRYSLER_CHECKSUM) { unsigned int chksm = chrysler_checksum(address, ReverseBytes(ret), message_lookup[address].size); ret = set_value(ret, sig, chksm); } else { //WARN("CHECKSUM signal type not valid\n"); } } return ret; } Msg* CANPacker::lookup_message(uint32_t address) { return &message_lookup[address]; } ================================================ FILE: opendbc/can/packer.py ================================================ # pylint: skip-file from opendbc.can.packer_pyx import CANPacker assert CANPacker ================================================ FILE: opendbc/can/packer_pyx.pyx ================================================ # distutils: language = c++ # cython: c_string_encoding=ascii, language_level=3 from libc.stdint cimport uint32_t, uint64_t from libcpp.vector cimport vector from libcpp.map cimport map from libcpp.string cimport string from libcpp cimport bool from posix.dlfcn cimport dlopen, dlsym, RTLD_LAZY from .common cimport CANPacker as cpp_CANPacker from .common cimport dbc_lookup, SignalPackValue, DBC cdef class CANPacker: cdef: cpp_CANPacker *packer const DBC *dbc map[string, (int, int)] name_to_address_and_size map[int, int] address_to_size def __init__(self, dbc_name): self.dbc = dbc_lookup(dbc_name) if not self.dbc: raise RuntimeError(f"Can't lookup {dbc_name}") self.packer = new cpp_CANPacker(dbc_name) num_msgs = self.dbc[0].num_msgs for i in range(num_msgs): msg = self.dbc[0].msgs[i] self.name_to_address_and_size[string(msg.name)] = (msg.address, msg.size) self.address_to_size[msg.address] = msg.size cdef uint64_t pack(self, addr, values, counter): cdef vector[SignalPackValue] values_thing values_thing.reserve(len(values)) cdef SignalPackValue spv for name, value in values.iteritems(): spv.name = name.encode('utf8') spv.value = value values_thing.push_back(spv) return self.packer.pack(addr, values_thing, counter) cdef inline uint64_t ReverseBytes(self, uint64_t x): return (((x & 0xff00000000000000ull) >> 56) | ((x & 0x00ff000000000000ull) >> 40) | ((x & 0x0000ff0000000000ull) >> 24) | ((x & 0x000000ff00000000ull) >> 8) | ((x & 0x00000000ff000000ull) << 8) | ((x & 0x0000000000ff0000ull) << 24) | ((x & 0x000000000000ff00ull) << 40) | ((x & 0x00000000000000ffull) << 56)) cpdef make_can_msg(self, name_or_addr, bus, values, counter=-1): cdef int addr, size if type(name_or_addr) == int: addr = name_or_addr size = self.address_to_size[name_or_addr] else: addr, size = self.name_to_address_and_size[name_or_addr.encode('utf8')] cdef uint64_t val = self.pack(addr, values, counter) val = self.ReverseBytes(val) return [addr, 0, (&val)[:size], bus] ================================================ FILE: opendbc/can/parser.cc ================================================ #include #include #include #include #include #include #include #include "common.h" #define DEBUG(...) // #define DEBUG printf #define INFO printf bool MessageState::parse(uint64_t sec, uint16_t ts_, uint8_t * dat) { uint64_t dat_le = read_u64_le(dat); uint64_t dat_be = read_u64_be(dat); for (int i=0; i < parse_sigs.size(); i++) { auto& sig = parse_sigs[i]; int64_t tmp; if (sig.is_little_endian){ tmp = (dat_le >> sig.b1) & ((1ULL << sig.b2)-1); } else { tmp = (dat_be >> sig.bo) & ((1ULL << sig.b2)-1); } if (sig.is_signed) { tmp -= (tmp >> (sig.b2-1)) ? (1ULL << sig.b2) : 0; //signed } DEBUG("parse 0x%X %s -> %lld\n", address, sig.name, tmp); if (!ignore_checksum) { if (sig.type == SignalType::HONDA_CHECKSUM) { if (honda_checksum(address, dat_be, size) != tmp) { INFO("0x%X CHECKSUM FAIL\n", address); return false; } } else if (sig.type == SignalType::TOYOTA_CHECKSUM) { if (toyota_checksum(address, dat_be, size) != tmp) { INFO("0x%X CHECKSUM FAIL\n", address); return false; } } else if (sig.type == SignalType::VOLKSWAGEN_CHECKSUM) { if (volkswagen_crc(address, dat_le, size) != tmp) { INFO("0x%X CRC FAIL\n", address); return false; } } else if (sig.type == SignalType::SUBARU_CHECKSUM) { if (subaru_checksum(address, dat_be, size) != tmp) { INFO("0x%X CHECKSUM FAIL\n", address); return false; } } else if (sig.type == SignalType::CHRYSLER_CHECKSUM) { if (chrysler_checksum(address, dat_le, size) != tmp) { INFO("0x%X CHECKSUM FAIL\n", address); return false; } } else if (sig.type == SignalType::PEDAL_CHECKSUM) { if (pedal_checksum(dat_be, size) != tmp) { INFO("0x%X PEDAL CHECKSUM FAIL\n", address); return false; } } } if (!ignore_counter) { if (sig.type == SignalType::HONDA_COUNTER) { if (!update_counter_generic(tmp, sig.b2)) { return false; } } else if (sig.type == SignalType::VOLKSWAGEN_COUNTER) { if (!update_counter_generic(tmp, sig.b2)) { return false; } } else if (sig.type == SignalType::PEDAL_COUNTER) { if (!update_counter_generic(tmp, sig.b2)) { return false; } } } vals[i] = tmp * sig.factor + sig.offset; } ts = ts_; seen = sec; return true; } bool MessageState::update_counter_generic(int64_t v, int cnt_size) { uint8_t old_counter = counter; counter = v; if (((old_counter+1) & ((1 << cnt_size) -1)) != v) { counter_fail += 1; if (counter_fail > 1) { INFO("0x%X COUNTER FAIL %d -- %d vs %d\n", address, counter_fail, old_counter, (int)v); } if (counter_fail >= MAX_BAD_COUNTER) { return false; } } else if (counter_fail > 0) { counter_fail--; } return true; } CANParser::CANParser(int abus, const std::string& dbc_name, const std::vector &options, const std::vector &sigoptions) : bus(abus), aligned_buf(kj::heapArray(1024)) { dbc = dbc_lookup(dbc_name); assert(dbc); init_crc_lookup_tables(); for (const auto& op : options) { MessageState &state = message_states[op.address]; state.address = op.address; // state.check_frequency = op.check_frequency, // msg is not valid if a message isn't received for 10 consecutive steps if (op.check_frequency > 0) { state.check_threshold = (1000000000ULL / op.check_frequency) * 10; } const Msg* msg = NULL; for (int i = 0; i < dbc->num_msgs; i++) { if (dbc->msgs[i].address == op.address) { msg = &dbc->msgs[i]; break; } } if (!msg) { fprintf(stderr, "CANParser: could not find message 0x%X in DBC %s\n", op.address, dbc_name.c_str()); assert(false); } state.size = msg->size; // track checksums and counters for this message for (int i = 0; i < msg->num_sigs; i++) { const Signal *sig = &msg->sigs[i]; if (sig->type != SignalType::DEFAULT) { state.parse_sigs.push_back(*sig); state.vals.push_back(0); } } // track requested signals for this message for (const auto& sigop : sigoptions) { if (sigop.address != op.address) continue; for (int i = 0; i < msg->num_sigs; i++) { const Signal *sig = &msg->sigs[i]; if (strcmp(sig->name, sigop.name) == 0 && sig->type == SignalType::DEFAULT) { state.parse_sigs.push_back(*sig); state.vals.push_back(sigop.default_value); break; } } } } } CANParser::CANParser(int abus, const std::string& dbc_name, bool ignore_checksum, bool ignore_counter) : bus(abus) { // Add all messages and signals dbc = dbc_lookup(dbc_name); assert(dbc); init_crc_lookup_tables(); for (int i = 0; i < dbc->num_msgs; i++) { const Msg* msg = &dbc->msgs[i]; MessageState state = { .address = msg->address, .size = msg->size, .ignore_checksum = ignore_checksum, .ignore_counter = ignore_counter, }; for (int j = 0; j < msg->num_sigs; j++) { const Signal *sig = &msg->sigs[j]; state.parse_sigs.push_back(*sig); state.vals.push_back(0); } message_states[state.address] = state; } } #ifndef DYNAMIC_CAPNP void CANParser::update_string(const std::string &data, bool sendcan) { // format for board, make copy due to alignment issues. const size_t buf_size = (data.length() / sizeof(capnp::word)) + 1; if (aligned_buf.size() < buf_size) { aligned_buf = kj::heapArray(buf_size); } memcpy(aligned_buf.begin(), data.data(), data.length()); // extract the messages capnp::FlatArrayMessageReader cmsg(aligned_buf.slice(0, buf_size)); cereal::Event::Reader event = cmsg.getRoot(); last_sec = event.getLogMonoTime(); auto cans = sendcan? event.getSendcan() : event.getCan(); UpdateCans(last_sec, cans); UpdateValid(last_sec); } void CANParser::UpdateCans(uint64_t sec, const capnp::List::Reader& cans) { int msg_count = cans.size(); DEBUG("got %d messages\n", msg_count); for (int i = 0; i < msg_count; i++) { auto cmsg = cans[i]; // parse the messages if (cmsg.getSrc() != bus) { // DEBUG("skip %d: wrong bus\n", cmsg.getAddress()); continue; } auto state_it = message_states.find(cmsg.getAddress()); if (state_it == message_states.end()) { // DEBUG("skip %d: not specified\n", cmsg.getAddress()); continue; } if (cmsg.getDat().size() > 8) continue; //shouldn't ever happen uint8_t dat[8] = {0}; memcpy(dat, cmsg.getDat().begin(), cmsg.getDat().size()); state_it->second.parse(sec, cmsg.getBusTime(), dat); } } #endif void CANParser::UpdateCans(uint64_t sec, const capnp::DynamicStruct::Reader& cmsg) { // assume message struct is `cereal::CanData` and parse assert(cmsg.has("address") && cmsg.has("src") && cmsg.has("dat") && cmsg.has("busTime")); if (cmsg.get("src").as() != bus) { DEBUG("skip %d: wrong bus\n", cmsg.get("address").as()); return; } auto state_it = message_states.find(cmsg.get("address").as()); if (state_it == message_states.end()) { DEBUG("skip %d: not specified\n", cmsg.get("address").as()); return; } auto dat = cmsg.get("dat").as(); if (dat.size() > 8) return; //shouldn't ever happen uint8_t data[8] = {0}; memcpy(data, dat.begin(), dat.size()); state_it->second.parse(sec, cmsg.get("busTime").as(), data); } void CANParser::UpdateValid(uint64_t sec) { can_valid = true; for (const auto& kv : message_states) { const auto& state = kv.second; if (state.check_threshold > 0 && (sec - state.seen) > state.check_threshold) { if (state.seen > 0) { DEBUG("0x%X TIMEOUT\n", state.address); } else { DEBUG("0x%X MISSING\n", state.address); } can_valid = false; } } } std::vector CANParser::query_latest() { std::vector ret; for (const auto& kv : message_states) { const auto& state = kv.second; if (last_sec != 0 && state.seen != last_sec) continue; for (int i=0; iself.address_to_msg_name[cv.address].c_str() cv_name = cv.name self.vl[cv.address][cv_name] = cv.value self.ts[cv.address][cv_name] = cv.ts self.vl[name][cv_name] = cv.value self.ts[name][cv_name] = cv.ts updated_val.insert(cv.address) return updated_val def update_string(self, dat, sendcan=False): self.can.update_string(dat, sendcan) return self.update_vl() def update_strings(self, strings, sendcan=False): updated_vals = set() for s in strings: updated_val = self.update_string(s, sendcan) updated_vals.update(updated_val) return updated_vals cdef class CANDefine(): cdef: const DBC *dbc cdef public: dict dv string dbc_name def __init__(self, dbc_name): self.dbc_name = dbc_name self.dbc = dbc_lookup(dbc_name) if not self.dbc: raise RuntimeError(f"Can't find DBC: '{dbc_name}'") num_vals = self.dbc[0].num_vals address_to_msg_name = {} num_msgs = self.dbc[0].num_msgs for i in range(num_msgs): msg = self.dbc[0].msgs[i] name = msg.name.decode('utf8') address = msg.address address_to_msg_name[address] = name dv = defaultdict(dict) for i in range(num_vals): val = self.dbc[0].vals[i] sgname = val.name.decode('utf8') def_val = val.def_val.decode('utf8') address = val.address msgname = address_to_msg_name[address] # separate definition/value pairs def_val = def_val.split() values = [int(v) for v in def_val[::2]] defs = def_val[1::2] # two ways to lookup: address or msg name dv[address][sgname] = dict(zip(values, defs)) dv[msgname][sgname] = dv[address][sgname] self.dv = dict(dv) ================================================ FILE: opendbc/can/process_dbc.py ================================================ #!/usr/bin/env python3 from __future__ import print_function import os import sys import jinja2 from collections import Counter from opendbc.can.dbc import dbc def process(in_fn, out_fn): dbc_name = os.path.split(out_fn)[-1].replace('.cc', '') # print("processing %s: %s -> %s" % (dbc_name, in_fn, out_fn)) template_fn = os.path.join(os.path.dirname(__file__), "dbc_template.cc") with open(template_fn, "r") as template_f: template = jinja2.Template(template_f.read(), trim_blocks=True, lstrip_blocks=True) can_dbc = dbc(in_fn) # process counter and checksums first msgs = [(address, msg_name, msg_size, sorted(msg_sigs, key=lambda s: s.name not in ("COUNTER", "CHECKSUM"))) for address, ((msg_name, msg_size), msg_sigs) in sorted(can_dbc.msgs.items()) if msg_sigs] def_vals = {a: sorted(set(b)) for a, b in can_dbc.def_vals.items()} # remove duplicates def_vals = sorted(def_vals.items()) if can_dbc.name.startswith(("honda_", "acura_")): checksum_type = "honda" checksum_size = 4 counter_size = 2 checksum_start_bit = 3 counter_start_bit = 5 little_endian = False elif can_dbc.name.startswith(("toyota_", "lexus_")): checksum_type = "toyota" checksum_size = 8 counter_size = None checksum_start_bit = 7 counter_start_bit = None little_endian = False elif can_dbc.name.startswith(("vw_", "volkswagen_", "audi_", "seat_", "skoda_")): checksum_type = "volkswagen" checksum_size = 8 counter_size = 4 checksum_start_bit = 0 counter_start_bit = 0 little_endian = True elif can_dbc.name.startswith(("subaru_global_")): checksum_type = "subaru" checksum_size = 8 counter_size = None checksum_start_bit = 0 counter_start_bit = None little_endian = True elif can_dbc.name.startswith(("chrysler_")): checksum_type = "chrysler" checksum_size = 8 counter_size = None checksum_start_bit = 7 counter_start_bit = None little_endian = False else: checksum_type = None checksum_size = None counter_size = None checksum_start_bit = None counter_start_bit = None little_endian = None # sanity checks on expected COUNTER and CHECKSUM rules, as packer and parser auto-compute those signals for address, msg_name, _, sigs in msgs: dbc_msg_name = dbc_name + " " + msg_name for sig in sigs: if checksum_type is not None: # checksum rules if sig.name == "CHECKSUM": if sig.size != checksum_size: sys.exit("%s: CHECKSUM is not %d bits long" % (dbc_msg_name, checksum_size)) if sig.start_bit % 8 != checksum_start_bit: sys.exit("%s: CHECKSUM starts at wrong bit" % dbc_msg_name) if little_endian != sig.is_little_endian: sys.exit("%s: CHECKSUM has wrong endianness" % dbc_msg_name) # counter rules if sig.name == "COUNTER": if counter_size is not None and sig.size != counter_size: sys.exit("%s: COUNTER is not %d bits long" % (dbc_msg_name, counter_size)) if counter_start_bit is not None and sig.start_bit % 8 != counter_start_bit: print(counter_start_bit, sig.start_bit) sys.exit("%s: COUNTER starts at wrong bit" % dbc_msg_name) if little_endian != sig.is_little_endian: sys.exit("%s: COUNTER has wrong endianness" % dbc_msg_name) # pedal rules if address in [0x200, 0x201]: if sig.name == "COUNTER_PEDAL" and sig.size != 4: sys.exit("%s: PEDAL COUNTER is not 4 bits long" % dbc_msg_name) if sig.name == "CHECKSUM_PEDAL" and sig.size != 8: sys.exit("%s: PEDAL CHECKSUM is not 8 bits long" % dbc_msg_name) # Fail on duplicate message names c = Counter([msg_name for address, msg_name, msg_size, sigs in msgs]) for name, count in c.items(): if count > 1: sys.exit("%s: Duplicate message name in DBC file %s" % (dbc_name, name)) parser_code = template.render(dbc=can_dbc, checksum_type=checksum_type, msgs=msgs, def_vals=def_vals, len=len) with open(out_fn, "a+") as out_f: out_f.seek(0) if out_f.read() != parser_code: out_f.seek(0) out_f.truncate() out_f.write(parser_code) def main(): if len(sys.argv) != 3: print("usage: %s dbc_directory output_filename" % (sys.argv[0],)) sys.exit(0) dbc_dir = sys.argv[1] out_fn = sys.argv[2] dbc_name = os.path.split(out_fn)[-1].replace('.cc', '') in_fn = os.path.join(dbc_dir, dbc_name + '.dbc') process(in_fn, out_fn) if __name__ == '__main__': main() ================================================ FILE: opendbc/chrysler_pacifica_2017_hybrid.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 258 STEERING: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ UNKNOWN_STEERING : 50|3@0+ (1,0) [0|15] "" XXX SG_ STEERING_RATE : 20|13@0+ (0.3187251,-1305.498) [0|8191] "deg/s" XXX SG_ STEER_ANGLE : 4|13@0+ (0.3187251,-1307.888) [-360|360] "deg" XXX BO_ 514 SPEED_1: 8 XXX SG_ SPEED_LEFT : 7|12@0+ (0.071028,0) [0|65535] "m/s" XXX SG_ SPEED_RIGHT : 23|12@0+ (0.071028,0) [0|1023] "m/s" XXX BO_ 653 BRAKE_MODULE: 2 XXX SG_ BRAKE_PRESSURE : 15|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|4] "" XXX BO_ 820 DOORS: 8 XXX SG_ DOOR_OPEN_FR : 18|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 19|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 20|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_TRUNK : 22|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 17|1@0+ (1,0) [0|1] "" XXX SG_ TURN_LIGHT_LEFT : 31|1@0+ (1,0) [0|1] "" XXX SG_ TURN_LIGHT_RIGHT : 30|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM_DISPLAY : 58|1@0+ (1,0) [0|1] "" XXX BO_ 746 GEAR: 5 XXX SG_ PRNDL : 2|3@0+ (1,0) [0|7] "" XXX SG_ GEAR_CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 31|4@0+ (1,0) [0|15] "" XXX BO_ 284 BRAKE_1: 8 XXX SG_ SPEED_RELATED_1 : 37|14@0+ (1,0) [0|255] "" XXX SG_ BRAKE_RELATED_1_2 : 18|11@0+ (1,0) [0|255] "" XXX SG_ BRAKE_RELATED_1_1 : 3|12@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 320 BRAKE_2: 8 XXX SG_ SPEED_RELATED_2 : 47|8@0+ (1,0) [0|63] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PRESSED_2 : 2|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_PRESSED_ACC : 6|1@0+ (1,0) [0|3] "" XXX BO_ 736 TRIP: 8 XXX SG_ COUNTER : 7|16@0+ (1,0) [0|65535] "Meters" XXX SG_ COUNTER_2 : 23|16@0+ (1,0) [0|65535] "Meters" XXX BO_ 344 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FL : 3|12@0+ (0.0189408,0) [0|65535] "m/s" XXX SG_ WHEEL_SPEED_RR : 51|12@0+ (0.0189408,0) [0|255] "m/s" XXX SG_ WHEEL_SPEED_RL : 35|12@0+ (0.0189408,0) [0|3] "m/s" XXX SG_ WHEEL_SPEED_FR : 19|12@0+ (0.0189408,0) [0|255] "m/s" XXX BO_ 792 STEERING_LEVERS: 8 XXX SG_ HIGH_BEAM_PUSHED_IN : 2|1@0+ (1,0) [0|3] "" XXX SG_ TURN_SIGNALS : 1|2@0+ (1,0) [0|3] "" XXX SG_ HIGH_BEAM_FLASH : 3|1@0+ (1,0) [0|3] "" XXX BO_ 264 ACCEL_PEDAL_MSG: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_PEDAL : 35|1@0+ (1,0) [0|1] "" XXX BO_ 464 SEATBELT_STATUS: 8 XXX SG_ SEATBELT_DRIVER_UNLATCHED : 13|1@0+ (1,0) [0|1] "" XXX BO_ 544 EPS_STATUS: 8 XXX SG_ LKAS_STATE : 23|4@0+ (1,0) [0|15] "" XXX SG_ TORQUE_DRIVER : 2|11@0+ (1,-1024) [-1024|1023] "" XXX SG_ TORQUE_MOTOR_RAW : 19|12@0+ (1,-2048) [-2048|2047] "" XXX SG_ TORQUE_MOTOR : 34|11@0+ (1,-1024) [-1024|1023] "" XXX SG_ AUTO_PARK_HAS_CONTROL_2 : 51|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 658 LKAS_COMMAND: 6 XXX SG_ COUNTER : 39|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX SG_ LKAS_STEERING_TORQUE : 2|11@0+ (1,-1024) [0|1] "" XXX SG_ LKAS_HIGH_TORQUE : 4|1@0+ (1,0) [0|1] "" XXX BO_ 678 LKAS_HUD: 8 XXX SG_ LKAS_ICON_COLOR : 1|2@0+ (1,0) [0|3] "" XXX SG_ LKAS_LANE_LINES : 19|4@0+ (1,0) [0|1] "" XXX SG_ LKAS_ALERTS : 27|4@0+ (1,0) [0|1] "" XXX SG_ CAR_MODEL : 15|8@0+ (1,0) [0|255] "" XXX BO_ 705 AUTO_PARK_BUTTON: 8 XXX SG_ AUTO_PARK_TOGGLE_2 : 8|1@0+ (1,0) [0|1] "" XXX SG_ AUTO_PARK_TOGGLE_1 : 11|1@0+ (1,0) [0|1] "" XXX SG_ INCREASING_UNKNOWN : 38|7@0+ (1,0) [0|15] "" XXX BO_ 719 AUTO_PARK_SIGNALS_1: 8 XXX SG_ AUTO_PARK_UNKNOWN_1 : 7|16@0+ (1,0) [0|31] "" XXX BO_ 671 AUTO_PARK_REQUEST: 8 XXX SG_ AUTO_PARK_CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ AUTO_PARK_STATUS : 7|5@0+ (1,0) [0|15] "" XXX SG_ AUTO_PARK_COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ AUTO_PARK_MODE : 22|2@0+ (1,0) [0|3] "" XXX SG_ AUTO_PARK_CMD : 2|11@0+ (1,-1024) [0|1] "NM" XXX BO_ 784 AUTO_PARK_LESS_INTERESTING: 8 XXX SG_ INCREASING_UNKNOWN : 55|8@0+ (1,0) [0|7] "" XXX SG_ AUTO_PARK_PERPENDICULAR_2 : 61|1@0+ (1,0) [0|255] "" XXX BO_ 826 AUTO_PARK_SIGNALS_3: 8 XXX SG_ AUTO_PARK_HAS_CONTROL_3 : 1|1@0+ (1,0) [0|1] "" XXX SG_ HUMAN_HAS_CONTROL : 2|1@0+ (1,0) [0|1] "" XXX SG_ AUTO_PARK_GEAR_1 : 27|4@0+ (1,0) [0|255] "" XXX SG_ AUTO_PARK_GEAR_2 : 35|4@0+ (1,0) [0|15] "" XXX SG_ AUTO_PARK_GEAR_3 : 51|4@0+ (1,0) [0|15] "" XXX BO_ 332 STEERING_2: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ ENERGY_RELATED : 39|16@0+ (1,0) [0|65535] "" XXX SG_ STEER_ANGLE_2 : 7|13@0+ (0.3187251,-1307.888) [-360|360] "deg" XXX BO_ 720 BLIND_SPOT_WARNINGS: 6 XXX SG_ BLIND_SPOT_RIGHT : 5|1@0+ (1,0) [0|1] "" XXX SG_ BLIND_SPOT_LEFT : 2|1@0+ (1,0) [0|1] "" XXX BO_ 331 BRAKE_3: 8 XXX SG_ BRAKE_RELATED_3 : 7|16@0+ (1,0) [0|65535] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 608 PARKSENSE_SIGNAL: 8 XXX SG_ PARKSENSE_DISABLED : 34|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ IN_REVERSE : 10|1@0+ (1,0) [0|255] "" XXX SG_ AUTO_PARK_HAS_CONTROL_1 : 16|1@0+ (1,0) [0|255] "" XXX SG_ HUMAN_HAS_CONTROL : 17|1@0+ (1,0) [0|3] "" XXX BO_ 729 LKAS_HEARTBIT: 5 XXX SG_ LKAS_STATUS_OK : 31|16@0+ (1,0) [0|65535] "" XXX BO_ 274 NEW_MSG_112: 2 XXX BO_ 290 NEW_MSG_122: 6 XXX BO_ 376 NEW_MSG_178: 3 XXX BO_ 288 ACCEL_RELATED_120: 7 XXX SG_ COUNTER : 47|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL : 23|8@0+ (1,0) [0|255] "" XXX SG_ GAS_ENGINE_RPM_MAYBE : 31|16@0+ (1,0) [0|65535] "" XXX BO_ 257 ACCEL_RELATED_101: 5 XXX SG_ ENERGY_OR_RPM : 31|8@0+ (1,0) [0|255] "" XXX BO_ 388 NEW_MSG_184: 4 XXX BO_ 448 NEW_MSG_1c0: 6 XXX BO_ 456 NEW_MSG_1c8: 4 XXX BO_ 560 NEW_MSG_230: 4 XXX BO_ 564 NEW_MSG_234: 4 XXX BO_ 571 WHEEL_BUTTONS: 3 XXX SG_ CHECKSUM : 23|8@0+ (1,0) [0|255] "" XXX SG_ ACC_FOLLOW_DEC : 1|1@0+ (1,0) [0|3] "" XXX SG_ ACC_SPEED_INC : 2|1@0+ (1,0) [0|255] "" XXX SG_ ACC_SPEED_DEC : 3|1@0+ (1,0) [0|3] "" XXX SG_ ACC_FOLLOW_INC : 8|1@0+ (1,0) [0|15] "" XXX SG_ ACC_CANCEL : 0|1@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX SG_ ACC_RESUME : 4|1@0+ (1,0) [0|15] "" XXX BO_ 669 NEW_MSG_29d: 3 XXX SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 23|8@0+ (1,0) [0|255] "" XXX BO_ 825 AUDIBLE_BEEP_339: 2 XXX SG_ BEEP_339 : 7|16@0+ (1,0) [0|65535] "" XXX BO_ 856 NEW_MSG_358: 4 XXX BO_ 860 NEW_MSG_35c: 6 XXX BO_ 924 NEW_MSG_39c: 3 XXX BO_ 969 NEW_MSG_3c9: 4 XXX BO_ 974 NEW_MSG_3ce: 5 XXX BO_ 993 NEW_MSG_3e1: 7 XXX BO_ 838 NEW_MSG_346: 2 XXX BO_ 926 NEW_MSG_39e: 3 XXX BO_ 168 ACCEL_RELATED_a8: 8 XXX SG_ ACCEL_RELATED : 23|16@0+ (1,0) [0|65535] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 270 ACCEL_RELATED_10e: 8 XXX SG_ ACCEL_OR_RPM : 7|16@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ELECTRIC_MOTOR : 23|16@0+ (1,0) [0|65535] "" XXX BO_ 291 ENERGY_RELATED_123: 8 XXX SG_ ENERGY_GAIN_LOSS : 18|11@0- (1,0) [0|255] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ENERGY_SMOOTHER_CURVE : 35|12@0+ (1,0) [0|2047] "" XXX BO_ 294 ENERGY_RELATED_126: 8 XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ UNKNOWN_126_1 : 3|12@0+ (1,0) [0|4095] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ UNKNOWN_126_2 : 35|12@0+ (1,0) [0|4095] "" XXX SG_ ENERGY_GAIN_LOSS_NOISY : 19|12@0+ (1,0) [0|2047] "" XXX BO_ 300 NEW_MSG_12C: 8 XXX BO_ 308 ACCEL_GAS_134: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ ACCEL_134 : 46|7@0+ (1,0) [0|127] "" XXX BO_ 532 ENERGY_RELATED_214: 8 XXX SG_ NOISY_SLOWLY_DECREASING : 16|9@0+ (1,0) [0|255] "" XXX SG_ ENERGY_RELATED : 0|9@0+ (1,0) [0|255] "" XXX BO_ 559 ACCEL_GAS_22F: 8 XXX SG_ ACCEL_22F : 3|4@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 655 CHARGING_MAYBE_28F: 8 XXX SG_ CHARGING : 1|2@0+ (1,0) [0|3] "" XXX BO_ 660 BRAKE_RELATED_294: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PERHAPS_294 : 31|8@0+ (1,0) [0|255] "" XXX BO_ 764 ACCEL_RELATED_2FC: 8 XXX SG_ ACCEL_2FC : 13|6@0+ (1,0) [0|255] "" XXX BO_ 816 TRACTION_BUTTON: 8 XXX SG_ TRACTION_OFF : 19|1@0+ (1,0) [0|3] "" XXX SG_ TOGGLE_PARKSENSE : 52|1@0+ (1,0) [0|3] "" XXX BO_ 878 ACCEL_RELATED_36E: 8 XXX SG_ ACCEL_OR_RPM_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_OR_RPM_1 : 7|8@0+ (1,0) [0|255] "" XXX BO_ 324 SPEED_2: 8 XXX SG_ SPEED_2 : 31|16@0+ (0.01,0) [0|255] "m/s" XXX BO_ 501 DASHBOARD: 8 XXX SG_ ACC_SPEED_CONFIG_KPH : 15|8@0+ (1,0) [0|3] "km/h" XXX SG_ ACC_SPEED_CONFIG_MPH : 23|8@0+ (1,0) [0|3] "mph" XXX SG_ ACC_DISTANCE_CONFIG_1 : 1|2@0+ (1,0) [0|3] "" XXX SG_ ACC_DISTANCE_CONFIG_2 : 41|2@0+ (1,0) [0|3] "" XXX SG_ SPEED_DIGITAL : 63|8@0+ (1,0) [0|255] "mph" XXX SG_ CRUISE_STATE : 38|3@0+ (1,0) [0|7] "" XXX BO_ 639 NEW_MSG_27f: 8 XXX SG_ INCREASING : 47|8@0+ (1,0) [0|255] "" XXX BO_ 701 NEW_MSG_2bd: 8 XXX SG_ unknown_1 : 39|8@0+ (1,0) [0|255] "" XXX BO_ 832 UNKNOWN_340: 8 XXX SG_ SPEED_DIGITAL : 63|8@0+ (1,0) [0|255] "mph" XXX BO_ 848 UNKNOWN_350: 8 XXX SG_ INCREASING_LSB : 5|6@0+ (1,0) [0|255] "" XXX SG_ INCREASING_MSB : 12|5@0+ (1,0) [0|31] "" XXX BO_ 908 NEW_MSG_38c: 8 XXX SG_ INCREASING_MSB : 44|5@0+ (1,0) [0|31] "" XXX SG_ INCREASING_LSB : 61|6@0+ (1,0) [0|255] "" XXX BO_ 938 NEW_MSG_3aa: 8 XXX SG_ INCREASING_UNKNOWN_1 : 39|8@0+ (1,0) [0|255] "" XXX SG_ INCREASING_UNKNOWN_2 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 940 NEW_MSG_3ac: 8 XXX SG_ INCREASING_1 : 35|4@0+ (1,0) [0|15] "" XXX SG_ INCREASING_2 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 941 NEW_MSG_3ad: 8 XXX SG_ INCREASING_1 : 36|5@0+ (1,0) [0|31] "" XXX SG_ INCREASING_2 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 500 ACC_2: 8 XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ ACC_STATUS_1 : 7|3@0+ (1,0) [0|255] "" XXX SG_ BRAKE_MAYBE : 18|11@0+ (1,0) [0|255] "" XXX SG_ ACC_STATUS_2 : 21|3@0+ (1,0) [0|255] "" XXX SG_ BRAKE_BOOL_1 : 36|1@0+ (1,0) [0|3] "" XXX BO_ 625 ACC_1: 8 XXX SG_ SPEED : 31|8@0+ (1,0) [0|255] "km/h" XXX SG_ ACCEL_PERHAPS : 39|16@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX BO_ 268 ACC_10c: 8 XXX SG_ BRAKE_PERHAPS : 48|1@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 384 NEW_MSG_180: 8 XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 39|8@0+ (1,0) [0|3] "" XXX BO_ 853 NEW_MSG_355: 8 XXX BO_ 939 NEW_MSG_3ab: 8 XXX BO_ 512 NEW_MSG_200: 8 XXX SG_ NEW_SIGNAL_1 : 23|8@0+ (1,0) [0|255] "" XXX SG_ INCREASING : 27|12@0+ (1,0) [0|127] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ SG_ 258 UNKNOWN_STEERING "never goes above 4. see if human-applied torque"; CM_ SG_ 258 STEER_ANGLE "positive is left (counter-clockwise)"; CM_ SG_ 514 SPEED_LEFT "TODO find upper limit"; CM_ SG_ 653 BRAKE_PRESSURE "max seems to be 148"; CM_ SG_ 820 TURN_LIGHT_LEFT "oscillates with the light blinking"; CM_ SG_ 820 TURN_LIGHT_RIGHT "hazard blinks both right and left lights"; CM_ SG_ 746 PRNDL "5=L, 4=D, 3=N, 2=R, 1=P"; CM_ SG_ 746 GEAR_CHECKSUM "different than the LKAS checksum. unknown non-simple algorithm. just build a lookup table for it."; CM_ SG_ 284 SPEED_RELATED_1 "Another Speed Signal, Maybe RPMs?"; CM_ SG_ 284 BRAKE_RELATED_1_1 "Correlates with braking"; CM_ SG_ 320 BRAKE_PRESSED_2 "Value is 5 when brake is pressed by human, 1 when ACC brake"; CM_ SG_ 320 BRAKE_PRESSED_ACC "set when ACC brakes"; CM_ SG_ 792 TURN_SIGNALS "1=Left, 2=Right"; CM_ SG_ 792 HIGH_BEAM_FLASH "use this for genericToggle"; CM_ SG_ 264 ACCEL_PEDAL "not in ACC so seems to be actual pedal. Use for gasPressed"; CM_ SG_ 544 LKAS_STATE "2 when autopark has control, 8 when is actuatable by lkas, 4 when there is a fault"; CM_ SG_ 544 TORQUE_MOTOR_RAW "has larger range than TORQUE_MOTOR but ut seems biased"; CM_ SG_ 658 COUNTER "each message increments, 0..f"; CM_ SG_ 658 CHECKSUM "checksum calculated with https://gist.github.com/adhintz/94bf8d19b9075539f50172ab0fb24ba1"; CM_ SG_ 658 LKAS_STEERING_TORQUE "Most sent by stock system is 1024+-230. + is left. typically changes by 2 or 3 each 0.01s"; CM_ SG_ 678 LKAS_ICON_COLOR "3 is yellow, 2 is green, 1 is white, 0 is null"; CM_ SG_ 678 LKAS_LANE_LINES "0x01 transparent lines, 0x02 left white, 0x03 right white, 0x04 left yellow with car on top, 0x05 left yellow with car on top, 0x06 both white, 0x07 left yellow, 0x08 left yellow right white, 0x09 right yellow, 0x0a right yellow left white, 0x0b left yellow with car on top right white, 0x0c right yellow with car on top left white, (0x00, 0x0d, 0x0e, 0x0f) null"; CM_ SG_ 678 LKAS_ALERTS "(0x01, 0x02) lane sense off, (0x03, 0x04, 0x06) place hands on steering wheel, 0x07 lane departure detected + place hands on steering wheel, (0x08, 0x09) lane sense unavailable + clean front windshield, 0x0b lane sense and auto high beam unavailable + clean front windshield, 0x0c lane sense unavailable + service required, (0x00, 0x05, 0x0a, 0x0d, 0x0e, 0x0f) null"; CM_ SG_ 705 AUTO_PARK_TOGGLE_1 "set briefly when turning on or off self-parking"; CM_ SG_ 705 INCREASING_UNKNOWN "sometimes decreasing"; CM_ SG_ 671 AUTO_PARK_CMD "Request Appears to be in NM"; CM_ SG_ 671 AUTO_PARK_STATUS "1 = IDLE / NO REQUEST 9 = START REQUEST 10 = REQUEST MODE 11 = REQUEST MODE"; CM_ SG_ 784 INCREASING_UNKNOWN "perhaps distance traveled"; CM_ SG_ 826 AUTO_PARK_GEAR_1 "Reverse=0, Forward=f"; CM_ SG_ 826 AUTO_PARK_GEAR_2 "Reverse=0, Forward=f"; CM_ SG_ 826 AUTO_PARK_GEAR_3 "Reverse=0, Forward=f"; CM_ SG_ 332 STEER_ANGLE_2 "slightly lags the other steer_angle signal. also more noisy."; CM_ SG_ 720 BLIND_SPOT_RIGHT "yellow triangle alert on side view mirror when a car is in your blind spot"; CM_ SG_ 608 PARKSENSE_DISABLED "set if parksense is disabled"; CM_ SG_ 729 LKAS_STATUS_OK "Set to 0x0820 when LKAS system is plugged in."; CM_ SG_ 288 UNKNOWN_CHECKSUM "not the LKAS checksum"; CM_ SG_ 288 GAS_ENGINE_RPM_MAYBE "lags acceleration, perhaps gas engine"; CM_ SG_ 257 ENERGY_OR_RPM "perhaps energy consumption or RPMs"; CM_ SG_ 571 CHECKSUM "standard checksum"; CM_ SG_ 825 BEEP_339 "sent every 0.5s. 0050 is no beep. To beep send 4355 or 4155. Used by ParkSense warning."; CM_ SG_ 270 ELECTRIC_MOTOR "0x7fff indicates electric motor not in use"; CM_ SG_ 291 ENERGY_GAIN_LOSS "unsure what this actually is"; CM_ SG_ 291 ENERGY_SMOOTHER_CURVE "unsure what it is, but smoother"; CM_ SG_ 308 ACCEL_134 "only set when human presses accel pedal"; CM_ SG_ 532 NOISY_SLOWLY_DECREASING "perhaps battery but do not know"; CM_ SG_ 816 TRACTION_OFF "set when traction off button is enabled"; CM_ SG_ 816 TOGGLE_PARKSENSE "sending 3000071ec0ff9000 enables or disables parksense"; CM_ SG_ 324 SPEED_2 "signal is approx half other speeds"; CM_ SG_ 501 ACC_SPEED_CONFIG_KPH "speed configured for ACC"; CM_ SG_ 501 ACC_SPEED_CONFIG_MPH "speed configured for ACC"; CM_ SG_ 639 INCREASING "perhaps number of seconds divided by two for this drive"; CM_ SG_ 848 INCREASING_LSB "lower part of time counter"; CM_ SG_ 848 INCREASING_MSB "upper part of time counter"; CM_ SG_ 908 INCREASING_MSB "time based"; CM_ SG_ 500 ACC_STATUS_1 "2 briefly (9 packets) when ACC goes to green, 1 help when ACC coming to a stop and at a stop"; CM_ SG_ 500 BRAKE_MAYBE "2046 in non-ACC and non-decel. Signal on deceleration. 818 for already stopped break."; CM_ SG_ 500 ACC_STATUS_2 "set to 1 in non-ACC, 3 when ACC enabled (white icon), and 7 when ACC in use (green icon)"; CM_ SG_ 500 BRAKE_BOOL_1 "set to 1 when ACC decel. 0 on non-ACC and accel."; CM_ SG_ 501 CRUISE_STATE "may just be an icon, but seems to indicate different cruise modes: ACC and Non-ACC and engaged state for both."; CM_ SG_ 625 SPEED "zero on non-acc drives"; CM_ SG_ 625 ACCEL_PERHAPS "set to 7767 on non-ACC drives. ACC drive 40k is constant speed, 42k is accelerating"; CM_ SG_ 268 BRAKE_PERHAPS "triggers only on ACC braking"; CM_ SG_ 384 NEW_SIGNAL_1 "set in ACC gas driving. not set in electric human. not sure about gas human driving."; VAL_ 501 CRUISE_STATE 0 "Off" 1 "CC On" 2 "CC Engaged" 3 "ACC On" 4 "ACC Engaged"; VAL_ 746 PRNDL 5 "L" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 792 TURN_SIGNALS 2 "Right" 1 "Left" ; ================================================ FILE: opendbc/chrysler_pacifica_2017_hybrid_private_fusion.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 544 a_1: 8 XXX SG_ track_id : 7|4@0+ (1,0) [0|15] "" XXX SG_ REL_ACCEL : 3|12@0+ (1,0) [0|31] "" XXX SG_ status1 : 23|4@0+ (1,0) [0|15] "" XXX SG_ REL_SPEED : 19|12@0+ (1,0) [0|65535] "" XXX SG_ status2 : 39|6@0+ (1,0) [0|15] "" XXX SG_ sig2 : 33|10@0+ (1,0) [0|255] "" XXX SG_ zeros : 55|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 576 b_1: 8 XXX SG_ sig0 : 7|8@0+ (1,0) [0|255] "" XXX SG_ sig1 : 15|16@0+ (1,0) [0|65535] "" XXX SG_ sig2 : 31|16@0+ (1,0) [0|255] "" XXX SG_ zeros : 47|12@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 608 a_2: 8 XXX SG_ track_id : 7|4@0+ (1,0) [0|15] "" XXX SG_ REL_ACCEL : 3|12@0+ (1,0) [0|31] "" XXX SG_ status1 : 23|4@0+ (1,0) [0|15] "" XXX SG_ REL_SPEED : 19|12@0+ (1,0) [0|65535] "" XXX SG_ status2 : 39|6@0+ (1,0) [0|15] "" XXX SG_ sig2 : 33|10@0+ (1,0) [0|255] "" XXX SG_ zeros : 55|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 640 b_2: 8 XXX SG_ sig0 : 7|8@0+ (1,0) [0|255] "" XXX SG_ sig1 : 15|16@0+ (1,0) [0|65535] "" XXX SG_ sig2 : 31|16@0+ (1,0) [0|255] "" XXX SG_ zeros : 47|12@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 644 a_3: 8 XXX SG_ track_id : 7|4@0+ (1,0) [0|15] "" XXX SG_ REL_ACCEL : 3|12@0+ (1,0) [0|31] "" XXX SG_ status1 : 23|4@0+ (1,0) [0|15] "" XXX SG_ REL_SPEED : 19|12@0+ (1,0) [0|65535] "" XXX SG_ status2 : 39|6@0+ (1,0) [0|15] "" XXX SG_ sig2 : 33|10@0+ (1,0) [0|255] "" XXX SG_ zeros : 55|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 648 b_3: 8 XXX SG_ sig0 : 7|8@0+ (1,0) [0|255] "" XXX SG_ sig1 : 15|16@0+ (1,0) [0|65535] "" XXX SG_ sig2 : 31|16@0+ (1,0) [0|255] "" XXX SG_ zeros : 47|12@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 652 a_4: 8 XXX SG_ track_id : 7|4@0+ (1,0) [0|15] "" XXX SG_ REL_ACCEL : 3|12@0+ (1,0) [0|31] "" XXX SG_ status1 : 23|4@0+ (1,0) [0|15] "" XXX SG_ REL_SPEED : 19|12@0+ (1,0) [0|65535] "" XXX SG_ status2 : 39|6@0+ (1,0) [0|15] "" XXX SG_ sig2 : 33|10@0+ (1,0) [0|255] "" XXX SG_ zeros : 55|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 656 b_4: 8 XXX SG_ sig0 : 7|8@0+ (1,0) [0|255] "" XXX SG_ sig1 : 15|16@0+ (1,0) [0|65535] "" XXX SG_ sig2 : 31|16@0+ (1,0) [0|255] "" XXX SG_ zeros : 47|12@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 512 unknown_200: 8 XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ increasing : 31|16@0+ (1,0) [0|255] "" XXX SG_ zeros_0 : 3|12@0+ (1,0) [0|63] "" XXX SG_ zeros_1 : 47|12@0+ (1,0) [0|63] "" XXX SG_ status0 : 7|4@0+ (1,0) [0|15] "" XXX SG_ unknown_0 : 23|8@0+ (1,0) [0|255] "" XXX BO_ 514 unknown_202: 8 XXX SG_ COUNTER : 43|4@0+ (1,0) [0|15] "" XXX SG_ sig3 : 31|8@0+ (1,0) [0|65535] "" XXX SG_ increasing : 39|12@0+ (1,0) [0|15] "" XXX BO_ 706 c_1: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX BO_ 708 c_2: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 710 c_3: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 712 c_4: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 714 c_5: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 716 c_6: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 718 c_7: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 720 c_8: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 722 c_9: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 724 c_10: 8 XXX SG_ LAT_DIST : 18|11@0+ (0.005,-1000) [0|2047] "m" XXX SG_ LONG_DIST : 34|11@0+ (0.073,0) [0|255] "m" XXX SG_ COUNTER : 55|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 674 d_1: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 676 d_2: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 678 d_3: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 680 d_4: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 682 d_5: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 684 d_6: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 686 d_7: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 688 d_8: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 690 d_9: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 692 d_10: 8 XXX SG_ REL_SPEED : 17|10@0+ (0.2857,-146.278) [0|1023] "m/s" XXX BO_ 672 NEW_MSG_5: 8 XXX SG_ NEW_SIGNAL_1 : 9|10@0+ (1,0) [0|1023] "" XXX SG_ NEW_SIGNAL_2 : 45|10@0+ (1,0) [0|1023] "" XXX CM_ SG_ 544 track_id "for message a_1 track_id is always 1, similar for other messages and track_id"; CM_ SG_ 544 REL_ACCEL "perhaps REL_ACCEL because it responds faster and before REL_SPEED"; CM_ SG_ 544 sig2 "perhaps distance to object. LONG_DIST or REL_ACCEL or REL_SPEED"; CM_ SG_ 576 zeros "not always zero, sometimes has value when another car changes lanes"; CM_ SG_ 706 LAT_DIST "positive is to the right, negative is to the left"; ================================================ FILE: opendbc/ford_fusion_2018_adas.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 1280 Object_00: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1281 Object_01: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1282 Object_02: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1283 Object_03: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1284 Object_04: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1285 Object_05: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1286 Object_06: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1287 Object_07: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1288 Object_08: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1289 Object_09: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1290 Object_10: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1291 Object_11: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1292 Object_12: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1293 Object_13: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1294 Object_14: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1295 Object_15: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1296 Object_16: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1297 Object_17: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1298 Object_18: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1299 Object_19: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1300 Object_20: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1301 Object_21: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1302 Object_22: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1303 Object_23: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1304 Object_24: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1305 Object_25: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1306 Object_26: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1307 Object_27: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1308 Object_28: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1309 Object_29: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1310 Object_30: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1311 Object_31: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1312 Object_32: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1313 Object_33: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1314 Object_34: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1315 Object_35: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1316 Object_36: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1317 Object_37: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1318 Object_38: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1319 Object_39: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1320 Object_40: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1321 Object_41: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1322 Object_42: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1323 Object_43: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1324 Object_44: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1325 Object_45: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1326 Object_46: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1327 Object_47: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1328 Object_48: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1329 Object_49: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1330 Object_50: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1331 Object_51: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1332 Object_52: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1333 Object_53: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1334 Object_54: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1335 Object_55: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1336 Object_56: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1337 Object_57: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1338 Object_58: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1339 Object_59: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1340 Object_60: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1341 Object_61: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1342 Object_62: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX BO_ 1343 Object_63: 8 XXX SG_ X_Rel : 18|11@0+ (0.1,0) [0|0] "m" XXX SG_ V_Rel : 52|13@0- (0.01,0) [0|0] "m/s" XXX SG_ A_Rel : 33|10@0- (0.05,0) [0|0] "m/s2" XXX SG_ Angle : 12|10@0- (-0.1,0) [0|0] "deg" XXX ================================================ FILE: opendbc/ford_fusion_2018_pt.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 130 EPAS_INFO: 8 XXX SG_ SteMdule_U_Meas : 39|8@0+ (0.05,6.0) [0|0] "Volts" XXX SG_ SteMdule_I_Est : 21|12@0+ (0.05,-64.0) [0|0] "Amps" XXX SG_ EPAS_FAILURE : 9|2@0+ (1,0) [0|0] "" XXX SG_ SteeringColumnTorque : 7|8@0+ (0.0625,-8.0) [0|0] "Nm" XXX SG_ SAPPAngleControlStat6 : 15|1@0+ (1,0) [0|0] "" XXX SG_ SAPPAngleControlStat5 : 14|1@0+ (1,0) [0|0] "" XXX SG_ SAPPAngleControlStat4 : 13|1@0+ (1,0) [0|0] "" XXX SG_ SAPPAngleControlStat3 : 12|1@0+ (1,0) [0|0] "" XXX SG_ SAPPAngleControlStat2 : 11|1@0+ (1,0) [0|0] "" XXX SG_ SAPPAngleControlStat1 : 23|2@0+ (1,0) [0|0] "" XXX BO_ 118 Steering_Wheel_Data_CG1: 8 XXX SG_ SteWhlRelInit_An_Sns : 6|15@0+ (0.1,-1600.0) [0|0] "deg" XXX SG_ SteWhlRelCalib_An_Sns : 23|15@0+ (0.1,-1600.0) [0|0] "deg" XXX SG_ SteWhlRelInit2_An_Sns : 55|16@0+ (0.1,-3200.0) [0|0] "deg" XXX SG_ SteWhlAn_No_Cs : 39|8@0+ (1,0) [0|0] "" XXX SG_ SteWhlAn_No_Cnt : 47|4@0+ (1,0) [0|0] "Counts" XXX BO_ 131 Steering_Buttons: 8 XXX SG_ Right_Turn_Light : 5|1@0+ (1,0) [0|0] "" XXX SG_ Left_Turn_Light : 4|1@0+ (1,0) [0|0] "" XXX SG_ Dist_Decr : 12|1@0+ (1,0) [0|0] "" XXX SG_ Dist_Incr : 11|1@0+ (1,0) [0|0] "" XXX SG_ Cancel : 8|1@0+ (1,0) [0|0] "" XXX SG_ Resume : 29|1@0+ (1,0) [0|0] "" XXX SG_ Set : 28|1@0+ (1,0) [0|0] "" XXX SG_ Main : 38|1@0+ (1,0) [0|0] "" XXX BO_ 145 Yaw_Data: 8 XXX SG_ VehYaw_W_Actl : 39|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX SG_ VehRol_W_Actl : 23|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX SG_ VehPtch_W_Actl : 7|16@0+ (0.0002,-6.5) [0|0] "rad/s" XXX BO_ 146 Accel_Data: 8 XXX SG_ VehVertAActl_D_Qf : 38|2@0+ (1,0) [0|0] "" XXX SG_ VehLongAActl_D_Qf : 22|2@0+ (1,0) [0|0] "" XXX SG_ VehLatAActl_D_Qf : 6|2@0+ (1,0) [0|0] "" XXX SG_ VehVert_A_Actl : 36|13@0+ (0.01,-40.0) [0|0] "m/s^2" XXX SG_ VehLong_A_Actl : 20|13@0+ (0.01,-40.0) [0|0] "m/s^2" XXX SG_ VehLat_A_Actl : 4|13@0+ (0.01,-40.0) [0|0] "m/s^2" XXX BO_ 357 Cruise_Status: 8 XXX SG_ Brake_Drv_Appl : 5|1@0+ (1,0) [0|0] "" XXX SG_ Cruise_State : 11|4@0+ (1,0) [0|0] "" XXX SG_ Set_Speed : 23|8@0+ (1,0) [0|0] "" XXX BO_ 516 EngineData_14: 8 XXX SG_ ApedPosScal_Pc_Actl : 1|10@0+ (0.1,0) [0|0] "%" XXX BO_ 535 WheelSpeed_CG1: 8 XXX SG_ WhlRr_W_Meas : 55|14@0+ (0.04,0) [0|0] "rad/s" XXX SG_ WhlRl_W_Meas : 39|14@0+ (0.04,0) [0|0] "rad/s" XXX SG_ WhlFr_W_Meas : 23|14@0+ (0.04,0) [0|0] "rad/s" XXX SG_ WhlFl_W_Meas : 7|14@0+ (0.04,0) [0|0] "rad/s" XXX BO_ 534 WheelData: 8 XXX SG_ WhlRotatRr_No_Cnt : 23|8@0+ (1,0) [0|0] "" XXX SG_ WhlDirRr_D_Actl : 33|2@0+ (1,0) [0|0] "" XXX SG_ WhlDirRl_D_Actl : 39|2@0+ (1,0) [0|0] "" XXX SG_ WhlDirFr_D_Actl : 37|2@0+ (1,0) [0|0] "" XXX SG_ WhlDirFl_D_Actl : 35|2@0+ (1,0) [0|0] "" XXX SG_ WhlRotatRl_No_Cnt : 31|8@0+ (1,0) [0|0] "" XXX SG_ WhlRotatFr_No_Cnt : 7|8@0+ (1,0) [0|0] "" XXX SG_ WhlRotatFl_No_Cnt : 15|8@0+ (1,0) [0|0] "" XXX SG_ WHEEL_ROLLING_TIMESTAMP : 47|8@0+ (1,0) [0|0] "" XXX BO_ 947 Doors: 8 XXX SG_ Door_FL_Open : 61|1@0+ (1,0) [0|0] "" XXX SG_ Door_FR_Open : 60|1@0+ (1,0) [0|0] "" XXX SG_ Door_RL_Open : 48|1@0+ (1,0) [0|0] "" XXX SG_ Door_RR_Open : 49|1@0+ (1,0) [0|0] "" XXX BO_ 963 BCM_to_HS_Body: 8 XXX SG_ Brake_Lights : 8|1@0+ (1,0) [0|0] "" XXX BO_ 970 Lane_Keep_Assist_Control: 8 XXX SG_ Lkas_Action : 7|4@0+ (1,0) [0|15] "" XXX SG_ Lkas_Alert : 3|4@0+ (1,0) [0|15] "" XXX SG_ Lane_Curvature : 15|12@0+ (5e-06,-0.01) [0|0] "1/m" XXX SG_ Steer_Angle_Req : 19|12@0+ (0.04297,-88.00445) [0|0] "deg" XXX BO_ 972 Lane_Keep_Assist_Status: 8 XXX SG_ LaHandsOff_B_Actl : 7|1@0+ (1,0) [0|0] "" XXX SG_ LaActDeny_B_Actl : 6|1@0+ (1,0) [0|0] "" XXX SG_ LaActAvail_D_Actl : 5|2@0+ (1,0) [0|0] "" XXX BO_ 984 Lane_Keep_Assist_Ui: 8 XXX SG_ Set_Me_X80 : 39|8@0+ (1,0) [0|255] "" XXX SG_ Set_Me_X45 : 47|8@0+ (1,0) [0|255] "" XXX SG_ Lines_Hud : 55|4@0+ (1,0) [0|15] "" XXX SG_ Hands_Warning_W_Chime : 50|1@0+ (1,0) [0|1] "" XXX SG_ Hands_Warning : 49|1@0+ (1,0) [0|1] "" XXX SG_ Set_Me_X30 : 63|8@0+ (1,0) [0|255] "" XXX CM_ SG_ 970 Lkas_Action "only vals 4, 5, 8, 9 seem to work. 4 and 5 are a bit smoother" ; VAL_ 357 Cruise_State 4 "active" 3 "standby" 0 "off" ; VAL_ 970 Lkas_Action 15 "off" 9 "abrupt" 8 "abrupt2" 5 "smooth" 4 "smooth2" ; VAL_ 970 Lkas_Alert 15 "no_alert" 3 "high_intensity" 2 "mid_intensity" 1 "low_intensity" ; VAL_ 972 LaActAvail_D_Actl 3 "available" 2 "tbd" 1 "not_available" 0 "fault" ; VAL_ 984 Lines_Hud 15 "none" 11 "grey_yellow" 8 "green_red" 7 "yellow_grey" 6 "grey_grey" 4 "red_green" 3 "green_green" ; ================================================ FILE: opendbc/gm_global_a_chassis.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: K182_PACM K43_PSCM K17_EBCM NEO K124_ASCM BO_ 823 PACMParkAssitCmd: 7 NEO SG_ RollingCounter : 35|2@0+ (1,0) [0|0] "" NEO SG_ SteeringWheelChecksum : 47|16@0+ (1,0) [0|0] "" NEO SG_ SteeringWheelCmd : 23|16@0+ (1,0) [0|0] "" NEO BO_ 560 EBCMRegen: 6 K17_EBCM SG_ Regen : 1|10@0+ (1,0) [0|0] "" NEO BO_ 368 EBCMFrictionBrakeStatus: 8 K17_EBCM SG_ FrictionBrakePressure : 23|16@0+ (1,0) [0|0] "" NEO BO_ 789 EBCMFrictionBrakeCmd: 5 K17_EBCM SG_ RollingCounter : 33|2@0+ (1,0) [0|0] "" NEO SG_ FrictionBrakeMode : 7|4@0+ (1,0) [0|0] "" NEO SG_ FrictionBrakeChecksum : 23|16@0+ (1,0) [0|0] "" NEO SG_ FrictionBrakeCmd : 3|12@0- (1,0) [0|0] "" NEO BO_TX_BU_ 823 : K43_PSCM,NEO; BO_TX_BU_ 789 : NEO,K17_EBCM; CM_ BU_ K182_PACM "Parking Assist Control Module"; CM_ BU_ K43_PSCM "Power Steering Control Module"; CM_ BU_ K17_EBCM "Electronic Brake Control Module"; CM_ BU_ NEO "Comma NEO"; CM_ BU_ K124_ASCM "Active Safety Control Module"; BA_DEF_ "UseGMParameterIDs" INT 0 0; BA_DEF_ "ProtocolType" STRING ; BA_DEF_ "BusType" STRING ; BA_DEF_DEF_ "UseGMParameterIDs" 1; BA_DEF_DEF_ "ProtocolType" "GMLAN"; BA_DEF_DEF_ "BusType" ""; BA_ "UseGMParameterIDs" 0; BA_ "BusType" "CAN"; BA_ "ProtocolType" "GMLAN"; ================================================ FILE: opendbc/gm_global_a_object.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: K109_FCM B233B_LRR NEO VIS_FO VIS2_FO K124_ASCM Vector__XXX EOCM_F_FO EOCM2A_IMX6_FO EOCM2A_K2_FO EOCM2A_K1_FO EOCM2B_IMX6_FO EOCM2B_K2_FO EOCM2B_K1_FO VAL_TABLE_ RangeMode 1 "Active" 0 "Inactive" ; VAL_TABLE_ TrkConf 3 "Confident" 2 "Speculative" 1 "Highly speculative" 0 "Invalid" ; VAL_TABLE_ TrkMeasStatus 3 "Measured current cycle" 2 "Latent track not detected" 1 "New object" 0 "No object" ; VAL_TABLE_ TrkDynProp 4 "Moving in opposite direction" 3 "Moving in same direction" 2 "Has moved but currently stopped" 1 "Has never moved," 0 "Unknown" ; VAL_TABLE_ FrntVsnInPthVehBrkNwSt 10 "Active" 5 "Inactive" ; VAL_TABLE_ FrntVsnClostPedBrkNwSt 10 "Active" 5 "Inactive" ; VAL_TABLE_ LaneSnsLLnPosValid 1 "Invalid" 0 "Valid" ; VAL_TABLE_ LnSnsRLnPosValid 1 "Invalid" 0 "Valid" ; VAL_TABLE_ ObjectType 7 "no object present" 6 "fixed roadside object" 5 "fixed overhead object" 4 "pedestrian" 3 "motocycle / bicycle" 2 "Large vehicle (semi)" 1 "4 Wheel Vehicle (car, small trk)" 0 "Unknown" ; VAL_TABLE_ FwVsnCinCoutPotT9Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT8Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT7Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT6Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT5Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT4Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT3Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT2Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT1Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT12Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT11Rev 2 "Right" 1 "Left" 0 "None" ; VAL_TABLE_ FwVsnCinCoutPotT10Rev 2 "Right" 1 "Left" 0 "None" ; BO_ 3221225472 VECTOR__INDEPENDENT_SIG_MSG: 0 Vector__XXX SG_ Always12 : 0|8@0+ (1,0) [0|0] "" Vector__XXX SG_ TimeStatusChecksum : 0|12@0+ (1,0) [0|0] "" Vector__XXX BO_ 161 ASCMTimeStatus: 7 NEO SG_ TimeStatus : 7|28@0+ (1,0) [0|0] "" B233B_LRR SG_ RollingCounter : 27|2@0+ (1,0) [0|0] "" B233B_LRR BO_ 774 ASCMSteeringStatus: 8 NEO SG_ ASCMSterringStatusChecksum : 55|16@0+ (1,0) [0|0] "" B233B_LRR SG_ AlwaysF0 : 15|8@0+ (1,0) [0|0] "" B233B_LRR SG_ Always20 : 23|8@0+ (1,0) [0|0] "" B233B_LRR SG_ RollingCounter : 7|2@0+ (1,0) [0|0] "" B233B_LRR BO_ 784 ASCMHeadlight: 2 NEO SG_ Always42 : 7|8@0+ (1,0) [0|0] "" B233B_LRR SG_ Always4 : 15|8@0+ (1,0) [0|0] "" B233B_LRR BO_ 776 ASCMAccSpeedStatus: 7 NEO SG_ AccSpeedChecksum : 42|11@0+ (1,0) [0|0] "" B233B_LRR SG_ RollingCounter : 46|2@0+ (1,0) [0|0] "" B233B_LRR SG_ NearRangeMode : 43|1@0+ (1,0) [0|0] "" B233B_LRR SG_ FarRangeMode : 44|1@0+ (1,0) [0|0] "" B233B_LRR SG_ VehicleAcceleration : 19|12@0+ (1,0) [0|0] "" B233B_LRR SG_ VehicleSpeed : 15|12@0+ (1,0) [0|0] "" B233B_LRR SG_ AlwaysOne : 3|1@0+ (1,0) [0|0] "" B233B_LRR BO_ 1120 F_LRR_Obj_Header: 8 LRR_FO SG_ FLRRRollingCount : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FLRRModeCmdFdbk : 23|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FLRRNumValidTargets : 20|5@0+ (1,0) [0|31] "" EOCM_F_FO SG_ FLRRTimeStampV : 31|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRTimeStamp : 2|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO SG_ FLRRRoadTypeInfo : 5|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FLRRBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO SG_ FLRRDiagSpare : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRVltgOutRngLo : 44|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRVltgOutRngHi : 43|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRSvcAlgnInPrcs : 38|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRSnsrBlckd : 45|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRSnstvFltPrsntInt : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRPlntAlgnInProc : 37|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRMsalgnYawRt : 47|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRMsalgnYawLt : 46|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRLonVelPlsblityFlt : 35|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRYawRtPlsblityFlt : 34|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRMsalgnPtchUp : 32|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRMsalgnPtchDn : 33|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRInitDiagCmplt : 40|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRHWFltPrsntInt : 25|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRExtIntrfrnc : 36|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRCANSgnlSpvFld : 29|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRCANRxErr : 28|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRTunlDtctd : 27|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRAmbTmpOutRngLw : 42|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRAmbTmpOutRngHi : 41|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRAntTngFltPrsnt : 26|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FLRRAlgnFltPrsnt : 39|1@0+ (1,0) [0|1] "" EOCM_F_FO BO_ 1134 LRRObject14: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1132 LRRObject12: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1131 LRRObject11: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1130 LRRObject10: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1129 LRRObject09: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1128 LRRObject08: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1127 LRRObject07: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1126 LRRObject06: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1125 LRRObject05: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1124 LRRObject04: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1123 LRRObject03: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1140 LRRObject20: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1139 LRRObject19: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1138 LRRObject18: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1137 LRRObject17: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1136 LRRObject16: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1135 LRRObject15: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1133 LRRObject13: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1122 LRRObject02: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1121 LRRObject01: 8 B233B_LRR SG_ TrkRange : 5|11@0+ (0.125,0) [0|255.875] "m" NEO SG_ TrkRangeRate : 10|11@0- (0.125,0) [-128|127.875] "m/s" NEO SG_ TrkRangeAccel : 31|9@0- (0.125,0) [-32|31.875] "m/s^2" NEO SG_ TrkAzimuth : 35|12@0- (0.125,0) [-256|255.875] "deg" NEO SG_ TrkWidth : 55|6@0+ (0.25,0) [0|15.75] "m" NEO SG_ TrkObjectID : 61|6@0+ (1,0) [0|63] "" NEO BO_ 1094 F_Vision_Obj_Track_12: 8 VIS2_FO SG_ FwdVsnObjTypTr12Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FwdVsnAzmthTrk12Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnRngTrk12Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FVisionWidthTrk12 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO SG_ FVisionMeasStatTrk12 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnVertPosTrk12 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FVisionRelLaneTrk12 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk12 : 34|11@0- (0.125,0) [-128|127.875] "deg/sec" EOCM_F_FO SG_ FVisionConfTrk12 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ ObjDirTrk12 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk12 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk12 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO BO_ 1093 F_Vision_Obj_Track_11: 8 VIS2_FO SG_ FwdVsnObjTypTr11Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FwdVsnAzmthTrk11Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnRngTrk11Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FVisionWidthTrk11 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO SG_ FVisionMeasStatTrk11 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnVertPosTrk11 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FVisionRelLaneTrk11 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk11 : 34|11@0- (0.125,0) [-128|127.875] "deg/sec" EOCM_F_FO SG_ FVisionConfTrk11 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ ObjDirTrk11 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk11 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk11 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO BO_ 1100 F_Vision_Obj_Track_12_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT12Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk12 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk12 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk12 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk12 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr12 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk12 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo12 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1099 F_Vision_Obj_Track_11_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT11Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk11 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk11 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk11 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk11 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr11 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk11 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo11 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1098 F_Vision_Obj_Track_10_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT10Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk10 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk10 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk10 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk10 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr10 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk10 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo10 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1097 F_Vision_Obj_Track_9_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT9Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk9 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk9 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk9 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk9 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr9 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk9 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo9 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1096 F_Vision_Obj_Track_8_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT8Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk8 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk8 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk8 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk8 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr8 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk8 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo8 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1095 F_Vision_Obj_Track_7_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT7Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk7 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk7 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk7 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk7 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr7 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk7 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo7 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1068 F_Vision_Obj_Track_6_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT6Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk6 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk6 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk6 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk6 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr6 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk6 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo6 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1067 F_Vision_Obj_Track_5_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT5Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk5 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk5 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk5 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk5 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr5 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk5 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo5 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1066 F_Vision_Obj_Track_4_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT4Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk4 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk4 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk4 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk4 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr4 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk4 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo4 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1065 F_Vision_Obj_Track_3_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT3Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk3 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk3 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk3 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk3 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr3 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk3 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo3 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1064 F_Vision_Obj_Track_2_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT2Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjAgeTrk2 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk2 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk2 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk2 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr2 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk2 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo2 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1063 F_Vision_Obj_Track_1_B: 8 VIS2_FO SG_ FwVsnCinCoutPotT1Rev : 5|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnObjSclChgTrk1 : 15|16@0- (0.0002,0) [-6.5536|6.5534] "pix/sec" EOCM_F_FO SG_ FwdVsnObjAgeTrk1 : 62|7@0+ (1,0) [0|127] "" EOCM_F_FO SG_ FwdVsnLongVlctyTrk1 : 42|12@0- (0.0625,0) [-128|127.9375] "m/sec" EOCM_F_FO SG_ FwdVsnLatOfstTrk1 : 36|10@0- (0.125,0) [-64|63.875] "m" EOCM_F_FO SG_ FwdVsnBrkLtStatTrk1 : 38|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FwdVsnTrnSigStatTr1 : 25|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FrtVsnBrstIDAddInfo1 : 7|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1088 F_Vision_Obj_Header_2: 8 VIS2_FO SG_ FrntVsnInPthVehBrkNwSt : 35|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FrntVsnClostPedBrkNwSt : 39|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FrntVsnClostPedObjID : 29|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FrntVsnClostPedAlrtNwFlg : 30|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrntVsnClostPedNotftnFlg : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrntVsnInPthVehAlrtNwFlg : 2|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrtVsnVldTgtNum2 : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FrtVsnTmStmp2V : 31|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrtVsnTmStmp2 : 10|11@0+ (1,0) [0|2047] "" EOCM_F_FO SG_ FrtVsnRollCnt2 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FrtVsnBrstChksum2 : 55|16@0+ (1,0) [0|65535] "" EOCM_F_FO BO_ 854 F_Vision_Environment_7: 3 VIS2_FO SG_ FwdVsnCnstrctAreaDst : 13|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ FwdVsnCnstrctZnDet : 15|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ FwdVsnEgoVehLnPos : 17|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ FwdVsnRdTypDet : 9|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ FwdVsnTunnlDetd : 23|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ FwdVsnTunnlDst : 21|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBrstID5 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_ 853 F_Vision_Environment_6: 8 VIS2_FO SG_ LnMrkg4LnSnsLnHdngTngtV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnHdngTngt : 23|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnDstV : 56|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnDst : 15|8@0- (0.1,0) [-12.8|12.7] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnCrvtV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnCrvtGradV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnCrvtGrad : 47|16@0- (5.96e-8,0) [-0.0019529728|0.0019529132] "1/(m*sec)" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnSnsLnCrvt : 31|16@0- (9.53e-7,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnQltyConfLvl : 63|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnMrkrTyp : 4|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBrstID4 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_ 852 F_Vision_Environment_5: 8 VIS2_FO SG_ LnMrkg3LnSnsLnHdngTngtV : 7|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnHdngTngt : 23|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnDstV : 56|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnDst : 15|8@0- (0.1,0) [-12.8|12.7] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnCrvtV : 6|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnCrvtGradV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnCrvtGrad : 47|16@0- (5.96e-8,0) [-0.0019529728|0.0019529132] "1/(m*sec)" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnSnsLnCrvt : 31|16@0- (9.53e-7,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnQltyConfLvl : 63|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnMrkrTyp : 4|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBrstID3 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_ 309 LHT_CameraObjConfirmation_FO: 1 VIS_FO SG_ HiBmRecmnd : 1|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ CtLghtDet : 0|1@0+ (1,0) [0|1] "" EOCM_F_FO BO_ 848 F_Vision_Environment: 8 VIS_FO SG_ FwdVsnEnvIllum : 37|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsTngtOfHdngLnRtV : 1|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsTngtOfHdngLnRt : 31|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLnChngStatus : 39|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBurstChecksum : 55|16@0+ (1,0) [0|65535] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LaneSenseRollingCount : 7|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LaneSenseSystemOK : 4|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LaneSnsLLnPosValid : 2|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSenseDistToLLnEdge : 14|7@0+ (0.05,0) [0|6.35] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsRLnPosValid : 0|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsDistToRLnEdge : 22|7@0+ (0.05,0) [0|6.35] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LaneSenseTimeStampV : 5|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LaneSenseTimeStamp : 34|11@0+ (1,0) [0|2047] "ms" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LaneSenseSystemOKV : 3|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_ 849 F_Vision_Environment_2: 8 VIS_FO SG_ LnSnsLatVRelToRgtMrkg : 23|8@0- (0.02,0) [-2.56|2.54] "m/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM_F_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO SG_ LnSnsRtLnMrkgTypChgDst : 61|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsCrvtGrdntRtV : 63|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLnMrkgWdthRt : 62|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsRtAnchrLn : 57|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLtAnchrLn : 56|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLnCrvtrRghtV : 0|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLnCrvtrRght : 47|16@0- (9.53e-7,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsCrvtGrdntRt : 31|16@0- (5.96e-8,0) [-0.0019529728|0.0019529132] "1/rad/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBurstID : 2|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLatVRelToLftMrkg : 15|8@0- (0.02,0) [-2.56|2.54] "m/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_ 1056 F_Vision_Obj_Header: 6 VIS_FO SG_ FVsnSnsrBlckd : 24|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ ClstInPathVehObjID : 30|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FrtVsnFld : 6|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrtVsnIniDiagSuccCmpt : 5|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrtVsnSrvAlgnInPrcs : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FrtVsnUnvlbl : 7|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisionRollingCnt : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVISModeCmdFdbk : 4|3@0+ (1,0) [0|7] "" EOCM_F_FO SG_ FVisionNumValidTrgts : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FVisionTimeStampV : 31|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisionTimeStamp : 10|11@0+ (1,0) [0|2047] "ms" EOCM_F_FO SG_ VISBurstChecksum : 39|16@0+ (1,0) [0|65535] "" EOCM_F_FO BO_ 1057 F_Vision_Obj_Track_1: 8 VIS_FO SG_ FwdVsnRngTrk1Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk1Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr1Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FwdVsnVertPosTrk1 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FVisBurstIDTrk1 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk1 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk1 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk1 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk1 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk1 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk1 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO SG_ ObjDirTrk1 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO BO_ 1058 F_Vision_Obj_Track_2: 8 VIS_FO SG_ FwdVsnVertPosTrk2 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FwdVsnRngTrk2Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk2Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ ObjDirTrk2 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FwdVsnObjTypTr2Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FVisBurstIDTrk2 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk2 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk2 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk2 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk2 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk2 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk2 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 1059 F_Vision_Obj_Track_3: 8 VIS_FO SG_ FwdVsnVertPosTrk3 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FwdVsnRngTrk3Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk3Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr3Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ ObjDirTrk3 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk3 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk3 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk3 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk3 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk3 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk3 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk3 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 1060 F_Vision_Obj_Track_4: 8 VIS_FO SG_ FwdVsnVertPosTrk4 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FVisionMeasStatTrk4 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk4 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO SG_ FwdVsnRngTrk4Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk4Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr4Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FVisBurstIDTrk4 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk4 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ ObjDirTrk4 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisionConfTrk4 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk4 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk4 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO BO_ 1061 F_Vision_Obj_Track_5: 8 VIS_FO SG_ FwdVsnVertPosTrk5 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FwdVsnRngTrk5Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk5Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr5Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ ObjDirTrk5 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk5 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk5 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk5 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk5 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk5 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk5 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk5 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 1062 F_Vision_Obj_Track_6: 8 VIS_FO SG_ FwdVsnVertPosTrk6 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FwdVsnRngTrk6Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk6Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr6Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ ObjDirTrk6 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk6 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk6 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk6 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk6 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk6 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk6 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk6 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 1089 F_Vision_Obj_Track_7: 8 VIS2_FO SG_ FVisBurstIDTrk7 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk7 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk7 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk7 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk7 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk7 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk7 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO SG_ FwdVsnRngTrk7Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnObjTypTr7Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FwdVsnAzmthTrk7Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnVertPosTrk7 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ ObjDirTrk7 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO BO_ 1090 F_Vision_Obj_Track_8: 8 VIS2_FO SG_ FVisBurstIDTrk8 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk8 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FwdVsnAzmthTrk8Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnVertPosTrk8 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FwdVsnRngTrk8Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnObjTypTr8Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ ObjDirTrk8 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisionConfTrk8 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk8 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk8 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk8 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk8 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 1091 F_Vision_Obj_Track_9: 8 VIS2_FO SG_ FwdVsnVertPosTrk9 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ FwdVsnRngTrk9Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk9Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr9Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ ObjDirTrk9 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk9 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk9 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk9 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk9 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk9 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk9 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk9 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 1092 F_Vision_Obj_Track_10: 8 VIS2_FO SG_ FwdVsnRngTrk10Rev : 16|12@0+ (0.1,0) [0|409.5] "m" EOCM_F_FO SG_ FwdVsnAzmthTrk10Rev : 10|10@0- (0.1,0) [-51.2|51.1] "deg" EOCM_F_FO SG_ FwdVsnObjTypTr10Rev : 14|4@0+ (1,0) [0|15] "" EOCM_F_FO SG_ FwdVsnVertPosTrk10 : 53|6@0+ (0.25,-2) [-2|13.75] "deg" EOCM_F_FO SG_ ObjDirTrk10 : 15|1@0+ (1,0) [0|1] "" EOCM_F_FO SG_ FVisBurstIDTrk10 : 1|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionObjectIDTrk10 : 7|6@0+ (1,0) [0|63] "" EOCM_F_FO SG_ FVisionConfTrk10 : 36|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionAzRateTrk10 : 34|11@0- (0.125,0) [-128|127.875] "deg/s" EOCM_F_FO SG_ FVisionRelLaneTrk10 : 55|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionMeasStatTrk10 : 63|2@0+ (1,0) [0|3] "" EOCM_F_FO SG_ FVisionWidthTrk10 : 61|6@0+ (0.25,0) [0|15.75] "m" EOCM_F_FO BO_ 851 F_Vision_Environment_4: 8 VIS_FO SG_ LnMrkg3LnPrvwDst : 45|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsTtlNmLnMrkgDetRt : 4|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsRtLinCrsTm : 25|5@0+ (0.1,0) [0|3.1] "s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsNumPrlLnsDetRt : 33|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsNumPrlLnsDetLt : 36|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsCrvtGrdntLftV : 31|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLtLinCrsTm : 30|5@0+ (0.1,0) [0|3.1] "s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnPrvwDst : 50|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnMrkgTypChgDst : 61|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnMrkgTypChgDst : 40|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnMrkgWdth : 62|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4LnMarkrElvtd : 51|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg4AnchrLnLin : 57|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnMrkgWdth : 41|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3LnMarkrElvtd : 46|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkg3AnchrLnLin : 52|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBurstID2 : 1|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsCrvtGrdntLft : 15|16@0- (5.96e-8,0) [-0.0019529728|0.0019529132] "1/rad/s" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_ 850 F_Vision_Environment_3: 8 VIS_FO SG_ LnSnsTtlNmLnMrkgDetLt : 58|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLtLnMrkgWdth : 63|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLtLnMrkgTypChgDst : 62|4@0+ (10,0) [0|150] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsTngtOfHdngLnLftV : 23|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsTngtOfHdngLnLft : 31|8@0- (0.002,0) [-0.256|0.254] "m/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLnCrvtrLftV : 15|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsLnCrvtrLft : 39|16@0- (9.53e-7,0) [-0.031227904|0.031226951] "1/m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkrTypRght : 50|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkrTypLft : 53|3@0+ (1,0) [0|7] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkrElvtdRght : 54|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnMrkrElvtdLft : 55|1@0+ (1,0) [0|1] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnSnsBurstID1 : 7|2@0+ (1,0) [0|3] "" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnQltyCnfdncLvlRght : 22|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnQltyCnfdncLvlLft : 14|7@0+ (0.7874016,0) [0|100.0000032] "%" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnPrvwDstncRght : 2|3@0+ (10,0) [0|70] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO SG_ LnPrvwDstncLft : 5|3@0+ (10,0) [0|70] "m" EOCM2A_IMX6_FO,EOCM2A_K2_FO,EOCM2A_K1_FO,EOCM2B_IMX6_FO,EOCM2B_K2_FO,EOCM2B_K1_FO,EOCM_F_FO BO_TX_BU_ 161 : K124_ASCM,NEO; BO_TX_BU_ 774 : K124_ASCM,NEO; BO_TX_BU_ 784 : K124_ASCM,NEO; BO_TX_BU_ 776 : K124_ASCM,NEO; CM_ BU_ K109_FCM "Frontview Camera Module"; CM_ BU_ B233B_LRR "Radar Sensor Module Long Range"; CM_ BU_ NEO "Comma NEO"; CM_ BU_ VIS_FO "Front Camera Data"; CM_ BU_ VIS2_FO "Front Camera Data2"; CM_ BU_ K124_ASCM "Active Safety Control Module"; CM_ BO_ 3221225472 "This is a message for not used signals, created by Vector CANdb++ DBC OLE DB Provider."; BA_DEF_ "UseGMParameterIDs" INT 0 0; BA_DEF_ "ProtocolType" STRING ; BA_DEF_ "BusType" STRING ; BA_DEF_DEF_ "UseGMParameterIDs" 1; BA_DEF_DEF_ "ProtocolType" "GMLAN"; BA_DEF_DEF_ "BusType" ""; BA_ "BusType" "CAN"; BA_ "ProtocolType" "GMLAN"; BA_ "UseGMParameterIDs" 0; VAL_ 776 NearRangeMode 1 "Active" 0 "Inactive"; VAL_ 776 FarRangeMode 1 "Active" 0 "Inactive"; ================================================ FILE: opendbc/gm_global_a_powertrain.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: K16_BECM K73_TCIC K9_BCM K43_PSCM K17_EBCM K20_ECM K114B_HPCM NEO K124_ASCM EPB VAL_TABLE_ TurnSignals 2 "Right Turn" 1 "Left Turn" 0 "None" ; VAL_TABLE_ Intellibeam 1 "Active" 0 "Inactive" ; VAL_TABLE_ HighBeamsActive 1 "Active" 0 "Inactive" ; VAL_TABLE_ HighBeamsTemporary 1 "Active" 0 "Inactive" ; VAL_TABLE_ ACCLeadCar 1 "Present" 0 "Not Present" ; VAL_TABLE_ ACCCmdActive 1 "Active" 0 "Inactive" ; VAL_TABLE_ BrakePedalPressed 1 "Pressed" 0 "Depressed" ; VAL_TABLE_ DistanceButton 1 "Active" 0 "Inactive" ; VAL_TABLE_ LKAButton 1 "Active" 0 "Inactive" ; VAL_TABLE_ ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; VAL_TABLE_ DriveModeButton 1 "Active" 0 "Inactive" ; VAL_TABLE_ PRNDL 3 "Reverse" 2 "Drive" 1 "Neutral" 0 "Park" ; VAL_TABLE_ ESPButton 1 "Active" 0 "Inactive" ; VAL_TABLE_ DoorStatus 1 "Opened" 0 "Closed" ; VAL_TABLE_ SeatBeltStatus 1 "Latched" 0 "Unlatched" ; VAL_TABLE_ LKASteeringCmdActive 1 "Active" 0 "Inactive" ; VAL_TABLE_ ACCGapLevel 3 "Far" 2 "Med" 1 "Near" 0 "Inactive" ; VAL_TABLE_ GasRegenCmdActiveInv 1 "Inactive" 0 "Active" ; VAL_TABLE_ GasRegenCmdActive 1 "Active" 0 "Inactive" ; VAL_TABLE_ LKATorqueDeliveredStatus 3 "Failed" 2 "Temp. Limited" 1 "Active" 0 "Inactive" ; VAL_TABLE_ HandsOffSWDetectionStatus 1 "Hands On" 0 "Hands Off" ; VAL_TABLE_ HandsOffSWDetectionMode 2 "Failed" 1 "Enabled" 0 "Disabled" ; BO_ 189 EBCMRegenPaddle: 7 K17_EBCM SG_ RegenPaddle : 7|4@0+ (1,0) [0|0] "" NEO BO_ 190 ECMAcceleratorPos: 6 K20_ECM SG_ BrakePedalPos : 15|8@0+ (1,0) [0|0] "sticky" NEO SG_ GasPedalAndAcc : 23|8@0+ (1,0) [0|0] "" NEO BO_ 201 ECMEngineStatus: 8 K20_ECM SG_ EngineTPS : 39|8@0+ (0.392156863,0) [0|100.000000065] "%" NEO SG_ EngineRPM : 13|14@0+ (0.25,0) [0|0] "RPM" NEO SG_ CruiseMainOn : 29|1@0+ (1,0) [0|1] "" NEO SG_ Brake_Pressed : 40|1@0+ (1,0) [0|1] "" NEO SG_ Standstill : 2|1@0+ (1,0) [0|1] "" NEO BO_ 209 EBCMBrakePedalTorque: 7 K17_EBCM SG_ BrakePedalTorque : 3|12@0+ (1,0) [0|0] "" NEO BO_ 241 EBCMBrakePedalPosition: 6 K17_EBCM SG_ BrakePedalPosition : 15|8@0+ (1,0) [0|255] "" NEO BO_ 298 BCMDoorBeltStatus: 8 K9_BCM SG_ RearLeftDoor : 8|1@0+ (1,0) [0|0] "" NEO SG_ FrontLeftDoor : 9|1@0+ (1,0) [0|0] "" NEO SG_ FrontRightDoor : 10|1@0+ (1,0) [0|0] "" NEO SG_ RearRightDoor : 23|1@0+ (1,0) [0|0] "" NEO SG_ LeftSeatBelt : 12|1@0+ (1,0) [0|0] "" NEO SG_ RightSeatBelt : 53|1@0+ (1,0) [0|0] "" NEO BO_ 309 ECMPRDNL: 8 K20_ECM SG_ PRNDL : 2|3@0+ (1,0) [0|0] "" NEO SG_ ESPButton : 4|1@0+ (1,0) [0|1] "" XXX BO_ 320 BCMTurnSignals: 3 K9_BCM SG_ TurnSignals : 19|2@0+ (1,0) [0|0] "" NEO SG_ Intellibeam : 13|1@0+ (1,0) [0|1] "" XXX SG_ HighBeamsActive : 7|1@0+ (1,0) [0|1] "" XXX SG_ HighBeamsTemporary : 5|1@0+ (1,0) [0|1] "" XXX BO_ 328 PSCM_148: 1 K43_PSCM BO_ 381 ESPStatus: 6 K20_ECM SG_ TractionControlOn : 5|1@0+ (1,0) [0|0] "" NEO SG_ MSG17D_AccPower : 35|12@0- (1,0) [0|0] "" NEO BO_ 384 ASCMLKASteeringCmd: 4 NEO SG_ RollingCounter : 5|2@0+ (1,0) [0|0] "" NEO SG_ LKASteeringCmdChecksum : 19|12@0+ (1,0) [0|0] "" NEO SG_ LKASteeringCmdActive : 3|1@0+ (1,0) [0|0] "" NEO SG_ LKASteeringCmd : 2|11@0- (1,0) [0|0] "" NEO BO_ 388 PSCMStatus: 8 K43_PSCM SG_ HandsOffSWDetectionMode : 20|2@0+ (1,0) [0|3] "" NEO SG_ HandsOffSWlDetectionStatus : 21|1@0+ (1,0) [0|1] "" NEO SG_ LKATorqueDeliveredStatus : 5|3@0+ (1,0) [0|7] "" NEO SG_ LKADriverAppldTrq : 50|11@0- (0.01,0) [-10.24|10.23] "Nm" NEO SG_ LKATorqueDelivered : 18|11@0- (0.01,0) [0|1] "" NEO SG_ LKATotalTorqueDelivered : 2|11@0- (0.01,0) [-10.24|10.23] "Nm" NEO BO_ 417 AcceleratorPedal: 7 XXX SG_ AcceleratorPedal : 55|8@0+ (1,0) [0|0] "" NEO BO_ 451 GasAndAcc: 8 XXX SG_ GasPedalAndAcc2 : 55|8@0+ (1,0) [0|0] "" NEO BO_ 452 AcceleratorPedal2: 8 XXX SG_ CruiseState : 15|3@0+ (1,0) [0|7] "" NEO SG_ AcceleratorPedal2 : 47|8@0+ (1,0) [0|0] "" NEO BO_ 481 ASCMSteeringButton: 7 K124_ASCM SG_ DistanceButton : 22|1@0+ (1,0) [0|0] "" NEO SG_ LKAButton : 23|1@0+ (1,0) [0|0] "" NEO SG_ ACCButtons : 46|3@0+ (1,0) [0|0] "" NEO SG_ DriveModeButton : 39|1@0+ (1,0) [0|1] "" XXX BO_ 485 PSCMSteeringAngle: 8 K43_PSCM SG_ SteeringWheelAngle : 15|16@0- (0.0625,0) [-2047|2047] "deg" NEO SG_ SteeringWheelRate : 27|12@0- (1,0) [-2047|2047] "deg/s" NEO BO_ 489 EBCMVehicleDynamic: 8 K17_EBCM SG_ BrakePedalPressed : 6|1@0+ (1,0) [0|0] "" NEO SG_ LateralAcceleration : 3|10@0- (0.161,0) [-2047|2047] "m/s2" NEO SG_ YawRate : 35|12@0- (0.625,0) [0|1] "" NEO SG_ YawRate2 : 51|12@0- (0.0625,0) [-2047|2047] "grad/s" NEO BO_ 560 EPBStatus: 8 EPB SG_ EPBClosed : 12|1@0+ (1,0) [0|1] "" NEO BO_ 711 BECMBatteryVoltageCurrent: 6 K17_EBCM SG_ HVBatteryVoltage : 31|12@0+ (0.125,0) [0|511.875] "V" NEO SG_ HVBatteryCurrent : 12|13@0- (0.15,0) [-614.4|614.25] "A" NEO BO_ 715 ASCMGasRegenCmd: 8 K124_ASCM SG_ GasRegenAlwaysOne2 : 9|1@0+ (1,0) [0|1] "" NEO SG_ GasRegenAlwaysOne : 14|1@0+ (1,0) [0|1] "" NEO SG_ GasRegenChecksum : 47|24@0+ (1,0) [0|0] "" NEO SG_ GasRegenCmdActiveInv : 32|1@0+ (1,0) [0|0] "" NEO SG_ GasRegenFullStopActive : 13|1@0+ (1,0) [0|0] "" NEO SG_ GasRegenCmdActive : 0|1@0+ (1,0) [0|0] "" NEO SG_ RollingCounter : 7|2@0+ (1,0) [0|0] "" NEO SG_ GasRegenAlwaysOne3 : 23|1@0+ (1,0) [0|1] "" NEO SG_ GasRegenCmd : 22|12@0+ (1,0) [0|0] "" NEO BO_ 717 ASCM_2CD: 5 K124_ASCM BO_ 810 TCICOnStarGPSPosition: 8 K73_TCIC SG_ GPSLongitude : 39|32@0+ (1,-2147483648) [0|0] "milliarcsecond" NEO SG_ GPSLatitude : 7|32@0+ (1,0) [0|0] "milliarcsecond" NEO BO_ 840 EBCMWheelSpdFront: 4 K17_EBCM SG_ FLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO SG_ FRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO BO_ 842 EBCMWheelSpdRear: 5 K17_EBCM SG_ RLWheelSpd : 7|16@0+ (0.0311,0) [0|255] "km/h" NEO SG_ RRWheelSpd : 23|16@0+ (0.0311,0) [0|255] "km/h" NEO BO_ 869 ASCM_365: 4 K124_ASCM BO_ 880 ASCMActiveCruiseControlStatus: 6 K124_ASCM SG_ ACCLeadCar : 44|1@0+ (1,0) [0|0] "" Vector__XXX SG_ ACCAlwaysOne2 : 32|1@0+ (1,0) [0|0] "" Vector__XXX SG_ ACCAlwaysOne : 0|1@0+ (1,0) [0|0] "" Vector__XXX SG_ ACCSpeedSetpoint : 19|12@0+ (1,0) [0|0] "km/h" NEO SG_ ACCGapLevel : 21|2@0+ (1,0) [0|0] "" NEO SG_ ACCResumeButton : 1|1@0+ (1,0) [0|0] "" NEO SG_ ACCCmdActive : 23|1@0+ (1,0) [0|0] "" NEO SG_ FCWAlert : 41|2@0+ (1,0) [0|3] "" XXX BO_ 1001 ECMVehicleSpeed: 8 K20_ECM SG_ VehicleSpeed : 7|16@0+ (0.01,0) [0|0] "mph" NEO BO_ 1033 ASCMKeepAlive: 7 NEO SG_ ASCMKeepAliveAllZero : 7|56@0+ (1,0) [0|0] "" NEO BO_ 1034 ASCM_40A: 7 K124_ASCM BO_ 1217 ECMEngineCoolantTemp: 8 K20_ECM SG_ EngineCoolantTemp : 23|8@0+ (1,-40) [0|0] "C" NEO BO_ 1249 VIN_Part2: 8 K20_ECM SG_ VINPart2 : 7|64@0+ (1,0) [0|0] "" NEO BO_ 1296 ASCM_510: 4 K124_ASCM BO_ 1300 VIN_Part1: 8 K20_ECM SG_ VINPart1 : 7|64@0+ (1,0) [0|0] "" NEO BO_ 1912 PSCM_778: 8 K43_PSCM BO_ 1930 ASCM_78A: 7 K124_ASCM BO_TX_BU_ 384 : K124_ASCM,NEO; BO_TX_BU_ 880 : NEO,K124_ASCM; BO_TX_BU_ 1033 : K124_ASCM,NEO; BO_TX_BU_ 715 : NEO,K124_ASCM; CM_ BU_ K16_BECM "Battery Energy Control Module"; CM_ BU_ K73_TCIC "Telematics Communication Control Module"; CM_ BU_ K9_BCM "Body Control Module"; CM_ BU_ K43_PSCM "Power Steering Control Module"; CM_ BU_ K17_EBCM "Electronic Brake Control Module"; CM_ BU_ K20_ECM "Engine Control Module"; CM_ BU_ K114B_HPCM "Hybrid Powertrain Control Module"; CM_ BU_ NEO "Comma NEO"; CM_ BU_ K124_ASCM "Active Safety Control Module"; CM_ SG_ 381 MSG17D_AccPower "Need to investigate"; CM_ SG_ 190 GasPedalAndAcc "ACC baseline is 62"; CM_ SG_ 451 GasPedalAndAcc2 "ACC baseline is 62"; BA_DEF_ "UseGMParameterIDs" INT 0 0; BA_DEF_ "ProtocolType" STRING ; BA_DEF_ "BusType" STRING ; BA_DEF_DEF_ "UseGMParameterIDs" 1; BA_DEF_DEF_ "ProtocolType" "GMLAN"; BA_DEF_DEF_ "BusType" ""; BA_ "BusType" "CAN"; BA_ "ProtocolType" "GMLAN"; BA_ "UseGMParameterIDs" 0; VAL_ 481 DistanceButton 1 "Active" 0 "Inactive" ; VAL_ 481 LKAButton 1 "Active" 0 "Inactive" ; VAL_ 481 ACCButtons 6 "Cancel" 5 "Main" 3 "Set" 2 "Resume" 1 "None" ; VAL_ 481 DriveModeButton 1 "Active" 0 "Inactive" ; VAL_ 452 CruiseState 4 "Standstill" 3 "Faulted" 1 "Active" 0 "Off" ; VAL_ 309 PRNDL 3 "R" 2 "D" 1 "N" 0 "P" ; VAL_ 309 ESPButton 1 "Active" 0 "Inactive" ; VAL_ 384 LKASteeringCmdActive 1 "Active" 0 "Inactive" ; VAL_ 880 ACCLeadCar 1 "Present" 0 "Not Present" ; VAL_ 880 ACCGapLevel 3 "Far" 2 "Med" 1 "Near" 0 "Inactive" ; VAL_ 880 ACCResumeButton 1 "Pressed" 0 "Depressed" ; VAL_ 880 ACCCmdActive 1 "Active" 0 "Inactive" ; VAL_ 388 HandsOffSWDetectionMode 2 "Failed" 1 "Enabled" 0 "Disabled" ; VAL_ 388 HandsOffSWlDetectionStatus 1 "Hands On" 0 "Hands Off" ; VAL_ 388 LKATorqueDeliveredStatus 3 "Failed" 2 "Temp. Limited" 1 "Active" 0 "Inactive" ; VAL_ 489 BrakePedalPressed 1 "Pressed" 0 "Depressed" ; VAL_ 715 GasRegenCmdActiveInv 1 "Inactive" 0 "Active" ; VAL_ 715 GasRegenCmdActive 1 "Active" 0 "Inactive" ; VAL_ 320 Intellibeam 1 "Active" 0 "Inactive" ; VAL_ 320 HighBeamsActive 1 "Active" 0 "Inactive" ; VAL_ 320 HighBeamsTemporary 1 "Active" 0 "Inactive" ; ================================================ FILE: opendbc/honda_accord_2018_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 13274 LKAS_HUD_A: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 13275 LKAS_HUD_B: 8 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_accord_2018_can.dbc starts here"; BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON BO_ 401 GEARBOX_15T: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX SG_ GEAR2 : 31|8@0+ (1,0) [0|1] "" XXX SG_ GEAR : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 47|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 446 BRAKE_MODULE: 3 VSA SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX SG_ BOH_2 : 30|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 13274 LKAS_HUD_A: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 13275 LKAS_HUD_B: 8 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_civic_hatchback_ex_2017_can.dbc starts here"; BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX SG_ GEAR2 : 31|8@0+ (1,0) [0|1] "" XXX SG_ GEAR : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 47|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 506 LEGACY_BRAKE_COMMAND: 8 ADAS SG_ CHIME : 40|8@1+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|15] "" EON BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX SG_ BOH_2 : 30|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 13274 LKAS_HUD_A: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 13275 LKAS_HUD_B: 8 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_civic_sedan_16_diesel_2019_can.dbc starts here"; BO_ 316 GAS_PEDAL_2: 8 XXX SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 419 GEARBOX: 8 XXX SG_ GEAR_SHIFTER : 24|8@1+ (1,0) [0|255] "" XXX SG_ GEAR : 32|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 432 STANDSTILL: 7 VSA SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 506 LEGACY_BRAKE_COMMAND: 8 ADAS SG_ CHIME : 40|8@1+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|15] "" EON BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH3 : 31|32@0+ (1,0) [0|4294967295] "" XXX SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON VAL_ 419 GEAR_SHIFTER 2 "S" 32 "D" 16 "N" 8 "R" 4 "P" ; VAL_ 419 GEAR 26 "S" 20 "D" 19 "N" 18 "R" 17 "P" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_civic_touring_2016_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_civic_touring_2016_can.dbc starts here"; BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 24|9@0- (-0.02,0) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 ADAS SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 493 HUD_SETTING: 5 XXX SG_ IMPERIAL_UNIT : 5|1@0+ (1,0) [0|1] "" EON BO_ 487 BRAKE_PRESSURE: 4 VSA SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON BO_ 545 ECON_STATUS: 6 XXX SG_ ECON_ON_2 : 37|2@0+ (1,0) [0|3] "" EON SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ CMBS_BUTTON : 22|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ REVERSE_LIGHT : 18|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 862 HIGHBEAM_CONTROL: 8 ADAS SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ DASHBOARD_ALERT : 39|8@0+ (1,0) [0|255] "" EON SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 WIPERS: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 927 RADAR_HUD: 8 ADAS SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; CM_ SG_ 450 EPB_STATE "3 \"engaged\" 2 \"disengaging\" 1 \"engaging\" 0 \"disengaged\""; CM_ SG_ 806 REVERSE_LIGHT "Might be reverse gear selected and not the lights"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 450 EPB_STATE 3 "engaged" 2 "disengaging" 1 "engaging" 0 "disengaged" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 884 DASHBOARD_ALERT 0 "none" 51 "acc_problem" 55 "cmbs_problem" 75 "key_not_detected" 79 "fasten_seatbelt" 111 "lkas_problem" 131 "brake_system_problem" 132 "brake_hold_problem" 139 "tbd" 161 "door_open" VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 927 ACC_ALERTS 29 "esp_active_acc_canceled" 10 "b_pedal_applied" 9 "speed_too_low" 8 "speed_too_high" 7 "p_brake_applied" 6 "gear_no_d" 5 "seatbelt" 4 "too_steep_downhill" 3 "too_steep_uphill" 2 "too_close" 1 "no_vehicle_ahead" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_crv_ex_2017_body_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "honda_crv_ex_2017_body.dbc starts here"; BO_ 318291879 BSM_STATUS_RIGHT: 8 XXX SG_ BSM_ALERT : 4|1@0+ (1,0) [0|1] "" XXX SG_ BSM_MODE : 6|2@0+ (1,0) [0|3] "" XXX BO_ 318291615 BSM_STATUS_LEFT: 8 XXX SG_ BSM_ALERT : 4|1@0+ (1,0) [0|1] "" XXX SG_ BSM_MODE : 6|2@0+ (1,0) [0|3] "" XXX VAL_ 318291879 BSM_MODE 2 "blind_spot" 1 "cross_traffic" 0 "off"; VAL_ 318291615 BSM_MODE 2 "blind_spot" 1 "cross_traffic" 0 "off"; ================================================ FILE: opendbc/honda_crv_ex_2017_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 13274 LKAS_HUD_A: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 13275 LKAS_HUD_B: 8 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_crv_ex_2017_can.dbc starts here"; BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ BOH : 45|6@0+ (1,0) [0|63] "" XXX SG_ GEAR2 : 31|8@0+ (1,0) [0|1] "" XXX SG_ GEAR : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 47|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 446 BRAKE_MODULE: 3 VSA SG_ BRAKE_PRESSED : 4|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" XXX BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH3 : 31|32@0+ (1,0) [0|4294967295] "" XXX SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 344 DISTANCE_COUNTER ""; CM_ SG_ 450 EPB_STATE "3: On, 2: Disengaging, 1: Engaging, 0: Off"; CM_ SG_ 479 CONTROL_ON "Set to 5 when car is being controlled"; CM_ SG_ 479 RELATED_TO_GAS "bits 7, 3, and 1 set to 1 when gas not applied"; CM_ SG_ 479 GAS_BRAKE "Signed value, negative when braking and positive when applying gas"; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_crv_executive_2016_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_crv_executive_2016_can.dbc starts here"; BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 6 EPS SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON SG_ STEER_TORQUE_MOTOR : 23|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON BO_ 404 STEERING_CONTROL: 4 EON SG_ STEER_TORQUE : 7|12@0- (1,0) [-768|768] "" EPS SG_ SET_ME_X00 : 11|4@0+ (1,0) [0|15] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 487 BRAKE_PRESSURE: 4 VSA SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 891 WIPERS: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_crv_hybrid_2019_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 13274 LKAS_HUD_A: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 13275 LKAS_HUD_B: 8 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_crv_hybrid_2019_can.dbc starts here"; BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX SG_ BOH : 40|1@0+ (1,0) [0|1] "" XXX SG_ BOH_2 : 30|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 344 DISTANCE_COUNTER ""; CM_ SG_ 450 EPB_STATE "3: On, 2: Disengaging, 1: Engaging, 0: Off"; CM_ SG_ 479 CONTROL_ON "Set to 5 when car is being controlled"; CM_ SG_ 479 RELATED_TO_GAS "bits 7, 3, and 1 set to 1 when gas not applied"; CM_ SG_ 479 GAS_BRAKE "Signed value, negative when braking and positive when applying gas"; VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; VAL_ 545 ECON_ON_2 0 "off" 3 "on" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_crv_touring_2016_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_crv_touring_2016_can.dbc starts here"; BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 6 EPS SG_ STEER_TORQUE_SENSOR : 7|12@0- (-1,0) [-2047.5|2047.5] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_CONTROL_ACTIVE : 36|1@0+ (1,0) [0|1] "" EON SG_ STEER_STATUS : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 404 STEERING_CONTROL: 4 EON SG_ STEER_TORQUE : 7|12@0- (1,0) [-768|768] "" EPS SG_ SET_ME_X00 : 11|4@0+ (1,0) [0|15] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 487 BRAKE_PRESSURE: 4 VSA SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 891 WIPERS: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_fit_ex_2018_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_fit_ex_2018_can.dbc starts here"; BO_ 145 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON BO_ 228 STEERING_CONTROL: 5 ADAS SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ DRIVERS_DOOR_OPEN : 63|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 487 BRAKE_PRESSURE: 4 VSA SG_ BRAKE_PRESSURE1 : 7|10@0+ (0.015625,-103) [0|1000] "" EON SG_ BRAKE_PRESSURE2 : 9|10@0+ (0.015625,-103) [0|1000] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 862 HIGHBEAM_CONTROL: 8 ADAS SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_insight_ex_2019_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _bosch_2018.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM EON CAM RADAR PCM EPS VSA SCM BDY XXX EPB BO_ 148 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 25|10@0+ (-0.035,17.92) [-20|20] "m/s2" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 228 STEERING_CONTROL: 5 EON SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ SET_ME_X00_2 : 31|8@0+ (1,0) [0|0] "" EPS SG_ STEER_TORQUE : 7|16@0- (1,0) [-4096|4096] "" EPS SG_ STEER_DOWN_TO_ZERO : 38|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" EPS BO_ 229 BOSCH_SUPPLEMENTAL_1: 8 XXX SG_ SET_ME_X04 : 0|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 8|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X80 : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X10 : 24|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 232 BRAKE_HOLD: 7 XXX SG_ XMISSION_SPEED : 7|14@0- (1,0) [1|0] "" XXX SG_ COMPUTER_BRAKE : 39|16@0+ (1,0) [0|0] "" XXX SG_ COMPUTER_BRAKE_REQUEST : 29|1@0+ (1,0) [0|0] "" XXX SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" XXX BO_ 330 STEERING_SENSORS: 8 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ STEER_SENSOR_STATUS_1 : 34|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_2 : 33|1@0+ (1,0) [0|1] "" EON SG_ STEER_SENSOR_STATUS_3 : 32|1@0+ (1,0) [0|1] "" EON SG_ STEER_WHEEL_ANGLE : 47|16@0- (-0.1,0) [-500|500] "deg" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 EPB SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" EON SG_ EPB_STATE : 29|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 479 ACC_CONTROL: 8 EON SG_ SET_TO_0 : 20|5@0+ (1,0) [0|1] "" XXX SG_ CONTROL_ON : 23|3@0+ (1,0) [0|5] "" XXX SG_ GAS_COMMAND : 7|16@0- (1,0) [0|0] "" XXX SG_ ACCEL_COMMAND : 31|11@0- (0.01,0) [0|0] "m/s2" XXX SG_ BRAKE_LIGHTS : 62|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_REQUEST : 34|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 35|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_RELEASE : 36|1@0+ (1,0) [0|1] "" XXX SG_ AEB_STATUS : 33|1@0+ (1,0) [0|1] "" XXX SG_ AEB_BRAKING : 47|1@0+ (1,0) [0|1] "" XXX SG_ AEB_PREPARE : 43|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LAT_ACCEL : 7|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ LONG_ACCEL : 23|16@0- (0.0015,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 495 ACC_CONTROL_ON: 8 XXX SG_ SET_TO_75 : 31|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_30 : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH : 23|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH2 : 47|16@0+ (1,0) [0|255] "" XXX SG_ SET_TO_FF : 15|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_3 : 6|7@0+ (1,0) [0|4095] "" XXX SG_ CONTROL_ON : 7|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 545 XXX_16: 6 SCM SG_ ECON_ON : 23|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_MODE : 37|2@0+ (1,0) [0|3] "" XXX SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" BDY BO_ 576 LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 577 LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 579 RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 580 RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 582 ADJACENT_LEFT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 583 ADJACENT_LEFT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 585 ADJACENT_RIGHT_LANE_LINE_1: 8 CAM SG_ LINE_DISTANCE_VISIBLE : 39|9@0+ (1,0) [0|1] "" XXX SG_ LINE_PROBABILITY : 46|6@0+ (0.015625,0) [0|1] "" XXX SG_ LINE_OFFSET : 23|12@0+ (0.004,-8.192) [0|1] "Meters" XXX SG_ LINE_ANGLE : 7|12@0+ (0.0005,-1.024) [0|1] "" XXX SG_ FRAME_INDEX : 8|4@1+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 586 ADJACENT_RIGHT_LANE_LINE_2: 8 CAM SG_ LINE_FAR_EDGE_POSITION : 55|8@0+ (1,-128) [0|1] "" XXX SG_ LINE_SOLID : 13|1@0+ (1,0) [0|1] "" XXX SG_ LINE_DASHED : 14|1@0+ (1,0) [0|1] "" XXX SG_ LINE_CURVATURE : 23|12@0+ (0.00001,-0.02048) [0|1] "" XXX SG_ LINE_PARAMETER : 39|12@0+ (1,0) [0|1] "" XXX SG_ FRAME_INDEX : 7|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|1] "" XXX BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" XXX SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ LONG_COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 CAR_SPEED: 8 PCM SG_ ROUGH_CAR_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX SG_ CAR_SPEED : 7|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_3 : 39|16@0+ (0.01,0) [0|65535] "kph" XXX SG_ ROUGH_CAR_SPEED_2 : 31|8@0+ (1,0) [0|255] "mph" XXX SG_ LOCK_STATUS : 55|2@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 780 ACC_HUD: 8 ADAS SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "kph" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ ZEROS_BOH : 7|24@0+ (0.002759506,0) [0|100] "m/s" BDY SG_ FCM_OFF : 35|1@0+ (1,0) [0|1] "" BDY SG_ SET_TO_1 : 36|1@0+ (1,0) [0|1] "" XXX SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ ACC_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ BOH_6 : 51|4@0+ (1,0) [0|15] "" XXX SG_ SET_TO_X1 : 55|1@0+ (1,0) [0|1] "" XXX SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 804 CRUISE: 8 PCM SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ DRIVERS_DOOR_OPEN : 17|1@0+ (1,0) [0|1] "" XXX SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ CMBS_STATES : 22|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 862 CAMERA_MESSAGES: 8 CAM SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ ZEROS_BOH_2 : 51|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 884 STALK_STATUS: 8 XXX SG_ AUTO_HEADLIGHTS : 46|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_HOLD : 47|1@0+ (1,0) [0|1] "" EON SG_ HIGH_BEAM_FLASH : 45|1@0+ (1,0) [0|1] "" EON SG_ HEADLIGHTS_ON : 54|1@0+ (1,0) [0|1] "" EON SG_ WIPER_SWITCH : 53|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 891 STALK_STATUS_2: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ LOW_BEAMS : 35|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAMS : 34|1@0+ (1,0) [0|1] "" XXX SG_ PARK_LIGHTS : 36|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 13274 LKAS_HUD_A: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 13275 LKAS_HUD_B: 8 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 20|1@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" BDY CM_ SG_ 479 AEB_STATUS "set for the duration of AEB event"; CM_ SG_ 479 AEB_BRAKING "set when braking is commanded during AEB event"; CM_ SG_ 479 AEB_PREPARE "set 1s before AEB"; CM_ SG_ 576 LINE_DISTANCE_VISIBLE "Length of line visible, undecoded"; CM_ SG_ 577 LINE_FAR_EDGE_POSITION "Appears to be a measure of line thickness, indicates location of the portion of the line furthest from the car, undecoded"; CM_ SG_ 577 LINE_PARAMETER "Unclear if this is low quality line curvature rate or if this is something else, but it is correlated with line curvature, undecoded"; CM_ SG_ 577 LINE_DASHED "1 = line is dashed"; CM_ SG_ 577 LINE_SOLID "1 = line is solid"; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; CM_ "honda_insight_ex_2019_can.dbc starts here"; BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 419 GEARBOX: 8 PCM SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ BRAKE_ERROR_1 : 13|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 12|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON BO_ 927 RADAR_HUD: 8 RADAR SG_ ZEROS_BOH : 7|10@0+ (1,0) [0|127] "" BDY SG_ CMBS_OFF : 12|1@0+ (1,0) [0|1] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_1 : 13|1@0+ (1,0) [0|1] "" BDY SG_ ZEROS_BOH2 : 11|4@0+ (1,0) [0|1] "" XXX SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|1] "" XXX SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|1] "" BDY SG_ SET_TO_0 : 22|1@0+ (1,0) [0|1] "" XXX SG_ HUD_LEAD : 40|1@0+ (1,0) [0|1] "" XXX SG_ SET_TO_64 : 31|8@0+ (1,0) [0|255] "" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|255] "" XXX SG_ ZEROS_BOH3 : 47|7@0+ (1,0) [0|127] "" XXX SG_ ZEROS_BOH4 : 55|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON VAL_ 419 GEAR 10 "R" 1 "D" 0 "P"; VAL_ 419 GEAR_SHIFTER 32 "D" 16 "N" 8 "R" 4 "P" ; CM_ "CHFFR_METRIC 330 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_odyssey_exl_2018_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_odyssey_exl_2018.dbc starts here"; BO_ 228 STEERING_CONTROL: 5 ADAS SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 419 GEARBOX: 8 PCM SG_ GEAR : 7|8@0+ (1,0) [0|256] "" EON SG_ GEAR_SHIFTER : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 450 EPB_STATUS: 8 XXX SG_ EPB_BRAKE_AND_PULL : 6|1@0+ (1,0) [0|1] "" XXX SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX SG_ EPB_STATE : 29|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 662 SCM_BUTTONS: 4 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ CRUISE_SETTING : 3|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 29|2@0+ (1,0) [0|3] "" EON BO_ 806 SCM_FEEDBACK: 8 SCM SG_ CMBS_BUTTON : 22|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 28|1@0+ (1,0) [0|1] "" EON SG_ RIGHT_BLINKER : 27|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 26|1@0+ (1,0) [0|1] "" EON SG_ REVERSE_LIGHT : 18|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 891 WIPERS: 8 XXX SG_ WIPERS : 17|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 862 HIGHBEAM_CONTROL: 8 ADAS SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 927 RADAR_HUD: 8 ADAS SG_ ZEROS_BOH : 7|17@0+ (1,0) [0|127] "" BDY SG_ APPLY_BRAKES_FOR_CANC : 23|1@0+ (1,0) [0|15] "" BDY SG_ ZEROS_BOH2 : 31|8@0+ (1,0) [0|127] "" BDY SG_ RESUME_INSTRUCTION : 21|1@0+ (1,0) [0|15] "" BDY SG_ ACC_ALERTS : 20|5@0+ (1,0) [0|15] "" BDY SG_ LEAD_SPEED : 39|9@0+ (1,0) [0|127] "" BDY SG_ LEAD_STATE : 46|3@0+ (1,0) [0|127] "" BDY SG_ LEAD_DISTANCE : 43|5@0+ (1,0) [0|31] "" BDY SG_ ZEROS_BOH3 : 54|7@0+ (1,0) [0|127] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 419 GEAR "10 = reverse, 11 = transition"; CM_ SG_ 420 BRAKE_HOLD_RELATED "On when Brake Hold engaged"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 806 REVERSE_LIGHT "Might be reverse gear selected and not the lights"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnings etc..."; VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 419 GEAR_SHIFTER 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 450 EPB_STATE 3 "engaged" 2 "disengaging" 1 "engaging" 0 "disengaged" ; VAL_ 662 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 662 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; VAL_ 780 HUD_LEAD 3 "no_car" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; VAL_ 891 WIPERS 4 "High" 2 "Low" 0 "Off" ; VAL_ 927 ACC_ALERTS 29 "esp_active_acc_canceled" 10 "b_pedal_applied" 9 "speed_too_low" 8 "speed_too_high" 7 "p_brake_applied" 6 "gear_no_d" 5 "seatbelt" 4 "too_steep_downhill" 3 "too_steep_uphill" 2 "too_close" 1 "no_vehicle_ahead" ; VAL_ 806 CMBS_BUTTON 3 "pressed" 0 "released" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_odyssey_extreme_edition_2018_china_can.dbc starts here"; BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE_RATE : 23|16@0- (1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|15] "" EON SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-2985|2985] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 43|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON BO_ 401 GEARBOX: 8 PCM SG_ GEAR_SHIFTER : 5|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 35|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 404 STEERING_CONTROL: 4 EON SG_ SET_ME_X00 : 22|7@0+ (1,0) [0|127] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ COUNTER : 29|2@0+ (1,0) [0|15] "" EPS SG_ CHECKSUM : 27|4@0+ (1,0) [0|3] "" EPS SG_ STEER_TORQUE : 7|16@0- (-1,0) [-32767|32767] "" EPS BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ DRIVERS_DOOR_OPEN : 63|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 450 EPB_STATUS: 8 XXX SG_ EPB_BRAKE_AND_PULL : 6|1@0+ (1,0) [0|1] "" XXX SG_ EPB_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX SG_ EPB_STATE : 29|2@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 862 HIGHBEAM_CONTROL: 8 ADAS SG_ ZEROS_BOH : 7|50@0+ (1,0) [0|127] "" BDY SG_ ZEROS_BOH_2 : 48|4@1+ (1,0) [0|15] "" XXX SG_ HIGHBEAMS_ON : 52|1@0+ (1,0) [0|1] "" XXX SG_ AUTO_HIGHBEAMS_ACTIVE : 53|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" XXX SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" XXX BO_ 1302 ODOMETER: 8 XXX SG_ ODOMETER : 7|24@0+ (1,0) [0|16777215] "km" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 401 GEAR "10 = reverse, 11 = transition"; VAL_ 399 STEER_STATUS 5 "fault" 4 "no_torque_alert_2" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 401 GEAR_SHIFTER 32 "L" 16 "S" 8 "D" 4 "N" 2 "R" 1 "P" ; VAL_ 401 GEAR 7 "L" 10 "S" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; ================================================ FILE: opendbc/honda_pilot_touring_2017_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_pilot_touring_2017_can.dbc starts here"; BO_ 145 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON BO_ 228 STEERING_CONTROL: 5 ADAS SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS BO_ 304 GAS_PEDAL_2: 8 PCM SG_ ENGINE_TORQUE_ESTIMATE : 7|16@0- (1,0) [-1000|1000] "Nm" EON SG_ ENGINE_TORQUE_REQUEST : 23|16@0- (1,0) [-1000|1000] "Nm" EON SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _honda_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BU_: EBCM ADAS PCM EPS VSA SCM BDY XXX EPB EON BO_ 344 ENGINE_DATA: 8 PCM SG_ XMISSION_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ XMISSION_SPEED2 : 39|16@0+ (0.01,0) [0|250] "kph" EON SG_ ODOMETER : 55|8@0+ (10,0) [0|2550] "m" XXX SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 380 POWERTRAIN_DATA: 8 PCM SG_ PEDAL_GAS : 7|8@0+ (1,0) [0|255] "" EON SG_ ENGINE_RPM : 23|16@0+ (1,0) [0|15000] "rpm" EON SG_ GAS_PRESSED : 39|1@0+ (1,0) [0|1] "" EON SG_ ACC_STATUS : 38|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH_17C : 37|5@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_SWITCH : 32|1@0+ (1,0) [0|1] "rpm" EON SG_ BOH2_17C : 47|10@0+ (1,0) [0|1] "rpm" EON SG_ BRAKE_PRESSED : 53|1@0+ (1,0) [0|1] "" EON SG_ BOH3_17C : 52|5@0+ (1,0) [0|1] "rpm" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 420 VSA_STATUS: 8 VSA SG_ USER_BRAKE : 7|16@0+ (0.015625,-1.609375) [0|1000] "" EON SG_ COMPUTER_BRAKING : 23|1@0+ (1,0) [0|1] "" EON SG_ ESP_DISABLED : 28|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_RELATED : 52|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_HOLD_ACTIVE : 46|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_HOLD_ENABLED : 45|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 427 STEER_MOTOR_TORQUE: 3 EPS SG_ CONFIG_VALID : 7|1@0+ (1,0) [0|1] "" EON SG_ MOTOR_TORQUE : 1|10@0+ (1,0) [0|256] "" EON SG_ OUTPUT_DISABLED : 22|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 21|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 19|4@0+ (1,0) [0|15] "" EON BO_ 432 STANDSTILL: 7 VSA SG_ CONTROLLED_STANDSTILL : 0|1@0+ (1,0) [0|1] "" EON SG_ WHEELS_MOVING : 12|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_1 : 11|1@0+ (1,0) [0|1] "" EON SG_ BRAKE_ERROR_2 : 9|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 464 WHEEL_SPEEDS: 8 VSA SG_ WHEEL_SPEED_FL : 7|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_FR : 8|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RL : 25|15@0+ (0.01,0) [0|250] "kph" EON SG_ WHEEL_SPEED_RR : 42|15@0+ (0.01,0) [0|250] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 490 VEHICLE_DYNAMICS: 8 VSA SG_ LONG_ACCEL : 23|16@0- (0.0015384,0) [-20|20] "m/s2" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 506 BRAKE_COMMAND: 8 ADAS SG_ COMPUTER_BRAKE : 7|10@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00 : 13|5@0+ (1,0) [0|1] "" EBCM SG_ BRAKE_PUMP_REQUEST : 8|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_2 : 23|3@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_OVERRIDE : 20|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_X00_3 : 19|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_FAULT_CMD : 18|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_CANCEL_CMD : 17|1@0+ (1,0) [0|1] "" EBCM SG_ COMPUTER_BRAKE_REQUEST : 16|1@0+ (1,0) [0|1] "" EBCM SG_ SET_ME_1 : 31|1@0+ (1,0) [0|1] "" EBCM SG_ AEB_REQ_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ AEB_REQ_2 : 26|3@0+ (1,0) [0|7] "" XXX SG_ BRAKE_LIGHTS : 39|1@0+ (1,0) [0|1] "" EBCM SG_ CRUISE_STATES : 38|7@0+ (1,0) [0|1] "" EBCM SG_ CHIME : 47|3@0+ (1,0) [0|7] "" EBCM SG_ SET_ME_X00_4 : 44|1@0+ (1,0) [0|1] "" EBCM SG_ FCW : 43|2@0+ (1,0) [0|3] "" EBCM SG_ AEB_STATUS : 41|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X00_5 : 55|8@0+ (1,0) [0|0] "" EBCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EBCM SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EBCM BO_ 597 ROUGH_WHEEL_SPEED: 8 VSA SG_ WHEEL_SPEED_FL : 7|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_FR : 15|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RL : 23|8@0+ (1,0) [0|255] "mph" EON SG_ WHEEL_SPEED_RR : 31|8@0+ (1,0) [0|255] "mph" EON SG_ SET_TO_X55 : 39|8@0+ (1,0) [0|255] "" EON SG_ SET_TO_X55_2 : 47|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|15] "" EON BO_ 773 SEATBELT_STATUS: 7 BDY SG_ SEATBELT_DRIVER_LAMP : 7|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_UNLATCHED : 10|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_PASS_LATCHED : 11|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_UNLATCHED : 12|1@0+ (1,0) [0|1] "" EON SG_ SEATBELT_DRIVER_LATCHED : 13|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_OFF : 14|1@0+ (1,0) [0|1] "" EON SG_ PASS_AIRBAG_ON : 15|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 777 LOCK_STATUS: 8 XXX SG_ DOORS_UNLOCKED : 54|1@0+ (1,0) [0|1] "" EON SG_ DOORS_LOCKED : 55|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 780 ACC_HUD: 8 ADAS SG_ PCM_SPEED : 7|16@0+ (0.01,0) [0|250] "kph" BDY SG_ PCM_GAS : 23|8@0+ (1,0) [0|127] "" BDY SG_ CRUISE_SPEED : 31|8@0+ (1,0) [0|255] "" BDY SG_ DTC_MODE : 39|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 38|1@0+ (1,0) [0|1] "" BDY SG_ ACC_PROBLEM : 37|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF : 36|1@0+ (1,0) [0|1] "" BDY SG_ FCM_OFF_2 : 35|1@0+ (1,0) [0|1] "" BDY SG_ FCM_PROBLEM : 34|1@0+ (1,0) [0|1] "" BDY SG_ RADAR_OBSTRUCTED : 33|1@0+ (1,0) [0|1] "" BDY SG_ ENABLE_MINI_CAR : 32|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE : 47|2@0+ (1,0) [0|3] "" BDY SG_ HUD_LEAD : 45|2@0+ (1,0) [0|3] "" BDY SG_ BOH_3 : 43|1@0+ (1,0) [0|3] "" BDY SG_ BOH_4 : 42|1@0+ (1,0) [0|3] "" BDY SG_ BOH_5 : 41|1@0+ (1,0) [0|3] "" BDY SG_ CRUISE_CONTROL_LABEL : 40|1@0+ (1,0) [0|3] "" BDY SG_ SET_ME_X01_2 : 55|1@0+ (1,0) [0|1] "" BDY SG_ IMPERIAL_UNIT : 54|1@0+ (1,0) [0|1] "" BDY SG_ HUD_DISTANCE_3 : 52|1@0+ (1,0) [0|1] "" BDY SG_ CHIME : 51|3@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X01 : 48|1@0+ (1,0) [0|1] "" BDY SG_ ICONS : 63|2@0+ (1,0) [0|1] "" BDY SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" BDY BO_ 804 CRUISE: 8 PCM SG_ HUD_SPEED_KPH : 7|8@0+ (1,0) [0|255] "kph" EON SG_ HUD_SPEED_MPH : 15|8@0+ (1,0) [0|255] "mph" EON SG_ TRIP_FUEL_CONSUMED : 23|16@0+ (1,0) [0|255] "" EON SG_ CRUISE_SPEED_PCM : 39|8@0+ (1,0) [0|255] "" EON SG_ BOH2 : 47|8@0- (1,0) [0|255] "" EON SG_ BOH3 : 55|8@0+ (1,0) [0|255] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 829 LKAS_HUD: 5 ADAS SG_ CAM_TEMP_HIGH : 7|1@0+ (1,0) [0|255] "" BDY SG_ SET_ME_X41 : 6|7@0+ (1,0) [0|127] "" BDY SG_ BOH : 6|7@0+ (1,0) [0|127] "" BDY SG_ DASHED_LANES : 14|1@0+ (1,0) [0|1] "" BDY SG_ DTC : 13|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_PROBLEM : 12|1@0+ (1,0) [0|1] "" BDY SG_ LKAS_OFF : 11|1@0+ (1,0) [0|1] "" BDY SG_ SOLID_LANES : 10|1@0+ (1,0) [0|1] "" BDY SG_ LDW_RIGHT : 9|1@0+ (1,0) [0|1] "" BDY SG_ STEERING_REQUIRED : 8|1@0+ (1,0) [0|1] "" BDY SG_ BOH : 23|2@0+ (1,0) [0|4] "" BDY SG_ LDW_PROBLEM : 21|1@0+ (1,0) [0|1] "" BDY SG_ BEEP : 17|2@0+ (1,0) [0|1] "" BDY SG_ LDW_ON : 28|1@0+ (1,0) [0|1] "" BDY SG_ LDW_OFF : 27|1@0+ (1,0) [0|1] "" BDY SG_ CLEAN_WINDSHIELD : 26|1@0+ (1,0) [0|1] "" BDY SG_ SET_ME_X48 : 31|8@0+ (1,0) [0|255] "" BDY SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" BDY SG_ CHECKSUM : 35|4@0+ (1,0) [0|15] "" BDY BO_ 892 CRUISE_PARAMS: 8 PCM SG_ CRUISE_SPEED_OFFSET : 31|8@0- (0.1,0) [-128|127] "kph" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON BO_ 1029 DOORS_STATUS: 8 BDY SG_ DOOR_OPEN_FL : 37|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_FR : 38|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RL : 39|1@0+ (1,0) [0|1] "" EON SG_ DOOR_OPEN_RR : 40|1@0+ (1,0) [0|1] "" EON SG_ TRUNK_OPEN : 41|1@0+ (1,0) [0|1] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON CM_ SG_ 490 LONG_ACCEL "wheel speed derivative, noisy and zero snapping"; CM_ SG_ 506 AEB_REQ_1 "set for duration of suspected AEB event"; CM_ SG_ 773 PASS_AIRBAG_ON "Might just be indicator light"; CM_ SG_ 773 PASS_AIRBAG_OFF "Might just be indicator light"; CM_ SG_ 780 CRUISE_SPEED "255 = no speed"; CM_ SG_ 804 CRUISE_SPEED_PCM "255 = no speed"; CM_ SG_ 829 BEEP "beeps are pleasant, chimes are for warnngs etc..."; VAL_ 506 FCW 3 "fcw" 2 "fcw" 1 "fcw" 0 "no_fcw" ; VAL_ 506 CHIME 4 "double_chime" 3 "single_chime" 2 "continuous_chime" 1 "repeating_chime" 0 "no_chime" ; VAL_ 506 AEB_STATUS 3 "aeb_prepare" 2 "aeb_ready" 1 "aeb_braking" 0 "no_aeb" ; VAL_ 780 CRUISE_SPEED 255 "no_speed" 252 "stopped" ; VAL_ 780 HUD_LEAD 3 "acc_off" 2 "solid_car" 1 "dashed_car" 0 "no_car" ; VAL_ 829 BEEP 3 "single_beep" 2 "triple_beep" 1 "repeated_beep" 0 "no_beep" ; CM_ "Imported file _comma.dbc starts here"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.253984064,-83.3) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.253984064,-83.3) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.126992032,-83.3) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "honda_ridgeline_black_edition_2017_can.dbc starts here"; BO_ 145 KINEMATICS: 8 XXX SG_ LAT_ACCEL : 7|10@0+ (0.02,-512) [-20|20] "m/s2" EON BO_ 228 STEERING_CONTROL: 5 ADAS SG_ STEER_TORQUE : 7|16@0- (1,0) [-3840|3840] "" EPS SG_ STEER_TORQUE_REQUEST : 23|1@0+ (1,0) [0|1] "" EPS SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|0] "" EPS SG_ COUNTER : 37|2@0+ (1,0) [0|3] "" EPS SG_ CHECKSUM : 35|4@0+ (1,0) [0|3] "" EPS BO_ 316 GAS_PEDAL: 8 PCM SG_ CAR_GAS : 39|8@0+ (1,0) [0|255] "" EON BO_ 342 STEERING_SENSORS: 6 EPS SG_ STEER_ANGLE : 7|16@0- (-0.1,0) [-500|500] "deg" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-1,0) [-3000|3000] "deg/s" EON SG_ COUNTER : 45|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 43|4@0+ (1,0) [0|3] "" EON BO_ 399 STEER_STATUS: 7 EPS SG_ STEER_TORQUE_SENSOR : 7|16@0- (-1,0) [-31000|31000] "tbd" EON SG_ STEER_ANGLE_RATE : 23|16@0- (-0.1,0) [-31000|31000] "deg/s" EON SG_ STEER_STATUS : 39|4@0+ (1,0) [0|15] "" EON SG_ STEER_CONTROL_ACTIVE : 35|1@0+ (1,0) [0|1] "" EON SG_ STEER_CONFIG_INDEX : 43|4@0+ (1,0) [0|15] "" EON SG_ COUNTER : 53|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 51|4@0+ (1,0) [0|3] "" EON BO_ 419 GEARBOX: 8 PCM SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON SG_ GEAR_SHIFTER : 29|6@0+ (1,0) [0|63] "" EON SG_ GEAR : 7|8@0+ (1,0) [0|255] "" EON BO_ 422 SCM_BUTTONS: 8 SCM SG_ CRUISE_BUTTONS : 7|3@0+ (1,0) [0|7] "" EON SG_ LIGHTS_SETTING : 1|2@0+ (1,0) [0|3] "" EON SG_ MAIN_ON : 47|1@0+ (1,0) [0|1] "" EON SG_ CRUISE_SETTING : 43|2@0+ (1,0) [0|3] "" EON SG_ COUNTER : 61|2@0+ (1,0) [0|3] "" EON SG_ CHECKSUM : 59|4@0+ (1,0) [0|3] "" EON BO_ 660 SCM_FEEDBACK: 8 SCM SG_ RIGHT_BLINKER : 6|1@0+ (1,0) [0|1] "" EON SG_ LEFT_BLINKER : 5|1@0+ (1,0) [0|1] "" EON SG_ WIPERS_SPEED : 4|2@0+ (1,0) [0|3] "" EON VAL_ 399 STEER_STATUS 6 "tmp_fault" 5 "fault_1" 4 "no_torque_alert_2" 3 "low_speed_lockout" 2 "no_torque_alert_1" 0 "normal" ; VAL_ 419 GEAR_SHIFTER 32 "D" 8 "R" 4 "P" ; VAL_ 422 CRUISE_BUTTONS 7 "tbd" 6 "tbd" 5 "tbd" 4 "accel_res" 3 "decel_set" 2 "cancel" 1 "main" 0 "none" ; VAL_ 422 LIGHTS_SETTING 3 "high_beam" 2 "low_beam" 1 "position" 0 "no_lights" ; VAL_ 422 CRUISE_SETTING 3 "distance_adj" 2 "tbd" 1 "lkas_button" 0 "none" ; CM_ "CHFFR_METRIC 342 STEER_ANGLE STEER_ANGLE 0.36 180; CHFFR_METRIC 380 ENGINE_RPM ENGINE_RPM 1 0; CHFFR_METRIC 804 ENGINE_TEMPERATURE ENGINE_TEMPERATURE 1 0"; ================================================ FILE: opendbc/hyundai_kia_generic.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: IAP ODS _4WD BCM HUD DATC MDPS AAF_Tester AEMC SMK _4WD EPB CUBIS MTS TMU EVP CGW TPMS LPI DI_BOX SPAS EMS LCA TCU IBOX FATC AFLS FPCM SCC AHLS AVM ABS SNV OPI PGS SAS AAF Dummy LDWS_LKAS LVR ESC PSB CLU ECS ACU REA BO_ 1532 ODS13: 5 ODS SG_ CR_Ods_ID : 0|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_Chksum_H : 8|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy SG_ CR_Ods_Chksum_L : 16|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy SG_ CR_Ods_RomID_H : 24|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy SG_ CR_Ods_RomID_L : 32|8@1+ (1.0,0.0) [0.0|255.0] "" Dummy BO_ 1531 ODS12: 8 ODS SG_ CR_Ods_SerNum0 : 0|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum1 : 8|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum3 : 24|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum4 : 32|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum5 : 40|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum6 : 48|8@1+ (1.0,0.0) [0.0|255.0] "" ACU SG_ CR_Ods_SerNum7 : 56|8@1+ (1.0,0.0) [0.0|255.0] "" ACU BO_ 1530 ODS11: 8 ODS SG_ CF_Ods_PrcCmd : 1|1@1+ (1.0,0.0) [0.0|1.0] "" Dummy SG_ CF_Ods_BtsFail : 3|1@1+ (1.0,0.0) [0.0|1.0] "" Dummy SG_ CF_Ods_AcuRcvSN : 4|1@1+ (1.0,0.0) [0.0|1.0] "" ACU SG_ CF_Ods_EolCal : 5|1@1+ (1.0,0.0) [0.0|1.0] "" ACU SG_ CF_Ods_PsFail : 6|1@1+ (1.0,0.0) [0.0|1.0] "" ACU SG_ CF_Ods_EcuFail : 7|1@1+ (1.0,0.0) [0.0|1.0] "" ACU SG_ CF_Ods_WgtStat : 8|1@1+ (1.0,0.0) [0.0|1.0] "" ACU SG_ CF_Ods_OccStat : 16|1@1+ (1.0,0.0) [0.0|1.0] "" ACU SG_ CR_Wcs_ErrStat : 32|8@1+ (1.0,0.0) [0.0|63.0] "" ACU SG_ CR_Wcs_ClassStat : 40|8@1+ (1.0,0.0) [0.0|4.0] "" ACU,BCM BO_ 1017 ECS12: 4 ECS SG_ Height_FL : 0|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS SG_ Height_FR : 8|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS SG_ Height_RL : 16|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS SG_ Height_RR : 24|8@1+ (1.0,-128.0) [-128.0|127.0] "mm" AFLS BO_ 1268 SPAS12: 8 SPAS SG_ CF_Spas_HMI_Stat : 0|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ CF_Spas_Disp : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS SG_ CF_Spas_FIL_Ind : 10|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_FIR_Ind : 13|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_FOL_Ind : 16|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_FOR_Ind : 19|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_VolDown : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_RIL_Ind : 24|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_RIR_Ind : 27|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_FLS_Alarm : 30|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_ROL_Ind : 32|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_ROR_Ind : 35|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_FCS_Alarm : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_FI_Ind : 40|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_RI_Ind : 43|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU SG_ CF_Spas_FRS_Alarm : 46|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_FR_Alarm : 48|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_Spas_RR_Alarm : 50|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_Spas_BEEP_Alarm : 52|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU SG_ CF_Spas_StatAlarm : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Spas_RLS_Alarm : 57|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_RCS_Alarm : 59|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_RRS_Alarm : 61|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1265 CLU11: 4 CLU SG_ CF_Clu_CruiseSwState : 0|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,LDWS_LKAS,SCC SG_ CF_Clu_CruiseSwMain : 3|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,LDWS_LKAS,SCC SG_ CF_Clu_SldMainSW : 4|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Clu_ParityBit1 : 5|1@1+ (1.0,0.0) [0.0|1.0] "pulse count" EMS SG_ CF_Clu_VanzDecimal : 6|2@1+ (0.125,0.0) [0.0|0.375] "" EMS SG_ CF_Clu_Vanz : 8|9@1+ (0.5,0.0) [0.0|255.5] "km/h or MPH" BCM,CUBIS,EMS,IBOX,LDWS_LKAS,MDPS,SCC SG_ CF_Clu_SPEED_UNIT : 17|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CUBIS,EMS,IBOX,LDWS_LKAS,MDPS,SCC SG_ CF_Clu_DetentOut : 18|1@1+ (1.0,0.0) [0.0|1.0] "" AVM,BCM,LCA,PGS,SPAS SG_ CF_Clu_RheostatLevel : 19|5@1+ (1.0,0.0) [0.0|31.0] "" AVM,BCM,LCA,PGS,SPAS SG_ CF_Clu_CluInfo : 24|1@1+ (1.0,0.0) [0.0|1.0] "" BCM SG_ CF_Clu_AmpInfo : 25|1@1+ (1.0,0.0) [0.0|1.0] "" BCM SG_ CF_Clu_AliveCnt1 : 28|4@1+ (1.0,0.0) [0.0|15.0] "" AHLS,EMS,EPB,LDWS_LKAS,MDPS,SCC BO_ 1492 TMU_GW_PE_01: 8 CLU SG_ TMU_IVRActivity : 0|2@1+ (1.0,0.0) [0.0|3.0] "" DATC SG_ TMU_PhoneActivity : 2|2@1+ (1.0,0.0) [0.0|3.0] "" DATC BO_ 1491 HU_DATC_PE_00: 8 CLU SG_ HU_VRActivity : 0|2@1+ (1.0,0.0) [0.0|3.0] "" DATC SG_ HU_PhoneActivity : 2|2@1+ (1.0,0.0) [0.0|3.0] "" DATC SG_ BlowerNoiseControl : 4|2@1+ (1.0,0.0) [0.0|3.0] "" DATC BO_ 1490 HU_DATC_E_02: 8 CLU SG_ HU_DATC_RearOnOffSet : 6|2@1+ (1.0,0.0) [0.0|3.0] "" DATC SG_ HU_DATC_ADSOnOffSet : 8|2@1+ (1.0,0.0) [0.0|3.0] "" DATC BO_ 1479 EMS21: 8 EMS SG_ SCR_LEVEL_WARN_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ SCR_LEVEL_WARN : 1|3@1+ (1.0,0.0) [0.0|4.0] "" CLU SG_ SCR_SYS_ERROR_WARN : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ SCR_SYSTEM_WARN_LAMP : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ SCR_INDUCEMENT_EXIT_COND : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ SCR_UREA_LEVEL : 16|8@1+ (0.5,0.0) [0.0|100.0] "%" CLU SG_ SCR_NO_REMAINING_RESTARTS : 24|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ SCR_REMAINING_DISTANCE : 32|16@1+ (1.0,0.0) [0.0|25000.0] "km" CLU BO_ 1472 GW_Warning_PE: 8 BCM SG_ Audio_VolumeDown : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ Pas_Spkr_Flh_Alarm : 48|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ Pas_Spkr_Fcnt_Alarm : 50|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ Pas_Spkr_Frh_Alarm : 52|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ Pas_Spkr_Rlh_Alarm : 56|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,PGS SG_ Pas_Spkr_Rcnt_Alarm : 58|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ Pas_Spkr_Rrh_Alarm : 60|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,PGS BO_ 1984 CAL_SAS11: 2 ESC SG_ CCW : 0|4@1+ (1.0,0.0) [0.0|15.0] "" SAS SG_ SAS_CID : 4|11@1+ (1.0,0.0) [0.0|2047.0] "" SAS BO_ 1456 CLU12: 4 CLU SG_ CF_Clu_Odometer : 0|24@1+ (0.1,0.0) [0.0|1677721.4] "km" _4WD,AAF,BCM,CUBIS,EMS,EPB,IBOX,LDWS_LKAS,SCC,TPMS BO_ 688 SAS11: 5 MDPS SG_ SAS_Angle : 0|16@1- (0.1,0.0) [-3276.8|3276.7] "Deg" _4WD,ACU,AFLS,AVM,CLU,ECS,EMS,ESC,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SPAS,TCU,_4WD,ACU,AFLS,AVM,BCM,CLU,ECS,EMS,ESC,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SPAS,TCU SG_ SAS_Speed : 16|8@1+ (4.0,0.0) [0.0|1016.0] "" AFLS,ECS,ESC,IBOX,LDWS_LKAS,SCC,SPAS,TCU,AFLS,ECS,ESC,IBOX,LDWS_LKAS,SCC,SPAS,TCU SG_ SAS_Stat : 24|8@1+ (1.0,0.0) [0.0|255.0] "" ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU,ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU SG_ MsgCount : 32|4@1+ (1.0,0.0) [0.0|15.0] "" ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,ECS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS SG_ CheckSum : 36|4@1+ (1.0,0.0) [0.0|15.0] "" ECS,EMS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS,ECS,EMS,ESC,IBOX,LDWS_LKAS,PSB,SCC,SPAS BO_ 1441 ACU12: 8 ACU SG_ CR_Acu_SN : 0|64@1+ (1.0,0.0) [0.0|0.0] "" ODS BO_ 1440 ACU11: 8 ACU SG_ CF_Ods_SNRcv : 1|1@1+ (1.0,0.0) [0.0|1.0] "" ODS SG_ CF_Ods_IDRcv : 2|1@1+ (1.0,0.0) [0.0|1.0] "" ODS SG_ CF_Ods_RZReq : 4|1@1+ (1.0,0.0) [0.0|1.0] "" ODS SG_ CF_Abg_DepInhEnt : 6|1@1+ (1.0,0.0) [0.0|1.0] "" ODS SG_ CF_Abg_DepEnt : 7|1@1+ (1.0,0.0) [0.0|1.0] "" ODS SG_ CF_PasBkl_FltStat : 28|1@1+ (1.0,0.0) [0.0|1.0] "" ODS,PSB SG_ CF_DriBkl_FltStat : 29|1@1+ (1.0,0.0) [0.0|1.0] "" ODS,PSB SG_ CF_PasBkl_Stat : 30|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,ODS,PSB,TMU SG_ CF_DriBkl_Stat : 31|1@1+ (1.0,0.0) [0.0|1.0] "" ODS,PSB SG_ CF_SWL_Ind : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CUBIS,IBOX SG_ CF_Acu_FltStat : 34|2@1+ (1.0,0.0) [0.0|3.0] "" CUBIS,IBOX SG_ CF_Acu_ExtOfSab : 36|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,CUBIS,IBOX SG_ CF_Acu_Dtc : 40|16@1+ (1.0,0.0) [0.0|65535.0] "" CUBIS,IBOX SG_ CF_Acu_NumOfFlt : 56|8@1+ (1.0,0.0) [0.0|255.0] "" CUBIS,IBOX BO_ 1437 AHLS11: 8 AHLS SG_ CF_Ahls_WarnLamp : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Ahls_WarnMsg : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1434 PSB11: 2 PSB SG_ PSB_LH_FAIL : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ PSB_LH_TGL : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ PSB_LH_ACT : 3|4@1+ (1.0,0.0) [0.0|4.0] "" Dummy SG_ PSB_RH_FAIL : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ PSB_RH_TGL : 10|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ PSB_RH_ACT : 11|4@1+ (1.0,0.0) [0.0|4.0] "" Dummy BO_ 916 TCS13: 8 ESC SG_ aBasis : 0|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,SCC SG_ BrakeLight : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,SCC SG_ DCEnable : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC SG_ AliveCounterTCS : 13|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,SCC SG_ Pre_TCS_CTL : 16|1@1+ (1.0,0.0) [0.0|1.0] "" Vector__XXX SG_ EBA_ACK : 17|1@1+ (1.0,0.0) [0.0|1.0] "" Vector__XXX SG_ FCA_ACK : 18|1@1+ (1.0,0.0) [0.0|1.0] "" Vector__XXX SG_ DF_BF_STAT : 19|2@1+ (1.0,0.0) [0.0|3.0] "" BCW SG_ SCCReqLim : 21|2@1+ (1.0,0.0) [0.0|3.0] "" SCC SG_ TQI_SCC : 23|9@1+ (0.390625,0.0) [0.0|199.609375] "%" Vector__XXX SG_ ACCEL_REF_ACC : 32|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" EMS,SCC SG_ ACCEnable : 43|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC SG_ DriverOverride : 45|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,SCC SG_ StandStill : 47|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC SG_ CheckSum_TCS3 : 48|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,SCC SG_ ACC_EQUIP : 52|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC SG_ PBRAKE_ACT : 53|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC SG_ ACC_REQ : 54|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ DriverBraking : 55|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,SCC SG_ CF_VSM_Coded : 56|1@1+ (1.0,0.0) [0.0|1.0] "" SCC SG_ CF_VSM_Avail : 57|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,SCC SG_ CF_VSM_Handshake : 59|1@1+ (1.0,0.0) [0.0|1.0] "" SCC SG_ CF_DriBkeStat : 60|1@1+ (1.0,0.0) [0.0|1.0] "" SCC SG_ CF_VSM_ConfSwi : 61|2@1+ (1.0,0.0) [0.0|3.0] "" SCC SG_ AEB_EQUIP : 63|1@1+ (1.0,0.0) [0.0|1.0] "" SCC BO_ 1427 TPMS11: 6 BCM SG_ TPMS_W_LAMP : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,HUD,IBOX,CLU,CUBIS,HUD,IBOX SG_ TREAD_W_LAMP : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,HUD,IBOX,CLU,CUBIS,HUD,IBOX SG_ POS_FL_W_LAMP : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX SG_ POS_FR_W_LAMP : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX SG_ POS_RL_W_LAMP : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX SG_ POS_RR_W_LAMP : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,HUD,IBOX SG_ STATUS_TPMS : 8|3@1+ (1.0,0.0) [0.0|0.0] "" CLU SG_ UNIT : 11|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ PRESSURE_FL : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ PRESSURE_FR : 24|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ PRESSURE_RL : 32|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ PRESSURE_RR : 40|8@1+ (1.0,0.0) [0.0|255.0] "" CLU BO_ 915 TCS12: 4 ESC SG_ SA_COUNT : 0|16@1+ (2.0,-32768.0) [-32768.0|98302.0] "" _4WD,ACU,MDPS SG_ SA_Z_COUNT : 16|15@1+ (2.0,-32768.0) [-32768.0|32766.0] "" _4WD,ACU,MDPS SG_ SA_Z_FLAG : 31|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,MDPS BO_ 1170 EMS19: 8 EMS SG_ CF_Ems_BrkReq : 0|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX,TCU SG_ CF_Ems_DnShftReq : 1|4@1+ (1.0,0.0) [0.0|14.0] "" IBOX,TCU SG_ CF_Ems_RepModChk : 5|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX SG_ CF_Ems_AAFOpenReq : 7|1@1+ (1.0,0.0) [0.0|1.0] "" AAF,IBOX SG_ CF_Ems_DecelReq : 8|12@1+ (0.0010,-4.094) [-4.094|0.0] "m/s^2" ESC,IBOX,TCU SG_ CR_Ems_BstPre : 20|12@1+ (1.322,0.0) [0.0|4094.0] "hPa" CLU,IBOX SG_ CR_Ems_EngOilTemp : 32|8@1+ (0.75,-40.0) [0.0|254.0] "deg" CLU,IBOX SG_ DPF_LAMP_STAT : 40|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX SG_ BAT_LAMP_STAT : 42|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_ModeledAmbTemp : 48|8@1+ (0.5,-41.0) [-41.0|85.5] "deg" AAF,IBOX SG_ CF_Ems_OPSFail : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_AliveCounterEMS9 : 58|2@1+ (1.0,0.0) [0.0|3.0] "" AAF,ABS,CUBIS,ECS,EPB,IBOX,MDPS,REA,SCC,SMK,TCU SG_ CF_Ems_ChecksumEMS9 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" AAF,ABS,CUBIS,ECS,EPB,IBOX,MDPS,REA,SCC,SMK,TCU BO_ 1425 AFLS11: 2 AFLS SG_ AFLS_STAT : 1|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Afls_TrfChgStat : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Afls_LedHLStat : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 912 SPAS11: 7 SPAS SG_ CF_Spas_Stat : 0|4@1+ (1.0,0.0) [0.0|15.0] "" ESC,MDPS SG_ CF_Spas_TestMode : 4|2@1+ (1.0,0.0) [0.0|3.0] "" MDPS SG_ CR_Spas_StrAngCmd : 8|16@1- (0.1,0.0) [-3276.8|3276.7] "" MDPS SG_ CF_Spas_BeepAlarm : 24|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ CF_Spas_Mode_Seq : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Spas_AliveCnt : 32|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS SG_ CF_Spas_Chksum : 40|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS SG_ CF_Spas_PasVol : 48|3@1+ (1.0,0.0) [0.0|7.0] "" CGW,CLU BO_ 1168 EPB11: 7 EPB SG_ EPB_I_LAMP : 0|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU,CUBIS,ESC,IBOX SG_ EPB_F_LAMP : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,ESC,IBOX SG_ EPB_ALARM : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC SG_ EPB_CLU : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,ESC SG_ EPB_SWITCH : 16|2@1+ (1.0,0.0) [0.0|3.0] "" ESC,SCC SG_ EPB_RBL : 18|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,ESC SG_ EPB_STATUS : 19|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EMS,ESC,SCC,TCU SG_ EPB_FRC_ERR : 22|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,SCC,TCU SG_ EPB_DBF_STAT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" ESC SG_ ESP_ACK : 25|1@1+ (1.0,0.0) [0.0|1.0] "" ESC SG_ EPB_DBF_REQ : 26|1@1+ (1.0,0.0) [0.0|1.0] "" ESC SG_ EPB_FAIL : 29|3@1+ (1.0,0.0) [0.0|7.0] "" ESC,SCC SG_ EPB_FORCE : 32|12@1+ (1.0,-1000.0) [-1000.0|3000.0] "" ESC SG_ EPB_DBF_DECEL : 48|8@1+ (0.01,0.0) [0.0|2.54] "g" ESC BO_ 399 EMS_H12: 8 EMS SG_ R_TqAcnApvC : 0|8@1+ (0.2,0.0) [0.0|51.0] "Nm" DATC,IBOX SG_ R_PAcnC : 8|8@1+ (125.0,0.0) [0.0|31875.0] "hPa" DATC,IBOX SG_ TQI_B : 16|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ABS,ESC,IBOX SG_ SLD_VS : 24|8@1+ (1.0,0.0) [0.0|255.0] "km/h" CLU,IBOX SG_ CF_CdaStat : 32|3@1+ (1.0,0.0) [0.0|7.0] "" AEMC,IBOX,TCU SG_ CF_Ems_IsgStat : 35|3@1+ (1.0,0.0) [0.0|7.0] "" ABS,BCM,CLU,DATC,EPB,ESC,IBOX,LDWS_LKAS,MDPS,SMK,TCU SG_ CF_Ems_OilChg : 38|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_EtcLimpMod : 39|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ R_NEngIdlTgC : 40|8@1+ (10.0,0.0) [0.0|2550.0] "rpm" DATC,IBOX,TCU SG_ CF_Ems_UpTarGr : 48|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_DownTarGr : 49|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_DesCurGr : 50|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX SG_ CF_Ems_SldAct : 54|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_SldPosAct : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_HPresStat : 56|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU SG_ CF_Ems_IsgBuz : 57|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_IdlStpFCO : 58|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_FCopen : 59|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Ems_ActEcoAct : 60|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,TCU SG_ CF_Ems_EngRunNorm : 61|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC,IBOX,TCU SG_ CF_Ems_IsgStat2 : 62|2@1+ (2.0,0.0) [0.0|3.0] "" CLU,IBOX,TCU BO_ 1419 LCA11: 8 LCA SG_ CF_Lca_Stat : 0|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU SG_ CF_Rcta_Stat : 4|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU SG_ CF_Lca_IndLeft : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_Rcw_Stat : 10|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU SG_ CF_RCW_Warning : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_Lca_IndRight : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_Lca_SndWan_Stat : 18|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_FR_SndWan : 20|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU SG_ CF_FL_SndWan : 21|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU SG_ CF_RR_SndWan : 22|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU SG_ CF_RL_SndWan : 23|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU SG_ CF_Lca_IndBriLeft : 24|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU SG_ CF_Lca_IndBriRight : 32|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU SG_ CF_RCTA_IndBriLeft : 40|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU SG_ CF_RCTA_IndBriRight : 48|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU SG_ CF_RCTA_IndLeft : 56|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_RCTA_IndRight : 58|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU SG_ CF_SndWarnForClu : 60|1@1+ (1.0,0.0) [0.0|1.0] "" CLU BO_ 906 ABS11: 8 ABS SG_ ABS_DEF : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,EMS,SPAS,TCU SG_ EBD_DEF : 1|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,SPAS,TCU SG_ ABS_ACT : 2|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,EPB,SPAS,TCU SG_ ABS_W_LAMP : 3|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,CUBIS,MTS,TMU SG_ EBD_W_LAMP : 4|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU SG_ ABS_DIAG : 5|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU SG_ ESS_STAT : 6|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,BCM,CLU,EMS BO_ 903 WHL_PUL11: 6 ABS SG_ WHL_PUL_FL : 0|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS SG_ WHL_PUL_FR : 8|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS SG_ WHL_PUL_RL : 16|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS SG_ WHL_PUL_RR : 24|8@1+ (0.5,0.0) [0.0|127.5] "pulse count" CUBIS,EPB,IBOX,SPAS,TMU,TPMS,CUBIS,EPB,IBOX,LDWS_LKAS,SPAS,TMU,TPMS SG_ WHL_DIR_FL : 32|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS SG_ WHL_DIR_FR : 34|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS SG_ WHL_DIR_RL : 36|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS SG_ WHL_DIR_RR : 38|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,SPAS,TPMS,EPB,LCA,SPAS,TPMS SG_ WHL_PUL_Chksum : 40|8@1+ (1.0,0.0) [0.0|255.0] "" EPB,SPAS,TPMS,EPB,LCA,LDWS_LKAS,SPAS,TPMS BO_ 1415 TMU11: 8 IBOX SG_ CF_Tmu_VehSld : 0|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Tmu_VehImmo : 1|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Tmu_ReqRepCnd : 2|2@1+ (1.0,0.0) [0.0|3.0] "" EMS SG_ CF_Tmu_AirconCtr : 4|1@1+ (1.0,0.0) [0.0|1.0] "" DATC SG_ CF_Tmu_TempMd : 5|1@1+ (1.0,0.0) [0.0|1.0] "" DATC SG_ CF_Tmu_TempSet : 6|16@1+ (1.0,0.0) [0.0|20.0] "" DATC SG_ CF_Tmu_DefrostCtr : 22|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,FATC SG_ CF_Tmu_AliveCnt1 : 56|4@1+ (1.0,0.0) [0.0|15.0] "" EMS BO_ 902 WHL_SPD11: 8 ABS SG_ WHL_SPD_FL : 0|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,AFLS,AHLS,AVM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS SG_ WHL_SPD_FR : 16|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,ACU,AFLS,AHLS,AVM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS SG_ WHL_SPD_RL : 32|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,AFLS,AHLS,AVM,BCM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,BCM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS SG_ WHL_SPD_RR : 48|14@1+ (0.03125,0.0) [0.0|511.96875] "km/h" _4WD,AFLS,AHLS,AVM,CLU,CUBIS,ECS,EMS,EPB,IBOX,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS,_4WD,ACU,AFLS,AHLS,AVM,CLU,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PGS,PSB,SCC,SMK,SPAS,TCU,TPMS SG_ WHL_SPD_AliveCounter_LSB : 14|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU SG_ WHL_SPD_AliveCounter_MSB : 30|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU SG_ WHL_SPD_Checksum_LSB : 46|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU SG_ WHL_SPD_Checksum_MSB : 62|2@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU BO_ 1414 EVP11: 3 EVP SG_ CF_Evp_Stat : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU BO_ 1412 AAF11: 8 AAF SG_ CF_Aaf_ActFlapStatus : 0|2@1+ (1.0,0.0) [0.0|3.0] "" AAF_Tester SG_ CF_Aaf_ModeStatus : 2|3@1+ (1.0,0.0) [0.0|7.0] "" AAF_Tester SG_ CF_Aaf_WrnLamp : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Aaf_ErrStatus : 6|10@1+ (1.0,0.0) [0.0|1023.0] "" AAF_Tester,EMS SG_ CF_Aaf_OpenRqSysAct : 16|8@1+ (1.0,0.0) [0.0|255.0] "" AAF_Tester SG_ CF_Aaf_PStatus : 24|8@1+ (1.0,0.0) [0.0|100.0] "%" AAF_Tester SG_ CF_Aaf_OpenRqSysSol : 32|8@1+ (1.0,0.0) [0.0|255.0] "" AAF_Tester SG_ CF_Aaf_SolFlapStatus : 40|2@1+ (1.0,0.0) [0.0|3.0] "" AAF_Tester SG_ CF_Aaf_MilOnReq : 42|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 900 EMS17: 8 EMS SG_ CF_Ems_PkpCurMSV : 0|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX SG_ CF_Ems_HolCurMSV : 8|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX SG_ CF_Ems_InjVBnkAct : 16|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX SG_ CF_Ems_InjVActSet : 24|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX SG_ CF_Ems_DiagFulHDEV : 32|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX SG_ CF_Ems_SwiOffIC1 : 33|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX SG_ CF_Ems_SwiOffIC2 : 34|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX SG_ CF_Ems_DiagReqHDEV : 38|1@1+ (1.0,0.0) [0.0|1.0] "" DI_BOX SG_ CR_Ems_DutyCycMSV : 40|8@1+ (0.3921568627,0.0) [0.0|100.0] "%" DI_BOX SG_ CR_Ems_BatVolRly : 48|8@1+ (0.1,0.0) [0.0|25.5] "V" DI_BOX BO_ 387 REA11: 8 REA SG_ CF_EndBst_PwmDuH : 0|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_PwmDuL : 1|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_PwmFqOutRng : 2|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_HbriOverCur : 3|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_HbriOverTemp : 4|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_PosSnsKOR : 6|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_PosSnsOSOR : 7|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_EepFlt : 8|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_RomFlt : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_RamFlt : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_CanFlt : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_AgH : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_AgL : 13|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_EndBst_ORVol : 14|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CR_EndBst_ActPos : 16|16@1+ (0.117,0.0) [1.989|118.053] "" EMS SG_ CR_EndBst_DemPos : 32|16@1+ (0.117,0.0) [0.0|119.691] "" EMS SG_ CR_EndBst_HbriPwr : 48|16@1+ (0.045,0.0) [0.0|99.99] "%" EMS BO_ 1411 CUBIS11: 8 CUBIS SG_ CF_Cubis_HUDisp : 0|4@1+ (1.0,0.0) [0.0|15.0] "" CLU BO_ 899 FATC11: 8 DATC SG_ CR_Fatc_TqAcnOut : 0|8@1+ (0.2,0.0) [0.0|50.8] "Nm" EMS,IBOX SG_ CF_Fatc_AcnRqSwi : 8|1@1+ (1.0,0.0) [0.0|1.0] "" AAF,EMS,IBOX SG_ CF_Fatc_AcnCltEnRq : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Fatc_EcvFlt : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Fatc_BlwrOn : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_FATC_Iden : 12|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX SG_ CF_Fatc_BlwrMax : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX SG_ CF_Fatc_EngStartReq : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Fatc_IsgStopReq : 16|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Fatc_CtrInf : 17|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,IBOX SG_ CF_Fatc_MsgCnt : 20|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,IBOX SG_ CR_Fatc_OutTemp : 24|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" BCM,CLU,EMS,IBOX,SPAS,TCU,TPMS SG_ CR_Fatc_OutTempSns : 32|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" AAF,AHLS,CLU,EMS,IBOX,SPAS,TCU SG_ CF_Fatc_Compload : 40|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,IBOX SG_ CF_Fatc_ActiveEco : 43|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Fatc_AutoActivation : 44|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX SG_ CF_Fatc_DefSw : 45|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,IBOX SG_ CF_Fatc_PtcRlyStat : 46|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Fatc_ChkSum : 56|8@1+ (1.0,0.0) [0.0|255.0] "" EMS,IBOX,SPAS BO_ 129 EMS_DCT12: 8 EMS SG_ CR_Ems_SoakTimeExt : 0|6@1+ (5.0,0.0) [0.0|315.0] "Min" TCU SG_ BRAKE_ACT : 6|2@1+ (1.0,0.0) [0.0|3.0] "" TCU SG_ CF_Ems_EngOperStat : 8|8@1+ (1.0,0.0) [0.0|255.0] "" TCU SG_ CR_Ems_IndAirTemp : 16|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" TCU SG_ CF_Ems_Alive2 : 56|4@1+ (1.0,0.0) [0.0|15.0] "" TCU SG_ CF_Ems_ChkSum2 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" TCU BO_ 897 MDPS11: 8 MDPS SG_ CF_Mdps_WLmp : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,CUBIS,EMS,IBOX,SPAS SG_ CF_Mdps_Flex : 2|3@1+ (1.0,0.0) [0.0|3.0] "" CLU,LDWS_LKAS SG_ CF_Mdps_FlexDisp : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Mdps_Stat : 7|4@1+ (1.0,0.0) [0.0|15.0] "" SPAS SG_ CR_Mdps_DrvTq : 11|12@1+ (1.0,-2048.0) [-2048.0|2046.0] "" SPAS SG_ CF_Mdps_ALTRequest : 23|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CR_Mdps_StrAng : 24|16@1- (0.1,0.0) [-3276.8|3276.7] "Deg" SPAS SG_ CF_Mdps_AliveCnt : 40|8@1+ (1.0,0.0) [0.0|255.0] "" LDWS_LKAS,SPAS SG_ CF_Mdps_Chksum : 48|8@1+ (1.0,0.0) [0.0|255.0] "" LDWS_LKAS,SPAS SG_ CF_Mdps_SPAS_FUNC : 57|1@1+ (1.0,0.0) [0.0|1.0] "flag" SPAS SG_ CF_Mdps_LKAS_FUNC : 58|1@1+ (1.0,0.0) [0.0|1.0] "flag" LDWS_LKAS SG_ CF_Mdps_CurrMode : 59|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS SG_ CF_Mdps_Type : 61|2@1+ (1.0,0.0) [0.0|2.0] "" LDWS_LKAS,SPAS SG_ CF_MDPS_VSM_FUNC : 56|1@0+ (1.0,0.0) [0.0|1.0] "" XXX BO_ 896 DI_BOX13: 8 DI_BOX SG_ CF_DiBox_HPreInjVConfStat : 0|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_HPreInjVStat1 : 8|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_HPreInjVStat2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_HPreInjVPkp : 24|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_HPreInjVBpt : 32|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_ErrRegFrtMSV : 40|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_ErrRegSedMSV : 48|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_SPIErrSedMSV : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_SPIErrFrtMSV : 57|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_IDErrSedMSV : 58|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_IDErrFrtMSV : 59|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_IniStatMSV : 60|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 640 EMS13: 8 EMS SG_ LV_FUEL_TYPE_ECU : 0|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,LPI,SMK SG_ LV_BFS_CFIRM : 1|1@1+ (1.0,0.0) [0.0|1.0] "" LPI SG_ LV_CRASH : 2|1@1+ (1.0,0.0) [0.0|1.0] "" LPI SG_ LV_VB_OFF_ACT : 3|1@1+ (1.0,0.0) [0.0|1.0] "" LPI SG_ LV_GSL_MAP M : 4|1@1+ (1.0,0.0) [0.0|1.0] "" LPI SG_ LV_ENG_TURN : 5|1@1+ (1.0,0.0) [0.0|1.0] "" LPI SG_ ERR_FUEL : 8|8@1+ (1.0,0.0) [0.0|255.0] "" LPI SG_ EOS : 16|8@1+ (1.0,0.0) [0.0|255.0] "" LPI SG_ TCO : 24|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" LPI SG_ N_32 : 32|8@1+ (32.0,0.0) [0.0|8160.0] "rpm" LPI SG_ MAF : 40|8@1+ (5.447,0.0) [0.0|1388.985] "mg/TDC" LPI SG_ TIA : 48|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" LPI SG_ MAP m1 : 56|8@1+ (0.47058,0.0) [0.0|119.9979] "kPa" LPI SG_ AMP m0 : 56|8@1+ (21.22,0.0) [0.0|5411.1] "hPa" LPI BO_ 128 EMS_DCT11: 8 EMS SG_ PV_AV_CAN : 0|8@1+ (0.3906,0.0) [0.0|99.603] "%" TCU SG_ TQ_STND : 8|6@1+ (10.0,0.0) [0.0|630.0] "Nm" TCU SG_ F_N_ENG : 14|1@1+ (1.0,0.0) [0.0|1.0] "" TCU SG_ F_SUB_TQI : 15|1@1+ (1.0,0.0) [0.0|1.0] "" TCU SG_ N : 16|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" TCU SG_ TQI_ACOR : 32|8@1+ (0.390625,0.0) [0.0|99.6094] "%" IBOX,TCU SG_ TQFR : 40|8@1+ (0.390625,0.0) [0.0|99.6094] "%" TCU SG_ TQI : 48|8@1+ (0.390625,0.0) [0.0|99.609375] "%" TCU SG_ CF_Ems_Alive : 56|4@1+ (1.0,0.0) [0.0|15.0] "" TCU SG_ CF_Ems_ChkSum : 60|4@1+ (1.0,0.0) [0.0|15.0] "" TCU BO_ 1407 HU_MON_PE_01: 8 CLU SG_ HU_Type : 0|8@1+ (1.0,0.0) [0.0|255.0] "" AVM,PGS BO_ 127 CGW5: 8 BCM SG_ C_StopLampLhOpenSts : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_StopLampRhOpenSts : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_HMSLOpenSts : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_HLampLowLhOpenSts : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_HLampLowRhOpenSts : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_HLampHighLhOpenSts : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_HLampHighRhOpenSts : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_DRLLampLhOpenSts : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_DRLLampRhOpenSts : 8|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_RearFOGLhOpenSts : 9|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_RearFOGRhOpenSts : 10|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_FrontFOGLhOpenSts : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_FrontFOGRhOpenSts : 12|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_RearEXTTailLhOpenSts : 13|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_RearEXTTailRhOpenSts : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_FrontEXTTailLhOpenSts : 15|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_FrontEXTTailRhOpenSts : 16|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_RearTSIGLhOpenSts : 17|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_RearTSIGRhOpenSts : 18|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_FrontTSIGLhOpenSts : 19|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_FrontTSIGRhOpenSts : 20|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_SBendingLhOpenSts : 21|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_SBendingRhOpenSts : 22|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_LicensePlateLhOpenSts : 23|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_LicensePlateRhOpenSts : 24|1@1+ (1.0,0.0) [0.0|1.0] "" CLU BO_ 1151 ESP11: 6 ESC SG_ AVH_STAT : 0|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EPB,TCU SG_ LDM_STAT : 2|1@1+ (1.0,0.0) [0.0|1.0] "" EPB,TCU SG_ REQ_EPB_ACT : 3|2@1+ (1.0,0.0) [0.0|3.0] "" EPB,TCU SG_ REQ_EPB_STAT : 5|1@1+ (1.0,0.0) [0.0|1.0] "" EPB SG_ ECD_ACT : 6|1@1+ (1.0,0.0) [0.0|1.0] "" EPB SG_ _4WD_LIM_REQ : 7|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS SG_ ROL_CNT_ESP : 8|8@1+ (1.0,0.0) [0.0|255.0] "" EPB,TCU SG_ _4WD_TQC_LIM : 16|16@1+ (1.0,0.0) [0.0|65535.0] "Nm" _4WD,EMS SG_ _4WD_CLU_LIM : 32|8@1+ (0.390625,0.0) [0.0|99.609375] "%" _4WD,EMS SG_ _4WD_OPEN : 40|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,EMS SG_ _4WD_LIM_MODE : 42|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD BO_ 1397 HU_AVM_E_00: 8 CLU SG_ HU_AVM_Cal_Cmd : 0|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_Cal_Method : 4|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS SG_ HU_AVM_Save_Controlpoint : 6|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS SG_ HU_AVM_PT_X : 8|12@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_RearViewPointOpt : 20|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_PT_Y : 24|12@1+ (1.0,0.0) [0.0|4095.0] "" AVM,PGS SG_ HU_AVM_FrontViewPointOpt : 36|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_SelectedMenu : 40|5@1+ (1.0,0.0) [0.0|31.0] "" AVM,PGS SG_ HU_AVM_CameraOff : 45|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS SG_ HU_AVM_Option : 48|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_CrossLineMove_Cmd : 52|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_RearView_Option : 56|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_FrontView_Option : 60|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS BO_ 1395 HU_AVM_E_01: 8 CLU SG_ HU_PGSSelectedMenu : 0|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_PGSOption : 8|5@1+ (1.0,0.0) [0.0|31.0] "" AVM,PGS SG_ HU_AVM_ParkingAssistMenu : 56|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS SG_ HU_AVM_ParkingAssistSB : 60|4@1+ (1.0,0.0) [0.0|15.0] "" AVM,PGS BO_ 1393 OPI11: 5 OPI SG_ CR_Opi_Spd_Rpm : 0|8@1+ (20.0,0.0) [0.0|3500.0] "rpm" TCU SG_ CF_Opi_Over_Temp : 8|1@1+ (1.0,0.0) [0.0|1.0] "" TCU SG_ CF_Opi_Over_Cur : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,TCU SG_ CF_Opi_Over_Vol : 10|1@1+ (1.0,0.0) [0.0|1.0] "" TCU SG_ CF_Opi_Hall_Fail : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,TCU SG_ CF_Opi_Flt : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,TCU SG_ CF_Opi_Motor_Dir : 15|1@1+ (1.0,0.0) [0.0|1.0] "" TCU SG_ CF_Opi_Romver : 16|8@1+ (1.0,0.0) [0.0|255.0] "" TCU SG_ CF_Opi_PWM_Rate : 24|12@1+ (1.0,0.0) [0.0|100.0] "%" TCU BO_ 625 LPI11: 8 LPI SG_ FUP_LPG_MMV : 0|8@1+ (128.0,0.0) [0.0|32640.0] "hPa" EMS SG_ LV_FUEL_TYPE_BOX : 8|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ LV_BFS_IN_PROGRESS : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ LV_GAS_OK : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ LV_FUP_ENA_THD : 11|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,EMS,SMK SG_ LPI_OBD : 12|4@1+ (1.0,0.0) [0.0|15.0] "" EMS SG_ ERR_GAS : 16|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ FAC_TI_GAS_COR : 24|16@1+ (3.05E-5,0.0) [0.0|1.9988175] "" EMS SG_ FTL_AFU : 40|8@1+ (0.392,0.0) [0.0|99.96] "%" EMS SG_ BFS_CYL : 48|8@1+ (1.0,0.0) [0.0|6.0] "Cyl Nr." EMS SG_ LV_PRE_CDN_LEAK : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ LV_CONF_INJECTION_DELAY : 57|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ LV_LPG_SW_DRIVER_REQ : 58|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 356 VSM11: 4 ESC SG_ CR_Esc_StrTqReq : 0|12@1+ (0.01,-20.48) [-20.48|20.47] "Nm" MDPS SG_ CF_Esc_Act : 12|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS,MDPS SG_ CF_Esc_CtrMode : 13|3@1+ (1.0,0.0) [0.0|7.0] "" MDPS SG_ CF_Esc_Def : 16|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS SG_ CF_Esc_AliveCnt : 17|4@1+ (1.0,0.0) [0.0|15.0] "" LDWS_LKAS,MDPS SG_ CF_Esc_Chksum : 24|8@1+ (1.0,0.0) [0.0|255.0] "" LDWS_LKAS,MDPS BO_ 1379 PGS_HU_PE_01: 8 PGS SG_ PGS_State : 0|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ PGS_ParkGuideState : 8|5@1+ (1.0,0.0) [0.0|31.0] "" CLU SG_ PGS_Option : 16|5@1+ (1.0,0.0) [0.0|31.0] "" CLU SG_ PGS_Version : 32|16@1+ (1.0,0.0) [0.0|65535.0] "" CLU BO_ 354 TCU_DCT13: 3 TCU SG_ Clutch_Driving_Tq : 0|10@1+ (1.0,-512.0) [0.0|0.0] "Nm" ESC SG_ Cluster_Engine_RPM : 10|13@1+ (0.9766,0.0) [0.0|0.0] "" CLU SG_ Cluster_Engine_RPM_Flag : 23|1@1+ (1.0,0.0) [0.0|0.0] "" CLU BO_ 1378 HUD11: 4 HUD SG_ CF_Hud_HeightStaus : 0|5@1+ (1.0,0.0) [0.0|31.0] "" CLU SG_ CF_Hud_PBackStatus : 6|2@1+ (1.0,0.0) [0.0|0.0] "" BCM,CLU SG_ CF_Hud_Brightness : 8|5@1+ (1.0,0.0) [0.0|31.0] "" CLU BO_ 608 EMS16: 8 EMS SG_ TQI_MIN : 0|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ESC,IBOX,TCU SG_ TQI : 8|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ESC,IBOX,TCU SG_ TQI_TARGET : 16|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EPB,ESC,IBOX,TCU SG_ GLOW_STAT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,IBOX,SMK SG_ CRUISE_LAMP_M : 25|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,TCU SG_ CRUISE_LAMP_S : 26|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,TCU SG_ PRE_FUEL_CUT_IN : 27|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU SG_ ENG_STAT : 28|3@1+ (1.0,0.0) [0.0|7.0] "" ABS,AHLS,AVM,BCM,CLU,EPB,ESC,EVP,FPCM,IBOX,LCA,LDWS_LKAS,MDPS,SCC,SMK,TCU SG_ SOAK_TIME_ERROR : 31|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,EPB,IBOX,TCU SG_ SOAK_TIME : 32|8@1+ (1.0,0.0) [0.0|255.0] "Min" _4WD,DATC,EPB,IBOX,TCU SG_ TQI_MAX : 40|8@1+ (0.390625,0.0) [0.0|99.609375] "%" ESC,IBOX,TCU SG_ SPK_TIME_CUR : 48|8@1+ (0.375,-35.625) [-35.625|60.0] "" IBOX,TCU SG_ Checksum : 56|4@1+ (1.0,0.0) [0.0|15.0] "" ECS,IBOX,LDWS_LKAS,MDPS,SCC SG_ AliveCounter : 60|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX,LDWS_LKAS,MDPS,SCC SG_ CF_Ems_AclAct : 62|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX,SCC BO_ 1371 AVM_HU_PE_00: 8 AVM SG_ AVM_View : 0|5@1+ (1.0,0.0) [0.0|31.0] "" CLU SG_ AVM_ParkingAssist_BtnSts : 5|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ AVM_Display_Message : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ AVM_Popup_Msg : 16|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_Ready : 20|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_ParkingAssist_Step : 24|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_FrontBtn_Type : 28|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_Option : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_HU_FrontViewPointOpt : 36|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_HU_RearView_Option : 40|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_HU_FrontView_Option : 44|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ AVM_Version : 48|16@1+ (1.0,0.0) [0.0|65535.0] "" CLU BO_ 1370 HU_AVM_PE_00: 8 CLU SG_ HU_AVM_Status : 0|2@1+ (1.0,0.0) [0.0|3.0] "" AVM,PGS BO_ 1369 CGW4: 8 BCM SG_ CF_Gway_MemoryP1Cmd : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_MemoryP2Cmd : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_PBackP1Cmd : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_PBackP2Cmd : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_StrgWhlHeatedState : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_PBackStopCmd : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,HUD SG_ CF_Gway_StaticBendLhAct : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_StaticBendRhAct : 7|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_DrvWdwStat : 8|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_RLWdwState : 9|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_RRWdwState : 10|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_AstWdwStat : 11|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_MemoryEnable : 12|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_PBACKStopCmd : 13|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_PBACKStop : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,HUD SG_ CF_Gway_IMSBuzzer : 15|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_DrvSeatBeltInd : 36|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_AstSeatBeltInd : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_RCSeatBeltInd : 40|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_RLSeatBeltInd : 42|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_RRSeatBeltInd : 44|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_RrWiperHighSw : 46|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_RrWiperLowSw : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CLU BO_ 1367 EngFrzFrm12: 8 EMS SG_ PID_06h : 0|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU SG_ PID_07h : 8|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU SG_ PID_08h : 16|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU SG_ PID_09h : 24|8@1+ (0.78125,-100.0) [-100.0|99.22] "%" AAF,IBOX,TCU SG_ PID_0Bh : 32|8@1+ (1.0,0.0) [0.0|255.0] "kPa" AAF,IBOX,TCU SG_ PID_23h : 40|16@1+ (10.0,0.0) [0.0|655350.0] "kPa" AAF,IBOX,TCU BO_ 1366 EngFrzFrm11: 8 EMS SG_ PID_04h : 0|8@1+ (0.3921568627,0.0) [0.0|100.0] "%" AAF,TCU SG_ PID_05h : 8|8@1+ (1.0,-40.0) [-40.0|215.0] "deg" AAF,TCU SG_ PID_0Ch : 16|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" AAF,TCU SG_ PID_0Dh : 32|8@1+ (1.0,0.0) [0.0|255.0] "km/h" AAF,TCU SG_ PID_11h : 40|8@1+ (0.3921568627,0.0) [0.0|100.0] "%" AAF,TCU SG_ PID_03h : 48|16@1+ (1.0,0.0) [0.0|65535.0] "" AAF,TCU BO_ 1365 FPCM11: 8 FPCM SG_ CR_Fpcm_LPActPre : 0|8@1+ (3.137254902,0.0) [0.0|800.0] "kPa" EMS SG_ CF_Fpcm_LPPumpOverCur : 8|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_PreSnrHi : 9|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_PreSnrDisc : 10|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_PreSnrShort : 11|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_LPPumpDiscShort : 12|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_LP_System_Error : 13|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_PreSnrSigErr : 14|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Fpcm_LPCtrCirFlt : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 871 LVR12: 8 LVR SG_ CF_Lvr_CruiseSet : 0|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,TCU SG_ CF_Lvr_Gear : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,TCU BO_ 872 LVR11: 8 LVR SG_ CF_Lvr_GearInf : 0|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,TCU SG_ CF_Lvr_PRelStat : 4|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,SMK,TCU SG_ CF_Lvr_BkeAct : 5|1@1+ (1.0,0.0) [0.0|1.0] "" TCU SG_ CF_Lvr_NFnStat : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Lvr_PosInf : 8|4@1+ (1.0,0.0) [0.0|15.0] "" TCU SG_ CF_Lvr_PosCpl : 12|4@1+ (1.0,0.0) [0.0|15.0] "" TCU SG_ CF_Lvr_UlkButStat : 18|2@1+ (1.0,0.0) [0.0|3.0] "" TCU SG_ CF_Lvr_PNStat : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Lvr_ShtLkStat : 24|4@1+ (1.0,0.0) [0.0|15.0] "" TCU SG_ CF_Lvr_ShfErrInf : 28|20@1+ (1.0,0.0) [0.0|8191.0] "" CLU,TCU SG_ CF_Lvr_AC : 48|4@1+ (1.0,0.0) [0.0|15.0] "" TCU SG_ CF_Lvr_CS : 52|4@1+ (1.0,0.0) [0.0|15.0] "" TCU BO_ 1363 CGW2: 8 BCM SG_ CF_Gway_GwayDiagState : 0|1@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_DDMDiagState : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_SCMDiagState : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_PSMDiagState : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_SJBDiagState : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_IPMDiagState : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_LDMFail : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,LDWS_LKAS,LDWS_LKAS SG_ CF_Gway_CLUSwGuiCtrl : 10|3@1+ (1.0,0.0) [0.0|63.0] "" CLU,Dummy SG_ CF_Gway_CLUSwGroup : 13|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_CLUSwMode : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_CLUSwEnter : 15|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_AutoLightValue : 16|1@1+ (1.0,0.0) [0.0|1.0] "" LCA,LCA SG_ CF_Gway_BrakeFluidSw : 17|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_DrvSeatBeltInd : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_AvTail : 20|1@1+ (1.0,0.0) [0.0|3.0] "" CLU,SNV,SNV SG_ CF_Gway_RearFogAct : 21|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_ExtTailAct : 22|1@1+ (1.0,0.0) [0.0|1.0] "" AVM,CLU,LCA,PGS,SPAS,AVM,LCA,PGS,SPAS SG_ CF_Gway_RRDrSw : 23|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_RLDrSw : 24|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_IntTailAct : 25|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_CountryCfg : 26|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,Dummy SG_ CF_Gway_WiperParkPosition : 32|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,EMS,LDWS_LKAS,AFLS,EMS,LDWS_LKAS SG_ CF_Gway_HLLowLHFail : 33|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS,SNV,LDWS_LKAS,SNV SG_ CF_Gway_HLLowRHFail : 34|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS,SNV,LDWS_LKAS,SNV SG_ CF_Gway_ESCLFailWarn : 35|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_ESCLNotLockedWarn : 36|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_ESCLNotUnlockWarn : 37|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_IDoutWarn : 38|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_ImmoLp : 40|1@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_BCMRKEID : 41|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy SG_ CF_Gway_VehicleNotPWarn : 44|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_DeactivationWarn : 45|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_KeyBATDischargeWarn : 46|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_SSBWarn : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_SMKFobID : 48|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy SG_ CF_Gway_SMKRKECmd : 51|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy SG_ CF_Gway_AutoLightOption : 54|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_SJBDeliveryMode : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_KeyoutLp : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,Dummy SG_ CF_Gway_SMKDispWarn : 57|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,Dummy SG_ CF_Gway_WngBuz : 61|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,Dummy BO_ 339 TCS11: 8 ESC SG_ TCS_REQ : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,TCU SG_ MSR_C_REQ : 1|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,EPB,SCC,TCU SG_ TCS_PAS : 2|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,SCC,SPAS,TCU SG_ TCS_GSC : 3|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,TCU SG_ CF_Esc_LimoInfo : 4|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,SCC SG_ ABS_DIAG : 6|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB SG_ ABS_DEF : 7|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,SCC,SPAS,TCU SG_ TCS_DEF : 8|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,SCC,SPAS,TCU SG_ TCS_CTL : 9|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,SCC,SPAS,TCU SG_ ABS_ACT : 10|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,LDWS_LKAS,SCC,SPAS,TCU SG_ EBD_DEF : 11|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,SPAS,TCU SG_ ESP_PAS : 12|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,CLU,EMS,EPB,LDWS_LKAS,SCC,TCU SG_ ESP_DEF : 13|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,LDWS_LKAS,SCC,TCU SG_ ESP_CTL : 14|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,ECS,EMS,EPB,LDWS_LKAS,SCC,SPAS,TCU SG_ TCS_MFRN : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,EPB,TCU SG_ DBC_CTL : 16|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB SG_ DBC_PAS : 17|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB SG_ DBC_DEF : 18|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB SG_ HAC_CTL : 19|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB,TCU SG_ HAC_PAS : 20|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB,TCU SG_ HAC_DEF : 21|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,EMS,EPB,TCU SG_ ESS_STAT : 22|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,BCM,CLU,EMS,EPB SG_ TQI_TCS : 24|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,EPB,TCU SG_ TQI_MSR : 32|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,EPB,TCU SG_ TQI_SLW_TCS : 40|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,EPB,TCU SG_ CF_Esc_BrkCtl : 48|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ BLA_CTL : 49|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CGW,CLU SG_ AliveCounter_TCS1 : 52|4@1+ (1.0,0.0) [0.0|14.0] "" EMS,EPB,LDWS_LKAS SG_ CheckSum_TCS1 : 56|8@1+ (1.0,0.0) [0.0|255.0] "" EMS,EPB,LDWS_LKAS BO_ 1362 SNV11: 4 SNV SG_ CF_SNV_DisplayControl : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,HUD SG_ CF_Snv_BeepWarning : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,HUD SG_ CF_Snv_WarningMessage : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,HUD SG_ CF_Snv_DetectionEnable : 7|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,CLU,HUD SG_ CF_Snv_PedestrianDetect : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,HUD SG_ CF_Snv_IRLampControl : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,HUD BO_ 593 MDPS12: 8 MDPS SG_ CR_Mdps_StrColTq : 0|11@1+ (1.0,-1024.0) [-1024.0|1024.0] "" LDWS_LKAS SG_ CF_Mdps_Def : 11|1@1+ (1.0,0.0) [0.0|1.0] "" ESC SG_ CF_Mdps_ToiUnavail : 12|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS SG_ CF_Mdps_ToiActive : 13|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS SG_ CF_Mdps_ToiFlt : 14|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS SG_ CF_Mdps_FailStat : 15|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS SG_ CF_Mdps_MsgCount2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" ESC,LDWS_LKAS SG_ CF_Mdps_Chksum2 : 24|8@1+ (1.0,0.0) [0.0|255.0] "" ESC,LDWS_LKAS SG_ CF_Mdps_SErr : 37|1@1+ (1.0,0.0) [0.0|1.0] "" ESC SG_ CR_Mdps_StrTq : 40|12@1+ (0.01,-20.48) [-20.48|20.47] "Nm" ESC SG_ CR_Mdps_OutTq : 52|12@1+ (0.1,-204.8) [-204.8|204.7] "" ESC,LDWS_LKAS BO_ 1360 IAP11: 3 IAP SG_ CF_Iap_EcoPmodSwi : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Iap_EcoPmodAct : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Iap_ReqWarn : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1356 TCU_DCT14: 8 TCU SG_ Vehicle_Stop_Time : 0|5@1+ (1.0,0.0) [0.0|0.0] "" CLU SG_ HILL_HOLD_WARNING : 5|1@1+ (1.0,0.0) [0.0|0.0] "" CLU BO_ 1353 BAT11: 8 EMS SG_ BAT_SNSR_I : 0|16@1+ (0.01,-327.0) [-327.0|328.0] "A" CGW,CUBIS,IBOX,TMU SG_ BAT_SOC : 16|8@1+ (1.0,0.0) [0.0|100.0] "%" CGW,CUBIS,IBOX,TMU SG_ BAT_SNSR_V : 24|14@1+ (0.0010,6.0) [6.0|18.0] "V" CGW,CUBIS,IBOX,TMU SG_ BAT_SNSR_Temp : 38|9@1- (0.5,-40.0) [-40.0|125.0] "deg" CGW,CUBIS,IBOX,TMU SG_ BAT_SNSR_State : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CGW,CUBIS,IBOX,TMU SG_ BAT_SOH : 48|7@1+ (1.0,0.0) [0.0|100.0] "%" CGW,CUBIS,IBOX,TMU SG_ BAT_SNSR_Invalid : 55|1@1+ (1.0,0.0) [0.0|1.0] "" CGW,CUBIS,IBOX,TMU SG_ BAT_SOF : 56|7@1+ (0.1,0.0) [0.0|12.0] "V" CGW,CUBIS,IBOX,TMU SG_ BAT_SNSR_Error : 63|1@1+ (1.0,0.0) [0.0|1.0] "" CGW,CUBIS,IBOX,TMU BO_ 1351 EMS15: 8 EMS SG_ ECGPOvrd : 0|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX,SCC SG_ QECACC : 1|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX SG_ ECFail : 2|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX SG_ SwitchOffCondExt : 3|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX SG_ BLECFail : 4|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX SG_ CF_Ems_IsaAct : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ FA_PV_CAN : 8|8@1+ (0.3906,0.0) [0.0|99.2] "%" IBOX,LDWS_LKAS,TCU SG_ IntAirTemp : 16|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" _4WD,ECS,EPB,IBOX,TCU SG_ STATE_DC_OBD : 24|7@1+ (1.0,0.0) [0.0|127.0] "" IBOX,TCU SG_ INH_DC_OBD : 31|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU SG_ CTR_IG_CYC_OBD : 32|16@1+ (1.0,0.0) [0.0|65535.0] "" ACU,IBOX,TCU SG_ CTR_CDN_OBD : 48|16@1+ (1.0,0.0) [0.0|65535.0] "" IBOX,TCU BO_ 1350 DI_BOX12: 8 DI_BOX SG_ CF_DiBox_FrtInjVDiagReg0 : 0|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_FrtInjVDiagReg1 : 8|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_FrtInjVDiagReg2 : 16|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_SedInjVDiagReg0 : 24|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_SedInjVDiagReg1 : 32|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CF_DiBox_SedInjVDiagReg2 : 40|8@1+ (1.0,0.0) [0.0|255.0] "" EMS SG_ CR_DiBox_BatVol : 48|8@1+ (0.1,0.0) [0.0|25.5] "V" EMS SG_ CF_DiBox_SedInjVChg : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_FrtInjVChg : 57|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_SedInjVErrSPI : 58|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_DiBox_FrtInjVErrSPI : 59|1@1+ (1.0,0.0) [0.0|1.0] "" EMS BO_ 1349 EMS14: 8 EMS SG_ IMMO_LAMP_STAT : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ L_MIL : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,IBOX SG_ IM_STAT : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ AMP_CAN : 3|5@1+ (10.731613,458.98) [458.98|791.660003] "mmHg" CLU,IBOX,TCU,TPMS SG_ BAT_Alt_FR_Duty : 8|8@1+ (0.4,0.0) [0.0|100.0] "%" CGW,CUBIS,IBOX,TMU SG_ VB : 24|8@1+ (0.1015625,0.0) [0.0|25.8984375] "V" CLU,CUBIS,DATC,EPB,FPCM,IBOX SG_ EMS_VS : 32|12@1+ (0.0625,0.0) [0.0|255.875] "km/h" CLU SG_ TEMP_FUEL : 56|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" FPCM BO_ 68 DATC11: 8 DATC SG_ CF_Datc_Type : 0|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ CF_Datc_VerMaj : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ CF_Datc_VerMin : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ CR_Datc_OutTempC : 24|8@1+ (0.5,-41.0) [-41.0|86.5] "deg" CLU,FPCM SG_ CR_Datc_OutTempF : 32|8@1+ (1.0,-42.0) [-42.0|213.0] "deg" CLU SG_ CF_Datc_IncarTemp : 40|8@1+ (0.5,-40.0) [-40.0|60.0] "deg" BCM,CLU BO_ 67 DATC13: 8 DATC SG_ CF_Datc_TempDispUnit : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX SG_ CF_Datc_ModDisp : 2|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ CF_Datc_IonClean : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_ChgReqDisp : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_IntakeDisp : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_AutoDisp : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_FrDefLed : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,IBOX SG_ CF_Datc_AutoDefogBlink : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_ClmScanDisp : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_AqsDisp : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_AcDisp : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_OpSts : 25|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Mtc_MaxAcDisp : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_DualDisp : 30|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_PwrInf : 32|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ CF_Datc_RearManual : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_RearAutoDisp : 40|2@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Datc_RearOffDisp : 42|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_RearClimateScnDisp : 44|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_RearChgReqDisp : 46|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_RearModDisp : 48|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ CF_Datc_RearBlwDisp : 52|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ CF_Datc_PSModDisp : 56|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ CF_Datc_FrontBlwDisp : 60|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX BO_ 66 DATC12: 8 DATC SG_ CR_Datc_DrTempDispC : 0|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU,IBOX SG_ CR_Datc_DrTempDispF : 8|8@1+ (1.0,56.0) [58.0|90.0] "deg" CLU,IBOX SG_ CR_Datc_PsTempDispC : 16|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU,IBOX SG_ CR_Datc_PsTempDispF : 24|8@1+ (1.0,56.0) [58.0|90.0] "deg" CLU,IBOX SG_ CR_Datc_RearDrTempDispC : 40|8@1+ (0.5,14.0) [15.0|32.0] "deg" CLU SG_ CR_Datc_RearDrTempDispF : 48|8@1+ (1.0,58.0) [58.0|90.0] "deg" CLU SG_ CF_Datc_CO2_Warning : 56|8@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1345 CGW1: 8 BCM SG_ CF_Gway_IGNSw : 0|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,ECS,EMS,EPB,ESC,IBOX,LVR,MDPS,SAS,SCC,ECS,EMS,EPB,ESC,IBOX,LVR,MDPS,SAS,SCC SG_ CF_Gway_RKECmd : 3|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,ECS,EMS,IBOX,ECS,EMS,IBOX SG_ CF_Gway_DrvKeyLockSw : 6|1@1+ (1.0,0.0) [0.0|1.0] "" ECS,EMS,IBOX,ECS,EMS,IBOX SG_ CF_Gway_DrvKeyUnlockSw : 7|1@1+ (1.0,0.0) [0.0|1.0] "" ECS,EMS,IBOX,ECS,EMS,IBOX SG_ CF_Gway_DrvDrSw : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ECS,EMS,EPB,ESC,IBOX,SCC,TCU,ECS,EMS,EPB,ESC,IBOX,SCC,TCU SG_ CF_Gway_DrvSeatBeltSw : 10|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EPB,ESC,IBOX,PSB,TCU,EMS,EPB,ESC,IBOX,PSB,TCU SG_ CF_Gway_TrunkTgSw : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ECS,EMS,EPB,ESC,IBOX,ECS,EMS,EPB,ESC,IBOX SG_ CF_Gway_AstSeatBeltSw : 14|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX,PSB,IBOX,PSB SG_ CF_Gway_SMKOption : 16|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,EMS,IBOX,SMK SG_ CF_Gway_HoodSw : 17|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,EPB,ESC,IBOX,EMS,EPB,ESC,IBOX SG_ CF_Gway_TurnSigLh : 19|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,IBOX,LCA,LDWS_LKAS,SCC,EMS,IBOX,LCA,LDWS_LKAS,SCC SG_ CF_Gway_WiperIntT : 21|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS SG_ CF_Gway_WiperIntSw : 24|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS SG_ CF_Gway_WiperLowSw : 25|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS SG_ CF_Gway_WiperHighSw : 26|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS SG_ CF_Gway_WiperAutoSw : 27|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS,EMS,ESC,IBOX,LDWS_LKAS SG_ CF_Gway_RainSnsState : 28|3@1+ (1.0,0.0) [0.0|7.0] "" AFLS,EMS,IBOX,LDWS_LKAS,AFLS,EMS,ESC,IBOX,LDWS_LKAS SG_ CF_Gway_HeadLampLow : 31|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,CLU,EMS,IBOX,LDWS_LKAS,SNV,AFLS,EMS,IBOX,LDWS_LKAS,SNV SG_ CF_Gway_HeadLampHigh : 32|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,CLU,EMS,IBOX,LDWS_LKAS,AFLS,EMS,IBOX,LDWS_LKAS SG_ CF_Gway_HazardSw : 33|2@1+ (1.0,0.0) [0.0|3.0] "" ABS,EMS,ESC,IBOX,LCA,LDWS_LKAS,ABS,EMS,ESC,IBOX,LCA,LDWS_LKAS SG_ CF_Gway_AstDrSw : 35|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,IBOX SG_ CF_Gway_DefoggerRly : 36|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX,EMS,IBOX SG_ CF_Gway_ALightStat : 37|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS SG_ CF_Gway_LightSwState : 38|2@1+ (1.0,0.0) [0.0|3.0] "" AFLS,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS SG_ CF_Gway_Frt_Fog_Act : 40|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,CLU,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS SG_ CF_Gway_TSigRHSw : 41|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS SG_ CF_Gway_TSigLHSw : 42|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS SG_ CF_Gway_DriveTypeOption : 43|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX,LDWS_LKAS,IBOX,LDWS_LKAS SG_ CF_Gway_StarterRlyState : 44|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX,EMS,IBOX,SMK SG_ CF_Gway_PassiveAccessLock : 45|2@1+ (1.0,0.0) [0.0|7.0] "" CLU,ECS,EMS,IBOX,ECS,EMS,IBOX,SMK SG_ CF_Gway_WiperMistSw : 47|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,IBOX,LDWS_LKAS SG_ CF_Gway_PassiveAccessUnlock : 48|2@1+ (1.0,0.0) [0.0|7.0] "" CLU,ECS,EMS,IBOX,ECS,EMS,IBOX,SMK SG_ CF_Gway_RrSunRoofOpenState : 50|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,DATC,IBOX SG_ CF_Gway_PassingSW : 51|1@1+ (1.0,0.0) [0.0|1.0] "" AFLS,IBOX,LDWS_LKAS,AFLS,IBOX,LDWS_LKAS SG_ CF_Gway_HBAControlMode : 52|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS SG_ CF_Gway_HLpHighSw : 53|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LDWS_LKAS,IBOX,LDWS_LKAS SG_ CF_Gway_InhibitRMT : 54|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EPB,ESC,IBOX,LCA,LDWS_LKAS,MDPS,PGS,SCC,SPAS,TPMS,EPB,ESC,IBOX,LCA,LDWS_LKAS,PGS,SCC,SPAS,TPMS SG_ CF_Gway_RainSnsOption : 56|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ C_SunRoofOpenState : 57|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,DATC,IBOX,DATC,IBOX SG_ CF_Gway_Ign1 : 58|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_Ign2 : 59|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Gway_ParkBrakeSw : 60|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,ESC,IBOX,SCC,ESC,IBOX,SCC SG_ CF_Gway_TurnSigRh : 62|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,IBOX,LCA,LDWS_LKAS,SCC,EMS,IBOX,LCA,LDWS_LKAS,SCC BO_ 64 DATC14: 8 DATC SG_ CF_Datc_AqsLevelOut : 0|4@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Datc_DiagMode : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CR_Datc_SelfDiagCode : 8|8@1+ (1.0,-1.0) [0.0|254.0] "" CLU SG_ DATC_SyncDisp : 16|4@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ DATC_OffDisp : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ DATC_SmartVentDisp : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ DATC_SmartVentOnOffStatus : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ DATC_AutoDefogSysOff_Disp : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ DATC_ADSDisp : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 832 LKAS11: 8 LDWS_LKAS SG_ CF_Lkas_LdwsActivemode : 0|2@1+ (1,0) [0|3] "" CLU,IBOX,PSB SG_ CF_Lkas_LdwsSysState : 2|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,IBOX,PSB SG_ CF_Lkas_SysWarning : 6|4@1+ (1.0,0.0) [0.0|15.0] "" BCM,CLU SG_ CF_Lkas_LdwsLHWarning : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,PSB SG_ CF_Lkas_LdwsRHWarning : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU,PSB SG_ CF_Lkas_HbaLamp : 14|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Lkas_FcwBasReq : 15|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC SG_ CR_Lkas_StrToqReq : 16|11@1+ (1.0,-1024.0) [-1024.0|1024.0] "" MDPS SG_ CF_Lkas_ActToi : 27|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS SG_ CF_Lkas_ToiFlt : 28|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS SG_ CF_Lkas_HbaSysState : 29|3@1+ (1.0,0.0) [0.0|7.0] "" BCM,CLU SG_ CF_Lkas_FcwOpt : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Lkas_HbaOpt : 34|2@1+ (1.0,0.0) [0.0|1.0] "" BCM,CGW SG_ CF_Lkas_MsgCount : 36|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,MDPS SG_ CF_Lkas_FcwSysState : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Lkas_FcwCollisionWarning : 43|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Lkas_FusionState : 45|2@1+ (1.0,0.0) [0.0|3.0] "" SCC SG_ CF_Lkas_Unknown1 : 47|1@1+ (1.0,0.0) [0.0|1.0] "" XXX SG_ CF_Lkas_Chksum : 48|8@1+ (1.0,0.0) [0.0|255.0] "" MDPS SG_ CF_Lkas_FcwOpt_USM : 56|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Lkas_LdwsOpt_USM : 59|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,MDPS SG_ CF_Lkas_Unknown2 : 62|2@1+ (1.0,0.0) [0.0|1.0] "" XXX BO_ 1342 LKAS12: 6 LDWS_LKAS SG_ CF_Lkas_TsrSlifOpt : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_LkasTsrStatus : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Lkas_TsrSpeed_Display_Clu : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU SG_ CF_LkasTsrSpeed_Display_Navi : 24|8@1+ (1.0,0.0) [0.0|255.0] "" BCM,CLU SG_ CF_Lkas_TsrAddinfo_Display : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_LkasDawStatus : 40|3@1+ (1,0) [0|7] "" CLU SG_ CF_Lkas_Daw_USM : 37|3@1+ (1,0) [0|7] "" CLU BO_ 1338 TMU_GW_E_01: 8 CLU SG_ CF_Gway_TeleReqDrLock : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Gway_TeleReqDrUnlock : 2|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Gway_TeleReqHazard : 4|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Gway_TeleReqHorn : 6|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Gway_TeleReqEngineOperate : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM BO_ 1078 PAS11: 4 BCM SG_ CF_Gway_PASDisplayFLH : 0|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,AVM SG_ CF_Gway_PASDisplayFRH : 3|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,AVM SG_ CF_Gway_PASRsound : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_PASDisplayFCTR : 8|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,AVM SG_ CF_Gway_PASDisplayRCTR : 11|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,AVM SG_ CF_Gway_PASFsound : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_PASDisplayRLH : 16|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,AVM SG_ CF_Gway_PASDisplayRRH : 19|3@1+ (1.0,0.0) [0.0|7.0] "" AVM,CLU,PGS,AVM SG_ CF_Gway_PASCheckSound : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_PASSystemOn : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,Dummy SG_ CF_Gway_PASOption : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_PASDistance : 28|1@1+ (1.0,0.0) [0.0|1.0] "" CLU BO_ 48 EMS18: 6 EMS SG_ CF_Ems_DC1NumPerMSV : 0|8@1+ (1.0,0.0) [0.0|255.0] "" DI_BOX SG_ CF_Ems_DC2NumPerMSV : 8|16@1+ (1.0,0.0) [0.0|65535.0] "" DI_BOX SG_ CR_Ems_DutyCyc1MSV : 24|8@1+ (0.1953,0.0) [0.0|49.8] "%" DI_BOX SG_ CR_Ems_DutyCyc2MSV : 32|8@1+ (0.13725,0.0) [0.0|35.0] "%" DI_BOX SG_ CR_Ems_DutyCyc3MSV : 40|8@1+ (0.392,0.0) [0.0|100.0] "%" DI_BOX BO_ 1322 CLU15: 8 CLU SG_ CF_Clu_VehicleSpeed : 0|8@1+ (1.0,0.0) [0.0|255.0] "" BCM SG_ CF_Clu_Gear : 9|4@1+ (1,0) [0|15] "" BCM SG_ CF_Clu_HudInfoSet : 13|7@1+ (1.0,0.0) [0.0|127.0] "" HUD SG_ CF_Clu_HudFontColorSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_HudBrightUpSW : 22|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_HudBrightDnSW : 24|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_HudHeightUpSW : 26|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_HudHeightDnSW : 28|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_HudSet : 30|1@1+ (1.0,0.0) [0.0|1.0] "" HUD SG_ CF_Clu_HudFontSizeSet : 31|2@1+ (1.0,0.0) [0.0|3.0] "" HUD SG_ CF_Clu_LanguageInfo : 33|5@1+ (1.0,0.0) [0.0|31.0] "" BCM,PGS SG_ CF_Clu_ClusterSound : 38|1@1- (1.0,0.0) [0.0|0.0] "" BCM,CGW,FATC SG_ CF_Clu_VehicleSpeed2 : 48|8@1+ (1,0) [0|255] "" XXX BO_ 1066 _4WD13: 6 _4WD SG_ _4WD_CURRENT : 0|8@1+ (0.390625,0.0) [-50.0|50.0] "A" TCU SG_ _4WD_POSITION : 8|16@1+ (0.015625,0.0) [-180.0|180.0] "Deg" TCU SG_ _4WD_CLU_THERM_STR : 24|8@1+ (1.0,0.0) [0.0|100.0] "%" TCU SG_ _4WD_STATUS : 32|8@1+ (1.0,0.0) [0.0|15.0] "" ESC,TCU BO_ 1065 _4WD12: 8 _4WD SG_ Ster_Pos : 0|16@1+ (1.0,-600.0) [-600.0|600.0] "Deg" ESC SG_ FRSS : 16|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC SG_ FLSS : 24|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC SG_ RRSS : 32|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC SG_ RLSS : 40|8@1+ (1.0,0.0) [0.0|254.0] "km/h" ESC SG_ CLU_PRES : 48|16@1+ (0.0625,-50.0) [-50.0|50.0] "Bar" ESC BO_ 809 EMS12: 8 EMS SG_ CONF_TCU m1 : 0|6@1+ (1.0,0.0) [0.0|63.0] "" _4WD,ACU,BCM,CLU,DATC,EPB,ESC,IBOX,LCA,SMK SG_ CAN_VERS m0 : 0|6@1+ (1.0,0.0) [0.0|7.7] "" _4WD,ABS,ESC,IBOX SG_ TQ_STND m3 : 0|6@1+ (10.0,0.0) [0.0|630.0] "Nm" _4WD,DATC,ECS,EPB,ESC,FATC,IBOX SG_ OBD_FRF_ACK m2 : 0|6@1+ (1.0,0.0) [0.0|63.0] "" _4WD,ESC,IBOX SG_ MUL_CODE M : 6|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ABS,ACU,BCM,CLU,DATC,ECS,EPB,ESC,IBOX,LCA,SMK,TCU SG_ TEMP_ENG : 8|8@1+ (0.75,-48.0) [-48.0|143.25] "deg" _4WD,BCM,CLU,DATC,EPB,ESC,IBOX,SMK,TCU SG_ MAF_FAC_ALTI_MMV : 16|8@1+ (0.00781,0.0) [0.0|1.99155] "" IBOX,TCU SG_ VB_OFF_ACT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU SG_ ACK_ES : 25|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,IBOX SG_ CONF_MIL_FMY : 26|3@1+ (1.0,0.0) [0.0|7.0] "" ESC,IBOX,TCU SG_ OD_OFF_REQ : 29|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,TCU SG_ ACC_ACT : 30|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ABS,CLU,ESC,IAP,IBOX,SCC,TCU SG_ CLU_ACK : 31|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EPB,ESC,IBOX SG_ BRAKE_ACT : 32|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ABS,ACU,AFLS,CLU,DATC,ECS,EPB,ESC,IBOX,LDWS_LKAS,TCU SG_ ENG_CHR : 34|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,ABS,ACU,CLU,DATC,EPB,ESC,FATC,IBOX,SCC,SMK,TCU SG_ GP_CTL : 38|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX SG_ TPS : 40|8@1+ (0.4694836,-15.0234742) [-15.0234742|104.6948357] "%" _4WD,ABS,ACU,CLU,DATC,ECS,EPB,ESC,IBOX,TCU SG_ PV_AV_CAN : 48|8@1+ (0.3906,0.0) [0.0|99.603] "%" _4WD,AAF,ABS,ACU,AFLS,CLU,DATC,EPB,ESC,IAP,IBOX,LDWS_LKAS,SCC,TCU SG_ ENG_VOL : 56|8@1+ (0.1,0.0) [0.0|25.5] "liter" _4WD,ABS,ACU,BCM,CLU,DATC,EPB,ESC,IBOX,LDWS_LKAS,SCC,SMK BO_ 1064 _4WD11: 8 _4WD SG_ _4WD_TYPE : 0|2@1+ (1.0,0.0) [0.0|3.0] "" ACU,ESC,TPMS SG_ _4WD_SUPPORT : 2|2@1+ (1.0,0.0) [0.0|3.0] "" ABS,ESC,TPMS SG_ _4WD_ERR : 8|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,ESC SG_ CLU_DUTY : 16|8@1+ (1.0,0.0) [0.0|64.0] "%" ABS,ESC SG_ R_TIRE : 24|8@1+ (1.0,200.0) [200.0|455.0] "mm" ABS,ESC,TPMS SG_ _4WD_SW : 32|8@1+ (1.0,0.0) [0.0|9.9] "" ESC SG_ _2H_ACT : 40|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC SG_ _4H_ACT : 41|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,CLU,ESC,TPMS SG_ LOW_ACT : 42|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC,TCU,TPMS SG_ AUTO_ACT : 43|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,ESC,TPMS SG_ LOCK_ACT : 44|1@1+ (1.0,0.0) [0.0|1.0] "" ABS,CLU,ESC,TPMS SG_ _4WD_TQC_CUR : 48|16@1+ (1.0,0.0) [0.0|65535.0] "Nm" ABS,ESC BO_ 1319 HU_GW_E_01: 8 CLU SG_ C_ADrLNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ C_ADrUNValueSet : 4|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ C_TwUnNValueSet : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_ABuzzerNValueSet : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_ArmWKeyNValueSet : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_PSMNValueSet : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_SCMNValueSet : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_HLEscortNValueSet : 18|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_WELNValueSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_TriTurnLNValueSet : 22|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_SNVWarnNValueSet : 24|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_LkasWarnNValueSet : 26|2@1+ (1.0,0.0) [0.0|3.0] "" BCM BO_ 1318 HU_GW_E_00: 8 CLU SG_ C_ADrLURValueReq : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_TwUnRValueReq : 2|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_AlarmRValueReq : 4|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_IMSRValueReq : 6|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_HLEscortRValueReq : 8|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_WELRValueReq : 10|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_TriTurnLRValueReq : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_SNVWarnRValueReq : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ C_LkasWarnRValueReq : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM BO_ 1317 GW_HU_E_01: 8 BCM SG_ C_ADrLRValue : 0|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ C_ADrURValue : 4|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ C_TwUnRValue : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_ABuzzerRValue : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_ArmWKeyRValue : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_PSMRValue : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SCMRValue : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_HLEscortRValue : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_WELRValue : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_TriTurnLRValue : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1316 GW_HU_E_00: 8 BCM SG_ C_ADrLUNValueConf : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_TwUnNValueConf : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_AlarmNValueConf : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_PSMNValueConf : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SCMNValueConf : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_HLEscortNValueConf : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_WELNValueConf : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_TriTurnLNValueConf : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1315 GW_SWRC_PE: 8 BCM SG_ C_ModeSW : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_MuteSW : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SeekDnSW : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SeekUpSW : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_BTPhoneCallSW : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_BTPhoneHangUpSW : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_DISCDownSW : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_DISCUpSW : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SdsSW : 18|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_MTSSW : 20|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_VolDnSW : 22|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_VolUpSW : 24|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1314 GW_IPM_PE_1: 8 BCM SG_ C_AV_Tail : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_ParkingBrakeSW : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_RKECMD : 4|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ C_BAState : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_IGNSW : 12|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ C_CountryCfg : 16|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ C_TailLampActivity : 26|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ RearSW_RSELockOnOff : 28|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SMKTeleCrankingState : 32|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_SMKTeleCrankingFailRes : 34|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1057 SCC12: 8 SCC SG_ CF_VSM_Prefill : 0|1@1+ (1,0) [0|1] "" ESC SG_ CF_VSM_DecCmdAct : 1|1@1+ (1,0) [0|1] "" ESC SG_ CF_VSM_HBACmd : 2|2@1+ (1,0) [0|3] "" ESC SG_ CF_VSM_Warn : 4|2@1+ (1,0) [0|3] "" CLU,ESC,IAP SG_ CF_VSM_Stat : 6|2@1+ (1,0) [0|3] "" CLU,ESC,PSB SG_ CF_VSM_BeltCmd : 8|3@1+ (1,0) [0|7] "" ESC,PSB SG_ ACCFailInfo : 11|2@1+ (1,0) [0|3] "" CLU,CUBIS,ESC,IBOX SG_ ACCMode : 13|2@1+ (1,0) [0|3] "" CLU,ESC,IBOX,TCU SG_ StopReq : 15|1@1+ (1,0) [0|1] "" EPB,ESC SG_ CR_VSM_DecCmd : 16|8@1+ (0.01,0) [0|2.55] "g" ESC SG_ TakeOverReq : 35|1@1+ (1,0) [0|1] "" CLU,ESC,TCU SG_ PreFill : 36|1@1+ (1,0) [0|1] "" ESC,TCU SG_ CF_VSM_ConfMode : 48|2@1+ (1,0) [0|3] "" CLU,ESC SG_ AEB_Failinfo : 50|2@1+ (1,0) [0|3] "" CLU,ESC SG_ AEB_Status : 52|2@1+ (1,0) [0|3] "" CLU,ESC SG_ AEB_CmdAct : 54|1@1+ (1,0) [0|1] "" ESC SG_ AEB_StopReq : 55|1@1+ (1,0) [0|1] "" CLU,ESC SG_ CR_VSM_Alive : 56|4@1+ (1,0) [0|15] "" ESC,PSB SG_ CR_VSM_ChkSum : 60|4@1+ (1,0) [0|15] "" ESC,PSB SG_ aReqValue : 37|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" Vector__XXX SG_ aReqRaw : 24|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" Vector__XXX BO_ 1313 GW_DDM_PE: 8 BCM SG_ C_DRVDoorStatus : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_ASTDoorStatus : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_RLDoorStatus : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_RRDoorStatus : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_TrunkStatus : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ C_OSMirrorStatus : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU BO_ 1056 SCC11: 8 SCC SG_ MainMode_ACC : 0|1@1+ (1,0) [0|1] "" CLU,EMS,ESC SG_ SCCInfoDisplay : 1|3@1+ (1,0) [0|7] "" CLU,ESC SG_ AliveCounterACC : 4|4@1+ (1,0) [0|15] "" CLU,EMS,ESC,TCU SG_ VSetDis : 8|8@1+ (1,0) [0|255] "km/h or MPH" CLU,ESC,TCU SG_ ObjValid : 16|1@1+ (1,0) [0|1] "" CLU,ESC,TCU SG_ DriverAlertDisplay : 17|2@1+ (1,0) [0|3] "" CLU,ESC SG_ TauGapSet : 19|3@1+ (1,0) [0|7] "" CLU,ESC,TCU SG_ Navi_SCC_Curve_Status : 56|2@1+ (1,0) [0|3] "" CLU SG_ Navi_SCC_Curve_Act : 58|2@1+ (1,0) [0|3] "" CLU SG_ Navi_SCC_Camera_Act : 60|2@1+ (1,0) [0|3] "" CLU SG_ Navi_SCC_Camera_Status : 62|2@1+ (1,0) [0|3] "" CLU SG_ ACC_ObjStatus : 22|2@1+ (1,0) [0|3] "" ABS,ESC SG_ ACC_ObjLatPos : 24|9@1+ (0.1,-20) [-20|31.1] "m" ABS,ESC SG_ ACC_ObjRelSpd : 44|12@1+ (0.1,-170) [-170|239.5] "m/s" ABS,ESC SG_ ACC_ObjDist : 33|11@1+ (0.1,0) [0|204.7] "m" ABS,ESC BO_ 1312 CGW3: 8 BCM SG_ CR_Photosensor_LH : 0|8@1+ (78.125,0.0) [0.0|20000.0] "" DATC,DATC SG_ CR_Photosensor_RH : 10|8@1+ (78.125,0.0) [0.0|20000.0] "" DATC,DATC SG_ CF_Hoodsw_memory : 22|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,EMS SG_ C_MirOutTempSns : 24|8@1+ (0.5,-40.5) [-40.0|60.0] "deg" AAF,CLU,DATC,EMS,SPAS,AAF,DATC,EMS,SPAS BO_ 544 ESP12: 8 ESC SG_ LAT_ACCEL : 0|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" _4WD,ECS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,TCU SG_ LAT_ACCEL_STAT : 11|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,IBOX,LDWS_LKAS,MDPS,PSB,SCC,TCU SG_ LAT_ACCEL_DIAG : 12|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,IBOX,LDWS_LKAS,MDPS,PSB,SCC,TCU SG_ LONG_ACCEL : 13|11@1+ (0.01,-10.23) [-10.23|10.24] "m/s^2" _4WD,ECS,EMS,EPB,IBOX,LCA,LDWS_LKAS,PSB,SCC,SPAS,TCU SG_ LONG_ACCEL_STAT : 24|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU SG_ LONG_ACCEL_DIAG : 25|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,SPAS,TCU SG_ CYL_PRES : 26|12@1+ (0.1,0.0) [0.0|409.5] "Bar" _4WD,ECS,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,TCU SG_ CYL_PRES_STAT : 38|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ECS,EMS,EPB,IBOX,LDWS_LKAS,PSB,SCC,TCU SG_ CYL_PRESS_DIAG : 39|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ECS,EMS,EPB,IBOX,PSB,SCC,TCU SG_ YAW_RATE : 40|13@1+ (0.01,-40.95) [-40.95|40.96] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU SG_ YAW_RATE_STAT : 53|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU SG_ YAW_RATE_DIAG : 54|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,AFLS,IBOX,LCA,LDWS_LKAS,MDPS,PSB,SCC,SPAS,TCU SG_ ESP12_Checksum : 56|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU SG_ ESP12_AliveCounter : 60|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,LPI,TCU,TMU BO_ 1307 CLU16: 8 CLU SG_ CF_Clu_TirePressUnitNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" TPMS SG_ CF_Clu_SlifNValueSet : 3|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS SG_ CF_Clu_RearWiperNValueSet : 12|2@1+ (1.0,0.0) [0.0|3.0] "" BCM BO_ 790 EMS11: 8 EMS SG_ SWI_IGK : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ABS,ACU,AHLS,CUBIS,DI_BOX,ECS,EPB,ESC,IBOX,LDWS_LKAS,MDPS,REA,SAS,SCC,TCU SG_ F_N_ENG : 1|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,AFLS,CLU,CUBIS,DATC,ECS,EPB,ESC,IBOX,MDPS,SCC,TCU SG_ ACK_TCS : 2|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,IBOX SG_ PUC_STAT : 3|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,DATC,IBOX,TCU SG_ TQ_COR_STAT : 4|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ESC,IBOX,TCU SG_ RLY_AC : 6|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,IBOX,TCU SG_ F_SUB_TQI : 7|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ECS,EPB,ESC,IBOX,TCU SG_ TQI_ACOR : 8|8@1+ (0.390625,0.0) [0.0|99.6094] "%" _4WD,EPB,ESC,IBOX,TCU SG_ N : 16|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" _4WD,ACU,AFLS,CLU,CUBIS,DATC,ECS,EPB,ESC,FPCM,IBOX,MDPS,SCC,TCU SG_ TQI : 32|8@1+ (0.390625,0.0) [0.0|99.6094] "%" _4WD,ECS,EPB,ESC,IBOX,TCU SG_ TQFR : 40|8@1+ (0.390625,0.0) [0.0|99.6094] "%" _4WD,EPB,ESC,IBOX,TCU SG_ VS : 48|8@1+ (1.0,0.0) [0.0|254.0] "km/h" _4WD,AAF,ACU,AHLS,BCM,CLU,DATC,ECS,EPB,IBOX,LCA,LDWS_LKAS,LVR,MDPS,ODS,SCC,SMK,SPAS,TCU,TPMS SG_ RATIO_TQI_BAS_MAX_STND : 56|8@1+ (0.0078,0.0) [0.0|2.0] "" _4WD,IBOX,TCU BO_ 1301 CLU14: 8 CLU SG_ CF_Clu_ADrUNValueSet : 0|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_ADrLNValueSet : 3|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_EscortHLNValueSet : 6|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Clu_DoorLSNValueSet : 8|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_PSMNValueSet : 11|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_TTUnlockNValueSet : 14|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Clu_PTGMNValueSet : 16|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Clu_SCMNValueSet : 18|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Clu_WlightNValueSet : 20|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Clu_TempUnitNValueSet : 22|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,DATC SG_ CF_Clu_MoodLpNValueSet : 24|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_TrfChgSet : 27|2@1+ (1.0,0.0) [0.0|3.0] "" AFLS SG_ CF_Clu_OTTurnNValueSet : 29|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_LcaNValueSet : 32|2@1+ (1.0,0.0) [0.0|3.0] "" LCA SG_ CF_Clu_RctaNValueSet : 34|2@1+ (1.0,0.0) [0.0|3.0] "" LCA SG_ CF_Clu_RcwNValueSet : 36|2@1+ (1.0,0.0) [0.0|3.0] "" LCA SG_ CF_Clu_EscOffNValueSet : 38|3@1+ (1.0,0.0) [0.0|7.0] "" ESC SG_ CF_Clu_SccNaviCrvNValueSet : 41|2@1+ (1.0,0.0) [0.0|3.0] "" SCC SG_ CF_Clu_SccNaviCamNValueSet : 43|2@1+ (1.0,0.0) [0.0|3.0] "" SCC SG_ CF_Clu_SccAebNValueSet : 45|2@1+ (1.0,0.0) [0.0|3.0] "" SCC SG_ CF_Clu_LkasModeNValueSet : 47|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS SG_ CF_Clu_FcwNValueSet : 51|2@1+ (1.0,0.0) [0.0|3.0] "" LDWS_LKAS SG_ CF_Clu_PasSpkrLvNValueSet : 53|3@1+ (1.0,0.0) [0.0|7.0] "" BCM SG_ CF_Clu_SccDrvModeNValueSet : 56|3@1+ (1.0,0.0) [0.0|7.0] "" SCC SG_ CF_Clu_HAnBNValueSet : 59|2@1+ (1.0,0.0) [0.0|3.0] "" BCM SG_ CF_Clu_HfreeTrunkTgNValueSet : 61|3@1+ (1.0,0.0) [0.0|7.0] "" BCM BO_ 275 TCU13: 8 TCU SG_ N_TGT_LUP : 0|8@1+ (10.0,500.0) [500.0|3040.0] "rpm" EMS,IBOX SG_ SLOPE_TCU : 8|6@1+ (0.5,-16.0) [-16.0|15.5] "%" CLU,CUBIS,EMS,IBOX SG_ CF_Tcu_InhCda : 14|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Tcu_IsgInhib : 15|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Tcu_BkeOnReq : 16|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX SG_ CF_Tcu_NCStat : 18|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX SG_ CF_Tcu_TarGr : 20|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,CLU,DATC,EMS,EPB,ESC,IBOX,SCC SG_ CF_Tcu_ShfPatt : 24|4@1+ (1.0,0.0) [0.0|15.0] "" CLU,CUBIS,EMS,IBOX SG_ CF_Tcu_InhVis : 28|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Tcu_PRelReq : 29|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX,LVR SG_ CF_Tcu_ITPhase : 30|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Tcu_ActEcoRdy : 31|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Tcu_TqGrdLim : 32|8@1+ (10.0,0.0) [0.0|2540.0] "Nm/s" EMS,IBOX SG_ CR_Tcu_IsgTgtRPM : 40|8@1+ (20.0,0.0) [0.0|3500.0] "rpm" EMS,IBOX SG_ CF_Tcu_SptRdy : 48|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,IBOX SG_ CF_Tcu_SbwPInfo : 56|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ CF_Tcu_Alive3 : 58|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX SG_ CF_Tcu_ChkSum3 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,IBOX BO_ 274 TCU12: 8 TCU SG_ ETL_TCU : 0|8@1+ (2.0,0.0) [0.0|508.0] "Nm" EMS,IBOX SG_ CUR_GR : 8|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,EMS,ESC,IBOX,SCC,TPMS SG_ CF_Tcu_Alive : 12|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,IBOX,SCC SG_ CF_Tcu_ChkSum : 14|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,IBOX,SCC SG_ VS_TCU : 16|8@1+ (1.0,0.0) [0.0|254.0] "km/h" BCM,CLU,DATC,EMS,IBOX,LCA,LVR,PGS,SMK,SNV SG_ FUEL_CUT_TCU : 28|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ INH_FUEL_CUT : 29|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ IDLE_UP_TCU : 30|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ N_INC_TCU : 31|1@1+ (1.0,0.0) [0.0|1.0] "" EMS,IBOX SG_ SPK_RTD_TCU : 32|8@1+ (0.375,-23.625) [-15.0|15.0] "" EMS,IBOX SG_ N_TC_RAW : 40|16@1+ (0.25,0.0) [0.0|16383.5] "rpm" EMS,IBOX SG_ VS_TCU_DECIMAL : 56|8@1+ (0.0078125,0.0) [0.0|0.9921875] "km/h" CLU,EMS,IBOX,LCA BO_ 273 TCU11: 8 TCU SG_ TQI_TCU_INC : 0|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,ESC,IBOX SG_ G_SEL_DISP : 8|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,AFLS,AVM,BCM,CGW,CLU,CUBIS,ECS,EMS,EPB,ESC,IAP,IBOX,LCA,LDWS_LKAS,LVR,MDPS,PGS,SCC,SMK,SNV,SPAS,TPMS SG_ F_TCU : 12|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,ESC,IBOX SG_ TCU_TYPE : 14|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,EMS,ESC,IBOX SG_ TCU_OBD : 16|3@1+ (1.0,0.0) [0.0|7.0] "" EMS,ESC,IBOX SG_ SWI_GS : 19|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,EMS,EPB,ESC,IBOX,SCC SG_ GEAR_TYPE : 20|4@1+ (1.0,0.0) [0.0|15.0] "" _4WD,CLU,EMS,ESC,IBOX,SCC SG_ TQI_TCU : 24|8@1+ (0.390625,0.0) [0.0|99.609375] "%" EMS,ESC,IBOX SG_ TEMP_AT : 32|8@1+ (1.0,-40.0) [-40.0|214.0] "deg" AAF,CLU,CUBIS,EMS,ESC,IBOX SG_ N_TC : 40|16@1+ (0.25,0.0) [0.0|16383.5] "rpm" _4WD,EMS,EPB,ESC,IBOX SG_ SWI_CC : 56|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,CLU,EMS,ESC,IBOX SG_ CF_Tcu_Alive1 : 58|2@1+ (1.0,0.0) [0.0|3.0] "" EMS,IBOX SG_ CF_Tcu_ChkSum1 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,IBOX BO_ 16 ACU13: 8 ACU SG_ CF_Acu_CshAct : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CUBIS,IBOX,ODS BO_ 1040 CGW_USM1: 8 BCM SG_ CF_Gway_ATTurnRValue : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_PTGMRValue : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_EscortHLRValue : 4|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_TTUnlockRValue : 6|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_ADrLRValue : 8|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_ADrURValue : 11|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_SCMRValue : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_WlightRValue : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_PSMRValue : 18|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_OTTurnRValue : 21|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_DrLockSoundRValue : 24|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_HAnBRValue : 27|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_MoodLpRValue : 30|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_HfreeTrunkRValue : 32|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_AutoLightRValue : 35|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_Gway_RearWiperRValue : 38|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_Gway_PasSpkrLvRValue : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CLU BO_ 1292 CLU13: 8 CLU SG_ CF_Clu_LowfuelWarn : 0|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,FPCM,IBOX SG_ CF_Clu_RefDetMod : 2|1@1+ (1.0,0.0) [0.0|1.0] "" IBOX SG_ CF_Clu_AvgFCU : 3|2@1+ (1.0,0.0) [0.0|3.0] "" IBOX SG_ CF_Clu_AvsmCur : 5|1@1+ (1.0,0.0) [0.0|1.0] "" ESC,SCC SG_ CF_Clu_AvgFCI : 6|10@1+ (0.1,0.0) [0.0|102.2] "" IBOX SG_ CF_Clu_DrivingModeSwi : 16|2@1+ (1.0,0.0) [0.0|3.0] "" DATC,ECS,EMS,ESC,IAP,MDPS,TCU SG_ CF_Clu_FuelDispLvl : 18|5@1+ (1.0,0.0) [0.0|31.0] "" CGW,IBOX SG_ CF_Clu_FlexSteerSW : 23|1@1+ (1.0,0.0) [0.0|1.0] "" MDPS SG_ CF_Clu_DTE : 24|10@1+ (1.0,0.0) [0.0|1023.0] "" DATC SG_ CF_Clu_TripUnit : 34|2@1+ (1.0,0.0) [0.0|3.0] "" DATC SG_ CF_Clu_SWL_Stat : 36|3@1+ (1.0,0.0) [0.0|7.0] "" ACU,EMS SG_ CF_Clu_ActiveEcoSW : 39|1@1+ (1.0,0.0) [0.0|1.0] "" DATC,EMS,TCU SG_ CF_Clu_EcoDriveInf : 40|3@1+ (1.0,0.0) [0.0|7.0] "" CUBIS,EMS,IAP,IBOX SG_ CF_Clu_IsaMainSW : 43|1@1+ (1.0,0.0) [0.0|1.0] "" EMS SG_ CF_Clu_LdwsLkasSW : 56|1@1+ (1.0,0.0) [0.0|1.0] "" LDWS_LKAS SG_ CF_Clu_AltLStatus : 59|1@1+ (1.0,0.0) [0.0|1.0] "" BCM,DATC,EMS SG_ CF_Clu_AliveCnt2 : 60|4@1+ (1.0,0.0) [0.0|15.0] "" EMS,LDWS_LKAS BO_ 1290 SCC13: 8 SCC SG_ SCCDrvModeRValue : 0|3@1+ (1,0) [0|7] "" CLU SG_ SCC_Equip : 3|1@1+ (1,0) [0|1] "" ESC SG_ AebDrvSetStatus : 4|3@1+ (1,0) [0|7] "" CLU,ESC SG_ Lead_Veh_Dep_Alert_USM : 13|2@0+ (1,0) [0|3] "" XXX BO_ 1287 TCS15: 4 ESC SG_ ABS_W_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU,CUBIS,IBOX SG_ TCS_OFF_LAMP : 1|2@1+ (1.0,0.0) [0.0|1.0] "" _4WD,ACU,CLU SG_ TCS_LAMP : 3|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,ACU,CLU,CUBIS,IBOX,SCC SG_ DBC_W_LAMP : 5|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU SG_ DBC_F_LAMP : 6|2@1+ (1.0,0.0) [0.0|3.0] "" _4WD,CLU SG_ ESC_Off_Step : 8|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ AVH_CLU : 16|8@1+ (1.0,0.0) [0.0|255.0] "" CLU,EPB SG_ AVH_I_LAMP : 24|2@1+ (1.0,0.0) [0.0|3.0] "" EPB SG_ EBD_W_LAMP : 26|1@1+ (1.0,0.0) [0.0|1.0] "" _4WD,CLU SG_ AVH_ALARM : 27|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ AVH_LAMP : 29|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EPB,SPAS BO_ 1282 TCU14: 4 TCU SG_ CF_TCU_WarnMsg : 0|3@1+ (1.0,0.0) [0.0|7.0] "" CLU SG_ CF_TCU_WarnImg : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_TCU_WarnSnd : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ CF_Tcu_GSel_BlinkReq : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,LVR SG_ CF_Tcu_StRelStat : 12|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,EMS,ESC SG_ CF_Tcu_DriWarn1 : 13|3@1+ (1.0,0.0) [0.0|7.0] "" CLU,EMS,ESC SG_ CF_Tcu_DriWarn2 : 16|2@1+ (1.0,0.0) [0.0|3.0] "" CLU,EMS,ESC BO_ 1281 ECS11: 3 ECS SG_ ECS_W_LAMP : 0|1@1+ (1.0,0.0) [0.0|1.0] "" CLU,CUBIS,IBOX SG_ SYS_NA : 1|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ ECS_DEF : 2|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ ECS_DIAG : 3|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ L_CHG_NA : 4|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ Leveling_Off : 5|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ LC_overheat : 6|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ Lifting : 8|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ Lowering : 9|1@1+ (1.0,0.0) [0.0|1.0] "" CLU SG_ Damping_Mode : 10|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ REQ_Damping : 12|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ REQ_Height : 14|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ REQ_level : 16|4@1+ (1.0,0.0) [0.0|15.0] "" CLU SG_ ACT_Height : 20|4@1+ (1.0,0.0) [0.0|15.0] "" CLU BO_ 1024 CLU_CFG11: 2 CLU SG_ Vehicle_Type : 0|16@1+ (1.0,0.0) [0.0|65536.0] "" _4WD BO_ 1280 ACU14: 1 ACU SG_ CF_SWL_Ind : 0|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_TTL_Ind : 2|2@1+ (1.0,0.0) [0.0|3.0] "" CLU SG_ CF_SBR_Ind : 4|2@1+ (1.0,0.0) [0.0|3.0] "" BCM,CLU BO_ 512 EMS20: 6 EMS SG_ FCO : 0|16@1+ (0.128,0.0) [0.0|8388.48] "ul" CLU,CUBIS,FPCM,IBOX SG_ CF_Ems_PumpTPres : 16|8@1+ (3.137254902,0.0) [0.0|800.0] "kPa" FPCM,IBOX SG_ Split_Stat : 32|1@1+ (1.0,0.0) [0.0|1.0] "" FPCM BO_ 909 FCA11: 8 FCA SG_ CF_VSM_Prefill : 0|1@1+ (1,0) [0|1] "" ESC SG_ CF_VSM_HBACmd : 1|2@1+ (1,0) [0|3] "" ESC SG_ CF_VSM_Warn : 3|2@1+ (1,0) [0|3] "" ACU,CLU,ESC SG_ CF_VSM_BeltCmd : 5|3@1+ (1,0) [0|7] "" ESC SG_ CR_VSM_DecCmd : 8|8@1+ (0.01,0) [0|2.55] "g" ESC SG_ FCA_Status : 18|2@1+ (1,0) [0|3] "" ACU,CLU,ESC SG_ FCA_CmdAct : 20|1@1+ (1,0) [0|1] "" ESC SG_ FCA_StopReq : 21|1@1+ (1,0) [0|1] "" CLU,ESC SG_ FCA_DrvSetStatus : 22|3@1+ (1,0) [0|7] "" CLU,ESC SG_ CF_VSM_DecCmdAct : 31|1@1+ (1,0) [0|1] "" ESC SG_ FCA_Failinfo : 32|3@1+ (1,0) [0|7] "" ACU,CLU,ESC SG_ FCA_RelativeVelocity : 39|9@1+ (0.1,-25.5) [-25.5|25.5] "m/s" iBAU SG_ FCA_TimetoCollision : 48|8@1+ (10,0) [0|2540] "ms" iBAU SG_ CR_FCA_Alive : 56|4@1+ (1,0) [0|15] "" ESC SG_ CR_FCA_ChkSum : 60|4@1+ (1,0) [0|15] "" ESC SG_ Supplemental_Counter : 35|4@1+ (1,0) [0|15] "" XXX SG_ PAINT1_Status : 16|2@1+ (1,0) [0|1] "" XXX BO_ 1156 HDA11_MFC: 8 XXX SG_ Counter : 5|4@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_1 : 1|2@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 7|2@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 16|2@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_5 : 18|14@1+ (1,0) [0|63] "" XXX SG_ NEW_SIGNAL_6 : 33|2@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 34|14@1+ (1,0) [0|16383] "" XXX SG_ NEW_SIGNAL_8 : 49|2@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_9 : 50|14@1- (1,-4095) [0|16383] "" XXX BO_ 1155 FCA12: 8 FCA SG_ FCA_USM : 0|3@1+ (1,0) [0|7] "" CGW,CLU,ESC SG_ FCA_DrvSetState : 3|3@1+ (1,0) [0|7] "" CGW BO_ 1186 FRT_RADAR11: 2 FCA SG_ CF_FCA_Equip_Front_Radar : 0|3@1+ (1,0) [0|7] "" LDWS_LKAS,LDW_LKA,ESC BO_ 905 SCC14: 8 SCC SG_ ComfortBandUpper : 0|6@1+ (0.02,0) [0|1.26] "m/s^2" ESC SG_ ComfortBandLower : 6|6@1+ (0.02,0) [0|1.26] "m/s^2" ESC SG_ JerkUpperLimit : 12|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC SG_ JerkLowerLimit : 19|7@1+ (0.1,0) [0|12.7] "m/s^3" ESC SG_ ACCMode : 32|3@1+ (1,0) [0|7] "" CLU,HUD,LDWS_LKAS,ESC SG_ ObjGap : 56|8@1+ (1,0) [0|255] "" CLU,HUD,ESC BO_ 1157 LFAHDA_MFC: 4 XXX SG_ HDA_USM : 0|2@1+ (1,0) [0|3] "" XXX SG_ HDA_Active : 2|1@1+ (1,0) [0|1] "" XXX SG_ HDA_Icon_State : 3|2@1+ (1,0) [0|3] "" XXX SG_ HDA_Chime : 7|1@1+ (1,0) [0|1] "" XXX SG_ HDA_VSetReq : 8|8@1+ (1,0) [0|255] "km/h" XXX SG_ LFA_SysWarning : 16|3@1+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_1 : 20|3@1+ (1,0) [0|7] "" XXX SG_ LFA_Icon_State : 24|2@1+ (1,0) [0|3] "" XXX SG_ LFA_USM : 27|2@1+ (1,0) [0|3] "" XXX SG_ HDA_SysWarning : 29|2@1+ (1,0) [0|3] "" XXX BO_ 913 BCM_PO_11: 8 Vector__XXX SG_ BCM_Door_Dri_Status : 5|1@0+ (1,0) [0|1] "" PT_ESC_ABS SG_ BCM_Shift_R_MT_SW_Status : 39|2@0+ (1,0) [0|3] "" PT_ESC_ABS SG_ LFA_Pressed : 4|1@0+ (1,0) [0|1] "" XXX BO_ 1426 LABEL11: 8 XXX SG_ CC_React : 34|1@1+ (1,0) [0|1] "" XXX BO_ 910 WHL_SPD12_FS: 5 iBAU SG_ CRC : 0|8@1+ (1,0) [0|0] "" Vector__XXX SG_ WHL_SPD12_AliveCounter : 8|4@1+ (1,0) [0|15] "" Vector__XXX SG_ WHL_SPD_FL : 12|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX SG_ WHL_SPD_FR : 26|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX BO_ 911 WHL_SPD13_FS: 5 iBAU SG_ CRC : 0|8@1+ (1,0) [0|0] "" Vector__XXX SG_ WHL_SPD13_AliveCounter : 8|4@1+ (1,0) [0|15] "" Vector__XXX SG_ WHL_SPD_RL : 12|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX SG_ WHL_SPD_RR : 26|14@1+ (0.03125,0) [0|511.96875] "km/h" Vector__XXX BO_ 865 ADAS_PRK_11: 8 ADAS_PRK SG_ CF_PCA_BrkReq : 24|1@1+ (1,0) [0|0] "" Vector__XXX SG_ CF_PCA_DclTrgtVal : 28|4@1+ (0.04,0) [0|0] "g" Vector__XXX SG_ PCA_ALIVE_CNT : 40|4@1+ (1,0) [0|0] "" Vector__XXX SG_ PCA_CHECK_SUM : 48|8@1+ (1,0) [0|0] "" Vector__XXX BO_ 882 ELECT_GEAR: 8 XXX SG_ Elect_Gear_Shifter : 16|4@1+ (1,0) [0|7] "" CLU BO_ 881 E_EMS11: 8 XXX SG_ Brake_Pedal_Pos : 0|8@1+ (1,0) [0|127] "" XXX SG_ IG_Reactive_Stat : 8|3@1+ (1,0) [0|3] "" XXX SG_ Gear_Change : 12|1@0+ (1,0) [0|31] "" XXX SG_ Cruise_Limit_Status : 13|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Limit_Target : 23|8@1+ (1,0) [0|15] "" XXX SG_ Accel_Pedal_Pos : 31|8@1+ (1,0) [0|254] "" XXX SG_ CR_Vcu_AccPedDep_Pos : 56|8@1+ (1,0) [0|254] "" XXX BO_ 1355 EV_PC6: 8 CGW SG_ CF_Vcu_SbwWarnMsg : 16|3@1+ (1,0) [0|7] "" Vector__XXX BO_ 1430 EV_PC2: 8 CGW SG_ CR_Ldc_ActVol_LS_V : 32|8@1+ (0.1,0) [0|0] "V" Vector__XXX BO_ 1535 EV_PC10: 8 CGW SG_ CF_Vcu_EpbRequest : 37|1@1+ (1,0) [0|0] "" Vector__XXX BO_ 908 RSPA11: 8 RSPA SG_ CF_RSPA_State : 0|4@1+ (1,0) [0|15] "" XXX SG_ CF_RSPA_Act : 4|2@1+ (1,0) [0|3] "" XXX SG_ CF_RSPA_DecCmd : 6|2@1+ (1,0) [0|3] "" XXX SG_ CF_RSPA_Trgt_Spd : 8|10@1+ (0.01,0) [0|10.23] "km/h" XXX SG_ CF_RSPA_StopReq : 18|1@1+ (1,0) [0|2] "" XXX SG_ CR_RSPA_EPB_Req : 22|2@1+ (1,0) [0|3] "" XXX SG_ CF_RSPA_ACC_ACT : 50|1@1+ (1,0) [0|2] "" XXX SG_ CF_RSPA_AliveCounter : 52|4@1+ (1,0) [0|15] "" XXX SG_ CF_RSPA_CRC : 56|8@1+ (1,0) [0|255] "" XXX BO_ 914 S_MDPS11: 8 XXX SG_ CF_Mdps_Stat : 0|4@1+ (1,0) [0|15] "" XXX SG_ CR_Mdps_DrvTq : 8|12@1+ (1,0) [0|15] "" XXX SG_ CR_Mdps_StrAng : 24|16@1- (1,0) [0|65535] "" XXX SG_ CF_Mdps_AliveCnt : 47|8@0+ (1,0) [0|255] "" XXX SG_ CF_Mdps_Chksum : 63|8@0+ (1,0) [0|255] "" XXX BO_ 357 S_MDPS12: 8 XXX SG_ NEW_SIGNAL_1 : 0|12@1+ (1,0) [0|4095] "" XXX SG_ NEW_SIGNAL_2 : 12|12@1+ (1,0) [0|4095] "" XXX SG_ Counter : 48|4@1+ (1,0) [0|15] "" XXX SG_ Checksum : 63|8@0+ (1,0) [0|255] "" XXX BO_ 352 AHB1: 8 iBAU SG_ CF_Ahb_SLmp : 0|2@1+ (1,0) [0|3] "" CLU SG_ CF_Ahb_Def : 2|2@1+ (1,0) [0|3] "" CGW SG_ CF_Ahb_Act : 4|2@1+ (1,0) [0|3] "" Vector__XXX SG_ CF_Ahb_Diag : 6|1@1+ (1,0) [0|1] "" Vector__XXX SG_ CF_Ahb_WLmp : 7|1@1+ (1,0) [0|1] "" CLU SG_ CR_Ahb_StDep_mm : 8|16@1- (0.1,0) [-3276.8|3276.7] "mm" Vector__XXX SG_ CF_Ahb_SnsFail : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ CF_Ahb_PedalCalStat : 25|1@1+ (1,0) [0|1] "" Vector__XXX SG_ CF_Ahb_Bzzr : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ CF_Ahb_ChkSum : 56|8@1+ (1,0) [0|255] "" Vector__XXX BO_ 1191 MFC_4a7: 8 XXX SG_ PAINT1 : 0|1@0+ (1,0) [0|1] "" XXX BO_ 1162 BCA11: 8 BCW SG_ CF_BCA_State : 16|3@1+ (1,0) [0|7] "" CLU,iBAU SG_ CF_BCA_Warning : 19|2@1+ (1,0) [0|3] "" CLU,iBAU SG_ AliveCounter : 21|4@1+ (1,0) [0|15] "" CLU,iBAU SG_ RCCA_Brake_Command : 29|1@1+ (1,0) [0|1] "" iBAU SG_ Check_Sum : 56|8@1+ (1,0) [0|16] "" iBAU BO_ 1136 P_STS: 8 CGW SG_ HCU1_STS : 6|2@1+ (1,0) [0|3] "" BCW,EPB,FCA,MDPS,SCC,iBAU SG_ HCU5_STS : 8|2@1+ (1,0) [0|3] "" EPB,FCA,MDPS,iBAU SG_ Counter : 58|4@1+ (1,0) [0|15] "" MDPS SG_ Checksum : 62|2@1+ (1,0) [0|3] "" MDPS BO_ 304 YRS11: 8 ACU SG_ CR_Yrs_Yr : 0|16@1+ (0.005,-163.84) [-163.84|163.83] "deg/s" CGW,iBAU SG_ CR_Yrs_LatAc : 16|16@1+ (0.000127465,-4.17677312) [-4.17677312|4.17651819] "g" iBAU SG_ CF_Yrs_YrStat : 32|4@1+ (1,0) [0|15] "" iBAU SG_ CF_Yrs_LatAcStat : 36|4@1+ (1,0) [0|15] "" iBAU SG_ CF_Yrs_MCUStat : 40|4@1+ (1,0) [0|15] "" iBAU SG_ CR_Yrs_MsgCnt1 : 48|4@1+ (1,0) [0|15] "" iBAU SG_ CR_Yrs_Crc1 : 56|8@1+ (1,0) [0|255] "" iBAU BO_ 320 YRS12: 8 ACU SG_ CF_Yrs_LongAcStat : 16|4@1+ (1,0) [0|15] "" iBAU SG_ CF_IMU_ResetStat : 20|4@1+ (1,0) [0|15] "" iBAU SG_ YRS_Temp : 24|8@1+ (1,-68) [-68|187] "" iBAU SG_ YRS_TempStat : 32|4@1+ (1,0) [0|15] "" iBAU SG_ CF_Yrs_Type : 36|4@1+ (1,0) [0|15] "" iBAU SG_ CR_Yrs_MsgCnt2 : 48|4@1+ (1,0) [0|15] "" iBAU SG_ CR_Yrs_Crc2 : 56|8@1+ (1,0) [0|255] "" iBAU SG_ CR_Yrs_LongAc : 0|16@1+ (0.000127465,-4.17677312) [-4.17677312|4.17651819] "g" CGW,iBAU BO_ 1173 YRS13: 8 ACU SG_ YRS_SeralNo : 16|48@1+ (1,0) [0|281474976710655] "" iBAU BO_ 870 EMS_366: 8 EMS SG_ TQI_1 : 0|8@1+ (0.390625,0) [0|99.6094] "%" MDPS SG_ N : 8|16@1+ (0.25,0.0) [0.0|16383.75] "rpm" MDPS SG_ TQI_2 : 24|8@1+ (0.390625,0) [0|99.6094] "%" MDPS SG_ VS : 40|8@1+ (1,0) [0|255] "km/h" MDPS SG_ SWI_IGK : 48|1@0+ (1,0) [0|1] "" XXX BO_ 854 M_356: 8 XXX SG_ PAINT1 : 32|1@0+ (1,0) [0|1] "" XXX SG_ PAINT2 : 34|2@0+ (1,0) [0|1] "" XXX SG_ PAINT3 : 36|2@0+ (1,0) [0|3] "" XXX SG_ PAINT4 : 38|1@0+ (1,0) [0|1] "" XXX BO_ 1042 ICM_412h: 8 ICM SG_ T_Outside_input : 0|9@0+ (0.01,0) [0|5] "V" Vector__XXX SG_ WarningSoundOutput_1Group : 5|1@0+ (1,0) [0|1] "" Vector__XXX SG_ WarningSoundOutput_2Group : 6|1@0+ (1,0) [0|1] "" Vector__XXX SG_ WarningSoundOutput_3Group : 7|1@0+ (1,0) [0|1] "" Vector__XXX SG_ TRIP_A_DT_Display_clock : 22|7@0+ (1,0) [0|99] "clock" Vector__XXX SG_ TRIP_A_DT_Display_minute : 29|6@0+ (1,0) [0|59] "minute" Vector__XXX SG_ TRIP_B_DT_Display_clock : 38|7@0+ (1,0) [0|99] "clock" Vector__XXX SG_ TRIP_B_DT_Display_minute : 45|6@0+ (1,0) [0|59] "minute" Vector__XXX SG_ PopupMessageOutput_1Level : 48|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_2Level : 49|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_3Level : 50|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_4Level : 51|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_5Level : 52|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_6Level : 53|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_7Level : 54|1@0+ (1,0) [0|1] "" Vector__XXX SG_ PopupMessageOutput_8Level : 55|1@0+ (1,0) [0|1] "" Vector__XXX BO_ 1348 Navi_HU: 8 XXX SG_ SpeedLim_Nav_Clu : 7|8@0+ (1,0) [0|255] "" XXX VAL_ 871 CF_Lvr_Gear 5 "D" 8 "S" 6 "N" 7 "R" 0 "P" ; VAL_ 1322 CF_Clu_Gear 1 "P" 2 "R" 4 "N" 8 "D" ; VAL_ 274 CUR_GR 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 7 "D" 8 "D" 14 "R" 0 "P" ; VAL_ 909 CF_VSM_Warn 2 "FCW" 3 "AEB" ; VAL_ 1157 HDA_Icon_State 0 "no_hda" 1 "white_hda" 2 "green_hda" ; VAL_ 1157 LFA_SysWarning 0 "no_message" 1 "switching_to_hda" 2 "switching_to_scc" 3 "lfa_error" 4 "check_hda" 5 "keep_hands_on_wheel_orange" 6 "keep_hands_on_wheel_red" ; VAL_ 1157 LFA_Icon_State 0 "no_wheel" 1 "white_wheel" 2 "green_wheel" 3 "green_wheel_blink" ; VAL_ 1157 HDA_SysWarning 0 "no_message" 1 "driving_convenience_systems_cancelled" 2 "highway_drive_assist_system_cancelled" ; VAL_ 882 Elect_Gear_Shifter 5 "D" 8 "S" 6 "N" 7 "R" 0 "P" ; CM_ "BO_ E_EMS11: All (plug-in) hybrids use this gas signal: CR_Vcu_AccPedDep_Pos, and all EVs use the Accel_Pedal_Pos signal. See hyundai/values.py for a specific car list"; CM_ SG_ 1348 SpeedLim_Nav_Clu "Speed limit displayed on Nav, Cluster and HUD"; ================================================ FILE: opendbc/lexus_ct200h_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "lexus_ct200h_2018_pt.dbc starts here"; BO_ 548 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 43|12@0+ (1,0) [0|4047] "" XXX SG_ BRAKE_PRESSED : 5|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (1,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; ================================================ FILE: opendbc/lexus_is300h_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT" CM_ "Imported file _comma.dbc starts here" BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM BO_ STEERING_IPAS_COMMA "Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; CM_ "Imported file _toyota_2017.dbc starts here" VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ SET_ME_X01 : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was "SET_ME_1" and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70" CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 129 "no entry"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "lexus_is_2018_pt.dbc starts here" BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL_ALT: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (1.30,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX BO_ 1009 PCM_CRUISE_ALT: 8 XXX SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX BO_ 1599 LIGHT_STALK_ISH: 8 SCM SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/lexus_is_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "lexus_is_2018_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL_ALT: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.77,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX BO_ 1009 PCM_CRUISE_ALT: 8 XXX SG_ MAIN_ON : 13|1@0+ (1,0) [0|3] "" XXX SG_ CRUISE_STATE : 10|1@0+ (1,0) [0|1] "" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "mph" XXX BO_ 1599 LIGHT_STALK_ISH: 8 SCM SG_ AUTO_HIGH_BEAM : 19|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; CM_ SG_ 1009 SET_SPEED "units seem to be whatever the car is set to"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/lexus_nx300_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "lexus_nx300_2018_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; ================================================ FILE: opendbc/lexus_nx300h_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "lexus_nx300h_2018_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; ================================================ FILE: opendbc/lexus_rx_350_2016_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "lexus_rx_350_2016_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_PEDAL : 55|8@0+ (1,0) [0|255] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled" ; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby" ; VAL_ 956 SPORT_ON 0 "off" 1 "on" ; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P" ; VAL_ 956 ECON_ON 0 "off" 1 "on" ; ================================================ FILE: opendbc/lexus_rx_hybrid_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "lexus_rx_hybrid_2017_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; ================================================ FILE: opendbc/mazda_2017.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 117 STEER_RELATED: 8 XXX SG_ CTR : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 48|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_2 : 49|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_5 : 50|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 54|4@0+ (1,0) [0|31] "" XXX SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|63] "" XXX SG_ STEER_ANGLE_2 : 39|16@0+ (0.1,-1800) [0|131071] "" XXX SG_ STEER_TORQUE : 19|12@0+ (1,-2000) [0|255] "" XXX BO_ 118 RPM_RELATED: 8 XXX SG_ CTR : 7|8@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_2 : 19|12@0+ (1,0) [0|4095] "" XXX BO_ 514 ENGINE_DATA: 8 XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|127] "" XXX SG_ RPM : 7|16@0+ (0.25,0) [0|8500] "rpm" XXX SG_ SPEED : 23|16@0+ (0.01,0) [0|32767] "kph" XXX SG_ PEDAL_GAS : 39|12@0+ (1,0) [0|255] "%" XXX BO_ 357 PEDALS: 8 XXX SG_ NEW_SIGNAL_6 : 31|4@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 8|3@1+ (1,0) [0|7] "" XXX SG_ ACC_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX SG_ ACC_OFF : 2|1@1+ (1,0) [0|15] "" XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX SG_ STANDSTILL : 26|1@0+ (1,0) [0|16777215] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ NO_BRAKE : 6|1@0+ (1,0) [0|7] "" XXX SG_ BRAKE_ON_2 : 7|1@1+ (1,0) [0|255] "" XXX SG_ NO_BRAKE_2 : 15|1@0+ (1,0) [0|7] "" XXX SG_ GEAR : 48|5@1+ (1,0) [0|255] "" XXX BO_ 533 WHEEL_SPEEDS: 8 XXX SG_ FL : 7|16@0+ (0.01,-100) [0|16383] "kph" XXX SG_ FR : 23|16@0+ (0.01,-100) [0|65535] "kph" XXX SG_ RL : 39|16@0+ (0.01,-100) [0|15] "kph" XXX SG_ RR : 55|16@0+ (0.01,-100) [0|65535] "kph" XXX BO_ 134 STEER2: 8 XXX SG_ CTR : 22|4@0+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|1] "" XXX SG_ CTR_2 : 28|3@1+ (1,0) [0|7] "" XXX SG_ STEER_ANGLE_ROUGH : 26|11@0+ (1,-1000) [0|15] "" XXX SG_ NEW_SIGNAL_5 : 18|3@0+ (1,0) [0|1] "" XXX SG_ STEER_ANGLE : 7|16@0+ (0.1,-1600) [-500|500] "deg" XXX SG_ NEW_SIGNAL_1 : 63|2@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|7] "" XXX BO_ 576 STEER_TORQUE: 8 XXX SG_ NEW_SIGNAL_1 : 23|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 47|1@0+ (1,0) [0|1] "" XXX SG_ SENSOR1 : 39|8@0+ (1,-128) [0|127] "" XXX SG_ STEER_TORQUE_MOTOR : 46|15@0- (0.1,0) [-3000|3000] "tbd" XXX SG_ NEW_SIGNAL_2 : 62|4@0+ (1,0) [0|31] "" XXX SG_ NEW_SIGNAL_4 : 15|8@0+ (1,0) [0|127] "" XXX SG_ STEER_TORQUE_SENSOR : 7|8@0+ (1,-127) [-85|85] "" XXX BO_ 577 STEER_RATE: 8 XXX SG_ STEER_ANGLE_RATE : 23|16@0+ (0.25,-8192) [0|1] "deg/s" XXX SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|15] "" XXX SG_ LKAS_EFFECTIVE : 39|12@0+ (1,-2048) [0|255] "" XXX SG_ HANDS_OFF_5_SECONDS : 51|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_BLOCK : 50|1@1+ (1,0) [0|3] "" XXX SG_ LKAS_TRACK_STATE : 52|1@0+ (1,0) [0|3] "" XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 582 CAM_LANEMAYBE: 8 XXX SG_ NEW_SIGNAL_4 : 40|8@1+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_1 : 31|16@0- (1,0) [0|65535] "" XXX SG_ NEW_SIGNAL_2 : 55|16@0+ (1,0) [0|65535] "" XXX SG_ CTR : 7|2@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_3 : 15|16@0+ (1,0) [0|65535] "" XXX BO_ 541 CAM_EMPTY: 8 XXX BO_ 605 CAM_PEDESTRIAN: 8 XXX SG_ CTR : 17|4@0+ (1,0) [0|255] "" XXX SG_ AEB_NOT_ENGAGED : 13|1@0+ (1,0) [0|1] "" XXX SG_ PED_WARNING : 9|1@0+ (1,0) [0|255] "" XXX SG_ PED_BRAKE : 3|3@0+ (1,0) [0|7] "" XXX SG_ RST_CTR : 23|6@0+ (1,0) [0|63] "" XXX SG_ S1 : 29|4@0+ (1,0) [0|31] "" XXX SG_ BRAKE_WARNING : 25|1@0+ (1,0) [0|1] "" XXX BO_ 578 CAM_LANETRACK: 8 XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ZERO : 53|6@0+ (1,0) [0|63] "" XXX SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX SG_ LINE2 : 9|10@0+ (1,-686) [0|255] "" XXX SG_ LANE_CURVE : 31|8@0+ (1,-127) [0|255] "" XXX SG_ SIG1 : 39|8@0+ (1,-128) [0|255] "" XXX SG_ SIG2 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SIG3 : 55|2@0+ (1,0) [0|3] "" XXX SG_ LINE1 : 3|10@0+ (1,-686) [0|1] "" XXX BO_ 579 CAM_LKAS: 8 XXX SG_ CTR : 7|4@0+ (1,0) [0|15] "" XXX SG_ ERR_BIT_1 : 16|1@0+ (1,0) [0|1] "" XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX SG_ LINE_NOT_VISIBLE : 19|1@0+ (1,0) [0|1] "" XXX SG_ BIT_1 : 29|1@0+ (1,0) [0|1] "" XXX SG_ LDW : 23|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_REQUEST : 3|12@0+ (1,-2048) [0|2048] "" XXX SG_ ERR_BIT_2 : 30|1@0+ (1,0) [0|1] "" XXX SG_ ANGLE_ENABLED : 52|1@0+ (1,0) [0|1] "" XXX SG_ STEERING_ANGLE : 33|12@0+ (1,-2048) [-2048|2047] "" XXX BO_ 580 CAM_DISTANCE: 8 XXX SG_ S1 : 0|8@1+ (1,0) [0|127] "" XXX SG_ S2 : 15|8@0+ (1,0) [0|1] "" XXX SG_ S3 : 16|8@1+ (1,0) [0|3] "" XXX SG_ S4 : 24|8@1+ (1,0) [0|31] "" XXX SG_ S5 : 32|8@1+ (1,0) [0|255] "" XXX SG_ DISTANCE : 47|8@0+ (1,0) [0|65535] "" XXX SG_ S6 : 55|16@0+ (1,0) [0|255] "" XXX BO_ 581 CAM_IDK3: 8 XXX SG_ S1 : 0|8@1+ (1,0) [0|15] "" XXX SG_ S2 : 8|6@1+ (1,0) [0|255] "" XXX SG_ S3 : 15|2@0+ (1,0) [0|3] "" XXX SG_ S4 : 16|8@1+ (1,0) [0|15] "" XXX SG_ S5 : 24|8@1+ (1,0) [0|255] "" XXX SG_ S6 : 32|8@1+ (1,0) [0|255] "" XXX SG_ S7 : 40|8@1+ (1,0) [0|3] "" XXX SG_ S8 : 48|8@1+ (1,0) [0|255] "" XXX SG_ S9 : 56|8@1+ (1,0) [0|255] "" XXX BO_ 863 CAM_TRAFFIC_SIGNS: 8 XXX SG_ NEW_SIGNAL_3 : 55|1@0+ (1,0) [0|127] "" XXX SG_ FORWARD_COLLISION : 40|8@1+ (1,0) [0|7] "" XXX SG_ SPEED_SIGN : 4|7@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_2 : 52|5@0+ (1,0) [0|31] "" XXX SG_ SPEED_SIGN_CAM : 32|1@0+ (1,0) [0|32767] "" XXX SG_ SPEED_SIGN_ON : 12|1@0+ (1,0) [0|3] "" XXX SG_ STOP_SIGN : 31|4@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 33|1@0+ (1,0) [0|1] "" XXX BO_ 1157 CAM_SETTINGS: 8 XXX SG_ SBS_WARNING_DISTANCE : 25|2@0+ (1,0) [0|127] "" XXX SG_ SBS_SCBC : 28|2@0+ (1,0) [0|7] "" XXX SG_ LKAS_ASSIT_TIMING : 13|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_SENSETIVITY : 10|1@0+ (1,0) [0|1] "" XXX SG_ ILKAS_NTERVENTION_ON2 : 17|1@0+ (1,0) [0|255] "" XXX SG_ LANEE_DEPARTURE_ALERT : 16|2@0+ (1,0) [0|1] "" XXX SG_ LKAS_INERVENTION_ON1 : 15|1@0+ (1,0) [0|1] "" XXX SG_ WARNING : 11|1@0+ (1,0) [0|1] "" XXX SG_ BIT1 : 12|1@0+ (1,0) [0|7] "" XXX SG_ BIT2 : 14|1@0+ (1,0) [0|1] "" XXX SG_ BIT3 : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1160 CAM_Empty3: 8 XXX SG_ NEW_SIGNAL_1 : 47|24@0+ (1,0) [0|16777215] "" XXX BO_ 1088 CAM_LANEINFO: 8 XXX SG_ BIT3 : 62|1@0+ (1,0) [0|3] "" XXX SG_ HANDS_ON_STEER_WARN_2 : 59|1@0+ (1,0) [0|1] "" XXX SG_ HANDS_ON_STEER_WARN : 56|1@0+ (1,0) [0|3] "" XXX SG_ S1_HBEAM : 54|1@0+ (1,0) [0|31] "" XXX SG_ S1 : 52|1@0+ (1,0) [0|1] "" XXX SG_ HANDS_WARN_3_BITS : 51|3@0+ (1,0) [0|7] "" XXX SG_ ERR_BIT : 40|1@0+ (1,0) [0|1] "" XXX SG_ NO_ERR_BIT : 14|1@0+ (1,0) [0|1] "" XXX SG_ BIT2 : 13|1@0+ (1,0) [0|15] "" XXX SG_ LANE_LINES : 10|3@0+ (1,0) [0|3] "" XXX SG_ BIT1 : 6|1@0+ (1,0) [0|65535] "" XXX SG_ LINE_NOT_VISIBLE : 1|1@0+ (1,0) [0|1] "" XXX SG_ LINE_VISIBLE : 0|1@0+ (1,0) [0|3] "" XXX SG_ LDW_WARN_RL : 58|1@0+ (1,0) [0|1] "" XXX SG_ LDW_WARN_LL : 57|1@0+ (1,0) [0|1] "" XXX BO_ 1479 NEW_MSG_470: 8 XXX BO_ 1456 NEW_MSG_300: 8 XXX BO_ 1446 NEW_MSG_a600: 8 XXX BO_ 1416 MSG_18: 8 XXX BO_ 1086 DOORS: 8 XXX SG_ LEFTGATE : 32|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 53|1@0+ (1,0) [0|255] "" XXX SG_ KEYFOB_HORN : 2|1@0+ (1,0) [0|1] "" XXX SG_ KEYFOB_LOCK : 3|1@0+ (1,0) [0|1] "" XXX SG_ KEYFOB_UNLOCK : 4|1@0+ (1,0) [0|1] "" XXX SG_ CTR1 : 8|4@1+ (1,0) [0|3] "" XXX SG_ CTR2 : 16|4@1+ (1,0) [0|15] "" XXX SG_ BR : 34|1@0+ (1,0) [0|1] "" XXX SG_ BL : 35|1@0+ (1,0) [0|1] "" XXX SG_ FR : 36|1@0+ (1,0) [0|1] "" XXX SG_ FL : 37|1@0+ (1,0) [0|255] "" XXX SG_ DOORS_UNLOCKED : 30|1@0+ (1,0) [0|255] "" XXX BO_ 977 TWO_STATES: 8 XXX SG_ NEW_SIGNAL_1 : 50|1@1+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_2 : 56|4@1+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_3 : 28|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 24|4@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_5 : 39|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_6 : 36|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 47|8@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_8 : 51|1@0+ (1,0) [0|1] "" XXX BO_ 1085 MSG_12: 8 XXX SG_ NEW_SIGNAL_3 : 36|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 16|8@1+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_2 : 48|8@1+ (1,0) [0|65535] "" XXX SG_ NEW_SIGNAL_4 : 31|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 24|1@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_6 : 40|3@1+ (1,0) [0|7] "" XXX BO_ 159 MSG_11: 8 XXX SG_ NEW_SIGNAL_1 : 50|4@1+ (1,0) [0|15] "" XXX SG_ INCREASEING : 39|8@0+ (1,0) [0|255] "" XXX BO_ 1278 NEW_MSG_3: 8 XXX SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 63|8@0+ (1,0) [0|255] "" XXX SG_ MILAGE_MAYBE : 7|16@0+ (1,0) [0|255] "" XXX BO_ 1277 NEW_MSG_10: 8 XXX SG_ NEW_SIGNAL_3 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ counter : 7|8@0+ (1,0) [0|255] "" XXX BO_ 1275 2017_5: 8 XXX SG_ counter : 4|5@0+ (1,0) [0|255] "" XXX BO_ 1274 NEW_MSG_12: 8 XXX SG_ NEW_SIGNAL_1 : 24|4@1+ (1,0) [0|15] "" XXX SG_ CTR : 55|4@0+ (1,0) [0|63] "" XXX SG_ NEW_SIGNAL_2 : 35|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 32|3@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_4 : 48|4@1+ (1,0) [0|7] "" XXX BO_ 1180 last_byte_roughRPM: 8 XXX SG_ NEW_SIGNAL_1 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 1078 HVAC: 8 XXX SG_ NEW_SIGNAL_1 : 2|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_2 : 8|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|1@0+ (1,0) [0|65535] "" XXX SG_ NEW_SIGNAL_4 : 56|5@0+ (1,0) [0|255] "" XXX BO_ 1056 CHECK_AND_TEMP: 8 XXX SG_ NEW_SIGNAL_1 : 29|6@0+ (1,0) [0|255] "" XXX SG_ counter_or_GEAR : 15|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 23|8@0+ (1,0) [0|255] "" XXX SG_ STANDSTILL : 32|1@0+ (1,0) [0|255] "" XXX SG_ COOLANT_TEMP : 7|8@0+ (1,0) [0|255] "" XXX SG_ LOW_ENGINE_OIL_PRESSURE : 43|1@0+ (1,0) [0|1] "" XXX SG_ CHECK_FUEL_CAP : 40|1@0+ (1,0) [0|1] "" XXX SG_ CHARGING_SYSTEM_MALFUNCTION : 38|1@0+ (1,0) [0|1] "" XXX SG_ OUTDOOR_TEMP : 63|8@0+ (0.25,-63) [0|255] "cel" XXX BO_ 1045 TRACTION: 8 XXX SG_ NEW_SIGNAL_2 : 20|1@0+ (1,0) [0|3] "" XXX SG_ CTR2 : 19|4@0+ (1,0) [0|31] "" XXX SG_ CTR3 : 8|4@1+ (1,0) [0|15] "" XXX SG_ IS_MOVING : 12|1@0+ (1,0) [0|3] "" XXX SG_ CTR1 : 53|6@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 54|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE : 55|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_WARNING : 2|1@0+ (1,0) [0|1] "" XXX SG_ ABS_MALFUNCTION : 1|2@0+ (1,0) [0|3] "" XXX SG_ DSC_OFF : 3|1@0+ (1,0) [0|1] "" XXX SG_ TCS_DCS_MALFUNCTION : 6|2@0+ (1,0) [0|3] "" XXX SG_ LOUD_BEEP : 28|1@0+ (1,0) [0|1] "" XXX SG_ TPMS_WARNING_DOUBLE_BLINK : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1034 MSG_07: 8 XXX SG_ NEW_SIGNAL_1 : 6|3@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_2 : 0|4@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_3 : 15|4@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_4 : 63|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_9 : 31|8@0+ (1,0) [0|255] "" XXX BO_ 870 NEW_MSG_16: 8 XXX SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX BO_ 867 NEW_MSG_17: 8 XXX SG_ NEW_SIGNAL_1 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 63|8@0+ (1,0) [0|255] "" XXX BO_ 130 STEER: 8 XXX SG_ NEW_SIGNAL_5 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 63|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 47|4@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 23|16@0+ (0.05,-1600) [500|-500] "deg" XXX SG_ CHKSUM_MAYBE : 39|8@0+ (1,0) [0|255] "" XXX BO_ 120 BRAKE: 8 XXX SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PRESSURE : 39|8@0+ (1,0) [0|255] "" XXX BO_ 304 GEAR_RELATED: 8 XXX SG_ NEW_SIGNAL_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX BO_ 865 NEW_MSG_5: 8 XXX SG_ SPEED_INVERSE : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 47|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 40|1@0+ (1,0) [0|1] "" XXX SG_ IS_MOVING : 43|3@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_2 : 46|1@0+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_4 : 44|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_10 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 15|3@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 7|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 56|4@1+ (1,0) [0|15] "" XXX BO_ 836 NEW_MSG_19: 8 XXX SG_ CTR : 48|4@1+ (1,0) [0|15] "" XXX SG_ CTR2 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 832 SEATBELT: 8 XXX SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX SG_ PASSENGER_SEATBELT : 26|1@1+ (1,0) [0|7] "" XXX SG_ CTR1 : 15|4@0+ (1,0) [0|15] "" XXX SG_ CTR2 : 23|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 8|4@1+ (1,0) [0|3] "" XXX SG_ DRIVER_SEATBELT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 866 NEW_MSG_21: 8 XXX SG_ NEW_SIGNAL_2 : 7|8@0+ (1,0) [0|131071] "" XXX SG_ NEW_SIGNAL_1 : 15|8@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 27|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 23|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 59|4@0+ (1,0) [0|15] "" XXX BO_ 158 MSG_05: 8 XXX SG_ NEW_SIGNAL_1 : 23|8@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_2 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 55|8@0+ (1,0) [0|255] "" XXX BO_ 157 CRZ_BTNS: 8 XXX SG_ BIT1 : 16|1@0+ (1,0) [0|1] "" XXX SG_ BIT2 : 18|1@0+ (1,0) [0|1] "" XXX SG_ BIT3 : 20|1@0+ (1,0) [0|1] "" XXX SG_ SET_P_INV : 21|1@0+ (1,0) [0|1] "" XXX SG_ CAN_OFF_INV : 17|1@0+ (1,0) [0|1] "" XXX SG_ CAN_OFF : 0|1@0+ (1,0) [0|1] "" XXX SG_ SET_M_INV : 22|1@0+ (1,0) [0|1] "" XXX SG_ SET_M : 5|1@0+ (1,0) [0|1] "" XXX SG_ SET_P : 4|1@0+ (1,0) [0|1] "" XXX SG_ RES_INV : 19|1@0+ (1,0) [0|1] "" XXX SG_ RES : 2|1@0+ (1,0) [0|1] "" XXX SG_ DISTANCE_LESS : 7|1@0+ (1,0) [0|1] "" XXX SG_ DISTANCE_LESS_INV : 8|1@0+ (1,0) [0|1] "" XXX SG_ DISTANCE_MORE : 6|1@0+ (1,0) [0|1] "" XXX SG_ DISTANCE_MORE_INV : 23|1@0+ (1,0) [0|1] "" XXX SG_ MODE_Y : 13|1@0+ (1,0) [0|1] "" XXX SG_ MODE_X : 14|1@0+ (1,0) [0|1] "" XXX SG_ MODE_Y_INV : 30|1@0+ (1,0) [0|1] "" XXX SG_ MODE_X_INV : 31|1@0+ (1,0) [0|1] "" XXX SG_ CTR : 29|4@0+ (1,0) [0|15] "" XXX BO_ 154 BLINK_INFO: 8 XXX SG_ LEFT_BLINK : 18|1@1+ (1,0) [0|3] "" XXX SG_ RIGHT_BLINK : 19|1@0+ (1,0) [0|255] "" XXX SG_ REAR_WIPER_ON : 0|1@0+ (1,0) [0|1] "" XXX SG_ WIPER_LO : 33|1@1+ (1,0) [0|31] "" XXX SG_ WIPER_HI : 34|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAMS : 5|2@0+ (1,0) [0|3] "" XXX SG_ HIGH_BEAMS : 7|2@0+ (1,0) [0|3] "" XXX SG_ LBEAM1 : 17|1@0+ (1,0) [0|1] "" XXX SG_ LBEAM2 : 50|1@0+ (1,0) [0|1] "" XXX SG_ LBEAM3 : 60|1@0+ (1,0) [0|1] "" XXX BO_ 145 TURN_SWITCH: 8 XXX SG_ HAZARD : 10|1@0+ (1,0) [0|1] "" XXX SG_ TURN_RIGHT_SWITCH : 12|1@0+ (1,0) [0|3] "" XXX SG_ TURN_LEFT_SWITCH : 13|1@0+ (1,0) [0|255] "" XXX SG_ CTR : 27|4@0+ (1,0) [0|255] "" XXX SG_ CHKSUM : 39|8@0+ (1,0) [0|15] "" XXX BO_ 80 MSG_04: 8 XXX SG_ NEW_SIGNAL_1 : 25|1@0+ (1,0) [0|1] "" XXX SG_ SIGNAL : 24|1@0+ (1,0) [0|1] "" XXX BO_ 978 MSG_03: 8 XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 39|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 47|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 63|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 1|2@0+ (1,0) [0|255] "" XXX BO_ 607 NEW_MSG_25: 8 XXX BO_ 1115 MSG_02: 8 XXX SG_ NEW_SIGNAL_2 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 47|16@0+ (1,0) [0|65535] "" XXX SG_ NEW_SIGNAL_3 : 63|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 39|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 2|3@0+ (1,0) [0|255] "" XXX BO_ 1067 NEW_MSG_27: 8 XXX SG_ NEW_SIGNAL_2 : 3|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 0|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_1 : 2|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_5 : 1|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 12|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_6 : 11|1@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_7 : 10|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_8 : 9|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_9 : 8|1@0+ (1,0) [0|1] "" XXX BO_ 358 NEW_MSG_28: 8 XXX BO_ 608 NEW_MSG_29: 8 XXX SG_ NEW_SIGNAL_1 : 8|5@1+ (1,0) [0|7] "" XXX BO_ 606 SPEED_TBD: 8 XXX SG_ SPEED_TBD : 7|12@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 23|12@0- (1,0) [0|65535] "" XXX BO_ 552 GEAR: 8 XXX SG_ NEW_SIGNAL_3 : 11|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_5 : 26|3@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 31|5@0+ (1,0) [0|31] "" XXX SG_ NEW_SIGNAL_7 : 39|1@0+ (1,0) [0|255] "" XXX SG_ MORE_GEAR : 7|4@0+ (1,0) [0|15] "" XXX SG_ GEAR : 2|3@0+ (1,0) [0|7] "" XXX SG_ GEAR_BOX : 36|4@0+ (1,0) [0|15] "" XXX BO_ 543 CRZ_EVENTS: 8 XXX SG_ NEW_SIGNAL_3 : 34|1@0+ (1,0) [0|1] "" XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_1 : 55|4@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_5 : 47|4@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_6 : 6|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 0|1@0+ (1,0) [0|31] "" XXX SG_ NEW_SIGNAL_9 : 1|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_10 : 2|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_12 : 10|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_13 : 9|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_18 : 12|1@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_19 : 14|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_20 : 15|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_21 : 23|1@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_24 : 31|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL_PRESSED : 32|1@0+ (1,0) [0|255] "" XXX SG_ CRZ_STARTED : 18|1@0+ (1,0) [0|1] "" XXX SG_ PLUS_ONE_CRZ : 17|1@0+ (1,0) [0|255] "" XXX SG_ PLUS_ONE_CRZ_2 : 19|1@0+ (1,0) [0|1] "" XXX SG_ GAS_MAYBE : 22|1@0+ (1,0) [0|1] "" XXX SG_ NONACC_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE_CAR_MOVING : 16|1@0+ (1,0) [0|1] "" XXX SG_ NONACC_RELATED : 11|1@0+ (1,0) [0|255] "" XXX SG_ CTR : 51|4@0+ (1,0) [0|15] "" XXX SG_ CAS_CMD_MAYBE : 30|7@0- (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 43|4@0+ (1,0) [0|255] "" XXX BO_ 542 NEW_MSG_33: 8 XXX SG_ CTR : 48|4@1+ (1,0) [0|15] "" XXX SG_ CTR2 : 56|4@1+ (1,0) [0|15] "" XXX BO_ 868 NEW_MSG_34: 8 XXX SG_ CTR : 59|4@0+ (1,0) [0|255] "" XXX BO_ 869 NEW_MSG_35: 8 XXX SG_ NEW_SIGNAL_1 : 7|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 23|16@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 39|16@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 55|2@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 50|4@1+ (1,0) [0|15] "" XXX SG_ CTR : 59|4@0+ (1,0) [0|255] "" XXX BO_ 1114 NEW_MSG_4: 8 XXX BO_ 535 CURVE_CTRS: 8 XXX SG_ CTR_A_1 : 4|3@0+ (1,0) [0|31] "" XXX SG_ CTR_A_2 : 7|3@0+ (1,0) [0|255] "" XXX SG_ CTR_B_1 : 12|3@0+ (1,0) [0|7] "" XXX SG_ CTR_B_2 : 15|3@0+ (1,0) [0|7] "" XXX SG_ CTR_C_1 : 20|3@0+ (1,0) [0|7] "" XXX SG_ CTR_C_2 : 23|3@0+ (1,0) [0|255] "" XXX SG_ CTR_D_2 : 31|3@0+ (1,0) [0|7] "" XXX SG_ CTR_D_1 : 28|3@0+ (1,0) [0|7] "" XXX SG_ SPEED : 39|16@0+ (0.01,0) [0|7] "kph" XXX SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHK_MAYBE : 63|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 0|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_2 : 1|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_6 : 17|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 24|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_8 : 25|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_MAYBE : 8|1@0+ (1,0) [0|1] "" XXX SG_ NO_SEATBELT_MAYBE : 16|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 9|1@0+ (1,0) [0|1] "" XXX BO_ 540 CRZ_CTRL: 8 XXX SG_ NEW_SIGNAL_3 : 1|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_4 : 8|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 9|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_6 : 10|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 18|3@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_9 : 31|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_10 : 30|1@0+ (1,0) [0|1] "" XXX SG_ ACC_GAS_MAYBE : 23|1@0+ (1,0) [0|31] "" XXX SG_ ACC_GAS_MAYBE2 : 29|1@0+ (1,0) [0|1] "" XXX SG_ CRZ_ACTIVE : 3|1@0+ (1,0) [0|1] "" XXX SG_ HANDS_OFF_STEERING : 48|1@0+ (1,0) [0|1] "" XXX SG_ HANDS_ON_STEER_WARN : 59|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_1 : 52|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_2 : 45|3@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 0|1@0+ (1,0) [0|1] "" XXX BO_ 539 CRZ_INFO: 8 XXX SG_ NEW_SIGNAL_1 : 17|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 16|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_5 : 34|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_7 : 47|1@0+ (1,0) [0|255] "" XXX SG_ CTR1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 37|1@0+ (1,0) [0|255] "" XXX SG_ ACC_ACTIVE : 33|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_CMD : 31|10@0- (1,0) [0|1] "" XXX SG_ CHKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 121 EPB: 8 XXX SG_ NEW_SIGNAL_1 : 4|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 0|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 25|2@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 39|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 55|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 63|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_8 : 41|2@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_9 : 47|1@0+ (1,0) [0|63] "" XXX SG_ NEW_SIGNAL_10 : 46|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_11 : 45|1@0+ (1,0) [0|1] "" XXX SG_ EPB_ACTIVE : 29|1@0+ (1,0) [0|15] "" XXX BO_ 1070 2017_1: 8 XXX BO_ 1183 2017_2: 8 XXX BO_ 1243 2017_3: 8 XXX SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX BO_ 1269 MSG_2017_4: 8 XXX SG_ NEW_SIGNAL_1 : 55|16@0+ (1,0) [0|18446744073709552000] "" XXX BO_ 1178 2017_6: 8 XXX SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX BO_ 1179 2017_7: 8 XXX SG_ NEW_SIGNAL_1 : 7|64@0+ (1,0) [0|18446744073709552000] "" XXX BO_ 1435 2017_8: 8 XXX BO_ 253 GAS: 8 XXX SG_ NEW_SIGNAL_1 : 16|1@0+ (1,0) [0|65535] "" XXX SG_ CTR : 23|4@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_2 : 41|1@0+ (1,0) [0|255] "" XXX SG_ CRZ_NOT_ACTIVE : 61|1@0+ (1,0) [0|255] "" XXX SG_ GAS_CMD : 55|8@0+ (1,0) [0|255] "" XXX BO_ 359 MORE_GAS: 8 XXX SG_ NEW_SIGNAL_1 : 15|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 7|8@0+ (1,0) [0|255] "" XXX SG_ CTR : 31|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 36|5@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 38|1@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_5 : 37|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_6 : 47|4@0+ (1,0) [0|255] "" XXX BO_ 512 NEW_MSG_30: 8 XXX SG_ NEW_SIGNAL_1 : 6|7@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 7|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 15|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 23|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 22|7@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_6 : 31|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_7 : 39|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_8 : 38|7@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_9 : 40|4@1+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_10 : 47|4@0+ (1,0) [0|15] "" XXX SG_ CTR : 51|3@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_11 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 515 MSG_01: 8 XXX SG_ CTR : 39|4@0+ (1,0) [0|65535] "" XXX SG_ CHKSUM : 47|8@0+ (1,0) [0|255] "" XXX SG_ START1 : 6|1@0+ (1,0) [0|1] "" XXX SG_ START2 : 28|5@0+ (1,0) [0|255] "" XXX BO_ 529 NEW_MSG_36: 8 XXX SG_ NEW_SIGNAL_1 : 22|5@0+ (1,0) [0|65535] "" XXX SG_ NEW_SIGNAL_2 : 31|8@0+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_3 : 32|4@1+ (1,0) [0|3] "" XXX SG_ CTR : 39|4@0+ (1,0) [0|255] "" XXX SG_ CTR_2 : 47|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 40|4@1+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_5 : 53|1@0+ (1,0) [0|255] "" XXX BO_ 1242 NEW_MSG_37: 8 XXX BO_ 1266 MSG_09: 8 XXX SG_ NEW_SIGNAL_1 : 20|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 19|4@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 31|1@0+ (1,0) [0|255] "" XXX BO_ 976 MSG_15: 8 XXX SG_ NEW_SIGNAL_1 : 55|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 61|6@0+ (1,0) [0|1] "" XXX BO_ 155 MSG_14: 8 XXX BO_ 1267 MSG_10: 8 XXX SG_ NEW_SIGNAL_1 : 40|1@0+ (1,0) [0|16777215] "" XXX SG_ NEW_SIGNAL_2 : 42|1@0+ (1,0) [0|1] "" XXX BO_ 305 NEW_MSG_6: 8 XXX SG_ NEW_SIGNAL_1 : 8|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 9|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 10|1@0+ (1,0) [0|1] "" XXX BO_ 1238 TEMPERATURE: 8 XXX SG_ TEMPERATURE_MAYBE : 47|8@0+ (1,0) [0|4294967295] "" XXX BO_ 1087 NEW_MSG_1: 8 XXX SG_ NEW_SIGNAL_1 : 7|8@0+ (1,0) [0|255] "" XXX BO_ 1143 BSM: 8 XXX SG_ BSM_OFF : 0|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_BS_3 : 37|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL : 8|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_BS1 : 12|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_BS3 : 38|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_BS4 : 39|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_BS_SIDE : 36|1@0+ (1,0) [0|1] "" XXX SG_ IS_MOVING : 9|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_BS_BEHIND : 46|2@1+ (1,0) [0|16777215] "" XXX SG_ RIGHT_BS1 : 14|1@0+ (1,0) [0|63] "" XXX SG_ RIGHT_BS_DISTANCE : 35|3@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_1 : 32|1@0+ (1,0) [0|1] "" XXX SG_ REAR_CT_ALERT : 23|5@0+ (1,0) [0|63] "" XXX BO_ 1361 KEY_POSITION: 8 XXX BO_ 1283 KEY_POSITION2: 8 XXX BO_ 628 MSG_06: 8 XXX BO_ 1154 MSG_08: 8 XXX BO_ 1139 MSG_13: 8 XXX BO_ 1270 MSG_16: 8 XXX BO_ 1272 MSG_17: 8 XXX BO_ 1425 MSG_19: 8 XXX BO_ 70 MOB1: 8 XXX SG_ NEW_SIGNAL_1 : 1|3@1+ (1,0) [0|15] "" XXX SG_ NEW_SIGNAL_2 : 14|6@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_3 : 23|8@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 30|6@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 38|6@0+ (1,0) [0|7] "" XXX BO_ 64 MOB2: 8 XXX SG_ NEW_SIGNAL_1 : 7|2@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_2 : 10|3@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_3 : 16|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_4 : 24|1@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_5 : 35|4@0+ (1,0) [0|255] "" XXX SG_ NEW_SIGNAL_6 : 0|3@1+ (1,0) [0|7] "" XXX SG_ NEW_SIGNAL_7 : 13|3@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_8 : 15|2@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_9 : 19|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_10 : 31|6@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_11 : 37|1@0+ (1,0) [0|1] "" XXX BO_ 1171 MOB3: 8 XXX BO_ 1248 MOB4: 8 XXX CM_ SG_ 357 GEAR "13P, 26R, 13N, 24D"; CM_ SG_ 605 PED_BRAKE "3: no brake, 4: brake"; CM_ SG_ 605 BRAKE_WARNING "Flashing brake warning and audible alert for potential forward collision"; CM_ SG_ 579 STEERING_ANGLE "steering angle aligns with 0.022 factor and -45.06 offset"; CM_ SG_ 863 SPEED_SIGN "speed limit in MPH"; CM_ SG_ 863 SPEED_SIGN_CAM "1: The speed limit is recognized by the camera. 0: speed limit is map based or is not available"; CM_ SG_ 863 STOP_SIGN "value 9 when stop sign is active"; CM_ SG_ 1157 SBS_WARNING_DISTANCE "1 far, 2 mid, 3 near"; CM_ SG_ 1157 SBS_SCBC "1 off, 2 on"; CM_ SG_ 1157 LKAS_ASSIT_TIMING "1 at, 0 before"; CM_ SG_ 1157 LKAS_SENSETIVITY "0 low, 1 high"; CM_ SG_ 1157 LANEE_DEPARTURE_ALERT "1 off, 2 on"; CM_ SG_ 1157 WARNING "1 Rare, 0 often"; CM_ SG_ 1088 LANE_LINES "0 LKAS disabled, 1 no lines, 2 two lines, 3 left line, 4 right line"; CM_ SG_ 1045 ABS_MALFUNCTION "off: 0, solid: 1, slow blink: 2, fast blink: 3"; CM_ SG_ 157 CAN_OFF "Disengage Cruise if enabled, if already disabled TURN it OFF "; CM_ SG_ 552 MORE_GEAR ""; CM_ SG_ 552 GEAR "0 Shifting, 1 P, 2 R, 3 N, 4 D"; CM_ SG_ 552 GEAR_BOX "0 P, 14 R, 1 though 6 D for speeds, 15 Shift"; CM_ SG_ 540 HANDS_ON_STEER_WARN "0 no warning, b warning"; CM_ SG_ 1143 REAR_CT_ALERT "Rear Cross Traffic Alert"; VAL_ 552 GEAR 1 "P" 2 "R" 3 "N" 4 "D" ; ================================================ FILE: opendbc/nissan_leaf_2018.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 2 STEER_ANGLE_SENSOR: 5 XXX SG_ STEER_ANGLE_RATE : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X07 : 24|8@1+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 0|16@1- (-0.1,0) [0|65535] "" XXX SG_ COUNTER : 32|4@1+ (1,0) [0|15] "" XXX BO_ 42 SEATBELT: 8 XXX SG_ SEATBELT_DRIVER_LATCHED : 27|1@1+ (1,0) [0|3] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 26|1@0+ (1,0) [0|1] "" XXX SG_ unknown2 : 31|4@0+ (1,0) [0|15] "" XXX SG_ unknown3 : 24|2@1+ (1,0) [0|3] "" XXX SG_ unknown1 : 7|24@0+ (1,0) [0|16777215] "" XXX SG_ unknown4 : 39|16@0+ (1,0) [0|65535] "" XXX BO_ 361 LKAS: 8 XXX SG_ MAX_TORQUE : 39|8@0+ (0.01,0) [0|255] "Nm" XXX SG_ SET_0x80 : 47|8@0+ (1,0) [0|255] "" XXX SG_ LKA_ACTIVE : 52|1@0+ (1,0) [0|15] "" XXX SG_ SET_0x80_2 : 31|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ DESIRED_ANGLE : 7|18@0+ (-0.01,1310) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 389 STEER_TORQUE_SENSOR: 8 XXX SG_ LKAS_ACTIVE : 37|1@0+ (1,0) [0|3] "" XXX SG_ STEER_TORQUE_LKAS : 47|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 23|18@0+ (-0.01,1310) [0|262143] "" XXX SG_ STEER_TORQUE_DRIVER : 7|12@0+ (-0.01,20.47) [0|4095] "Nm" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|127] "" XXX BO_ 460 BRAKE_PEDAL: 8 XXX SG_ BRAKE_PEDAL : 7|8@0+ (1,0) [0|256] "" XXX BO_ 569 CRUISE_THROTTLE: 8 XXX SG_ GAS_PEDAL_INVERTED : 15|8@0+ (1,0) [0|255] "" XXX SG_ GAS_PEDAL : 7|8@0+ (1,0) [0|255] "" XXX SG_ CRUISE_AVAILABLE : 17|1@0+ (1,0) [0|1] "" XXX SG_ unsure1 : 23|6@0+ (1,0) [0|63] "" XXX SG_ unsure2 : 16|1@0+ (1,0) [0|1] "" XXX SG_ unsure3 : 31|2@0+ (1,0) [0|3] "" XXX SG_ NO_BUTTON_PRESSED : 29|1@0+ (1,0) [0|1] "" XXX SG_ RES_BUTTON : 28|1@0+ (1,0) [0|1] "" XXX SG_ SET_BUTTON : 27|1@0+ (1,0) [0|1] "" XXX SG_ FOLLOW_DISTANCE_BUTTON : 26|1@0+ (1,0) [0|1] "" XXX SG_ CANCEL_BUTTON : 25|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_BUTTON : 24|1@0+ (1,0) [0|1] "" XXX SG_ unsure4 : 39|6@0+ (1,0) [0|63] "" XXX SG_ COUNTER : 32|2@1+ (1,0) [0|3] "" XXX SG_ unsure5 : 47|8@0+ (1,0) [0|255] "" XXX SG_ unsure6 : 55|8@0+ (1,0) [0|255] "" XXX SG_ unsure7 : 63|8@0+ (1,0) [0|255] "" XXX BO_ 640 CANCEL_MSG: 8 XXX SG_ CANCEL_SEATBELT : 1|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_1 : 7|6@0+ (1,0) [0|63] "" XXX SG_ NEW_SIGNAL_2 : 0|1@0+ (1,0) [0|1] "" XXX SG_ NEW_SIGNAL_3 : 15|56@0+ (1,0) [0|72057594037927940] "" XXX BO_ 644 WHEEL_SPEEDS_FRONT: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX BO_ 645 WHEEL_SPEEDS_REAR: 8 XXX SG_ WHEEL_SPEED_RR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX SG_ WHEEL_SPEED_RL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX BO_ 689 PROPILOT_HUD: 8 XXX SG_ LARGE_WARNING_FLASHING : 9|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_ERROR_FLASHING1 : 10|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_ERROR_FLASHING2 : 11|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_LANE_YELLOW_FLASH : 12|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_LANE_YELLOW_FLASH : 13|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_CAR : 14|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_CAR_ERROR : 15|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_ERROR : 16|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_ERROR_FLASHING : 17|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_LANE_GREEN : 24|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_LANE_GREEN : 25|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_ERROR_FLASHING3 : 27|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_ERROR_FLASHING : 29|1@0+ (1,0) [0|1] "" XXX SG_ SAFETY_SHIELD_ACTIVE : 44|1@0+ (1,0) [0|1] "" XXX SG_ LARGE_STEERING_WHEEL_ICON : 61|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LANE_GREEN_FLASH : 62|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_LANE_GREEN_FLASH : 63|1@0+ (1,0) [0|1] "" XXX SG_ FOLLOW_DISTANCE : 3|2@0+ (1,0) [0|3] "" XXX SG_ AUDIBLE_TONE : 47|3@0+ (1,0) [0|8] "" XXX SG_ SPEED_SET_ICON : 7|2@0+ (1,0) [0|3] "" XXX SG_ SMALL_STEERING_WHEEL_ICON : 42|3@0+ (1,0) [0|7] "" XXX SG_ SET_SPEED : 39|8@0+ (1,0) [0|255] "" XXX SG_ unknown02 : 1|2@0+ (1,0) [0|3] "" XXX SG_ unknown05 : 5|2@0+ (1,0) [0|3] "" XXX SG_ unknown08 : 8|7@0+ (1,0) [0|63] "" XXX SG_ unknown26 : 26|1@0+ (1,0) [0|1] "" XXX SG_ unknown28 : 28|1@0+ (1,0) [0|1] "" XXX SG_ unknown31 : 31|2@0+ (1,0) [0|3] "" XXX SG_ unknown43 : 43|1@0+ (1,0) [0|1] "" XXX SG_ unknown55 : 55|8@0+ (1,0) [0|63] "" XXX SG_ unknown59 : 59|4@0+ (1,0) [0|15] "" XXX BO_ 783 CRUISE_STATE: 3 XXX SG_ CRUISE_ENABLED : 3|1@0+ (1,0) [0|1] "" XXX BO_ 852 ESP: 8 XXX SG_ ESP_DISABLED : 38|1@0+ (1,0) [0|1] "" XXX BO_ 853 HUD_SETTINGS: 8 XXX SG_ SPEED_MPH : 37|1@0+ (1,0) [0|1] "" XXX BO_ 856 LIGHTS: 8 XXX SG_ LEFT_BLINKER : 17|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_BLINKER : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1057 GEARBOX: 3 XXX SG_ GEAR_SHIFTER : 5|3@0+ (1,0) [0|255] "" XXX BO_ 1228 PROPILOT_HUD_INFO_MSG: 8 XXX SG_ NA_HIGH_ACCEL_TEMP : 0|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_NA_HIGH_CABIN_TEMP : 8|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_MALFUNCTION : 11|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_MALFUNCTION : 12|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_MALFUNCTION : 13|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_NA_CLEAN_REAR_CAMERA : 14|1@0+ (1,0) [0|1] "" XXX SG_ NA_POOR_ROAD_CONDITIONS : 16|1@0+ (1,0) [0|1] "" XXX SG_ CURRENTLY_UNAVAILABLE : 17|1@0+ (1,0) [0|1] "" XXX SG_ SAFETY_SHIELD_OFF : 18|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_COLLISION_NA_FRONT_RADAR_OBSTRUCTION : 20|1@0+ (1,0) [0|1] "" XXX SG_ PEDAL_MISSAPPLICATION_SYSTEM_ACTIVATED : 24|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_IMPACT_NA_RADAR_OBSTRUCTION : 25|1@0+ (1,0) [0|1] "" XXX SG_ WARNING_DO_NOT_ENTER : 33|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_IMPACT_SYSTEM_OFF : 34|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_IMPACT_MALFUNCTION : 35|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_COLLISION_MALFUNCTION : 36|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_MALFUNCTION2 : 37|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_MALFUNCTION2 : 38|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_MALFUNCTION2 : 39|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_NA_MSGS : 42|3@0+ (1,0) [0|7] "" XXX SG_ BOTTOM_MSG : 45|3@0+ (1,0) [0|7] "" XXX SG_ HANDS_ON_WHEEL_WARNING : 47|1@0+ (1,0) [0|1] "" XXX SG_ WARNING_STEP_ON_BRAKE_NOW : 51|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_NA_FRONT_CAMERA_OBSTRUCTED : 52|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_NA_HIGH_CABIN_TEMP : 53|1@0+ (1,0) [0|1] "" XXX SG_ WARNING_PROPILOT_MALFUNCTION : 54|1@0+ (1,0) [0|3] "" XXX SG_ ACC_UNAVAILABLE_HIGH_CABIN_TEMP : 62|1@0+ (1,0) [0|1] "" XXX SG_ ACC_NA_FRONT_CAMERA_IMPARED : 63|1@0+ (1,0) [0|1] "" XXX SG_ unknown07 : 7|7@0+ (1,0) [0|127] "" XXX SG_ unknown10 : 10|2@0+ (1,0) [0|3] "" XXX SG_ unknown15 : 15|1@0+ (1,0) [0|1] "" XXX SG_ unknown23 : 23|3@0+ (1,0) [0|7] "" XXX SG_ unknown19 : 19|1@0+ (1,0) [0|1] "" XXX SG_ unknown31 : 31|6@0+ (1,0) [0|63] "" XXX SG_ unknown32 : 32|1@0+ (1,0) [0|1] "" XXX SG_ unknown46 : 46|1@0+ (1,0) [0|1] "" XXX SG_ unknown50 : 50|3@0+ (1,0) [0|7] "" XXX SG_ unknown55 : 55|1@0+ (1,0) [0|1] "" XXX SG_ unknown61 : 61|6@0+ (1,0) [0|63] "" XXX BO_ 1549 DOORS_LIGHTS: 8 XXX SG_ DOOR_OPEN_FL : 3|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 4|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 5|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 6|1@0+ (1,0) [0|1] "" XXX BO_ 1227 LKAS_SETTINGS: 8 XXX SG_ LKAS_ENABLED : 51|1@0+ (1,0) [0|1] "" XXX VAL_ 1057 GEAR_SHIFTER 7 "B" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 1228 PROPILOT_NA_MSGS 0 "NO_MSG" 1 "NA_FRONT_CAMERA_IMPARED" 2 "STEERING_ASSIST_ON_STANDBY" 3 "NA_PARKING_ASSIST_ENABLED" 4 "STEER_ASSIST_CURRENTLY_NA" 5 "NA_BAD_WEATHER" 6 "NA_PARK_BRAKE_ON" 7 "NA_SEATBELT_NOT_FASTENED" ; VAL_ 1228 BOTTOM_MSG 0 "OK_STEER_ASSIST_SETTINGS" 1 "NO_MSG" 2 "PRESS_SET_TO_SET_SPEED" 3 "PRESS_RES_SET_TO_CHANGE_SPEED" 4 "PRESS_RES_TO_RESTART" 5 "NO_MSG" 6 "CRUISE_NOT_AVAIL" 7 "NO_MSG" ; VAL_ 689 FOLLOW_DISTANCE 0 "NO_FOLLOW_DISTANCE" 1 "FOLLOW_DISTANCE_1" 2 "FOLLOW_DISTANCE_2" 3 "FOLLOW_DISANCE_3" ; VAL_ 689 AUDIBLE_TONE 0 "NO_TONE" 1 "CONT" 2 "FAST_BEEP_CONT" 3 "TRIPLE_FAST_BEEP_CONT" 4 "SLOW_BEEP_CONT" 5 "QUAD_SLOW_BEEP_CONT" 6 "SINGLE_BEEP_ONCE" 7 "DOUBLE_BEEP_ONCE" ; VAL_ 689 SMALL_STEERING_WHEEL_ICON 0 "NO_ICON" 1 "GRAY_ICON" 2 "GRAY_ICON_FLASHING" 3 "GREEN_ICON" 4 "GREEN_ICON_FLASHING" 5 "RED_ICON" 6 "RED_ICON_FLASHING" 7 "YELLOW_ICON" ; VAL_ 689 LARGE_STEERING_WHEEL_ICON 0 "NO_STEERINGWHEEL" 1 "GRAY_STEERINGWHEEL" 2 "GREEN_STEERINGWHEEL" 3 "GREEN_STEERINGWHEEL_FLASHING" ; ================================================ FILE: opendbc/nissan_x_trail_2017.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 2 STEER_ANGLE_SENSOR: 5 XXX SG_ STEER_ANGLE_RATE : 16|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_X07 : 24|8@1+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 0|16@1- (-0.1,0) [0|65535] "" XXX SG_ COUNTER : 32|4@1+ (1,0) [0|15] "" XXX BO_ 348 GAS_PEDAL: 8 XXX SG_ GAS_PEDAL_RAW : 26|11@0+ (1,0) [0|2047] "" XXX SG_ GAS_PEDAL : 47|10@0+ (1,0) [0|1023] "" XXX BO_ 361 LKAS: 8 XXX SG_ MAX_TORQUE : 39|8@0+ (0.01,0) [0|255] "Nm" XXX SG_ SET_0x80 : 47|8@0+ (1,0) [0|255] "" XXX SG_ LKA_ACTIVE : 52|1@0+ (1,0) [0|15] "" XXX SG_ SET_0x80_2 : 31|8@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ DESIRED_ANGLE : 7|18@0+ (-0.01,1310) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 389 STEER_TORQUE_SENSOR: 8 XXX SG_ LKAS_ACTIVE : 37|1@0+ (1,0) [0|3] "" XXX SG_ STEER_TORQUE_LKAS : 47|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 23|18@0+ (-0.01,1310) [0|262143] "" XXX SG_ STEER_TORQUE_DRIVER : 7|12@0+ (-0.01,20.47) [0|4095] "Nm" XXX SG_ COUNTER : 51|4@0+ (1,0) [0|15] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|127] "" XXX BO_ 438 PRO_PILOT: 8 XXX SG_ COUNTER : 55|4@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X03 : 33|2@0+ (1,0) [0|15] "" XXX SG_ CRUISE_ACTIVATED : 38|1@0+ (1,0) [0|3] "" XXX SG_ CRUISE_ON : 36|1@0+ (1,0) [0|255] "" XXX SG_ STEER_STATUS : 51|1@0+ (1,0) [0|3] "" XXX BO_ 523 CRUISE_THROTTLE: 6 XXX SG_ PROPILOT_BUTTON : 8|1@0+ (1,0) [0|1] "" XXX SG_ CANCEL_BUTTON : 9|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL_INVERTED : 37|10@0+ (1,0) [0|1023] "" XXX SG_ SET_BUTTON : 11|1@0+ (1,0) [0|1] "" XXX SG_ RES_BUTTON : 12|1@0+ (1,0) [0|1] "" XXX SG_ FOLLOW_DISTANCE_BUTTON : 10|1@0+ (1,0) [0|1] "" XXX SG_ NO_BUTTON_PRESSED : 13|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 31|10@0+ (1,0) [0|255] "" XXX SG_ USER_BRAKE_PRESSED : 21|1@0+ (1,0) [0|1] "" XXX SG_ USER_BRAKE_PRESSED_INVERTED : 22|1@0+ (1,0) [0|3] "" XXX SG_ NEW_SIGNAL_2 : 23|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PRESSED_INVERTED : 20|1@0+ (1,0) [0|255] "" XXX SG_ COUNTER : 17|2@0+ (1,0) [0|3] "" XXX SG_ unsure1 : 7|10@0+ (1,0) [0|1023] "" XXX SG_ unsure2 : 43|4@0+ (1,0) [0|1] "" XXX SG_ unsure3 : 19|2@0+ (1,0) [0|3] "" XXX BO_ 645 WHEEL_SPEEDS_REAR: 8 XXX SG_ WHEEL_SPEED_RR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX SG_ WHEEL_SPEED_RL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX BO_ 665 ESP: 8 XXX SG_ ESP_DISABLED : 24|1@0+ (1,0) [0|1] "" XXX BO_ 666 WHEEL_SPEEDS_FRONT: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.005,0) [0|65535] "KPH" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.005,0) [0|65535] "KPH" XXX BO_ 689 PROPILOT_HUD: 8 XXX SG_ LARGE_WARNING_FLASHING : 9|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_ERROR_FLASHING1 : 10|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_ERROR_FLASHING2 : 11|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_LANE_YELLOW_FLASH : 12|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_LANE_YELLOW_FLASH : 13|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_CAR : 14|1@0+ (1,0) [0|1] "" XXX SG_ LEAD_CAR_ERROR : 15|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_ERROR : 16|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_ERROR_FLASHING : 17|1@0+ (1,0) [0|1] "" XXX SG_ RIGHT_LANE_GREEN : 24|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_LANE_GREEN : 25|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_ERROR_FLASHING3 : 27|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_ERROR_FLASHING : 29|1@0+ (1,0) [0|1] "" XXX SG_ SAFETY_SHIELD_ACTIVE : 44|1@0+ (1,0) [0|1] "" XXX SG_ LARGE_STEERING_WHEEL_ICON : 61|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LANE_GREEN_FLASH : 62|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_LANE_GREEN_FLASH : 63|1@0+ (1,0) [0|1] "" XXX SG_ FOLLOW_DISTANCE : 3|2@0+ (1,0) [0|3] "" XXX SG_ AUDIBLE_TONE : 47|3@0+ (1,0) [0|8] "" XXX SG_ SPEED_SET_ICON : 7|2@0+ (1,0) [0|3] "" XXX SG_ SMALL_STEERING_WHEEL_ICON : 42|3@0+ (1,0) [0|7] "" XXX SG_ SET_SPEED : 39|8@0+ (1,0) [0|255] "" XXX SG_ unknown02 : 1|2@0+ (1,0) [0|3] "" XXX SG_ unknown05 : 5|2@0+ (1,0) [0|3] "" XXX SG_ unknown08 : 8|7@0+ (1,0) [0|63] "" XXX SG_ unknown26 : 26|1@0+ (1,0) [0|1] "" XXX SG_ unknown28 : 28|1@0+ (1,0) [0|1] "" XXX SG_ unknown31 : 31|2@0+ (1,0) [0|3] "" XXX SG_ unknown43 : 43|1@0+ (1,0) [0|1] "" XXX SG_ unknown55 : 55|8@0+ (1,0) [0|63] "" XXX SG_ unknown59 : 59|4@0+ (1,0) [0|15] "" XXX BO_ 768 STEER_TORQUE_SENSOR2: 2 XXX SG_ STEERING_TORQUE : 6|7@0+ (1,0) [0|127] "" XXX SG_ STEERING_PRESSED : 15|1@0+ (-1,1) [0|7] "" XXX BO_ 783 CRUISE_STATE: 3 XXX SG_ CRUISE_ENABLED : 3|1@0+ (1,0) [0|1] "" XXX BO_ 1055 GEARBOX: 2 XXX SG_ SPORTS_MODE : 13|1@0+ (1,0) [0|1] "" XXX SG_ GEAR_SHIFTER : 5|3@0+ (1,0) [0|255] "" XXX BO_ 1107 LIGHTS: 8 XXX SG_ RIGHT_BLINKER : 12|1@0+ (1,0) [0|1] "" XXX SG_ LEFT_BLINKER : 11|1@0+ (1,0) [0|1] "" XXX SG_ HEADLIGHTS : 5|1@0+ (1,0) [0|1] "" XXX BO_ 1108 DOORS_LIGHTS: 8 XXX SG_ DOOR_CLOSED_RR : 40|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 41|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_CLOSED_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_CLOSED_FL : 44|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_CLOSED_FR : 46|1@0+ (1,0) [0|3] "" XXX SG_ DOOR_OPEN_FR : 47|1@0+ (1,0) [0|3] "" XXX SG_ BOOT_OPEN : 55|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHT : 54|1@0+ (1,0) [0|1] "" XXX SG_ USER_BRAKE_PRESSED : 23|1@0+ (1,0) [0|1] "" XXX BO_ 1228 PROPILOT_HUD_INFO_MSG: 8 XXX SG_ NA_HIGH_ACCEL_TEMP : 0|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_NA_HIGH_CABIN_TEMP : 8|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_MALFUNCTION : 11|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_MALFUNCTION : 12|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_MALFUNCTION : 13|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_NA_CLEAN_REAR_CAMERA : 14|1@0+ (1,0) [0|1] "" XXX SG_ NA_POOR_ROAD_CONDITIONS : 16|1@0+ (1,0) [0|1] "" XXX SG_ CURRENTLY_UNAVAILABLE : 17|1@0+ (1,0) [0|1] "" XXX SG_ SAFETY_SHIELD_OFF : 18|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_COLLISION_NA_FRONT_RADAR_OBSTRUCTION : 20|1@0+ (1,0) [0|1] "" XXX SG_ PEDAL_MISSAPPLICATION_SYSTEM_ACTIVATED : 24|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_IMPACT_NA_RADAR_OBSTRUCTION : 25|1@0+ (1,0) [0|1] "" XXX SG_ WARNING_DO_NOT_ENTER : 33|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_IMPACT_SYSTEM_OFF : 34|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_IMPACT_MALFUNCTION : 35|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_COLLISION_MALFUNCTION : 36|1@0+ (1,0) [0|1] "" XXX SG_ SIDE_RADAR_MALFUNCTION2 : 37|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_MALFUNCTION2 : 38|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_RADAR_MALFUNCTION2 : 39|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_NA_MSGS : 42|3@0+ (1,0) [0|7] "" XXX SG_ BOTTOM_MSG : 45|3@0+ (1,0) [0|7] "" XXX SG_ HANDS_ON_WHEEL_WARNING : 47|1@0+ (1,0) [0|1] "" XXX SG_ WARNING_STEP_ON_BRAKE_NOW : 51|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_NA_FRONT_CAMERA_OBSTRUCTED : 52|1@0+ (1,0) [0|1] "" XXX SG_ PROPILOT_NA_HIGH_CABIN_TEMP : 53|1@0+ (1,0) [0|1] "" XXX SG_ WARNING_PROPILOT_MALFUNCTION : 54|1@0+ (1,0) [0|3] "" XXX SG_ ACC_UNAVAILABLE_HIGH_CABIN_TEMP : 62|1@0+ (1,0) [0|1] "" XXX SG_ ACC_NA_FRONT_CAMERA_IMPARED : 63|1@0+ (1,0) [0|1] "" XXX SG_ unknown07 : 7|7@0+ (1,0) [0|127] "" XXX SG_ unknown10 : 10|2@0+ (1,0) [0|3] "" XXX SG_ unknown15 : 15|1@0+ (1,0) [0|1] "" XXX SG_ unknown23 : 23|3@0+ (1,0) [0|7] "" XXX SG_ unknown19 : 19|1@0+ (1,0) [0|1] "" XXX SG_ unknown31 : 31|6@0+ (1,0) [0|63] "" XXX SG_ unknown32 : 32|1@0+ (1,0) [0|1] "" XXX SG_ unknown46 : 46|1@0+ (1,0) [0|1] "" XXX SG_ unknown50 : 50|3@0+ (1,0) [0|7] "" XXX SG_ unknown55 : 55|1@0+ (1,0) [0|1] "" XXX SG_ unknown61 : 61|6@0+ (1,0) [0|63] "" XXX BO_ 1227 LKAS_SETTINGS: 8 XXX SG_ LKAS_ENABLED : 51|1@0+ (1,0) [0|1] "" XXX BO_ 1273 HUD: 7 XXX SG_ SEATBELT_DRIVER_LATCHED : 25|1@0+ (1,0) [0|1] "" XXX SG_ SPEED_MPH : 5|1@0+ (1,0) [0|1] "" XXX VAL_ 1055 GEAR_SHIFTER 6 "L" 4 "D" 3 "N" 2 "R" 1 "P" ; VAL_ 1228 PROPILOT_NA_MSGS 0 "NO_MSG" 1 "NA_FRONT_CAMERA_IMPARED" 2 "STEERING_ASSIST_ON_STANDBY" 3 "NA_PARKING_ASSIST_ENABLED" 4 "STEER_ASSIST_CURRENTLY_NA" 5 "NA_BAD_WEATHER" 6 "NA_PARK_BRAKE_ON" 7 "NA_SEATBELT_NOT_FASTENED" ; VAL_ 1228 BOTTOM_MSG 0 "OK_STEER_ASSIST_SETTINGS" 1 "NO_MSG" 2 "PRESS_SET_TO_SET_SPEED" 3 "PRESS_RES_SET_TO_CHANGE_SPEED" 4 "PRESS_RES_TO_RESTART" 5 "NO_MSG" 6 "CRUISE_NOT_AVAIL" 7 "NO_MSG" ; VAL_ 689 FOLLOW_DISTANCE 0 "NO_FOLLOW_DISTANCE" 1 "FOLLOW_DISTANCE_1" 2 "FOLLOW_DISTANCE_2" 3 "FOLLOW_DISANCE_3" ; VAL_ 689 AUDIBLE_TONE 0 "NO_TONE" 1 "CONT" 2 "FAST_BEEP_CONT" 3 "TRIPLE_FAST_BEEP_CONT" 4 "SLOW_BEEP_CONT" 5 "QUAD_SLOW_BEEP_CONT" 6 "SINGLE_BEEP_ONCE" 7 "DOUBLE_BEEP_ONCE" ; VAL_ 689 SMALL_STEERING_WHEEL_ICON 0 "NO_ICON" 1 "GRAY_ICON" 2 "GRAY_ICON_FLASHING" 3 "GREEN_ICON" 4 "GREEN_ICON_FLASHING" 5 "RED_ICON" 6 "RED_ICON_FLASHING" 7 "YELLOW_ICON" ; VAL_ 689 LARGE_STEERING_WHEEL_ICON 0 "NO_STEERINGWHEEL" 1 "GRAY_STEERINGWHEEL" 2 "GREEN_STEERINGWHEEL" 3 "GREEN_STEERINGWHEEL_FLASHING" ; ================================================ FILE: opendbc/subaru_forester_2017_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _subaru_preglobal_2015.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX X BO_ 2 Steering: 8 XXX SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX SG_ Counter : 27|3@0+ (1,0) [0|7] "" XXX SG_ Checksum : 39|8@0+ (1,0) [0|255] "" XXX BO_ 208 G_Sensor: 8 XXX SG_ Steering_Angle : 0|16@1- (-0.1,0) [-500|500] "" XXX SG_ Lateral : 16|16@1- (-0.0035,1) [-255|255] "" XXX SG_ Longitudinal : 48|16@1- (-0.00035,0) [-255|255] "" XXX BO_ 209 Brake_Pedal: 8 XXX SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX SG_ Brake_Pedal : 16|8@1+ (1,0) [0|255] "" XXX BO_ 210 Brake_2: 8 XXX SG_ Brake_Light : 35|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Related : 36|1@1+ (1,0) [0|1] "" XXX SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX SG_ Left_Brake : 56|8@1+ (1,0) [0|255] "" XXX BO_ 211 Brake_Type: 8 XXX SG_ Brake_Light : 21|1@1+ (1,0) [0|1] "" XXX SG_ Speed_Counter : 32|8@1+ (1,0) [0|255] "" XXX SG_ Brake_Cruise_On : 42|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal_On : 46|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 48|8@1+ (1,0) [0|255] "" XXX BO_ 212 Wheel_Speeds: 8 XXX SG_ FL : 0|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ FR : 16|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ RL : 32|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ RR : 48|16@1+ (0.0592,0) [0|255] "KPH" XXX BO_ 320 Throttle: 8 XXX SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|2@1+ (1,0) [0|7] "" XXX SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 15|1@1+ (1,0) [0|1] "" XXX SG_ Engine_RPM : 16|14@1+ (1,0) [0|32767] "" XXX SG_ Off_Throttle : 30|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 31|1@1+ (1,0) [0|1] "" XXX SG_ Throttle_Cruise : 32|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Body : 48|8@1+ (1,0) [0|255] "" XXX SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|1] "" XXX SG_ Signal4 : 57|7@1+ (1,0) [0|127] "" XXX BO_ 321 Engine: 8 XXX SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" XXX SG_ Engine_Stop : 15|1@1+ (1,0) [0|1] "" XXX SG_ Wheel_Torque : 16|12@1+ (1,0) [0|4095] "" XXX SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX BO_ 324 CruiseControl: 8 XXX SG_ OnOffButton : 2|1@1+ (1,0) [0|1] "" XXX SG_ SET_BUTTON : 3|1@1+ (1,0) [0|1] "" XXX SG_ RES_BUTTON : 4|1@1+ (1,0) [0|1] "" XXX SG_ Button : 13|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_On : 48|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 49|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal_On : 51|1@1+ (1,0) [0|1] "" XXX BO_ 328 Transmission: 8 XXX SG_ Manual_Gear : 4|4@1+ (1,0) [0|15] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX SG_ Paddle_Shift : 60|2@1+ (1,0) [0|3] "" XXX BO_ 329 CVT_Ratio: 8 XXX BO_ 336 Brake_Pressure: 8 XXX SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|255] "" XXX SG_ Brake_Pressure_Left : 8|8@1+ (1,0) [0|255] "" XXX BO_ 338 Stalk: 8 XXX SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX SG_ Brake_Light : 52|1@1+ (1,0) [0|1] "" XXX SG_ Runlights : 58|1@1+ (1,0) [0|1] "" XXX SG_ Headlights : 59|1@1+ (1,0) [0|1] "" XXX SG_ Highbeam : 60|1@1+ (1,0) [0|1] "" XXX SG_ Wiper : 62|1@1+ (1,0) [0|1] "" XXX BO_ 352 ES_Brake: 8 XXX SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX SG_ Brake_Light : 20|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 21|1@1+ (1,0) [0|1] "" XXX SG_ Brake_On : 22|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 23|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 353 ES_CruiseThrottle: 8 XXX SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|4095] "" XXX SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Cruise_Activated : 16|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 17|3@1+ (1,0) [0|7] "" XXX SG_ Brake_On : 20|1@1+ (1,0) [0|1] "" XXX SG_ Distance_Swap : 21|1@1+ (1,0) [0|1] "" XXX SG_ Standstill : 22|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 23|1@1+ (1,0) [0|1] "" XXX SG_ Close_Distance : 24|8@1+ (0.0196,0) [0|255] "m" XXX SG_ Signal4 : 32|9@1+ (1,0) [0|255] "" XXX SG_ Standstill_2 : 41|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 42|1@1+ (1,0) [0|1] "" XXX SG_ Signal5 : 43|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 44|3@1+ (1,0) [0|7] "" XXX SG_ Signal6 : 47|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Button : 48|3@1+ (1,0) [0|7] "" XXX SG_ Signal7 : 51|5@1+ (1,0) [0|31] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 354 ES_RPM: 8 XXX SG_ Brake : 8|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 9|1@1+ (1,0) [0|1] "" XXX SG_ RPM : 16|16@1+ (1,0) [0|65535] "" XXX SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX BO_ 356 ES_LKAS: 8 XXX SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 359 ES_LDW: 8 XXX SG_ All_depart_2015 : 0|1@1+ (1,0) [0|1] "" XXX SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|1] "" XXX SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|1] "" XXX SG_ Sig1All_Depart : 28|1@1+ (1,0) [0|1] "" XXX SG_ Sig2All_Depart : 31|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Active : 37|1@1+ (1,0) [0|1] "" XXX SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|1] "" XXX SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|1] "" XXX SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|1] "" XXX SG_ Left_Depart_Front : 51|1@1+ (1,0) [0|1] "" XXX SG_ Sig3All_Depart : 52|1@1+ (1,0) [0|1] "" XXX BO_ 604 BSD_RCTA: 8 XXX SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX SG_ State : 5|1@1+ (1,0) [0|1] "" XXX SG_ R_ADJACENT : 32|1@1+ (1,0) [0|1] "" XXX SG_ L_ADJACENT : 33|1@1+ (1,0) [0|1] "" XXX SG_ R_APPROACHING : 42|1@1+ (1,0) [0|1] "" XXX SG_ L_APPROACHING : 43|1@1+ (1,0) [0|1] "" XXX SG_ R_RCTA : 46|1@1+ (1,0) [0|1] "" XXX SG_ L_RCTA : 47|1@1+ (1,0) [0|1] "" XXX BO_ 642 Dashlights: 8 XXX SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|1] "" XXX SG_ LEFT_BLINKER : 44|1@1+ (1,0) [0|1] "" XXX SG_ RIGHT_BLINKER : 45|1@1+ (1,0) [0|1] "" XXX BO_ 880 Steering_Torque_2: 8 XXX SG_ Steering_Voltage_Flat : 0|8@1+ (1,0) [0|255] "" XXX SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX BO_ 884 BodyInfo: 8 XXX SG_ DOOR_OPEN_FR : 24|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 25|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 26|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 27|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_Hatch : 28|1@1+ (1,0) [0|1] "" XXX BO_ 864 Engine_Temp: 8 XXX SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX SG_ Cruise_Activated : 45|1@1+ (1,0) [0|1] "" XXX SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX BO_ 866 Fuel: 8 XXX BO_ 977 Dash_State2: 8 XXX SG_ UNITS : 15|1@1+ (1,0) [0|1] "" XXX BO_ 1745 Dash_State: 8 XXX SG_ Units : 15|1@1+ (1,0) [0|1] "" XXX CM_ SG_ 320 Off_Throttle_2 "Less sensitive"; CM_ SG_ 320 Throttle_Body "Throttle related"; CM_ SG_ 328 Gear "15 = P, 14 = R, 0 = N, 1-6=gear"; CM_ SG_ 328 Gear_2 "15 = P, 14 = R, 0 = N, 1-6=gear"; CM_ SG_ 353 Cruise_Button "1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 resume deep"; CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission"; CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage"; CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering"; CM_ SG_ 359 Sig1Right_Depart_Front "object in front, right depart, hill steep and seatbelt disengage alert "; CM_ SG_ 359 Left_Depart_Front "warning after acceleration into car in front and left depart"; CM_ SG_ 359 Sig1All_Depart "Left and right depart"; CM_ SG_ 359 Sig2All_Depart "Left and right depart"; CM_ SG_ 359 All_depart_2015 "always 1 on 2017"; CM_ SG_ 604 R_APPROACHING "Faster car approaching in far right lane"; CM_ SG_ 604 L_APPROACHING "Faster car approaching in far left lane"; CM_ SG_ 604 R_RCTA "Rear cross traffic alert, only when in R gear"; CM_ SG_ 604 L_RCTA "Rear cross traffic alert, only when in R gear"; CM_ SG_ 642 Counter "Affected by signals"; CM_ SG_ 642 SEATBELT_FL "Driver seatbelt"; CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371"; CM_ SG_ 977 UNITS "0 = Metric, 1 = Imperial"; VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; CM_ "subaru_forester_2017.dbc starts here"; BO_ 355 ES_DashStatus: 8 XXX SG_ Not_Ready_Startup : 4|2@1+ (1,0) [0|3] "" XXX SG_ Cruise_On : 16|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 40|3@1+ (1,0) [0|7] "" XXX SG_ Cruise_Activated : 54|1@1+ (1,0) [0|1] "" XXX BO_ 881 Steering_Torque: 8 XXX SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|1000] "" XXX SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-1000|1000] "" XXX SG_ Steer_Error_1 : 27|1@1+ (1,0) [0|1] "" XXX SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX SG_ Steering_Angle : 40|16@1- (-0.033,0) [-600|600] "" XXX ================================================ FILE: opendbc/subaru_global_2017_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _subaru_global.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX X BO_ 2 Steering: 8 XXX SG_ Steering_Angle : 7|16@0- (0.1,0) [0|65535] "" XXX SG_ Counter : 25|3@1+ (1,0) [0|7] "" XXX SG_ CHECKSUM : 32|8@1+ (1,0) [0|255] "" XXX BO_ 64 Throttle: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Engine_RPM : 16|12@1+ (1,0) [0|4095] "" XXX SG_ Signal2 : 28|4@1+ (1,0) [0|15] "" XXX SG_ Throttle_Pedal : 32|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Cruise : 40|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Combo : 48|8@1+ (1,0) [0|255] "" XXX SG_ Signal3 : 56|4@1+ (1,0) [0|15] "" XXX SG_ Off_Accel : 60|4@1+ (1,0) [0|15] "" XXX BO_ 316 Brake_Status: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|46@1+ (1,0) [0|1] "" XXX SG_ ES_Brake : 58|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 59|3@1+ (1,0) [0|1] "" XXX SG_ Brake : 62|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 63|1@1+ (1,0) [0|1] "" XXX BO_ 326 Cruise_Buttons: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|30@1+ (1,0) [0|1073741823] "" XXX SG_ Main : 42|1@1+ (1,0) [0|1] "" XXX SG_ Set : 43|1@1+ (1,0) [0|1] "" XXX SG_ Resume : 44|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 45|19@1+ (1,0) [0|524287] "" XXX BO_ 315 G_Sensor: 8 XXX SG_ Lateral : 48|8@1- (-0.1,0) [0|255] "m/s2" XXX SG_ Longitudinal : 56|8@1- (-0.1,0) [0|255] "m/s2" XXX BO_ 314 Wheel_Speeds: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ FR : 12|13@1+ (0.057,0) [0|255] "kph" XXX SG_ RR : 25|13@1+ (0.057,0) [0|255] "kph" XXX SG_ FL : 51|13@1+ (0.057,0) [0|255] "kph" XXX SG_ RL : 38|13@1+ (0.057,0) [0|255] "kph" XXX BO_ 280 STOP_START: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ State : 63|1@1+ (1,0) [0|1] "" XXX BO_ 281 Steering_Torque: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Steer_Error_1 : 12|1@0+ (1,0) [0|1] "" XXX SG_ Steer_Torque_Sensor : 16|11@1- (-1,0) [-1000|1000] "" XXX SG_ Steer_Error_2 : 28|1@1+ (1,0) [0|1] "" XXX SG_ Steer_Warning : 29|1@1+ (1,0) [0|1] "" XXX SG_ Steering_Angle : 32|16@1- (-0.0217,0) [-600|600] "" X SG_ Steer_Torque_Output : 48|11@1- (-1,0) [-1000|1000] "" XXX BO_ 312 Brake_Pressure_L_R: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Brake_1 : 48|8@1+ (1,0) [0|255] "" XXX SG_ Brake_2 : 56|8@1+ (1,0) [0|255] "" XXX BO_ 313 Brake_Pedal: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Speed : 16|12@1+ (0.05625,0) [0|255] "kph" XXX SG_ Signal2 : 28|6@1+ (1,0) [0|63] "" XXX SG_ Brake_Lights : 34|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 35|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal : 36|12@1+ (1,0) [0|4095] "" XXX SG_ Signal4 : 48|16@1+ (1,0) [0|65535] "" XXX BO_ 290 ES_LKAS: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ SET_1 : 12|1@0+ (1,0) [0|1] "" XXX SG_ LKAS_Output : 16|13@1- (-1,0) [-8191|8191] "" XXX SG_ LKAS_Request : 29|1@0+ (1,0) [0|1] "" XXX BO_ 544 ES_Brake: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Brake_Pressure : 16|16@1+ (1,0) [0|65535] "" XXX SG_ Signal2 : 32|4@1+ (1,0) [0|15] "" XXX SG_ Cruise_Brake_Lights : 36|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Brake_Fault : 37|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Brake_Active : 38|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 39|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 40|24@1+ (1,0) [0|16777215] "" XXX BO_ 577 Cruise_Status: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Cruise_On : 54|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 55|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Active : 57|4@1+ (1,0) [0|15] "" XXX BO_ 552 BSD_RCTA: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ R_ADJACENT : 48|1@1+ (1,0) [0|1] "" XXX SG_ L_ADJACENT : 49|1@1+ (1,0) [0|1] "" XXX SG_ R_APPROACHING : 58|1@1+ (1,0) [0|1] "" XXX SG_ L_APPROACHING : 59|1@1+ (1,0) [0|1] "" XXX BO_ 912 Dashlights: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ UNITS : 24|1@1+ (1,0) [0|1] "" XXX SG_ ICY_ROAD : 32|2@1+ (1,0) [0|3] "" XXX SG_ SEATBELT_FL : 48|1@1+ (1,0) [0|1] "" XXX SG_ LEFT_BLINKER : 50|1@1+ (1,0) [0|1] "" XXX SG_ RIGHT_BLINKER : 51|1@1+ (1,0) [0|1] "" XXX BO_ 940 BodyInfo: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ DOOR_OPEN_FL : 32|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 33|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 34|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 35|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_TRUNK : 36|1@0+ (1,0) [0|1] "" XXX SG_ BRAKE : 54|1@1+ (1,0) [0|1] "" XXX SG_ DASH_BTN_LIGHTS : 56|1@0+ (1,0) [0|1] "" XXX SG_ LOWBEAM : 57|1@1+ (1,0) [0|1] "" XXX SG_ HIGHBEAM : 58|1@1+ (1,0) [0|1] "" XXX SG_ FOG_LIGHTS : 60|1@1+ (1,0) [0|1] "" XXX SG_ WIPERS : 62|1@0+ (1,0) [0|1] "" XXX BO_ 801 ES_DashStatus: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ PCB_Off : 12|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Off : 13|1@1+ (1,0) [0|1] "" XXX SG_ Signal1 : 14|2@1+ (1,0) [0|3] "" XXX SG_ Cruise_State_Msg : 16|4@1+ (1,0) [0|15] "" XXX SG_ LKAS_State_Msg : 20|3@1+ (1,0) [0|7] "" XXX SG_ Signal2 : 23|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Soft_Disable : 24|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Status_Msg : 25|2@1+ (1,0) [0|3] "" XXX SG_ Signal3 : 27|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Distance : 28|3@1+ (1,0) [0|7] "" XXX SG_ Signal4 : 31|1@1+ (1,0) [0|1] "" XXX SG_ Conventional_Cruise : 32|1@1+ (1,0) [0|1] "" XXX SG_ Signal5 : 33|2@1+ (1,0) [0|3] "" XXX SG_ Cruise_Disengaged : 35|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 36|1@1+ (1,0) [0|1] "" XXX SG_ Signal6 : 37|3@1+ (1,0) [0|1] "" XXX SG_ Cruise_Set_Speed : 40|8@1+ (1,0) [0|255] "" XXX SG_ Cruise_Fault : 48|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_On : 49|1@1+ (1,0) [0|1] "" XXX SG_ Display_Own_Car : 50|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Lights : 51|1@1+ (1,0) [0|1] "" XXX SG_ Car_Follow : 52|1@1+ (1,0) [0|1] "" XXX SG_ Signal7 : 53|3@1+ (1,0) [0|1] "" XXX SG_ Far_Distance : 56|4@1+ (1,0) [0|15] "" XXX SG_ Cruise_State : 60|4@1+ (1,0) [0|15] "" XXX BO_ 802 ES_LKAS_State: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ LKAS_Alert_Msg : 12|3@1+ (1,0) [0|7] "" XXX SG_ Signal1 : 15|2@1+ (1,0) [0|3] "" XXX SG_ LKAS_ACTIVE : 17|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Dash_State : 18|2@1+ (1,0) [0|2] "" XXX SG_ Signal2 : 20|3@1+ (1,0) [0|7] "" XXX SG_ Backward_Speed_Limit_Menu : 23|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Left_Line_Enable : 24|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Left_Line_Light_Blink : 25|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Right_Line_Enable : 26|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Right_Line_Light_Blink : 27|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Left_Line_Visible : 28|2@1+ (1,0) [0|3] "" XXX SG_ LKAS_Right_Line_Visible : 30|2@1+ (1,0) [0|3] "" XXX SG_ LKAS_Alert : 32|5@1+ (1,0) [0|31] "" XXX SG_ Signal3 : 37|27@1+ (1,0) [0|1] "" XXX BO_ 722 AC_State: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ AC_Mode : 37|3@1+ (1,0) [0|1] "" XXX SG_ AC_ON : 24|2@1+ (1,0) [0|1] "" XXX BO_ 1677 Dash_State: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Units : 29|3@1+ (1,0) [0|7] "" XXX CM_ SG_ 64 Throttle_Combo "Throttle Cruise + Pedal"; CM_ SG_ 313 Brake_Lights "Driver or Cruise Brake on"; CM_ SG_ 544 Cruise_Brake_Lights "1 = switch on brake lights"; CM_ SG_ 801 PCB_Off "Pre-Collision Braking off"; CM_ SG_ 801 Brake_Lights "Driver or Cruise brake on"; CM_ SG_ 801 Cruise_State "0 = Normal, 1 = Hold+User Brake, 2 = Ready, 3 = Hold"; CM_ SG_ 801 Far_Distance "1=0-5m, 2=5-10m, 3=10-15m, 4=15-20m, 5=20-25m, 6=25-30m, 7=30-35m, 8=35-40m, 9=40-45m, 10=45-50m, 11=50-55m, 12=55-60m, 13=60-65m, 14=65-70m, 15=75m+"; CM_ SG_ 801 LKAS_State_Msg "1 = LKAS_Off_Sharp_Curve, 2 = Keep_Hands_On_Steering_wheel_disabled, 3 = LKAS_Off, 4 = LKAS_Off_Too_Slow, 5 = LKAS_Off_Too_Fast"; CM_ SG_ 801 Cruise_State_Msg "1 = Cruise_Off_Steep_Slope, 2 = Cruise_lvl1_eco, 3 = Cruise_lvl2_comfort, 4 = Cruise_off_empty_reason, 5 = Cruise_off, 6 = Cruise_Unable_to_set, 7 = Cruise_Unable_to_set_brakes_applied, 8 = Eyesight_not_ready, 9 = Cruise_lvl3_standard, 10 = Cruise_lvl4_dynamic, 11 = Cruise_Unable_to_set_steep_slope"; CM_ SG_ 801 Cruise_Soft_Disable "Eyesight soft disable (eg direct sunlight)"; CM_ SG_ 801 Cruise_Status_Msg "1 = Disabled_Bad_Visibility, 2 = Disabled_Check_Manual"; CM_ SG_ 802 LKAS_ACTIVE "Turns on the full LKAS dash display"; CM_ SG_ 802 LKAS_Alert_Msg "1 = Keep_Hands_On_Wheel, 6 = Pre_Collision_Braking, 7 = Keep_Hands_On_Wheel_Off"; CM_ SG_ 802 LKAS_Alert "1 = FCW_Cont_Beep, 2 = FCW_Repeated_Beep, 3 = Throttle_Management_Activated_Warning, 4 = Throttle_Management_Activated_Alert, 5 = Pre_Collision_Activated_Alert, 8 = Traffic_Light_Ahead, 9 = Apply_Brake_to_Hold Position, 11 = LDW_Right, 12 = LDW_Left, 13 = Stay_Alert, 14 = Lead_Vehicle_Start_Alert, 18 = Keep_Hands_On_Steering_Alert, 24 = Audio_Beep, 25 = Audio_Lead_Car_Change, 26 = Audio_ACC_Disengaged, 27 = Audio_LKAS_disabled, 28 = Audio_Ding_Ding, 30 = Audio_Repeated_Beep"; CM_ SG_ 802 LKAS_Left_Line_Visible "0 = Off, 1 = White, 2 = Green, 3 = Orange"; CM_ SG_ 802 LKAS_Dash_State "0 = Off, 1 = Ready, 2 = Active"; CM_ SG_ 802 LKAS_Right_Line_Visible "0 = Off, 1 = White, 2 = Green, 3 = Orange"; CM_ SG_ 912 UNITS "0 = Metric, 1 = Imperial"; CM_ SG_ 912 ICY_ROAD "1 = DASHLIGHT ON, 2 = WARNING, 3 = OFF"; CM_ "subaru_global_2017.dbc starts here"; BO_ 72 Transmission: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Gear : 24|8@1+ (1,0) [0|255] "" XXX SG_ RPM : 40|16@1+ (1,0) [0|65535] "" XXX BO_ 73 CVT: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ CVT_Gear : 24|8@1+ (1,0) [0|255] "" XXX BO_ 545 ES_Distance: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|3@1+ (1,0) [0|7] "" XXX SG_ Cruise_Fault : 15|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Throttle : 16|12@1+ (1,0) [0|4095] "" XXX SG_ Signal2 : 28|4@1+ (1,0) [0|15] "" XXX SG_ Car_Follow : 32|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 33|3@1+ (1,0) [0|1] "" XXX SG_ Cruise_Brake_Active : 36|1@1+ (1,0) [0|1] "" XXX SG_ Distance_Swap : 37|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_EPB : 38|1@1+ (1,0) [0|1] "" XXX SG_ Signal4 : 39|1@0+ (1,0) [0|1] "" XXX SG_ Close_Distance : 40|8@1+ (1,0) [0|1] "" XXX SG_ Signal5 : 48|8@1+ (1,0) [0|1] "" XXX SG_ Cruise_Cancel : 56|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Set : 57|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Resume : 58|1@1+ (1,0) [0|1] "" XXX SG_ Signal6 : 59|5@1+ (1,0) [0|1] "" XXX BO_ 546 ES_Status: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|3@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 15|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_RPM : 16|12@1+ (1,0) [0|4095] "" XXX SG_ Signal2 : 28|1@0+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 29|1@0+ (1,0) [0|1] "" XXX SG_ Brake_Lights : 30|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Hold : 31|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 32|32@1+ (1,0) [0|1] "" XXX BO_ 576 CruiseControl: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|28@1+ (1,0) [0|268435455] "" XXX SG_ Cruise_On : 40|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 41|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 42|22@1+ (1,0) [0|4194303] "" XXX CM_ SG_ 545 Cruise_Throttle "RPM-like output signal"; CM_ SG_ 545 Cruise_EPB "1 = Electric Parking Brake set"; CM_ SG_ 545 Distance_Swap "Switch from Close to Far distance"; CM_ SG_ 546 Cruise_RPM "ES RPM output for ECM and TCM"; CM_ SG_ 546 Signal3 "0 when cruise_activated = 1"; VAL_ 72 Gear 2 "N" 3 "R" 4 "P" 121 "D" 137 "1" 145 "2" 153 "3" 161 "4" 169 "5" 177 "6"; ================================================ FILE: opendbc/subaru_outback_2015_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _subaru_preglobal_2015.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX X BO_ 2 Steering: 8 XXX SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX SG_ Counter : 27|3@0+ (1,0) [0|7] "" XXX SG_ Checksum : 39|8@0+ (1,0) [0|255] "" XXX BO_ 208 G_Sensor: 8 XXX SG_ Steering_Angle : 0|16@1- (-0.1,0) [-500|500] "" XXX SG_ Lateral : 16|16@1- (-0.0035,1) [-255|255] "" XXX SG_ Longitudinal : 48|16@1- (-0.00035,0) [-255|255] "" XXX BO_ 209 Brake_Pedal: 8 XXX SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX SG_ Brake_Pedal : 16|8@1+ (1,0) [0|255] "" XXX BO_ 210 Brake_2: 8 XXX SG_ Brake_Light : 35|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Related : 36|1@1+ (1,0) [0|1] "" XXX SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX SG_ Left_Brake : 56|8@1+ (1,0) [0|255] "" XXX BO_ 211 Brake_Type: 8 XXX SG_ Brake_Light : 21|1@1+ (1,0) [0|1] "" XXX SG_ Speed_Counter : 32|8@1+ (1,0) [0|255] "" XXX SG_ Brake_Cruise_On : 42|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal_On : 46|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 48|8@1+ (1,0) [0|255] "" XXX BO_ 212 Wheel_Speeds: 8 XXX SG_ FL : 0|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ FR : 16|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ RL : 32|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ RR : 48|16@1+ (0.0592,0) [0|255] "KPH" XXX BO_ 320 Throttle: 8 XXX SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|2@1+ (1,0) [0|7] "" XXX SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 15|1@1+ (1,0) [0|1] "" XXX SG_ Engine_RPM : 16|14@1+ (1,0) [0|32767] "" XXX SG_ Off_Throttle : 30|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 31|1@1+ (1,0) [0|1] "" XXX SG_ Throttle_Cruise : 32|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Body : 48|8@1+ (1,0) [0|255] "" XXX SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|1] "" XXX SG_ Signal4 : 57|7@1+ (1,0) [0|127] "" XXX BO_ 321 Engine: 8 XXX SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" XXX SG_ Engine_Stop : 15|1@1+ (1,0) [0|1] "" XXX SG_ Wheel_Torque : 16|12@1+ (1,0) [0|4095] "" XXX SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX BO_ 324 CruiseControl: 8 XXX SG_ OnOffButton : 2|1@1+ (1,0) [0|1] "" XXX SG_ SET_BUTTON : 3|1@1+ (1,0) [0|1] "" XXX SG_ RES_BUTTON : 4|1@1+ (1,0) [0|1] "" XXX SG_ Button : 13|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_On : 48|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 49|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal_On : 51|1@1+ (1,0) [0|1] "" XXX BO_ 328 Transmission: 8 XXX SG_ Manual_Gear : 4|4@1+ (1,0) [0|15] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX SG_ Paddle_Shift : 60|2@1+ (1,0) [0|3] "" XXX BO_ 329 CVT_Ratio: 8 XXX BO_ 336 Brake_Pressure: 8 XXX SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|255] "" XXX SG_ Brake_Pressure_Left : 8|8@1+ (1,0) [0|255] "" XXX BO_ 338 Stalk: 8 XXX SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX SG_ Brake_Light : 52|1@1+ (1,0) [0|1] "" XXX SG_ Runlights : 58|1@1+ (1,0) [0|1] "" XXX SG_ Headlights : 59|1@1+ (1,0) [0|1] "" XXX SG_ Highbeam : 60|1@1+ (1,0) [0|1] "" XXX SG_ Wiper : 62|1@1+ (1,0) [0|1] "" XXX BO_ 352 ES_Brake: 8 XXX SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX SG_ Brake_Light : 20|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 21|1@1+ (1,0) [0|1] "" XXX SG_ Brake_On : 22|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 23|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 353 ES_CruiseThrottle: 8 XXX SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|4095] "" XXX SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Cruise_Activated : 16|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 17|3@1+ (1,0) [0|7] "" XXX SG_ Brake_On : 20|1@1+ (1,0) [0|1] "" XXX SG_ Distance_Swap : 21|1@1+ (1,0) [0|1] "" XXX SG_ Standstill : 22|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 23|1@1+ (1,0) [0|1] "" XXX SG_ Close_Distance : 24|8@1+ (0.0196,0) [0|255] "m" XXX SG_ Signal4 : 32|9@1+ (1,0) [0|255] "" XXX SG_ Standstill_2 : 41|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 42|1@1+ (1,0) [0|1] "" XXX SG_ Signal5 : 43|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 44|3@1+ (1,0) [0|7] "" XXX SG_ Signal6 : 47|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Button : 48|3@1+ (1,0) [0|7] "" XXX SG_ Signal7 : 51|5@1+ (1,0) [0|31] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 354 ES_RPM: 8 XXX SG_ Brake : 8|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 9|1@1+ (1,0) [0|1] "" XXX SG_ RPM : 16|16@1+ (1,0) [0|65535] "" XXX SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX BO_ 356 ES_LKAS: 8 XXX SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 359 ES_LDW: 8 XXX SG_ All_depart_2015 : 0|1@1+ (1,0) [0|1] "" XXX SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|1] "" XXX SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|1] "" XXX SG_ Sig1All_Depart : 28|1@1+ (1,0) [0|1] "" XXX SG_ Sig2All_Depart : 31|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Active : 37|1@1+ (1,0) [0|1] "" XXX SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|1] "" XXX SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|1] "" XXX SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|1] "" XXX SG_ Left_Depart_Front : 51|1@1+ (1,0) [0|1] "" XXX SG_ Sig3All_Depart : 52|1@1+ (1,0) [0|1] "" XXX BO_ 604 BSD_RCTA: 8 XXX SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX SG_ State : 5|1@1+ (1,0) [0|1] "" XXX SG_ R_ADJACENT : 32|1@1+ (1,0) [0|1] "" XXX SG_ L_ADJACENT : 33|1@1+ (1,0) [0|1] "" XXX SG_ R_APPROACHING : 42|1@1+ (1,0) [0|1] "" XXX SG_ L_APPROACHING : 43|1@1+ (1,0) [0|1] "" XXX SG_ R_RCTA : 46|1@1+ (1,0) [0|1] "" XXX SG_ L_RCTA : 47|1@1+ (1,0) [0|1] "" XXX BO_ 642 Dashlights: 8 XXX SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|1] "" XXX SG_ LEFT_BLINKER : 44|1@1+ (1,0) [0|1] "" XXX SG_ RIGHT_BLINKER : 45|1@1+ (1,0) [0|1] "" XXX BO_ 880 Steering_Torque_2: 8 XXX SG_ Steering_Voltage_Flat : 0|8@1+ (1,0) [0|255] "" XXX SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX BO_ 884 BodyInfo: 8 XXX SG_ DOOR_OPEN_FR : 24|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 25|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 26|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 27|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_Hatch : 28|1@1+ (1,0) [0|1] "" XXX BO_ 864 Engine_Temp: 8 XXX SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX SG_ Cruise_Activated : 45|1@1+ (1,0) [0|1] "" XXX SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX BO_ 866 Fuel: 8 XXX BO_ 977 Dash_State2: 8 XXX SG_ UNITS : 15|1@1+ (1,0) [0|1] "" XXX BO_ 1745 Dash_State: 8 XXX SG_ Units : 15|1@1+ (1,0) [0|1] "" XXX CM_ SG_ 320 Off_Throttle_2 "Less sensitive"; CM_ SG_ 320 Throttle_Body "Throttle related"; CM_ SG_ 328 Gear "15 = P, 14 = R, 0 = N, 1-6=gear"; CM_ SG_ 328 Gear_2 "15 = P, 14 = R, 0 = N, 1-6=gear"; CM_ SG_ 353 Cruise_Button "1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 resume deep"; CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission"; CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage"; CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering"; CM_ SG_ 359 Sig1Right_Depart_Front "object in front, right depart, hill steep and seatbelt disengage alert "; CM_ SG_ 359 Left_Depart_Front "warning after acceleration into car in front and left depart"; CM_ SG_ 359 Sig1All_Depart "Left and right depart"; CM_ SG_ 359 Sig2All_Depart "Left and right depart"; CM_ SG_ 359 All_depart_2015 "always 1 on 2017"; CM_ SG_ 604 R_APPROACHING "Faster car approaching in far right lane"; CM_ SG_ 604 L_APPROACHING "Faster car approaching in far left lane"; CM_ SG_ 604 R_RCTA "Rear cross traffic alert, only when in R gear"; CM_ SG_ 604 L_RCTA "Rear cross traffic alert, only when in R gear"; CM_ SG_ 642 Counter "Affected by signals"; CM_ SG_ 642 SEATBELT_FL "Driver seatbelt"; CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371"; CM_ SG_ 977 UNITS "0 = Metric, 1 = Imperial"; VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; CM_ "subaru_outback_2015.dbc starts here"; BO_ 358 ES_DashStatus: 8 XXX SG_ Not_Ready_Startup : 0|3@1+ (1,0) [0|7] "" XXX SG_ Seatbelt_Disengage : 12|2@1+ (1,0) [0|3] "" XXX SG_ Disengage_Alert : 14|2@1+ (1,0) [0|3] "" XXX SG_ Cruise_On : 16|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 17|1@1+ (1,0) [0|1] "" XXX SG_ Signal1 : 18|1@1+ (1,0) [0|1] "" XXX SG_ WHEELS_MOVING_2015 : 19|1@1+ (1,0) [0|1] "" XXX SG_ Driver_Input : 20|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Distance : 21|3@1+ (1,0) [0|7] "" XXX SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX SG_ Cruise_Fault : 32|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_On_2 : 34|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 37|3@1+ (1,0) [0|7] "" XXX SG_ Steep_Hill_Disengage : 44|1@1+ (1,0) [0|3] "" XXX SG_ Car_Follow : 46|1@1+ (1,0) [0|1] "" XXX SG_ Far_Distance : 48|4@1+ (5,0) [0|15] "m" XXX BO_ 881 Steering_Torque: 8 XXX SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|1000] "" XXX SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-1000|1000] "" XXX SG_ Steer_Error_1 : 27|1@1+ (1,0) [0|1] "" XXX SG_ Steer_Torque_Sensor : 29|11@1- (1,0) [-1000|1000] "" XXX SG_ Steering_Angle : 40|16@1- (-0.033,0) [-600|600] "" XXX CM_ SG_ 358 Disengage_Alert "seatbelt and steep hill disengage"; CM_ SG_ 358 Cruise_Fault "No engagement until restart"; CM_ SG_ 358 Car_Follow "lead car detected"; ================================================ FILE: opendbc/subaru_outback_2019_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _subaru_preglobal_2015.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX X BO_ 2 Steering: 8 XXX SG_ Steering_Angle : 7|16@0- (0.1,0) [-500|500] "degree" XXX SG_ Counter : 27|3@0+ (1,0) [0|7] "" XXX SG_ Checksum : 39|8@0+ (1,0) [0|255] "" XXX BO_ 208 G_Sensor: 8 XXX SG_ Steering_Angle : 0|16@1- (-0.1,0) [-500|500] "" XXX SG_ Lateral : 16|16@1- (-0.0035,1) [-255|255] "" XXX SG_ Longitudinal : 48|16@1- (-0.00035,0) [-255|255] "" XXX BO_ 209 Brake_Pedal: 8 XXX SG_ Speed : 0|16@1+ (0.05625,0) [0|255] "KPH" XXX SG_ Brake_Pedal : 16|8@1+ (1,0) [0|255] "" XXX BO_ 210 Brake_2: 8 XXX SG_ Brake_Light : 35|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Related : 36|1@1+ (1,0) [0|1] "" XXX SG_ Right_Brake : 48|8@1+ (1,0) [0|255] "" XXX SG_ Left_Brake : 56|8@1+ (1,0) [0|255] "" XXX BO_ 211 Brake_Type: 8 XXX SG_ Brake_Light : 21|1@1+ (1,0) [0|1] "" XXX SG_ Speed_Counter : 32|8@1+ (1,0) [0|255] "" XXX SG_ Brake_Cruise_On : 42|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal_On : 46|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 48|8@1+ (1,0) [0|255] "" XXX BO_ 212 Wheel_Speeds: 8 XXX SG_ FL : 0|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ FR : 16|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ RL : 32|16@1+ (0.0592,0) [0|255] "KPH" XXX SG_ RR : 48|16@1+ (0.0592,0) [0|255] "KPH" XXX BO_ 320 Throttle: 8 XXX SG_ Throttle_Pedal : 0|8@1+ (0.392157,0) [0|255] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Signal1 : 12|2@1+ (1,0) [0|7] "" XXX SG_ Not_Full_Throttle : 14|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 15|1@1+ (1,0) [0|1] "" XXX SG_ Engine_RPM : 16|14@1+ (1,0) [0|32767] "" XXX SG_ Off_Throttle : 30|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 31|1@1+ (1,0) [0|1] "" XXX SG_ Throttle_Cruise : 32|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Combo : 40|8@1+ (1,0) [0|255] "" XXX SG_ Throttle_Body : 48|8@1+ (1,0) [0|255] "" XXX SG_ Off_Throttle_2 : 56|1@1+ (1,0) [0|1] "" XXX SG_ Signal4 : 57|7@1+ (1,0) [0|127] "" XXX BO_ 321 Engine: 8 XXX SG_ Engine_Torque : 0|15@1+ (1,0) [0|255] "" XXX SG_ Engine_Stop : 15|1@1+ (1,0) [0|1] "" XXX SG_ Wheel_Torque : 16|12@1+ (1,0) [0|4095] "" XXX SG_ Engine_RPM : 32|12@1+ (1,0) [0|8191] "" XXX BO_ 324 CruiseControl: 8 XXX SG_ OnOffButton : 2|1@1+ (1,0) [0|1] "" XXX SG_ SET_BUTTON : 3|1@1+ (1,0) [0|1] "" XXX SG_ RES_BUTTON : 4|1@1+ (1,0) [0|1] "" XXX SG_ Button : 13|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_On : 48|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 49|1@1+ (1,0) [0|1] "" XXX SG_ Brake_Pedal_On : 51|1@1+ (1,0) [0|1] "" XXX BO_ 328 Transmission: 8 XXX SG_ Manual_Gear : 4|4@1+ (1,0) [0|15] "" XXX SG_ Counter : 8|4@1+ (1,0) [0|15] "" XXX SG_ Transmission_Engine : 16|15@1+ (1,0) [0|65535] "" XXX SG_ Gear : 48|4@1+ (1,0) [0|15] "" XXX SG_ Gear_2 : 52|4@1+ (1,0) [0|15] "" XXX SG_ Paddle_Shift : 60|2@1+ (1,0) [0|3] "" XXX BO_ 329 CVT_Ratio: 8 XXX BO_ 336 Brake_Pressure: 8 XXX SG_ Brake_Pressure_Right : 0|8@1+ (1,0) [0|255] "" XXX SG_ Brake_Pressure_Left : 8|8@1+ (1,0) [0|255] "" XXX BO_ 338 Stalk: 8 XXX SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX SG_ Brake_Light : 52|1@1+ (1,0) [0|1] "" XXX SG_ Runlights : 58|1@1+ (1,0) [0|1] "" XXX SG_ Headlights : 59|1@1+ (1,0) [0|1] "" XXX SG_ Highbeam : 60|1@1+ (1,0) [0|1] "" XXX SG_ Wiper : 62|1@1+ (1,0) [0|1] "" XXX BO_ 352 ES_Brake: 8 XXX SG_ Brake_Pressure : 0|16@1+ (1,0) [0|255] "" XXX SG_ Brake_Light : 20|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 21|1@1+ (1,0) [0|1] "" XXX SG_ Brake_On : 22|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 23|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 353 ES_CruiseThrottle: 8 XXX SG_ Throttle_Cruise : 0|12@1+ (1,0) [0|4095] "" XXX SG_ Signal1 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Cruise_Activated : 16|1@1+ (1,0) [0|1] "" XXX SG_ Signal2 : 17|3@1+ (1,0) [0|7] "" XXX SG_ Brake_On : 20|1@1+ (1,0) [0|1] "" XXX SG_ Distance_Swap : 21|1@1+ (1,0) [0|1] "" XXX SG_ Standstill : 22|1@1+ (1,0) [0|1] "" XXX SG_ Signal3 : 23|1@1+ (1,0) [0|1] "" XXX SG_ Close_Distance : 24|8@1+ (0.0196,0) [0|255] "m" XXX SG_ Signal4 : 32|9@1+ (1,0) [0|255] "" XXX SG_ Standstill_2 : 41|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Fault : 42|1@1+ (1,0) [0|1] "" XXX SG_ Signal5 : 43|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 44|3@1+ (1,0) [0|7] "" XXX SG_ Signal6 : 47|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Button : 48|3@1+ (1,0) [0|7] "" XXX SG_ Signal7 : 51|5@1+ (1,0) [0|31] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 354 ES_RPM: 8 XXX SG_ Brake : 8|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 9|1@1+ (1,0) [0|1] "" XXX SG_ RPM : 16|16@1+ (1,0) [0|65535] "" XXX SG_ Checksum : 32|8@1+ (1,0) [0|255] "" XXX SG_ Counter : 48|3@1+ (1,0) [0|7] "" XXX BO_ 356 ES_LKAS: 8 XXX SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX SG_ LKAS_Command : 8|13@1- (-1,0) [-4096|4096] "" XXX SG_ LKAS_Active : 24|1@1+ (1,0) [0|1] "" XXX SG_ Checksum : 56|8@1+ (1,0) [0|255] "" XXX BO_ 359 ES_LDW: 8 XXX SG_ All_depart_2015 : 0|1@1+ (1,0) [0|1] "" XXX SG_ Right_Line_2017 : 24|1@1+ (1,0) [0|1] "" XXX SG_ Left_Line_2017 : 25|1@1+ (1,0) [0|1] "" XXX SG_ Sig1All_Depart : 28|1@1+ (1,0) [0|1] "" XXX SG_ Sig2All_Depart : 31|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Inactive_2017 : 36|1@1+ (1,0) [0|1] "" XXX SG_ LKAS_Active : 37|1@1+ (1,0) [0|1] "" XXX SG_ Sig1Right_Depart : 48|1@1+ (1,0) [0|1] "" XXX SG_ Sig1Right_Depart_Front : 49|1@1+ (1,0) [0|1] "" XXX SG_ Sig2Right_Depart : 50|1@1+ (1,0) [0|1] "" XXX SG_ Left_Depart_Front : 51|1@1+ (1,0) [0|1] "" XXX SG_ Sig3All_Depart : 52|1@1+ (1,0) [0|1] "" XXX BO_ 604 BSD_RCTA: 8 XXX SG_ Counter : 0|3@1+ (1,0) [0|7] "" XXX SG_ State : 5|1@1+ (1,0) [0|1] "" XXX SG_ R_ADJACENT : 32|1@1+ (1,0) [0|1] "" XXX SG_ L_ADJACENT : 33|1@1+ (1,0) [0|1] "" XXX SG_ R_APPROACHING : 42|1@1+ (1,0) [0|1] "" XXX SG_ L_APPROACHING : 43|1@1+ (1,0) [0|1] "" XXX SG_ R_RCTA : 46|1@1+ (1,0) [0|1] "" XXX SG_ L_RCTA : 47|1@1+ (1,0) [0|1] "" XXX BO_ 642 Dashlights: 8 XXX SG_ Counter : 12|4@1+ (1,0) [0|15] "" XXX SG_ SEATBELT_FL : 40|1@1+ (1,0) [0|1] "" XXX SG_ LEFT_BLINKER : 44|1@1+ (1,0) [0|1] "" XXX SG_ RIGHT_BLINKER : 45|1@1+ (1,0) [0|1] "" XXX BO_ 880 Steering_Torque_2: 8 XXX SG_ Steering_Voltage_Flat : 0|8@1+ (1,0) [0|255] "" XXX SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX SG_ Counter : 40|4@1+ (1,0) [0|15] "" XXX BO_ 884 BodyInfo: 8 XXX SG_ DOOR_OPEN_FR : 24|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 25|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 26|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 27|1@1+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_Hatch : 28|1@1+ (1,0) [0|1] "" XXX BO_ 864 Engine_Temp: 8 XXX SG_ Oil_Temp : 16|8@1+ (1,-40) [0|255] "" XXX SG_ Coolant_Temp : 24|8@1+ (1,-40) [0|255] "" XXX SG_ Cruise_Activated : 45|1@1+ (1,0) [0|1] "" XXX SG_ Saved_Speed : 56|8@1+ (1,0) [0|255] "" XXX BO_ 866 Fuel: 8 XXX BO_ 977 Dash_State2: 8 XXX SG_ UNITS : 15|1@1+ (1,0) [0|1] "" XXX BO_ 1745 Dash_State: 8 XXX SG_ Units : 15|1@1+ (1,0) [0|1] "" XXX CM_ SG_ 320 Off_Throttle_2 "Less sensitive"; CM_ SG_ 320 Throttle_Body "Throttle related"; CM_ SG_ 328 Gear "15 = P, 14 = R, 0 = N, 1-6=gear"; CM_ SG_ 328 Gear_2 "15 = P, 14 = R, 0 = N, 1-6=gear"; CM_ SG_ 353 Cruise_Button "1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 resume deep"; CM_ SG_ 354 RPM "20hz version of Transmission_Engine under Transmission"; CM_ SG_ 359 Sig1Right_Depart "right depart, hill steep and seatbelt disengage"; CM_ SG_ 359 LKAS_Inactive_2017 "1 when not steering, 0 when lkas steering"; CM_ SG_ 359 Sig1Right_Depart_Front "object in front, right depart, hill steep and seatbelt disengage alert "; CM_ SG_ 359 Left_Depart_Front "warning after acceleration into car in front and left depart"; CM_ SG_ 359 Sig1All_Depart "Left and right depart"; CM_ SG_ 359 Sig2All_Depart "Left and right depart"; CM_ SG_ 359 All_depart_2015 "always 1 on 2017"; CM_ SG_ 604 R_APPROACHING "Faster car approaching in far right lane"; CM_ SG_ 604 L_APPROACHING "Faster car approaching in far left lane"; CM_ SG_ 604 R_RCTA "Rear cross traffic alert, only when in R gear"; CM_ SG_ 604 L_RCTA "Rear cross traffic alert, only when in R gear"; CM_ SG_ 642 Counter "Affected by signals"; CM_ SG_ 642 SEATBELT_FL "Driver seatbelt"; CM_ SG_ 880 Steering_Voltage_Flat "receives later than 371"; CM_ SG_ 977 UNITS "0 = Metric, 1 = Imperial"; VAL_ 328 Gear 0 "N" 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 14 "R" 15 "P"; CM_ "subaru_outback_2019.dbc starts here"; BO_ 358 ES_DashStatus: 8 XXX SG_ Not_Ready_Startup : 0|3@1+ (1,0) [0|7] "" XXX SG_ Seatbelt_Disengage : 12|2@1+ (1,0) [0|3] "" XXX SG_ Disengage_Alert : 14|2@1+ (1,0) [0|3] "" XXX SG_ Cruise_On : 16|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Activated : 17|1@1+ (1,0) [0|1] "" XXX SG_ Signal1 : 18|1@1+ (1,0) [0|1] "" XXX SG_ WHEELS_MOVING_2015 : 19|1@1+ (1,0) [0|1] "" XXX SG_ Driver_Input : 20|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_Distance : 21|3@1+ (1,0) [0|7] "" XXX SG_ Cruise_Set_Speed : 24|8@1+ (1,0) [0|255] "" XXX SG_ Cruise_Fault : 32|1@1+ (1,0) [0|1] "" XXX SG_ Cruise_On_2 : 34|1@1+ (1,0) [0|1] "" XXX SG_ Counter : 37|3@1+ (1,0) [0|7] "" XXX SG_ Steep_Hill_Disengage : 44|1@1+ (1,0) [0|3] "" XXX SG_ Car_Follow : 46|1@1+ (1,0) [0|1] "" XXX SG_ Far_Distance : 48|4@1+ (5,0) [0|15] "m" XXX BO_ 881 Steering_Torque: 8 XXX SG_ Steering_Motor_Flat : 0|10@1+ (32,0) [0|1000] "" XXX SG_ Steer_Torque_Output : 16|11@1- (-32,0) [-1000|1000] "" XXX SG_ Steer_Error_1 : 27|1@1+ (1,0) [0|1] "" XXX SG_ Steer_Torque_Sensor : 29|11@1- (-1,0) [-1000|1000] "" XXX SG_ Steering_Angle : 40|16@1- (-0.033,0) [-600|600] "" XXX CM_ SG_ 358 Disengage_Alert "seatbelt and steep hill disengage"; CM_ SG_ 358 Cruise_Fault "No engagement until restart"; CM_ SG_ 358 Car_Follow "lead car detected"; ================================================ FILE: opendbc/tesla_can.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: NEO MCU GTW EPAS DI ESP SBW STW APP DAS XXX VAL_TABLE_ StW_AnglHP_Spd 16383 "SNA" ; VAL_TABLE_ DI_aebFaultReason 15 "DI_AEB_FAULT_DAS_REQ_DI_UNAVAIL" 14 "DI_AEB_FAULT_ACCEL_REQ_INVALID" 13 "DI_AEB_FAULT_MIN_TIME_BTWN_EVENTS" 12 "DI_AEB_FAULT_ESP_MIA" 11 "DI_AEB_FAULT_ESP_FAULT" 10 "DI_AEB_FAULT_EPB_NOT_PARKED" 9 "DI_AEB_FAULT_ACCEL_OUT_OF_BOUNDS" 8 "DI_AEB_FAULT_PM_REQUEST" 7 "DI_AEB_FAULT_VEL_EST_ABNORMAL" 6 "DI_AEB_FAULT_DAS_SNA" 5 "DI_AEB_FAULT_DAS_CONTROL_MIA" 4 "DI_AEB_FAULT_SPEED_DELTA" 3 "DI_AEB_FAULT_EBR_FAULT" 2 "DI_AEB_FAULT_PM_MIA" 1 "DI_AEB_FAULT_EPB_MIA" 0 "DI_AEB_FAULT_NONE" ; VAL_TABLE_ DI_aebLockState 3 "AEB_LOCK_STATE_SNA" 2 "AEB_LOCK_STATE_UNUSED" 1 "AEB_LOCK_STATE_UNLOCKED" 0 "AEB_LOCK_STATE_LOCKED" ; VAL_TABLE_ DI_aebSmState 7 "DI_AEB_STATE_FAULT" 6 "DI_AEB_STATE_EXIT" 5 "DI_AEB_STATE_STANDSTILL" 4 "DI_AEB_STATE_STOPPING" 3 "DI_AEB_STATE_ENABLE" 2 "DI_AEB_STATE_ENABLE_INIT" 1 "DI_AEB_STATE_STANDBY" 0 "DI_AEB_STATE_UNAVAILABLE" ; VAL_TABLE_ DI_aebState 7 "AEB_CAN_STATE_SNA" 4 "AEB_CAN_STATE_FAULT" 3 "AEB_CAN_STATE_STANDSTILL" 2 "AEB_CAN_STATE_ENABLED" 1 "AEB_CAN_STATE_STANDBY" 0 "AEB_CAN_STATE_UNAVAILABLE" ; VAL_TABLE_ DI_epbInterfaceReady 1 "EPB_INTERFACE_READY" 0 "EPB_INTERFACE_NOT_READY" ; VAL_TABLE_ DI_gear 7 "DI_GEAR_SNA" 4 "DI_GEAR_D" 3 "DI_GEAR_N" 2 "DI_GEAR_R" 1 "DI_GEAR_P" 0 "DI_GEAR_INVALID" ; VAL_TABLE_ DI_gpoReason 8 "DI_GPO_NUMREASONS" 7 "DI_GPO_CAPACITOR_OVERTEMP" 6 "DI_GPO_NOT_ENOUGH_12V" 5 "DI_GPO_NO_BATTERY_POWER" 4 "DI_GPO_AMBIENT_OVERTEMP" 3 "DI_GPO_FLUID_DELTAT" 2 "DI_GPO_STATOR_OVERTEMP" 1 "DI_GPO_HEATSINK_OVERTEMP" 0 "DI_GPO_OUTLET_OVERTEMP" ; VAL_TABLE_ DI_immobilizerCondition 1 "DI_IMM_CONDITION_LEARNED" 0 "DI_IMM_CONDITION_VIRGIN_SNA" ; VAL_TABLE_ DI_immobilizerState 7 "DI_IMM_STATE_FAULT" 6 "DI_IMM_STATE_FAULTRETRY" 5 "DI_IMM_STATE_RESET" 4 "DI_IMM_STATE_LEARN" 3 "DI_IMM_STATE_DISARMED" 2 "DI_IMM_STATE_AUTHENTICATING" 1 "DI_IMM_STATE_REQUEST" 0 "DI_IMM_STATE_INIT_SNA" ; VAL_TABLE_ DI_limpReason 24 "DI_LIMP_NUMREASONS" 23 "DI_LIMP_CAPACITOR_OVERTEMP" 22 "DI_LIMP_GTW_MIA" 21 "DI_LIMP_TRQCMD_VALIDITY_UNKNOWN" 20 "DI_LIMP_DI_MIA" 19 "DI_LIMP_CONFIG_MISMATCH" 18 "DI_LIMP_HEATSINK_TEMP" 17 "DI_LIMP_PMREQUEST" 16 "DI_LIMP_PMHEARTBEAT" 15 "DI_LIMP_TRQ_CROSS_CHECK" 14 "DI_LIMP_EXTERNAL_COMMAND" 13 "DI_LIMP_WRONG_CS_CALIBRATION" 12 "DI_LIMP_STATOR_TEMP" 11 "DI_LIMP_DELTAT_TOO_NEGATIVE" 10 "DI_LIMP_DELTAT_TOO_POSITIVE" 9 "DI_LIMP_AMBIENT_TEMP" 8 "DI_LIMP_OUTLET_TEMP" 7 "DI_LIMP_LOW_FLOW" 6 "DI_LIMP_BMS_MIA" 5 "DI_LIMP_12V_SUPPLY_UNDERVOLTAGE" 4 "DI_LIMP_NO_FLUID" 3 "DI_LIMP_NO_FUNC_HEATSINK_SENSOR" 2 "DI_LIMP_NO_FUNC_STATORT_SENSOR" 1 "DI_LIMP_BUSV_SENSOR_IRRATIONAL" 0 "DI_LIMP_PHASE_IMBALANCE" ; VAL_TABLE_ DI_mode 2 "DI_MODE_DYNO" 1 "DI_MODE_DRIVE" 0 "DI_MODE_UNDEF" ; VAL_TABLE_ DI_motorType 14 "DI_MOTOR_F2AE" 13 "DI_MOTOR_F2AD" 12 "DI_MOTOR_F2AC" 11 "DI_MOTOR_F2AB" 10 "DI_MOTOR_F1AC" 9 "DI_MOTOR_SSR1A" 8 "DI_MOTOR_F1A" 7 "DI_MOTOR_M7M6" 6 "DI_MOTOR_M8A" 5 "DI_MOTOR_M7M5" 4 "DI_MOTOR_M7M4" 3 "DI_MOTOR_M7M3" 2 "DI_MOTOR_ROADSTER_SPORT" 1 "DI_MOTOR_ROADSTER_BASE" 0 "DI_MOTOR_SNA" ; VAL_TABLE_ DI_speedUnits 1 "DI_SPEED_KPH" 0 "DI_SPEED_MPH" ; VAL_TABLE_ DI_state 4 "DI_STATE_ENABLE" 3 "DI_STATE_FAULT" 2 "DI_STATE_CLEAR_FAULT" 1 "DI_STATE_STANDBY" 0 "DI_STATE_PREAUTH" ; VAL_TABLE_ DI_velocityEstimatorState 4 "VE_STATE_BACKUP_MOTOR" 3 "VE_STATE_BACKUP_WHEELS_B" 2 "VE_STATE_BACKUP_WHEELS_A" 1 "VE_STATE_WHEELS_NORMAL" 0 "VE_STATE_NOT_INITIALIZED" ; BO_ 1160 DAS_steeringControl: 4 NEO SG_ DAS_steeringControlType : 23|2@0+ (1,0) [0|0] "" EPAS SG_ DAS_steeringControlChecksum : 31|8@0+ (1,0) [0|0] "" EPAS SG_ DAS_steeringControlCounter : 19|4@0+ (1,0) [0|0] "" EPAS SG_ DAS_steeringAngleRequest : 6|15@0+ (0.1,-1638.35) [-1638.35|1638.35] "deg" EPAS SG_ DAS_steeringHapticRequest : 7|1@0+ (1,0) [0|0] "" EPAS BO_ 257 GTW_epasControl: 3 NEO SG_ GTW_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO SG_ GTW_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO SG_ GTW_epasControlType : 15|2@0+ (1,0) [-1|4] "" NEO SG_ GTW_epasEmergencyOn : 7|1@0+ (1,0) [-1|2] "" NEO SG_ GTW_epasLDWEnabled : 12|1@0+ (1,0) [-1|2] "" NEO SG_ GTW_epasPowerMode : 6|4@0+ (1,0) [4|14] "" NEO SG_ GTW_epasTuneRequest : 2|3@0+ (1,0) [-1|8] "" NEO BO_ 880 EPAS_sysStatus: 8 EPAS SG_ EPAS_currentTuneMode : 7|4@0+ (1,0) [8|15] "" NEO SG_ EPAS_eacErrorCode : 23|4@0+ (1,0) [-1|16] "" NEO SG_ EPAS_eacStatus : 55|3@0+ (1,0) [5|7] "" NEO SG_ EPAS_handsOnLevel : 39|2@0+ (1,0) [-1|4] "" NEO SG_ EPAS_internalSAS : 37|14@0+ (0.1,-819.200012) [0|0] "deg" NEO SG_ EPAS_steeringFault : 2|1@0+ (1,0) [-1|2] "" NEO SG_ EPAS_steeringRackForce : 1|10@0+ (50,-25575) [0|0] "N" NEO SG_ EPAS_steeringReduced : 3|1@0+ (1,0) [-1|2] "" NEO SG_ EPAS_sysStatusChecksum : 63|8@0+ (1,0) [0|255] "" NEO SG_ EPAS_sysStatusCounter : 51|4@0+ (1,0) [0|15] "" NEO SG_ EPAS_torsionBarTorque : 19|12@0+ (0.01,-20.5) [0|0] "Nm" NEO BO_ 3 STW_ANGL_STAT: 8 STW SG_ StW_Angl : 5|14@0+ (0.5,-2048) [0|0] "deg" NEO SG_ StW_AnglSpd : 21|14@0+ (0.5,-2048) [0|0] "/s" NEO SG_ StW_AnglSens_Stat : 33|2@0+ (1,0) [-1|4] "" NEO SG_ StW_AnglSens_Id : 35|2@0+ (1,0) [3|3] "" NEO SG_ MC_STW_ANGL_STAT : 55|4@0+ (1,0) [0|15] "" NEO SG_ CRC_STW_ANGL_STAT : 63|8@0+ (1,0) [0|255] "" NEO BO_ 14 STW_ANGLHP_STAT: 8 STW SG_ StW_AnglHP : 5|14@0+ (0.1,-819.2) [-819.2|819] "deg" NEO SG_ StW_AnglHP_Spd : 21|14@0+ (0.5,-4096) [-4096|4095.5] "deg/s" NEO SG_ StW_AnglHP_Sens_Stat : 33|2@0+ (1,0) [0|0] "" NEO SG_ StW_AnglHP_Sens_Id : 35|2@0+ (1,0) [0|0] "" NEO SG_ MC_STW_ANGLHP_STAT : 55|4@0+ (1,0) [0|15] "" NEO SG_ CRC_STW_ANGLHP_STAT : 63|8@0+ (1,0) [0|0] "" NEO BO_ 264 DI_torque1: 8 DI SG_ DI_torqueDriver : 0|13@1- (0.25,0) [-750|750] "Nm" NEO SG_ DI_torque1Counter : 13|3@1+ (1,0) [0|0] "" NEO SG_ DI_torqueMotor : 16|13@1- (0.25,0) [-750|750] "Nm" NEO SG_ DI_soptState : 29|3@1+ (1,0) [0|0] "" NEO SG_ DI_motorRPM : 32|16@1- (1,0) [-17000|17000] "RPM" NEO SG_ DI_pedalPos : 48|8@1+ (0.4,0) [0|100] "%" NEO SG_ DI_torque1Checksum : 56|8@1+ (1,0) [0|0] "" NEO BO_ 280 DI_torque2: 6 DI SG_ DI_torqueEstimate : 0|12@1- (0.5,0) [-750|750] "Nm" NEO SG_ DI_gear : 12|3@1+ (1,0) [0|0] "" NEO SG_ DI_brakePedal : 15|1@1+ (1,0) [0|0] "" NEO SG_ DI_vehicleSpeed : 16|12@1+ (0.05,-25) [-25|179.75] "MPH" NEO SG_ DI_gearRequest : 28|3@1+ (1,0) [0|0] "" NEO SG_ DI_torqueInterfaceFailure : 31|1@1+ (1,0) [0|0] "" NEO SG_ DI_torque2Counter : 32|4@1+ (1,0) [0|0] "" NEO SG_ DI_brakePedalState : 36|2@1+ (1,0) [0|0] "" NEO SG_ DI_epbParkRequest : 38|1@1+ (1,0) [0|0] "" NEO SG_ DI_epbInterfaceReady : 39|1@1+ (1,0) [0|0] "" NEO SG_ DI_torque2Checksum : 40|8@1+ (1,0) [0|0] "" NEO BO_ 309 ESP_135h: 5 ESP SG_ ESP_135hChecksum : 23|8@0+ (1,0) [0|255] "" NEO SG_ ESP_135hCounter : 11|4@0+ (1,0) [0|15] "" NEO SG_ ESP_absBrakeEvent : 2|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_brakeDiscWipingActive : 4|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_brakeLamp : 3|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_espFaultLamp : 6|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_espLampFlash : 7|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_hillStartAssistActive : 1|2@0+ (1,0) [-1|4] "" NEO SG_ ESP_messagePumpService : 24|1@0+ (1,0) [0|1] "" NEO SG_ ESP_messagePumpFailure : 25|1@0+ (1,0) [0|1] "" NEO SG_ ESP_messageEBDFailure : 26|1@0+ (1,0) [0|1] "" NEO SG_ ESP_absFaultLamp : 27|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_tcDisabledByFault : 28|1@0+ (1,0) [0|1] "" NEO SG_ ESP_messageDynoModeActive : 29|1@0+ (1,0) [0|1] "" NEO SG_ ESP_hydraulicBoostEnabled : 30|1@0+ (1,0) [0|1] "" NEO SG_ ESP_espOffLamp : 31|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_stabilityControlSts : 14|3@0+ (1,0) [6|7] "" NEO SG_ ESP_tcLampFlash : 5|1@0+ (1,0) [-1|2] "" NEO SG_ ESP_tcOffLamp : 15|1@0+ (1,0) [0|1] "" NEO BO_ 341 ESP_B: 8 ESP SG_ ESP_BChecksum : 39|8@0+ (1,0) [0|255] "" NEO,EPAS SG_ ESP_BCounter : 62|4@0+ (1,0) [1|15] "" NEO,EPAS SG_ ESP_vehicleSpeed : 47|16@0+ (0.00999999978,0) [0|0] "kph" NEO,EPAS SG_ ESP_vehicleSpeedQF : 57|2@0+ (1,0) [1|2] "" NEO,EPAS SG_ ESP_wheelPulseCountFrL : 7|8@0+ (1,0) [0|254] "" NEO,EPAS SG_ ESP_wheelPulseCountFrR : 15|8@0+ (1,0) [0|254] "" NEO,EPAS SG_ ESP_wheelPulseCountReL : 23|8@0+ (1,0) [0|254] "" NEO,EPAS SG_ ESP_wheelPulseCountReR : 31|8@0+ (1,0) [0|254] "" NEO,EPAS BO_ 513 SDM1: 5 GTW SG_ SDM_bcklPassStatus : 3|2@0+ (1,0) [0|3] "" NEO SG_ SDM_bcklDrivStatus : 5|2@0+ (1,0) [0|3] "" NEO BO_ 532 EPB_epasControl: 3 EPB SG_ EPB_epasControlChecksum : 23|8@0+ (1,0) [0|255] "" NEO,EPAS SG_ EPB_epasControlCounter : 11|4@0+ (1,0) [0|15] "" NEO,EPAS SG_ EPB_epasEACAllow : 2|3@0+ (1,0) [4|7] "" NEO,EPAS BO_ 792 GTW_carState: 8 GTW SG_ YEAR : 0|7@1+ (1,2000) [2000|2127] "Year" NEO SG_ CERRD : 7|1@1+ (1,0) [0|1] "" NEO SG_ MONTH : 8|4@1+ (1,0) [1|12] "Month" NEO SG_ DOOR_STATE_FL : 12|2@1+ (1,0) [0|3] "" NEO SG_ DOOR_STATE_FR : 14|2@1+ (1,0) [0|3] "" NEO SG_ SECOND : 16|6@1+ (1,0) [0|59] "s" NEO SG_ DOOR_STATE_RL : 22|2@1+ (1,0) [0|3] "" NEO SG_ Hour : 24|5@1+ (1,0) [0|23] "h" NEO SG_ DOOR_STATE_RR : 29|2@1+ (1,0) [0|3] "" NEO SG_ DAY : 32|5@1+ (1,0) [0|31] "" NEO SG_ MINUTE : 40|6@1+ (1,0) [0|59] "min" NEO SG_ BOOT_STATE : 46|2@1+ (1,0) [0|3] "" NEO SG_ GTW_updateInProgress : 48|2@1+ (1,0) [0|3] "" NEO SG_ DOOR_STATE_FrontTrunk : 50|2@1+ (1,0) [0|3] "" NEO SG_ MCU_factoryMode : 52|1@1+ (1,0) [0|1] "" NEO SG_ MCU_transportModeOn : 53|1@0+ (1,0) [0|1] "" NEO SG_ BC_headLightLStatus : 55|2@0+ (1,0) [0|3] "" NEO SG_ BC_headLightRStatus : 57|2@0+ (1,0) [0|3] "" NEO SG_ BC_indicatorLStatus : 59|2@0+ (1,0) [0|3] "" NEO SG_ BC_indicatorRStatus : 61|2@0+ (1,0) [0|3] "" NEO BO_ 872 DI_state: 8 DI SG_ DI_systemState : 0|3@1+ (1,0) [0|0] "" NEO SG_ DI_vehicleHoldState : 3|3@1+ (1,0) [0|0] "" NEO SG_ DI_proximity : 6|1@1+ (1,0) [0|0] "" NEO SG_ DI_driveReady : 7|1@1+ (1,0) [0|0] "" NEO SG_ DI_regenLight : 8|1@1+ (1,0) [0|0] "" NEO SG_ DI_state : 9|3@1+ (1,0) [0|0] "" NEO SG_ DI_cruiseState : 12|4@1+ (1,0) [0|0] "" NEO SG_ DI_analogSpeed : 16|12@1+ (0.1,0) [0|150] "speed" NEO SG_ DI_immobilizerState : 28|3@1+ (1,0) [0|0] "" NEO SG_ DI_speedUnits : 31|1@1+ (1,0) [0|1] "" NEO SG_ DI_cruiseSet : 32|9@1+ (0.5,0) [0|255.5] "speed" NEO SG_ DI_aebState : 41|3@1+ (1,0) [0|0] "" NEO SG_ DI_stateCounter : 44|4@1+ (1,0) [0|0] "" NEO SG_ DI_digitalSpeed : 48|8@1+ (1,0) [0|250] "" NEO SG_ DI_stateChecksum : 56|8@1+ (1,0) [0|0] "" NEO BO_ 109 SBW_RQ_SCCM: 4 STW SG_ StW_Sw_Stat3 : 0|3@1+ (1,0) [0|0] "" NEO SG_ MsgTxmtId : 6|2@1+ (1,0) [0|0] "" NEO SG_ TSL_RND_Posn_StW : 8|4@1+ (1,0) [0|0] "" NEO SG_ TSL_P_Psd_StW : 12|2@1+ (1,0) [0|0] "" NEO SG_ MC_SBW_RQ_SCCM : 20|4@1+ (1,0) [0|15] "" NEO SG_ CRC_SBW_RQ_SCCM : 24|8@1+ (1,0) [0|0] "" NEO BO_ 69 STW_ACTN_RQ: 8 STW SG_ SpdCtrlLvr_Stat : 0|6@1+ (1,0) [0|0] "" NEO SG_ VSL_Enbl_Rq : 6|1@1+ (1,0) [0|0] "" NEO SG_ SpdCtrlLvrStat_Inv : 7|1@1+ (1,0) [0|0] "" NEO SG_ DTR_Dist_Rq : 8|8@1+ (1,0) [0|200] "" NEO SG_ TurnIndLvr_Stat : 16|2@1+ (1,0) [0|0] "" NEO SG_ HiBmLvr_Stat : 18|2@1+ (1,0) [0|0] "" NEO SG_ WprWashSw_Psd : 20|2@1+ (1,0) [0|0] "" NEO SG_ WprWash_R_Sw_Posn_V2 : 22|2@1+ (1,0) [0|0] "" NEO SG_ StW_Lvr_Stat : 24|3@1+ (1,0) [0|0] "" NEO SG_ StW_Cond_Flt : 27|1@1+ (1,0) [0|0] "" NEO SG_ StW_Cond_Psd : 28|2@1+ (1,0) [0|0] "" NEO SG_ HrnSw_Psd : 30|2@1+ (1,0) [0|0] "" NEO SG_ StW_Sw00_Psd : 32|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw01_Psd : 33|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw02_Psd : 34|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw03_Psd : 35|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw04_Psd : 36|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw05_Psd : 37|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw06_Psd : 38|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw07_Psd : 39|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw08_Psd : 40|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw09_Psd : 41|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw10_Psd : 42|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw11_Psd : 43|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw12_Psd : 44|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw13_Psd : 45|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw14_Psd : 46|1@1+ (1,0) [0|0] "" NEO SG_ StW_Sw15_Psd : 47|1@1+ (1,0) [0|0] "" NEO SG_ WprSw6Posn : 48|3@1+ (1,0) [0|0] "" NEO SG_ MC_STW_ACTN_RQ : 52|4@1+ (1,0) [0|15] "" NEO SG_ CRC_STW_ACTN_RQ : 56|8@1+ (1,0) [0|0] "" NEO BO_ 643 BODY_R1: 8 GTW SG_ AirTemp_Insd : 47|8@0+ (0.25,0) [0|63.5] "C" NEO SG_ AirTemp_Outsd : 63|8@0+ (0.5,-40) [-40|86.5] "C" NEO SG_ Bckl_Sw_RL_Stat_SAM_R : 49|2@0+ (1,0) [-1|4] "" NEO SG_ Bckl_Sw_RM_Stat_SAM_R : 53|2@0+ (1,0) [-1|4] "" NEO SG_ Bckl_Sw_RR_Stat_SAM_R : 51|2@0+ (1,0) [-1|4] "" NEO SG_ DL_RLtch_Stat : 9|2@0+ (1,0) [-1|4] "" NEO SG_ DrRLtch_FL_Stat : 1|2@0+ (1,0) [-1|4] "" NEO SG_ DrRLtch_FR_Stat : 3|2@0+ (1,0) [-1|4] "" NEO SG_ DrRLtch_RL_Stat : 5|2@0+ (1,0) [-1|4] "" NEO SG_ DrRLtch_RR_Stat : 7|2@0+ (1,0) [-1|4] "" NEO SG_ EngHd_Stat : 11|2@0+ (1,0) [-1|4] "" NEO SG_ LoBm_On_Rq : 32|1@0+ (1,0) [0|1] "" NEO SG_ HiBm_On : 33|1@0+ (1,0) [0|1] "" NEO SG_ Hrn_On : 26|1@0+ (1,0) [0|1] "" NEO SG_ IrLmp_D_Lt_Flt : 34|1@0+ (1,0) [0|1] "" NEO SG_ IrLmp_P_Rt_Flt : 35|1@0+ (1,0) [0|1] "" NEO SG_ LgtSens_Twlgt : 18|3@0+ (1,0) [0|7] "Steps" NEO SG_ LgtSens_SNA : 19|1@0+ (1,0) [0|1] "" NEO SG_ LgtSens_Tunnel : 20|1@0+ (1,0) [0|1] "" NEO SG_ LgtSens_Flt : 21|1@0+ (1,0) [0|1] "" NEO SG_ LgtSens_Night : 22|1@0+ (1,0) [-1|2] "" NEO SG_ ADL_LoBm_On_Rq : 23|1@0+ (1,0) [0|1] "" NEO SG_ LoBm_D_Lt_Flt : 36|1@0+ (1,0) [0|1] "" NEO SG_ LoBm_P_Rt_Flt : 37|1@0+ (1,0) [0|1] "" NEO SG_ MPkBrk_Stat : 28|1@0+ (1,0) [-1|2] "" NEO SG_ RevGr_Engg : 39|2@0+ (1,0) [-1|4] "" NEO SG_ StW_Cond_Stat : 55|2@0+ (1,0) [-1|4] "" NEO SG_ Term54_Actv : 27|1@0+ (1,0) [0|1] "" NEO SG_ Trlr_Stat : 25|2@0+ (1,0) [-1|4] "" NEO SG_ VTA_Alm_Actv : 13|1@0+ (1,0) [0|1] "" NEO SG_ WprOutsdPkPosn : 29|1@0+ (1,0) [0|1] "" NEO BO_ 760 UI_gpsVehicleSpeed: 8 GTW SG_ UI_gpsHDOP : 0|8@1+ (0.1,0) [0|25.5] "1" DAS SG_ UI_gpsVehicleHeading : 8|16@1+ (0.0078125,0) [0|511.9921875] "deg" DAS SG_ UI_gpsVehicleSpeed : 24|16@1+ (0.00390625,0) [0|250.996] "km/hr" Vector__XXX SG_ UI_userSpeedOffset : 40|6@1+ (1,-30) [-30|33] "kph/mph" DAS SG_ UI_mapSpeedLimitUnits : 46|1@1+ (1,0) [0|1] "" DAS SG_ UI_userSpeedOffsetUnits : 47|1@1+ (1,0) [0|1] "" DAS SG_ UI_mppSpeedLimit : 48|5@1+ (5,0) [0|155] "kph/mph" DAS SG_ UI_gpsNmeaMIA : 53|1@1+ (1,0) [0|0] "" DAS BO_ 536 MCU_chassisControl: 8 GTW SG_ MCU_dasDebugEnable : 0|1@1+ (1,0) [0|0] "" NEO SG_ MCU_parkBrakeRequest : 1|2@1+ (1,0) [0|0] "" NEO SG_ MCU_trailerModeCH : 3|1@1+ (1,0) [0|0] "" NEO SG_ MCU_fcwSensitivity : 4|2@1+ (1,0) [0|0] "" NEO SG_ MCU_fcwEnable : 6|2@1+ (1,0) [0|0] "" NEO SG_ MCU_latControlEnable : 8|2@1+ (1,0) [0|0] "" NEO SG_ MCU_accOvertakeEnable : 10|2@1+ (1,0) [0|0] "" NEO SG_ MCU_ldwEnable : 12|2@1+ (1,0) [0|0] "" NEO SG_ MCU_aebEnable : 14|2@1+ (1,0) [0|0] "" NEO SG_ MCU_bsdEnable : 16|2@1+ (1,0) [0|0] "" NEO SG_ MCU_ahlbEnable : 18|2@1+ (1,0) [0|0] "" NEO SG_ MCU_parkSetting : 20|2@1+ (1,0) [0|0] "" NEO SG_ MCU_pedalSafetyEnable : 22|2@1+ (1,0) [0|0] "" NEO SG_ MCU_frontDefrostReq_das : 24|2@1+ (1,0) [0|0] "" NEO SG_ MCU_autoParkRequest : 26|4@1+ (1,0) [0|0] "" NEO SG_ MCU_redLightStopSignEnable : 30|2@1+ (1,0) [0|0] "" NEO SG_ MCU_enableCreepTorqueCH : 32|1@1+ (1,0) [0|0] "" NEO SG_ MCU_narrowGarages : 33|1@1+ (1,0) [0|0] "" NEO SG_ MCU_rebootAutopilot : 34|1@1+ (1,0) [0|0] "" NEO SG_ MCU_enableAutowipers : 35|1@1+ (1,0) [0|0] "" NEO SG_ MCU_overPaintedUSS : 38|2@1+ (1,0) [0|0] "" NEO SG_ MCU_selfParkTune : 40|4@1+ (1,0) [0|15] "" NEO SG_ MCU_towModeEnable : 44|2@1+ (1,0) [0|0] "" NEO SG_ MCU_zeroSpeedConfirmed : 46|2@1+ (1,0) [0|0] "" NEO SG_ MCU_aesEnable : 48|2@1+ (1,0) [0|0] "" NEO SG_ MCU_autoLaneChangeEnable : 50|2@1+ (1,0) [0|0] "" NEO SG_ MCU_chassisControlCounter : 52|4@1+ (1,0) [0|0] "" NEO SG_ MCU_chassisControlChecksum : 56|8@1+ (1,0) [0|0] "" NEO BO_ 904 MCU_clusterBacklightRequest: 3 NEO SG_ MCU_clusterBacklightOn : 7|1@1+ (1,0) [0|1] "" NEO SG_ MCU_clusterBrightnessLevel : 8|8@1+ (0.5,0) [0|127.5] "%" NEO SG_ MCU_clusterReadyForDrive : 6|1@1+ (1,0) [-1|2] "" NEO SG_ MCU_clusterReadyForPowerOff : 5|1@1+ (1,0) [0|1] "" NEO BO_ 984 MCU_locationStatus: 8 MCU SG_ MCU_gpsAccuracy : 57|7@1+ (0.2,0) [0|0] "m" NEO SG_ MCU_latitude : 0|28@1- (1E-06,0) [0|0] "deg" NEO SG_ MCU_longitude : 28|29@1- (1E-06,0) [0|0] "deg" NEO BO_ 104 MCU_locationStatus2: 8 MCU SG_ MCU_elevation : 0|32@1- (0.1,0) [0|0] "m" GTW SG_ MCU_navigonExpectedSpeed : 32|7@1+ (1,0) [0|126] "mph" GTW BO_ 840 GTW_status: 8 GTW SG_ GTW_accGoingDown : 6|1@0+ (1,0) [0|1] "" NEO SG_ GTW_accRailReq : 8|1@0+ (1,0) [0|1] "" NEO SG_ GTW_brakePressed : 1|1@0+ (1,0) [0|1] "" NEO SG_ GTW_driveGoingDown : 7|1@0+ (1,0) [0|1] "" NEO SG_ GTW_driveRailReq : 0|1@0+ (1,0) [0|1] "" NEO SG_ GTW_driverIsLeaving : 5|1@0+ (1,0) [0|1] "" NEO SG_ GTW_driverPresent : 2|1@0+ (1,0) [0|1] "" NEO SG_ GTW_hvacGoingDown : 11|1@0+ (1,0) [0|1] "" NEO SG_ GTW_hvacRailReq : 9|1@0+ (1,0) [0|1] "" NEO SG_ GTW_icPowerOff : 4|1@0+ (1,0) [0|1] "" NEO SG_ GTW_notEnough12VForDrive : 3|1@0+ (1,0) [0|1] "" NEO SG_ GTW_preconditionRequest : 10|1@0+ (1,0) [0|1] "" NEO SG_ GTW_statusChecksum : 63|8@0+ (1,0) [0|255] "" NEO SG_ GTW_statusCounter : 51|4@0+ (1,0) [0|15] "" NEO BO_ 920 GTW_carConfig: 8 GTW SG_ GTW_performanceConfig : 2|3@0+ (1,0) [0|0] "" NEO SG_ GTW_fourWheelDrive : 4|2@0+ (1,0) [0|0] "" NEO SG_ GTW_unknown1 : 5|1@0+ (1,0) [0|0] "" NEO SG_ GTW_dasHw : 7|2@0+ (1,0) [0|0] "" NEO SG_ GTW_parkAssistInstalled : 9|2@0+ (1,0) [0|0] "" NEO SG_ GTW_forwardRadarHw : 11|2@0+ (1,0) [0|0] "" NEO SG_ GTW_airSuspensionInstalled : 14|3@0+ (1,0) [0|0] "" NEO SG_ GTW_unknown2 : 15|1@0+ (1,0) [0|0] "" NEO SG_ GTW_country : 23|16@0+ (1,0) [0|0] "" NEO SG_ GTW_parkSensorGeometryType : 33|2@0+ (1,0) [0|0] "" NEO SG_ GTW_rhd : 34|1@0+ (1,0) [0|0] "" NEO SG_ GTW_bodyControlsType : 35|1@0+ (1,0) [0|0] "" NEO SG_ GTW_radarPosition : 39|4@0+ (1,0) [0|0] "" NEO SG_ GTW_rearCornerRadarHw : 41|2@0+ (1,0) [0|0] "" NEO SG_ GTW_frontCornerRadarHw : 43|2@0+ (1,0) [0|0] "" NEO SG_ GTW_epasType : 45|2@0+ (1,0) [0|0] "" NEO SG_ GTW_chassisType : 47|2@0+ (1,0) [0|2] "" NEO SG_ GTW_wheelType : 52|5@0+ (1,0) [0|0] "" NEO SG_ GTW_rearSeatControllerMask : 55|3@0+ (1,0) [0|7] "" NEO SG_ GTW_euVehicle : 56|1@0+ (1,0) [0|0] "" NEO SG_ GTW_foldingMirrorsInstalled : 57|1@0+ (1,0) [0|0] "" NEO SG_ GTW_brakeHwType : 59|2@0+ (1,0) [0|2] "" NEO SG_ GTW_autopilot : 61|2@0+ (1,0) [0|0] "" NEO SG_ GTW_unknown3 : 63|2@0+ (1,0) [0|0] "" NEO BO_ 1006 UI_autopilotControl: 8 GTW SG_ UI_autopilotControlIndex M : 0|3@1+ (1,0) [0|7] "" APP,APS SG_ UI_hovEnabled m0 : 3|1@1+ (1,0) [0|0] "" APP,APS SG_ UI_donDisableAutoWiperDuration m0 : 4|3@1+ (1,0) [0|0] "" APP,APS SG_ UI_donDisableOnAutoWiperSpeed m0 : 7|4@1+ (1,0) [0|0] "" APP,APS SG_ UI_blindspotMinSpeed m0 : 11|4@1+ (1,0) [0|0] "" APP,APS SG_ UI_blindspotDistance m0 : 15|3@1+ (1,0) [0|0] "" APP,APS SG_ UI_blindspotTTC m0 : 18|3@1+ (1,0) [0|0] "" APP,APS SG_ UI_donStopEndOfRampBuffer m0 : 21|3@1+ (1,0) [0|0] "" APP,APS SG_ UI_donDisableCutin m0 : 24|1@1+ (1,0) [0|0] "" APP,APS SG_ UI_donMinGoreWidthForAbortMap m0 : 25|4@1+ (1,0) [0|0] "" APP,APS SG_ UI_donAlcProgGoreAbortThres m0 : 29|4@1+ (1,0) [0|0] "" APP,APS SG_ UI_donMinGoreWidthForAbortNotMap m0 : 33|4@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcDisableUltrasonicCheck m0 : 37|1@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcUltrasonicDistance m0 : 38|4@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcUltrasonicWaitTime m0 : 42|3@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcEgoLeadingReactionAccel m0 : 48|2@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcMergIntervalRearDHyst m0 : 50|2@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcMergingIntervalHeadwayHyst m0 : 52|2@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcAssertivenessRate m0 : 54|2@1+ (1,0) [0|0] "" APP,APS SG_ UI_alcViewRangeSensitivity m0 : 56|2@1+ (1,0) [0|0] "" APP,APS SG_ UI_camBlockLaneCheckDisable m1 : 3|1@1+ (1,0) [0|0] "" APP,APS SG_ UI_camBlockLaneCheckThreshold m1 : 4|6@1+ (0.01587,0) [0|1] "%" APP,APS SG_ UI_camBlockBlurDisable m1 : 10|1@1+ (1,0) [0|0] "" APP,APS SG_ UI_camBlockBlurThreshold m1 : 11|6@1+ (0.01587,0) [0|1] "%" APP,APS BO_ 728 UI_csaOfframpCurvature: 8 GTW SG_ UI_csaOfframpCurvC2 : 0|16@1- (1E-06,0) [-0.032768|0.032767] "1/m" DAS SG_ UI_csaOfframpCurvC3 : 16|16@1- (4E-09,0) [-0.000131072|0.000131068] "1/m2" DAS SG_ UI_csaOfframpCurvRange : 32|8@1+ (2,0) [0|510] "m" DAS SG_ UI_csaOfframpCurvCounter : 40|8@1+ (1,0) [0|255] "" Vector__XXX SG_ UI_csaOfframpCurvUsingTspline : 48|1@1+ (1,0) [0|1] "" DAS SG_ UI_csaOfframpCurvReserved : 49|7@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_csaOfframpCurvChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX BO_ 744 UI_csaRoadCurvature: 8 GTW SG_ UI_csaRoadCurvC2 : 0|16@1- (1E-06,0) [-0.032768|0.032767] "1/m" DAS SG_ UI_csaRoadCurvC3 : 16|16@1- (4E-09,0) [-0.000131072|0.000131068] "1/m2" DAS SG_ UI_csaRoadCurvRange : 32|8@1+ (2,0) [0|510] "m" DAS SG_ UI_csaRoadCurvCounter : 40|8@1+ (1,0) [0|255] "" Vector__XXX SG_ UI_csaRoadCurvUsingTspline : 48|1@1+ (1,0) [0|1] "" DAS SG_ UI_csaRoadCurvReserved : 49|7@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_csaRoadCurvChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX BO_ 1080 UI_driverAssistAnonDebugParams: 8 GTW SG_ UI_anonDebugParam1 : 0|7@1+ (1,0) [0|100] "" DAS SG_ UI_anonDebugFlag1 : 7|1@1+ (1,0) [0|0] "" DAS SG_ UI_anonDebugParam2 : 8|7@1+ (1,0) [0|100] "" DAS SG_ UI_anonDebugFlag2 : 15|1@1+ (1,0) [0|0] "" DAS SG_ UI_anonDebugParam3 : 16|7@1+ (1,0) [0|100] "" DAS SG_ UI_anonDebugFlag3 : 23|1@1+ (1,0) [0|0] "" DAS SG_ UI_anonDebugParam4 : 24|7@1+ (1,0) [0|100] "" DAS SG_ UI_anonDebugFlag4 : 31|1@1+ (1,0) [0|0] "" DAS SG_ UI_anonDebugParam5 : 32|7@1+ (1,0) [0|100] "" DAS SG_ UI_anonDebugParam6 : 40|7@1+ (1,0) [0|100] "" DAS SG_ UI_anonDebugParam7 : 48|7@1+ (1,0) [0|100] "" DAS SG_ UI_visionSpeedSlider : 56|7@1+ (1,0) [0|100] "" DAS BO_ 1000 UI_driverAssistControl: 8 GTW SG_ UI_autopilotControlRequest : 0|1@1+ (1,0) [1|0] "" DAS SG_ UI_ulcStalkConfirm : 1|1@1+ (1,0) [1|0] "" DAS SG_ UI_summonHeartbeat : 2|2@1+ (1,0) [0|0] "" DAS SG_ UI_curvSpeedAdaptDisable : 4|1@1+ (1,0) [0|0] "" DAS SG_ UI_dasDeveloper : 5|1@1+ (1,0) [0|0] "" DAS SG_ UI_enableVinAssociation : 6|1@1+ (1,0) [0|0] "" DAS SG_ UI_lssLkaEnabled : 7|1@1+ (1,0) [0|0] "" DAS SG_ UI_lssLdwEnabled : 8|1@1+ (1,0) [0|0] "" DAS SG_ UI_autoSummonEnable : 10|1@1+ (1,0) [0|1] "" DAS SG_ UI_exceptionListEnable : 11|1@1+ (1,0) [0|1] "" APP SG_ UI_roadCheckDisable : 12|1@1+ (1,0) [0|0] "" DAS SG_ UI_driveOnMapsEnable : 13|1@1+ (1,0) [0|0] "" DAS SG_ UI_handsOnRequirementDisable : 14|1@1+ (1,0) [0|0] "" DAS SG_ UI_forksEnable : 15|1@1+ (1,0) [0|0] "" DAS SG_ UI_fuseLanesDisable : 16|1@1+ (1,0) [0|0] "" DAS SG_ UI_fuseHPPDisable : 17|1@1+ (1,0) [0|0] "" DAS SG_ UI_fuseVehiclesDisable : 18|1@1+ (1,0) [0|0] "" DAS SG_ UI_enableNextGenACC : 19|1@1+ (1,0) [0|1] "" APP SG_ UI_visionSpeedType : 20|2@1+ (1,0) [0|0] "" APP SG_ UI_curvatureDatabaseOnly : 22|1@1+ (1,0) [0|0] "" DAS SG_ UI_lssElkEnabled : 23|1@1+ (1,0) [0|0] "" DAS SG_ UI_summonExitType : 24|2@1+ (1,0) [0|3] "" DAS SG_ UI_summonEntryType : 26|2@1+ (1,0) [0|3] "" DAS SG_ UI_selfParkRequest : 28|4@1+ (1,0) [0|15] "" DAS,PARK SG_ UI_summonReverseDist : 32|6@1+ (1,0) [0|63] "" DAS SG_ UI_undertakeAssistEnable : 38|1@1+ (1,0) [0|0] "" DAS SG_ UI_adaptiveSetSpeedEnable : 39|1@1+ (1,0) [0|0] "" DAS SG_ UI_drivingSide : 40|2@1+ (1,0) [0|3] "" DAS SG_ UI_enableClipTelemetry : 42|1@1+ (1,0) [0|0] "" APP SG_ UI_enableTripTelemetry : 43|1@1+ (1,0) [0|0] "" APP SG_ UI_enableRoadSegmentTelemetry : 44|1@1+ (1,0) [0|0] "" APP SG_ UI_followNavRouteEnable : 46|1@1+ (1,0) [0|0] "" APP SG_ UI_ulcSpeedConfig : 48|2@1+ (1,0) [0|3] "" APP SG_ UI_ulcBlindSpotConfig : 50|2@1+ (1,0) [0|3] "" APP SG_ UI_autopilotAlwaysOn : 52|1@1+ (1,0) [0|1] "" APP SG_ UI_accFromZero : 53|1@1+ (1,0) [0|1] "" APP SG_ UI_alcOffHighwayEnable : 54|1@1+ (1,0) [0|1] "" APP SG_ UI_validationLoop : 55|1@1+ (1,0) [0|1] "" APP SG_ UI_ulcOffHighway : 56|1@1+ (1,0) [0|1] "" APP SG_ UI_enableNavRouteCSA : 57|1@1+ (1,0) [0|1] "" APP SG_ UI_enableCutinExperiments : 58|1@1+ (1,0) [0|1] "" APP SG_ UI_source3D : 60|3@1+ (1,0) [0|7] "" APP SG_ UI_enableVisionOnlyStops : 63|1@1+ (1,0) [0|1] "" APP BO_ 968 UI_driverAssistMapData: 8 GTW SG_ UI_mapSpeedLimitDependency : 0|3@1+ (1,0) [0|0] "" DAS SG_ UI_roadClass : 3|3@1+ (1,0) [0|0] "" DAS SG_ UI_inSuperchargerGeofence : 6|1@1+ (1,0) [0|0] "" DAS SG_ UI_mapSpeedUnits : 7|1@1+ (1,0) [0|0] "" DAS SG_ UI_mapSpeedLimit : 8|5@1+ (1,0) [0|0] "" DAS SG_ UI_mapSpeedLimitType : 13|3@1+ (1,0) [0|0] "" DAS SG_ UI_countryCode : 16|10@1+ (1,0) [0|0] "" DAS SG_ UI_streetCount : 26|2@1+ (1,0) [0|0] "" DAS SG_ UI_gpsRoadMatch : 28|1@1+ (1,0) [0|0] "" DAS SG_ UI_navRouteActive : 29|1@1+ (1,0) [0|0] "" DAS SG_ UI_parallelAutoparkEnabled : 30|1@1+ (1,0) [0|1] "" DAS SG_ UI_perpendicularAutoparkEnabled : 31|1@1+ (1,0) [0|1] "" DAS SG_ UI_nextBranchDist : 32|5@1+ (10,0) [0|300] "m" DAS SG_ UI_controlledAccess : 37|1@1+ (1,0) [0|0] "" DAS SG_ UI_nextBranchLeftOffRamp : 38|1@1+ (1,0) [0|0] "" DAS SG_ UI_nextBranchRightOffRamp : 39|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectLeftLane : 40|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectRightLane : 41|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectHPP : 42|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectNav : 43|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectLeftFreeSpace : 44|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectRightFreeSpace : 45|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectAutosteer : 46|1@1+ (1,0) [0|0] "" DAS SG_ UI_rejectHandsOn : 47|1@1+ (1,0) [0|0] "" DAS SG_ UI_acceptBottsDots : 48|1@1+ (1,0) [0|0] "" DAS SG_ UI_autosteerRestricted : 49|1@1+ (1,0) [0|0] "" DAS SG_ UI_pmmEnabled : 50|1@1+ (1,0) [0|0] "" DAS SG_ UI_scaEnabled : 51|1@1+ (1,0) [0|0] "" DAS SG_ UI_mapDataCounter : 52|4@1+ (1,0) [0|0] "" DAS SG_ UI_mapDataChecksum : 56|8@1+ (1,0) [0|0] "" DAS BO_ 568 UI_driverAssistRoadSign: 8 GTW SG_ UI_roadSign M : 0|8@1+ (1,0) [0|0] "" DAS SG_ UI_splineLocConfidence : 40|7@1+ (1,0) [0|100] "" DAS SG_ UI_splineID : 48|4@1+ (1,0) [0|15] "" Vector__XXX SG_ UI_roadSignCounter : 52|4@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_roadSignChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_dummyData m0 : 8|1@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_stopSignStopLineDist m1 : 8|10@1+ (0.25,-8) [-8|247.5] "m" Vector__XXX SG_ UI_stopSignStopLineConf m1 : 18|7@1+ (1,0) [0|100] "" Vector__XXX SG_ UI_trafficLightStopLineDist m2 : 8|10@1+ (0.25,-8) [-8|247.5] "m" Vector__XXX SG_ UI_trafficLightStopLineConf m2 : 18|7@1+ (1,0) [0|100] "" Vector__XXX SG_ UI_baseMapSpeedLimitMPS m3 : 8|8@1+ (0.25,0) [0|63.75] "m/s" DAS SG_ UI_bottomQrtlFleetSpeedMPS m3 : 16|8@1+ (0.25,0) [0|63.75] "m/s" DAS SG_ UI_topQrtlFleetSpeedMPS m3 : 24|8@1+ (0.25,0) [0|63.75] "m/s" DAS SG_ UI_meanFleetSplineSpeedMPS m4 : 8|8@1+ (0.25,0) [0|63.75] "m/s" DAS SG_ UI_medianFleetSpeedMPS m4 : 16|8@1+ (0.25,0) [0|63.75] "m/s" DAS SG_ UI_meanFleetSplineAccelMPS2 m4 : 24|8@1+ (0.05,-6.35) [-6.35|6.4] "m/s^2" DAS SG_ UI_rampType m4 : 32|3@1+ (1,0) [0|7] "" DAS SG_ UI_currSplineIdFull m5 : 8|32@1+ (1,0) [0|1] "" APP BO_ 696 UI_radarMapData: 8 GTW SG_ UI_radarTargetDx : 0|8@1+ (1,-95) [-95|160] "m" DAS SG_ UI_radarTargetDxEnd : 8|8@1+ (1,0) [0|255] "m" DAS SG_ UI_radarTargetTrustMap : 16|1@1+ (1,0) [0|1] "" DAS SG_ UI_radarEnableBraking : 17|1@1+ (1,0) [0|1] "" DAS SG_ UI_radarMapDataCounter : 52|4@1+ (1,0) [0|0] "" DAS SG_ UI_radarMapDataChecksum : 56|8@1+ (1,0) [0|0] "" DAS BO_ 712 UI_roadCurvature: 8 GTW SG_ UI_roadCurvC0 : 0|11@1- (0.02,0) [-20.48|20.46] "m" DAS SG_ UI_roadCurvC1 : 11|10@1- (0.00075,0) [-0.384|0.38325] "1" DAS SG_ UI_roadCurvC2 : 21|14@1- (7.5E-06,0) [-0.03072|0.03071625] "1/m" DAS SG_ UI_roadCurvC3 : 35|13@1- (3E-08,0) [-0.00012288|0.00012285] "1/m2" DAS SG_ UI_roadCurvRange : 48|6@1+ (4,0) [0|252] "m" DAS SG_ UI_roadCurvHealth : 54|2@1+ (1,0) [0|0] "" DAS SG_ UI_roadCurvChecksum : 56|8@1+ (1,0) [0|0] "" Vector__XXX BO_ 582 UI_solarData: 5 GTW SG_ UI_solarAzimuthAngle : 0|16@1- (1,0) [0|360] "deg" APP SG_ UI_solarAzimuthAngleCarRef : 16|9@1- (1,0) [-180|180] "deg" APP SG_ UI_isSunUp : 25|1@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_solarElevationAngle : 32|8@1- (1,0) [-90|90] "deg" APP BO_ 824 UI_status: 8 GTW SG_ UI_touchActive : 0|1@1+ (1,0) [0|0] "" IC SG_ UI_audioActive : 1|1@1+ (1,0) [0|0] "" IC SG_ UI_bluetoothActive : 2|1@1+ (1,0) [0|0] "" IC SG_ UI_cellActive : 3|1@1+ (1,0) [0|0] "" IC SG_ UI_displayReady : 4|1@1+ (1,0) [0|0] "" IC SG_ UI_gpsActive : 5|1@1+ (1,0) [0|0] "" IC SG_ UI_wifiConnected : 6|1@1+ (1,0) [0|0] "" IC,APP SG_ UI_systemActive : 7|1@1+ (1,0) [0|0] "" IC SG_ UI_xmActive : 8|1@1+ (1,0) [0|0] "" IC SG_ UI_displayOn : 9|1@1+ (1,0) [0|0] "" IC,APP SG_ UI_readyForDrive : 10|1@1+ (1,0) [0|0] "" IC SG_ UI_cellConnected : 11|1@1+ (1,0) [0|0] "" IC,APP SG_ UI_vpnActive : 12|1@1+ (1,0) [0|0] "" IC,APP SG_ UI_wifiActive : 13|1@1+ (1,0) [0|0] "" IC SG_ UI_cameraActive : 14|1@1+ (1,0) [0|0] "" IC,APP SG_ UI_usbActive : 15|1@1+ (1,0) [0|0] "" IC SG_ UI_screenshotActive : 16|1@1+ (1,0) [0|0] "" IC,APP SG_ UI_monitorModemPower : 17|1@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_factoryReset : 18|2@1+ (1,0) [0|3] "" Vector__XXX SG_ UI_cellNetworkTechnology : 20|4@1+ (1,0) [0|15] "" APP SG_ UI_tegraCoreTemperature : 24|8@1+ (1,-64) [0|0] "deg C" IC SG_ UI_tegraAmbientTemperature : 32|8@1+ (1,-64) [0|0] "deg C" IC SG_ UI_googleWifiUsages : 40|8@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_autopilotTrial : 48|2@1+ (1,0) [0|0] "" APP SG_ UI_cellSignalBars : 50|3@1+ (1,0) [0|7] "" APP SG_ UI_hardwareType : 53|2@1+ (1,0) [0|3] "" APP SG_ UI_developmentCar : 55|1@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_cellReceiverPower : 56|8@1+ (1,-128) [-128|127] "dB" APP BO_ 1064 UI_telemetryControl: 8 GTW SG_ UI_TCR_enable : 0|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_moveStateStanding : 1|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_moveStateStopped : 2|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_moveStateMoving : 3|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_moveStateIndeterm : 4|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_classConstElem : 5|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_classMovingPed : 6|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_classMovingTwoWheel : 7|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_classMovingFourWheel : 8|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_classUnknown : 9|1@1+ (1,0) [0|0] "" DAS SG_ UI_TCR_downSampleFactor : 16|4@1+ (1,0) [0|15] "" Vector__XXX SG_ UI_TCR_wExist : 24|5@1+ (1,0) [0|31] "" Vector__XXX SG_ UI_TCR_vehSpeed : 32|8@1+ (1,0) [0|0] "" Vector__XXX SG_ UI_TCR_minRCS : 40|8@1+ (0.25,-14) [-14|49.75] "dB" Vector__XXX SG_ UI_TCR_maxDy : 48|5@1+ (0.5,0) [0|15.5] "m" Vector__XXX SG_ UI_TCR_maxObjects : 56|5@1+ (1,0) [0|31] "" Vector__XXX SG_ UI_TCR_maxRoadClass : 61|3@1+ (1,0) [0|7] "" Vector__XXX BO_ 522 BrakeMessage: 8 XXX SG_ driverBrakeStatus : 2|2@1+ (1,0) [0|3] "" XXX BO_ 921 AutopilotStatus: 8 XXX SG_ autopilotStatus : 0|4@1+ (1,0) [0|0] "" XXX VAL_ 3 StW_Angl 16383 "SNA" ; VAL_ 3 StW_AnglSens_Id 2 "MUST" 0 "PSBL" 1 "SELF" ; VAL_ 3 StW_AnglSens_Stat 2 "ERR" 3 "ERR_INI" 1 "INI" 0 "OK" ; VAL_ 3 StW_AnglSpd 16383 "SNA" ; VAL_ 14 StW_AnglHP 16383 "SNA" ; VAL_ 14 StW_AnglHP_Spd 16383 "SNA" ; VAL_ 14 StW_AnglHP_Sens_Stat 3 "SNA" 2 "ERR" 1 "INI" 0 "OK" ; VAL_ 14 StW_AnglHP_Sens_Id 3 "SNA" 2 "KOSTAL" 1 "DELPHI" 0 "TEST" ; VAL_ 69 SpdCtrlLvr_Stat 32 "DN_1ST" 16 "UP_1ST" 8 "DN_2ND" 4 "UP_2ND" 2 "RWD" 1 "FWD" 0 "IDLE" ; VAL_ 69 DTR_Dist_Rq 255 "SNA" 200 "ACC_DIST_7" 166 "ACC_DIST_6" 133 "ACC_DIST_5" 100 "ACC_DIST_4" 66 "ACC_DIST_3" 33 "ACC_DIST_2" 0 "ACC_DIST_1" ; VAL_ 69 TurnIndLvr_Stat 3 "SNA" 2 "RIGHT" 1 "LEFT" 0 "IDLE" ; VAL_ 69 HiBmLvr_Stat 3 "SNA" 2 "HIBM_FLSH_ON_PSD" 1 "HIBM_ON_PSD" 0 "IDLE" ; VAL_ 69 WprWashSw_Psd 3 "SNA" 2 "WASH" 1 "TIPWIPE" 0 "NPSD" ; VAL_ 69 WprWash_R_Sw_Posn_V2 3 "SNA" 2 "WASH" 1 "INTERVAL" 0 "OFF" ; VAL_ 69 StW_Lvr_Stat 4 "STW_BACK" 3 "STW_FWD" 2 "STW_DOWN" 1 "STW_UP" 0 "NPSD" ; VAL_ 69 StW_Cond_Psd 3 "SNA" 2 "DOWN" 1 "UP" 0 "NPSD" ; VAL_ 69 HrnSw_Psd 3 "SNA" 2 "NDEF2" 1 "PSD" 0 "NPSD" ; VAL_ 69 StW_Sw00_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; VAL_ 69 StW_Sw01_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; VAL_ 69 StW_Sw03_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; VAL_ 69 StW_Sw04_Psd 1 "PRESSED" 0 "NOT_PRESSED_SNA" ; VAL_ 69 WprSw6Posn 7 "SNA" 6 "STAGE2" 5 "STAGE1" 4 "INTERVAL4" 3 "INTERVAL3" 2 "INTERVAL2" 1 "INTERVAL1" 0 "OFF" ; VAL_ 257 GTW_epasControlType 0 "WITHOUT" 1 "WITH_ANGLE" 3 "WITH_BOTH" 2 "WITH_TORQUE" ; VAL_ 109 StW_Sw_Stat3 7 "SNA" 6 "NDEF6" 5 "NDEF5" 4 "NDEF4" 3 "PLUS_MINUS" 2 "MINUS" 1 "PLUS" 0 "NPSD" ; VAL_ 109 MsgTxmtId 3 "NDEF3" 2 "NDEF2" 1 "SCCM" 0 "EWM" ; VAL_ 109 TSL_RND_Posn_StW 15 "SNA" 8 "D" 6 "INI" 4 "N_DOWN" 2 "N_UP" 1 "R" 0 "IDLE" ; VAL_ 109 TSL_P_Psd_StW 3 "SNA" 2 "INI" 1 "PSD" 0 "IDLE" ; VAL_ 257 GTW_epasEmergencyOn 1 "EMERGENCY_POWER" 0 "NONE" ; VAL_ 257 GTW_epasLDWEnabled 1 "ALLOWED" 0 "INHIBITED" ; VAL_ 257 GTW_epasPowerMode 0 "DRIVE_OFF" 1 "DRIVE_ON" 3 "LOAD_SHED" 2 "SHUTTING_DOWN" 15 "SNA" ; VAL_ 257 GTW_epasTuneRequest 1 "DM_COMFORT" 3 "DM_SPORT" 2 "DM_STANDARD" 0 "FAIL_SAFE_DEFAULT" 4 "RWD_COMFORT" 6 "RWD_SPORT" 5 "RWD_STANDARD" 7 "SNA" ; VAL_ 264 DI_torqueDriver -4096 "SNA" ; VAL_ 264 DI_torqueMotor -4096 "SNA" ; VAL_ 264 DI_soptState 7 "SOPT_TEST_SNA" 4 "SOPT_TEST_NOT_RUN" 3 "SOPT_TEST_PASSED" 2 "SOPT_TEST_FAILED" 1 "SOPT_TEST_IN_PROGRESS" 0 "SOPT_PRE_TEST" ; VAL_ 264 DI_motorRPM -32768 "SNA" ; VAL_ 264 DI_pedalPos 255 "SNA" ; VAL_ 280 DI_torqueEstimate -2048 "SNA" ; VAL_ 280 DI_gear 7 "DI_GEAR_SNA" 4 "DI_GEAR_D" 3 "DI_GEAR_N" 2 "DI_GEAR_R" 1 "DI_GEAR_P" 0 "DI_GEAR_INVALID" ; VAL_ 280 DI_brakePedal 1 "Applied" 0 "Not_applied" ; VAL_ 280 DI_vehicleSpeed 4095 "SNA" ; VAL_ 280 DI_gearRequest 7 "DI_GEAR_SNA" 4 "DI_GEAR_D" 3 "DI_GEAR_N" 2 "DI_GEAR_R" 1 "DI_GEAR_P" 0 "DI_GEAR_INVALID" ; VAL_ 280 DI_torqueInterfaceFailure 1 "TORQUE_INTERFACE_FAILED" 0 "TORQUE_INTERFACE_NORMAL" ; VAL_ 280 DI_brakePedalState 3 "SNA" 2 "INVALID" 1 "ON" 0 "OFF" ; VAL_ 280 DI_epbParkRequest 1 "Park_requested" 0 "No_request" ; VAL_ 280 DI_epbInterfaceReady 1 "EPB_INTERFACE_READY" 0 "EPB_INTERFACE_NOT_READY" ; VAL_ 309 ESP_absBrakeEvent 1 "ACTIVE" 0 "NOT_ACTIVE" ; VAL_ 309 ESP_brakeDiscWipingActive 1 "ACTIVE" 0 "INACTIVE" ; VAL_ 309 ESP_brakeLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_espFaultLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_espLampFlash 1 "FLASH" 0 "OFF" ; VAL_ 309 ESP_hillStartAssistActive 1 "ACTIVE" 0 "INACTIVE" 2 "NOT_AVAILABLE" 3 "SNA" ; VAL_ 309 ESP_absFaultLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_espOffLamp 0 "OFF" 1 "ON" ; VAL_ 309 ESP_stabilityControlSts 2 "ENGAGED" 3 "FAULTED" 5 "INIT" 4 "NOT_CONFIGURED" 0 "OFF" 1 "ON" ; VAL_ 309 ESP_tcLampFlash 1 "FLASH" 0 "OFF" ; VAL_ 568 UI_mapSpeedLimit 31 "SNA" 30 "UNLIMITED" 29 "LESS_OR_EQ_160" 28 "LESS_OR_EQ_150" 27 "LESS_OR_EQ_140" 26 "LESS_OR_EQ_130" 25 "LESS_OR_EQ_120" 24 "LESS_OR_EQ_115" 23 "LESS_OR_EQ_110" 22 "LESS_OR_EQ_105" 21 "LESS_OR_EQ_100" 20 "LESS_OR_EQ_95" 19 "LESS_OR_EQ_90" 18 "LESS_OR_EQ_85" 17 "LESS_OR_EQ_80" 16 "LESS_OR_EQ_75" 15 "LESS_OR_EQ_70" 14 "LESS_OR_EQ_65" 13 "LESS_OR_EQ_60" 12 "LESS_OR_EQ_55" 11 "LESS_OR_EQ_50" 10 "LESS_OR_EQ_45" 9 "LESS_OR_EQ_40" 8 "LESS_OR_EQ_35" 7 "LESS_OR_EQ_30" 6 "LESS_OR_EQ_25" 5 "LESS_OR_EQ_20" 4 "LESS_OR_EQ_15" 3 "LESS_OR_EQ_10" 2 "LESS_OR_EQ_7" 1 "LESS_OR_EQ_5" 0 "UNKNOWN" ; VAL_ 522 driverBrakeStatus 2 "APPLIED" 1 "NOT_APPLIED" ; VAL_ 760 UI_mapSpeedLimitUnits 1 "KPH" 0 "MPH" ; VAL_ 760 UI_userSpeedOffsetUnits 1 "KPH" 0 "MPH" ; VAL_ 643 AirTemp_Insd 255 "SNA" ; VAL_ 643 AirTemp_Outsd 254 "INIT" 255 "SNA" ; VAL_ 643 Bckl_Sw_RL_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; VAL_ 643 Bckl_Sw_RM_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; VAL_ 643 Bckl_Sw_RR_Stat_SAM_R 2 "FLT" 1 "NOT" 0 "OK" 3 "SNA" ; VAL_ 643 DL_RLtch_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; VAL_ 643 DrRLtch_FL_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; VAL_ 643 DrRLtch_FR_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; VAL_ 643 DrRLtch_RL_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; VAL_ 643 DrRLtch_RR_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; VAL_ 643 EngHd_Stat 1 "CLS" 0 "NDEF0" 2 "OPN" 3 "SNA" ; VAL_ 643 LgtSens_Night 0 "DAY" 1 "NIGHT" ; VAL_ 643 MPkBrk_Stat 1 "ENGG" 0 "RELS" ; VAL_ 643 RevGr_Engg 0 "DISENGG" 1 "ENGG" 2 "NDEF2" 3 "SNA" ; VAL_ 643 StW_Cond_Stat 3 "BLINK" 1 "NDEF1" 0 "OFF" 2 "ON" ; VAL_ 643 Trlr_Stat 2 "NDEF2" 0 "NONE" 1 "OK" 3 "SNA" ; VAL_ 792 BOOT_STATE 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 CERRD 1 "CAN error detect" 0 "no Can error detected" ; VAL_ 792 DAY 1 "Init" 0 "SNA" ; VAL_ 792 DOOR_STATE_FL 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 DOOR_STATE_FR 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 DOOR_STATE_FrontTrunk 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 DOOR_STATE_RL 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 DOOR_STATE_RR 2 "Init" 3 "SNA" 0 "closed" 1 "open" ; VAL_ 792 GTW_updateInProgress 1 "IN_PROGRESS" 2 "IN_PROGRESS_NOT_USED" 3 "IN_PROGRESS_SNA" 0 "NOT_IN_PROGRESS" ; VAL_ 792 Hour 30 "Init" 31 "SNA" ; VAL_ 792 MCU_factoryMode 1 "FACTORY_MODE" 0 "NORMAL_MODE" ; VAL_ 792 MCU_transportModeOn 0 "NORMAL_MODE" ; VAL_ 792 MINUTE 62 "Init" 63 "SNA" ; VAL_ 792 MONTH 1 "Init" 15 "SNA" ; VAL_ 792 SECOND 62 "Init" 63 "SNA" ; VAL_ 792 YEAR 126 "Init" 127 "SNA" ; VAL_ 872 DI_aebState 2 "ENABLED" 4 "FAULT" 7 "SNA" 1 "STANDBY" 3 "STANDSTILL" 0 "UNAVAILABLE" ; VAL_ 872 DI_analogSpeed 4095 "SNA" ; VAL_ 872 DI_cruiseState 2 "ENABLED" 5 "FAULT" 0 "OFF" 4 "OVERRIDE" 7 "PRE_CANCEL" 6 "PRE_FAULT" 1 "STANDBY" 3 "STANDSTILL" ; VAL_ 872 DI_digitalSpeed 255 "SNA" ; VAL_ 872 DI_immobilizerState 2 "AUTHENTICATING" 3 "DISARMED" 6 "FAULT" 4 "IDLE" 0 "INIT_SNA" 1 "REQUEST" 5 "RESET" ; VAL_ 872 DI_speedUnits 1 "KPH" 0 "MPH" ; VAL_ 872 DI_state 3 "ABORT" 4 "ENABLE" 2 "FAULT" 1 "STANDBY" 0 "UNAVAILABLE" ; VAL_ 872 DI_systemState 3 "ABORT" 4 "ENABLE" 2 "FAULT" 1 "STANDBY" 0 "UNAVAILABLE" ; VAL_ 872 DI_vehicleHoldState 2 "BLEND_IN" 4 "BLEND_OUT" 6 "FAULT" 7 "INIT" 5 "PARK" 1 "STANDBY" 3 "STANDSTILL" 0 "UNAVAILABLE" ; VAL_ 880 EPAS_currentTuneMode 1 "DM_COMFORT" 3 "DM_SPORT" 2 "DM_STANDARD" 0 "FAIL_SAFE_DEFAULT" 4 "RWD_COMFORT" 6 "RWD_SPORT" 5 "RWD_STANDARD" 7 "UNAVAILABLE" ; VAL_ 880 EPAS_eacErrorCode 14 "EAC_ERROR_EPB_INHIBIT" 3 "EAC_ERROR_HANDS_ON" 7 "EAC_ERROR_HIGH_ANGLE_RATE_REQ" 9 "EAC_ERROR_HIGH_ANGLE_RATE_SAFETY" 6 "EAC_ERROR_HIGH_ANGLE_REQ" 8 "EAC_ERROR_HIGH_ANGLE_SAFETY" 10 "EAC_ERROR_HIGH_MMOT_SAFETY" 11 "EAC_ERROR_HIGH_TORSION_SAFETY" 0 "EAC_ERROR_IDLE" 12 "EAC_ERROR_LOW_ASSIST" 2 "EAC_ERROR_MAX_SPEED" 1 "EAC_ERROR_MIN_SPEED" 13 "EAC_ERROR_PINION_VEL_DIFF" 4 "EAC_ERROR_TMP_FAULT" 5 "EAR_ERROR_MAX_STEER_DELTA" 15 "SNA" ; VAL_ 880 EPAS_eacStatus 2 "EAC_ACTIVE" 1 "EAC_AVAILABLE" 3 "EAC_FAULT" 0 "EAC_INHIBITED" 4 "SNA" ; VAL_ 880 EPAS_handsOnLevel 0 "0" 1 "1" 2 "2" 3 "3" ; VAL_ 880 EPAS_steeringFault 1 "FAULT" 0 "NO_FAULT" ; VAL_ 880 EPAS_steeringRackForce 1022 "NOT_IN_SPEC" 1023 "SNA" ; VAL_ 880 EPAS_steeringReduced 0 "NORMAL_ASSIST" 1 "REDUCED_ASSIST" ; VAL_ 880 EPAS_torsionBarTorque 0 "SEE_SPECIFICATION" 4095 "SNA" 4094 "UNDEFINABLE_DATA" ; VAL_ 904 MCU_clusterReadyForDrive 0 "NO_SNA" 1 "YES" ; VAL_ 921 autopilotStatus 5 "ACTIVE_NAVIGATE_ON_AUTOPILOT" 4 "ACTIVE_2" 3 "ACTIVE_1" 2 "AVAILABLE" 1 "UNAVAILABLE" 0 "DISABLED" ; VAL_ 1160 DAS_steeringAngleRequest 16384 "ZERO_ANGLE" ; VAL_ 1160 DAS_steeringControlType 1 "ANGLE_CONTROL" 3 "DISABLED" 0 "NONE" 2 "RESERVED" ; VAL_ 1160 DAS_steeringHapticRequest 1 "ACTIVE" 0 "IDLE" ; CM_ "CHFFR_METRIC 1160 DAS_steeringAngleRequest STEER_ANGLE 0.1098666 180; CHFFR_METRIC 264 DI_motorRPM ENGINE_RPM 1 0"; ================================================ FILE: opendbc/tesla_radar.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: FrontCamera Radar BO_ 769 TeslaRadarSguInfo: 8 Radar SG_ RADC_VerticalMisalignment : 0|8@1+ (1,0) [0|255] "" FrontCamera SG_ RADC_SCUTemperature : 8|8@1+ (1,-128) [-128|127] "" FrontCamera SG_ RADC_VMA_Plaus : 16|8@1+ (1,0) [0|255] "" FrontCamera SG_ RADC_SGU_ITC : 24|8@1+ (1,0) [0|255] "" FrontCamera SG_ RADC_HorizontMisalignment : 32|12@1+ (1,0) [0|4096] "" FrontCamera SG_ RADC_SensorDirty : 44|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_HWFail : 45|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_SGUFail : 46|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_SGUInfoConsistBit : 47|1@1+ (1,0) [0|1] "" FrontCamera BO_ 770 TeslaRadarTguInfo: 8 Radar SG_ RADC_ACCTargObj1_sguIndex : 0|6@1+ (1,0) [0|63] "" FrontCamera SG_ RADC_ACCTargObj2_sguIndex : 6|6@1+ (1,0) [0|63] "" FrontCamera SG_ RADC_ACCTargObj3_sguIndex : 12|6@1+ (1,0) [0|63] "" FrontCamera SG_ RADC_ACCTargObj4_sguIndex : 18|6@1+ (1,0) [0|63] "" FrontCamera SG_ RADC_ACCTargObj5_sguIndex : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ unused30 : 30|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_TGUInfoConsistBit : 31|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_ACCTargObj1_dBPower : 32|16@1+ (1,0) [0|65535] "" FrontCamera SG_ RADC_ACCTargObj5_dBPower : 48|16@1+ (1,0) [0|65535] "" FrontCamera BO_ 1281 TeslaRadarAlertMatrix: 8 Radar SG_ RADC_a001_ecuInternalPerf : 0|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a002_flashPerformance : 1|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a003_vBatHigh : 2|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a004_adjustmentNotDone : 3|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a005_adjustmentReq : 4|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a006_adjustmentNotOk : 5|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a007_sensorBlinded : 6|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a008_plantModeActive : 7|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a009_configMismatch : 8|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a010_canBusOff : 9|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a011_bdyMIA : 10|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a012_espMIA : 11|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a013_gtwMIA : 12|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a014_sccmMIA : 13|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a015_adasMIA : 14|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a016_bdyInvalidCount : 15|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a017_adasInvalidCount : 16|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a018_espInvalidCount : 17|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a019_sccmInvalidCount : 18|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a020_bdyInvalidChkSm : 19|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a021_espInvalidChkSm : 20|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a022_sccmInvalidChkSm : 21|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a023_sccmInvalidChkSm : 22|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a024_absValidity : 23|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a025_ambTValidity : 24|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a026_brakeValidity : 25|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a027_CntryCdValidity : 26|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a028_espValidity : 27|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a029_longAccOffValidity : 28|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a030_longAccValidity : 29|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a031_odoValidity : 30|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a032_gearValidity : 31|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a033_steerAngValidity : 32|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a034_steerAngSpdValidity : 33|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a035_indctrValidity : 34|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a036_vehStandStillValidity : 35|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a037_vinValidity : 36|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a038_whlRotValidity : 37|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a039_whlSpdValidity : 38|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a040_whlStandStillValidity : 39|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a041_wiperValidity : 40|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a042_xwdValidity : 41|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a043_yawOffValidity : 42|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a044_yawValidity : 43|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a045_bsdSanity : 44|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a046_rctaSanity : 45|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a047_lcwSanity : 46|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a048_steerAngOffSanity : 47|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a049_tireSizeSanity : 48|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a050_velocitySanity : 49|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a051_yawSanity : 50|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a052_radomeHtrInop : 51|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a053_espmodValidity : 52|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a054_gtwmodValidity : 53|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a055_stwmodValidity : 54|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a056_bcmodValidity : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a057_dimodValidity : 56|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a058_opmodValidity : 57|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a059_drmiInvalidChkSm : 58|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a060_drmiInvalidCount : 59|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a061_radPositionMismatch : 60|1@1+ (1,0) [0|1] "" FrontCamera SG_ RADC_a062_strRackMismatch : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ unused62 : 62|2@1+ (1,0) [0|3] "" FrontCamera BO_ 784 M_310hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 785 M_310hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 787 M_313hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 788 M_313hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 790 M_316hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 791 M_316hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 793 M_319hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 794 M_319hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 796 M_31Chex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 797 M_31Chex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 799 M_31Fhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 800 M_31Fhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 802 M_322hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 803 M_322hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 805 M_325hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 806 M_325hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 808 M_328hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 809 M_328hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 811 M_32Bhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 812 M_32Bhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 814 M_32Ehex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 815 M_32Ehex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 817 M_331hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 818 M_331hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 820 M_334hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 821 M_334hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 823 M_337hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 824 M_337hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 826 M_33Ahex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 827 M_33Ahex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 829 M_33Dhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 830 M_33Dhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 832 M_340hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 833 M_340hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 835 M_343hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 836 M_343hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 838 M_346hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 839 M_346hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 841 M_349hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 842 M_349hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 844 M_34Chex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 845 M_34Chex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 847 M_34Fhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 848 M_34Fhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 850 M_352hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 851 M_352hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 853 M_355hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 854 M_355hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 856 M_358hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 857 M_358hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 859 M_35Bhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 860 M_35Bhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 862 M_35Ehex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 863 M_35Ehex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 865 M_361hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 866 M_361hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 868 M_364hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 869 M_364hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 871 M_367hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 872 M_367hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 874 M_36Ahex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 875 M_36Ahex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 877 M_36Dhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 878 M_36Dhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 881 L_1_371hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 882 L_1_371hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 884 L_2_374hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 885 L_2_375hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 887 L_3_377hex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 888 L_3_378hex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 890 L_4_37ahex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 891 L_4_37ahex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 893 L_5_37dhex: 8 Radar SG_ LongDist : 0|12@1+ (0.0625,0) [0|255.9] "meters" FrontCamera SG_ LongSpeed : 12|12@1+ (0.0625,-128) [-128|128] "meters/sec" FrontCamera SG_ LatDist : 24|11@1+ (0.125,-128) [-128|128] "meters" FrontCamera SG_ ProbExist : 35|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ LongAccel : 40|10@1+ (0.03125,-16) [-16|16] "meters/sec/sec" FrontCamera SG_ ProbObstacle : 50|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Valid : 55|1@1+ (1,0) [0|1] "" FrontCamera SG_ ProbNonObstacle : 56|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Meas : 61|1@1+ (1,0) [0|1] "" FrontCamera SG_ Tracked : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 894 L_5_37dhex2: 8 Radar SG_ LatSpeed : 0|10@1+ (0.125,-64) [-64|64] "meters/sec" FrontCamera SG_ Length : 10|6@1+ (0.125,0) [0|7.875] "m" FrontCamera SG_ dZ : 16|6@1+ (0.25,-5) [-5|10.75] "m" FrontCamera SG_ MovingState : 22|2@1+ (1,0) [0|3] "" FrontCamera SG_ dxSigma : 24|6@1+ (1,0) [0|63] "" FrontCamera SG_ vxSigma : 30|6@1+ (1,0) [0|63] "" FrontCamera SG_ axSigma : 36|6@1+ (1,0) [0|63] "" FrontCamera SG_ dySigma : 42|6@1+ (1,0) [0|63] "" FrontCamera SG_ ProbClass : 48|5@1+ (3.125,0) [0|96.875] "%" FrontCamera SG_ Class : 53|3@1+ (1,0) [0|7] "" FrontCamera SG_ dxRearEndLoss : 56|6@1+ (1,0) [0|63] "" FrontCamera SG_ NotUsed : 62|1@1+ (1,0) [0|1] "" FrontCamera SG_ Index2 : 63|1@1+ (1,0) [0|1] "" FrontCamera BO_ 697 VIN_VIP_405HS: 8 FrontCamera SG_ VIN_MuxID M : 0|8@1+ (1,0) [0|0] "" Radar SG_ VIN_Part1 m16 : 47|24@0+ (1,0) [0|16777215] "" Radar SG_ VIN_Part2 m17 : 15|56@0+ (1,0) [0|7.2057594038E+16] "" Radar SG_ VIN_Part3 m18 : 15|56@0+ (1,0) [0|7.2057594038E+16] "" Radar BO_ 681 Msg2A9_GTW_carConfig: 8 FrontCamera SG_ Msg2A9_Always0x02 : 48|8@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_Always0x10 : 56|8@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_Always0x16 : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_Always0x41 : 24|8@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_Value1_0x02 : 0|3@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_FourWheelDrive : 3|2@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_Value2_0x02 : 5|3@1+ (1,0) [0|0] "" Radar SG_ Msg2A9_Always0x43 : 16|8@1+ (1,0) [0|0] "" Radar BO_ 409 Msg199_STW_ANGLHP_STAT: 8 FrontCamera SG_ Msg199Always0x04 : 32|8@1+ (1,0) [0|0] "" Radar SG_ Msg199Always0x20 : 16|8@1+ (1,0) [0|0] "" Radar SG_ Msg199Always0x2F : 0|8@1+ (1,0) [0|0] "" Radar SG_ Msg199Always0x67 : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg199Always0xFF : 40|8@1+ (1,0) [0|0] "" Radar SG_ Msg199Checksum : 56|8@1+ (1,0) [0|0] "" Radar SG_ Msg199Counter : 52|4@1+ (1,0) [0|0] "" Radar BO_ 361 Msg169_ESP_wheelSpeeds: 8 FrontCamera SG_ ESP_wheelSpeedFrL_HS : 0|13@1+ (0.04,0) [0|327.64] "km/h" Radar SG_ ESP_wheelSpeedFrR_HS : 13|13@1+ (0.04,0) [0|327.64] "km/h" Radar SG_ ESP_wheelSpeedReL_HS : 26|13@1+ (0.04,0) [0|327.64] "km/h" Radar SG_ ESP_wheelSpeedReR_HS : 39|13@1+ (0.04,0) [0|327.64] "km/h" Radar SG_ Msg169Checksum : 56|8@1+ (1,0) [0|0] "" Radar SG_ Msg169Counter : 52|4@1+ (1,0) [0|0] "" Radar BO_ 345 Msg159_ESP_C: 8 FrontCamera SG_ Msg159Always0x3A : 16|8@1+ (1,0) [0|0] "" Radar SG_ Msg159Always0xA5 : 0|8@1+ (1,0) [0|0] "" Radar SG_ Msg159Always0xCF : 32|8@1+ (1,0) [0|0] "" Radar SG_ Msg159Always0xF4 : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg159Counter : 44|4@1+ (1,0) [0|0] "" Radar SG_ Msg159Checksum : 24|8@1+ (1,0) [0|0] "" Radar BO_ 329 Msg149_ESP_145h: 8 FrontCamera SG_ Msg149Always0x02 : 16|8@1+ (1,0) [0|0] "" Radar SG_ Msg149Always0x04 : 40|8@1+ (1,0) [0|0] "" Radar SG_ Msg149Always0x26 : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg149Always0x6A : 24|8@1+ (1,0) [0|0] "" Radar SG_ Msg149Always0xAA : 32|8@1+ (1,0) [0|0] "" Radar SG_ Msg149Always0xF : 48|4@1+ (1,0) [0|0] "" Radar SG_ Msg149Checksum : 56|8@1+ (1,0) [0|0] "" Radar SG_ Msg149Counter : 52|4@1+ (1,0) [0|0] "" Radar BO_ 297 Msg129_ESP_115h: 6 FrontCamera SG_ Msg129Always0x20 : 24|8@1+ (1,0) [0|0] "" Radar SG_ Msg129Checksum : 40|8@1+ (1,0) [0|0] "" Radar SG_ Msg129Counter : 36|4@1+ (1,0) [0|0] "" Radar BO_ 281 Msg119_DI_torque2: 6 FrontCamera SG_ Msg119Always0x11 : 24|8@1+ (1,0) [0|0] "" Radar SG_ Msg119Always0x1F : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg119Always0x8 : 36|4@1+ (1,0) [0|0] "" Radar SG_ Msg119Always0xF4 : 16|8@1+ (1,0) [0|0] "" Radar SG_ Msg119Always0xFF : 0|8@1+ (1,0) [0|0] "" Radar SG_ Msg119Checksum : 40|8@1+ (1,0) [0|0] "" Radar SG_ Msg119Counter : 32|4@1+ (1,0) [0|0] "" Radar BO_ 265 Msg109_DI_torque1: 8 FrontCamera SG_ Msg109Always0x80 : 24|8@1+ (1,0) [0|0] "" Radar SG_ Msg109Checksum : 56|8@1+ (1,0) [0|0] "" Radar SG_ Msg109Counter : 13|3@1+ (1,0) [0|0] "" Radar BO_ 521 Msg209_GTW_odo: 8 FrontCamera SG_ Msg209Always0x61 : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg209Always0x94 : 16|8@1+ (1,0) [0|0] "" Radar SG_ Msg209Always0x52 : 24|8@1+ (1,0) [0|0] "" Radar SG_ Msg209Always0x13 : 32|8@1+ (1,0) [0|0] "" Radar SG_ Msg209Always0x03 : 40|8@1+ (1,0) [0|0] "" Radar SG_ Msg209Always0x80 : 48|8@1+ (1,0) [0|0] "" Radar BO_ 537 Msg219_STW_ACTN_RQ: 8 FrontCamera SG_ Msg219Counter : 52|4@1+ (1,0) [0|15] "" Radar SG_ Msg219CRC : 56|8@1+ (1,0) [0|0] "" Radar BO_ 425 Msg1A9_DI_espControl: 5 FrontCamera SG_ Msg1A9Always0x0C : 16|8@1+ (1,0) [0|0] "" Radar SG_ Msg1A9Counter : 28|4@1+ (1,0) [0|0] "" Radar SG_ Msg1A9Checksum : 32|8@1+ (1,0) [0|0] "" Radar BO_ 729 Msg2D9_BC_status : 8 FrontCamera SG_ Msg2D9Always0x80 : 0|8@1+ (1,0) [0|0] "" Radar SG_ Msg2D9Always0x40 : 8|8@1+ (1,0) [0|0] "" Radar SG_ Msg2D9Always0x83 : 16|8@1+ (1,0) [0|0] "" Radar BO_ 1601 UDS_radarRequest: 8 FrontCamera SG_ UDS_radarRequestData : 7|64@0+ (1,0) [0|0] "" Radar BO_ 1617 Radar_udsResponse: 8 Radar SG_ Radar_udsResponseData : 7|64@0+ (1,0) [0|0] "" FrontCamera CM_ BO_ 697 "Start with MuxID 0x12, then 0x11 and finally 0x10 (VIN is then transmitted in the reverse order)"; CM_ BO_ 681 "Message sent every 1000 ms. All fixed bytes, no checksum, the byte for RWD or AWD needs to match VIN config"; CM_ BO_ 409 "Message sent every 10ms. Checksum : use all first 7 bytes with the SAE J1850 CRC algo"; CM_ BO_ 361 "Message sent every 10ms. Checksum : Sum of all first 7 bytes + 0x76"; CM_ BO_ 345 "Message sent every 20ms. Checksum : Sum of all first bytes + 0xc; place checksum in 4th octet"; CM_ BO_ 329 "Message sent every 20ms. Checksum : Sum of all first 7 bytes + 0x46"; CM_ BO_ 297 "Message sent every 20ms. Checksum : Sum of all first 5 bytes + 0x16"; CM_ BO_ 281 "Message sent every 10ms. Checksum : Sum of all first 5 bytes + 0x17"; CM_ BO_ 265 "Message sent every 10ms. Checksum : Sum of all first 7 bytes + 0x7"; CM_ BO_ 521 "Message sent every 100ms. All fixed bytes, no checksum."; CM_ BO_ 537 "Message sent every 100ms. Checksum : use all first 7 bytes with the SAE J1850 CRC algo"; CM_ BO_ 425 "Message sent every 20ms. Checksum : Sum of all first 4 bytes + 0x38"; CM_ BO_ 729 "Message sent every 1000ms. All fixed bytes, no checksum."; BA_DEF_ "BusType" STRING ; BA_DEF_ BO_ "GenMsgCycleTime" INT 0 0; BA_DEF_ SG_ "FieldType" STRING ; BA_DEF_DEF_ "BusType" "CAN"; BA_DEF_DEF_ "FieldType" ""; BA_DEF_DEF_ "GenMsgCycleTime" 0; BA_ "GenMsgCycleTime" BO_ 697 250; BA_ "GenMsgCycleTime" BO_ 681 1000; BA_ "GenMsgCycleTime" BO_ 409 10; BA_ "GenMsgCycleTime" BO_ 361 10; BA_ "GenMsgCycleTime" BO_ 345 20; BA_ "GenMsgCycleTime" BO_ 329 20; BA_ "GenMsgCycleTime" BO_ 297 20; BA_ "GenMsgCycleTime" BO_ 281 10; BA_ "GenMsgCycleTime" BO_ 265 10; BA_ "GenMsgCycleTime" BO_ 521 100; BA_ "GenMsgCycleTime" BO_ 537 100; BA_ "GenMsgCycleTime" BO_ 425 20; BA_ "GenMsgCycleTime" BO_ 729 1000; VAL_ 681 Msg2A9_FourWheelDrive 3 "SNA" 2 "UNUSED" 1 "4WD" 0 "2WD" ; VAL_ 785 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 785 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 788 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 788 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 791 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 791 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 794 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 794 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 797 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 797 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 800 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 800 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 803 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 803 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 806 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 806 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 809 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 809 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 812 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 812 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 815 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 815 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 818 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 818 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 821 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 821 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 824 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 824 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 827 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 827 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 830 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 830 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 833 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 833 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 836 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 836 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 839 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 839 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 842 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 842 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 845 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 845 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 848 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 848 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 851 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 851 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 854 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 854 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 857 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 857 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 860 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 860 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 863 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 863 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 866 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 866 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 869 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 869 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 872 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 872 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 875 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 875 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 878 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 878 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 882 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 882 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 885 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 885 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 888 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 888 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 891 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 891 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; VAL_ 894 MovingState 3 "RADAR_MOVESTATE_STANDING" 2 "RADAR_MOVESTATE_STOPPED" 1 "RADAR_MOVESTATE_MOVING" 0 "RADAR_MOVESTATE_INDETERMINATE" ; VAL_ 894 Class 4 "RADAR_CLASS_CONSTRUCTION_ELEMENT" 3 "RADAR_CLASS_MOVING_PEDESTRIAN" 2 "RADAR_CLASS_MOVING_TWO_WHEEL_VEHICLE" 1 "RADAR_CLASS_MOVING_FOUR_WHEEL_VEHICLE" 0 "RADAR_CLASS_UNKNOWN" ; ================================================ FILE: opendbc/toyota_adas.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 528 TRACK_A_0: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 529 TRACK_A_1: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 530 TRACK_A_2: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 531 TRACK_A_3: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 532 TRACK_A_4: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 533 TRACK_A_5: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 534 TRACK_A_6: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 535 TRACK_A_7: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 536 TRACK_A_8: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 537 TRACK_A_9: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 538 TRACK_A_10: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 539 TRACK_A_11: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 540 TRACK_A_12: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 541 TRACK_A_13: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 542 TRACK_A_14: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 543 TRACK_A_15: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 544 TRACK_B_0: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 545 TRACK_B_1: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 546 TRACK_B_2: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 547 TRACK_B_3: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 548 TRACK_B_4: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 549 TRACK_B_5: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 550 TRACK_B_6: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 551 TRACK_B_7: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 TRACK_B_8: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 553 TRACK_B_9: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 554 TRACK_B_10: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 555 TRACK_B_11: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 556 TRACK_B_12: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 557 TRACK_B_13: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 558 TRACK_B_14: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX BO_ 559 TRACK_B_15: 6 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX ================================================ FILE: opendbc/toyota_avalon_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_avalon_2017_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|255] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|65535] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|3] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_camry_hybrid_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_camry_hybrid_2018_pt.dbc starts here"; BO_ 295 GEAR_PACKET: 8 XXX SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 8 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_corolla_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_corolla_2017_pt.dbc starts here"; BO_ 548 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 43|12@0+ (1,0) [0|4047] "" XXX SG_ BRAKE_PRESSED : 5|1@0+ (1,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.88,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ SPORT_ON : 3|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_highlander_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_highlander_2017_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|255] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|65535] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|3] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_highlander_hybrid_2018_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; ================================================ FILE: opendbc/toyota_nodsu_hybrid_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX BO_ 956 GEAR_PACKET2: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ SPORT_GEAR_ON : 33|1@0+ (1,0) [0|1] "" XXX SG_ SPORT_GEAR : 38|3@0+ (1,0) [0|7] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_ENGAGED : 47|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 36 "speed sign mph" 1 "speed sign kph" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 6 "snow" 5 "rain" 4 "wet road" 5 "rain" 3 "left" 2 "right" 1 "time" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "Imported file _toyota_nodsu_common.dbc starts here"; BO_ 401 STEERING_LTA: 8 XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ SETME_X3 : 29|2@0+ (1,0) [0|3] "" XXX SG_ PERCENTAGE : 39|8@0+ (1,0) [0|255] "" XXX SG_ SETME_X64 : 47|8@0+ (1,0) [0|255] "" XXX SG_ ANGLE : 55|8@0- (0.5,0) [0|255] "" XXX SG_ STEER_ANGLE_CMD : 15|16@0- (0.0573,0) [-540|540] "" XXX SG_ STEER_REQUEST : 25|1@0+ (1,0) [0|1] "" XXX SG_ BIT : 30|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST_2 : 0|1@0+ (1,0) [0|1] "" XXX SG_ SETME_X1 : 7|1@0+ (1,0) [0|1] "" XXX BO_ 1014 BSM: 8 XXX SG_ L_ADJACENT : 0|1@0+ (1,0) [0|1] "" XXX SG_ L_APPROACHING : 8|1@0+ (1,0) [0|1] "" XXX SG_ R_ADJACENT : 1|1@0+ (1,0) [0|1] "" XXX SG_ R_APPROACHING : 10|1@0+ (1,0) [0|1] "" XXX SG_ ADJACENT_ENABLED : 7|1@0+ (1,0) [0|1] "" XXX SG_ APPROACHING_ENABLED : 15|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 1014 L_ADJACENT "vehicle adjacent left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 L_APPROACHING "vehicle approaching from left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 R_ADJACENT "vehicle adjacent right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 R_APPROACHING "vehicle approaching from right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 ADJACENT_ENABLED "when BSM is enabled in settings, this is on along with APPROACHING_ENABLED. this controls bsm alert visibility"; CM_ SG_ 1014 APPROACHING_ENABLED "when BSM is enabled in settings, this is on along with ADJACENT_ENABLED. this controls bsm alert visibility"; CM_ "toyota_nodsu_hybrid_pt.dbc starts here"; BO_ 295 GEAR_PACKET: 8 XXX SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 8 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_nodsu_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "Imported file _toyota_nodsu_common.dbc starts here"; BO_ 401 STEERING_LTA: 8 XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ SETME_X3 : 29|2@0+ (1,0) [0|3] "" XXX SG_ PERCENTAGE : 39|8@0+ (1,0) [0|255] "" XXX SG_ SETME_X64 : 47|8@0+ (1,0) [0|255] "" XXX SG_ ANGLE : 55|8@0- (0.5,0) [0|255] "" XXX SG_ STEER_ANGLE_CMD : 15|16@0- (0.0573,0) [-540|540] "" XXX SG_ STEER_REQUEST : 25|1@0+ (1,0) [0|1] "" XXX SG_ BIT : 30|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST_2 : 0|1@0+ (1,0) [0|1] "" XXX SG_ SETME_X1 : 7|1@0+ (1,0) [0|1] "" XXX BO_ 1014 BSM: 8 XXX SG_ L_ADJACENT : 0|1@0+ (1,0) [0|1] "" XXX SG_ L_APPROACHING : 8|1@0+ (1,0) [0|1] "" XXX SG_ R_ADJACENT : 1|1@0+ (1,0) [0|1] "" XXX SG_ R_APPROACHING : 10|1@0+ (1,0) [0|1] "" XXX SG_ ADJACENT_ENABLED : 7|1@0+ (1,0) [0|1] "" XXX SG_ APPROACHING_ENABLED : 15|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 1014 L_ADJACENT "vehicle adjacent left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 L_APPROACHING "vehicle approaching from left side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 R_ADJACENT "vehicle adjacent right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 R_APPROACHING "vehicle approaching from right side of car. enabled above 10mph, regardless of ADJACENT_ENABLED or APPROACHING_ENABLED"; CM_ SG_ 1014 ADJACENT_ENABLED "when BSM is enabled in settings, this is on along with APPROACHING_ENABLED. this controls bsm alert visibility"; CM_ SG_ 1014 APPROACHING_ENABLED "when BSM is enabled in settings, this is on along with ADJACENT_ENABLED. this controls bsm alert visibility"; CM_ "toyota_nodsu_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX SG_ SPORT_ON_2 : 55|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; VAL_ 956 SPORT_ON_2 0 "off" 1 "on"; ================================================ FILE: opendbc/toyota_prius_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_prius_2017_pt.dbc starts here"; BO_ 295 GEAR_PACKET: 8 XXX SG_ CAR_MOVEMENT : 39|8@0- (1,0) [0|255] "" XXX SG_ COUNTER : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ GEAR : 47|4@0+ (1,0) [0|15] "" XXX BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 8 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.66,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 8 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 1083 AUTOPARK_STATUS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; CM_ SG_ 1083 STATE "when the dashboard button is pressed, the value changes from zero to non-zero"; VAL_ 295 GEAR 0 "P" 1 "R" 2 "N" 3 "D" 4 "B"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_prius_alpha_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_prius_alpha_2017_pt_generated.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 ECON_ON 0 "off" 1 "on"; ================================================ FILE: opendbc/toyota_rav4_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_rav4_2017_pt.dbc starts here"; BO_ 548 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 43|12@0+ (1,0) [0|4047] "" XXX SG_ BRAKE_PRESSED : 5|1@0+ (1,0) [0|1] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; ================================================ FILE: opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_rav4_hybrid_2017_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|511] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|1] "" XXX BO_ 581 GAS_PEDAL: 5 XXX SG_ GAS_PEDAL : 23|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ SPORT_ON : 2|1@0+ (1,0) [0|1] "" XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX SG_ SPORT_GEAR_ON : 33|1@0+ (1,0) [0|1] "" XXX SG_ SPORT_GEAR : 38|3@0+ (1,0) [0|7] "" XXX SG_ ECON_ON : 40|1@0+ (1,0) [0|1] "" XXX SG_ DRIVE_ENGAGED : 47|1@0+ (1,0) [0|1] "" XXX CM_ SG_ 550 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 550 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 581 GAS_PEDAL "it seems slightly filtered"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby"; VAL_ 956 SPORT_ON 0 "off" 1 "on"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 956 SPORT_GEAR_ON 0 "off" 1 "on"; VAL_ 956 SPORT_GEAR 1 "S1" 2 "S2" 3 "S3" 4 "S4" 5 "S5" 6 "S6"; VAL_ 956 ECON_ON 0 "off" 1 "on"; VAL_ 956 DRIVE_ENGAGED 0 "off" 1 "on"; ================================================ FILE: opendbc/toyota_sienna_xle_2018_pt_generated.dbc ================================================ CM_ "AUTOGENERATED FILE, DO NOT EDIT"; CM_ "Imported file _toyota_2017.dbc starts here"; VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX DSU HCU EPS IPAS CGW BO_ 36 KINEMATICS: 8 XXX SG_ ACCEL_Y : 33|10@0+ (0.03589,-18.375) [0|65535] "m/s^2" XXX SG_ YAW_RATE : 1|10@0+ (0.244,-125) [0|65535] "deg/sec" XXX SG_ STEERING_TORQUE : 17|10@0+ (1,-512) [0|65535] "" XXX BO_ 37 STEER_ANGLE_SENSOR: 8 XXX SG_ STEER_ANGLE : 3|12@0- (1.5,0) [-500|500] "deg" XXX SG_ STEER_FRACTION : 39|4@0- (0.1,0) [-0.7|0.7] "deg" XXX SG_ STEER_RATE : 35|12@0- (1,0) [-2000|2000] "deg/s" XXX BO_ 166 BRAKE: 8 XXX SG_ BRAKE_AMOUNT : 7|8@0+ (1,0) [0|255] "" XXX SG_ BRAKE_PEDAL : 23|8@0+ (1,0) [0|255] "" XXX BO_ 170 WHEEL_SPEEDS: 8 XXX SG_ WHEEL_SPEED_FR : 7|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_FL : 23|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RR : 39|16@0+ (0.01,-67.67) [0|250] "kph" XXX SG_ WHEEL_SPEED_RL : 55|16@0+ (0.01,-67.67) [0|250] "kph" XXX BO_ 180 SPEED: 8 XXX SG_ ENCODER : 39|8@0+ (1,0) [0|255] "" XXX SG_ SPEED : 47|16@0+ (0.01,0) [0|250] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 353 DSU_SPEED: 7 XXX SG_ FORWARD_SPEED : 15|16@0- (0.00390625,-30) [0|255] "kph" XXX BO_ 452 ENGINE_RPM: 8 CGW SG_ RPM : 7|16@0- (0.78125,0) [0|0] "rpm" SCS BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_ACTIVE : 5|1@0+ (1,0) [0|1] "" XXX SG_ STANDSTILL_ON : 12|1@0+ (1,0) [0|1] "" XXX SG_ ACCEL_NET : 23|16@0- (0.001,0) [-20|20] "m/s2" XXX SG_ CRUISE_STATE : 55|4@0+ (1,0) [0|15] "" XXX SG_ CANCEL_REQ : 49|1@1+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 467 PCM_CRUISE_2: 8 XXX SG_ MAIN_ON : 15|1@0+ (1,0) [0|1] "" XXX SG_ LOW_SPEED_LOCKOUT : 14|2@0+ (1,0) [0|3] "kph" XXX SG_ SET_SPEED : 23|8@0+ (1,0) [0|255] "kph" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX SG_ ACCEL_X : 6|15@0- (0.001,0) [-20|20] "m/s2" XXX BO_ 560 BRAKE_MODULE2: 7 XXX SG_ BRAKE_PRESSED : 26|1@0+ (1,0) [0|1] "" XXX BO_ 614 STEERING_IPAS: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 643 PRE_COLLISION: 7 DSU SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 15|8@0+ (1,0) [0|255] "" XXX SG_ FORCE : 23|16@0- (2,0) [0|255] "N" XXX SG_ SET_ME_X002 : 33|8@0+ (1,0) [0|3] "" XXX SG_ BRAKE_STATUS : 39|3@0+ (1,0) [0|255] "" XXX SG_ STATE : 36|3@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X003 : 40|1@0+ (1,0) [0|1] "" XXX SG_ PRECOLLISION_ACTIVE : 41|1@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 55|8@0+ (1,0) [0|255] "" XXX BO_ 740 STEERING_LKA: 5 XXX SG_ LKA_STATE : 31|8@0+ (1,0) [0|255] "" XXX SG_ STEER_REQUEST : 0|1@0+ (1,0) [0|1] "" XXX SG_ COUNTER : 6|6@0+ (1,0) [0|63] "" XXX SG_ SET_ME_1 : 7|1@0+ (1,0) [0|1] "" XXX SG_ STEER_TORQUE_CMD : 15|16@0- (1,0) [0|65535] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 742 LEAD_INFO: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" HCU SG_ LEAD_REL_SPEED : 23|12@0- (0.025,0) [-100|100] "m/s" HCU SG_ LEAD_LONG_DIST : 7|13@0+ (0.05,0) [0|300] "m" HCU BO_ 835 ACC_CONTROL: 8 DSU SG_ ACCEL_CMD : 7|16@0- (0.001,0) [-20|20] "m/s2" HCU SG_ ACC_TYPE : 23|2@0+ (1,0) [0|3] "" HCU SG_ DISTANCE : 20|1@0+ (1,0) [0|1] "" XXX SG_ MINI_CAR : 21|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X3 : 19|4@0+ (1,0) [0|15] "" XXX SG_ PERMIT_BRAKING : 30|1@0+ (1,0) [0|1] "" HCU SG_ RELEASE_STANDSTILL : 31|1@0+ (1,0) [0|1] "" HCU SG_ CANCEL_REQ : 24|1@0+ (1,0) [0|1] "" HCU SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ ACCEL_CMD_ALT : 47|8@0- (0.05,0) [0|0] "m/s^2" XXX BO_ 836 PRE_COLLISION_2: 8 DSU SG_ CHECKSUM : 63|8@0+ (1,0) [0|0] "" XXX BO_ 869 DSU_CRUISE : 7 DSU SG_ RES_BTN : 3|1@0+ (1,0) [0|0] "" XXX SG_ SET_BTN : 2|1@0+ (1,0) [0|0] "" XXX SG_ CANCEL_BTN : 1|1@0+ (1,0) [0|0] "" XXX SG_ MAIN_ON : 0|1@0+ (1,0) [0|0] "" XXX SG_ SET_SPEED : 15|8@0+ (1,0) [0|0] "km/h" XXX SG_ CRUISE_REQUEST : 31|8@0+ (100,-12800) [0|0] "N" XXX SG_ LEAD_DISTANCE : 39|8@0+ (1,0) [0|0] "m" XXX BO_ 921 PCM_CRUISE_SM: 8 XXX SG_ MAIN_ON : 4|1@0+ (1,0) [0|1] "" XXX SG_ CRUISE_CONTROL_STATE : 11|4@0+ (1,0) [0|15] "" XXX SG_ DISTANCE_LINES : 14|2@0+ (1,0) [0|3] "" XXX SG_ UI_SET_SPEED : 31|8@0+ (1,0) [0|255] "" XXX BO_ 951 ESP_CONTROL: 8 ESP SG_ TC_DISABLED : 13|1@0+ (1,0) [0|1] "" XXX SG_ VSC_DISABLED : 12|2@0+ (1,0) [0|1] "" XXX SG_ BRAKE_LIGHTS_ACC : 18|1@0+ (1,0) [0|1] "" XXX BO_ 1020 SOLAR_SENSOR: 8 XXX SG_ LUX_SENSOR : 55|13@0+ (1,0) [0|0] "" XXX BO_ 1041 ACC_HUD: 8 DSU SG_ FCW : 4|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X20 : 15|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X10 : 39|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X80 : 55|8@0+ (1,0) [0|1] "" XXX BO_ 1042 LKAS_HUD: 8 XXX SG_ BARRIERS : 1|2@0+ (1,0) [0|3] "" XXX SG_ RIGHT_LINE : 3|2@0+ (1,0) [0|3] "" XXX SG_ LEFT_LINE : 5|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01 : 7|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X01_2 : 11|2@0+ (1,0) [0|3] "" XXX SG_ LDA_ALERT : 9|2@0+ (1,0) [0|3] "" XXX SG_ TWO_BEEPS : 12|1@0+ (1,0) [0|1] "" XXX SG_ ADJUSTING_CAMERA : 13|1@0+ (1,0) [0|1] "" XXX SG_ LDA_MALFUNCTION : 15|1@0+ (1,0) [0|1] "" XXX SG_ REPEATED_BEEPS : 32|1@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X0C : 23|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X2C : 47|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X38 : 55|8@0+ (1,0) [0|1] "" XXX SG_ SET_ME_X02 : 63|8@0+ (1,0) [0|1] "" XXX BO_ 1043 TIME : 8 CGW SG_ YEAR : 7|8@0+ (1,0) [0|0] "year" XXX SG_ MONTH : 15|8@0+ (1,0) [0|0] "month" XXX SG_ DAY : 23|8@0+ (1,0) [0|0] "day" XXX SG_ HOUR : 31|8@0+ (1,0) [0|0] "hour" XXX SG_ MINUTE : 39|8@0+ (1,0) [0|0] "minute" XXX SG_ GMT_DIFF : 55|1@0+ (1,0) [0|0] "" XXX SG_ GMTDIFF_HOURS : 54|4@0+ (1,0) [0|0] "hours" XXX SG_ GMTDIFF_MINUTES : 50|6@0+ (1,0) [0|0] "minutes" XXX SG_ SUMMER : 60|1@0+ (1,0) [0|0] "" XXX BO_ 1408 VIN_PART_1: 8 CGW SG_ VIN_1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_2 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_3 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_4 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_5 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_6 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_7 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_8 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1409 VIN_PART_2: 8 CGW SG_ VIN_9 : 7|8@0+ (1,0) [0|0] "" XXX SG_ VIN_10 : 15|8@0+ (1,0) [0|0] "" XXX SG_ VIN_11 : 23|8@0+ (1,0) [0|0] "" XXX SG_ VIN_12 : 31|8@0+ (1,0) [0|0] "" XXX SG_ VIN_13 : 39|8@0+ (1,0) [0|0] "" XXX SG_ VIN_14 : 47|8@0+ (1,0) [0|0] "" XXX SG_ VIN_15 : 55|8@0+ (1,0) [0|0] "" XXX SG_ VIN_16 : 63|8@0+ (1,0) [0|0] "" XXX BO_ 1410 VIN_PART_3: 8 CGW SG_ VIN_17 : 7|8@0+ (1,0) [0|0] "" XXX BO_ 1553 UI_SETTING: 8 XXX SG_ UNITS : 26|2@0+ (1,0) [0|3] "" XXX SG_ ODOMETER : 43|20@0+ (1,0) [0|1048575] "" XXX BO_ 1556 STEERING_LEVERS: 8 XXX SG_ TURN_SIGNALS : 29|2@0+ (1,0) [0|3] "" XXX SG_ HAZARD_LIGHT : 27|1@0+ (1,0) [0|1] "" XXX BO_ 1568 SEATS_DOORS: 8 XXX SG_ METER_DIMMED : 38|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_BRAKE : 60|1@0+ (1,0) [0|1] "" XXX SG_ SEATBELT_DRIVER_UNLATCHED : 62|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FL : 45|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RL : 42|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_RR : 43|1@0+ (1,0) [0|1] "" XXX SG_ DOOR_OPEN_FR : 44|1@0+ (1,0) [0|1] "" XXX BO_ 1570 LIGHT_STALK: 8 SCM SG_ AUTO_HIGH_BEAM : 37|1@0+ (1,0) [0|1] "" XXX SG_ FRONT_FOG : 27|1@0+ (1,0) [0|1] "" XXX SG_ PARKING_LIGHT : 28|1@0+ (1,0) [0|1] "" XXX SG_ LOW_BEAM : 29|1@0+ (1,0) [0|1] "" XXX SG_ HIGH_BEAM : 30|1@0+ (1,0) [0|1] "" XXX SG_ DAYTIME_RUNNING_LIGHT : 31|1@0+ (1,0) [0|1] "" XXX BO_ 1161 RSA1: 8 FCM SG_ TSGN1 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY1 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT1 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL1 : 23|8@0+ (1,0) [0|0] "kph" XXX SG_ SPLSGN1 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN2 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN2 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY2 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT2 : 41|2@0+ (1,0) [0|0] "" XXX SG_ SPDVAL2 : 55|8@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_P : 63|2@0+ (1,0) [0|0] "" XXX SG_ BZRRQ_A : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID1 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1162 RSA2: 8 FCM SG_ TSGN3 : 7|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY3 : 12|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT3 : 9|2@0+ (1,0) [0|0] "" XXX SG_ SPLSGN3 : 31|4@0+ (1,0) [0|0] "" XXX SG_ SPLSGN4 : 27|4@0+ (1,0) [0|0] "" XXX SG_ TSGN4 : 39|8@0+ (1,0) [0|0] "" XXX SG_ TSGNGRY4 : 44|3@0+ (1,0) [0|0] "" XXX SG_ TSGNHLT4 : 41|2@0+ (1,0) [0|0] "" XXX SG_ DPSGNREQ : 54|1@0+ (1,0) [0|0] "" XXX SG_ SGNNUMP : 53|3@0+ (1,0) [0|0] "" XXX SG_ SGNNUMA : 50|3@0+ (1,0) [0|0] "" XXX SG_ SPDUNT : 63|2@0+ (1,0) [0|0] "" XXX SG_ TSRWMSG : 61|2@0+ (1,0) [0|0] "" XXX SG_ SYNCID2 : 59|4@0+ (1,0) [0|0] "" XXX BO_ 1163 RSA3: 8 FCM SG_ TSREQPD : 7|1@0+ (1,0) [0|0] "" XXX SG_ TSRMSW : 6|1@0+ (1,0) [0|0] "" XXX SG_ OTSGNNTM : 5|2@0+ (1,0) [0|0] "" XXX SG_ NTLVLSPD : 3|2@0+ (1,0) [0|0] "" XXX SG_ OVSPNTM : 1|2@0+ (1,0) [0|0] "" XXX SG_ OVSPVALL : 11|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALM : 19|4@0+ (1,-5) [0|0] "" XXX SG_ OVSPVALH : 27|4@0+ (1,-5) [0|0] "" XXX SG_ TSRSPU : 33|2@0+ (1,0) [0|0] "" XXX BO_ 1571 CENTRAL_GATEWAY_UNIT: 8 CGW SG_ DOOR_LOCK_FEEDBACK_LIGHT : 15|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_LOCKING_FEEDBACK_LIGHT : 61|1@0+ (1,0) [0|0] "" XXX SG_ KEYFOB_UNLOCKING_FEEDBACK_LIGHT : 62|1@0+ (1,0) [0|0] "" XXX CM_ SG_ 36 ACCEL_Y "unit is tbd"; CM_ SG_ 36 YAW_RATE "verify"; CM_ SG_ 36 STEERING_TORQUE "does not seem the steer torque, tbd"; CM_ SG_ 37 STEER_FRACTION "1/15th of the signal STEER_ANGLE, which is 1.5 deg; note that 0x8 is never set"; CM_ SG_ 37 STEER_RATE "factor is tbd"; CM_ SG_ 466 ACCEL_NET "net acceleration produced by the system, given ACCEL_CMD, road grade and other factors"; CM_ SG_ 466 CRUISE_STATE "Active state is 8, if standstill is requested will switch to state 11(3 sec timer), after timer is elapsed will switch into state 7(standstill). If plus button was pressed - status 9, minus button pressed - status 10"; CM_ SG_ 467 SET_SPEED "43 kph are shown as 28mph, so conversion isn't perfect"; CM_ SG_ 467 LOW_SPEED_LOCKOUT "in low speed lockout, system would always disengage below 28mph"; CM_ SG_ 560 BRAKE_PRESSED "another brake pressed?"; CM_ SG_ 608 STEER_TORQUE_DRIVER "driver torque"; CM_ SG_ 608 STEER_OVERRIDE "set when driver torque exceeds a certain value"; CM_ SG_ 614 ANGLE "set to measured angle when ipas control isn't active"; CM_ SG_ 643 COUNTER "only used on cars that use this msg for cruise control"; CM_ SG_ 643 BRAKE_STATUS "only used on cars that use this msg for cruise control"; CM_ SG_ 643 PRECOLLISION_ACTIVE "set 0.5s before any braking"; CM_ SG_ 835 ACC_TYPE "if 2, car is likely to have a permanent low speed lockout. 1 is ok"; CM_ SG_ 835 PERMIT_BRAKING "Original ACC has this going high when a car in front is detected. In openpilot and before the PERMIT_BRAKING name, this was 'SET_ME_1' and is hardcoded to be high. Unsure if only informational or has an effect though existing usage in openpilot is to always set it to 1. Originally 'PMTBRKG' in the leaked toyota_2017_ref_pt.dbc file and name expansion speculated to be PerMiT BRaKinG."; CM_ SG_ 835 ACCEL_CMD_ALT "Copy of main ACCEL_CMD, but across 8 bits instead of 16 bits like ACCEL_CMD. Unsure if only informational or has an effect. Likely informational as existing openpilot sets this to 0 and no loss of functionality observed. Originally 'AT_RAW' in leaked toyota_2017_ref_pt.dbc file."; CM_ SG_ 921 UI_SET_SPEED "set speed shown in UI with user set unit"; CM_ SG_ 951 BRAKE_LIGHTS_ACC "brake lights when ACC commands decel"; CM_ SG_ 1042 SET_ME_1 "unclear what this is, but it's always 1 in drive traces"; CM_ SG_ 1042 REPEATED_BEEPS "recommended for fcw and other important alerts"; CM_ SG_ 1161 SPDVAL1 "Numbers 0-199 is displayed, 200-254 displays circle without number and 255 is for no limit."; CM_ SG_ 1161 SYNCID1 "counter from 1 to f at 1 Hz"; CM_ SG_ 1161 SPDVAL2 "conditional speed value 70"; CM_ SG_ 1162 SGNNUMP "1 if SPDVAL1 is set, otherwise 0"; CM_ SG_ 1162 SYNCID2 "counter from 1 to f at 1 Hz"; CM_ SG_ 1163 TSREQPD "always 1"; CM_ SG_ 1163 TSRMSW "always 1"; CM_ SG_ 1163 OTSGNNTM "always 3"; CM_ SG_ 1163 NTLVLSPD "always 3"; CM_ SG_ 1163 OVSPNTM "always 3"; CM_ SG_ 1163 OVSPVALL "-5 at start then 2 after 2 seconds"; CM_ SG_ 1163 OVSPVALM "-5 at start then 5 after 2 seconds"; CM_ SG_ 1163 OVSPVALH "-5 at start then 10 after 2 seconds"; CM_ SG_ 1163 TSRSPU "always 1"; CM_ SG_ 1553 ODOMETER "Unit is dependent upon units signal"; VAL_ 466 CRUISE_STATE 11 "timer_3sec" 10 "adaptive click down" 9 "adaptive click up" 8 "adaptive engaged" 7 "standstill" 6 "non-adaptive click up" 5 "non-adaptive click down" 4 "non-adaptive hold down" 3 "non-adaptive hold up" 2 "non-adaptive being engaged" 1 "non-adaptive engaged" 0 "off"; VAL_ 467 LOW_SPEED_LOCKOUT 2 "low speed locked" 1 "ok"; VAL_ 614 STATE 3 "enabled" 1 "disabled"; VAL_ 614 DIRECTION_CMD 3 "right" 2 "center" 1 "left"; VAL_ 643 STATE 0 "normal" 1 "adaptive_cruise_control" 3 "emergency_braking"; VAL_ 835 ACC_TYPE 2 "permanent low speed lockout" 1 "ok"; VAL_ 921 CRUISE_CONTROL_STATE 2 "disabled" 11 "hold" 10 "hold_waiting_user_cmd" 6 "enabled" 5 "faulted"; VAL_ 1042 LDA_ALERT 3 "hold with continuous beep" 2 "LDA unavailable" 1 "hold" 0 "none"; VAL_ 1042 BARRIERS 3 "both" 2 "right" 1 "left" 0 "none"; VAL_ 1042 RIGHT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1042 LEFT_LINE 3 "orange" 2 "faded" 1 "solid" 0 "none"; VAL_ 1553 UNITS 1 "km" 2 "miles"; VAL_ 1556 TURN_SIGNALS 3 "none" 2 "right" 1 "left"; VAL_ 1161 TSGN1 1 "speed sign" 0 "none"; VAL_ 1161 TSGN2 1 "speed sign" 0 "none"; VAL_ 1161 SPLSGN2 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; VAL_ 1162 TSGN3 0 "none" 1 "speed sign" 2 "0 unlimited" 7 "unlimited" 16 "highway" 17 "no highway" 18 "motorway" 19 "no motorway" 20 "in city" 21 "outside city" 22 "pedestrian area" 23 "no pedestrian area" 65 "no overtaking left" 66 "no overtaking right" 67 "overtaking allowed again" 81 "no right turn" 97 "stop" 105 "yield" 113 "stop" 114 "yield us" 129 "no entry" 138 "no entry tss2" 145 "do not enter"; VAL_ 1162 SPLSGN3 15 "conditional blank" 4 "wet road" 5 "rain" 0 "none"; CM_ "CHFFR_METRIC 37 STEER_ANGLE STEER_ANGLE 0.36 180"; CM_ "Imported file _comma.dbc starts here"; BO_ 359 STEERING_IPAS_COMMA: 8 IPAS SG_ STATE : 7|4@0+ (1,0) [0|15] "" XXX SG_ ANGLE : 3|12@0- (1.5,0) [-510|510] "deg" XXX SG_ SET_ME_X10 : 23|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00 : 31|8@0+ (1,0) [0|255] "" XXX SG_ DIRECTION_CMD : 38|2@0+ (1,0) [0|3] "" XXX SG_ SET_ME_X40 : 47|8@0+ (1,0) [0|255] "" XXX SG_ SET_ME_X00_1 : 55|8@0+ (1,0) [0|255] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX CM_ "BO_ STEERING_IPAS_COMMA: Copy of msg 614 so we can do angle control while the Park Assist ECU is connected (Panda spoofs 614 with 359 on connector J70). Note that addresses 0x266 and 0x167 are checksum-invariant"; BO_ 512 GAS_COMMAND: 6 EON SG_ GAS_COMMAND : 7|16@0+ (0.159375,-75.555) [0|1] "" INTERCEPTOR SG_ GAS_COMMAND2 : 23|16@0+ (0.159375,-151.111) [0|1] "" INTERCEPTOR SG_ ENABLE : 39|1@0+ (1,0) [0|1] "" INTERCEPTOR SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" INTERCEPTOR SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" INTERCEPTOR BO_ 513 GAS_SENSOR: 6 INTERCEPTOR SG_ INTERCEPTOR_GAS : 7|16@0+ (0.159375,-75.555) [0|1] "" EON SG_ INTERCEPTOR_GAS2 : 23|16@0+ (0.159375,-151.111) [0|1] "" EON SG_ STATE : 39|4@0+ (1,0) [0|15] "" EON SG_ COUNTER_PEDAL : 35|4@0+ (1,0) [0|15] "" EON SG_ CHECKSUM_PEDAL : 47|8@0+ (1,0) [0|255] "" EON VAL_ 513 STATE 5 "FAULT_TIMEOUT" 4 "FAULT_STARTUP" 3 "FAULT_SCE" 2 "FAULT_SEND" 1 "FAULT_BAD_CHECKSUM" 0 "NO_FAULT" ; BO_ 35 SECONDARY_STEER_ANGLE: 8 XXX SG_ ZORRO_STEER : 7|24@0- (0.004901594652,0) [-500|500] "" XXX CM_ "BO_ SECONDARY_STEER_ANGLE: ZSS is a high-precision steering angle sensor that can replace the lower resolution sensor in most TSS1 Toyotas. Learn more: https://github.com/commaai/openpilot/wiki/Toyota-Lexus#zorro-steering-sensor-zss"; CM_ "toyota_sienna_xle_2018_pt.dbc starts here"; BO_ 550 BRAKE_MODULE: 8 XXX SG_ BRAKE_PRESSURE : 0|9@0+ (1,0) [0|255] "" XXX SG_ BRAKE_POSITION : 16|9@0+ (1,0) [0|65535] "" XXX SG_ BRAKE_PRESSED : 37|1@0+ (1,0) [0|3] "" XXX BO_ 705 GAS_PEDAL: 8 XXX SG_ GAS_RELEASED : 3|1@0+ (1,0) [0|1] "" XXX SG_ GAS_PEDAL : 55|8@0+ (0.005,0) [0|1] "" XXX BO_ 608 STEER_TORQUE_SENSOR: 8 XXX SG_ STEER_TORQUE_EPS : 47|16@0- (0.73,0) [-20000|20000] "" XXX SG_ STEER_TORQUE_DRIVER : 15|16@0- (1,0) [-32768|32767] "" XXX SG_ STEER_OVERRIDE : 0|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX SG_ STEER_ANGLE : 31|16@0- (0.0573,0) [-500|500] "" XXX BO_ 610 EPS_STATUS: 5 EPS SG_ IPAS_STATE : 3|4@0+ (1,0) [0|15] "" XXX SG_ LKA_STATE : 31|7@0+ (1,0) [0|127] "" XXX SG_ TYPE : 24|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 39|8@0+ (1,0) [0|255] "" XXX BO_ 956 GEAR_PACKET: 8 XXX SG_ GEAR : 13|6@0+ (1,0) [0|63] "" XXX CM_ SG_ 548 BRAKE_PRESSURE "seems prop to pedal force"; CM_ SG_ 548 BRAKE_POSITION "seems proportional to pedal displacement, unclear the max value of 0x1c8"; CM_ SG_ 610 TYPE "seems 1 on Corolla, 0 on all others"; VAL_ 956 GEAR 0 "D" 1 "S" 8 "N" 16 "R" 32 "P"; VAL_ 610 IPAS_STATE 5 "override" 3 "enabled" 1 "disabled"; VAL_ 610 LKA_STATE 25 "temporary_fault" 9 "temporary_fault2" 5 "active" 1 "standby" ================================================ FILE: opendbc/toyota_tss2_adas.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: XXX BO_ 384 TRACK_A_0: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 385 TRACK_A_1: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 386 TRACK_A_2: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 387 TRACK_A_3: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 388 TRACK_A_4: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 389 TRACK_A_5: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 390 TRACK_A_6: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 391 TRACK_A_7: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 392 TRACK_A_8: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 393 TRACK_A_9: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 394 TRACK_A_10: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 395 TRACK_A_11: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 396 TRACK_A_12: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 397 TRACK_A_13: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 398 TRACK_A_14: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 399 TRACK_A_15: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ LAT_DIST : 31|11@0- (0.04,0) [-50|50] "m" XXX SG_ LONG_DIST : 15|13@0+ (0.04,0) [0|300] "m" XXX SG_ NEW_TRACK : 36|1@0+ (1,0) [0|1] "" XXX SG_ REL_SPEED : 47|12@0- (0.025,0) [-100|100] "m/s" XXX SG_ VALID : 48|1@0+ (1,0) [0|1] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 400 TRACK_B_0: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 401 TRACK_B_1: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 402 TRACK_B_2: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 403 TRACK_B_3: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 404 TRACK_B_4: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 405 TRACK_B_5: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 406 TRACK_B_6: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 407 TRACK_B_7: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 408 TRACK_B_8: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 409 TRACK_B_9: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 410 TRACK_B_10: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 411 TRACK_B_11: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 412 TRACK_B_12: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 413 TRACK_B_13: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 414 TRACK_B_14: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 415 TRACK_B_15: 8 XXX SG_ COUNTER : 7|8@0+ (1,0) [0|255] "" XXX SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX SG_ CHECKSUM : 63|8@0+ (1,0) [0|255] "" XXX BO_ 576 NEW_MSG_1: 8 XXX SG_ NEW_SIGNAL_1 : 15|7@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX BO_ 577 NEW_MSG_2: 8 XXX SG_ NEW_SIGNAL_1 : 15|7@0+ (1,0) [0|127] "" XXX SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX ================================================ FILE: opendbc/vw_mqb_2010.dbc ================================================ VERSION "" NS_ : NS_DESC_ CM_ BA_DEF_ BA_ VAL_ CAT_DEF_ CAT_ FILTER BA_DEF_DEF_ EV_DATA_ ENVVAR_DATA_ SGTYPE_ SGTYPE_VAL_ BA_DEF_SGTYPE_ BA_SGTYPE_ SIG_TYPE_REF_ VAL_TABLE_ SIG_GROUP_ SIG_VALTYPE_ SIGTYPE_VALTYPE_ BO_TX_BU_ BA_DEF_REL_ BA_REL_ BA_DEF_DEF_REL_ BU_SG_REL_ BU_EV_REL_ BU_BO_REL_ SG_MUL_VAL_ BS_: BU_: Airbag_MQB BAP_Tester_MQB BMS_MQB Datenlogger_MQB Gateway_MQB Getriebe_DQ_Hybrid_MQB Getriebe_DQ_MQB LEH_MQB Motor_Diesel_MQB Motor_Hybrid_MQB Motor_Otto_MQB SAK_MQB Waehlhebel_MQB Vector__XXX 9 l c i XXX BO_ 290 ACC_06: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_limitierte_Anfahrdyn : 12|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_zul_Regelabw_unten : 16|6@1+ (0.024,0) [0|1.512] "Unit_MeterPerSeconSquar" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_StartStopp_Info : 22|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ ACC_Sollbeschleunigung_02 : 24|11@1+ (0.005,-7.22) [-7.22|3.005] "Unit_MeterPerSeconSquar" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_zul_Regelabw_oben : 35|5@1+ (0.0625,0) [0|1.9375] "Unit_MeterPerSeconSquar" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_neg_Sollbeschl_Grad_02 : 40|8@1+ (0.05,0) [0|12.75] "Unit_MeterPerCubicSecon" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_pos_Sollbeschl_Grad_02 : 48|8@1+ (0.05,0) [0|12.75] "Unit_MeterPerCubicSecon" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_Anfahren : 56|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_Anhalten : 57|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_Typ : 58|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_Status_ACC : 60|3@1+ (1,0) [0|7] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ACC_Minimale_Bremsung : 63|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 279 ACC_10: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB SG_ AWV1_Anf_Prefill : 16|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ANB_CM_Info : 17|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AWV2_Freigabe : 18|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ AWV1_HBA_Param : 19|2@1+ (1,0) [0|3] "" Vector__XXX SG_ AWV2_Ruckprofil : 21|3@1+ (1,0) [0|7] "" Vector__XXX SG_ AWV2_Priowarnung : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ANB_CM_Anforderung : 25|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ANB_Info_Teilbremsung : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ANB_Notfallblinken : 27|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ANB_Teilbremsung_Freigabe : 28|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ANB_Zielbrems_Teilbrems_Verz_Anf : 29|10@1+ (0.024,-20.016) [-20.016|4.536] "Unit_MeterPerSeconSquar" Airbag_MQB SG_ ANB_Zielbremsung_Freigabe : 39|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ AWV_Vorstufe : 40|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AWV_Halten : 41|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 64 Airbag_01: 8 Airbag_MQB SG_ Airbag_01_CRC : 0|8@1+ (1,0) [0|255] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ Airbag_01_BZ : 8|4@1+ (1,0) [0|15] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AB_RGS_Anst : 12|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ AB_Front_Crash : 16|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Heck_Crash : 17|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_SF_Crash : 18|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_SB_Crash : 19|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Rollover_Crash : 20|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Crash_Int : 21|3@1+ (1,0) [0|7] "" BMS_MQB,Gateway_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AB_Lampe : 24|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Deaktiviert : 25|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_VB_deaktiviert : 26|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Systemfehler : 27|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB,LEH_MQB SG_ AB_Diagnose : 28|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Stellgliedtest : 29|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AB_Erh_Auf_VB : 30|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtwarn_VF : 32|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Gurtwarn_VB : 33|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Anzeige_Fussg : 34|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Texte_AKS : 36|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_PAO_Leuchte_Anf : 38|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_MKB_gueltig : 39|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_MKB_Anforderung : 40|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ AB_Versorgungsspannung : 41|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 1312 Airbag_02: 8 Airbag_MQB SG_ AB_Belegung_VB : 26|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_FA : 40|2@1+ (1,0) [0|3] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Otto_MQB SG_ AB_Gurtschloss_BF : 42|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_Reihe2_FA : 44|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_Reihe2_MI : 46|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_Reihe2_BF : 48|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_Reihe3_FA : 50|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_Reihe3_MI : 52|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Gurtschloss_Reihe3_BF : 54|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Sitzpos_Sens_FA : 56|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ AB_Sitzpos_Sens_BF : 58|2@1+ (1,0) [0|3] "" Gateway_MQB BO_ 65 Airbag_03: 8 Airbag_MQB SG_ Airbag_03_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB SG_ Airbag_03_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ AB_MKB_Safing : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 1633 Anhaenger_01: 8 Gateway_MQB SG_ AAG_BZ : 0|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AAG_Bremsl_durch_ECD : 5|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AAG_Anhaenger_abgesteckt : 6|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_NSL_aktiv : 7|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_Anhaenger_erkannt : 8|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AAG_Blinker_H_aktiv : 9|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_Blinker_HL_def : 10|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_Blinker_HR_def : 11|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_Bremslicht_H_def : 12|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AAG_Schlusslicht_HL_def : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_Schlusslicht_HR_def : 14|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_AVS_Fehler_02 : 18|1@1+ (1,0) [0|1] "" Vector__XXX SG_ AAG_AVS_Stati : 20|4@1+ (1,0) [0|15] "" Vector__XXX BO_ 1626 BCM_01: 8 Gateway_MQB SG_ BCM_Bremsbelag_Sensor : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM_Bremsfluessigkeit_Sensor : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM1_Licht_Warn : 14|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM_Waschwasser_Sensor : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM_Kuehlmittel_Sensor : 16|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ BCM1_Kl_15_HW_erkannt : 17|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM_Eis_Offroad_Taste : 18|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Otto_MQB SG_ ZZH_Endlage_oben : 19|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZZH_Endlage_unten : 20|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZZH_Endlage_unplausibel : 21|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM2_EZS_gedrueckt : 22|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM2_SST_gedrueckt : 23|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM_Hybrid_StartStopp_Taste : 24|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM1_Warnblink_Taster : 25|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM1_Valet_Parking_Taster : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM_Remotestart_Betrieb : 27|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ BCM1_HSK_Taster : 28|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM1_Heckrollo_Taster : 29|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM1_Rueckfahrlicht_Schalter : 30|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM1_MH_Schalter : 31|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ BCM1_MH_WIV_Schalter : 32|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM_Eco_Charisma_Taste : 33|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ BCM_Thermomanagement : 34|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM_Thermomanagement_Fehler : 36|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM_Thermomanagement_gueltig : 37|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM1_Lichtwarn_Texte : 38|2@1+ (1,0) [0|3] "" Vector__XXX BO_ 869 BEM_05: 8 Gateway_MQB SG_ BEM_P_Generator : 16|8@1+ (50,0) [0|12700] "Unit_Watt" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_n_LLA : 24|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_01_Abschaltstufen : 26|3@1+ (1,0) [0|7] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_Anf_KL : 29|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_StartStopp_Info : 30|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ BEM_DFM : 32|5@1+ (3.225,0.025) [0.025|100] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_EMLIN_ungueltig : 37|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_Batt_Ab : 38|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_Segel_Info : 48|2@1+ (1,0) [0|3] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BEM_HYB_DC_uSollLV : 50|6@1+ (0.1,10.6) [10.6|16] "Unit_Volt" LEH_MQB SG_ BEM_HYB_DC_uMinLV : 56|8@1+ (0.1,0) [0|25.3] "Unit_Volt" LEH_MQB BO_ 1628 BMS_Hybrid_01: 8 BMS_MQB SG_ BMS_HYB_ASV_hinten_Status : 13|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ BMS_HYB_ASV_vorne_Status : 14|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ BMS_HYB_KD_Fehler : 15|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ BMS_HYB_BattFanSpd : 16|4@1+ (10,0) [0|100] "Unit_PerCent" Gateway_MQB SG_ BMS_HYB_VentilationReq : 20|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ BMS_HYB_Spuelbetrieb_Status : 21|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ BMS_HYB_Kuehlung_Anf : 22|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ BMS_HYB_Temp_vor_Verd : 24|8@1+ (0.5,-40) [-40|86.5] "Unit_DegreCelsi" Gateway_MQB SG_ BMS_HYB_Temp_nach_Verd : 32|8@1+ (0.5,-40) [-40|86.5] "Unit_DegreCelsi" Gateway_MQB SG_ BMS_Temperatur : 40|8@1+ (0.5,-40) [-40|86.5] "Unit_DegreCelsi" Gateway_MQB SG_ BMS_Temperatur_Ansaugluft : 48|8@1+ (0.5,-40) [-40|86.5] "Unit_DegreCelsi" Gateway_MQB SG_ BMS_IstSpannung_HV : 56|8@1+ (1,100) [100|350] "Unit_Volt" Gateway_MQB BO_ 901 Charisma_01: 8 Gateway_MQB SG_ CHA_Ziel_FahrPr_ALR : 0|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_ESP : 4|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_FL : 8|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Fahrer_Umschaltung : 14|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ CHA_Ziel_FahrPr_MO : 16|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ CHA_Ziel_FahrPr_GE : 20|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ CHA_Ziel_FahrPr_ST : 24|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_SCU : 28|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_DR : 32|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_QS : 36|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_AFS : 40|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_RGS : 44|4@1+ (1,0) [0|15] "" Airbag_MQB SG_ CHA_Ziel_FahrPr_EPS : 48|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_ACC : 52|4@1+ (1,0) [0|15] "" Vector__XXX SG_ CHA_Ziel_FahrPr_SAK : 56|4@1+ (1,0) [0|15] "" SAK_MQB SG_ CHA_Ziel_FahrPr_MStSt : 60|4@1+ (1,0) [0|15] "" Vector__XXX BO_ 945 DC_Hybrid_01: 8 LEH_MQB SG_ DC_HYB_iAktLV : 12|10@1+ (1,-511) [-511|510] "Unit_Amper" Gateway_MQB SG_ DC_HYB_iAktReserveLV : 22|10@1+ (1,-511) [-511|510] "Unit_Amper" Gateway_MQB SG_ DC_HYB_uAktLV : 32|8@1+ (0.1,0) [0|25.3] "Unit_Volt" Gateway_MQB SG_ DC_HYB_LangsRegelung : 40|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ DC_HYB_Abregelung_Temperatur : 41|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ DC_HYB_Fehler_RedLeistung : 42|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ DC_HYB_Fehler_intern : 43|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ DC_HYB_Fehler_Spannung : 44|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ DC_HYB_Auslastungsgrad : 56|8@1+ (0.4,0) [0|100] "Unit_PerCent" Gateway_MQB BO_ 1714 Diagnose_01: 8 Gateway_MQB SG_ DGN_Verlernzaehler : 0|8@1+ (1,0) [0|254] "" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,SAK_MQB SG_ KBI_Kilometerstand : 8|20@1+ (1,0) [0|1048573] "Unit_KiloMeter" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ UH_Jahr : 28|7@1+ (1,2000) [2000|2127] "Unit_Year" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ UH_Monat : 35|4@1+ (1,0) [1|12] "Unit_Month" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ UH_Tag : 39|5@1+ (1,0) [1|31] "Unit_Day" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ UH_Stunde : 44|5@1+ (1,0) [0|23] "Unit_Hours" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ UH_Minute : 49|6@1+ (1,0) [0|59] "Unit_Minut" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ UH_Sekunde : 55|6@1+ (1,0) [0|59] "Unit_Secon" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ Kombi_02_alt : 62|1@1+ (1,0) [0|1] "" Airbag_MQB,BMS_MQB,LEH_MQB SG_ Uhrzeit_01_alt : 63|1@1+ (1,0) [0|1] "" Airbag_MQB,BMS_MQB,LEH_MQB BO_ 1520 Dimmung_01: 8 Gateway_MQB SG_ DI_KL_58xd : 0|8@1+ (1,0) [0|253] "" Airbag_MQB SG_ DI_KL_58xs : 8|7@1+ (1,0) [0|100] "Unit_PerCent" Vector__XXX SG_ DI_Display_Nachtdesign : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ DI_KL_58xt : 16|7@1+ (1,0) [0|100] "Unit_PerCent" Vector__XXX SG_ DI_Fotosensor : 24|16@1+ (1,0) [0|65535] "" Vector__XXX BO_ 1603 Einheiten_01: 8 Gateway_MQB SG_ KBI_Einheit_Datum : 0|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KBI_Einheit_Druck : 2|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KBI_Einheit_Streckenanz : 4|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB SG_ KBI_MFA_v_Einheit_02 : 5|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Einheit_Temp : 6|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Einheit_Uhrzeit : 7|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Einheit_Verbrauch : 8|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KBI_Einheit_Volumen : 10|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KBI_Einheit_Sprache : 16|8@1+ (1,0) [0|255] "" Vector__XXX BO_ 260 EPB_01: 8 Gateway_MQB SG_ EPB_01_CRC : 0|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EPB_01_BZ : 8|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EPB_QBit_Laengsbeschleunigung : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EPB_QBit_Pedalweg_Kuppl : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EPB_BCM2_Motor_Wakeup : 14|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EPB_Freig_Verzoeg_Anf : 15|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EPB_Verzoeg_Anf : 16|8@1+ (0.048,-7.968) [-7.968|4.224] "Unit_MeterPerSeconSquar" Vector__XXX SG_ EPB_Laengsbeschleunigung : 24|8@1+ (1,-128) [-128|126] "Unit_PerCentOfForceOfGravi" Vector__XXX SG_ EPB_Pedalweg_Kuppl : 32|8@1+ (0.4,0) [8|92] "Unit_PerCent" Vector__XXX SG_ EPB_Anfahrwunsch_erkannt : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EPB_DAA_Randbed_erf : 49|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ EPB_Fehlerstatus : 50|2@1+ (1,0) [0|3] "" Vector__XXX SG_ EPB_Schalterposition : 52|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EPB_QBit_Schalterpos : 54|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EPB_Konsistenz_ACC : 55|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EPB_Spannkraft : 56|5@1+ (1,0) [0|29] "Unit_KiloNewto" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ EPB_Status : 61|2@1+ (1,0) [0|3] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 257 ESP_02: 8 Gateway_MQB SG_ ESP_02_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_02_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Gierrate : 12|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_QBit_Laengsbeschl : 13|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Querb : 14|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Stillstandsflag : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Querbeschleunigung : 16|8@1+ (0.01,-1.27) [-1.27|1.27] "Unit_ForceOfGravi" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Laengsbeschl : 24|10@1+ (0.03125,-16) [-16|15.90625] "Unit_MeterPerSeconSquar" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Verteil_Wankmom : 34|5@1+ (0.1,-1) [-1|1] "" Vector__XXX SG_ ESP_QBit_Anf_Vert_Wank : 39|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Gierrate : 40|14@1+ (0.01,0) [0|163.82] "Unit_DegreOfArcPerSecon" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_VZ_Gierrate : 54|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_Notbremsanzeige : 55|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ESP_SpannungsAnf : 56|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_PLA_Abbruch : 57|3@1+ (1,0) [0|7] "" Vector__XXX SG_ ESP_Status_ESP_PLA : 60|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 262 ESP_05: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Bremsdruck : 12|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Fahrer_bremst : 13|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Schwelle_Unterdruck : 14|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Bremsdruck : 16|10@1+ (0.3,-30) [-30|276.6] "Unit_Bar" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Fahrer_bremst : 26|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Verz_TSK_aktiv : 27|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Lenkeingriff_ADS : 28|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Konsistenz_TSK : 29|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Bremsruck_AWV2 : 30|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Konsistenz_AWV2 : 31|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ECD_Fehler : 32|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ECD_nicht_verfuegbar : 33|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Status_Bremsentemp : 34|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Autohold_Standby : 35|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_HDC_Standby : 36|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_HBA_aktiv : 37|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Prefill_ausgeloest : 38|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Rueckwaertsfahrt_erkannt : 39|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Status_Anfahrhilfe : 40|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_HDC_aktiv : 41|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_StartStopp_Info : 42|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ ESP_Eingr_HL : 44|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Eingr_HR : 45|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Eingr_VL : 46|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Eingr_VR : 47|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_BKV_Unterdruck : 48|8@1+ (4,0) [0|1012] "Unit_MilliBar" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Autohold_aktiv : 56|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_FStatus_Anfahrhilfe : 57|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_Verz_EPB_aktiv : 58|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ECD_Bremslicht : 59|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Verzoeg_EPB_verf : 60|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Status_Bremsdruck : 61|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Anforderung_EPB : 62|2@1+ (1,0) [0|3] "" Vector__XXX BO_ 914 ESP_07: 8 Gateway_MQB SG_ ESP_07_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_07_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_ACC_LDE : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Quattro_Antrieb : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Codierung_ADS : 14|2@1+ (1,0) [0|3] "" Vector__XXX SG_ ESP_RTA_HL : 16|8@1+ (0.048828125,-6.20117) [-6.20117|6.152345625] "Unit_PerCent" Vector__XXX SG_ ESP_RTA_HR : 24|8@1+ (0.048828125,-6.20117) [-6.20117|6.152345625] "Unit_PerCent" Vector__XXX SG_ ESP_RTA_VR : 32|8@1+ (0.048828125,-6.20117) [-6.20117|6.152345625] "Unit_PerCent" Vector__XXX SG_ OBD_Fehler_Radsensor_HL : 40|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_Fehler_Radsensor_HR : 44|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_Fehler_Radsensor_VL : 48|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_Fehler_Radsensor_VR : 52|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Qualifizierung_Antriebsart : 56|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_Offroad_Modus : 57|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_MKB_ausloesbar : 58|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ESP_MKB_Status : 59|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ESP_CM_Variante : 60|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ESP_OBD_Status : 61|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 278 ESP_10: 8 Gateway_MQB SG_ ESP_10_CRC : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_10_BZ : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_VL : 12|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_VR : 13|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_HL : 14|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_Wegimpuls_HR : 15|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Wegimpuls_VL : 16|10@1+ (1,0) [0|1000] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Wegimpuls_VR : 26|10@1+ (1,0) [0|1000] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Wegimpuls_HL : 36|10@1+ (1,0) [0|1000] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Wegimpuls_HR : 46|10@1+ (1,0) [0|1000] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_VL_Fahrtrichtung : 56|2@1+ (1,0) [0|3] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_VR_Fahrtrichtung : 58|2@1+ (1,0) [0|3] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_HL_Fahrtrichtung : 60|2@1+ (1,0) [0|3] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_HR_Fahrtrichtung : 62|2@1+ (1,0) [0|3] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 178 ESP_19: 8 Gateway_MQB SG_ ESP_HL_Radgeschw_02 : 0|16@1+ (0.0075,0) [0|491.49] "Unit_KiloMeterPerHour" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_HR_Radgeschw_02 : 16|16@1+ (0.0075,0) [0|491.49] "Unit_KiloMeterPerHour" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_VL_Radgeschw_02 : 32|16@1+ (0.0075,0) [0|491.49] "Unit_KiloMeterPerHour" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_VR_Radgeschw_02 : 48|16@1+ (0.0075,0) [0|491.49] "Unit_KiloMeterPerHour" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 1629 ESP_20: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Vector__XXX SG_ BR_Systemart : 12|2@1+ (1,0) [0|3] "" Vector__XXX SG_ ESP_Zaehnezahl : 16|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_Charisma_FahrPr : 24|4@1+ (1,0) [0|15] "" Vector__XXX SG_ ESP_Charisma_Status : 28|2@1+ (1,0) [0|3] "" Vector__XXX SG_ BR_QBit_Reifenumfang : 51|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ BR_Reifenumfang : 52|12@1+ (1,0) [0|4095] "Unit_MilliMeter" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 253 ESP_21: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BR_Eingriffsmoment : 12|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_v_Signal : 32|16@1+ (0.01,0) [0|655.32] "Unit_KiloMeterPerHour" Airbag_MQB,BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB,SAK_MQB SG_ ASR_Tastung_passiv : 48|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Tastung_passiv : 49|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Systemstatus : 50|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ASR_Schalteingriff : 51|2@1+ (1,0) [0|3] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ ESP_Haltebestaetigung : 53|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_QBit_v_Signal : 55|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ABS_Bremsung : 56|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ASR_Anf : 57|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ MSR_Anf : 58|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EBV_Eingriff : 59|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ EDS_Eingriff : 60|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Eingriff : 61|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_ASP : 62|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ESP_Anhaltevorgang_ACC_aktiv : 63|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 987 Gateway_72: 8 Gateway_MQB SG_ BCM_01_alt : 0|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ SMLS_01_alt : 1|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ ZV_02_alt : 2|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ Wischer_01_alt : 3|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ Anhaenger_01_alt : 4|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ Klima_Sensor_02_alt : 5|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ VSG_01_alt : 6|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ Klima_01_alt : 7|1@1+ (1,0) [0|1] "" Vector__XXX SG_ WFS_01_alt : 8|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Licht_Anf_01_alt : 9|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZV_HFS_offen : 20|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZV_HBFS_offen : 21|1@1+ (1,0) [0|1] "" Vector__XXX SG_ VS_VD_offen_ver : 22|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ VS_VD_zu_ver : 23|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZV_BT_offen : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM1_Rueckfahrlicht_Schalter : 25|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ ZV_FT_offen : 26|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ Wischer_vorne_aktiv : 27|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ AAG_Anhaenger_erkannt : 28|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ BCM1_MH_Schalter : 29|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZV_HD_offen : 30|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Waschen_vorne_aktiv : 31|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KL_Thermomanagement : 32|2@1+ (1,0) [0|3] "" Vector__XXX SG_ WFS_Schluessel_Fahrberecht : 34|4@1+ (1,0) [0|15] "" Vector__XXX SG_ BCM1_RFahrlicht_Fzg_Anf : 38|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BCM1_RFahrlicht_Ahg_Anf : 39|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BH_Fernlicht : 49|1@1+ (1,0) [0|1] "" Vector__XXX SG_ BH_Blinker_li : 50|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ BH_Blinker_re : 51|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ BCM1_OBD_FStatus_ATemp : 52|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM1_Aussen_Temp_ungef : 56|8@1+ (0.5,-50) [-50|76] "Unit_DegreCelsi" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 989 Gateway_74: 8 Gateway_MQB SG_ LH_EPS_01_alt : 0|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB SG_ Kessy_04_alt : 1|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ LIN_2_alt : 2|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MFG_01_alt : 3|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ GW_74_va_14 : 4|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Klima_02_alt : 5|1@1+ (1,0) [0|1] "" BMS_MQB SG_ Parkhilfe_01_alt : 6|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ ELV_01_alt : 7|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KY_StartStopp_Info : 16|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ PH_StartStopp_Info : 18|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ EPS_Lenkerposition : 20|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB SG_ ELV_Anf_Klemme_50 : 22|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ MF_StartStopp_Info : 25|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ KL_Geblaesespannung_Soll : 40|8@1+ (0.05,0.5) [2|13] "Unit_Volt" BMS_MQB SG_ KL_Umluftklappe_Status : 48|4@1+ (1,0) [0|15] "" Vector__XXX SG_ MFL_Tip_Down : 56|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MFL_Tip_Up : 57|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ LS_Tiptronic_Fehler : 58|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 296 Getriebe_06: 3 Getriebe_DQ_Hybrid_MQB SG_ GE_WH_Sperre : 0|1@1+ (1,0) [0|1] "" Waehlhebel_MQB SG_ GE_Ausleuchtungsmode : 1|1@1+ (1,0) [0|1] "" Waehlhebel_MQB SG_ GE_Test_Freigabe : 2|1@1+ (1,0) [0|1] "" Waehlhebel_MQB SG_ GE_Ist_Fahrstufe : 4|4@1+ (1,0) [0|15] "" Waehlhebel_MQB SG_ GE_Testparameter_1 : 8|8@1+ (1,0) [0|255] "" Waehlhebel_MQB SG_ GE_Testparameter_2 : 16|8@1+ (1,0) [0|255] "" Waehlhebel_MQB BO_ 173 Getriebe_11: 8 Getriebe_DQ_Hybrid_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTERXX : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_MMom_Soll_02 : 12|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_MMom_Vorhalt_02 : 22|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Uefkt : 32|10@1+ (0.1,0) [0|102.2] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Fahrstufe : 42|5@1+ (1,0) [0|31] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Schaltvorgang : 47|1@1+ (1,0) [0|1] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Status_Kupplung : 54|2@1+ (1,0) [0|3] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_MMom_Status : 56|2@1+ (1,0) [0|3] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Freig_MMom_Vorhalt : 58|1@1+ (1,0) [0|1] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Verbot_Ausblendung : 59|1@1+ (1,0) [0|1] "" Gateway_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Zielgang : 60|4@1+ (1,0) [0|15] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 174 Getriebe_12: 8 Getriebe_DQ_Hybrid_MQB SG_ Getriebe_12_CRC : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ Getriebe_12_BZ : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Drehzahlmesser_Daempfung : 12|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Schubabschalt_Unt : 13|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Freigabe_Synchro : 14|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Synchro_Wunschdrehz : 15|9@1+ (25,0) [0|12750] "Unit_MinutInver" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Synchro_Zeit : 24|8@1+ (20,0) [0|5080] "Unit_MilliSecon" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Mom_Begr_Gradient : 32|8@1+ (10,0) [0|2540] "Unit_NewtoMeterPerSecon" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Anheb_Solldrehz_Leerlauf : 40|8@1+ (10,0) [0|2540] "Unit_MinutInver" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Aufnahmemoment : 48|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Anf_Zylabsch : 58|2@1+ (1,0) [0|3] "" Vector__XXX SG_ GE_HYB_DZ_Eingriff : 62|2@1+ (1,0) [0|3] "" Motor_Hybrid_MQB BO_ 301 Getriebe_13: 8 Getriebe_DQ_Hybrid_MQB SG_ Getriebe_13_CRC : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ Getriebe_13_BZ : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_StartStopp_Info : 12|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ GE_Langfr_Schutzmom_02 : 14|9@1+ (1,0) [0|509] "Unit_NewtoMeter" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Eingangsdrehz : 48|14@1+ (1,0) [0|16381] "Unit_MinutInver" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Notlauf : 62|1@1+ (1,0) [0|1] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Freig_Langfr_Schutzmom : 63|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 968 Getriebe_14: 8 Getriebe_DQ_Hybrid_MQB SG_ GE_OBD_AbsperrVent : 12|4@1+ (1,0) [0|15] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_amax_moeglich : 16|9@1+ (0.024,-2.016) [-2.016|10.224] "Unit_MeterPerSeconSquar" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Charisma_FahrPr : 25|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ GE_Charisma_Status : 29|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ GE_Verlustmoment : 32|8@1+ (1,0) [0|254] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Freigabe_Verfallsinfo_WFS : 49|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ GE_Codierung_MSG : 50|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ GE_LaunchControl : 51|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ GE_Heizwunsch : 52|2@1+ (1,0) [0|3] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_OBD_Status : 54|1@1+ (1,0) [0|1] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_LFR_Adaption : 55|1@1+ (1,0) [0|1] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GE_Sumpftemperatur : 56|8@1+ (1,-58) [-58|196] "Unit_DegreCelsi" Gateway_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 158 Getriebe_Hybrid_01: 8 Getriebe_DQ_Hybrid_MQB SG_ Getriebe_Hybrid_01_CRC : 0|8@1+ (1,0) [0|255] "" Motor_Hybrid_MQB SG_ Getriebe_Hybrid_01_BZ : 8|4@1+ (1,0) [0|15] "" Motor_Hybrid_MQB SG_ GE_HYB_Fehlerstatus : 12|2@1+ (1,0) [0|3] "" Motor_Hybrid_MQB SG_ GE_HYB_Freigabe_K0 : 16|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_Freigabe_LL_Reg : 17|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_Freig_sSchl_K0 : 18|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_Freig_VM_EM_Stop : 19|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_Wiederstart : 20|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_Filt_MomAufbau : 21|3@1+ (1,0) [0|7] "" Motor_Hybrid_MQB SG_ GE_HYB_nK0 : 24|8@1+ (25,0) [0|6350] "Unit_MinutInver" Vector__XXX SG_ GE_HYB_MomEingriff_EM : 32|6@1+ (0.5,0) [0|31.5] "Unit_NewtoMeter" LEH_MQB SG_ GE_HYB_VZ_MomEingriff_EM : 38|1@1+ (1,0) [0|1] "" LEH_MQB SG_ GE_HYB_Sportfaktor : 56|4@1+ (1,0) [0|15] "" Motor_Hybrid_MQB SG_ GE_HYB_VM_akt_halten : 61|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_StartAnf : 62|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB SG_ GE_HYB_VM_Startkontr : 63|1@1+ (1,0) [0|1] "" Motor_Hybrid_MQB BO_ 299 GRA_ACC_01: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Hauptschalter : 12|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Abbrechen : 13|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Typ_Hauptschalter : 14|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Limiter : 15|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Tip_Setzen : 16|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Tip_Hoch : 17|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Tip_Runter : 18|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Tip_Wiederaufnahme : 19|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Verstellung_Zeitluecke : 20|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Codierung : 22|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Fehler : 24|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Typ468 : 25|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_Tip_Stufe_2 : 27|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ GRA_ButtonTypeInfo : 28|2@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 960 Klemmen_Status_01: 4 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ZAS_Kl_S : 16|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZAS_Kl_15 : 17|1@1+ (1,0) [0|1] "" Airbag_MQB,BMS_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ ZAS_Kl_X : 18|1@1+ (1,0) [0|1] "" Vector__XXX SG_ ZAS_Kl_50 : 19|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 949 Klima_11: 8 Gateway_MQB SG_ KL_Drehz_Anh : 0|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_Vorwarn_Komp_ein : 1|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_AC_Schalter : 2|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KL_Komp_Moment_alt : 3|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KL_Zonen : 4|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_Vorwarn_Zuheizer_ein : 6|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KL_Zustand : 7|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_Comp_rev_rq : 8|8@1+ (50,0) [0|8600] "Unit_MinutInver" Vector__XXX SG_ KL_Charisma_FahrPr : 16|4@1+ (1,0) [0|15] "" Vector__XXX SG_ KL_Charisma_Status : 20|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KL_Comp_enable : 23|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KL_Last_Kompr : 24|8@1+ (0.25,0) [0|63.5] "Unit_NewtoMeter" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_Spannungs_Anf : 32|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KL_Thermomanagement : 34|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_StartStopp_Info : 36|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ KL_Anf_KL : 40|8@1+ (0.4,0) [0|101.6] "Unit_PerCent" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KL_el_Zuheizer_Stufe : 48|3@1+ (1,0) [0|7] "" Motor_Diesel_MQB BO_ 1625 Klimakomp_01: 8 Gateway_MQB SG_ EKL_KD_Fehler : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EKL_Comp_SCI_com_stat : 16|2@1+ (1,0) [0|3] "" Vector__XXX SG_ EKL_Comp_output_stat : 18|2@1+ (1,0) [0|3] "" Vector__XXX SG_ EKL_Comp_main_stat : 20|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EKL_Comp_ovld_stat : 21|3@1+ (1,0) [0|7] "" Vector__XXX SG_ EKL_Comp_Inv_stat : 24|2@1+ (1,0) [0|3] "" Vector__XXX SG_ EKL_Comp_photo_temp_stat : 30|2@1+ (1,0) [0|3] "" Vector__XXX SG_ EKL_Comp_photo_temp : 32|8@1+ (1,0) [0|254] "Unit_DegreCelsi" Vector__XXX SG_ EKL_Comp_current : 40|8@1+ (0.1,0) [0|25.4] "Unit_Amper" Motor_Hybrid_MQB SG_ EKL_Comp_rev_stat : 48|8@1+ (50,0) [0|8600] "Unit_MinutInver" Vector__XXX BO_ 2549088277 KN_Airbag_01: 8 Airbag_MQB SG_ Airbag_01_KompSchutz : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Airbag_01_Nachlauftyp : 4|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ AB_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 2549088380 KN_EMotor_01: 8 LEH_MQB SG_ EMotor_KompSchutz : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ EMotor_Nachlauftyp : 4|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ EM_HYB_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 2549088375 KN_Getriebe_01: 8 Getriebe_DQ_Hybrid_MQB SG_ Getriebe_KompSchutz : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Getriebe_Nachlauftyp : 4|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ GE_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 2549088379 KN_Hybrid_01: 8 BMS_MQB SG_ Hybrid_KompSchutz : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Hybrid_Nachlauftyp : 4|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ BMS_HYB_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 2549088374 KN_MO_01: 8 Motor_Diesel_MQB SG_ Motor_KompSchutz : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Motor_Nachlauftyp : 4|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 2549088284 KN_SAK: 8 SAK_MQB SG_ SAK_KompSchutz : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SAK_Nachlauftyp : 4|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ SAK_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 779 Kombi_01: 8 Gateway_MQB SG_ KBI_ABS_Lampe : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_ESP_Lampe : 1|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_BKL_Lampe : 2|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Airbag_Lampe : 3|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ KBI_SILA_gueltig : 4|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ KBI_Lenkung_Lampe : 5|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Vorglueh_System_Lampe : 6|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB SG_ KBI_NV_in_Anzeige : 7|1@1+ (1,0) [0|1] "" Vector__XXX SG_ Kombi_01_BZ : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_Anzeigestatus_ACC : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Anzeigestatus_GRA : 13|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_Oeldruck_Schalter : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Tankwarnung : 16|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_MFA_v_Einheit_01 : 17|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_im_Stellgliedtest : 18|1@1+ (1,0) [0|1] "" Airbag_MQB SG_ KBI_Anzeigefehler_LDW : 19|2@1+ (1,0) [0|3] "" Vector__XXX SG_ KBI_Variante_USA : 21|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Oeldruckwarnung : 22|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Handbremse : 23|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ KBI_V_Digital : 24|9@1+ (1,0) [0|511] "" Vector__XXX SG_ KBI_PLA_in_Anzeige : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Anzeigefehler_NV : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Anzeigestatus_LIM : 35|2@1+ (1,0) [0|3] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_angez_Geschw : 48|10@1+ (0.32,0) [0|325.12] "Unit_KiloMeterPerHour" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_Einheit_Tacho : 58|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_Konsistenz_ACC : 59|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Fehler_Anzeige_ACC : 60|1@1+ (1,0) [0|1] "" Vector__XXX SG_ KBI_Anzeigefehler_SWA : 61|2@1+ (1,0) [0|3] "" Vector__XXX BO_ 1719 Kombi_02: 8 Gateway_MQB SG_ KBI_Kilometerstand : 0|20@1+ (1,0) [0|1048573] "Unit_KiloMeter" Vector__XXX SG_ KBI_Standzeit_02 : 20|17@1+ (1,0) [0|131068] "Unit_Secon" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_Inhalt_Tank : 40|7@1+ (1,0) [0|125] "Unit_Liter" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_FStatus_Tank : 47|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_QBit_Aussen_Temp_gef : 55|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ KBI_Aussen_Temp_gef : 56|8@1+ (0.5,-50) [-50|75] "Unit_DegreCelsi" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 982 Licht_hinten_01: 8 Gateway_MQB SG_ Licht_hinten_01_BZ : 0|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ BCM2_Bremsl_durch_ECD : 5|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LH_Aussenlicht_def : 7|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Standlicht_H_aktiv : 8|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Parklicht_HL_aktiv : 9|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Parklicht_HR_aktiv : 10|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Bremslicht_H_aktiv : 11|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Nebelschluss_aktiv : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Rueckfahrlicht_aktiv : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Blinker_HL_akt : 14|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Blinker_HR_akt : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Blinker_li_def : 16|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Bremsl_li_def : 17|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schlusslicht_li_def : 18|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Rueckf_li_def : 19|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Nebel_li_def : 20|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schluss_Brems_Nebel_li_def : 21|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schluss_Brems_Nebel_re_def : 22|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schluss_Brems_li_def : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schluss_Nebel_li_def : 25|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_SL_BRL_BLK_li_def : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Brems_Blk_li_def : 27|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Blinker_re_def : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Bremsl_re_def : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schlusslicht_re_def : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Rueckf_re_def : 35|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Nebel_re_def : 36|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schluss_Brems_re_def : 40|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Schluss_Nebel_re_def : 41|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_SL_BRL_BLK_re_def : 42|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Brems_Blk_re_def : 43|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Kennzl_def : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_3_Bremsl_def : 49|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LH_Nebel_mi_def : 50|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Rueckf_mi_def : 51|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LH_Bremsl_li_ges_def : 54|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LH_Bremsl_re_ges_def : 55|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 134 LWI_01: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_Sensorstatus : 12|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_QBit_Sub_Daten : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LWI_QBit_Lenkradwinkel : 15|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_Lenkradwinkel : 16|13@1+ (0.1,0) [0|800] "Unit_DegreOfArc" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_VZ_Lenkradwinkel : 29|1@1+ (1,0) [0|1] "" Airbag_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ LWI_VZ_Lenkradw_Geschw : 30|1@1+ (1,0) [0|1] "" Vector__XXX SG_ LWI_Lenkradw_Geschw : 31|9@1+ (5,0) [0|2500] "Unit_DegreOfArcPerSecon" Vector__XXX SG_ LWI_Sub_Daten : 40|16@1+ (1,0) [0|65535] "" Vector__XXX BO_ 263 Motor_04: 8 Motor_Diesel_MQB SG_ MO_Istgang : 8|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_Sollgang : 12|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_Oeldruck : 16|8@1+ (0.04,0) [0|10] "Unit_Bar" Gateway_MQB SG_ MO_Anzeigedrehz : 24|12@1+ (3,0) [0|12282] "Unit_MinutInver" Gateway_MQB SG_ MO_Schaltempf_verfbar : 38|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Ladedruck : 39|9@1+ (0.01,0) [0|5.1] "Unit_Bar" Gateway_MQB SG_ MO_KVS : 48|15@1+ (1,0) [0|32767] "Unit_MicroLiter" Gateway_MQB SG_ MO_KVS_Ueberlauf : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 1600 Motor_07: 8 Motor_Diesel_MQB SG_ MO_QBit_Ansaugluft_Temp : 0|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_QBit_Oel_Temp : 1|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_QBit_Kuehlmittel_Temp : 2|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ MO_Stellgliedtest_Soundaktuator : 3|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Fehler_HV_Netz : 4|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_aktives_Getriebeheizen : 5|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Absperrventil_oeffnen : 6|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Ansaugluft_Temp : 8|8@1+ (0.75,-48) [-48|141.75] "Unit_DegreCelsi" Gateway_MQB SG_ MO_Oel_Temp : 16|8@1+ (1,-60) [-60|192] "Unit_DegreCelsi" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Kuehlmittel_Temp : 24|8@1+ (0.75,-48) [-48|141.75] "Unit_DegreCelsi" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ MO_Hoeheninfo : 32|8@1+ (0.00781,0) [0|1.98374] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Kennfeldk : 40|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Versionsinfo : 41|6@1+ (1,0) [0|63] "" Gateway_MQB SG_ MO_Getriebe_kuehlen : 47|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Mom_Traegheit_02 : 48|5@1+ (0.01,0) [0|0.31] "Unit_KiloGramMeterSquar" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Heizungspumpenansteuerung : 53|4@1+ (10,0) [0|100] "Unit_PerCent" Gateway_MQB SG_ MO_SpannungsAnf : 57|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Nachlaufzeit_Heizungspumpe : 58|6@1+ (15,0) [0|945] "Unit_Secon" Gateway_MQB BO_ 1607 Motor_09: 8 Motor_Diesel_MQB SG_ MO_ITM_Kuehlmittel_Temp : 0|8@1+ (0.75,-48) [-45.75|143.25] "Unit_DegreCelsi" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_E85_Sensor : 8|4@1+ (10,0) [0|100] "Unit_PerCent" Gateway_MQB SG_ SCR_Anz_Motorstarts : 12|4@1+ (1,0) [0|8] "" Gateway_MQB SG_ SCR_Reichweite : 16|15@1+ (1,0) [0|32766] "" Gateway_MQB SG_ SCR_Warnstufe_1 : 32|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ SCR_Warnstufe_2 : 33|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ SCR_Text : 34|3@1+ (1,0) [0|7] "" Gateway_MQB SG_ SCR_Akustik : 37|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Kraftstofffilter_Wasser : 40|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ SCR_Systemfehler : 41|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ SCR_Inducement_Strategie : 42|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_CO2_Faktor : 44|12@1+ (1,0) [1|4094] "Unit_GramPerLiter" Gateway_MQB BO_ 167 Motor_11: 8 Motor_Diesel_MQB SG_ Motor_11_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ Motor_11_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Mom_Soll_Roh : 12|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Mom_Ist_Summe : 22|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,SAK_MQB SG_ MO_Mom_Traegheit_Summe : 32|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Mom_Soll_gefiltert : 42|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Mom_Schub : 52|9@1+ (1,-509) [-509|0] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Status_Normalbetrieb_01 : 61|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_erste_Ungenauschwelle : 62|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_QBit_Motormomente : 63|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 168 Motor_12: 8 Motor_Diesel_MQB SG_ Motor_12_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ Motor_12_BZ : 8|4@1+ (1,0) [0|15] "" BMS_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ MO_Mom_neg_verfuegbar : 12|9@1+ (1,-509) [-509|0] "Unit_NewtoMeter" Gateway_MQB SG_ MO_Mom_Begr_stat : 21|9@1+ (1,0) [0|509] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Mom_Begr_dyn : 30|10@1+ (1,-509) [-509|509] "Unit_NewtoMeter" Gateway_MQB SG_ MO_Momentenintegral_02 : 40|7@1+ (1,0) [0|100] "Unit_PerCent" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_QBit_Drehzahl_01 : 47|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ MO_Drehzahl_01 : 48|16@1+ (0.25,0) [0|16383] "Unit_MinutInver" BMS_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,SAK_MQB BO_ 958 Motor_14: 8 Motor_Diesel_MQB SG_ MO_StartStopp_Status : 12|2@1+ (1,0) [0|3] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_StartStopp_Wiederstart : 14|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_StartStopp_Motorstopp : 15|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Freig_Reku : 16|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Kl_75 : 18|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Kl_50 : 19|1@1+ (1,0) [0|1] "" Gateway_MQB,LEH_MQB SG_ MO_Gangposition : 20|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_StartStopp_Fahrerwunsch : 24|2@1+ (1,0) [0|3] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_HYB_Fahrbereitschaft : 26|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB SG_ MO_Ext_E_Fahrt_aktiv : 27|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Fahrer_bremst : 28|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_QBit_Fahrer_bremst : 29|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_BLS : 30|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Konsistenz_Bremsped : 31|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Timeout_ESP : 32|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Klima_Eingr : 33|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Aussp_Anlass : 35|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Freig_Anlass : 36|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Kuppl_schalter : 37|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Interlock : 38|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Motor_laeuft : 39|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Kickdown : 40|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Status_Zylabschalt_01 : 41|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_EKlKomLeiRed : 42|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Handshake_STH : 44|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_BKV_Unterdruckwarnung : 45|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Freigabe_Segeln : 46|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_PTC_Status : 47|3@1+ (1,0) [0|7] "" Gateway_MQB SG_ MO_QBit_Gangposition : 50|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Signalquelle_Gangposition : 51|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Remotestart_Betrieb : 52|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 1631 Motor_16: 8 Motor_Diesel_MQB SG_ TSK_QBit_Steigung : 12|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_QBit_Fahrzeugmasse : 13|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_SpannungsAnf_02 : 14|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_DPF_reg : 16|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Heizstrom_EKAT : 17|7@1+ (1,0) [0|126] "Unit_Amper" Gateway_MQB SG_ MO_Heizstrom_SCR : 24|6@1+ (1,0) [0|62] "Unit_Amper" Gateway_MQB SG_ TSK_Fahrzeugmasse_02 : 48|8@1+ (32,0) [0|8128] "Unit_KiloGram" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Steigung : 56|8@1+ (0.8,-101.6) [-101.6|101.6] "Unit_PerCent" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 812 Motor_17: 8 Motor_Diesel_MQB SG_ MO_Prio_MAX_Wunschdrehzahl : 12|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Prio_MIN_Wunschdrehzahl : 13|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Luftpfad_aktiv : 14|1@1+ (1,0) [0|1] "" Vector__XXX SG_ MO_v_Begrenz_Aktivierbar : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ MO_Drehzahlbeeinflussung : 16|8@1+ (0.39,0) [0|99.45] "Unit_PerCent" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_MIN_Wunschdrehzahl : 24|8@1+ (25,0) [0|6350] "Unit_MinutInver" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_MAX_Wunschdrehzahl : 32|9@1+ (25,0) [0|12750] "Unit_MinutInver" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Charisma_FahrPr : 41|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_Charisma_Status : 45|2@1+ (1,0) [0|3] "" Gateway_MQB BO_ 1648 Motor_18: 8 Motor_Diesel_MQB SG_ MO_Hybrid_StartStopp_LED : 43|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Eis_Offroad_LED : 45|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Anzahl_Abgesch_Zyl : 47|3@1+ (1,0) [0|7] "" Gateway_MQB SG_ MO_Zylabsch_Texte : 50|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_E85_BS_Texte : 52|3@1+ (1,0) [0|7] "" Gateway_MQB SG_ MO_Drehzahl_Warnung : 55|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_obere_Drehzahlgrenze : 56|8@1+ (50,0) [50|12750] "Unit_MinutInver" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 289 Motor_20: 8 Motor_Diesel_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 8|4@1+ (1,0) [0|255] "" XXX SG_ MO_Fahrpedalrohwert_01 : 12|8@1+ (0.4,0) [0|101.6] "Unit_PerCent" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_QBit_Fahrpedalwerte_01 : 20|1@1+ (1,0) [0|1] "" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Fahrpedalgradient : 21|8@1+ (25,0) [0|6350] "Unit_PerCentPerSecon" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Sig_Fahrpedalgradient : 29|1@1+ (1,0) [0|1] "" Airbag_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_rel_Saugrohrdruck : 30|6@1+ (18,0) [0|1116] "Unit_MilliBar" Gateway_MQB SG_ MO_rel_Saugrohrdruck_gem_err : 36|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Moment_im_Leerlauf : 37|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Schubabschaltung : 38|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Solldrehz_Leerlauf : 40|8@1+ (10,0) [0|2540] "Unit_MinutInver" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 967 Motor_26: 8 Motor_Diesel_MQB SG_ MO_HYB_Status_HV_Ladung : 8|3@1+ (1,0) [0|7] "" Gateway_MQB SG_ WIV_Anzeige_aktiv : 12|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Oelmin_Warn : 13|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Sensorfehler : 14|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Schieflage : 15|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Oelstand : 16|4@1+ (12.5,0) [0|100] "Unit_PerCent" Gateway_MQB SG_ MO_Zustand_HWP : 20|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ WIV_Oelsystem_aktiv : 24|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_nicht_betriebswarm : 25|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Ueberfuell_Warn : 26|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_laufender_Motor : 27|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Text_1 : 28|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Text_2 : 29|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Text_3 : 30|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Text_4 : 31|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Text_Motorstart : 32|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_HYB_Text_5 : 36|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Text_6 : 37|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_HYB_Text_7 : 38|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Text_Partikelfil_Reg : 41|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Oelmenge : 43|5@1+ (125,0) [0|3875] "Unit_MilliLiter" Gateway_MQB SG_ MO_Systemlampe : 48|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_OBD2_Lampe : 49|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Heissleuchte : 50|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Partikel_Lampe : 51|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Winterfahrprog : 52|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WIV_Oelstand_nicht_vorhanden : 53|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_nachfuellanzeige_ein : 54|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Ueberfuell_deaktiv : 55|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Unterfuell_Warn : 56|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Tankdeckel_Lampe : 57|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Text_Tankdeckelwarn : 58|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WIV_Oeldr_Warn_Motor : 60|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 1601 Motor_Code_01: 8 Motor_Diesel_MQB SG_ Motor_Code_01_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB SG_ Motor_Code_01_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_Faktor_Momente_02 : 12|2@1+ (1,0) [0|3] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Hybridfahrzeug : 14|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ MO_Code : 16|8@1+ (1,0) [0|255] "" Gateway_MQB,SAK_MQB SG_ MO_Getriebe_Code : 24|6@1+ (1,0) [0|63] "" Gateway_MQB SG_ MO_StartStopp_Codiert : 30|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Anzahl_Zyl : 32|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ MO_Kraftstoffart : 36|4@1+ (1,0) [0|15] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Hubraum : 40|7@1+ (0.1,0) [0|12.7] "Unit_Liter" Gateway_MQB SG_ MO_Ansaugsystem : 47|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ MO_Leistung : 48|9@1+ (1,0) [0|511] "Unit_KiloWatt" Gateway_MQB SG_ MO_Abgastyp_EOBD : 57|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB,LEH_MQB SG_ MO_Abgastyp_OBD : 58|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB,LEH_MQB SG_ MO_DPF_verbaut : 59|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ TSK_Codierung : 60|3@1+ (1,0) [0|7] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ MO_Einspritzart : 63|1@1+ (1,0) [0|1] "" Gateway_MQB BO_ 157 Motor_Hybrid_01: 8 Motor_Hybrid_MQB SG_ Motor_Hybrid_01_CRC : 0|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB SG_ Motor_Hybrid_01_BZ : 8|4@1+ (1,0) [0|15] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_IstStatusK0 : 12|2@1+ (1,0) [0|3] "" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_max_ind_VM_Mom : 16|10@1+ (1,0) [0|1021] "Unit_NewtoMeter" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_Zielzustand : 26|3@1+ (1,0) [0|7] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_Startmodus : 29|3@1+ (1,0) [0|7] "" Vector__XXX SG_ MO_HYB_Startmodus_PQ3x : 32|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_Stoppmodus : 33|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_VM_Mom_oE : 40|10@1+ (1,-100) [-100|922] "Unit_NewtoMeter" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_VM_aktiv : 50|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_Schaltverhinderung : 51|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB BO_ 811 Motor_Hybrid_02: 8 Motor_Hybrid_MQB SG_ MO_HYB_E_Faktor : 12|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_Drehzahl_VM : 16|16@1+ (0.25,0) [0|16256] "Unit_MinutInver" Getriebe_DQ_Hybrid_MQB SG_ MO_HYB_LowSpeedModus : 32|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB BO_ 2600468501 NMH_Airbag_01: 8 Airbag_MQB SG_ NM_Airbag_01_SNI : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Airbag_01_NM_State : 16|6@1+ (1,0) [0|63] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ NM_Airbag_01_Car_Wakeup : 22|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ NM_Airbag_01_Wakeup : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Airbag_01_NM_aktiv_KL15 : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Airbag_01_NM_aktiv_Diagnose : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Airbag_01_NM_aktiv_Tmin : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Airbag_01_UDS_CC : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 2600468604 NMH_EMotor_01: 8 LEH_MQB SG_ NM_EMotor_01_SNI : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_EMotor_01_NM_State : 16|6@1+ (1,0) [0|63] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ NM_EMotor_01_Car_Wakeup : 22|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ NM_EMotor_01_Wakeup : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_EMotor_01_NM_aktiv_KL15 : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_EMotor_01_NM_aktiv_Diagnose : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_EMotor_01_NM_aktiv_Tmin : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_EMotor_01_NL_Daten_EEPROM : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_EMotor_01_UDS_CC : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 2600468496 NMH_Gateway: 8 Gateway_MQB SG_ NM_Gateway_SNI : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Gateway_NM_State : 16|6@1+ (1,0) [0|63] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ NM_Gateway_Car_Wakeup : 22|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_Wakeup : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Gateway_NM_aktiv_KL15 : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_NM_aktiv_Diagnose : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_NM_aktiv_Tmin : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_ACAN_Aktivitaet : 35|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_FCAN_Aktivitaet : 36|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_KCAN_Aktivitaet : 37|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_ICAN_Aktivitaet : 38|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_DiagCAN_Aktivitaet : 39|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_ECAN_Aktivitaet : 40|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_Energie_LIN_Aktivi000 : 41|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_Bedien_LIN_Aktivitaet : 42|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_EM_Aktivitaet : 43|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_NL_EM : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_NL_Shutdown : 49|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_NL_Spg_Messung : 50|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_NL_Wakeup_Monitor : 51|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Gateway_UDS_CC : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 2600468599 NMH_Getriebe_01: 8 Getriebe_DQ_Hybrid_MQB SG_ NM_Getriebe_01_SNI : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Getriebe_01_NM_State : 16|6@1+ (1,0) [0|63] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ NM_Getriebe_01_Car_Wakeup : 22|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ NM_Getriebe_01_Wakeup : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Getriebe_01_NM_aktiv_KL15 : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_NM_aktiv_Diagnose : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_NM_aktiv_Tmin : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_NM_aktiv_v_gr_0 : 35|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_NM_aktiv_Pos_Erk : 36|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_NM_aktiv_Umg_Bed : 37|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_NL_Daten_EEPROM : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Getriebe_01_UDS_CC : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 2600468603 NMH_Hybrid_01: 8 BMS_MQB SG_ NM_Hybrid_01_SNI : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Hybrid_01_NM_State : 16|6@1+ (1,0) [0|63] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ NM_Hybrid_01_Car_Wakeup : 22|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ NM_Hybrid_01_Wakeup : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_Hybrid_01_NM_aktiv_KL15 : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Hybrid_01_NM_aktiv_Diagnose : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Hybrid_01_NM_aktiv_Tmin : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Hybrid_01_NL_Daten_EEPROM : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Hybrid_01_NL_Luefter : 49|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_Hybrid_01_UDS_CC : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 2600468598 NMH_MO_01: 8 Motor_Diesel_MQB SG_ NM_MO_01_SNI : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_MO_01_NM_State : 16|6@1+ (1,0) [0|63] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB,Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ NM_MO_01_Car_Wakeup : 22|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ NM_MO_01_Wakeup : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ NM_MO_01_NM_aktiv_KL15 : 32|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NM_aktiv_Diagnose : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NM_aktiv_Tmin : 34|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NM_aktiv_HV_Abschaltung : 35|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NM_aktiv_EKP_Vorlauf : 36|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NM_aktiv_STH_Betrieb : 37|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NL_Kuehlerluefter : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NL_Diagnose : 49|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NL_WFS : 50|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NL_EEPROM : 51|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_NL_Sonstige : 52|1@1+ (1,0) [0|1] "" Vector__XXX SG_ NM_MO_01_UDS_CC : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 913 OBD_01: 8 Motor_Diesel_MQB SG_ OBD_Calc_Load_Val : 0|8@1+ (0.39215686275,0) [0|100] "Unit_PerCent" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Eng_Cool_Temp : 8|8@1+ (1,-40) [-40|215] "Unit_DegreCelsi" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Abs_Throttle_Pos : 16|8@1+ (0.39215686275,0) [0|100] "Unit_PerCent" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Abs_Load_Val : 24|16@1+ (0.39215686275,0) [0|25700] "Unit_PerCent" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Abs_Pedal_Pos : 40|8@1+ (0.39215686275,0) [0|100] "Unit_PerCent" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Kaltstart_Denominator : 59|1@1+ (1,0) [0|1] "" BMS_MQB,LEH_MQB SG_ OBD_Minimum_Trip : 60|1@1+ (1,0) [0|1] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Driving_Cycle : 61|1@1+ (1,0) [0|1] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Warm_Up_Cycle : 62|1@1+ (1,0) [0|1] "" BMS_MQB,Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB SG_ OBD_Normed_Trip : 63|1@1+ (1,0) [0|1] "" BMS_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB,LEH_MQB BO_ 1630 OBD_Tankgeber_01: 8 Gateway_MQB SG_ OBD_TG_F_Status_1 : 0|4@1+ (1,0) [0|15] "" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_F_Status_2 : 4|4@1+ (1,0) [0|15] "" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_F_Status_3 : 8|4@1+ (1,0) [0|15] "" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_F_Status_4 : 12|4@1+ (1,0) [0|15] "" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_Sens_Rohwert_1 : 16|12@1+ (0.5,0) [0|2047.5] "Unit_Ohm" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_Sens_Rohwert_2 : 28|12@1+ (0.5,0) [0|2047.5] "Unit_Ohm" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_Sens_Rohwert_3 : 40|12@1+ (0.5,0) [0|2047.5] "Unit_Ohm" Motor_Hybrid_MQB,Motor_Otto_MQB SG_ OBD_TG_Sens_Rohwert_4 : 52|12@1+ (0.5,0) [0|2047.5] "Unit_Ohm" Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 1437 Remotestart_FFB: 8 Gateway_MQB SG_ RSF_Tastencode_1 : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ RSF_Tastencode_2 : 8|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Otto_MQB SG_ RSF_Tastencode_Maske : 16|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Otto_MQB BO_ 984 RGS_VL_01: 8 Airbag_MQB SG_ RGS_VL_Texte : 12|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ RGS_VL_Charisma_FahrPr : 14|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ RGS_VL_Charisma_Status : 18|2@1+ (1,0) [0|3] "" Gateway_MQB SG_ RGS_VL_aktiv : 21|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ RGS_VL_PC_Aktuator_Sitz : 25|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ RGS_VL_PC_Aktuator_Schiebedach : 26|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ RGS_VL_PC_Aktuator_Fenster : 27|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ RGS_VL_PC_Aktuator_Warnblinken : 28|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ RGS_VL_Precrash_Basis : 32|8@1+ (1,0) [0|255] "" Gateway_MQB SG_ RGS_VL_Precrash_Front : 40|8@1+ (1,0) [0|255] "" Gateway_MQB SG_ RGS_VL_Precrash_Rear : 48|8@1+ (1,0) [0|255] "" Gateway_MQB BO_ 1528 SAK_01: 8 SAK_MQB SG_ SAK_Charisma_FahrPr : 16|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ SAK_Charisma_Status : 20|2@1+ (1,0) [0|3] "" Gateway_MQB BO_ 1313 STH_01: 8 Gateway_MQB SG_ STH_Funk_ein : 0|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_Funk_aus : 1|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_Zusatzheizung : 2|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_LED : 3|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ STH_Pumpe_ein : 4|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_Geblaese : 5|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_EKP_Anst : 6|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ STH_Start_folgt : 7|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_Ventiloeffnungszeit : 8|6@1+ (1,0) [0|63] "Unit_Minut" Vector__XXX SG_ STH_Ventil_Status : 14|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_Waermeeintrag : 16|6@1+ (1,0) [0|63] "" Vector__XXX SG_ STH_KVS : 24|13@1+ (1,0) [0|8191] "Unit_MilliLiter" Vector__XXX SG_ STH_Fehlerstatus : 37|3@1+ (1,0) [0|7] "" Vector__XXX SG_ STH_Heizleistung : 40|8@1+ (1,0) [0|255] "" Vector__XXX SG_ STH_Wassertemp : 48|8@1+ (0.75,-40) [-40|142.25] "Unit_DegreCelsi" Vector__XXX SG_ STH_Motorvorwaermung : 59|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ STH_Servicemode : 60|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_war_aktiv : 61|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ STH_KVS_Ueberlauf : 62|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STH_KD_Fehler : 63|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 1172 STS_01: 8 Gateway_MQB SG_ STS_01_CRC : 0|8@1+ (1,0) [0|255] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ STS_01_BZ : 8|4@1+ (1,0) [0|15] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ STS_Car_not_under_theft : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Car_under_theft : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Anlassersperre : 15|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Typencodierung : 16|5@1+ (1,0) [0|31] "" Vector__XXX SG_ STS_LIN_aktiv : 23|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Standlicht : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Fahrlicht : 25|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Alarm_still : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Texte : 27|4@1+ (1,0) [0|15] "" Vector__XXX SG_ STS_Laderelais : 38|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Summer : 48|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Alarm_Blinker : 50|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Notstart : 51|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Signalhorn : 55|1@1+ (1,0) [0|1] "" Vector__XXX SG_ STS_Leerlaufschaltung : 56|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB BO_ 1413 Systeminfo_01: 8 Gateway_MQB SG_ SI_Sammel_SG_Fehler : 0|6@1+ (1,0) [0|60] "" Vector__XXX SG_ SI_Rollenmode : 6|2@1+ (1,0) [0|3] "" Vector__XXX SG_ SI_QRS_Mode : 8|1@1+ (1,0) [0|1] "" Motor_Diesel_MQB,Motor_Hybrid_MQB,Motor_Otto_MQB SG_ SI_T_Mode : 9|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_NWDF : 10|1@1+ (1,0) [0|1] "" SAK_MQB SG_ SI_NWDF_gueltig : 11|1@1+ (1,0) [0|1] "" SAK_MQB SG_ SI_Sammelfehler : 12|1@1+ (1,0) [0|1] "" Vector__XXX SG_ GW_KD_Fehler : 13|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_01 : 16|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_02 : 17|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_03 : 18|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_04 : 19|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_05 : 20|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_06 : 21|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_07 : 22|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_08 : 23|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_09 : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_10 : 25|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_11 : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_12 : 27|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_13 : 28|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_14 : 29|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SI_BUS_15 : 30|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 288 TSK_06: 8 Motor_Diesel_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Radbremsmom : 12|12@1+ (8,0) [0|32760] "Unit_NewtoMeter" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Status : 24|3@1+ (1,0) [0|7] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_v_Begrenzung_aktiv : 27|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Standby_Anf_ESP : 28|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ TSK_Freig_Verzoeg_Anf : 30|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Limiter_ausgewaehlt : 31|1@1+ (1,0) [0|1] "" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_ax_Getriebe_02 : 48|9@1+ (0.024,-2.016) [-2.016|10.224] "Unit_MeterPerSeconSquar" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ TSK_Zwangszusch_ESP : 57|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ TSK_zul_Regelabw : 58|6@1+ (0.024,0) [0|1.512] "Unit_MeterPerSeconSquar" Gateway_MQB,Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 798 TSK_07: 8 Motor_Diesel_MQB SG_ TSK_07_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB SG_ TSK_07_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ TSK_Wunschgeschw : 12|10@1+ (0.32,0) [0|326.72] "Unit_KiloMeterPerHour" Gateway_MQB SG_ TSK_Texte_Primaeranz : 48|5@1+ (1,0) [0|31] "" Gateway_MQB SG_ TSK_Limiter_Anzeige : 55|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ TSK_Status_Anzeige : 61|3@1+ (1,0) [0|7] "" Gateway_MQB BO_ 1716 VIN_01: 8 Gateway_MQB SG_ VIN_01_MUX M : 0|2@1+ (1,0) [0|3] "" Airbag_MQB SG_ KS_Geheimnis_1 m0 : 8|8@1+ (1,0) [0|255] "" Vector__XXX SG_ VIN_4 m1 : 8|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_11 m2 : 8|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ KS_Geheimnis_2 m0 : 16|8@1+ (1,0) [0|255] "" Vector__XXX SG_ VIN_5 m1 : 16|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_12 m2 : 16|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ KS_Geheimnis_3 m0 : 24|8@1+ (1,0) [0|255] "" Vector__XXX SG_ VIN_6 m1 : 24|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_13 m2 : 24|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ KS_Geheimnis_4 m0 : 32|8@1+ (1,0) [0|255] "" Vector__XXX SG_ VIN_7 m1 : 32|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_14 m2 : 32|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_1 m0 : 40|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_8 m1 : 40|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_15 m2 : 40|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_2 m0 : 48|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_9 m1 : 48|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_16 m2 : 48|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_3 m0 : 56|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_10 m1 : 56|8@1+ (1,0) [0|255] "" Airbag_MQB SG_ VIN_17 m2 : 56|8@1+ (1,0) [0|255] "" Airbag_MQB BO_ 175 Waehlhebel_03: 4 Waehlhebel_MQB SG_ WH_Status_Sperre : 0|3@1+ (1,0) [0|7] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_Initialisierung : 3|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_SensorPos_roh : 4|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_03_BZ : 8|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_SensorPos_roh_inv : 12|4@1+ (1,0) [0|15] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_Testergebnis : 16|8@1+ (1,0) [0|255] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_Test_Aktiv : 24|1@1+ (1,0) [0|1] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB SG_ WH_Status : 25|7@1+ (1,0) [0|127] "" Getriebe_DQ_Hybrid_MQB,Getriebe_DQ_MQB BO_ 916 WBA_03: 8 Getriebe_DQ_Hybrid_MQB SG_ WBA_03_CRC : 0|8@1+ (1,0) [0|255] "" Gateway_MQB SG_ WBA_03_BZ : 8|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ WBA_Fahrstufe_02 : 12|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ WBA_ZielFahrstufe : 16|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ WBA_GE_Warnung_02 : 20|4@1+ (1,0) [0|15] "" Gateway_MQB SG_ WBA_eing_Gang_02 : 24|4@1+ (1,0) [0|15] "" Gateway_MQB,Motor_Diesel_MQB,Motor_Otto_MQB SG_ WBA_GE_Texte : 28|3@1+ (1,0) [0|7] "" Gateway_MQB SG_ WBA_Segeln_aktiv : 31|1@1+ (1,0) [0|1] "" Gateway_MQB SG_ WBA_Schaltschema : 32|5@1+ (1,0) [0|31] "" Gateway_MQB BO_ 1602 WIV_01: 8 Motor_Diesel_MQB SG_ WIV_Verschleissindex : 0|16@1+ (2e-8,0) [0|0.00131068] "" Gateway_MQB SG_ WIV_Russindex : 16|16@1+ (2e-8,0) [0|0.00131068] "" Gateway_MQB SG_ WIV_t_min : 32|6@1+ (1,0) [0|63] "Unit_Month" Gateway_MQB SG_ WIV_t_max : 40|6@1+ (1,0) [0|63] "Unit_Month" Gateway_MQB SG_ WIV_W_min : 48|7@1+ (1000,0) [0|127000] "Unit_KiloMeter" Gateway_MQB SG_ WIV_W_max : 56|7@1+ (1000,0) [0|127000] "Unit_KiloMeter" Gateway_MQB BO_ 294 HCA_01: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 8|4@1+ (1,0) [0|255] "" XXX SG_ SET_ME_0X3 : 12|4@1+ (1,0) [0|15] "" XXX SG_ Assist_Torque : 16|14@1+ (1,0) [0|300] "Nm" XXX SG_ Assist_Requested : 30|1@1+ (1,0) [0|1] "" XXX SG_ Assist_VZ : 31|1@1+ (1,0) [0|1] "" XXX SG_ HCA_Available : 32|1@1+ (1,0) [0|1] "" XXX SG_ HCA_Standby : 33|1@1+ (1,0) [0|1] "" XXX SG_ HCA_Active : 34|1@1+ (1,0) [0|1] "" XXX SG_ SET_ME_0XFE : 40|8@1+ (1,0) [0|255] "" XXX SG_ SET_ME_0X07 : 48|8@1+ (1,0) [0|255] "" XXX BO_ 159 LH_EPS_03: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX SG_ EPS_DSR_Status : 12|4@1+ (1,0) [0|15] "" XXX SG_ EPS_Berechneter_LW : 16|12@1+ (0.15,0) [0|613.95] "Unit_DegreOfArc" XXX SG_ EPS_BLW_QBit : 30|1@1+ (1,0) [0|1] "" XXX SG_ EPS_VZ_BLW : 31|1@1+ (1,0) [0|1] "" XXX SG_ EPS_HCA_Status : 32|4@1+ (1,0) [0|15] "" XXX SG_ EPS_Lenkmoment : 40|10@1+ (1,0) [0|8] "Unit_centiNewtoMeter" XXX SG_ EPS_Lenkmoment_QBit : 54|1@1+ (1,0) [0|1] "" XXX SG_ EPS_VZ_Lenkmoment : 55|1@1+ (1,0) [0|1] "" XXX SG_ EPS_Lenkungstyp : 60|4@1+ (1,0) [0|15] "" XXX BO_ 286 VehicleSpeed: 8 XXX SG_ VehicleSpeed_CRC : 0|8@1+ (1,0) [0|255] "" XXX SG_ VehicleSpeed_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ Speed : 52|12@1+ (0.125,0) [0|1] "" XXX BO_ 919 LDW_02: 8 XXX SG_ LDW_Gong : 12|2@1+ (1,0) [0|3] "" XXX SG_ LDW_SW_Warnung_links : 14|1@1+ (1,0) [0|1] "" XXX SG_ LDW_SW_Warnung_rechts : 15|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Texte : 16|4@1+ (1,0) [0|15] "" XXX SG_ LDW_Seite_DLCTLC : 20|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Lernmodus : 21|3@1+ (1,0) [0|7] "" XXX SG_ LDW_Anlaufsp_VLR : 24|4@1+ (1,0) [0|15] "" XXX SG_ LDW_Vib_Amp_VLR : 28|4@1+ (1,0) [0|15] "" XXX SG_ LDW_Anlaufzeit_VLR : 32|4@1+ (1,0) [0|15] "" XXX SG_ LDW_Lernmodus_rechts : 36|2@1+ (1,0) [0|3] "" XXX SG_ LDW_Lernmodus_links : 38|2@1+ (1,0) [0|3] "" XXX SG_ LDW_DLC : 40|8@1+ (0.01,-1.25) [-1.25|1.25] "Unit_Meter" XXX SG_ LDW_TLC : 48|5@1+ (0.1,0) [0|3] "Unit_Secon" XXX SG_ LDW_Warnung_links : 56|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Warnung_rechts : 57|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Codierinfo_fuer_VLR : 58|2@1+ (1,0) [0|3] "" XXX SG_ LDW_Frontscheibenheizung_aktiv : 60|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Status_LED_gelb : 61|1@1+ (1,0) [0|1] "" XXX SG_ LDW_Status_LED_gruen : 62|1@1+ (1,0) [0|1] "" XXX SG_ LDW_KD_Fehler : 63|1@1+ (1,0) [0|1] "" XXX BO_ 780 ACC_02: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX SG_ ACC_Wunschgeschw : 12|10@1+ (0.32,0) [0.00|326.72] "Unit_KiloMeterPerHour" XXX SG_ ACC_Status_Prim_Anz : 22|2@1+ (1.0,0.0) [0.0|3] "" XXX SG_ ACC_Abstandsindex : 24|10@1+ (1,0) [1|1021] "" XXX SG_ ACC_Akustik : 34|3@1+ (1.0,0.0) [0.0|7] "" XXX SG_ ACC_Gesetzte_Zeitluecke : 37|3@1+ (1.0,0.0) [0.0|7] "" XXX SG_ ACC_Optischer_Fahrerhinweis : 40|1@1+ (1.0,0.0) [0.0|1] "" XXX SG_ ACC_Typ_Tachokranz : 41|1@1+ (1.0,0.0) [0.0|1] "" XXX SG_ ACC_Anzeige_Zeitluecke : 42|1@1+ (1.0,0.0) [0.0|1] "" XXX SG_ ACC_Tachokranz : 43|1@1+ (1.0,0.0) [0.0|1] "" XXX SG_ ACC_Display_Prio : 44|2@1+ (1.0,0.0) [0.0|3] "" XXX SG_ ACC_Relevantes_Objekt : 46|2@1+ (1.0,0.0) [0.0|3] "" XXX SG_ ACC_Texte_Primaeranz : 48|7@1+ (1.0,0.0) [0.0|127] "" XXX SG_ ACC_Wunschgeschw_erreicht : 55|1@1+ (1.0,0.0) [0.0|1] "" XXX SG_ ACC_Status_Anzeige : 61|3@1+ (1.0,0.0) [0.0|7] "" XXX BO_ 302 ACC_07: 8 XXX SG_ ACC_07_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ ACC_07_CRC : 0|8@1+ (1,0) [0|255] "" XXX BO_ 264 Fahrwerk_01: 8 XXX SG_ Fahrwerk_01_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ Fahrwerk_01_CRC : 0|8@1+ (1,0) [0|255] "" XXX BO_ 695 RCTA_01: 8 XXX SG_ RCTA_01_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ RCTA_01_CRC : 0|8@1+ (1,0) [0|255] "" XXX BO_ 783 SWA_01: 8 Gateway_MQB SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" Vector__XXX SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" Vector__XXX SG_ SWA_Anzeigen : 12|4@1+ (1,0) [0|15] "" Kombi_D4 SG_ SWA_Blindheit_erkannt : 16|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_rel_Nichtverf : 17|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_rel_Fehler : 18|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Sta_aktiv : 19|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Sta_passiv : 20|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Standziele_li : 24|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Kolonne_li : 25|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Infostufe_SWA_li : 26|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Warnung_SWA_li : 27|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Kolonne_mi : 33|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Standziele_re : 40|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Kolonne_re : 41|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Infostufe_SWA_re : 42|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Warnung_SWA_re : 43|1@1+ (1,0) [0|1] "" Vector__XXX SG_ SWA_Gischtzaehler : 48|7@1+ (1,0) [0|100] "Unit_PerCent" Vector__XXX SG_ SWA_KD_Fehler : 59|1@1+ (1,0) [0|1] "" Vector__XXX BO_ 804 ACC_04: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX SG_ ACC_Texte_Zusatzanz : 16|6@1+ (1.0,0.0) [0.0|63] "" XXX SG_ ACC_Status_Zusatzanz : 22|5@1+ (1.0,0.0) [0.0|31] "" XXX SG_ ACC_Texte : 27|5@1+ (1.0,0.0) [0.0|31] "" XXX SG_ ACC_Texte_braking_guard : 32|3@1+ (1.0,0.0) [0.0|7] "" XXX SG_ ACC_Warnhinweis : 35|1@1+ (1.0,0.0) [0.0|1] "" XXX SG_ ACC_Geschw_Zielfahrzeug : 40|10@1+ (0.32,0) [0.00|326.72] "Unit_KiloMeterPerHour" XXX SG_ ACC_Charisma_FahrPr : 56|3@1+ (1.0,0.0) [0.0|7] "" XXX SG_ ACC_Charisma_Status : 59|2@1+ (1.0,0.0) [0.0|3] "" XXX SG_ ACC_Charisma_Umschaltung : 61|2@1+ (1.0,0.0) [0.0|3] "" XXX BO_ 917 LWR_AFS_01: 8 XXX BO_ 991 Gateway_76: 8 XXX BO_ 997 TSG_FT_02: 8 XXX SG_ TSG_FT_02_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ TSG_FT_02_CRC : 0|8@1+ (1,0) [0|255] "" XXX BO_ 1175 Parkhilfe_01: 8 XXX BO_ 427 ESP_33: 8 XXX SG_ ESP_33_BZ : 8|4@1+ (1,0) [0|15] "" XXX SG_ ESP_33_CRC : 0|8@1+ (1,0) [0|255] "" XXX BO_ 418 ESP_15: 8 XXX SG_ ESP_15_CRC : 0|8@1+ (1,0) [0|255] "" XXX SG_ ESP_15_BZ : 8|4@1+ (1,0) [0|15] "" XXX BO_ 1122 PSD_04: 8 XXX SG_ PSD_Object_Index : 0|6@1+ (1,0) [0|63] "" XXX BO_ 1123 PSD_05: 8 XXX SG_ PSD_Current_Route_Index : 0|6@1+ (1,0) [0|63] "" XXX SG_ Route_Distance_Remaining : 8|5@1+ (1,0) [0|31] "" XXX BO_ 1124 PSD_06: 8 XXX BO_ 988 Gateway_73: 8 XXX BO_ 792 Kamera_Status: 8 XXX BO_ 981 Licht_Anf_01: 8 XXX BO_ 1440 RLS_01: 8 XXX BO_ 870 Blinkmodi_02: 8 XXX SG_ Hazard_Switch : 20|1@1+ (1,0) [0|1] "" XXX SG_ Comfort_Signal_Left : 23|1@1+ (1,0) [0|1] "" XXX SG_ Comfort_Signal_Right : 24|1@1+ (1,0) [0|1] "" XXX SG_ Left_Turn_Exterior_Bulb_1 : 25|1@1+ (1,0) [0|1] "" XXX SG_ Right_Turn_Exterior_Bulb_1 : 26|1@1+ (1,0) [0|1] "" XXX SG_ Left_Turn_Exterior_Bulb_2 : 27|1@1+ (1,0) [0|1] "" XXX SG_ Right_Turn_Exterior_Bulb_2 : 28|1@1+ (1,0) [0|1] "" XXX SG_ Fast_Send_Rate_Active : 37|1@1+ (1,0) [0|1] "" XXX BO_ 1385 HVEM_04: 8 XXX BO_ 1605 FLA_01: 8 XXX BO_ 1624 Licht_vorne_01: 8 XXX BO_ 1646 Klima_03: 8 XXX BO_ 1720 Kombi_03: 8 XXX BO_ 391 EV_Gearshift: 8 XXX SG_ CHECKSUM : 0|8@1+ (1,0) [0|255] "" XXX SG_ COUNTER : 8|4@1+ (1,0) [0|15] "" XXX SG_ GearPosition : 16|4@1+ (1,0) [0|255] "" XXX SG_ RegenBrakingMode : 12|2@1+ (1,0) [0|3] "" XXX CM_ SG_ 134 LWI_Lenkradwinkel "Steering angle WITH variable ratio effect included"; CM_ SG_ 159 EPS_HCA_Status "Status of Heading Control Assist feature" CM_ SG_ 159 EPS_Lenkmoment "Steering input by driver, torque"; CM_ SG_ 159 EPS_VZ_Lenkmoment "Steering input by driver, direction"; CM_ SG_ 159 EPS_Berechneter_LW "Raw steering angle, degrees"; CM_ SG_ 159 EPS_VZ_BLW "Raw steering angle, direction" CM_ SG_ 173 COUNTERXX "Message not renamed to COUNTER because J533 rate-limiting makes it look like messages are being lost"; CM_ SG_ 294 3 "May be zero when sent by older cameras"; CM_ SG_ 294 7 "May be zero when sent by older cameras"; CM_ SG_ 294 254 "May be zero when sent by older cameras"; CM_ SG_ 294 Assist_Torque "Heading control input, torque"; CM_ SG_ 294 Assist_VZ "Heading control input, direction (sign)"; CM_ SG_ 294 HCA_Available "Must be 1 for steering rack to accept HCA commands"; CM_ SG_ 870 Hazard_Switch "Four-way flashers active"; CM_ SG_ 870 Comfort_Signal_Left "Comfort turn signal active, left"; CM_ SG_ 870 Comfort_Signal_Right "Comfort turn signal active, right"; CM_ SG_ 870 Left_Turn_Exterior_Bulb_1 "Probably front"; CM_ SG_ 870 Right_Turn_Exterior_Bulb_1 "Probably front"; CM_ SG_ 870 Left_Turn_Exterior_Bulb_2 "Probably rear"; CM_ SG_ 870 Right_Turn_Exterior_Bulb_2 "Probably rear"; CM_ SG_ 870 Fast_Send_Rate_Active "CAN message send rate"; CM_ SG_ 919 LDW_DLC "Probable DLC (distance to line crossing)"; CM_ SG_ 919 LDW_TLC "Probable TLC (time to line crossing)"; CM_ SG_ 919 LDW_Unknown "Might be a steering pressed / driver active flag"; CM_ SG_ 919 Alert_Message "Static table of alert messages to be invoked in the instrument cluster, some with or without beeps, 0 = no current message"; CM_ SG_ 919 LDW_Direction "Left/right indicator for DLC and TLC"; CM_ SG_ 919 Right_Lane_Status "Display brightness range, 0 = no lane, 3 = full brightness"; CM_ SG_ 919 Left_Lane_Status "Display brightness range, 0 = no lane, 3 = full brightness"; CM_ SG_ 919 Kombi_Lamp_Orange "Enables orange LDW light in instrument cluster"; CM_ SG_ 919 Kombi_Lamp_Green "Enables green LDW light in instrument cluster"; CM_ SG_ 780 Folgefahrt "Following another vehicle"; CM_ SG_ 780 SetAbstand "Set following distance"; CM_ SG_ 780 Abstand "Following distance"; CM_ SG_ 780 SetSpeed "ACC set speed"; CM_ SG_ 391 GearPosition "Traditional PRND plus B-mode aggressive regen, B-mode mapped to Drive"; CM_ SG_ 960 ZAS_Kl_15 "Indicates ignition on"; VAL_ 159 EPS_HCA_Status 0 "disabled" 1 "initializing" 2 "fault" 3 "ready" 4 "rejected" 5 "active"; VAL_ 173 GE_Fahrstufe 5 "P" 6 "R" 7 "N" 8 "D" 9 "S" 10 "E" 14 "T"; VAL_ 391 GearPosition 2 "P" 3 "R" 4 "N" 5 "D" 6 "D"; VAL_ 391 RegenBrakingMode 0 "default" 1 "B1" 2 "B2" 3 "B3"; VAL_ 870 Fast_Send_Rate_Active 0 "1 Hz" 1 "50 Hz"; ================================================ FILE: panda/.gitignore ================================================ *.pyc .*.swp .*.swo *.o *.so *.os *.d *.dump a.out *~ .#* dist/ pandacan.egg-info/ board/obj/ examples/output.csv .DS_Store .vscode* nosetests.xml .mypy_cache/ .sconsign.dblite ================================================ FILE: panda/__init__.py ================================================ # flake8: noqa # pylint: skip-file from .python import Panda, PandaWifiStreaming, PandaDFU, flash_release, \ BASEDIR, ensure_st_up_to_date, PandaSerial, \ DEFAULT_FW_FN, DEFAULT_H7_FW_FN, MCU_TYPE_H7, MCU_TYPE_F4 from .python.config import BOOTSTUB_ADDRESS, BLOCK_SIZE_FX, APP_ADDRESS_FX, \ BLOCK_SIZE_H7, APP_ADDRESS_H7, DEVICE_SERIAL_NUMBER_ADDR_H7, \ DEVICE_SERIAL_NUMBER_ADDR_FX ================================================ FILE: panda/board/Makefile ================================================ ================================================ FILE: panda/board/README.md ================================================ Dependencies -------- **Mac** ``` xcode-select --install ./get_sdk_mac.sh ``` **Debian / Ubuntu** ``` ./get_sdk.sh ``` Programming ---- **Panda** ``` scons -u # Compile ./flash.sh # Compile & Flash ``` Troubleshooting ---- If your panda will not flash and is quickly blinking a single Green LED, use: ``` ./recover.sh ``` [dfu-util](http://github.com/dsigma/dfu-util.git) for flashing ================================================ FILE: panda/board/SConscript ================================================ import os import subprocess PREFIX = "arm-none-eabi-" BUILDER = "DEV" if os.getenv("PEDAL"): PROJECT = "pedal" STARTUP_FILE = "stm32fx/startup_stm32f205xx.s" LINKER_SCRIPT = "stm32fx/stm32fx_flash.ld" APP_START_ADDRESS = "0x8004000" MAIN = "pedal/main.c" PROJECT_FLAGS = [ "-mcpu=cortex-m3", "-msoft-float", "-DSTM32F2", "-DSTM32F205xx", "-O2", "-DPEDAL", ] if os.getenv("PEDAL_USB"): PROJECT = "pedal_usb" PROJECT_FLAGS.append("-DPEDAL_USB") elif os.getenv("PANDA_H7"): PROJECT = "panda_h7" STARTUP_FILE = "stm32h7/startup_stm32h7x5xx.s" LINKER_SCRIPT = "stm32h7/stm32h7x5_flash.ld" APP_START_ADDRESS = "0x8020000" MAIN = "main.c" PROJECT_FLAGS = [ "-mcpu=cortex-m7", "-mhard-float", "-DSTM32H7", "-DSTM32H725xx", "-mfpu=fpv5-d16", "-fsingle-precision-constant", "-Os", "-g", "-DPANDA", ] else: PROJECT = "panda" STARTUP_FILE = "stm32fx/startup_stm32f413xx.s" LINKER_SCRIPT = "stm32fx/stm32fx_flash.ld" APP_START_ADDRESS = "0x8004000" MAIN = "main.c" PROJECT_FLAGS = [ "-mcpu=cortex-m4", "-mhard-float", "-DSTM32F4", "-DSTM32F413xx", "-mfpu=fpv4-sp-d16", "-fsingle-precision-constant", "-Os", "-g", "-DPANDA", ] if FindFile('dp_vw_panda', '/data/params/d') != None: with open('/data/params/d/dp_vw_panda') as f: if (int(f.read().strip())) == 1: PROJECT_FLAGS += ['-Dvw'] def get_version(builder, build_type): try: git = subprocess.check_output(["git", "rev-parse", "--short=8", "HEAD"], encoding='utf8').strip() except subprocess.CalledProcessError: git = "unknown" return f"{builder}-{git}-{build_type}" def to_c_uint32(x): nums = [] for _ in range(0x20): nums.append(x % (2**32)) x //= (2**32) return "{" + 'U,'.join(map(str, nums)) + "U}" def get_key_header(name): from Crypto.PublicKey import RSA public_fn = File(f'../certs/{name}.pub').srcnode().abspath rsa = RSA.importKey(open(public_fn).read()) assert(rsa.size_in_bits() == 1024) rr = pow(2**1024, 2, rsa.n) n0inv = 2**32 - pow(rsa.n, -1, 2**32) r = [ f"RSAPublicKey {name}_rsa_key = {{", f" .len = 0x20,", f" .n0inv = {n0inv}U,", f" .n = {to_c_uint32(rsa.n)},", f" .rr = {to_c_uint32(rr)},", f" .exponent = {rsa.e},", f"}};", ] return r def objcopy(source, target, env, for_signature): return '$OBJCOPY -O binary %s %s' % (source[0], target[0]) linkerscript_fn = File(LINKER_SCRIPT).srcnode().abspath flags = [ "-Wall", "-Wextra", "-Wstrict-prototypes", "-Werror", "-mlittle-endian", "-mthumb", "-nostdlib", "-fno-builtin", f"-T{linkerscript_fn}", "-std=gnu11", ] + PROJECT_FLAGS if os.getenv("RELEASE"): BUILD_TYPE = "RELEASE" cert_fn = os.getenv("CERT") assert cert_fn is not None, 'No certificate file specified. Please set CERT env variable' assert os.path.exists(cert_fn), 'Certificate file not found. Please specify absolute path' else: BUILD_TYPE = "DEBUG" cert_fn = File("../certs/debug").srcnode().abspath flags += ["-DALLOW_DEBUG"] includes = [ "stm32fx/inc", "stm32h7/inc", "..", ".", ] panda_env = Environment( ENV=os.environ, CC=PREFIX + 'gcc', AS=PREFIX + 'gcc', OBJCOPY=PREFIX + 'objcopy', OBJDUMP=PREFIX + 'objdump', ASCOM="$AS $ASFLAGS -o $TARGET -c $SOURCES", CFLAGS=flags, ASFLAGS=flags, LINKFLAGS=flags, CPPPATH=includes, BUILDERS={ 'Objcopy': Builder(generator=objcopy, suffix='.bin', src_suffix='.elf') } ) # Common autogenerated includes version = f'const uint8_t gitversion[] = "{get_version(BUILDER, BUILD_TYPE)}";' gitversion = panda_env.Textfile("obj/gitversion.h", [version, ""]) Ignore('bootstub.o', gitversion) Requires('bootstub.o', gitversion) Ignore('main.o', gitversion) Requires('main.o', gitversion) certs = [get_key_header(n) for n in ["debug", "release"]] certheader = panda_env.Textfile("obj/cert.h", certs + [""]) startup = panda_env.Object(STARTUP_FILE) # Bootstub crypto = ["../crypto/rsa.c", "../crypto/sha.c"] bootstub_elf = panda_env.Program(f"obj/bootstub.{PROJECT}.elf", [startup] + crypto + ["bootstub.c"]) bootstub_bin = panda_env.Objcopy(f"obj/bootstub.{PROJECT}.bin", bootstub_elf) # Build main main_elf = panda_env.Program(f"obj/{PROJECT}.elf", [startup, MAIN], LINKFLAGS=[f"-Wl,--section-start,.isr_vector={APP_START_ADDRESS}"] + flags) main_bin = panda_env.Objcopy(f"obj/{PROJECT}.bin", main_elf) # Sign main sign_py = File("../crypto/sign.py").srcnode().abspath panda_bin_signed = panda_env.Command(f"obj/{PROJECT}.bin.signed", main_bin, f"SETLEN=1 {sign_py} $SOURCE $TARGET {cert_fn}") ================================================ FILE: panda/board/__init__.py ================================================ ================================================ FILE: panda/board/boards/black.h ================================================ // ///////////////////// // // Black Panda + Harness // // ///////////////////// // void black_enable_can_transceiver(uint8_t transceiver, bool enabled) { switch (transceiver){ case 1U: set_gpio_output(GPIOC, 1, !enabled); break; case 2U: set_gpio_output(GPIOC, 13, !enabled); break; case 3U: set_gpio_output(GPIOA, 0, !enabled); break; case 4U: set_gpio_output(GPIOB, 10, !enabled); break; default: puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } void black_enable_can_transceivers(bool enabled) { for(uint8_t i=1U; i<=4U; i++){ // Leave main CAN always on for CAN-based ignition detection if((car_harness_status == HARNESS_STATUS_FLIPPED) ? (i == 3U) : (i == 1U)){ black_enable_can_transceiver(i, true); } else { black_enable_can_transceiver(i, enabled); } } } void black_set_led(uint8_t color, bool enabled) { switch (color){ case LED_RED: set_gpio_output(GPIOC, 9, !enabled); break; case LED_GREEN: set_gpio_output(GPIOC, 7, !enabled); break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); break; default: break; } } void black_set_gps_load_switch(bool enabled) { set_gpio_output(GPIOC, 12, enabled); } void black_set_usb_load_switch(bool enabled) { set_gpio_output(GPIOB, 1, !enabled); } void black_set_usb_power_mode(uint8_t mode) { bool valid = false; switch (mode) { case USB_POWER_CLIENT: black_set_usb_load_switch(false); valid = true; break; case USB_POWER_CDP: black_set_usb_load_switch(true); valid = true; break; default: puts("Invalid USB power mode\n"); break; } if (valid) { usb_power_mode = mode; } } void black_set_gps_mode(uint8_t mode) { switch (mode) { case GPS_DISABLED: // GPS OFF set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); break; case GPS_ENABLED: // GPS ON set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); break; case GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); break; default: puts("Invalid GPS mode\n"); break; } } void black_set_can_mode(uint8_t mode){ switch (mode) { case CAN_MODE_NORMAL: case CAN_MODE_OBD_CAN2: if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { // B12,B13: disable OBD mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); } else { // B5,B6: disable normal CAN2 mode set_gpio_mode(GPIOB, 5, MODE_INPUT); set_gpio_mode(GPIOB, 6, MODE_INPUT); // B12,B13: OBD mode set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); } break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); break; } } bool black_check_ignition(void){ // ignition is checked through harness return harness_check_ignition(); } void black_init(void) { common_init_gpio(); // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); // C0: OBD_SBU1 (orientation detection) // C3: OBD_SBU2 (orientation detection) set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 3, MODE_ANALOG); // Set default state of GPS current_board->set_gps_mode(GPS_ENABLED); // C10: OBD_SBU1_RELAY (harness relay driving output) // C11: OBD_SBU2_RELAY (harness relay driving output) set_gpio_mode(GPIOC, 10, MODE_OUTPUT); set_gpio_mode(GPIOC, 11, MODE_OUTPUT); set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_output(GPIOC, 10, 1); set_gpio_output(GPIOC, 11, 1); // Turn on GPS load switch. black_set_gps_load_switch(true); // Turn on USB load switch. black_set_usb_load_switch(true); // Set right power mode black_set_usb_power_mode(USB_POWER_CDP); // Initialize harness harness_init(); // Enable CAN transceivers black_enable_can_transceivers(true); // Disable LEDs black_set_led(LED_RED, false); black_set_led(LED_GREEN, false); black_set_led(LED_BLUE, false); // Set normal CAN mode black_set_can_mode(CAN_MODE_NORMAL); // flip CAN0 and CAN2 if we are flipped if (car_harness_status == HARNESS_STATUS_FLIPPED) { can_flip_buses(0, 2); } } const harness_configuration black_harness_config = { .has_harness = true, .GPIO_SBU1 = GPIOC, .GPIO_SBU2 = GPIOC, .GPIO_relay_SBU1 = GPIOC, .GPIO_relay_SBU2 = GPIOC, .pin_SBU1 = 0, .pin_SBU2 = 3, .pin_relay_SBU1 = 10, .pin_relay_SBU2 = 11, .adc_channel_SBU1 = 10, .adc_channel_SBU2 = 13 }; const board board_black = { .board_type = "Black", .harness_config = &black_harness_config, .has_gps = true, .has_hw_gmlan = false, .has_obd = true, .has_lin = false, .has_rtc = false, .init = black_init, .enable_can_transceiver = black_enable_can_transceiver, .enable_can_transceivers = black_enable_can_transceivers, .set_led = black_set_led, .set_usb_power_mode = black_set_usb_power_mode, .set_gps_mode = black_set_gps_mode, .set_can_mode = black_set_can_mode, .usb_power_mode_tick = unused_usb_power_mode_tick, .check_ignition = black_check_ignition, .read_current = unused_read_current, .set_fan_power = unused_set_fan_power, .set_ir_power = unused_set_ir_power, .set_phone_power = unused_set_phone_power, .set_clock_source_mode = unused_set_clock_source_mode, .set_siren = unused_set_siren }; ================================================ FILE: panda/board/boards/board_declarations.h ================================================ // ******************** Prototypes ******************** typedef void (*board_init)(void); typedef void (*board_enable_can_transceiver)(uint8_t transceiver, bool enabled); typedef void (*board_enable_can_transceivers)(bool enabled); typedef void (*board_set_led)(uint8_t color, bool enabled); typedef void (*board_set_usb_power_mode)(uint8_t mode); typedef void (*board_set_gps_mode)(uint8_t mode); typedef void (*board_set_can_mode)(uint8_t mode); typedef void (*board_usb_power_mode_tick)(uint32_t uptime); typedef bool (*board_check_ignition)(void); typedef uint32_t (*board_read_current)(void); typedef void (*board_set_ir_power)(uint8_t percentage); typedef void (*board_set_fan_power)(uint8_t percentage); typedef void (*board_set_phone_power)(bool enabled); typedef void (*board_set_clock_source_mode)(uint8_t mode); typedef void (*board_set_siren)(bool enabled); struct board { const char *board_type; const harness_configuration *harness_config; const bool has_gps; const bool has_hw_gmlan; const bool has_obd; const bool has_lin; const bool has_rtc; board_init init; board_enable_can_transceiver enable_can_transceiver; board_enable_can_transceivers enable_can_transceivers; board_set_led set_led; board_set_usb_power_mode set_usb_power_mode; board_set_gps_mode set_gps_mode; board_set_can_mode set_can_mode; board_usb_power_mode_tick usb_power_mode_tick; board_check_ignition check_ignition; board_read_current read_current; board_set_ir_power set_ir_power; board_set_fan_power set_fan_power; board_set_phone_power set_phone_power; board_set_clock_source_mode set_clock_source_mode; board_set_siren set_siren; }; // ******************* Definitions ******************** // These should match the enums in cereal/log.capnp and __init__.py #define HW_TYPE_UNKNOWN 0U #define HW_TYPE_WHITE_PANDA 1U #define HW_TYPE_GREY_PANDA 2U #define HW_TYPE_BLACK_PANDA 3U #define HW_TYPE_PEDAL 4U #define HW_TYPE_UNO 5U #define HW_TYPE_DOS 6U #define HW_TYPE_RED_PANDA 7U // LED colors #define LED_RED 0U #define LED_GREEN 1U #define LED_BLUE 2U // USB power modes (from cereal.log.health) #define USB_POWER_NONE 0U #define USB_POWER_CLIENT 1U #define USB_POWER_CDP 2U #define USB_POWER_DCP 3U // GPS modes #define GPS_DISABLED 0U #define GPS_ENABLED 1U #define GPS_BOOTMODE 2U // CAN modes #define CAN_MODE_NORMAL 0U #define CAN_MODE_GMLAN_CAN2 1U #define CAN_MODE_GMLAN_CAN3 2U #define CAN_MODE_OBD_CAN2 3U // ********************* Globals ********************** uint8_t usb_power_mode = USB_POWER_NONE; ================================================ FILE: panda/board/boards/dos.h ================================================ // ///////////// // // Dos + Harness // // ///////////// // void dos_enable_can_transceiver(uint8_t transceiver, bool enabled) { switch (transceiver){ case 1U: set_gpio_output(GPIOC, 1, !enabled); break; case 2U: set_gpio_output(GPIOC, 13, !enabled); break; case 3U: set_gpio_output(GPIOA, 0, !enabled); break; case 4U: set_gpio_output(GPIOB, 10, !enabled); break; default: puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } void dos_enable_can_transceivers(bool enabled) { for(uint8_t i=1U; i<=4U; i++){ // Leave main CAN always on for CAN-based ignition detection if((car_harness_status == HARNESS_STATUS_FLIPPED) ? (i == 3U) : (i == 1U)){ dos_enable_can_transceiver(i, true); } else { dos_enable_can_transceiver(i, enabled); } } } void dos_set_led(uint8_t color, bool enabled) { switch (color){ case LED_RED: set_gpio_output(GPIOC, 9, !enabled); break; case LED_GREEN: set_gpio_output(GPIOC, 7, !enabled); break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); break; default: break; } } void dos_set_bootkick(bool enabled){ set_gpio_output(GPIOC, 4, !enabled); } void dos_set_usb_power_mode(uint8_t mode) { bool valid = false; switch (mode) { case USB_POWER_CLIENT: dos_set_bootkick(false); valid = true; break; case USB_POWER_CDP: dos_set_bootkick(true); valid = true; break; default: puts("Invalid USB power mode\n"); break; } if (valid) { usb_power_mode = mode; } } void dos_set_can_mode(uint8_t mode){ switch (mode) { case CAN_MODE_NORMAL: case CAN_MODE_OBD_CAN2: if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { // B12,B13: disable OBD mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); } else { // B5,B6: disable normal CAN2 mode set_gpio_mode(GPIOB, 5, MODE_INPUT); set_gpio_mode(GPIOB, 6, MODE_INPUT); // B12,B13: OBD mode set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); } break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); break; } } bool dos_check_ignition(void){ // ignition is checked through harness return harness_check_ignition(); } void dos_set_usb_switch(bool phone){ set_gpio_output(GPIOB, 3, phone); } void dos_set_ir_power(uint8_t percentage){ pwm_set(TIM4, 2, percentage); } void dos_set_fan_power(uint8_t percentage){ // Enable fan power only if percentage is non-zero. set_gpio_output(GPIOA, 1, (percentage != 0U)); fan_set_power(percentage); } void dos_set_clock_source_mode(uint8_t mode){ clock_source_init(mode); } void dos_set_siren(bool enabled){ set_gpio_output(GPIOC, 12, enabled); } void dos_init(void) { common_init_gpio(); // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); // C0: OBD_SBU1 (orientation detection) // C3: OBD_SBU2 (orientation detection) set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 3, MODE_ANALOG); // C10: OBD_SBU1_RELAY (harness relay driving output) // C11: OBD_SBU2_RELAY (harness relay driving output) set_gpio_mode(GPIOC, 10, MODE_OUTPUT); set_gpio_mode(GPIOC, 11, MODE_OUTPUT); set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_output(GPIOC, 10, 1); set_gpio_output(GPIOC, 11, 1); // C8: FAN PWM aka TIM3_CH3 set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); // Initialize IR PWM and set to 0% set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4); pwm_init(TIM4, 2); dos_set_ir_power(0U); // Initialize fan and set to 0% fan_init(); dos_set_fan_power(0U); // Initialize harness harness_init(); // Initialize RTC rtc_init(); // Enable CAN transceivers dos_enable_can_transceivers(true); // Disable LEDs dos_set_led(LED_RED, false); dos_set_led(LED_GREEN, false); dos_set_led(LED_BLUE, false); // Set normal CAN mode dos_set_can_mode(CAN_MODE_NORMAL); // flip CAN0 and CAN2 if we are flipped if (car_harness_status == HARNESS_STATUS_FLIPPED) { can_flip_buses(0, 2); } // Init clock source as internal free running dos_set_clock_source_mode(CLOCK_SOURCE_MODE_FREE_RUNNING); } const harness_configuration dos_harness_config = { .has_harness = true, .GPIO_SBU1 = GPIOC, .GPIO_SBU2 = GPIOC, .GPIO_relay_SBU1 = GPIOC, .GPIO_relay_SBU2 = GPIOC, .pin_SBU1 = 0, .pin_SBU2 = 3, .pin_relay_SBU1 = 10, .pin_relay_SBU2 = 11, .adc_channel_SBU1 = 10, .adc_channel_SBU2 = 13 }; const board board_dos = { .board_type = "Dos", .harness_config = &dos_harness_config, .has_gps = false, .has_hw_gmlan = false, .has_obd = true, .has_lin = false, .has_rtc = true, .init = dos_init, .enable_can_transceiver = dos_enable_can_transceiver, .enable_can_transceivers = dos_enable_can_transceivers, .set_led = dos_set_led, .set_usb_power_mode = dos_set_usb_power_mode, .set_gps_mode = unused_set_gps_mode, .set_can_mode = dos_set_can_mode, .usb_power_mode_tick = unused_usb_power_mode_tick, .check_ignition = dos_check_ignition, .read_current = unused_read_current, .set_fan_power = dos_set_fan_power, .set_ir_power = dos_set_ir_power, .set_phone_power = unused_set_phone_power, .set_clock_source_mode = dos_set_clock_source_mode, .set_siren = dos_set_siren }; ================================================ FILE: panda/board/boards/grey.h ================================================ // ////////// // // Grey Panda // // ////////// // // Most hardware functionality is similar to white panda void grey_init(void) { white_grey_common_init(); // Set default state of GPS current_board->set_gps_mode(GPS_ENABLED); } void grey_set_gps_mode(uint8_t mode) { switch (mode) { case GPS_DISABLED: // GPS OFF set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); break; case GPS_ENABLED: // GPS ON set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); break; case GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); break; default: puts("Invalid ESP/GPS mode\n"); break; } } const board board_grey = { .board_type = "Grey", .harness_config = &white_harness_config, .has_gps = true, .has_hw_gmlan = true, .has_obd = false, .has_lin = true, .has_rtc = false, .init = grey_init, .enable_can_transceiver = white_enable_can_transceiver, .enable_can_transceivers = white_enable_can_transceivers, .set_led = white_set_led, .set_usb_power_mode = white_set_usb_power_mode, .set_gps_mode = grey_set_gps_mode, .set_can_mode = white_set_can_mode, .usb_power_mode_tick = unused_usb_power_mode_tick, .check_ignition = white_check_ignition, .read_current = white_read_current, .set_fan_power = unused_set_fan_power, .set_ir_power = unused_set_ir_power, .set_phone_power = unused_set_phone_power, .set_clock_source_mode = unused_set_clock_source_mode, .set_siren = unused_set_siren }; ================================================ FILE: panda/board/boards/pedal.h ================================================ // ///// // // Pedal // // ///// // void pedal_enable_can_transceiver(uint8_t transceiver, bool enabled) { switch (transceiver){ case 1: set_gpio_output(GPIOB, 3, !enabled); break; default: puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } void pedal_enable_can_transceivers(bool enabled) { pedal_enable_can_transceiver(1U, enabled); } void pedal_set_led(uint8_t color, bool enabled) { switch (color){ case LED_RED: set_gpio_output(GPIOB, 10, !enabled); break; case LED_GREEN: set_gpio_output(GPIOB, 11, !enabled); break; default: break; } } void pedal_set_usb_power_mode(uint8_t mode){ usb_power_mode = mode; puts("Trying to set USB power mode on pedal. This is not supported.\n"); } void pedal_set_gps_mode(uint8_t mode) { UNUSED(mode); puts("Trying to set ESP/GPS mode on pedal. This is not supported.\n"); } void pedal_set_can_mode(uint8_t mode){ switch (mode) { case CAN_MODE_NORMAL: break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); break; } } bool pedal_check_ignition(void){ // not supported on pedal return false; } void pedal_init(void) { common_init_gpio(); // C0, C1: Throttle inputs set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 1, MODE_ANALOG); // DAC outputs on A4 and A5 // apparently they don't need GPIO setup // Enable transceiver pedal_enable_can_transceivers(true); // Disable LEDs pedal_set_led(LED_RED, false); pedal_set_led(LED_GREEN, false); } const harness_configuration pedal_harness_config = { .has_harness = false }; const board board_pedal = { .board_type = "Pedal", .harness_config = &pedal_harness_config, .has_gps = false, .has_hw_gmlan = false, .has_obd = false, .has_lin = false, .has_rtc = false, .init = pedal_init, .enable_can_transceiver = pedal_enable_can_transceiver, .enable_can_transceivers = pedal_enable_can_transceivers, .set_led = pedal_set_led, .set_usb_power_mode = pedal_set_usb_power_mode, .set_gps_mode = pedal_set_gps_mode, .set_can_mode = pedal_set_can_mode, .usb_power_mode_tick = unused_usb_power_mode_tick, .check_ignition = pedal_check_ignition, .read_current = unused_read_current, .set_fan_power = unused_set_fan_power, .set_ir_power = unused_set_ir_power, .set_phone_power = unused_set_phone_power, .set_clock_source_mode = unused_set_clock_source_mode, .set_siren = unused_set_siren }; ================================================ FILE: panda/board/boards/red.h ================================================ // ///////////////////// // // Red Panda + Harness // // ///////////////////// // void red_enable_can_transceiver(uint8_t transceiver, bool enabled) { switch (transceiver) { case 1U: set_gpio_output(GPIOG, 11, !enabled); break; case 2U: set_gpio_output(GPIOB, 3, !enabled); break; case 3U: set_gpio_output(GPIOD, 7, !enabled); break; case 4U: set_gpio_output(GPIOB, 4, !enabled); break; default: break; } } void red_enable_can_transceivers(bool enabled) { uint8_t main_bus = (car_harness_status == HARNESS_STATUS_FLIPPED) ? 3U : 1U; for (uint8_t i=1U; i<=4U; i++) { // Leave main CAN always on for CAN-based ignition detection if (i == main_bus) { red_enable_can_transceiver(i, true); } else { red_enable_can_transceiver(i, enabled); } } } void red_set_led(uint8_t color, bool enabled) { switch (color) { case LED_RED: set_gpio_output(GPIOE, 4, !enabled); break; case LED_GREEN: set_gpio_output(GPIOE, 3, !enabled); break; case LED_BLUE: set_gpio_output(GPIOE, 2, !enabled); break; default: break; } } void red_set_usb_load_switch(bool enabled) { set_gpio_output(GPIOB, 14, !enabled); } void red_set_usb_power_mode(uint8_t mode) { bool valid = false; switch (mode) { case USB_POWER_CLIENT: red_set_usb_load_switch(false); valid = true; break; case USB_POWER_CDP: red_set_usb_load_switch(true); valid = true; break; default: break; } if (valid) { usb_power_mode = mode; } } void red_set_can_mode(uint8_t mode) { switch (mode) { case CAN_MODE_NORMAL: case CAN_MODE_OBD_CAN2: if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { // B12,B13: disable normal mode set_gpio_pullup(GPIOB, 12, PULL_NONE); set_gpio_mode(GPIOB, 12, MODE_ANALOG); set_gpio_pullup(GPIOB, 13, PULL_NONE); set_gpio_mode(GPIOB, 13, MODE_ANALOG); // B5,B6: FDCAN2 mode set_gpio_pullup(GPIOB, 5, PULL_NONE); set_gpio_alternate(GPIOB, 5, GPIO_AF9_FDCAN2); set_gpio_pullup(GPIOB, 6, PULL_NONE); set_gpio_alternate(GPIOB, 6, GPIO_AF9_FDCAN2); } else { // B5,B6: disable normal mode set_gpio_pullup(GPIOB, 5, PULL_NONE); set_gpio_mode(GPIOB, 5, MODE_ANALOG); set_gpio_pullup(GPIOB, 6, PULL_NONE); set_gpio_mode(GPIOB, 6, MODE_ANALOG); // B12,B13: FDCAN2 mode set_gpio_pullup(GPIOB, 12, PULL_NONE); set_gpio_alternate(GPIOB, 12, GPIO_AF9_FDCAN2); set_gpio_pullup(GPIOB, 13, PULL_NONE); set_gpio_alternate(GPIOB, 13, GPIO_AF9_FDCAN2); } break; default: break; } } bool red_check_ignition(void) { // ignition is checked through harness return harness_check_ignition(); } void red_init(void) { common_init_gpio(); //C4,A1: OBD_SBU1, OBD_SBU2 set_gpio_pullup(GPIOC, 4, PULL_NONE); set_gpio_mode(GPIOC, 4, MODE_ANALOG); set_gpio_pullup(GPIOA, 1, PULL_NONE); set_gpio_mode(GPIOA, 1, MODE_ANALOG); //C10,C11 : OBD_SBU1_RELAY, OBD_SBU2_RELAY set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_pullup(GPIOC, 10, PULL_NONE); set_gpio_mode(GPIOC, 10, MODE_OUTPUT); set_gpio_output(GPIOC, 10, 1); set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_pullup(GPIOC, 11, PULL_NONE); set_gpio_mode(GPIOC, 11, MODE_OUTPUT); set_gpio_output(GPIOC, 11, 1); // Turn on USB load switch. red_set_usb_load_switch(true); // Set right power mode red_set_usb_power_mode(USB_POWER_CDP); // Initialize harness harness_init(); // Enable CAN transceivers red_enable_can_transceivers(true); // Disable LEDs red_set_led(LED_RED, false); red_set_led(LED_GREEN, false); red_set_led(LED_BLUE, false); // Set normal CAN mode red_set_can_mode(CAN_MODE_NORMAL); // flip CAN0 and CAN2 if we are flipped if (car_harness_status == HARNESS_STATUS_FLIPPED) { can_flip_buses(0, 2); } } const harness_configuration red_harness_config = { .has_harness = true, .GPIO_SBU1 = GPIOC, .GPIO_SBU2 = GPIOA, .GPIO_relay_SBU1 = GPIOC, .GPIO_relay_SBU2 = GPIOC, .pin_SBU1 = 4, .pin_SBU2 = 1, .pin_relay_SBU1 = 10, .pin_relay_SBU2 = 11, .adc_channel_SBU1 = 4, //ADC12_INP4 .adc_channel_SBU2 = 17 //ADC1_INP17 }; const board board_red = { .board_type = "Red", .harness_config = &red_harness_config, .has_gps = false, .has_hw_gmlan = false, .has_obd = true, .has_lin = false, .has_rtc = false, .init = red_init, .enable_can_transceiver = red_enable_can_transceiver, .enable_can_transceivers = red_enable_can_transceivers, .set_led = red_set_led, .set_usb_power_mode = red_set_usb_power_mode, .set_gps_mode = unused_set_gps_mode, .set_can_mode = red_set_can_mode, .usb_power_mode_tick = unused_usb_power_mode_tick, .check_ignition = red_check_ignition, .read_current = unused_read_current, .set_fan_power = unused_set_fan_power, .set_ir_power = unused_set_ir_power, .set_phone_power = unused_set_phone_power, .set_clock_source_mode = unused_set_clock_source_mode, .set_siren = unused_set_siren }; ================================================ FILE: panda/board/boards/uno.h ================================================ // ///////////// // // Uno + Harness // // ///////////// // #define BOOTKICK_TIME 3U uint8_t bootkick_timer = 0U; void uno_enable_can_transceiver(uint8_t transceiver, bool enabled) { switch (transceiver){ case 1U: set_gpio_output(GPIOC, 1, !enabled); break; case 2U: set_gpio_output(GPIOC, 13, !enabled); break; case 3U: set_gpio_output(GPIOA, 0, !enabled); break; case 4U: set_gpio_output(GPIOB, 10, !enabled); break; default: puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } void uno_enable_can_transceivers(bool enabled) { for(uint8_t i=1U; i<=4U; i++){ // Leave main CAN always on for CAN-based ignition detection if((car_harness_status == HARNESS_STATUS_FLIPPED) ? (i == 3U) : (i == 1U)){ uno_enable_can_transceiver(i, true); } else { uno_enable_can_transceiver(i, enabled); } } } void uno_set_led(uint8_t color, bool enabled) { switch (color){ case LED_RED: set_gpio_output(GPIOC, 9, !enabled); break; case LED_GREEN: set_gpio_output(GPIOC, 7, !enabled); break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); break; default: break; } } void uno_set_gps_load_switch(bool enabled) { set_gpio_output(GPIOC, 12, enabled); } void uno_set_bootkick(bool enabled){ set_gpio_output(GPIOB, 14, !enabled); } void uno_bootkick(void) { bootkick_timer = BOOTKICK_TIME; uno_set_bootkick(true); } void uno_set_phone_power(bool enabled){ set_gpio_output(GPIOB, 4, enabled); } void uno_set_usb_power_mode(uint8_t mode) { bool valid = false; switch (mode) { case USB_POWER_CLIENT: uno_set_phone_power(false); valid = true; break; case USB_POWER_CDP: uno_set_phone_power(true); uno_bootkick(); valid = true; break; default: puts("Invalid USB power mode\n"); break; } if (valid) { usb_power_mode = mode; } } void uno_set_gps_mode(uint8_t mode) { switch (mode) { case GPS_DISABLED: // GPS OFF set_gpio_output(GPIOB, 1, 0); set_gpio_output(GPIOC, 5, 0); uno_set_gps_load_switch(false); break; case GPS_ENABLED: // GPS ON set_gpio_output(GPIOB, 1, 1); set_gpio_output(GPIOC, 5, 1); uno_set_gps_load_switch(true); break; case GPS_BOOTMODE: set_gpio_output(GPIOB, 1, 1); set_gpio_output(GPIOC, 5, 0); uno_set_gps_load_switch(true); break; default: puts("Invalid ESP/GPS mode\n"); break; } } void uno_set_can_mode(uint8_t mode){ switch (mode) { case CAN_MODE_NORMAL: case CAN_MODE_OBD_CAN2: if ((bool)(mode == CAN_MODE_NORMAL) != (bool)(car_harness_status == HARNESS_STATUS_FLIPPED)) { // B12,B13: disable OBD mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); } else { // B5,B6: disable normal CAN2 mode set_gpio_mode(GPIOB, 5, MODE_INPUT); set_gpio_mode(GPIOB, 6, MODE_INPUT); // B12,B13: OBD mode set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); } break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); break; } } void uno_usb_power_mode_tick(uint32_t uptime){ UNUSED(uptime); if(bootkick_timer != 0U){ bootkick_timer--; } else { uno_set_bootkick(false); } } bool uno_check_ignition(void){ // ignition is checked through harness return harness_check_ignition(); } void uno_set_usb_switch(bool phone){ set_gpio_output(GPIOB, 3, phone); } void uno_set_ir_power(uint8_t percentage){ pwm_set(TIM4, 2, percentage); } void uno_set_fan_power(uint8_t percentage){ // Enable fan power only if percentage is non-zero. set_gpio_output(GPIOA, 1, (percentage != 0U)); fan_set_power(percentage); } void uno_init(void) { common_init_gpio(); // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); // C0: OBD_SBU1 (orientation detection) // C3: OBD_SBU2 (orientation detection) set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 3, MODE_ANALOG); // Set default state of GPS current_board->set_gps_mode(GPS_ENABLED); // C10: OBD_SBU1_RELAY (harness relay driving output) // C11: OBD_SBU2_RELAY (harness relay driving output) set_gpio_mode(GPIOC, 10, MODE_OUTPUT); set_gpio_mode(GPIOC, 11, MODE_OUTPUT); set_gpio_output_type(GPIOC, 10, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_output_type(GPIOC, 11, OUTPUT_TYPE_OPEN_DRAIN); set_gpio_output(GPIOC, 10, 1); set_gpio_output(GPIOC, 11, 1); // C8: FAN PWM aka TIM3_CH3 set_gpio_alternate(GPIOC, 8, GPIO_AF2_TIM3); // Turn on GPS load switch. uno_set_gps_load_switch(true); // Turn on phone regulator uno_set_phone_power(true); // Initialize IR PWM and set to 0% set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4); pwm_init(TIM4, 2); uno_set_ir_power(0U); // Initialize fan and set to 0% fan_init(); uno_set_fan_power(0U); // Initialize harness harness_init(); // Initialize RTC rtc_init(); // Enable CAN transceivers uno_enable_can_transceivers(true); // Disable LEDs uno_set_led(LED_RED, false); uno_set_led(LED_GREEN, false); uno_set_led(LED_BLUE, false); // Set normal CAN mode uno_set_can_mode(CAN_MODE_NORMAL); // flip CAN0 and CAN2 if we are flipped if (car_harness_status == HARNESS_STATUS_FLIPPED) { can_flip_buses(0, 2); } // Switch to phone usb mode if harness connection is powered by less than 7V if(adc_get_voltage() < 7000U){ uno_set_usb_switch(true); } else { uno_set_usb_switch(false); } // Bootkick phone uno_bootkick(); } const harness_configuration uno_harness_config = { .has_harness = true, .GPIO_SBU1 = GPIOC, .GPIO_SBU2 = GPIOC, .GPIO_relay_SBU1 = GPIOC, .GPIO_relay_SBU2 = GPIOC, .pin_SBU1 = 0, .pin_SBU2 = 3, .pin_relay_SBU1 = 10, .pin_relay_SBU2 = 11, .adc_channel_SBU1 = 10, .adc_channel_SBU2 = 13 }; const board board_uno = { .board_type = "Uno", .harness_config = &uno_harness_config, .has_gps = true, .has_hw_gmlan = false, .has_obd = true, .has_lin = false, .has_rtc = true, .init = uno_init, .enable_can_transceiver = uno_enable_can_transceiver, .enable_can_transceivers = uno_enable_can_transceivers, .set_led = uno_set_led, .set_usb_power_mode = uno_set_usb_power_mode, .set_gps_mode = uno_set_gps_mode, .set_can_mode = uno_set_can_mode, .usb_power_mode_tick = uno_usb_power_mode_tick, .check_ignition = uno_check_ignition, .read_current = unused_read_current, .set_fan_power = uno_set_fan_power, .set_ir_power = uno_set_ir_power, .set_phone_power = uno_set_phone_power, .set_clock_source_mode = unused_set_clock_source_mode, .set_siren = unused_set_siren }; ================================================ FILE: panda/board/boards/unused_funcs.h ================================================ void unused_set_gps_mode(uint8_t mode) { UNUSED(mode); } void unused_usb_power_mode_tick(uint32_t uptime) { UNUSED(uptime); } void unused_set_ir_power(uint8_t percentage) { UNUSED(percentage); } void unused_set_fan_power(uint8_t percentage) { UNUSED(percentage); } void unused_set_phone_power(bool enabled) { UNUSED(enabled); } void unused_set_clock_source_mode(uint8_t mode) { UNUSED(mode); } void unused_set_siren(bool enabled) { UNUSED(enabled); } uint32_t unused_read_current(void) { return 0U; } ================================================ FILE: panda/board/boards/white.h ================================================ // /////////// // // White Panda // // /////////// // void white_enable_can_transceiver(uint8_t transceiver, bool enabled) { switch (transceiver){ case 1U: set_gpio_output(GPIOC, 1, !enabled); break; case 2U: set_gpio_output(GPIOC, 13, !enabled); break; case 3U: set_gpio_output(GPIOA, 0, !enabled); break; default: puts("Invalid CAN transceiver ("); puth(transceiver); puts("): enabling failed\n"); break; } } void white_enable_can_transceivers(bool enabled) { uint8_t t1 = enabled ? 1U : 2U; // leave transceiver 1 enabled to detect CAN ignition for(uint8_t i=t1; i<=3U; i++) { white_enable_can_transceiver(i, enabled); } } void white_set_led(uint8_t color, bool enabled) { switch (color){ case LED_RED: set_gpio_output(GPIOC, 9, !enabled); break; case LED_GREEN: set_gpio_output(GPIOC, 7, !enabled); break; case LED_BLUE: set_gpio_output(GPIOC, 6, !enabled); break; default: break; } } void white_set_usb_power_mode(uint8_t mode){ bool valid_mode = true; switch (mode) { case USB_POWER_CLIENT: // B2,A13: set client mode set_gpio_output(GPIOB, 2, 0); set_gpio_output(GPIOA, 13, 1); break; case USB_POWER_CDP: // B2,A13: set CDP mode set_gpio_output(GPIOB, 2, 1); set_gpio_output(GPIOA, 13, 1); break; case USB_POWER_DCP: // B2,A13: set DCP mode on the charger (breaks USB!) set_gpio_output(GPIOB, 2, 0); set_gpio_output(GPIOA, 13, 0); break; default: valid_mode = false; puts("Invalid usb power mode\n"); break; } if (valid_mode) { usb_power_mode = mode; } } void white_set_gps_mode(uint8_t mode) { switch (mode) { case GPS_DISABLED: // ESP OFF set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); break; case GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); break; default: puts("Invalid ESP/GPS mode\n"); break; } } void white_set_can_mode(uint8_t mode){ switch (mode) { case CAN_MODE_NORMAL: // B12,B13: disable GMLAN mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); // B3,B4: disable GMLAN mode set_gpio_mode(GPIOB, 3, MODE_INPUT); set_gpio_mode(GPIOB, 4, MODE_INPUT); // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); break; case CAN_MODE_GMLAN_CAN2: // B5,B6: disable CAN2 mode set_gpio_mode(GPIOB, 5, MODE_INPUT); set_gpio_mode(GPIOB, 6, MODE_INPUT); // B3,B4: disable GMLAN mode set_gpio_mode(GPIOB, 3, MODE_INPUT); set_gpio_mode(GPIOB, 4, MODE_INPUT); // B12,B13: GMLAN mode set_gpio_alternate(GPIOB, 12, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 13, GPIO_AF9_CAN2); // A8,A15: normal CAN3 mode set_gpio_alternate(GPIOA, 8, GPIO_AF11_CAN3); set_gpio_alternate(GPIOA, 15, GPIO_AF11_CAN3); break; case CAN_MODE_GMLAN_CAN3: // A8,A15: disable CAN3 mode set_gpio_mode(GPIOA, 8, MODE_INPUT); set_gpio_mode(GPIOA, 15, MODE_INPUT); // B12,B13: disable GMLAN mode set_gpio_mode(GPIOB, 12, MODE_INPUT); set_gpio_mode(GPIOB, 13, MODE_INPUT); // B3,B4: GMLAN mode set_gpio_alternate(GPIOB, 3, GPIO_AF11_CAN3); set_gpio_alternate(GPIOB, 4, GPIO_AF11_CAN3); // B5,B6: normal CAN2 mode set_gpio_alternate(GPIOB, 5, GPIO_AF9_CAN2); set_gpio_alternate(GPIOB, 6, GPIO_AF9_CAN2); break; default: puts("Tried to set unsupported CAN mode: "); puth(mode); puts("\n"); break; } } uint32_t white_read_current(void){ return adc_get(ADCCHAN_CURRENT); } bool white_check_ignition(void){ // ignition is on PA1 return !get_gpio_input(GPIOA, 1); } void white_grey_common_init(void) { common_init_gpio(); // C3: current sense set_gpio_mode(GPIOC, 3, MODE_ANALOG); // A1: started_alt set_gpio_pullup(GPIOA, 1, PULL_UP); // A2, A3: USART 2 for debugging set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); // A4, A5, A6, A7: SPI set_gpio_alternate(GPIOA, 4, GPIO_AF5_SPI1); set_gpio_alternate(GPIOA, 5, GPIO_AF5_SPI1); set_gpio_alternate(GPIOA, 6, GPIO_AF5_SPI1); set_gpio_alternate(GPIOA, 7, GPIO_AF5_SPI1); // B12: GMLAN, ignition sense, pull up set_gpio_pullup(GPIOB, 12, PULL_UP); /* GMLAN mode pins: M0(B15) M1(B14) mode ======================= 0 0 sleep 1 0 100kbit 0 1 high voltage wakeup 1 1 33kbit (normal) */ set_gpio_output(GPIOB, 14, 1); set_gpio_output(GPIOB, 15, 1); // B7: K-line enable set_gpio_output(GPIOB, 7, 1); // C12, D2: Setup K-line (UART5) set_gpio_alternate(GPIOC, 12, GPIO_AF8_UART5); set_gpio_alternate(GPIOD, 2, GPIO_AF8_UART5); set_gpio_pullup(GPIOD, 2, PULL_UP); // L-line enable set_gpio_output(GPIOA, 14, 1); // C10, C11: L-Line setup (USART3) set_gpio_alternate(GPIOC, 10, GPIO_AF7_USART3); set_gpio_alternate(GPIOC, 11, GPIO_AF7_USART3); set_gpio_pullup(GPIOC, 11, PULL_UP); // Enable CAN transceivers white_enable_can_transceivers(true); // Disable LEDs white_set_led(LED_RED, false); white_set_led(LED_GREEN, false); white_set_led(LED_BLUE, false); // Set normal CAN mode white_set_can_mode(CAN_MODE_NORMAL); // Init usb power mode uint32_t voltage = adc_get_voltage(); // Init in CDP mode only if panda is powered by 12V. // Otherwise a PC would not be able to flash a standalone panda if (voltage > 8000U) { // 8V threshold white_set_usb_power_mode(USB_POWER_CDP); } else { white_set_usb_power_mode(USB_POWER_CLIENT); } } void white_init(void) { white_grey_common_init(); // Set ESP off by default current_board->set_gps_mode(GPS_DISABLED); } const harness_configuration white_harness_config = { .has_harness = false }; const board board_white = { .board_type = "White", .harness_config = &white_harness_config, .has_gps = false, .has_hw_gmlan = true, .has_obd = false, .has_lin = true, .has_rtc = false, .init = white_init, .enable_can_transceiver = white_enable_can_transceiver, .enable_can_transceivers = white_enable_can_transceivers, .set_led = white_set_led, .set_usb_power_mode = white_set_usb_power_mode, .set_gps_mode = white_set_gps_mode, .set_can_mode = white_set_can_mode, .usb_power_mode_tick = unused_usb_power_mode_tick, .check_ignition = white_check_ignition, .read_current = white_read_current, .set_fan_power = unused_set_fan_power, .set_ir_power = unused_set_ir_power, .set_phone_power = unused_set_phone_power, .set_clock_source_mode = unused_set_clock_source_mode, .set_siren = unused_set_siren }; ================================================ FILE: panda/board/bootstub.c ================================================ #define BOOTSTUB #define VERS_TAG 0x53524556 #define MIN_VERSION 2 // ********************* Includes ********************* #include "config.h" #include "drivers/pwm.h" #include "drivers/usb.h" #include "early_init.h" #include "provision.h" #include "crypto/rsa.h" #include "crypto/sha.h" #include "obj/cert.h" #include "obj/gitversion.h" #include "flasher.h" void __initialize_hardware_early(void) { early_initialization(); } void fail(void) { soft_flasher_start(); } // know where to sig check extern void *_app_start[]; // FIXME: sometimes your panda will fail flashing and will quickly blink a single Green LED // BOUNTY: $200 coupon on shop.comma.ai or $100 check. int main(void) { // Init interrupt table init_interrupts(true); disable_interrupts(); clock_init(); detect_external_debug_serial(); detect_board_type(); if (enter_bootloader_mode == ENTER_SOFTLOADER_MAGIC) { enter_bootloader_mode = 0; soft_flasher_start(); } // validate length int len = (int)_app_start[0]; if ((len < 8) || (len > (0x1000000 - 0x4000 - 4 - RSANUMBYTES))) goto fail; // compute SHA hash uint8_t digest[SHA_DIGEST_SIZE]; SHA_hash(&_app_start[1], len-4, digest); // verify version, last bytes in the signed area uint32_t vers[2] = {0}; memcpy(&vers, ((void*)&_app_start[0]) + len - sizeof(vers), sizeof(vers)); if (vers[0] != VERS_TAG || vers[1] < MIN_VERSION) { goto fail; } // verify RSA signature if (RSA_verify(&release_rsa_key, ((void*)&_app_start[0]) + len, RSANUMBYTES, digest, SHA_DIGEST_SIZE)) { goto good; } // allow debug if built from source #ifdef ALLOW_DEBUG if (RSA_verify(&debug_rsa_key, ((void*)&_app_start[0]) + len, RSANUMBYTES, digest, SHA_DIGEST_SIZE)) { goto good; } #endif // here is a failure fail: fail(); return 0; good: // jump to flash ((void(*)(void)) _app_start[1])(); return 0; } ================================================ FILE: panda/board/bootstub_declarations.h ================================================ // ******************** Prototypes ******************** void puts(const char *a){ UNUSED(a); } void puth(uint8_t i){ UNUSED(i); } void puth2(uint8_t i){ UNUSED(i); } typedef struct board board; typedef struct harness_configuration harness_configuration; // No CAN support on bootloader void can_flip_buses(uint8_t bus1, uint8_t bus2){UNUSED(bus1); UNUSED(bus2);} void pwm_init(TIM_TypeDef *TIM, uint8_t channel); void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage); // ********************* Globals ********************** uint8_t hw_type = 0; const board *current_board; ================================================ FILE: panda/board/build_all.sh ================================================ #!/usr/bin/env sh set -e scons -u PANDA_H7=1 scons -u PEDAL=1 scons -u PEDAL=1 PEDAL_USB=1 scons -u ================================================ FILE: panda/board/config.h ================================================ #ifndef PANDA_CONFIG_H #define PANDA_CONFIG_H //#define DEBUG //#define DEBUG_UART //#define DEBUG_USB //#define DEBUG_SPI //#define DEBUG_FAULTS #define USB_VID 0xbbaaU #ifdef BOOTSTUB #define USB_PID 0xddeeU #else #define USB_PID 0xddccU #endif #define NULL ((void*)0) #define COMPILE_TIME_ASSERT(pred) ((void)sizeof(char[1 - (2 * ((int)(!(pred))))])) #define MIN(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ (_a < _b) ? _a : _b; }) #define MAX(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ (_a > _b) ? _a : _b; }) #define ABS(a) \ ({ __typeof__ (a) _a = (a); \ (_a > 0) ? _a : (-_a); }) #define MAX_RESP_LEN 0x40U #define GET_BUS(msg) (((msg)->RDTR >> 4) & 0xFF) #define GET_LEN(msg) ((msg)->RDTR & 0xF) #define GET_ADDR(msg) ((((msg)->RIR & 4) != 0) ? ((msg)->RIR >> 3) : ((msg)->RIR >> 21)) #define GET_BYTE(msg, b) (((int)(b) > 3) ? (((msg)->RDHR >> (8U * ((unsigned int)(b) % 4U))) & 0xFFU) : (((msg)->RDLR >> (8U * (unsigned int)(b))) & 0xFFU)) #define GET_BYTES_04(msg) ((msg)->RDLR) #define GET_BYTES_48(msg) ((msg)->RDHR) #define GET_FLAG(value, mask) (((__typeof__(mask))(value) & (mask)) == (mask)) #define CAN_INIT_TIMEOUT_MS 500U #include #ifdef STM32H7 #include "stm32h7/stm32h7_config.h" #else #include "stm32fx/stm32fx_config.h" #endif #endif ================================================ FILE: panda/board/crc.h ================================================ uint8_t crc_checksum(uint8_t *dat, int len, const uint8_t poly) { uint8_t crc = 0xFFU; int i; int j; for (i = len - 1; i >= 0; i--) { crc ^= dat[i]; for (j = 0; j < 8; j++) { if ((crc & 0x80U) != 0U) { crc = (uint8_t)((crc << 1) ^ poly); } else { crc <<= 1; } } } return crc; } ================================================ FILE: panda/board/critical.h ================================================ // ********************* Critical section helpers ********************* volatile bool interrupts_enabled = false; void enable_interrupts(void) { interrupts_enabled = true; __enable_irq(); } void disable_interrupts(void) { interrupts_enabled = false; __disable_irq(); } uint8_t global_critical_depth = 0U; #define ENTER_CRITICAL() \ __disable_irq(); \ global_critical_depth += 1U; #define EXIT_CRITICAL() \ global_critical_depth -= 1U; \ if ((global_critical_depth == 0U) && interrupts_enabled) { \ __enable_irq(); \ } ================================================ FILE: panda/board/drivers/bxcan.h ================================================ // IRQs: CAN1_TX, CAN1_RX0, CAN1_SCE // CAN2_TX, CAN2_RX0, CAN2_SCE // CAN3_TX, CAN3_RX0, CAN3_SCE CAN_TypeDef *cans[] = {CAN1, CAN2, CAN3}; bool can_set_speed(uint8_t can_number) { bool ret = true; CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); ret &= llcan_set_speed(CAN, can_speed[bus_number], can_loopback, (unsigned int)(can_silent) & (1U << can_number)); return ret; } // TODO: Cleanup with new abstraction void can_set_gmlan(uint8_t bus) { if(current_board->has_hw_gmlan){ // first, disable GMLAN on prev bus uint8_t prev_bus = can_num_lookup[3]; if (bus != prev_bus) { switch (prev_bus) { case 1: case 2: puts("Disable GMLAN on CAN"); puth(prev_bus + 1U); puts("\n"); current_board->set_can_mode(CAN_MODE_NORMAL); bus_lookup[prev_bus] = prev_bus; can_num_lookup[prev_bus] = prev_bus; can_num_lookup[3] = -1; bool ret = can_init(prev_bus); UNUSED(ret); break; default: // GMLAN was not set on either BUS 1 or 2 break; } } // now enable GMLAN on the new bus switch (bus) { case 1: case 2: puts("Enable GMLAN on CAN"); puth(bus + 1U); puts("\n"); current_board->set_can_mode((bus == 1U) ? CAN_MODE_GMLAN_CAN2 : CAN_MODE_GMLAN_CAN3); bus_lookup[bus] = 3; can_num_lookup[bus] = -1; can_num_lookup[3] = bus; bool ret = can_init(bus); UNUSED(ret); break; case 0xFF: //-1 unsigned break; default: puts("GMLAN can only be set on CAN2 or CAN3\n"); break; } } else { puts("GMLAN not available on black panda\n"); } } // CAN error void can_sce(CAN_TypeDef *CAN) { ENTER_CRITICAL(); #ifdef DEBUG if (CAN==CAN1) puts("CAN1: "); if (CAN==CAN2) puts("CAN2: "); #ifdef CAN3 if (CAN==CAN3) puts("CAN3: "); #endif puts("MSR:"); puth(CAN->MSR); puts(" TSR:"); puth(CAN->TSR); puts(" RF0R:"); puth(CAN->RF0R); puts(" RF1R:"); puth(CAN->RF1R); puts(" ESR:"); puth(CAN->ESR); puts("\n"); #endif can_err_cnt += 1; llcan_clear_send(CAN); EXIT_CRITICAL(); } // ***************************** CAN ***************************** void process_can(uint8_t can_number) { if (can_number != 0xffU) { ENTER_CRITICAL(); CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); // check for empty mailbox CAN_FIFOMailBox_TypeDef to_send; if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) { // add successfully transmitted message to my fifo if ((CAN->TSR & CAN_TSR_RQCP0) == CAN_TSR_RQCP0) { can_txd_cnt += 1; if ((CAN->TSR & CAN_TSR_TXOK0) == CAN_TSR_TXOK0) { CAN_FIFOMailBox_TypeDef to_push; to_push.RIR = CAN->sTxMailBox[0].TIR; to_push.RDTR = (CAN->sTxMailBox[0].TDTR & 0xFFFF000FU) | ((CAN_BUS_RET_FLAG | bus_number) << 4); to_push.RDLR = CAN->sTxMailBox[0].TDLR; to_push.RDHR = CAN->sTxMailBox[0].TDHR; can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; } if ((CAN->TSR & CAN_TSR_TERR0) == CAN_TSR_TERR0) { #ifdef DEBUG puts("CAN TX ERROR!\n"); #endif } if ((CAN->TSR & CAN_TSR_ALST0) == CAN_TSR_ALST0) { #ifdef DEBUG puts("CAN TX ARBITRATION LOST!\n"); #endif } // clear interrupt // careful, this can also be cleared by requesting a transmission CAN->TSR |= CAN_TSR_RQCP0; } if (can_pop(can_queues[bus_number], &to_send)) { can_tx_cnt += 1; // only send if we have received a packet CAN->sTxMailBox[0].TDLR = to_send.RDLR; CAN->sTxMailBox[0].TDHR = to_send.RDHR; CAN->sTxMailBox[0].TDTR = to_send.RDTR; CAN->sTxMailBox[0].TIR = to_send.RIR; if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) { usb_outep3_resume_if_paused(); } } } EXIT_CRITICAL(); } } // CAN receive handlers // blink blue when we are receiving CAN messages void can_rx(uint8_t can_number) { CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { can_rx_cnt += 1; // can is live pending_can_live = 1; // add to my fifo CAN_FIFOMailBox_TypeDef to_push; to_push.RIR = CAN->sFIFOMailBox[0].RIR; to_push.RDTR = CAN->sFIFOMailBox[0].RDTR; to_push.RDLR = CAN->sFIFOMailBox[0].RDLR; to_push.RDHR = CAN->sFIFOMailBox[0].RDHR; // modify RDTR for our API to_push.RDTR = (to_push.RDTR & 0xFFFF000F) | (bus_number << 4); // forwarding (panda only) int bus_fwd_num = (can_forwarding[bus_number] != -1) ? can_forwarding[bus_number] : safety_fwd_hook(bus_number, &to_push); if (bus_fwd_num != -1) { CAN_FIFOMailBox_TypeDef to_send; to_send.RIR = to_push.RIR | 1; // TXRQ to_send.RDTR = to_push.RDTR; to_send.RDLR = to_push.RDLR; to_send.RDHR = to_push.RDHR; can_send(&to_send, bus_fwd_num, true); } can_rx_errs += safety_rx_hook(&to_push) ? 0U : 1U; ignition_can_hook(&to_push); current_board->set_led(LED_BLUE, true); can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; // next CAN->RF0R |= CAN_RF0R_RFOM0; } } void CAN1_TX_IRQ_Handler(void) { process_can(0); } void CAN1_RX0_IRQ_Handler(void) { can_rx(0); } void CAN1_SCE_IRQ_Handler(void) { can_sce(CAN1); } void CAN2_TX_IRQ_Handler(void) { process_can(1); } void CAN2_RX0_IRQ_Handler(void) { can_rx(1); } void CAN2_SCE_IRQ_Handler(void) { can_sce(CAN2); } void CAN3_TX_IRQ_Handler(void) { process_can(2); } void CAN3_RX0_IRQ_Handler(void) { can_rx(2); } void CAN3_SCE_IRQ_Handler(void) { can_sce(CAN3); } bool can_init(uint8_t can_number) { bool ret = false; REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN2_TX_IRQn, CAN2_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) REGISTER_INTERRUPT(CAN2_RX0_IRQn, CAN2_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) REGISTER_INTERRUPT(CAN2_SCE_IRQn, CAN2_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) REGISTER_INTERRUPT(CAN3_TX_IRQn, CAN3_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) REGISTER_INTERRUPT(CAN3_RX0_IRQn, CAN3_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) REGISTER_INTERRUPT(CAN3_SCE_IRQn, CAN3_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) if (can_number != 0xffU) { CAN_TypeDef *CAN = CANIF_FROM_CAN_NUM(can_number); ret &= can_set_speed(can_number); ret &= llcan_init(CAN); // in case there are queued up messages process_can(can_number); } return ret; } ================================================ FILE: panda/board/drivers/can_common.h ================================================ typedef struct { volatile uint32_t w_ptr; volatile uint32_t r_ptr; uint32_t fifo_size; CAN_FIFOMailBox_TypeDef *elems; } can_ring; #define CAN_BUS_RET_FLAG 0x80U #define CAN_BUS_NUM_MASK 0x7FU #define BUS_MAX 4U uint32_t can_rx_errs = 0; uint32_t can_send_errs = 0; uint32_t can_fwd_errs = 0; uint32_t gmlan_send_errs = 0; extern int can_live; extern int pending_can_live; // must reinit after changing these extern int can_loopback; extern int can_silent; extern uint32_t can_speed[4]; extern uint32_t can_data_speed[3]; // Ignition detected from CAN meessages bool ignition_can = false; bool ignition_cadillac = false; uint32_t ignition_can_cnt = 0U; #define ALL_CAN_SILENT 0xFF #define ALL_CAN_LIVE 0 int can_live = 0; int pending_can_live = 0; int can_loopback = 0; int can_silent = ALL_CAN_SILENT; // ******************* functions prototypes ********************* bool can_init(uint8_t can_number); void process_can(uint8_t can_number); // ********************* instantiate queues ********************* #define can_buffer(x, size) \ CAN_FIFOMailBox_TypeDef elems_##x[size]; \ can_ring can_##x = { .w_ptr = 0, .r_ptr = 0, .fifo_size = (size), .elems = (CAN_FIFOMailBox_TypeDef *)&(elems_##x) }; can_buffer(rx_q, 0x1000) can_buffer(tx1_q, 0x100) can_buffer(tx2_q, 0x100) can_buffer(tx3_q, 0x100) can_buffer(txgmlan_q, 0x100) // FIXME: // cppcheck-suppress misra-c2012-9.3 can_ring *can_queues[] = {&can_tx1_q, &can_tx2_q, &can_tx3_q, &can_txgmlan_q}; // global CAN stats int can_rx_cnt = 0; int can_tx_cnt = 0; int can_txd_cnt = 0; int can_err_cnt = 0; int can_overflow_cnt = 0; // ********************* interrupt safe queue ********************* bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = 0; ENTER_CRITICAL(); if (q->w_ptr != q->r_ptr) { *elem = q->elems[q->r_ptr]; if ((q->r_ptr + 1U) == q->fifo_size) { q->r_ptr = 0; } else { q->r_ptr += 1U; } ret = 1; } EXIT_CRITICAL(); return ret; } bool can_push(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) { bool ret = false; uint32_t next_w_ptr; ENTER_CRITICAL(); if ((q->w_ptr + 1U) == q->fifo_size) { next_w_ptr = 0; } else { next_w_ptr = q->w_ptr + 1U; } if (next_w_ptr != q->r_ptr) { q->elems[q->w_ptr] = *elem; q->w_ptr = next_w_ptr; ret = true; } EXIT_CRITICAL(); if (!ret) { can_overflow_cnt++; #ifdef DEBUG puts("can_push failed!\n"); #endif } return ret; } uint32_t can_slots_empty(can_ring *q) { uint32_t ret = 0; ENTER_CRITICAL(); if (q->w_ptr >= q->r_ptr) { ret = q->fifo_size - 1U - q->w_ptr + q->r_ptr; } else { ret = q->r_ptr - q->w_ptr - 1U; } EXIT_CRITICAL(); return ret; } void can_clear(can_ring *q) { ENTER_CRITICAL(); q->w_ptr = 0; q->r_ptr = 0; EXIT_CRITICAL(); } // assign CAN numbering // bus num: Can bus number on ODB connector. Sent to/from USB // Min: 0; Max: 127; Bit 7 marks message as receipt (bus 129 is receipt for but 1) // cans: Look up MCU can interface from bus number // can number: numeric lookup for MCU CAN interfaces (0 = CAN1, 1 = CAN2, etc); // bus_lookup: Translates from 'can number' to 'bus number'. // can_num_lookup: Translates from 'bus number' to 'can number'. // can_forwarding: Given a bus num, lookup bus num to forward to. -1 means no forward. // Helpers // Panda: Bus 0=CAN1 Bus 1=CAN2 Bus 2=CAN3 uint8_t bus_lookup[] = {0,1,2}; uint8_t can_num_lookup[] = {0,1,2,-1}; int8_t can_forwarding[] = {-1,-1,-1,-1}; uint32_t can_speed[] = {5000, 5000, 5000, 333}; uint32_t can_data_speed[] = {5000, 5000, 5000}; //For CAN FD with BRS only #define CAN_MAX 3U #define CANIF_FROM_CAN_NUM(num) (cans[num]) #define BUS_NUM_FROM_CAN_NUM(num) (bus_lookup[num]) #define CAN_NUM_FROM_BUS_NUM(num) (can_num_lookup[num]) void can_init_all(void) { bool ret = true; for (uint8_t i=0U; i < CAN_MAX; i++) { can_clear(can_queues[i]); ret &= can_init(i); } UNUSED(ret); } void can_flip_buses(uint8_t bus1, uint8_t bus2){ bus_lookup[bus1] = bus2; bus_lookup[bus2] = bus1; can_num_lookup[bus1] = bus2; can_num_lookup[bus2] = bus1; } void ignition_can_hook(CAN_FIFOMailBox_TypeDef *to_push) { int bus = GET_BUS(to_push); int addr = GET_ADDR(to_push); int len = GET_LEN(to_push); ignition_can_cnt = 0U; // reset counter if (bus == 0) { // TODO: verify on all supported GM models that we can reliably detect ignition using only this signal, // since the 0x1F1 signal can briefly go low immediately after ignition if ((addr == 0x160) && (len == 5)) { // this message isn't all zeros when ignition is on ignition_cadillac = GET_BYTES_04(to_push) != 0; } // GM exception if ((addr == 0x1F1) && (len == 8)) { // Bit 5 is ignition "on" bool ignition_gm = ((GET_BYTE(to_push, 0) & 0x20) != 0); ignition_can = ignition_gm || ignition_cadillac; } // Tesla exception if ((addr == 0x348) && (len == 8)) { // GTW_status ignition_can = (GET_BYTE(to_push, 0) & 0x1) != 0; } } } bool can_tx_check_min_slots_free(uint32_t min) { return (can_slots_empty(&can_tx1_q) >= min) && (can_slots_empty(&can_tx2_q) >= min) && (can_slots_empty(&can_tx3_q) >= min) && (can_slots_empty(&can_txgmlan_q) >= min); } void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook) { if (skip_tx_hook || safety_tx_hook(to_push) != 0) { if (bus_number < BUS_MAX) { // add CAN packet to send queue // bus number isn't passed through to_push->RDTR &= 0xF; if ((bus_number == 3U) && (can_num_lookup[3] == 0xFFU)) { gmlan_send_errs += bitbang_gmlan(to_push) ? 0U : 1U; } else { can_fwd_errs += can_push(can_queues[bus_number], to_push) ? 0U : 1U; process_can(CAN_NUM_FROM_BUS_NUM(bus_number)); } } } } void can_set_forwarding(int from, int to) { can_forwarding[from] = to; } ================================================ FILE: panda/board/drivers/fan.h ================================================ uint16_t fan_tach_counter = 0U; uint16_t fan_rpm = 0U; void fan_set_power(uint8_t percentage){ pwm_set(TIM3, 3, percentage); } // Can be way more acurate than this, but this is probably good enough for our purposes. // Call this every second void fan_tick(void){ // 4 interrupts per rotation fan_rpm = fan_tach_counter * 15U; fan_tach_counter = 0U; } ================================================ FILE: panda/board/drivers/fdcan.h ================================================ // IRQs: FDCAN1_IT0, FDCAN1_IT1 // FDCAN2_IT0, FDCAN2_IT1 // FDCAN3_IT0, FDCAN3_IT1 #define BUS_OFF_FAIL_LIMIT 2U uint8_t bus_off_err[] = {0U, 0U, 0U}; FDCAN_GlobalTypeDef *cans[] = {FDCAN1, FDCAN2, FDCAN3}; bool can_set_speed(uint8_t can_number) { bool ret = true; FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); ret &= llcan_set_speed(CANx, can_speed[bus_number], can_data_speed[bus_number], can_loopback, (unsigned int)(can_silent) & (1U << can_number)); return ret; } void can_set_gmlan(uint8_t bus) { UNUSED(bus); puts("GMLAN not available on red panda\n"); } void cycle_transceiver(uint8_t can_number) { // FDCAN1 = trans 1, FDCAN3 = trans 3, FDCAN2 = trans 2 normal or 4 flipped harness uint8_t transceiver_number = can_number; if (can_number == 2U) { uint8_t flip = (car_harness_status == HARNESS_STATUS_FLIPPED) ? 2U : 0U; transceiver_number += flip; } current_board->enable_can_transceiver(transceiver_number, false); delay(20000); current_board->enable_can_transceiver(transceiver_number, true); bus_off_err[can_number] = 0U; puts("Cycled transceiver number: "); puth(transceiver_number); puts("\n"); } // ***************************** CAN ***************************** void process_can(uint8_t can_number) { if (can_number != 0xffU) { ENTER_CRITICAL(); FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); CANx->IR |= FDCAN_IR_TFE; // Clear Tx FIFO Empty flag if ((CANx->TXFQS & FDCAN_TXFQS_TFQF) == 0) { CAN_FIFOMailBox_TypeDef to_send; if (can_pop(can_queues[bus_number], &to_send)) { can_tx_cnt += 1; uint32_t TxFIFOSA = FDCAN_START_ADDRESS + (can_number * FDCAN_OFFSET) + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_SIZE); uint8_t tx_index = (CANx->TXFQS >> FDCAN_TXFQS_TFQPI_Pos) & 0x1F; // only send if we have received a packet CAN_FIFOMailBox_TypeDef *fifo; fifo = (CAN_FIFOMailBox_TypeDef *)(TxFIFOSA + (tx_index * FDCAN_TX_FIFO_EL_SIZE)); // Convert from "mailbox type" fifo->RIR = ((to_send.RIR & 0x6) << 28) | (to_send.RIR >> 3); // identifier format and frame type | identifier //REDEBUG: enable CAN FD and BRS for test purposes //fifo->RDTR = ((to_send.RDTR & 0xF) << 16) | ((to_send.RDTR) >> 16) | (1U << 21) | (1U << 20); // DLC (length) | timestamp | enable CAN FD | enable BRS fifo->RDTR = ((to_send.RDTR & 0xF) << 16) | ((to_send.RDTR) >> 16); // DLC (length) | timestamp fifo->RDLR = to_send.RDLR; fifo->RDHR = to_send.RDHR; CANx->TXBAR = (1UL << tx_index); // Send back to USB can_txd_cnt += 1; CAN_FIFOMailBox_TypeDef to_push; to_push.RIR = to_send.RIR; to_push.RDTR = (to_send.RDTR & 0xFFFF000FU) | ((CAN_BUS_RET_FLAG | bus_number) << 4); to_push.RDLR = to_send.RDLR; to_push.RDHR = to_send.RDHR; can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) { usb_outep3_resume_if_paused(); } } } // Recover after Bus-off state if (((CANx->PSR & FDCAN_PSR_BO) != 0) && ((CANx->CCCR & FDCAN_CCCR_INIT) != 0)) { bus_off_err[can_number] += 1U; puts("CAN is in Bus_Off state! Resetting... CAN number: "); puth(can_number); puts("\n"); if (bus_off_err[can_number] > BUS_OFF_FAIL_LIMIT) { cycle_transceiver(can_number); } CANx->IR = 0xFFC60000U; // Reset all flags(Only errors!) CANx->CCCR &= ~(FDCAN_CCCR_INIT); uint32_t timeout_counter = 0U; while((CANx->CCCR & FDCAN_CCCR_INIT) != 0) { // Delay for about 1ms delay(10000); timeout_counter++; if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ puts(CAN_NAME_FROM_CANIF(CANx)); puts(" Bus_Off reset timed out!\n"); break; } } } EXIT_CRITICAL(); } } // CAN receive handlers // blink blue when we are receiving CAN messages void can_rx(uint8_t can_number) { FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); uint8_t bus_number = BUS_NUM_FROM_CAN_NUM(can_number); uint8_t rx_fifo_idx; // Rx FIFO 0 new message if((CANx->IR & FDCAN_IR_RF0N) != 0) { CANx->IR |= FDCAN_IR_RF0N; while((CANx->RXF0S & FDCAN_RXF0S_F0FL) != 0) { can_rx_cnt += 1; // can is live pending_can_live = 1; // getting new message index (0 to 63) rx_fifo_idx = (uint8_t)((CANx->RXF0S >> FDCAN_RXF0S_F0GI_Pos) & 0x3F); uint32_t RxFIFO0SA = FDCAN_START_ADDRESS + (can_number * FDCAN_OFFSET); CAN_FIFOMailBox_TypeDef to_push; CAN_FIFOMailBox_TypeDef *fifo; // getting address fifo = (CAN_FIFOMailBox_TypeDef *)(RxFIFO0SA + (rx_fifo_idx * FDCAN_RX_FIFO_0_EL_SIZE)); // Need to convert real CAN frame format to mailbox "type" to_push.RIR = ((fifo->RIR >> 28) & 0x6) | (fifo->RIR << 3); // identifier format and frame type | identifier to_push.RDTR = ((fifo->RDTR >> 16) & 0xF) | (fifo->RDTR << 16); // DLC (length) | timestamp to_push.RDLR = fifo->RDLR; to_push.RDHR = fifo->RDHR; // modify RDTR for our API to_push.RDTR = (to_push.RDTR & 0xFFFF000F) | (bus_number << 4); // forwarding (panda only) int bus_fwd_num = (can_forwarding[bus_number] != -1) ? can_forwarding[bus_number] : safety_fwd_hook(bus_number, &to_push); if (bus_fwd_num != -1) { CAN_FIFOMailBox_TypeDef to_send; to_send.RIR = to_push.RIR; to_send.RDTR = to_push.RDTR; to_send.RDLR = to_push.RDLR; to_send.RDHR = to_push.RDHR; can_send(&to_send, bus_fwd_num, true); } can_rx_errs += safety_rx_hook(&to_push) ? 0U : 1U; ignition_can_hook(&to_push); current_board->set_led(LED_BLUE, true); can_send_errs += can_push(&can_rx_q, &to_push) ? 0U : 1U; // update read index CANx->RXF0A = rx_fifo_idx; } } else if((CANx->IR & (FDCAN_IR_PEA | FDCAN_IR_PED | FDCAN_IR_RF0L | FDCAN_IR_RF0F | FDCAN_IR_EW | FDCAN_IR_MRAF | FDCAN_IR_TOO)) != 0) { #ifdef DEBUG puts("FDCAN error, FDCAN_IR: ");puth(CANx->IR);puts("\n"); #endif CANx->IR |= (FDCAN_IR_PEA | FDCAN_IR_PED | FDCAN_IR_RF0L | FDCAN_IR_RF0F | FDCAN_IR_EW | FDCAN_IR_MRAF | FDCAN_IR_TOO); // Clean all error flags can_err_cnt += 1; } else { } } void FDCAN1_IT0_IRQ_Handler(void) { can_rx(0); } void FDCAN1_IT1_IRQ_Handler(void) { process_can(0); } void FDCAN2_IT0_IRQ_Handler(void) { can_rx(1); } void FDCAN2_IT1_IRQ_Handler(void) { process_can(1); } void FDCAN3_IT0_IRQ_Handler(void) { can_rx(2); } void FDCAN3_IT1_IRQ_Handler(void) { process_can(2); } bool can_init(uint8_t can_number) { bool ret = false; REGISTER_INTERRUPT(FDCAN1_IT0_IRQn, FDCAN1_IT0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(FDCAN1_IT1_IRQn, FDCAN1_IT1_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(FDCAN2_IT0_IRQn, FDCAN2_IT0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) REGISTER_INTERRUPT(FDCAN2_IT1_IRQn, FDCAN2_IT1_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_2) REGISTER_INTERRUPT(FDCAN3_IT0_IRQn, FDCAN3_IT0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) REGISTER_INTERRUPT(FDCAN3_IT1_IRQn, FDCAN3_IT1_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_3) if (can_number != 0xffU) { FDCAN_GlobalTypeDef *CANx = CANIF_FROM_CAN_NUM(can_number); ret &= can_set_speed(can_number); ret &= llcan_init(CANx); // in case there are queued up messages process_can(can_number); } return ret; } ================================================ FILE: panda/board/drivers/gmlan_alt.h ================================================ #define GMLAN_TICKS_PER_SECOND 33300 //1sec @ 33.3kbps #define GMLAN_TICKS_PER_TIMEOUT_TICKLE 500 //15ms @ 33.3kbps #define GMLAN_HIGH 0 //0 is high on bus (dominant) #define GMLAN_LOW 1 //1 is low on bus #define DISABLED -1 #define BITBANG 0 #define GPIO_SWITCH 1 #define MAX_BITS_CAN_PACKET (200) int gmlan_alt_mode = DISABLED; // returns out_len int do_bitstuff(char *out, char *in, int in_len) { int last_bit = -1; int bit_cnt = 0; int j = 0; for (int i = 0; i < in_len; i++) { char bit = in[i]; out[j] = bit; j++; // do the stuffing if (bit == last_bit) { bit_cnt++; if (bit_cnt == 5) { // 5 in a row the same, do stuff last_bit = !bit; out[j] = last_bit; j++; bit_cnt = 1; } } else { // this is a new bit last_bit = bit; bit_cnt = 1; } } return j; } int append_crc(char *in, int in_len) { unsigned int crc = 0; for (int i = 0; i < in_len; i++) { crc <<= 1; if (((unsigned int)(in[i]) ^ ((crc >> 15) & 1U)) != 0U) { crc = crc ^ 0x4599U; } crc &= 0x7fffU; } int in_len_copy = in_len; for (int i = 14; i >= 0; i--) { in[in_len_copy] = (crc >> (unsigned int)(i)) & 1U; in_len_copy++; } return in_len_copy; } int append_bits(char *in, int in_len, char *app, int app_len) { int in_len_copy = in_len; for (int i = 0; i < app_len; i++) { in[in_len_copy] = app[i]; in_len_copy++; } return in_len_copy; } int append_int(char *in, int in_len, int val, int val_len) { int in_len_copy = in_len; for (int i = val_len - 1; i >= 0; i--) { in[in_len_copy] = ((unsigned int)(val) & (1U << (unsigned int)(i))) != 0U; in_len_copy++; } return in_len_copy; } int get_bit_message(char *out, CAN_FIFOMailBox_TypeDef *to_bang) { char pkt[MAX_BITS_CAN_PACKET]; char footer[] = { 1, // CRC delimiter 1, // ACK 1, // ACK delimiter 1,1,1,1,1,1,1, // EOF 1,1,1, // IFS }; int len = 0; // test packet int dlc_len = to_bang->RDTR & 0xF; len = append_int(pkt, len, 0, 1); // Start-of-frame if ((to_bang->RIR & 4) != 0) { // extended identifier len = append_int(pkt, len, to_bang->RIR >> 21, 11); // Identifier len = append_int(pkt, len, 3, 2); // SRR+IDE len = append_int(pkt, len, (to_bang->RIR >> 3) & ((1U << 18) - 1U), 18); // Identifier len = append_int(pkt, len, 0, 3); // RTR+r1+r0 } else { // standard identifier len = append_int(pkt, len, to_bang->RIR >> 21, 11); // Identifier len = append_int(pkt, len, 0, 3); // RTR+IDE+reserved } len = append_int(pkt, len, dlc_len, 4); // Data length code // append data for (int i = 0; i < dlc_len; i++) { unsigned char dat = ((unsigned char *)(&(to_bang->RDLR)))[i]; len = append_int(pkt, len, dat, 8); } // append crc len = append_crc(pkt, len); // do bitstuffing len = do_bitstuff(out, pkt, len); // append footer len = append_bits(out, len, footer, sizeof(footer)); return len; } void TIM12_IRQ_Handler(void); void setup_timer(void) { // register interrupt REGISTER_INTERRUPT(TIM8_BRK_TIM12_IRQn, TIM12_IRQ_Handler, 40000U, FAULT_INTERRUPT_RATE_GMLAN) // setup register_set(&(TIM12->PSC), (48-1), 0xFFFFU); // Tick on 1 us register_set(&(TIM12->CR1), TIM_CR1_CEN, 0x3FU); // Enable register_set(&(TIM12->ARR), (30-1), 0xFFFFU); // 33.3 kbps // in case it's disabled NVIC_EnableIRQ(TIM8_BRK_TIM12_IRQn); // run the interrupt register_set(&(TIM12->DIER), TIM_DIER_UIE, 0x5F5FU); // Update interrupt TIM12->SR = 0; } int gmlan_timeout_counter = GMLAN_TICKS_PER_TIMEOUT_TICKLE; //GMLAN transceiver times out every 17ms held high; tickle every 15ms int can_timeout_counter = GMLAN_TICKS_PER_SECOND; //1 second int inverted_bit_to_send = GMLAN_HIGH; int gmlan_switch_below_timeout = -1; int gmlan_switch_timeout_enable = 0; void gmlan_switch_init(int timeout_enable) { gmlan_switch_timeout_enable = timeout_enable; gmlan_alt_mode = GPIO_SWITCH; gmlan_switch_below_timeout = 1; set_gpio_mode(GPIOB, 13, MODE_OUTPUT); setup_timer(); inverted_bit_to_send = GMLAN_LOW; //We got initialized, set the output low } void set_gmlan_digital_output(int to_set) { inverted_bit_to_send = to_set; /* puts("Writing "); puth(inverted_bit_to_send); puts("\n"); */ } void reset_gmlan_switch_timeout(void) { can_timeout_counter = GMLAN_TICKS_PER_SECOND; gmlan_switch_below_timeout = 1; gmlan_alt_mode = GPIO_SWITCH; } void set_bitbanged_gmlan(int val) { if (val != 0) { register_set_bits(&(GPIOB->ODR), (1U << 13)); } else { register_clear_bits(&(GPIOB->ODR), (1U << 13)); } } char pkt_stuffed[MAX_BITS_CAN_PACKET]; int gmlan_sending = -1; int gmlan_sendmax = -1; bool gmlan_send_ok = true; int gmlan_silent_count = 0; int gmlan_fail_count = 0; #define REQUIRED_SILENT_TIME 10 #define MAX_FAIL_COUNT 10 void TIM12_IRQ_Handler(void) { if (gmlan_alt_mode == BITBANG) { if ((TIM12->SR & TIM_SR_UIF) && (gmlan_sendmax != -1)) { int read = get_gpio_input(GPIOB, 12); if (gmlan_silent_count < REQUIRED_SILENT_TIME) { if (read == 0) { gmlan_silent_count = 0; } else { gmlan_silent_count++; } } else { bool retry = 0; // in send loop if ((gmlan_sending > 0) && // not first bit ((read == 0) && (pkt_stuffed[gmlan_sending-1] == 1)) && // bus wrongly dominant (gmlan_sending != (gmlan_sendmax - 11))) { //not ack bit puts("GMLAN ERR: bus driven at "); puth(gmlan_sending); puts("\n"); retry = 1; } else if ((read == 1) && (gmlan_sending == (gmlan_sendmax - 11))) { // recessive during ACK puts("GMLAN ERR: didn't recv ACK\n"); retry = 1; } else { // do not retry } if (retry) { // reset sender (retry after 7 silent) set_bitbanged_gmlan(1); // recessive gmlan_silent_count = 0; gmlan_sending = 0; gmlan_fail_count++; if (gmlan_fail_count == MAX_FAIL_COUNT) { puts("GMLAN ERR: giving up send\n"); gmlan_send_ok = false; } } else { set_bitbanged_gmlan(pkt_stuffed[gmlan_sending]); gmlan_sending++; } } if ((gmlan_sending == gmlan_sendmax) || (gmlan_fail_count == MAX_FAIL_COUNT)) { set_bitbanged_gmlan(1); // recessive set_gpio_mode(GPIOB, 13, MODE_INPUT); register_clear_bits(&(TIM12->DIER), TIM_DIER_UIE); // No update interrupt register_set(&(TIM12->CR1), 0U, 0x3FU); // Disable timer gmlan_sendmax = -1; // exit } } } else if (gmlan_alt_mode == GPIO_SWITCH) { if ((TIM12->SR & TIM_SR_UIF) && (gmlan_switch_below_timeout != -1)) { if ((can_timeout_counter == 0) && gmlan_switch_timeout_enable) { //it has been more than 1 second since timeout was reset; disable timer and restore the GMLAN output set_gpio_output(GPIOB, 13, GMLAN_LOW); gmlan_switch_below_timeout = -1; gmlan_timeout_counter = GMLAN_TICKS_PER_TIMEOUT_TICKLE; gmlan_alt_mode = DISABLED; } else { can_timeout_counter--; if (gmlan_timeout_counter == 0) { //Send a 1 (bus low) every 15ms to reset the GMLAN transceivers timeout gmlan_timeout_counter = GMLAN_TICKS_PER_TIMEOUT_TICKLE; set_gpio_output(GPIOB, 13, GMLAN_LOW); } else { set_gpio_output(GPIOB, 13, inverted_bit_to_send); gmlan_timeout_counter--; } } } } else { // Invalid GMLAN mode. Do not put a print statement here, way too fast to keep up with } TIM12->SR = 0; } bool bitbang_gmlan(CAN_FIFOMailBox_TypeDef *to_bang) { gmlan_send_ok = true; gmlan_alt_mode = BITBANG; if (gmlan_sendmax == -1) { int len = get_bit_message(pkt_stuffed, to_bang); gmlan_fail_count = 0; gmlan_silent_count = 0; gmlan_sending = 0; gmlan_sendmax = len; // setup for bitbang loop set_bitbanged_gmlan(1); // recessive set_gpio_mode(GPIOB, 13, MODE_OUTPUT); // 33kbps setup_timer(); } return gmlan_send_ok; } ================================================ FILE: panda/board/drivers/gpio.h ================================================ #define MODE_INPUT 0 #define MODE_OUTPUT 1 #define MODE_ALTERNATE 2 #define MODE_ANALOG 3 #define PULL_NONE 0 #define PULL_UP 1 #define PULL_DOWN 2 #define OUTPUT_TYPE_PUSH_PULL 0U #define OUTPUT_TYPE_OPEN_DRAIN 1U void set_gpio_mode(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { ENTER_CRITICAL(); uint32_t tmp = GPIO->MODER; tmp &= ~(3U << (pin * 2U)); tmp |= (mode << (pin * 2U)); register_set(&(GPIO->MODER), tmp, 0xFFFFFFFFU); EXIT_CRITICAL(); } void set_gpio_output(GPIO_TypeDef *GPIO, unsigned int pin, bool enabled) { ENTER_CRITICAL(); if (enabled) { register_set_bits(&(GPIO->ODR), (1U << pin)); } else { register_clear_bits(&(GPIO->ODR), (1U << pin)); } set_gpio_mode(GPIO, pin, MODE_OUTPUT); EXIT_CRITICAL(); } void set_gpio_output_type(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int output_type){ ENTER_CRITICAL(); if(output_type == OUTPUT_TYPE_OPEN_DRAIN) { register_set_bits(&(GPIO->OTYPER), (1U << pin)); } else { register_clear_bits(&(GPIO->OTYPER), (1U << pin)); } EXIT_CRITICAL(); } void set_gpio_alternate(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { ENTER_CRITICAL(); uint32_t tmp = GPIO->AFR[pin >> 3U]; tmp &= ~(0xFU << ((pin & 7U) * 4U)); tmp |= mode << ((pin & 7U) * 4U); register_set(&(GPIO->AFR[pin >> 3]), tmp, 0xFFFFFFFFU); set_gpio_mode(GPIO, pin, MODE_ALTERNATE); EXIT_CRITICAL(); } void set_gpio_pullup(GPIO_TypeDef *GPIO, unsigned int pin, unsigned int mode) { ENTER_CRITICAL(); uint32_t tmp = GPIO->PUPDR; tmp &= ~(3U << (pin * 2U)); tmp |= (mode << (pin * 2U)); register_set(&(GPIO->PUPDR), tmp, 0xFFFFFFFFU); EXIT_CRITICAL(); } int get_gpio_input(GPIO_TypeDef *GPIO, unsigned int pin) { return (GPIO->IDR & (1U << pin)) == (1U << pin); } // Detection with internal pullup #define PULL_EFFECTIVE_DELAY 4096 bool detect_with_pull(GPIO_TypeDef *GPIO, int pin, int mode) { set_gpio_mode(GPIO, pin, MODE_INPUT); set_gpio_pullup(GPIO, pin, mode); for (volatile int i=0; iharness_config->GPIO_relay_SBU2, current_board->harness_config->pin_relay_SBU2, !intercept); } else { set_gpio_output(current_board->harness_config->GPIO_relay_SBU1, current_board->harness_config->pin_relay_SBU1, !intercept); } } } bool harness_check_ignition(void) { bool ret = false; switch(car_harness_status){ case HARNESS_STATUS_NORMAL: ret = !get_gpio_input(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1); break; case HARNESS_STATUS_FLIPPED: ret = !get_gpio_input(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2); break; default: break; } return ret; } uint8_t harness_detect_orientation(void) { uint8_t ret = HARNESS_STATUS_NC; #ifndef BOOTSTUB uint32_t sbu1_voltage = adc_get(current_board->harness_config->adc_channel_SBU1); uint32_t sbu2_voltage = adc_get(current_board->harness_config->adc_channel_SBU2); // Detect connection and orientation if((sbu1_voltage < HARNESS_CONNECTED_THRESHOLD) || (sbu2_voltage < HARNESS_CONNECTED_THRESHOLD)){ if (sbu1_voltage < sbu2_voltage) { // orientation flipped (PANDA_SBU1->HARNESS_SBU1(relay), PANDA_SBU2->HARNESS_SBU2(ign)) ret = HARNESS_STATUS_FLIPPED; } else { // orientation normal (PANDA_SBU2->HARNESS_SBU1(relay), PANDA_SBU1->HARNESS_SBU2(ign)) ret = HARNESS_STATUS_NORMAL; } } #endif return ret; } void harness_init(void) { // delay such that the connection is fully made before trying orientation detection current_board->set_led(LED_BLUE, true); delay(10000000); current_board->set_led(LED_BLUE, false); // try to detect orientation uint8_t ret = harness_detect_orientation(); if (ret != HARNESS_STATUS_NC) { puts("detected car harness with orientation "); puth2(ret); puts("\n"); car_harness_status = ret; // set the SBU lines to be inputs before using the relay. The lines are not 5V tolerant in ADC mode! set_gpio_mode(current_board->harness_config->GPIO_SBU1, current_board->harness_config->pin_SBU1, MODE_INPUT); set_gpio_mode(current_board->harness_config->GPIO_SBU2, current_board->harness_config->pin_SBU2, MODE_INPUT); // keep busses connected by default set_intercept_relay(false); } else { puts("failed to detect car harness!\n"); } } ================================================ FILE: panda/board/drivers/interrupts.h ================================================ typedef struct interrupt { IRQn_Type irq_type; void (*handler)(void); uint32_t call_counter; uint32_t max_call_rate; // Call rate is defined as the amount of calls each second uint32_t call_rate_fault; } interrupt; void interrupt_timer_init(void); void unused_interrupt_handler(void) { // Something is wrong if this handler is called! puts("Unused interrupt handler called!\n"); fault_occurred(FAULT_UNUSED_INTERRUPT_HANDLED); } interrupt interrupts[NUM_INTERRUPTS]; #define REGISTER_INTERRUPT(irq_num, func_ptr, call_rate, rate_fault) \ interrupts[irq_num].irq_type = (irq_num); \ interrupts[irq_num].handler = (func_ptr); \ interrupts[irq_num].call_counter = 0U; \ interrupts[irq_num].max_call_rate = (call_rate); \ interrupts[irq_num].call_rate_fault = (rate_fault); bool check_interrupt_rate = false; void handle_interrupt(IRQn_Type irq_type){ interrupts[irq_type].call_counter++; interrupts[irq_type].handler(); // Check that the interrupts don't fire too often if(check_interrupt_rate && (interrupts[irq_type].call_counter > interrupts[irq_type].max_call_rate)){ puts("Interrupt 0x"); puth(irq_type); puts(" fired too often (0x"); puth(interrupts[irq_type].call_counter); puts("/s)!\n"); fault_occurred(interrupts[irq_type].call_rate_fault); } } // Reset interrupt counter every second void interrupt_timer_handler(void) { if (INTERRUPT_TIMER->SR != 0) { for(uint16_t i=0U; iSR = 0; } void init_interrupts(bool check_rate_limit){ check_interrupt_rate = check_rate_limit; for(uint16_t i=0U; iPSC), (48-1), 0xFFFFU); // Tick on 1 us register_set(&(TIM5->CR1), TIM_CR1_CEN, 0x3FU); // Enable register_set(&(TIM5->ARR), (5000-1), 0xFFFFFFFFU); // Reset every 5 ms // in case it's disabled NVIC_EnableIRQ(TIM5_IRQn); // run the interrupt register_set(&(TIM5->DIER), TIM_DIER_UIE, 0x5F5FU); // Update interrupt TIM5->SR = 0; } bool k_init = false; bool l_init = false; void setup_kline(bool bitbang) { if (bitbang) { if (k_init) { set_gpio_output(GPIOC, 12, true); } if (l_init) { set_gpio_output(GPIOC, 10, true); } } else { if (k_init) { set_gpio_mode(GPIOC, 12, MODE_ALTERNATE); } if (l_init) { set_gpio_mode(GPIOC, 10, MODE_ALTERNATE); } } } void set_bitbanged_kline(bool marking) { // tickle needs to be super fast (so logic level doesn't change) ENTER_CRITICAL(); if (k_init) { register_set_bits(&(GPIOC->ODR), (1U << 12)); if (!marking) { register_clear_bits(&(GPIOC->ODR), (1U << 12)); } } if (l_init) { register_set_bits(&(GPIOC->ODR), (1U << 10)); if (!marking) { register_clear_bits(&(GPIOC->ODR), (1U << 10)); } } EXIT_CRITICAL(); // blink blue LED each time line is pulled low current_board->set_led(LED_BLUE, marking); } uint16_t kline_data = 0; uint16_t kline_data_len = 0; uint16_t kline_bit_count = 0; uint16_t kline_tick_count = 0; uint16_t kline_ticks_per_bit = 0; void TIM5_IRQ_Handler(void) { if ((TIM5->SR & TIM_SR_UIF) && (kline_data != 0U)) { if (kline_bit_count < kline_data_len) { bool marking = (kline_data & (1U << kline_bit_count)) != 0U; set_bitbanged_kline(marking); } else { register_clear_bits(&(TIM5->DIER), TIM_DIER_UIE); // No update interrupt register_set(&(TIM5->CR1), 0U, 0x3FU); // Disable timer setup_kline(false); kline_data = 0U; USB_WritePacket(NULL, 0, 0); // required call (so send nothing) USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } kline_tick_count++; if ((kline_tick_count % kline_ticks_per_bit) == 0U) { kline_bit_count++; } } TIM5->SR = 0; } bool bitbang_five_baud_addr(bool k, bool l, uint8_t addr) { bool result = false; if (kline_data == 0U) { k_init = k; l_init = l; kline_data = (addr << 1) + 0x200U; // add start/stop bits kline_data_len = 10U; kline_bit_count = 0; kline_tick_count = 0; kline_ticks_per_bit = 40U; // 200ms == 5bps setup_kline(true); setup_timer5(); result = true; } return result; } bool bitbang_wakeup(bool k, bool l) { bool result = false; if (kline_data == 0U) { k_init = k; l_init = l; kline_data = 2U; // low then high kline_data_len = 2U; kline_bit_count = 0; kline_tick_count = 0; kline_ticks_per_bit = 5U; // 25ms == 40bps setup_kline(true); setup_timer5(); result = true; } return result; } ================================================ FILE: panda/board/drivers/pwm.h ================================================ #define PWM_COUNTER_OVERFLOW 2000U // To get ~50kHz // TODO: Implement for 32-bit timers void pwm_init(TIM_TypeDef *TIM, uint8_t channel){ // Enable timer and auto-reload register_set(&(TIM->CR1), TIM_CR1_CEN | TIM_CR1_ARPE, 0x3FU); // Set channel as PWM mode 1 and enable output switch(channel){ case 1U: register_set_bits(&(TIM->CCMR1), (TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1PE)); register_set_bits(&(TIM->CCER), TIM_CCER_CC1E); break; case 2U: register_set_bits(&(TIM->CCMR1), (TIM_CCMR1_OC2M_2 | TIM_CCMR1_OC2M_1 | TIM_CCMR1_OC2PE)); register_set_bits(&(TIM->CCER), TIM_CCER_CC2E); break; case 3U: register_set_bits(&(TIM->CCMR2), (TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3PE)); register_set_bits(&(TIM->CCER), TIM_CCER_CC3E); break; case 4U: register_set_bits(&(TIM->CCMR2), (TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4M_1 | TIM_CCMR2_OC4PE)); register_set_bits(&(TIM->CCER), TIM_CCER_CC4E); break; default: break; } // Set max counter value register_set(&(TIM->ARR), PWM_COUNTER_OVERFLOW, 0xFFFFU); // Update registers and clear counter TIM->EGR |= TIM_EGR_UG; } void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage){ uint16_t comp_value = (((uint16_t) percentage * PWM_COUNTER_OVERFLOW) / 100U); switch(channel){ case 1U: register_set(&(TIM->CCR1), comp_value, 0xFFFFU); break; case 2U: register_set(&(TIM->CCR2), comp_value, 0xFFFFU); break; case 3U: register_set(&(TIM->CCR3), comp_value, 0xFFFFU); break; case 4U: register_set(&(TIM->CCR4), comp_value, 0xFFFFU); break; default: break; } } ================================================ FILE: panda/board/drivers/registers.h ================================================ typedef struct reg { volatile uint32_t *address; uint32_t value; uint32_t check_mask; } reg; // 10 bit hash with 23 as a prime #define REGISTER_MAP_SIZE 0x3FFU #define HASHING_PRIME 23U #define CHECK_COLLISION(hash, addr) (((uint32_t) register_map[hash].address != 0U) && (register_map[hash].address != (addr))) reg register_map[REGISTER_MAP_SIZE]; // Hash spread in first and second iterations seems to be reasonable. // See: tests/development/register_hashmap_spread.py // Also, check the collision warnings in the debug output, and minimize those. uint16_t hash_addr(uint32_t input){ return (((input >> 16U) ^ ((((input + 1U) & 0xFFFFU) * HASHING_PRIME) & 0xFFFFU)) & REGISTER_MAP_SIZE); } // Do not put bits in the check mask that get changed by the hardware void register_set(volatile uint32_t *addr, uint32_t val, uint32_t mask){ ENTER_CRITICAL() // Set bits in register that are also in the mask (*addr) = ((*addr) & (~mask)) | (val & mask); // Add these values to the map uint16_t hash = hash_addr((uint32_t) addr); uint16_t tries = REGISTER_MAP_SIZE; while(CHECK_COLLISION(hash, addr) && (tries > 0U)) { hash = hash_addr((uint32_t) hash); tries--;} if (tries != 0U){ register_map[hash].address = addr; register_map[hash].value = (register_map[hash].value & (~mask)) | (val & mask); register_map[hash].check_mask |= mask; } else { #ifdef DEBUG_FAULTS puts("Hash collision: address 0x"); puth((uint32_t) addr); puts("!\n"); #endif } EXIT_CRITICAL() } // Set individual bits. Also add them to the check_mask. // Do not use this to change bits that get reset by the hardware void register_set_bits(volatile uint32_t *addr, uint32_t val) { return register_set(addr, val, val); } // Clear individual bits. Also add them to the check_mask. // Do not use this to clear bits that get set by the hardware void register_clear_bits(volatile uint32_t *addr, uint32_t val) { return register_set(addr, (~val), val); } // To be called periodically void check_registers(void){ for(uint16_t i=0U; i> 4U) * 10U) + (value & 0x0FU); } void rtc_init(void){ if(current_board->has_rtc){ // Initialize RTC module and clock if not done already. if((RCC->BDCR & RCC_BDCR_MASK) != RCC_BDCR_OPTIONS){ puts("Initializing RTC\n"); // Reset backup domain register_set_bits(&(RCC->BDCR), RCC_BDCR_BDRST); // Disable write protection disable_bdomain_protection(); // Clear backup domain reset register_clear_bits(&(RCC->BDCR), RCC_BDCR_BDRST); // Set RTC options register_set(&(RCC->BDCR), RCC_BDCR_OPTIONS, RCC_BDCR_MASK); // Enable write protection enable_bdomain_protection(); } } } void rtc_set_time(timestamp_t time){ if(current_board->has_rtc){ puts("Setting RTC time\n"); // Disable write protection disable_bdomain_protection(); RTC->WPR = 0xCA; RTC->WPR = 0x53; // Enable initialization mode register_set_bits(&(RTC->ISR), RTC_ISR_INIT); while((RTC->ISR & RTC_ISR_INITF) == 0){} // Set time RTC->TR = (to_bcd(time.hour) << RTC_TR_HU_Pos) | (to_bcd(time.minute) << RTC_TR_MNU_Pos) | (to_bcd(time.second) << RTC_TR_SU_Pos); RTC->DR = (to_bcd(time.year - YEAR_OFFSET) << RTC_DR_YU_Pos) | (time.weekday << RTC_DR_WDU_Pos) | (to_bcd(time.month) << RTC_DR_MU_Pos) | (to_bcd(time.day) << RTC_DR_DU_Pos); // Set options register_set(&(RTC->CR), 0U, 0xFCFFFFU); // Disable initalization mode register_clear_bits(&(RTC->ISR), RTC_ISR_INIT); // Wait for synchronization while((RTC->ISR & RTC_ISR_RSF) == 0){} // Re-enable write protection RTC->WPR = 0x00; enable_bdomain_protection(); } } timestamp_t rtc_get_time(void){ timestamp_t result; // Init with zero values in case there is no RTC running result.year = 0U; result.month = 0U; result.day = 0U; result.weekday = 0U; result.hour = 0U; result.minute = 0U; result.second = 0U; if(current_board->has_rtc){ // Wait until the register sync flag is set while((RTC->ISR & RTC_ISR_RSF) == 0){} // Read time and date registers. Since our HSE > 7*LSE, this should be fine. uint32_t time = RTC->TR; uint32_t date = RTC->DR; // Parse values result.year = from_bcd((date & (RTC_DR_YT | RTC_DR_YU)) >> RTC_DR_YU_Pos) + YEAR_OFFSET; result.month = from_bcd((date & (RTC_DR_MT | RTC_DR_MU)) >> RTC_DR_MU_Pos); result.day = from_bcd((date & (RTC_DR_DT | RTC_DR_DU)) >> RTC_DR_DU_Pos); result.weekday = ((date & RTC_DR_WDU) >> RTC_DR_WDU_Pos); result.hour = from_bcd((time & (RTC_TR_HT | RTC_TR_HU)) >> RTC_TR_HU_Pos); result.minute = from_bcd((time & (RTC_TR_MNT | RTC_TR_MNU)) >> RTC_TR_MNU_Pos); result.second = from_bcd((time & (RTC_TR_ST | RTC_TR_SU)) >> RTC_TR_SU_Pos); } return result; } ================================================ FILE: panda/board/drivers/timers.h ================================================ void timer_init(TIM_TypeDef *TIM, int psc) { register_set(&(TIM->PSC), (psc-1), 0xFFFFU); register_set(&(TIM->DIER), TIM_DIER_UIE, 0x5F5FU); register_set(&(TIM->CR1), TIM_CR1_CEN, 0x3FU); TIM->SR = 0; } void microsecond_timer_init(void) { MICROSECOND_TIMER->PSC = (APB1_FREQ)-1U; MICROSECOND_TIMER->CR1 = TIM_CR1_CEN; MICROSECOND_TIMER->EGR = TIM_EGR_UG; } uint32_t microsecond_timer_get(void) { return MICROSECOND_TIMER->CNT; } void interrupt_timer_init(void) { enable_interrupt_timer(); REGISTER_INTERRUPT(INTERRUPT_TIMER_IRQ, interrupt_timer_handler, 1, FAULT_INTERRUPT_RATE_INTERRUPTS) register_set(&(INTERRUPT_TIMER->PSC), ((uint16_t)(15.25*APB1_FREQ)-1U), 0xFFFFU); register_set(&(INTERRUPT_TIMER->DIER), TIM_DIER_UIE, 0x5F5FU); register_set(&(INTERRUPT_TIMER->CR1), TIM_CR1_CEN, 0x3FU); INTERRUPT_TIMER->SR = 0; NVIC_EnableIRQ(INTERRUPT_TIMER_IRQ); } void tick_timer_init(void) { timer_init(TICK_TIMER, (uint16_t)((15.25*APB2_FREQ)/8U)); NVIC_EnableIRQ(TICK_TIMER_IRQ); } ================================================ FILE: panda/board/drivers/uart.h ================================================ // IRQs: USART1, USART2, USART3, UART5 // ***************************** Definitions ***************************** #define FIFO_SIZE_INT 0x400U #define FIFO_SIZE_DMA 0x1000U typedef struct uart_ring { volatile uint16_t w_ptr_tx; volatile uint16_t r_ptr_tx; uint8_t *elems_tx; uint32_t tx_fifo_size; volatile uint16_t w_ptr_rx; volatile uint16_t r_ptr_rx; uint8_t *elems_rx; uint32_t rx_fifo_size; USART_TypeDef *uart; void (*callback)(struct uart_ring*); bool dma_rx; } uart_ring; #define UART_BUFFER(x, size_rx, size_tx, uart_ptr, callback_ptr, rx_dma) \ uint8_t elems_rx_##x[size_rx]; \ uint8_t elems_tx_##x[size_tx]; \ uart_ring uart_ring_##x = { \ .w_ptr_tx = 0, \ .r_ptr_tx = 0, \ .elems_tx = ((uint8_t *)&(elems_tx_##x)), \ .tx_fifo_size = (size_tx), \ .w_ptr_rx = 0, \ .r_ptr_rx = 0, \ .elems_rx = ((uint8_t *)&(elems_rx_##x)), \ .rx_fifo_size = (size_rx), \ .uart = (uart_ptr), \ .callback = (callback_ptr), \ .dma_rx = (rx_dma) \ }; // ***************************** Function prototypes ***************************** void debug_ring_callback(uart_ring *ring); void uart_tx_ring(uart_ring *q); void uart_send_break(uart_ring *u); // ******************************** UART buffers ******************************** // gps = USART1 UART_BUFFER(gps, FIFO_SIZE_DMA, FIFO_SIZE_INT, USART1, NULL, true) // lin1, K-LINE = UART5 // lin2, L-LINE = USART3 UART_BUFFER(lin1, FIFO_SIZE_INT, FIFO_SIZE_INT, UART5, NULL, false) UART_BUFFER(lin2, FIFO_SIZE_INT, FIFO_SIZE_INT, USART3, NULL, false) // debug = USART2 UART_BUFFER(debug, FIFO_SIZE_INT, FIFO_SIZE_INT, USART2, debug_ring_callback, false) uart_ring *get_ring_by_number(int a) { uart_ring *ring = NULL; switch(a) { case 0: ring = &uart_ring_debug; break; case 1: ring = &uart_ring_gps; break; case 2: ring = &uart_ring_lin1; break; case 3: ring = &uart_ring_lin2; break; default: ring = NULL; break; } return ring; } // ************************* Low-level buffer functions ************************* bool getc(uart_ring *q, char *elem) { bool ret = false; ENTER_CRITICAL(); if (q->w_ptr_rx != q->r_ptr_rx) { if (elem != NULL) *elem = q->elems_rx[q->r_ptr_rx]; q->r_ptr_rx = (q->r_ptr_rx + 1U) % q->rx_fifo_size; ret = true; } EXIT_CRITICAL(); return ret; } bool injectc(uart_ring *q, char elem) { int ret = false; uint16_t next_w_ptr; ENTER_CRITICAL(); next_w_ptr = (q->w_ptr_rx + 1U) % q->tx_fifo_size; if (next_w_ptr != q->r_ptr_rx) { q->elems_rx[q->w_ptr_rx] = elem; q->w_ptr_rx = next_w_ptr; ret = true; } EXIT_CRITICAL(); return ret; } bool putc(uart_ring *q, char elem) { bool ret = false; uint16_t next_w_ptr; ENTER_CRITICAL(); next_w_ptr = (q->w_ptr_tx + 1U) % q->tx_fifo_size; if (next_w_ptr != q->r_ptr_tx) { q->elems_tx[q->w_ptr_tx] = elem; q->w_ptr_tx = next_w_ptr; ret = true; } EXIT_CRITICAL(); uart_tx_ring(q); return ret; } // Seems dangerous to use (might lock CPU if called with interrupts disabled f.e.) // TODO: Remove? Not used anyways void uart_flush(uart_ring *q) { while (q->w_ptr_tx != q->r_ptr_tx) { __WFI(); } } void uart_flush_sync(uart_ring *q) { // empty the TX buffer while (q->w_ptr_tx != q->r_ptr_tx) { uart_tx_ring(q); } } void clear_uart_buff(uart_ring *q) { ENTER_CRITICAL(); q->w_ptr_tx = 0; q->r_ptr_tx = 0; q->w_ptr_rx = 0; q->r_ptr_rx = 0; EXIT_CRITICAL(); } // ************************ High-level debug functions ********************** void putch(const char a) { if (has_external_debug_serial) { // assuming debugging is important if there's external serial connected while (!putc(&uart_ring_debug, a)); } else { // misra-c2012-17.7: serial debug function, ok to ignore output (void)injectc(&uart_ring_debug, a); } } void puts(const char *a) { for (const char *in = a; *in; in++) { if (*in == '\n') putch('\r'); putch(*in); } } void putui(uint32_t i) { uint32_t i_copy = i; char str[11]; uint8_t idx = 10; str[idx] = '\0'; idx--; do { str[idx] = (i_copy % 10U) + 0x30U; idx--; i_copy /= 10; } while (i_copy != 0U); puts(&str[idx + 1U]); } void puth(unsigned int i) { const char c[] = "0123456789abcdef"; for (int pos = 28; pos != -4; pos -= 4) { putch(c[(i >> (unsigned int)(pos)) & 0xFU]); } } void puth2(unsigned int i) { const char c[] = "0123456789abcdef"; for (int pos = 4; pos != -4; pos -= 4) { putch(c[(i >> (unsigned int)(pos)) & 0xFU]); } } void hexdump(const void *a, int l) { if (a != NULL) { for (int i=0; i < l; i++) { if ((i != 0) && ((i & 0xf) == 0)) puts("\n"); puth2(((const unsigned char*)a)[i]); puts(" "); } } puts("\n"); } ================================================ FILE: panda/board/drivers/usb.h ================================================ // IRQs: OTG_FS typedef union { uint16_t w; struct BW { uint8_t msb; uint8_t lsb; } bw; } uint16_t_uint8_t; typedef union _USB_Setup { uint32_t d8[2]; struct _SetupPkt_Struc { uint8_t bmRequestType; uint8_t bRequest; uint16_t_uint8_t wValue; uint16_t_uint8_t wIndex; uint16_t_uint8_t wLength; } b; } USB_Setup_TypeDef; #define MAX_CAN_MSGS_PER_BULK_TRANSFER 4U bool usb_eopf_detected = false; void usb_init(void); int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired); int usb_cb_ep1_in(void *usbdata, int len, bool hardwired); void usb_cb_ep2_out(void *usbdata, int len, bool hardwired); void usb_cb_ep3_out(void *usbdata, int len, bool hardwired); void usb_cb_ep3_out_complete(void); void usb_cb_enumeration_complete(void); void usb_outep3_resume_if_paused(void); // **** supporting defines **** #define USB_REQ_GET_STATUS 0x00 #define USB_REQ_CLEAR_FEATURE 0x01 #define USB_REQ_SET_FEATURE 0x03 #define USB_REQ_SET_ADDRESS 0x05 #define USB_REQ_GET_DESCRIPTOR 0x06 #define USB_REQ_SET_DESCRIPTOR 0x07 #define USB_REQ_GET_CONFIGURATION 0x08 #define USB_REQ_SET_CONFIGURATION 0x09 #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C #define USB_DESC_TYPE_DEVICE 0x01 #define USB_DESC_TYPE_CONFIGURATION 0x02 #define USB_DESC_TYPE_STRING 0x03 #define USB_DESC_TYPE_INTERFACE 0x04 #define USB_DESC_TYPE_ENDPOINT 0x05 #define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06 #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07 #define USB_DESC_TYPE_BINARY_OBJECT_STORE 0x0f // offsets for configuration strings #define STRING_OFFSET_LANGID 0x00 #define STRING_OFFSET_IMANUFACTURER 0x01 #define STRING_OFFSET_IPRODUCT 0x02 #define STRING_OFFSET_ISERIAL 0x03 #define STRING_OFFSET_ICONFIGURATION 0x04 #define STRING_OFFSET_IINTERFACE 0x05 // WebUSB requests #define WEBUSB_REQ_GET_URL 0x02 // WebUSB types #define WEBUSB_DESC_TYPE_URL 0x03 #define WEBUSB_URL_SCHEME_HTTPS 0x01 #define WEBUSB_URL_SCHEME_HTTP 0x00 // WinUSB requests #define WINUSB_REQ_GET_COMPATID_DESCRIPTOR 0x04 #define WINUSB_REQ_GET_EXT_PROPS_OS 0x05 #define WINUSB_REQ_GET_DESCRIPTOR 0x07 #define STS_GOUT_NAK 1 #define STS_DATA_UPDT 2 #define STS_XFER_COMP 3 #define STS_SETUP_COMP 4 #define STS_SETUP_UPDT 6 uint8_t resp[MAX_RESP_LEN]; // for the repeating interfaces #define DSCR_INTERFACE_LEN 9 #define DSCR_ENDPOINT_LEN 7 #define DSCR_CONFIG_LEN 9 #define DSCR_DEVICE_LEN 18 // endpoint types #define ENDPOINT_TYPE_CONTROL 0 #define ENDPOINT_TYPE_ISO 1 #define ENDPOINT_TYPE_BULK 2 #define ENDPOINT_TYPE_INT 3 // These are arbitrary values used in bRequest #define MS_VENDOR_CODE 0x20 #define WEBUSB_VENDOR_CODE 0x30 // BOS constants #define BINARY_OBJECT_STORE_DESCRIPTOR_LENGTH 0x05 #define BINARY_OBJECT_STORE_DESCRIPTOR 0x0F #define WINUSB_PLATFORM_DESCRIPTOR_LENGTH 0x9E // Convert machine byte order to USB byte order #define TOUSBORDER(num)\ ((num) & 0xFFU), (((num) >> 8) & 0xFFU) // take in string length and return the first 2 bytes of a string descriptor #define STRING_DESCRIPTOR_HEADER(size)\ (((((size) * 2) + 2) & 0xFF) | 0x0300) uint8_t device_desc[] = { DSCR_DEVICE_LEN, USB_DESC_TYPE_DEVICE, //Length, Type 0x10, 0x02, // bcdUSB max version of USB supported (2.1) 0xFF, 0xFF, 0xFF, 0x40, // Class, Subclass, Protocol, Max Packet Size TOUSBORDER(USB_VID), // idVendor TOUSBORDER(USB_PID), // idProduct 0x00, 0x00, // bcdDevice 0x01, 0x02, // Manufacturer, Product 0x03, 0x01 // Serial Number, Num Configurations }; uint8_t device_qualifier[] = { 0x0a, USB_DESC_TYPE_DEVICE_QUALIFIER, //Length, Type 0x10, 0x02, // bcdUSB max version of USB supported (2.1) 0xFF, 0xFF, 0xFF, 0x40, // bDeviceClass, bDeviceSubClass, bDeviceProtocol, bMaxPacketSize0 0x01, 0x00 // bNumConfigurations, bReserved }; #define ENDPOINT_RCV 0x80 #define ENDPOINT_SND 0x00 uint8_t configuration_desc[] = { DSCR_CONFIG_LEN, USB_DESC_TYPE_CONFIGURATION, // Length, Type, TOUSBORDER(0x0045U), // Total Len (uint16) 0x01, 0x01, STRING_OFFSET_ICONFIGURATION, // Num Interface, Config Value, Configuration 0xc0, 0x32, // Attributes, Max Power // interface 0 ALT 0 DSCR_INTERFACE_LEN, USB_DESC_TYPE_INTERFACE, // Length, Type 0x00, 0x00, 0x03, // Index, Alt Index idx, Endpoint count 0XFF, 0xFF, 0xFF, // Class, Subclass, Protocol 0x00, // Interface // endpoint 1, read CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_RCV | 1, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval (NA) // endpoint 2, send serial DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 2, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval // endpoint 3, send CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 3, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval // interface 0 ALT 1 DSCR_INTERFACE_LEN, USB_DESC_TYPE_INTERFACE, // Length, Type 0x00, 0x01, 0x03, // Index, Alt Index idx, Endpoint count 0XFF, 0xFF, 0xFF, // Class, Subclass, Protocol 0x00, // Interface // endpoint 1, read CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_RCV | 1, ENDPOINT_TYPE_INT, // Endpoint Num/Direction, Type TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x05, // Polling Interval (5 frames) // endpoint 2, send serial DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 2, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval // endpoint 3, send CAN DSCR_ENDPOINT_LEN, USB_DESC_TYPE_ENDPOINT, // Length, Type ENDPOINT_SND | 3, ENDPOINT_TYPE_BULK, // Endpoint Num/Direction, Type TOUSBORDER(0x0040U), // Max Packet (0x0040) 0x00, // Polling Interval }; // STRING_DESCRIPTOR_HEADER is for uint16 string descriptors // it takes in a string length, which is bytes/2 because unicode uint16_t string_language_desc[] = { STRING_DESCRIPTOR_HEADER(1), 0x0409 // american english }; // these strings are all uint16's so that we don't need to spam ,0 after every character uint16_t string_manufacturer_desc[] = { STRING_DESCRIPTOR_HEADER(8), 'c', 'o', 'm', 'm', 'a', '.', 'a', 'i' }; uint16_t string_product_desc[] = { STRING_DESCRIPTOR_HEADER(5), 'p', 'a', 'n', 'd', 'a' }; // default serial number when we're not a panda uint16_t string_serial_desc[] = { STRING_DESCRIPTOR_HEADER(4), 'n', 'o', 'n', 'e' }; // a string containing the default configuration index uint16_t string_configuration_desc[] = { STRING_DESCRIPTOR_HEADER(2), '0', '1' // "01" }; // WCID (auto install WinUSB driver) // https://github.com/pbatard/libwdi/wiki/WCID-Devices // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb-installation#automatic-installation-of--winusb-without-an-inf-file // WinUSB 1.0 descriptors, this is mostly used by Windows XP uint8_t string_238_desc[] = { 0x12, USB_DESC_TYPE_STRING, // bLength, bDescriptorType 'M',0, 'S',0, 'F',0, 'T',0, '1',0, '0',0, '0',0, // qwSignature (MSFT100) MS_VENDOR_CODE, 0x00 // bMS_VendorCode, bPad }; uint8_t winusb_ext_compatid_os_desc[] = { 0x28, 0x00, 0x00, 0x00, // dwLength 0x00, 0x01, // bcdVersion 0x04, 0x00, // wIndex 0x01, // bCount 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Reserved 0x00, // bFirstInterfaceNumber 0x00, // Reserved 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, // compatible ID (WINUSB) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // subcompatible ID (none) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // Reserved }; uint8_t winusb_ext_prop_os_desc[] = { 0x8e, 0x00, 0x00, 0x00, // dwLength 0x00, 0x01, // bcdVersion 0x05, 0x00, // wIndex 0x01, 0x00, // wCount // first property 0x84, 0x00, 0x00, 0x00, // dwSize 0x01, 0x00, 0x00, 0x00, // dwPropertyDataType 0x28, 0x00, // wPropertyNameLength 'D',0, 'e',0, 'v',0, 'i',0, 'c',0, 'e',0, 'I',0, 'n',0, 't',0, 'e',0, 'r',0, 'f',0, 'a',0, 'c',0, 'e',0, 'G',0, 'U',0, 'I',0, 'D',0, 0, 0, // bPropertyName (DeviceInterfaceGUID) 0x4e, 0x00, 0x00, 0x00, // dwPropertyDataLength '{',0, 'c',0, 'c',0, 'e',0, '5',0, '2',0, '9',0, '1',0, 'c',0, '-',0, 'a',0, '6',0, '9',0, 'f',0, '-',0, '4',0 ,'9',0 ,'9',0 ,'5',0 ,'-',0, 'a',0, '4',0, 'c',0, '2',0, '-',0, '2',0, 'a',0, 'e',0, '5',0, '7',0, 'a',0, '5',0, '1',0, 'a',0, 'd',0, 'e',0, '9',0, '}',0, 0, 0, // bPropertyData ({CCE5291C-A69F-4995-A4C2-2AE57A51ADE9}) }; /* Binary Object Store descriptor used to expose WebUSB (and more WinUSB) metadata comments are from the wicg spec References used: https://wicg.github.io/webusb/#webusb-platform-capability-descriptor https://github.com/sowbug/weblight/blob/192ad7a0e903542e2aa28c607d98254a12a6399d/firmware/webusb.c https://os.mbed.com/users/larsgk/code/USBDevice_WebUSB/file/1d8a6665d607/WebUSBDevice/ */ uint8_t binary_object_store_desc[] = { // BOS header BINARY_OBJECT_STORE_DESCRIPTOR_LENGTH, // bLength, this is only the length of the header BINARY_OBJECT_STORE_DESCRIPTOR, // bDescriptorType 0x39, 0x00, // wTotalLength (LSB, MSB) 0x02, // bNumDeviceCaps (WebUSB + WinUSB) // ------------------------------------------------- // WebUSB descriptor // header 0x18, // bLength, Size of this descriptor. Must be set to 24. 0x10, // bDescriptorType, DEVICE CAPABILITY descriptor 0x05, // bDevCapabilityType, PLATFORM capability 0x00, // bReserved, This field is reserved and shall be set to zero. // PlatformCapabilityUUID, Must be set to {3408b638-09a9-47a0-8bfd-a0768815b665}. 0x38, 0xB6, 0x08, 0x34, 0xA9, 0x09, 0xA0, 0x47, 0x8B, 0xFD, 0xA0, 0x76, 0x88, 0x15, 0xB6, 0x65, // 0x00, 0x01, // bcdVersion, Protocol version supported. Must be set to 0x0100. WEBUSB_VENDOR_CODE, // bVendorCode, bRequest value used for issuing WebUSB requests. // there used to be a concept of "allowed origins", but it was removed from the spec // it was intended to be a security feature, but then the entire security model relies on domain ownership // https://github.com/WICG/webusb/issues/49 // other implementations use various other indexed to leverate this no-longer-valid feature. we wont. // the spec says we *must* reply to index 0x03 with the url, so we'll hint that that's the right index 0x03, // iLandingPage, URL descriptor index of the device’s landing page. // ------------------------------------------------- // WinUSB descriptor // header 0x1C, // Descriptor size (28 bytes) 0x10, // Descriptor type (Device Capability) 0x05, // Capability type (Platform) 0x00, // Reserved // MS OS 2.0 Platform Capability ID (D8DD60DF-4589-4CC7-9CD2-659D9E648A9F) // Indicates the device supports the Microsoft OS 2.0 descriptor 0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, 0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F, 0x00, 0x00, 0x03, 0x06, // Windows version, currently set to 8.1 (0x06030000) WINUSB_PLATFORM_DESCRIPTOR_LENGTH, 0x00, // MS OS 2.0 descriptor size (word) MS_VENDOR_CODE, 0x00 // vendor code, no alternate enumeration }; uint8_t webusb_url_descriptor[] = { 0x14, /* bLength */ WEBUSB_DESC_TYPE_URL, // bDescriptorType WEBUSB_URL_SCHEME_HTTPS, // bScheme 'u', 's', 'b', 'p', 'a', 'n', 'd', 'a', '.', 'c', 'o', 'm', 'm', 'a', '.', 'a', 'i' }; // WinUSB 2.0 descriptor. This is what modern systems use // https://github.com/sowbug/weblight/blob/192ad7a0e903542e2aa28c607d98254a12a6399d/firmware/webusb.c // http://janaxelson.com/files/ms_os_20_descriptors.c // https://books.google.com/books?id=pkefBgAAQBAJ&pg=PA353&lpg=PA353 uint8_t winusb_20_desc[WINUSB_PLATFORM_DESCRIPTOR_LENGTH] = { // Microsoft OS 2.0 descriptor set header (table 10) 0x0A, 0x00, // Descriptor size (10 bytes) 0x00, 0x00, // MS OS 2.0 descriptor set header 0x00, 0x00, 0x03, 0x06, // Windows version (8.1) (0x06030000) WINUSB_PLATFORM_DESCRIPTOR_LENGTH, 0x00, // Total size of MS OS 2.0 descriptor set // Microsoft OS 2.0 compatible ID descriptor 0x14, 0x00, // Descriptor size (20 bytes) 0x03, 0x00, // MS OS 2.0 compatible ID descriptor 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, // compatible ID (WINUSB) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub-compatible ID // Registry property descriptor 0x80, 0x00, // Descriptor size (130 bytes) 0x04, 0x00, // Registry Property descriptor 0x01, 0x00, // Strings are null-terminated Unicode 0x28, 0x00, // Size of Property Name (40 bytes) "DeviceInterfaceGUID" // bPropertyName (DeviceInterfaceGUID) 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00, 0x4E, 0x00, // Size of Property Data (78 bytes) // Vendor-defined property data: {CCE5291C-A69F-4995-A4C2-2AE57A51ADE9} '{', 0x00, 'c', 0x00, 'c', 0x00, 'e', 0x00, '5', 0x00, '2', 0x00, '9', 0x00, '1', 0x00, // 16 'c', 0x00, '-', 0x00, 'a', 0x00, '6', 0x00, '9', 0x00, 'f', 0x00, '-', 0x00, '4', 0x00, // 32 '9', 0x00, '9', 0x00, '5', 0x00, '-', 0x00, 'a', 0x00, '4', 0x00, 'c', 0x00, '2', 0x00, // 48 '-', 0x00, '2', 0x00, 'a', 0x00, 'e', 0x00, '5', 0x00, '7', 0x00, 'a', 0x00, '5', 0x00, // 64 '1', 0x00, 'a', 0x00, 'd', 0x00, 'e', 0x00, '9', 0x00, '}', 0x00, 0x00, 0x00 // 78 bytes }; // current packet USB_Setup_TypeDef setup; uint8_t usbdata[0x100]; uint8_t* ep0_txdata = NULL; uint16_t ep0_txlen = 0; bool outep3_processing = false; // Store the current interface alt setting. int current_int0_alt_setting = 0; // packet read and write void *USB_ReadPacket(void *dest, uint16_t len) { uint32_t *dest_copy = (uint32_t *)dest; uint32_t count32b = (len + 3U) / 4U; for (uint32_t i = 0; i < count32b; i++) { *dest_copy = USBx_DFIFO(0); dest_copy++; } return ((void *)dest_copy); } void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) { #ifdef DEBUG_USB puts("writing "); hexdump(src, len); #endif uint32_t numpacket = (len + (MAX_RESP_LEN - 1U)) / MAX_RESP_LEN; uint32_t count32b = 0; count32b = (len + 3U) / 4U; // TODO: revisit this USBx_INEP(ep)->DIEPTSIZ = ((numpacket << 19) & USB_OTG_DIEPTSIZ_PKTCNT) | (len & USB_OTG_DIEPTSIZ_XFRSIZ); USBx_INEP(ep)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA); // load the FIFO if (src != NULL) { const uint32_t *src_copy = (const uint32_t *)src; for (uint32_t i = 0; i < count32b; i++) { USBx_DFIFO(ep) = *src_copy; src_copy++; } } } // IN EP 0 TX FIFO has a max size of 127 bytes (much smaller than the rest) // so use TX FIFO empty interrupt to send larger amounts of data void USB_WritePacket_EP0(uint8_t *src, uint16_t len) { #ifdef DEBUG_USB puts("writing "); hexdump(src, len); #endif uint16_t wplen = MIN(len, 0x40); USB_WritePacket(src, wplen, 0); if (wplen < len) { ep0_txdata = &src[wplen]; ep0_txlen = len - wplen; USBx_DEVICE->DIEPEMPMSK |= 1; } else { USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } } void usb_reset(void) { // unmask endpoint interrupts, so many sets USBx_DEVICE->DAINT = 0xFFFFFFFF; USBx_DEVICE->DAINTMSK = 0xFFFFFFFF; //USBx_DEVICE->DOEPMSK = (USB_OTG_DOEPMSK_STUPM | USB_OTG_DOEPMSK_XFRCM | USB_OTG_DOEPMSK_EPDM); //USBx_DEVICE->DIEPMSK = (USB_OTG_DIEPMSK_TOM | USB_OTG_DIEPMSK_XFRCM | USB_OTG_DIEPMSK_EPDM | USB_OTG_DIEPMSK_ITTXFEMSK); //USBx_DEVICE->DIEPMSK = (USB_OTG_DIEPMSK_TOM | USB_OTG_DIEPMSK_XFRCM | USB_OTG_DIEPMSK_EPDM); // all interrupts for debugging USBx_DEVICE->DIEPMSK = 0xFFFFFFFF; USBx_DEVICE->DOEPMSK = 0xFFFFFFFF; // clear interrupts USBx_INEP(0)->DIEPINT = 0xFF; USBx_OUTEP(0)->DOEPINT = 0xFF; // unset the address USBx_DEVICE->DCFG &= ~USB_OTG_DCFG_DAD; // set up USB FIFOs // RX start address is fixed to 0 USBx->GRXFSIZ = 0x40; // 0x100 to offset past GRXFSIZ USBx->DIEPTXF0_HNPTXFSIZ = (0x40U << 16) | 0x40U; // EP1, massive USBx->DIEPTXF[0] = (0x40U << 16) | 0x80U; // flush TX fifo USBx->GRSTCTL = USB_OTG_GRSTCTL_TXFFLSH | USB_OTG_GRSTCTL_TXFNUM_4; while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH); // flush RX FIFO USBx->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH; while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH); // no global NAK USBx_DEVICE->DCTL |= USB_OTG_DCTL_CGINAK; // ready to receive setup packets USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19)) | (3U << 3); } char to_hex_char(int a) { char ret; if (a < 10) { ret = '0' + a; } else { ret = 'a' + (a - 10); } return ret; } void usb_setup(void) { int resp_len; // setup packet is ready switch (setup.b.bRequest) { case USB_REQ_SET_CONFIGURATION: // enable other endpoints, has to be here? USBx_INEP(1)->DIEPCTL = (0x40U & USB_OTG_DIEPCTL_MPSIZ) | (2U << 18) | (1U << 22) | USB_OTG_DIEPCTL_SD0PID_SEVNFRM | USB_OTG_DIEPCTL_USBAEP; USBx_INEP(1)->DIEPINT = 0xFF; USBx_OUTEP(2)->DOEPTSIZ = (1U << 19) | 0x40U; USBx_OUTEP(2)->DOEPCTL = (0x40U & USB_OTG_DOEPCTL_MPSIZ) | (2U << 18) | USB_OTG_DOEPCTL_SD0PID_SEVNFRM | USB_OTG_DOEPCTL_USBAEP; USBx_OUTEP(2)->DOEPINT = 0xFF; USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; USBx_OUTEP(3)->DOEPCTL = (0x40U & USB_OTG_DOEPCTL_MPSIZ) | (2U << 18) | USB_OTG_DOEPCTL_SD0PID_SEVNFRM | USB_OTG_DOEPCTL_USBAEP; USBx_OUTEP(3)->DOEPINT = 0xFF; // mark ready to receive USBx_OUTEP(2)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; USB_WritePacket(0, 0, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_REQ_SET_ADDRESS: // set now? USBx_DEVICE->DCFG |= ((setup.b.wValue.w & 0x7fU) << 4); #ifdef DEBUG_USB puts(" set address\n"); #endif // TODO: this isn't enumeration complete // moved here to work better on OS X usb_cb_enumeration_complete(); USB_WritePacket(0, 0, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_REQ_GET_DESCRIPTOR: switch (setup.b.wValue.bw.lsb) { case USB_DESC_TYPE_DEVICE: //puts(" writing device descriptor\n"); // set bcdDevice to hardware type device_desc[13] = hw_type; // setup transfer USB_WritePacket(device_desc, MIN(sizeof(device_desc), setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; //puts("D"); break; case USB_DESC_TYPE_CONFIGURATION: USB_WritePacket(configuration_desc, MIN(sizeof(configuration_desc), setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_DESC_TYPE_DEVICE_QUALIFIER: USB_WritePacket(device_qualifier, MIN(sizeof(device_qualifier), setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_DESC_TYPE_STRING: switch (setup.b.wValue.bw.msb) { case STRING_OFFSET_LANGID: USB_WritePacket((uint8_t*)string_language_desc, MIN(sizeof(string_language_desc), setup.b.wLength.w), 0); break; case STRING_OFFSET_IMANUFACTURER: USB_WritePacket((uint8_t*)string_manufacturer_desc, MIN(sizeof(string_manufacturer_desc), setup.b.wLength.w), 0); break; case STRING_OFFSET_IPRODUCT: USB_WritePacket((uint8_t*)string_product_desc, MIN(sizeof(string_product_desc), setup.b.wLength.w), 0); break; case STRING_OFFSET_ISERIAL: #ifdef UID_BASE resp[0] = 0x02 + (12 * 4); resp[1] = 0x03; // 96 bits = 12 bytes for (int i = 0; i < 12; i++){ uint8_t cc = ((uint8_t *)UID_BASE)[i]; resp[2 + (i * 4) + 0] = to_hex_char((cc >> 4) & 0xFU); resp[2 + (i * 4) + 1] = '\0'; resp[2 + (i * 4) + 2] = to_hex_char((cc >> 0) & 0xFU); resp[2 + (i * 4) + 3] = '\0'; } USB_WritePacket(resp, MIN(resp[0], setup.b.wLength.w), 0); #else USB_WritePacket((const uint8_t *)string_serial_desc, MIN(sizeof(string_serial_desc), setup.b.wLength.w), 0); #endif break; case STRING_OFFSET_ICONFIGURATION: USB_WritePacket((uint8_t*)string_configuration_desc, MIN(sizeof(string_configuration_desc), setup.b.wLength.w), 0); break; case 238: USB_WritePacket((uint8_t*)string_238_desc, MIN(sizeof(string_238_desc), setup.b.wLength.w), 0); break; default: // nothing USB_WritePacket(0, 0, 0); break; } USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_DESC_TYPE_BINARY_OBJECT_STORE: USB_WritePacket(binary_object_store_desc, MIN(sizeof(binary_object_store_desc), setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; default: // nothing here? USB_WritePacket(0, 0, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; } break; case USB_REQ_GET_STATUS: // empty resp? resp[0] = 0; resp[1] = 0; USB_WritePacket((void*)&resp, 2, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case USB_REQ_SET_INTERFACE: // Store the alt setting number for IN EP behavior. current_int0_alt_setting = setup.b.wValue.w; USB_WritePacket(0, 0, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; case WEBUSB_VENDOR_CODE: switch (setup.b.wIndex.w) { case WEBUSB_REQ_GET_URL: USB_WritePacket(webusb_url_descriptor, MIN(sizeof(webusb_url_descriptor), setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; default: // probably asking for allowed origins, which was removed from the spec USB_WritePacket(0, 0, 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; break; } break; case MS_VENDOR_CODE: switch (setup.b.wIndex.w) { // winusb 2.0 descriptor from BOS case WINUSB_REQ_GET_DESCRIPTOR: USB_WritePacket_EP0((uint8_t*)winusb_20_desc, MIN(sizeof(winusb_20_desc), setup.b.wLength.w)); break; // Extended Compat ID OS Descriptor case WINUSB_REQ_GET_COMPATID_DESCRIPTOR: USB_WritePacket_EP0((uint8_t*)winusb_ext_compatid_os_desc, MIN(sizeof(winusb_ext_compatid_os_desc), setup.b.wLength.w)); break; // Extended Properties OS Descriptor case WINUSB_REQ_GET_EXT_PROPS_OS: USB_WritePacket_EP0((uint8_t*)winusb_ext_prop_os_desc, MIN(sizeof(winusb_ext_prop_os_desc), setup.b.wLength.w)); break; default: USB_WritePacket_EP0(0, 0); } break; default: resp_len = usb_cb_control_msg(&setup, resp, 1); // response pending if -1 was returned if (resp_len != -1) { USB_WritePacket(resp, MIN(resp_len, setup.b.wLength.w), 0); USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } } } // ***************************** USB port ***************************** void usb_irqhandler(void) { //USBx->GINTMSK = 0; unsigned int gintsts = USBx->GINTSTS; unsigned int gotgint = USBx->GOTGINT; unsigned int daint = USBx_DEVICE->DAINT; // gintsts SUSPEND? 04008428 #ifdef DEBUG_USB puth(gintsts); puts(" "); /*puth(USBx->GCCFG); puts(" ");*/ puth(gotgint); puts(" ep "); puth(daint); puts(" USB interrupt!\n"); #endif if ((gintsts & USB_OTG_GINTSTS_CIDSCHG) != 0) { puts("connector ID status change\n"); } if ((gintsts & USB_OTG_GINTSTS_ESUSP) != 0) { puts("ESUSP detected\n"); } if ((gintsts & USB_OTG_GINTSTS_EOPF) != 0) { usb_eopf_detected = true; } if ((gintsts & USB_OTG_GINTSTS_USBRST) != 0) { puts("USB reset\n"); usb_reset(); } if ((gintsts & USB_OTG_GINTSTS_ENUMDNE) != 0) { puts("enumeration done"); // Full speed, ENUMSPD //puth(USBx_DEVICE->DSTS); puts("\n"); } if ((gintsts & USB_OTG_GINTSTS_OTGINT) != 0) { puts("OTG int:"); puth(USBx->GOTGINT); puts("\n"); // getting ADTOCHG //USBx->GOTGINT = USBx->GOTGINT; } // RX FIFO first if ((gintsts & USB_OTG_GINTSTS_RXFLVL) != 0) { // 1. Read the Receive status pop register volatile unsigned int rxst = USBx->GRXSTSP; int status = (rxst & USB_OTG_GRXSTSP_PKTSTS) >> 17; #ifdef DEBUG_USB puts(" RX FIFO:"); puth(rxst); puts(" status: "); puth(status); puts(" len: "); puth((rxst & USB_OTG_GRXSTSP_BCNT) >> 4); puts("\n"); #endif if (status == STS_DATA_UPDT) { int endpoint = (rxst & USB_OTG_GRXSTSP_EPNUM); int len = (rxst & USB_OTG_GRXSTSP_BCNT) >> 4; (void)USB_ReadPacket(&usbdata, len); #ifdef DEBUG_USB puts(" data "); puth(len); puts("\n"); hexdump(&usbdata, len); #endif if (endpoint == 2) { usb_cb_ep2_out(usbdata, len, 1); } if (endpoint == 3) { outep3_processing = true; usb_cb_ep3_out(usbdata, len, 1); } } else if (status == STS_SETUP_UPDT) { (void)USB_ReadPacket(&setup, 8); #ifdef DEBUG_USB puts(" setup "); hexdump(&setup, 8); puts("\n"); #endif } else { // status is neither STS_DATA_UPDT or STS_SETUP_UPDT, skip } } /*if (gintsts & USB_OTG_GINTSTS_HPRTINT) { // host puts("HPRT:"); puth(USBx_HOST_PORT->HPRT); puts("\n"); if (USBx_HOST_PORT->HPRT & USB_OTG_HPRT_PCDET) { USBx_HOST_PORT->HPRT |= USB_OTG_HPRT_PRST; USBx_HOST_PORT->HPRT |= USB_OTG_HPRT_PCDET; } }*/ if ((gintsts & USB_OTG_GINTSTS_BOUTNAKEFF) || (gintsts & USB_OTG_GINTSTS_GINAKEFF)) { // no global NAK, why is this getting set? #ifdef DEBUG_USB puts("GLOBAL NAK\n"); #endif USBx_DEVICE->DCTL |= USB_OTG_DCTL_CGONAK | USB_OTG_DCTL_CGINAK; } if ((gintsts & USB_OTG_GINTSTS_SRQINT) != 0) { // we want to do "A-device host negotiation protocol" since we are the A-device /*puts("start request\n"); puth(USBx->GOTGCTL); puts("\n");*/ //USBx->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; //USBx_HOST_PORT->HPRT = USB_OTG_HPRT_PPWR | USB_OTG_HPRT_PENA; //USBx->GOTGCTL |= USB_OTG_GOTGCTL_SRQ; } // out endpoint hit if ((gintsts & USB_OTG_GINTSTS_OEPINT) != 0) { #ifdef DEBUG_USB puts(" 0:"); puth(USBx_OUTEP(0)->DOEPINT); puts(" 2:"); puth(USBx_OUTEP(2)->DOEPINT); puts(" 3:"); puth(USBx_OUTEP(3)->DOEPINT); puts(" "); puth(USBx_OUTEP(3)->DOEPCTL); puts(" 4:"); puth(USBx_OUTEP(4)->DOEPINT); puts(" OUT ENDPOINT\n"); #endif if ((USBx_OUTEP(2)->DOEPINT & USB_OTG_DOEPINT_XFRC) != 0) { #ifdef DEBUG_USB puts(" OUT2 PACKET XFRC\n"); #endif USBx_OUTEP(2)->DOEPTSIZ = (1U << 19) | 0x40U; USBx_OUTEP(2)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; } if ((USBx_OUTEP(3)->DOEPINT & USB_OTG_DOEPINT_XFRC) != 0) { #ifdef DEBUG_USB puts(" OUT3 PACKET XFRC\n"); #endif // NAK cleared by process_can (if tx buffers have room) outep3_processing = false; usb_cb_ep3_out_complete(); } else if ((USBx_OUTEP(3)->DOEPINT & 0x2000) != 0) { #ifdef DEBUG_USB puts(" OUT3 PACKET WTF\n"); #endif // if NAK was set trigger this, unknown interrupt // TODO: why was this here? fires when TX buffers when we can't clear NAK // USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; // USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } else if ((USBx_OUTEP(3)->DOEPINT) != 0) { puts("OUTEP3 error "); puth(USBx_OUTEP(3)->DOEPINT); puts("\n"); } else { // USBx_OUTEP(3)->DOEPINT is 0, ok to skip } if ((USBx_OUTEP(0)->DOEPINT & USB_OTG_DIEPINT_XFRC) != 0) { // ready for next packet USBx_OUTEP(0)->DOEPTSIZ = USB_OTG_DOEPTSIZ_STUPCNT | (USB_OTG_DOEPTSIZ_PKTCNT & (1U << 19)) | (1U << 3); } // respond to setup packets if ((USBx_OUTEP(0)->DOEPINT & USB_OTG_DOEPINT_STUP) != 0) { usb_setup(); } USBx_OUTEP(0)->DOEPINT = USBx_OUTEP(0)->DOEPINT; USBx_OUTEP(2)->DOEPINT = USBx_OUTEP(2)->DOEPINT; USBx_OUTEP(3)->DOEPINT = USBx_OUTEP(3)->DOEPINT; } // interrupt endpoint hit (Page 1221) if ((gintsts & USB_OTG_GINTSTS_IEPINT) != 0) { #ifdef DEBUG_USB puts(" "); puth(USBx_INEP(0)->DIEPINT); puts(" "); puth(USBx_INEP(1)->DIEPINT); puts(" IN ENDPOINT\n"); #endif // Should likely check the EP of the IN request even if there is // only one IN endpoint. // No need to set NAK in OTG_DIEPCTL0 when nothing to send, // Appears USB core automatically sets NAK. WritePacket clears it. // Handle the two interface alternate settings. Setting 0 has EP1 // as bulk. Setting 1 has EP1 as interrupt. The code to handle // these two EP variations are very similar and can be // restructured for smaller code footprint. Keeping split out for // now for clarity. //TODO add default case. Should it NAK? switch (current_int0_alt_setting) { case 0: ////// Bulk config // *** IN token received when TxFIFO is empty if ((USBx_INEP(1)->DIEPINT & USB_OTG_DIEPMSK_ITTXFEMSK) != 0) { #ifdef DEBUG_USB puts(" IN PACKET QUEUE\n"); #endif // TODO: always assuming max len, can we get the length? USB_WritePacket((void *)resp, usb_cb_ep1_in(resp, 0x40, 1), 1); } break; case 1: ////// Interrupt config // *** IN token received when TxFIFO is empty if ((USBx_INEP(1)->DIEPINT & USB_OTG_DIEPMSK_ITTXFEMSK) != 0) { #ifdef DEBUG_USB puts(" IN PACKET QUEUE\n"); #endif // TODO: always assuming max len, can we get the length? int len = usb_cb_ep1_in(resp, 0x40, 1); if (len > 0) { USB_WritePacket((void *)resp, len, 1); } } break; default: puts("current_int0_alt_setting value invalid\n"); break; } if ((USBx_INEP(0)->DIEPINT & USB_OTG_DIEPMSK_ITTXFEMSK) != 0) { #ifdef DEBUG_USB puts(" IN PACKET QUEUE\n"); #endif if ((ep0_txlen != 0U) && ((USBx_INEP(0)->DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV) >= 0x40U)) { uint16_t len = MIN(ep0_txlen, 0x40); USB_WritePacket(ep0_txdata, len, 0); ep0_txdata = &ep0_txdata[len]; ep0_txlen -= len; if (ep0_txlen == 0U) { ep0_txdata = NULL; USBx_DEVICE->DIEPEMPMSK &= ~1; USBx_OUTEP(0)->DOEPCTL |= USB_OTG_DOEPCTL_CNAK; } } } // clear interrupts USBx_INEP(0)->DIEPINT = USBx_INEP(0)->DIEPINT; // Why ep0? USBx_INEP(1)->DIEPINT = USBx_INEP(1)->DIEPINT; } // clear all interrupts we handled USBx_DEVICE->DAINT = daint; USBx->GOTGINT = gotgint; USBx->GINTSTS = gintsts; //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM | USB_OTG_GINTSTS_SOF | USB_OTG_GINTSTS_EOPF); } void usb_outep3_resume_if_paused(void) { ENTER_CRITICAL(); if (!outep3_processing && (USBx_OUTEP(3)->DOEPCTL & USB_OTG_DOEPCTL_NAKSTS) != 0) { USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U; USBx_OUTEP(3)->DOEPCTL |= USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK; } EXIT_CRITICAL(); } bool usb_enumerated(void) { // This relies on the USB being suspended after no activity for 3ms. // Seems pretty stable in combination with the EOPF to reject noise. bool ret = false; if(!(USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS)){ // Check to see if an end of periodic frame is detected ret = usb_eopf_detected; } usb_eopf_detected = false; return ret; } ================================================ FILE: panda/board/early_init.h ================================================ // Early bringup #define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU #define ENTER_SOFTLOADER_MAGIC 0xdeadc0deU #define BOOT_NORMAL 0xdeadb111U extern void *g_pfnVectors; extern uint32_t enter_bootloader_mode; void jump_to_bootloader(void) { // do enter bootloader enter_bootloader_mode = 0; void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *)BOOTLOADER_ADDRESS)); // jump to bootloader enable_interrupts(); bootloader(); // reset on exit enter_bootloader_mode = BOOT_NORMAL; NVIC_SystemReset(); } void early_initialization(void) { // Reset global critical depth disable_interrupts(); global_critical_depth = 0; // Init register and interrupt tables init_registers(); // after it's been in the bootloader, things are initted differently, so we reset if ((enter_bootloader_mode != BOOT_NORMAL) && (enter_bootloader_mode != ENTER_BOOTLOADER_MAGIC) && (enter_bootloader_mode != ENTER_SOFTLOADER_MAGIC)) { enter_bootloader_mode = BOOT_NORMAL; NVIC_SystemReset(); } // if wrong chip, reboot volatile unsigned int id = DBGMCU->IDCODE; if ((id & 0xFFFU) != MCU_IDCODE) { enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; } // setup interrupt table SCB->VTOR = (uint32_t)&g_pfnVectors; // early GPIOs float everything early_gpio_float(); detect_external_debug_serial(); detect_board_type(); if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) { #ifdef PANDA current_board->set_gps_mode(GPS_DISABLED); #endif current_board->set_led(LED_GREEN, 1); jump_to_bootloader(); } } ================================================ FILE: panda/board/faults.h ================================================ #define FAULT_STATUS_NONE 0U #define FAULT_STATUS_TEMPORARY 1U #define FAULT_STATUS_PERMANENT 2U // Fault types #define FAULT_RELAY_MALFUNCTION (1U << 0) #define FAULT_UNUSED_INTERRUPT_HANDLED (1U << 1) #define FAULT_INTERRUPT_RATE_CAN_1 (1U << 2) #define FAULT_INTERRUPT_RATE_CAN_2 (1U << 3) #define FAULT_INTERRUPT_RATE_CAN_3 (1U << 4) #define FAULT_INTERRUPT_RATE_TACH (1U << 5) #define FAULT_INTERRUPT_RATE_GMLAN (1U << 6) #define FAULT_INTERRUPT_RATE_INTERRUPTS (1U << 7) #define FAULT_INTERRUPT_RATE_SPI_DMA (1U << 8) #define FAULT_INTERRUPT_RATE_SPI_CS (1U << 9) #define FAULT_INTERRUPT_RATE_UART_1 (1U << 10) #define FAULT_INTERRUPT_RATE_UART_2 (1U << 11) #define FAULT_INTERRUPT_RATE_UART_3 (1U << 12) #define FAULT_INTERRUPT_RATE_UART_5 (1U << 13) #define FAULT_INTERRUPT_RATE_UART_DMA (1U << 14) #define FAULT_INTERRUPT_RATE_USB (1U << 15) #define FAULT_INTERRUPT_RATE_TIM1 (1U << 16) #define FAULT_INTERRUPT_RATE_TIM3 (1U << 17) #define FAULT_REGISTER_DIVERGENT (1U << 18) #define FAULT_INTERRUPT_RATE_KLINE_INIT (1U << 19) #define FAULT_INTERRUPT_RATE_CLOCK_SOURCE (1U << 20) #define FAULT_INTERRUPT_RATE_TICK (1U << 21) // Permanent faults #define PERMANENT_FAULTS 0U uint8_t fault_status = FAULT_STATUS_NONE; uint32_t faults = 0U; void fault_occurred(uint32_t fault) { faults |= fault; if((PERMANENT_FAULTS & fault) != 0U){ puts("Permanent fault occurred: 0x"); puth(fault); puts("\n"); fault_status = FAULT_STATUS_PERMANENT; } else { puts("Temporary fault occurred: 0x"); puth(fault); puts("\n"); fault_status = FAULT_STATUS_TEMPORARY; } } void fault_recovered(uint32_t fault) { if((PERMANENT_FAULTS & fault) == 0U){ faults &= ~fault; } else { puts("Cannot recover from a permanent fault!\n"); } } ================================================ FILE: panda/board/flash.sh ================================================ #!/usr/bin/env sh set -e scons -u PYTHONPATH=.. python3 -c "from python import Panda; Panda().flash('obj/panda.bin.signed')" ================================================ FILE: panda/board/flash_h7.sh ================================================ #!/usr/bin/env sh set -e PANDA_GEN3=1 scons -u PYTHONPATH=.. python3 -c "from python import Panda; Panda().flash('obj/panda_h7.bin.signed')" ================================================ FILE: panda/board/flasher.h ================================================ // flasher state variables uint32_t *prog_ptr = NULL; bool unlocked = false; #ifdef uart_ring void debug_ring_callback(uart_ring *ring) {} #endif int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { int resp_len = 0; // flasher machine memset(resp, 0, 4); memcpy(resp+4, "\xde\xad\xd0\x0d", 4); resp[0] = 0xff; resp[2] = setup->b.bRequest; resp[3] = ~setup->b.bRequest; *((uint32_t **)&resp[8]) = prog_ptr; resp_len = 0xc; int sec; switch (setup->b.bRequest) { // **** 0xb0: flasher echo case 0xb0: resp[1] = 0xff; break; // **** 0xb1: unlock flash case 0xb1: if (flash_is_locked()) { flash_unlock(); resp[1] = 0xff; } current_board->set_led(LED_GREEN, 1); unlocked = true; prog_ptr = (uint32_t *)APP_START_ADDRESS; break; // **** 0xb2: erase sector case 0xb2: sec = setup->b.wValue.w; if (flash_erase_sector(sec, unlocked)) { resp[1] = 0xff; } break; // **** 0xd0: fetch serial number case 0xd0: #ifndef STM32F2 // addresses are OTP if (setup->b.wValue.w == 1) { memcpy(resp, (void *)DEVICE_SERIAL_NUMBER_ADDRESS, 0x10); resp_len = 0x10; } else { get_provision_chunk(resp); resp_len = PROVISION_CHUNK_LEN; } #endif break; // **** 0xd1: enter bootloader mode case 0xd1: // this allows reflashing of the bootstub // so it's blocked over wifi switch (setup->b.wValue.w) { case 0: // TODO: put this back when it's no longer a "devkit" //#ifdef ALLOW_DEBUG #if 1 if (hardwired) { #else // no more bootstub on UNO once OTP block is flashed if (hardwired && ((hw_type != HW_TYPE_UNO) || (!is_provisioned()))) { #endif puts("-> entering bootloader\n"); enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; NVIC_SystemReset(); } break; case 1: puts("-> entering softloader\n"); enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; NVIC_SystemReset(); break; } break; // **** 0xd6: get version case 0xd6: COMPILE_TIME_ASSERT(sizeof(gitversion) <= MAX_RESP_LEN); memcpy(resp, gitversion, sizeof(gitversion)); resp_len = sizeof(gitversion); break; // **** 0xd8: reset ST case 0xd8: flush_write_buffer(); NVIC_SystemReset(); break; } return resp_len; } int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); return 0; } void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); } void usb_cb_ep3_out_complete(void) {} int is_enumerated = 0; void usb_cb_enumeration_complete(void) { puts("USB enumeration complete\n"); is_enumerated = 1; } void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { UNUSED(hardwired); current_board->set_led(LED_RED, 0); for (int i = 0; i < len/4; i++) { flash_write_word(prog_ptr, *(uint32_t*)(usbdata+(i*4))); //*(uint64_t*)(&spi_tx_buf[0x30+(i*4)]) = *prog_ptr; prog_ptr++; } current_board->set_led(LED_RED, 1); } int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out) { UNUSED(len); int resp_len = 0; switch (data[0]) { case 0: // control transfer resp_len = usb_cb_control_msg((USB_Setup_TypeDef *)(data+4), data_out, 0); break; case 2: // ep 2, flash! usb_cb_ep2_out(data+4, data[2], 0); break; } return resp_len; } #ifdef PEDAL #include "stm32fx/llbxcan.h" #define CAN CAN1 #define CAN_BL_INPUT 0x1 #define CAN_BL_OUTPUT 0x2 void CAN1_TX_IRQ_Handler(void) { // clear interrupt CAN->TSR |= CAN_TSR_RQCP0; } #define ISOTP_BUF_SIZE 0x110 uint8_t isotp_buf[ISOTP_BUF_SIZE]; uint8_t *isotp_buf_ptr = NULL; int isotp_buf_remain = 0; uint8_t isotp_buf_out[ISOTP_BUF_SIZE]; uint8_t *isotp_buf_out_ptr = NULL; int isotp_buf_out_remain = 0; int isotp_buf_out_idx = 0; void bl_can_send(uint8_t *odat) { // wait for send while (!(CAN->TSR & CAN_TSR_TME0)); // send continue CAN->sTxMailBox[0].TDLR = ((uint32_t*)odat)[0]; CAN->sTxMailBox[0].TDHR = ((uint32_t*)odat)[1]; CAN->sTxMailBox[0].TDTR = 8; CAN->sTxMailBox[0].TIR = (CAN_BL_OUTPUT << 21) | 1; } void CAN1_RX0_IRQ_Handler(void) { while (CAN->RF0R & CAN_RF0R_FMP0) { if ((CAN->sFIFOMailBox[0].RIR>>21) == CAN_BL_INPUT) { uint8_t dat[8]; for (int i = 0; i < 8; i++) { dat[i] = GET_BYTE(&CAN->sFIFOMailBox[0], i); } uint8_t odat[8]; uint8_t type = dat[0] & 0xF0; if (type == 0x30) { // continue while (isotp_buf_out_remain > 0) { // wait for send while (!(CAN->TSR & CAN_TSR_TME0)); odat[0] = 0x20 | isotp_buf_out_idx; memcpy(odat+1, isotp_buf_out_ptr, 7); isotp_buf_out_remain -= 7; isotp_buf_out_ptr += 7; isotp_buf_out_idx++; bl_can_send(odat); } } else if (type == 0x20) { if (isotp_buf_remain > 0) { memcpy(isotp_buf_ptr, dat+1, 7); isotp_buf_ptr += 7; isotp_buf_remain -= 7; } if (isotp_buf_remain <= 0) { int len = isotp_buf_ptr - isotp_buf + isotp_buf_remain; // call the function memset(isotp_buf_out, 0, ISOTP_BUF_SIZE); isotp_buf_out_remain = spi_cb_rx(isotp_buf, len, isotp_buf_out); isotp_buf_out_ptr = isotp_buf_out; isotp_buf_out_idx = 0; // send initial if (isotp_buf_out_remain <= 7) { odat[0] = isotp_buf_out_remain; memcpy(odat+1, isotp_buf_out_ptr, isotp_buf_out_remain); } else { odat[0] = 0x10 | (isotp_buf_out_remain>>8); odat[1] = isotp_buf_out_remain & 0xFF; memcpy(odat+2, isotp_buf_out_ptr, 6); isotp_buf_out_remain -= 6; isotp_buf_out_ptr += 6; isotp_buf_out_idx++; } bl_can_send(odat); } } else if (type == 0x10) { int len = ((dat[0]&0xF)<<8) | dat[1]; // setup buffer isotp_buf_ptr = isotp_buf; memcpy(isotp_buf_ptr, dat+2, 6); if (len < (ISOTP_BUF_SIZE-0x10)) { isotp_buf_ptr += 6; isotp_buf_remain = len-6; } memset(odat, 0, 8); odat[0] = 0x30; bl_can_send(odat); } } // next CAN->RF0R |= CAN_RF0R_RFOM0; } } void CAN1_SCE_IRQ_Handler(void) { llcan_clear_send(CAN); } #endif void soft_flasher_start(void) { #ifdef PEDAL REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) #endif puts("\n\n\n************************ FLASHER START ************************\n"); enter_bootloader_mode = 0; flasher_peripherals_init(); // pedal has the canloader #ifdef PEDAL RCC->APB1ENR |= RCC_APB1ENR_CAN1EN; // B8,B9: CAN 1 set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); current_board->enable_can_transceiver(1, true); // init can llcan_set_speed(CAN1, 5000, false, false); llcan_init(CAN1); #endif gpio_usart2_init(); gpio_usb_init(); // enable USB usb_init(); // green LED on for flashing current_board->set_led(LED_GREEN, 1); enable_interrupts(); uint64_t cnt = 0; for (cnt=0;;cnt++) { if (cnt == 35 && !is_enumerated && usb_power_mode == USB_POWER_CLIENT) { // if you are connected through a hub to the phone // you need power to be able to see the device puts("USBP: didn't enumerate, switching to CDP mode\n"); current_board->set_usb_power_mode(USB_POWER_CDP); current_board->set_led(LED_BLUE, 1); } // blink the green LED fast current_board->set_led(LED_GREEN, 0); delay(500000); current_board->set_led(LED_GREEN, 1); delay(500000); } } ================================================ FILE: panda/board/get_sdk.sh ================================================ #!/bin/bash sudo apt-get install gcc-arm-none-eabi python-pip sudo pip install libusb1 pycryptodome requests ================================================ FILE: panda/board/get_sdk_mac.sh ================================================ #!/bin/bash # Need formula for gcc sudo easy_install pip /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew tap ArmMbed/homebrew-formulae brew install python dfu-util arm-none-eabi-gcc pip install --user libusb1 pycryptodome requests ================================================ FILE: panda/board/libc.h ================================================ // **** libc **** void delay(uint32_t a) { volatile uint32_t i; for (i = 0; i < a; i++); } void *memset(void *str, int c, unsigned int n) { uint8_t *s = str; for (unsigned int i = 0; i < n; i++) { *s = c; s++; } return str; } void *memcpy(void *dest, const void *src, unsigned int n) { uint8_t *d = dest; const uint8_t *s = src; for (unsigned int i = 0; i < n; i++) { *d = *s; d++; s++; } return dest; } int memcmp(const void * ptr1, const void * ptr2, unsigned int num) { int ret = 0; const uint8_t *p1 = ptr1; const uint8_t *p2 = ptr2; for (unsigned int i = 0; i < num; i++) { if (*p1 != *p2) { ret = -1; break; } p1++; p2++; } return ret; } ================================================ FILE: panda/board/main.c ================================================ // ********************* Includes ********************* #include "config.h" #include "drivers/pwm.h" #include "drivers/usb.h" #include "drivers/gmlan_alt.h" #include "drivers/kline_init.h" #include "early_init.h" #include "provision.h" #include "power_saving.h" #include "safety.h" #include "drivers/can_common.h" #ifdef STM32H7 #include "drivers/fdcan.h" #else #include "drivers/bxcan.h" #endif #include "obj/gitversion.h" extern int _app_start[0xc000]; // Only first 3 sectors of size 0x4000 are used // When changing this struct, boardd and python/__init__.py needs to be kept up to date! struct __attribute__((packed)) health_t { uint32_t uptime_pkt; uint32_t voltage_pkt; uint32_t current_pkt; uint32_t can_rx_errs_pkt; uint32_t can_send_errs_pkt; uint32_t can_fwd_errs_pkt; uint32_t gmlan_send_errs_pkt; uint32_t faults_pkt; uint8_t ignition_line_pkt; uint8_t ignition_can_pkt; uint8_t controls_allowed_pkt; uint8_t gas_interceptor_detected_pkt; uint8_t car_harness_status_pkt; uint8_t usb_power_mode_pkt; uint8_t safety_mode_pkt; int16_t safety_param_pkt; uint8_t fault_status_pkt; uint8_t power_save_enabled_pkt; uint8_t heartbeat_lost_pkt; }; // ********************* Serial debugging ********************* bool check_started(void) { return current_board->check_ignition() || ignition_can; } void debug_ring_callback(uart_ring *ring) { char rcv; while (getc(ring, &rcv)) { (void)putc(ring, rcv); // misra-c2012-17.7: cast to void is ok: debug function // only allow bootloader entry on debug builds #ifdef ALLOW_DEBUG // jump to DFU flash if (rcv == 'z') { enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; NVIC_SystemReset(); } #endif // normal reset if (rcv == 'x') { NVIC_SystemReset(); } // enable CDP mode if (rcv == 'C') { puts("switching USB to CDP mode\n"); current_board->set_usb_power_mode(USB_POWER_CDP); } if (rcv == 'c') { puts("switching USB to client mode\n"); current_board->set_usb_power_mode(USB_POWER_CLIENT); } if (rcv == 'D') { puts("switching USB to DCP mode\n"); current_board->set_usb_power_mode(USB_POWER_DCP); } } } // ****************************** safety mode ****************************** // this is the only way to leave silent mode void set_safety_mode(uint16_t mode, int16_t param) { uint16_t mode_copy = mode; int err = set_safety_hooks(mode_copy, param); if (err == -1) { puts("Error: safety set mode failed. Falling back to SILENT\n"); mode_copy = SAFETY_SILENT; err = set_safety_hooks(mode_copy, 0); if (err == -1) { puts("Error: Failed setting SILENT mode. Hanging\n"); while (true) { // TERMINAL ERROR: we can't continue if SILENT safety mode isn't succesfully set } } } switch (mode_copy) { case SAFETY_SILENT: set_intercept_relay(false); #ifdef vw // Volkswagen community port: // J533 integrations with White/Grey Panda really need Panda to respond // at all times. Let the CAN transceivers ACK traffic unless this is // BP/Uno where the physical relay makes it irrelevant. This makes // SILENT identical to NOOUTPUT for White/Grey Panda. if (current_board->has_obd) { current_board->set_can_mode(CAN_MODE_NORMAL); can_silent = ALL_CAN_SILENT; } else { can_silent = ALL_CAN_LIVE; } #else if (current_board->has_obd) { current_board->set_can_mode(CAN_MODE_NORMAL); } can_silent = ALL_CAN_SILENT; #endif break; case SAFETY_NOOUTPUT: set_intercept_relay(false); if (current_board->has_obd) { current_board->set_can_mode(CAN_MODE_NORMAL); } can_silent = ALL_CAN_LIVE; break; case SAFETY_ELM327: set_intercept_relay(false); heartbeat_counter = 0U; heartbeat_lost = false; if (current_board->has_obd) { if (param == 0) { current_board->set_can_mode(CAN_MODE_OBD_CAN2); } else { current_board->set_can_mode(CAN_MODE_NORMAL); } } can_silent = ALL_CAN_LIVE; break; default: set_intercept_relay(true); heartbeat_counter = 0U; heartbeat_lost = false; if (current_board->has_obd) { current_board->set_can_mode(CAN_MODE_NORMAL); } can_silent = ALL_CAN_LIVE; break; } can_init_all(); } bool is_car_safety_mode(uint16_t mode) { return (mode != SAFETY_SILENT) && (mode != SAFETY_NOOUTPUT) && (mode != SAFETY_ELM327); } // ***************************** USB port ***************************** int get_health_pkt(void *dat) { COMPILE_TIME_ASSERT(sizeof(struct health_t) <= MAX_RESP_LEN); struct health_t * health = (struct health_t*)dat; health->uptime_pkt = uptime_cnt; health->voltage_pkt = adc_get_voltage(); health->current_pkt = current_board->read_current(); //Use the GPIO pin to determine ignition or use a CAN based logic health->ignition_line_pkt = (uint8_t)(current_board->check_ignition()); health->ignition_can_pkt = (uint8_t)(ignition_can); health->controls_allowed_pkt = controls_allowed; health->gas_interceptor_detected_pkt = gas_interceptor_detected; health->can_rx_errs_pkt = can_rx_errs; health->can_send_errs_pkt = can_send_errs; health->can_fwd_errs_pkt = can_fwd_errs; health->gmlan_send_errs_pkt = gmlan_send_errs; health->car_harness_status_pkt = car_harness_status; health->usb_power_mode_pkt = usb_power_mode; health->safety_mode_pkt = (uint8_t)(current_safety_mode); health->safety_param_pkt = current_safety_param; health->power_save_enabled_pkt = (uint8_t)(power_save_status == POWER_SAVE_STATUS_ENABLED); health->heartbeat_lost_pkt = (uint8_t)(heartbeat_lost); health->fault_status_pkt = fault_status; health->faults_pkt = faults; return sizeof(*health); } int get_rtc_pkt(void *dat) { timestamp_t t = rtc_get_time(); (void)memcpy(dat, &t, sizeof(t)); return sizeof(t); } int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { UNUSED(hardwired); CAN_FIFOMailBox_TypeDef *reply = (CAN_FIFOMailBox_TypeDef *)usbdata; int ilen = 0; while (ilen < MIN(len/0x10, 4) && can_pop(&can_rx_q, &reply[ilen])) { ilen++; } return ilen*0x10; } // send on serial, first byte to select the ring void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { UNUSED(hardwired); uint8_t *usbdata8 = (uint8_t *)usbdata; uart_ring *ur = get_ring_by_number(usbdata8[0]); if ((len != 0) && (ur != NULL)) { if ((usbdata8[0] < 2U) || safety_tx_lin_hook(usbdata8[0] - 2U, &usbdata8[1], len - 1)) { for (int i = 1; i < len; i++) { while (!putc(ur, usbdata8[i])) { // wait } } } } } // send on CAN void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { UNUSED(hardwired); int dpkt = 0; uint32_t *d32 = (uint32_t *)usbdata; for (dpkt = 0; dpkt < (len / 4); dpkt += 4) { CAN_FIFOMailBox_TypeDef to_push; to_push.RDHR = d32[dpkt + 3]; to_push.RDLR = d32[dpkt + 2]; to_push.RDTR = d32[dpkt + 1]; to_push.RIR = d32[dpkt]; uint8_t bus_number = (to_push.RDTR >> 4) & CAN_BUS_NUM_MASK; can_send(&to_push, bus_number, false); } } void usb_cb_ep3_out_complete(void) { if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) { usb_outep3_resume_if_paused(); } } void usb_cb_enumeration_complete(void) { puts("USB enumeration complete\n"); is_enumerated = 1; } int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { unsigned int resp_len = 0; uart_ring *ur = NULL; timestamp_t t; switch (setup->b.bRequest) { // **** 0xa0: get rtc time case 0xa0: resp_len = get_rtc_pkt(resp); break; // **** 0xa1: set rtc year case 0xa1: t = rtc_get_time(); t.year = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xa2: set rtc month case 0xa2: t = rtc_get_time(); t.month = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xa3: set rtc day case 0xa3: t = rtc_get_time(); t.day = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xa4: set rtc weekday case 0xa4: t = rtc_get_time(); t.weekday = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xa5: set rtc hour case 0xa5: t = rtc_get_time(); t.hour = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xa6: set rtc minute case 0xa6: t = rtc_get_time(); t.minute = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xa7: set rtc second case 0xa7: t = rtc_get_time(); t.second = setup->b.wValue.w; rtc_set_time(t); break; // **** 0xb0: set IR power case 0xb0: current_board->set_ir_power(setup->b.wValue.w); break; // **** 0xb1: set fan power case 0xb1: current_board->set_fan_power(setup->b.wValue.w); break; // **** 0xb2: get fan rpm case 0xb2: resp[0] = (fan_rpm & 0x00FFU); resp[1] = ((fan_rpm & 0xFF00U) >> 8U); resp_len = 2; break; // **** 0xb3: set phone power case 0xb3: current_board->set_phone_power(setup->b.wValue.w > 0U); break; // **** 0xc0: get CAN debug info case 0xc0: puts("can tx: "); puth(can_tx_cnt); puts(" txd: "); puth(can_txd_cnt); puts(" rx: "); puth(can_rx_cnt); puts(" err: "); puth(can_err_cnt); puts("\n"); break; // **** 0xc1: get hardware type case 0xc1: resp[0] = hw_type; resp_len = 1; break; // **** 0xd0: fetch serial number case 0xd0: // addresses are OTP if (setup->b.wValue.w == 1U) { (void)memcpy(resp, (uint8_t *)DEVICE_SERIAL_NUMBER_ADDRESS, 0x10); resp_len = 0x10; } else { get_provision_chunk(resp); resp_len = PROVISION_CHUNK_LEN; } break; // **** 0xd1: enter bootloader mode case 0xd1: // this allows reflashing of the bootstub // so it's blocked over wifi switch (setup->b.wValue.w) { case 0: // only allow bootloader entry on debug builds #ifdef ALLOW_DEBUG if (hardwired) { puts("-> entering bootloader\n"); enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; NVIC_SystemReset(); } #endif break; case 1: puts("-> entering softloader\n"); enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; NVIC_SystemReset(); break; default: puts("Bootloader mode invalid\n"); break; } break; // **** 0xd2: get health packet case 0xd2: resp_len = get_health_pkt(resp); break; // **** 0xd3: get first 64 bytes of signature case 0xd3: { resp_len = 64; char * code = (char*)_app_start; int code_len = _app_start[0]; (void)memcpy(resp, &code[code_len], resp_len); } break; // **** 0xd4: get second 64 bytes of signature case 0xd4: { resp_len = 64; char * code = (char*)_app_start; int code_len = _app_start[0]; (void)memcpy(resp, &code[code_len + 64], resp_len); } break; // **** 0xd6: get version case 0xd6: COMPILE_TIME_ASSERT(sizeof(gitversion) <= MAX_RESP_LEN); (void)memcpy(resp, gitversion, sizeof(gitversion)); resp_len = sizeof(gitversion) - 1U; break; // **** 0xd8: reset ST case 0xd8: NVIC_SystemReset(); break; // **** 0xd9: set ESP power case 0xd9: if (setup->b.wValue.w == 1U) { current_board->set_gps_mode(GPS_ENABLED); } else if (setup->b.wValue.w == 2U) { current_board->set_gps_mode(GPS_BOOTMODE); } else { current_board->set_gps_mode(GPS_DISABLED); } break; // **** 0xda: reset ESP, with optional boot mode case 0xda: current_board->set_gps_mode(GPS_DISABLED); delay(1000000); if (setup->b.wValue.w == 1U) { current_board->set_gps_mode(GPS_BOOTMODE); } else { current_board->set_gps_mode(GPS_ENABLED); } delay(1000000); current_board->set_gps_mode(GPS_ENABLED); break; // **** 0xdb: set GMLAN (white/grey) or OBD CAN (black) multiplexing mode case 0xdb: if(current_board->has_obd){ if (setup->b.wValue.w == 1U) { // Enable OBD CAN current_board->set_can_mode(CAN_MODE_OBD_CAN2); } else { // Disable OBD CAN current_board->set_can_mode(CAN_MODE_NORMAL); } } else { if (setup->b.wValue.w == 1U) { // GMLAN ON if (setup->b.wIndex.w == 1U) { can_set_gmlan(1); } else if (setup->b.wIndex.w == 2U) { can_set_gmlan(2); } else { puts("Invalid bus num for GMLAN CAN set\n"); } } else { can_set_gmlan(-1); } } break; // **** 0xdc: set safety mode case 0xdc: // Blocked over WiFi. // Allow SILENT, NOOUTPUT and ELM security mode to be set over wifi. if (hardwired || (setup->b.wValue.w == SAFETY_SILENT) || (setup->b.wValue.w == SAFETY_NOOUTPUT) || (setup->b.wValue.w == SAFETY_ELM327)) { set_safety_mode(setup->b.wValue.w, (uint16_t) setup->b.wIndex.w); } break; // **** 0xdd: enable can forwarding case 0xdd: // wValue = Can Bus Num to forward from // wIndex = Can Bus Num to forward to if ((setup->b.wValue.w < BUS_MAX) && (setup->b.wIndex.w < BUS_MAX) && (setup->b.wValue.w != setup->b.wIndex.w)) { // set forwarding can_set_forwarding(setup->b.wValue.w, setup->b.wIndex.w & CAN_BUS_NUM_MASK); } else if((setup->b.wValue.w < BUS_MAX) && (setup->b.wIndex.w == 0xFFU)){ //Clear Forwarding can_set_forwarding(setup->b.wValue.w, -1); } else { puts("Invalid CAN bus forwarding\n"); } break; // **** 0xde: set can bitrate case 0xde: if (setup->b.wValue.w < BUS_MAX) { // TODO: add sanity check, ideally check if value is correct(from array of correct values) can_speed[setup->b.wValue.w] = setup->b.wIndex.w; bool ret = can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w)); UNUSED(ret); } break; // **** 0xdf: set unsafe mode case 0xdf: // you can only set this if you are in a non car safety mode if (!is_car_safety_mode(current_safety_mode)) { unsafe_mode = setup->b.wValue.w; } break; // **** 0xe0: uart read case 0xe0: ur = get_ring_by_number(setup->b.wValue.w); if (!ur) { break; } // TODO: Remove this again and fix boardd code to hande the message bursts instead of single chars if (ur == &uart_ring_gps) { dma_pointer_handler(ur, DMA2_Stream5->NDTR); } // read while ((resp_len < MIN(setup->b.wLength.w, MAX_RESP_LEN)) && getc(ur, (char*)&resp[resp_len])) { ++resp_len; } break; // **** 0xe1: uart set baud rate case 0xe1: ur = get_ring_by_number(setup->b.wValue.w); if (!ur) { break; } uart_set_baud(ur->uart, setup->b.wIndex.w); break; // **** 0xe2: uart set parity case 0xe2: ur = get_ring_by_number(setup->b.wValue.w); if (!ur) { break; } switch (setup->b.wIndex.w) { case 0: // disable parity, 8-bit ur->uart->CR1 &= ~(USART_CR1_PCE | USART_CR1_M); break; case 1: // even parity, 9-bit ur->uart->CR1 &= ~USART_CR1_PS; ur->uart->CR1 |= USART_CR1_PCE | USART_CR1_M; break; case 2: // odd parity, 9-bit ur->uart->CR1 |= USART_CR1_PS; ur->uart->CR1 |= USART_CR1_PCE | USART_CR1_M; break; default: break; } break; // **** 0xe4: uart set baud rate extended case 0xe4: ur = get_ring_by_number(setup->b.wValue.w); if (!ur) { break; } uart_set_baud(ur->uart, (int)setup->b.wIndex.w*300); break; // **** 0xe5: set CAN loopback (for testing) case 0xe5: can_loopback = (setup->b.wValue.w > 0U); can_init_all(); break; // **** 0xe6: set USB power case 0xe6: current_board->set_usb_power_mode(setup->b.wValue.w); break; // **** 0xe7: set power save state case 0xe7: set_power_save_state(setup->b.wValue.w); break; // **** 0xf0: k-line/l-line wake-up pulse for KWP2000 fast initialization case 0xf0: if(current_board->has_lin) { bool k = (setup->b.wValue.w == 0U) || (setup->b.wValue.w == 2U); bool l = (setup->b.wValue.w == 1U) || (setup->b.wValue.w == 2U); if (bitbang_wakeup(k, l)) { resp_len = -1; // do not clear NAK yet (wait for bit banging to finish) } } break; // **** 0xf1: Clear CAN ring buffer. case 0xf1: if (setup->b.wValue.w == 0xFFFFU) { puts("Clearing CAN Rx queue\n"); can_clear(&can_rx_q); } else if (setup->b.wValue.w < BUS_MAX) { puts("Clearing CAN Tx queue\n"); can_clear(can_queues[setup->b.wValue.w]); } else { puts("Clearing CAN CAN ring buffer failed: wrong bus number\n"); } break; // **** 0xf2: Clear UART ring buffer. case 0xf2: { uart_ring * rb = get_ring_by_number(setup->b.wValue.w); if (rb != NULL) { puts("Clearing UART queue.\n"); clear_uart_buff(rb); } break; } // **** 0xf3: Heartbeat. Resets heartbeat counter. case 0xf3: { heartbeat_counter = 0U; heartbeat_lost = false; heartbeat_disabled = false; break; } // **** 0xf4: k-line/l-line 5 baud initialization case 0xf4: if(current_board->has_lin) { bool k = (setup->b.wValue.w == 0U) || (setup->b.wValue.w == 2U); bool l = (setup->b.wValue.w == 1U) || (setup->b.wValue.w == 2U); uint8_t five_baud_addr = (setup->b.wIndex.w & 0xFFU); if (bitbang_five_baud_addr(k, l, five_baud_addr)) { resp_len = -1; // do not clear NAK yet (wait for bit banging to finish) } } break; // **** 0xf5: set clock source mode case 0xf5: current_board->set_clock_source_mode(setup->b.wValue.w); break; // **** 0xf6: set siren enabled case 0xf6: siren_enabled = (setup->b.wValue.w != 0U); break; // **** 0xf7: set green led enabled case 0xf7: green_led_enabled = (setup->b.wValue.w != 0U); break; #ifdef ALLOW_DEBUG // **** 0xf8: disable heartbeat checks case 0xf8: heartbeat_disabled = true; break; #endif // **** 0xde: set CAN FD data bitrate case 0xf9: if (setup->b.wValue.w < CAN_MAX) { // TODO: add sanity check, ideally check if value is correct(from array of correct values) can_data_speed[setup->b.wValue.w] = setup->b.wIndex.w; bool ret = can_init(CAN_NUM_FROM_BUS_NUM(setup->b.wValue.w)); UNUSED(ret); } break; default: puts("NO HANDLER "); puth(setup->b.bRequest); puts("\n"); break; } return resp_len; } // ***************************** main code ***************************** // cppcheck-suppress unusedFunction ; used in headers not included in cppcheck void __initialize_hardware_early(void) { early_initialization(); } void __attribute__ ((noinline)) enable_fpu(void) { // enable the FPU SCB->CPACR |= ((3UL << (10U * 2U)) | (3UL << (11U * 2U))); } // go into SILENT when heartbeat isn't received for this amount of seconds. #define HEARTBEAT_IGNITION_CNT_ON 5U #define HEARTBEAT_IGNITION_CNT_OFF 2U // called at 8Hz uint8_t loop_counter = 0U; void tick_handler(void) { if (TICK_TIMER->SR != 0) { // siren current_board->set_siren((loop_counter & 1U) && (siren_enabled || (siren_countdown > 0U))); // decimated to 1Hz if (loop_counter == 0U) { can_live = pending_can_live; current_board->usb_power_mode_tick(uptime_cnt); //puth(usart1_dma); puts(" "); puth(DMA2_Stream5->M0AR); puts(" "); puth(DMA2_Stream5->NDTR); puts("\n"); // reset this every 16th pass if ((uptime_cnt & 0xFU) == 0U) { pending_can_live = 0; } #ifdef DEBUG puts("** blink "); puth(can_rx_q.r_ptr); puts(" "); puth(can_rx_q.w_ptr); puts(" "); puth(can_tx1_q.r_ptr); puts(" "); puth(can_tx1_q.w_ptr); puts(" "); puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n"); #endif // Tick drivers fan_tick(); // set green LED to be controls allowed current_board->set_led(LED_GREEN, controls_allowed | green_led_enabled); // turn off the blue LED, turned on by CAN // unless we are in power saving mode current_board->set_led(LED_BLUE, (uptime_cnt & 1U) && (power_save_status == POWER_SAVE_STATUS_ENABLED)); // increase heartbeat counter and cap it at the uint32 limit if (heartbeat_counter < __UINT32_MAX__) { heartbeat_counter += 1U; } if (siren_countdown > 0U) { siren_countdown -= 1U; } if (controls_allowed) { controls_allowed_countdown = 30U; } else if (controls_allowed_countdown > 0U) { controls_allowed_countdown -= 1U; } else { } if (!heartbeat_disabled) { // if the heartbeat has been gone for a while, go to SILENT safety mode and enter power save if (heartbeat_counter >= (check_started() ? HEARTBEAT_IGNITION_CNT_ON : HEARTBEAT_IGNITION_CNT_OFF)) { puts("device hasn't sent a heartbeat for 0x"); puth(heartbeat_counter); puts(" seconds. Safety is set to SILENT mode.\n"); if (controls_allowed_countdown > 0U) { siren_countdown = 5U; controls_allowed_countdown = 0U; } // set flag to indicate the heartbeat was lost if (is_car_safety_mode(current_safety_mode)) { heartbeat_lost = true; } if (current_safety_mode != SAFETY_SILENT) { set_safety_mode(SAFETY_SILENT, 0U); } if (power_save_status != POWER_SAVE_STATUS_ENABLED) { set_power_save_state(POWER_SAVE_STATUS_ENABLED); } // Also disable IR when the heartbeat goes missing current_board->set_ir_power(0U); // If enumerated but no heartbeat (phone up, boardd not running), turn the fan on to cool the device if(usb_enumerated()){ current_board->set_fan_power(50U); } else { current_board->set_fan_power(0U); } } // enter CDP mode when car starts to ensure we are charging a turned off EON if (check_started() && (usb_power_mode != USB_POWER_CDP)) { current_board->set_usb_power_mode(USB_POWER_CDP); } } // check registers check_registers(); // set ignition_can to false after 2s of no CAN seen if (ignition_can_cnt > 2U) { ignition_can = false; } // on to the next one uptime_cnt += 1U; safety_mode_cnt += 1U; ignition_can_cnt += 1U; // synchronous safety check safety_tick(current_rx_checks); } loop_counter++; loop_counter %= 8U; } TICK_TIMER->SR = 0; } int main(void) { // Init interrupt table init_interrupts(true); // shouldn't have interrupts here, but just in case disable_interrupts(); // init early devices clock_init(); peripherals_init(); detect_external_debug_serial(); detect_board_type(); adc_init(); // print hello puts("\n\n\n************************ MAIN START ************************\n"); // check for non-supported board types if(hw_type == HW_TYPE_UNKNOWN){ puts("Unsupported board type\n"); while (1) { /* hang */ } } puts("Config:\n"); puts(" Board type: "); puts(current_board->board_type); puts("\n"); puts(has_external_debug_serial ? " Real serial\n" : " USB serial\n"); // init board current_board->init(); // panda has an FPU, let's use it! enable_fpu(); // enable main uart if it's connected if (has_external_debug_serial) { // WEIRDNESS: without this gate around the UART, it would "crash", but only if the ESP is enabled // assuming it's because the lines were left floating and spurious noise was on them uart_init(&uart_ring_debug, 115200); } if (current_board->has_gps) { uart_init(&uart_ring_gps, 9600); } else { // enable ESP uart uart_init(&uart_ring_gps, 115200); } if(current_board->has_lin){ // enable LIN uart_init(&uart_ring_lin1, 10400); UART5->CR2 |= USART_CR2_LINEN; uart_init(&uart_ring_lin2, 10400); USART3->CR2 |= USART_CR2_LINEN; } microsecond_timer_init(); // init to SILENT and can silent set_safety_mode(SAFETY_SILENT, 0); // enable CAN TXs current_board->enable_can_transceivers(true); // 8Hz timer REGISTER_INTERRUPT(TICK_TIMER_IRQ, tick_handler, 10U, FAULT_INTERRUPT_RATE_TICK) tick_timer_init(); #ifdef DEBUG puts("DEBUG ENABLED\n"); #endif // enable USB (right before interrupts or enum can fail!) usb_init(); puts("**** INTERRUPTS ON ****\n"); enable_interrupts(); // LED should keep on blinking all the time uint64_t cnt = 0; for (cnt=0;;cnt++) { if (power_save_status == POWER_SAVE_STATUS_DISABLED) { #ifdef DEBUG_FAULTS if(fault_status == FAULT_STATUS_NONE){ #endif uint32_t div_mode = ((usb_power_mode == USB_POWER_DCP) ? 4U : 1U); // useful for debugging, fade breaks = panda is overloaded for(uint32_t fade = 0U; fade < MAX_LED_FADE; fade += div_mode){ current_board->set_led(LED_RED, true); delay(fade >> 4); current_board->set_led(LED_RED, false); delay((MAX_LED_FADE - fade) >> 4); } for(uint32_t fade = MAX_LED_FADE; fade > 0U; fade -= div_mode){ current_board->set_led(LED_RED, true); delay(fade >> 4); current_board->set_led(LED_RED, false); delay((MAX_LED_FADE - fade) >> 4); } #ifdef DEBUG_FAULTS } else { current_board->set_led(LED_RED, 1); delay(512000U); current_board->set_led(LED_RED, 0); delay(512000U); } #endif } else { __WFI(); } } return 0; } ================================================ FILE: panda/board/main_declarations.h ================================================ // ******************** Prototypes ******************** void puts(const char *a); void puth(unsigned int i); void puth2(unsigned int i); typedef struct board board; typedef struct harness_configuration harness_configuration; void can_flip_buses(uint8_t bus1, uint8_t bus2); void pwm_init(TIM_TypeDef *TIM, uint8_t channel); void pwm_set(TIM_TypeDef *TIM, uint8_t channel, uint8_t percentage); // ********************* Globals ********************** uint8_t hw_type = 0; const board *current_board; bool is_enumerated = 0; uint32_t uptime_cnt = 0; bool green_led_enabled = false; // heartbeat state uint32_t heartbeat_counter = 0; bool heartbeat_lost = false; bool heartbeat_disabled = false; // set over USB // siren state bool siren_enabled = false; uint32_t siren_countdown = 0; // siren plays while countdown > 0 uint32_t controls_allowed_countdown = 0; ================================================ FILE: panda/board/obj/.placeholder ================================================ ================================================ FILE: panda/board/pedal/.gitignore ================================================ obj/* ================================================ FILE: panda/board/pedal/README ================================================ This is the firmware for the comma pedal. It borrows a lot from panda. The comma pedal is a gas pedal interceptor for Honda/Acura. It allows you to "virtually" press the pedal. This is the open source software. Note that it is not ready to use yet. == Test Plan == * Startup ** Confirm STATE_FAULT_STARTUP * Timeout ** Send value ** Confirm value is output ** Stop sending messages ** Confirm value is passthru after 100ms ** Confirm STATE_FAULT_TIMEOUT * Random values ** Send random 6 byte messages ** Confirm random values cause passthru ** Confirm STATE_FAULT_BAD_CHECKSUM * Same message lockout ** Send same message repeated ** Confirm timeout behavior * Don't set enable ** Confirm no output * Set enable and values ** Confirm output ================================================ FILE: panda/board/pedal/flash_can.sh ================================================ #!/usr/bin/env sh set -e cd .. PEDAL=1 scons -u cd pedal ../../tests/pedal/enter_canloader.py ../obj/pedal.bin.signed ================================================ FILE: panda/board/pedal/main.c ================================================ // ********************* Includes ********************* //#define PEDAL_USB #include "../config.h" #include "early_init.h" #include "crc.h" #define CAN CAN1 #ifdef PEDAL_USB #include "drivers/usb.h" #else // no serial either void puts(const char *a) { UNUSED(a); } void puth(unsigned int i) { UNUSED(i); } void puth2(unsigned int i) { UNUSED(i); } #endif #define ENTER_BOOTLOADER_MAGIC 0xdeadbeefU uint32_t enter_bootloader_mode; // cppcheck-suppress unusedFunction ; used in headers not included in cppcheck void __initialize_hardware_early(void) { early_initialization(); } // ********************* serial debugging ********************* #ifdef PEDAL_USB void debug_ring_callback(uart_ring *ring) { char rcv; while (getc(ring, &rcv) != 0) { (void)putc(ring, rcv); } } int usb_cb_ep1_in(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); return 0; } void usb_cb_ep2_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); } void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) { UNUSED(usbdata); UNUSED(len); UNUSED(hardwired); } void usb_cb_ep3_out_complete(void) {} void usb_cb_enumeration_complete(void) {} int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired) { UNUSED(hardwired); unsigned int resp_len = 0; uart_ring *ur = NULL; switch (setup->b.bRequest) { // **** 0xc1: get hardware type case 0xc1: resp[0] = hw_type; resp_len = 1; break; // **** 0xe0: uart read case 0xe0: ur = get_ring_by_number(setup->b.wValue.w); if (!ur) { break; } // read while ((resp_len < MIN(setup->b.wLength.w, MAX_RESP_LEN)) && getc(ur, (char*)&resp[resp_len])) { ++resp_len; } break; default: puts("NO HANDLER "); puth(setup->b.bRequest); puts("\n"); break; } return resp_len; } #endif // ***************************** can port ***************************** // addresses to be used on CAN #define CAN_GAS_INPUT 0x200 #define CAN_GAS_OUTPUT 0x201U #define CAN_GAS_SIZE 6 #define COUNTER_CYCLE 0xFU void CAN1_TX_IRQ_Handler(void) { // clear interrupt CAN->TSR |= CAN_TSR_RQCP0; } // two independent values uint16_t gas_set_0 = 0; uint16_t gas_set_1 = 0; #define MAX_TIMEOUT 10U uint32_t timeout = 0; uint32_t current_index = 0; #define NO_FAULT 0U #define FAULT_BAD_CHECKSUM 1U #define FAULT_SEND 2U #define FAULT_SCE 3U #define FAULT_STARTUP 4U #define FAULT_TIMEOUT 5U #define FAULT_INVALID 6U uint8_t state = FAULT_STARTUP; const uint8_t crc_poly = 0xD5U; // standard crc8 void CAN1_RX0_IRQ_Handler(void) { while ((CAN->RF0R & CAN_RF0R_FMP0) != 0) { #ifdef DEBUG puts("CAN RX\n"); #endif int address = CAN->sFIFOMailBox[0].RIR >> 21; if (address == CAN_GAS_INPUT) { // softloader entry if (GET_BYTES_04(&CAN->sFIFOMailBox[0]) == 0xdeadface) { if (GET_BYTES_48(&CAN->sFIFOMailBox[0]) == 0x0ab00b1e) { enter_bootloader_mode = ENTER_SOFTLOADER_MAGIC; NVIC_SystemReset(); } else if (GET_BYTES_48(&CAN->sFIFOMailBox[0]) == 0x02b00b1e) { enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC; NVIC_SystemReset(); } else { puts("Failed entering Softloader or Bootloader\n"); } } // normal packet uint8_t dat[8]; for (int i=0; i<8; i++) { dat[i] = GET_BYTE(&CAN->sFIFOMailBox[0], i); } uint16_t value_0 = (dat[0] << 8) | dat[1]; uint16_t value_1 = (dat[2] << 8) | dat[3]; bool enable = ((dat[4] >> 7) & 1U) != 0U; uint8_t index = dat[4] & COUNTER_CYCLE; if (crc_checksum(dat, CAN_GAS_SIZE - 1, crc_poly) == dat[5]) { if (((current_index + 1U) & COUNTER_CYCLE) == index) { #ifdef DEBUG puts("setting gas "); puth(value_0); puts("\n"); #endif if (enable) { gas_set_0 = value_0; gas_set_1 = value_1; } else { // clear the fault state if values are 0 if ((value_0 == 0U) && (value_1 == 0U)) { state = NO_FAULT; } else { state = FAULT_INVALID; } gas_set_0 = 0; gas_set_1 = 0; } // clear the timeout timeout = 0; } current_index = index; } else { // wrong checksum = fault state = FAULT_BAD_CHECKSUM; } } // next CAN->RF0R |= CAN_RF0R_RFOM0; } } void CAN1_SCE_IRQ_Handler(void) { state = FAULT_SCE; llcan_clear_send(CAN); } uint32_t pdl0 = 0; uint32_t pdl1 = 0; unsigned int pkt_idx = 0; int led_value = 0; void TIM3_IRQ_Handler(void) { #ifdef DEBUG puth(TIM3->CNT); puts(" "); puth(pdl0); puts(" "); puth(pdl1); puts("\n"); #endif // check timer for sending the user pedal and clearing the CAN if ((CAN->TSR & CAN_TSR_TME0) == CAN_TSR_TME0) { uint8_t dat[8]; dat[0] = (pdl0 >> 8) & 0xFFU; dat[1] = (pdl0 >> 0) & 0xFFU; dat[2] = (pdl1 >> 8) & 0xFFU; dat[3] = (pdl1 >> 0) & 0xFFU; dat[4] = ((state & 0xFU) << 4) | pkt_idx; dat[5] = crc_checksum(dat, CAN_GAS_SIZE - 1, crc_poly); CAN->sTxMailBox[0].TDLR = dat[0] | (dat[1] << 8) | (dat[2] << 16) | (dat[3] << 24); CAN->sTxMailBox[0].TDHR = dat[4] | (dat[5] << 8); CAN->sTxMailBox[0].TDTR = 6; // len of packet is 5 CAN->sTxMailBox[0].TIR = (CAN_GAS_OUTPUT << 21) | 1U; ++pkt_idx; pkt_idx &= COUNTER_CYCLE; } else { // old can packet hasn't sent! state = FAULT_SEND; #ifdef DEBUG puts("CAN MISS\n"); #endif } // blink the LED current_board->set_led(LED_GREEN, led_value); led_value = !led_value; TIM3->SR = 0; // up timeout for gas set if (timeout == MAX_TIMEOUT) { state = FAULT_TIMEOUT; } else { timeout += 1U; } } // ***************************** main code ***************************** void pedal(void) { // read/write pdl0 = adc_get(ADCCHAN_ACCEL0); pdl1 = adc_get(ADCCHAN_ACCEL1); // write the pedal to the DAC if (state == NO_FAULT) { dac_set(0, MAX(gas_set_0, pdl0)); dac_set(1, MAX(gas_set_1, pdl1)); } else { dac_set(0, pdl0); dac_set(1, pdl1); } watchdog_feed(); } int main(void) { // Init interrupt table init_interrupts(true); REGISTER_INTERRUPT(CAN1_TX_IRQn, CAN1_TX_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN1_RX0_IRQn, CAN1_RX0_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) REGISTER_INTERRUPT(CAN1_SCE_IRQn, CAN1_SCE_IRQ_Handler, CAN_INTERRUPT_RATE, FAULT_INTERRUPT_RATE_CAN_1) // Should run at around 732Hz (see init below) REGISTER_INTERRUPT(TIM3_IRQn, TIM3_IRQ_Handler, 1000U, FAULT_INTERRUPT_RATE_TIM3) disable_interrupts(); // init devices clock_init(); peripherals_init(); detect_external_debug_serial(); detect_board_type(); // init board current_board->init(); #ifdef PEDAL_USB // enable USB usb_init(); #endif // pedal stuff dac_init(); adc_init(); // init can bool llcan_speed_set = llcan_set_speed(CAN1, 5000, false, false); if (!llcan_speed_set) { puts("Failed to set llcan speed"); } bool ret = llcan_init(CAN1); UNUSED(ret); // 48mhz / 65536 ~= 732 timer_init(TIM3, 15); NVIC_EnableIRQ(TIM3_IRQn); watchdog_init(); puts("**** INTERRUPTS ON ****\n"); enable_interrupts(); // main pedal loop while (1) { pedal(); } return 0; } ================================================ FILE: panda/board/pedal/main_declarations.h ================================================ // ******************** Prototypes ******************** void puts(const char *a); void puth(unsigned int i); void puth2(unsigned int i); typedef struct board board; typedef struct harness_configuration harness_configuration; // ********************* Globals ********************** uint8_t hw_type = 0; const board *current_board; bool is_enumerated = 0; ================================================ FILE: panda/board/pedal/recover.sh ================================================ #!/usr/bin/env sh set -e DFU_UTIL="dfu-util" cd .. PEDAL=1 scons -u cd pedal $DFU_UTIL -d 0483:df11 -a 0 -s 0x08004000 -D ../obj/pedal.bin.signed $DFU_UTIL -d 0483:df11 -a 0 -s 0x08000000:leave -D ../obj/bootstub.pedal.bin ================================================ FILE: panda/board/power_saving.h ================================================ // WARNING: To stay in compliance with the SIL2 rules laid out in STM UM1840, we should never implement any of the available hardware low power modes. // See rule: CoU_3 #define POWER_SAVE_STATUS_DISABLED 0 #define POWER_SAVE_STATUS_ENABLED 1 int power_save_status = POWER_SAVE_STATUS_DISABLED; void set_power_save_state(int state) { bool is_valid_state = (state == POWER_SAVE_STATUS_ENABLED) || (state == POWER_SAVE_STATUS_DISABLED); if (is_valid_state && (state != power_save_status)) { bool enable = false; if (state == POWER_SAVE_STATUS_ENABLED) { puts("enable power savings\n"); if (current_board->has_gps) { const char UBLOX_SLEEP_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78"; uart_ring *ur = get_ring_by_number(1); for (unsigned int i = 0; i < sizeof(UBLOX_SLEEP_MSG) - 1U; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i])); } } else { puts("disable power savings\n"); if (current_board->has_gps) { const char UBLOX_WAKE_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a"; uart_ring *ur = get_ring_by_number(1); for (unsigned int i = 0; i < sizeof(UBLOX_WAKE_MSG) - 1U; i++) while (!putc(ur, UBLOX_WAKE_MSG[i])); } enable = true; } #ifdef vw // Volkswagen community port: // If this is a White or Grey Panda, always keep the CAN transceivers // powered up so that transparent forwarding is maintained. current_board->enable_can_transceivers(current_board->has_obd ? enable : true); #else current_board->enable_can_transceivers(enable); #endif // Switch EPS/GPS if (enable) { current_board->set_gps_mode(GPS_ENABLED); } else { current_board->set_gps_mode(GPS_DISABLED); } if(current_board->has_hw_gmlan){ // turn on GMLAN set_gpio_output(GPIOB, 14, enable); set_gpio_output(GPIOB, 15, enable); } if(current_board->has_lin){ // turn on LIN set_gpio_output(GPIOB, 7, enable); set_gpio_output(GPIOA, 14, enable); } // Switch off IR when in power saving if(!enable){ current_board->set_ir_power(0U); } power_save_status = state; } } ================================================ FILE: panda/board/provision.h ================================================ #define PROVISION_CHUNK_LEN 0x20 // WiFi SSID = 0x0 - 0x10 // WiFi password = 0x10 - 0x1C // SHA1 checksum = 0x1C - 0x20 void get_provision_chunk(uint8_t *resp) { (void)memcpy(resp, (uint8_t *)PROVISION_CHUNK_ADDRESS, PROVISION_CHUNK_LEN); if (memcmp(resp, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 0x20) == 0) { (void)memcpy(resp, "unprovisioned\x00\x00\x00testing123\x00\x00\xa3\xa6\x99\xec", 0x20); } } uint8_t chunk[PROVISION_CHUNK_LEN]; bool is_provisioned(void) { (void)memcpy(chunk, (uint8_t *)PROVISION_CHUNK_ADDRESS, PROVISION_CHUNK_LEN); return (memcmp(chunk, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 0x20) != 0); } ================================================ FILE: panda/board/recover.sh ================================================ #!/usr/bin/env sh set -e DFU_UTIL="dfu-util" scons -u PYTHONPATH=.. python3 -c "from python import Panda; Panda().reset(enter_bootstub=True); Panda().reset(enter_bootloader=True)" || true sleep 1 $DFU_UTIL -d 0483:df11 -a 0 -s 0x08004000 -D obj/panda.bin.signed $DFU_UTIL -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.panda.bin ================================================ FILE: panda/board/recover_h7.sh ================================================ #!/usr/bin/env sh set -e DFU_UTIL="dfu-util" PANDA_H7=1 scons -u PYTHONPATH=.. python3 -c "from python import Panda; Panda().reset(enter_bootstub=True); Panda().reset(enter_bootloader=True)" || true sleep 1 $DFU_UTIL -d 0483:df11 -a 0 -s 0x08020000 -D obj/panda_h7.bin.signed $DFU_UTIL -d 0483:df11 -a 0 -s 0x08000000:leave -D obj/bootstub.panda_h7.bin ================================================ FILE: panda/board/safety/safety_chrysler.h ================================================ const int CHRYSLER_MAX_STEER = 261; const int CHRYSLER_MAX_RT_DELTA = 112; // max delta torque allowed for real time checks const uint32_t CHRYSLER_RT_INTERVAL = 250000; // 250ms between real time checks const int CHRYSLER_MAX_RATE_UP = 3; const int CHRYSLER_MAX_RATE_DOWN = 3; const int CHRYSLER_MAX_TORQUE_ERROR = 80; // max torque cmd in excess of torque motor const int CHRYSLER_GAS_THRSLD = 30; // 7% more than 2m/s const int CHRYSLER_STANDSTILL_THRSLD = 10; // about 1m/s const CanMsg CHRYSLER_TX_MSGS[] = {{571, 0, 3}, {658, 0, 6}, {678, 0, 8}}; AddrCheckStruct chrysler_addr_checks[] = { {.msg = {{544, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{514, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{500, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{308, 0, 8, .check_checksum = false, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{320, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, }; #define CHRYSLER_ADDR_CHECK_LEN (sizeof(chrysler_addr_checks) / sizeof(chrysler_addr_checks[0])) addr_checks chrysler_rx_checks = {chrysler_addr_checks, CHRYSLER_ADDR_CHECK_LEN}; static uint8_t chrysler_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int checksum_byte = GET_LEN(to_push) - 1; return (uint8_t)(GET_BYTE(to_push, checksum_byte)); } static uint8_t chrysler_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { /* This function does not want the checksum byte in the input data. jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf */ uint8_t checksum = 0xFFU; int len = GET_LEN(to_push); for (int j = 0; j < (len - 1); j++) { uint8_t shift = 0x80U; uint8_t curr = (uint8_t)GET_BYTE(to_push, j); for (int i=0; i<8; i++) { uint8_t bit_sum = curr & shift; uint8_t temp_chk = checksum & 0x80U; if (bit_sum != 0U) { bit_sum = 0x1C; if (temp_chk != 0U) { bit_sum = 1; } checksum = checksum << 1; temp_chk = checksum | 1U; bit_sum ^= temp_chk; } else { if (temp_chk != 0U) { bit_sum = 0x1D; } checksum = checksum << 1; bit_sum ^= checksum; } checksum = bit_sum; shift = shift >> 1; } } return ~checksum; } static uint8_t chrysler_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { // Well defined counter only for 8 bytes messages return (uint8_t)(GET_BYTE(to_push, 6) >> 4); } static int chrysler_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &chrysler_rx_checks, chrysler_get_checksum, chrysler_compute_checksum, chrysler_get_counter); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); // Measured eps torque if (addr == 544) { int torque_meas_new = ((GET_BYTE(to_push, 4) & 0x7U) << 8) + GET_BYTE(to_push, 5) - 1024U; // update array of samples update_sample(&torque_meas, torque_meas_new); } // enter controls on rising edge of ACC, exit controls on ACC off if (addr == 500) { int cruise_engaged = ((GET_BYTE(to_push, 2) & 0x38) >> 3) == 7; if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } // update speed if (addr == 514) { int speed_l = (GET_BYTE(to_push, 0) << 4) + (GET_BYTE(to_push, 1) >> 4); int speed_r = (GET_BYTE(to_push, 2) << 4) + (GET_BYTE(to_push, 3) >> 4); vehicle_speed = (speed_l + speed_r) / 2; vehicle_moving = (int)vehicle_speed > CHRYSLER_STANDSTILL_THRSLD; } // exit controls on rising edge of gas press if (addr == 308) { gas_pressed = ((GET_BYTE(to_push, 5) & 0x7F) != 0) && ((int)vehicle_speed > CHRYSLER_GAS_THRSLD); } // exit controls on rising edge of brake press if (addr == 320) { brake_pressed = (GET_BYTE(to_push, 0) & 0x7) == 5; if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) { controls_allowed = 0; } brake_pressed_prev = brake_pressed; } generic_rx_checks((addr == 0x292)); } return valid; } static int chrysler_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); if (!msg_allowed(to_send, CHRYSLER_TX_MSGS, sizeof(CHRYSLER_TX_MSGS) / sizeof(CHRYSLER_TX_MSGS[0]))) { tx = 0; } if (relay_malfunction) { tx = 0; } // LKA STEER if (addr == 0x292) { int desired_torque = ((GET_BYTE(to_send, 0) & 0x7U) << 8) + GET_BYTE(to_send, 1) - 1024U; uint32_t ts = microsecond_timer_get(); bool violation = 0; if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, CHRYSLER_MAX_STEER, -CHRYSLER_MAX_STEER); // *** torque rate limit check *** violation |= dist_to_meas_check(desired_torque, desired_torque_last, &torque_meas, CHRYSLER_MAX_RATE_UP, CHRYSLER_MAX_RATE_DOWN, CHRYSLER_MAX_TORQUE_ERROR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, CHRYSLER_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > CHRYSLER_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } // FORCE CANCEL: only the cancel button press is allowed if (addr == 571) { if ((GET_BYTE(to_send, 0) != 1) || ((GET_BYTE(to_send, 1) & 1) == 1)) { tx = 0; } } return tx; } static int chrysler_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; int addr = GET_ADDR(to_fwd); if (!relay_malfunction) { // forward CAN 0 -> 2 so stock LKAS camera sees messages if (bus_num == 0) { bus_fwd = 2; } // forward all messages from camera except LKAS_COMMAND and LKAS_HUD if ((bus_num == 2) && (addr != 658) && (addr != 678)) { bus_fwd = 0; } } return bus_fwd; } static const addr_checks* chrysler_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); return &chrysler_rx_checks; } const safety_hooks chrysler_hooks = { .init = chrysler_init, .rx = chrysler_rx_hook, .tx = chrysler_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = chrysler_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_defaults.h ================================================ const addr_checks default_rx_checks = { .check = NULL, .len = 0, }; int default_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { UNUSED(to_push); return true; } // *** no output safety mode *** static const addr_checks* nooutput_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); return &default_rx_checks; } static int nooutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { UNUSED(to_send); return false; } static int nooutput_tx_lin_hook(int lin_num, uint8_t *data, int len) { UNUSED(lin_num); UNUSED(data); UNUSED(len); return false; } static int default_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { UNUSED(to_fwd); #ifdef vw // Volkswagen community port: Advanced Virtual Relay Technology! // Make Panda fully transparent from bus 0->2 and bus 2->0 if not otherwise // instructed by EON/OP, returning the car to stock behavior under NOOUTPUT. // Don't do this for BP/C2, where we have Advanced Actual Relay Technology. int bus_fwd = -1; if(hw_type == HW_TYPE_WHITE_PANDA || hw_type == HW_TYPE_GREY_PANDA) { switch (bus_num) { case 0: bus_fwd = 2; break; case 2: bus_fwd = 0; break; default: bus_fwd = -1; break; } } return bus_fwd; #else UNUSED(bus_num); return -1; #endif } const safety_hooks nooutput_hooks = { .init = nooutput_init, .rx = default_rx_hook, .tx = nooutput_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = default_fwd_hook, }; // *** all output safety mode *** static const addr_checks* alloutput_init(int16_t param) { UNUSED(param); controls_allowed = true; relay_malfunction_reset(); return &default_rx_checks; } static int alloutput_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { UNUSED(to_send); return true; } static int alloutput_tx_lin_hook(int lin_num, uint8_t *data, int len) { UNUSED(lin_num); UNUSED(data); UNUSED(len); return true; } const safety_hooks alloutput_hooks = { .init = alloutput_init, .rx = default_rx_hook, .tx = alloutput_tx_hook, .tx_lin = alloutput_tx_lin_hook, .fwd = default_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_elm327.h ================================================ static int elm327_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); int len = GET_LEN(to_send); //All ISO 15765-4 messages must be 8 bytes long if (len != 8) { tx = 0; } //Check valid 29 bit send addresses for ISO 15765-4 //Check valid 11 bit send addresses for ISO 15765-4 if ((addr != 0x18DB33F1) && ((addr & 0x1FFF00FF) != 0x18DA00F1) && ((addr & 0x1FFFFF00) != 0x700)) { tx = 0; } return tx; } static int elm327_tx_lin_hook(int lin_num, uint8_t *data, int len) { int tx = 1; if (lin_num != 0) { tx = 0; //Only operate on LIN 0, aka serial 2 } if ((len < 5) || (len > 11)) { tx = 0; //Valid KWP size } if (!(((data[0] & 0xF8U) == 0xC0U) && ((data[0] & 0x07U) != 0U) && (data[1] == 0x33U) && (data[2] == 0xF1U))) { tx = 0; //Bad msg } return tx; } // If current_board->has_obd and safety_param == 0, bus 1 is multiplexed to the OBD-II port const safety_hooks elm327_hooks = { .init = nooutput_init, .rx = default_rx_hook, .tx = elm327_tx_hook, .tx_lin = elm327_tx_lin_hook, .fwd = default_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_ford.h ================================================ // board enforces // in-state // accel set/resume // out-state // cancel button // accel rising edge // brake rising edge // brake > 0mph static int ford_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); int bus = GET_BUS(to_push); bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; if (addr == 0x217) { // wheel speeds are 14 bits every 16 vehicle_moving = false; for (int i = 0; i < 8; i += 2) { vehicle_moving |= GET_BYTE(to_push, i) | (GET_BYTE(to_push, (int)(i + 1)) & 0xFCU); } } // state machine to enter and exit controls if (addr == 0x83) { bool cancel = GET_BYTE(to_push, 1) & 0x1; bool set_or_resume = GET_BYTE(to_push, 3) & 0x30; if (cancel) { controls_allowed = 0; } if (set_or_resume) { controls_allowed = 1; } } // exit controls on rising edge of brake press or on brake press when // speed > 0 if (addr == 0x165) { brake_pressed = GET_BYTE(to_push, 0) & 0x20; if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) { controls_allowed = 0; } brake_pressed_prev = brake_pressed; } // exit controls on rising edge of gas press if (addr == 0x204) { gas_pressed = ((GET_BYTE(to_push, 0) & 0x03) | GET_BYTE(to_push, 1)) != 0; if (!unsafe_allow_gas && gas_pressed && !gas_pressed_prev) { controls_allowed = 0; } gas_pressed_prev = gas_pressed; } if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && (bus == 0) && (addr == 0x3CA)) { relay_malfunction_set(); } return 1; } // all commands: just steering // if controls_allowed and no pedals pressed // allow all commands up to limit // else // block all commands that produce actuation static int ford_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True int pedal_pressed = brake_pressed_prev && vehicle_moving; bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; if (!unsafe_allow_gas) { pedal_pressed = pedal_pressed || gas_pressed_prev; } bool current_controls_allowed = controls_allowed && !(pedal_pressed); if (relay_malfunction) { tx = 0; } // STEER: safety check if (addr == 0x3CA) { if (!current_controls_allowed) { // bits 7-4 need to be 0xF to disallow lkas commands if ((GET_BYTE(to_send, 0) & 0xF0) != 0xF0) { tx = 0; } } } // FORCE CANCEL: safety check only relevant when spamming the cancel button // ensuring that set and resume aren't sent if (addr == 0x83) { if ((GET_BYTE(to_send, 3) & 0x30) != 0) { tx = 0; } } // 1 allows the message through return tx; } // TODO: keep camera on bus 2 and make a fwd_hook const safety_hooks ford_hooks = { .init = nooutput_init, .rx = ford_rx_hook, .tx = ford_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = default_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_gm.h ================================================ // board enforces // in-state // accel set/resume // out-state // cancel button // regen paddle // accel rising edge // brake rising edge // brake > 0mph const int GM_MAX_STEER = 300; const int GM_MAX_RT_DELTA = 128; // max delta torque allowed for real time checks const uint32_t GM_RT_INTERVAL = 250000; // 250ms between real time checks const int GM_MAX_RATE_UP = 7; const int GM_MAX_RATE_DOWN = 17; const int GM_DRIVER_TORQUE_ALLOWANCE = 50; const int GM_DRIVER_TORQUE_FACTOR = 4; const int GM_MAX_GAS = 3072; const int GM_MAX_REGEN = 1404; const int GM_MAX_BRAKE = 350; const CanMsg GM_TX_MSGS[] = {{384, 0, 4}, {1033, 0, 7}, {1034, 0, 7}, {715, 0, 8}, {880, 0, 6}, // pt bus {161, 1, 7}, {774, 1, 8}, {776, 1, 7}, {784, 1, 2}, // obs bus {789, 2, 5}, // ch bus {0x104c006c, 3, 3}, {0x10400060, 3, 5}}; // gmlan // TODO: do checksum and counter checks. Add correct timestep, 0.1s for now. AddrCheckStruct gm_addr_checks[] = { {.msg = {{388, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, {.msg = {{842, 0, 5, .expected_timestep = 100000U}, { 0 }, { 0 }}}, {.msg = {{481, 0, 7, .expected_timestep = 100000U}, { 0 }, { 0 }}}, {.msg = {{241, 0, 6, .expected_timestep = 100000U}, { 0 }, { 0 }}}, {.msg = {{417, 0, 7, .expected_timestep = 100000U}, { 0 }, { 0 }}}, }; #define GM_RX_CHECK_LEN (sizeof(gm_addr_checks) / sizeof(gm_addr_checks[0])) addr_checks gm_rx_checks = {gm_addr_checks, GM_RX_CHECK_LEN}; static int gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &gm_rx_checks, NULL, NULL, NULL); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); if (addr == 388) { int torque_driver_new = ((GET_BYTE(to_push, 6) & 0x7) << 8) | GET_BYTE(to_push, 7); torque_driver_new = to_signed(torque_driver_new, 11); // update array of samples update_sample(&torque_driver, torque_driver_new); } // sample speed, really only care if car is moving or not // rear left wheel speed if (addr == 842) { vehicle_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); } // ACC steering wheel buttons if (addr == 481) { int button = (GET_BYTE(to_push, 5) & 0x70) >> 4; switch (button) { case 2: // resume case 3: // set controls_allowed = 1; break; case 6: // cancel controls_allowed = 0; break; default: break; // any other button is irrelevant } } // speed > 0 if (addr == 241) { // Brake pedal's potentiometer returns near-zero reading // even when pedal is not pressed brake_pressed = GET_BYTE(to_push, 1) >= 10; } if (addr == 417) { gas_pressed = GET_BYTE(to_push, 6) != 0; } // exit controls on regen paddle if (addr == 189) { bool regen = GET_BYTE(to_push, 0) & 0x20; if (regen) { controls_allowed = 0; } } // Check if ASCM or LKA camera are online // on powertrain bus. // 384 = ASCMLKASteeringCmd // 715 = ASCMGasRegenCmd generic_rx_checks(((addr == 384) || (addr == 715))); } return valid; } // all commands: gas/regen, friction brake and steering // if controls_allowed and no pedals pressed // allow all commands up to limit // else // block all commands that produce actuation static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); if (!msg_allowed(to_send, GM_TX_MSGS, sizeof(GM_TX_MSGS)/sizeof(GM_TX_MSGS[0]))) { tx = 0; } if (relay_malfunction) { tx = 0; } // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True int pedal_pressed = brake_pressed_prev && vehicle_moving; bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; if (!unsafe_allow_gas) { pedal_pressed = pedal_pressed || gas_pressed_prev; } bool current_controls_allowed = controls_allowed && !pedal_pressed; // BRAKE: safety check if (addr == 789) { int brake = ((GET_BYTE(to_send, 0) & 0xFU) << 8) + GET_BYTE(to_send, 1); brake = (0x1000 - brake) & 0xFFF; if (!current_controls_allowed) { if (brake != 0) { tx = 0; } } if (brake > GM_MAX_BRAKE) { tx = 0; } } // LKA STEER: safety check if (addr == 384) { int desired_torque = ((GET_BYTE(to_send, 0) & 0x7U) << 8) + GET_BYTE(to_send, 1); uint32_t ts = microsecond_timer_get(); bool violation = 0; desired_torque = to_signed(desired_torque, 11); if (current_controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, GM_MAX_STEER, -GM_MAX_STEER); // *** torque rate limit check *** violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, GM_MAX_STEER, GM_MAX_RATE_UP, GM_MAX_RATE_DOWN, GM_DRIVER_TORQUE_ALLOWANCE, GM_DRIVER_TORQUE_FACTOR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, GM_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > GM_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!current_controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !current_controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } // GAS/REGEN: safety check if (addr == 715) { int gas_regen = ((GET_BYTE(to_send, 2) & 0x7FU) << 5) + ((GET_BYTE(to_send, 3) & 0xF8U) >> 3); // Disabled message is !engaged with gas // value that corresponds to max regen. if (!current_controls_allowed) { bool apply = GET_BYTE(to_send, 0) & 1U; if (apply || (gas_regen != GM_MAX_REGEN)) { tx = 0; } } if (gas_regen > GM_MAX_GAS) { tx = 0; } } // 1 allows the message through return tx; } static const addr_checks* gm_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); return &gm_rx_checks; } const safety_hooks gm_hooks = { .init = gm_init, .rx = gm_rx_hook, .tx = gm_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = default_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_gm_ascm.h ================================================ // BUS 0 is on the LKAS module (ASCM) side // BUS 2 is on the actuator (EPS) side static int gm_ascm_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; if (bus_num == 0) { int addr = GET_ADDR(to_fwd); bus_fwd = 2; // do not propagate lkas messages from ascm to actuators, unless supercruise is on // block 0x152 and 0x154, which are the lkas command from ASCM1 and ASCM2 // block 0x315 and 0x2cb, which are the brake and accel commands from ASCM1 //if ((addr == 0x152) || (addr == 0x154) || (addr == 0x315) || (addr == 0x2cb)) { if ((addr == 0x152) || (addr == 0x154)) { bool supercruise_on = (GET_BYTE(to_fwd, 4) & 0x10) != 0; // bit 36 if (!supercruise_on) { bus_fwd = -1; } } if ((addr == 0x151) || (addr == 0x153) || (addr == 0x314)) { // on the chassis bus, the OBDII port is on the module side, so we need to read // the lkas messages sent by openpilot (put on unused 0x151 ane 0x153 addrs) and send it to // the actuator as 0x152 and 0x154 uint32_t fwd_addr = addr + 1; to_fwd->RIR = (fwd_addr << 21) | (to_fwd->RIR & 0x1fffff); } } if (bus_num == 2) { bus_fwd = 0; } return bus_fwd; } const safety_hooks gm_ascm_hooks = { .init = nooutput_init, .rx = default_rx_hook, .tx = alloutput_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = gm_ascm_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_honda.h ================================================ // board enforces // in-state // accel set/resume // out-state // cancel button // accel rising edge // brake rising edge // brake > 0mph const CanMsg HONDA_N_TX_MSGS[] = {{0xE4, 0, 5}, {0x194, 0, 4}, {0x1FA, 0, 8}, {0x200, 0, 6}, {0x30C, 0, 8}, {0x33D, 0, 5}}; const CanMsg HONDA_BG_TX_MSGS[] = {{0xE4, 2, 5}, {0xE5, 2, 8}, {0x296, 0, 4}, {0x33D, 2, 5}}; // Bosch Giraffe const CanMsg HONDA_BH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}}; // Bosch Harness const CanMsg HONDA_BG_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x1DF, 0, 8}, {0x1EF, 0, 8}, {0x1FA, 0, 8}, {0x30C, 0, 8}, {0x33D, 0, 5}, {0x39F, 0, 8}, {0x18DAB0F1, 0, 8}}; // Bosch Giraffe w/ gas and brakes const CanMsg HONDA_BH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch Harness w/ gas and brakes // Roughly calculated using the offsets in openpilot +5%: // In openpilot: ((gas1_norm + gas2_norm)/2) > 15 // gas_norm1 = ((gain_dbc1*gas1) + offset_dbc) // gas_norm2 = ((gain_dbc2*gas2) + offset_dbc) // assuming that 2*(gain_dbc1*gas1) == (gain_dbc2*gas2) // In this safety: ((gas1 + (gas2/2))/2) > THRESHOLD const int HONDA_GAS_INTERCEPTOR_THRESHOLD = 344; #define HONDA_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + ((GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2 ) / 2) // avg between 2 tracks const int HONDA_BOSCH_NO_GAS_VALUE = -30000; // value sent when not requesting gas const int HONDA_BOSCH_GAS_MAX = 2000; const int HONDA_BOSCH_ACCEL_MIN = -350; // max braking == -3.5m/s2 // Nidec and Bosch giraffe have pt on bus 0 AddrCheckStruct honda_addr_checks[] = { {.msg = {{0x1A6, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}, {0x296, 0, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U},{ 0 }}}, {.msg = {{0x158, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{0x17C, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, }; #define HONDA_ADDR_CHECKS_LEN (sizeof(honda_addr_checks) / sizeof(honda_addr_checks[0])) // Bosch harness has pt on bus 1 AddrCheckStruct honda_bh_addr_checks[] = { {.msg = {{0x296, 1, 4, .check_checksum = true, .max_counter = 3U, .expected_timestep = 40000U}, { 0 }, { 0 }}}, {.msg = {{0x158, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{0x17C, 1, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, {0x1BE, 1, 3, .check_checksum = true, .max_counter = 3U, .expected_timestep = 20000U}, { 0 }}}, }; #define HONDA_BH_ADDR_CHECKS_LEN (sizeof(honda_bh_addr_checks) / sizeof(honda_bh_addr_checks[0])) const uint16_t HONDA_PARAM_ALT_BRAKE = 1; const uint16_t HONDA_PARAM_BOSCH_LONG = 2; int honda_brake = 0; bool honda_alt_brake_msg = false; bool honda_fwd_brake = false; bool honda_bosch_long = false; enum {HONDA_N_HW, HONDA_BG_HW, HONDA_BH_HW} honda_hw = HONDA_N_HW; addr_checks honda_rx_checks = {honda_addr_checks, HONDA_ADDR_CHECKS_LEN}; static uint8_t honda_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int checksum_byte = GET_LEN(to_push) - 1; return (uint8_t)(GET_BYTE(to_push, checksum_byte)) & 0xFU; } static uint8_t honda_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int len = GET_LEN(to_push); uint8_t checksum = 0U; unsigned int addr = GET_ADDR(to_push); while (addr > 0U) { checksum += (addr & 0xFU); addr >>= 4; } for (int j = 0; j < len; j++) { uint8_t byte = GET_BYTE(to_push, j); checksum += (byte & 0xFU) + (byte >> 4U); if (j == (len - 1)) { checksum -= (byte & 0xFU); // remove checksum in message } } return (8U - checksum) & 0xFU; } static uint8_t honda_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { int counter_byte = GET_LEN(to_push) - 1; return ((uint8_t)(GET_BYTE(to_push, counter_byte)) >> 4U) & 0x3U; } static int honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &honda_rx_checks, honda_get_checksum, honda_compute_checksum, honda_get_counter); if (valid) { int addr = GET_ADDR(to_push); int len = GET_LEN(to_push); int bus = GET_BUS(to_push); // sample speed if (addr == 0x158) { // first 2 bytes vehicle_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); } // state machine to enter and exit controls // 0x1A6 for the ILX, 0x296 for the Civic Touring if ((addr == 0x1A6) || (addr == 0x296)) { int button = (GET_BYTE(to_push, 0) & 0xE0) >> 5; switch (button) { case 2: // cancel controls_allowed = 0; break; case 3: // set case 4: // resume controls_allowed = 1; break; default: break; // any other button is irrelevant } } // user brake signal on 0x17C reports applied brake from computer brake on accord // and crv, which prevents the usual brake safety from working correctly. these // cars have a signal on 0x1BE which only detects user's brake being applied so // in these cases, this is used instead. // most hondas: 0x17C bit 53 // accord, crv: 0x1BE bit 4 bool is_user_brake_msg = honda_alt_brake_msg ? ((addr) == 0x1BE) : ((addr) == 0x17C); if (is_user_brake_msg) { brake_pressed = honda_alt_brake_msg ? (GET_BYTE((to_push), 0) & 0x10) : (GET_BYTE((to_push), 6) & 0x20); } // length check because bosch hardware also uses this id (0x201 w/ len = 8) if ((addr == 0x201) && (len == 6)) { gas_interceptor_detected = 1; int gas_interceptor = HONDA_GET_INTERCEPTOR(to_push); gas_pressed = gas_interceptor > HONDA_GAS_INTERCEPTOR_THRESHOLD; gas_interceptor_prev = gas_interceptor; } if (!gas_interceptor_detected) { if (addr == 0x17C) { gas_pressed = GET_BYTE(to_push, 0) != 0; } } // disable stock Honda AEB in unsafe mode if ( !(unsafe_mode & UNSAFE_DISABLE_STOCK_AEB) ) { if ((bus == 2) && (addr == 0x1FA)) { bool honda_stock_aeb = GET_BYTE(to_push, 3) & 0x20; int honda_stock_brake = (GET_BYTE(to_push, 0) << 2) + ((GET_BYTE(to_push, 1) >> 6) & 0x3); // Forward AEB when stock braking is higher than openpilot braking // only stop forwarding when AEB event is over if (!honda_stock_aeb) { honda_fwd_brake = false; } else if (honda_stock_brake >= honda_brake) { honda_fwd_brake = true; } else { // Leave Honda forward brake as is } } } bool stock_ecu_detected = false; int bus_rdr_car = (honda_hw == HONDA_BH_HW) ? 0 : 2; // radar bus, car side int pt_bus = (honda_hw == HONDA_BH_HW) ? 1 : 0; if (safety_mode_cnt > RELAY_TRNS_TIMEOUT) { // If steering controls messages are received on the destination bus, it's an indication // that the relay might be malfunctioning if ((addr == 0xE4) || (addr == 0x194)) { if (((honda_hw != HONDA_N_HW) && (bus == bus_rdr_car)) || ((honda_hw == HONDA_N_HW) && (bus == 0))) { stock_ecu_detected = true; } } // If Honda Bosch longitudinal mode is selected we need to ensure the radar is turned off // Verify this by ensuring ACC_CONTROL (0x1DF) is not received on the PT bus if (honda_bosch_long && (bus == pt_bus) && (addr == 0x1DF)) { stock_ecu_detected = true; } } generic_rx_checks(stock_ecu_detected); } return valid; } // all commands: gas, brake and steering // if controls_allowed and no pedals pressed // allow all commands up to limit // else // block all commands that produce actuation static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); if ((honda_hw == HONDA_BG_HW) && !honda_bosch_long) { tx = msg_allowed(to_send, HONDA_BG_TX_MSGS, sizeof(HONDA_BG_TX_MSGS)/sizeof(HONDA_BG_TX_MSGS[0])); } else if ((honda_hw == HONDA_BG_HW) && honda_bosch_long) { tx = msg_allowed(to_send, HONDA_BG_LONG_TX_MSGS, sizeof(HONDA_BG_LONG_TX_MSGS)/sizeof(HONDA_BG_LONG_TX_MSGS[0])); } else if ((honda_hw == HONDA_BH_HW) && !honda_bosch_long) { tx = msg_allowed(to_send, HONDA_BH_TX_MSGS, sizeof(HONDA_BH_TX_MSGS)/sizeof(HONDA_BH_TX_MSGS[0])); } else if ((honda_hw == HONDA_BH_HW) && honda_bosch_long) { tx = msg_allowed(to_send, HONDA_BH_LONG_TX_MSGS, sizeof(HONDA_BH_LONG_TX_MSGS)/sizeof(HONDA_BH_LONG_TX_MSGS[0])); } else { tx = msg_allowed(to_send, HONDA_N_TX_MSGS, sizeof(HONDA_N_TX_MSGS)/sizeof(HONDA_N_TX_MSGS[0])); } if (relay_malfunction) { tx = 0; } // disallow actuator commands if gas or brake (with vehicle moving) are pressed // and the the latching controls_allowed flag is True int pedal_pressed = brake_pressed_prev && vehicle_moving; bool unsafe_allow_gas = unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS; if (!unsafe_allow_gas) { pedal_pressed = pedal_pressed || gas_pressed_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD); } bool current_controls_allowed = controls_allowed && !(pedal_pressed); int bus_pt = (honda_hw == HONDA_BH_HW)? 1 : 0; // BRAKE: safety check (nidec) if ((addr == 0x1FA) && (bus == bus_pt)) { honda_brake = (GET_BYTE(to_send, 0) << 2) + ((GET_BYTE(to_send, 1) >> 6) & 0x3); if (!current_controls_allowed) { if (honda_brake != 0) { tx = 0; } } if (honda_brake > 255) { tx = 0; } if (honda_fwd_brake) { tx = 0; } } // BRAKE/GAS: safety check (bosch) if ((addr == 0x1DF) && (bus == bus_pt)) { int accel = (GET_BYTE(to_send, 3) << 3) | ((GET_BYTE(to_send, 4) >> 5) & 0x7); accel = to_signed(accel, 11); if (!current_controls_allowed) { if (accel != 0) { tx = 0; } } if (accel < HONDA_BOSCH_ACCEL_MIN) { tx = 0; } int gas = (GET_BYTE(to_send, 0) << 8) | GET_BYTE(to_send, 1); gas = to_signed(gas, 16); if (!current_controls_allowed) { if (gas != HONDA_BOSCH_NO_GAS_VALUE) { tx = 0; } } if (gas > HONDA_BOSCH_GAS_MAX) { tx = 0; } } // STEER: safety check if ((addr == 0xE4) || (addr == 0x194)) { if (!current_controls_allowed) { bool steer_applied = GET_BYTE(to_send, 0) | GET_BYTE(to_send, 1); if (steer_applied) { tx = 0; } } } // Bosch supplemental control check if (addr == 0xE5) { if ((GET_BYTES_04(to_send) != 0x10800004) || ((GET_BYTES_48(to_send) & 0x00FFFFFF) != 0x0)) { tx = 0; } } // GAS: safety check (interceptor) if (addr == 0x200) { if (!current_controls_allowed) { if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { tx = 0; } } } // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW // ensuring that only the cancel button press is sent (VAL 2) when controls are off. // This avoids unintended engagements while still allowing resume spam if ((addr == 0x296) && !current_controls_allowed && (bus == bus_pt)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7) != 2) { tx = 0; } } // Only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address if (addr == 0x18DAB0F1) { if ((GET_BYTES_04(to_send) != 0x00803E02) || (GET_BYTES_48(to_send) != 0x0)) { tx = 0; } } // 1 allows the message through return tx; } static const addr_checks* honda_nidec_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); gas_interceptor_detected = 0; honda_hw = HONDA_N_HW; honda_alt_brake_msg = false; honda_bosch_long = false; honda_rx_checks = (addr_checks){honda_addr_checks, HONDA_ADDR_CHECKS_LEN}; return &honda_rx_checks; } static const addr_checks* honda_bosch_giraffe_init(int16_t param) { controls_allowed = false; relay_malfunction_reset(); honda_hw = HONDA_BG_HW; // Checking for alternate brake override from safety parameter honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); // radar disabled so allow gas/brakes honda_bosch_long = GET_FLAG(param, HONDA_PARAM_BOSCH_LONG); honda_rx_checks = (addr_checks){honda_addr_checks, HONDA_ADDR_CHECKS_LEN}; return &honda_rx_checks; } static const addr_checks* honda_bosch_harness_init(int16_t param) { controls_allowed = false; relay_malfunction_reset(); honda_hw = HONDA_BH_HW; // Checking for alternate brake override from safety parameter honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); // radar disabled so allow gas/brakes honda_bosch_long = GET_FLAG(param, HONDA_PARAM_BOSCH_LONG); honda_rx_checks = (addr_checks){honda_bh_addr_checks, HONDA_BH_ADDR_CHECKS_LEN}; return &honda_rx_checks; } static int honda_nidec_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { // fwd from car to camera. also fwd certain msgs from camera to car // 0xE4 is steering on all cars except CRV and RDX, 0x194 for CRV and RDX, // 0x1FA is brake control, 0x30C is acc hud, 0x33D is lkas hud, int bus_fwd = -1; if (!relay_malfunction) { if (bus_num == 0) { bus_fwd = 2; } if (bus_num == 2) { // block stock lkas messages and stock acc messages (if OP is doing ACC) int addr = GET_ADDR(to_fwd); bool is_lkas_msg = (addr == 0xE4) || (addr == 0x194) || (addr == 0x33D); bool is_acc_hud_msg = addr == 0x30C; bool is_brake_msg = addr == 0x1FA; bool block_fwd = is_lkas_msg || is_acc_hud_msg || (is_brake_msg && !honda_fwd_brake); if (!block_fwd) { bus_fwd = 0; } } } return bus_fwd; } static int honda_bosch_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; int bus_rdr_cam = (honda_hw == HONDA_BH_HW) ? 2 : 1; // radar bus, camera side int bus_rdr_car = (honda_hw == HONDA_BH_HW) ? 0 : 2; // radar bus, car side if (!relay_malfunction) { if (bus_num == bus_rdr_car) { bus_fwd = bus_rdr_cam; } if (bus_num == bus_rdr_cam) { int addr = GET_ADDR(to_fwd); int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D); if (!is_lkas_msg) { bus_fwd = bus_rdr_car; } } } return bus_fwd; } const safety_hooks honda_nidec_hooks = { .init = honda_nidec_init, .rx = honda_rx_hook, .tx = honda_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = honda_nidec_fwd_hook, }; const safety_hooks honda_bosch_giraffe_hooks = { .init = honda_bosch_giraffe_init, .rx = honda_rx_hook, .tx = honda_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = honda_bosch_fwd_hook, }; const safety_hooks honda_bosch_harness_hooks = { .init = honda_bosch_harness_init, .rx = honda_rx_hook, .tx = honda_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = honda_bosch_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_hyundai.h ================================================ const int HYUNDAI_MAX_STEER = 384; // like stock const int HYUNDAI_MAX_RT_DELTA = 112; // max delta torque allowed for real time checks const uint32_t HYUNDAI_RT_INTERVAL = 250000; // 250ms between real time checks const int HYUNDAI_MAX_RATE_UP = 3; const int HYUNDAI_MAX_RATE_DOWN = 7; const int HYUNDAI_DRIVER_TORQUE_ALLOWANCE = 50; const int HYUNDAI_DRIVER_TORQUE_FACTOR = 2; const int HYUNDAI_STANDSTILL_THRSLD = 30; // ~1kph const CanMsg HYUNDAI_TX_MSGS[] = { {832, 0, 8}, // LKAS11 Bus 0 {1265, 0, 4}, // CLU11 Bus 0 {1157, 0, 4}, // LFAHDA_MFC Bus 0 // {1056, 0, 8}, // SCC11, Bus 0 // {1057, 0, 8}, // SCC12, Bus 0 // {1290, 0, 8}, // SCC13, Bus 0 // {905, 0, 8}, // SCC14, Bus 0 // {1186, 0, 8} // 4a2SCC, Bus 0 }; AddrCheckStruct hyundai_addr_checks[] = { {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, {881, 0, 8, .expected_timestep = 10000U}, { 0 }}}, {.msg = {{902, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{916, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, }; #define HYUNDAI_ADDR_CHECK_LEN (sizeof(hyundai_addr_checks) / sizeof(hyundai_addr_checks[0])) // older hyundai models have less checks due to missing counters and checksums AddrCheckStruct hyundai_legacy_addr_checks[] = { {.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, {881, 0, 8, .expected_timestep = 10000U}, { 0 }}}, {.msg = {{902, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{916, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, }; #define HYUNDAI_LEGACY_ADDR_CHECK_LEN (sizeof(hyundai_legacy_addr_checks) / sizeof(hyundai_legacy_addr_checks[0])) const int HYUNDAI_PARAM_EV_GAS = 1; const int HYUNDAI_PARAM_HYBRID_GAS = 2; bool hyundai_legacy = false; bool hyundai_ev_gas_signal = false; bool hyundai_hybrid_gas_signal = false; addr_checks hyundai_rx_checks = {hyundai_addr_checks, HYUNDAI_ADDR_CHECK_LEN}; static uint8_t hyundai_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); uint8_t cnt; if (addr == 608) { cnt = (GET_BYTE(to_push, 7) >> 4) & 0x3; } else if (addr == 902) { cnt = ((GET_BYTE(to_push, 3) >> 6) << 2) | (GET_BYTE(to_push, 1) >> 6); } else if (addr == 916) { cnt = (GET_BYTE(to_push, 1) >> 5) & 0x7; } else if (addr == 1057) { cnt = GET_BYTE(to_push, 7) & 0xF; } else { cnt = 0; } return cnt; } static uint8_t hyundai_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); uint8_t chksum; if (addr == 608) { chksum = GET_BYTE(to_push, 7) & 0xF; } else if (addr == 902) { chksum = ((GET_BYTE(to_push, 7) >> 6) << 2) | (GET_BYTE(to_push, 5) >> 6); } else if (addr == 916) { chksum = GET_BYTE(to_push, 6) & 0xF; } else if (addr == 1057) { chksum = GET_BYTE(to_push, 7) >> 4; } else { chksum = 0; } return chksum; } static uint8_t hyundai_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); uint8_t chksum = 0; if (addr == 902) { // count the bits for (int i = 0; i < 8; i++) { uint8_t b = GET_BYTE(to_push, i); for (int j = 0; j < 8; j++) { uint8_t bit = 0; // exclude checksum and counter if (((i != 1) || (j < 6)) && ((i != 3) || (j < 6)) && ((i != 5) || (j < 6)) && ((i != 7) || (j < 6))) { bit = (b >> (uint8_t)j) & 1U; } chksum += bit; } } chksum = (chksum ^ 9U) & 15U; } else { // sum of nibbles for (int i = 0; i < 8; i++) { if ((addr == 916) && (i == 7)) { continue; // exclude } uint8_t b = GET_BYTE(to_push, i); if (((addr == 608) && (i == 7)) || ((addr == 916) && (i == 6)) || ((addr == 1057) && (i == 7))) { b &= (addr == 1057) ? 0x0FU : 0xF0U; // remove checksum } chksum += (b % 16U) + (b / 16U); } chksum = (16U - (chksum % 16U)) % 16U; } return chksum; } static int hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &hyundai_rx_checks, hyundai_get_checksum, hyundai_compute_checksum, hyundai_get_counter); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); if (addr == 593) { int torque_driver_new = ((GET_BYTES_04(to_push) & 0x7ff) * 0.79) - 808; // scale down new driver torque signal to match previous one // update array of samples update_sample(&torque_driver, torque_driver_new); } // enter controls on rising edge of ACC, exit controls on ACC off if (addr == 1057) { // 2 bits: 13-14 int cruise_engaged = (GET_BYTES_04(to_push) >> 13) & 0x3; if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } // read gas pressed signal if ((addr == 881) && hyundai_ev_gas_signal) { gas_pressed = (((GET_BYTE(to_push, 4) & 0x7F) << 1) | GET_BYTE(to_push, 3) >> 7) != 0; } else if ((addr == 881) && hyundai_hybrid_gas_signal) { gas_pressed = GET_BYTE(to_push, 7) != 0; } else if (addr == 608) { // ICE gas_pressed = (GET_BYTE(to_push, 7) >> 6) != 0; } else { } // sample wheel speed, averaging opposite corners if (addr == 902) { int hyundai_speed = GET_BYTES_04(to_push) & 0x3FFF; // FL hyundai_speed += (GET_BYTES_48(to_push) >> 16) & 0x3FFF; // RL hyundai_speed /= 2; vehicle_moving = hyundai_speed > HYUNDAI_STANDSTILL_THRSLD; } if (addr == 916) { brake_pressed = (GET_BYTE(to_push, 6) >> 7) != 0; } generic_rx_checks((addr == 832)); } return valid; } static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); if (!msg_allowed(to_send, HYUNDAI_TX_MSGS, sizeof(HYUNDAI_TX_MSGS)/sizeof(HYUNDAI_TX_MSGS[0]))) { tx = 0; } if (relay_malfunction) { tx = 0; } // LKA STEER: safety check if (addr == 832) { int desired_torque = ((GET_BYTES_04(to_send) >> 16) & 0x7ff) - 1024; uint32_t ts = microsecond_timer_get(); bool violation = 0; if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, HYUNDAI_MAX_STEER, -HYUNDAI_MAX_STEER); // *** torque rate limit check *** violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, HYUNDAI_MAX_STEER, HYUNDAI_MAX_RATE_UP, HYUNDAI_MAX_RATE_DOWN, HYUNDAI_DRIVER_TORQUE_ALLOWANCE, HYUNDAI_DRIVER_TORQUE_FACTOR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, HYUNDAI_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > HYUNDAI_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } // FORCE CANCEL: safety check only relevant when spamming the cancel button. // ensuring that only the cancel button press is sent (VAL 4) when controls are off. // This avoids unintended engagements while still allowing resume spam if ((addr == 1265) && !controls_allowed) { if ((GET_BYTES_04(to_send) & 0x7) != 4) { tx = 0; } } // 1 allows the message through return tx; } static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; int addr = GET_ADDR(to_fwd); // forward cam to ccan and viceversa, except lkas cmd if (!relay_malfunction) { if (bus_num == 0) { bus_fwd = 2; } if ((bus_num == 2) && (addr != 832) && (addr != 1157)) { bus_fwd = 0; } } return bus_fwd; } static const addr_checks* hyundai_init(int16_t param) { controls_allowed = false; relay_malfunction_reset(); hyundai_legacy = false; hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS); hyundai_hybrid_gas_signal = !hyundai_ev_gas_signal && GET_FLAG(param, HYUNDAI_PARAM_HYBRID_GAS); hyundai_rx_checks = (addr_checks){hyundai_addr_checks, HYUNDAI_ADDR_CHECK_LEN}; return &hyundai_rx_checks; } static const addr_checks* hyundai_legacy_init(int16_t param) { controls_allowed = false; relay_malfunction_reset(); hyundai_legacy = true; hyundai_ev_gas_signal = GET_FLAG(param, HYUNDAI_PARAM_EV_GAS); hyundai_hybrid_gas_signal = !hyundai_ev_gas_signal && GET_FLAG(param, HYUNDAI_PARAM_HYBRID_GAS); hyundai_rx_checks = (addr_checks){hyundai_legacy_addr_checks, HYUNDAI_LEGACY_ADDR_CHECK_LEN}; return &hyundai_rx_checks; } const safety_hooks hyundai_hooks = { .init = hyundai_init, .rx = hyundai_rx_hook, .tx = hyundai_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = hyundai_fwd_hook, }; const safety_hooks hyundai_legacy_hooks = { .init = hyundai_legacy_init, .rx = hyundai_rx_hook, .tx = hyundai_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = hyundai_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_mazda.h ================================================ // CAN msgs we care about #define MAZDA_LKAS 0x243 #define MAZDA_CRZ_CTRL 0x21c #define MAZDA_CRZ_BTNS 0x09d #define MAZDA_STEER_TORQUE 0x240 #define MAZDA_ENGINE_DATA 0x202 #define MAZDA_PEDALS 0x165 // CAN bus numbers #define MAZDA_MAIN 0 #define MAZDA_AUX 1 #define MAZDA_CAM 2 #define MAZDA_MAX_STEER 2048 // max delta torque allowed for real time checks #define MAZDA_MAX_RT_DELTA 940 // 250ms between real time checks #define MAZDA_RT_INTERVAL 250000 #define MAZDA_MAX_RATE_UP 10 #define MAZDA_MAX_RATE_DOWN 25 #define MAZDA_DRIVER_TORQUE_ALLOWANCE 15 #define MAZDA_DRIVER_TORQUE_FACTOR 1 #define MAZDA_MAX_TORQUE_ERROR 350 // lkas enable speed 52kph, disable at 45kph #define MAZDA_LKAS_ENABLE_SPEED 5200 #define MAZDA_LKAS_DISABLE_SPEED 4500 const CanMsg MAZDA_TX_MSGS[] = {{MAZDA_LKAS, 0, 8}, {MAZDA_CRZ_BTNS, 0, 8}}; bool mazda_lkas_allowed = false; AddrCheckStruct mazda_addr_checks[] = { {.msg = {{MAZDA_CRZ_CTRL, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{MAZDA_CRZ_BTNS, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, {.msg = {{MAZDA_STEER_TORQUE, 0, 8, .expected_timestep = 12000U}, { 0 }, { 0 }}}, {.msg = {{MAZDA_ENGINE_DATA, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{MAZDA_PEDALS, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, }; #define MAZDA_ADDR_CHECKS_LEN (sizeof(mazda_addr_checks) / sizeof(mazda_addr_checks[0])) addr_checks mazda_rx_checks = {mazda_addr_checks, MAZDA_ADDR_CHECKS_LEN}; // track msgs coming from OP so that we know what CAM msgs to drop and what to forward static int mazda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &mazda_rx_checks, NULL, NULL, NULL); if (valid && (GET_BUS(to_push) == MAZDA_MAIN)) { int addr = GET_ADDR(to_push); if (addr == MAZDA_ENGINE_DATA) { // sample speed: scale by 0.01 to get kph int speed = (GET_BYTE(to_push, 2) << 8) | GET_BYTE(to_push, 3); vehicle_moving = speed > 10; // moving when speed > 0.1 kph // Enable LKAS at 52kph going up, disable at 45kph going down if (speed > MAZDA_LKAS_ENABLE_SPEED) { mazda_lkas_allowed = true; } else if (speed < MAZDA_LKAS_DISABLE_SPEED) { mazda_lkas_allowed = false; } else { // Misra-able appeasment block! } } if (addr == MAZDA_STEER_TORQUE) { int torque_driver_new = GET_BYTE(to_push, 0) - 127; // update array of samples update_sample(&torque_driver, torque_driver_new); } // enter controls on rising edge of ACC, exit controls on ACC off if (addr == MAZDA_CRZ_CTRL) { bool cruise_engaged = GET_BYTE(to_push, 0) & 8; if (cruise_engaged) { if (!cruise_engaged_prev) { // do not engage until we hit the speed at which lkas is on if (mazda_lkas_allowed) { controls_allowed = 1; } else { controls_allowed = 0; cruise_engaged = false; } } } else { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } if (addr == MAZDA_ENGINE_DATA) { gas_pressed = (GET_BYTE(to_push, 4) || (GET_BYTE(to_push, 5) & 0xF0)); } if (addr == MAZDA_PEDALS) { brake_pressed = (GET_BYTE(to_push, 0) & 0x10); } generic_rx_checks((addr == MAZDA_LKAS)); } return valid; } static int mazda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); if (!msg_allowed(to_send, MAZDA_TX_MSGS, sizeof(MAZDA_TX_MSGS)/sizeof(MAZDA_TX_MSGS[0]))) { tx = 0; } if (relay_malfunction) { tx = 0; } // Check if msg is sent on the main BUS if (bus == MAZDA_MAIN) { // steer cmd checks if (addr == MAZDA_LKAS) { int desired_torque = (((GET_BYTE(to_send, 0) & 0x0f) << 8) | GET_BYTE(to_send, 1)) - MAZDA_MAX_STEER; bool violation = 0; uint32_t ts = microsecond_timer_get(); if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, MAZDA_MAX_STEER, -MAZDA_MAX_STEER); // *** torque rate limit check *** violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, MAZDA_MAX_STEER, MAZDA_MAX_RATE_UP, MAZDA_MAX_RATE_DOWN, MAZDA_DRIVER_TORQUE_ALLOWANCE, MAZDA_DRIVER_TORQUE_FACTOR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, MAZDA_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > ((uint32_t) MAZDA_RT_INTERVAL)) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } } return tx; } static int mazda_fwd_hook(int bus, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; if (!relay_malfunction) { int addr = GET_ADDR(to_fwd); if (bus == MAZDA_MAIN) { bus_fwd = MAZDA_CAM; } else if (bus == MAZDA_CAM) { if (!(addr == MAZDA_LKAS)) { bus_fwd = MAZDA_MAIN; } } else { bus_fwd = -1; } } return bus_fwd; } static const addr_checks* mazda_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); mazda_lkas_allowed = false; return &mazda_rx_checks; } const safety_hooks mazda_hooks = { .init = mazda_init, .rx = mazda_rx_hook, .tx = mazda_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = mazda_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_nissan.h ================================================ const uint32_t NISSAN_RT_INTERVAL = 250000; // 250ms between real time checks const struct lookup_t NISSAN_LOOKUP_ANGLE_RATE_UP = { {2., 7., 17.}, {5., .8, .15}}; const struct lookup_t NISSAN_LOOKUP_ANGLE_RATE_DOWN = { {2., 7., 17.}, {5., 3.5, .5}}; const int NISSAN_DEG_TO_CAN = 100; const CanMsg NISSAN_TX_MSGS[] = {{0x169, 0, 8}, {0x2b1, 0, 8}, {0x4cc, 0, 8}, {0x20b, 2, 6}, {0x20b, 1, 6}, {0x280, 2, 8}}; // Signals duplicated below due to the fact that these messages can come in on either CAN bus, depending on car model. AddrCheckStruct nissan_addr_checks[] = { {.msg = {{0x2, 0, 5, .expected_timestep = 10000U}, {0x2, 1, 5, .expected_timestep = 10000U}, { 0 }}}, // STEER_ANGLE_SENSOR (100Hz) {.msg = {{0x285, 0, 8, .expected_timestep = 20000U}, {0x285, 1, 8, .expected_timestep = 20000U}, { 0 }}}, // WHEEL_SPEEDS_REAR (50Hz) {.msg = {{0x30f, 2, 3, .expected_timestep = 100000U}, {0x30f, 1, 3, .expected_timestep = 100000U}, { 0 }}}, // CRUISE_STATE (10Hz) {.msg = {{0x15c, 0, 8, .expected_timestep = 20000U}, {0x15c, 1, 8, .expected_timestep = 20000U}, {0x239, 0, 8, .expected_timestep = 20000U}}}, // GAS_PEDAL (100Hz / 50Hz) {.msg = {{0x454, 0, 8, .expected_timestep = 100000U}, {0x454, 1, 8, .expected_timestep = 100000U}, {0x1cc, 0, 4, .expected_timestep = 10000U}}}, // DOORS_LIGHTS (10Hz) / BRAKE (100Hz) }; #define NISSAN_ADDR_CHECK_LEN (sizeof(nissan_addr_checks) / sizeof(nissan_addr_checks[0])) addr_checks nissan_rx_checks = {nissan_addr_checks, NISSAN_ADDR_CHECK_LEN}; // EPS Location. false = V-CAN, true = C-CAN bool nissan_alt_eps = false; static int nissan_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &nissan_rx_checks, NULL, NULL, NULL); if (valid) { int bus = GET_BUS(to_push); int addr = GET_ADDR(to_push); if (((bus == 0) && (!nissan_alt_eps)) || ((bus == 1) && (nissan_alt_eps))) { if (addr == 0x2) { // Current steering angle // Factor -0.1, little endian int angle_meas_new = (GET_BYTES_04(to_push) & 0xFFFF); // Need to multiply by 10 here as LKAS and Steering wheel are different base unit angle_meas_new = to_signed(angle_meas_new, 16) * 10; // update array of samples update_sample(&angle_meas, angle_meas_new); } if (addr == 0x285) { // Get current speed // Factor 0.005 vehicle_speed = ((GET_BYTE(to_push, 2) << 8) | (GET_BYTE(to_push, 3))) * 0.005 / 3.6; vehicle_moving = vehicle_speed > 0.; } // X-Trail 0x15c, Leaf 0x239 if ((addr == 0x15c) || (addr == 0x239)) { if (addr == 0x15c){ gas_pressed = ((GET_BYTE(to_push, 5) << 2) | ((GET_BYTE(to_push, 6) >> 6) & 0x3)) > 3; } else { gas_pressed = GET_BYTE(to_push, 0) > 3; } } } // X-trail 0x454, Leaf 0x1cc if ((addr == 0x454) || (addr == 0x1cc)) { if (addr == 0x454){ brake_pressed = (GET_BYTE(to_push, 2) & 0x80) != 0; } else { brake_pressed = GET_BYTE(to_push, 0) > 3; } } // Handle cruise enabled if ((addr == 0x30f) && (((bus == 2) && (!nissan_alt_eps)) || ((bus == 1) && (nissan_alt_eps)))) { bool cruise_engaged = (GET_BYTE(to_push, 0) >> 3) & 1; if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } generic_rx_checks((addr == 0x169) && (bus == 0)); } return valid; } static int nissan_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); bool violation = 0; if (!msg_allowed(to_send, NISSAN_TX_MSGS, sizeof(NISSAN_TX_MSGS) / sizeof(NISSAN_TX_MSGS[0]))) { tx = 0; } if (relay_malfunction) { tx = 0; } // steer cmd checks if (addr == 0x169) { int desired_angle = ((GET_BYTE(to_send, 0) << 10) | (GET_BYTE(to_send, 1) << 2) | ((GET_BYTE(to_send, 2) >> 6) & 0x3)); bool lka_active = (GET_BYTE(to_send, 6) >> 4) & 1; // offeset 1310 * NISSAN_DEG_TO_CAN desired_angle = desired_angle - 131000; if (controls_allowed && lka_active) { // add 1 to not false trigger the violation float delta_angle_float; delta_angle_float = (interpolate(NISSAN_LOOKUP_ANGLE_RATE_UP, vehicle_speed) * NISSAN_DEG_TO_CAN) + 1.; int delta_angle_up = (int)(delta_angle_float); delta_angle_float = (interpolate(NISSAN_LOOKUP_ANGLE_RATE_DOWN, vehicle_speed) * NISSAN_DEG_TO_CAN) + 1.; int delta_angle_down = (int)(delta_angle_float); int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down); int lowest_desired_angle = desired_angle_last - ((desired_angle_last >= 0) ? delta_angle_down : delta_angle_up); // check for violation; violation |= max_limit_check(desired_angle, highest_desired_angle, lowest_desired_angle); } desired_angle_last = desired_angle; // desired steer angle should be the same as steer angle measured when controls are off if ((!controls_allowed) && ((desired_angle < (angle_meas.min - 1)) || (desired_angle > (angle_meas.max + 1)))) { violation = 1; } // no lka_enabled bit if controls not allowed if (!controls_allowed && lka_active) { violation = 1; } } // acc button check, only allow cancel button to be sent if (addr == 0x20b) { // Violation of any button other than cancel is pressed violation |= ((GET_BYTE(to_send, 1) & 0x3d) > 0); } if (violation) { controls_allowed = 0; tx = 0; } return tx; } static int nissan_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; int addr = GET_ADDR(to_fwd); if (bus_num == 0) { int block_msg = (addr == 0x280); // CANCEL_MSG if (!block_msg) { bus_fwd = 2; // ADAS } } if (bus_num == 2) { // 0x169 is LKAS, 0x2b1 LKAS_HUD, 0x4cc LKAS_HUD_INFO_MSG int block_msg = ((addr == 0x169) || (addr == 0x2b1) || (addr == 0x4cc)); if (!block_msg) { bus_fwd = 0; // V-CAN } } if (relay_malfunction) { bus_fwd = -1; } // fallback to do not forward return bus_fwd; } static const addr_checks* nissan_init(int16_t param) { controls_allowed = 0; nissan_alt_eps = param ? 1 : 0; relay_malfunction_reset(); return &nissan_rx_checks; } const safety_hooks nissan_hooks = { .init = nissan_init, .rx = nissan_rx_hook, .tx = nissan_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = nissan_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_subaru.h ================================================ const int SUBARU_MAX_STEER = 2047; // 1s // real time torque limit to prevent controls spamming // the real time limit is 1500/sec const int SUBARU_MAX_RT_DELTA = 940; // max delta torque allowed for real time checks const uint32_t SUBARU_RT_INTERVAL = 250000; // 250ms between real time checks const int SUBARU_MAX_RATE_UP = 50; const int SUBARU_MAX_RATE_DOWN = 70; const int SUBARU_DRIVER_TORQUE_ALLOWANCE = 60; const int SUBARU_DRIVER_TORQUE_FACTOR = 10; const int SUBARU_STANDSTILL_THRSLD = 20; // about 1kph const int SUBARU_L_DRIVER_TORQUE_ALLOWANCE = 75; const int SUBARU_L_DRIVER_TORQUE_FACTOR = 10; const CanMsg SUBARU_TX_MSGS[] = {{0x122, 0, 8}, {0x221, 0, 8}, {0x322, 0, 8}}; #define SUBARU_TX_MSGS_LEN (sizeof(SUBARU_TX_MSGS) / sizeof(SUBARU_TX_MSGS[0])) AddrCheckStruct subaru_addr_checks[] = { {.msg = {{ 0x40, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{0x119, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{0x139, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{0x13a, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{0x240, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 50000U}, { 0 }, { 0 }}}, }; #define SUBARU_ADDR_CHECK_LEN (sizeof(subaru_addr_checks) / sizeof(subaru_addr_checks[0])) addr_checks subaru_rx_checks = {subaru_addr_checks, SUBARU_ADDR_CHECK_LEN}; const CanMsg SUBARU_L_TX_MSGS[] = {{0x161, 0, 8}, {0x164, 0, 8}}; #define SUBARU_L_TX_MSGS_LEN (sizeof(SUBARU_L_TX_MSGS) / sizeof(SUBARU_L_TX_MSGS[0])) // TODO: do checksum and counter checks after adding the signals to the outback dbc file AddrCheckStruct subaru_l_addr_checks[] = { {.msg = {{0x140, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{0x371, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{0x144, 0, 8, .expected_timestep = 50000U}, { 0 }, { 0 }}}, }; #define SUBARU_L_ADDR_CHECK_LEN (sizeof(subaru_l_addr_checks) / sizeof(subaru_l_addr_checks[0])) addr_checks subaru_l_rx_checks = {subaru_addr_checks, SUBARU_L_ADDR_CHECK_LEN}; static uint8_t subaru_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { return (uint8_t)GET_BYTE(to_push, 0); } static uint8_t subaru_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { return (uint8_t)(GET_BYTE(to_push, 1) & 0xF); } static uint8_t subaru_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); int len = GET_LEN(to_push); uint8_t checksum = (uint8_t)(addr) + (uint8_t)((unsigned int)(addr) >> 8U); for (int i = 1; i < len; i++) { checksum += (uint8_t)GET_BYTE(to_push, i); } return checksum; } static int subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &subaru_rx_checks, subaru_get_checksum, subaru_compute_checksum, subaru_get_counter); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); if (addr == 0x119) { int torque_driver_new; torque_driver_new = ((GET_BYTES_04(to_push) >> 16) & 0x7FF); torque_driver_new = -1 * to_signed(torque_driver_new, 11); update_sample(&torque_driver, torque_driver_new); } // enter controls on rising edge of ACC, exit controls on ACC off if (addr == 0x240) { int cruise_engaged = ((GET_BYTES_48(to_push) >> 9) & 1); if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } // sample wheel speed, averaging opposite corners if (addr == 0x13a) { int subaru_speed = (GET_BYTES_04(to_push) >> 12) & 0x1FFF; // FR subaru_speed += (GET_BYTES_48(to_push) >> 6) & 0x1FFF; // RL subaru_speed /= 2; vehicle_moving = subaru_speed > SUBARU_STANDSTILL_THRSLD; } if (addr == 0x139) { brake_pressed = (GET_BYTES_48(to_push) & 0xFFF0) > 0; } if (addr == 0x40) { gas_pressed = GET_BYTE(to_push, 4) != 0; } generic_rx_checks((addr == 0x122)); } return valid; } static int subaru_legacy_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &subaru_l_rx_checks, NULL, NULL, NULL); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); if (addr == 0x371) { int torque_driver_new; torque_driver_new = (GET_BYTE(to_push, 3) >> 5) + (GET_BYTE(to_push, 4) << 3); torque_driver_new = to_signed(torque_driver_new, 11); update_sample(&torque_driver, torque_driver_new); } // enter controls on rising edge of ACC, exit controls on ACC off if (addr == 0x144) { int cruise_engaged = ((GET_BYTES_48(to_push) >> 17) & 1); if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } // sample wheel speed, averaging opposite corners if (addr == 0xD4) { int subaru_speed = (GET_BYTES_04(to_push) >> 16) & 0xFFFF; // FR subaru_speed += GET_BYTES_48(to_push) & 0xFFFF; // RL subaru_speed /= 2; vehicle_moving = subaru_speed > SUBARU_STANDSTILL_THRSLD; } if (addr == 0xD1) { brake_pressed = ((GET_BYTES_04(to_push) >> 16) & 0xFF) > 0; } if (addr == 0x140) { gas_pressed = GET_BYTE(to_push, 0) != 0; } generic_rx_checks((addr == 0x164)); } return valid; } static int subaru_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); if (!msg_allowed(to_send, SUBARU_TX_MSGS, SUBARU_TX_MSGS_LEN)) { tx = 0; } if (relay_malfunction) { tx = 0; } // steer cmd checks if (addr == 0x122) { int desired_torque = ((GET_BYTES_04(to_send) >> 16) & 0x1FFF); bool violation = 0; uint32_t ts = microsecond_timer_get(); desired_torque = -1 * to_signed(desired_torque, 13); if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, SUBARU_MAX_STEER, -SUBARU_MAX_STEER); // *** torque rate limit check *** violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, SUBARU_MAX_STEER, SUBARU_MAX_RATE_UP, SUBARU_MAX_RATE_DOWN, SUBARU_DRIVER_TORQUE_ALLOWANCE, SUBARU_DRIVER_TORQUE_FACTOR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, SUBARU_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > SUBARU_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } return tx; } static int subaru_legacy_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); if (!msg_allowed(to_send, SUBARU_L_TX_MSGS, SUBARU_L_TX_MSGS_LEN)) { tx = 0; } if (relay_malfunction) { tx = 0; } // steer cmd checks if (addr == 0x164) { int desired_torque = ((GET_BYTES_04(to_send) >> 8) & 0x1FFF); bool violation = 0; uint32_t ts = microsecond_timer_get(); desired_torque = -1 * to_signed(desired_torque, 13); if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, SUBARU_MAX_STEER, -SUBARU_MAX_STEER); // *** torque rate limit check *** violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, SUBARU_MAX_STEER, SUBARU_MAX_RATE_UP, SUBARU_MAX_RATE_DOWN, SUBARU_L_DRIVER_TORQUE_ALLOWANCE, SUBARU_L_DRIVER_TORQUE_FACTOR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, SUBARU_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > SUBARU_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } return tx; } static int subaru_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; if (!relay_malfunction) { if (bus_num == 0) { bus_fwd = 2; // Camera CAN } if (bus_num == 2) { // Global platform // 0x122 ES_LKAS // 0x221 ES_Distance // 0x322 ES_LKAS_State int addr = GET_ADDR(to_fwd); int block_msg = ((addr == 0x122) || (addr == 0x221) || (addr == 0x322)); if (!block_msg) { bus_fwd = 0; // Main CAN } } } // fallback to do not forward return bus_fwd; } static int subaru_legacy_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; if (!relay_malfunction) { if (bus_num == 0) { bus_fwd = 2; // Camera CAN } if (bus_num == 2) { // Preglobal platform // 0x161 is ES_CruiseThrottle // 0x164 is ES_LKAS int addr = GET_ADDR(to_fwd); int block_msg = ((addr == 0x161) || (addr == 0x164)); if (!block_msg) { bus_fwd = 0; // Main CAN } } } // fallback to do not forward return bus_fwd; } static const addr_checks* subaru_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); return &subaru_rx_checks; } const safety_hooks subaru_hooks = { .init = subaru_init, .rx = subaru_rx_hook, .tx = subaru_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = subaru_fwd_hook, }; static const addr_checks* subaru_legacy_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); return &subaru_l_rx_checks; } const safety_hooks subaru_legacy_hooks = { .init = subaru_legacy_init, .rx = subaru_legacy_rx_hook, .tx = subaru_legacy_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = subaru_legacy_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_tesla.h ================================================ const struct lookup_t TESLA_LOOKUP_ANGLE_RATE_UP = { {2., 7., 17.}, {5., .8, .25}}; const struct lookup_t TESLA_LOOKUP_ANGLE_RATE_DOWN = { {2., 7., 17.}, {5., 3.5, .8}}; const int TESLA_DEG_TO_CAN = 10; const CanMsg TESLA_TX_MSGS[] = { {0x488, 0, 4}, // DAS_steeringControl {0x45, 0, 8}, // STW_ACTN_RQ {0x45, 2, 8}, // STW_ACTN_RQ }; AddrCheckStruct tesla_addr_checks[] = { {.msg = {{0x370, 0, 8, .expected_timestep = 40000U}, { 0 }, { 0 }}}, // EPAS_sysStatus (25Hz) {.msg = {{0x108, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}}, // DI_torque1 (100Hz) {.msg = {{0x118, 0, 6, .expected_timestep = 10000U}, { 0 }, { 0 }}}, // DI_torque2 (100Hz) {.msg = {{0x155, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, // ESP_B (50Hz) {.msg = {{0x20a, 0, 8, .expected_timestep = 20000U}, { 0 }, { 0 }}}, // BrakeMessage (50Hz) {.msg = {{0x368, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, // DI_state (10Hz) {.msg = {{0x318, 0, 8, .expected_timestep = 100000U}, { 0 }, { 0 }}}, // GTW_carState (10Hz) }; #define TESLA_ADDR_CHECK_LEN (sizeof(tesla_addr_checks) / sizeof(tesla_addr_checks[0])) addr_checks tesla_rx_checks = {tesla_addr_checks, TESLA_ADDR_CHECK_LEN}; bool autopilot_enabled = false; static int tesla_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &tesla_rx_checks, NULL, NULL, NULL); if(valid) { int bus = GET_BUS(to_push); int addr = GET_ADDR(to_push); if(bus == 0) { if(addr == 0x370) { // Steering angle: (0.1 * val) - 819.2 in deg. // Store it 1/10 deg to match steering request int angle_meas_new = (((GET_BYTE(to_push, 4) & 0x3F) << 8) | GET_BYTE(to_push, 5)) - 8192; update_sample(&angle_meas, angle_meas_new); } if(addr == 0x155) { // Vehicle speed: (0.01 * val) * KPH_TO_MPS vehicle_speed = ((GET_BYTE(to_push, 5) << 8) | (GET_BYTE(to_push, 6))) * 0.01 / 3.6; vehicle_moving = vehicle_speed > 0.; } if(addr == 0x108) { // Gas pressed gas_pressed = (GET_BYTE(to_push, 6) != 0); } if(addr == 0x20a) { // Brake pressed brake_pressed = (((GET_BYTE(to_push, 0) & 0x0C) >> 2) != 1); } if(addr == 0x368) { // Cruise state int cruise_state = (GET_BYTE(to_push, 1) >> 4); bool cruise_engaged = (cruise_state == 2) || // ENABLED (cruise_state == 3) || // STANDSTILL (cruise_state == 4) || // OVERRIDE (cruise_state == 6) || // PRE_FAULT (cruise_state == 7); // PRE_CANCEL if(cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if(!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } } if (bus == 2) { if (addr == 0x399) { // Autopilot status int autopilot_status = (GET_BYTE(to_push, 0) & 0xF); autopilot_enabled = (autopilot_status == 3) || // ACTIVE_1 (autopilot_status == 4) || // ACTIVE_2 (autopilot_status == 5); // ACTIVE_NAVIGATE_ON_AUTOPILOT if (autopilot_enabled) { controls_allowed = 0; } } } // 0x488: DAS_steeringControl should not be received on bus 0 generic_rx_checks((addr == 0x488) && (bus == 0)); } return valid; } static int tesla_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); bool violation = false; if(!msg_allowed(to_send, TESLA_TX_MSGS, sizeof(TESLA_TX_MSGS) / sizeof(TESLA_TX_MSGS[0]))) { tx = 0; } if(relay_malfunction) { tx = 0; } if(addr == 0x488) { // Steering control: (0.1 * val) - 1638.35 in deg. // We use 1/10 deg as a unit here int raw_angle_can = (((GET_BYTE(to_send, 0) & 0x7F) << 8) | GET_BYTE(to_send, 1)); int desired_angle = raw_angle_can - 16384; int steer_control_type = GET_BYTE(to_send, 2) >> 6; bool steer_control_enabled = (steer_control_type != 0) && // NONE (steer_control_type != 3); // DISABLED // Rate limit while steering if(controls_allowed && steer_control_enabled) { // Add 1 to not false trigger the violation float delta_angle_float; delta_angle_float = (interpolate(TESLA_LOOKUP_ANGLE_RATE_UP, vehicle_speed) * TESLA_DEG_TO_CAN); int delta_angle_up = (int)(delta_angle_float) + 1; delta_angle_float = (interpolate(TESLA_LOOKUP_ANGLE_RATE_DOWN, vehicle_speed) * TESLA_DEG_TO_CAN); int delta_angle_down = (int)(delta_angle_float) + 1; int highest_desired_angle = desired_angle_last + ((desired_angle_last > 0) ? delta_angle_up : delta_angle_down); int lowest_desired_angle = desired_angle_last - ((desired_angle_last >= 0) ? delta_angle_down : delta_angle_up); // Check for violation; violation |= max_limit_check(desired_angle, highest_desired_angle, lowest_desired_angle); } desired_angle_last = desired_angle; // Angle should be the same as current angle while not steering if(!controls_allowed && ((desired_angle < (angle_meas.min - 1)) || (desired_angle > (angle_meas.max + 1)))) { violation = true; } // No angle control allowed when controls are not allowed if(!controls_allowed && steer_control_enabled) { violation = true; } } if(addr == 0x45) { // No button other than cancel can be sent by us int control_lever_status = (GET_BYTE(to_send, 0) & 0x3F); if((control_lever_status != 0) && (control_lever_status != 1)) { violation = true; } } if(violation) { controls_allowed = 0; tx = 0; } return tx; } static int tesla_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; int addr = GET_ADDR(to_fwd); if(bus_num == 0) { // Chassis to autopilot bus_fwd = 2; } if(bus_num == 2) { // Autopilot to chassis bool block_msg = ((addr == 0x488) && !autopilot_enabled); if(!block_msg) { bus_fwd = 0; } } if(relay_malfunction) { bus_fwd = -1; } return bus_fwd; } static const addr_checks* tesla_init(int16_t param) { UNUSED(param); controls_allowed = 0; relay_malfunction_reset(); return &tesla_rx_checks; } const safety_hooks tesla_hooks = { .init = tesla_init, .rx = tesla_rx_hook, .tx = tesla_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = tesla_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_toyota.h ================================================ // global torque limit const int TOYOTA_MAX_TORQUE = 1500; // max torque cmd allowed ever // rate based torque limit + stay within actually applied // packet is sent at 100hz, so this limit is 1000/sec const int TOYOTA_MAX_RATE_UP = 10; // ramp up slow const int TOYOTA_MAX_RATE_DOWN = 25; // ramp down fast const int TOYOTA_MAX_TORQUE_ERROR = 350; // max torque cmd in excess of torque motor // real time torque limit to prevent controls spamming // the real time limit is 1500/sec const int TOYOTA_MAX_RT_DELTA = 375; // max delta torque allowed for real time checks const uint32_t TOYOTA_RT_INTERVAL = 250000; // 250ms between real time checks // longitudinal limits const int TOYOTA_MAX_ACCEL = 2000; // 2.0 m/s2 const int TOYOTA_MIN_ACCEL = -3500; // -3.5 m/s2 const int TOYOTA_STANDSTILL_THRSLD = 100; // 1kph // Roughly calculated using the offsets in openpilot +5%: // In openpilot: ((gas1_norm + gas2_norm)/2) > 15 // gas_norm1 = ((gain_dbc*gas1) + offset1_dbc) // gas_norm2 = ((gain_dbc*gas2) + offset2_dbc) // In this safety: ((gas1 + gas2)/2) > THRESHOLD const int TOYOTA_GAS_INTERCEPTOR_THRSLD = 845; #define TOYOTA_GET_INTERCEPTOR(msg) (((GET_BYTE((msg), 0) << 8) + GET_BYTE((msg), 1) + (GET_BYTE((msg), 2) << 8) + GET_BYTE((msg), 3)) / 2) // avg between 2 tracks const CanMsg TOYOTA_TX_MSGS[] = {{0x283, 0, 7}, {0x2E6, 0, 8}, {0x2E7, 0, 8}, {0x33E, 0, 7}, {0x344, 0, 8}, {0x365, 0, 7}, {0x366, 0, 7}, {0x4CB, 0, 8}, // DSU bus 0 {0x128, 1, 6}, {0x141, 1, 4}, {0x160, 1, 8}, {0x161, 1, 7}, {0x470, 1, 4}, // DSU bus 1 {0x2E4, 0, 5}, {0x191, 0, 8}, {0x411, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, // LKAS + ACC {0x200, 0, 6}}; // interceptor AddrCheckStruct toyota_addr_checks[] = { {.msg = {{ 0xaa, 0, 8, .check_checksum = false, .expected_timestep = 12000U}, { 0 }, { 0 }}}, {.msg = {{0x260, 0, 8, .check_checksum = true, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{0x1D2, 0, 8, .check_checksum = true, .expected_timestep = 30000U}, { 0 }, { 0 }}}, {.msg = {{0x224, 0, 8, .check_checksum = false, .expected_timestep = 25000U}, {0x226, 0, 8, .check_checksum = false, .expected_timestep = 25000U}, { 0 }}}, }; #define TOYOTA_ADDR_CHECKS_LEN (sizeof(toyota_addr_checks) / sizeof(toyota_addr_checks[0])) addr_checks toyota_rx_checks = {toyota_addr_checks, TOYOTA_ADDR_CHECKS_LEN}; // global actuation limit states int toyota_dbc_eps_torque_factor = 100; // conversion factor for STEER_TORQUE_EPS in %: see dbc file static uint8_t toyota_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); int len = GET_LEN(to_push); uint8_t checksum = (uint8_t)(addr) + (uint8_t)((unsigned int)(addr) >> 8U) + (uint8_t)(len); for (int i = 0; i < (len - 1); i++) { checksum += (uint8_t)GET_BYTE(to_push, i); } return checksum; } static uint8_t toyota_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int checksum_byte = GET_LEN(to_push) - 1; return (uint8_t)(GET_BYTE(to_push, checksum_byte)); } static int toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &toyota_rx_checks, toyota_get_checksum, toyota_compute_checksum, NULL); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); // get eps motor torque (0.66 factor in dbc) if (addr == 0x260) { int torque_meas_new = (GET_BYTE(to_push, 5) << 8) | GET_BYTE(to_push, 6); torque_meas_new = to_signed(torque_meas_new, 16); // scale by dbc_factor torque_meas_new = (torque_meas_new * toyota_dbc_eps_torque_factor) / 100; // update array of sample update_sample(&torque_meas, torque_meas_new); // increase torque_meas by 1 to be conservative on rounding torque_meas.min--; torque_meas.max++; } // enter controls on rising edge of ACC, exit controls on ACC off // exit controls on rising edge of gas press if (addr == 0x1D2) { // 5th bit is CRUISE_ACTIVE int cruise_engaged = GET_BYTE(to_push, 0) & 0x20; if (!cruise_engaged) { controls_allowed = 0; } if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } cruise_engaged_prev = cruise_engaged; // sample gas pedal if (!gas_interceptor_detected) { gas_pressed = ((GET_BYTE(to_push, 0) >> 4) & 1) == 0; } } // sample speed if (addr == 0xaa) { int speed = 0; // sum 4 wheel speeds for (int i=0; i<8; i+=2) { int next_byte = i + 1; // hack to deal with misra 10.8 speed += (GET_BYTE(to_push, i) << 8) + GET_BYTE(to_push, next_byte) - 0x1a6f; } vehicle_moving = ABS(speed / 4) > TOYOTA_STANDSTILL_THRSLD; } // most cars have brake_pressed on 0x226, corolla and rav4 on 0x224 if ((addr == 0x224) || (addr == 0x226)) { int byte = (addr == 0x224) ? 0 : 4; brake_pressed = ((GET_BYTE(to_push, byte) >> 5) & 1) != 0; } // sample gas interceptor if (addr == 0x201) { gas_interceptor_detected = 1; int gas_interceptor = TOYOTA_GET_INTERCEPTOR(to_push); gas_pressed = gas_interceptor > TOYOTA_GAS_INTERCEPTOR_THRSLD; // TODO: remove this, only left in for gas_interceptor_prev test gas_interceptor_prev = gas_interceptor; } generic_rx_checks((addr == 0x2E4)); } return valid; } static int toyota_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int tx = 1; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); if (!msg_allowed(to_send, TOYOTA_TX_MSGS, sizeof(TOYOTA_TX_MSGS)/sizeof(TOYOTA_TX_MSGS[0]))) { tx = 0; } if (relay_malfunction) { tx = 0; } // Check if msg is sent on BUS 0 if (bus == 0) { // GAS PEDAL: safety check if (addr == 0x200) { if (!controls_allowed) { if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) { tx = 0; } } } // ACCEL: safety check on byte 1-2 if (addr == 0x343) { int desired_accel = (GET_BYTE(to_send, 0) << 8) | GET_BYTE(to_send, 1); desired_accel = to_signed(desired_accel, 16); if (!controls_allowed) { if (desired_accel != 0) { tx = 0; } } bool violation = max_limit_check(desired_accel, TOYOTA_MAX_ACCEL, TOYOTA_MIN_ACCEL); if (violation) { tx = 0; } } // LTA steering check // only sent to prevent dash errors, no actuation is accepted if (addr == 0x191) { // check the STEER_REQUEST, STEER_REQUEST_2, and STEER_ANGLE_CMD signals bool lta_request = (GET_BYTE(to_send, 0) & 1) != 0; bool lta_request2 = ((GET_BYTE(to_send, 3) >> 1) & 1) != 0; int lta_angle = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2); lta_angle = to_signed(lta_angle, 16); // block LTA msgs with actuation requests if (lta_request || lta_request2 || (lta_angle != 0)) { tx = 0; } } // STEER: safety check on bytes 2-3 if (addr == 0x2E4) { int desired_torque = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2); desired_torque = to_signed(desired_torque, 16); bool violation = 0; uint32_t ts = microsecond_timer_get(); if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, TOYOTA_MAX_TORQUE, -TOYOTA_MAX_TORQUE); // *** torque rate limit check *** violation |= dist_to_meas_check(desired_torque, desired_torque_last, &torque_meas, TOYOTA_MAX_RATE_UP, TOYOTA_MAX_RATE_DOWN, TOYOTA_MAX_TORQUE_ERROR); // used next time desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, TOYOTA_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > TOYOTA_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = 1; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } if (violation) { tx = 0; } } } return tx; } static const addr_checks* toyota_init(int16_t param) { controls_allowed = 0; relay_malfunction_reset(); gas_interceptor_detected = 0; toyota_dbc_eps_torque_factor = param; return &toyota_rx_checks; } static int toyota_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int bus_fwd = -1; if (!relay_malfunction) { if (bus_num == 0) { bus_fwd = 2; } if (bus_num == 2) { int addr = GET_ADDR(to_fwd); // block stock lkas messages and stock acc messages (if OP is doing ACC) // in TSS2, 0x191 is LTA which we need to block to avoid controls collision int is_lkas_msg = ((addr == 0x2E4) || (addr == 0x412) || (addr == 0x191)); // in TSS2 the camera does ACC as well, so filter 0x343 int is_acc_msg = (addr == 0x343); int block_msg = is_lkas_msg || is_acc_msg; if (!block_msg) { bus_fwd = 0; } } } return bus_fwd; } const safety_hooks toyota_hooks = { .init = toyota_init, .rx = toyota_rx_hook, .tx = toyota_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = toyota_fwd_hook, }; ================================================ FILE: panda/board/safety/safety_volkswagen.h ================================================ // Safety-relevant steering constants for Volkswagen const int VOLKSWAGEN_MAX_STEER = 300; // 3.0 Nm (EPS side max of 3.0Nm with fault if violated) const int VOLKSWAGEN_MAX_RT_DELTA = 188; // 10 max rate up * 50Hz send rate * 250000 RT interval / 1000000 = 125 ; 125 * 1.5 for safety pad = 187.5 const uint32_t VOLKSWAGEN_RT_INTERVAL = 250000; // 250ms between real time checks const int VOLKSWAGEN_MAX_RATE_UP = 10; // 5.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s) const int VOLKSWAGEN_MAX_RATE_DOWN = 10; // 5.0 Nm/s RoC limit (EPS rack has own soft-limit of 5.0 Nm/s) const int VOLKSWAGEN_DRIVER_TORQUE_ALLOWANCE = 80; const int VOLKSWAGEN_DRIVER_TORQUE_FACTOR = 3; // Safety-relevant CAN messages for the Volkswagen MQB platform #define MSG_ESP_19 0x0B2 // RX from ABS, for wheel speeds #define MSG_LH_EPS_03 0x09F // RX from EPS, for driver steering torque #define MSG_ESP_05 0x106 // RX from ABS, for brake switch state #define MSG_TSK_06 0x120 // RX from ECU, for ACC status from drivetrain coordinator #define MSG_MOTOR_20 0x121 // RX from ECU, for driver throttle input #define MSG_HCA_01 0x126 // TX by OP, Heading Control Assist steering torque #define MSG_GRA_ACC_01 0x12B // TX by OP, ACC control buttons for cancel/resume #define MSG_LDW_02 0x397 // TX by OP, Lane line recognition and text alerts // Transmit of GRA_ACC_01 is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration const CanMsg VOLKSWAGEN_MQB_TX_MSGS[] = {{MSG_HCA_01, 0, 8}, {MSG_GRA_ACC_01, 0, 8}, {MSG_GRA_ACC_01, 2, 8}, {MSG_LDW_02, 0, 8}}; #define VOLKSWAGEN_MQB_TX_MSGS_LEN (sizeof(VOLKSWAGEN_MQB_TX_MSGS) / sizeof(VOLKSWAGEN_MQB_TX_MSGS[0])) AddrCheckStruct volkswagen_mqb_addr_checks[] = { {.msg = {{MSG_ESP_19, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{MSG_LH_EPS_03, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{MSG_ESP_05, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{MSG_TSK_06, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{MSG_MOTOR_20, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, }; #define VOLKSWAGEN_MQB_ADDR_CHECKS_LEN (sizeof(volkswagen_mqb_addr_checks) / sizeof(volkswagen_mqb_addr_checks[0])) addr_checks volkswagen_mqb_rx_checks = {volkswagen_mqb_addr_checks, VOLKSWAGEN_MQB_ADDR_CHECKS_LEN}; // Safety-relevant CAN messages for the Volkswagen PQ35/PQ46/NMS platforms #define MSG_LENKHILFE_3 0x0D0 // RX from EPS, for steering angle and driver steering torque #define MSG_HCA_1 0x0D2 // TX by OP, Heading Control Assist steering torque #define MSG_MOTOR_2 0x288 // RX from ECU, for CC state and brake switch state #define MSG_MOTOR_3 0x380 // RX from ECU, for driver throttle input #define MSG_GRA_NEU 0x38A // TX by OP, ACC control buttons for cancel/resume #define MSG_BREMSE_3 0x4A0 // RX from ABS, for wheel speeds #define MSG_LDW_1 0x5BE // TX by OP, Lane line recognition and text alerts // Transmit of GRA_Neu is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration const CanMsg VOLKSWAGEN_PQ_TX_MSGS[] = {{MSG_HCA_1, 0, 5}, {MSG_GRA_NEU, 0, 4}, {MSG_GRA_NEU, 2, 4}, {MSG_LDW_1, 0, 8}}; #define VOLKSWAGEN_PQ_TX_MSGS_LEN (sizeof(VOLKSWAGEN_PQ_TX_MSGS) / sizeof(VOLKSWAGEN_PQ_TX_MSGS[0])) AddrCheckStruct volkswagen_pq_addr_checks[] = { {.msg = {{MSG_LENKHILFE_3, 0, 6, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{MSG_MOTOR_2, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, {.msg = {{MSG_MOTOR_3, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, {.msg = {{MSG_BREMSE_3, 0, 8, .check_checksum = false, .max_counter = 0U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, }; #define VOLKSWAGEN_PQ_ADDR_CHECKS_LEN (sizeof(volkswagen_pq_addr_checks) / sizeof(volkswagen_pq_addr_checks[0])) addr_checks volkswagen_pq_rx_checks = {volkswagen_pq_addr_checks, VOLKSWAGEN_PQ_ADDR_CHECKS_LEN}; int volkswagen_torque_msg = 0; int volkswagen_lane_msg = 0; uint8_t volkswagen_crc8_lut_8h2f[256]; // Static lookup table for CRC8 poly 0x2F, aka 8H2F/AUTOSAR static uint8_t volkswagen_get_checksum(CAN_FIFOMailBox_TypeDef *to_push) { return (uint8_t)GET_BYTE(to_push, 0); } static uint8_t volkswagen_mqb_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { // MQB message counters are consistently found at LSB 8. return (uint8_t)GET_BYTE(to_push, 1) & 0xFU; } static uint8_t volkswagen_pq_get_counter(CAN_FIFOMailBox_TypeDef *to_push) { // Few PQ messages have counters, and their offsets are inconsistent. This // function works only for Lenkhilfe_3 at this time. return (uint8_t)(GET_BYTE(to_push, 1) & 0xF0U) >> 4; } static uint8_t volkswagen_mqb_compute_crc(CAN_FIFOMailBox_TypeDef *to_push) { int addr = GET_ADDR(to_push); int len = GET_LEN(to_push); // This is CRC-8H2F/AUTOSAR with a twist. See the OpenDBC implementation // of this algorithm for a version with explanatory comments. uint8_t crc = 0xFFU; for (int i = 1; i < len; i++) { crc ^= (uint8_t)GET_BYTE(to_push, i); crc = volkswagen_crc8_lut_8h2f[crc]; } uint8_t counter = volkswagen_mqb_get_counter(to_push); switch(addr) { case MSG_LH_EPS_03: crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter]; break; case MSG_ESP_05: crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter]; break; case MSG_TSK_06: crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter]; break; case MSG_MOTOR_20: crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter]; break; default: // Undefined CAN message, CRC check expected to fail break; } crc = volkswagen_crc8_lut_8h2f[crc]; return crc ^ 0xFFU; } static uint8_t volkswagen_pq_compute_checksum(CAN_FIFOMailBox_TypeDef *to_push) { int len = GET_LEN(to_push); uint8_t checksum = 0U; for (int i = 1; i < len; i++) { checksum ^= (uint8_t)GET_BYTE(to_push, i); } return checksum; } static const addr_checks* volkswagen_mqb_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); volkswagen_torque_msg = MSG_HCA_01; volkswagen_lane_msg = MSG_LDW_02; gen_crc_lookup_table(0x2F, volkswagen_crc8_lut_8h2f); return &volkswagen_mqb_rx_checks; } static const addr_checks* volkswagen_pq_init(int16_t param) { UNUSED(param); controls_allowed = false; relay_malfunction_reset(); volkswagen_torque_msg = MSG_HCA_1; volkswagen_lane_msg = MSG_LDW_1; return &volkswagen_pq_rx_checks; } static int volkswagen_mqb_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &volkswagen_mqb_rx_checks, volkswagen_get_checksum, volkswagen_mqb_compute_crc, volkswagen_mqb_get_counter); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); // Update in-motion state by sampling front wheel speeds // Signal: ESP_19.ESP_VL_Radgeschw_02 (front left) in scaled km/h // Signal: ESP_19.ESP_VR_Radgeschw_02 (front right) in scaled km/h if (addr == MSG_ESP_19) { int wheel_speed_fl = GET_BYTE(to_push, 4) | (GET_BYTE(to_push, 5) << 8); int wheel_speed_fr = GET_BYTE(to_push, 6) | (GET_BYTE(to_push, 7) << 8); // Check for average front speed in excess of 0.3m/s, 1.08km/h // DBC speed scale 0.0075: 0.3m/s = 144, sum both wheels to compare vehicle_moving = (wheel_speed_fl + wheel_speed_fr) > 288; } // Update driver input torque samples // Signal: LH_EPS_03.EPS_Lenkmoment (absolute torque) // Signal: LH_EPS_03.EPS_VZ_Lenkmoment (direction) if (addr == MSG_LH_EPS_03) { int torque_driver_new = GET_BYTE(to_push, 5) | ((GET_BYTE(to_push, 6) & 0x1F) << 8); int sign = (GET_BYTE(to_push, 6) & 0x80) >> 7; if (sign == 1) { torque_driver_new *= -1; } update_sample(&torque_driver, torque_driver_new); } // Enter controls on rising edge of stock ACC, exit controls if stock ACC disengages // Signal: TSK_06.TSK_Status if (addr == MSG_TSK_06) { int acc_status = (GET_BYTE(to_push, 3) & 0x7); int cruise_engaged = ((acc_status == 3) || (acc_status == 4) || (acc_status == 5)) ? 1 : 0; if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } // Signal: Motor_20.MO_Fahrpedalrohwert_01 if (addr == MSG_MOTOR_20) { gas_pressed = ((GET_BYTES_04(to_push) >> 12) & 0xFF) != 0; } // Signal: ESP_05.ESP_Fahrer_bremst if (addr == MSG_ESP_05) { brake_pressed = (GET_BYTE(to_push, 3) & 0x4) >> 2; } generic_rx_checks((addr == MSG_HCA_01)); } return valid; } static int volkswagen_pq_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { bool valid = addr_safety_check(to_push, &volkswagen_pq_rx_checks, volkswagen_get_checksum, volkswagen_pq_compute_checksum, volkswagen_pq_get_counter); if (valid && (GET_BUS(to_push) == 0)) { int addr = GET_ADDR(to_push); // Update in-motion state by sampling front wheel speeds // Signal: Bremse_3.Radgeschw__VL_4_1 (front left) // Signal: Bremse_3.Radgeschw__VR_4_1 (front right) if (addr == MSG_BREMSE_3) { int wheel_speed_fl = (GET_BYTE(to_push, 0) | (GET_BYTE(to_push, 1) << 8)) >> 1; int wheel_speed_fr = (GET_BYTE(to_push, 2) | (GET_BYTE(to_push, 3) << 8)) >> 1; // Check for average front speed in excess of 0.3m/s, 1.08km/h // DBC speed scale 0.01: 0.3m/s = 108, sum both wheels to compare vehicle_moving = (wheel_speed_fl + wheel_speed_fr) > 216; } // Update driver input torque samples // Signal: Lenkhilfe_3.LH3_LM (absolute torque) // Signal: Lenkhilfe_3.LH3_LMSign (direction) if (addr == MSG_LENKHILFE_3) { int torque_driver_new = GET_BYTE(to_push, 2) | ((GET_BYTE(to_push, 3) & 0x3) << 8); int sign = (GET_BYTE(to_push, 3) & 0x4) >> 2; if (sign == 1) { torque_driver_new *= -1; } update_sample(&torque_driver, torque_driver_new); } // Enter controls on rising edge of stock ACC, exit controls if stock ACC disengages // Signal: Motor_2.GRA_Status if (addr == MSG_MOTOR_2) { int acc_status = (GET_BYTE(to_push, 2) & 0xC0) >> 6; int cruise_engaged = ((acc_status == 1) || (acc_status == 2)) ? 1 : 0; if (cruise_engaged && !cruise_engaged_prev) { controls_allowed = 1; } if (!cruise_engaged) { controls_allowed = 0; } cruise_engaged_prev = cruise_engaged; } // Signal: Motor_3.Fahrpedal_Rohsignal if (addr == MSG_MOTOR_3) { gas_pressed = (GET_BYTE(to_push, 2)); } // Signal: Motor_2.Bremslichtschalter if (addr == MSG_MOTOR_2) { brake_pressed = (GET_BYTE(to_push, 2) & 0x1); } generic_rx_checks((addr == MSG_HCA_1)); } return valid; } static bool volkswagen_steering_check(int desired_torque) { bool violation = false; uint32_t ts = microsecond_timer_get(); if (controls_allowed) { // *** global torque limit check *** violation |= max_limit_check(desired_torque, VOLKSWAGEN_MAX_STEER, -VOLKSWAGEN_MAX_STEER); // *** torque rate limit check *** violation |= driver_limit_check(desired_torque, desired_torque_last, &torque_driver, VOLKSWAGEN_MAX_STEER, VOLKSWAGEN_MAX_RATE_UP, VOLKSWAGEN_MAX_RATE_DOWN, VOLKSWAGEN_DRIVER_TORQUE_ALLOWANCE, VOLKSWAGEN_DRIVER_TORQUE_FACTOR); desired_torque_last = desired_torque; // *** torque real time rate limit check *** violation |= rt_rate_limit_check(desired_torque, rt_torque_last, VOLKSWAGEN_MAX_RT_DELTA); // every RT_INTERVAL set the new limits uint32_t ts_elapsed = get_ts_elapsed(ts, ts_last); if (ts_elapsed > VOLKSWAGEN_RT_INTERVAL) { rt_torque_last = desired_torque; ts_last = ts; } } // no torque if controls is not allowed if (!controls_allowed && (desired_torque != 0)) { violation = true; } // reset to 0 if either controls is not allowed or there's a violation if (violation || !controls_allowed) { desired_torque_last = 0; rt_torque_last = 0; ts_last = ts; } return violation; } static int volkswagen_mqb_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int addr = GET_ADDR(to_send); int tx = 1; if (!msg_allowed(to_send, VOLKSWAGEN_MQB_TX_MSGS, VOLKSWAGEN_MQB_TX_MSGS_LEN) || relay_malfunction) { tx = 0; } // Safety check for HCA_01 Heading Control Assist torque // Signal: HCA_01.Assist_Torque (absolute torque) // Signal: HCA_01.Assist_VZ (direction) if (addr == MSG_HCA_01) { int desired_torque = GET_BYTE(to_send, 2) | ((GET_BYTE(to_send, 3) & 0x3F) << 8); int sign = (GET_BYTE(to_send, 3) & 0x80) >> 7; if (sign == 1) { desired_torque *= -1; } if (volkswagen_steering_check(desired_torque)) { tx = 0; } } // FORCE CANCEL: ensuring that only the cancel button press is sent when controls are off. // This avoids unintended engagements while still allowing resume spam if ((addr == MSG_GRA_ACC_01) && !controls_allowed) { // disallow resume and set: bits 16 and 19 if ((GET_BYTE(to_send, 2) & 0x9) != 0) { tx = 0; } } // 1 allows the message through return tx; } static int volkswagen_pq_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { int addr = GET_ADDR(to_send); int tx = 1; if (!msg_allowed(to_send, VOLKSWAGEN_PQ_TX_MSGS, VOLKSWAGEN_PQ_TX_MSGS_LEN) || relay_malfunction) { tx = 0; } // Safety check for HCA_1 Heading Control Assist torque // Signal: HCA_1.LM_Offset (absolute torque) // Signal: HCA_1.LM_Offsign (direction) if (addr == MSG_HCA_1) { int desired_torque = GET_BYTE(to_send, 2) | ((GET_BYTE(to_send, 3) & 0x7F) << 8); desired_torque = desired_torque / 32; // DBC scale from PQ network to centi-Nm int sign = (GET_BYTE(to_send, 3) & 0x80) >> 7; if (sign == 1) { desired_torque *= -1; } if (volkswagen_steering_check(desired_torque)) { tx = 0; } } // FORCE CANCEL: ensuring that only the cancel button press is sent when controls are off. // This avoids unintended engagements while still allowing resume spam if ((addr == MSG_GRA_NEU) && !controls_allowed) { // disallow resume and set: bits 16 and 17 if ((GET_BYTE(to_send, 2) & 0x3) != 0) { tx = 0; } } // 1 allows the message through return tx; } static int volkswagen_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { int addr = GET_ADDR(to_fwd); int bus_fwd = -1; if (!relay_malfunction) { switch (bus_num) { case 0: // Forward all traffic from the Extended CAN onward bus_fwd = 2; break; case 2: if ((addr == volkswagen_torque_msg) || (addr == volkswagen_lane_msg)) { // OP takes control of the Heading Control Assist and Lane Departure Warning messages from the camera bus_fwd = -1; } else { // Forward all remaining traffic from Extended CAN devices to J533 gateway bus_fwd = 0; } break; default: // No other buses should be in use; fallback to do-not-forward bus_fwd = -1; break; } } return bus_fwd; } // Volkswagen MQB platform const safety_hooks volkswagen_mqb_hooks = { .init = volkswagen_mqb_init, .rx = volkswagen_mqb_rx_hook, .tx = volkswagen_mqb_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = volkswagen_fwd_hook, }; // Volkswagen PQ35/PQ46/NMS platforms const safety_hooks volkswagen_pq_hooks = { .init = volkswagen_pq_init, .rx = volkswagen_pq_rx_hook, .tx = volkswagen_pq_tx_hook, .tx_lin = nooutput_tx_lin_hook, .fwd = volkswagen_fwd_hook, }; ================================================ FILE: panda/board/safety.h ================================================ // include first, needed by safety policies #include "safety_declarations.h" // Include the actual safety policies. #include "safety/safety_defaults.h" #include "safety/safety_honda.h" #include "safety/safety_toyota.h" #include "safety/safety_tesla.h" #include "safety/safety_gm_ascm.h" #include "safety/safety_gm.h" #include "safety/safety_ford.h" #include "safety/safety_hyundai.h" #include "safety/safety_chrysler.h" #include "safety/safety_subaru.h" #include "safety/safety_mazda.h" #include "safety/safety_nissan.h" #include "safety/safety_volkswagen.h" #include "safety/safety_elm327.h" // from cereal.car.CarParams.SafetyModel #define SAFETY_SILENT 0U #define SAFETY_HONDA_NIDEC 1U #define SAFETY_TOYOTA 2U #define SAFETY_ELM327 3U #define SAFETY_GM 4U #define SAFETY_HONDA_BOSCH_GIRAFFE 5U #define SAFETY_FORD 6U #define SAFETY_HYUNDAI 8U #define SAFETY_CHRYSLER 9U #define SAFETY_TESLA 10U #define SAFETY_SUBARU 11U #define SAFETY_MAZDA 13U #define SAFETY_NISSAN 14U #define SAFETY_VOLKSWAGEN_MQB 15U #define SAFETY_ALLOUTPUT 17U #define SAFETY_GM_ASCM 18U #define SAFETY_NOOUTPUT 19U #define SAFETY_HONDA_BOSCH_HARNESS 20U #define SAFETY_VOLKSWAGEN_PQ 21U #define SAFETY_SUBARU_LEGACY 22U #define SAFETY_HYUNDAI_LEGACY 23U #define SAFETY_HYUNDAI_COMMUNITY 24U uint16_t current_safety_mode = SAFETY_SILENT; int16_t current_safety_param = 0; const safety_hooks *current_hooks = &nooutput_hooks; const addr_checks *current_rx_checks = &default_rx_checks; int safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { return current_hooks->rx(to_push); } int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { return current_hooks->tx(to_send); } int safety_tx_lin_hook(int lin_num, uint8_t *data, int len) { return current_hooks->tx_lin(lin_num, data, len); } int safety_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { return current_hooks->fwd(bus_num, to_fwd); } // Given a CRC-8 poly, generate a static lookup table to use with a fast CRC-8 // algorithm. Called at init time for safety modes using CRC-8. void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]) { for (int i = 0; i < 256; i++) { uint8_t crc = i; for (int j = 0; j < 8; j++) { if ((crc & 0x80U) != 0U) crc = (uint8_t)((crc << 1) ^ poly); else crc <<= 1; } crc_lut[i] = crc; } } bool msg_allowed(CAN_FIFOMailBox_TypeDef *to_send, const CanMsg msg_list[], int len) { int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); int length = GET_LEN(to_send); bool allowed = false; for (int i = 0; i < len; i++) { if ((addr == msg_list[i].addr) && (bus == msg_list[i].bus) && (length == msg_list[i].len)) { allowed = true; break; } } return allowed; } // compute the time elapsed (in microseconds) from 2 counter samples // case where ts < ts_last is ok: overflow is properly re-casted into uint32_t uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) { return ts - ts_last; } int get_addr_check_index(CAN_FIFOMailBox_TypeDef *to_push, AddrCheckStruct addr_list[], const int len) { int bus = GET_BUS(to_push); int addr = GET_ADDR(to_push); int length = GET_LEN(to_push); int index = -1; for (int i = 0; i < len; i++) { // if multiple msgs are allowed, determine which one is present on the bus if (!addr_list[i].msg_seen) { for (uint8_t j = 0U; addr_list[i].msg[j].addr != 0; j++) { if ((addr == addr_list[i].msg[j].addr) && (bus == addr_list[i].msg[j].bus) && (length == addr_list[i].msg[j].len)) { addr_list[i].index = j; addr_list[i].msg_seen = true; break; } } } int idx = addr_list[i].index; if ((addr == addr_list[i].msg[idx].addr) && (bus == addr_list[i].msg[idx].bus) && (length == addr_list[i].msg[idx].len)) { index = i; break; } } return index; } // 1Hz safety function called by main. Now just a check for lagging safety messages void safety_tick(const addr_checks *rx_checks) { uint32_t ts = microsecond_timer_get(); if (rx_checks != NULL) { for (int i=0; i < rx_checks->len; i++) { uint32_t elapsed_time = get_ts_elapsed(ts, rx_checks->check[i].last_timestamp); // lag threshold is max of: 1s and MAX_MISSED_MSGS * expected timestep. // Quite conservative to not risk false triggers. // 2s of lag is worse case, since the function is called at 1Hz bool lagging = elapsed_time > MAX(rx_checks->check[i].msg[rx_checks->check[i].index].expected_timestep * MAX_MISSED_MSGS, 1e6); rx_checks->check[i].lagging = lagging; if (lagging) { controls_allowed = 0; } } } } void update_counter(AddrCheckStruct addr_list[], int index, uint8_t counter) { if (index != -1) { uint8_t expected_counter = (addr_list[index].last_counter + 1U) % (addr_list[index].msg[addr_list[index].index].max_counter + 1U); addr_list[index].wrong_counters += (expected_counter == counter) ? -1 : 1; addr_list[index].wrong_counters = MAX(MIN(addr_list[index].wrong_counters, MAX_WRONG_COUNTERS), 0); addr_list[index].last_counter = counter; } } bool is_msg_valid(AddrCheckStruct addr_list[], int index) { bool valid = true; if (index != -1) { if ((!addr_list[index].valid_checksum) || (addr_list[index].wrong_counters >= MAX_WRONG_COUNTERS)) { valid = false; controls_allowed = 0; } } return valid; } void update_addr_timestamp(AddrCheckStruct addr_list[], int index) { if (index != -1) { uint32_t ts = microsecond_timer_get(); addr_list[index].last_timestamp = ts; } } bool addr_safety_check(CAN_FIFOMailBox_TypeDef *to_push, const addr_checks *rx_checks, uint8_t (*get_checksum)(CAN_FIFOMailBox_TypeDef *to_push), uint8_t (*compute_checksum)(CAN_FIFOMailBox_TypeDef *to_push), uint8_t (*get_counter)(CAN_FIFOMailBox_TypeDef *to_push)) { int index = get_addr_check_index(to_push, rx_checks->check, rx_checks->len); update_addr_timestamp(rx_checks->check, index); if (index != -1) { // checksum check if ((get_checksum != NULL) && (compute_checksum != NULL) && rx_checks->check[index].msg[rx_checks->check[index].index].check_checksum) { uint8_t checksum = get_checksum(to_push); uint8_t checksum_comp = compute_checksum(to_push); rx_checks->check[index].valid_checksum = checksum_comp == checksum; } else { rx_checks->check[index].valid_checksum = true; } // counter check (max_counter == 0 means skip check) if ((get_counter != NULL) && (rx_checks->check[index].msg[rx_checks->check[index].index].max_counter > 0U)) { uint8_t counter = get_counter(to_push); update_counter(rx_checks->check, index, counter); } else { rx_checks->check[index].wrong_counters = 0U; } } return is_msg_valid(rx_checks->check, index); } void generic_rx_checks(bool stock_ecu_detected) { // exit controls on rising edge of gas press if (gas_pressed && !gas_pressed_prev && !(unsafe_mode & UNSAFE_DISABLE_DISENGAGE_ON_GAS)) { controls_allowed = 0; } gas_pressed_prev = gas_pressed; // exit controls on rising edge of brake press if (brake_pressed && (!brake_pressed_prev || vehicle_moving)) { controls_allowed = 0; } brake_pressed_prev = brake_pressed; // check if stock ECU is on bus broken by car harness if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && stock_ecu_detected) { relay_malfunction_set(); } } void relay_malfunction_set(void) { relay_malfunction = true; fault_occurred(FAULT_RELAY_MALFUNCTION); } void relay_malfunction_reset(void) { relay_malfunction = false; fault_recovered(FAULT_RELAY_MALFUNCTION); } typedef struct { uint16_t id; const safety_hooks *hooks; } safety_hook_config; const safety_hook_config safety_hook_registry[] = { {SAFETY_SILENT, &nooutput_hooks}, {SAFETY_HONDA_NIDEC, &honda_nidec_hooks}, {SAFETY_TOYOTA, &toyota_hooks}, {SAFETY_ELM327, &elm327_hooks}, {SAFETY_GM, &gm_hooks}, {SAFETY_HONDA_BOSCH_GIRAFFE, &honda_bosch_giraffe_hooks}, {SAFETY_HONDA_BOSCH_HARNESS, &honda_bosch_harness_hooks}, {SAFETY_HYUNDAI, &hyundai_hooks}, {SAFETY_CHRYSLER, &chrysler_hooks}, {SAFETY_SUBARU, &subaru_hooks}, {SAFETY_VOLKSWAGEN_MQB, &volkswagen_mqb_hooks}, {SAFETY_NISSAN, &nissan_hooks}, {SAFETY_NOOUTPUT, &nooutput_hooks}, {SAFETY_HYUNDAI_LEGACY, &hyundai_legacy_hooks}, #ifdef ALLOW_DEBUG {SAFETY_TESLA, &tesla_hooks}, {SAFETY_MAZDA, &mazda_hooks}, {SAFETY_SUBARU_LEGACY, &subaru_legacy_hooks}, {SAFETY_VOLKSWAGEN_PQ, &volkswagen_pq_hooks}, {SAFETY_ALLOUTPUT, &alloutput_hooks}, {SAFETY_GM_ASCM, &gm_ascm_hooks}, {SAFETY_FORD, &ford_hooks}, #endif }; int set_safety_hooks(uint16_t mode, int16_t param) { // reset state set by safety mode safety_mode_cnt = 0U; relay_malfunction = false; gas_interceptor_detected = false; gas_interceptor_prev = 0; gas_pressed = false; gas_pressed_prev = false; brake_pressed = false; brake_pressed_prev = false; cruise_engaged_prev = false; vehicle_speed = 0; vehicle_moving = false; desired_torque_last = 0; rt_torque_last = 0; ts_angle_last = 0; desired_angle_last = 0; ts_last = 0; torque_meas.max = 0; torque_meas.max = 0; torque_driver.min = 0; torque_driver.max = 0; angle_meas.min = 0; angle_meas.max = 0; int set_status = -1; // not set int hook_config_count = sizeof(safety_hook_registry) / sizeof(safety_hook_config); for (int i = 0; i < hook_config_count; i++) { if (safety_hook_registry[i].id == mode) { current_hooks = safety_hook_registry[i].hooks; current_safety_mode = mode; current_safety_param = param; set_status = 0; // set } } if ((set_status == 0) && (current_hooks->init != NULL)) { current_rx_checks = current_hooks->init(param); // reset message index and seen flags in addr struct for (int j = 0; j < current_rx_checks->len; j++) { current_rx_checks->check[j].index = 0; current_rx_checks->check[j].msg_seen = false; } } return set_status; } // convert a trimmed integer to signed 32 bit int int to_signed(int d, int bits) { int d_signed = d; if (d >= (1 << MAX((bits - 1), 0))) { d_signed = d - (1 << MAX(bits, 0)); } return d_signed; } // given a new sample, update the smaple_t struct void update_sample(struct sample_t *sample, int sample_new) { int sample_size = sizeof(sample->values) / sizeof(sample->values[0]); for (int i = sample_size - 1; i > 0; i--) { sample->values[i] = sample->values[i-1]; } sample->values[0] = sample_new; // get the minimum and maximum measured samples sample->min = sample->values[0]; sample->max = sample->values[0]; for (int i = 1; i < sample_size; i++) { if (sample->values[i] < sample->min) { sample->min = sample->values[i]; } if (sample->values[i] > sample->max) { sample->max = sample->values[i]; } } } bool max_limit_check(int val, const int MAX_VAL, const int MIN_VAL) { return (val > MAX_VAL) || (val < MIN_VAL); } // check that commanded value isn't too far from measured bool dist_to_meas_check(int val, int val_last, struct sample_t *val_meas, const int MAX_RATE_UP, const int MAX_RATE_DOWN, const int MAX_ERROR) { // *** val rate limit check *** int highest_allowed_rl = MAX(val_last, 0) + MAX_RATE_UP; int lowest_allowed_rl = MIN(val_last, 0) - MAX_RATE_UP; // if we've exceeded the meas val, we must start moving toward 0 int highest_allowed = MIN(highest_allowed_rl, MAX(val_last - MAX_RATE_DOWN, MAX(val_meas->max, 0) + MAX_ERROR)); int lowest_allowed = MAX(lowest_allowed_rl, MIN(val_last + MAX_RATE_DOWN, MIN(val_meas->min, 0) - MAX_ERROR)); // check for violation return (val < lowest_allowed) || (val > highest_allowed); } // check that commanded value isn't fighting against driver bool driver_limit_check(int val, int val_last, struct sample_t *val_driver, const int MAX_VAL, const int MAX_RATE_UP, const int MAX_RATE_DOWN, const int MAX_ALLOWANCE, const int DRIVER_FACTOR) { int highest_allowed_rl = MAX(val_last, 0) + MAX_RATE_UP; int lowest_allowed_rl = MIN(val_last, 0) - MAX_RATE_UP; int driver_max_limit = MAX_VAL + (MAX_ALLOWANCE + val_driver->max) * DRIVER_FACTOR; int driver_min_limit = -MAX_VAL + (-MAX_ALLOWANCE + val_driver->min) * DRIVER_FACTOR; // if we've exceeded the applied torque, we must start moving toward 0 int highest_allowed = MIN(highest_allowed_rl, MAX(val_last - MAX_RATE_DOWN, MAX(driver_max_limit, 0))); int lowest_allowed = MAX(lowest_allowed_rl, MIN(val_last + MAX_RATE_DOWN, MIN(driver_min_limit, 0))); // check for violation return (val < lowest_allowed) || (val > highest_allowed); } // real time check, mainly used for steer torque rate limiter bool rt_rate_limit_check(int val, int val_last, const int MAX_RT_DELTA) { // *** torque real time rate limit check *** int highest_val = MAX(val_last, 0) + MAX_RT_DELTA; int lowest_val = MIN(val_last, 0) - MAX_RT_DELTA; // check for violation return (val < lowest_val) || (val > highest_val); } // interp function that holds extreme values float interpolate(struct lookup_t xy, float x) { int size = sizeof(xy.x) / sizeof(xy.x[0]); float ret = xy.y[size - 1]; // default output is last point // x is lower than the first point in the x array. Return the first point if (x <= xy.x[0]) { ret = xy.y[0]; } else { // find the index such that (xy.x[i] <= x < xy.x[i+1]) and linearly interp for (int i=0; i < (size - 1); i++) { if (x < xy.x[i+1]) { float x0 = xy.x[i]; float y0 = xy.y[i]; float dx = xy.x[i+1] - x0; float dy = xy.y[i+1] - y0; // dx should not be zero as xy.x is supposed to be monotonic if (dx <= 0.) { dx = 0.0001; } ret = (dy * (x - x0) / dx) + y0; break; } } } return ret; } ================================================ FILE: panda/board/safety_declarations.h ================================================ const int MAX_WRONG_COUNTERS = 5; const uint8_t MAX_MISSED_MSGS = 10U; // sample struct that keeps 3 samples in memory struct sample_t { int values[6]; int min; int max; } sample_t_default = {.values = {0}, .min = 0, .max = 0}; // safety code requires floats struct lookup_t { float x[3]; float y[3]; }; typedef struct { int addr; int bus; int len; } CanMsg; typedef struct { const int addr; const int bus; const int len; const bool check_checksum; // true is checksum check is performed const uint8_t max_counter; // maximum value of the counter. 0 means that the counter check is skipped const uint32_t expected_timestep; // expected time between message updates [us] } CanMsgCheck; // params and flags about checksum, counter and frequency checks for each monitored address typedef struct { // const params const CanMsgCheck msg[3]; // check either messages (e.g. honda steer). Array MUST terminate with an empty struct to know its length. // dynamic flags bool msg_seen; int index; // if multiple messages are allowed to be checked, this stores the index of the first one seen. only msg[msg_index] will be used bool valid_checksum; // true if and only if checksum check is passed int wrong_counters; // counter of wrong counters, saturated between 0 and MAX_WRONG_COUNTERS uint8_t last_counter; // last counter value uint32_t last_timestamp; // micro-s bool lagging; // true if and only if the time between updates is excessive } AddrCheckStruct; typedef struct { AddrCheckStruct *check; int len; } addr_checks; int safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push); int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send); int safety_tx_lin_hook(int lin_num, uint8_t *data, int len); uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last); int to_signed(int d, int bits); void update_sample(struct sample_t *sample, int sample_new); bool max_limit_check(int val, const int MAX, const int MIN); bool dist_to_meas_check(int val, int val_last, struct sample_t *val_meas, const int MAX_RATE_UP, const int MAX_RATE_DOWN, const int MAX_ERROR); bool driver_limit_check(int val, int val_last, struct sample_t *val_driver, const int MAX, const int MAX_RATE_UP, const int MAX_RATE_DOWN, const int MAX_ALLOWANCE, const int DRIVER_FACTOR); bool rt_rate_limit_check(int val, int val_last, const int MAX_RT_DELTA); float interpolate(struct lookup_t xy, float x); void gen_crc_lookup_table(uint8_t poly, uint8_t crc_lut[]); bool msg_allowed(CAN_FIFOMailBox_TypeDef *to_send, const CanMsg msg_list[], int len); int get_addr_check_index(CAN_FIFOMailBox_TypeDef *to_push, AddrCheckStruct addr_list[], const int len); void update_counter(AddrCheckStruct addr_list[], int index, uint8_t counter); void update_addr_timestamp(AddrCheckStruct addr_list[], int index); bool is_msg_valid(AddrCheckStruct addr_list[], int index); bool addr_safety_check(CAN_FIFOMailBox_TypeDef *to_push, const addr_checks *rx_checks, uint8_t (*get_checksum)(CAN_FIFOMailBox_TypeDef *to_push), uint8_t (*compute_checksum)(CAN_FIFOMailBox_TypeDef *to_push), uint8_t (*get_counter)(CAN_FIFOMailBox_TypeDef *to_push)); void generic_rx_checks(bool stock_ecu_detected); void relay_malfunction_set(void); void relay_malfunction_reset(void); typedef const addr_checks* (*safety_hook_init)(int16_t param); typedef int (*rx_hook)(CAN_FIFOMailBox_TypeDef *to_push); typedef int (*tx_hook)(CAN_FIFOMailBox_TypeDef *to_send); typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len); typedef int (*fwd_hook)(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd); typedef struct { safety_hook_init init; rx_hook rx; tx_hook tx; tx_lin_hook tx_lin; fwd_hook fwd; } safety_hooks; void safety_tick(const addr_checks *addr_checks); // This can be set by the safety hooks bool controls_allowed = false; bool relay_malfunction = false; bool gas_interceptor_detected = false; int gas_interceptor_prev = 0; bool gas_pressed = false; bool gas_pressed_prev = false; bool brake_pressed = false; bool brake_pressed_prev = false; bool cruise_engaged_prev = false; float vehicle_speed = 0; bool vehicle_moving = false; // for safety modes with torque steering control int desired_torque_last = 0; // last desired steer torque int rt_torque_last = 0; // last desired torque for real time check struct sample_t torque_meas; // last 3 motor torques produced by the eps struct sample_t torque_driver; // last 3 driver torques measured uint32_t ts_last = 0; // for safety modes with angle steering control uint32_t ts_angle_last = 0; int desired_angle_last = 0; struct sample_t angle_meas; // last 3 steer angles // This can be set with a USB command // It enables features we consider to be unsafe, but understand others may have different opinions // It is always 0 on mainline comma.ai openpilot // If using this flag, be very careful about what happens if your fork wants to brake while the // user is pressing the gas. Tesla is careful with this. #define UNSAFE_DISABLE_DISENGAGE_ON_GAS 1 // If using this flag, make sure to communicate to your users that a stock safety feature is now disabled. #define UNSAFE_DISABLE_STOCK_AEB 2 // If using this flag, be aware that harder braking is more likely to lead to rear endings, // and that alone this flag doesn't make braking compliant because there's also a time element. // Setting this flag is used for allowing the full -5.0 to +4.0 m/s^2 at lower speeds // See ISO 15622:2018 for more information. #define UNSAFE_RAISE_LONGITUDINAL_LIMITS_TO_ISO_MAX 8 int unsafe_mode = 0; // time since safety mode has been changed uint32_t safety_mode_cnt = 0U; // allow 1s of transition timeout after relay changes state before assessing malfunctioning const uint32_t RELAY_TRNS_TIMEOUT = 1U; ================================================ FILE: panda/board/stm32fx/board.h ================================================ // ///////////////////////////////////////////////////////////// // // Hardware abstraction layer for all different supported boards // // ///////////////////////////////////////////////////////////// // #include "boards/board_declarations.h" #include "boards/unused_funcs.h" // ///// Board definition and detection ///// // #include "drivers/harness.h" #ifdef PANDA #include "drivers/fan.h" #include "stm32fx/llfan.h" #include "stm32fx/llrtc.h" #include "drivers/rtc.h" #include "stm32fx/clock_source.h" #include "boards/white.h" #include "boards/grey.h" #include "boards/black.h" #include "boards/uno.h" #include "boards/dos.h" #else #include "boards/pedal.h" #endif void detect_board_type(void) { #ifdef PANDA // SPI lines floating: white (TODO: is this reliable? Not really, we have to enable ESP/GPS to be able to detect this on the UART) set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); if(!detect_with_pull(GPIOB, 1, PULL_UP) && !detect_with_pull(GPIOB, 7, PULL_UP)){ hw_type = HW_TYPE_DOS; current_board = &board_dos; } else if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){ hw_type = HW_TYPE_WHITE_PANDA; current_board = &board_white; } else if(detect_with_pull(GPIOA, 13, PULL_DOWN)) { // Rev AB deprecated, so no pullup means black. In REV C, A13 is pulled up to 5V with a 10K hw_type = HW_TYPE_GREY_PANDA; current_board = &board_grey; } else if(!detect_with_pull(GPIOB, 15, PULL_UP)) { hw_type = HW_TYPE_UNO; current_board = &board_uno; } else { hw_type = HW_TYPE_BLACK_PANDA; current_board = &board_black; } #else #ifdef PEDAL hw_type = HW_TYPE_PEDAL; current_board = &board_pedal; #else hw_type = HW_TYPE_UNKNOWN; puts("Hardware type is UNKNOWN!\n"); #endif #endif } bool has_external_debug_serial = 0; void detect_external_debug_serial(void) { // detect if external serial debugging is present has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN); } ================================================ FILE: panda/board/stm32fx/clock.h ================================================ void clock_init(void) { // enable external oscillator register_set_bits(&(RCC->CR), RCC_CR_HSEON); while ((RCC->CR & RCC_CR_HSERDY) == 0); // divide things register_set(&(RCC->CFGR), RCC_CFGR_HPRE_DIV1 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_PPRE1_DIV4, 0xFF7FFCF3U); // 16mhz crystal register_set(&(RCC->PLLCFGR), RCC_PLLCFGR_PLLQ_2 | RCC_PLLCFGR_PLLM_3 | RCC_PLLCFGR_PLLN_6 | RCC_PLLCFGR_PLLN_5 | RCC_PLLCFGR_PLLSRC_HSE, 0x7F437FFFU); // start PLL register_set_bits(&(RCC->CR), RCC_CR_PLLON); while ((RCC->CR & RCC_CR_PLLRDY) == 0); // Configure Flash prefetch, Instruction cache, Data cache and wait state // *** without this, it breaks *** register_set(&(FLASH->ACR), FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_5WS, 0x1F0FU); // switch to PLL register_set_bits(&(RCC->CFGR), RCC_CFGR_SW_PLL); while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // *** running on PLL *** } void watchdog_init(void) { // setup watchdog IWDG->KR = 0x5555U; register_set(&(IWDG->PR), 0x0U, 0x7U); // divider/4 // 0 = 0.125 ms, let's have a 50ms watchdog register_set(&(IWDG->RLR), (400U-1U), 0xFFFU); IWDG->KR = 0xCCCCU; } void watchdog_feed(void) { IWDG->KR = 0xAAAAU; } ================================================ FILE: panda/board/stm32fx/clock_source.h ================================================ #define CLOCK_SOURCE_MODE_DISABLED 0U #define CLOCK_SOURCE_MODE_FREE_RUNNING 1U #define CLOCK_SOURCE_MODE_EXTERNAL_SYNC 2U #define CLOCK_SOURCE_PERIOD_MS 50U #define CLOCK_SOURCE_PULSE_LEN_MS 2U uint8_t clock_source_mode = CLOCK_SOURCE_MODE_DISABLED; void EXTI0_IRQ_Handler(void) { volatile unsigned int pr = EXTI->PR & (1U << 0); if (pr != 0U) { if(clock_source_mode == CLOCK_SOURCE_MODE_EXTERNAL_SYNC){ // TODO: Implement! } } EXTI->PR = (1U << 0); } void TIM1_UP_TIM10_IRQ_Handler(void) { if((TIM1->SR & TIM_SR_UIF) != 0) { if(clock_source_mode != CLOCK_SOURCE_MODE_DISABLED) { // Start clock pulse set_gpio_output(GPIOB, 14, true); set_gpio_output(GPIOB, 15, true); set_gpio_output(GPIOC, 5, true); } // Reset interrupt TIM1->SR &= ~(TIM_SR_UIF); } } void TIM1_CC_IRQ_Handler(void) { if((TIM1->SR & TIM_SR_CC1IF) != 0) { if(clock_source_mode != CLOCK_SOURCE_MODE_DISABLED) { // End clock pulse set_gpio_output(GPIOB, 14, false); set_gpio_output(GPIOB, 15, false); set_gpio_output(GPIOC, 5, false); } // Reset interrupt TIM1->SR &= ~(TIM_SR_CC1IF); } } void clock_source_init(uint8_t mode){ // Setup external clock signal interrupt REGISTER_INTERRUPT(EXTI0_IRQn, EXTI0_IRQ_Handler, 110U, FAULT_INTERRUPT_RATE_CLOCK_SOURCE) register_set(&(SYSCFG->EXTICR[0]), SYSCFG_EXTICR1_EXTI0_PB, 0xFU); register_set_bits(&(EXTI->IMR), (1U << 0)); register_set_bits(&(EXTI->RTSR), (1U << 0)); register_clear_bits(&(EXTI->FTSR), (1U << 0)); // Setup timer REGISTER_INTERRUPT(TIM1_UP_TIM10_IRQn, TIM1_UP_TIM10_IRQ_Handler, (1200U / CLOCK_SOURCE_PERIOD_MS) , FAULT_INTERRUPT_RATE_TIM1) REGISTER_INTERRUPT(TIM1_CC_IRQn, TIM1_CC_IRQ_Handler, (1200U / CLOCK_SOURCE_PERIOD_MS) , FAULT_INTERRUPT_RATE_TIM1) register_set(&(TIM1->PSC), ((APB2_FREQ*100U)-1U), 0xFFFFU); // Tick on 0.1 ms register_set(&(TIM1->ARR), ((CLOCK_SOURCE_PERIOD_MS*10U) - 1U), 0xFFFFU); // Period register_set(&(TIM1->CCMR1), 0U, 0xFFFFU); // No output on compare register_set_bits(&(TIM1->CCER), TIM_CCER_CC1E); // Enable compare 1 register_set(&(TIM1->CCR1), (CLOCK_SOURCE_PULSE_LEN_MS*10U), 0xFFFFU); // Compare 1 value register_set_bits(&(TIM1->DIER), TIM_DIER_UIE | TIM_DIER_CC1IE); // Enable interrupts register_set(&(TIM1->CR1), TIM_CR1_CEN, 0x3FU); // Enable timer // Set mode switch(mode) { case CLOCK_SOURCE_MODE_DISABLED: // No clock signal NVIC_DisableIRQ(EXTI0_IRQn); NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn); NVIC_DisableIRQ(TIM1_CC_IRQn); // Disable pulse if we were in the middle of it set_gpio_output(GPIOB, 14, false); set_gpio_output(GPIOB, 15, false); clock_source_mode = CLOCK_SOURCE_MODE_DISABLED; break; case CLOCK_SOURCE_MODE_FREE_RUNNING: // Clock signal is based on internal timer NVIC_DisableIRQ(EXTI0_IRQn); NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); NVIC_EnableIRQ(TIM1_CC_IRQn); clock_source_mode = CLOCK_SOURCE_MODE_FREE_RUNNING; break; case CLOCK_SOURCE_MODE_EXTERNAL_SYNC: // Clock signal is based on external timer NVIC_EnableIRQ(EXTI0_IRQn); NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn); NVIC_EnableIRQ(TIM1_CC_IRQn); clock_source_mode = CLOCK_SOURCE_MODE_EXTERNAL_SYNC; break; default: puts("Unknown clock source mode: "); puth(mode); puts("\n"); break; } } ================================================ FILE: panda/board/stm32fx/inc/cmsis_compiler.h ================================================ /**************************************************************************//** * @file cmsis_compiler.h * @brief CMSIS compiler generic header file * @version V5.1.0 * @date 09. October 2018 ******************************************************************************/ /* * Copyright (c) 2009-2018 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CMSIS_COMPILER_H #define __CMSIS_COMPILER_H #include /* * Arm Compiler 4/5 */ #if defined ( __CC_ARM ) #include "cmsis_armcc.h" /* * Arm Compiler 6.6 LTM (armclang) */ #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) #include "cmsis_armclang_ltm.h" /* * Arm Compiler above 6.10.1 (armclang) */ #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) #include "cmsis_armclang.h" /* * GNU Compiler */ #elif defined ( __GNUC__ ) #include "cmsis_gcc.h" /* * IAR Compiler */ #elif defined ( __ICCARM__ ) #include /* * TI Arm Compiler */ #elif defined ( __TI_ARM__ ) #include #ifndef __ASM #define __ASM __asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __STATIC_INLINE #endif #ifndef __NO_RETURN #define __NO_RETURN __attribute__((noreturn)) #endif #ifndef __USED #define __USED __attribute__((used)) #endif #ifndef __WEAK #define __WEAK __attribute__((weak)) #endif #ifndef __PACKED #define __PACKED __attribute__((packed)) #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT struct __attribute__((packed)) #endif #ifndef __PACKED_UNION #define __PACKED_UNION union __attribute__((packed)) #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ struct __attribute__((packed)) T_UINT32 { uint32_t v; }; #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #define __ALIGNED(x) __attribute__((aligned(x))) #endif #ifndef __RESTRICT #define __RESTRICT __restrict #endif #ifndef __COMPILER_BARRIER #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. #define __COMPILER_BARRIER() (void)0 #endif /* * TASKING Compiler */ #elif defined ( __TASKING__ ) /* * The CMSIS functions have been implemented as intrinsics in the compiler. * Please use "carm -?i" to get an up to date list of all intrinsics, * Including the CMSIS ones. */ #ifndef __ASM #define __ASM __asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __STATIC_INLINE #endif #ifndef __NO_RETURN #define __NO_RETURN __attribute__((noreturn)) #endif #ifndef __USED #define __USED __attribute__((used)) #endif #ifndef __WEAK #define __WEAK __attribute__((weak)) #endif #ifndef __PACKED #define __PACKED __packed__ #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT struct __packed__ #endif #ifndef __PACKED_UNION #define __PACKED_UNION union __packed__ #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ struct __packed__ T_UINT32 { uint32_t v; }; #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #define __ALIGNED(x) __align(x) #endif #ifndef __RESTRICT #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. #define __RESTRICT #endif #ifndef __COMPILER_BARRIER #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. #define __COMPILER_BARRIER() (void)0 #endif /* * COSMIC Compiler */ #elif defined ( __CSMC__ ) #include #ifndef __ASM #define __ASM _asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __STATIC_INLINE #endif #ifndef __NO_RETURN // NO RETURN is automatically detected hence no warning here #define __NO_RETURN #endif #ifndef __USED #warning No compiler specific solution for __USED. __USED is ignored. #define __USED #endif #ifndef __WEAK #define __WEAK __weak #endif #ifndef __PACKED #define __PACKED @packed #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT @packed struct #endif #ifndef __PACKED_UNION #define __PACKED_UNION @packed union #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ @packed struct T_UINT32 { uint32_t v; }; #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. #define __ALIGNED(x) #endif #ifndef __RESTRICT #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. #define __RESTRICT #endif #ifndef __COMPILER_BARRIER #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. #define __COMPILER_BARRIER() (void)0 #endif #else #error Unknown compiler. #endif #endif /* __CMSIS_COMPILER_H */ ================================================ FILE: panda/board/stm32fx/inc/cmsis_gcc.h ================================================ /**************************************************************************//** * @file cmsis_gcc.h * @brief CMSIS compiler GCC header file * @version V5.2.0 * @date 08. May 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CMSIS_GCC_H #define __CMSIS_GCC_H /* ignore some GCC warnings */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wunused-parameter" /* Fallback for __has_builtin */ #ifndef __has_builtin #define __has_builtin(x) (0) #endif /* CMSIS compiler specific defines */ #ifndef __ASM #define __ASM __asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline #endif #ifndef __NO_RETURN #define __NO_RETURN __attribute__((__noreturn__)) #endif #ifndef __USED #define __USED __attribute__((used)) #endif #ifndef __WEAK #define __WEAK __attribute__((weak)) #endif #ifndef __PACKED #define __PACKED __attribute__((packed, aligned(1))) #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) #endif #ifndef __PACKED_UNION #define __PACKED_UNION union __attribute__((packed, aligned(1))) #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" struct __attribute__((packed)) T_UINT32 { uint32_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #define __ALIGNED(x) __attribute__((aligned(x))) #endif #ifndef __RESTRICT #define __RESTRICT __restrict #endif #ifndef __COMPILER_BARRIER #define __COMPILER_BARRIER() __ASM volatile("":::"memory") #endif /* ######################### Startup and Lowlevel Init ######################## */ #ifndef __PROGRAM_START /** \brief Initializes data and bss sections \details This default implementations initialized all data and additional bss sections relying on .copy.table and .zero.table specified properly in the used linker script. */ __STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) { extern void _start(void) __NO_RETURN; typedef struct { uint32_t const* src; uint32_t* dest; uint32_t wlen; } __copy_table_t; typedef struct { uint32_t* dest; uint32_t wlen; } __zero_table_t; extern const __copy_table_t __copy_table_start__; extern const __copy_table_t __copy_table_end__; extern const __zero_table_t __zero_table_start__; extern const __zero_table_t __zero_table_end__; for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { for(uint32_t i=0u; iwlen; ++i) { pTable->dest[i] = pTable->src[i]; } } for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { for(uint32_t i=0u; iwlen; ++i) { pTable->dest[i] = 0u; } } _start(); } #define __PROGRAM_START __cmsis_start #endif #ifndef __INITIAL_SP #define __INITIAL_SP __StackTop #endif #ifndef __STACK_LIMIT #define __STACK_LIMIT __StackLimit #endif #ifndef __VECTOR_TABLE #define __VECTOR_TABLE __Vectors #endif #ifndef __VECTOR_TABLE_ATTRIBUTE #define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors"))) #endif /* ########################### Core Function Access ########################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions @{ */ /** \brief Enable IRQ Interrupts \details Enables IRQ interrupts by clearing the I-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __enable_irq(void) { __ASM volatile ("cpsie i" : : : "memory"); } /** \brief Disable IRQ Interrupts \details Disables IRQ interrupts by setting the I-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __disable_irq(void) { __ASM volatile ("cpsid i" : : : "memory"); } /** \brief Get Control Register \details Returns the content of the Control Register. \return Control Register value */ __STATIC_FORCEINLINE uint32_t __get_CONTROL(void) { uint32_t result; __ASM volatile ("MRS %0, control" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Control Register (non-secure) \details Returns the content of the non-secure Control Register when in secure mode. \return non-secure Control Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) { uint32_t result; __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Control Register \details Writes the given value to the Control Register. \param [in] control Control Register value to set */ __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) { __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Control Register (non-secure) \details Writes the given value to the non-secure Control Register when in secure state. \param [in] control Control Register value to set */ __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) { __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); } #endif /** \brief Get IPSR Register \details Returns the content of the IPSR Register. \return IPSR Register value */ __STATIC_FORCEINLINE uint32_t __get_IPSR(void) { uint32_t result; __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); return(result); } /** \brief Get APSR Register \details Returns the content of the APSR Register. \return APSR Register value */ __STATIC_FORCEINLINE uint32_t __get_APSR(void) { uint32_t result; __ASM volatile ("MRS %0, apsr" : "=r" (result) ); return(result); } /** \brief Get xPSR Register \details Returns the content of the xPSR Register. \return xPSR Register value */ __STATIC_FORCEINLINE uint32_t __get_xPSR(void) { uint32_t result; __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); return(result); } /** \brief Get Process Stack Pointer \details Returns the current value of the Process Stack Pointer (PSP). \return PSP Register value */ __STATIC_FORCEINLINE uint32_t __get_PSP(void) { uint32_t result; __ASM volatile ("MRS %0, psp" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Process Stack Pointer (non-secure) \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. \return PSP Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) { uint32_t result; __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Process Stack Pointer \details Assigns the given value to the Process Stack Pointer (PSP). \param [in] topOfProcStack Process Stack Pointer value to set */ __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) { __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Process Stack Pointer (non-secure) \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. \param [in] topOfProcStack Process Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) { __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); } #endif /** \brief Get Main Stack Pointer \details Returns the current value of the Main Stack Pointer (MSP). \return MSP Register value */ __STATIC_FORCEINLINE uint32_t __get_MSP(void) { uint32_t result; __ASM volatile ("MRS %0, msp" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Main Stack Pointer (non-secure) \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. \return MSP Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) { uint32_t result; __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Main Stack Pointer \details Assigns the given value to the Main Stack Pointer (MSP). \param [in] topOfMainStack Main Stack Pointer value to set */ __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) { __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Main Stack Pointer (non-secure) \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. \param [in] topOfMainStack Main Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) { __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); } #endif #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Stack Pointer (non-secure) \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. \return SP Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) { uint32_t result; __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); return(result); } /** \brief Set Stack Pointer (non-secure) \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. \param [in] topOfStack Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) { __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); } #endif /** \brief Get Priority Mask \details Returns the current state of the priority mask bit from the Priority Mask Register. \return Priority Mask value */ __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) { uint32_t result; __ASM volatile ("MRS %0, primask" : "=r" (result) :: "memory"); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Priority Mask (non-secure) \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. \return Priority Mask value */ __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) { uint32_t result; __ASM volatile ("MRS %0, primask_ns" : "=r" (result) :: "memory"); return(result); } #endif /** \brief Set Priority Mask \details Assigns the given value to the Priority Mask Register. \param [in] priMask Priority Mask */ __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) { __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Priority Mask (non-secure) \details Assigns the given value to the non-secure Priority Mask Register when in secure state. \param [in] priMask Priority Mask */ __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) { __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); } #endif #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) /** \brief Enable FIQ \details Enables FIQ interrupts by clearing the F-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __enable_fault_irq(void) { __ASM volatile ("cpsie f" : : : "memory"); } /** \brief Disable FIQ \details Disables FIQ interrupts by setting the F-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __disable_fault_irq(void) { __ASM volatile ("cpsid f" : : : "memory"); } /** \brief Get Base Priority \details Returns the current value of the Base Priority register. \return Base Priority register value */ __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) { uint32_t result; __ASM volatile ("MRS %0, basepri" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Base Priority (non-secure) \details Returns the current value of the non-secure Base Priority register when in secure state. \return Base Priority register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) { uint32_t result; __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Base Priority \details Assigns the given value to the Base Priority register. \param [in] basePri Base Priority value to set */ __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) { __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Base Priority (non-secure) \details Assigns the given value to the non-secure Base Priority register when in secure state. \param [in] basePri Base Priority value to set */ __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) { __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); } #endif /** \brief Set Base Priority with condition \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, or the new value increases the BASEPRI priority level. \param [in] basePri Base Priority value to set */ __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) { __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); } /** \brief Get Fault Mask \details Returns the current value of the Fault Mask register. \return Fault Mask register value */ __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) { uint32_t result; __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Fault Mask (non-secure) \details Returns the current value of the non-secure Fault Mask register when in secure state. \return Fault Mask register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) { uint32_t result; __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Fault Mask \details Assigns the given value to the Fault Mask register. \param [in] faultMask Fault Mask value to set */ __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) { __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Fault Mask (non-secure) \details Assigns the given value to the non-secure Fault Mask register when in secure state. \param [in] faultMask Fault Mask value to set */ __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) { __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); } #endif #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief Get Process Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always in non-secure mode. \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). \return PSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure PSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, psplim" : "=r" (result) ); return result; #endif } #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Process Stack Pointer Limit (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always. \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. \return PSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure PSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); return result; #endif } #endif /** \brief Set Process Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored in non-secure mode. \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set */ __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure PSPLIM is RAZ/WI (void)ProcStackPtrLimit; #else __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); #endif } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Process Stack Pointer (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored. \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set */ __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure PSPLIM is RAZ/WI (void)ProcStackPtrLimit; #else __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); #endif } #endif /** \brief Get Main Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always in non-secure mode. \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). \return MSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure MSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, msplim" : "=r" (result) ); return result; #endif } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Main Stack Pointer Limit (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always. \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. \return MSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure MSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); return result; #endif } #endif /** \brief Set Main Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored in non-secure mode. \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set */ __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure MSPLIM is RAZ/WI (void)MainStackPtrLimit; #else __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); #endif } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Main Stack Pointer Limit (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored. \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. \param [in] MainStackPtrLimit Main Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure MSPLIM is RAZ/WI (void)MainStackPtrLimit; #else __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); #endif } #endif #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ /** \brief Get FPSCR \details Returns the current value of the Floating Point Status/Control register. \return Floating Point Status/Control register value */ __STATIC_FORCEINLINE uint32_t __get_FPSCR(void) { #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) #if __has_builtin(__builtin_arm_get_fpscr) // Re-enable using built-in when GCC has been fixed // || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ return __builtin_arm_get_fpscr(); #else uint32_t result; __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); return(result); #endif #else return(0U); #endif } /** \brief Set FPSCR \details Assigns the given value to the Floating Point Status/Control register. \param [in] fpscr Floating Point Status/Control value to set */ __STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) { #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) #if __has_builtin(__builtin_arm_set_fpscr) // Re-enable using built-in when GCC has been fixed // || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ __builtin_arm_set_fpscr(fpscr); #else __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); #endif #else (void)fpscr; #endif } /*@} end of CMSIS_Core_RegAccFunctions */ /* ########################## Core Instruction Access ######################### */ /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface Access to dedicated instructions @{ */ /* Define macros for porting to both thumb1 and thumb2. * For thumb1, use low register (r0-r7), specified by constraint "l" * Otherwise, use general registers, specified by constraint "r" */ #if defined (__thumb__) && !defined (__thumb2__) #define __CMSIS_GCC_OUT_REG(r) "=l" (r) #define __CMSIS_GCC_RW_REG(r) "+l" (r) #define __CMSIS_GCC_USE_REG(r) "l" (r) #else #define __CMSIS_GCC_OUT_REG(r) "=r" (r) #define __CMSIS_GCC_RW_REG(r) "+r" (r) #define __CMSIS_GCC_USE_REG(r) "r" (r) #endif /** \brief No Operation \details No Operation does nothing. This instruction can be used for code alignment purposes. */ #define __NOP() __ASM volatile ("nop") /** \brief Wait For Interrupt \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. */ #define __WFI() __ASM volatile ("wfi") /** \brief Wait For Event \details Wait For Event is a hint instruction that permits the processor to enter a low-power state until one of a number of events occurs. */ #define __WFE() __ASM volatile ("wfe") /** \brief Send Event \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. */ #define __SEV() __ASM volatile ("sev") /** \brief Instruction Synchronization Barrier \details Instruction Synchronization Barrier flushes the pipeline in the processor, so that all instructions following the ISB are fetched from cache or memory, after the instruction has been completed. */ __STATIC_FORCEINLINE void __ISB(void) { __ASM volatile ("isb 0xF":::"memory"); } /** \brief Data Synchronization Barrier \details Acts as a special kind of Data Memory Barrier. It completes when all explicit memory accesses before this instruction complete. */ __STATIC_FORCEINLINE void __DSB(void) { __ASM volatile ("dsb 0xF":::"memory"); } /** \brief Data Memory Barrier \details Ensures the apparent order of the explicit memory operations before and after the instruction, without ensuring their completion. */ __STATIC_FORCEINLINE void __DMB(void) { __ASM volatile ("dmb 0xF":::"memory"); } /** \brief Reverse byte order (32 bit) \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE uint32_t __REV(uint32_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) return __builtin_bswap32(value); #else uint32_t result; __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return result; #endif } /** \brief Reverse byte order (16 bit) \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) { uint32_t result; __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return result; } /** \brief Reverse byte order (16 bit) \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE int16_t __REVSH(int16_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) return (int16_t)__builtin_bswap16(value); #else int16_t result; __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return result; #endif } /** \brief Rotate Right in unsigned value (32 bit) \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. \param [in] op1 Value to rotate \param [in] op2 Number of Bits to rotate \return Rotated value */ __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) { op2 %= 32U; if (op2 == 0U) { return op1; } return (op1 >> op2) | (op1 << (32U - op2)); } /** \brief Breakpoint \details Causes the processor to enter Debug state. Debug tools can use this to investigate system state when the instruction at a particular address is reached. \param [in] value is ignored by the processor. If required, a debugger can use it to store additional information about the breakpoint. */ #define __BKPT(value) __ASM volatile ("bkpt "#value) /** \brief Reverse bit order of value \details Reverses the bit order of the given value. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) { uint32_t result; #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); #else uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ result = value; /* r will be reversed bits of v; first get LSB of v */ for (value >>= 1U; value != 0U; value >>= 1U) { result <<= 1U; result |= value & 1U; s--; } result <<= s; /* shift when v's highest bits are zero */ #endif return result; } /** \brief Count leading zeros \details Counts the number of leading zeros of a data value. \param [in] value Value to count the leading zeros \return number of leading zeros in value */ __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) { /* Even though __builtin_clz produces a CLZ instruction on ARM, formally __builtin_clz(0) is undefined behaviour, so handle this case specially. This guarantees ARM-compatible results if happening to compile on a non-ARM target, and ensures the compiler doesn't decide to activate any optimisations using the logic "value was passed to __builtin_clz, so it is non-zero". ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a single CLZ instruction. */ if (value == 0U) { return 32U; } return __builtin_clz(value); } #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief LDR Exclusive (8 bit) \details Executes a exclusive LDR instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } /** \brief LDR Exclusive (16 bit) \details Executes a exclusive LDR instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } /** \brief LDR Exclusive (32 bit) \details Executes a exclusive LDR instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) { uint32_t result; __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); return(result); } /** \brief STR Exclusive (8 bit) \details Executes a exclusive STR instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) { uint32_t result; __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); return(result); } /** \brief STR Exclusive (16 bit) \details Executes a exclusive STR instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) { uint32_t result; __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); return(result); } /** \brief STR Exclusive (32 bit) \details Executes a exclusive STR instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) { uint32_t result; __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); return(result); } /** \brief Remove the exclusive lock \details Removes the exclusive lock which is created by LDREX. */ __STATIC_FORCEINLINE void __CLREX(void) { __ASM volatile ("clrex" ::: "memory"); } #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) /** \brief Signed Saturate \details Saturates a signed value. \param [in] ARG1 Value to be saturated \param [in] ARG2 Bit position to saturate to (1..32) \return Saturated value */ #define __SSAT(ARG1,ARG2) \ __extension__ \ ({ \ int32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) /** \brief Unsigned Saturate \details Saturates an unsigned value. \param [in] ARG1 Value to be saturated \param [in] ARG2 Bit position to saturate to (0..31) \return Saturated value */ #define __USAT(ARG1,ARG2) \ __extension__ \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) /** \brief Rotate Right with Extend (32 bit) \details Moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring. \param [in] value Value to rotate \return Rotated value */ __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) { uint32_t result; __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return(result); } /** \brief LDRT Unprivileged (8 bit) \details Executes a Unprivileged LDRT instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } /** \brief LDRT Unprivileged (16 bit) \details Executes a Unprivileged LDRT instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } /** \brief LDRT Unprivileged (32 bit) \details Executes a Unprivileged LDRT instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } /** \brief STRT Unprivileged (8 bit) \details Executes a Unprivileged STRT instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) { __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief STRT Unprivileged (16 bit) \details Executes a Unprivileged STRT instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) { __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief STRT Unprivileged (32 bit) \details Executes a Unprivileged STRT instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) { __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); } #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ /** \brief Signed Saturate \details Saturates a signed value. \param [in] value Value to be saturated \param [in] sat Bit position to saturate to (1..32) \return Saturated value */ __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) { if ((sat >= 1U) && (sat <= 32U)) { const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); const int32_t min = -1 - max ; if (val > max) { return max; } else if (val < min) { return min; } } return val; } /** \brief Unsigned Saturate \details Saturates an unsigned value. \param [in] value Value to be saturated \param [in] sat Bit position to saturate to (0..31) \return Saturated value */ __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) { if (sat <= 31U) { const uint32_t max = ((1U << sat) - 1U); if (val > (int32_t)max) { return max; } else if (val < 0) { return 0U; } } return (uint32_t)val; } #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief Load-Acquire (8 bit) \details Executes a LDAB instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) { uint32_t result; __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint8_t) result); } /** \brief Load-Acquire (16 bit) \details Executes a LDAH instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) { uint32_t result; __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint16_t) result); } /** \brief Load-Acquire (32 bit) \details Executes a LDA instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } /** \brief Store-Release (8 bit) \details Executes a STLB instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) { __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief Store-Release (16 bit) \details Executes a STLH instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) { __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief Store-Release (32 bit) \details Executes a STL instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) { __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief Load-Acquire Exclusive (8 bit) \details Executes a LDAB exclusive instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) { uint32_t result; __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint8_t) result); } /** \brief Load-Acquire Exclusive (16 bit) \details Executes a LDAH exclusive instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) { uint32_t result; __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint16_t) result); } /** \brief Load-Acquire Exclusive (32 bit) \details Executes a LDA exclusive instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } /** \brief Store-Release Exclusive (8 bit) \details Executes a STLB exclusive instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) { uint32_t result; __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); return(result); } /** \brief Store-Release Exclusive (16 bit) \details Executes a STLH exclusive instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) { uint32_t result; __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); return(result); } /** \brief Store-Release Exclusive (32 bit) \details Executes a STL exclusive instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); return(result); } #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ /* ################### Compiler specific Intrinsics ########################### */ /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics Access to dedicated SIMD instructions @{ */ #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } #define __SSAT16(ARG1,ARG2) \ ({ \ int32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) #define __USAT16(ARG1,ARG2) \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) { uint32_t result; __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); return(result); } __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) { uint32_t result; __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); return(result); } __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) { int32_t result; __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) { int32_t result; __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } #if 0 #define __PKHBT(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) #define __PKHTB(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ if (ARG3 == 0) \ __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ else \ __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) #endif #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) { int32_t result; __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); return(result); } #endif /* (__ARM_FEATURE_DSP == 1) */ /*@} end of group CMSIS_SIMD_intrinsics */ #pragma GCC diagnostic pop #endif /* __CMSIS_GCC_H */ ================================================ FILE: panda/board/stm32fx/inc/cmsis_version.h ================================================ /**************************************************************************//** * @file cmsis_version.h * @brief CMSIS Core(M) Version definitions * @version V5.0.3 * @date 24. June 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 ARM Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CMSIS_VERSION_H #define __CMSIS_VERSION_H /* CMSIS Version definitions */ #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ #endif ================================================ FILE: panda/board/stm32fx/inc/core_cm3.h ================================================ /**************************************************************************//** * @file core_cm3.h * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File * @version V5.1.0 * @date 13. March 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CM3_H_GENERIC #define __CORE_CM3_H_GENERIC #include #ifdef __cplusplus extern "C" { #endif /** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions CMSIS violates the following MISRA-C:2004 rules: \li Required Rule 8.5, object/function definition in header file.
Function definitions in header files are used to allow 'inlining'. \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
Unions are used for effective representation of core registers. \li Advisory Rule 19.7, Function-like macro defined.
Function-like macros are used to allow more efficient code. */ /******************************************************************************* * CMSIS definitions ******************************************************************************/ /** \ingroup Cortex_M3 @{ */ #include "cmsis_version.h" /* CMSIS CM3 definitions */ #define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ #define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ #define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ #define __CORTEX_M (3U) /*!< Cortex-M Core */ /** __FPU_USED indicates whether an FPU is used or not. This core does not support an FPU at all */ #define __FPU_USED 0U #if defined ( __CC_ARM ) #if defined __TARGET_FPU_VFP #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #if defined __ARM_FP #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #elif defined ( __GNUC__ ) #if defined (__VFP_FP__) && !defined(__SOFTFP__) #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #elif defined ( __ICCARM__ ) #if defined __ARMVFP__ #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #elif defined ( __TI_ARM__ ) #if defined __TI_VFP_SUPPORT__ #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #elif defined ( __TASKING__ ) #if defined __FPU_VFP__ #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #elif defined ( __CSMC__ ) #if ( __CSMC__ & 0x400U) #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #endif #endif #include "cmsis_compiler.h" /* CMSIS compiler specific defines */ #ifdef __cplusplus } #endif #endif /* __CORE_CM3_H_GENERIC */ #ifndef __CMSIS_GENERIC #ifndef __CORE_CM3_H_DEPENDANT #define __CORE_CM3_H_DEPENDANT #ifdef __cplusplus extern "C" { #endif /* check device defines and use defaults */ #if defined __CHECK_DEVICE_DEFINES #ifndef __CM3_REV #define __CM3_REV 0x0200U #warning "__CM3_REV not defined in device header file; using default!" #endif #ifndef __MPU_PRESENT #define __MPU_PRESENT 0U #warning "__MPU_PRESENT not defined in device header file; using default!" #endif #ifndef __NVIC_PRIO_BITS #define __NVIC_PRIO_BITS 3U #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" #endif #ifndef __Vendor_SysTickConfig #define __Vendor_SysTickConfig 0U #warning "__Vendor_SysTickConfig not defined in device header file; using default!" #endif #endif /* IO definitions (access restrictions to peripheral registers) */ /** \defgroup CMSIS_glob_defs CMSIS Global Defines IO Type Qualifiers are used \li to specify the access to peripheral variables. \li for automatic generation of peripheral register debug information. */ #ifdef __cplusplus #define __I volatile /*!< Defines 'read only' permissions */ #else #define __I volatile const /*!< Defines 'read only' permissions */ #endif #define __O volatile /*!< Defines 'write only' permissions */ #define __IO volatile /*!< Defines 'read / write' permissions */ /* following defines should be used for structure members */ #define __IM volatile const /*! Defines 'read only' structure member permissions */ #define __OM volatile /*! Defines 'write only' structure member permissions */ #define __IOM volatile /*! Defines 'read / write' structure member permissions */ /*@} end of group Cortex_M3 */ /******************************************************************************* * Register Abstraction Core Register contain: - Core Register - Core NVIC Register - Core SCB Register - Core SysTick Register - Core Debug Register - Core MPU Register ******************************************************************************/ /** \defgroup CMSIS_core_register Defines and Type Definitions \brief Type definitions and defines for Cortex-M processor based devices. */ /** \ingroup CMSIS_core_register \defgroup CMSIS_CORE Status and Control Registers \brief Core Register type definitions. @{ */ /** \brief Union type to access the Application Program Status Register (APSR). */ typedef union { struct { uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } APSR_Type; /* APSR Register Definitions */ #define APSR_N_Pos 31U /*!< APSR: N Position */ #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ #define APSR_Z_Pos 30U /*!< APSR: Z Position */ #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ #define APSR_C_Pos 29U /*!< APSR: C Position */ #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ #define APSR_V_Pos 28U /*!< APSR: V Position */ #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ #define APSR_Q_Pos 27U /*!< APSR: Q Position */ #define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ /** \brief Union type to access the Interrupt Program Status Register (IPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } IPSR_Type; /* IPSR Register Definitions */ #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ /** \brief Union type to access the Special-Purpose Program Status Registers (xPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:1; /*!< bit: 9 Reserved */ uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ uint32_t T:1; /*!< bit: 24 Thumb bit */ uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } xPSR_Type; /* xPSR Register Definitions */ #define xPSR_N_Pos 31U /*!< xPSR: N Position */ #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ #define xPSR_C_Pos 29U /*!< xPSR: C Position */ #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ #define xPSR_V_Pos 28U /*!< xPSR: V Position */ #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ #define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ #define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ #define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ #define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ #define xPSR_T_Pos 24U /*!< xPSR: T Position */ #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ #define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ #define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ /** \brief Union type to access the Control Registers (CONTROL). */ typedef union { struct { uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } CONTROL_Type; /* CONTROL Register Definitions */ #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ #define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ #define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ /*@} end of group CMSIS_CORE */ /** \ingroup CMSIS_core_register \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) \brief Type definitions for the NVIC Registers @{ */ /** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). */ typedef struct { __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ uint32_t RESERVED0[24U]; __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ uint32_t RESERVED1[24U]; __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ uint32_t RESERVED2[24U]; __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ uint32_t RESERVED3[24U]; __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ uint32_t RESERVED4[56U]; __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ uint32_t RESERVED5[644U]; __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ } NVIC_Type; /* Software Triggered Interrupt Register Definitions */ #define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ #define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ /*@} end of group CMSIS_NVIC */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCB System Control Block (SCB) \brief Type definitions for the System Control Block Registers @{ */ /** \brief Structure type to access the System Control Block (SCB). */ typedef struct { __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ uint32_t RESERVED0[5U]; __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ } SCB_Type; /* SCB CPUID Register Definitions */ #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ /* SCB Interrupt Control State Register Definitions */ #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ #define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ /* SCB Vector Table Offset Register Definitions */ #if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ #define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ #define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ #define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ #define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ #else #define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ #endif /* SCB Application Interrupt and Reset Control Register Definitions */ #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ #define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ #define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ #define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ /* SCB System Control Register Definitions */ #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ /* SCB Configuration Control Register Definitions */ #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ #define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ #define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ #define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ #define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ #define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ /* SCB System Handler Control and State Register Definitions */ #define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ #define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ #define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ #define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ #define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ #define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ #define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ #define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ #define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ #define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ #define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ #define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ #define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ #define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ /* SCB Configurable Fault Status Register Definitions */ #define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ #define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ #define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ /* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ #define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ #define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ #define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ #define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ #define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ #define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ #define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ #define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ #define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ /* BusFault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ #define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ #define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ #define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ #define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ #define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ #define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ #define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ #define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ #define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ #define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ #define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ /* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ #define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ #define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ #define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ #define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ #define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ #define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ #define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ #define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ #define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ #define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ #define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ /* SCB Hard Fault Status Register Definitions */ #define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ #define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ #define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ /* SCB Debug Fault Status Register Definitions */ #define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ #define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ #define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ #define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ #define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ #define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ /*@} end of group CMSIS_SCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) \brief Type definitions for the System Control and ID Register not in the SCB @{ */ /** \brief Structure type to access the System Control and ID Register not in the SCB. */ typedef struct { uint32_t RESERVED0[1U]; __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ #if defined (__CM3_REV) && (__CM3_REV >= 0x200U) __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ #else uint32_t RESERVED1[1U]; #endif } SCnSCB_Type; /* Interrupt Controller Type Register Definitions */ #define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ /* Auxiliary Control Register Definitions */ #if defined (__CM3_REV) && (__CM3_REV >= 0x200U) #define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ #define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ #define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ #define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ #define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ #define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ #define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ #define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ #endif /*@} end of group CMSIS_SCnotSCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SysTick System Tick Timer (SysTick) \brief Type definitions for the System Timer Registers. @{ */ /** \brief Structure type to access the System Timer (SysTick). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ } SysTick_Type; /* SysTick Control / Status Register Definitions */ #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ /* SysTick Reload Register Definitions */ #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ /* SysTick Current Register Definitions */ #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ /* SysTick Calibration Register Definitions */ #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ /*@} end of group CMSIS_SysTick */ /** \ingroup CMSIS_core_register \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) \brief Type definitions for the Instrumentation Trace Macrocell (ITM) @{ */ /** \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). */ typedef struct { __OM union { __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ uint32_t RESERVED0[864U]; __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ uint32_t RESERVED1[15U]; __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ uint32_t RESERVED2[15U]; __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ uint32_t RESERVED3[32U]; uint32_t RESERVED4[43U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ uint32_t RESERVED5[6U]; __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ } ITM_Type; /* ITM Trace Privilege Register Definitions */ #define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ #define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ /* ITM Trace Control Register Definitions */ #define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ #define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ #define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ #define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ #define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ #define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ #define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ #define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ #define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ #define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ #define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ /* ITM Lock Status Register Definitions */ #define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ #define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ #define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ #define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ #define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ /*@}*/ /* end of group CMSIS_ITM */ /** \ingroup CMSIS_core_register \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) \brief Type definitions for the Data Watchpoint and Trace (DWT) @{ */ /** \brief Structure type to access the Data Watchpoint and Trace Register (DWT). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ uint32_t RESERVED0[1U]; __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ uint32_t RESERVED1[1U]; __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ uint32_t RESERVED2[1U]; __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ } DWT_Type; /* DWT Control Register Definitions */ #define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ #define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ #define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ #define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ #define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ #define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ #define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ #define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ #define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ #define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ #define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ #define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ #define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ #define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ #define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ #define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ #define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ #define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ #define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ #define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ #define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ #define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ #define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ #define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ #define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ #define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ #define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ #define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ #define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ #define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ #define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ #define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ #define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ #define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ #define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ #define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ /* DWT CPI Count Register Definitions */ #define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ #define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ /* DWT Exception Overhead Count Register Definitions */ #define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ #define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ /* DWT Sleep Count Register Definitions */ #define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ #define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ /* DWT LSU Count Register Definitions */ #define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ #define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ /* DWT Folded-instruction Count Register Definitions */ #define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ #define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ /* DWT Comparator Mask Register Definitions */ #define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ #define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ /* DWT Comparator Function Register Definitions */ #define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ #define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ #define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ #define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ #define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ #define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ #define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ #define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ #define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ #define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ #define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ #define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ #define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ #define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ #define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ #define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ #define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ #define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ /*@}*/ /* end of group CMSIS_DWT */ /** \ingroup CMSIS_core_register \defgroup CMSIS_TPI Trace Port Interface (TPI) \brief Type definitions for the Trace Port Interface (TPI) @{ */ /** \brief Structure type to access the Trace Port Interface Register (TPI). */ typedef struct { __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ uint32_t RESERVED0[2U]; __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ uint32_t RESERVED1[55U]; __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ uint32_t RESERVED2[131U]; __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ uint32_t RESERVED3[759U]; __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ uint32_t RESERVED4[1U]; __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ uint32_t RESERVED5[39U]; __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ uint32_t RESERVED7[8U]; __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ } TPI_Type; /* TPI Asynchronous Clock Prescaler Register Definitions */ #define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ #define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ /* TPI Selected Pin Protocol Register Definitions */ #define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ #define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ /* TPI Formatter and Flush Status Register Definitions */ #define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ #define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ #define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ #define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ #define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ #define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ #define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ #define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ /* TPI Formatter and Flush Control Register Definitions */ #define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ #define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ #define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ #define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ /* TPI TRIGGER Register Definitions */ #define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ #define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ /* TPI Integration ETM Data Register Definitions (FIFO0) */ #define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ #define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ #define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ #define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ #define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ #define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ #define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ #define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ #define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ #define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ #define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ #define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ /* TPI ITATBCTR2 Register Definitions */ #define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ #define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ #define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ #define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ /* TPI Integration ITM Data Register Definitions (FIFO1) */ #define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ #define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ #define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ #define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ #define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ #define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ #define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ #define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ #define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ #define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ #define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ #define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ /* TPI ITATBCTR0 Register Definitions */ #define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ #define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ #define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ #define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ /* TPI Integration Mode Control Register Definitions */ #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ #define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ /* TPI DEVID Register Definitions */ #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ #define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ #define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ #define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ #define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ #define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ #define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ #define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ #define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ #define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ #define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ #define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ /* TPI DEVTYPE Register Definitions */ #define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ #define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ #define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ /*@}*/ /* end of group CMSIS_TPI */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_MPU Memory Protection Unit (MPU) \brief Type definitions for the Memory Protection Unit (MPU) @{ */ /** \brief Structure type to access the Memory Protection Unit (MPU). */ typedef struct { __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ } MPU_Type; #define MPU_TYPE_RALIASES 4U /* MPU Type Register Definitions */ #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ #define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ #define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ #define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ /* MPU Control Register Definitions */ #define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ #define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ #define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ #define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ /* MPU Region Number Register Definitions */ #define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ #define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ /* MPU Region Base Address Register Definitions */ #define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ #define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ #define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ #define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ /* MPU Region Attribute and Size Register Definitions */ #define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ #define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ #define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ #define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ #define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ #define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ #define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ #define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ #define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ #define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ #define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ /*@} end of group CMSIS_MPU */ #endif /** \ingroup CMSIS_core_register \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) \brief Type definitions for the Core Debug Registers @{ */ /** \brief Structure type to access the Core Debug Register (CoreDebug). */ typedef struct { __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ } CoreDebug_Type; /* Debug Halting Control and Status Register Definitions */ #define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ #define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ #define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ #define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ #define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ #define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ #define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ #define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ #define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ /* Debug Core Register Selector Register Definitions */ #define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ #define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ /* Debug Exception and Monitor Control Register Definitions */ #define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ #define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ #define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ #define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ #define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ #define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ #define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ #define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ #define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ #define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ #define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ #define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ /*@} end of group CMSIS_CoreDebug */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_bitfield Core register bit field macros \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). @{ */ /** \brief Mask and shift a bit field value for use in a register bit range. \param[in] field Name of the register bit field. \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. \return Masked and shifted value. */ #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) /** \brief Mask and shift a register value to extract a bit filed value. \param[in] field Name of the register bit field. \param[in] value Value of register. This parameter is interpreted as an uint32_t type. \return Masked and shifted bit field value. */ #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) /*@} end of group CMSIS_core_bitfield */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_base Core Definitions \brief Definitions for base addresses, unions, and structures. @{ */ /* Memory mapping of Core Hardware */ #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ #endif /*@} */ /******************************************************************************* * Hardware Abstraction Layer Core Function Interface contains: - Core NVIC Functions - Core SysTick Functions - Core Debug Functions - Core Register Access Functions ******************************************************************************/ /** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference */ /* ########################## NVIC functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_NVICFunctions NVIC Functions \brief Functions that manage interrupts and exceptions via the NVIC. @{ */ #ifdef CMSIS_NVIC_VIRTUAL #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" #endif #include CMSIS_NVIC_VIRTUAL_HEADER_FILE #else #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping #define NVIC_EnableIRQ __NVIC_EnableIRQ #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ #define NVIC_DisableIRQ __NVIC_DisableIRQ #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ #define NVIC_GetActive __NVIC_GetActive #define NVIC_SetPriority __NVIC_SetPriority #define NVIC_GetPriority __NVIC_GetPriority #define NVIC_SystemReset __NVIC_SystemReset #endif /* CMSIS_NVIC_VIRTUAL */ #ifdef CMSIS_VECTAB_VIRTUAL #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" #endif #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE #else #define NVIC_SetVector __NVIC_SetVector #define NVIC_GetVector __NVIC_GetVector #endif /* (CMSIS_VECTAB_VIRTUAL) */ #define NVIC_USER_IRQ_OFFSET 16 /* The following EXC_RETURN values are saved the LR on exception entry */ #define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ #define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ #define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ /** \brief Set Priority Grouping \details Sets the priority grouping field using the required unlock sequence. The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Priority grouping field. */ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ reg_value = SCB->AIRCR; /* read old register configuration */ reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } /** \brief Get Priority Grouping \details Reads the priority grouping field from the NVIC Interrupt Controller. \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). */ __STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) { return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); } /** \brief Enable Interrupt \details Enables a device specific interrupt in the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { __COMPILER_BARRIER(); NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); __COMPILER_BARRIER(); } } /** \brief Get Interrupt Enable status \details Returns a device specific interrupt enable status from the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt is not enabled. \return 1 Interrupt is enabled. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Disable Interrupt \details Disables a device specific interrupt in the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); __DSB(); __ISB(); } } /** \brief Get Pending Interrupt \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not pending. \return 1 Interrupt status is pending. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Set Pending Interrupt \details Sets the pending bit of a device specific interrupt in the NVIC pending register. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); } } /** \brief Clear Pending Interrupt \details Clears the pending bit of a device specific interrupt in the NVIC pending register. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); } } /** \brief Get Active Interrupt \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not active. \return 1 Interrupt status is active. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Set Interrupt Priority \details Sets the priority of a device specific interrupt or a processor exception. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \param [in] priority Priority to set. \note The priority cannot be set for every processor exception. */ __STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { if ((int32_t)(IRQn) >= 0) { NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } else { SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } } /** \brief Get Interrupt Priority \details Reads the priority of a device specific interrupt or a processor exception. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. */ __STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); } else { return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); } } /** \brief Encode Priority \details Encodes the priority for an interrupt with the given priority group, preemptive priority value, and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Used priority group. \param [in] PreemptPriority Preemptive priority value (starting from 0). \param [in] SubPriority Subpriority value (starting from 0). \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). */ __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); return ( ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) ); } /** \brief Decode Priority \details Decodes an interrupt priority value with a given priority group to preemptive priority value and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). \param [in] PriorityGroup Used priority group. \param [out] pPreemptPriority Preemptive priority value (starting from 0). \param [out] pSubPriority Subpriority value (starting from 0). */ __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); } /** \brief Set Interrupt Vector \details Sets an interrupt vector in SRAM based interrupt vector table. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. VTOR must been relocated to SRAM before. \param [in] IRQn Interrupt number \param [in] vector Address of interrupt handler function */ __STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { uint32_t vectors = (uint32_t )SCB->VTOR; (* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector; /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ } /** \brief Get Interrupt Vector \details Reads an interrupt vector from interrupt vector table. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Address of interrupt handler function */ __STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) { uint32_t vectors = (uint32_t )SCB->VTOR; return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)); } /** \brief System Reset \details Initiates a system reset request to reset the MCU. */ __NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ __DSB(); /* Ensure completion of memory access */ for(;;) /* wait until reset */ { __NOP(); } } /*@} end of CMSIS_Core_NVICFunctions */ /* ########################## MPU functions #################################### */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #include "mpu_armv7.h" #endif /* ########################## FPU functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_FpuFunctions FPU Functions \brief Function that provides FPU type. @{ */ /** \brief get FPU type \details returns the FPU type \returns - \b 0: No FPU - \b 1: Single precision FPU - \b 2: Double + Single precision FPU */ __STATIC_INLINE uint32_t SCB_GetFPUType(void) { return 0U; /* No FPU */ } /*@} end of CMSIS_Core_FpuFunctions */ /* ################################## SysTick function ############################################ */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_SysTickFunctions SysTick Functions \brief Functions that configure the System. @{ */ #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) /** \brief System Tick Configuration \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. Counter is in free running mode to generate periodic interrupts. \param [in] ticks Number of ticks between two interrupts. \return 0 Function succeeded. \return 1 Function failed. \note When the variable __Vendor_SysTickConfig is set to 1, then the function SysTick_Config is not included. In this case, the file device.h must contain a vendor-specific implementation of this function. */ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) { if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) { return (1UL); /* Reload value impossible */ } SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ return (0UL); /* Function successful */ } #endif /*@} end of CMSIS_Core_SysTickFunctions */ /* ##################################### Debug In/Output function ########################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_core_DebugFunctions ITM Functions \brief Functions that access the ITM debug interface. @{ */ extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ #define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ /** \brief ITM Send Character \details Transmits a character via the ITM channel 0, and \li Just returns when no debugger is connected that has booked the output. \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. \param [in] ch Character to transmit. \returns Character to transmit. */ __STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) { if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ { while (ITM->PORT[0U].u32 == 0UL) { __NOP(); } ITM->PORT[0U].u8 = (uint8_t)ch; } return (ch); } /** \brief ITM Receive Character \details Inputs a character via the external variable \ref ITM_RxBuffer. \return Received character. \return -1 No character pending. */ __STATIC_INLINE int32_t ITM_ReceiveChar (void) { int32_t ch = -1; /* no character available */ if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) { ch = ITM_RxBuffer; ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ } return (ch); } /** \brief ITM Check Character \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. \return 0 No character available. \return 1 Character available. */ __STATIC_INLINE int32_t ITM_CheckChar (void) { if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) { return (0); /* no character available */ } else { return (1); /* character available */ } } /*@} end of CMSIS_core_DebugFunctions */ #ifdef __cplusplus } #endif #endif /* __CORE_CM3_H_DEPENDANT */ #endif /* __CMSIS_GENERIC */ ================================================ FILE: panda/board/stm32fx/inc/core_cm4.h ================================================ /**************************************************************************//** * @file core_cm4.h * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File * @version V5.1.0 * @date 13. March 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CM4_H_GENERIC #define __CORE_CM4_H_GENERIC #include #ifdef __cplusplus extern "C" { #endif /** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions CMSIS violates the following MISRA-C:2004 rules: \li Required Rule 8.5, object/function definition in header file.
Function definitions in header files are used to allow 'inlining'. \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
Unions are used for effective representation of core registers. \li Advisory Rule 19.7, Function-like macro defined.
Function-like macros are used to allow more efficient code. */ /******************************************************************************* * CMSIS definitions ******************************************************************************/ /** \ingroup Cortex_M4 @{ */ #include "cmsis_version.h" /* CMSIS CM4 definitions */ #define __CM4_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ #define __CM4_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ #define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ __CM4_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ #define __CORTEX_M (4U) /*!< Cortex-M Core */ /** __FPU_USED indicates whether an FPU is used or not. For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. */ #if defined ( __CC_ARM ) #if defined __TARGET_FPU_VFP #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #if defined __ARM_FP #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __GNUC__ ) #if defined (__VFP_FP__) && !defined(__SOFTFP__) #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __ICCARM__ ) #if defined __ARMVFP__ #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __TI_ARM__ ) #if defined __TI_VFP_SUPPORT__ #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __TASKING__ ) #if defined __FPU_VFP__ #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __CSMC__ ) #if ( __CSMC__ & 0x400U) #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #endif #include "cmsis_compiler.h" /* CMSIS compiler specific defines */ #ifdef __cplusplus } #endif #endif /* __CORE_CM4_H_GENERIC */ #ifndef __CMSIS_GENERIC #ifndef __CORE_CM4_H_DEPENDANT #define __CORE_CM4_H_DEPENDANT #ifdef __cplusplus extern "C" { #endif /* check device defines and use defaults */ #if defined __CHECK_DEVICE_DEFINES #ifndef __CM4_REV #define __CM4_REV 0x0000U #warning "__CM4_REV not defined in device header file; using default!" #endif #ifndef __FPU_PRESENT #define __FPU_PRESENT 0U #warning "__FPU_PRESENT not defined in device header file; using default!" #endif #ifndef __MPU_PRESENT #define __MPU_PRESENT 0U #warning "__MPU_PRESENT not defined in device header file; using default!" #endif #ifndef __NVIC_PRIO_BITS #define __NVIC_PRIO_BITS 3U #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" #endif #ifndef __Vendor_SysTickConfig #define __Vendor_SysTickConfig 0U #warning "__Vendor_SysTickConfig not defined in device header file; using default!" #endif #endif /* IO definitions (access restrictions to peripheral registers) */ /** \defgroup CMSIS_glob_defs CMSIS Global Defines IO Type Qualifiers are used \li to specify the access to peripheral variables. \li for automatic generation of peripheral register debug information. */ #ifdef __cplusplus #define __I volatile /*!< Defines 'read only' permissions */ #else #define __I volatile const /*!< Defines 'read only' permissions */ #endif #define __O volatile /*!< Defines 'write only' permissions */ #define __IO volatile /*!< Defines 'read / write' permissions */ /* following defines should be used for structure members */ #define __IM volatile const /*! Defines 'read only' structure member permissions */ #define __OM volatile /*! Defines 'write only' structure member permissions */ #define __IOM volatile /*! Defines 'read / write' structure member permissions */ /*@} end of group Cortex_M4 */ /******************************************************************************* * Register Abstraction Core Register contain: - Core Register - Core NVIC Register - Core SCB Register - Core SysTick Register - Core Debug Register - Core MPU Register - Core FPU Register ******************************************************************************/ /** \defgroup CMSIS_core_register Defines and Type Definitions \brief Type definitions and defines for Cortex-M processor based devices. */ /** \ingroup CMSIS_core_register \defgroup CMSIS_CORE Status and Control Registers \brief Core Register type definitions. @{ */ /** \brief Union type to access the Application Program Status Register (APSR). */ typedef union { struct { uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } APSR_Type; /* APSR Register Definitions */ #define APSR_N_Pos 31U /*!< APSR: N Position */ #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ #define APSR_Z_Pos 30U /*!< APSR: Z Position */ #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ #define APSR_C_Pos 29U /*!< APSR: C Position */ #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ #define APSR_V_Pos 28U /*!< APSR: V Position */ #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ #define APSR_Q_Pos 27U /*!< APSR: Q Position */ #define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ #define APSR_GE_Pos 16U /*!< APSR: GE Position */ #define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ /** \brief Union type to access the Interrupt Program Status Register (IPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } IPSR_Type; /* IPSR Register Definitions */ #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ /** \brief Union type to access the Special-Purpose Program Status Registers (xPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:1; /*!< bit: 9 Reserved */ uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ uint32_t T:1; /*!< bit: 24 Thumb bit */ uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } xPSR_Type; /* xPSR Register Definitions */ #define xPSR_N_Pos 31U /*!< xPSR: N Position */ #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ #define xPSR_C_Pos 29U /*!< xPSR: C Position */ #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ #define xPSR_V_Pos 28U /*!< xPSR: V Position */ #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ #define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ #define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ #define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ #define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ #define xPSR_T_Pos 24U /*!< xPSR: T Position */ #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ #define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ #define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ #define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ #define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ /** \brief Union type to access the Control Registers (CONTROL). */ typedef union { struct { uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } CONTROL_Type; /* CONTROL Register Definitions */ #define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ #define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ #define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ #define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ /*@} end of group CMSIS_CORE */ /** \ingroup CMSIS_core_register \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) \brief Type definitions for the NVIC Registers @{ */ /** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). */ typedef struct { __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ uint32_t RESERVED0[24U]; __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ uint32_t RESERVED1[24U]; __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ uint32_t RESERVED2[24U]; __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ uint32_t RESERVED3[24U]; __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ uint32_t RESERVED4[56U]; __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ uint32_t RESERVED5[644U]; __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ } NVIC_Type; /* Software Triggered Interrupt Register Definitions */ #define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ #define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ /*@} end of group CMSIS_NVIC */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCB System Control Block (SCB) \brief Type definitions for the System Control Block Registers @{ */ /** \brief Structure type to access the System Control Block (SCB). */ typedef struct { __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ uint32_t RESERVED0[5U]; __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ } SCB_Type; /* SCB CPUID Register Definitions */ #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ /* SCB Interrupt Control State Register Definitions */ #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ #define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ /* SCB Vector Table Offset Register Definitions */ #define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ /* SCB Application Interrupt and Reset Control Register Definitions */ #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ #define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ #define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ #define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ /* SCB System Control Register Definitions */ #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ /* SCB Configuration Control Register Definitions */ #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ #define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ #define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ #define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ #define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ #define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ /* SCB System Handler Control and State Register Definitions */ #define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ #define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ #define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ #define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ #define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ #define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ #define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ #define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ #define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ #define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ #define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ #define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ #define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ #define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ /* SCB Configurable Fault Status Register Definitions */ #define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ #define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ #define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ /* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ #define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ #define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ #define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ #define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ #define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ #define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ #define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ #define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ #define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ #define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ #define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ /* BusFault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ #define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ #define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ #define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ #define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ #define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ #define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ #define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ #define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ #define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ #define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ #define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ #define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ #define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ /* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ #define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ #define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ #define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ #define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ #define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ #define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ #define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ #define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ #define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ #define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ #define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ /* SCB Hard Fault Status Register Definitions */ #define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ #define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ #define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ /* SCB Debug Fault Status Register Definitions */ #define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ #define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ #define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ #define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ #define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ #define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ /*@} end of group CMSIS_SCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) \brief Type definitions for the System Control and ID Register not in the SCB @{ */ /** \brief Structure type to access the System Control and ID Register not in the SCB. */ typedef struct { uint32_t RESERVED0[1U]; __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ } SCnSCB_Type; /* Interrupt Controller Type Register Definitions */ #define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ /* Auxiliary Control Register Definitions */ #define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ #define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ #define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ #define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ #define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ #define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ #define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ #define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ /*@} end of group CMSIS_SCnotSCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SysTick System Tick Timer (SysTick) \brief Type definitions for the System Timer Registers. @{ */ /** \brief Structure type to access the System Timer (SysTick). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ } SysTick_Type; /* SysTick Control / Status Register Definitions */ #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ /* SysTick Reload Register Definitions */ #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ /* SysTick Current Register Definitions */ #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ /* SysTick Calibration Register Definitions */ #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ /*@} end of group CMSIS_SysTick */ /** \ingroup CMSIS_core_register \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) \brief Type definitions for the Instrumentation Trace Macrocell (ITM) @{ */ /** \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). */ typedef struct { __OM union { __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ uint32_t RESERVED0[864U]; __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ uint32_t RESERVED1[15U]; __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ uint32_t RESERVED2[15U]; __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ uint32_t RESERVED3[32U]; uint32_t RESERVED4[43U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ uint32_t RESERVED5[6U]; __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ } ITM_Type; /* ITM Trace Privilege Register Definitions */ #define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ #define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ /* ITM Trace Control Register Definitions */ #define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ #define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ #define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ #define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ #define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ #define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ #define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ #define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ #define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ #define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ #define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ /* ITM Lock Status Register Definitions */ #define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ #define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ #define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ #define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ #define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ /*@}*/ /* end of group CMSIS_ITM */ /** \ingroup CMSIS_core_register \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) \brief Type definitions for the Data Watchpoint and Trace (DWT) @{ */ /** \brief Structure type to access the Data Watchpoint and Trace Register (DWT). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ uint32_t RESERVED0[1U]; __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ uint32_t RESERVED1[1U]; __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ uint32_t RESERVED2[1U]; __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ } DWT_Type; /* DWT Control Register Definitions */ #define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ #define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ #define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ #define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ #define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ #define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ #define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ #define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ #define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ #define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ #define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ #define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ #define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ #define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ #define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ #define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ #define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ #define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ #define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ #define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ #define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ #define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ #define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ #define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ #define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ #define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ #define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ #define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ #define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ #define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ #define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ #define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ #define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ #define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ #define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ #define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ /* DWT CPI Count Register Definitions */ #define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ #define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ /* DWT Exception Overhead Count Register Definitions */ #define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ #define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ /* DWT Sleep Count Register Definitions */ #define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ #define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ /* DWT LSU Count Register Definitions */ #define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ #define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ /* DWT Folded-instruction Count Register Definitions */ #define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ #define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ /* DWT Comparator Mask Register Definitions */ #define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ #define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ /* DWT Comparator Function Register Definitions */ #define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ #define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ #define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ #define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ #define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ #define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ #define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ #define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ #define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ #define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ #define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ #define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ #define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ #define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ #define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ #define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ #define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ #define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ /*@}*/ /* end of group CMSIS_DWT */ /** \ingroup CMSIS_core_register \defgroup CMSIS_TPI Trace Port Interface (TPI) \brief Type definitions for the Trace Port Interface (TPI) @{ */ /** \brief Structure type to access the Trace Port Interface Register (TPI). */ typedef struct { __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ uint32_t RESERVED0[2U]; __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ uint32_t RESERVED1[55U]; __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ uint32_t RESERVED2[131U]; __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ uint32_t RESERVED3[759U]; __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ uint32_t RESERVED4[1U]; __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ uint32_t RESERVED5[39U]; __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ uint32_t RESERVED7[8U]; __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ } TPI_Type; /* TPI Asynchronous Clock Prescaler Register Definitions */ #define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ #define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ /* TPI Selected Pin Protocol Register Definitions */ #define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ #define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ /* TPI Formatter and Flush Status Register Definitions */ #define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ #define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ #define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ #define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ #define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ #define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ #define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ #define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ /* TPI Formatter and Flush Control Register Definitions */ #define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ #define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ #define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ #define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ /* TPI TRIGGER Register Definitions */ #define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ #define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ /* TPI Integration ETM Data Register Definitions (FIFO0) */ #define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ #define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ #define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ #define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ #define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ #define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ #define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ #define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ #define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ #define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ #define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ #define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ /* TPI ITATBCTR2 Register Definitions */ #define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ #define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ #define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ #define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ /* TPI Integration ITM Data Register Definitions (FIFO1) */ #define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ #define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ #define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ #define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ #define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ #define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ #define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ #define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ #define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ #define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ #define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ #define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ /* TPI ITATBCTR0 Register Definitions */ #define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ #define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ #define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ #define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ /* TPI Integration Mode Control Register Definitions */ #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ #define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ /* TPI DEVID Register Definitions */ #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ #define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ #define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ #define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ #define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ #define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ #define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ #define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ #define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ #define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ #define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ #define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ /* TPI DEVTYPE Register Definitions */ #define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ #define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ #define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ /*@}*/ /* end of group CMSIS_TPI */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_MPU Memory Protection Unit (MPU) \brief Type definitions for the Memory Protection Unit (MPU) @{ */ /** \brief Structure type to access the Memory Protection Unit (MPU). */ typedef struct { __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ } MPU_Type; #define MPU_TYPE_RALIASES 4U /* MPU Type Register Definitions */ #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ #define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ #define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ #define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ /* MPU Control Register Definitions */ #define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ #define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ #define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ #define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ /* MPU Region Number Register Definitions */ #define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ #define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ /* MPU Region Base Address Register Definitions */ #define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ #define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ #define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ #define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ /* MPU Region Attribute and Size Register Definitions */ #define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ #define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ #define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ #define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ #define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ #define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ #define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ #define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ #define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ #define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ #define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ /*@} end of group CMSIS_MPU */ #endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ /** \ingroup CMSIS_core_register \defgroup CMSIS_FPU Floating Point Unit (FPU) \brief Type definitions for the Floating Point Unit (FPU) @{ */ /** \brief Structure type to access the Floating Point Unit (FPU). */ typedef struct { uint32_t RESERVED0[1U]; __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ } FPU_Type; /* Floating-Point Context Control Register Definitions */ #define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ #define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ #define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ #define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ #define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ #define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ #define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ #define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ #define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ #define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ #define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ #define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ #define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ #define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ #define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ #define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ #define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ #define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ /* Floating-Point Context Address Register Definitions */ #define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ #define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ /* Floating-Point Default Status Control Register Definitions */ #define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ #define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ #define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ #define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ #define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ #define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ #define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ #define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ /* Media and FP Feature Register 0 Definitions */ #define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ #define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ #define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ #define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ #define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ #define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ #define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ #define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ #define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ #define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ #define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ #define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ #define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ #define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ #define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ #define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ /* Media and FP Feature Register 1 Definitions */ #define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ #define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ #define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ #define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ #define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ #define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ #define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ #define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ /* Media and FP Feature Register 2 Definitions */ #define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ #define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ /*@} end of group CMSIS_FPU */ /** \ingroup CMSIS_core_register \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) \brief Type definitions for the Core Debug Registers @{ */ /** \brief Structure type to access the Core Debug Register (CoreDebug). */ typedef struct { __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ } CoreDebug_Type; /* Debug Halting Control and Status Register Definitions */ #define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ #define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ #define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ #define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ #define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ #define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ #define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ #define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ #define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ /* Debug Core Register Selector Register Definitions */ #define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ #define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ /* Debug Exception and Monitor Control Register Definitions */ #define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ #define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ #define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ #define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ #define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ #define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ #define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ #define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ #define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ #define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ #define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ #define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ /*@} end of group CMSIS_CoreDebug */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_bitfield Core register bit field macros \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). @{ */ /** \brief Mask and shift a bit field value for use in a register bit range. \param[in] field Name of the register bit field. \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. \return Masked and shifted value. */ #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) /** \brief Mask and shift a register value to extract a bit filed value. \param[in] field Name of the register bit field. \param[in] value Value of register. This parameter is interpreted as an uint32_t type. \return Masked and shifted bit field value. */ #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) /*@} end of group CMSIS_core_bitfield */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_base Core Definitions \brief Definitions for base addresses, unions, and structures. @{ */ /* Memory mapping of Core Hardware */ #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ #endif #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ /*@} */ /******************************************************************************* * Hardware Abstraction Layer Core Function Interface contains: - Core NVIC Functions - Core SysTick Functions - Core Debug Functions - Core Register Access Functions ******************************************************************************/ /** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference */ /* ########################## NVIC functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_NVICFunctions NVIC Functions \brief Functions that manage interrupts and exceptions via the NVIC. @{ */ #ifdef CMSIS_NVIC_VIRTUAL #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" #endif #include CMSIS_NVIC_VIRTUAL_HEADER_FILE #else #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping #define NVIC_EnableIRQ __NVIC_EnableIRQ #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ #define NVIC_DisableIRQ __NVIC_DisableIRQ #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ #define NVIC_GetActive __NVIC_GetActive #define NVIC_SetPriority __NVIC_SetPriority #define NVIC_GetPriority __NVIC_GetPriority #define NVIC_SystemReset __NVIC_SystemReset #endif /* CMSIS_NVIC_VIRTUAL */ #ifdef CMSIS_VECTAB_VIRTUAL #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" #endif #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE #else #define NVIC_SetVector __NVIC_SetVector #define NVIC_GetVector __NVIC_GetVector #endif /* (CMSIS_VECTAB_VIRTUAL) */ #define NVIC_USER_IRQ_OFFSET 16 /* The following EXC_RETURN values are saved the LR on exception entry */ #define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ #define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ #define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ #define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ #define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ #define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ /** \brief Set Priority Grouping \details Sets the priority grouping field using the required unlock sequence. The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Priority grouping field. */ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ reg_value = SCB->AIRCR; /* read old register configuration */ reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } /** \brief Get Priority Grouping \details Reads the priority grouping field from the NVIC Interrupt Controller. \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). */ __STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) { return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); } /** \brief Enable Interrupt \details Enables a device specific interrupt in the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { __COMPILER_BARRIER(); NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); __COMPILER_BARRIER(); } } /** \brief Get Interrupt Enable status \details Returns a device specific interrupt enable status from the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt is not enabled. \return 1 Interrupt is enabled. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Disable Interrupt \details Disables a device specific interrupt in the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); __DSB(); __ISB(); } } /** \brief Get Pending Interrupt \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not pending. \return 1 Interrupt status is pending. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Set Pending Interrupt \details Sets the pending bit of a device specific interrupt in the NVIC pending register. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); } } /** \brief Clear Pending Interrupt \details Clears the pending bit of a device specific interrupt in the NVIC pending register. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); } } /** \brief Get Active Interrupt \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not active. \return 1 Interrupt status is active. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Set Interrupt Priority \details Sets the priority of a device specific interrupt or a processor exception. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \param [in] priority Priority to set. \note The priority cannot be set for every processor exception. */ __STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { if ((int32_t)(IRQn) >= 0) { NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } else { SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } } /** \brief Get Interrupt Priority \details Reads the priority of a device specific interrupt or a processor exception. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. */ __STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); } else { return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); } } /** \brief Encode Priority \details Encodes the priority for an interrupt with the given priority group, preemptive priority value, and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Used priority group. \param [in] PreemptPriority Preemptive priority value (starting from 0). \param [in] SubPriority Subpriority value (starting from 0). \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). */ __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); return ( ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) ); } /** \brief Decode Priority \details Decodes an interrupt priority value with a given priority group to preemptive priority value and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). \param [in] PriorityGroup Used priority group. \param [out] pPreemptPriority Preemptive priority value (starting from 0). \param [out] pSubPriority Subpriority value (starting from 0). */ __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); } /** \brief Set Interrupt Vector \details Sets an interrupt vector in SRAM based interrupt vector table. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. VTOR must been relocated to SRAM before. \param [in] IRQn Interrupt number \param [in] vector Address of interrupt handler function */ __STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { uint32_t vectors = (uint32_t )SCB->VTOR; (* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector; /* ARM Application Note 321 states that the M4 does not require the architectural barrier */ } /** \brief Get Interrupt Vector \details Reads an interrupt vector from interrupt vector table. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Address of interrupt handler function */ __STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) { uint32_t vectors = (uint32_t )SCB->VTOR; return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)); } /** \brief System Reset \details Initiates a system reset request to reset the MCU. */ __NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ __DSB(); /* Ensure completion of memory access */ for(;;) /* wait until reset */ { __NOP(); } } /*@} end of CMSIS_Core_NVICFunctions */ /* ########################## MPU functions #################################### */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #include "mpu_armv7.h" #endif /* ########################## FPU functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_FpuFunctions FPU Functions \brief Function that provides FPU type. @{ */ /** \brief get FPU type \details returns the FPU type \returns - \b 0: No FPU - \b 1: Single precision FPU - \b 2: Double + Single precision FPU */ __STATIC_INLINE uint32_t SCB_GetFPUType(void) { uint32_t mvfr0; mvfr0 = FPU->MVFR0; if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) { return 1U; /* Single precision FPU */ } else { return 0U; /* No FPU */ } } /*@} end of CMSIS_Core_FpuFunctions */ /* ################################## SysTick function ############################################ */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_SysTickFunctions SysTick Functions \brief Functions that configure the System. @{ */ #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) /** \brief System Tick Configuration \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. Counter is in free running mode to generate periodic interrupts. \param [in] ticks Number of ticks between two interrupts. \return 0 Function succeeded. \return 1 Function failed. \note When the variable __Vendor_SysTickConfig is set to 1, then the function SysTick_Config is not included. In this case, the file device.h must contain a vendor-specific implementation of this function. */ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) { if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) { return (1UL); /* Reload value impossible */ } SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ return (0UL); /* Function successful */ } #endif /*@} end of CMSIS_Core_SysTickFunctions */ /* ##################################### Debug In/Output function ########################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_core_DebugFunctions ITM Functions \brief Functions that access the ITM debug interface. @{ */ extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ #define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ /** \brief ITM Send Character \details Transmits a character via the ITM channel 0, and \li Just returns when no debugger is connected that has booked the output. \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. \param [in] ch Character to transmit. \returns Character to transmit. */ __STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) { if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ { while (ITM->PORT[0U].u32 == 0UL) { __NOP(); } ITM->PORT[0U].u8 = (uint8_t)ch; } return (ch); } /** \brief ITM Receive Character \details Inputs a character via the external variable \ref ITM_RxBuffer. \return Received character. \return -1 No character pending. */ __STATIC_INLINE int32_t ITM_ReceiveChar (void) { int32_t ch = -1; /* no character available */ if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) { ch = ITM_RxBuffer; ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ } return (ch); } /** \brief ITM Check Character \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. \return 0 No character available. \return 1 Character available. */ __STATIC_INLINE int32_t ITM_CheckChar (void) { if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) { return (0); /* no character available */ } else { return (1); /* character available */ } } /*@} end of CMSIS_core_DebugFunctions */ #ifdef __cplusplus } #endif #endif /* __CORE_CM4_H_DEPENDANT */ #endif /* __CMSIS_GENERIC */ ================================================ FILE: panda/board/stm32fx/inc/mpu_armv7.h ================================================ /****************************************************************************** * @file mpu_armv7.h * @brief CMSIS MPU API for Armv7-M MPU * @version V5.1.0 * @date 08. March 2019 ******************************************************************************/ /* * Copyright (c) 2017-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef ARM_MPU_ARMV7_H #define ARM_MPU_ARMV7_H #define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes #define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes #define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes #define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes #define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes #define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte #define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes #define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes #define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes #define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes #define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes #define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes #define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes #define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes #define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes #define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte #define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes #define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes #define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes #define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes #define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes #define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes #define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes #define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes #define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes #define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte #define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes #define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes #define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access #define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only #define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only #define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access #define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only #define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access /** MPU Region Base Address Register Value * * \param Region The region to be configured, number 0 to 15. * \param BaseAddress The base address for the region. */ #define ARM_MPU_RBAR(Region, BaseAddress) \ (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ ((Region) & MPU_RBAR_REGION_Msk) | \ (MPU_RBAR_VALID_Msk)) /** * MPU Memory Access Attributes * * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. * \param IsShareable Region is shareable between multiple bus masters. * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. */ #define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) /** * MPU Region Attribute and Size Register Value * * \param DisableExec Instruction access disable bit, 1= disable instruction fetches. * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. * \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. * \param SubRegionDisable Sub-region disable field. * \param Size Region size of the region to be configured, for example 4K, 8K. */ #define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ (((MPU_RASR_ENABLE_Msk)))) /** * MPU Region Attribute and Size Register Value * * \param DisableExec Instruction access disable bit, 1= disable instruction fetches. * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. * \param IsShareable Region is shareable between multiple bus masters. * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. * \param SubRegionDisable Sub-region disable field. * \param Size Region size of the region to be configured, for example 4K, 8K. */ #define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) /** * MPU Memory Access Attribute for strongly ordered memory. * - TEX: 000b * - Shareable * - Non-cacheable * - Non-bufferable */ #define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) /** * MPU Memory Access Attribute for device memory. * - TEX: 000b (if shareable) or 010b (if non-shareable) * - Shareable or non-shareable * - Non-cacheable * - Bufferable (if shareable) or non-bufferable (if non-shareable) * * \param IsShareable Configures the device memory as shareable or non-shareable. */ #define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) /** * MPU Memory Access Attribute for normal memory. * - TEX: 1BBb (reflecting outer cacheability rules) * - Shareable or non-shareable * - Cacheable or non-cacheable (reflecting inner cacheability rules) * - Bufferable or non-bufferable (reflecting inner cacheability rules) * * \param OuterCp Configures the outer cache policy. * \param InnerCp Configures the inner cache policy. * \param IsShareable Configures the memory as shareable or non-shareable. */ #define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U)) /** * MPU Memory Access Attribute non-cacheable policy. */ #define ARM_MPU_CACHEP_NOCACHE 0U /** * MPU Memory Access Attribute write-back, write and read allocate policy. */ #define ARM_MPU_CACHEP_WB_WRA 1U /** * MPU Memory Access Attribute write-through, no write allocate policy. */ #define ARM_MPU_CACHEP_WT_NWA 2U /** * MPU Memory Access Attribute write-back, no write allocate policy. */ #define ARM_MPU_CACHEP_WB_NWA 3U /** * Struct for a single MPU Region */ typedef struct { uint32_t RBAR; //!< The region base address register value (RBAR) uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR } ARM_MPU_Region_t; /** Enable the MPU. * \param MPU_Control Default access permissions for unconfigured regions. */ __STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) { MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; #ifdef SCB_SHCSR_MEMFAULTENA_Msk SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; #endif __DSB(); __ISB(); } /** Disable the MPU. */ __STATIC_INLINE void ARM_MPU_Disable(void) { __DMB(); #ifdef SCB_SHCSR_MEMFAULTENA_Msk SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; #endif MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; } /** Clear and disable the given MPU region. * \param rnr Region number to be cleared. */ __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) { MPU->RNR = rnr; MPU->RASR = 0U; } /** Configure an MPU region. * \param rbar Value for RBAR register. * \param rsar Value for RSAR register. */ __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) { MPU->RBAR = rbar; MPU->RASR = rasr; } /** Configure the given MPU region. * \param rnr Region number to be configured. * \param rbar Value for RBAR register. * \param rsar Value for RSAR register. */ __STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) { MPU->RNR = rnr; MPU->RBAR = rbar; MPU->RASR = rasr; } /** Memcopy with strictly ordered memory access, e.g. for register targets. * \param dst Destination data is copied to. * \param src Source data is copied from. * \param len Amount of data words to be copied. */ __STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) { uint32_t i; for (i = 0U; i < len; ++i) { dst[i] = src[i]; } } /** Load the given number of MPU regions from a table. * \param table Pointer to the MPU configuration table. * \param cnt Amount of regions to be configured. */ __STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) { const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; while (cnt > MPU_TYPE_RALIASES) { ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); table += MPU_TYPE_RALIASES; cnt -= MPU_TYPE_RALIASES; } ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); } #endif ================================================ FILE: panda/board/stm32fx/inc/stm32f205xx.h ================================================ /** ****************************************************************************** * @file stm32f205xx.h * @author MCD Application Team * @version V2.1.2 * @date 29-June-2016 * @brief CMSIS STM32F205xx Device Peripheral Access Layer Header File. * This file contains : * - Data structures and the address mapping for all peripherals * - Peripherals registers declarations and bits definition * - Macros to access peripherals registers hardware * ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f205xx * @{ */ #ifndef __STM32F205xx_H #define __STM32F205xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M3 Processor and Core Peripherals */ #define __CM3_REV 0x0200U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F2XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F2XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F2XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M3 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M3 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M3 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M3 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M3 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M3 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M3 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M3 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FSMC_IRQn = 48, /*!< FSMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ HASH_RNG_IRQn = 80 /*!< Hash and RNG global interrupt */ } IRQn_Type; /** * @} */ #include "core_cm3.h" #include "system_stm32f2xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register, Address offset: 0x14 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief Flexible Static Memory Controller Bank2 */ typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ uint32_t RESERVED0; /*!< Reserved, 0x70 */ __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ uint32_t RESERVED1; /*!< Reserved, 0x78 */ uint32_t RESERVED2; /*!< Reserved, 0x7C */ __IO uint32_t PCR3; /*!< NAND Flash control register 3, Address offset: 0x80 */ __IO uint32_t SR3; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ __IO uint32_t PMEM3; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ __IO uint32_t PATT3; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ uint32_t RESERVED3; /*!< Reserved, 0x90 */ __IO uint32_t ECCR3; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FSMC_Bank2_3_TypeDef; /** * @brief Flexible Static Memory Controller Bank4 */ typedef struct { __IO uint32_t PCR4; /*!< PC Card control register 4, Address offset: 0xA0 */ __IO uint32_t SR4; /*!< PC Card FIFO status and interrupt register 4, Address offset: 0xA4 */ __IO uint32_t PMEM4; /*!< PC Card Common memory space timing register 4, Address offset: 0xA8 */ __IO uint32_t PATT4; /*!< PC Card Attribute memory space timing register 4, Address offset: 0xAC */ __IO uint32_t PIO4; /*!< PC Card I/O space timing register 4, Address offset: 0xB0 */ } FSMC_Bank4_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED[2]; /*!< Reserved, 0x18-0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ uint32_t RESERVED1; /*!< Reserved, 0x28 */ uint32_t RESERVED2; /*!< Reserved, 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ uint32_t RESERVED3; /*!< Reserved, 0x38 */ uint32_t RESERVED4; /*!< Reserved, 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ uint32_t RESERVED5; /*!< Reserved, 0x44 */ uint32_t RESERVED6; /*!< Reserved, 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief __USB_OTG_Core_register */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register Address offset : 0x00 */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register Address offset : 0x04 */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register Address offset : 0x08 */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register Address offset : 0x0C */ __IO uint32_t GRSTCTL; /*!< Core Reset Register Address offset : 0x10 */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register Address offset : 0x14 */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register Address offset : 0x18 */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register Address offset : 0x1C */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register Address offset : 0x20 */ __IO uint32_t GRXFSIZ; /* Receive FIFO Size Register Address offset : 0x24 */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register Address offset : 0x28 */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg Address offset : 0x2C */ uint32_t Reserved30[2]; /* Reserved Address offset : 0x30 */ __IO uint32_t GCCFG; /*!< General Purpose IO Register Address offset : 0x38 */ __IO uint32_t CID; /*!< User ID Register Address offset : 0x3C */ uint32_t Reserved40[48]; /*!< Reserved Address offset : 0x40-0xFF */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg Address offset : 0x100 */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief __device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register Address offset : 0x800 */ __IO uint32_t DCTL; /*!< dev Control Register Address offset : 0x804 */ __IO uint32_t DSTS; /*!< dev Status Register (RO) Address offset : 0x808 */ uint32_t Reserved0C; /*!< Reserved Address offset : 0x80C */ __IO uint32_t DIEPMSK; /* !< dev IN Endpoint Mask Address offset : 0x810 */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask Address offset : 0x814 */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg Address offset : 0x818 */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask Address offset : 0x81C */ uint32_t Reserved20; /*!< Reserved Address offset : 0x820 */ uint32_t Reserved9; /*!< Reserved Address offset : 0x824 */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register Address offset : 0x828 */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register Address offset : 0x82C */ __IO uint32_t DTHRCTL; /*!< dev thr Address offset : 0x830 */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk Address offset : 0x834 */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt Address offset : 0x838 */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk Address offset : 0x83C */ uint32_t Reserved40; /*!< dedicated EP mask Address offset : 0x840 */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask Address offset : 0x844 */ uint32_t Reserved44[15]; /*!< Reserved Address offset : 0x844-0x87C */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk Address offset : 0x884 */ } USB_OTG_DeviceTypeDef; /** * @brief __IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /* dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /* Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /* dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /* Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /* IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /* IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /* Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief __OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /* dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h*/ uint32_t Reserved04; /* Reserved B00h + (ep_num * 20h) + 04h*/ __IO uint32_t DOEPINT; /* dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h*/ uint32_t Reserved0C; /* Reserved B00h + (ep_num * 20h) + 0Ch*/ __IO uint32_t DOEPTSIZ; /* dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h*/ __IO uint32_t DOEPDMA; /* dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h*/ uint32_t Reserved18[2]; /* Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch*/ } USB_OTG_OUTEndpointTypeDef; /** * @brief __Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /* Host Configuration Register 400h*/ __IO uint32_t HFIR; /* Host Frame Interval Register 404h*/ __IO uint32_t HFNUM; /* Host Frame Nbr/Frame Remaining 408h*/ uint32_t Reserved40C; /* Reserved 40Ch*/ __IO uint32_t HPTXSTS; /* Host Periodic Tx FIFO/ Queue Status 410h*/ __IO uint32_t HAINT; /* Host All Channels Interrupt Register 414h*/ __IO uint32_t HAINTMSK; /* Host All Channels Interrupt Mask 418h*/ } USB_OTG_HostTypeDef; /** * @brief __Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; __IO uint32_t HCSPLT; __IO uint32_t HCINT; __IO uint32_t HCINTMSK; __IO uint32_t HCTSIZ; __IO uint32_t HCDMA; uint32_t Reserved[2]; } USB_OTG_HostChannelTypeDef; /** * @brief Peripheral_memory_map */ #define FLASH_BASE 0x08000000U /*!< FLASH(up to 1 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000U /*!< SRAM1(112 KB) base address in the alias region */ #define SRAM2_BASE 0x2001C000U /*!< SRAM2(16 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000U /*!< Peripheral base address in the alias region */ #define BKPSRAM_BASE 0x40024000U /*!< Backup SRAM(4 KB) base address in the alias region */ #define FSMC_R_BASE 0xA0000000U /*!< FSMC registers base address */ #define SRAM1_BB_BASE 0x22000000U /*!< SRAM1(112 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22380000U /*!< SRAM2(16 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000U /*!< Peripheral base address in the bit-band region */ #define BKPSRAM_BB_BASE 0x42480000U /*!< Backup SRAM(4 KB) base address in the bit-band region */ #define FLASH_END 0x080FFFFFU /*!< FLASH end address */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000U) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000U) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000U) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000U) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400U) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800U) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00U) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000U) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400U) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800U) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00U) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000U) #define RTC_BASE (APB1PERIPH_BASE + 0x2800U) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00U) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000U) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800U) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00U) #define USART2_BASE (APB1PERIPH_BASE + 0x4400U) #define USART3_BASE (APB1PERIPH_BASE + 0x4800U) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00U) #define UART5_BASE (APB1PERIPH_BASE + 0x5000U) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400U) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800U) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00U) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400U) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800U) #define PWR_BASE (APB1PERIPH_BASE + 0x7000U) #define DAC_BASE (APB1PERIPH_BASE + 0x7400U) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000U) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400U) #define USART1_BASE (APB2PERIPH_BASE + 0x1000U) #define USART6_BASE (APB2PERIPH_BASE + 0x1400U) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000U) #define ADC2_BASE (APB2PERIPH_BASE + 0x2100U) #define ADC3_BASE (APB2PERIPH_BASE + 0x2200U) #define ADC_BASE (APB2PERIPH_BASE + 0x2300U) #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00U) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000U) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800U) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00U) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000U) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400U) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800U) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000U) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400U) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800U) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00U) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000U) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400U) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800U) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00U) #define GPIOI_BASE (AHB1PERIPH_BASE + 0x2000U) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000U) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800U) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00U) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000U) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010U) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028U) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040U) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058U) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070U) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088U) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0U) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8U) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400U) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010U) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028U) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040U) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058U) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070U) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088U) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0U) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8U) /*!< AHB2 peripherals */ #define RNG_BASE (AHB2PERIPH_BASE + 0x60800U) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000U) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104U) #define FSMC_Bank2_3_R_BASE (FSMC_R_BASE + 0x0060U) #define FSMC_Bank4_R_BASE (FSMC_R_BASE + 0x00A0U) /* Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000U /*!< USB registers base address */ #define USB_OTG_HS_PERIPH_BASE 0x40040000U #define USB_OTG_FS_PERIPH_BASE 0x50000000U #define USB_OTG_GLOBAL_BASE 0x000U #define USB_OTG_DEVICE_BASE 0x800U #define USB_OTG_IN_ENDPOINT_BASE 0x900U #define USB_OTG_OUT_ENDPOINT_BASE 0xB00U #define USB_OTG_EP_REG_SIZE 0x20U #define USB_OTG_HOST_BASE 0x400U #define USB_OTG_HOST_PORT_BASE 0x440U #define USB_OTG_HOST_CHANNEL_BASE 0x500U #define USB_OTG_HOST_CHANNEL_SIZE 0x20U #define USB_OTG_PCGCCTL_BASE 0xE00U #define USB_OTG_FIFO_BASE 0x1000U #define USB_OTG_FIFO_SIZE 0x1000U /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define ADC ((ADC_Common_TypeDef *) ADC_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define GPIOI ((GPIO_TypeDef *) GPIOI_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define FSMC_Bank2_3 ((FSMC_Bank2_3_TypeDef *) FSMC_Bank2_3_R_BASE) #define FSMC_Bank4 ((FSMC_Bank4_TypeDef *) FSMC_Bank4_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) #define USB_OTG_HS ((USB_OTG_GlobalTypeDef *) USB_OTG_HS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD 0x00000001U /*!
© COPYRIGHT(c) 2016 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f2xx * @{ */ #ifndef __STM32F2xx_H #define __STM32F2xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Library_configuration_section * @{ */ /** * @brief STM32 Family */ #if !defined (STM32F2) #define STM32F2 #endif /* STM32F2 */ /* Uncomment the line below according to the target STM32 device used in your application */ /* #if !defined (STM32F205xx) && !defined (STM32F215xx) && !defined (STM32F207xx) && !defined (STM32F217xx) */ /* #define STM32F205xx */ /*!< STM32F205RG, STM32F205VG, STM32F205ZG, STM32F205RF, STM32F205VF, STM32F205ZF, STM32F205RE, STM32F205VE, STM32F205ZE, STM32F205RC, STM32F205VC, STM32F205ZC, STM32F205RB and STM32F205VB Devices */ /* #define STM32F215xx */ /*!< STM32F215RG, STM32F215VG, STM32F215ZG, STM32F215RE, STM32F215VE and STM32F215ZE Devices */ /* #define STM32F207xx */ /*!< STM32F207VG, STM32F207ZG, STM32F207IG, STM32F207VF, STM32F207ZF, STM32F207IF, STM32F207VE, STM32F207ZE, STM32F207IE, STM32F207VC, STM32F207ZC and STM32F207IC Devices */ /* #define STM32F217xx */ /*!< STM32F217VG, STM32F217ZG, STM32F217IG, STM32F217VE, STM32F217ZE and STM32F217IE Devices */ //#endif /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. */ #if !defined (USE_HAL_DRIVER) /** * @brief Comment the line below if you will not use the peripherals drivers. In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ /*#define USE_HAL_DRIVER */ #endif /* USE_HAL_DRIVER */ /** * @brief CMSIS Device version number V2.1.2 */ #define __STM32F2xx_CMSIS_VERSION_MAIN (0x02U) /*!< [31:24] main version */ #define __STM32F2xx_CMSIS_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ #define __STM32F2xx_CMSIS_VERSION_SUB2 (0x02U) /*!< [15:8] sub2 version */ #define __STM32F2xx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32F2xx_CMSIS_VERSION ((__STM32F2xx_CMSIS_VERSION_MAIN << 24)\ |(__STM32F2xx_CMSIS_VERSION_SUB1 << 16)\ |(__STM32F2xx_CMSIS_VERSION_SUB2 << 8 )\ |(__STM32F2xx_CMSIS_VERSION)) /** * @} */ /** @addtogroup Device_Included * @{ */ #if defined(STM32F215xx) #include "stm32f215xx.h" #elif defined(STM32F205xx) #include "stm32f205xx.h" // #elif defined(STM32F207xx) // #include "stm32f207xx.h" // #elif defined(STM32F217xx) // #include "stm32f217xx.h" #else #error "Please select first the target STM32F2xx device used in your application (in stm32f2xx.h file)" #endif /** * @} */ /** @addtogroup Exported_types * @{ */ typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus; typedef enum { DISABLE = 0, ENABLE = !DISABLE } FunctionalState; #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) typedef enum { ERROR = 0, SUCCESS = !ERROR } ErrorStatus; /** * @} */ /** @addtogroup Exported_macro * @{ */ #define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) #define READ_BIT(REG, BIT) ((REG) & (BIT)) #define CLEAR_REG(REG) ((REG) = (0x0)) #define WRITE_REG(REG, VAL) ((REG) = (VAL)) #define READ_REG(REG) ((REG)) #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) /** * @} */ #if defined (USE_HAL_DRIVER) #include "stm32f2xx_hal.h" #endif /* USE_HAL_DRIVER */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __STM32F2xx_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/stm32f2xx_hal_def.h ================================================ /** ****************************************************************************** * @file stm32f2xx_hal_def.h * @author MCD Application Team * @version V1.1.3 * @date 29-June-2016 * @brief This file contains HAL common defines, enumeration, macros and * structures definitions. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F2xx_HAL_DEF #define __STM32F2xx_HAL_DEF #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f2xx.h" //#include "Legacy/stm32_hal_legacy.h" //#include /* Exported types ------------------------------------------------------------*/ /** * @brief HAL Status structures definition */ typedef enum { HAL_OK = 0x00U, HAL_ERROR = 0x01U, HAL_BUSY = 0x02U, HAL_TIMEOUT = 0x03U } HAL_StatusTypeDef; /** * @brief HAL Lock structures definition */ typedef enum { HAL_UNLOCKED = 0x00U, HAL_LOCKED = 0x01U } HAL_LockTypeDef; /* Exported macro ------------------------------------------------------------*/ #define HAL_MAX_DELAY 0xFFFFFFFFU #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ do{ \ (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ (__DMA_HANDLE_).Parent = (__HANDLE__); \ } while(0) #define UNUSED(x) ((void)(x)) /** @brief Reset the Handle's State field. * @param __HANDLE__: specifies the Peripheral Handle. * @note This macro can be used for the following purpose: * - When the Handle is declared as local variable; before passing it as parameter * to HAL_PPP_Init() for the first time, it is mandatory to use this macro * to set to 0 the Handle's "State" field. * Otherwise, "State" field may have any random value and the first time the function * HAL_PPP_Init() is called, the low level hardware initialization will be missed * (i.e. HAL_PPP_MspInit() will not be executed). * - When there is a need to reconfigure the low level hardware: instead of calling * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). * In this later function, when the Handle's "State" field is set to 0, it will execute the function * HAL_PPP_MspInit() which will reconfigure the low level hardware. * @retval None */ #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) #if (USE_RTOS == 1) /* Reserved for future use */ #error " USE_RTOS should be 0 in the current HAL release " #else #define __HAL_LOCK(__HANDLE__) \ do{ \ if((__HANDLE__)->Lock == HAL_LOCKED) \ { \ return HAL_BUSY; \ } \ else \ { \ (__HANDLE__)->Lock = HAL_LOCKED; \ } \ }while (0) #define __HAL_UNLOCK(__HANDLE__) \ do{ \ (__HANDLE__)->Lock = HAL_UNLOCKED; \ }while (0) #endif /* USE_RTOS */ #if defined ( __GNUC__ ) #ifndef __weak #define __weak __attribute__((weak)) #endif /* __weak */ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed */ #endif /* __GNUC__ */ /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ #if defined (__GNUC__) /* GNU Compiler */ #ifndef __ALIGN_END #define __ALIGN_END __attribute__ ((aligned (4))) #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #define __ALIGN_BEGIN #endif /* __ALIGN_BEGIN */ #else #ifndef __ALIGN_END #define __ALIGN_END #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #if defined (__CC_ARM) /* ARM Compiler */ #define __ALIGN_BEGIN __align(4) #elif defined (__ICCARM__) /* IAR Compiler */ #define __ALIGN_BEGIN #endif /* __CC_ARM */ #endif /* __ALIGN_BEGIN */ #endif /* __GNUC__ */ /** * @brief __NOINLINE definition */ #if defined ( __CC_ARM ) || defined ( __GNUC__ ) /* ARM & GNUCompiler ---------------- */ #define __NOINLINE __attribute__ ( (noinline) ) #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- */ #define __NOINLINE _Pragma("optimize = no_inline") #endif #ifdef __cplusplus } #endif #endif /* ___STM32F2xx_HAL_DEF */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/stm32f2xx_hal_gpio_ex.h ================================================ /** ****************************************************************************** * @file stm32f2xx_hal_gpio_ex.h * @author MCD Application Team * @version V1.1.3 * @date 29-June-2016 * @brief Header file of GPIO HAL Extension module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F2xx_HAL_GPIO_EX_H #define __STM32F2xx_HAL_GPIO_EX_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f2xx_hal_def.h" /** @addtogroup STM32F2xx_HAL_Driver * @{ */ /** @defgroup GPIOEx GPIOEx * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants * @{ */ /** @defgroup GPIO_Alternate_function_selection GPIO Alternate function selection * @{ */ /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0xAU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0xAU) /* OTG_HS Alternate Function mapping */ /** * @brief AF 11 selection */ #if defined(STM32F207xx) || defined(STM32F217xx) #define GPIO_AF11_ETH ((uint8_t)0x0BU) /* ETHERNET Alternate Function mapping */ #endif /* STM32F207xx || STM32F217xx */ /** * @brief AF 12 selection */ #define GPIO_AF12_FSMC ((uint8_t)0xCU) /* FSMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0xCU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0xCU) /* SDIO Alternate Function mapping */ /** * @brief AF 13 selection */ #if defined(STM32F207xx) || defined(STM32F217xx) #define GPIO_AF13_DCMI ((uint8_t)0x0DU) /* DCMI Alternate Function mapping */ #endif /* STM32F207xx || STM32F217xx */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros * @{ */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions * @{ */ /** * @} */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Constants GPIO Private Constants * @{ */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Macros GPIO Private Macros * @{ */ /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index * @{ */ #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ ((__GPIOx__) == (GPIOB))? 1U :\ ((__GPIOx__) == (GPIOC))? 2U :\ ((__GPIOx__) == (GPIOD))? 3U :\ ((__GPIOx__) == (GPIOE))? 4U :\ ((__GPIOx__) == (GPIOF))? 5U :\ ((__GPIOx__) == (GPIOG))? 6U :\ ((__GPIOx__) == (GPIOH))? 7U :\ ((__GPIOx__) == (GPIOI))? 8U : 9U) /** * @} */ /** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function * @{ */ #if defined(STM32F207xx) || defined(STM32F217xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) #else /* STM32F207xx || STM32F217xx */ #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF12_OTG_HS_FS) || ((AF) == GPIO_AF12_SDIO) || \ ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) #endif /* STM32F207xx || STM32F217xx */ /** * @} */ /** * @} */ /* Private functions ---------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Functions GPIO Private Functions * @{ */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F2xx_HAL_GPIO_EX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/stm32f413xx.h ================================================ /** ****************************************************************************** * @file stm32f413xx.h * @author MCD Application Team * @version V2.6.0 * @date 04-November-2016 * @brief CMSIS STM32F413xx Device Peripheral Access Layer Header File. * * This file contains: * - Data structures and the address mapping for all peripherals * - peripherals registers declarations and bits definition * - Macros to access peripheral’s registers hardware * ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32f413xx * @{ */ #ifndef __STM32F413xx_H #define __STM32F413xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Configuration_section_for_CMSIS * @{ */ /** * @brief Configuration of the Cortex-M4 Processor and Core Peripherals */ #define __CM4_REV 0x0001U /*!< Core revision r0p1 */ #define __MPU_PRESENT 1U /*!< STM32F4XX provides an MPU */ #define __NVIC_PRIO_BITS 4U /*!< STM32F4XX uses 4 Bits for the Priority Levels */ #define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ #define __FPU_PRESENT 1U /*!< FPU present */ /** * @} */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32F4XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M4 Processor Exceptions Numbers ****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M4 Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M4 Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M4 Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M4 SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M4 Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M4 Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M4 System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt */ PVD_IRQn = 1, /*!< PVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1, ADC2 and ADC3 global Interrupts */ CAN1_TX_IRQn = 19, /*!< CAN1 TX Interrupt */ CAN1_RX0_IRQn = 20, /*!< CAN1 RX0 Interrupt */ CAN1_RX1_IRQn = 21, /*!< CAN1 RX1 Interrupt */ CAN1_SCE_IRQn = 22, /*!< CAN1 SCE Interrupt */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_TIM9_IRQn = 24, /*!< TIM1 Break interrupt and TIM9 global interrupt */ TIM1_UP_TIM10_IRQn = 25, /*!< TIM1 Update Interrupt and TIM10 global interrupt */ TIM1_TRG_COM_TIM11_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt and TIM11 global interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ OTG_FS_WKUP_IRQn = 42, /*!< USB OTG FS Wakeup through EXTI line interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare global interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FSMC_IRQn = 48, /*!< FSMC global Interrupt */ SDIO_IRQn = 49, /*!< SDIO global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ DFSDM1_FLT0_IRQn = 61, /*!< DFSDM1 Filter 0 global Interrupt */ DFSDM1_FLT1_IRQn = 62, /*!< DFSDM1 Filter 1 global Interrupt */ CAN2_TX_IRQn = 63, /*!< CAN2 TX Interrupt */ CAN2_RX0_IRQn = 64, /*!< CAN2 RX0 Interrupt */ CAN2_RX1_IRQn = 65, /*!< CAN2 RX1 Interrupt */ CAN2_SCE_IRQn = 66, /*!< CAN2 SCE Interrupt */ OTG_FS_IRQn = 67, /*!< USB OTG FS global Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ CAN3_TX_IRQn = 74, /*!< CAN3 TX Interrupt */ CAN3_RX0_IRQn = 75, /*!< CAN3 RX0 Interrupt */ CAN3_RX1_IRQn = 76, /*!< CAN3 RX1 Interrupt */ CAN3_SCE_IRQn = 77, /*!< CAN3 SCE Interrupt */ RNG_IRQn = 80, /*!< RNG global Interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ UART7_IRQn = 82, /*!< UART7 global interrupt */ UART8_IRQn = 83, /*!< UART8 global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ UART9_IRQn = 88, /*!< UART9 global Interrupt */ UART10_IRQn = 89, /*!< UART10 global Interrupt */ QUADSPI_IRQn = 92, /*!< QuadSPI global Interrupt */ FMPI2C1_EV_IRQn = 95, /*!< FMPI2C1 Event Interrupt */ FMPI2C1_ER_IRQn = 96, /*!< FMPI2C1 Error Interrupt */ LPTIM1_IRQn = 97, /*!< LP TIM1 interrupt */ DFSDM2_FLT0_IRQn = 98, /*!< DFSDM2 Filter 0 global Interrupt */ DFSDM2_FLT1_IRQn = 99, /*!< DFSDM2 Filter 1 global Interrupt */ DFSDM2_FLT2_IRQn = 100, /*!< DFSDM2 Filter 2 global Interrupt */ DFSDM2_FLT3_IRQn = 101 /*!< DFSDM2 Filter 3 global Interrupt */ } IRQn_Type; /** * @} */ #include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ #include "system_stm32f4xx.h" #include /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1 base address + 0x300 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1 base address + 0x304 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual AND triple modes, Address offset: ADC1 base address + 0x308 */ } ADC_Common_TypeDef; /** * @brief Controller Area Network TxMailBox */ typedef struct { __IO uint32_t TIR; /*!< CAN TX mailbox identifier register */ __IO uint32_t TDTR; /*!< CAN mailbox data length control and time stamp register */ __IO uint32_t TDLR; /*!< CAN mailbox data low register */ __IO uint32_t TDHR; /*!< CAN mailbox data high register */ } CAN_TxMailBox_TypeDef; /** * @brief Controller Area Network FIFOMailBox */ typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; /** * @brief Controller Area Network FilterRegister */ typedef struct { __IO uint32_t FR1; /*!< CAN Filter bank register 1 */ __IO uint32_t FR2; /*!< CAN Filter bank register 1 */ } CAN_FilterRegister_TypeDef; /** * @brief Controller Area Network */ typedef struct { __IO uint32_t MCR; /*!< CAN master control register, Address offset: 0x00 */ __IO uint32_t MSR; /*!< CAN master status register, Address offset: 0x04 */ __IO uint32_t TSR; /*!< CAN transmit status register, Address offset: 0x08 */ __IO uint32_t RF0R; /*!< CAN receive FIFO 0 register, Address offset: 0x0C */ __IO uint32_t RF1R; /*!< CAN receive FIFO 1 register, Address offset: 0x10 */ __IO uint32_t IER; /*!< CAN interrupt enable register, Address offset: 0x14 */ __IO uint32_t ESR; /*!< CAN error status register, Address offset: 0x18 */ __IO uint32_t BTR; /*!< CAN bit timing register, Address offset: 0x1C */ uint32_t RESERVED0[88]; /*!< Reserved, 0x020 - 0x17F */ CAN_TxMailBox_TypeDef sTxMailBox[3]; /*!< CAN Tx MailBox, Address offset: 0x180 - 0x1AC */ CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]; /*!< CAN FIFO MailBox, Address offset: 0x1B0 - 0x1CC */ uint32_t RESERVED1[12]; /*!< Reserved, 0x1D0 - 0x1FF */ __IO uint32_t FMR; /*!< CAN filter master register, Address offset: 0x200 */ __IO uint32_t FM1R; /*!< CAN filter mode register, Address offset: 0x204 */ uint32_t RESERVED2; /*!< Reserved, 0x208 */ __IO uint32_t FS1R; /*!< CAN filter scale register, Address offset: 0x20C */ uint32_t RESERVED3; /*!< Reserved, 0x210 */ __IO uint32_t FFA1R; /*!< CAN filter FIFO assignment register, Address offset: 0x214 */ uint32_t RESERVED4; /*!< Reserved, 0x218 */ __IO uint32_t FA1R; /*!< CAN filter activation register, Address offset: 0x21C */ uint32_t RESERVED5[8]; /*!< Reserved, 0x220-0x23F */ CAN_FilterRegister_TypeDef sFilterRegister[28]; /*!< CAN Filter Register, Address offset: 0x240-0x31C */ } CAN_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint8_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ uint8_t RESERVED0; /*!< Reserved, 0x05 */ uint16_t RESERVED1; /*!< Reserved, 0x06 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ } CRC_TypeDef; /** * @brief DFSDM module registers */ typedef struct { __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ } DFSDM_Filter_TypeDef; /** * @brief DFSDM channel configuration registers */ typedef struct { __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and short circuit detector register, Address offset: 0x08 */ __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ } DFSDM_Channel_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ } DAC_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ __IO uint32_t APB1FZ; /*!< Debug MCU APB1 freeze register, Address offset: 0x08 */ __IO uint32_t APB2FZ; /*!< Debug MCU APB2 freeze register, Address offset: 0x0C */ }DBGMCU_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t IMR; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t RTSR; /*!< EXTI Rising trigger selection register, Address offset: 0x08 */ __IO uint32_t FTSR; /*!< EXTI Falling trigger selection register, Address offset: 0x0C */ __IO uint32_t SWIER; /*!< EXTI Software interrupt event register, Address offset: 0x10 */ __IO uint32_t PR; /*!< EXTI Pending register, Address offset: 0x14 */ } EXTI_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR; /*!< FLASH key register, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< FLASH option key register, Address offset: 0x08 */ __IO uint32_t SR; /*!< FLASH status register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FLASH control register, Address offset: 0x10 */ __IO uint32_t OPTCR; /*!< FLASH option control register , Address offset: 0x14 */ __IO uint32_t OPTCR1; /*!< FLASH option control register 1, Address offset: 0x18 */ } FLASH_TypeDef; /** * @brief Flexible Static Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FSMC_Bank1_TypeDef; /** * @brief Flexible Static Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FSMC_Bank1E_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset register, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief System configuration controller */ typedef struct { __IO uint32_t MEMRMP; /*!< SYSCFG memory remap register, Address offset: 0x00 */ __IO uint32_t PMC; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ uint32_t RESERVED; /*!< Reserved, 0x18 */ __IO uint32_t CFGR2; /*!< SYSCFG Configuration register2, Address offset: 0x1C */ __IO uint32_t CMPCR; /*!< SYSCFG Compensation cell control register, Address offset: 0x20 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x24-0x28 */ __IO uint32_t CFGR; /*!< SYSCFG Configuration register, Address offset: 0x2C */ __IO uint32_t MCHDLYCR; /*!< SYSCFG multi-channel delay register, Address offset: 0x30 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address register 1, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address register 2, Address offset: 0x0C */ __IO uint32_t DR; /*!< I2C Data register, Address offset: 0x10 */ __IO uint32_t SR1; /*!< I2C Status register 1, Address offset: 0x14 */ __IO uint32_t SR2; /*!< I2C Status register 2, Address offset: 0x18 */ __IO uint32_t CCR; /*!< I2C Clock control register, Address offset: 0x1C */ __IO uint32_t TRISE; /*!< I2C TRISE register, Address offset: 0x20 */ __IO uint32_t FLTR; /*!< I2C FLTR register, Address offset: 0x24 */ } I2C_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< FMPI2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< FMPI2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< FMPI2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< FMPI2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< FMPI2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< FMPI2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< FMPI2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< FMPI2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< FMPI2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< FMPI2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< FMPI2C Transmit data register, Address offset: 0x28 */ } FMPI2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ } IWDG_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR; /*!< PWR power control register, Address offset: 0x00 */ __IO uint32_t CSR; /*!< PWR power control/status register, Address offset: 0x04 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t PLLCFGR; /*!< RCC PLL configuration register, Address offset: 0x04 */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x08 */ __IO uint32_t CIR; /*!< RCC clock interrupt register, Address offset: 0x0C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x10 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x14 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t APB1RSTR; /*!< RCC APB1 peripheral reset register, Address offset: 0x20 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x24 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0x30 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0x34 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0x38 */ uint32_t RESERVED2; /*!< Reserved, 0x3C */ __IO uint32_t APB1ENR; /*!< RCC APB1 peripheral clock enable register, Address offset: 0x40 */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock enable register, Address offset: 0x44 */ uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral clock enable in low power mode register, Address offset: 0x50 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral clock enable in low power mode register, Address offset: 0x54 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral clock enable in low power mode register, Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, 0x5C */ __IO uint32_t APB1LPENR; /*!< RCC APB1 peripheral clock enable in low power mode register, Address offset: 0x60 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral clock enable in low power mode register, Address offset: 0x64 */ uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */ __IO uint32_t BDCR; /*!< RCC Backup domain control register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */ __IO uint32_t SSCGR; /*!< RCC spread spectrum clock generation register, Address offset: 0x80 */ __IO uint32_t PLLI2SCFGR; /*!< RCC PLLI2S configuration register, Address offset: 0x84 */ uint32_t RESERVED7; /*!< Reserved, 0x84 */ __IO uint32_t DCKCFGR; /*!< RCC Dedicated Clocks configuration register, Address offset: 0x8C */ __IO uint32_t CKGATENR; /*!< RCC Clocks Gated ENable Register, Address offset: 0x90 */ __IO uint32_t DCKCFGR2; /*!< RCC Dedicated Clocks configuration register 2, Address offset: 0x94 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ __IO uint32_t CALIBR; /*!< RTC calibration register, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAFCR; /*!< RTC tamper and alternate function configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR;/*!< RTC alarm B sub second register, Address offset: 0x48 */ uint32_t RESERVED7; /*!< Reserved, 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 1, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ } RTC_TypeDef; /** * @brief Serial Audio Interface */ typedef struct { __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ } SAI_TypeDef; typedef struct { __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ } SAI_Block_TypeDef; /** * @brief SD host Interface */ typedef struct { __IO uint32_t POWER; /*!< SDIO power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDI clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDIO argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDIO command register, Address offset: 0x0C */ __IO const uint32_t RESPCMD; /*!< SDIO command response register, Address offset: 0x10 */ __IO const uint32_t RESP1; /*!< SDIO response 1 register, Address offset: 0x14 */ __IO const uint32_t RESP2; /*!< SDIO response 2 register, Address offset: 0x18 */ __IO const uint32_t RESP3; /*!< SDIO response 3 register, Address offset: 0x1C */ __IO const uint32_t RESP4; /*!< SDIO response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDIO data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDIO data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDIO data control register, Address offset: 0x2C */ __IO const uint32_t DCOUNT; /*!< SDIO data counter register, Address offset: 0x30 */ __IO const uint32_t STA; /*!< SDIO status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDIO interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDIO mask register, Address offset: 0x3C */ uint32_t RESERVED0[2]; /*!< Reserved, 0x40-0x44 */ __IO const uint32_t FIFOCNT; /*!< SDIO FIFO counter register, Address offset: 0x48 */ uint32_t RESERVED1[13]; /*!< Reserved, 0x4C-0x7C */ __IO uint32_t FIFO; /*!< SDIO data FIFO register, Address offset: 0x80 */ } SDIO_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI control register 2, Address offset: 0x04 */ __IO uint32_t SR; /*!< SPI status register, Address offset: 0x08 */ __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI RX CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI TX CRC register (not used in I2S mode), Address offset: 0x18 */ __IO uint32_t I2SCFGR; /*!< SPI_I2S configuration register, Address offset: 0x1C */ __IO uint32_t I2SPR; /*!< SPI_I2S prescaler register, Address offset: 0x20 */ } SPI_TypeDef; /** * @brief QUAD Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< QUADSPI Control register, Address offset: 0x00 */ __IO uint32_t DCR; /*!< QUADSPI Device Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< QUADSPI Status register, Address offset: 0x08 */ __IO uint32_t FCR; /*!< QUADSPI Flag Clear register, Address offset: 0x0C */ __IO uint32_t DLR; /*!< QUADSPI Data Length register, Address offset: 0x10 */ __IO uint32_t CCR; /*!< QUADSPI Communication Configuration register, Address offset: 0x14 */ __IO uint32_t AR; /*!< QUADSPI Address register, Address offset: 0x18 */ __IO uint32_t ABR; /*!< QUADSPI Alternate Bytes register, Address offset: 0x1C */ __IO uint32_t DR; /*!< QUADSPI Data register, Address offset: 0x20 */ __IO uint32_t PSMKR; /*!< QUADSPI Polling Status Mask register, Address offset: 0x24 */ __IO uint32_t PSMAR; /*!< QUADSPI Polling Status Match register, Address offset: 0x28 */ __IO uint32_t PIR; /*!< QUADSPI Polling Interval register, Address offset: 0x2C */ __IO uint32_t LPTR; /*!< QUADSPI Low Power Timeout register, Address offset: 0x30 */ } QUADSPI_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ __IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */ } TIM_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t SR; /*!< USART Status register, Address offset: 0x00 */ __IO uint32_t DR; /*!< USART Data register, Address offset: 0x04 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x0C */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x10 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x14 */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x18 */ } USART_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ } RNG_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ uint32_t Reserved5[3]; /*!< Reserved 040h-048h */ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ uint32_t Reserved; /*!< Reserved 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ uint32_t Reserved43[40]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @brief LPTIMER */ typedef struct { __IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */ __IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */ __IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */ __IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */ __IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */ __IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */ __IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */ __IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */ __IO uint32_t OR; /*!< LPTIM Option register, Address offset: 0x20 */ } LPTIM_TypeDef; /** * @} */ /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000U /*!< FLASH (up to 1.5 MB) base address in the alias region */ #define SRAM1_BASE 0x20000000U /*!< SRAM1(256 KB) base address in the alias region */ #define SRAM2_BASE 0x20040000U /*!< SRAM2(64 KB) base address in the alias region */ #define PERIPH_BASE 0x40000000U /*!< Peripheral base address in the alias region */ #define FSMC_R_BASE 0xA0000000U /*!< FSMC registers base address */ #define QSPI_R_BASE 0xA0001000U /*!< QuadSPI registers base address */ #define SRAM1_BB_BASE 0x22000000U /*!< SRAM1(256 KB) base address in the bit-band region */ #define SRAM2_BB_BASE 0x22800000U /*!< SRAM2(64 KB) base address in the bit-band region */ #define PERIPH_BB_BASE 0x42000000U /*!< Peripheral base address in the bit-band region */ #define FLASH_END 0x0817FFFFU /*!< FLASH end address */ /* Legacy defines */ #define SRAM_BASE SRAM1_BASE #define SRAM_BB_BASE SRAM1_BB_BASE /*!< Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000U) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000U) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000U) /*!< APB1 peripherals */ #define TIM2_BASE (APB1PERIPH_BASE + 0x0000U) #define TIM3_BASE (APB1PERIPH_BASE + 0x0400U) #define TIM4_BASE (APB1PERIPH_BASE + 0x0800U) #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00U) #define TIM6_BASE (APB1PERIPH_BASE + 0x1000U) #define TIM7_BASE (APB1PERIPH_BASE + 0x1400U) #define TIM12_BASE (APB1PERIPH_BASE + 0x1800U) #define TIM13_BASE (APB1PERIPH_BASE + 0x1C00U) #define TIM14_BASE (APB1PERIPH_BASE + 0x2000U) #define LPTIM1_BASE (APB1PERIPH_BASE + 0x2400U) #define RTC_BASE (APB1PERIPH_BASE + 0x2800U) #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00U) #define IWDG_BASE (APB1PERIPH_BASE + 0x3000U) #define I2S2ext_BASE (APB1PERIPH_BASE + 0x3400U) #define SPI2_BASE (APB1PERIPH_BASE + 0x3800U) #define SPI3_BASE (APB1PERIPH_BASE + 0x3C00U) #define I2S3ext_BASE (APB1PERIPH_BASE + 0x4000U) #define USART2_BASE (APB1PERIPH_BASE + 0x4400U) #define USART3_BASE (APB1PERIPH_BASE + 0x4800U) #define UART4_BASE (APB1PERIPH_BASE + 0x4C00U) #define UART5_BASE (APB1PERIPH_BASE + 0x5000U) #define I2C1_BASE (APB1PERIPH_BASE + 0x5400U) #define I2C2_BASE (APB1PERIPH_BASE + 0x5800U) #define I2C3_BASE (APB1PERIPH_BASE + 0x5C00U) #define FMPI2C1_BASE (APB1PERIPH_BASE + 0x6000U) #define CAN1_BASE (APB1PERIPH_BASE + 0x6400U) #define CAN2_BASE (APB1PERIPH_BASE + 0x6800U) #define CAN3_BASE (APB1PERIPH_BASE + 0x6C00U) #define PWR_BASE (APB1PERIPH_BASE + 0x7000U) #define DAC_BASE (APB1PERIPH_BASE + 0x7400U) #define UART7_BASE (APB1PERIPH_BASE + 0x7800U) #define UART8_BASE (APB1PERIPH_BASE + 0x7C00U) /*!< APB2 peripherals */ #define TIM1_BASE (APB2PERIPH_BASE + 0x0000U) #define TIM8_BASE (APB2PERIPH_BASE + 0x0400U) #define USART1_BASE (APB2PERIPH_BASE + 0x1000U) #define USART6_BASE (APB2PERIPH_BASE + 0x1400U) #define UART9_BASE (APB2PERIPH_BASE + 0x1800U) #define UART10_BASE (APB2PERIPH_BASE + 0x1C00U) #define ADC1_BASE (APB2PERIPH_BASE + 0x2000U) #define ADC_BASE (APB2PERIPH_BASE + 0x2300U) #define SDIO_BASE (APB2PERIPH_BASE + 0x2C00U) #define SPI1_BASE (APB2PERIPH_BASE + 0x3000U) #define SPI4_BASE (APB2PERIPH_BASE + 0x3400U) #define SYSCFG_BASE (APB2PERIPH_BASE + 0x3800U) #define EXTI_BASE (APB2PERIPH_BASE + 0x3C00U) #define TIM9_BASE (APB2PERIPH_BASE + 0x4000U) #define TIM10_BASE (APB2PERIPH_BASE + 0x4400U) #define TIM11_BASE (APB2PERIPH_BASE + 0x4800U) #define SPI5_BASE (APB2PERIPH_BASE + 0x5000U) #define DFSDM1_BASE (APB2PERIPH_BASE + 0x6000U) #define DFSDM2_BASE (APB2PERIPH_BASE + 0x6400U) #define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00U) #define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20U) #define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40U) #define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60U) #define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100U) #define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180U) #define DFSDM2_Channel0_BASE (DFSDM2_BASE + 0x00U) #define DFSDM2_Channel1_BASE (DFSDM2_BASE + 0x20U) #define DFSDM2_Channel2_BASE (DFSDM2_BASE + 0x40U) #define DFSDM2_Channel3_BASE (DFSDM2_BASE + 0x60U) #define DFSDM2_Channel4_BASE (DFSDM2_BASE + 0x80U) #define DFSDM2_Channel5_BASE (DFSDM2_BASE + 0xA0U) #define DFSDM2_Channel6_BASE (DFSDM2_BASE + 0xC0U) #define DFSDM2_Channel7_BASE (DFSDM2_BASE + 0xE0U) #define DFSDM2_Filter0_BASE (DFSDM2_BASE + 0x100U) #define DFSDM2_Filter1_BASE (DFSDM2_BASE + 0x180U) #define DFSDM2_Filter2_BASE (DFSDM2_BASE + 0x200U) #define DFSDM2_Filter3_BASE (DFSDM2_BASE + 0x280U) #define SAI1_BASE (APB2PERIPH_BASE + 0x5800U) #define SAI1_Block_A_BASE (SAI1_BASE + 0x004U) #define SAI1_Block_B_BASE (SAI1_BASE + 0x024U) /*!< AHB1 peripherals */ #define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000U) #define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400U) #define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800U) #define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00U) #define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000U) #define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400U) #define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800U) #define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00U) #define CRC_BASE (AHB1PERIPH_BASE + 0x3000U) #define RCC_BASE (AHB1PERIPH_BASE + 0x3800U) #define FLASH_R_BASE (AHB1PERIPH_BASE + 0x3C00U) #define DMA1_BASE (AHB1PERIPH_BASE + 0x6000U) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010U) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028U) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040U) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058U) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070U) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088U) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0U) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8U) #define DMA2_BASE (AHB1PERIPH_BASE + 0x6400U) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010U) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028U) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040U) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058U) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070U) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088U) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0U) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8U) /*!< AHB2 peripherals */ #define RNG_BASE (AHB2PERIPH_BASE + 0x60800U) /*!< FSMC Bankx registers base address */ #define FSMC_Bank1_R_BASE (FSMC_R_BASE + 0x0000U) #define FSMC_Bank1E_R_BASE (FSMC_R_BASE + 0x0104U) /*!< Debug MCU registers base address */ #define DBGMCU_BASE 0xE0042000U /*!< USB registers base address */ #define USB_OTG_FS_PERIPH_BASE 0x50000000U #define USB_OTG_GLOBAL_BASE 0x000U #define USB_OTG_DEVICE_BASE 0x800U #define USB_OTG_IN_ENDPOINT_BASE 0x900U #define USB_OTG_OUT_ENDPOINT_BASE 0xB00U #define USB_OTG_EP_REG_SIZE 0x20U #define USB_OTG_HOST_BASE 0x400U #define USB_OTG_HOST_PORT_BASE 0x440U #define USB_OTG_HOST_CHANNEL_BASE 0x500U #define USB_OTG_HOST_CHANNEL_SIZE 0x20U #define USB_OTG_PCGCCTL_BASE 0xE00U #define USB_OTG_FIFO_BASE 0x1000U #define USB_OTG_FIFO_SIZE 0x1000U #define UID_BASE 0x1FFF7A10U /*!< Unique device ID register base address */ #define FLASHSIZE_BASE 0x1FFF7A22U /*!< FLASH Size register base address */ #define PACKAGE_BASE 0x1FFF7BF0U /*!< Package size register base address */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG ((WWDG_TypeDef *) WWDG_BASE) #define IWDG ((IWDG_TypeDef *) IWDG_BASE) #define I2S2ext ((SPI_TypeDef *) I2S2ext_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define I2S3ext ((SPI_TypeDef *) I2S3ext_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define FMPI2C1 ((FMPI2C_TypeDef *) FMPI2C1_BASE) #define CAN1 ((CAN_TypeDef *) CAN1_BASE) #define CAN2 ((CAN_TypeDef *) CAN2_BASE) #define CAN3 ((CAN_TypeDef *) CAN3_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC_BASE) #define DAC ((DAC_TypeDef *) DAC_BASE) /* Kept for legacy purpose */ #define UART7 ((USART_TypeDef *) UART7_BASE) #define UART8 ((USART_TypeDef *) UART8_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define UART9 ((USART_TypeDef *) UART9_BASE) #define UART10 ((USART_TypeDef *) UART10_BASE) #define ADC ((ADC_Common_TypeDef *) ADC_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define SDIO ((SDIO_TypeDef *) SDIO_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define TIM9 ((TIM_TypeDef *) TIM9_BASE) #define TIM10 ((TIM_TypeDef *) TIM10_BASE) #define TIM11 ((TIM_TypeDef *) TIM11_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) #define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) #define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) #define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) #define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) #define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) #define DFSDM2_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel0_BASE) #define DFSDM2_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel1_BASE) #define DFSDM2_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel2_BASE) #define DFSDM2_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel3_BASE) #define DFSDM2_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel4_BASE) #define DFSDM2_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel5_BASE) #define DFSDM2_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel6_BASE) #define DFSDM2_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM2_Channel7_BASE) #define DFSDM2_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter0_BASE) #define DFSDM2_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter1_BASE) #define DFSDM2_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter2_BASE) #define DFSDM2_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM2_Filter3_BASE) #define SAI1 ((SAI_TypeDef *) SAI1_BASE) #define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) #define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define FSMC_Bank1 ((FSMC_Bank1_TypeDef *) FSMC_Bank1_R_BASE) #define FSMC_Bank1E ((FSMC_Bank1E_TypeDef *) FSMC_Bank1E_R_BASE) #define QUADSPI ((QUADSPI_TypeDef *) QSPI_R_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define USB_OTG_FS ((USB_OTG_GlobalTypeDef *) USB_OTG_FS_PERIPH_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************** Bit definition for ADC_SR register ********************/ #define ADC_SR_AWD_Pos (0U) #define ADC_SR_AWD_Msk (0x1U << ADC_SR_AWD_Pos) /*!< 0x00000001 */ #define ADC_SR_AWD ADC_SR_AWD_Msk /*!
© COPYRIGHT(c) 2016 STMicroelectronics
* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f4xx * @{ */ #ifndef __STM32F4xx_H #define __STM32F4xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Library_configuration_section * @{ */ /** * @brief STM32 Family */ #if !defined (STM32F4) #define STM32F4 #endif /* STM32F4 */ /* Uncomment the line below according to the target STM32 device used in your application */ /* #if !defined (STM32F405xx) && !defined (STM32F415xx) && !defined (STM32F407xx) && !defined (STM32F417xx) && \ !defined (STM32F427xx) && !defined (STM32F437xx) && !defined (STM32F429xx) && !defined (STM32F439xx) && \ !defined (STM32F401xC) && !defined (STM32F401xE) && !defined (STM32F410Tx) && !defined (STM32F410Cx) && \ !defined (STM32F410Rx) && !defined (STM32F411xE) && !defined (STM32F446xx) && !defined (STM32F469xx) && \ !defined (STM32F479xx) && !defined (STM32F412Cx) && !defined (STM32F412Rx) && !defined (STM32F412Vx) && \ !defined (STM32F412Zx) && !defined (STM32F413xx) && !defined (STM32F423xx) */ /* #define STM32F405xx */ /*!< STM32F405RG, STM32F405VG and STM32F405ZG Devices */ /* #define STM32F415xx */ /*!< STM32F415RG, STM32F415VG and STM32F415ZG Devices */ /* #define STM32F407xx */ /*!< STM32F407VG, STM32F407VE, STM32F407ZG, STM32F407ZE, STM32F407IG and STM32F407IE Devices */ /* #define STM32F417xx */ /*!< STM32F417VG, STM32F417VE, STM32F417ZG, STM32F417ZE, STM32F417IG and STM32F417IE Devices */ /* #define STM32F427xx */ /*!< STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI, STM32F427IG and STM32F427II Devices */ /* #define STM32F437xx */ /*!< STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI, STM32F437IG and STM32F437II Devices */ /* #define STM32F429xx */ /*!< STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI, STM32F429BG, STM32F429BI, STM32F429NG, STM32F439NI, STM32F429IG and STM32F429II Devices */ /* #define STM32F439xx */ /*!< STM32F439VG, STM32F439VI, STM32F439ZG, STM32F439ZI, STM32F439BG, STM32F439BI, STM32F439NG, STM32F439NI, STM32F439IG and STM32F439II Devices */ /* #define STM32F401xC */ /*!< STM32F401CB, STM32F401CC, STM32F401RB, STM32F401RC, STM32F401VB and STM32F401VC Devices */ /* #define STM32F401xE */ /*!< STM32F401CD, STM32F401RD, STM32F401VD, STM32F401CE, STM32F401RE and STM32F401VE Devices */ /* #define STM32F410Tx */ /*!< STM32F410T8 and STM32F410TB Devices */ /* #define STM32F410Cx */ /*!< STM32F410C8 and STM32F410CB Devices */ /* #define STM32F410Rx */ /*!< STM32F410R8 and STM32F410RB Devices */ /* #define STM32F411xE */ /*!< STM32F411CC, STM32F411RC, STM32F411VC, STM32F411CE, STM32F411RE and STM32F411VE Devices */ /* #define STM32F446xx */ /*!< STM32F446MC, STM32F446ME, STM32F446RC, STM32F446RE, STM32F446VC, STM32F446VE, STM32F446ZC, and STM32F446ZE Devices */ /* #define STM32F469xx */ /*!< STM32F469AI, STM32F469II, STM32F469BI, STM32F469NI, STM32F469AG, STM32F469IG, STM32F469BG, STM32F469NG, STM32F469AE, STM32F469IE, STM32F469BE and STM32F469NE Devices */ /* #define STM32F479xx */ /*!< STM32F479AI, STM32F479II, STM32F479BI, STM32F479NI, STM32F479AG, STM32F479IG, STM32F479BG and STM32F479NG Devices */ /* #define STM32F412Cx */ /*!< STM32F412CEU and STM32F412CGU Devices */ /* #define STM32F412Zx */ /*!< STM32F412ZET, STM32F412ZGT, STM32F412ZEJ and STM32F412ZGJ Devices */ /* #define STM32F412Vx */ /*!< STM32F412VET, STM32F412VGT, STM32F412VEH and STM32F412VGH Devices */ /* #define STM32F412Rx */ /*!< STM32F412RET, STM32F412RGT, STM32F412REY and STM32F412RGY Devices */ /* #define STM32F413xx */ /*!< STM32F413CH, STM32F413MH, STM32F413RH, STM32F413VH, STM32F413ZH, STM32F413CG, STM32F413MG, STM32F413RG, STM32F413VG and STM32F413ZG Devices */ /* #define STM32F423xx */ /*!< STM32F423CH, STM32F423RH, STM32F423VH and STM32F423ZH Devices */ //#endif /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. */ #if !defined (USE_HAL_DRIVER) /** * @brief Comment the line below if you will not use the peripherals drivers. In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ /*#define USE_HAL_DRIVER */ #endif /* USE_HAL_DRIVER */ /** * @brief CMSIS version number V2.6.0 */ #define __STM32F4xx_CMSIS_VERSION_MAIN (0x02U) /*!< [31:24] main version */ #define __STM32F4xx_CMSIS_VERSION_SUB1 (0x06U) /*!< [23:16] sub1 version */ #define __STM32F4xx_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ #define __STM32F4xx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ #define __STM32F4xx_CMSIS_VERSION ((__STM32F4xx_CMSIS_VERSION_MAIN << 24)\ |(__STM32F4xx_CMSIS_VERSION_SUB1 << 16)\ |(__STM32F4xx_CMSIS_VERSION_SUB2 << 8 )\ |(__STM32F4xx_CMSIS_VERSION)) /** * @} */ /** @addtogroup Device_Included * @{ */ // #if defined(STM32F405xx) // #include "stm32f405xx.h" // #elif defined(STM32F415xx) // #include "stm32f415xx.h" // #elif defined(STM32F407xx) // #include "stm32f407xx.h" // #elif defined(STM32F417xx) // #include "stm32f417xx.h" // #elif defined(STM32F427xx) // #include "stm32f427xx.h" // #elif defined(STM32F437xx) // #include "stm32f437xx.h" // #elif defined(STM32F429xx) // #include "stm32f429xx.h" // #elif defined(STM32F439xx) // #include "stm32f439xx.h" // #elif defined(STM32F401xC) // #include "stm32f401xc.h" // #elif defined(STM32F401xE) // #include "stm32f401xe.h" // #elif defined(STM32F410Tx) // #include "stm32f410tx.h" // #elif defined(STM32F410Cx) // #include "stm32f410cx.h" // #elif defined(STM32F410Rx) // #include "stm32f410rx.h" // #elif defined(STM32F411xE) // #include "stm32f411xe.h" // #elif defined(STM32F446xx) // #include "stm32f446xx.h" // #elif defined(STM32F469xx) // #include "stm32f469xx.h" // #elif defined(STM32F479xx) // #include "stm32f479xx.h" // #elif defined(STM32F412Cx) // #include "stm32f412cx.h" // #elif defined(STM32F412Zx) // #include "stm32f412zx.h" // #elif defined(STM32F412Rx) // #include "stm32f412rx.h" // #elif defined(STM32F412Vx) // #include "stm32f412vx.h" #if defined(STM32F413xx) #include "stm32f413xx.h" #elif defined(STM32F423xx) #include "stm32f423xx.h" #else #error "Please select first the target STM32F4xx device used in your application (in stm32f4xx.h file)" #endif /** * @} */ /** @addtogroup Exported_types * @{ */ typedef enum { RESET = 0U, SET = !RESET } FlagStatus, ITStatus; typedef enum { DISABLE = 0U, ENABLE = !DISABLE } FunctionalState; #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) typedef enum { ERROR = 0U, SUCCESS = !ERROR } ErrorStatus; /** * @} */ /** @addtogroup Exported_macro * @{ */ #define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) #define READ_BIT(REG, BIT) ((REG) & (BIT)) #define CLEAR_REG(REG) ((REG) = (0x0)) #define WRITE_REG(REG, VAL) ((REG) = (VAL)) #define READ_REG(REG) ((REG)) #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) /** * @} */ #if defined (USE_HAL_DRIVER) #include "stm32f4xx_hal.h" #endif /* USE_HAL_DRIVER */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __STM32F4xx_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/stm32f4xx_hal_def.h ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_def.h * @author MCD Application Team * @version V1.6.0 * @date 04-November-2016 * @brief This file contains HAL common defines, enumeration, macros and * structures definitions. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_DEF #define __STM32F4xx_HAL_DEF #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" //#include "Legacy/stm32_hal_legacy.h" //#include /* Exported types ------------------------------------------------------------*/ /** * @brief HAL Status structures definition */ typedef enum { HAL_OK = 0x00U, HAL_ERROR = 0x01U, HAL_BUSY = 0x02U, HAL_TIMEOUT = 0x03U } HAL_StatusTypeDef; /** * @brief HAL Lock structures definition */ typedef enum { HAL_UNLOCKED = 0x00U, HAL_LOCKED = 0x01U } HAL_LockTypeDef; /* Exported macro ------------------------------------------------------------*/ #define HAL_MAX_DELAY 0xFFFFFFFFU #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ do{ \ (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ (__DMA_HANDLE__).Parent = (__HANDLE__); \ } while(0) #define UNUSED(x) ((void)(x)) /** @brief Reset the Handle's State field. * @param __HANDLE__: specifies the Peripheral Handle. * @note This macro can be used for the following purpose: * - When the Handle is declared as local variable; before passing it as parameter * to HAL_PPP_Init() for the first time, it is mandatory to use this macro * to set to 0 the Handle's "State" field. * Otherwise, "State" field may have any random value and the first time the function * HAL_PPP_Init() is called, the low level hardware initialization will be missed * (i.e. HAL_PPP_MspInit() will not be executed). * - When there is a need to reconfigure the low level hardware: instead of calling * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). * In this later function, when the Handle's "State" field is set to 0, it will execute the function * HAL_PPP_MspInit() which will reconfigure the low level hardware. * @retval None */ #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) #if (USE_RTOS == 1) /* Reserved for future use */ #error "USE_RTOS should be 0 in the current HAL release" #else #define __HAL_LOCK(__HANDLE__) \ do{ \ if((__HANDLE__)->Lock == HAL_LOCKED) \ { \ return HAL_BUSY; \ } \ else \ { \ (__HANDLE__)->Lock = HAL_LOCKED; \ } \ }while (0) #define __HAL_UNLOCK(__HANDLE__) \ do{ \ (__HANDLE__)->Lock = HAL_UNLOCKED; \ }while (0) #endif /* USE_RTOS */ #if defined ( __GNUC__ ) #ifndef __weak #define __weak __attribute__((weak)) #endif /* __weak */ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed */ #endif /* __GNUC__ */ /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ #if defined (__GNUC__) /* GNU Compiler */ #ifndef __ALIGN_END #define __ALIGN_END __attribute__ ((aligned (4))) #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #define __ALIGN_BEGIN #endif /* __ALIGN_BEGIN */ #else #ifndef __ALIGN_END #define __ALIGN_END #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #if defined (__CC_ARM) /* ARM Compiler */ #define __ALIGN_BEGIN __align(4) #elif defined (__ICCARM__) /* IAR Compiler */ #define __ALIGN_BEGIN #endif /* __CC_ARM */ #endif /* __ALIGN_BEGIN */ #endif /* __GNUC__ */ /** * @brief __RAM_FUNC definition */ #if defined ( __CC_ARM ) /* ARM Compiler ------------ RAM functions are defined using the toolchain options. Functions that are executed in RAM should reside in a separate source module. Using the 'Options for File' dialog you can simply change the 'Code / Const' area of a module to a memory space in physical RAM. Available memory areas are declared in the 'Target' tab of the 'Options for Target' dialog. */ #define __RAM_FUNC HAL_StatusTypeDef #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- RAM functions are defined using a specific toolchain keyword "__ramfunc". */ #define __RAM_FUNC __ramfunc HAL_StatusTypeDef #elif defined ( __GNUC__ ) /* GNU Compiler ------------ RAM functions are defined using a specific toolchain attribute "__attribute__((section(".RamFunc")))". */ #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) #endif /** * @brief __NOINLINE definition */ #if defined ( __CC_ARM ) || defined ( __GNUC__ ) /* ARM & GNUCompiler ---------------- */ #define __NOINLINE __attribute__ ( (noinline) ) #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- */ #define __NOINLINE _Pragma("optimize = no_inline") #endif #ifdef __cplusplus } #endif #endif /* ___STM32F4xx_HAL_DEF */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/stm32f4xx_hal_gpio_ex.h ================================================ /** ****************************************************************************** * @file stm32f4xx_hal_gpio_ex.h * @author MCD Application Team * @version V1.6.0 * @date 04-November-2016 * @brief Header file of GPIO HAL Extension module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F4xx_HAL_GPIO_EX_H #define __STM32F4xx_HAL_GPIO_EX_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal_def.h" /** @addtogroup STM32F4xx_HAL_Driver * @{ */ /** @defgroup GPIOEx GPIOEx * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants * @{ */ /** @defgroup GPIO_Alternate_function_selection GPIO Alternate Function Selection * @{ */ /*------------------------------------------ STM32F429xx/STM32F439xx ---------*/ #if defined(STM32F429xx) || defined(STM32F439xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4 Alternate Function mapping */ #define GPIO_AF5_SPI5 ((uint8_t)0x05U) /* SPI5 Alternate Function mapping */ #define GPIO_AF5_SPI6 ((uint8_t)0x05U) /* SPI6 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ #define GPIO_AF6_SAI1 ((uint8_t)0x06U) /* SAI1 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ #define GPIO_AF8_UART7 ((uint8_t)0x08U) /* UART7 Alternate Function mapping */ #define GPIO_AF8_UART8 ((uint8_t)0x08U) /* UART8 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_LTDC ((uint8_t)0x09U) /* LCD-TFT Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0x0AU) /* OTG_HS Alternate Function mapping */ /** * @brief AF 11 selection */ #define GPIO_AF11_ETH ((uint8_t)0x0BU) /* ETHERNET Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_FMC ((uint8_t)0x0CU) /* FMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0CU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 13 selection */ #define GPIO_AF13_DCMI ((uint8_t)0x0DU) /* DCMI Alternate Function mapping */ /** * @brief AF 14 selection */ #define GPIO_AF14_LTDC ((uint8_t)0x0EU) /* LCD-TFT Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F429xx || STM32F439xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------- STM32F427xx/STM32F437xx------------------*/ #if defined(STM32F427xx) || defined(STM32F437xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4 Alternate Function mapping */ #define GPIO_AF5_SPI5 ((uint8_t)0x05U) /* SPI5 Alternate Function mapping */ #define GPIO_AF5_SPI6 ((uint8_t)0x05U) /* SPI6 Alternate Function mapping */ /** @brief GPIO_Legacy */ #define GPIO_AF5_I2S3ext GPIO_AF5_SPI3 /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ #define GPIO_AF6_SAI1 ((uint8_t)0x06U) /* SAI1 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ #define GPIO_AF8_UART7 ((uint8_t)0x08U) /* UART7 Alternate Function mapping */ #define GPIO_AF8_UART8 ((uint8_t)0x08U) /* UART8 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0x0AU) /* OTG_HS Alternate Function mapping */ /** * @brief AF 11 selection */ #define GPIO_AF11_ETH ((uint8_t)0x0BU) /* ETHERNET Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_FMC ((uint8_t)0x0CU) /* FMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0CU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 13 selection */ #define GPIO_AF13_DCMI ((uint8_t)0x0DU) /* DCMI Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F427xx || STM32F437xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------- STM32F407xx/STM32F417xx------------------*/ #if defined(STM32F407xx) || defined(STM32F417xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0x0AU) /* OTG_HS Alternate Function mapping */ /** * @brief AF 11 selection */ #define GPIO_AF11_ETH ((uint8_t)0x0BU) /* ETHERNET Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_FSMC ((uint8_t)0x0CU) /* FSMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0CU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 13 selection */ #define GPIO_AF13_DCMI ((uint8_t)0x0DU) /* DCMI Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F407xx || STM32F417xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------- STM32F405xx/STM32F415xx------------------*/ #if defined(STM32F405xx) || defined(STM32F415xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0x0AU) /* OTG_HS Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_FSMC ((uint8_t)0x0CU) /* FSMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0CU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F405xx || STM32F415xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------------- STM32F401xx------------------------*/ #if defined(STM32F401xC) || defined(STM32F401xE) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_I2C2 ((uint8_t)0x09U) /* I2C2 Alternate Function mapping */ #define GPIO_AF9_I2C3 ((uint8_t)0x09U) /* I2C3 Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F401xC || STM32F401xE */ /*----------------------------------------------------------------------------*/ /*--------------- STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx-------------*/ #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ #define GPIO_AF4_FMPI2C1 ((uint8_t)0x04U) /* FMPI2C1 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1/I2S1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4/I2S4 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI2 ((uint8_t)0x06U) /* I2S2 Alternate Function mapping */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_SPI4 ((uint8_t)0x06U) /* SPI4/I2S4 Alternate Function mapping */ #define GPIO_AF6_SPI5 ((uint8_t)0x06U) /* SPI5/I2S5 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ #define GPIO_AF6_DFSDM1 ((uint8_t)0x06U) /* DFSDM1 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_SPI3 ((uint8_t)0x07U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ #define GPIO_AF8_USART3 ((uint8_t)0x08U) /* USART3 Alternate Function mapping */ #define GPIO_AF8_DFSDM1 ((uint8_t)0x08U) /* DFSDM1 Alternate Function mapping */ #define GPIO_AF8_CAN1 ((uint8_t)0x08U) /* CAN1 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_I2C2 ((uint8_t)0x09U) /* I2C2 Alternate Function mapping */ #define GPIO_AF9_I2C3 ((uint8_t)0x09U) /* I2C3 Alternate Function mapping */ #define GPIO_AF9_FMPI2C1 ((uint8_t)0x09U) /* FMPI2C1 Alternate Function mapping */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_QSPI ((uint8_t)0x09U) /* QSPI Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_DFSDM1 ((uint8_t)0x0AU) /* DFSDM1 Alternate Function mapping */ #define GPIO_AF10_QSPI ((uint8_t)0x0AU) /* QSPI Alternate Function mapping */ #define GPIO_AF10_FMC ((uint8_t)0x0AU) /* FMC Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ #define GPIO_AF12_FSMC ((uint8_t)0x0CU) /* FMC Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ /*----------------------------------------------------------------------------*/ /*--------------- STM32F413xx/STM32F423xx-------------------------------------*/ #if defined(STM32F413xx) || defined(STM32F423xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ #define GPIO_AF3_DFSDM2 ((uint8_t)0x03U) /* DFSDM2 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ #define GPIO_AF4_FMPI2C1 ((uint8_t)0x04U) /* FMPI2C1 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1/I2S1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4/I2S4 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI2 ((uint8_t)0x06U) /* I2S2 Alternate Function mapping */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_SPI4 ((uint8_t)0x06U) /* SPI4/I2S4 Alternate Function mapping */ #define GPIO_AF6_SPI5 ((uint8_t)0x06U) /* SPI5/I2S5 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ #define GPIO_AF6_DFSDM1 ((uint8_t)0x06U) /* DFSDM1 Alternate Function mapping */ #define GPIO_AF6_DFSDM2 ((uint8_t)0x06U) /* DFSDM2 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_SPI3 ((uint8_t)0x07U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF7_SAI1 ((uint8_t)0x07U) /* SAI1 Alternate Function mapping */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ #define GPIO_AF7_DFSDM2 ((uint8_t)0x07U) /* DFSDM2 Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ #define GPIO_AF8_USART3 ((uint8_t)0x08U) /* USART3 Alternate Function mapping */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_UART7 ((uint8_t)0x08U) /* UART8 Alternate Function mapping */ #define GPIO_AF8_UART8 ((uint8_t)0x08U) /* UART8 Alternate Function mapping */ #define GPIO_AF8_DFSDM1 ((uint8_t)0x08U) /* DFSDM1 Alternate Function mapping */ #define GPIO_AF8_CAN1 ((uint8_t)0x08U) /* CAN1 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_I2C2 ((uint8_t)0x09U) /* I2C2 Alternate Function mapping */ #define GPIO_AF9_I2C3 ((uint8_t)0x09U) /* I2C3 Alternate Function mapping */ #define GPIO_AF9_FMPI2C1 ((uint8_t)0x09U) /* FMPI2C1 Alternate Function mapping */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_QSPI ((uint8_t)0x09U) /* QSPI Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_SAI1 ((uint8_t)0x0AU) /* SAI1 Alternate Function mapping */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_DFSDM1 ((uint8_t)0x0AU) /* DFSDM1 Alternate Function mapping */ #define GPIO_AF10_DFSDM2 ((uint8_t)0x0AU) /* DFSDM2 Alternate Function mapping */ #define GPIO_AF10_QSPI ((uint8_t)0x0AU) /* QSPI Alternate Function mapping */ #define GPIO_AF10_FSMC ((uint8_t)0x0AU) /* FSMC Alternate Function mapping */ /** * @brief AF 11 selection */ #define GPIO_AF11_UART4 ((uint8_t)0x0BU) /* UART4 Alternate Function mapping */ #define GPIO_AF11_UART5 ((uint8_t)0x0BU) /* UART5 Alternate Function mapping */ #define GPIO_AF11_UART9 ((uint8_t)0x0BU) /* UART9 Alternate Function mapping */ #define GPIO_AF11_UART10 ((uint8_t)0x0BU) /* UART10 Alternate Function mapping */ #define GPIO_AF11_CAN3 ((uint8_t)0x0BU) /* CAN3 Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ #define GPIO_AF12_FSMC ((uint8_t)0x0CU) /* FMC Alternate Function mapping */ /** * @brief AF 14 selection */ #define GPIO_AF14_RNG ((uint8_t)0x0EU) /* RNG Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F413xx || STM32F423xx */ /*---------------------------------------- STM32F411xx------------------------*/ #if defined(STM32F411xE) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1/I2S1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI2 ((uint8_t)0x06U) /* I2S2 Alternate Function mapping */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_SPI4 ((uint8_t)0x06U) /* SPI4/I2S4 Alternate Function mapping */ #define GPIO_AF6_SPI5 ((uint8_t)0x06U) /* SPI5/I2S5 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_SPI3 ((uint8_t)0x07U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_I2C2 ((uint8_t)0x09U) /* I2C2 Alternate Function mapping */ #define GPIO_AF9_I2C3 ((uint8_t)0x09U) /* I2C3 Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F411xE */ /*---------------------------------------- STM32F410xx------------------------*/ #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_FMPI2C1 ((uint8_t)0x04U) /* FMPI2C1 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1/I2S1 Alternate Function mapping */ #if defined(STM32F410Cx) || defined(STM32F410Rx) #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #endif /* STM32F410Cx || STM32F410Rx */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI1 ((uint8_t)0x06U) /* SPI1 Alternate Function mapping */ #if defined(STM32F410Cx) || defined(STM32F410Rx) #define GPIO_AF6_SPI2 ((uint8_t)0x06U) /* I2S2 Alternate Function mapping */ #endif /* STM32F410Cx || STM32F410Rx */ #define GPIO_AF6_SPI5 ((uint8_t)0x06U) /* SPI5/I2S5 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_I2C2 ((uint8_t)0x09U) /* I2C2 Alternate Function mapping */ #define GPIO_AF9_FMPI2C1 ((uint8_t)0x09U) /* FMPI2C1 Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ /*---------------------------------------- STM32F446xx -----------------------*/ #if defined(STM32F446xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ #define GPIO_AF3_CEC ((uint8_t)0x03U) /* CEC Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ #define GPIO_AF4_FMPI2C1 ((uint8_t)0x04U) /* FMPI2C1 Alternate Function mapping */ #define GPIO_AF4_CEC ((uint8_t)0x04U) /* CEC Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1/I2S1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4 Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI2 ((uint8_t)0x06U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_SPI4 ((uint8_t)0x06U) /* SPI4 Alternate Function mapping */ #define GPIO_AF6_SAI1 ((uint8_t)0x06U) /* SAI1 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_UART5 ((uint8_t)0x07U) /* UART5 Alternate Function mapping */ #define GPIO_AF7_SPI2 ((uint8_t)0x07U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF7_SPI3 ((uint8_t)0x07U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF7_SPDIFRX ((uint8_t)0x07U) /* SPDIFRX Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ #define GPIO_AF8_SPDIFRX ((uint8_t)0x08U) /* SPDIFRX Alternate Function mapping */ #define GPIO_AF8_SAI2 ((uint8_t)0x08U) /* SAI2 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_QSPI ((uint8_t)0x09U) /* QSPI Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0x0AU) /* OTG_HS Alternate Function mapping */ #define GPIO_AF10_SAI2 ((uint8_t)0x0AU) /* SAI2 Alternate Function mapping */ #define GPIO_AF10_QSPI ((uint8_t)0x0AU) /* QSPI Alternate Function mapping */ /** * @brief AF 11 selection */ #define GPIO_AF11_ETH ((uint8_t)0x0BU) /* ETHERNET Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_FMC ((uint8_t)0x0CU) /* FMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0CU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 13 selection */ #define GPIO_AF13_DCMI ((uint8_t)0x0DU) /* DCMI Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F446xx */ /*----------------------------------------------------------------------------*/ /*-------------------------------- STM32F469xx/STM32F479xx--------------------*/ #if defined(STM32F469xx) || defined(STM32F479xx) /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00U) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_TAMPER ((uint8_t)0x00U) /* TAMPER (TAMPER_1 and TAMPER_2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00U) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00U) /* TRACE Alternate Function mapping */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01U) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01U) /* TIM2 Alternate Function mapping */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02U) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02U) /* TIM5 Alternate Function mapping */ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03U) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_TIM9 ((uint8_t)0x03U) /* TIM9 Alternate Function mapping */ #define GPIO_AF3_TIM10 ((uint8_t)0x03U) /* TIM10 Alternate Function mapping */ #define GPIO_AF3_TIM11 ((uint8_t)0x03U) /* TIM11 Alternate Function mapping */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04U) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04U) /* I2C3 Alternate Function mapping */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2/I2S2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05U) /* SPI4 Alternate Function mapping */ #define GPIO_AF5_SPI5 ((uint8_t)0x05U) /* SPI5 Alternate Function mapping */ #define GPIO_AF5_SPI6 ((uint8_t)0x05U) /* SPI6 Alternate Function mapping */ #define GPIO_AF5_I2S3ext ((uint8_t)0x05U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI3 ((uint8_t)0x06U) /* SPI3/I2S3 Alternate Function mapping */ #define GPIO_AF6_I2S2ext ((uint8_t)0x06U) /* I2S2ext_SD Alternate Function mapping */ #define GPIO_AF6_SAI1 ((uint8_t)0x06U) /* SAI1 Alternate Function mapping */ /** * @brief AF 7 selection */ #define GPIO_AF7_USART1 ((uint8_t)0x07U) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07U) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07U) /* USART3 Alternate Function mapping */ #define GPIO_AF7_I2S3ext ((uint8_t)0x07U) /* I2S3ext_SD Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_UART4 ((uint8_t)0x08U) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08U) /* UART5 Alternate Function mapping */ #define GPIO_AF8_USART6 ((uint8_t)0x08U) /* USART6 Alternate Function mapping */ #define GPIO_AF8_UART7 ((uint8_t)0x08U) /* UART7 Alternate Function mapping */ #define GPIO_AF8_UART8 ((uint8_t)0x08U) /* UART8 Alternate Function mapping */ /** * @brief AF 9 selection */ #define GPIO_AF9_CAN1 ((uint8_t)0x09U) /* CAN1 Alternate Function mapping */ #define GPIO_AF9_CAN2 ((uint8_t)0x09U) /* CAN2 Alternate Function mapping */ #define GPIO_AF9_TIM12 ((uint8_t)0x09U) /* TIM12 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09U) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09U) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_LTDC ((uint8_t)0x09U) /* LCD-TFT Alternate Function mapping */ #define GPIO_AF9_QSPI ((uint8_t)0x09U) /* QSPI Alternate Function mapping */ /** * @brief AF 10 selection */ #define GPIO_AF10_OTG_FS ((uint8_t)0x0AU) /* OTG_FS Alternate Function mapping */ #define GPIO_AF10_OTG_HS ((uint8_t)0x0AU) /* OTG_HS Alternate Function mapping */ #define GPIO_AF10_QSPI ((uint8_t)0x0AU) /* QSPI Alternate Function mapping */ /** * @brief AF 11 selection */ #define GPIO_AF11_ETH ((uint8_t)0x0BU) /* ETHERNET Alternate Function mapping */ /** * @brief AF 12 selection */ #define GPIO_AF12_FMC ((uint8_t)0x0CU) /* FMC Alternate Function mapping */ #define GPIO_AF12_OTG_HS_FS ((uint8_t)0x0CU) /* OTG HS configured in FS, Alternate Function mapping */ #define GPIO_AF12_SDIO ((uint8_t)0x0CU) /* SDIO Alternate Function mapping */ /** * @brief AF 13 selection */ #define GPIO_AF13_DCMI ((uint8_t)0x0DU) /* DCMI Alternate Function mapping */ #define GPIO_AF13_DSI ((uint8_t)0x0DU) /* DSI Alternate Function mapping */ /** * @brief AF 14 selection */ #define GPIO_AF14_LTDC ((uint8_t)0x0EU) /* LCD-TFT Alternate Function mapping */ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0FU) /* EVENTOUT Alternate Function mapping */ #endif /* STM32F469xx || STM32F479xx */ /*----------------------------------------------------------------------------*/ /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros * @{ */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions * @{ */ /** * @} */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Constants GPIO Private Constants * @{ */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Macros GPIO Private Macros * @{ */ /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index * @{ */ #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ ((__GPIOx__) == (GPIOB))? 1U :\ ((__GPIOx__) == (GPIOC))? 2U :\ ((__GPIOx__) == (GPIOD))? 3U :\ ((__GPIOx__) == (GPIOE))? 4U :\ ((__GPIOx__) == (GPIOF))? 5U :\ ((__GPIOx__) == (GPIOG))? 6U :\ ((__GPIOx__) == (GPIOH))? 7U : 8U) #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ defined(STM32F469xx) || defined(STM32F479xx) #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ ((__GPIOx__) == (GPIOB))? 1U :\ ((__GPIOx__) == (GPIOC))? 2U :\ ((__GPIOx__) == (GPIOD))? 3U :\ ((__GPIOx__) == (GPIOE))? 4U :\ ((__GPIOx__) == (GPIOF))? 5U :\ ((__GPIOx__) == (GPIOG))? 6U :\ ((__GPIOx__) == (GPIOH))? 7U :\ ((__GPIOx__) == (GPIOI))? 8U :\ ((__GPIOx__) == (GPIOJ))? 9U : 10U) #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ ((__GPIOx__) == (GPIOB))? 1U :\ ((__GPIOx__) == (GPIOC))? 2U : 7U) #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ ((__GPIOx__) == (GPIOB))? 1U :\ ((__GPIOx__) == (GPIOC))? 2U :\ ((__GPIOx__) == (GPIOD))? 3U :\ ((__GPIOx__) == (GPIOE))? 4U : 7U) #endif /* STM32F401xC || STM32F401xE || STM32F411xE */ #if defined(STM32F446xx) || defined(STM32F412Zx) ||defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) #define GPIO_GET_INDEX(__GPIOx__) (uint8_t)(((__GPIOx__) == (GPIOA))? 0U :\ ((__GPIOx__) == (GPIOB))? 1U :\ ((__GPIOx__) == (GPIOC))? 2U :\ ((__GPIOx__) == (GPIOD))? 3U :\ ((__GPIOx__) == (GPIOE))? 4U :\ ((__GPIOx__) == (GPIOF))? 5U :\ ((__GPIOx__) == (GPIOG))? 6U : 7U) #endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ /** * @} */ /** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function * @{ */ /*------------------------- STM32F429xx/STM32F439xx---------------------------*/ #if defined(STM32F429xx) || defined(STM32F439xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ ((AF) == GPIO_AF15_EVENTOUT) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF5_SPI5) || ((AF) == GPIO_AF5_SPI6) || \ ((AF) == GPIO_AF8_UART7) || ((AF) == GPIO_AF8_UART8) || \ ((AF) == GPIO_AF12_FMC) || ((AF) == GPIO_AF6_SAI1) || \ ((AF) == GPIO_AF14_LTDC)) #endif /* STM32F429xx || STM32F439xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------- STM32F427xx/STM32F437xx------------------*/ #if defined(STM32F427xx) || defined(STM32F437xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ ((AF) == GPIO_AF15_EVENTOUT) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF5_SPI5) || ((AF) == GPIO_AF5_SPI6) || \ ((AF) == GPIO_AF8_UART7) || ((AF) == GPIO_AF8_UART8) || \ ((AF) == GPIO_AF12_FMC) || ((AF) == GPIO_AF6_SAI1)) #endif /* STM32F427xx || STM32F437xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------- STM32F407xx/STM32F417xx------------------*/ #if defined(STM32F407xx) || defined(STM32F417xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) #endif /* STM32F407xx || STM32F417xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------- STM32F405xx/STM32F415xx------------------*/ #if defined(STM32F405xx) || defined(STM32F415xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF12_OTG_HS_FS) || ((AF) == GPIO_AF12_SDIO) || \ ((AF) == GPIO_AF12_FSMC) || ((AF) == GPIO_AF15_EVENTOUT)) #endif /* STM32F405xx || STM32F415xx */ /*----------------------------------------------------------------------------*/ /*---------------------------------------- STM32F401xx------------------------*/ #if defined(STM32F401xC) || defined(STM32F401xE) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF4_I2C1) || \ ((AF) == GPIO_AF4_I2C2) || ((AF) == GPIO_AF4_I2C3) || \ ((AF) == GPIO_AF5_SPI1) || ((AF) == GPIO_AF5_SPI2) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF8_USART6) || ((AF) == GPIO_AF10_OTG_FS) || \ ((AF) == GPIO_AF9_I2C2) || ((AF) == GPIO_AF9_I2C3) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF15_EVENTOUT)) #endif /* STM32F401xC || STM32F401xE */ /*----------------------------------------------------------------------------*/ /*---------------------------------------- STM32F410xx------------------------*/ #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) #define IS_GPIO_AF(AF) (((AF) < 10U) || ((AF) == 15U)) #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ /*---------------------------------------- STM32F411xx------------------------*/ #if defined(STM32F411xE) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF4_I2C1) || \ ((AF) == GPIO_AF4_I2C2) || ((AF) == GPIO_AF4_I2C3) || \ ((AF) == GPIO_AF5_SPI1) || ((AF) == GPIO_AF5_SPI2) || \ ((AF) == GPIO_AF5_SPI3) || ((AF) == GPIO_AF6_SPI4) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF6_SPI5) || ((AF) == GPIO_AF7_SPI3) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF8_USART6) || ((AF) == GPIO_AF10_OTG_FS) || \ ((AF) == GPIO_AF9_I2C2) || ((AF) == GPIO_AF9_I2C3) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF15_EVENTOUT)) #endif /* STM32F411xE */ /*----------------------------------------------------------------------------*/ /*----------------------------------------------- STM32F446xx ----------------*/ #if defined(STM32F446xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ ((AF) == GPIO_AF15_EVENTOUT) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF12_FMC) || ((AF) == GPIO_AF6_SAI1) || \ ((AF) == GPIO_AF3_CEC) || ((AF) == GPIO_AF4_CEC) || \ ((AF) == GPIO_AF5_SPI3) || ((AF) == GPIO_AF6_SPI2) || \ ((AF) == GPIO_AF6_SPI4) || ((AF) == GPIO_AF7_UART5) || \ ((AF) == GPIO_AF7_SPI2) || ((AF) == GPIO_AF7_SPI3) || \ ((AF) == GPIO_AF7_SPDIFRX) || ((AF) == GPIO_AF8_SPDIFRX) || \ ((AF) == GPIO_AF8_SAI2) || ((AF) == GPIO_AF9_QSPI) || \ ((AF) == GPIO_AF10_SAI2) || ((AF) == GPIO_AF10_QSPI)) #endif /* STM32F446xx */ /*----------------------------------------------------------------------------*/ /*------------------------------------------- STM32F469xx/STM32F479xx --------*/ #if defined(STM32F469xx) || defined(STM32F479xx) #define IS_GPIO_AF(AF) (((AF) == GPIO_AF0_RTC_50Hz) || ((AF) == GPIO_AF9_TIM14) || \ ((AF) == GPIO_AF0_MCO) || ((AF) == GPIO_AF0_TAMPER) || \ ((AF) == GPIO_AF0_SWJ) || ((AF) == GPIO_AF0_TRACE) || \ ((AF) == GPIO_AF1_TIM1) || ((AF) == GPIO_AF1_TIM2) || \ ((AF) == GPIO_AF2_TIM3) || ((AF) == GPIO_AF2_TIM4) || \ ((AF) == GPIO_AF2_TIM5) || ((AF) == GPIO_AF3_TIM8) || \ ((AF) == GPIO_AF4_I2C1) || ((AF) == GPIO_AF4_I2C2) || \ ((AF) == GPIO_AF4_I2C3) || ((AF) == GPIO_AF5_SPI1) || \ ((AF) == GPIO_AF5_SPI2) || ((AF) == GPIO_AF9_TIM13) || \ ((AF) == GPIO_AF6_SPI3) || ((AF) == GPIO_AF9_TIM12) || \ ((AF) == GPIO_AF7_USART1) || ((AF) == GPIO_AF7_USART2) || \ ((AF) == GPIO_AF7_USART3) || ((AF) == GPIO_AF8_UART4) || \ ((AF) == GPIO_AF8_UART5) || ((AF) == GPIO_AF8_USART6) || \ ((AF) == GPIO_AF9_CAN1) || ((AF) == GPIO_AF9_CAN2) || \ ((AF) == GPIO_AF10_OTG_FS) || ((AF) == GPIO_AF10_OTG_HS) || \ ((AF) == GPIO_AF11_ETH) || ((AF) == GPIO_AF12_OTG_HS_FS) || \ ((AF) == GPIO_AF12_SDIO) || ((AF) == GPIO_AF13_DCMI) || \ ((AF) == GPIO_AF15_EVENTOUT) || ((AF) == GPIO_AF5_SPI4) || \ ((AF) == GPIO_AF5_SPI5) || ((AF) == GPIO_AF5_SPI6) || \ ((AF) == GPIO_AF8_UART7) || ((AF) == GPIO_AF8_UART8) || \ ((AF) == GPIO_AF12_FMC) || ((AF) == GPIO_AF6_SAI1) || \ ((AF) == GPIO_AF14_LTDC) || ((AF) == GPIO_AF13_DSI) || \ ((AF) == GPIO_AF9_QSPI) || ((AF) == GPIO_AF10_QSPI)) #endif /* STM32F469xx || STM32F479xx */ /*----------------------------------------------------------------------------*/ /*------------------STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx-----------*/ #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) #define IS_GPIO_AF(AF) (((AF) < 16U) && ((AF) != 11U) && ((AF) != 14U) && ((AF) != 13U)) #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ /*----------------------------------------------------------------------------*/ /*------------------STM32F413xx/STM32F423xx-----------------------------------*/ #if defined(STM32F413xx) || defined(STM32F423xx) #define IS_GPIO_AF(AF) (((AF) < 16U) && ((AF) != 13U)) #endif /* STM32F413xx || STM32F423xx */ /*----------------------------------------------------------------------------*/ /** * @} */ /** * @} */ /* Private functions ---------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Functions GPIO Private Functions * @{ */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* __STM32F4xx_HAL_GPIO_EX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/system_stm32f2xx.h ================================================ /** ****************************************************************************** * @file system_stm32f2xx.h * @author MCD Application Team * @version V2.1.2 * @date 29-June-2016 * @brief CMSIS Cortex-M3 Device System Source File for STM32F2xx devices. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f2xx_system * @{ */ /** * @brief Define to prevent recursive inclusion */ #ifndef __SYSTEM_STM32F2XX_H #define __SYSTEM_STM32F2XX_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup STM32F2xx_System_Includes * @{ */ /** * @} */ /** @addtogroup STM32F2xx_System_Exported_types * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ /** * @} */ /** @addtogroup STM32F2xx_System_Exported_Constants * @{ */ /** * @} */ /** @addtogroup STM32F2xx_System_Exported_Macros * @{ */ /** * @} */ /** @addtogroup STM32F2xx_System_Exported_Functions * @{ */ extern void SystemInit(void); extern void SystemCoreClockUpdate(void); /** * @} */ #ifdef __cplusplus } #endif #endif /*__SYSTEM_STM32F2XX_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/inc/system_stm32f4xx.h ================================================ /** ****************************************************************************** * @file system_stm32f4xx.h * @author MCD Application Team * @version V2.6.0 * @date 04-November-2016 * @brief CMSIS Cortex-M4 Device System Source File for STM32F4xx devices. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32f4xx_system * @{ */ /** * @brief Define to prevent recursive inclusion */ #ifndef __SYSTEM_STM32F4XX_H #define __SYSTEM_STM32F4XX_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup STM32F4xx_System_Includes * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_types * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */ extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_Constants * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_Macros * @{ */ /** * @} */ /** @addtogroup STM32F4xx_System_Exported_Functions * @{ */ extern void SystemInit(void); extern void SystemCoreClockUpdate(void); /** * @} */ #ifdef __cplusplus } #endif #endif /*__SYSTEM_STM32F4XX_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/interrupt_handlers.h ================================================ // ********************* Bare interrupt handlers ********************* // Only implemented the STM32F413 interrupts for now, the STM32F203 specific ones do not fall into the scope of SIL2 void WWDG_IRQHandler(void) {handle_interrupt(WWDG_IRQn);} void PVD_IRQHandler(void) {handle_interrupt(PVD_IRQn);} void TAMP_STAMP_IRQHandler(void) {handle_interrupt(TAMP_STAMP_IRQn);} void RTC_WKUP_IRQHandler(void) {handle_interrupt(RTC_WKUP_IRQn);} void FLASH_IRQHandler(void) {handle_interrupt(FLASH_IRQn);} void RCC_IRQHandler(void) {handle_interrupt(RCC_IRQn);} void EXTI0_IRQHandler(void) {handle_interrupt(EXTI0_IRQn);} void EXTI1_IRQHandler(void) {handle_interrupt(EXTI1_IRQn);} void EXTI2_IRQHandler(void) {handle_interrupt(EXTI2_IRQn);} void EXTI3_IRQHandler(void) {handle_interrupt(EXTI3_IRQn);} void EXTI4_IRQHandler(void) {handle_interrupt(EXTI4_IRQn);} void DMA1_Stream0_IRQHandler(void) {handle_interrupt(DMA1_Stream0_IRQn);} void DMA1_Stream1_IRQHandler(void) {handle_interrupt(DMA1_Stream1_IRQn);} void DMA1_Stream2_IRQHandler(void) {handle_interrupt(DMA1_Stream2_IRQn);} void DMA1_Stream3_IRQHandler(void) {handle_interrupt(DMA1_Stream3_IRQn);} void DMA1_Stream4_IRQHandler(void) {handle_interrupt(DMA1_Stream4_IRQn);} void DMA1_Stream5_IRQHandler(void) {handle_interrupt(DMA1_Stream5_IRQn);} void DMA1_Stream6_IRQHandler(void) {handle_interrupt(DMA1_Stream6_IRQn);} void ADC_IRQHandler(void) {handle_interrupt(ADC_IRQn);} void CAN1_TX_IRQHandler(void) {handle_interrupt(CAN1_TX_IRQn);} void CAN1_RX0_IRQHandler(void) {handle_interrupt(CAN1_RX0_IRQn);} void CAN1_RX1_IRQHandler(void) {handle_interrupt(CAN1_RX1_IRQn);} void CAN1_SCE_IRQHandler(void) {handle_interrupt(CAN1_SCE_IRQn);} void EXTI9_5_IRQHandler(void) {handle_interrupt(EXTI9_5_IRQn);} void TIM1_BRK_TIM9_IRQHandler(void) {handle_interrupt(TIM1_BRK_TIM9_IRQn);} void TIM1_UP_TIM10_IRQHandler(void) {handle_interrupt(TIM1_UP_TIM10_IRQn);} void TIM1_TRG_COM_TIM11_IRQHandler(void) {handle_interrupt(TIM1_TRG_COM_TIM11_IRQn);} void TIM1_CC_IRQHandler(void) {handle_interrupt(TIM1_CC_IRQn);} void TIM2_IRQHandler(void) {handle_interrupt(TIM2_IRQn);} void TIM3_IRQHandler(void) {handle_interrupt(TIM3_IRQn);} void TIM4_IRQHandler(void) {handle_interrupt(TIM4_IRQn);} void I2C1_EV_IRQHandler(void) {handle_interrupt(I2C1_EV_IRQn);} void I2C1_ER_IRQHandler(void) {handle_interrupt(I2C1_ER_IRQn);} void I2C2_EV_IRQHandler(void) {handle_interrupt(I2C2_EV_IRQn);} void I2C2_ER_IRQHandler(void) {handle_interrupt(I2C2_ER_IRQn);} void SPI1_IRQHandler(void) {handle_interrupt(SPI1_IRQn);} void SPI2_IRQHandler(void) {handle_interrupt(SPI2_IRQn);} void USART1_IRQHandler(void) {handle_interrupt(USART1_IRQn);} void USART2_IRQHandler(void) {handle_interrupt(USART2_IRQn);} void USART3_IRQHandler(void) {handle_interrupt(USART3_IRQn);} void EXTI15_10_IRQHandler(void) {handle_interrupt(EXTI15_10_IRQn);} void RTC_Alarm_IRQHandler(void) {handle_interrupt(RTC_Alarm_IRQn);} void OTG_FS_WKUP_IRQHandler(void) {handle_interrupt(OTG_FS_WKUP_IRQn);} void TIM8_BRK_TIM12_IRQHandler(void) {handle_interrupt(TIM8_BRK_TIM12_IRQn);} void TIM8_UP_TIM13_IRQHandler(void) {handle_interrupt(TIM8_UP_TIM13_IRQn);} void TIM8_TRG_COM_TIM14_IRQHandler(void) {handle_interrupt(TIM8_TRG_COM_TIM14_IRQn);} void TIM8_CC_IRQHandler(void) {handle_interrupt(TIM8_CC_IRQn);} void DMA1_Stream7_IRQHandler(void) {handle_interrupt(DMA1_Stream7_IRQn);} void FSMC_IRQHandler(void) {handle_interrupt(FSMC_IRQn);} void SDIO_IRQHandler(void) {handle_interrupt(SDIO_IRQn);} void TIM5_IRQHandler(void) {handle_interrupt(TIM5_IRQn);} void SPI3_IRQHandler(void) {handle_interrupt(SPI3_IRQn);} void UART4_IRQHandler(void) {handle_interrupt(UART4_IRQn);} void UART5_IRQHandler(void) {handle_interrupt(UART5_IRQn);} void TIM6_DAC_IRQHandler(void) {handle_interrupt(TIM6_DAC_IRQn);} void TIM7_IRQHandler(void) {handle_interrupt(TIM7_IRQn);} void DMA2_Stream0_IRQHandler(void) {handle_interrupt(DMA2_Stream0_IRQn);} void DMA2_Stream1_IRQHandler(void) {handle_interrupt(DMA2_Stream1_IRQn);} void DMA2_Stream2_IRQHandler(void) {handle_interrupt(DMA2_Stream2_IRQn);} void DMA2_Stream3_IRQHandler(void) {handle_interrupt(DMA2_Stream3_IRQn);} void DMA2_Stream4_IRQHandler(void) {handle_interrupt(DMA2_Stream4_IRQn);} void CAN2_TX_IRQHandler(void) {handle_interrupt(CAN2_TX_IRQn);} void CAN2_RX0_IRQHandler(void) {handle_interrupt(CAN2_RX0_IRQn);} void CAN2_RX1_IRQHandler(void) {handle_interrupt(CAN2_RX1_IRQn);} void CAN2_SCE_IRQHandler(void) {handle_interrupt(CAN2_SCE_IRQn);} void OTG_FS_IRQHandler(void) {handle_interrupt(OTG_FS_IRQn);} void DMA2_Stream5_IRQHandler(void) {handle_interrupt(DMA2_Stream5_IRQn);} void DMA2_Stream6_IRQHandler(void) {handle_interrupt(DMA2_Stream6_IRQn);} void DMA2_Stream7_IRQHandler(void) {handle_interrupt(DMA2_Stream7_IRQn);} void USART6_IRQHandler(void) {handle_interrupt(USART6_IRQn);} void I2C3_EV_IRQHandler(void) {handle_interrupt(I2C3_EV_IRQn);} void I2C3_ER_IRQHandler(void) {handle_interrupt(I2C3_ER_IRQn);} #ifdef STM32F4 void DFSDM1_FLT0_IRQHandler(void) {handle_interrupt(DFSDM1_FLT0_IRQn);} void DFSDM1_FLT1_IRQHandler(void) {handle_interrupt(DFSDM1_FLT1_IRQn);} void CAN3_TX_IRQHandler(void) {handle_interrupt(CAN3_TX_IRQn);} void CAN3_RX0_IRQHandler(void) {handle_interrupt(CAN3_RX0_IRQn);} void CAN3_RX1_IRQHandler(void) {handle_interrupt(CAN3_RX1_IRQn);} void CAN3_SCE_IRQHandler(void) {handle_interrupt(CAN3_SCE_IRQn);} void RNG_IRQHandler(void) {handle_interrupt(RNG_IRQn);} void FPU_IRQHandler(void) {handle_interrupt(FPU_IRQn);} void UART7_IRQHandler(void) {handle_interrupt(UART7_IRQn);} void UART8_IRQHandler(void) {handle_interrupt(UART8_IRQn);} void SPI4_IRQHandler(void) {handle_interrupt(SPI4_IRQn);} void SPI5_IRQHandler(void) {handle_interrupt(SPI5_IRQn);} void SAI1_IRQHandler(void) {handle_interrupt(SAI1_IRQn);} void UART9_IRQHandler(void) {handle_interrupt(UART9_IRQn);} void UART10_IRQHandler(void) {handle_interrupt(UART10_IRQn);} void QUADSPI_IRQHandler(void) {handle_interrupt(QUADSPI_IRQn);} void FMPI2C1_EV_IRQHandler(void) {handle_interrupt(FMPI2C1_EV_IRQn);} void FMPI2C1_ER_IRQHandler(void) {handle_interrupt(FMPI2C1_ER_IRQn);} void LPTIM1_IRQHandler(void) {handle_interrupt(LPTIM1_IRQn);} void DFSDM2_FLT0_IRQHandler(void) {handle_interrupt(DFSDM2_FLT0_IRQn);} void DFSDM2_FLT1_IRQHandler(void) {handle_interrupt(DFSDM2_FLT1_IRQn);} void DFSDM2_FLT2_IRQHandler(void) {handle_interrupt(DFSDM2_FLT2_IRQn);} void DFSDM2_FLT3_IRQHandler(void) {handle_interrupt(DFSDM2_FLT3_IRQn);} #endif ================================================ FILE: panda/board/stm32fx/lladc.h ================================================ // ACCEL1 = ADC10 // ACCEL2 = ADC11 // VOLT_S = ADC12 // CURR_S = ADC13 #define ADCCHAN_ACCEL0 10 #define ADCCHAN_ACCEL1 11 #define ADCCHAN_VOLTAGE 12 #define ADCCHAN_CURRENT 13 void register_set(volatile uint32_t *addr, uint32_t val, uint32_t mask); void adc_init(void) { register_set(&(ADC->CCR), ADC_CCR_TSVREFE | ADC_CCR_VBATE, 0xC30000U); register_set(&(ADC1->CR2), ADC_CR2_ADON, 0xFF7F0F03U); register_set(&(ADC1->SMPR1), ADC_SMPR1_SMP12 | ADC_SMPR1_SMP13, 0x7FFFFFFU); } uint32_t adc_get(unsigned int channel) { // Select channel register_set(&(ADC1->JSQR), (channel << 15U), 0x3FFFFFU); // Start conversion ADC1->SR &= ~(ADC_SR_JEOC); ADC1->CR2 |= ADC_CR2_JSWSTART; while (!(ADC1->SR & ADC_SR_JEOC)); return ADC1->JDR1; } uint32_t adc_get_voltage(void) { // REVC has a 10, 1 (1/11) voltage divider // Here is the calculation for the scale (s) // ADCV = VIN_S * (1/11) * (4095/3.3) // RETVAL = ADCV * s = VIN_S*1000 // s = 1000/((4095/3.3)*(1/11)) = 8.8623046875 // Avoid needing floating point math, so output in mV return (adc_get(ADCCHAN_VOLTAGE) * 8862U) / 1000U; } ================================================ FILE: panda/board/stm32fx/llbxcan.h ================================================ // this is needed for 1 mbps support #define CAN_QUANTA 8U #define CAN_SEQ1 6 // roundf(quanta * 0.875f) - 1; #define CAN_SEQ2 1 // roundf(quanta * 0.125f); #define CAN_PCLK 24000U // 333 = 33.3 kbps // 5000 = 500 kbps #define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10U / (x)) #define CAN_NAME_FROM_CANIF(CAN_DEV) (((CAN_DEV)==CAN1) ? "CAN1" : (((CAN_DEV) == CAN2) ? "CAN2" : "CAN3")) void puts(const char *a); bool llcan_set_speed(CAN_TypeDef *CAN_obj, uint32_t speed, bool loopback, bool silent) { bool ret = true; // initialization mode register_set(&(CAN_obj->MCR), CAN_MCR_TTCM | CAN_MCR_INRQ, 0x180FFU); uint32_t timeout_counter = 0U; while((CAN_obj->MSR & CAN_MSR_INAK) != CAN_MSR_INAK){ // Delay for about 1ms delay(10000); timeout_counter++; if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ puts(CAN_NAME_FROM_CANIF(CAN_obj)); puts(" set_speed timed out (1)!\n"); ret = false; break; } } if(ret){ // set time quanta from defines register_set(&(CAN_obj->BTR), ((CAN_BTR_TS1_0 * (CAN_SEQ1-1)) | (CAN_BTR_TS2_0 * (CAN_SEQ2-1)) | (can_speed_to_prescaler(speed) - 1U)), 0xC37F03FFU); // silent loopback mode for debugging if (loopback) { register_set_bits(&(CAN_obj->BTR), CAN_BTR_SILM | CAN_BTR_LBKM); } if (silent) { register_set_bits(&(CAN_obj->BTR), CAN_BTR_SILM); } // reset register_set(&(CAN_obj->MCR), CAN_MCR_TTCM | CAN_MCR_ABOM, 0x180FFU); timeout_counter = 0U; while(((CAN_obj->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)) { // Delay for about 1ms delay(10000); timeout_counter++; if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ puts(CAN_NAME_FROM_CANIF(CAN_obj)); puts(" set_speed timed out (2)!\n"); ret = false; break; } } } return ret; } bool llcan_init(CAN_TypeDef *CAN_obj) { bool ret = true; // Enter init mode register_set_bits(&(CAN_obj->FMR), CAN_FMR_FINIT); // Wait for INAK bit to be set uint32_t timeout_counter = 0U; while(((CAN_obj->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)) { // Delay for about 1ms delay(10000); timeout_counter++; if(timeout_counter >= CAN_INIT_TIMEOUT_MS){ puts(CAN_NAME_FROM_CANIF(CAN_obj)); puts(" initialization timed out!\n"); ret = false; break; } } if(ret){ // no mask // For some weird reason some of these registers do not want to set properly on CAN2 and CAN3. Probably something to do with the single/dual mode and their different filters. CAN_obj->sFilterRegister[0].FR1 = 0U; CAN_obj->sFilterRegister[0].FR2 = 0U; CAN_obj->sFilterRegister[14].FR1 = 0U; CAN_obj->sFilterRegister[14].FR2 = 0U; CAN_obj->FA1R |= 1U | (1U << 14); // Exit init mode, do not wait register_clear_bits(&(CAN_obj->FMR), CAN_FMR_FINIT); // enable certain CAN interrupts register_set_bits(&(CAN_obj->IER), CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_WKUIE); if (CAN_obj == CAN1) { NVIC_EnableIRQ(CAN1_TX_IRQn); NVIC_EnableIRQ(CAN1_RX0_IRQn); NVIC_EnableIRQ(CAN1_SCE_IRQn); } else if (CAN_obj == CAN2) { NVIC_EnableIRQ(CAN2_TX_IRQn); NVIC_EnableIRQ(CAN2_RX0_IRQn); NVIC_EnableIRQ(CAN2_SCE_IRQn); #ifdef CAN3 } else if (CAN_obj == CAN3) { NVIC_EnableIRQ(CAN3_TX_IRQn); NVIC_EnableIRQ(CAN3_RX0_IRQn); NVIC_EnableIRQ(CAN3_SCE_IRQn); #endif } else { puts("Invalid CAN: initialization failed\n"); } } return ret; } void llcan_clear_send(CAN_TypeDef *CAN_obj) { CAN_obj->TSR |= CAN_TSR_ABRQ0; register_clear_bits(&(CAN_obj->MSR), CAN_MSR_ERRI); // cppcheck-suppress selfAssignment ; needed to clear the register CAN_obj->MSR = CAN_obj->MSR; } ================================================ FILE: panda/board/stm32fx/lldac.h ================================================ void dac_init(void) { // No buffers required since we have an opamp register_set(&(DAC->DHR12R1), 0U, 0xFFFU); register_set(&(DAC->DHR12R2), 0U, 0xFFFU); register_set(&(DAC->CR), DAC_CR_EN1 | DAC_CR_EN2, 0x3FFF3FFFU); } void dac_set(int channel, uint32_t value) { if (channel == 0) { register_set(&(DAC->DHR12R1), value, 0xFFFU); } else if (channel == 1) { register_set(&(DAC->DHR12R2), value, 0xFFFU); } else { puts("Failed to set DAC: invalid channel value: 0x"); puth(value); puts("\n"); } } ================================================ FILE: panda/board/stm32fx/llfan.h ================================================ // TACH interrupt handler void EXTI2_IRQ_Handler(void) { volatile unsigned int pr = EXTI->PR & (1U << 2); if ((pr & (1U << 2)) != 0U) { fan_tach_counter++; } EXTI->PR = (1U << 2); } void fan_init(void){ // 5000RPM * 4 tach edges / 60 seconds REGISTER_INTERRUPT(EXTI2_IRQn, EXTI2_IRQ_Handler, 700U, FAULT_INTERRUPT_RATE_TACH) // Init PWM speed control pwm_init(TIM3, 3); // Init TACH interrupt register_set(&(SYSCFG->EXTICR[0]), SYSCFG_EXTICR1_EXTI2_PD, 0xF00U); register_set_bits(&(EXTI->IMR), (1U << 2)); register_set_bits(&(EXTI->RTSR), (1U << 2)); register_set_bits(&(EXTI->FTSR), (1U << 2)); NVIC_EnableIRQ(EXTI2_IRQn); } ================================================ FILE: panda/board/stm32fx/llflash.h ================================================ bool flash_is_locked(void) { return (FLASH->CR & FLASH_CR_LOCK); } void flash_unlock(void) { FLASH->KEYR = 0x45670123; FLASH->KEYR = 0xCDEF89AB; } bool flash_erase_sector(uint8_t sector, bool unlocked) { // don't erase the bootloader(sector 0) if (sector != 0 && sector < 12 && unlocked) { FLASH->CR = (sector << 3) | FLASH_CR_SER; FLASH->CR |= FLASH_CR_STRT; while (FLASH->SR & FLASH_SR_BSY); return true; } return false; } void flash_write_word(void *prog_ptr, uint32_t data) { uint32_t *pp = prog_ptr; FLASH->CR = FLASH_CR_PSIZE_1 | FLASH_CR_PG; *pp = data; while (FLASH->SR & FLASH_SR_BSY); } void flush_write_buffer(void) { } ================================================ FILE: panda/board/stm32fx/llrtc.h ================================================ #define RCC_BDCR_MASK (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL | RCC_BDCR_LSEMOD | RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) void enable_bdomain_protection(void) { register_clear_bits(&(PWR->CR), PWR_CR_DBP); } void disable_bdomain_protection(void) { register_set_bits(&(PWR->CR), PWR_CR_DBP); } ================================================ FILE: panda/board/stm32fx/llspi.h ================================================ // IRQs: DMA2_Stream2, DMA2_Stream3, EXTI4 void spi_init(void); int spi_cb_rx(uint8_t *data, int len, uint8_t *data_out); // end API #define SPI_BUF_SIZE 256 uint8_t spi_buf[SPI_BUF_SIZE]; int spi_buf_count = 0; int spi_total_count = 0; void spi_tx_dma(void *addr, int len) { // disable DMA register_clear_bits(&(SPI1->CR2), SPI_CR2_TXDMAEN); register_clear_bits(&(DMA2_Stream3->CR), DMA_SxCR_EN); // DMA2, stream 3, channel 3 register_set(&(DMA2_Stream3->M0AR), (uint32_t)addr, 0xFFFFFFFFU); DMA2_Stream3->NDTR = len; register_set(&(DMA2_Stream3->PAR), (uint32_t)&(SPI1->DR), 0xFFFFFFFFU); // channel3, increment memory, memory -> periph, enable register_set(&(DMA2_Stream3->CR), (DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_EN), 0x1E077EFEU); delay(0); register_set_bits(&(DMA2_Stream3->CR), DMA_SxCR_TCIE); register_set_bits(&(SPI1->CR2), SPI_CR2_TXDMAEN); // signal data is ready by driving low // esp must be configured as input by this point set_gpio_output(GPIOB, 0, 0); } void spi_rx_dma(void *addr, int len) { // disable DMA register_clear_bits(&(SPI1->CR2), SPI_CR2_RXDMAEN); register_clear_bits(&(DMA2_Stream2->CR), DMA_SxCR_EN); // drain the bus volatile uint8_t dat = SPI1->DR; (void)dat; // DMA2, stream 2, channel 3 register_set(&(DMA2_Stream2->M0AR), (uint32_t)addr, 0xFFFFFFFFU); DMA2_Stream2->NDTR = len; register_set(&(DMA2_Stream2->PAR), (uint32_t)&(SPI1->DR), 0xFFFFFFFFU); // channel3, increment memory, periph -> memory, enable register_set(&(DMA2_Stream2->CR), (DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0 | DMA_SxCR_MINC | DMA_SxCR_EN), 0x1E077EFEU); delay(0); register_set_bits(&(DMA2_Stream2->CR), DMA_SxCR_TCIE); register_set_bits(&(SPI1->CR2), SPI_CR2_RXDMAEN); } // ***************************** SPI IRQs ***************************** // can't go on the stack cause it's DMAed uint8_t spi_tx_buf[0x44]; // SPI RX void DMA2_Stream2_IRQ_Handler(void) { int *resp_len = (int*)spi_tx_buf; (void)memset(spi_tx_buf, 0xaa, 0x44); *resp_len = spi_cb_rx(spi_buf, 0x14, spi_tx_buf+4); #ifdef DEBUG_SPI puts("SPI write: "); puth(*resp_len); puts("\n"); #endif spi_tx_dma(spi_tx_buf, *resp_len + 4); // ack DMA2->LIFCR = DMA_LIFCR_CTCIF2; } // SPI TX void DMA2_Stream3_IRQ_Handler(void) { #ifdef DEBUG_SPI puts("SPI handshake\n"); #endif // reset handshake back to pull up set_gpio_mode(GPIOB, 0, MODE_INPUT); set_gpio_pullup(GPIOB, 0, PULL_UP); // ack DMA2->LIFCR = DMA_LIFCR_CTCIF3; } void EXTI4_IRQ_Handler(void) { volatile unsigned int pr = EXTI->PR & (1U << 4); #ifdef DEBUG_SPI puts("exti4\n"); #endif // SPI CS falling if ((pr & (1U << 4)) != 0U) { spi_total_count = 0; spi_rx_dma(spi_buf, 0x14); } EXTI->PR = pr; } // ***************************** SPI init ***************************** void spi_init(void) { // Max SPI clock the ESP can produce is 80MHz. At buffer size of 256 bytes, that's a max of about 40k buffers per second REGISTER_INTERRUPT(DMA2_Stream2_IRQn, DMA2_Stream2_IRQ_Handler, 50000U, FAULT_INTERRUPT_RATE_SPI_DMA) REGISTER_INTERRUPT(DMA2_Stream3_IRQn, DMA2_Stream3_IRQ_Handler, 50000U, FAULT_INTERRUPT_RATE_SPI_DMA) REGISTER_INTERRUPT(EXTI4_IRQn, EXTI4_IRQ_Handler, 50000U, FAULT_INTERRUPT_RATE_SPI_CS) // TODO: Figure out if this is a reasonable limit //puts("SPI init\n"); register_set(&(SPI1->CR1), SPI_CR1_SPE, 0xFFFFU); // enable SPI interrupts //SPI1->CR2 = SPI_CR2_RXNEIE | SPI_CR2_ERRIE | SPI_CR2_TXEIE; register_set(&(SPI1->CR2), SPI_CR2_RXNEIE, 0xF7U); NVIC_EnableIRQ(DMA2_Stream2_IRQn); NVIC_EnableIRQ(DMA2_Stream3_IRQn); //NVIC_EnableIRQ(SPI1_IRQn); // reset handshake back to pull up set_gpio_mode(GPIOB, 0, MODE_INPUT); set_gpio_pullup(GPIOB, 0, PULL_UP); // setup interrupt on falling edge of SPI enable (on PA4) register_set(&(SYSCFG->EXTICR[2]), SYSCFG_EXTICR2_EXTI4_PA, 0xFFFFU); register_set_bits(&(EXTI->IMR), (1U << 4)); register_set_bits(&(EXTI->FTSR), (1U << 4)); NVIC_EnableIRQ(EXTI4_IRQn); } ================================================ FILE: panda/board/stm32fx/lluart.h ================================================ // ***************************** Interrupt handlers ***************************** void uart_tx_ring(uart_ring *q){ ENTER_CRITICAL(); // Send out next byte of TX buffer if (q->w_ptr_tx != q->r_ptr_tx) { // Only send if transmit register is empty (aka last byte has been sent) if ((q->uart->SR & USART_SR_TXE) != 0) { q->uart->DR = q->elems_tx[q->r_ptr_tx]; // This clears TXE q->r_ptr_tx = (q->r_ptr_tx + 1U) % q->tx_fifo_size; } // Enable TXE interrupt if there is still data to be sent if(q->r_ptr_tx != q->w_ptr_tx){ q->uart->CR1 |= USART_CR1_TXEIE; } else { q->uart->CR1 &= ~USART_CR1_TXEIE; } } EXIT_CRITICAL(); } void uart_rx_ring(uart_ring *q){ // Do not read out directly if DMA enabled if (q->dma_rx == false) { ENTER_CRITICAL(); // Read out RX buffer uint8_t c = q->uart->DR; // This read after reading SR clears a bunch of interrupts uint16_t next_w_ptr = (q->w_ptr_rx + 1U) % q->rx_fifo_size; // Do not overwrite buffer data if (next_w_ptr != q->r_ptr_rx) { q->elems_rx[q->w_ptr_rx] = c; q->w_ptr_rx = next_w_ptr; if (q->callback != NULL) { q->callback(q); } } EXIT_CRITICAL(); } } void uart_send_break(uart_ring *u) { while ((u->uart->CR1 & USART_CR1_SBK) != 0); u->uart->CR1 |= USART_CR1_SBK; } // This function should be called on: // * Half-transfer DMA interrupt // * Full-transfer DMA interrupt // * UART IDLE detection uint32_t prev_w_index = 0; void dma_pointer_handler(uart_ring *q, uint32_t dma_ndtr) { ENTER_CRITICAL(); uint32_t w_index = (q->rx_fifo_size - dma_ndtr); // Check for new data if (w_index != prev_w_index){ // Check for overflow if ( ((prev_w_index < q->r_ptr_rx) && (q->r_ptr_rx <= w_index)) || // No rollover ((w_index < prev_w_index) && ((q->r_ptr_rx <= w_index) || (prev_w_index < q->r_ptr_rx))) // Rollover ){ // We lost data. Set the new read pointer to the oldest byte still available q->r_ptr_rx = (w_index + 1U) % q->rx_fifo_size; } // Set write pointer q->w_ptr_rx = w_index; } prev_w_index = w_index; EXIT_CRITICAL(); } // This read after reading SR clears all error interrupts. We don't want compiler warnings, nor optimizations #define UART_READ_DR(uart) volatile uint8_t t = (uart)->DR; UNUSED(t); void uart_interrupt_handler(uart_ring *q) { ENTER_CRITICAL(); // Read UART status. This is also the first step necessary in clearing most interrupts uint32_t status = q->uart->SR; // If RXNE is set, perform a read. This clears RXNE, ORE, IDLE, NF and FE if((status & USART_SR_RXNE) != 0U){ uart_rx_ring(q); } // Detect errors and clear them uint32_t err = (status & USART_SR_ORE) | (status & USART_SR_NE) | (status & USART_SR_FE) | (status & USART_SR_PE); if(err != 0U){ #ifdef DEBUG_UART puts("Encountered UART error: "); puth(err); puts("\n"); #endif UART_READ_DR(q->uart) } // Send if necessary uart_tx_ring(q); // Run DMA pointer handler if the line is idle if(q->dma_rx && (status & USART_SR_IDLE)){ // Reset IDLE flag UART_READ_DR(q->uart) if(q == &uart_ring_gps){ dma_pointer_handler(&uart_ring_gps, DMA2_Stream5->NDTR); } else { #ifdef DEBUG_UART puts("No IDLE dma_pointer_handler implemented for this UART."); #endif } } EXIT_CRITICAL(); } void USART1_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_gps); } void USART2_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_debug); } void USART3_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_lin2); } void UART5_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_lin1); } void DMA2_Stream5_IRQ_Handler(void) { ENTER_CRITICAL(); // Handle errors if((DMA2->HISR & DMA_HISR_TEIF5) || (DMA2->HISR & DMA_HISR_DMEIF5) || (DMA2->HISR & DMA_HISR_FEIF5)){ #ifdef DEBUG_UART puts("Encountered UART DMA error. Clearing and restarting DMA...\n"); #endif // Clear flags DMA2->HIFCR = DMA_HIFCR_CTEIF5 | DMA_HIFCR_CDMEIF5 | DMA_HIFCR_CFEIF5; // Re-enable the DMA if necessary DMA2_Stream5->CR |= DMA_SxCR_EN; } // Re-calculate write pointer and reset flags dma_pointer_handler(&uart_ring_gps, DMA2_Stream5->NDTR); DMA2->HIFCR = DMA_HIFCR_CTCIF5 | DMA_HIFCR_CHTIF5; EXIT_CRITICAL(); } // ***************************** Hardware setup ***************************** void dma_rx_init(uart_ring *q) { // Initialization is UART-dependent if(q == &uart_ring_gps){ // DMA2, stream 5, channel 4 // Disable FIFO mode (enable direct) DMA2_Stream5->FCR &= ~DMA_SxFCR_DMDIS; // Setup addresses DMA2_Stream5->PAR = (uint32_t)&(USART1->DR); // Source DMA2_Stream5->M0AR = (uint32_t)q->elems_rx; // Destination DMA2_Stream5->NDTR = q->rx_fifo_size; // Number of bytes to copy // Circular, Increment memory, byte size, periph -> memory, enable // Transfer complete, half transfer, transfer error and direct mode error interrupt enable DMA2_Stream5->CR = DMA_SxCR_CHSEL_2 | DMA_SxCR_MINC | DMA_SxCR_CIRC | DMA_SxCR_HTIE | DMA_SxCR_TCIE | DMA_SxCR_TEIE | DMA_SxCR_DMEIE | DMA_SxCR_EN; // Enable DMA receiver in UART q->uart->CR3 |= USART_CR3_DMAR; // Enable UART IDLE interrupt q->uart->CR1 |= USART_CR1_IDLEIE; // Enable interrupt NVIC_EnableIRQ(DMA2_Stream5_IRQn); } else { puts("Tried to initialize RX DMA for an unsupported UART\n"); } } #define __DIV(_PCLK_, _BAUD_) (((_PCLK_) * 25U) / (4U * (_BAUD_))) #define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_)) / 100U) #define __DIVFRAQ(_PCLK_, _BAUD_) ((((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U) #define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4) | (__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU)) void uart_set_baud(USART_TypeDef *u, unsigned int baud) { if (u == USART1) { // USART1 is on APB2 u->BRR = __USART_BRR(48000000U, baud); } else { u->BRR = __USART_BRR(24000000U, baud); } } void uart_init(uart_ring *q, int baud) { // Register interrupts (max data rate: 115200 baud) if(q->uart == USART1){ REGISTER_INTERRUPT(USART1_IRQn, USART1_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_1) } else if (q->uart == USART2){ REGISTER_INTERRUPT(USART2_IRQn, USART2_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_2) } else if (q->uart == USART3){ REGISTER_INTERRUPT(USART3_IRQn, USART3_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_3) } else if (q->uart == UART5){ REGISTER_INTERRUPT(UART5_IRQn, UART5_IRQ_Handler, 150000U, FAULT_INTERRUPT_RATE_UART_5) } else { // UART not used. Skip registering interrupts } if(q->dma_rx){ REGISTER_INTERRUPT(DMA2_Stream5_IRQn, DMA2_Stream5_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_UART_DMA) // Called twice per buffer } // Set baud and enable peripheral with TX and RX mode uart_set_baud(q->uart, baud); q->uart->CR1 = USART_CR1_UE | USART_CR1_TE | USART_CR1_RE; if ((q->uart == USART2) || (q->uart == USART3) || (q->uart == UART5)) { q->uart->CR1 |= USART_CR1_RXNEIE; } // Enable UART interrupts if(q->uart == USART1){ NVIC_EnableIRQ(USART1_IRQn); } else if (q->uart == USART2){ NVIC_EnableIRQ(USART2_IRQn); } else if (q->uart == USART3){ NVIC_EnableIRQ(USART3_IRQn); } else if (q->uart == UART5){ NVIC_EnableIRQ(UART5_IRQn); } else { // UART not used. Skip enabling interrupts } // Initialise RX DMA if used if(q->dma_rx){ dma_rx_init(q); } } ================================================ FILE: panda/board/stm32fx/llusb.h ================================================ typedef struct { __IO uint32_t HPRT; } USB_OTG_HostPortTypeDef; USB_OTG_GlobalTypeDef *USBx = USB_OTG_FS; #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE)) #define USBx_HOST_PORT ((USB_OTG_HostPortTypeDef *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE)) #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t)USBx + USB_OTG_DEVICE_BASE)) #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) #define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE) #define USBD_FS_TRDT_VALUE 5U #define USB_OTG_SPEED_FULL 3 void usb_irqhandler(void); void OTG_FS_IRQ_Handler(void) { NVIC_DisableIRQ(OTG_FS_IRQn); //__disable_irq(); usb_irqhandler(); //__enable_irq(); NVIC_EnableIRQ(OTG_FS_IRQn); } void usb_init(void) { REGISTER_INTERRUPT(OTG_FS_IRQn, OTG_FS_IRQ_Handler, 1500000U, FAULT_INTERRUPT_RATE_USB) //TODO: Find out a better rate limit for USB. Now it's the 1.5MB/s rate // full speed PHY, do reset and remove power down /*puth(USBx->GRSTCTL); puts(" resetting PHY\n");*/ while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0); //puts("AHB idle\n"); // reset PHY here USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST; while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST); //puts("reset done\n"); // internal PHY, force device mode USBx->GUSBCFG = USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_FDMOD; // slowest timings USBx->GUSBCFG |= ((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); // power up the PHY #ifdef STM32F4 USBx->GCCFG = USB_OTG_GCCFG_PWRDWN; //USBx->GCCFG |= USB_OTG_GCCFG_VBDEN | USB_OTG_GCCFG_SDEN |USB_OTG_GCCFG_PDEN | USB_OTG_GCCFG_DCDEN; /* B-peripheral session valid override enable*/ USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; #else USBx->GCCFG = USB_OTG_GCCFG_PWRDWN | USB_OTG_GCCFG_NOVBUSSENS; #endif // be a device, slowest timings //USBx->GUSBCFG = USB_OTG_GUSBCFG_FDMOD | USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_TRDT | USB_OTG_GUSBCFG_TOCAL; //USBx->GUSBCFG |= (uint32_t)((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); //USBx->GUSBCFG = USB_OTG_GUSBCFG_PHYSEL | USB_OTG_GUSBCFG_TRDT | USB_OTG_GUSBCFG_TOCAL; // **** for debugging, doesn't seem to work **** //USBx->GUSBCFG |= USB_OTG_GUSBCFG_CTXPKT; // reset PHY clock USBx_PCGCCTL = 0; // enable the fancy OTG things // DCFG_FRAME_INTERVAL_80 is 0 //USBx->GUSBCFG |= USB_OTG_GUSBCFG_HNPCAP | USB_OTG_GUSBCFG_SRPCAP; USBx_DEVICE->DCFG |= USB_OTG_SPEED_FULL | USB_OTG_DCFG_NZLSOHSK; //USBx_DEVICE->DCFG = USB_OTG_DCFG_NZLSOHSK | USB_OTG_DCFG_DSPD; //USBx_DEVICE->DCFG = USB_OTG_DCFG_DSPD; // clear pending interrupts USBx->GINTSTS = 0xBFFFFFFFU; // setup USB interrupts // all interrupts except TXFIFO EMPTY //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM | USB_OTG_GINTSTS_SOF | USB_OTG_GINTSTS_EOPF); //USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM); USBx->GINTMSK = USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_OTGINT | USB_OTG_GINTMSK_RXFLVLM | USB_OTG_GINTMSK_GONAKEFFM | USB_OTG_GINTMSK_GINAKEFFM | USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IEPINT | USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_CIDSCHGM | USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_MMISM | USB_OTG_GINTMSK_EOPFM; USBx->GAHBCFG = USB_OTG_GAHBCFG_GINT; // DCTL startup value is 2 on new chip, 0 on old chip USBx_DEVICE->DCTL = 0; // enable the IRQ NVIC_EnableIRQ(OTG_FS_IRQn); } ================================================ FILE: panda/board/stm32fx/peripherals.h ================================================ void gpio_usb_init(void) { // A11,A12: USB set_gpio_alternate(GPIOA, 11, GPIO_AF10_OTG_FS); set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG_FS); GPIOA->OSPEEDR = GPIO_OSPEEDER_OSPEEDR11 | GPIO_OSPEEDER_OSPEEDR12; } void gpio_usart2_init(void) { // A2,A3: USART 2 for debugging set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); } // Common GPIO initialization void common_init_gpio(void) { // TODO: Is this block actually doing something??? // pull low to hold ESP in reset?? // enable OTG out tied to ground GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOA->PUPDR = 0; GPIOB->AFR[0] = 0; GPIOB->AFR[1] = 0; // C2: Voltage sense line set_gpio_mode(GPIOC, 2, MODE_ANALOG); gpio_usb_init(); // A9,A10: USART 1 for talking to the GPS set_gpio_alternate(GPIOA, 9, GPIO_AF7_USART1); set_gpio_alternate(GPIOA, 10, GPIO_AF7_USART1); // B8,B9: CAN 1 #ifdef STM32F4 set_gpio_alternate(GPIOB, 8, GPIO_AF8_CAN1); set_gpio_alternate(GPIOB, 9, GPIO_AF8_CAN1); #else set_gpio_alternate(GPIOB, 8, GPIO_AF9_CAN1); set_gpio_alternate(GPIOB, 9, GPIO_AF9_CAN1); #endif } void flasher_peripherals_init(void) { RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; RCC->APB1ENR |= RCC_APB1ENR_USART2EN; } // Peripheral initialization void peripherals_init(void) { // enable GPIOB, UART2, CAN, USB clock RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; RCC->APB1ENR |= RCC_APB1ENR_USART2EN; RCC->APB1ENR |= RCC_APB1ENR_USART3EN; #ifdef PANDA RCC->APB1ENR |= RCC_APB1ENR_UART5EN; #endif RCC->APB1ENR |= RCC_APB1ENR_CAN1EN; RCC->APB1ENR |= RCC_APB1ENR_CAN2EN; #ifdef CAN3 RCC->APB1ENR |= RCC_APB1ENR_CAN3EN; #endif RCC->APB1ENR |= RCC_APB1ENR_DACEN; RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; // main counter RCC->APB1ENR |= RCC_APB1ENR_TIM3EN; // pedal and fan PWM RCC->APB1ENR |= RCC_APB1ENR_TIM4EN; // IR PWM RCC->APB1ENR |= RCC_APB1ENR_TIM5EN; // k-line init RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; // interrupt timer RCC->APB1ENR |= RCC_APB1ENR_TIM12EN; // gmlan_alt RCC->APB1ENR |= RCC_APB1ENR_PWREN; // for RTC config RCC->APB2ENR |= RCC_APB2ENR_USART1EN; RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // clock source timer RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; RCC->APB2ENR |= RCC_APB2ENR_SPI1EN; RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; RCC->APB2ENR |= RCC_APB2ENR_TIM9EN; // slow loop } void enable_interrupt_timer(void) { register_set_bits(&(RCC->APB1ENR), RCC_APB1ENR_TIM6EN); // Enable interrupt timer peripheral } ================================================ FILE: panda/board/stm32fx/startup_stm32f205xx.s ================================================ /** ****************************************************************************** * @file startup_stm32f205xx.s * @author MCD Application Team * @version V2.1.2 * @date 29-June-2016 * @brief STM32F205xx Devices vector table for Atollic TrueSTUDIO toolchain. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, * - Set the vector table entries with the exceptions ISR address * - Branches to main in the C library (which eventually * calls main()). * After Reset the Cortex-M3 processor is in Thread mode, * priority is Privileged, and the Stack is set to Main. ****************************************************************************** * @attention * *

© COPYRIGHT 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ .syntax unified .cpu cortex-m3 .thumb .global g_pfnVectors .global Default_Handler /* start address for the initialization values of the .data section. defined in linker script */ .word _sidata /* start address for the .data section. defined in linker script */ .word _sdata /* end address for the .data section. defined in linker script */ .word _edata /* start address for the .bss section. defined in linker script */ .word _sbss /* end address for the .bss section. defined in linker script */ .word _ebss /* stack used for SystemInit_ExtMemCtl; always internal RAM used */ /** * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application * supplied main() routine is called. * @param None * @retval : None */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: ldr sp, =_estack /* set stack pointer */ bl __initialize_hardware_early /* Copy the data segment initializers from flash to SRAM */ movs r1, #0 b LoopCopyDataInit CopyDataInit: ldr r3, =_sidata ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 LoopCopyDataInit: ldr r0, =_sdata ldr r3, =_edata adds r2, r0, r1 cmp r2, r3 bcc CopyDataInit ldr r2, =_sbss b LoopFillZerobss /* Zero fill the bss segment. */ FillZerobss: movs r3, #0 str r3, [r2], #4 LoopFillZerobss: ldr r3, = _ebss cmp r2, r3 bcc FillZerobss /* Call the clock system initialization function.*/ /*bl SystemInit */ /* Call static constructors */ /*bl __libc_init_array*/ /* Call the application's entry point.*/ bl main bx lr .size Reset_Handler, .-Reset_Handler /** * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, preserving * the system state for examination by a debugger. * @param None * @retval None */ .section .text.Default_Handler,"ax",%progbits Default_Handler: Infinite_Loop: b Infinite_Loop .size Default_Handler, .-Default_Handler /****************************************************************************** * * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * *******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word 0 .word 0 .word 0 .word SVC_Handler .word DebugMon_Handler .word 0 .word PendSV_Handler .word SysTick_Handler /* External Interrupts */ .word WWDG_IRQHandler /* Window WatchDog */ .word PVD_IRQHandler /* PVD through EXTI Line detection */ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ .word FLASH_IRQHandler /* FLASH */ .word RCC_IRQHandler /* RCC */ .word EXTI0_IRQHandler /* EXTI Line0 */ .word EXTI1_IRQHandler /* EXTI Line1 */ .word EXTI2_IRQHandler /* EXTI Line2 */ .word EXTI3_IRQHandler /* EXTI Line3 */ .word EXTI4_IRQHandler /* EXTI Line4 */ .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ .word CAN1_TX_IRQHandler /* CAN1 TX */ .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ .word CAN1_SCE_IRQHandler /* CAN1 SCE */ .word EXTI9_5_IRQHandler /* External Line[9:5]s */ .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ .word TIM2_IRQHandler /* TIM2 */ .word TIM3_IRQHandler /* TIM3 */ .word TIM4_IRQHandler /* TIM4 */ .word I2C1_EV_IRQHandler /* I2C1 Event */ .word I2C1_ER_IRQHandler /* I2C1 Error */ .word I2C2_EV_IRQHandler /* I2C2 Event */ .word I2C2_ER_IRQHandler /* I2C2 Error */ .word SPI1_IRQHandler /* SPI1 */ .word SPI2_IRQHandler /* SPI2 */ .word USART1_IRQHandler /* USART1 */ .word USART2_IRQHandler /* USART2 */ .word USART3_IRQHandler /* USART3 */ .word EXTI15_10_IRQHandler /* External Line[15:10]s */ .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ .word FSMC_IRQHandler /* FSMC */ .word SDIO_IRQHandler /* SDIO */ .word TIM5_IRQHandler /* TIM5 */ .word SPI3_IRQHandler /* SPI3 */ .word UART4_IRQHandler /* UART4 */ .word UART5_IRQHandler /* UART5 */ .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ .word TIM7_IRQHandler /* TIM7 */ .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word CAN2_TX_IRQHandler /* CAN2 TX */ .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ .word CAN2_SCE_IRQHandler /* CAN2 SCE */ .word OTG_FS_IRQHandler /* USB OTG FS */ .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ .word USART6_IRQHandler /* USART6 */ .word I2C3_EV_IRQHandler /* I2C3 event */ .word I2C3_ER_IRQHandler /* I2C3 error */ .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ .word OTG_HS_IRQHandler /* USB OTG HS */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word HASH_RNG_IRQHandler /* Hash and Rng */ /******************************************************************************* * * Provide weak aliases for each Exception handler to the Default_Handler. * As they are weak aliases, any function with the same name will override * this definition. * *******************************************************************************/ .weak NMI_Handler .thumb_set NMI_Handler,Default_Handler .weak HardFault_Handler .thumb_set HardFault_Handler,Default_Handler .weak MemManage_Handler .thumb_set MemManage_Handler,Default_Handler .weak BusFault_Handler .thumb_set BusFault_Handler,Default_Handler .weak UsageFault_Handler .thumb_set UsageFault_Handler,Default_Handler .weak SVC_Handler .thumb_set SVC_Handler,Default_Handler .weak DebugMon_Handler .thumb_set DebugMon_Handler,Default_Handler .weak PendSV_Handler .thumb_set PendSV_Handler,Default_Handler .weak SysTick_Handler .thumb_set SysTick_Handler,Default_Handler .weak WWDG_IRQHandler .thumb_set WWDG_IRQHandler,Default_Handler .weak PVD_IRQHandler .thumb_set PVD_IRQHandler,Default_Handler .weak TAMP_STAMP_IRQHandler .thumb_set TAMP_STAMP_IRQHandler,Default_Handler .weak RTC_WKUP_IRQHandler .thumb_set RTC_WKUP_IRQHandler,Default_Handler .weak FLASH_IRQHandler .thumb_set FLASH_IRQHandler,Default_Handler .weak RCC_IRQHandler .thumb_set RCC_IRQHandler,Default_Handler .weak EXTI0_IRQHandler .thumb_set EXTI0_IRQHandler,Default_Handler .weak EXTI1_IRQHandler .thumb_set EXTI1_IRQHandler,Default_Handler .weak EXTI2_IRQHandler .thumb_set EXTI2_IRQHandler,Default_Handler .weak EXTI3_IRQHandler .thumb_set EXTI3_IRQHandler,Default_Handler .weak EXTI4_IRQHandler .thumb_set EXTI4_IRQHandler,Default_Handler .weak DMA1_Stream0_IRQHandler .thumb_set DMA1_Stream0_IRQHandler,Default_Handler .weak DMA1_Stream1_IRQHandler .thumb_set DMA1_Stream1_IRQHandler,Default_Handler .weak DMA1_Stream2_IRQHandler .thumb_set DMA1_Stream2_IRQHandler,Default_Handler .weak DMA1_Stream3_IRQHandler .thumb_set DMA1_Stream3_IRQHandler,Default_Handler .weak DMA1_Stream4_IRQHandler .thumb_set DMA1_Stream4_IRQHandler,Default_Handler .weak DMA1_Stream5_IRQHandler .thumb_set DMA1_Stream5_IRQHandler,Default_Handler .weak DMA1_Stream6_IRQHandler .thumb_set DMA1_Stream6_IRQHandler,Default_Handler .weak ADC_IRQHandler .thumb_set ADC_IRQHandler,Default_Handler .weak CAN1_TX_IRQHandler .thumb_set CAN1_TX_IRQHandler,Default_Handler .weak CAN1_RX0_IRQHandler .thumb_set CAN1_RX0_IRQHandler,Default_Handler .weak CAN1_RX1_IRQHandler .thumb_set CAN1_RX1_IRQHandler,Default_Handler .weak CAN1_SCE_IRQHandler .thumb_set CAN1_SCE_IRQHandler,Default_Handler .weak EXTI9_5_IRQHandler .thumb_set EXTI9_5_IRQHandler,Default_Handler .weak TIM1_BRK_TIM9_IRQHandler .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler .weak TIM1_UP_TIM10_IRQHandler .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler .weak TIM1_TRG_COM_TIM11_IRQHandler .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler .weak TIM1_CC_IRQHandler .thumb_set TIM1_CC_IRQHandler,Default_Handler .weak TIM2_IRQHandler .thumb_set TIM2_IRQHandler,Default_Handler .weak TIM3_IRQHandler .thumb_set TIM3_IRQHandler,Default_Handler .weak TIM4_IRQHandler .thumb_set TIM4_IRQHandler,Default_Handler .weak I2C1_EV_IRQHandler .thumb_set I2C1_EV_IRQHandler,Default_Handler .weak I2C1_ER_IRQHandler .thumb_set I2C1_ER_IRQHandler,Default_Handler .weak I2C2_EV_IRQHandler .thumb_set I2C2_EV_IRQHandler,Default_Handler .weak I2C2_ER_IRQHandler .thumb_set I2C2_ER_IRQHandler,Default_Handler .weak SPI1_IRQHandler .thumb_set SPI1_IRQHandler,Default_Handler .weak SPI2_IRQHandler .thumb_set SPI2_IRQHandler,Default_Handler .weak USART1_IRQHandler .thumb_set USART1_IRQHandler,Default_Handler .weak USART2_IRQHandler .thumb_set USART2_IRQHandler,Default_Handler .weak USART3_IRQHandler .thumb_set USART3_IRQHandler,Default_Handler .weak EXTI15_10_IRQHandler .thumb_set EXTI15_10_IRQHandler,Default_Handler .weak RTC_Alarm_IRQHandler .thumb_set RTC_Alarm_IRQHandler,Default_Handler .weak OTG_FS_WKUP_IRQHandler .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler .weak TIM8_BRK_TIM12_IRQHandler .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler .weak TIM8_UP_TIM13_IRQHandler .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler .weak TIM8_TRG_COM_TIM14_IRQHandler .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler .weak TIM8_CC_IRQHandler .thumb_set TIM8_CC_IRQHandler,Default_Handler .weak DMA1_Stream7_IRQHandler .thumb_set DMA1_Stream7_IRQHandler,Default_Handler .weak FSMC_IRQHandler .thumb_set FSMC_IRQHandler,Default_Handler .weak SDIO_IRQHandler .thumb_set SDIO_IRQHandler,Default_Handler .weak TIM5_IRQHandler .thumb_set TIM5_IRQHandler,Default_Handler .weak SPI3_IRQHandler .thumb_set SPI3_IRQHandler,Default_Handler .weak UART4_IRQHandler .thumb_set UART4_IRQHandler,Default_Handler .weak UART5_IRQHandler .thumb_set UART5_IRQHandler,Default_Handler .weak TIM6_DAC_IRQHandler .thumb_set TIM6_DAC_IRQHandler,Default_Handler .weak TIM7_IRQHandler .thumb_set TIM7_IRQHandler,Default_Handler .weak DMA2_Stream0_IRQHandler .thumb_set DMA2_Stream0_IRQHandler,Default_Handler .weak DMA2_Stream1_IRQHandler .thumb_set DMA2_Stream1_IRQHandler,Default_Handler .weak DMA2_Stream2_IRQHandler .thumb_set DMA2_Stream2_IRQHandler,Default_Handler .weak DMA2_Stream3_IRQHandler .thumb_set DMA2_Stream3_IRQHandler,Default_Handler .weak DMA2_Stream4_IRQHandler .thumb_set DMA2_Stream4_IRQHandler,Default_Handler .weak CAN2_TX_IRQHandler .thumb_set CAN2_TX_IRQHandler,Default_Handler .weak CAN2_RX0_IRQHandler .thumb_set CAN2_RX0_IRQHandler,Default_Handler .weak CAN2_RX1_IRQHandler .thumb_set CAN2_RX1_IRQHandler,Default_Handler .weak CAN2_SCE_IRQHandler .thumb_set CAN2_SCE_IRQHandler,Default_Handler .weak OTG_FS_IRQHandler .thumb_set OTG_FS_IRQHandler,Default_Handler .weak DMA2_Stream5_IRQHandler .thumb_set DMA2_Stream5_IRQHandler,Default_Handler .weak DMA2_Stream6_IRQHandler .thumb_set DMA2_Stream6_IRQHandler,Default_Handler .weak DMA2_Stream7_IRQHandler .thumb_set DMA2_Stream7_IRQHandler,Default_Handler .weak USART6_IRQHandler .thumb_set USART6_IRQHandler,Default_Handler .weak I2C3_EV_IRQHandler .thumb_set I2C3_EV_IRQHandler,Default_Handler .weak I2C3_ER_IRQHandler .thumb_set I2C3_ER_IRQHandler,Default_Handler .weak OTG_HS_EP1_OUT_IRQHandler .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler .weak OTG_HS_EP1_IN_IRQHandler .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler .weak OTG_HS_WKUP_IRQHandler .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler .weak OTG_HS_IRQHandler .thumb_set OTG_HS_IRQHandler,Default_Handler .weak HASH_RNG_IRQHandler .thumb_set HASH_RNG_IRQHandler,Default_Handler /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/startup_stm32f413xx.s ================================================ /** ****************************************************************************** * @file startup_stm32f413xx.s * @author MCD Application Team * @version V2.6.0 * @date 04-November-2016 * @brief STM32F413xx Devices vector table for GCC based toolchains. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, * - Set the vector table entries with the exceptions ISR address * - Branches to main in the C library (which eventually * calls main()). * After Reset the Cortex-M4 processor is in Thread mode, * priority is Privileged, and the Stack is set to Main. ****************************************************************************** * @attention * *

© COPYRIGHT 2016 STMicroelectronics

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ .syntax unified .cpu cortex-m4 .fpu softvfp .thumb .global g_pfnVectors .global Default_Handler /* start address for the initialization values of the .data section. defined in linker script */ .word _sidata /* start address for the .data section. defined in linker script */ .word _sdata /* end address for the .data section. defined in linker script */ .word _edata /* start address for the .bss section. defined in linker script */ .word _sbss /* end address for the .bss section. defined in linker script */ .word _ebss /* stack used for SystemInit_ExtMemCtl; always internal RAM used */ /** * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application * supplied main() routine is called. * @param None * @retval : None */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: ldr sp, =_estack /* set stack pointer */ bl __initialize_hardware_early /* Copy the data segment initializers from flash to SRAM */ movs r1, #0 b LoopCopyDataInit CopyDataInit: ldr r3, =_sidata ldr r3, [r3, r1] str r3, [r0, r1] adds r1, r1, #4 LoopCopyDataInit: ldr r0, =_sdata ldr r3, =_edata adds r2, r0, r1 cmp r2, r3 bcc CopyDataInit ldr r2, =_sbss b LoopFillZerobss /* Zero fill the bss segment. */ FillZerobss: movs r3, #0 str r3, [r2], #4 LoopFillZerobss: ldr r3, = _ebss cmp r2, r3 bcc FillZerobss /* Call the clock system intitialization function.*/ /* bl SystemInit */ /* Call static constructors */ /* bl __libc_init_array */ /* Call the application's entry point.*/ bl main bx lr .size Reset_Handler, .-Reset_Handler /** * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, preserving * the system state for examination by a debugger. * @param None * @retval None */ .section .text.Default_Handler,"ax",%progbits Default_Handler: Infinite_Loop: b Infinite_Loop .size Default_Handler, .-Default_Handler /****************************************************************************** * * The minimal vector table for a Cortex M3. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * *******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word 0 .word 0 .word 0 .word SVC_Handler .word DebugMon_Handler .word 0 .word PendSV_Handler .word SysTick_Handler /* External Interrupts */ .word WWDG_IRQHandler /* Window WatchDog */ .word PVD_IRQHandler /* PVD through EXTI Line detection */ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ .word FLASH_IRQHandler /* FLASH */ .word RCC_IRQHandler /* RCC */ .word EXTI0_IRQHandler /* EXTI Line0 */ .word EXTI1_IRQHandler /* EXTI Line1 */ .word EXTI2_IRQHandler /* EXTI Line2 */ .word EXTI3_IRQHandler /* EXTI Line3 */ .word EXTI4_IRQHandler /* EXTI Line4 */ .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ .word CAN1_TX_IRQHandler /* CAN1 TX */ .word CAN1_RX0_IRQHandler /* CAN1 RX0 */ .word CAN1_RX1_IRQHandler /* CAN1 RX1 */ .word CAN1_SCE_IRQHandler /* CAN1 SCE */ .word EXTI9_5_IRQHandler /* External Line[9:5]s */ .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */ .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */ .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ .word TIM2_IRQHandler /* TIM2 */ .word TIM3_IRQHandler /* TIM3 */ .word TIM4_IRQHandler /* TIM4 */ .word I2C1_EV_IRQHandler /* I2C1 Event */ .word I2C1_ER_IRQHandler /* I2C1 Error */ .word I2C2_EV_IRQHandler /* I2C2 Event */ .word I2C2_ER_IRQHandler /* I2C2 Error */ .word SPI1_IRQHandler /* SPI1 */ .word SPI2_IRQHandler /* SPI2 */ .word USART1_IRQHandler /* USART1 */ .word USART2_IRQHandler /* USART2 */ .word USART3_IRQHandler /* USART3 */ .word EXTI15_10_IRQHandler /* External Line[15:10]s */ .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */ .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ .word FSMC_IRQHandler /* FSMC */ .word SDIO_IRQHandler /* SDIO */ .word TIM5_IRQHandler /* TIM5 */ .word SPI3_IRQHandler /* SPI3 */ .word UART4_IRQHandler /* UART4 */ .word UART5_IRQHandler /* UART5 */ .word TIM6_DAC_IRQHandler /* TIM6, DAC1 and DAC2 */ .word TIM7_IRQHandler /* TIM7 */ .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ .word DFSDM1_FLT0_IRQHandler /* DFSDM1 Filter0 */ .word DFSDM1_FLT1_IRQHandler /* DFSDM1 Filter1 */ .word CAN2_TX_IRQHandler /* CAN2 TX */ .word CAN2_RX0_IRQHandler /* CAN2 RX0 */ .word CAN2_RX1_IRQHandler /* CAN2 RX1 */ .word CAN2_SCE_IRQHandler /* CAN2 SCE */ .word OTG_FS_IRQHandler /* USB OTG FS */ .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ .word USART6_IRQHandler /* USART6 */ .word I2C3_EV_IRQHandler /* I2C3 event */ .word I2C3_ER_IRQHandler /* I2C3 error */ .word CAN3_TX_IRQHandler /* CAN3 TX */ .word CAN3_RX0_IRQHandler /* CAN3 RX0 */ .word CAN3_RX1_IRQHandler /* CAN3 RX1 */ .word CAN3_SCE_IRQHandler /* CAN3 SCE */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word RNG_IRQHandler /* RNG */ .word FPU_IRQHandler /* FPU */ .word UART7_IRQHandler /* UART7 */ .word UART8_IRQHandler /* UART8 */ .word SPI4_IRQHandler /* SPI4 */ .word SPI5_IRQHandler /* SPI5 */ .word 0 /* Reserved */ .word SAI1_IRQHandler /* SAI1 */ .word UART9_IRQHandler /* UART9 */ .word UART10_IRQHandler /* UART10 */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word QUADSPI_IRQHandler /* QuadSPI */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word FMPI2C1_EV_IRQHandler /* FMPI2C1 Event */ .word FMPI2C1_ER_IRQHandler /* FMPI2C1 Error */ .word LPTIM1_IRQHandler /* LPTIM1 */ .word DFSDM2_FLT0_IRQHandler /* DFSDM2 Filter0 */ .word DFSDM2_FLT1_IRQHandler /* DFSDM2 Filter1 */ .word DFSDM2_FLT2_IRQHandler /* DFSDM2 Filter2 */ .word DFSDM2_FLT3_IRQHandler /* DFSDM2 Filter3 */ /******************************************************************************* * * Provide weak aliases for each Exception handler to the Default_Handler. * As they are weak aliases, any function with the same name will override * this definition. * *******************************************************************************/ .weak NMI_Handler .thumb_set NMI_Handler,Default_Handler .weak HardFault_Handler .thumb_set HardFault_Handler,Default_Handler .weak MemManage_Handler .thumb_set MemManage_Handler,Default_Handler .weak BusFault_Handler .thumb_set BusFault_Handler,Default_Handler .weak UsageFault_Handler .thumb_set UsageFault_Handler,Default_Handler .weak SVC_Handler .thumb_set SVC_Handler,Default_Handler .weak DebugMon_Handler .thumb_set DebugMon_Handler,Default_Handler .weak PendSV_Handler .thumb_set PendSV_Handler,Default_Handler .weak SysTick_Handler .thumb_set SysTick_Handler,Default_Handler .weak WWDG_IRQHandler .thumb_set WWDG_IRQHandler,Default_Handler .weak PVD_IRQHandler .thumb_set PVD_IRQHandler,Default_Handler .weak TAMP_STAMP_IRQHandler .thumb_set TAMP_STAMP_IRQHandler,Default_Handler .weak RTC_WKUP_IRQHandler .thumb_set RTC_WKUP_IRQHandler,Default_Handler .weak FLASH_IRQHandler .thumb_set FLASH_IRQHandler,Default_Handler .weak RCC_IRQHandler .thumb_set RCC_IRQHandler,Default_Handler .weak EXTI0_IRQHandler .thumb_set EXTI0_IRQHandler,Default_Handler .weak EXTI1_IRQHandler .thumb_set EXTI1_IRQHandler,Default_Handler .weak EXTI2_IRQHandler .thumb_set EXTI2_IRQHandler,Default_Handler .weak EXTI3_IRQHandler .thumb_set EXTI3_IRQHandler,Default_Handler .weak EXTI4_IRQHandler .thumb_set EXTI4_IRQHandler,Default_Handler .weak DMA1_Stream0_IRQHandler .thumb_set DMA1_Stream0_IRQHandler,Default_Handler .weak DMA1_Stream1_IRQHandler .thumb_set DMA1_Stream1_IRQHandler,Default_Handler .weak DMA1_Stream2_IRQHandler .thumb_set DMA1_Stream2_IRQHandler,Default_Handler .weak DMA1_Stream3_IRQHandler .thumb_set DMA1_Stream3_IRQHandler,Default_Handler .weak DMA1_Stream4_IRQHandler .thumb_set DMA1_Stream4_IRQHandler,Default_Handler .weak DMA1_Stream5_IRQHandler .thumb_set DMA1_Stream5_IRQHandler,Default_Handler .weak DMA1_Stream6_IRQHandler .thumb_set DMA1_Stream6_IRQHandler,Default_Handler .weak ADC_IRQHandler .thumb_set ADC_IRQHandler,Default_Handler .weak CAN1_TX_IRQHandler .thumb_set CAN1_TX_IRQHandler,Default_Handler .weak CAN1_RX0_IRQHandler .thumb_set CAN1_RX0_IRQHandler,Default_Handler .weak CAN1_RX1_IRQHandler .thumb_set CAN1_RX1_IRQHandler,Default_Handler .weak CAN1_SCE_IRQHandler .thumb_set CAN1_SCE_IRQHandler,Default_Handler .weak EXTI9_5_IRQHandler .thumb_set EXTI9_5_IRQHandler,Default_Handler .weak TIM1_BRK_TIM9_IRQHandler .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler .weak TIM1_UP_TIM10_IRQHandler .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler .weak TIM1_TRG_COM_TIM11_IRQHandler .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler .weak TIM1_CC_IRQHandler .thumb_set TIM1_CC_IRQHandler,Default_Handler .weak TIM2_IRQHandler .thumb_set TIM2_IRQHandler,Default_Handler .weak TIM3_IRQHandler .thumb_set TIM3_IRQHandler,Default_Handler .weak TIM4_IRQHandler .thumb_set TIM4_IRQHandler,Default_Handler .weak I2C1_EV_IRQHandler .thumb_set I2C1_EV_IRQHandler,Default_Handler .weak I2C1_ER_IRQHandler .thumb_set I2C1_ER_IRQHandler,Default_Handler .weak I2C2_EV_IRQHandler .thumb_set I2C2_EV_IRQHandler,Default_Handler .weak I2C2_ER_IRQHandler .thumb_set I2C2_ER_IRQHandler,Default_Handler .weak SPI1_IRQHandler .thumb_set SPI1_IRQHandler,Default_Handler .weak SPI2_IRQHandler .thumb_set SPI2_IRQHandler,Default_Handler .weak USART1_IRQHandler .thumb_set USART1_IRQHandler,Default_Handler .weak USART2_IRQHandler .thumb_set USART2_IRQHandler,Default_Handler .weak USART3_IRQHandler .thumb_set USART3_IRQHandler,Default_Handler .weak EXTI15_10_IRQHandler .thumb_set EXTI15_10_IRQHandler,Default_Handler .weak RTC_Alarm_IRQHandler .thumb_set RTC_Alarm_IRQHandler,Default_Handler .weak OTG_FS_WKUP_IRQHandler .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler .weak TIM8_BRK_TIM12_IRQHandler .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler .weak TIM8_UP_TIM13_IRQHandler .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler .weak TIM8_TRG_COM_TIM14_IRQHandler .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler .weak TIM8_CC_IRQHandler .thumb_set TIM8_CC_IRQHandler,Default_Handler .weak DMA1_Stream7_IRQHandler .thumb_set DMA1_Stream7_IRQHandler,Default_Handler .weak FSMC_IRQHandler .thumb_set FSMC_IRQHandler,Default_Handler .weak SDIO_IRQHandler .thumb_set SDIO_IRQHandler,Default_Handler .weak TIM5_IRQHandler .thumb_set TIM5_IRQHandler,Default_Handler .weak SPI3_IRQHandler .thumb_set SPI3_IRQHandler,Default_Handler .weak UART4_IRQHandler .thumb_set UART4_IRQHandler,Default_Handler .weak UART5_IRQHandler .thumb_set UART5_IRQHandler,Default_Handler .weak TIM6_DAC_IRQHandler .thumb_set TIM6_DAC_IRQHandler,Default_Handler .weak TIM7_IRQHandler .thumb_set TIM7_IRQHandler,Default_Handler .weak DMA2_Stream0_IRQHandler .thumb_set DMA2_Stream0_IRQHandler,Default_Handler .weak DMA2_Stream1_IRQHandler .thumb_set DMA2_Stream1_IRQHandler,Default_Handler .weak DMA2_Stream2_IRQHandler .thumb_set DMA2_Stream2_IRQHandler,Default_Handler .weak DMA2_Stream3_IRQHandler .thumb_set DMA2_Stream3_IRQHandler,Default_Handler .weak DMA2_Stream4_IRQHandler .thumb_set DMA2_Stream4_IRQHandler,Default_Handler .weak DFSDM1_FLT0_IRQHandler .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler .weak DFSDM1_FLT1_IRQHandler .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler .weak CAN2_TX_IRQHandler .thumb_set CAN2_TX_IRQHandler,Default_Handler .weak CAN2_RX0_IRQHandler .thumb_set CAN2_RX0_IRQHandler,Default_Handler .weak CAN2_RX1_IRQHandler .thumb_set CAN2_RX1_IRQHandler,Default_Handler .weak CAN2_SCE_IRQHandler .thumb_set CAN2_SCE_IRQHandler,Default_Handler .weak OTG_FS_IRQHandler .thumb_set OTG_FS_IRQHandler,Default_Handler .weak DMA2_Stream5_IRQHandler .thumb_set DMA2_Stream5_IRQHandler,Default_Handler .weak DMA2_Stream6_IRQHandler .thumb_set DMA2_Stream6_IRQHandler,Default_Handler .weak DMA2_Stream7_IRQHandler .thumb_set DMA2_Stream7_IRQHandler,Default_Handler .weak USART6_IRQHandler .thumb_set USART6_IRQHandler,Default_Handler .weak I2C3_EV_IRQHandler .thumb_set I2C3_EV_IRQHandler,Default_Handler .weak I2C3_ER_IRQHandler .thumb_set I2C3_ER_IRQHandler,Default_Handler .weak CAN3_TX_IRQHandler .thumb_set CAN3_TX_IRQHandler,Default_Handler .weak CAN3_RX0_IRQHandler .thumb_set CAN3_RX0_IRQHandler,Default_Handler .weak CAN3_RX1_IRQHandler .thumb_set CAN3_RX1_IRQHandler,Default_Handler .weak CAN3_SCE_IRQHandler .thumb_set CAN3_SCE_IRQHandler,Default_Handler .weak RNG_IRQHandler .thumb_set RNG_IRQHandler,Default_Handler .weak FPU_IRQHandler .thumb_set FPU_IRQHandler,Default_Handler .weak UART7_IRQHandler .thumb_set UART7_IRQHandler,Default_Handler .weak UART8_IRQHandler .thumb_set UART8_IRQHandler,Default_Handler .weak SPI4_IRQHandler .thumb_set SPI4_IRQHandler,Default_Handler .weak SPI5_IRQHandler .thumb_set SPI5_IRQHandler,Default_Handler .weak SAI1_IRQHandler .thumb_set SAI1_IRQHandler,Default_Handler .weak UART9_IRQHandler .thumb_set UART9_IRQHandler,Default_Handler .weak UART10_IRQHandler .thumb_set UART10_IRQHandler,Default_Handler .weak QUADSPI_IRQHandler .thumb_set QUADSPI_IRQHandler,Default_Handler .weak FMPI2C1_EV_IRQHandler .thumb_set FMPI2C1_EV_IRQHandler,Default_Handler .weak FMPI2C1_ER_IRQHandler .thumb_set FMPI2C1_ER_IRQHandler,Default_Handler .weak LPTIM1_IRQHandler .thumb_set LPTIM1_IRQHandler,Default_Handler .weak DFSDM2_FLT0_IRQHandler .thumb_set DFSDM2_FLT0_IRQHandler,Default_Handler .weak DFSDM2_FLT1_IRQHandler .thumb_set DFSDM2_FLT1_IRQHandler,Default_Handler .weak DFSDM2_FLT2_IRQHandler .thumb_set DFSDM2_FLT2_IRQHandler,Default_Handler .weak DFSDM2_FLT3_IRQHandler .thumb_set DFSDM2_FLT3_IRQHandler,Default_Handler /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32fx/stm32fx_config.h ================================================ #ifdef STM32F4 #include "stm32fx/inc/stm32f4xx.h" #include "stm32fx/inc/stm32f4xx_hal_gpio_ex.h" #define MCU_IDCODE 0x463U #else #include "stm32fx/inc/stm32f2xx.h" #include "stm32fx/inc/stm32f2xx_hal_gpio_ex.h" #define MCU_IDCODE 0x411U #endif // from the linker script #define APP_START_ADDRESS 0x8004000U #define CORE_FREQ 96U // in Mhz //APB1 - 48Mhz, APB2 - 96Mhz #define APB1_FREQ CORE_FREQ/2U #define APB2_FREQ CORE_FREQ/1U #define BOOTLOADER_ADDRESS 0x1FFF0004U // Around (1Mbps / 8 bits/byte / 12 bytes per message) #define CAN_INTERRUPT_RATE 12000U #define MAX_LED_FADE 8192U // Threshold voltage (mV) for either of the SBUs to be below before deciding harness is connected #define HARNESS_CONNECTED_THRESHOLD 2500U #define NUM_INTERRUPTS 102U // There are 102 external interrupt sources (see stm32f413.h) #define TICK_TIMER_IRQ TIM1_BRK_TIM9_IRQn #define TICK_TIMER TIM9 #define MICROSECOND_TIMER TIM2 #define INTERRUPT_TIMER_IRQ TIM6_DAC_IRQn #define INTERRUPT_TIMER TIM6 #define PROVISION_CHUNK_ADDRESS 0x1FFF79E0U #define DEVICE_SERIAL_NUMBER_ADDRESS 0x1FFF79C0U #ifndef BOOTSTUB #ifdef PANDA #include "main_declarations.h" #else #include "pedal/main_declarations.h" #endif #else #include "bootstub_declarations.h" #endif #include "libc.h" #include "critical.h" #include "faults.h" #include "drivers/registers.h" #include "drivers/interrupts.h" #include "drivers/gpio.h" #include "stm32fx/peripherals.h" #include "stm32fx/interrupt_handlers.h" #include "drivers/timers.h" #include "stm32fx/lladc.h" #include "stm32fx/board.h" #include "stm32fx/clock.h" #if !defined (BOOTSTUB) && (defined(PANDA) || defined(PEDAL_USB)) #include "drivers/uart.h" #include "stm32fx/lluart.h" #endif #ifdef BOOTSTUB #include "stm32fx/llflash.h" #else #include "stm32fx/llbxcan.h" #endif #if defined(PANDA) || defined(BOOTSTUB) || defined(PEDAL_USB) #include "stm32fx/llusb.h" #endif #ifdef PEDAL #include "stm32fx/lldac.h" #endif void early_gpio_float(void) { RCC->AHB1ENR = RCC_AHB1ENR_GPIOAEN | RCC_AHB1ENR_GPIOBEN | RCC_AHB1ENR_GPIOCEN; GPIOA->MODER = 0; GPIOB->MODER = 0; GPIOC->MODER = 0; GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOC->ODR = 0; GPIOA->PUPDR = 0; GPIOB->PUPDR = 0; GPIOC->PUPDR = 0; } ================================================ FILE: panda/board/stm32fx/stm32fx_flash.ld ================================================ /* ***************************************************************************** ** ** File : stm32f4_flash.ld ** ** Abstract : Linker script for STM32F407VG Device with ** 1024KByte FLASH, 192KByte RAM ** ** Set heap size, stack size and stack location according ** to application requirements. ** ** Set memory bank area and size if external memory is used. ** ** Target : STMicroelectronics STM32 ** ** Environment : Atollic TrueSTUDIO(R) ** ** Distribution: The file is distributed "as is," without any warranty ** of any kind. ** ** (c)Copyright Atollic AB. ** You may use this file as-is or modify it according to the needs of your ** project. Distribution of this file (unmodified or modified) is not ** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the ** rights to distribute the assembled, compiled & linked contents of this ** file as part of an application binary file, provided that it is built ** using the Atollic TrueSTUDIO(R) toolchain. ** ***************************************************************************** */ /* Entry Point */ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ enter_bootloader_mode = 0x2001FFFC; _estack = 0x2001FFFC; /* end of 128K RAM on AHB bus*/ _app_start = 0x08004000; /* Reserve Sector 0(16K) for bootloader */ /* Generate a link error if heap and stack don't fit into RAM */ _Min_Heap_Size = 0; /* required amount of heap */ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K } /* Define output sections */ SECTIONS { /* The startup code goes first into FLASH */ .isr_vector : { . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } >FLASH /* The program code and other data goes into FLASH */ .text : { . = ALIGN(4); *(.text) /* .text sections (code) */ *(.text*) /* .text* sections (code) */ *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ *(.glue_7) /* glue arm to thumb code */ *(.glue_7t) /* glue thumb to arm code */ *(.eh_frame) KEEP (*(.init)) KEEP (*(.fini)) . = ALIGN(4); _etext = .; /* define a global symbols at end of code */ _exit = .; } >FLASH .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH .ARM : { __exidx_start = .; *(.ARM.exidx*) __exidx_end = .; } >FLASH .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array*)) PROVIDE_HIDDEN (__preinit_array_end = .); } >FLASH .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT(.init_array.*))) KEEP (*(.init_array*)) PROVIDE_HIDDEN (__init_array_end = .); } >FLASH .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(.fini_array*)) KEEP (*(SORT(.fini_array.*))) PROVIDE_HIDDEN (__fini_array_end = .); } >FLASH /* used by the startup to initialize data */ _sidata = .; /* Initialized data sections goes into RAM, load LMA copy after code */ .data : AT ( _sidata ) { . = ALIGN(4); _sdata = .; /* create a global symbol at data start */ *(.data) /* .data sections */ *(.data*) /* .data* sections */ . = ALIGN(4); _edata = .; /* define a global symbol at data end */ } >RAM /* Uninitialized data section */ . = ALIGN(4); .bss : { /* This is used by the startup in order to initialize the .bss secion */ _sbss = .; /* define a global symbol at bss start */ __bss_start__ = _sbss; *(.bss) *(.bss*) *(COMMON) . = ALIGN(4); _ebss = .; /* define a global symbol at bss end */ __bss_end__ = _ebss; } >RAM /* User_heap_stack section, used to check that there is enough RAM left */ ._user_heap_stack : { . = ALIGN(4); PROVIDE ( end = . ); PROVIDE ( _end = . ); . = . + _Min_Heap_Size; . = . + _Min_Stack_Size; . = ALIGN(4); } >RAM /* MEMORY_bank1 section, code must be located here explicitly */ /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ .memory_b1_text : { *(.mb1text) /* .mb1text sections (code) */ *(.mb1text*) /* .mb1text* sections (code) */ *(.mb1rodata) /* read-only data (constants) */ *(.mb1rodata*) } >MEMORY_B1 .ARM.attributes 0 : { *(.ARM.attributes) } } ================================================ FILE: panda/board/stm32h7/board.h ================================================ // ///////////////////////////////////////////////////////////// // // Hardware abstraction layer for all different supported boards // // ///////////////////////////////////////////////////////////// // #include "boards/board_declarations.h" #include "boards/unused_funcs.h" // ///// Board definition and detection ///// // #include "drivers/harness.h" #include "drivers/fan.h" #include "stm32h7/llfan.h" #include "stm32h7/llrtc.h" #include "drivers/rtc.h" #include "boards/red.h" uint8_t board_id(void) { return detect_with_pull(GPIOF, 7, PULL_UP) | (detect_with_pull(GPIOF, 8, PULL_UP) << 1U) | (detect_with_pull(GPIOF, 9, PULL_UP) << 2U) | (detect_with_pull(GPIOF, 10, PULL_UP) << 3U); } void detect_board_type(void) { if(board_id() == 0U){ hw_type = HW_TYPE_RED_PANDA; current_board = &board_red; } else { hw_type = HW_TYPE_UNKNOWN; puts("Hardware type is UNKNOWN!\n"); } } bool has_external_debug_serial = 0; void detect_external_debug_serial(void) { // detect if external serial debugging is present has_external_debug_serial = detect_with_pull(GPIOA, 3, PULL_DOWN); } ================================================ FILE: panda/board/stm32h7/clock.h ================================================ void clock_init(void) { //Set power mode to direct SMPS power supply(depends on the board layout) register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS //Set VOS level to VOS0. (VOS3 to 170Mhz, VOS2 to 300Mhz, VOS1 to 400Mhz, VOS0 to 550Mhz) register_set(&(PWR->D3CR), PWR_D3CR_VOS_1, 0xC000U); //VOS2 while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0); while ((PWR->CSR1 & PWR_CSR1_ACTVOS) != (PWR->D3CR & PWR_D3CR_VOS)); // check that VOS level was actually set // Configure Flash ACR register LATENCY and WRHIGHFREQ (VOS0 range!) register_set(&(FLASH->ACR), FLASH_ACR_LATENCY_2WS | 0x20U, 0x3FU); // VOS2, AXI 100MHz-150MHz // enable external oscillator HSE register_set_bits(&(RCC->CR), RCC_CR_HSEON); while ((RCC->CR & RCC_CR_HSERDY) == 0); // Specify the frequency source for PLL1, divider for DIVM1, divider for DIVM2 : HSE, 5, 5 register_set(&(RCC->PLLCKSELR), RCC_PLLCKSELR_PLLSRC_HSE | RCC_PLLCKSELR_DIVM1_0 | RCC_PLLCKSELR_DIVM1_2 | RCC_PLLCKSELR_DIVM2_0 | RCC_PLLCKSELR_DIVM2_2, 0x3F3F3U); // *** PLL1 start *** // Specify multiplier N and dividers P, Q, R for PLL1 : 48, 1, 5, 2 register_set(&(RCC->PLL1DIVR), 0x104002FU, 0x7F7FFFFFU); // Specify the input and output frequency ranges, enable dividers for PLL1 register_set(&(RCC->PLLCFGR), RCC_PLLCFGR_PLL1RGE_2 | RCC_PLLCFGR_DIVP1EN | RCC_PLLCFGR_DIVQ1EN | RCC_PLLCFGR_DIVR1EN, 0x7000CU); // Enable PLL1 register_set_bits(&(RCC->CR), RCC_CR_PLL1ON); while((RCC->CR & RCC_CR_PLL1RDY) == 0); // *** PLL1 end *** //////////////OTHER CLOCKS//////////////////// // RCC HCLK Clock Source / RCC APB3 Clock Source / RCC SYS Clock Source register_set(&(RCC->D1CFGR), RCC_D1CFGR_HPRE_DIV2 | RCC_D1CFGR_D1PPRE_DIV2 | RCC_D1CFGR_D1CPRE_DIV1, 0xF7FU); // RCC APB1 Clock Source / RCC APB2 Clock Source register_set(&(RCC->D2CFGR), RCC_D2CFGR_D2PPRE1_DIV2 | RCC_D2CFGR_D2PPRE2_DIV2, 0x770U); // RCC APB4 Clock Source register_set(&(RCC->D3CFGR), RCC_D3CFGR_D3PPRE_DIV2, 0x70U); // PLL2P for ADC register_clear_bits(&(RCC->D3CFGR), RCC_D3CCIPR_ADCSEL); // Set SysClock source to PLL register_set(&(RCC->CFGR), RCC_CFGR_SW_PLL1, 0x7U); while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL1); // SYSCFG peripheral clock enable register_set_bits(&(RCC->AHB4ENR), RCC_APB4ENR_SYSCFGEN); //////////////END OTHER CLOCKS//////////////////// // Configure clock source for USB register_set(&(RCC->D2CCIP2R), RCC_D2CCIP2R_USBSEL_0, RCC_D2CCIP2R_USBSEL); //PLL1Q // Configure clock source for FDCAN register_set(&(RCC->D2CCIP1R), RCC_D2CCIP1R_FDCANSEL_0, RCC_D2CCIP1R_FDCANSEL); //PLL1Q // Configure clock source for ADC1,2,3 register_set(&(RCC->D3CCIPR), RCC_D3CCIPR_ADCSEL_1, RCC_D3CCIPR_ADCSEL); //per_ck(currently HSE) //Enable the Clock Security System register_set_bits(&(RCC->CR), RCC_CR_CSSHSEON); //Enable Vdd33usb supply level detector register_set_bits(&(PWR->CR3), PWR_CR3_USB33DEN); } ================================================ FILE: panda/board/stm32h7/inc/cmsis_compiler.h ================================================ /**************************************************************************//** * @file cmsis_compiler.h * @brief CMSIS compiler generic header file * @version V5.1.0 * @date 09. October 2018 ******************************************************************************/ /* * Copyright (c) 2009-2018 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CMSIS_COMPILER_H #define __CMSIS_COMPILER_H #include /* * Arm Compiler 4/5 */ #if defined ( __CC_ARM ) #include "cmsis_armcc.h" /* * Arm Compiler 6.6 LTM (armclang) */ #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) #include "cmsis_armclang_ltm.h" /* * Arm Compiler above 6.10.1 (armclang) */ #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) #include "cmsis_armclang.h" /* * GNU Compiler */ #elif defined ( __GNUC__ ) #include "cmsis_gcc.h" /* * IAR Compiler */ #elif defined ( __ICCARM__ ) #include /* * TI Arm Compiler */ #elif defined ( __TI_ARM__ ) #include #ifndef __ASM #define __ASM __asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __STATIC_INLINE #endif #ifndef __NO_RETURN #define __NO_RETURN __attribute__((noreturn)) #endif #ifndef __USED #define __USED __attribute__((used)) #endif #ifndef __WEAK #define __WEAK __attribute__((weak)) #endif #ifndef __PACKED #define __PACKED __attribute__((packed)) #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT struct __attribute__((packed)) #endif #ifndef __PACKED_UNION #define __PACKED_UNION union __attribute__((packed)) #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ struct __attribute__((packed)) T_UINT32 { uint32_t v; }; #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #define __ALIGNED(x) __attribute__((aligned(x))) #endif #ifndef __RESTRICT #define __RESTRICT __restrict #endif #ifndef __COMPILER_BARRIER #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. #define __COMPILER_BARRIER() (void)0 #endif /* * TASKING Compiler */ #elif defined ( __TASKING__ ) /* * The CMSIS functions have been implemented as intrinsics in the compiler. * Please use "carm -?i" to get an up to date list of all intrinsics, * Including the CMSIS ones. */ #ifndef __ASM #define __ASM __asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __STATIC_INLINE #endif #ifndef __NO_RETURN #define __NO_RETURN __attribute__((noreturn)) #endif #ifndef __USED #define __USED __attribute__((used)) #endif #ifndef __WEAK #define __WEAK __attribute__((weak)) #endif #ifndef __PACKED #define __PACKED __packed__ #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT struct __packed__ #endif #ifndef __PACKED_UNION #define __PACKED_UNION union __packed__ #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ struct __packed__ T_UINT32 { uint32_t v; }; #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #define __ALIGNED(x) __align(x) #endif #ifndef __RESTRICT #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. #define __RESTRICT #endif #ifndef __COMPILER_BARRIER #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. #define __COMPILER_BARRIER() (void)0 #endif /* * COSMIC Compiler */ #elif defined ( __CSMC__ ) #include #ifndef __ASM #define __ASM _asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __STATIC_INLINE #endif #ifndef __NO_RETURN // NO RETURN is automatically detected hence no warning here #define __NO_RETURN #endif #ifndef __USED #warning No compiler specific solution for __USED. __USED is ignored. #define __USED #endif #ifndef __WEAK #define __WEAK __weak #endif #ifndef __PACKED #define __PACKED @packed #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT @packed struct #endif #ifndef __PACKED_UNION #define __PACKED_UNION @packed union #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ @packed struct T_UINT32 { uint32_t v; }; #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. #define __ALIGNED(x) #endif #ifndef __RESTRICT #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. #define __RESTRICT #endif #ifndef __COMPILER_BARRIER #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. #define __COMPILER_BARRIER() (void)0 #endif #else #error Unknown compiler. #endif #endif /* __CMSIS_COMPILER_H */ ================================================ FILE: panda/board/stm32h7/inc/cmsis_gcc.h ================================================ /**************************************************************************//** * @file cmsis_gcc.h * @brief CMSIS compiler GCC header file * @version V5.2.0 * @date 08. May 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CMSIS_GCC_H #define __CMSIS_GCC_H /* ignore some GCC warnings */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wunused-parameter" /* Fallback for __has_builtin */ #ifndef __has_builtin #define __has_builtin(x) (0) #endif /* CMSIS compiler specific defines */ #ifndef __ASM #define __ASM __asm #endif #ifndef __INLINE #define __INLINE inline #endif #ifndef __STATIC_INLINE #define __STATIC_INLINE static inline #endif #ifndef __STATIC_FORCEINLINE #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline #endif #ifndef __NO_RETURN #define __NO_RETURN __attribute__((__noreturn__)) #endif #ifndef __USED #define __USED __attribute__((used)) #endif #ifndef __WEAK #define __WEAK __attribute__((weak)) #endif #ifndef __PACKED #define __PACKED __attribute__((packed, aligned(1))) #endif #ifndef __PACKED_STRUCT #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) #endif #ifndef __PACKED_UNION #define __PACKED_UNION union __attribute__((packed, aligned(1))) #endif #ifndef __UNALIGNED_UINT32 /* deprecated */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" struct __attribute__((packed)) T_UINT32 { uint32_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) #endif #ifndef __UNALIGNED_UINT16_WRITE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT16_READ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) #endif #ifndef __UNALIGNED_UINT32_WRITE #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) #endif #ifndef __UNALIGNED_UINT32_READ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpacked" #pragma GCC diagnostic ignored "-Wattributes" __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; #pragma GCC diagnostic pop #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) #endif #ifndef __ALIGNED #define __ALIGNED(x) __attribute__((aligned(x))) #endif #ifndef __RESTRICT #define __RESTRICT __restrict #endif #ifndef __COMPILER_BARRIER #define __COMPILER_BARRIER() __ASM volatile("":::"memory") #endif /* ######################### Startup and Lowlevel Init ######################## */ #ifndef __PROGRAM_START /** \brief Initializes data and bss sections \details This default implementations initialized all data and additional bss sections relying on .copy.table and .zero.table specified properly in the used linker script. */ __STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) { extern void _start(void) __NO_RETURN; typedef struct { uint32_t const* src; uint32_t* dest; uint32_t wlen; } __copy_table_t; typedef struct { uint32_t* dest; uint32_t wlen; } __zero_table_t; extern const __copy_table_t __copy_table_start__; extern const __copy_table_t __copy_table_end__; extern const __zero_table_t __zero_table_start__; extern const __zero_table_t __zero_table_end__; for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { for(uint32_t i=0u; iwlen; ++i) { pTable->dest[i] = pTable->src[i]; } } for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { for(uint32_t i=0u; iwlen; ++i) { pTable->dest[i] = 0u; } } _start(); } #define __PROGRAM_START __cmsis_start #endif #ifndef __INITIAL_SP #define __INITIAL_SP __StackTop #endif #ifndef __STACK_LIMIT #define __STACK_LIMIT __StackLimit #endif #ifndef __VECTOR_TABLE #define __VECTOR_TABLE __Vectors #endif #ifndef __VECTOR_TABLE_ATTRIBUTE #define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors"))) #endif /* ########################### Core Function Access ########################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions @{ */ /** \brief Enable IRQ Interrupts \details Enables IRQ interrupts by clearing the I-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __enable_irq(void) { __ASM volatile ("cpsie i" : : : "memory"); } /** \brief Disable IRQ Interrupts \details Disables IRQ interrupts by setting the I-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __disable_irq(void) { __ASM volatile ("cpsid i" : : : "memory"); } /** \brief Get Control Register \details Returns the content of the Control Register. \return Control Register value */ __STATIC_FORCEINLINE uint32_t __get_CONTROL(void) { uint32_t result; __ASM volatile ("MRS %0, control" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Control Register (non-secure) \details Returns the content of the non-secure Control Register when in secure mode. \return non-secure Control Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) { uint32_t result; __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Control Register \details Writes the given value to the Control Register. \param [in] control Control Register value to set */ __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) { __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Control Register (non-secure) \details Writes the given value to the non-secure Control Register when in secure state. \param [in] control Control Register value to set */ __STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) { __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); } #endif /** \brief Get IPSR Register \details Returns the content of the IPSR Register. \return IPSR Register value */ __STATIC_FORCEINLINE uint32_t __get_IPSR(void) { uint32_t result; __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); return(result); } /** \brief Get APSR Register \details Returns the content of the APSR Register. \return APSR Register value */ __STATIC_FORCEINLINE uint32_t __get_APSR(void) { uint32_t result; __ASM volatile ("MRS %0, apsr" : "=r" (result) ); return(result); } /** \brief Get xPSR Register \details Returns the content of the xPSR Register. \return xPSR Register value */ __STATIC_FORCEINLINE uint32_t __get_xPSR(void) { uint32_t result; __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); return(result); } /** \brief Get Process Stack Pointer \details Returns the current value of the Process Stack Pointer (PSP). \return PSP Register value */ __STATIC_FORCEINLINE uint32_t __get_PSP(void) { uint32_t result; __ASM volatile ("MRS %0, psp" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Process Stack Pointer (non-secure) \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. \return PSP Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) { uint32_t result; __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Process Stack Pointer \details Assigns the given value to the Process Stack Pointer (PSP). \param [in] topOfProcStack Process Stack Pointer value to set */ __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) { __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Process Stack Pointer (non-secure) \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. \param [in] topOfProcStack Process Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) { __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); } #endif /** \brief Get Main Stack Pointer \details Returns the current value of the Main Stack Pointer (MSP). \return MSP Register value */ __STATIC_FORCEINLINE uint32_t __get_MSP(void) { uint32_t result; __ASM volatile ("MRS %0, msp" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Main Stack Pointer (non-secure) \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. \return MSP Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) { uint32_t result; __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Main Stack Pointer \details Assigns the given value to the Main Stack Pointer (MSP). \param [in] topOfMainStack Main Stack Pointer value to set */ __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) { __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Main Stack Pointer (non-secure) \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. \param [in] topOfMainStack Main Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) { __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); } #endif #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Stack Pointer (non-secure) \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. \return SP Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) { uint32_t result; __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); return(result); } /** \brief Set Stack Pointer (non-secure) \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. \param [in] topOfStack Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) { __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); } #endif /** \brief Get Priority Mask \details Returns the current state of the priority mask bit from the Priority Mask Register. \return Priority Mask value */ __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) { uint32_t result; __ASM volatile ("MRS %0, primask" : "=r" (result) :: "memory"); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Priority Mask (non-secure) \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. \return Priority Mask value */ __STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) { uint32_t result; __ASM volatile ("MRS %0, primask_ns" : "=r" (result) :: "memory"); return(result); } #endif /** \brief Set Priority Mask \details Assigns the given value to the Priority Mask Register. \param [in] priMask Priority Mask */ __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) { __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Priority Mask (non-secure) \details Assigns the given value to the non-secure Priority Mask Register when in secure state. \param [in] priMask Priority Mask */ __STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) { __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); } #endif #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) /** \brief Enable FIQ \details Enables FIQ interrupts by clearing the F-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __enable_fault_irq(void) { __ASM volatile ("cpsie f" : : : "memory"); } /** \brief Disable FIQ \details Disables FIQ interrupts by setting the F-bit in the CPSR. Can only be executed in Privileged modes. */ __STATIC_FORCEINLINE void __disable_fault_irq(void) { __ASM volatile ("cpsid f" : : : "memory"); } /** \brief Get Base Priority \details Returns the current value of the Base Priority register. \return Base Priority register value */ __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) { uint32_t result; __ASM volatile ("MRS %0, basepri" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Base Priority (non-secure) \details Returns the current value of the non-secure Base Priority register when in secure state. \return Base Priority register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) { uint32_t result; __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Base Priority \details Assigns the given value to the Base Priority register. \param [in] basePri Base Priority value to set */ __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) { __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Base Priority (non-secure) \details Assigns the given value to the non-secure Base Priority register when in secure state. \param [in] basePri Base Priority value to set */ __STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) { __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); } #endif /** \brief Set Base Priority with condition \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, or the new value increases the BASEPRI priority level. \param [in] basePri Base Priority value to set */ __STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) { __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); } /** \brief Get Fault Mask \details Returns the current value of the Fault Mask register. \return Fault Mask register value */ __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) { uint32_t result; __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); return(result); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Fault Mask (non-secure) \details Returns the current value of the non-secure Fault Mask register when in secure state. \return Fault Mask register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) { uint32_t result; __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); return(result); } #endif /** \brief Set Fault Mask \details Assigns the given value to the Fault Mask register. \param [in] faultMask Fault Mask value to set */ __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) { __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Fault Mask (non-secure) \details Assigns the given value to the non-secure Fault Mask register when in secure state. \param [in] faultMask Fault Mask value to set */ __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) { __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); } #endif #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief Get Process Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always in non-secure mode. \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). \return PSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure PSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, psplim" : "=r" (result) ); return result; #endif } #if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Process Stack Pointer Limit (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always. \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. \return PSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure PSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); return result; #endif } #endif /** \brief Set Process Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored in non-secure mode. \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set */ __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure PSPLIM is RAZ/WI (void)ProcStackPtrLimit; #else __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); #endif } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Process Stack Pointer (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored. \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set */ __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure PSPLIM is RAZ/WI (void)ProcStackPtrLimit; #else __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); #endif } #endif /** \brief Get Main Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always in non-secure mode. \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). \return MSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure MSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, msplim" : "=r" (result) ); return result; #endif } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Get Main Stack Pointer Limit (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence zero is returned always. \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. \return MSPLIM Register value */ __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure MSPLIM is RAZ/WI return 0U; #else uint32_t result; __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); return result; #endif } #endif /** \brief Set Main Stack Pointer Limit Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored in non-secure mode. \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set */ __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) // without main extensions, the non-secure MSPLIM is RAZ/WI (void)MainStackPtrLimit; #else __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); #endif } #if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) /** \brief Set Main Stack Pointer Limit (non-secure) Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure Stack Pointer Limit register hence the write is silently ignored. \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. \param [in] MainStackPtrLimit Main Stack Pointer value to set */ __STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) { #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) // without main extensions, the non-secure MSPLIM is RAZ/WI (void)MainStackPtrLimit; #else __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); #endif } #endif #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ /** \brief Get FPSCR \details Returns the current value of the Floating Point Status/Control register. \return Floating Point Status/Control register value */ __STATIC_FORCEINLINE uint32_t __get_FPSCR(void) { #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) #if __has_builtin(__builtin_arm_get_fpscr) // Re-enable using built-in when GCC has been fixed // || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ return __builtin_arm_get_fpscr(); #else uint32_t result; __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); return(result); #endif #else return(0U); #endif } /** \brief Set FPSCR \details Assigns the given value to the Floating Point Status/Control register. \param [in] fpscr Floating Point Status/Control value to set */ __STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) { #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) #if __has_builtin(__builtin_arm_set_fpscr) // Re-enable using built-in when GCC has been fixed // || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ __builtin_arm_set_fpscr(fpscr); #else __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); #endif #else (void)fpscr; #endif } /*@} end of CMSIS_Core_RegAccFunctions */ /* ########################## Core Instruction Access ######################### */ /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface Access to dedicated instructions @{ */ /* Define macros for porting to both thumb1 and thumb2. * For thumb1, use low register (r0-r7), specified by constraint "l" * Otherwise, use general registers, specified by constraint "r" */ #if defined (__thumb__) && !defined (__thumb2__) #define __CMSIS_GCC_OUT_REG(r) "=l" (r) #define __CMSIS_GCC_RW_REG(r) "+l" (r) #define __CMSIS_GCC_USE_REG(r) "l" (r) #else #define __CMSIS_GCC_OUT_REG(r) "=r" (r) #define __CMSIS_GCC_RW_REG(r) "+r" (r) #define __CMSIS_GCC_USE_REG(r) "r" (r) #endif /** \brief No Operation \details No Operation does nothing. This instruction can be used for code alignment purposes. */ #define __NOP() __ASM volatile ("nop") /** \brief Wait For Interrupt \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. */ #define __WFI() __ASM volatile ("wfi") /** \brief Wait For Event \details Wait For Event is a hint instruction that permits the processor to enter a low-power state until one of a number of events occurs. */ #define __WFE() __ASM volatile ("wfe") /** \brief Send Event \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. */ #define __SEV() __ASM volatile ("sev") /** \brief Instruction Synchronization Barrier \details Instruction Synchronization Barrier flushes the pipeline in the processor, so that all instructions following the ISB are fetched from cache or memory, after the instruction has been completed. */ __STATIC_FORCEINLINE void __ISB(void) { __ASM volatile ("isb 0xF":::"memory"); } /** \brief Data Synchronization Barrier \details Acts as a special kind of Data Memory Barrier. It completes when all explicit memory accesses before this instruction complete. */ __STATIC_FORCEINLINE void __DSB(void) { __ASM volatile ("dsb 0xF":::"memory"); } /** \brief Data Memory Barrier \details Ensures the apparent order of the explicit memory operations before and after the instruction, without ensuring their completion. */ __STATIC_FORCEINLINE void __DMB(void) { __ASM volatile ("dmb 0xF":::"memory"); } /** \brief Reverse byte order (32 bit) \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE uint32_t __REV(uint32_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) return __builtin_bswap32(value); #else uint32_t result; __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return result; #endif } /** \brief Reverse byte order (16 bit) \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) { uint32_t result; __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return result; } /** \brief Reverse byte order (16 bit) \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE int16_t __REVSH(int16_t value) { #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) return (int16_t)__builtin_bswap16(value); #else int16_t result; __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return result; #endif } /** \brief Rotate Right in unsigned value (32 bit) \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. \param [in] op1 Value to rotate \param [in] op2 Number of Bits to rotate \return Rotated value */ __STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) { op2 %= 32U; if (op2 == 0U) { return op1; } return (op1 >> op2) | (op1 << (32U - op2)); } /** \brief Breakpoint \details Causes the processor to enter Debug state. Debug tools can use this to investigate system state when the instruction at a particular address is reached. \param [in] value is ignored by the processor. If required, a debugger can use it to store additional information about the breakpoint. */ #define __BKPT(value) __ASM volatile ("bkpt "#value) /** \brief Reverse bit order of value \details Reverses the bit order of the given value. \param [in] value Value to reverse \return Reversed value */ __STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) { uint32_t result; #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); #else uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ result = value; /* r will be reversed bits of v; first get LSB of v */ for (value >>= 1U; value != 0U; value >>= 1U) { result <<= 1U; result |= value & 1U; s--; } result <<= s; /* shift when v's highest bits are zero */ #endif return result; } /** \brief Count leading zeros \details Counts the number of leading zeros of a data value. \param [in] value Value to count the leading zeros \return number of leading zeros in value */ __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) { /* Even though __builtin_clz produces a CLZ instruction on ARM, formally __builtin_clz(0) is undefined behaviour, so handle this case specially. This guarantees ARM-compatible results if happening to compile on a non-ARM target, and ensures the compiler doesn't decide to activate any optimisations using the logic "value was passed to __builtin_clz, so it is non-zero". ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a single CLZ instruction. */ if (value == 0U) { return 32U; } return __builtin_clz(value); } #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief LDR Exclusive (8 bit) \details Executes a exclusive LDR instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } /** \brief LDR Exclusive (16 bit) \details Executes a exclusive LDR instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } /** \brief LDR Exclusive (32 bit) \details Executes a exclusive LDR instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) { uint32_t result; __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); return(result); } /** \brief STR Exclusive (8 bit) \details Executes a exclusive STR instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) { uint32_t result; __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); return(result); } /** \brief STR Exclusive (16 bit) \details Executes a exclusive STR instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) { uint32_t result; __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); return(result); } /** \brief STR Exclusive (32 bit) \details Executes a exclusive STR instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) { uint32_t result; __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); return(result); } /** \brief Remove the exclusive lock \details Removes the exclusive lock which is created by LDREX. */ __STATIC_FORCEINLINE void __CLREX(void) { __ASM volatile ("clrex" ::: "memory"); } #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ #if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) /** \brief Signed Saturate \details Saturates a signed value. \param [in] ARG1 Value to be saturated \param [in] ARG2 Bit position to saturate to (1..32) \return Saturated value */ #define __SSAT(ARG1,ARG2) \ __extension__ \ ({ \ int32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) /** \brief Unsigned Saturate \details Saturates an unsigned value. \param [in] ARG1 Value to be saturated \param [in] ARG2 Bit position to saturate to (0..31) \return Saturated value */ #define __USAT(ARG1,ARG2) \ __extension__ \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) /** \brief Rotate Right with Extend (32 bit) \details Moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring. \param [in] value Value to rotate \return Rotated value */ __STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) { uint32_t result; __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); return(result); } /** \brief LDRT Unprivileged (8 bit) \details Executes a Unprivileged LDRT instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); #endif return ((uint8_t) result); /* Add explicit type cast here */ } /** \brief LDRT Unprivileged (16 bit) \details Executes a Unprivileged LDRT instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) { uint32_t result; #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); #else /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not accepted by assembler. So has to use following less efficient pattern. */ __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); #endif return ((uint16_t) result); /* Add explicit type cast here */ } /** \brief LDRT Unprivileged (32 bit) \details Executes a Unprivileged LDRT instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } /** \brief STRT Unprivileged (8 bit) \details Executes a Unprivileged STRT instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) { __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief STRT Unprivileged (16 bit) \details Executes a Unprivileged STRT instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) { __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief STRT Unprivileged (32 bit) \details Executes a Unprivileged STRT instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) { __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); } #else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ /** \brief Signed Saturate \details Saturates a signed value. \param [in] value Value to be saturated \param [in] sat Bit position to saturate to (1..32) \return Saturated value */ __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) { if ((sat >= 1U) && (sat <= 32U)) { const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); const int32_t min = -1 - max ; if (val > max) { return max; } else if (val < min) { return min; } } return val; } /** \brief Unsigned Saturate \details Saturates an unsigned value. \param [in] value Value to be saturated \param [in] sat Bit position to saturate to (0..31) \return Saturated value */ __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) { if (sat <= 31U) { const uint32_t max = ((1U << sat) - 1U); if (val > (int32_t)max) { return max; } else if (val < 0) { return 0U; } } return (uint32_t)val; } #endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) /** \brief Load-Acquire (8 bit) \details Executes a LDAB instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) { uint32_t result; __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint8_t) result); } /** \brief Load-Acquire (16 bit) \details Executes a LDAH instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) { uint32_t result; __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint16_t) result); } /** \brief Load-Acquire (32 bit) \details Executes a LDA instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } /** \brief Store-Release (8 bit) \details Executes a STLB instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) { __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief Store-Release (16 bit) \details Executes a STLH instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) { __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief Store-Release (32 bit) \details Executes a STL instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location */ __STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) { __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); } /** \brief Load-Acquire Exclusive (8 bit) \details Executes a LDAB exclusive instruction for 8 bit value. \param [in] ptr Pointer to data \return value of type uint8_t at (*ptr) */ __STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) { uint32_t result; __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint8_t) result); } /** \brief Load-Acquire Exclusive (16 bit) \details Executes a LDAH exclusive instruction for 16 bit values. \param [in] ptr Pointer to data \return value of type uint16_t at (*ptr) */ __STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) { uint32_t result; __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) ); return ((uint16_t) result); } /** \brief Load-Acquire Exclusive (32 bit) \details Executes a LDA exclusive instruction for 32 bit values. \param [in] ptr Pointer to data \return value of type uint32_t at (*ptr) */ __STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) ); return(result); } /** \brief Store-Release Exclusive (8 bit) \details Executes a STLB exclusive instruction for 8 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) { uint32_t result; __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); return(result); } /** \brief Store-Release Exclusive (16 bit) \details Executes a STLH exclusive instruction for 16 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) { uint32_t result; __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); return(result); } /** \brief Store-Release Exclusive (32 bit) \details Executes a STL exclusive instruction for 32 bit values. \param [in] value Value to store \param [in] ptr Pointer to location \return 0 Function succeeded \return 1 Function failed */ __STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) { uint32_t result; __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) ); return(result); } #endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ /*@}*/ /* end of group CMSIS_Core_InstructionInterface */ /* ################### Compiler specific Intrinsics ########################### */ /** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics Access to dedicated SIMD instructions @{ */ #if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) __STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } #define __SSAT16(ARG1,ARG2) \ ({ \ int32_t __RES, __ARG1 = (ARG1); \ __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) #define __USAT16(ARG1,ARG2) \ ({ \ uint32_t __RES, __ARG1 = (ARG1); \ __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ __RES; \ }) __STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) { uint32_t result; __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); return(result); } __STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) { uint32_t result; __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); return(result); } __STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) { uint32_t result; __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); return(result); } __STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) { union llreg_u{ uint32_t w32[2]; uint64_t w64; } llr; llr.w64 = acc; #ifndef __ARMEB__ /* Little endian */ __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); #else /* Big endian */ __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); #endif return(llr.w64); } __STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) { uint32_t result; __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) { int32_t result; __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } __STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) { int32_t result; __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); return(result); } #if 0 #define __PKHBT(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) #define __PKHTB(ARG1,ARG2,ARG3) \ ({ \ uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ if (ARG3 == 0) \ __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ else \ __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ __RES; \ }) #endif #define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) #define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) { int32_t result; __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); return(result); } #endif /* (__ARM_FEATURE_DSP == 1) */ /*@} end of group CMSIS_SIMD_intrinsics */ #pragma GCC diagnostic pop #endif /* __CMSIS_GCC_H */ ================================================ FILE: panda/board/stm32h7/inc/cmsis_version.h ================================================ /**************************************************************************//** * @file cmsis_version.h * @brief CMSIS Core(M) Version definitions * @version V5.0.3 * @date 24. June 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 ARM Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CMSIS_VERSION_H #define __CMSIS_VERSION_H /* CMSIS Version definitions */ #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ #endif ================================================ FILE: panda/board/stm32h7/inc/core_cm7.h ================================================ /**************************************************************************//** * @file core_cm7.h * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File * @version V5.1.1 * @date 28. March 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef __CORE_CM7_H_GENERIC #define __CORE_CM7_H_GENERIC #include #ifdef __cplusplus extern "C" { #endif /** \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions CMSIS violates the following MISRA-C:2004 rules: \li Required Rule 8.5, object/function definition in header file.
Function definitions in header files are used to allow 'inlining'. \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
Unions are used for effective representation of core registers. \li Advisory Rule 19.7, Function-like macro defined.
Function-like macros are used to allow more efficient code. */ /******************************************************************************* * CMSIS definitions ******************************************************************************/ /** \ingroup Cortex_M7 @{ */ #include "cmsis_version.h" /* CMSIS CM7 definitions */ #define __CM7_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ #define __CM7_CMSIS_VERSION_SUB ( __CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ #define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ __CM7_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ #define __CORTEX_M (7U) /*!< Cortex-M Core */ /** __FPU_USED indicates whether an FPU is used or not. For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. */ #if defined ( __CC_ARM ) #if defined __TARGET_FPU_VFP #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) #if defined __ARM_FP #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __GNUC__ ) #if defined (__VFP_FP__) && !defined(__SOFTFP__) #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __ICCARM__ ) #if defined __ARMVFP__ #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __TI_ARM__ ) #if defined __TI_VFP_SUPPORT__ #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __TASKING__ ) #if defined __FPU_VFP__ #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #elif defined ( __CSMC__ ) #if ( __CSMC__ & 0x400U) #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" #define __FPU_USED 0U #endif #else #define __FPU_USED 0U #endif #endif #include "cmsis_compiler.h" /* CMSIS compiler specific defines */ #ifdef __cplusplus } #endif #endif /* __CORE_CM7_H_GENERIC */ #ifndef __CMSIS_GENERIC #ifndef __CORE_CM7_H_DEPENDANT #define __CORE_CM7_H_DEPENDANT #ifdef __cplusplus extern "C" { #endif /* check device defines and use defaults */ #if defined __CHECK_DEVICE_DEFINES #ifndef __CM7_REV #define __CM7_REV 0x0000U #warning "__CM7_REV not defined in device header file; using default!" #endif #ifndef __FPU_PRESENT #define __FPU_PRESENT 0U #warning "__FPU_PRESENT not defined in device header file; using default!" #endif #ifndef __MPU_PRESENT #define __MPU_PRESENT 0U #warning "__MPU_PRESENT not defined in device header file; using default!" #endif #ifndef __ICACHE_PRESENT #define __ICACHE_PRESENT 0U #warning "__ICACHE_PRESENT not defined in device header file; using default!" #endif #ifndef __DCACHE_PRESENT #define __DCACHE_PRESENT 0U #warning "__DCACHE_PRESENT not defined in device header file; using default!" #endif #ifndef __DTCM_PRESENT #define __DTCM_PRESENT 0U #warning "__DTCM_PRESENT not defined in device header file; using default!" #endif #ifndef __NVIC_PRIO_BITS #define __NVIC_PRIO_BITS 3U #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" #endif #ifndef __Vendor_SysTickConfig #define __Vendor_SysTickConfig 0U #warning "__Vendor_SysTickConfig not defined in device header file; using default!" #endif #endif /* IO definitions (access restrictions to peripheral registers) */ /** \defgroup CMSIS_glob_defs CMSIS Global Defines IO Type Qualifiers are used \li to specify the access to peripheral variables. \li for automatic generation of peripheral register debug information. */ #ifdef __cplusplus #define __I volatile /*!< Defines 'read only' permissions */ #else #define __I volatile const /*!< Defines 'read only' permissions */ #endif #define __O volatile /*!< Defines 'write only' permissions */ #define __IO volatile /*!< Defines 'read / write' permissions */ /* following defines should be used for structure members */ #define __IM volatile const /*! Defines 'read only' structure member permissions */ #define __OM volatile /*! Defines 'write only' structure member permissions */ #define __IOM volatile /*! Defines 'read / write' structure member permissions */ /*@} end of group Cortex_M7 */ /******************************************************************************* * Register Abstraction Core Register contain: - Core Register - Core NVIC Register - Core SCB Register - Core SysTick Register - Core Debug Register - Core MPU Register - Core FPU Register ******************************************************************************/ /** \defgroup CMSIS_core_register Defines and Type Definitions \brief Type definitions and defines for Cortex-M processor based devices. */ /** \ingroup CMSIS_core_register \defgroup CMSIS_CORE Status and Control Registers \brief Core Register type definitions. @{ */ /** \brief Union type to access the Application Program Status Register (APSR). */ typedef union { struct { uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } APSR_Type; /* APSR Register Definitions */ #define APSR_N_Pos 31U /*!< APSR: N Position */ #define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ #define APSR_Z_Pos 30U /*!< APSR: Z Position */ #define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ #define APSR_C_Pos 29U /*!< APSR: C Position */ #define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ #define APSR_V_Pos 28U /*!< APSR: V Position */ #define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ #define APSR_Q_Pos 27U /*!< APSR: Q Position */ #define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ #define APSR_GE_Pos 16U /*!< APSR: GE Position */ #define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ /** \brief Union type to access the Interrupt Program Status Register (IPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } IPSR_Type; /* IPSR Register Definitions */ #define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ #define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ /** \brief Union type to access the Special-Purpose Program Status Registers (xPSR). */ typedef union { struct { uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ uint32_t _reserved0:1; /*!< bit: 9 Reserved */ uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ uint32_t T:1; /*!< bit: 24 Thumb bit */ uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ uint32_t C:1; /*!< bit: 29 Carry condition code flag */ uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ uint32_t N:1; /*!< bit: 31 Negative condition code flag */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } xPSR_Type; /* xPSR Register Definitions */ #define xPSR_N_Pos 31U /*!< xPSR: N Position */ #define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ #define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ #define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ #define xPSR_C_Pos 29U /*!< xPSR: C Position */ #define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ #define xPSR_V_Pos 28U /*!< xPSR: V Position */ #define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ #define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ #define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ #define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ #define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ #define xPSR_T_Pos 24U /*!< xPSR: T Position */ #define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ #define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ #define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ #define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ #define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ #define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ #define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ /** \brief Union type to access the Control Registers (CONTROL). */ typedef union { struct { uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ } b; /*!< Structure used for bit access */ uint32_t w; /*!< Type used for word access */ } CONTROL_Type; /* CONTROL Register Definitions */ #define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ #define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ #define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ #define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ #define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ #define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ /*@} end of group CMSIS_CORE */ /** \ingroup CMSIS_core_register \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) \brief Type definitions for the NVIC Registers @{ */ /** \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). */ typedef struct { __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ uint32_t RESERVED0[24U]; __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ uint32_t RESERVED1[24U]; __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ uint32_t RESERVED2[24U]; __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ uint32_t RESERVED3[24U]; __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ uint32_t RESERVED4[56U]; __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ uint32_t RESERVED5[644U]; __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ } NVIC_Type; /* Software Triggered Interrupt Register Definitions */ #define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ #define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ /*@} end of group CMSIS_NVIC */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCB System Control Block (SCB) \brief Type definitions for the System Control Block Registers @{ */ /** \brief Structure type to access the System Control Block (SCB). */ typedef struct { __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ uint32_t RESERVED0[1U]; __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ uint32_t RESERVED3[93U]; __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ uint32_t RESERVED4[15U]; __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ uint32_t RESERVED5[1U]; __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ uint32_t RESERVED6[1U]; __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ uint32_t RESERVED7[6U]; __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ uint32_t RESERVED8[1U]; __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ } SCB_Type; /* SCB CPUID Register Definitions */ #define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ #define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ #define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ #define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ #define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ #define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ /* SCB Interrupt Control State Register Definitions */ #define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ #define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ #define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ #define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ #define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ #define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ #define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ #define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ #define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ #define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ #define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ #define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ #define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ #define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ #define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ #define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ #define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ #define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ #define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ #define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ /* SCB Vector Table Offset Register Definitions */ #define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ #define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ /* SCB Application Interrupt and Reset Control Register Definitions */ #define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ #define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ #define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ #define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ #define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ #define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ #define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ #define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ #define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ #define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ #define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ #define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ #define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ #define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ /* SCB System Control Register Definitions */ #define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ #define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ #define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ #define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ #define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ #define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ /* SCB Configuration Control Register Definitions */ #define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ #define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ #define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ #define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ #define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ #define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ #define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ #define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ #define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ #define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ #define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ #define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ #define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ #define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ #define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ #define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ #define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ #define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ /* SCB System Handler Control and State Register Definitions */ #define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ #define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ #define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ #define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ #define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ #define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ #define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ #define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ #define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ #define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ #define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ #define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ #define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ #define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ #define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ #define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ #define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ #define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ #define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ #define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ #define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ #define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ #define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ #define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ #define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ #define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ #define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ #define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ /* SCB Configurable Fault Status Register Definitions */ #define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ #define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ #define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ #define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ #define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ #define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ /* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ #define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ #define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ #define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ #define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ #define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ #define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ #define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ #define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ #define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ #define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ #define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ /* BusFault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ #define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ #define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ #define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ #define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ #define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ #define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ #define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ #define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ #define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ #define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ #define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ #define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ #define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ /* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ #define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ #define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ #define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ #define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ #define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ #define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ #define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ #define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ #define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ #define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ #define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ #define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ /* SCB Hard Fault Status Register Definitions */ #define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ #define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ #define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ #define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ #define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ #define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ /* SCB Debug Fault Status Register Definitions */ #define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ #define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ #define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ #define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ #define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ #define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ #define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ #define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ #define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ #define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ /* SCB Cache Level ID Register Definitions */ #define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ #define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ #define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ #define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ /* SCB Cache Type Register Definitions */ #define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ #define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ #define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ #define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ #define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ #define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ #define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ #define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ #define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ #define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ /* SCB Cache Size ID Register Definitions */ #define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ #define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ #define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ #define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ #define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ #define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ #define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ #define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ #define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ #define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ #define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ #define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ #define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ #define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ /* SCB Cache Size Selection Register Definitions */ #define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ #define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ #define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ #define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ /* SCB Software Triggered Interrupt Register Definitions */ #define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ #define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ /* SCB D-Cache Invalidate by Set-way Register Definitions */ #define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ #define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ #define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ #define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ /* SCB D-Cache Clean by Set-way Register Definitions */ #define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ #define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ #define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ #define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ /* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ #define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ #define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ #define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ #define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ /* Instruction Tightly-Coupled Memory Control Register Definitions */ #define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ #define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ #define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ #define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ #define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ #define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ #define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ #define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ /* Data Tightly-Coupled Memory Control Register Definitions */ #define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ #define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ #define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ #define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ #define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ #define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ #define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ #define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ /* AHBP Control Register Definitions */ #define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ #define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ #define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ #define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ /* L1 Cache Control Register Definitions */ #define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ #define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ #define SCB_CACR_ECCEN_Pos 1U /*!< SCB CACR: ECCEN Position */ #define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< SCB CACR: ECCEN Mask */ #define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ #define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ /* AHBS Control Register Definitions */ #define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ #define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBPCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ #define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ #define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBPCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ #define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ #define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBPCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ /* Auxiliary Bus Fault Status Register Definitions */ #define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ #define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ #define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ #define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ #define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ #define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ #define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ #define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ #define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ #define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ #define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ #define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ /*@} end of group CMSIS_SCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) \brief Type definitions for the System Control and ID Register not in the SCB @{ */ /** \brief Structure type to access the System Control and ID Register not in the SCB. */ typedef struct { uint32_t RESERVED0[1U]; __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ } SCnSCB_Type; /* Interrupt Controller Type Register Definitions */ #define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ #define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ /* Auxiliary Control Register Definitions */ #define SCnSCB_ACTLR_DISDYNADD_Pos 26U /*!< ACTLR: DISDYNADD Position */ #define SCnSCB_ACTLR_DISDYNADD_Msk (1UL << SCnSCB_ACTLR_DISDYNADD_Pos) /*!< ACTLR: DISDYNADD Mask */ #define SCnSCB_ACTLR_DISISSCH1_Pos 21U /*!< ACTLR: DISISSCH1 Position */ #define SCnSCB_ACTLR_DISISSCH1_Msk (0x1FUL << SCnSCB_ACTLR_DISISSCH1_Pos) /*!< ACTLR: DISISSCH1 Mask */ #define SCnSCB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ #define SCnSCB_ACTLR_DISDI_Msk (0x1FUL << SCnSCB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ #define SCnSCB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ #define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (1UL << SCnSCB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ #define SCnSCB_ACTLR_DISBTACALLOC_Pos 14U /*!< ACTLR: DISBTACALLOC Position */ #define SCnSCB_ACTLR_DISBTACALLOC_Msk (1UL << SCnSCB_ACTLR_DISBTACALLOC_Pos) /*!< ACTLR: DISBTACALLOC Mask */ #define SCnSCB_ACTLR_DISBTACREAD_Pos 13U /*!< ACTLR: DISBTACREAD Position */ #define SCnSCB_ACTLR_DISBTACREAD_Msk (1UL << SCnSCB_ACTLR_DISBTACREAD_Pos) /*!< ACTLR: DISBTACREAD Mask */ #define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ #define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ #define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ #define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ #define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ #define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ #define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ #define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ #define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ #define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ /*@} end of group CMSIS_SCnotSCB */ /** \ingroup CMSIS_core_register \defgroup CMSIS_SysTick System Tick Timer (SysTick) \brief Type definitions for the System Timer Registers. @{ */ /** \brief Structure type to access the System Timer (SysTick). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ } SysTick_Type; /* SysTick Control / Status Register Definitions */ #define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ #define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ #define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ #define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ #define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ #define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ #define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ #define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ /* SysTick Reload Register Definitions */ #define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ #define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ /* SysTick Current Register Definitions */ #define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ #define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ /* SysTick Calibration Register Definitions */ #define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ #define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ #define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ #define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ #define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ #define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ /*@} end of group CMSIS_SysTick */ /** \ingroup CMSIS_core_register \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) \brief Type definitions for the Instrumentation Trace Macrocell (ITM) @{ */ /** \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). */ typedef struct { __OM union { __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ uint32_t RESERVED0[864U]; __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ uint32_t RESERVED1[15U]; __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ uint32_t RESERVED2[15U]; __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ uint32_t RESERVED3[32U]; uint32_t RESERVED4[43U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ uint32_t RESERVED5[6U]; __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ } ITM_Type; /* ITM Trace Privilege Register Definitions */ #define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ #define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ /* ITM Trace Control Register Definitions */ #define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ #define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ #define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ #define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ #define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ #define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ #define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ #define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ #define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ #define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ #define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ #define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ #define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ #define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ #define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ #define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ #define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ #define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ /* ITM Lock Status Register Definitions */ #define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ #define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ #define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ #define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ #define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ #define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ /*@}*/ /* end of group CMSIS_ITM */ /** \ingroup CMSIS_core_register \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) \brief Type definitions for the Data Watchpoint and Trace (DWT) @{ */ /** \brief Structure type to access the Data Watchpoint and Trace Register (DWT). */ typedef struct { __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ uint32_t RESERVED0[1U]; __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ uint32_t RESERVED1[1U]; __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ uint32_t RESERVED2[1U]; __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ uint32_t RESERVED3[981U]; __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ } DWT_Type; /* DWT Control Register Definitions */ #define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ #define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ #define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ #define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ #define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ #define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ #define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ #define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ #define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ #define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ #define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ #define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ #define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ #define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ #define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ #define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ #define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ #define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ #define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ #define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ #define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ #define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ #define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ #define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ #define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ #define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ #define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ #define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ #define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ #define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ #define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ #define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ #define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ #define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ #define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ #define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ /* DWT CPI Count Register Definitions */ #define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ #define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ /* DWT Exception Overhead Count Register Definitions */ #define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ #define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ /* DWT Sleep Count Register Definitions */ #define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ #define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ /* DWT LSU Count Register Definitions */ #define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ #define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ /* DWT Folded-instruction Count Register Definitions */ #define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ #define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ /* DWT Comparator Mask Register Definitions */ #define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ #define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ /* DWT Comparator Function Register Definitions */ #define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ #define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ #define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ #define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ #define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ #define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ #define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ #define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ #define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ #define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ #define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ #define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ #define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ #define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ #define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ #define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ #define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ #define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ /*@}*/ /* end of group CMSIS_DWT */ /** \ingroup CMSIS_core_register \defgroup CMSIS_TPI Trace Port Interface (TPI) \brief Type definitions for the Trace Port Interface (TPI) @{ */ /** \brief Structure type to access the Trace Port Interface Register (TPI). */ typedef struct { __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ uint32_t RESERVED0[2U]; __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ uint32_t RESERVED1[55U]; __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ uint32_t RESERVED2[131U]; __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ uint32_t RESERVED3[759U]; __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ uint32_t RESERVED4[1U]; __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ uint32_t RESERVED5[39U]; __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ uint32_t RESERVED7[8U]; __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ } TPI_Type; /* TPI Asynchronous Clock Prescaler Register Definitions */ #define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ #define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ /* TPI Selected Pin Protocol Register Definitions */ #define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ #define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ /* TPI Formatter and Flush Status Register Definitions */ #define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ #define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ #define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ #define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ #define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ #define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ #define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ #define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ /* TPI Formatter and Flush Control Register Definitions */ #define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ #define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ #define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ #define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ /* TPI TRIGGER Register Definitions */ #define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ #define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ /* TPI Integration ETM Data Register Definitions (FIFO0) */ #define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ #define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ #define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ #define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ #define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ #define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ #define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ #define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ #define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ #define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ #define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ #define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ #define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ #define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ /* TPI ITATBCTR2 Register Definitions */ #define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ #define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ #define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ #define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ /* TPI Integration ITM Data Register Definitions (FIFO1) */ #define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ #define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ #define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ #define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ #define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ #define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ #define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ #define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ #define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ #define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ #define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ #define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ #define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ #define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ /* TPI ITATBCTR0 Register Definitions */ #define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ #define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ #define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ #define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ /* TPI Integration Mode Control Register Definitions */ #define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ #define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ /* TPI DEVID Register Definitions */ #define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ #define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ #define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ #define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ #define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ #define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ #define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ #define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ #define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ #define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ #define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ #define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ /* TPI DEVTYPE Register Definitions */ #define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ #define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ #define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ #define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ /*@}*/ /* end of group CMSIS_TPI */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) /** \ingroup CMSIS_core_register \defgroup CMSIS_MPU Memory Protection Unit (MPU) \brief Type definitions for the Memory Protection Unit (MPU) @{ */ /** \brief Structure type to access the Memory Protection Unit (MPU). */ typedef struct { __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ } MPU_Type; #define MPU_TYPE_RALIASES 4U /* MPU Type Register Definitions */ #define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ #define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ #define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ #define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ #define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ #define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ /* MPU Control Register Definitions */ #define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ #define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ #define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ #define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ #define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ #define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ /* MPU Region Number Register Definitions */ #define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ #define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ /* MPU Region Base Address Register Definitions */ #define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ #define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ #define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ #define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ #define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ #define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ /* MPU Region Attribute and Size Register Definitions */ #define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ #define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ #define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ #define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ #define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ #define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ #define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ #define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ #define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ #define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ #define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ #define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ #define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ #define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ #define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ #define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ #define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ #define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ #define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ #define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ /*@} end of group CMSIS_MPU */ #endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ /** \ingroup CMSIS_core_register \defgroup CMSIS_FPU Floating Point Unit (FPU) \brief Type definitions for the Floating Point Unit (FPU) @{ */ /** \brief Structure type to access the Floating Point Unit (FPU). */ typedef struct { uint32_t RESERVED0[1U]; __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ } FPU_Type; /* Floating-Point Context Control Register Definitions */ #define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ #define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ #define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ #define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ #define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ #define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ #define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ #define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ #define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ #define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ #define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ #define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ #define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ #define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ #define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ #define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ #define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ #define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ /* Floating-Point Context Address Register Definitions */ #define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ #define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ /* Floating-Point Default Status Control Register Definitions */ #define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ #define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ #define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ #define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ #define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ #define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ #define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ #define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ /* Media and FP Feature Register 0 Definitions */ #define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ #define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ #define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ #define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ #define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ #define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ #define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ #define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ #define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ #define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ #define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ #define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ #define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ #define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ #define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ #define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ /* Media and FP Feature Register 1 Definitions */ #define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ #define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ #define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ #define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ #define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ #define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ #define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ #define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ /* Media and FP Feature Register 2 Definitions */ #define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ #define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ /*@} end of group CMSIS_FPU */ /** \ingroup CMSIS_core_register \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) \brief Type definitions for the Core Debug Registers @{ */ /** \brief Structure type to access the Core Debug Register (CoreDebug). */ typedef struct { __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ } CoreDebug_Type; /* Debug Halting Control and Status Register Definitions */ #define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ #define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ #define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ #define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ #define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ #define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ #define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ #define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ #define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ #define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ #define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ #define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ #define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ #define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ #define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ #define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ #define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ #define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ #define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ #define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ #define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ #define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ #define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ #define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ /* Debug Core Register Selector Register Definitions */ #define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ #define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ #define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ #define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ /* Debug Exception and Monitor Control Register Definitions */ #define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ #define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ #define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ #define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ #define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ #define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ #define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ #define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ #define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ #define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ #define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ #define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ #define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ #define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ #define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ #define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ #define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ #define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ #define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ #define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ #define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ #define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ #define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ #define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ #define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ /*@} end of group CMSIS_CoreDebug */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_bitfield Core register bit field macros \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). @{ */ /** \brief Mask and shift a bit field value for use in a register bit range. \param[in] field Name of the register bit field. \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. \return Masked and shifted value. */ #define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) /** \brief Mask and shift a register value to extract a bit filed value. \param[in] field Name of the register bit field. \param[in] value Value of register. This parameter is interpreted as an uint32_t type. \return Masked and shifted bit field value. */ #define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) /*@} end of group CMSIS_core_bitfield */ /** \ingroup CMSIS_core_register \defgroup CMSIS_core_base Core Definitions \brief Definitions for base addresses, unions, and structures. @{ */ /* Memory mapping of Core Hardware */ #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ #define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ #endif #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ /*@} */ /******************************************************************************* * Hardware Abstraction Layer Core Function Interface contains: - Core NVIC Functions - Core SysTick Functions - Core Debug Functions - Core Register Access Functions ******************************************************************************/ /** \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference */ /* ########################## NVIC functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_NVICFunctions NVIC Functions \brief Functions that manage interrupts and exceptions via the NVIC. @{ */ #ifdef CMSIS_NVIC_VIRTUAL #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" #endif #include CMSIS_NVIC_VIRTUAL_HEADER_FILE #else #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping #define NVIC_EnableIRQ __NVIC_EnableIRQ #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ #define NVIC_DisableIRQ __NVIC_DisableIRQ #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ #define NVIC_GetActive __NVIC_GetActive #define NVIC_SetPriority __NVIC_SetPriority #define NVIC_GetPriority __NVIC_GetPriority #define NVIC_SystemReset __NVIC_SystemReset #endif /* CMSIS_NVIC_VIRTUAL */ #ifdef CMSIS_VECTAB_VIRTUAL #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" #endif #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE #else #define NVIC_SetVector __NVIC_SetVector #define NVIC_GetVector __NVIC_GetVector #endif /* (CMSIS_VECTAB_VIRTUAL) */ #define NVIC_USER_IRQ_OFFSET 16 /* The following EXC_RETURN values are saved the LR on exception entry */ #define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ #define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ #define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ #define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ #define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ #define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ /** \brief Set Priority Grouping \details Sets the priority grouping field using the required unlock sequence. The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Priority grouping field. */ __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) { uint32_t reg_value; uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ reg_value = SCB->AIRCR; /* read old register configuration */ reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ reg_value = (reg_value | ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ SCB->AIRCR = reg_value; } /** \brief Get Priority Grouping \details Reads the priority grouping field from the NVIC Interrupt Controller. \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). */ __STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) { return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); } /** \brief Enable Interrupt \details Enables a device specific interrupt in the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { __COMPILER_BARRIER(); NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); __COMPILER_BARRIER(); } } /** \brief Get Interrupt Enable status \details Returns a device specific interrupt enable status from the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt is not enabled. \return 1 Interrupt is enabled. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Disable Interrupt \details Disables a device specific interrupt in the NVIC interrupt controller. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); __DSB(); __ISB(); } } /** \brief Get Pending Interrupt \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not pending. \return 1 Interrupt status is pending. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Set Pending Interrupt \details Sets the pending bit of a device specific interrupt in the NVIC pending register. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); } } /** \brief Clear Pending Interrupt \details Clears the pending bit of a device specific interrupt in the NVIC pending register. \param [in] IRQn Device specific interrupt number. \note IRQn must not be negative. */ __STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); } } /** \brief Get Active Interrupt \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. \param [in] IRQn Device specific interrupt number. \return 0 Interrupt status is not active. \return 1 Interrupt status is active. \note IRQn must not be negative. */ __STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); } else { return(0U); } } /** \brief Set Interrupt Priority \details Sets the priority of a device specific interrupt or a processor exception. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \param [in] priority Priority to set. \note The priority cannot be set for every processor exception. */ __STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) { if ((int32_t)(IRQn) >= 0) { NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } else { SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); } } /** \brief Get Interrupt Priority \details Reads the priority of a device specific interrupt or a processor exception. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. */ __STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) { if ((int32_t)(IRQn) >= 0) { return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); } else { return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); } } /** \brief Encode Priority \details Encodes the priority for an interrupt with the given priority group, preemptive priority value, and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. \param [in] PriorityGroup Used priority group. \param [in] PreemptPriority Preemptive priority value (starting from 0). \param [in] SubPriority Subpriority value (starting from 0). \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). */ __STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); return ( ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) ); } /** \brief Decode Priority \details Decodes an interrupt priority value with a given priority group to preemptive priority value and subpriority value. In case of a conflict between priority grouping and available priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). \param [in] PriorityGroup Used priority group. \param [out] pPreemptPriority Preemptive priority value (starting from 0). \param [out] pSubPriority Subpriority value (starting from 0). */ __STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) { uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ uint32_t PreemptPriorityBits; uint32_t SubPriorityBits; PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); } /** \brief Set Interrupt Vector \details Sets an interrupt vector in SRAM based interrupt vector table. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. VTOR must been relocated to SRAM before. \param [in] IRQn Interrupt number \param [in] vector Address of interrupt handler function */ __STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) { uint32_t vectors = (uint32_t )SCB->VTOR; (* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector; __DSB(); } /** \brief Get Interrupt Vector \details Reads an interrupt vector from interrupt vector table. The interrupt number can be positive to specify a device specific interrupt, or negative to specify a processor exception. \param [in] IRQn Interrupt number. \return Address of interrupt handler function */ __STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) { uint32_t vectors = (uint32_t )SCB->VTOR; return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)); } /** \brief System Reset \details Initiates a system reset request to reset the MCU. */ __NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) { __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ __DSB(); /* Ensure completion of memory access */ for(;;) /* wait until reset */ { __NOP(); } } /*@} end of CMSIS_Core_NVICFunctions */ /* ########################## MPU functions #################################### */ #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) #include "mpu_armv7.h" #endif /* ########################## FPU functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_FpuFunctions FPU Functions \brief Function that provides FPU type. @{ */ /** \brief get FPU type \details returns the FPU type \returns - \b 0: No FPU - \b 1: Single precision FPU - \b 2: Double + Single precision FPU */ __STATIC_INLINE uint32_t SCB_GetFPUType(void) { uint32_t mvfr0; mvfr0 = SCB->MVFR0; if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) { return 2U; /* Double + Single precision FPU */ } else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) { return 1U; /* Single precision FPU */ } else { return 0U; /* No FPU */ } } /*@} end of CMSIS_Core_FpuFunctions */ /* ########################## Cache functions #################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_CacheFunctions Cache Functions \brief Functions that configure Instruction and Data cache. @{ */ /* Cache Size ID Register Macros */ #define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) #define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) #define __SCB_DCACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ #define __SCB_ICACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ /** \brief Enable I-Cache \details Turns on I-Cache */ __STATIC_FORCEINLINE void SCB_EnableICache (void) { #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ __DSB(); __ISB(); SCB->ICIALLU = 0UL; /* invalidate I-Cache */ __DSB(); __ISB(); SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ __DSB(); __ISB(); #endif } /** \brief Disable I-Cache \details Turns off I-Cache */ __STATIC_FORCEINLINE void SCB_DisableICache (void) { #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) __DSB(); __ISB(); SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ SCB->ICIALLU = 0UL; /* invalidate I-Cache */ __DSB(); __ISB(); #endif } /** \brief Invalidate I-Cache \details Invalidates I-Cache */ __STATIC_FORCEINLINE void SCB_InvalidateICache (void) { #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) __DSB(); __ISB(); SCB->ICIALLU = 0UL; __DSB(); __ISB(); #endif } /** \brief I-Cache Invalidate by address \details Invalidates I-Cache for the given address. I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. I-Cache memory blocks which are part of given address + given size are invalidated. \param[in] addr address \param[in] isize size of memory block (in number of bytes) */ __STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (void *addr, int32_t isize) { #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) if ( isize > 0 ) { int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; __DSB(); do { SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ op_addr += __SCB_ICACHE_LINE_SIZE; op_size -= __SCB_ICACHE_LINE_SIZE; } while ( op_size > 0 ); __DSB(); __ISB(); } #endif } /** \brief Enable D-Cache \details Turns on D-Cache */ __STATIC_FORCEINLINE void SCB_EnableDCache (void) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) uint32_t ccsidr; uint32_t sets; uint32_t ways; if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ SCB->CSSELR = 0U; /* select Level 1 data cache */ __DSB(); ccsidr = SCB->CCSIDR; /* invalidate D-Cache */ sets = (uint32_t)(CCSIDR_SETS(ccsidr)); do { ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); do { SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); #if defined ( __CC_ARM ) __schedule_barrier(); #endif } while (ways-- != 0U); } while(sets-- != 0U); __DSB(); SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ __DSB(); __ISB(); #endif } /** \brief Disable D-Cache \details Turns off D-Cache */ __STATIC_FORCEINLINE void SCB_DisableDCache (void) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) uint32_t ccsidr; uint32_t sets; uint32_t ways; SCB->CSSELR = 0U; /* select Level 1 data cache */ __DSB(); SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ __DSB(); ccsidr = SCB->CCSIDR; /* clean & invalidate D-Cache */ sets = (uint32_t)(CCSIDR_SETS(ccsidr)); do { ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); do { SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); #if defined ( __CC_ARM ) __schedule_barrier(); #endif } while (ways-- != 0U); } while(sets-- != 0U); __DSB(); __ISB(); #endif } /** \brief Invalidate D-Cache \details Invalidates D-Cache */ __STATIC_FORCEINLINE void SCB_InvalidateDCache (void) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) uint32_t ccsidr; uint32_t sets; uint32_t ways; SCB->CSSELR = 0U; /* select Level 1 data cache */ __DSB(); ccsidr = SCB->CCSIDR; /* invalidate D-Cache */ sets = (uint32_t)(CCSIDR_SETS(ccsidr)); do { ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); do { SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); #if defined ( __CC_ARM ) __schedule_barrier(); #endif } while (ways-- != 0U); } while(sets-- != 0U); __DSB(); __ISB(); #endif } /** \brief Clean D-Cache \details Cleans D-Cache */ __STATIC_FORCEINLINE void SCB_CleanDCache (void) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) uint32_t ccsidr; uint32_t sets; uint32_t ways; SCB->CSSELR = 0U; /* select Level 1 data cache */ __DSB(); ccsidr = SCB->CCSIDR; /* clean D-Cache */ sets = (uint32_t)(CCSIDR_SETS(ccsidr)); do { ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); do { SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); #if defined ( __CC_ARM ) __schedule_barrier(); #endif } while (ways-- != 0U); } while(sets-- != 0U); __DSB(); __ISB(); #endif } /** \brief Clean & Invalidate D-Cache \details Cleans and Invalidates D-Cache */ __STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) uint32_t ccsidr; uint32_t sets; uint32_t ways; SCB->CSSELR = 0U; /* select Level 1 data cache */ __DSB(); ccsidr = SCB->CCSIDR; /* clean & invalidate D-Cache */ sets = (uint32_t)(CCSIDR_SETS(ccsidr)); do { ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); do { SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); #if defined ( __CC_ARM ) __schedule_barrier(); #endif } while (ways-- != 0U); } while(sets-- != 0U); __DSB(); __ISB(); #endif } /** \brief D-Cache Invalidate by address \details Invalidates D-Cache for the given address. D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. D-Cache memory blocks which are part of given address + given size are invalidated. \param[in] addr address \param[in] dsize size of memory block (in number of bytes) */ __STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (void *addr, int32_t dsize) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) if ( dsize > 0 ) { int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; __DSB(); do { SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ op_addr += __SCB_DCACHE_LINE_SIZE; op_size -= __SCB_DCACHE_LINE_SIZE; } while ( op_size > 0 ); __DSB(); __ISB(); } #endif } /** \brief D-Cache Clean by address \details Cleans D-Cache for the given address D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. D-Cache memory blocks which are part of given address + given size are cleaned. \param[in] addr address \param[in] dsize size of memory block (in number of bytes) */ __STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) if ( dsize > 0 ) { int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; __DSB(); do { SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ op_addr += __SCB_DCACHE_LINE_SIZE; op_size -= __SCB_DCACHE_LINE_SIZE; } while ( op_size > 0 ); __DSB(); __ISB(); } #endif } /** \brief D-Cache Clean and Invalidate by address \details Cleans and invalidates D_Cache for the given address D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. \param[in] addr address (aligned to 32-byte boundary) \param[in] dsize size of memory block (in number of bytes) */ __STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) { #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) if ( dsize > 0 ) { int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; __DSB(); do { SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ op_addr += __SCB_DCACHE_LINE_SIZE; op_size -= __SCB_DCACHE_LINE_SIZE; } while ( op_size > 0 ); __DSB(); __ISB(); } #endif } /*@} end of CMSIS_Core_CacheFunctions */ /* ################################## SysTick function ############################################ */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_Core_SysTickFunctions SysTick Functions \brief Functions that configure the System. @{ */ #if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) /** \brief System Tick Configuration \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. Counter is in free running mode to generate periodic interrupts. \param [in] ticks Number of ticks between two interrupts. \return 0 Function succeeded. \return 1 Function failed. \note When the variable __Vendor_SysTickConfig is set to 1, then the function SysTick_Config is not included. In this case, the file device.h must contain a vendor-specific implementation of this function. */ __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) { if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) { return (1UL); /* Reload value impossible */ } SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ return (0UL); /* Function successful */ } #endif /*@} end of CMSIS_Core_SysTickFunctions */ /* ##################################### Debug In/Output function ########################################### */ /** \ingroup CMSIS_Core_FunctionInterface \defgroup CMSIS_core_DebugFunctions ITM Functions \brief Functions that access the ITM debug interface. @{ */ extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ #define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ /** \brief ITM Send Character \details Transmits a character via the ITM channel 0, and \li Just returns when no debugger is connected that has booked the output. \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. \param [in] ch Character to transmit. \returns Character to transmit. */ __STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) { if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ { while (ITM->PORT[0U].u32 == 0UL) { __NOP(); } ITM->PORT[0U].u8 = (uint8_t)ch; } return (ch); } /** \brief ITM Receive Character \details Inputs a character via the external variable \ref ITM_RxBuffer. \return Received character. \return -1 No character pending. */ __STATIC_INLINE int32_t ITM_ReceiveChar (void) { int32_t ch = -1; /* no character available */ if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) { ch = ITM_RxBuffer; ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ } return (ch); } /** \brief ITM Check Character \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. \return 0 No character available. \return 1 Character available. */ __STATIC_INLINE int32_t ITM_CheckChar (void) { if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) { return (0); /* no character available */ } else { return (1); /* character available */ } } /*@} end of CMSIS_core_DebugFunctions */ #ifdef __cplusplus } #endif #endif /* __CORE_CM7_H_DEPENDANT */ #endif /* __CMSIS_GENERIC */ ================================================ FILE: panda/board/stm32h7/inc/mpu_armv8.h ================================================ /****************************************************************************** * @file mpu_armv8.h * @brief CMSIS MPU API for Armv8-M and Armv8.1-M MPU * @version V5.1.0 * @date 08. March 2019 ******************************************************************************/ /* * Copyright (c) 2017-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the License); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #if defined ( __ICCARM__ ) #pragma system_include /* treat file as system include file for MISRA check */ #elif defined (__clang__) #pragma clang system_header /* treat file as system include file */ #endif #ifndef ARM_MPU_ARMV8_H #define ARM_MPU_ARMV8_H /** \brief Attribute for device memory (outer only) */ #define ARM_MPU_ATTR_DEVICE ( 0U ) /** \brief Attribute for non-cacheable, normal memory */ #define ARM_MPU_ATTR_NON_CACHEABLE ( 4U ) /** \brief Attribute for normal memory (outer and inner) * \param NT Non-Transient: Set to 1 for non-transient data. * \param WB Write-Back: Set to 1 to use write-back update policy. * \param RA Read Allocation: Set to 1 to use cache allocation on read miss. * \param WA Write Allocation: Set to 1 to use cache allocation on write miss. */ #define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \ (((NT & 1U) << 3U) | ((WB & 1U) << 2U) | ((RA & 1U) << 1U) | (WA & 1U)) /** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */ #define ARM_MPU_ATTR_DEVICE_nGnRnE (0U) /** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */ #define ARM_MPU_ATTR_DEVICE_nGnRE (1U) /** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */ #define ARM_MPU_ATTR_DEVICE_nGRE (2U) /** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */ #define ARM_MPU_ATTR_DEVICE_GRE (3U) /** \brief Memory Attribute * \param O Outer memory attributes * \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes */ #define ARM_MPU_ATTR(O, I) (((O & 0xFU) << 4U) | (((O & 0xFU) != 0U) ? (I & 0xFU) : ((I & 0x3U) << 2U))) /** \brief Normal memory non-shareable */ #define ARM_MPU_SH_NON (0U) /** \brief Normal memory outer shareable */ #define ARM_MPU_SH_OUTER (2U) /** \brief Normal memory inner shareable */ #define ARM_MPU_SH_INNER (3U) /** \brief Memory access permissions * \param RO Read-Only: Set to 1 for read-only memory. * \param NP Non-Privileged: Set to 1 for non-privileged memory. */ #define ARM_MPU_AP_(RO, NP) (((RO & 1U) << 1U) | (NP & 1U)) /** \brief Region Base Address Register value * \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned. * \param SH Defines the Shareability domain for this memory region. * \param RO Read-Only: Set to 1 for a read-only memory region. * \param NP Non-Privileged: Set to 1 for a non-privileged memory region. * \oaram XN eXecute Never: Set to 1 for a non-executable memory region. */ #define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ ((BASE & MPU_RBAR_BASE_Msk) | \ ((SH << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \ ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \ ((XN << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk)) /** \brief Region Limit Address Register value * \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. * \param IDX The attribute index to be associated with this memory region. */ #define ARM_MPU_RLAR(LIMIT, IDX) \ ((LIMIT & MPU_RLAR_LIMIT_Msk) | \ ((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ (MPU_RLAR_EN_Msk)) #if defined(MPU_RLAR_PXN_Pos) /** \brief Region Limit Address Register with PXN value * \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. * \param PXN Privileged execute never. Defines whether code can be executed from this privileged region. * \param IDX The attribute index to be associated with this memory region. */ #define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \ ((LIMIT & MPU_RLAR_LIMIT_Msk) | \ ((PXN << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \ ((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ (MPU_RLAR_EN_Msk)) #endif /** * Struct for a single MPU Region */ typedef struct { uint32_t RBAR; /*!< Region Base Address Register value */ uint32_t RLAR; /*!< Region Limit Address Register value */ } ARM_MPU_Region_t; /** Enable the MPU. * \param MPU_Control Default access permissions for unconfigured regions. */ __STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) { MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; #ifdef SCB_SHCSR_MEMFAULTENA_Msk SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; #endif __DSB(); __ISB(); } /** Disable the MPU. */ __STATIC_INLINE void ARM_MPU_Disable(void) { __DMB(); #ifdef SCB_SHCSR_MEMFAULTENA_Msk SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; #endif MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; } #ifdef MPU_NS /** Enable the Non-secure MPU. * \param MPU_Control Default access permissions for unconfigured regions. */ __STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control) { MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; #ifdef SCB_SHCSR_MEMFAULTENA_Msk SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; #endif __DSB(); __ISB(); } /** Disable the Non-secure MPU. */ __STATIC_INLINE void ARM_MPU_Disable_NS(void) { __DMB(); #ifdef SCB_SHCSR_MEMFAULTENA_Msk SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; #endif MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk; } #endif /** Set the memory attribute encoding to the given MPU. * \param mpu Pointer to the MPU to be configured. * \param idx The attribute index to be set [0-7] * \param attr The attribute value to be set. */ __STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr) { const uint8_t reg = idx / 4U; const uint32_t pos = ((idx % 4U) * 8U); const uint32_t mask = 0xFFU << pos; if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) { return; // invalid index } mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask)); } /** Set the memory attribute encoding. * \param idx The attribute index to be set [0-7] * \param attr The attribute value to be set. */ __STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr) { ARM_MPU_SetMemAttrEx(MPU, idx, attr); } #ifdef MPU_NS /** Set the memory attribute encoding to the Non-secure MPU. * \param idx The attribute index to be set [0-7] * \param attr The attribute value to be set. */ __STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr) { ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr); } #endif /** Clear and disable the given MPU region of the given MPU. * \param mpu Pointer to MPU to be used. * \param rnr Region number to be cleared. */ __STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr) { mpu->RNR = rnr; mpu->RLAR = 0U; } /** Clear and disable the given MPU region. * \param rnr Region number to be cleared. */ __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) { ARM_MPU_ClrRegionEx(MPU, rnr); } #ifdef MPU_NS /** Clear and disable the given Non-secure MPU region. * \param rnr Region number to be cleared. */ __STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr) { ARM_MPU_ClrRegionEx(MPU_NS, rnr); } #endif /** Configure the given MPU region of the given MPU. * \param mpu Pointer to MPU to be used. * \param rnr Region number to be configured. * \param rbar Value for RBAR register. * \param rlar Value for RLAR register. */ __STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar) { mpu->RNR = rnr; mpu->RBAR = rbar; mpu->RLAR = rlar; } /** Configure the given MPU region. * \param rnr Region number to be configured. * \param rbar Value for RBAR register. * \param rlar Value for RLAR register. */ __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar) { ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar); } #ifdef MPU_NS /** Configure the given Non-secure MPU region. * \param rnr Region number to be configured. * \param rbar Value for RBAR register. * \param rlar Value for RLAR register. */ __STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar) { ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar); } #endif /** Memcopy with strictly ordered memory access, e.g. for register targets. * \param dst Destination data is copied to. * \param src Source data is copied from. * \param len Amount of data words to be copied. */ __STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) { uint32_t i; for (i = 0U; i < len; ++i) { dst[i] = src[i]; } } /** Load the given number of MPU regions from a table to the given MPU. * \param mpu Pointer to the MPU registers to be used. * \param rnr First region number to be configured. * \param table Pointer to the MPU configuration table. * \param cnt Amount of regions to be configured. */ __STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) { const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; if (cnt == 1U) { mpu->RNR = rnr; ARM_MPU_OrderedMemcpy(&(mpu->RBAR), &(table->RBAR), rowWordSize); } else { uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U); uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES; mpu->RNR = rnrBase; while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) { uint32_t c = MPU_TYPE_RALIASES - rnrOffset; ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize); table += c; cnt -= c; rnrOffset = 0U; rnrBase += MPU_TYPE_RALIASES; mpu->RNR = rnrBase; } ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize); } } /** Load the given number of MPU regions from a table. * \param rnr First region number to be configured. * \param table Pointer to the MPU configuration table. * \param cnt Amount of regions to be configured. */ __STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) { ARM_MPU_LoadEx(MPU, rnr, table, cnt); } #ifdef MPU_NS /** Load the given number of MPU regions from a table to the Non-secure MPU. * \param rnr First region number to be configured. * \param table Pointer to the MPU configuration table. * \param cnt Amount of regions to be configured. */ __STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) { ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt); } #endif #endif ================================================ FILE: panda/board/stm32h7/inc/stm32h725xx.h ================================================ /** ****************************************************************************** * @file stm32h735xx.h * @author MCD Application Team * @brief CMSIS STM32H735xx Device Peripheral Access Layer Header File. * * This file contains: * - Data structures and the address mapping for all peripherals * - Peripheral's registers declarations and bits definition * - Macros to access peripheral's registers hardware * ****************************************************************************** * @attention * *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32h735xx * @{ */ #ifndef STM32H735xx_H #define STM32H735xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32H7XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M Processor Exceptions Numbers *****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /*!< 4 Cortex-M Memory Management Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt ( wwdg1_it, wwdg2_it) */ PVD_AVD_IRQn = 1, /*!< PVD/AVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1 and ADC2 global Interrupts */ FDCAN1_IT0_IRQn = 19, /*!< FDCAN1 Interrupt line 0 */ FDCAN2_IT0_IRQn = 20, /*!< FDCAN2 Interrupt line 0 */ FDCAN1_IT1_IRQn = 21, /*!< FDCAN1 Interrupt line 1 */ FDCAN2_IT1_IRQn = 22, /*!< FDCAN2 Interrupt line 1 */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FMC_IRQn = 48, /*!< FMC global Interrupt */ SDMMC1_IRQn = 49, /*!< SDMMC1 global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ ETH_IRQn = 61, /*!< Ethernet global Interrupt */ ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ FDCAN_CAL_IRQn = 63, /*!< FDCAN Calibration unit Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ DCMI_PSSI_IRQn = 78, /*!< DCMI and PSSI global interrupt */ CRYP_IRQn = 79, /*!< CRYP crypto global interrupt */ HASH_RNG_IRQn = 80, /*!< HASH and RNG global interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ UART7_IRQn = 82, /*!< UART7 global interrupt */ UART8_IRQn = 83, /*!< UART8 global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ SPI6_IRQn = 86, /*!< SPI6 global Interrupt */ SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ LTDC_IRQn = 88, /*!< LTDC global Interrupt */ LTDC_ER_IRQn = 89, /*!< LTDC Error global Interrupt */ DMA2D_IRQn = 90, /*!< DMA2D global Interrupt */ OCTOSPI1_IRQn = 92, /*!< OCTOSPI1 global interrupt */ LPTIM1_IRQn = 93, /*!< LP TIM1 interrupt */ CEC_IRQn = 94, /*!< HDMI-CEC global Interrupt */ I2C4_EV_IRQn = 95, /*!< I2C4 Event Interrupt */ I2C4_ER_IRQn = 96, /*!< I2C4 Error Interrupt */ SPDIF_RX_IRQn = 97, /*!< SPDIF-RX global Interrupt */ DMAMUX1_OVR_IRQn = 102, /*! /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t ISR; /*!< ADC Interrupt and Status Register, Address offset: 0x00 */ __IO uint32_t IER; /*!< ADC Interrupt Enable Register, Address offset: 0x04 */ __IO uint32_t CR; /*!< ADC control register, Address offset: 0x08 */ __IO uint32_t CFGR; /*!< ADC Configuration register, Address offset: 0x0C */ __IO uint32_t CFGR2; /*!< ADC Configuration register 2, Address offset: 0x10 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x14 */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x18 */ __IO uint32_t PCSEL_RES0; /*!< Rserved for ADC3, ADC1/2 pre-channel selection, Address offset: 0x1C */ __IO uint32_t LTR1_TR1; /*!< ADC watchdog Lower threshold register 1, Address offset: 0x20 */ __IO uint32_t HTR1_TR2; /*!< ADC watchdog higher threshold register 1, Address offset: 0x24 */ __IO uint32_t RES1_TR3; /*!< Rserved for ADC1/2, ADC3 threshold register, Address offset: 0x28 */ uint32_t RESERVED2; /*!< Reserved, 0x02C */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x30 */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x34 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x38 */ __IO uint32_t SQR4; /*!< ADC regular sequence register 4, Address offset: 0x3C */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x40 */ uint32_t RESERVED3; /*!< Reserved, 0x044 */ uint32_t RESERVED4; /*!< Reserved, 0x048 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x4C */ uint32_t RESERVED5[4]; /*!< Reserved, 0x050 - 0x05C */ __IO uint32_t OFR1; /*!< ADC offset register 1, Address offset: 0x60 */ __IO uint32_t OFR2; /*!< ADC offset register 2, Address offset: 0x64 */ __IO uint32_t OFR3; /*!< ADC offset register 3, Address offset: 0x68 */ __IO uint32_t OFR4; /*!< ADC offset register 4, Address offset: 0x6C */ uint32_t RESERVED6[4]; /*!< Reserved, 0x070 - 0x07C */ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x80 */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x84 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x88 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x8C */ uint32_t RESERVED7[4]; /*!< Reserved, 0x090 - 0x09C */ __IO uint32_t AWD2CR; /*!< ADC Analog Watchdog 2 Configuration Register, Address offset: 0xA0 */ __IO uint32_t AWD3CR; /*!< ADC Analog Watchdog 3 Configuration Register, Address offset: 0xA4 */ uint32_t RESERVED8; /*!< Reserved, 0x0A8 */ uint32_t RESERVED9; /*!< Reserved, 0x0AC */ __IO uint32_t LTR2_DIFSEL; /*!< ADC watchdog Lower threshold register 2, Difsel for ADC3, Address offset: 0xB0 */ __IO uint32_t HTR2_CALFACT; /*!< ADC watchdog Higher threshold register 2, Calfact for ADC3, Address offset: 0xB4 */ __IO uint32_t LTR3_RES10; /*!< ADC watchdog Lower threshold register 3, specific ADC1/2, Address offset: 0xB8 */ __IO uint32_t HTR3_RES11; /*!< ADC watchdog Higher threshold register 3, specific ADC1/2, Address offset: 0xBC */ __IO uint32_t DIFSEL_RES12; /*!< ADC Differential Mode Selection Register specific ADC1/2, Address offset: 0xC0 */ __IO uint32_t CALFACT_RES13; /*!< ADC Calibration Factors specific ADC1/2, Address offset: 0xC4 */ __IO uint32_t CALFACT2_RES14; /*!< ADC Linearity Calibration Factors specific ADC1/2, Address offset: 0xC8 */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1/3 base address + 0x300 */ uint32_t RESERVED; /*!< Reserved, ADC1/3 base address + 0x304 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1/3 base address + 0x308 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual Address offset: ADC1/3 base address + 0x30C */ __IO uint32_t CDR2; /*!< ADC common regular data register for 32-bit dual mode Address offset: ADC1/3 base address + 0x310 */ } ADC_Common_TypeDef; /** * @brief VREFBUF */ typedef struct { __IO uint32_t CSR; /*!< VREFBUF control and status register, Address offset: 0x00 */ __IO uint32_t CCR; /*!< VREFBUF calibration and control register, Address offset: 0x04 */ } VREFBUF_TypeDef; /** * @brief FD Controller Area Network */ typedef struct { __IO uint32_t CREL; /*!< FDCAN Core Release register, Address offset: 0x000 */ __IO uint32_t ENDN; /*!< FDCAN Endian register, Address offset: 0x004 */ __IO uint32_t RESERVED1; /*!< Reserved, 0x008 */ __IO uint32_t DBTP; /*!< FDCAN Data Bit Timing & Prescaler register, Address offset: 0x00C */ __IO uint32_t TEST; /*!< FDCAN Test register, Address offset: 0x010 */ __IO uint32_t RWD; /*!< FDCAN RAM Watchdog register, Address offset: 0x014 */ __IO uint32_t CCCR; /*!< FDCAN CC Control register, Address offset: 0x018 */ __IO uint32_t NBTP; /*!< FDCAN Nominal Bit Timing & Prescaler register, Address offset: 0x01C */ __IO uint32_t TSCC; /*!< FDCAN Timestamp Counter Configuration register, Address offset: 0x020 */ __IO uint32_t TSCV; /*!< FDCAN Timestamp Counter Value register, Address offset: 0x024 */ __IO uint32_t TOCC; /*!< FDCAN Timeout Counter Configuration register, Address offset: 0x028 */ __IO uint32_t TOCV; /*!< FDCAN Timeout Counter Value register, Address offset: 0x02C */ __IO uint32_t RESERVED2[4]; /*!< Reserved, 0x030 - 0x03C */ __IO uint32_t ECR; /*!< FDCAN Error Counter register, Address offset: 0x040 */ __IO uint32_t PSR; /*!< FDCAN Protocol Status register, Address offset: 0x044 */ __IO uint32_t TDCR; /*!< FDCAN Transmitter Delay Compensation register, Address offset: 0x048 */ __IO uint32_t RESERVED3; /*!< Reserved, 0x04C */ __IO uint32_t IR; /*!< FDCAN Interrupt register, Address offset: 0x050 */ __IO uint32_t IE; /*!< FDCAN Interrupt Enable register, Address offset: 0x054 */ __IO uint32_t ILS; /*!< FDCAN Interrupt Line Select register, Address offset: 0x058 */ __IO uint32_t ILE; /*!< FDCAN Interrupt Line Enable register, Address offset: 0x05C */ __IO uint32_t RESERVED4[8]; /*!< Reserved, 0x060 - 0x07C */ __IO uint32_t GFC; /*!< FDCAN Global Filter Configuration register, Address offset: 0x080 */ __IO uint32_t SIDFC; /*!< FDCAN Standard ID Filter Configuration register, Address offset: 0x084 */ __IO uint32_t XIDFC; /*!< FDCAN Extended ID Filter Configuration register, Address offset: 0x088 */ __IO uint32_t RESERVED5; /*!< Reserved, 0x08C */ __IO uint32_t XIDAM; /*!< FDCAN Extended ID AND Mask register, Address offset: 0x090 */ __IO uint32_t HPMS; /*!< FDCAN High Priority Message Status register, Address offset: 0x094 */ __IO uint32_t NDAT1; /*!< FDCAN New Data 1 register, Address offset: 0x098 */ __IO uint32_t NDAT2; /*!< FDCAN New Data 2 register, Address offset: 0x09C */ __IO uint32_t RXF0C; /*!< FDCAN Rx FIFO 0 Configuration register, Address offset: 0x0A0 */ __IO uint32_t RXF0S; /*!< FDCAN Rx FIFO 0 Status register, Address offset: 0x0A4 */ __IO uint32_t RXF0A; /*!< FDCAN Rx FIFO 0 Acknowledge register, Address offset: 0x0A8 */ __IO uint32_t RXBC; /*!< FDCAN Rx Buffer Configuration register, Address offset: 0x0AC */ __IO uint32_t RXF1C; /*!< FDCAN Rx FIFO 1 Configuration register, Address offset: 0x0B0 */ __IO uint32_t RXF1S; /*!< FDCAN Rx FIFO 1 Status register, Address offset: 0x0B4 */ __IO uint32_t RXF1A; /*!< FDCAN Rx FIFO 1 Acknowledge register, Address offset: 0x0B8 */ __IO uint32_t RXESC; /*!< FDCAN Rx Buffer/FIFO Element Size Configuration register, Address offset: 0x0BC */ __IO uint32_t TXBC; /*!< FDCAN Tx Buffer Configuration register, Address offset: 0x0C0 */ __IO uint32_t TXFQS; /*!< FDCAN Tx FIFO/Queue Status register, Address offset: 0x0C4 */ __IO uint32_t TXESC; /*!< FDCAN Tx Buffer Element Size Configuration register, Address offset: 0x0C8 */ __IO uint32_t TXBRP; /*!< FDCAN Tx Buffer Request Pending register, Address offset: 0x0CC */ __IO uint32_t TXBAR; /*!< FDCAN Tx Buffer Add Request register, Address offset: 0x0D0 */ __IO uint32_t TXBCR; /*!< FDCAN Tx Buffer Cancellation Request register, Address offset: 0x0D4 */ __IO uint32_t TXBTO; /*!< FDCAN Tx Buffer Transmission Occurred register, Address offset: 0x0D8 */ __IO uint32_t TXBCF; /*!< FDCAN Tx Buffer Cancellation Finished register, Address offset: 0x0DC */ __IO uint32_t TXBTIE; /*!< FDCAN Tx Buffer Transmission Interrupt Enable register, Address offset: 0x0E0 */ __IO uint32_t TXBCIE; /*!< FDCAN Tx Buffer Cancellation Finished Interrupt Enable register, Address offset: 0x0E4 */ __IO uint32_t RESERVED6[2]; /*!< Reserved, 0x0E8 - 0x0EC */ __IO uint32_t TXEFC; /*!< FDCAN Tx Event FIFO Configuration register, Address offset: 0x0F0 */ __IO uint32_t TXEFS; /*!< FDCAN Tx Event FIFO Status register, Address offset: 0x0F4 */ __IO uint32_t TXEFA; /*!< FDCAN Tx Event FIFO Acknowledge register, Address offset: 0x0F8 */ __IO uint32_t RESERVED7; /*!< Reserved, 0x0FC */ } FDCAN_GlobalTypeDef; /** * @brief TTFD Controller Area Network */ typedef struct { __IO uint32_t TTTMC; /*!< TT Trigger Memory Configuration register, Address offset: 0x100 */ __IO uint32_t TTRMC; /*!< TT Reference Message Configuration register, Address offset: 0x104 */ __IO uint32_t TTOCF; /*!< TT Operation Configuration register, Address offset: 0x108 */ __IO uint32_t TTMLM; /*!< TT Matrix Limits register, Address offset: 0x10C */ __IO uint32_t TURCF; /*!< TUR Configuration register, Address offset: 0x110 */ __IO uint32_t TTOCN; /*!< TT Operation Control register, Address offset: 0x114 */ __IO uint32_t TTGTP; /*!< TT Global Time Preset register, Address offset: 0x118 */ __IO uint32_t TTTMK; /*!< TT Time Mark register, Address offset: 0x11C */ __IO uint32_t TTIR; /*!< TT Interrupt register, Address offset: 0x120 */ __IO uint32_t TTIE; /*!< TT Interrupt Enable register, Address offset: 0x124 */ __IO uint32_t TTILS; /*!< TT Interrupt Line Select register, Address offset: 0x128 */ __IO uint32_t TTOST; /*!< TT Operation Status register, Address offset: 0x12C */ __IO uint32_t TURNA; /*!< TT TUR Numerator Actual register, Address offset: 0x130 */ __IO uint32_t TTLGT; /*!< TT Local and Global Time register, Address offset: 0x134 */ __IO uint32_t TTCTC; /*!< TT Cycle Time and Count register, Address offset: 0x138 */ __IO uint32_t TTCPT; /*!< TT Capture Time register, Address offset: 0x13C */ __IO uint32_t TTCSM; /*!< TT Cycle Sync Mark register, Address offset: 0x140 */ __IO uint32_t RESERVED1[111]; /*!< Reserved, 0x144 - 0x2FC */ __IO uint32_t TTTS; /*!< TT Trigger Select register, Address offset: 0x300 */ } TTCAN_TypeDef; /** * @brief FD Controller Area Network */ typedef struct { __IO uint32_t CREL; /*!< Clock Calibration Unit Core Release register, Address offset: 0x00 */ __IO uint32_t CCFG; /*!< Calibration Configuration register, Address offset: 0x04 */ __IO uint32_t CSTAT; /*!< Calibration Status register, Address offset: 0x08 */ __IO uint32_t CWD; /*!< Calibration Watchdog register, Address offset: 0x0C */ __IO uint32_t IR; /*!< CCU Interrupt register, Address offset: 0x10 */ __IO uint32_t IE; /*!< CCU Interrupt Enable register, Address offset: 0x14 */ } FDCAN_ClockCalibrationUnit_TypeDef; /** * @brief Consumer Electronics Control */ typedef struct { __IO uint32_t CR; /*!< CEC control register, Address offset:0x00 */ __IO uint32_t CFGR; /*!< CEC configuration register, Address offset:0x04 */ __IO uint32_t TXDR; /*!< CEC Tx data register , Address offset:0x08 */ __IO uint32_t RXDR; /*!< CEC Rx Data Register, Address offset:0x0C */ __IO uint32_t ISR; /*!< CEC Interrupt and Status Register, Address offset:0x10 */ __IO uint32_t IER; /*!< CEC interrupt enable register, Address offset:0x14 */ }CEC_TypeDef; /** * @brief COordincate Rotation DIgital Computer */ typedef struct { __IO uint32_t CSR; /*!< CORDIC control and status register, Address offset: 0x00 */ __IO uint32_t WDATA; /*!< CORDIC argument register, Address offset: 0x04 */ __IO uint32_t RDATA; /*!< CORDIC result register, Address offset: 0x08 */ } CORDIC_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint32_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ uint32_t RESERVED2; /*!< Reserved, 0x0C */ __IO uint32_t INIT; /*!< Initial CRC value register, Address offset: 0x10 */ __IO uint32_t POL; /*!< CRC polynomial register, Address offset: 0x14 */ } CRC_TypeDef; /** * @brief Clock Recovery System */ typedef struct { __IO uint32_t CR; /*!< CRS ccontrol register, Address offset: 0x00 */ __IO uint32_t CFGR; /*!< CRS configuration register, Address offset: 0x04 */ __IO uint32_t ISR; /*!< CRS interrupt and status register, Address offset: 0x08 */ __IO uint32_t ICR; /*!< CRS interrupt flag clear register, Address offset: 0x0C */ } CRS_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ __IO uint32_t CCR; /*!< DAC calibration control register, Address offset: 0x38 */ __IO uint32_t MCR; /*!< DAC mode control register, Address offset: 0x3C */ __IO uint32_t SHSR1; /*!< DAC Sample and Hold sample time register 1, Address offset: 0x40 */ __IO uint32_t SHSR2; /*!< DAC Sample and Hold sample time register 2, Address offset: 0x44 */ __IO uint32_t SHHR; /*!< DAC Sample and Hold hold time register, Address offset: 0x48 */ __IO uint32_t SHRR; /*!< DAC Sample and Hold refresh time register, Address offset: 0x4C */ } DAC_TypeDef; /** * @brief DFSDM module registers */ typedef struct { __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ } DFSDM_Filter_TypeDef; /** * @brief DFSDM channel configuration registers */ typedef struct { __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and short circuit detector register, Address offset: 0x08 */ __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ } DFSDM_Channel_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ uint32_t RESERVED4[11]; /*!< Reserved, Address offset: 0x08 */ __IO uint32_t APB3FZ1; /*!< Debug MCU APB3FZ1 freeze register, Address offset: 0x34 */ uint32_t RESERVED5; /*!< Reserved, Address offset: 0x38 */ __IO uint32_t APB1LFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x3C */ uint32_t RESERVED6; /*!< Reserved, Address offset: 0x40 */ __IO uint32_t APB1HFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x44 */ uint32_t RESERVED7; /*!< Reserved, Address offset: 0x48 */ __IO uint32_t APB2FZ1; /*!< Debug MCU APB2FZ1 freeze register, Address offset: 0x4C */ uint32_t RESERVED8; /*!< Reserved, Address offset: 0x50 */ __IO uint32_t APB4FZ1; /*!< Debug MCU APB4FZ1 freeze register, Address offset: 0x54 */ __IO uint32_t RESERVED9[990]; /*!< Reserved, Address offset: 0x58-0xFCC */ __IO uint32_t PIDR4; /*!< Debug MCU peripheral identity register 4, Address offset: 0xFD0 */ __IO uint32_t RESERVED10[3];/*!< Reserved, Address offset: 0xFD4-0xFDC */ __IO uint32_t PIDR0; /*!< Debug MCU peripheral identity register 0, Address offset: 0xFE0 */ __IO uint32_t PIDR1; /*!< Debug MCU peripheral identity register 1, Address offset: 0xFE4 */ __IO uint32_t PIDR2; /*!< Debug MCU peripheral identity register 2, Address offset: 0xFE8 */ __IO uint32_t PIDR3; /*!< Debug MCU peripheral identity register 3, Address offset: 0xFEC */ __IO uint32_t CIDR0; /*!< Debug MCU component identity register 0, Address offset: 0xFF0 */ __IO uint32_t CIDR1; /*!< Debug MCU component identity register 1, Address offset: 0xFF4 */ __IO uint32_t CIDR2; /*!< Debug MCU component identity register 2, Address offset: 0xFF8 */ __IO uint32_t CIDR3; /*!< Debug MCU component identity register 3, Address offset: 0xFFC */ }DBGMCU_TypeDef; /** * @brief DCMI */ typedef struct { __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ } DCMI_TypeDef; /** * @brief PSSI */ typedef struct { __IO uint32_t CR; /*!< PSSI control register 1, Address offset: 0x000 */ __IO uint32_t SR; /*!< PSSI status register, Address offset: 0x004 */ __IO uint32_t RIS; /*!< PSSI raw interrupt status register, Address offset: 0x008 */ __IO uint32_t IER; /*!< PSSI interrupt enable register, Address offset: 0x00C */ __IO uint32_t MIS; /*!< PSSI masked interrupt status register, Address offset: 0x010 */ __IO uint32_t ICR; /*!< PSSI interrupt clear register, Address offset: 0x014 */ __IO uint32_t RESERVED1[4]; /*!< Reserved, 0x018 - 0x024 */ __IO uint32_t DR; /*!< PSSI data register, Address offset: 0x028 */ __IO uint32_t RESERVED2[241]; /*!< Reserved, 0x02C - 0x3EC */ __IO uint32_t HWCFGR; /*!< PSSI IP HW configuration register, Address offset: 0x3F0 */ __IO uint32_t VERR; /*!< PSSI IP version register, Address offset: 0x3F4 */ __IO uint32_t IPIDR; /*!< PSSI IP ID register, Address offset: 0x3F8 */ __IO uint32_t SIDR; /*!< PSSI SIZE ID register, Address offset: 0x3FC */ } PSSI_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; typedef struct { __IO uint32_t CCR; /*!< DMA channel x configuration register */ __IO uint32_t CNDTR; /*!< DMA channel x number of data register */ __IO uint32_t CPAR; /*!< DMA channel x peripheral address register */ __IO uint32_t CM0AR; /*!< DMA channel x memory 0 address register */ __IO uint32_t CM1AR; /*!< DMA channel x memory 1 address register */ } BDMA_Channel_TypeDef; typedef struct { __IO uint32_t ISR; /*!< DMA interrupt status register, Address offset: 0x00 */ __IO uint32_t IFCR; /*!< DMA interrupt flag clear register, Address offset: 0x04 */ } BDMA_TypeDef; typedef struct { __IO uint32_t CCR; /*!< DMA Multiplexer Channel x Control Register */ }DMAMUX_Channel_TypeDef; typedef struct { __IO uint32_t CSR; /*!< DMA Channel Status Register */ __IO uint32_t CFR; /*!< DMA Channel Clear Flag Register */ }DMAMUX_ChannelStatus_TypeDef; typedef struct { __IO uint32_t RGCR; /*!< DMA Request Generator x Control Register */ }DMAMUX_RequestGen_TypeDef; typedef struct { __IO uint32_t RGSR; /*!< DMA Request Generator Status Register */ __IO uint32_t RGCFR; /*!< DMA Request Generator Clear Flag Register */ }DMAMUX_RequestGenStatus_TypeDef; /** * @brief MDMA Controller */ typedef struct { __IO uint32_t GISR0; /*!< MDMA Global Interrupt/Status Register 0, Address offset: 0x00 */ }MDMA_TypeDef; typedef struct { __IO uint32_t CISR; /*!< MDMA channel x interrupt/status register, Address offset: 0x40 */ __IO uint32_t CIFCR; /*!< MDMA channel x interrupt flag clear register, Address offset: 0x44 */ __IO uint32_t CESR; /*!< MDMA Channel x error status register, Address offset: 0x48 */ __IO uint32_t CCR; /*!< MDMA channel x control register, Address offset: 0x4C */ __IO uint32_t CTCR; /*!< MDMA channel x Transfer Configuration register, Address offset: 0x50 */ __IO uint32_t CBNDTR; /*!< MDMA Channel x block number of data register, Address offset: 0x54 */ __IO uint32_t CSAR; /*!< MDMA channel x source address register, Address offset: 0x58 */ __IO uint32_t CDAR; /*!< MDMA channel x destination address register, Address offset: 0x5C */ __IO uint32_t CBRUR; /*!< MDMA channel x Block Repeat address Update register, Address offset: 0x60 */ __IO uint32_t CLAR; /*!< MDMA channel x Link Address register, Address offset: 0x64 */ __IO uint32_t CTBR; /*!< MDMA channel x Trigger and Bus selection Register, Address offset: 0x68 */ uint32_t RESERVED0; /*!< Reserved, 0x6C */ __IO uint32_t CMAR; /*!< MDMA channel x Mask address register, Address offset: 0x70 */ __IO uint32_t CMDR; /*!< MDMA channel x Mask Data register, Address offset: 0x74 */ }MDMA_Channel_TypeDef; /** * @brief DMA2D Controller */ typedef struct { __IO uint32_t CR; /*!< DMA2D Control Register, Address offset: 0x00 */ __IO uint32_t ISR; /*!< DMA2D Interrupt Status Register, Address offset: 0x04 */ __IO uint32_t IFCR; /*!< DMA2D Interrupt Flag Clear Register, Address offset: 0x08 */ __IO uint32_t FGMAR; /*!< DMA2D Foreground Memory Address Register, Address offset: 0x0C */ __IO uint32_t FGOR; /*!< DMA2D Foreground Offset Register, Address offset: 0x10 */ __IO uint32_t BGMAR; /*!< DMA2D Background Memory Address Register, Address offset: 0x14 */ __IO uint32_t BGOR; /*!< DMA2D Background Offset Register, Address offset: 0x18 */ __IO uint32_t FGPFCCR; /*!< DMA2D Foreground PFC Control Register, Address offset: 0x1C */ __IO uint32_t FGCOLR; /*!< DMA2D Foreground Color Register, Address offset: 0x20 */ __IO uint32_t BGPFCCR; /*!< DMA2D Background PFC Control Register, Address offset: 0x24 */ __IO uint32_t BGCOLR; /*!< DMA2D Background Color Register, Address offset: 0x28 */ __IO uint32_t FGCMAR; /*!< DMA2D Foreground CLUT Memory Address Register, Address offset: 0x2C */ __IO uint32_t BGCMAR; /*!< DMA2D Background CLUT Memory Address Register, Address offset: 0x30 */ __IO uint32_t OPFCCR; /*!< DMA2D Output PFC Control Register, Address offset: 0x34 */ __IO uint32_t OCOLR; /*!< DMA2D Output Color Register, Address offset: 0x38 */ __IO uint32_t OMAR; /*!< DMA2D Output Memory Address Register, Address offset: 0x3C */ __IO uint32_t OOR; /*!< DMA2D Output Offset Register, Address offset: 0x40 */ __IO uint32_t NLR; /*!< DMA2D Number of Line Register, Address offset: 0x44 */ __IO uint32_t LWR; /*!< DMA2D Line Watermark Register, Address offset: 0x48 */ __IO uint32_t AMTCR; /*!< DMA2D AHB Master Timer Configuration Register, Address offset: 0x4C */ uint32_t RESERVED[236]; /*!< Reserved, 0x50-0x3FF */ __IO uint32_t FGCLUT[256]; /*!< DMA2D Foreground CLUT, Address offset:400-7FF */ __IO uint32_t BGCLUT[256]; /*!< DMA2D Background CLUT, Address offset:800-BFF */ } DMA2D_TypeDef; /** * @brief Ethernet MAC */ typedef struct { __IO uint32_t MACCR; __IO uint32_t MACECR; __IO uint32_t MACPFR; __IO uint32_t MACWTR; __IO uint32_t MACHT0R; __IO uint32_t MACHT1R; uint32_t RESERVED1[14]; __IO uint32_t MACVTR; uint32_t RESERVED2; __IO uint32_t MACVHTR; uint32_t RESERVED3; __IO uint32_t MACVIR; __IO uint32_t MACIVIR; uint32_t RESERVED4[2]; __IO uint32_t MACTFCR; uint32_t RESERVED5[7]; __IO uint32_t MACRFCR; uint32_t RESERVED6[7]; __IO uint32_t MACISR; __IO uint32_t MACIER; __IO uint32_t MACRXTXSR; uint32_t RESERVED7; __IO uint32_t MACPCSR; __IO uint32_t MACRWKPFR; uint32_t RESERVED8[2]; __IO uint32_t MACLCSR; __IO uint32_t MACLTCR; __IO uint32_t MACLETR; __IO uint32_t MAC1USTCR; uint32_t RESERVED9[12]; __IO uint32_t MACVR; __IO uint32_t MACDR; uint32_t RESERVED10; __IO uint32_t MACHWF0R; __IO uint32_t MACHWF1R; __IO uint32_t MACHWF2R; uint32_t RESERVED11[54]; __IO uint32_t MACMDIOAR; __IO uint32_t MACMDIODR; uint32_t RESERVED12[2]; __IO uint32_t MACARPAR; uint32_t RESERVED13[59]; __IO uint32_t MACA0HR; __IO uint32_t MACA0LR; __IO uint32_t MACA1HR; __IO uint32_t MACA1LR; __IO uint32_t MACA2HR; __IO uint32_t MACA2LR; __IO uint32_t MACA3HR; __IO uint32_t MACA3LR; uint32_t RESERVED14[248]; __IO uint32_t MMCCR; __IO uint32_t MMCRIR; __IO uint32_t MMCTIR; __IO uint32_t MMCRIMR; __IO uint32_t MMCTIMR; uint32_t RESERVED15[14]; __IO uint32_t MMCTSCGPR; __IO uint32_t MMCTMCGPR; uint32_t RESERVED16[5]; __IO uint32_t MMCTPCGR; uint32_t RESERVED17[10]; __IO uint32_t MMCRCRCEPR; __IO uint32_t MMCRAEPR; uint32_t RESERVED18[10]; __IO uint32_t MMCRUPGR; uint32_t RESERVED19[9]; __IO uint32_t MMCTLPIMSTR; __IO uint32_t MMCTLPITCR; __IO uint32_t MMCRLPIMSTR; __IO uint32_t MMCRLPITCR; uint32_t RESERVED20[65]; __IO uint32_t MACL3L4C0R; __IO uint32_t MACL4A0R; uint32_t RESERVED21[2]; __IO uint32_t MACL3A0R0R; __IO uint32_t MACL3A1R0R; __IO uint32_t MACL3A2R0R; __IO uint32_t MACL3A3R0R; uint32_t RESERVED22[4]; __IO uint32_t MACL3L4C1R; __IO uint32_t MACL4A1R; uint32_t RESERVED23[2]; __IO uint32_t MACL3A0R1R; __IO uint32_t MACL3A1R1R; __IO uint32_t MACL3A2R1R; __IO uint32_t MACL3A3R1R; uint32_t RESERVED24[108]; __IO uint32_t MACTSCR; __IO uint32_t MACSSIR; __IO uint32_t MACSTSR; __IO uint32_t MACSTNR; __IO uint32_t MACSTSUR; __IO uint32_t MACSTNUR; __IO uint32_t MACTSAR; uint32_t RESERVED25; __IO uint32_t MACTSSR; uint32_t RESERVED26[3]; __IO uint32_t MACTTSSNR; __IO uint32_t MACTTSSSR; uint32_t RESERVED27[2]; __IO uint32_t MACACR; uint32_t RESERVED28; __IO uint32_t MACATSNR; __IO uint32_t MACATSSR; __IO uint32_t MACTSIACR; __IO uint32_t MACTSEACR; __IO uint32_t MACTSICNR; __IO uint32_t MACTSECNR; uint32_t RESERVED29[4]; __IO uint32_t MACPPSCR; uint32_t RESERVED30[3]; __IO uint32_t MACPPSTTSR; __IO uint32_t MACPPSTTNR; __IO uint32_t MACPPSIR; __IO uint32_t MACPPSWR; uint32_t RESERVED31[12]; __IO uint32_t MACPOCR; __IO uint32_t MACSPI0R; __IO uint32_t MACSPI1R; __IO uint32_t MACSPI2R; __IO uint32_t MACLMIR; uint32_t RESERVED32[11]; __IO uint32_t MTLOMR; uint32_t RESERVED33[7]; __IO uint32_t MTLISR; uint32_t RESERVED34[55]; __IO uint32_t MTLTQOMR; __IO uint32_t MTLTQUR; __IO uint32_t MTLTQDR; uint32_t RESERVED35[8]; __IO uint32_t MTLQICSR; __IO uint32_t MTLRQOMR; __IO uint32_t MTLRQMPOCR; __IO uint32_t MTLRQDR; uint32_t RESERVED36[177]; __IO uint32_t DMAMR; __IO uint32_t DMASBMR; __IO uint32_t DMAISR; __IO uint32_t DMADSR; uint32_t RESERVED37[60]; __IO uint32_t DMACCR; __IO uint32_t DMACTCR; __IO uint32_t DMACRCR; uint32_t RESERVED38[2]; __IO uint32_t DMACTDLAR; uint32_t RESERVED39; __IO uint32_t DMACRDLAR; __IO uint32_t DMACTDTPR; uint32_t RESERVED40; __IO uint32_t DMACRDTPR; __IO uint32_t DMACTDRLR; __IO uint32_t DMACRDRLR; __IO uint32_t DMACIER; __IO uint32_t DMACRIWTR; __IO uint32_t DMACSFCSR; uint32_t RESERVED41; __IO uint32_t DMACCATDR; uint32_t RESERVED42; __IO uint32_t DMACCARDR; uint32_t RESERVED43; __IO uint32_t DMACCATBR; uint32_t RESERVED44; __IO uint32_t DMACCARBR; __IO uint32_t DMACSR; uint32_t RESERVED45[2]; __IO uint32_t DMACMFCR; }ETH_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t RTSR1; /*!< EXTI Rising trigger selection register, Address offset: 0x00 */ __IO uint32_t FTSR1; /*!< EXTI Falling trigger selection register, Address offset: 0x04 */ __IO uint32_t SWIER1; /*!< EXTI Software interrupt event register, Address offset: 0x08 */ __IO uint32_t D3PMR1; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR1) Address offset: 0x0C */ __IO uint32_t D3PCR1L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR1L) Address offset: 0x10 */ __IO uint32_t D3PCR1H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR1H) Address offset: 0x14 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x18 to 0x1C */ __IO uint32_t RTSR2; /*!< EXTI Rising trigger selection register, Address offset: 0x20 */ __IO uint32_t FTSR2; /*!< EXTI Falling trigger selection register, Address offset: 0x24 */ __IO uint32_t SWIER2; /*!< EXTI Software interrupt event register, Address offset: 0x28 */ __IO uint32_t D3PMR2; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR2) Address offset: 0x2C */ __IO uint32_t D3PCR2L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR2L) Address offset: 0x30 */ __IO uint32_t D3PCR2H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR2H) Address offset: 0x34 */ uint32_t RESERVED2[2]; /*!< Reserved, 0x38 to 0x3C */ __IO uint32_t RTSR3; /*!< EXTI Rising trigger selection register, Address offset: 0x40 */ __IO uint32_t FTSR3; /*!< EXTI Falling trigger selection register, Address offset: 0x44 */ __IO uint32_t SWIER3; /*!< EXTI Software interrupt event register, Address offset: 0x48 */ __IO uint32_t D3PMR3; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR3) Address offset: 0x4C */ __IO uint32_t D3PCR3L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR3L) Address offset: 0x50 */ __IO uint32_t D3PCR3H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR3H) Address offset: 0x54 */ uint32_t RESERVED3[10]; /*!< Reserved, 0x58 to 0x7C */ __IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x80 */ __IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x84 */ __IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x88 */ uint32_t RESERVED4; /*!< Reserved, 0x8C */ __IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x90 */ __IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x94 */ __IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x98 */ uint32_t RESERVED5; /*!< Reserved, 0x9C */ __IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0xA0 */ __IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0xA4 */ __IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0xA8 */ }EXTI_TypeDef; /** * @brief This structure registers corresponds to EXTI_Typdef CPU1/CPU2 registers subset (IMRx, EMRx and PRx), allowing to define EXTI_D1/EXTI_D2 * with rapid/common access to these IMRx, EMRx, PRx registers for CPU1 and CPU2. * Note that EXTI_D1 and EXTI_D2 bases addresses are calculated to point to CPUx first register: * IMR1 in case of EXTI_D1 that is addressing CPU1 (Coretx-M7) * C2IMR1 in case of EXTI_D2 that is addressing CPU2 (Coretx-M4) * Note: EXTI_D2 and corresponding C2IMRx, C2EMRx and C2PRx registers are available for Dual Core devices only */ typedef struct { __IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x08 */ uint32_t RESERVED1; /*!< Reserved, 0x0C */ __IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x10 */ __IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x14 */ __IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x18 */ uint32_t RESERVED2; /*!< Reserved, 0x1C */ __IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0x20 */ __IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0x24 */ __IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0x28 */ }EXTI_Core_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR1; /*!< Flash Key Register for bank1, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< Flash Option Key Register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< Flash Control Register for bank1, Address offset: 0x0C */ __IO uint32_t SR1; /*!< Flash Status Register for bank1, Address offset: 0x10 */ __IO uint32_t CCR1; /*!< Flash Control Register for bank1, Address offset: 0x14 */ __IO uint32_t OPTCR; /*!< Flash Option Control Register, Address offset: 0x18 */ __IO uint32_t OPTSR_CUR; /*!< Flash Option Status Current Register, Address offset: 0x1C */ __IO uint32_t OPTSR_PRG; /*!< Flash Option Status to Program Register, Address offset: 0x20 */ __IO uint32_t OPTCCR; /*!< Flash Option Clear Control Register, Address offset: 0x24 */ __IO uint32_t PRAR_CUR1; /*!< Flash Current Protection Address Register for bank1, Address offset: 0x28 */ __IO uint32_t PRAR_PRG1; /*!< Flash Protection Address to Program Register for bank1, Address offset: 0x2C */ __IO uint32_t SCAR_CUR1; /*!< Flash Current Secure Address Register for bank1, Address offset: 0x30 */ __IO uint32_t SCAR_PRG1; /*!< Flash Secure Address to Program Register for bank1, Address offset: 0x34 */ __IO uint32_t WPSN_CUR1; /*!< Flash Current Write Protection Register on bank1, Address offset: 0x38 */ __IO uint32_t WPSN_PRG1; /*!< Flash Write Protection to Program Register on bank1, Address offset: 0x3C */ __IO uint32_t BOOT_CUR; /*!< Flash Current Boot Address for Pelican Core Register, Address offset: 0x40 */ __IO uint32_t BOOT_PRG; /*!< Flash Boot Address to Program for Pelican Core Register, Address offset: 0x44 */ uint32_t RESERVED0[2]; /*!< Reserved, 0x48 to 0x4C */ __IO uint32_t CRCCR1; /*!< Flash CRC Control register For Bank1 Register , Address offset: 0x50 */ __IO uint32_t CRCSADD1; /*!< Flash CRC Start Address Register for Bank1 , Address offset: 0x54 */ __IO uint32_t CRCEADD1; /*!< Flash CRC End Address Register for Bank1 , Address offset: 0x58 */ __IO uint32_t CRCDATA; /*!< Flash CRC Data Register for Bank1 , Address offset: 0x5C */ __IO uint32_t ECC_FA1; /*!< Flash ECC Fail Address For Bank1 Register , Address offset: 0x60 */ uint32_t RESERVED[3]; /*!< Reserved, 0x64 to 0x6C */ __IO uint32_t OPTSR2_CUR; /*!< Flash Option Status Current Register 2, Address offset: 0x70 */ __IO uint32_t OPTSR2_PRG; /*!< Flash Option Status to Program Register 2, Address offset: 0x74 */ } FLASH_TypeDef; /** * @brief Filter and Mathematical ACcelerator */ typedef struct { __IO uint32_t X1BUFCFG; /*!< FMAC X1 Buffer Configuration register, Address offset: 0x00 */ __IO uint32_t X2BUFCFG; /*!< FMAC X2 Buffer Configuration register, Address offset: 0x04 */ __IO uint32_t YBUFCFG; /*!< FMAC Y Buffer Configuration register, Address offset: 0x08 */ __IO uint32_t PARAM; /*!< FMAC Parameter register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FMAC Control register, Address offset: 0x10 */ __IO uint32_t SR; /*!< FMAC Status register, Address offset: 0x14 */ __IO uint32_t WDATA; /*!< FMAC Write Data register, Address offset: 0x18 */ __IO uint32_t RDATA; /*!< FMAC Read Data register, Address offset: 0x1C */ } FMAC_TypeDef; /** * @brief Flexible Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FMC_Bank1_TypeDef; /** * @brief Flexible Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FMC_Bank1E_TypeDef; /** * @brief Flexible Memory Controller Bank2 */ typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ uint32_t RESERVED0; /*!< Reserved, 0x70 */ __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ } FMC_Bank2_TypeDef; /** * @brief Flexible Memory Controller Bank3 */ typedef struct { __IO uint32_t PCR; /*!< NAND Flash control register 3, Address offset: 0x80 */ __IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ __IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ __IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ uint32_t RESERVED; /*!< Reserved, 0x90 */ __IO uint32_t ECCR; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FMC_Bank3_TypeDef; /** * @brief Flexible Memory Controller Bank5 and 6 */ typedef struct { __IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */ __IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */ __IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */ __IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */ __IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */ } FMC_Bank5_6_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief Operational Amplifier (OPAMP) */ typedef struct { __IO uint32_t CSR; /*!< OPAMP control/status register, Address offset: 0x00 */ __IO uint32_t OTR; /*!< OPAMP offset trimming register for normal mode, Address offset: 0x04 */ __IO uint32_t HSOTR; /*!< OPAMP offset trimming register for high speed mode, Address offset: 0x08 */ } OPAMP_TypeDef; /** * @brief System configuration controller */ typedef struct { uint32_t RESERVED1; /*!< Reserved, Address offset: 0x00 */ __IO uint32_t PMCR; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ __IO uint32_t CFGR; /*!< SYSCFG configuration registers, Address offset: 0x18 */ uint32_t RESERVED2; /*!< Reserved, Address offset: 0x1C */ __IO uint32_t CCCSR; /*!< SYSCFG compensation cell control/status register, Address offset: 0x20 */ __IO uint32_t CCVR; /*!< SYSCFG compensation cell value register, Address offset: 0x24 */ __IO uint32_t CCCR; /*!< SYSCFG compensation cell code register, Address offset: 0x28 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2C */ __IO uint32_t ADC2ALT; /*!< ADC2 internal input alternate connection register, Address offset: 0x30 */ uint32_t RESERVED4[60]; /*!< Reserved, 0x34-0x120 */ __IO uint32_t PKGR; /*!< SYSCFG package register, Address offset: 0x124 */ uint32_t RESERVED5[118]; /*!< Reserved, 0x128-0x2FC */ __IO uint32_t UR0; /*!< SYSCFG user register 0, Address offset: 0x300 */ __IO uint32_t UR1; /*!< SYSCFG user register 1, Address offset: 0x304 */ __IO uint32_t UR2; /*!< SYSCFG user register 2, Address offset: 0x308 */ __IO uint32_t UR3; /*!< SYSCFG user register 3, Address offset: 0x30C */ __IO uint32_t UR4; /*!< SYSCFG user register 4, Address offset: 0x310 */ __IO uint32_t UR5; /*!< SYSCFG user register 5, Address offset: 0x314 */ __IO uint32_t UR6; /*!< SYSCFG user register 6, Address offset: 0x318 */ __IO uint32_t UR7; /*!< SYSCFG user register 7, Address offset: 0x31C */ uint32_t RESERVED6[3]; /*!< Reserved, Address offset: 0x320-0x328 */ __IO uint32_t UR11; /*!< SYSCFG user register 11, Address offset: 0x32C */ __IO uint32_t UR12; /*!< SYSCFG user register 12, Address offset: 0x330 */ __IO uint32_t UR13; /*!< SYSCFG user register 13, Address offset: 0x334 */ __IO uint32_t UR14; /*!< SYSCFG user register 14, Address offset: 0x338 */ __IO uint32_t UR15; /*!< SYSCFG user register 15, Address offset: 0x33C */ __IO uint32_t UR16; /*!< SYSCFG user register 16, Address offset: 0x340 */ __IO uint32_t UR17; /*!< SYSCFG user register 17, Address offset: 0x344 */ __IO uint32_t UR18; /*!< SYSCFG user register 18, Address offset: 0x348 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< I2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< I2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< I2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< I2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< I2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< I2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< I2C Transmit data register, Address offset: 0x28 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ __IO uint32_t WINR; /*!< IWDG Window register, Address offset: 0x10 */ } IWDG_TypeDef; /** * @brief LCD-TFT Display Controller */ typedef struct { uint32_t RESERVED0[2]; /*!< Reserved, 0x00-0x04 */ __IO uint32_t SSCR; /*!< LTDC Synchronization Size Configuration Register, Address offset: 0x08 */ __IO uint32_t BPCR; /*!< LTDC Back Porch Configuration Register, Address offset: 0x0C */ __IO uint32_t AWCR; /*!< LTDC Active Width Configuration Register, Address offset: 0x10 */ __IO uint32_t TWCR; /*!< LTDC Total Width Configuration Register, Address offset: 0x14 */ __IO uint32_t GCR; /*!< LTDC Global Control Register, Address offset: 0x18 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x1C-0x20 */ __IO uint32_t SRCR; /*!< LTDC Shadow Reload Configuration Register, Address offset: 0x24 */ uint32_t RESERVED2[1]; /*!< Reserved, 0x28 */ __IO uint32_t BCCR; /*!< LTDC Background Color Configuration Register, Address offset: 0x2C */ uint32_t RESERVED3[1]; /*!< Reserved, 0x30 */ __IO uint32_t IER; /*!< LTDC Interrupt Enable Register, Address offset: 0x34 */ __IO uint32_t ISR; /*!< LTDC Interrupt Status Register, Address offset: 0x38 */ __IO uint32_t ICR; /*!< LTDC Interrupt Clear Register, Address offset: 0x3C */ __IO uint32_t LIPCR; /*!< LTDC Line Interrupt Position Configuration Register, Address offset: 0x40 */ __IO uint32_t CPSR; /*!< LTDC Current Position Status Register, Address offset: 0x44 */ __IO uint32_t CDSR; /*!< LTDC Current Display Status Register, Address offset: 0x48 */ } LTDC_TypeDef; /** * @brief LCD-TFT Display layer x Controller */ typedef struct { __IO uint32_t CR; /*!< LTDC Layerx Control Register Address offset: 0x84 */ __IO uint32_t WHPCR; /*!< LTDC Layerx Window Horizontal Position Configuration Register Address offset: 0x88 */ __IO uint32_t WVPCR; /*!< LTDC Layerx Window Vertical Position Configuration Register Address offset: 0x8C */ __IO uint32_t CKCR; /*!< LTDC Layerx Color Keying Configuration Register Address offset: 0x90 */ __IO uint32_t PFCR; /*!< LTDC Layerx Pixel Format Configuration Register Address offset: 0x94 */ __IO uint32_t CACR; /*!< LTDC Layerx Constant Alpha Configuration Register Address offset: 0x98 */ __IO uint32_t DCCR; /*!< LTDC Layerx Default Color Configuration Register Address offset: 0x9C */ __IO uint32_t BFCR; /*!< LTDC Layerx Blending Factors Configuration Register Address offset: 0xA0 */ uint32_t RESERVED0[2]; /*!< Reserved */ __IO uint32_t CFBAR; /*!< LTDC Layerx Color Frame Buffer Address Register Address offset: 0xAC */ __IO uint32_t CFBLR; /*!< LTDC Layerx Color Frame Buffer Length Register Address offset: 0xB0 */ __IO uint32_t CFBLNR; /*!< LTDC Layerx ColorFrame Buffer Line Number Register Address offset: 0xB4 */ uint32_t RESERVED1[3]; /*!< Reserved */ __IO uint32_t CLUTWR; /*!< LTDC Layerx CLUT Write Register Address offset: 0x144 */ } LTDC_Layer_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR1; /*!< PWR power control register 1, Address offset: 0x00 */ __IO uint32_t CSR1; /*!< PWR power control status register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< PWR power control register 2, Address offset: 0x08 */ __IO uint32_t CR3; /*!< PWR power control register 3, Address offset: 0x0C */ __IO uint32_t CPUCR; /*!< PWR CPU control register, Address offset: 0x10 */ uint32_t RESERVED0; /*!< Reserved, Address offset: 0x14 */ __IO uint32_t D3CR; /*!< PWR D3 domain control register, Address offset: 0x18 */ uint32_t RESERVED1; /*!< Reserved, Address offset: 0x1C */ __IO uint32_t WKUPCR; /*!< PWR wakeup clear register, Address offset: 0x20 */ __IO uint32_t WKUPFR; /*!< PWR wakeup flag register, Address offset: 0x24 */ __IO uint32_t WKUPEPR; /*!< PWR wakeup enable and polarity register, Address offset: 0x28 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t HSICFGR; /*!< HSI Clock Calibration Register, Address offset: 0x04 */ __IO uint32_t CRRCR; /*!< Clock Recovery RC Register, Address offset: 0x08 */ __IO uint32_t CSICFGR; /*!< CSI Clock Calibration Register, Address offset: 0x0C */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x10 */ uint32_t RESERVED1; /*!< Reserved, Address offset: 0x14 */ __IO uint32_t D1CFGR; /*!< RCC Domain 1 configuration register, Address offset: 0x18 */ __IO uint32_t D2CFGR; /*!< RCC Domain 2 configuration register, Address offset: 0x1C */ __IO uint32_t D3CFGR; /*!< RCC Domain 3 configuration register, Address offset: 0x20 */ uint32_t RESERVED2; /*!< Reserved, Address offset: 0x24 */ __IO uint32_t PLLCKSELR; /*!< RCC PLLs Clock Source Selection Register, Address offset: 0x28 */ __IO uint32_t PLLCFGR; /*!< RCC PLLs Configuration Register, Address offset: 0x2C */ __IO uint32_t PLL1DIVR; /*!< RCC PLL1 Dividers Configuration Register, Address offset: 0x30 */ __IO uint32_t PLL1FRACR; /*!< RCC PLL1 Fractional Divider Configuration Register, Address offset: 0x34 */ __IO uint32_t PLL2DIVR; /*!< RCC PLL2 Dividers Configuration Register, Address offset: 0x38 */ __IO uint32_t PLL2FRACR; /*!< RCC PLL2 Fractional Divider Configuration Register, Address offset: 0x3C */ __IO uint32_t PLL3DIVR; /*!< RCC PLL3 Dividers Configuration Register, Address offset: 0x40 */ __IO uint32_t PLL3FRACR; /*!< RCC PLL3 Fractional Divider Configuration Register, Address offset: 0x44 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x48 */ __IO uint32_t D1CCIPR; /*!< RCC Domain 1 Kernel Clock Configuration Register Address offset: 0x4C */ __IO uint32_t D2CCIP1R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x50 */ __IO uint32_t D2CCIP2R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x54 */ __IO uint32_t D3CCIPR; /*!< RCC Domain 3 Kernel Clock Configuration Register Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, Address offset: 0x5C */ __IO uint32_t CIER; /*!< RCC Clock Source Interrupt Enable Register Address offset: 0x60 */ __IO uint32_t CIFR; /*!< RCC Clock Source Interrupt Flag Register Address offset: 0x64 */ __IO uint32_t CICR; /*!< RCC Clock Source Interrupt Clear Register Address offset: 0x68 */ uint32_t RESERVED5; /*!< Reserved, Address offset: 0x6C */ __IO uint32_t BDCR; /*!< RCC Vswitch Backup Domain Control Register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6; /*!< Reserved, Address offset: 0x78 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x7C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x80 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x84 */ __IO uint32_t AHB4RSTR; /*!< RCC AHB4 peripheral reset register, Address offset: 0x88 */ __IO uint32_t APB3RSTR; /*!< RCC APB3 peripheral reset register, Address offset: 0x8C */ __IO uint32_t APB1LRSTR; /*!< RCC APB1 peripheral reset Low Word register, Address offset: 0x90 */ __IO uint32_t APB1HRSTR; /*!< RCC APB1 peripheral reset High Word register, Address offset: 0x94 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x98 */ __IO uint32_t APB4RSTR; /*!< RCC APB4 peripheral reset register, Address offset: 0x9C */ __IO uint32_t GCR; /*!< RCC RCC Global Control Register, Address offset: 0xA0 */ uint32_t RESERVED8; /*!< Reserved, Address offset: 0xA4 */ __IO uint32_t D3AMR; /*!< RCC Domain 3 Autonomous Mode Register, Address offset: 0xA8 */ uint32_t RESERVED11[9]; /*!< Reserved, 0xAC-0xCC Address offset: 0xAC */ __IO uint32_t RSR; /*!< RCC Reset status register, Address offset: 0xD0 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0xD4 */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0xD8 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0xDC */ __IO uint32_t AHB4ENR; /*!< RCC AHB4 peripheral clock register, Address offset: 0xE0 */ __IO uint32_t APB3ENR; /*!< RCC APB3 peripheral clock register, Address offset: 0xE4 */ __IO uint32_t APB1LENR; /*!< RCC APB1 peripheral clock Low Word register, Address offset: 0xE8 */ __IO uint32_t APB1HENR; /*!< RCC APB1 peripheral clock High Word register, Address offset: 0xEC */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock register, Address offset: 0xF0 */ __IO uint32_t APB4ENR; /*!< RCC APB4 peripheral clock register, Address offset: 0xF4 */ uint32_t RESERVED12; /*!< Reserved, Address offset: 0xF8 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral sleep clock register, Address offset: 0xFC */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral sleep clock register, Address offset: 0x100 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral sleep clock register, Address offset: 0x104 */ __IO uint32_t AHB4LPENR; /*!< RCC AHB4 peripheral sleep clock register, Address offset: 0x108 */ __IO uint32_t APB3LPENR; /*!< RCC APB3 peripheral sleep clock register, Address offset: 0x10C */ __IO uint32_t APB1LLPENR; /*!< RCC APB1 peripheral sleep clock Low Word register, Address offset: 0x110 */ __IO uint32_t APB1HLPENR; /*!< RCC APB1 peripheral sleep clock High Word register, Address offset: 0x114 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral sleep clock register, Address offset: 0x118 */ __IO uint32_t APB4LPENR; /*!< RCC APB4 peripheral sleep clock register, Address offset: 0x11C */ uint32_t RESERVED13[4]; /*!< Reserved, 0x120-0x12C Address offset: 0x120 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ uint32_t RESERVED; /*!< Reserved, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAMPCR; /*!< RTC tamper configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR; /*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR; /*!< RTC alarm B sub second register, Address offset: 0x48 */ __IO uint32_t OR; /*!< RTC option register, Address offset: 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 0, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ __IO uint32_t BKP20R; /*!< RTC backup register 20, Address offset: 0xA0 */ __IO uint32_t BKP21R; /*!< RTC backup register 21, Address offset: 0xA4 */ __IO uint32_t BKP22R; /*!< RTC backup register 22, Address offset: 0xA8 */ __IO uint32_t BKP23R; /*!< RTC backup register 23, Address offset: 0xAC */ __IO uint32_t BKP24R; /*!< RTC backup register 24, Address offset: 0xB0 */ __IO uint32_t BKP25R; /*!< RTC backup register 25, Address offset: 0xB4 */ __IO uint32_t BKP26R; /*!< RTC backup register 26, Address offset: 0xB8 */ __IO uint32_t BKP27R; /*!< RTC backup register 27, Address offset: 0xBC */ __IO uint32_t BKP28R; /*!< RTC backup register 28, Address offset: 0xC0 */ __IO uint32_t BKP29R; /*!< RTC backup register 29, Address offset: 0xC4 */ __IO uint32_t BKP30R; /*!< RTC backup register 30, Address offset: 0xC8 */ __IO uint32_t BKP31R; /*!< RTC backup register 31, Address offset: 0xCC */ } RTC_TypeDef; /** * @brief Serial Audio Interface */ typedef struct { __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ uint32_t RESERVED0[16]; /*!< Reserved, 0x04 - 0x43 */ __IO uint32_t PDMCR; /*!< SAI PDM control register, Address offset: 0x44 */ __IO uint32_t PDMDLY; /*!< SAI PDM delay register, Address offset: 0x48 */ } SAI_TypeDef; typedef struct { __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ } SAI_Block_TypeDef; /** * @brief SPDIF-RX Interface */ typedef struct { __IO uint32_t CR; /*!< Control register, Address offset: 0x00 */ __IO uint32_t IMR; /*!< Interrupt mask register, Address offset: 0x04 */ __IO uint32_t SR; /*!< Status register, Address offset: 0x08 */ __IO uint32_t IFCR; /*!< Interrupt Flag Clear register, Address offset: 0x0C */ __IO uint32_t DR; /*!< Data input register, Address offset: 0x10 */ __IO uint32_t CSR; /*!< Channel Status register, Address offset: 0x14 */ __IO uint32_t DIR; /*!< Debug Information register, Address offset: 0x18 */ uint32_t RESERVED2; /*!< Reserved, 0x1A */ } SPDIFRX_TypeDef; /** * @brief Secure digital input/output Interface */ typedef struct { __IO uint32_t POWER; /*!< SDMMC power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDMMC clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDMMC argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDMMC command register, Address offset: 0x0C */ __I uint32_t RESPCMD; /*!< SDMMC command response register, Address offset: 0x10 */ __I uint32_t RESP1; /*!< SDMMC response 1 register, Address offset: 0x14 */ __I uint32_t RESP2; /*!< SDMMC response 2 register, Address offset: 0x18 */ __I uint32_t RESP3; /*!< SDMMC response 3 register, Address offset: 0x1C */ __I uint32_t RESP4; /*!< SDMMC response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDMMC data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDMMC data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDMMC data control register, Address offset: 0x2C */ __I uint32_t DCOUNT; /*!< SDMMC data counter register, Address offset: 0x30 */ __I uint32_t STA; /*!< SDMMC status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDMMC interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDMMC mask register, Address offset: 0x3C */ __IO uint32_t ACKTIME; /*!< SDMMC Acknowledgement timer register, Address offset: 0x40 */ uint32_t RESERVED0[3]; /*!< Reserved, 0x44 - 0x4C - 0x4C */ __IO uint32_t IDMACTRL; /*!< SDMMC DMA control register, Address offset: 0x50 */ __IO uint32_t IDMABSIZE; /*!< SDMMC DMA buffer size register, Address offset: 0x54 */ __IO uint32_t IDMABASE0; /*!< SDMMC DMA buffer 0 base address register, Address offset: 0x58 */ __IO uint32_t IDMABASE1; /*!< SDMMC DMA buffer 1 base address register, Address offset: 0x5C */ uint32_t RESERVED1[8]; /*!< Reserved, 0x60-0x7C */ __IO uint32_t FIFO; /*!< SDMMC data FIFO register, Address offset: 0x80 */ uint32_t RESERVED2[222]; /*!< Reserved, 0x84-0x3F8 */ __IO uint32_t IPVR; /*!< SDMMC data FIFO register, Address offset: 0x3FC */ } SDMMC_TypeDef; /** * @brief Delay Block DLYB */ typedef struct { __IO uint32_t CR; /*!< DELAY BLOCK control register, Address offset: 0x00 */ __IO uint32_t CFGR; /*!< DELAY BLOCK configuration register, Address offset: 0x04 */ } DLYB_TypeDef; /** * @brief HW Semaphore HSEM */ typedef struct { __IO uint32_t R[32]; /*!< 2-step write lock and read back registers, Address offset: 00h-7Ch */ __IO uint32_t RLR[32]; /*!< 1-step read lock registers, Address offset: 80h-FCh */ __IO uint32_t C1IER; /*!< HSEM Interrupt enable register , Address offset: 100h */ __IO uint32_t C1ICR; /*!< HSEM Interrupt clear register , Address offset: 104h */ __IO uint32_t C1ISR; /*!< HSEM Interrupt Status register , Address offset: 108h */ __IO uint32_t C1MISR; /*!< HSEM Interrupt Masked Status register , Address offset: 10Ch */ uint32_t Reserved[12]; /* Reserved Address offset: 110h-13Ch */ __IO uint32_t CR; /*!< HSEM Semaphore clear register , Address offset: 140h */ __IO uint32_t KEYR; /*!< HSEM Semaphore clear key register , Address offset: 144h */ } HSEM_TypeDef; typedef struct { __IO uint32_t IER; /*!< HSEM interrupt enable register , Address offset: 0h */ __IO uint32_t ICR; /*!< HSEM interrupt clear register , Address offset: 4h */ __IO uint32_t ISR; /*!< HSEM interrupt status register , Address offset: 8h */ __IO uint32_t MISR; /*!< HSEM masked interrupt status register , Address offset: Ch */ } HSEM_Common_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI/I2S Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI Control register 2, Address offset: 0x04 */ __IO uint32_t CFG1; /*!< SPI Configuration register 1, Address offset: 0x08 */ __IO uint32_t CFG2; /*!< SPI Configuration register 2, Address offset: 0x0C */ __IO uint32_t IER; /*!< SPI/I2S Interrupt Enable register, Address offset: 0x10 */ __IO uint32_t SR; /*!< SPI/I2S Status register, Address offset: 0x14 */ __IO uint32_t IFCR; /*!< SPI/I2S Interrupt/Status flags clear register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t TXDR; /*!< SPI/I2S Transmit data register, Address offset: 0x20 */ uint32_t RESERVED1[3]; /*!< Reserved, 0x24-0x2C */ __IO uint32_t RXDR; /*!< SPI/I2S Receive data register, Address offset: 0x30 */ uint32_t RESERVED2[3]; /*!< Reserved, 0x34-0x3C */ __IO uint32_t CRCPOLY; /*!< SPI CRC Polynomial register, Address offset: 0x40 */ __IO uint32_t TXCRC; /*!< SPI Transmitter CRC register, Address offset: 0x44 */ __IO uint32_t RXCRC; /*!< SPI Receiver CRC register, Address offset: 0x48 */ __IO uint32_t UDRDR; /*!< SPI Underrun data register, Address offset: 0x4C */ __IO uint32_t I2SCFGR; /*!< I2S Configuration register, Address offset: 0x50 */ } SPI_TypeDef; /** * @brief DTS */ typedef struct { __IO uint32_t CFGR1; /*!< DTS configuration register, Address offset: 0x00 */ uint32_t RESERVED0; /*!< Reserved, Address offset: 0x04 */ __IO uint32_t T0VALR1; /*!< DTS T0 Value register, Address offset: 0x08 */ uint32_t RESERVED1; /*!< Reserved, Address offset: 0x0C */ __IO uint32_t RAMPVALR; /*!< DTS Ramp value register, Address offset: 0x10 */ __IO uint32_t ITR1; /*!< DTS Interrupt threshold register, Address offset: 0x14 */ uint32_t RESERVED2; /*!< Reserved, Address offset: 0x18 */ __IO uint32_t DR; /*!< DTS data register, Address offset: 0x1C */ __IO uint32_t SR; /*!< DTS status register Address offset: 0x20 */ __IO uint32_t ITENR; /*!< DTS Interrupt enable register, Address offset: 0x24 */ __IO uint32_t ICIFR; /*!< DTS Clear Interrupt flag register, Address offset: 0x28 */ __IO uint32_t OR; /*!< DTS option register 1, Address offset: 0x2C */ } DTS_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ uint32_t RESERVED1; /*!< Reserved, 0x50 */ __IO uint32_t CCMR3; /*!< TIM capture/compare mode register 3, Address offset: 0x54 */ __IO uint32_t CCR5; /*!< TIM capture/compare register5, Address offset: 0x58 */ __IO uint32_t CCR6; /*!< TIM capture/compare register6, Address offset: 0x5C */ __IO uint32_t AF1; /*!< TIM alternate function option register 1, Address offset: 0x60 */ __IO uint32_t AF2; /*!< TIM alternate function option register 2, Address offset: 0x64 */ __IO uint32_t TISEL; /*!< TIM Input Selection register, Address offset: 0x68 */ } TIM_TypeDef; /** * @brief LPTIMIMER */ typedef struct { __IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */ __IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */ __IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */ __IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */ __IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */ __IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */ __IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */ __IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */ uint32_t RESERVED1; /*!< Reserved, 0x20 */ __IO uint32_t CFGR2; /*!< LPTIM Configuration register, Address offset: 0x24 */ } LPTIM_TypeDef; /** * @brief Comparator */ typedef struct { __IO uint32_t SR; /*!< Comparator status register, Address offset: 0x00 */ __IO uint32_t ICFR; /*!< Comparator interrupt clear flag register, Address offset: 0x04 */ __IO uint32_t OR; /*!< Comparator option register, Address offset: 0x08 */ } COMPOPT_TypeDef; typedef struct { __IO uint32_t CFGR; /*!< Comparator configuration register , Address offset: 0x00 */ } COMP_TypeDef; typedef struct { __IO uint32_t CFGR; /*!< COMP control and status register, used for bits common to several COMP instances, Address offset: 0x00 */ } COMP_Common_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x04 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x08 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x0C */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x10 */ __IO uint32_t RTOR; /*!< USART Receiver Time Out register, Address offset: 0x14 */ __IO uint32_t RQR; /*!< USART Request register, Address offset: 0x18 */ __IO uint32_t ISR; /*!< USART Interrupt and status register, Address offset: 0x1C */ __IO uint32_t ICR; /*!< USART Interrupt flag Clear register, Address offset: 0x20 */ __IO uint32_t RDR; /*!< USART Receive Data register, Address offset: 0x24 */ __IO uint32_t TDR; /*!< USART Transmit Data register, Address offset: 0x28 */ __IO uint32_t PRESC; /*!< USART clock Prescaler register, Address offset: 0x2C */ } USART_TypeDef; /** * @brief Single Wire Protocol Master Interface SPWMI */ typedef struct { __IO uint32_t CR; /*!< SWPMI Configuration/Control register, Address offset: 0x00 */ __IO uint32_t BRR; /*!< SWPMI bitrate register, Address offset: 0x04 */ uint32_t RESERVED1; /*!< Reserved, 0x08 */ __IO uint32_t ISR; /*!< SWPMI Interrupt and Status register, Address offset: 0x0C */ __IO uint32_t ICR; /*!< SWPMI Interrupt Flag Clear register, Address offset: 0x10 */ __IO uint32_t IER; /*!< SWPMI Interrupt Enable register, Address offset: 0x14 */ __IO uint32_t RFL; /*!< SWPMI Receive Frame Length register, Address offset: 0x18 */ __IO uint32_t TDR; /*!< SWPMI Transmit data register, Address offset: 0x1C */ __IO uint32_t RDR; /*!< SWPMI Receive data register, Address offset: 0x20 */ __IO uint32_t OR; /*!< SWPMI Option register, Address offset: 0x24 */ } SWPMI_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RAM_ECC_Specific_Registers */ typedef struct { __IO uint32_t CR; /*!< RAMECC monitor configuration register */ __IO uint32_t SR; /*!< RAMECC monitor status register */ __IO uint32_t FAR; /*!< RAMECC monitor failing address register */ __IO uint32_t FDRL; /*!< RAMECC monitor failing data low register */ __IO uint32_t FDRH; /*!< RAMECC monitor failing data high register */ __IO uint32_t FECR; /*!< RAMECC monitor failing ECC error code register */ } RAMECC_MonitorTypeDef; typedef struct { __IO uint32_t IER; /*!< RAMECC interrupt enable register */ } RAMECC_TypeDef; /** * @} */ /** * @brief Crypto Processor */ typedef struct { __IO uint32_t CR; /*!< CRYP control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< CRYP status register, Address offset: 0x04 */ __IO uint32_t DIN; /*!< CRYP data input register, Address offset: 0x08 */ __IO uint32_t DOUT; /*!< CRYP data output register, Address offset: 0x0C */ __IO uint32_t DMACR; /*!< CRYP DMA control register, Address offset: 0x10 */ __IO uint32_t IMSCR; /*!< CRYP interrupt mask set/clear register, Address offset: 0x14 */ __IO uint32_t RISR; /*!< CRYP raw interrupt status register, Address offset: 0x18 */ __IO uint32_t MISR; /*!< CRYP masked interrupt status register, Address offset: 0x1C */ __IO uint32_t K0LR; /*!< CRYP key left register 0, Address offset: 0x20 */ __IO uint32_t K0RR; /*!< CRYP key right register 0, Address offset: 0x24 */ __IO uint32_t K1LR; /*!< CRYP key left register 1, Address offset: 0x28 */ __IO uint32_t K1RR; /*!< CRYP key right register 1, Address offset: 0x2C */ __IO uint32_t K2LR; /*!< CRYP key left register 2, Address offset: 0x30 */ __IO uint32_t K2RR; /*!< CRYP key right register 2, Address offset: 0x34 */ __IO uint32_t K3LR; /*!< CRYP key left register 3, Address offset: 0x38 */ __IO uint32_t K3RR; /*!< CRYP key right register 3, Address offset: 0x3C */ __IO uint32_t IV0LR; /*!< CRYP initialization vector left-word register 0, Address offset: 0x40 */ __IO uint32_t IV0RR; /*!< CRYP initialization vector right-word register 0, Address offset: 0x44 */ __IO uint32_t IV1LR; /*!< CRYP initialization vector left-word register 1, Address offset: 0x48 */ __IO uint32_t IV1RR; /*!< CRYP initialization vector right-word register 1, Address offset: 0x4C */ __IO uint32_t CSGCMCCM0R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 0, Address offset: 0x50 */ __IO uint32_t CSGCMCCM1R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 1, Address offset: 0x54 */ __IO uint32_t CSGCMCCM2R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 2, Address offset: 0x58 */ __IO uint32_t CSGCMCCM3R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 3, Address offset: 0x5C */ __IO uint32_t CSGCMCCM4R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 4, Address offset: 0x60 */ __IO uint32_t CSGCMCCM5R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 5, Address offset: 0x64 */ __IO uint32_t CSGCMCCM6R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 6, Address offset: 0x68 */ __IO uint32_t CSGCMCCM7R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 7, Address offset: 0x6C */ __IO uint32_t CSGCM0R; /*!< CRYP GCM/GMAC context swap register 0, Address offset: 0x70 */ __IO uint32_t CSGCM1R; /*!< CRYP GCM/GMAC context swap register 1, Address offset: 0x74 */ __IO uint32_t CSGCM2R; /*!< CRYP GCM/GMAC context swap register 2, Address offset: 0x78 */ __IO uint32_t CSGCM3R; /*!< CRYP GCM/GMAC context swap register 3, Address offset: 0x7C */ __IO uint32_t CSGCM4R; /*!< CRYP GCM/GMAC context swap register 4, Address offset: 0x80 */ __IO uint32_t CSGCM5R; /*!< CRYP GCM/GMAC context swap register 5, Address offset: 0x84 */ __IO uint32_t CSGCM6R; /*!< CRYP GCM/GMAC context swap register 6, Address offset: 0x88 */ __IO uint32_t CSGCM7R; /*!< CRYP GCM/GMAC context swap register 7, Address offset: 0x8C */ } CRYP_TypeDef; /** * @brief HASH */ typedef struct { __IO uint32_t CR; /*!< HASH control register, Address offset: 0x00 */ __IO uint32_t DIN; /*!< HASH data input register, Address offset: 0x04 */ __IO uint32_t STR; /*!< HASH start register, Address offset: 0x08 */ __IO uint32_t HR[5]; /*!< HASH digest registers, Address offset: 0x0C-0x1C */ __IO uint32_t IMR; /*!< HASH interrupt enable register, Address offset: 0x20 */ __IO uint32_t SR; /*!< HASH status register, Address offset: 0x24 */ uint32_t RESERVED[52]; /*!< Reserved, 0x28-0xF4 */ __IO uint32_t CSR[54]; /*!< HASH context swap registers, Address offset: 0x0F8-0x1CC */ } HASH_TypeDef; /** * @brief HASH_DIGEST */ typedef struct { __IO uint32_t HR[8]; /*!< HASH digest registers, Address offset: 0x310-0x32C */ } HASH_DIGEST_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ uint32_t RESERVED; __IO uint32_t HTCR; /*!< RNG health test configuration register, Address offset: 0x10 */ } RNG_TypeDef; /** * @brief MDIOS */ typedef struct { __IO uint32_t CR; __IO uint32_t WRFR; __IO uint32_t CWRFR; __IO uint32_t RDFR; __IO uint32_t CRDFR; __IO uint32_t SR; __IO uint32_t CLRFR; uint32_t RESERVED[57]; __IO uint32_t DINR0; __IO uint32_t DINR1; __IO uint32_t DINR2; __IO uint32_t DINR3; __IO uint32_t DINR4; __IO uint32_t DINR5; __IO uint32_t DINR6; __IO uint32_t DINR7; __IO uint32_t DINR8; __IO uint32_t DINR9; __IO uint32_t DINR10; __IO uint32_t DINR11; __IO uint32_t DINR12; __IO uint32_t DINR13; __IO uint32_t DINR14; __IO uint32_t DINR15; __IO uint32_t DINR16; __IO uint32_t DINR17; __IO uint32_t DINR18; __IO uint32_t DINR19; __IO uint32_t DINR20; __IO uint32_t DINR21; __IO uint32_t DINR22; __IO uint32_t DINR23; __IO uint32_t DINR24; __IO uint32_t DINR25; __IO uint32_t DINR26; __IO uint32_t DINR27; __IO uint32_t DINR28; __IO uint32_t DINR29; __IO uint32_t DINR30; __IO uint32_t DINR31; __IO uint32_t DOUTR0; __IO uint32_t DOUTR1; __IO uint32_t DOUTR2; __IO uint32_t DOUTR3; __IO uint32_t DOUTR4; __IO uint32_t DOUTR5; __IO uint32_t DOUTR6; __IO uint32_t DOUTR7; __IO uint32_t DOUTR8; __IO uint32_t DOUTR9; __IO uint32_t DOUTR10; __IO uint32_t DOUTR11; __IO uint32_t DOUTR12; __IO uint32_t DOUTR13; __IO uint32_t DOUTR14; __IO uint32_t DOUTR15; __IO uint32_t DOUTR16; __IO uint32_t DOUTR17; __IO uint32_t DOUTR18; __IO uint32_t DOUTR19; __IO uint32_t DOUTR20; __IO uint32_t DOUTR21; __IO uint32_t DOUTR22; __IO uint32_t DOUTR23; __IO uint32_t DOUTR24; __IO uint32_t DOUTR25; __IO uint32_t DOUTR26; __IO uint32_t DOUTR27; __IO uint32_t DOUTR28; __IO uint32_t DOUTR29; __IO uint32_t DOUTR30; __IO uint32_t DOUTR31; } MDIOS_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ __IO uint32_t GSNPSID; /* USB_OTG core ID 040h*/ __IO uint32_t GHWCFG1; /* User HW config1 044h*/ __IO uint32_t GHWCFG2; /* User HW config2 048h*/ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ __IO uint32_t GPWRDN; /*!< Power Down Register 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ __IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */ uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** * @brief OCTO Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< OCTOSPI Control register, Address offset: 0x000 */ uint32_t RESERVED; /*!< Reserved, Address offset: 0x004 */ __IO uint32_t DCR1; /*!< OCTOSPI Device Configuration register 1, Address offset: 0x008 */ __IO uint32_t DCR2; /*!< OCTOSPI Device Configuration register 2, Address offset: 0x00C */ __IO uint32_t DCR3; /*!< OCTOSPI Device Configuration register 3, Address offset: 0x010 */ __IO uint32_t DCR4; /*!< OCTOSPI Device Configuration register 4, Address offset: 0x014 */ uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x018-0x01C */ __IO uint32_t SR; /*!< OCTOSPI Status register, Address offset: 0x020 */ __IO uint32_t FCR; /*!< OCTOSPI Flag Clear register, Address offset: 0x024 */ uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x028-0x03C */ __IO uint32_t DLR; /*!< OCTOSPI Data Length register, Address offset: 0x040 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x044 */ __IO uint32_t AR; /*!< OCTOSPI Address register, Address offset: 0x048 */ uint32_t RESERVED4; /*!< Reserved, Address offset: 0x04C */ __IO uint32_t DR; /*!< OCTOSPI Data register, Address offset: 0x050 */ uint32_t RESERVED5[11]; /*!< Reserved, Address offset: 0x054-0x07C */ __IO uint32_t PSMKR; /*!< OCTOSPI Polling Status Mask register, Address offset: 0x080 */ uint32_t RESERVED6; /*!< Reserved, Address offset: 0x084 */ __IO uint32_t PSMAR; /*!< OCTOSPI Polling Status Match register, Address offset: 0x088 */ uint32_t RESERVED7; /*!< Reserved, Address offset: 0x08C */ __IO uint32_t PIR; /*!< OCTOSPI Polling Interval register, Address offset: 0x090 */ uint32_t RESERVED8[27]; /*!< Reserved, Address offset: 0x094-0x0FC */ __IO uint32_t CCR; /*!< OCTOSPI Communication Configuration register, Address offset: 0x100 */ uint32_t RESERVED9; /*!< Reserved, Address offset: 0x104 */ __IO uint32_t TCR; /*!< OCTOSPI Timing Configuration register, Address offset: 0x108 */ uint32_t RESERVED10; /*!< Reserved, Address offset: 0x10C */ __IO uint32_t IR; /*!< OCTOSPI Instruction register, Address offset: 0x110 */ uint32_t RESERVED11[3]; /*!< Reserved, Address offset: 0x114-0x11C */ __IO uint32_t ABR; /*!< OCTOSPI Alternate Bytes register, Address offset: 0x120 */ uint32_t RESERVED12[3]; /*!< Reserved, Address offset: 0x124-0x12C */ __IO uint32_t LPTR; /*!< OCTOSPI Low Power Timeout register, Address offset: 0x130 */ uint32_t RESERVED13[3]; /*!< Reserved, Address offset: 0x134-0x13C */ __IO uint32_t WPCCR; /*!< OCTOSPI Wrap Communication Configuration register, Address offset: 0x140 */ uint32_t RESERVED14; /*!< Reserved, Address offset: 0x144 */ __IO uint32_t WPTCR; /*!< OCTOSPI Wrap Timing Configuration register, Address offset: 0x148 */ uint32_t RESERVED15; /*!< Reserved, Address offset: 0x14C */ __IO uint32_t WPIR; /*!< OCTOSPI Wrap Instruction register, Address offset: 0x150 */ uint32_t RESERVED16[3]; /*!< Reserved, Address offset: 0x154-0x15C */ __IO uint32_t WPABR; /*!< OCTOSPI Wrap Alternate Bytes register, Address offset: 0x160 */ uint32_t RESERVED17[7]; /*!< Reserved, Address offset: 0x164-0x17C */ __IO uint32_t WCCR; /*!< OCTOSPI Write Communication Configuration register, Address offset: 0x180 */ uint32_t RESERVED18; /*!< Reserved, Address offset: 0x184 */ __IO uint32_t WTCR; /*!< OCTOSPI Write Timing Configuration register, Address offset: 0x188 */ uint32_t RESERVED19; /*!< Reserved, Address offset: 0x18C */ __IO uint32_t WIR; /*!< OCTOSPI Write Instruction register, Address offset: 0x190 */ uint32_t RESERVED20[3]; /*!< Reserved, Address offset: 0x194-0x19C */ __IO uint32_t WABR; /*!< OCTOSPI Write Alternate Bytes register, Address offset: 0x1A0 */ uint32_t RESERVED21[23]; /*!< Reserved, Address offset: 0x1A4-0x1FC */ __IO uint32_t HLCR; /*!< OCTOSPI Hyperbus Latency Configuration register, Address offset: 0x200 */ uint32_t RESERVED22[122]; /*!< Reserved, Address offset: 0x204-0x3EC */ __IO uint32_t HWCFGR; /*!< OCTOSPI HW Configuration register, Address offset: 0x3F0 */ __IO uint32_t VER; /*!< OCTOSPI Version register, Address offset: 0x3F4 */ __IO uint32_t ID; /*!< OCTOSPI Identification register, Address offset: 0x3F8 */ __IO uint32_t MID; /*!< OCTOPSI HW Magic ID register, Address offset: 0x3FC */ } OCTOSPI_TypeDef; /** * @} */ /** * @brief OCTO Serial Peripheral Interface IO Manager */ typedef struct { __IO uint32_t CR; /*!< OCTOSPI IO Manager Control register, Address offset: 0x00 */ __IO uint32_t PCR[3]; /*!< OCTOSPI IO Manager Port[1:3] Configuration register, Address offset: 0x04-0x20 */ } OCTOSPIM_TypeDef; /** * @} */ /** * @brief OTFD register */ typedef struct { __IO uint32_t REG_CONFIGR; __IO uint32_t REG_START_ADDR; __IO uint32_t REG_END_ADDR; __IO uint32_t REG_NONCER0; __IO uint32_t REG_NONCER1; __IO uint32_t REG_KEYR0; __IO uint32_t REG_KEYR1; __IO uint32_t REG_KEYR2; __IO uint32_t REG_KEYR3; } OTFDEC_Region_TypeDef; typedef struct { __IO uint32_t CR; uint32_t RESERVED1[191]; __IO uint32_t ISR; __IO uint32_t ICR; __IO uint32_t IER; uint32_t RESERVED2[56]; __IO uint32_t HWCFGR2; __IO uint32_t HWCFGR1; __IO uint32_t VERR; __IO uint32_t IPIDR; __IO uint32_t SIDR; } OTFDEC_TypeDef; /** * @} */ /** * @brief Global Programmer View */ typedef struct { uint32_t RESERVED0[2036]; /*!< Reserved, Address offset: 0x00-0x1FCC */ __IO uint32_t AXI_PERIPH_ID_4; /*!< AXI interconnect - peripheral ID4 register, Address offset: 0x1FD0 */ uint32_t AXI_PERIPH_ID_5; /*!< Reserved, Address offset: 0x1FD4 */ uint32_t AXI_PERIPH_ID_6; /*!< Reserved, Address offset: 0x1FD8 */ uint32_t AXI_PERIPH_ID_7; /*!< Reserved, Address offset: 0x1FDC */ __IO uint32_t AXI_PERIPH_ID_0; /*!< AXI interconnect - peripheral ID0 register, Address offset: 0x1FE0 */ __IO uint32_t AXI_PERIPH_ID_1; /*!< AXI interconnect - peripheral ID1 register, Address offset: 0x1FE4 */ __IO uint32_t AXI_PERIPH_ID_2; /*!< AXI interconnect - peripheral ID2 register, Address offset: 0x1FE8 */ __IO uint32_t AXI_PERIPH_ID_3; /*!< AXI interconnect - peripheral ID3 register, Address offset: 0x1FEC */ __IO uint32_t AXI_COMP_ID_0; /*!< AXI interconnect - component ID0 register, Address offset: 0x1FF0 */ __IO uint32_t AXI_COMP_ID_1; /*!< AXI interconnect - component ID1 register, Address offset: 0x1FF4 */ __IO uint32_t AXI_COMP_ID_2; /*!< AXI interconnect - component ID2 register, Address offset: 0x1FF8 */ __IO uint32_t AXI_COMP_ID_3; /*!< AXI interconnect - component ID3 register, Address offset: 0x1FFC */ uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x2000-0x2004 */ __IO uint32_t AXI_TARG1_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 1 bus matrix issuing functionality register, Address offset: 0x2008 */ uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x200C-0x2020 */ __IO uint32_t AXI_TARG1_FN_MOD2; /*!< AXI interconnect - TARG 1 bus matrix functionality 2 register, Address offset: 0x2024 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2028 */ __IO uint32_t AXI_TARG1_FN_MOD_LB; /*!< AXI interconnect - TARG 1 long burst functionality modification register, Address offset: 0x202C */ uint32_t RESERVED4[54]; /*!< Reserved, Address offset: 0x2030-0x2104 */ __IO uint32_t AXI_TARG1_FN_MOD; /*!< AXI interconnect - TARG 1 issuing functionality modification register, Address offset: 0x2108 */ uint32_t RESERVED5[959]; /*!< Reserved, Address offset: 0x210C-0x3004 */ __IO uint32_t AXI_TARG2_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 2 bus matrix issuing functionality register, Address offset: 0x3008 */ uint32_t RESERVED6[6]; /*!< Reserved, Address offset: 0x300C-0x3020 */ __IO uint32_t AXI_TARG2_FN_MOD2; /*!< AXI interconnect - TARG 2 bus matrix functionality 2 register, Address offset: 0x3024 */ uint32_t RESERVED7; /*!< Reserved, Address offset: 0x3028 */ __IO uint32_t AXI_TARG2_FN_MOD_LB; /*!< AXI interconnect - TARG 2 long burst functionality modification register, Address offset: 0x302C */ uint32_t RESERVED8[54]; /*!< Reserved, Address offset: 0x3030-0x3104 */ __IO uint32_t AXI_TARG2_FN_MOD; /*!< AXI interconnect - TARG 2 issuing functionality modification register, Address offset: 0x3108 */ uint32_t RESERVED9[959]; /*!< Reserved, Address offset: 0x310C-0x4004 */ __IO uint32_t AXI_TARG3_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 3 bus matrix issuing functionality register, Address offset: 0x4008 */ uint32_t RESERVED10[1023]; /*!< Reserved, Address offset: 0x400C-0x5004 */ __IO uint32_t AXI_TARG4_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 4 bus matrix issuing functionality register, Address offset: 0x5008 */ uint32_t RESERVED11[1023]; /*!< Reserved, Address offset: 0x500C-0x6004 */ __IO uint32_t AXI_TARG5_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 5 bus matrix issuing functionality register, Address offset: 0x6008 */ uint32_t RESERVED12[1023]; /*!< Reserved, Address offset: 0x600C-0x7004 */ __IO uint32_t AXI_TARG6_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 6 bus matrix issuing functionality register, Address offset: 0x7008 */ uint32_t RESERVED13[1023]; /*!< Reserved, Address offset: 0x700C-0x8004 */ __IO uint32_t AXI_TARG7_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 7 bus matrix issuing functionality register, Address offset: 0x8008 */ uint32_t RESERVED14[6]; /*!< Reserved, Address offset: 0x800C-0x8020 */ __IO uint32_t AXI_TARG7_FN_MOD2; /*!< AXI interconnect - TARG 7 bus matrix functionality 2 register, Address offset: 0x8024 */ uint32_t RESERVED15; /*!< Reserved, Address offset: 0x8028 */ __IO uint32_t AXI_TARG7_FN_MOD_LB; /*!< AXI interconnect - TARG 7 long burst functionality modification register, Address offset: 0x802C */ uint32_t RESERVED16[54]; /*!< Reserved, Address offset: 0x8030-0x8104 */ __IO uint32_t AXI_TARG7_FN_MOD; /*!< AXI interconnect - TARG 7 issuing functionality modification register, Address offset: 0x8108 */ uint32_t RESERVED17[959]; /*!< Reserved, Address offset: 0x810C-0x9004 */ __IO uint32_t AXI_TARG8_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 8 bus matrix issuing functionality register, Address offset: 0x9008 */ uint32_t RESERVED117[6]; /*!< Reserved, Address offset: 0x900C-0x9020 */ __IO uint32_t AXI_TARG8_FN_MOD2; /*!< AXI interconnect - TARG 8 bus matrix functionality 2 register, Address offset: 0x9024 */ uint32_t RESERVED118[56]; /*!< Reserved, Address offset: 0x9028-0x9104 */ __IO uint32_t AXI_TARG8_FN_MOD; /*!< AXI interconnect - TARG 8 issuing functionality modification register, Address offset: 0x9108 */ uint32_t RESERVED119[58310]; /*!< Reserved, Address offset: 0x910C-0x42020 */ __IO uint32_t AXI_INI1_FN_MOD2; /*!< AXI interconnect - INI 1 functionality modification 2 register, Address offset: 0x42024 */ __IO uint32_t AXI_INI1_FN_MOD_AHB; /*!< AXI interconnect - INI 1 AHB functionality modification register, Address offset: 0x42028 */ uint32_t RESERVED18[53]; /*!< Reserved, Address offset: 0x4202C-0x420FC */ __IO uint32_t AXI_INI1_READ_QOS; /*!< AXI interconnect - INI 1 read QoS register, Address offset: 0x42100 */ __IO uint32_t AXI_INI1_WRITE_QOS; /*!< AXI interconnect - INI 1 write QoS register, Address offset: 0x42104 */ __IO uint32_t AXI_INI1_FN_MOD; /*!< AXI interconnect - INI 1 issuing functionality modification register, Address offset: 0x42108 */ uint32_t RESERVED19[1021]; /*!< Reserved, Address offset: 0x4210C-0x430FC */ __IO uint32_t AXI_INI2_READ_QOS; /*!< AXI interconnect - INI 2 read QoS register, Address offset: 0x43100 */ __IO uint32_t AXI_INI2_WRITE_QOS; /*!< AXI interconnect - INI 2 write QoS register, Address offset: 0x43104 */ __IO uint32_t AXI_INI2_FN_MOD; /*!< AXI interconnect - INI 2 issuing functionality modification register, Address offset: 0x43108 */ uint32_t RESERVED20[966]; /*!< Reserved, Address offset: 0x4310C-0x44020 */ __IO uint32_t AXI_INI3_FN_MOD2; /*!< AXI interconnect - INI 3 functionality modification 2 register, Address offset: 0x44024 */ __IO uint32_t AXI_INI3_FN_MOD_AHB; /*!< AXI interconnect - INI 3 AHB functionality modification register, Address offset: 0x44028 */ uint32_t RESERVED21[53]; /*!< Reserved, Address offset: 0x4402C-0x440FC */ __IO uint32_t AXI_INI3_READ_QOS; /*!< AXI interconnect - INI 3 read QoS register, Address offset: 0x44100 */ __IO uint32_t AXI_INI3_WRITE_QOS; /*!< AXI interconnect - INI 3 write QoS register, Address offset: 0x44104 */ __IO uint32_t AXI_INI3_FN_MOD; /*!< AXI interconnect - INI 3 issuing functionality modification register, Address offset: 0x44108 */ uint32_t RESERVED22[1021]; /*!< Reserved, Address offset: 0x4410C-0x450FC */ __IO uint32_t AXI_INI4_READ_QOS; /*!< AXI interconnect - INI 4 read QoS register, Address offset: 0x45100 */ __IO uint32_t AXI_INI4_WRITE_QOS; /*!< AXI interconnect - INI 4 write QoS register, Address offset: 0x45104 */ __IO uint32_t AXI_INI4_FN_MOD; /*!< AXI interconnect - INI 4 issuing functionality modification register, Address offset: 0x45108 */ uint32_t RESERVED23[1021]; /*!< Reserved, Address offset: 0x4510C-0x460FC */ __IO uint32_t AXI_INI5_READ_QOS; /*!< AXI interconnect - INI 5 read QoS register, Address offset: 0x46100 */ __IO uint32_t AXI_INI5_WRITE_QOS; /*!< AXI interconnect - INI 5 write QoS register, Address offset: 0x46104 */ __IO uint32_t AXI_INI5_FN_MOD; /*!< AXI interconnect - INI 5 issuing functionality modification register, Address offset: 0x46108 */ uint32_t RESERVED24[1021]; /*!< Reserved, Address offset: 0x4610C-0x470FC */ __IO uint32_t AXI_INI6_READ_QOS; /*!< AXI interconnect - INI 6 read QoS register, Address offset: 0x47100 */ __IO uint32_t AXI_INI6_WRITE_QOS; /*!< AXI interconnect - INI 6 write QoS register, Address offset: 0x47104 */ __IO uint32_t AXI_INI6_FN_MOD; /*!< AXI interconnect - INI 6 issuing functionality modification register, Address offset: 0x47108 */ } GPV_TypeDef; /** @addtogroup Peripheral_memory_map * @{ */ #define D1_ITCMRAM_BASE (0x00000000UL) /*!< Base address of : 64KB RAM reserved for CPU execution/instruction accessible over ITCM */ #define D1_ITCMICP_BASE (0x00100000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over ITCM */ #define D1_DTCMRAM_BASE (0x20000000UL) /*!< Base address of : 128KB system data RAM accessible over DTCM */ #define D1_AXIFLASH_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) embedded FLASH memory accessible over AXI */ #define D1_AXIICP_BASE (0x1FF00000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over AXI */ #define D1_AXISRAM1_BASE (0x24000000UL) /*!< Base address of : (up to 128KB) system data RAM1 accessible over over AXI */ #define D1_AXISRAM2_BASE (0x24020000UL) /*!< Base address of : (up to 192KB) system data RAM2 accessible over over AXI to be shared with ITCM (64K granularity) */ #define D1_AXISRAM_BASE D1_AXISRAM1_BASE /*!< Base address of : (up to 320KB) system data RAM1/2 accessible over over AXI */ #define D2_AHBSRAM1_BASE (0x30000000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ #define D2_AHBSRAM2_BASE (0x30004000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ #define D2_AHBSRAM_BASE D2_AHBSRAM1_BASE /*!< Base address of : (up to 32KB) system data RAM1/2 accessible over over AXI->AHB Bridge */ #define D3_BKPSRAM_BASE (0x38800000UL) /*!< Base address of : Backup SRAM(4 KB) over AXI->AHB Bridge */ #define D3_SRAM_BASE (0x38000000UL) /*!< Base address of : Backup SRAM(16 KB) over AXI->AHB Bridge */ #define PERIPH_BASE (0x40000000UL) /*!< Base address of : AHB/APB Peripherals */ #define OCTOSPI1_BASE (0x90000000UL) /*!< Base address of : OCTOSPI1 memories accessible over AXI */ #define OCTOSPI2_BASE (0x70000000UL) /*!< Base address of : OCTOSPI2 memories accessible over AXI */ #define FLASH_BANK1_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) Flash Bank1 accessible over AXI */ #define FLASH_END (0x080FFFFFUL) /*!< FLASH end address */ /* Legacy define */ #define FLASH_BASE FLASH_BANK1_BASE /*!< Device electronic signature memory map */ #define UID_BASE (0x1FF1E800UL) /*!< Unique device ID register base address */ #define FLASHSIZE_BASE (0x1FF1E880UL) /*!< FLASH Size register base address */ /*!< Peripheral memory map */ #define D2_APB1PERIPH_BASE PERIPH_BASE #define D2_APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define D2_AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define D2_AHB2PERIPH_BASE (PERIPH_BASE + 0x08020000UL) #define D1_APB1PERIPH_BASE (PERIPH_BASE + 0x10000000UL) #define D1_AHB1PERIPH_BASE (PERIPH_BASE + 0x12000000UL) #define D3_APB1PERIPH_BASE (PERIPH_BASE + 0x18000000UL) #define D3_AHB1PERIPH_BASE (PERIPH_BASE + 0x18020000UL) /*!< Legacy Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x08000000UL) /*!< D1_AHB1PERIPH peripherals */ #define MDMA_BASE (D1_AHB1PERIPH_BASE + 0x0000UL) #define DMA2D_BASE (D1_AHB1PERIPH_BASE + 0x1000UL) #define FLASH_R_BASE (D1_AHB1PERIPH_BASE + 0x2000UL) #define FMC_R_BASE (D1_AHB1PERIPH_BASE + 0x4000UL) #define OCTOSPI1_R_BASE (D1_AHB1PERIPH_BASE + 0x5000UL) #define DLYB_OCTOSPI1_BASE (D1_AHB1PERIPH_BASE + 0x6000UL) #define SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x7000UL) #define DLYB_SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x8000UL) #define RAMECC1_BASE (D1_AHB1PERIPH_BASE + 0x9000UL) #define OCTOSPI2_R_BASE (D1_AHB1PERIPH_BASE + 0xA000UL) #define DLYB_OCTOSPI2_BASE (D1_AHB1PERIPH_BASE + 0xB000UL) #define OCTOSPIM_BASE (D1_AHB1PERIPH_BASE + 0xB400UL) #define OTFDEC1_BASE (D1_AHB1PERIPH_BASE + 0xB800UL) #define OTFDEC1_REGION1_BASE (OTFDEC1_BASE + 0x20UL) #define OTFDEC1_REGION2_BASE (OTFDEC1_BASE + 0x50UL) #define OTFDEC1_REGION3_BASE (OTFDEC1_BASE + 0x80UL) #define OTFDEC1_REGION4_BASE (OTFDEC1_BASE + 0xB0UL) #define OTFDEC2_BASE (D1_AHB1PERIPH_BASE + 0xBC00UL) #define OTFDEC2_REGION1_BASE (OTFDEC2_BASE + 0x20UL) #define OTFDEC2_REGION2_BASE (OTFDEC2_BASE + 0x50UL) #define OTFDEC2_REGION3_BASE (OTFDEC2_BASE + 0x80UL) #define OTFDEC2_REGION4_BASE (OTFDEC2_BASE + 0xB0UL) /*!< D2_AHB1PERIPH peripherals */ #define DMA1_BASE (D2_AHB1PERIPH_BASE + 0x0000UL) #define DMA2_BASE (D2_AHB1PERIPH_BASE + 0x0400UL) #define DMAMUX1_BASE (D2_AHB1PERIPH_BASE + 0x0800UL) #define ADC1_BASE (D2_AHB1PERIPH_BASE + 0x2000UL) #define ADC2_BASE (D2_AHB1PERIPH_BASE + 0x2100UL) #define ADC12_COMMON_BASE (D2_AHB1PERIPH_BASE + 0x2300UL) #define ETH_BASE (D2_AHB1PERIPH_BASE + 0x8000UL) #define ETH_MAC_BASE (ETH_BASE) /*!< USB registers base address */ #define USB1_OTG_HS_PERIPH_BASE (0x40040000UL) #define USB_OTG_GLOBAL_BASE (0x000UL) #define USB_OTG_DEVICE_BASE (0x800UL) #define USB_OTG_IN_ENDPOINT_BASE (0x900UL) #define USB_OTG_OUT_ENDPOINT_BASE (0xB00UL) #define USB_OTG_EP_REG_SIZE (0x20UL) #define USB_OTG_HOST_BASE (0x400UL) #define USB_OTG_HOST_PORT_BASE (0x440UL) #define USB_OTG_HOST_CHANNEL_BASE (0x500UL) #define USB_OTG_HOST_CHANNEL_SIZE (0x20UL) #define USB_OTG_PCGCCTL_BASE (0xE00UL) #define USB_OTG_FIFO_BASE (0x1000UL) #define USB_OTG_FIFO_SIZE (0x1000UL) /*!< D2_AHB2PERIPH peripherals */ #define DCMI_BASE (D2_AHB2PERIPH_BASE + 0x0000UL) #define PSSI_BASE (D2_AHB2PERIPH_BASE + 0x0400UL) #define CRYP_BASE (D2_AHB2PERIPH_BASE + 0x1000UL) #define HASH_BASE (D2_AHB2PERIPH_BASE + 0x1400UL) #define HASH_DIGEST_BASE (D2_AHB2PERIPH_BASE + 0x1710UL) #define RNG_BASE (D2_AHB2PERIPH_BASE + 0x1800UL) #define SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2400UL) #define DLYB_SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2800UL) #define RAMECC2_BASE (D2_AHB2PERIPH_BASE + 0x3000UL) #define FMAC_BASE (D2_AHB2PERIPH_BASE + 0x4000UL) #define CORDIC_BASE (D2_AHB2PERIPH_BASE + 0x4400UL) /*!< D3_AHB1PERIPH peripherals */ #define GPIOA_BASE (D3_AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (D3_AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (D3_AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (D3_AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (D3_AHB1PERIPH_BASE + 0x1000UL) #define GPIOF_BASE (D3_AHB1PERIPH_BASE + 0x1400UL) #define GPIOG_BASE (D3_AHB1PERIPH_BASE + 0x1800UL) #define GPIOH_BASE (D3_AHB1PERIPH_BASE + 0x1C00UL) #define GPIOJ_BASE (D3_AHB1PERIPH_BASE + 0x2400UL) #define GPIOK_BASE (D3_AHB1PERIPH_BASE + 0x2800UL) #define RCC_BASE (D3_AHB1PERIPH_BASE + 0x4400UL) #define PWR_BASE (D3_AHB1PERIPH_BASE + 0x4800UL) #define CRC_BASE (D3_AHB1PERIPH_BASE + 0x4C00UL) #define BDMA_BASE (D3_AHB1PERIPH_BASE + 0x5400UL) #define DMAMUX2_BASE (D3_AHB1PERIPH_BASE + 0x5800UL) #define ADC3_BASE (D3_AHB1PERIPH_BASE + 0x6000UL) #define ADC3_COMMON_BASE (D3_AHB1PERIPH_BASE + 0x6300UL) #define HSEM_BASE (D3_AHB1PERIPH_BASE + 0x6400UL) #define RAMECC3_BASE (D3_AHB1PERIPH_BASE + 0x7000UL) /*!< D1_APB1PERIPH peripherals */ #define LTDC_BASE (D1_APB1PERIPH_BASE + 0x1000UL) #define LTDC_Layer1_BASE (LTDC_BASE + 0x84UL) #define LTDC_Layer2_BASE (LTDC_BASE + 0x104UL) #define WWDG1_BASE (D1_APB1PERIPH_BASE + 0x3000UL) /*!< D2_APB1PERIPH peripherals */ #define TIM2_BASE (D2_APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (D2_APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (D2_APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (D2_APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (D2_APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (D2_APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (D2_APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (D2_APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (D2_APB1PERIPH_BASE + 0x2000UL) #define LPTIM1_BASE (D2_APB1PERIPH_BASE + 0x2400UL) #define SPI2_BASE (D2_APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (D2_APB1PERIPH_BASE + 0x3C00UL) #define SPDIFRX_BASE (D2_APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (D2_APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (D2_APB1PERIPH_BASE + 0x4800UL) #define UART4_BASE (D2_APB1PERIPH_BASE + 0x4C00UL) #define UART5_BASE (D2_APB1PERIPH_BASE + 0x5000UL) #define I2C1_BASE (D2_APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (D2_APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (D2_APB1PERIPH_BASE + 0x5C00UL) #define I2C5_BASE (D2_APB1PERIPH_BASE + 0x6400UL) #define CEC_BASE (D2_APB1PERIPH_BASE + 0x6C00UL) #define DAC1_BASE (D2_APB1PERIPH_BASE + 0x7400UL) #define UART7_BASE (D2_APB1PERIPH_BASE + 0x7800UL) #define UART8_BASE (D2_APB1PERIPH_BASE + 0x7C00UL) #define CRS_BASE (D2_APB1PERIPH_BASE + 0x8400UL) #define SWPMI1_BASE (D2_APB1PERIPH_BASE + 0x8800UL) #define OPAMP_BASE (D2_APB1PERIPH_BASE + 0x9000UL) #define OPAMP1_BASE (D2_APB1PERIPH_BASE + 0x9000UL) #define OPAMP2_BASE (D2_APB1PERIPH_BASE + 0x9010UL) #define MDIOS_BASE (D2_APB1PERIPH_BASE + 0x9400UL) #define FDCAN1_BASE (D2_APB1PERIPH_BASE + 0xA000UL) #define FDCAN2_BASE (D2_APB1PERIPH_BASE + 0xA400UL) #define FDCAN_CCU_BASE (D2_APB1PERIPH_BASE + 0xA800UL) #define SRAMCAN_BASE (D2_APB1PERIPH_BASE + 0xAC00UL) #define FDCAN3_BASE (D2_APB1PERIPH_BASE + 0xD400UL) #define TIM23_BASE (D2_APB1PERIPH_BASE + 0xE000UL) #define TIM24_BASE (D2_APB1PERIPH_BASE + 0xE400UL) /*!< D2_APB2PERIPH peripherals */ #define TIM1_BASE (D2_APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (D2_APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (D2_APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (D2_APB2PERIPH_BASE + 0x1400UL) #define UART9_BASE (D2_APB2PERIPH_BASE + 0x1800UL) #define USART10_BASE (D2_APB2PERIPH_BASE + 0x1C00UL) #define SPI1_BASE (D2_APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (D2_APB2PERIPH_BASE + 0x3400UL) #define TIM15_BASE (D2_APB2PERIPH_BASE + 0x4000UL) #define TIM16_BASE (D2_APB2PERIPH_BASE + 0x4400UL) #define TIM17_BASE (D2_APB2PERIPH_BASE + 0x4800UL) #define SPI5_BASE (D2_APB2PERIPH_BASE + 0x5000UL) #define SAI1_BASE (D2_APB2PERIPH_BASE + 0x5800UL) #define SAI1_Block_A_BASE (SAI1_BASE + 0x004UL) #define SAI1_Block_B_BASE (SAI1_BASE + 0x024UL) #define DFSDM1_BASE (D2_APB2PERIPH_BASE + 0x7800UL) #define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) #define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) #define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) #define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) #define DFSDM1_Channel4_BASE (DFSDM1_BASE + 0x80UL) #define DFSDM1_Channel5_BASE (DFSDM1_BASE + 0xA0UL) #define DFSDM1_Channel6_BASE (DFSDM1_BASE + 0xC0UL) #define DFSDM1_Channel7_BASE (DFSDM1_BASE + 0xE0UL) #define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) #define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) #define DFSDM1_Filter2_BASE (DFSDM1_BASE + 0x200UL) #define DFSDM1_Filter3_BASE (DFSDM1_BASE + 0x280UL) /*!< D3_APB1PERIPH peripherals */ #define EXTI_BASE (D3_APB1PERIPH_BASE + 0x0000UL) #define EXTI_D1_BASE (EXTI_BASE + 0x0080UL) #define EXTI_D2_BASE (EXTI_BASE + 0x00C0UL) #define SYSCFG_BASE (D3_APB1PERIPH_BASE + 0x0400UL) #define LPUART1_BASE (D3_APB1PERIPH_BASE + 0x0C00UL) #define SPI6_BASE (D3_APB1PERIPH_BASE + 0x1400UL) #define I2C4_BASE (D3_APB1PERIPH_BASE + 0x1C00UL) #define LPTIM2_BASE (D3_APB1PERIPH_BASE + 0x2400UL) #define LPTIM3_BASE (D3_APB1PERIPH_BASE + 0x2800UL) #define LPTIM4_BASE (D3_APB1PERIPH_BASE + 0x2C00UL) #define LPTIM5_BASE (D3_APB1PERIPH_BASE + 0x3000UL) #define COMP12_BASE (D3_APB1PERIPH_BASE + 0x3800UL) #define COMP1_BASE (COMP12_BASE + 0x0CUL) #define COMP2_BASE (COMP12_BASE + 0x10UL) #define VREFBUF_BASE (D3_APB1PERIPH_BASE + 0x3C00UL) #define RTC_BASE (D3_APB1PERIPH_BASE + 0x4000UL) #define IWDG1_BASE (D3_APB1PERIPH_BASE + 0x4800UL) #define SAI4_BASE (D3_APB1PERIPH_BASE + 0x5400UL) #define SAI4_Block_A_BASE (SAI4_BASE + 0x004UL) #define SAI4_Block_B_BASE (SAI4_BASE + 0x024UL) #define DTS_BASE (D3_APB1PERIPH_BASE + 0x6800UL) #define BDMA_Channel0_BASE (BDMA_BASE + 0x0008UL) #define BDMA_Channel1_BASE (BDMA_BASE + 0x001CUL) #define BDMA_Channel2_BASE (BDMA_BASE + 0x0030UL) #define BDMA_Channel3_BASE (BDMA_BASE + 0x0044UL) #define BDMA_Channel4_BASE (BDMA_BASE + 0x0058UL) #define BDMA_Channel5_BASE (BDMA_BASE + 0x006CUL) #define BDMA_Channel6_BASE (BDMA_BASE + 0x0080UL) #define BDMA_Channel7_BASE (BDMA_BASE + 0x0094UL) #define DMAMUX2_Channel0_BASE (DMAMUX2_BASE) #define DMAMUX2_Channel1_BASE (DMAMUX2_BASE + 0x0004UL) #define DMAMUX2_Channel2_BASE (DMAMUX2_BASE + 0x0008UL) #define DMAMUX2_Channel3_BASE (DMAMUX2_BASE + 0x000CUL) #define DMAMUX2_Channel4_BASE (DMAMUX2_BASE + 0x0010UL) #define DMAMUX2_Channel5_BASE (DMAMUX2_BASE + 0x0014UL) #define DMAMUX2_Channel6_BASE (DMAMUX2_BASE + 0x0018UL) #define DMAMUX2_Channel7_BASE (DMAMUX2_BASE + 0x001CUL) #define DMAMUX2_RequestGenerator0_BASE (DMAMUX2_BASE + 0x0100UL) #define DMAMUX2_RequestGenerator1_BASE (DMAMUX2_BASE + 0x0104UL) #define DMAMUX2_RequestGenerator2_BASE (DMAMUX2_BASE + 0x0108UL) #define DMAMUX2_RequestGenerator3_BASE (DMAMUX2_BASE + 0x010CUL) #define DMAMUX2_RequestGenerator4_BASE (DMAMUX2_BASE + 0x0110UL) #define DMAMUX2_RequestGenerator5_BASE (DMAMUX2_BASE + 0x0114UL) #define DMAMUX2_RequestGenerator6_BASE (DMAMUX2_BASE + 0x0118UL) #define DMAMUX2_RequestGenerator7_BASE (DMAMUX2_BASE + 0x011CUL) #define DMAMUX2_ChannelStatus_BASE (DMAMUX2_BASE + 0x0080UL) #define DMAMUX2_RequestGenStatus_BASE (DMAMUX2_BASE + 0x0140UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) #define DMAMUX1_Channel0_BASE (DMAMUX1_BASE) #define DMAMUX1_Channel1_BASE (DMAMUX1_BASE + 0x0004UL) #define DMAMUX1_Channel2_BASE (DMAMUX1_BASE + 0x0008UL) #define DMAMUX1_Channel3_BASE (DMAMUX1_BASE + 0x000CUL) #define DMAMUX1_Channel4_BASE (DMAMUX1_BASE + 0x0010UL) #define DMAMUX1_Channel5_BASE (DMAMUX1_BASE + 0x0014UL) #define DMAMUX1_Channel6_BASE (DMAMUX1_BASE + 0x0018UL) #define DMAMUX1_Channel7_BASE (DMAMUX1_BASE + 0x001CUL) #define DMAMUX1_Channel8_BASE (DMAMUX1_BASE + 0x0020UL) #define DMAMUX1_Channel9_BASE (DMAMUX1_BASE + 0x0024UL) #define DMAMUX1_Channel10_BASE (DMAMUX1_BASE + 0x0028UL) #define DMAMUX1_Channel11_BASE (DMAMUX1_BASE + 0x002CUL) #define DMAMUX1_Channel12_BASE (DMAMUX1_BASE + 0x0030UL) #define DMAMUX1_Channel13_BASE (DMAMUX1_BASE + 0x0034UL) #define DMAMUX1_Channel14_BASE (DMAMUX1_BASE + 0x0038UL) #define DMAMUX1_Channel15_BASE (DMAMUX1_BASE + 0x003CUL) #define DMAMUX1_RequestGenerator0_BASE (DMAMUX1_BASE + 0x0100UL) #define DMAMUX1_RequestGenerator1_BASE (DMAMUX1_BASE + 0x0104UL) #define DMAMUX1_RequestGenerator2_BASE (DMAMUX1_BASE + 0x0108UL) #define DMAMUX1_RequestGenerator3_BASE (DMAMUX1_BASE + 0x010CUL) #define DMAMUX1_RequestGenerator4_BASE (DMAMUX1_BASE + 0x0110UL) #define DMAMUX1_RequestGenerator5_BASE (DMAMUX1_BASE + 0x0114UL) #define DMAMUX1_RequestGenerator6_BASE (DMAMUX1_BASE + 0x0118UL) #define DMAMUX1_RequestGenerator7_BASE (DMAMUX1_BASE + 0x011CUL) #define DMAMUX1_ChannelStatus_BASE (DMAMUX1_BASE + 0x0080UL) #define DMAMUX1_RequestGenStatus_BASE (DMAMUX1_BASE + 0x0140UL) /*!< FMC Banks registers base address */ #define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000UL) #define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104UL) #define FMC_Bank2_R_BASE (FMC_R_BASE + 0x0060UL) #define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080UL) #define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140UL) /* Debug MCU registers base address */ #define DBGMCU_BASE (0x5C001000UL) #define MDMA_Channel0_BASE (MDMA_BASE + 0x00000040UL) #define MDMA_Channel1_BASE (MDMA_BASE + 0x00000080UL) #define MDMA_Channel2_BASE (MDMA_BASE + 0x000000C0UL) #define MDMA_Channel3_BASE (MDMA_BASE + 0x00000100UL) #define MDMA_Channel4_BASE (MDMA_BASE + 0x00000140UL) #define MDMA_Channel5_BASE (MDMA_BASE + 0x00000180UL) #define MDMA_Channel6_BASE (MDMA_BASE + 0x000001C0UL) #define MDMA_Channel7_BASE (MDMA_BASE + 0x00000200UL) #define MDMA_Channel8_BASE (MDMA_BASE + 0x00000240UL) #define MDMA_Channel9_BASE (MDMA_BASE + 0x00000280UL) #define MDMA_Channel10_BASE (MDMA_BASE + 0x000002C0UL) #define MDMA_Channel11_BASE (MDMA_BASE + 0x00000300UL) #define MDMA_Channel12_BASE (MDMA_BASE + 0x00000340UL) #define MDMA_Channel13_BASE (MDMA_BASE + 0x00000380UL) #define MDMA_Channel14_BASE (MDMA_BASE + 0x000003C0UL) #define MDMA_Channel15_BASE (MDMA_BASE + 0x00000400UL) #define RAMECC1_Monitor1_BASE (RAMECC1_BASE + 0x20UL) #define RAMECC1_Monitor2_BASE (RAMECC1_BASE + 0x40UL) #define RAMECC1_Monitor3_BASE (RAMECC1_BASE + 0x60UL) #define RAMECC1_Monitor4_BASE (RAMECC1_BASE + 0x80UL) #define RAMECC1_Monitor5_BASE (RAMECC1_BASE + 0xA0UL) #define RAMECC1_Monitor6_BASE (RAMECC1_BASE + 0xC0UL) #define RAMECC2_Monitor1_BASE (RAMECC2_BASE + 0x20UL) #define RAMECC2_Monitor2_BASE (RAMECC2_BASE + 0x40UL) #define RAMECC2_Monitor3_BASE (RAMECC2_BASE + 0x60UL) #define RAMECC3_Monitor1_BASE (RAMECC3_BASE + 0x20UL) #define RAMECC3_Monitor2_BASE (RAMECC3_BASE + 0x40UL) #define GPV_BASE (PERIPH_BASE + 0x11000000UL) /*!< GPV_BASE (PERIPH_BASE + 0x11000000UL) */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define VREFBUF ((VREFBUF_TypeDef *) VREFBUF_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG1 ((WWDG_TypeDef *) WWDG1_BASE) #define IWDG1 ((IWDG_TypeDef *) IWDG1_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define SPI6 ((SPI_TypeDef *) SPI6_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define USART10 ((USART_TypeDef *) USART10_BASE) #define UART7 ((USART_TypeDef *) UART7_BASE) #define UART8 ((USART_TypeDef *) UART8_BASE) #define UART9 ((USART_TypeDef *) UART9_BASE) #define CRS ((CRS_TypeDef *) CRS_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define I2C4 ((I2C_TypeDef *) I2C4_BASE) #define I2C5 ((I2C_TypeDef *) I2C5_BASE) #define FDCAN1 ((FDCAN_GlobalTypeDef *) FDCAN1_BASE) #define FDCAN2 ((FDCAN_GlobalTypeDef *) FDCAN2_BASE) #define FDCAN_CCU ((FDCAN_ClockCalibrationUnit_TypeDef *) FDCAN_CCU_BASE) #define FDCAN3 ((FDCAN_GlobalTypeDef *) FDCAN3_BASE) #define TIM23 ((TIM_TypeDef *) TIM23_BASE) #define TIM24 ((TIM_TypeDef *) TIM24_BASE) #define CEC ((CEC_TypeDef *) CEC_BASE) #define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC1_BASE) #define LPUART1 ((USART_TypeDef *) LPUART1_BASE) #define SWPMI1 ((SWPMI_TypeDef *) SWPMI1_BASE) #define LPTIM2 ((LPTIM_TypeDef *) LPTIM2_BASE) #define LPTIM3 ((LPTIM_TypeDef *) LPTIM3_BASE) #define DTS ((DTS_TypeDef *) DTS_BASE) #define LPTIM4 ((LPTIM_TypeDef *) LPTIM4_BASE) #define LPTIM5 ((LPTIM_TypeDef *) LPTIM5_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define COMP12 ((COMPOPT_TypeDef *) COMP12_BASE) #define COMP1 ((COMP_TypeDef *) COMP1_BASE) #define COMP2 ((COMP_TypeDef *) COMP2_BASE) #define COMP12_COMMON ((COMP_Common_TypeDef *) COMP2_BASE) #define OPAMP ((OPAMP_TypeDef *) OPAMP_BASE) #define OPAMP1 ((OPAMP_TypeDef *) OPAMP1_BASE) #define OPAMP2 ((OPAMP_TypeDef *) OPAMP2_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define EXTI_D1 ((EXTI_Core_TypeDef *) EXTI_D1_BASE) #define EXTI_D2 ((EXTI_Core_TypeDef *) EXTI_D2_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM15 ((TIM_TypeDef *) TIM15_BASE) #define TIM16 ((TIM_TypeDef *) TIM16_BASE) #define TIM17 ((TIM_TypeDef *) TIM17_BASE) #define SAI1 ((SAI_TypeDef *) SAI1_BASE) #define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) #define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) #define SAI4 ((SAI_TypeDef *) SAI4_BASE) #define SAI4_Block_A ((SAI_Block_TypeDef *)SAI4_Block_A_BASE) #define SAI4_Block_B ((SAI_Block_TypeDef *)SAI4_Block_B_BASE) #define SPDIFRX ((SPDIFRX_TypeDef *) SPDIFRX_BASE) #define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) #define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) #define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) #define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) #define DFSDM1_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel4_BASE) #define DFSDM1_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel5_BASE) #define DFSDM1_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel6_BASE) #define DFSDM1_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel7_BASE) #define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) #define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) #define DFSDM1_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter2_BASE) #define DFSDM1_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter3_BASE) #define DMA2D ((DMA2D_TypeDef *) DMA2D_BASE) #define DCMI ((DCMI_TypeDef *) DCMI_BASE) #define PSSI ((PSSI_TypeDef *) PSSI_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define GPIOJ ((GPIO_TypeDef *) GPIOJ_BASE) #define GPIOK ((GPIO_TypeDef *) GPIOK_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define ADC3_COMMON ((ADC_Common_TypeDef *) ADC3_COMMON_BASE) #define ADC12_COMMON ((ADC_Common_TypeDef *) ADC12_COMMON_BASE) #define CRYP ((CRYP_TypeDef *) CRYP_BASE) #define HASH ((HASH_TypeDef *) HASH_BASE) #define HASH_DIGEST ((HASH_DIGEST_TypeDef *) HASH_DIGEST_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define SDMMC2 ((SDMMC_TypeDef *) SDMMC2_BASE) #define DLYB_SDMMC2 ((DLYB_TypeDef *) DLYB_SDMMC2_BASE) #define FMAC ((FMAC_TypeDef *) FMAC_BASE) #define CORDIC ((CORDIC_TypeDef *) CORDIC_BASE) #define BDMA ((BDMA_TypeDef *) BDMA_BASE) #define BDMA_Channel0 ((BDMA_Channel_TypeDef *) BDMA_Channel0_BASE) #define BDMA_Channel1 ((BDMA_Channel_TypeDef *) BDMA_Channel1_BASE) #define BDMA_Channel2 ((BDMA_Channel_TypeDef *) BDMA_Channel2_BASE) #define BDMA_Channel3 ((BDMA_Channel_TypeDef *) BDMA_Channel3_BASE) #define BDMA_Channel4 ((BDMA_Channel_TypeDef *) BDMA_Channel4_BASE) #define BDMA_Channel5 ((BDMA_Channel_TypeDef *) BDMA_Channel5_BASE) #define BDMA_Channel6 ((BDMA_Channel_TypeDef *) BDMA_Channel6_BASE) #define BDMA_Channel7 ((BDMA_Channel_TypeDef *) BDMA_Channel7_BASE) #define RAMECC1 ((RAMECC_TypeDef *)RAMECC1_BASE) #define RAMECC1_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor1_BASE) #define RAMECC1_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor2_BASE) #define RAMECC1_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor3_BASE) #define RAMECC1_Monitor4 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor4_BASE) #define RAMECC1_Monitor5 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor5_BASE) #define RAMECC1_Monitor6 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor6_BASE) #define RAMECC2 ((RAMECC_TypeDef *)RAMECC2_BASE) #define RAMECC2_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor1_BASE) #define RAMECC2_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor2_BASE) #define RAMECC2_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor3_BASE) #define RAMECC3 ((RAMECC_TypeDef *)RAMECC3_BASE) #define RAMECC3_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor1_BASE) #define RAMECC3_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor2_BASE) #define DMAMUX2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_BASE) #define DMAMUX2_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel0_BASE) #define DMAMUX2_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel1_BASE) #define DMAMUX2_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel2_BASE) #define DMAMUX2_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel3_BASE) #define DMAMUX2_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel4_BASE) #define DMAMUX2_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel5_BASE) #define DMAMUX2_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel6_BASE) #define DMAMUX2_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel7_BASE) #define DMAMUX2_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator0_BASE) #define DMAMUX2_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator1_BASE) #define DMAMUX2_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator2_BASE) #define DMAMUX2_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator3_BASE) #define DMAMUX2_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator4_BASE) #define DMAMUX2_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator5_BASE) #define DMAMUX2_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator6_BASE) #define DMAMUX2_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator7_BASE) #define DMAMUX2_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX2_ChannelStatus_BASE) #define DMAMUX2_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX2_RequestGenStatus_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMAMUX1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_BASE) #define DMAMUX1_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel0_BASE) #define DMAMUX1_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel1_BASE) #define DMAMUX1_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel2_BASE) #define DMAMUX1_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel3_BASE) #define DMAMUX1_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel4_BASE) #define DMAMUX1_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel5_BASE) #define DMAMUX1_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel6_BASE) #define DMAMUX1_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel7_BASE) #define DMAMUX1_Channel8 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel8_BASE) #define DMAMUX1_Channel9 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel9_BASE) #define DMAMUX1_Channel10 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel10_BASE) #define DMAMUX1_Channel11 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel11_BASE) #define DMAMUX1_Channel12 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel12_BASE) #define DMAMUX1_Channel13 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel13_BASE) #define DMAMUX1_Channel14 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel14_BASE) #define DMAMUX1_Channel15 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel15_BASE) #define DMAMUX1_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator0_BASE) #define DMAMUX1_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator1_BASE) #define DMAMUX1_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator2_BASE) #define DMAMUX1_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator3_BASE) #define DMAMUX1_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator4_BASE) #define DMAMUX1_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator5_BASE) #define DMAMUX1_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator6_BASE) #define DMAMUX1_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator7_BASE) #define DMAMUX1_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX1_ChannelStatus_BASE) #define DMAMUX1_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX1_RequestGenStatus_BASE) #define FMC_Bank1_R ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE) #define FMC_Bank1E_R ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE) #define FMC_Bank2_R ((FMC_Bank2_TypeDef *) FMC_Bank2_R_BASE) #define FMC_Bank3_R ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE) #define FMC_Bank5_6_R ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE) #define OCTOSPI1 ((OCTOSPI_TypeDef *) OCTOSPI1_R_BASE) #define DLYB_OCTOSPI1 ((DLYB_TypeDef *) DLYB_OCTOSPI1_BASE) #define OCTOSPI2 ((OCTOSPI_TypeDef *) OCTOSPI2_R_BASE) #define DLYB_OCTOSPI2 ((DLYB_TypeDef *) DLYB_OCTOSPI2_BASE) #define OCTOSPIM ((OCTOSPIM_TypeDef *) OCTOSPIM_BASE) #define OTFDEC1 ((OTFDEC_TypeDef *) OTFDEC1_BASE) #define OTFDEC1_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION1_BASE) #define OTFDEC1_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION2_BASE) #define OTFDEC1_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION3_BASE) #define OTFDEC1_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION4_BASE) #define OTFDEC2 ((OTFDEC_TypeDef *) OTFDEC2_BASE) #define OTFDEC2_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION1_BASE) #define OTFDEC2_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION2_BASE) #define OTFDEC2_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION3_BASE) #define OTFDEC2_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION4_BASE) #define SDMMC1 ((SDMMC_TypeDef *) SDMMC1_BASE) #define DLYB_SDMMC1 ((DLYB_TypeDef *) DLYB_SDMMC1_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define HSEM ((HSEM_TypeDef *) HSEM_BASE) #define HSEM_COMMON ((HSEM_Common_TypeDef *) (HSEM_BASE + 0x100UL)) #define LTDC ((LTDC_TypeDef *)LTDC_BASE) #define LTDC_Layer1 ((LTDC_Layer_TypeDef *)LTDC_Layer1_BASE) #define LTDC_Layer2 ((LTDC_Layer_TypeDef *)LTDC_Layer2_BASE) #define MDIOS ((MDIOS_TypeDef *) MDIOS_BASE) #define ETH ((ETH_TypeDef *)ETH_BASE) #define MDMA ((MDMA_TypeDef *)MDMA_BASE) #define MDMA_Channel0 ((MDMA_Channel_TypeDef *)MDMA_Channel0_BASE) #define MDMA_Channel1 ((MDMA_Channel_TypeDef *)MDMA_Channel1_BASE) #define MDMA_Channel2 ((MDMA_Channel_TypeDef *)MDMA_Channel2_BASE) #define MDMA_Channel3 ((MDMA_Channel_TypeDef *)MDMA_Channel3_BASE) #define MDMA_Channel4 ((MDMA_Channel_TypeDef *)MDMA_Channel4_BASE) #define MDMA_Channel5 ((MDMA_Channel_TypeDef *)MDMA_Channel5_BASE) #define MDMA_Channel6 ((MDMA_Channel_TypeDef *)MDMA_Channel6_BASE) #define MDMA_Channel7 ((MDMA_Channel_TypeDef *)MDMA_Channel7_BASE) #define MDMA_Channel8 ((MDMA_Channel_TypeDef *)MDMA_Channel8_BASE) #define MDMA_Channel9 ((MDMA_Channel_TypeDef *)MDMA_Channel9_BASE) #define MDMA_Channel10 ((MDMA_Channel_TypeDef *)MDMA_Channel10_BASE) #define MDMA_Channel11 ((MDMA_Channel_TypeDef *)MDMA_Channel11_BASE) #define MDMA_Channel12 ((MDMA_Channel_TypeDef *)MDMA_Channel12_BASE) #define MDMA_Channel13 ((MDMA_Channel_TypeDef *)MDMA_Channel13_BASE) #define MDMA_Channel14 ((MDMA_Channel_TypeDef *)MDMA_Channel14_BASE) #define MDMA_Channel15 ((MDMA_Channel_TypeDef *)MDMA_Channel15_BASE) #define USB1_OTG_HS ((USB_OTG_GlobalTypeDef *) USB1_OTG_HS_PERIPH_BASE) /* Legacy defines */ #define USB_OTG_HS USB1_OTG_HS #define USB_OTG_HS_PERIPH_BASE USB1_OTG_HS_PERIPH_BASE #define GPV ((GPV_TypeDef *) GPV_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************************* ADC VERSION ********************************/ #define ADC_VER_V5_V90 /******************** Bit definition for ADC_ISR register ********************/ #define ADC_ISR_ADRDY_Pos (0U) #define ADC_ISR_ADRDY_Msk (0x1UL << ADC_ISR_ADRDY_Pos) /*!< 0x00000001 */ #define ADC_ISR_ADRDY ADC_ISR_ADRDY_Msk /*!< ADC Ready (ADRDY) flag */ #define ADC_ISR_EOSMP_Pos (1U) #define ADC_ISR_EOSMP_Msk (0x1UL << ADC_ISR_EOSMP_Pos) /*!< 0x00000002 */ #define ADC_ISR_EOSMP ADC_ISR_EOSMP_Msk /*!< ADC End of Sampling flag */ #define ADC_ISR_EOC_Pos (2U) #define ADC_ISR_EOC_Msk (0x1UL << ADC_ISR_EOC_Pos) /*!< 0x00000004 */ #define ADC_ISR_EOC ADC_ISR_EOC_Msk /*!< ADC End of Regular Conversion flag */ #define ADC_ISR_EOS_Pos (3U) #define ADC_ISR_EOS_Msk (0x1UL << ADC_ISR_EOS_Pos) /*!< 0x00000008 */ #define ADC_ISR_EOS ADC_ISR_EOS_Msk /*!< ADC End of Regular sequence of Conversions flag */ #define ADC_ISR_OVR_Pos (4U) #define ADC_ISR_OVR_Msk (0x1UL << ADC_ISR_OVR_Pos) /*!< 0x00000010 */ #define ADC_ISR_OVR ADC_ISR_OVR_Msk /*!< ADC overrun flag */ #define ADC_ISR_JEOC_Pos (5U) #define ADC_ISR_JEOC_Msk (0x1UL << ADC_ISR_JEOC_Pos) /*!< 0x00000020 */ #define ADC_ISR_JEOC ADC_ISR_JEOC_Msk /*!< ADC End of Injected Conversion flag */ #define ADC_ISR_JEOS_Pos (6U) #define ADC_ISR_JEOS_Msk (0x1UL << ADC_ISR_JEOS_Pos) /*!< 0x00000040 */ #define ADC_ISR_JEOS ADC_ISR_JEOS_Msk /*!< ADC End of Injected sequence of Conversions flag */ #define ADC_ISR_AWD1_Pos (7U) #define ADC_ISR_AWD1_Msk (0x1UL << ADC_ISR_AWD1_Pos) /*!< 0x00000080 */ #define ADC_ISR_AWD1 ADC_ISR_AWD1_Msk /*!< ADC Analog watchdog 1 flag */ #define ADC_ISR_AWD2_Pos (8U) #define ADC_ISR_AWD2_Msk (0x1UL << ADC_ISR_AWD2_Pos) /*!< 0x00000100 */ #define ADC_ISR_AWD2 ADC_ISR_AWD2_Msk /*!< ADC Analog watchdog 2 flag */ #define ADC_ISR_AWD3_Pos (9U) #define ADC_ISR_AWD3_Msk (0x1UL << ADC_ISR_AWD3_Pos) /*!< 0x00000200 */ #define ADC_ISR_AWD3 ADC_ISR_AWD3_Msk /*!< ADC Analog watchdog 3 flag */ #define ADC_ISR_JQOVF_Pos (10U) #define ADC_ISR_JQOVF_Msk (0x1UL << ADC_ISR_JQOVF_Pos) /*!< 0x00000400 */ #define ADC_ISR_JQOVF ADC_ISR_JQOVF_Msk /*!< ADC Injected Context Queue Overflow flag */ #define ADC_ISR_LDORDY_Pos (12U) #define ADC_ISR_LDORDY_Msk (0x1UL << ADC_ISR_LDORDY_Pos) /*!< 0x00001000 */ #define ADC_ISR_LDORDY ADC_ISR_LDORDY_Msk /*!< ADC LDO Ready (LDORDY) flag */ /******************** Bit definition for ADC_IER register ********************/ #define ADC_IER_ADRDYIE_Pos (0U) #define ADC_IER_ADRDYIE_Msk (0x1UL << ADC_IER_ADRDYIE_Pos) /*!< 0x00000001 */ #define ADC_IER_ADRDYIE ADC_IER_ADRDYIE_Msk /*!< ADC Ready (ADRDY) interrupt source */ #define ADC_IER_EOSMPIE_Pos (1U) #define ADC_IER_EOSMPIE_Msk (0x1UL << ADC_IER_EOSMPIE_Pos) /*!< 0x00000002 */ #define ADC_IER_EOSMPIE ADC_IER_EOSMPIE_Msk /*!< ADC End of Sampling interrupt source */ #define ADC_IER_EOCIE_Pos (2U) #define ADC_IER_EOCIE_Msk (0x1UL << ADC_IER_EOCIE_Pos) /*!< 0x00000004 */ #define ADC_IER_EOCIE ADC_IER_EOCIE_Msk /*!< ADC End of Regular Conversion interrupt source */ #define ADC_IER_EOSIE_Pos (3U) #define ADC_IER_EOSIE_Msk (0x1UL << ADC_IER_EOSIE_Pos) /*!< 0x00000008 */ #define ADC_IER_EOSIE ADC_IER_EOSIE_Msk /*!< ADC End of Regular sequence of Conversions interrupt source */ #define ADC_IER_OVRIE_Pos (4U) #define ADC_IER_OVRIE_Msk (0x1UL << ADC_IER_OVRIE_Pos) /*!< 0x00000010 */ #define ADC_IER_OVRIE ADC_IER_OVRIE_Msk /*!< ADC overrun interrupt source */ #define ADC_IER_JEOCIE_Pos (5U) #define ADC_IER_JEOCIE_Msk (0x1UL << ADC_IER_JEOCIE_Pos) /*!< 0x00000020 */ #define ADC_IER_JEOCIE ADC_IER_JEOCIE_Msk /*!< ADC End of Injected Conversion interrupt source */ #define ADC_IER_JEOSIE_Pos (6U) #define ADC_IER_JEOSIE_Msk (0x1UL << ADC_IER_JEOSIE_Pos) /*!< 0x00000040 */ #define ADC_IER_JEOSIE ADC_IER_JEOSIE_Msk /*!< ADC End of Injected sequence of Conversions interrupt source */ #define ADC_IER_AWD1IE_Pos (7U) #define ADC_IER_AWD1IE_Msk (0x1UL << ADC_IER_AWD1IE_Pos) /*!< 0x00000080 */ #define ADC_IER_AWD1IE ADC_IER_AWD1IE_Msk /*!< ADC Analog watchdog 1 interrupt source */ #define ADC_IER_AWD2IE_Pos (8U) #define ADC_IER_AWD2IE_Msk (0x1UL << ADC_IER_AWD2IE_Pos) /*!< 0x00000100 */ #define ADC_IER_AWD2IE ADC_IER_AWD2IE_Msk /*!< ADC Analog watchdog 2 interrupt source */ #define ADC_IER_AWD3IE_Pos (9U) #define ADC_IER_AWD3IE_Msk (0x1UL << ADC_IER_AWD3IE_Pos) /*!< 0x00000200 */ #define ADC_IER_AWD3IE ADC_IER_AWD3IE_Msk /*!< ADC Analog watchdog 3 interrupt source */ #define ADC_IER_JQOVFIE_Pos (10U) #define ADC_IER_JQOVFIE_Msk (0x1UL << ADC_IER_JQOVFIE_Pos) /*!< 0x00000400 */ #define ADC_IER_JQOVFIE ADC_IER_JQOVFIE_Msk /*!< ADC Injected Context Queue Overflow interrupt source */ /******************** Bit definition for ADC_CR register ********************/ #define ADC_CR_ADEN_Pos (0U) #define ADC_CR_ADEN_Msk (0x1UL << ADC_CR_ADEN_Pos) /*!< 0x00000001 */ #define ADC_CR_ADEN ADC_CR_ADEN_Msk /*!< ADC Enable control */ #define ADC_CR_ADDIS_Pos (1U) #define ADC_CR_ADDIS_Msk (0x1UL << ADC_CR_ADDIS_Pos) /*!< 0x00000002 */ #define ADC_CR_ADDIS ADC_CR_ADDIS_Msk /*!< ADC Disable command */ #define ADC_CR_ADSTART_Pos (2U) #define ADC_CR_ADSTART_Msk (0x1UL << ADC_CR_ADSTART_Pos) /*!< 0x00000004 */ #define ADC_CR_ADSTART ADC_CR_ADSTART_Msk /*!< ADC Start of Regular conversion */ #define ADC_CR_JADSTART_Pos (3U) #define ADC_CR_JADSTART_Msk (0x1UL << ADC_CR_JADSTART_Pos) /*!< 0x00000008 */ #define ADC_CR_JADSTART ADC_CR_JADSTART_Msk /*!< ADC Start of injected conversion */ #define ADC_CR_ADSTP_Pos (4U) #define ADC_CR_ADSTP_Msk (0x1UL << ADC_CR_ADSTP_Pos) /*!< 0x00000010 */ #define ADC_CR_ADSTP ADC_CR_ADSTP_Msk /*!< ADC Stop of Regular conversion */ #define ADC_CR_JADSTP_Pos (5U) #define ADC_CR_JADSTP_Msk (0x1UL << ADC_CR_JADSTP_Pos) /*!< 0x00000020 */ #define ADC_CR_JADSTP ADC_CR_JADSTP_Msk /*!< ADC Stop of injected conversion */ #define ADC_CR_BOOST_Pos (8U) #define ADC_CR_BOOST_Msk (0x3UL << ADC_CR_BOOST_Pos) /*!< 0x00000300 */ #define ADC_CR_BOOST ADC_CR_BOOST_Msk /*!< ADC Boost Mode configuration */ #define ADC_CR_BOOST_0 (0x1UL << ADC_CR_BOOST_Pos) /*!< 0x00000100 */ #define ADC_CR_BOOST_1 (0x2UL << ADC_CR_BOOST_Pos) /*!< 0x00000200 */ #define ADC_CR_ADCALLIN_Pos (16U) #define ADC_CR_ADCALLIN_Msk (0x1UL << ADC_CR_ADCALLIN_Pos) /*!< 0x00010000 */ #define ADC_CR_ADCALLIN ADC_CR_ADCALLIN_Msk /*!< ADC Linearity calibration */ #define ADC_CR_LINCALRDYW1_Pos (22U) #define ADC_CR_LINCALRDYW1_Msk (0x1UL << ADC_CR_LINCALRDYW1_Pos) /*!< 0x00400000 */ #define ADC_CR_LINCALRDYW1 ADC_CR_LINCALRDYW1_Msk /*!< ADC Linearity calibration ready Word 1 */ #define ADC_CR_LINCALRDYW2_Pos (23U) #define ADC_CR_LINCALRDYW2_Msk (0x1UL << ADC_CR_LINCALRDYW2_Pos) /*!< 0x00800000 */ #define ADC_CR_LINCALRDYW2 ADC_CR_LINCALRDYW2_Msk /*!< ADC Linearity calibration ready Word 2 */ #define ADC_CR_LINCALRDYW3_Pos (24U) #define ADC_CR_LINCALRDYW3_Msk (0x1UL << ADC_CR_LINCALRDYW3_Pos) /*!< 0x01000000 */ #define ADC_CR_LINCALRDYW3 ADC_CR_LINCALRDYW3_Msk /*!< ADC Linearity calibration ready Word 3 */ #define ADC_CR_LINCALRDYW4_Pos (25U) #define ADC_CR_LINCALRDYW4_Msk (0x1UL << ADC_CR_LINCALRDYW4_Pos) /*!< 0x02000000 */ #define ADC_CR_LINCALRDYW4 ADC_CR_LINCALRDYW4_Msk /*!< ADC Linearity calibration ready Word 4 */ #define ADC_CR_LINCALRDYW5_Pos (26U) #define ADC_CR_LINCALRDYW5_Msk (0x1UL << ADC_CR_LINCALRDYW5_Pos) /*!< 0x04000000 */ #define ADC_CR_LINCALRDYW5 ADC_CR_LINCALRDYW5_Msk /*!< ADC Linearity calibration ready Word 5 */ #define ADC_CR_LINCALRDYW6_Pos (27U) #define ADC_CR_LINCALRDYW6_Msk (0x1UL << ADC_CR_LINCALRDYW6_Pos) /*!< 0x08000000 */ #define ADC_CR_LINCALRDYW6 ADC_CR_LINCALRDYW6_Msk /*!< ADC Linearity calibration ready Word 6 */ #define ADC_CR_ADVREGEN_Pos (28U) #define ADC_CR_ADVREGEN_Msk (0x1UL << ADC_CR_ADVREGEN_Pos) /*!< 0x10000000 */ #define ADC_CR_ADVREGEN ADC_CR_ADVREGEN_Msk /*!< ADC Voltage regulator Enable */ #define ADC_CR_DEEPPWD_Pos (29U) #define ADC_CR_DEEPPWD_Msk (0x1UL << ADC_CR_DEEPPWD_Pos) /*!< 0x20000000 */ #define ADC_CR_DEEPPWD ADC_CR_DEEPPWD_Msk /*!< ADC Deep power down Enable */ #define ADC_CR_ADCALDIF_Pos (30U) #define ADC_CR_ADCALDIF_Msk (0x1UL << ADC_CR_ADCALDIF_Pos) /*!< 0x40000000 */ #define ADC_CR_ADCALDIF ADC_CR_ADCALDIF_Msk /*!< ADC Differential Mode for calibration */ #define ADC_CR_ADCAL_Pos (31U) #define ADC_CR_ADCAL_Msk (0x1UL << ADC_CR_ADCAL_Pos) /*!< 0x80000000 */ #define ADC_CR_ADCAL ADC_CR_ADCAL_Msk /*!< ADC Calibration */ /******************** Bit definition for ADC_CFGR register ********************/ #define ADC_CFGR_DMNGT_Pos (0U) #define ADC_CFGR_DMNGT_Msk (0x3UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000003 */ #define ADC_CFGR_DMNGT ADC_CFGR_DMNGT_Msk /*!< ADC Data Management configuration */ #define ADC_CFGR_DMNGT_0 (0x1UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000001 */ #define ADC_CFGR_DMNGT_1 (0x2UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000002 */ #define ADC_CFGR_RES_Pos (2U) #define ADC_CFGR_RES_Msk (0x7UL << ADC_CFGR_RES_Pos) /*!< 0x0000001C */ #define ADC_CFGR_RES ADC_CFGR_RES_Msk /*!< ADC Data resolution */ #define ADC_CFGR_RES_0 (0x1UL << ADC_CFGR_RES_Pos) /*!< 0x00000004 */ #define ADC_CFGR_RES_1 (0x2UL << ADC_CFGR_RES_Pos) /*!< 0x00000008 */ #define ADC_CFGR_RES_2 (0x4UL << ADC_CFGR_RES_Pos) /*!< 0x00000010 */ #define ADC_CFGR_EXTSEL_Pos (5U) #define ADC_CFGR_EXTSEL_Msk (0x1FUL << ADC_CFGR_EXTSEL_Pos) /*!< 0x000003E0 */ #define ADC_CFGR_EXTSEL ADC_CFGR_EXTSEL_Msk /*!< ADC External trigger selection for regular group */ #define ADC_CFGR_EXTSEL_0 (0x01UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000020 */ #define ADC_CFGR_EXTSEL_1 (0x02UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000040 */ #define ADC_CFGR_EXTSEL_2 (0x04UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000080 */ #define ADC_CFGR_EXTSEL_3 (0x08UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000100 */ #define ADC_CFGR_EXTSEL_4 (0x10UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000200 */ #define ADC_CFGR_EXTEN_Pos (10U) #define ADC_CFGR_EXTEN_Msk (0x3UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000C00 */ #define ADC_CFGR_EXTEN ADC_CFGR_EXTEN_Msk /*!< ADC External trigger enable and polarity selection for regular channels */ #define ADC_CFGR_EXTEN_0 (0x1UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000400 */ #define ADC_CFGR_EXTEN_1 (0x2UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000800 */ #define ADC_CFGR_OVRMOD_Pos (12U) #define ADC_CFGR_OVRMOD_Msk (0x1UL << ADC_CFGR_OVRMOD_Pos) /*!< 0x00001000 */ #define ADC_CFGR_OVRMOD ADC_CFGR_OVRMOD_Msk /*!< ADC overrun mode */ #define ADC_CFGR_CONT_Pos (13U) #define ADC_CFGR_CONT_Msk (0x1UL << ADC_CFGR_CONT_Pos) /*!< 0x00002000 */ #define ADC_CFGR_CONT ADC_CFGR_CONT_Msk /*!< ADC Single/continuous conversion mode for regular conversion */ #define ADC_CFGR_AUTDLY_Pos (14U) #define ADC_CFGR_AUTDLY_Msk (0x1UL << ADC_CFGR_AUTDLY_Pos) /*!< 0x00004000 */ #define ADC_CFGR_AUTDLY ADC_CFGR_AUTDLY_Msk /*!< ADC Delayed conversion mode */ #define ADC_CFGR_DISCEN_Pos (16U) #define ADC_CFGR_DISCEN_Msk (0x1UL << ADC_CFGR_DISCEN_Pos) /*!< 0x00010000 */ #define ADC_CFGR_DISCEN ADC_CFGR_DISCEN_Msk /*!< ADC Discontinuous mode for regular channels */ #define ADC_CFGR_DISCNUM_Pos (17U) #define ADC_CFGR_DISCNUM_Msk (0x7UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x000E0000 */ #define ADC_CFGR_DISCNUM ADC_CFGR_DISCNUM_Msk /*!< ADC Discontinuous mode channel count */ #define ADC_CFGR_DISCNUM_0 (0x1UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00020000 */ #define ADC_CFGR_DISCNUM_1 (0x2UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00040000 */ #define ADC_CFGR_DISCNUM_2 (0x4UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00080000 */ #define ADC_CFGR_JDISCEN_Pos (20U) #define ADC_CFGR_JDISCEN_Msk (0x1UL << ADC_CFGR_JDISCEN_Pos) /*!< 0x00100000 */ #define ADC_CFGR_JDISCEN ADC_CFGR_JDISCEN_Msk /*!< ADC Discontinuous mode on injected channels */ #define ADC_CFGR_JQM_Pos (21U) #define ADC_CFGR_JQM_Msk (0x1UL << ADC_CFGR_JQM_Pos) /*!< 0x00200000 */ #define ADC_CFGR_JQM ADC_CFGR_JQM_Msk /*!< ADC JSQR Queue mode */ #define ADC_CFGR_AWD1SGL_Pos (22U) #define ADC_CFGR_AWD1SGL_Msk (0x1UL << ADC_CFGR_AWD1SGL_Pos) /*!< 0x00400000 */ #define ADC_CFGR_AWD1SGL ADC_CFGR_AWD1SGL_Msk /*!< Enable the watchdog 1 on a single channel or on all channels */ #define ADC_CFGR_AWD1EN_Pos (23U) #define ADC_CFGR_AWD1EN_Msk (0x1UL << ADC_CFGR_AWD1EN_Pos) /*!< 0x00800000 */ #define ADC_CFGR_AWD1EN ADC_CFGR_AWD1EN_Msk /*!< ADC Analog watchdog 1 enable on regular Channels */ #define ADC_CFGR_JAWD1EN_Pos (24U) #define ADC_CFGR_JAWD1EN_Msk (0x1UL << ADC_CFGR_JAWD1EN_Pos) /*!< 0x01000000 */ #define ADC_CFGR_JAWD1EN ADC_CFGR_JAWD1EN_Msk /*!< ADC Analog watchdog 1 enable on injected Channels */ #define ADC_CFGR_JAUTO_Pos (25U) #define ADC_CFGR_JAUTO_Msk (0x1UL << ADC_CFGR_JAUTO_Pos) /*!< 0x02000000 */ #define ADC_CFGR_JAUTO ADC_CFGR_JAUTO_Msk /*!< ADC Automatic injected group conversion */ #define ADC_CFGR_AWD1CH_Pos (26U) #define ADC_CFGR_AWD1CH_Msk (0x1FUL << ADC_CFGR_AWD1CH_Pos) /*!< 0x7C000000 */ #define ADC_CFGR_AWD1CH ADC_CFGR_AWD1CH_Msk /*!< ADC Analog watchdog 1 Channel selection */ #define ADC_CFGR_AWD1CH_0 (0x01UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x04000000 */ #define ADC_CFGR_AWD1CH_1 (0x02UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x08000000 */ #define ADC_CFGR_AWD1CH_2 (0x04UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x10000000 */ #define ADC_CFGR_AWD1CH_3 (0x08UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x20000000 */ #define ADC_CFGR_AWD1CH_4 (0x10UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x40000000 */ #define ADC_CFGR_JQDIS_Pos (31U) #define ADC_CFGR_JQDIS_Msk (0x1UL << ADC_CFGR_JQDIS_Pos) /*!< 0x80000000 */ #define ADC_CFGR_JQDIS ADC_CFGR_JQDIS_Msk /*!< ADC Injected queue disable */ #define ADC3_CFGR_DMAEN_Pos (0U) #define ADC3_CFGR_DMAEN_Msk (0x1UL << ADC3_CFGR_DMAEN_Pos) /*!< 0x00000001 */ #define ADC3_CFGR_DMAEN ADC3_CFGR_DMAEN_Msk /*!< ADC DMA transfer enable */ #define ADC3_CFGR_DMACFG_Pos (1U) #define ADC3_CFGR_DMACFG_Msk (0x1UL << ADC3_CFGR_DMACFG_Pos) /*!< 0x00000002 */ #define ADC3_CFGR_DMACFG ADC3_CFGR_DMACFG_Msk /*!< ADC DMA transfer configuration */ #define ADC3_CFGR_RES_Pos (3U) #define ADC3_CFGR_RES_Msk (0x3UL << ADC3_CFGR_RES_Pos) /*!< 0x00000018 */ #define ADC3_CFGR_RES ADC3_CFGR_RES_Msk /*!< ADC data resolution */ #define ADC3_CFGR_RES_0 (0x1UL << ADC3_CFGR_RES_Pos) /*!< 0x00000008 */ #define ADC3_CFGR_RES_1 (0x2UL << ADC3_CFGR_RES_Pos) /*!< 0x00000010 */ #define ADC3_CFGR_ALIGN_Pos (15U) #define ADC3_CFGR_ALIGN_Msk (0x1UL << ADC3_CFGR_ALIGN_Pos) /*!< 0x00008000 */ #define ADC3_CFGR_ALIGN ADC3_CFGR_ALIGN_Msk /*!< ADC data alignment */ /******************** Bit definition for ADC_CFGR2 register ********************/ #define ADC_CFGR2_ROVSE_Pos (0U) #define ADC_CFGR2_ROVSE_Msk (0x1UL << ADC_CFGR2_ROVSE_Pos) /*!< 0x00000001 */ #define ADC_CFGR2_ROVSE ADC_CFGR2_ROVSE_Msk /*!< ADC Regular group oversampler enable */ #define ADC_CFGR2_JOVSE_Pos (1U) #define ADC_CFGR2_JOVSE_Msk (0x1UL << ADC_CFGR2_JOVSE_Pos) /*!< 0x00000002 */ #define ADC_CFGR2_JOVSE ADC_CFGR2_JOVSE_Msk /*!< ADC Injected group oversampler enable */ #define ADC_CFGR2_OVSS_Pos (5U) #define ADC_CFGR2_OVSS_Msk (0xFUL << ADC_CFGR2_OVSS_Pos) /*!< 0x000001E0 */ #define ADC_CFGR2_OVSS ADC_CFGR2_OVSS_Msk /*!< ADC Regular Oversampling shift */ #define ADC_CFGR2_OVSS_0 (0x1UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000020 */ #define ADC_CFGR2_OVSS_1 (0x2UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000040 */ #define ADC_CFGR2_OVSS_2 (0x4UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000080 */ #define ADC_CFGR2_OVSS_3 (0x8UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000100 */ #define ADC_CFGR2_TROVS_Pos (9U) #define ADC_CFGR2_TROVS_Msk (0x1UL << ADC_CFGR2_TROVS_Pos) /*!< 0x00000200 */ #define ADC_CFGR2_TROVS ADC_CFGR2_TROVS_Msk /*!< ADC Triggered regular Oversampling */ #define ADC_CFGR2_ROVSM_Pos (10U) #define ADC_CFGR2_ROVSM_Msk (0x1UL << ADC_CFGR2_ROVSM_Pos) /*!< 0x00000400 */ #define ADC_CFGR2_ROVSM ADC_CFGR2_ROVSM_Msk /*!< ADC Regular oversampling mode */ #define ADC_CFGR2_RSHIFT1_Pos (11U) #define ADC_CFGR2_RSHIFT1_Msk (0x1UL << ADC_CFGR2_RSHIFT1_Pos) /*!< 0x00000800 */ #define ADC_CFGR2_RSHIFT1 ADC_CFGR2_RSHIFT1_Msk /*!< ADC Right-shift data after Offset 1 correction */ #define ADC_CFGR2_RSHIFT2_Pos (12U) #define ADC_CFGR2_RSHIFT2_Msk (0x1UL << ADC_CFGR2_RSHIFT2_Pos) /*!< 0x00001000 */ #define ADC_CFGR2_RSHIFT2 ADC_CFGR2_RSHIFT2_Msk /*!< ADC Right-shift data after Offset 2 correction */ #define ADC_CFGR2_RSHIFT3_Pos (13U) #define ADC_CFGR2_RSHIFT3_Msk (0x1UL << ADC_CFGR2_RSHIFT3_Pos) /*!< 0x00002000 */ #define ADC_CFGR2_RSHIFT3 ADC_CFGR2_RSHIFT3_Msk /*!< ADC Right-shift data after Offset 3 correction */ #define ADC_CFGR2_RSHIFT4_Pos (14U) #define ADC_CFGR2_RSHIFT4_Msk (0x1UL << ADC_CFGR2_RSHIFT4_Pos) /*!< 0x00004000 */ #define ADC_CFGR2_RSHIFT4 ADC_CFGR2_RSHIFT4_Msk /*!< ADC Right-shift data after Offset 4 correction */ #define ADC_CFGR2_OVSR_Pos (16U) #define ADC_CFGR2_OVSR_Msk (0x3FFUL << ADC_CFGR2_OVSR_Pos) /*!< 0x03FF0000 */ #define ADC_CFGR2_OVSR ADC_CFGR2_OVSR_Msk /*!< ADC oversampling Ratio */ #define ADC_CFGR2_OVSR_0 (0x001UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00010000 */ #define ADC_CFGR2_OVSR_1 (0x002UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00020000 */ #define ADC_CFGR2_OVSR_2 (0x004UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00040000 */ #define ADC_CFGR2_OVSR_3 (0x008UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00080000 */ #define ADC_CFGR2_OVSR_4 (0x010UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00100000 */ #define ADC_CFGR2_OVSR_5 (0x020UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00200000 */ #define ADC_CFGR2_OVSR_6 (0x040UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00400000 */ #define ADC_CFGR2_OVSR_7 (0x080UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00800000 */ #define ADC_CFGR2_OVSR_8 (0x100UL << ADC_CFGR2_OVSR_Pos) /*!< 0x01000000 */ #define ADC_CFGR2_OVSR_9 (0x200UL << ADC_CFGR2_OVSR_Pos) /*!< 0x02000000 */ #define ADC_CFGR2_LSHIFT_Pos (28U) #define ADC_CFGR2_LSHIFT_Msk (0xFUL << ADC_CFGR2_LSHIFT_Pos) /*!< 0xF0000000 */ #define ADC_CFGR2_LSHIFT ADC_CFGR2_LSHIFT_Msk /*!< ADC Left shift factor */ #define ADC_CFGR2_LSHIFT_0 (0x1UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x10000000 */ #define ADC_CFGR2_LSHIFT_1 (0x2UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x20000000 */ #define ADC_CFGR2_LSHIFT_2 (0x4UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x40000000 */ #define ADC_CFGR2_LSHIFT_3 (0x8UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x80000000 */ #define ADC3_CFGR2_OVSR_Pos (2U) #define ADC3_CFGR2_OVSR_Msk (0x7UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x0000001C */ #define ADC3_CFGR2_OVSR ADC3_CFGR2_OVSR_Msk /*!< ADC oversampling ratio */ #define ADC3_CFGR2_OVSR_0 (0x1UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000004 */ #define ADC3_CFGR2_OVSR_1 (0x2UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000008 */ #define ADC3_CFGR2_OVSR_2 (0x4UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000010 */ #define ADC3_CFGR2_SWTRIG_Pos (25U) #define ADC3_CFGR2_SWTRIG_Msk (0x1UL << ADC3_CFGR2_SWTRIG_Pos) /*!< 0x02000000 */ #define ADC3_CFGR2_SWTRIG ADC3_CFGR2_SWTRIG_Msk /*!< ADC Software Trigger Bit for Sample time control trigger mode */ #define ADC3_CFGR2_BULB_Pos (26U) #define ADC3_CFGR2_BULB_Msk (0x1UL << ADC3_CFGR2_BULB_Pos) /*!< 0x04000000 */ #define ADC3_CFGR2_BULB ADC3_CFGR2_BULB_Msk /*!< ADC Bulb sampling mode */ #define ADC3_CFGR2_SMPTRIG_Pos (27U) #define ADC3_CFGR2_SMPTRIG_Msk (0x1UL << ADC3_CFGR2_SMPTRIG_Pos) /*!< 0x08000000 */ #define ADC3_CFGR2_SMPTRIG ADC3_CFGR2_SMPTRIG_Msk /*!< ADC Sample Time Control Trigger mode */ /******************** Bit definition for ADC_SMPR1 register ********************/ #define ADC_SMPR1_SMP0_Pos (0U) #define ADC_SMPR1_SMP0_Msk (0x7UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000007 */ #define ADC_SMPR1_SMP0 ADC_SMPR1_SMP0_Msk /*!< ADC Channel 0 Sampling time selection */ #define ADC_SMPR1_SMP0_0 (0x1UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000001 */ #define ADC_SMPR1_SMP0_1 (0x2UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000002 */ #define ADC_SMPR1_SMP0_2 (0x4UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000004 */ #define ADC_SMPR1_SMP1_Pos (3U) #define ADC_SMPR1_SMP1_Msk (0x7UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000038 */ #define ADC_SMPR1_SMP1 ADC_SMPR1_SMP1_Msk /*!< ADC Channel 1 Sampling time selection */ #define ADC_SMPR1_SMP1_0 (0x1UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000008 */ #define ADC_SMPR1_SMP1_1 (0x2UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000010 */ #define ADC_SMPR1_SMP1_2 (0x4UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000020 */ #define ADC_SMPR1_SMP2_Pos (6U) #define ADC_SMPR1_SMP2_Msk (0x7UL << ADC_SMPR1_SMP2_Pos) /*!< 0x000001C0 */ #define ADC_SMPR1_SMP2 ADC_SMPR1_SMP2_Msk /*!< ADC Channel 2 Sampling time selection */ #define ADC_SMPR1_SMP2_0 (0x1UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000040 */ #define ADC_SMPR1_SMP2_1 (0x2UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000080 */ #define ADC_SMPR1_SMP2_2 (0x4UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000100 */ #define ADC_SMPR1_SMP3_Pos (9U) #define ADC_SMPR1_SMP3_Msk (0x7UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000E00 */ #define ADC_SMPR1_SMP3 ADC_SMPR1_SMP3_Msk /*!< ADC Channel 3 Sampling time selection */ #define ADC_SMPR1_SMP3_0 (0x1UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000200 */ #define ADC_SMPR1_SMP3_1 (0x2UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000400 */ #define ADC_SMPR1_SMP3_2 (0x4UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000800 */ #define ADC_SMPR1_SMP4_Pos (12U) #define ADC_SMPR1_SMP4_Msk (0x7UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00007000 */ #define ADC_SMPR1_SMP4 ADC_SMPR1_SMP4_Msk /*!< ADC Channel 4 Sampling time selection */ #define ADC_SMPR1_SMP4_0 (0x1UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00001000 */ #define ADC_SMPR1_SMP4_1 (0x2UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00002000 */ #define ADC_SMPR1_SMP4_2 (0x4UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00004000 */ #define ADC_SMPR1_SMP5_Pos (15U) #define ADC_SMPR1_SMP5_Msk (0x7UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00038000 */ #define ADC_SMPR1_SMP5 ADC_SMPR1_SMP5_Msk /*!< ADC Channel 5 Sampling time selection */ #define ADC_SMPR1_SMP5_0 (0x1UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00008000 */ #define ADC_SMPR1_SMP5_1 (0x2UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00010000 */ #define ADC_SMPR1_SMP5_2 (0x4UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00020000 */ #define ADC_SMPR1_SMP6_Pos (18U) #define ADC_SMPR1_SMP6_Msk (0x7UL << ADC_SMPR1_SMP6_Pos) /*!< 0x001C0000 */ #define ADC_SMPR1_SMP6 ADC_SMPR1_SMP6_Msk /*!< ADC Channel 6 Sampling time selection */ #define ADC_SMPR1_SMP6_0 (0x1UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00040000 */ #define ADC_SMPR1_SMP6_1 (0x2UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00080000 */ #define ADC_SMPR1_SMP6_2 (0x4UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00100000 */ #define ADC_SMPR1_SMP7_Pos (21U) #define ADC_SMPR1_SMP7_Msk (0x7UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00E00000 */ #define ADC_SMPR1_SMP7 ADC_SMPR1_SMP7_Msk /*!< ADC Channel 7 Sampling time selection */ #define ADC_SMPR1_SMP7_0 (0x1UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00200000 */ #define ADC_SMPR1_SMP7_1 (0x2UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00400000 */ #define ADC_SMPR1_SMP7_2 (0x4UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00800000 */ #define ADC_SMPR1_SMP8_Pos (24U) #define ADC_SMPR1_SMP8_Msk (0x7UL << ADC_SMPR1_SMP8_Pos) /*!< 0x07000000 */ #define ADC_SMPR1_SMP8 ADC_SMPR1_SMP8_Msk /*!< ADC Channel 8 Sampling time selection */ #define ADC_SMPR1_SMP8_0 (0x1UL << ADC_SMPR1_SMP8_Pos) /*!< 0x01000000 */ #define ADC_SMPR1_SMP8_1 (0x2UL << ADC_SMPR1_SMP8_Pos) /*!< 0x02000000 */ #define ADC_SMPR1_SMP8_2 (0x4UL << ADC_SMPR1_SMP8_Pos) /*!< 0x04000000 */ #define ADC_SMPR1_SMP9_Pos (27U) #define ADC_SMPR1_SMP9_Msk (0x7UL << ADC_SMPR1_SMP9_Pos) /*!< 0x38000000 */ #define ADC_SMPR1_SMP9 ADC_SMPR1_SMP9_Msk /*!< ADC Channel 9 Sampling time selection */ #define ADC_SMPR1_SMP9_0 (0x1UL << ADC_SMPR1_SMP9_Pos) /*!< 0x08000000 */ #define ADC_SMPR1_SMP9_1 (0x2UL << ADC_SMPR1_SMP9_Pos) /*!< 0x10000000 */ #define ADC_SMPR1_SMP9_2 (0x4UL << ADC_SMPR1_SMP9_Pos) /*!< 0x20000000 */ /******************** Bit definition for ADC_SMPR2 register ********************/ #define ADC_SMPR2_SMP10_Pos (0U) #define ADC_SMPR2_SMP10_Msk (0x7UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000007 */ #define ADC_SMPR2_SMP10 ADC_SMPR2_SMP10_Msk /*!< ADC Channel 10 Sampling time selection */ #define ADC_SMPR2_SMP10_0 (0x1UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000001 */ #define ADC_SMPR2_SMP10_1 (0x2UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000002 */ #define ADC_SMPR2_SMP10_2 (0x4UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000004 */ #define ADC_SMPR2_SMP11_Pos (3U) #define ADC_SMPR2_SMP11_Msk (0x7UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000038 */ #define ADC_SMPR2_SMP11 ADC_SMPR2_SMP11_Msk /*!< ADC Channel 11 Sampling time selection */ #define ADC_SMPR2_SMP11_0 (0x1UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000008 */ #define ADC_SMPR2_SMP11_1 (0x2UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000010 */ #define ADC_SMPR2_SMP11_2 (0x4UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000020 */ #define ADC_SMPR2_SMP12_Pos (6U) #define ADC_SMPR2_SMP12_Msk (0x7UL << ADC_SMPR2_SMP12_Pos) /*!< 0x000001C0 */ #define ADC_SMPR2_SMP12 ADC_SMPR2_SMP12_Msk /*!< ADC Channel 12 Sampling time selection */ #define ADC_SMPR2_SMP12_0 (0x1UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000040 */ #define ADC_SMPR2_SMP12_1 (0x2UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000080 */ #define ADC_SMPR2_SMP12_2 (0x4UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000100 */ #define ADC_SMPR2_SMP13_Pos (9U) #define ADC_SMPR2_SMP13_Msk (0x7UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000E00 */ #define ADC_SMPR2_SMP13 ADC_SMPR2_SMP13_Msk /*!< ADC Channel 13 Sampling time selection */ #define ADC_SMPR2_SMP13_0 (0x1UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000200 */ #define ADC_SMPR2_SMP13_1 (0x2UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000400 */ #define ADC_SMPR2_SMP13_2 (0x4UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000800 */ #define ADC_SMPR2_SMP14_Pos (12U) #define ADC_SMPR2_SMP14_Msk (0x7UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00007000 */ #define ADC_SMPR2_SMP14 ADC_SMPR2_SMP14_Msk /*!< ADC Channel 14 Sampling time selection */ #define ADC_SMPR2_SMP14_0 (0x1UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00001000 */ #define ADC_SMPR2_SMP14_1 (0x2UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00002000 */ #define ADC_SMPR2_SMP14_2 (0x4UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00004000 */ #define ADC_SMPR2_SMP15_Pos (15U) #define ADC_SMPR2_SMP15_Msk (0x7UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00038000 */ #define ADC_SMPR2_SMP15 ADC_SMPR2_SMP15_Msk /*!< ADC Channel 15 Sampling time selection */ #define ADC_SMPR2_SMP15_0 (0x1UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00008000 */ #define ADC_SMPR2_SMP15_1 (0x2UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00010000 */ #define ADC_SMPR2_SMP15_2 (0x4UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00020000 */ #define ADC_SMPR2_SMP16_Pos (18U) #define ADC_SMPR2_SMP16_Msk (0x7UL << ADC_SMPR2_SMP16_Pos) /*!< 0x001C0000 */ #define ADC_SMPR2_SMP16 ADC_SMPR2_SMP16_Msk /*!< ADC Channel 16 Sampling time selection */ #define ADC_SMPR2_SMP16_0 (0x1UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00040000 */ #define ADC_SMPR2_SMP16_1 (0x2UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00080000 */ #define ADC_SMPR2_SMP16_2 (0x4UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00100000 */ #define ADC_SMPR2_SMP17_Pos (21U) #define ADC_SMPR2_SMP17_Msk (0x7UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00E00000 */ #define ADC_SMPR2_SMP17 ADC_SMPR2_SMP17_Msk /*!< ADC Channel 17 Sampling time selection */ #define ADC_SMPR2_SMP17_0 (0x1UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00200000 */ #define ADC_SMPR2_SMP17_1 (0x2UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00400000 */ #define ADC_SMPR2_SMP17_2 (0x4UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00800000 */ #define ADC_SMPR2_SMP18_Pos (24U) #define ADC_SMPR2_SMP18_Msk (0x7UL << ADC_SMPR2_SMP18_Pos) /*!< 0x07000000 */ #define ADC_SMPR2_SMP18 ADC_SMPR2_SMP18_Msk /*!< ADC Channel 18 Sampling time selection */ #define ADC_SMPR2_SMP18_0 (0x1UL << ADC_SMPR2_SMP18_Pos) /*!< 0x01000000 */ #define ADC_SMPR2_SMP18_1 (0x2UL << ADC_SMPR2_SMP18_Pos) /*!< 0x02000000 */ #define ADC_SMPR2_SMP18_2 (0x4UL << ADC_SMPR2_SMP18_Pos) /*!< 0x04000000 */ #define ADC_SMPR2_SMP19_Pos (27U) #define ADC_SMPR2_SMP19_Msk (0x7UL << ADC_SMPR2_SMP19_Pos) /*!< 0x38000000 */ #define ADC_SMPR2_SMP19 ADC_SMPR2_SMP19_Msk /*!< ADC Channel 19 Sampling time selection */ #define ADC_SMPR2_SMP19_0 (0x1UL << ADC_SMPR2_SMP19_Pos) /*!< 0x08000000 */ #define ADC_SMPR2_SMP19_1 (0x2UL << ADC_SMPR2_SMP19_Pos) /*!< 0x10000000 */ #define ADC_SMPR2_SMP19_2 (0x4UL << ADC_SMPR2_SMP19_Pos) /*!< 0x20000000 */ /******************** Bit definition for ADC_PCSEL register ********************/ #define ADC_PCSEL_PCSEL_Pos (0U) #define ADC_PCSEL_PCSEL_Msk (0xFFFFFUL << ADC_PCSEL_PCSEL_Pos) /*!< 0x000FFFFF */ #define ADC_PCSEL_PCSEL ADC_PCSEL_PCSEL_Msk /*!< ADC pre channel selection */ #define ADC_PCSEL_PCSEL_0 (0x00001UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000001 */ #define ADC_PCSEL_PCSEL_1 (0x00002UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000002 */ #define ADC_PCSEL_PCSEL_2 (0x00004UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000004 */ #define ADC_PCSEL_PCSEL_3 (0x00008UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000008 */ #define ADC_PCSEL_PCSEL_4 (0x00010UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000010 */ #define ADC_PCSEL_PCSEL_5 (0x00020UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000020 */ #define ADC_PCSEL_PCSEL_6 (0x00040UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000040 */ #define ADC_PCSEL_PCSEL_7 (0x00080UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000080 */ #define ADC_PCSEL_PCSEL_8 (0x00100UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000100 */ #define ADC_PCSEL_PCSEL_9 (0x00200UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000200 */ #define ADC_PCSEL_PCSEL_10 (0x00400UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000400 */ #define ADC_PCSEL_PCSEL_11 (0x00800UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000800 */ #define ADC_PCSEL_PCSEL_12 (0x01000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00001000 */ #define ADC_PCSEL_PCSEL_13 (0x02000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00002000 */ #define ADC_PCSEL_PCSEL_14 (0x04000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00004000 */ #define ADC_PCSEL_PCSEL_15 (0x08000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00008000 */ #define ADC_PCSEL_PCSEL_16 (0x10000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00010000 */ #define ADC_PCSEL_PCSEL_17 (0x20000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00020000 */ #define ADC_PCSEL_PCSEL_18 (0x40000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00040000 */ #define ADC_PCSEL_PCSEL_19 (0x80000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00080000 */ /***************** Bit definition for ADC_LTR1, 2, 3 registers *****************/ #define ADC_LTR_LT_Pos (0U) #define ADC_LTR_LT_Msk (0x3FFFFFFUL << ADC_LTR_LT_Pos) /*!< 0x03FFFFFF */ #define ADC_LTR_LT ADC_LTR_LT_Msk /*!< ADC Analog watchdog 1, 2 and 3 lower threshold */ /***************** Bit definition for ADC_HTR1, 2, 3 registers ****************/ #define ADC_HTR_HT_Pos (0U) #define ADC_HTR_HT_Msk (0x3FFFFFFUL << ADC_HTR_HT_Pos) /*!< 0x03FFFFFF */ #define ADC_HTR_HT ADC_HTR_HT_Msk /*!< ADC Analog watchdog 1,2 and 3 higher threshold */ /******************** Bit definition for ADC3_TR1 register *******************/ #define ADC3_TR1_LT1_Pos (0U) #define ADC3_TR1_LT1_Msk (0xFFFUL << ADC3_TR1_LT1_Pos) /*!< 0x00000FFF */ #define ADC3_TR1_LT1 ADC3_TR1_LT1_Msk /*!< ADC analog watchdog 1 threshold low */ #define ADC3_TR1_AWDFILT_Pos (12U) #define ADC3_TR1_AWDFILT_Msk (0x7UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00007000 */ #define ADC3_TR1_AWDFILT ADC3_TR1_AWDFILT_Msk /*!< ADC analog watchdog filtering parameter */ #define ADC3_TR1_AWDFILT_0 (0x1UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00001000 */ #define ADC3_TR1_AWDFILT_1 (0x2UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00002000 */ #define ADC3_TR1_AWDFILT_2 (0x4UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00004000 */ #define ADC3_TR1_HT1_Pos (16U) #define ADC3_TR1_HT1_Msk (0xFFFUL << ADC3_TR1_HT1_Pos) /*!< 0x0FFF0000 */ #define ADC3_TR1_HT1 ADC3_TR1_HT1_Msk /*!< ADC analog watchdog 1 threshold high */ /******************** Bit definition for ADC3_TR2 register *******************/ #define ADC3_TR2_LT2_Pos (0U) #define ADC3_TR2_LT2_Msk (0xFFUL << ADC3_TR2_LT2_Pos) /*!< 0x000000FF */ #define ADC3_TR2_LT2 ADC3_TR2_LT2_Msk /*!< ADC analog watchdog 2 threshold low */ #define ADC3_TR2_HT2_Pos (16U) #define ADC3_TR2_HT2_Msk (0xFFUL << ADC3_TR2_HT2_Pos) /*!< 0x00FF0000 */ #define ADC3_TR2_HT2 ADC3_TR2_HT2_Msk /*!< ADC analog watchdog 2 threshold high */ /******************** Bit definition for ADC3_TR3 register *******************/ #define ADC3_TR3_LT3_Pos (0U) #define ADC3_TR3_LT3_Msk (0xFFUL << ADC3_TR3_LT3_Pos) /*!< 0x000000FF */ #define ADC3_TR3_LT3 ADC3_TR3_LT3_Msk /*!< ADC analog watchdog 3 threshold low */ #define ADC3_TR3_HT3_Pos (16U) #define ADC3_TR3_HT3_Msk (0xFFUL << ADC3_TR3_HT3_Pos) /*!< 0x00FF0000 */ #define ADC3_TR3_HT3 ADC3_TR3_HT3_Msk /*!< ADC analog watchdog 3 threshold high */ /******************** Bit definition for ADC_SQR1 register ********************/ #define ADC_SQR1_L_Pos (0U) #define ADC_SQR1_L_Msk (0xFUL << ADC_SQR1_L_Pos) /*!< 0x0000000F */ #define ADC_SQR1_L ADC_SQR1_L_Msk /*!< ADC regular channel sequence length */ #define ADC_SQR1_L_0 (0x1UL << ADC_SQR1_L_Pos) /*!< 0x00000001 */ #define ADC_SQR1_L_1 (0x2UL << ADC_SQR1_L_Pos) /*!< 0x00000002 */ #define ADC_SQR1_L_2 (0x4UL << ADC_SQR1_L_Pos) /*!< 0x00000004 */ #define ADC_SQR1_L_3 (0x8UL << ADC_SQR1_L_Pos) /*!< 0x00000008 */ #define ADC_SQR1_SQ1_Pos (6U) #define ADC_SQR1_SQ1_Msk (0x1FUL << ADC_SQR1_SQ1_Pos) /*!< 0x000007C0 */ #define ADC_SQR1_SQ1 ADC_SQR1_SQ1_Msk /*!< ADC 1st conversion in regular sequence */ #define ADC_SQR1_SQ1_0 (0x01UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000040 */ #define ADC_SQR1_SQ1_1 (0x02UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000080 */ #define ADC_SQR1_SQ1_2 (0x04UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000100 */ #define ADC_SQR1_SQ1_3 (0x08UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000200 */ #define ADC_SQR1_SQ1_4 (0x10UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000400 */ #define ADC_SQR1_SQ2_Pos (12U) #define ADC_SQR1_SQ2_Msk (0x1FUL << ADC_SQR1_SQ2_Pos) /*!< 0x0001F000 */ #define ADC_SQR1_SQ2 ADC_SQR1_SQ2_Msk /*!< ADC 2nd conversion in regular sequence */ #define ADC_SQR1_SQ2_0 (0x01UL << ADC_SQR1_SQ2_Pos) /*!< 0x00001000 */ #define ADC_SQR1_SQ2_1 (0x02UL << ADC_SQR1_SQ2_Pos) /*!< 0x00002000 */ #define ADC_SQR1_SQ2_2 (0x04UL << ADC_SQR1_SQ2_Pos) /*!< 0x00004000 */ #define ADC_SQR1_SQ2_3 (0x08UL << ADC_SQR1_SQ2_Pos) /*!< 0x00008000 */ #define ADC_SQR1_SQ2_4 (0x10UL << ADC_SQR1_SQ2_Pos) /*!< 0x00010000 */ #define ADC_SQR1_SQ3_Pos (18U) #define ADC_SQR1_SQ3_Msk (0x1FUL << ADC_SQR1_SQ3_Pos) /*!< 0x007C0000 */ #define ADC_SQR1_SQ3 ADC_SQR1_SQ3_Msk /*!< ADC 3rd conversion in regular sequence */ #define ADC_SQR1_SQ3_0 (0x01UL << ADC_SQR1_SQ3_Pos) /*!< 0x00040000 */ #define ADC_SQR1_SQ3_1 (0x02UL << ADC_SQR1_SQ3_Pos) /*!< 0x00080000 */ #define ADC_SQR1_SQ3_2 (0x04UL << ADC_SQR1_SQ3_Pos) /*!< 0x00100000 */ #define ADC_SQR1_SQ3_3 (0x08UL << ADC_SQR1_SQ3_Pos) /*!< 0x00200000 */ #define ADC_SQR1_SQ3_4 (0x10UL << ADC_SQR1_SQ3_Pos) /*!< 0x00400000 */ #define ADC_SQR1_SQ4_Pos (24U) #define ADC_SQR1_SQ4_Msk (0x1FUL << ADC_SQR1_SQ4_Pos) /*!< 0x1F000000 */ #define ADC_SQR1_SQ4 ADC_SQR1_SQ4_Msk /*!< ADC 4th conversion in regular sequence */ #define ADC_SQR1_SQ4_0 (0x01UL << ADC_SQR1_SQ4_Pos) /*!< 0x01000000 */ #define ADC_SQR1_SQ4_1 (0x02UL << ADC_SQR1_SQ4_Pos) /*!< 0x02000000 */ #define ADC_SQR1_SQ4_2 (0x04UL << ADC_SQR1_SQ4_Pos) /*!< 0x04000000 */ #define ADC_SQR1_SQ4_3 (0x08UL << ADC_SQR1_SQ4_Pos) /*!< 0x08000000 */ #define ADC_SQR1_SQ4_4 (0x10UL << ADC_SQR1_SQ4_Pos) /*!< 0x10000000 */ /******************** Bit definition for ADC_SQR2 register ********************/ #define ADC_SQR2_SQ5_Pos (0U) #define ADC_SQR2_SQ5_Msk (0x1FUL << ADC_SQR2_SQ5_Pos) /*!< 0x0000001F */ #define ADC_SQR2_SQ5 ADC_SQR2_SQ5_Msk /*!< ADC 5th conversion in regular sequence */ #define ADC_SQR2_SQ5_0 (0x01UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000001 */ #define ADC_SQR2_SQ5_1 (0x02UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000002 */ #define ADC_SQR2_SQ5_2 (0x04UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000004 */ #define ADC_SQR2_SQ5_3 (0x08UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000008 */ #define ADC_SQR2_SQ5_4 (0x10UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000010 */ #define ADC_SQR2_SQ6_Pos (6U) #define ADC_SQR2_SQ6_Msk (0x1FUL << ADC_SQR2_SQ6_Pos) /*!< 0x000007C0 */ #define ADC_SQR2_SQ6 ADC_SQR2_SQ6_Msk /*!< ADC 6th conversion in regular sequence */ #define ADC_SQR2_SQ6_0 (0x01UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000040 */ #define ADC_SQR2_SQ6_1 (0x02UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000080 */ #define ADC_SQR2_SQ6_2 (0x04UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000100 */ #define ADC_SQR2_SQ6_3 (0x08UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000200 */ #define ADC_SQR2_SQ6_4 (0x10UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000400 */ #define ADC_SQR2_SQ7_Pos (12U) #define ADC_SQR2_SQ7_Msk (0x1FUL << ADC_SQR2_SQ7_Pos) /*!< 0x0001F000 */ #define ADC_SQR2_SQ7 ADC_SQR2_SQ7_Msk /*!< ADC 7th conversion in regular sequence */ #define ADC_SQR2_SQ7_0 (0x01UL << ADC_SQR2_SQ7_Pos) /*!< 0x00001000 */ #define ADC_SQR2_SQ7_1 (0x02UL << ADC_SQR2_SQ7_Pos) /*!< 0x00002000 */ #define ADC_SQR2_SQ7_2 (0x04UL << ADC_SQR2_SQ7_Pos) /*!< 0x00004000 */ #define ADC_SQR2_SQ7_3 (0x08UL << ADC_SQR2_SQ7_Pos) /*!< 0x00008000 */ #define ADC_SQR2_SQ7_4 (0x10UL << ADC_SQR2_SQ7_Pos) /*!< 0x00010000 */ #define ADC_SQR2_SQ8_Pos (18U) #define ADC_SQR2_SQ8_Msk (0x1FUL << ADC_SQR2_SQ8_Pos) /*!< 0x007C0000 */ #define ADC_SQR2_SQ8 ADC_SQR2_SQ8_Msk /*!< ADC 8th conversion in regular sequence */ #define ADC_SQR2_SQ8_0 (0x01UL << ADC_SQR2_SQ8_Pos) /*!< 0x00040000 */ #define ADC_SQR2_SQ8_1 (0x02UL << ADC_SQR2_SQ8_Pos) /*!< 0x00080000 */ #define ADC_SQR2_SQ8_2 (0x04UL << ADC_SQR2_SQ8_Pos) /*!< 0x00100000 */ #define ADC_SQR2_SQ8_3 (0x08UL << ADC_SQR2_SQ8_Pos) /*!< 0x00200000 */ #define ADC_SQR2_SQ8_4 (0x10UL << ADC_SQR2_SQ8_Pos) /*!< 0x00400000 */ #define ADC_SQR2_SQ9_Pos (24U) #define ADC_SQR2_SQ9_Msk (0x1FUL << ADC_SQR2_SQ9_Pos) /*!< 0x1F000000 */ #define ADC_SQR2_SQ9 ADC_SQR2_SQ9_Msk /*!< ADC 9th conversion in regular sequence */ #define ADC_SQR2_SQ9_0 (0x01UL << ADC_SQR2_SQ9_Pos) /*!< 0x01000000 */ #define ADC_SQR2_SQ9_1 (0x02UL << ADC_SQR2_SQ9_Pos) /*!< 0x02000000 */ #define ADC_SQR2_SQ9_2 (0x04UL << ADC_SQR2_SQ9_Pos) /*!< 0x04000000 */ #define ADC_SQR2_SQ9_3 (0x08UL << ADC_SQR2_SQ9_Pos) /*!< 0x08000000 */ #define ADC_SQR2_SQ9_4 (0x10UL << ADC_SQR2_SQ9_Pos) /*!< 0x10000000 */ /******************** Bit definition for ADC_SQR3 register ********************/ #define ADC_SQR3_SQ10_Pos (0U) #define ADC_SQR3_SQ10_Msk (0x1FUL << ADC_SQR3_SQ10_Pos) /*!< 0x0000001F */ #define ADC_SQR3_SQ10 ADC_SQR3_SQ10_Msk /*!< ADC 10th conversion in regular sequence */ #define ADC_SQR3_SQ10_0 (0x01UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000001 */ #define ADC_SQR3_SQ10_1 (0x02UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000002 */ #define ADC_SQR3_SQ10_2 (0x04UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000004 */ #define ADC_SQR3_SQ10_3 (0x08UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000008 */ #define ADC_SQR3_SQ10_4 (0x10UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000010 */ #define ADC_SQR3_SQ11_Pos (6U) #define ADC_SQR3_SQ11_Msk (0x1FUL << ADC_SQR3_SQ11_Pos) /*!< 0x000007C0 */ #define ADC_SQR3_SQ11 ADC_SQR3_SQ11_Msk /*!< ADC 11th conversion in regular sequence */ #define ADC_SQR3_SQ11_0 (0x01UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000040 */ #define ADC_SQR3_SQ11_1 (0x02UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000080 */ #define ADC_SQR3_SQ11_2 (0x04UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000100 */ #define ADC_SQR3_SQ11_3 (0x08UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000200 */ #define ADC_SQR3_SQ11_4 (0x10UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000400 */ #define ADC_SQR3_SQ12_Pos (12U) #define ADC_SQR3_SQ12_Msk (0x1FUL << ADC_SQR3_SQ12_Pos) /*!< 0x0001F000 */ #define ADC_SQR3_SQ12 ADC_SQR3_SQ12_Msk /*!< ADC 12th conversion in regular sequence */ #define ADC_SQR3_SQ12_0 (0x01UL << ADC_SQR3_SQ12_Pos) /*!< 0x00001000 */ #define ADC_SQR3_SQ12_1 (0x02UL << ADC_SQR3_SQ12_Pos) /*!< 0x00002000 */ #define ADC_SQR3_SQ12_2 (0x04UL << ADC_SQR3_SQ12_Pos) /*!< 0x00004000 */ #define ADC_SQR3_SQ12_3 (0x08UL << ADC_SQR3_SQ12_Pos) /*!< 0x00008000 */ #define ADC_SQR3_SQ12_4 (0x10UL << ADC_SQR3_SQ12_Pos) /*!< 0x00010000 */ #define ADC_SQR3_SQ13_Pos (18U) #define ADC_SQR3_SQ13_Msk (0x1FUL << ADC_SQR3_SQ13_Pos) /*!< 0x007C0000 */ #define ADC_SQR3_SQ13 ADC_SQR3_SQ13_Msk /*!< ADC 13th conversion in regular sequence */ #define ADC_SQR3_SQ13_0 (0x01UL << ADC_SQR3_SQ13_Pos) /*!< 0x00040000 */ #define ADC_SQR3_SQ13_1 (0x02UL << ADC_SQR3_SQ13_Pos) /*!< 0x00080000 */ #define ADC_SQR3_SQ13_2 (0x04UL << ADC_SQR3_SQ13_Pos) /*!< 0x00100000 */ #define ADC_SQR3_SQ13_3 (0x08UL << ADC_SQR3_SQ13_Pos) /*!< 0x00200000 */ #define ADC_SQR3_SQ13_4 (0x10UL << ADC_SQR3_SQ13_Pos) /*!< 0x00400000 */ #define ADC_SQR3_SQ14_Pos (24U) #define ADC_SQR3_SQ14_Msk (0x1FUL << ADC_SQR3_SQ14_Pos) /*!< 0x1F000000 */ #define ADC_SQR3_SQ14 ADC_SQR3_SQ14_Msk /*!< ADC 14th conversion in regular sequence */ #define ADC_SQR3_SQ14_0 (0x01UL << ADC_SQR3_SQ14_Pos) /*!< 0x01000000 */ #define ADC_SQR3_SQ14_1 (0x02UL << ADC_SQR3_SQ14_Pos) /*!< 0x02000000 */ #define ADC_SQR3_SQ14_2 (0x04UL << ADC_SQR3_SQ14_Pos) /*!< 0x04000000 */ #define ADC_SQR3_SQ14_3 (0x08UL << ADC_SQR3_SQ14_Pos) /*!< 0x08000000 */ #define ADC_SQR3_SQ14_4 (0x10UL << ADC_SQR3_SQ14_Pos) /*!< 0x10000000 */ /******************** Bit definition for ADC_SQR4 register ********************/ #define ADC_SQR4_SQ15_Pos (0U) #define ADC_SQR4_SQ15_Msk (0x1FUL << ADC_SQR4_SQ15_Pos) /*!< 0x0000001F */ #define ADC_SQR4_SQ15 ADC_SQR4_SQ15_Msk /*!< ADC 15th conversion in regular sequence */ #define ADC_SQR4_SQ15_0 (0x01UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000001 */ #define ADC_SQR4_SQ15_1 (0x02UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000002 */ #define ADC_SQR4_SQ15_2 (0x04UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000004 */ #define ADC_SQR4_SQ15_3 (0x08UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000008 */ #define ADC_SQR4_SQ15_4 (0x10UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000010 */ #define ADC_SQR4_SQ16_Pos (6U) #define ADC_SQR4_SQ16_Msk (0x1FUL << ADC_SQR4_SQ16_Pos) /*!< 0x000007C0 */ #define ADC_SQR4_SQ16 ADC_SQR4_SQ16_Msk /*!< ADC 16th conversion in regular sequence */ #define ADC_SQR4_SQ16_0 (0x01UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000040 */ #define ADC_SQR4_SQ16_1 (0x02UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000080 */ #define ADC_SQR4_SQ16_2 (0x04UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000100 */ #define ADC_SQR4_SQ16_3 (0x08UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000200 */ #define ADC_SQR4_SQ16_4 (0x10UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000400 */ /******************** Bit definition for ADC_DR register ********************/ #define ADC_DR_RDATA_Pos (0U) #define ADC_DR_RDATA_Msk (0xFFFFFFFFUL << ADC_DR_RDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_DR_RDATA ADC_DR_RDATA_Msk /*!< ADC regular Data converted */ /******************** Bit definition for ADC_JSQR register ********************/ #define ADC_JSQR_JL_Pos (0U) #define ADC_JSQR_JL_Msk (0x3UL << ADC_JSQR_JL_Pos) /*!< 0x00000003 */ #define ADC_JSQR_JL ADC_JSQR_JL_Msk /*!< ADC injected channel sequence length */ #define ADC_JSQR_JL_0 (0x1UL << ADC_JSQR_JL_Pos) /*!< 0x00000001 */ #define ADC_JSQR_JL_1 (0x2UL << ADC_JSQR_JL_Pos) /*!< 0x00000002 */ #define ADC_JSQR_JEXTSEL_Pos (2U) #define ADC_JSQR_JEXTSEL_Msk (0x1FUL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x0000007C */ #define ADC_JSQR_JEXTSEL ADC_JSQR_JEXTSEL_Msk /*!< ADC external trigger selection for injected group */ #define ADC_JSQR_JEXTSEL_0 (0x01UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000004 */ #define ADC_JSQR_JEXTSEL_1 (0x02UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000008 */ #define ADC_JSQR_JEXTSEL_2 (0x04UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000010 */ #define ADC_JSQR_JEXTSEL_3 (0x08UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000020 */ #define ADC_JSQR_JEXTSEL_4 (0x10UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000040 */ #define ADC_JSQR_JEXTEN_Pos (7U) #define ADC_JSQR_JEXTEN_Msk (0x3UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000180 */ #define ADC_JSQR_JEXTEN ADC_JSQR_JEXTEN_Msk /*!< ADC external trigger enable and polarity selection for injected channels */ #define ADC_JSQR_JEXTEN_0 (0x1UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000080 */ #define ADC_JSQR_JEXTEN_1 (0x2UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000100 */ #define ADC_JSQR_JSQ1_Pos (9U) #define ADC_JSQR_JSQ1_Msk (0x1FUL << ADC_JSQR_JSQ1_Pos) /*!< 0x00003E00 */ #define ADC_JSQR_JSQ1 ADC_JSQR_JSQ1_Msk /*!< ADC 1st conversion in injected sequence */ #define ADC_JSQR_JSQ1_0 (0x01UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000200 */ #define ADC_JSQR_JSQ1_1 (0x02UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000400 */ #define ADC_JSQR_JSQ1_2 (0x04UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000800 */ #define ADC_JSQR_JSQ1_3 (0x08UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00001000 */ #define ADC_JSQR_JSQ1_4 (0x10UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00002000 */ #define ADC_JSQR_JSQ2_Pos (15U) #define ADC_JSQR_JSQ2_Msk (0x1FUL << ADC_JSQR_JSQ2_Pos) /*!< 0x000F8000 */ #define ADC_JSQR_JSQ2 ADC_JSQR_JSQ2_Msk /*!< ADC 2nd conversion in injected sequence */ #define ADC_JSQR_JSQ2_0 (0x01UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00008000 */ #define ADC_JSQR_JSQ2_1 (0x02UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00010000 */ #define ADC_JSQR_JSQ2_2 (0x04UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00020000 */ #define ADC_JSQR_JSQ2_3 (0x08UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00040000 */ #define ADC_JSQR_JSQ2_4 (0x10UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00080000 */ #define ADC_JSQR_JSQ3_Pos (21U) #define ADC_JSQR_JSQ3_Msk (0x1FUL << ADC_JSQR_JSQ3_Pos) /*!< 0x03E00000 */ #define ADC_JSQR_JSQ3 ADC_JSQR_JSQ3_Msk /*!< ADC 3rd conversion in injected sequence */ #define ADC_JSQR_JSQ3_0 (0x01UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00200000 */ #define ADC_JSQR_JSQ3_1 (0x02UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00400000 */ #define ADC_JSQR_JSQ3_2 (0x04UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00800000 */ #define ADC_JSQR_JSQ3_3 (0x08UL << ADC_JSQR_JSQ3_Pos) /*!< 0x01000000 */ #define ADC_JSQR_JSQ3_4 (0x10UL << ADC_JSQR_JSQ3_Pos) /*!< 0x02000000 */ #define ADC_JSQR_JSQ4_Pos (27U) #define ADC_JSQR_JSQ4_Msk (0x1FUL << ADC_JSQR_JSQ4_Pos) /*!< 0xF8000000 */ #define ADC_JSQR_JSQ4 ADC_JSQR_JSQ4_Msk /*!< ADC 4th conversion in injected sequence */ #define ADC_JSQR_JSQ4_0 (0x01UL << ADC_JSQR_JSQ4_Pos) /*!< 0x08000000 */ #define ADC_JSQR_JSQ4_1 (0x02UL << ADC_JSQR_JSQ4_Pos) /*!< 0x10000000 */ #define ADC_JSQR_JSQ4_2 (0x04UL << ADC_JSQR_JSQ4_Pos) /*!< 0x20000000 */ #define ADC_JSQR_JSQ4_3 (0x08UL << ADC_JSQR_JSQ4_Pos) /*!< 0x40000000 */ #define ADC_JSQR_JSQ4_4 (0x10UL << ADC_JSQR_JSQ4_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_OFR1 register ********************/ #define ADC_OFR1_OFFSET1_Pos (0U) #define ADC_OFR1_OFFSET1_Msk (0x3FFFFFFUL << ADC_OFR1_OFFSET1_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR1_OFFSET1 ADC_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC_OFR1_OFFSET1_0 (0x0000001UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000001 */ #define ADC_OFR1_OFFSET1_1 (0x0000002UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000002 */ #define ADC_OFR1_OFFSET1_2 (0x0000004UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000004 */ #define ADC_OFR1_OFFSET1_3 (0x0000008UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000008 */ #define ADC_OFR1_OFFSET1_4 (0x0000010UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000010 */ #define ADC_OFR1_OFFSET1_5 (0x0000020UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000020 */ #define ADC_OFR1_OFFSET1_6 (0x0000040UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000040 */ #define ADC_OFR1_OFFSET1_7 (0x0000080UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000080 */ #define ADC_OFR1_OFFSET1_8 (0x0000100UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000100 */ #define ADC_OFR1_OFFSET1_9 (0x0000200UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000200 */ #define ADC_OFR1_OFFSET1_10 (0x0000400UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000400 */ #define ADC_OFR1_OFFSET1_11 (0x0000800UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000800 */ #define ADC_OFR1_OFFSET1_12 (0x0001000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00001000 */ #define ADC_OFR1_OFFSET1_13 (0x0002000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00002000 */ #define ADC_OFR1_OFFSET1_14 (0x0004000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00004000 */ #define ADC_OFR1_OFFSET1_15 (0x0008000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00008000 */ #define ADC_OFR1_OFFSET1_16 (0x0010000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00010000 */ #define ADC_OFR1_OFFSET1_17 (0x0020000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00020000 */ #define ADC_OFR1_OFFSET1_18 (0x0040000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00040000 */ #define ADC_OFR1_OFFSET1_19 (0x0080000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00080000 */ #define ADC_OFR1_OFFSET1_20 (0x0100000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00100000 */ #define ADC_OFR1_OFFSET1_21 (0x0200000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00200000 */ #define ADC_OFR1_OFFSET1_22 (0x0400000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00400000 */ #define ADC_OFR1_OFFSET1_23 (0x0800000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00800000 */ #define ADC_OFR1_OFFSET1_24 (0x1000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x01000000 */ #define ADC_OFR1_OFFSET1_25 (0x2000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x02000000 */ #define ADC_OFR1_OFFSET1_CH_Pos (26U) #define ADC_OFR1_OFFSET1_CH_Msk (0x1FUL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR1_OFFSET1_CH ADC_OFR1_OFFSET1_CH_Msk /*!< ADC Channel selection for the data offset 1 */ #define ADC_OFR1_OFFSET1_CH_0 (0x01UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR1_OFFSET1_CH_1 (0x02UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR1_OFFSET1_CH_2 (0x04UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR1_OFFSET1_CH_3 (0x08UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR1_OFFSET1_CH_4 (0x10UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR1_SSATE_Pos (31U) #define ADC_OFR1_SSATE_Msk (0x1UL << ADC_OFR1_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR1_SSATE ADC_OFR1_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR1_OFFSET1_Pos (0U) #define ADC3_OFR1_OFFSET1_Msk (0xFFFUL << ADC3_OFR1_OFFSET1_Pos) /*!< 0x00000FFF */ #define ADC3_OFR1_OFFSET1 ADC3_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR1_OFFSETPOS_Pos (24U) #define ADC3_OFR1_OFFSETPOS_Msk (0x1UL << ADC3_OFR1_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR1_OFFSETPOS ADC3_OFR1_OFFSETPOS_Msk /*!< ADC offset number 1 positive */ #define ADC3_OFR1_SATEN_Pos (25U) #define ADC3_OFR1_SATEN_Msk (0x1UL << ADC3_OFR1_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR1_SATEN ADC3_OFR1_SATEN_Msk /*!< ADC offset number 1 saturation enable */ #define ADC3_OFR1_OFFSET1_EN_Pos (31U) #define ADC3_OFR1_OFFSET1_EN_Msk (0x1UL << ADC3_OFR1_OFFSET1_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR1_OFFSET1_EN ADC3_OFR1_OFFSET1_EN_Msk /*!< ADC offset number 1 enable */ /******************** Bit definition for ADC_OFR2 register ********************/ #define ADC_OFR2_OFFSET2_Pos (0U) #define ADC_OFR2_OFFSET2_Msk (0x3FFFFFFUL << ADC_OFR2_OFFSET2_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR2_OFFSET2 ADC_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET2_CH[4:0] */ #define ADC_OFR2_OFFSET2_0 (0x0000001UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000001 */ #define ADC_OFR2_OFFSET2_1 (0x0000002UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000002 */ #define ADC_OFR2_OFFSET2_2 (0x0000004UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000004 */ #define ADC_OFR2_OFFSET2_3 (0x0000008UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000008 */ #define ADC_OFR2_OFFSET2_4 (0x0000010UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000010 */ #define ADC_OFR2_OFFSET2_5 (0x0000020UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000020 */ #define ADC_OFR2_OFFSET2_6 (0x0000040UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000040 */ #define ADC_OFR2_OFFSET2_7 (0x0000080UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000080 */ #define ADC_OFR2_OFFSET2_8 (0x0000100UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000100 */ #define ADC_OFR2_OFFSET2_9 (0x0000200UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000200 */ #define ADC_OFR2_OFFSET2_10 (0x0000400UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000400 */ #define ADC_OFR2_OFFSET2_11 (0x0000800UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000800 */ #define ADC_OFR2_OFFSET2_12 (0x0001000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00001000 */ #define ADC_OFR2_OFFSET2_13 (0x0002000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00002000 */ #define ADC_OFR2_OFFSET2_14 (0x0004000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00004000 */ #define ADC_OFR2_OFFSET2_15 (0x0008000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00008000 */ #define ADC_OFR2_OFFSET2_16 (0x0010000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00010000 */ #define ADC_OFR2_OFFSET2_17 (0x0020000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00020000 */ #define ADC_OFR2_OFFSET2_18 (0x0040000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00040000 */ #define ADC_OFR2_OFFSET2_19 (0x0080000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00080000 */ #define ADC_OFR2_OFFSET2_20 (0x0100000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00100000 */ #define ADC_OFR2_OFFSET2_21 (0x0200000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00200000 */ #define ADC_OFR2_OFFSET2_22 (0x0400000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00400000 */ #define ADC_OFR2_OFFSET2_23 (0x0800000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00800000 */ #define ADC_OFR2_OFFSET2_24 (0x1000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x01000000 */ #define ADC_OFR2_OFFSET2_25 (0x2000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x02000000 */ #define ADC_OFR2_OFFSET2_CH_Pos (26U) #define ADC_OFR2_OFFSET2_CH_Msk (0x1FUL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR2_OFFSET2_CH ADC_OFR2_OFFSET2_CH_Msk /*!< ADC Channel selection for the data offset 2 */ #define ADC_OFR2_OFFSET2_CH_0 (0x01UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR2_OFFSET2_CH_1 (0x02UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR2_OFFSET2_CH_2 (0x04UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR2_OFFSET2_CH_3 (0x08UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR2_OFFSET2_CH_4 (0x10UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR2_SSATE_Pos (31U) #define ADC_OFR2_SSATE_Msk (0x1UL << ADC_OFR2_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR2_SSATE ADC_OFR2_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR2_OFFSET2_Pos (0U) #define ADC3_OFR2_OFFSET2_Msk (0xFFFUL << ADC3_OFR2_OFFSET2_Pos) /*!< 0x00000FFF */ #define ADC3_OFR2_OFFSET2 ADC3_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR2_OFFSETPOS_Pos (24U) #define ADC3_OFR2_OFFSETPOS_Msk (0x1UL << ADC3_OFR2_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR2_OFFSETPOS ADC3_OFR2_OFFSETPOS_Msk /*!< ADC offset number 2 positive */ #define ADC3_OFR2_SATEN_Pos (25U) #define ADC3_OFR2_SATEN_Msk (0x1UL << ADC3_OFR2_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR2_SATEN ADC3_OFR2_SATEN_Msk /*!< ADC offset number 2 saturation enable */ #define ADC3_OFR2_OFFSET2_EN_Pos (31U) #define ADC3_OFR2_OFFSET2_EN_Msk (0x1UL << ADC3_OFR2_OFFSET2_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR2_OFFSET2_EN ADC3_OFR2_OFFSET2_EN_Msk /*!< ADC offset number 2 enable */ /******************** Bit definition for ADC_OFR3 register ********************/ #define ADC_OFR3_OFFSET3_Pos (0U) #define ADC_OFR3_OFFSET3_Msk (0x3FFFFFFUL << ADC_OFR3_OFFSET3_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR3_OFFSET3 ADC_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET3_CH[4:0] */ #define ADC_OFR3_OFFSET3_0 (0x0000001UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000001 */ #define ADC_OFR3_OFFSET3_1 (0x0000002UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000002 */ #define ADC_OFR3_OFFSET3_2 (0x0000004UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000004 */ #define ADC_OFR3_OFFSET3_3 (0x0000008UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000008 */ #define ADC_OFR3_OFFSET3_4 (0x0000010UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000010 */ #define ADC_OFR3_OFFSET3_5 (0x0000020UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000020 */ #define ADC_OFR3_OFFSET3_6 (0x0000040UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000040 */ #define ADC_OFR3_OFFSET3_7 (0x0000080UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000080 */ #define ADC_OFR3_OFFSET3_8 (0x0000100UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000100 */ #define ADC_OFR3_OFFSET3_9 (0x0000200UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000200 */ #define ADC_OFR3_OFFSET3_10 (0x0000400UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000400 */ #define ADC_OFR3_OFFSET3_11 (0x0000800UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000800 */ #define ADC_OFR3_OFFSET3_12 (0x0001000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00001000 */ #define ADC_OFR3_OFFSET3_13 (0x0002000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00002000 */ #define ADC_OFR3_OFFSET3_14 (0x0004000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00004000 */ #define ADC_OFR3_OFFSET3_15 (0x0008000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00008000 */ #define ADC_OFR3_OFFSET3_16 (0x0010000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00010000 */ #define ADC_OFR3_OFFSET3_17 (0x0020000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00020000 */ #define ADC_OFR3_OFFSET3_18 (0x0040000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00040000 */ #define ADC_OFR3_OFFSET3_19 (0x0080000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00080000 */ #define ADC_OFR3_OFFSET3_20 (0x0100000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00100000 */ #define ADC_OFR3_OFFSET3_21 (0x0200000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00200000 */ #define ADC_OFR3_OFFSET3_22 (0x0400000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00400000 */ #define ADC_OFR3_OFFSET3_23 (0x0800000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00800000 */ #define ADC_OFR3_OFFSET3_24 (0x1000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x01000000 */ #define ADC_OFR3_OFFSET3_25 (0x2000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x02000000 */ #define ADC_OFR3_OFFSET3_CH_Pos (26U) #define ADC_OFR3_OFFSET3_CH_Msk (0x1FUL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR3_OFFSET3_CH ADC_OFR3_OFFSET3_CH_Msk /*!< ADC Channel selection for the data offset 3 */ #define ADC_OFR3_OFFSET3_CH_0 (0x01UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR3_OFFSET3_CH_1 (0x02UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR3_OFFSET3_CH_2 (0x04UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR3_OFFSET3_CH_3 (0x08UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR3_OFFSET3_CH_4 (0x10UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR3_SSATE_Pos (31U) #define ADC_OFR3_SSATE_Msk (0x1UL << ADC_OFR3_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR3_SSATE ADC_OFR3_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR3_OFFSET3_Pos (0U) #define ADC3_OFR3_OFFSET3_Msk (0xFFFUL << ADC3_OFR3_OFFSET3_Pos) /*!< 0x00000FFF */ #define ADC3_OFR3_OFFSET3 ADC3_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR3_OFFSETPOS_Pos (24U) #define ADC3_OFR3_OFFSETPOS_Msk (0x1UL << ADC3_OFR3_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR3_OFFSETPOS ADC3_OFR3_OFFSETPOS_Msk /*!< ADC offset number 3 positive */ #define ADC3_OFR3_SATEN_Pos (25U) #define ADC3_OFR3_SATEN_Msk (0x1UL << ADC3_OFR3_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR3_SATEN ADC3_OFR3_SATEN_Msk /*!< ADC offset number 3 saturation enable */ #define ADC3_OFR3_OFFSET3_EN_Pos (31U) #define ADC3_OFR3_OFFSET3_EN_Msk (0x1UL << ADC3_OFR3_OFFSET3_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR3_OFFSET3_EN ADC3_OFR3_OFFSET3_EN_Msk /*!< ADC offset number 3 enable */ /******************** Bit definition for ADC_OFR4 register ********************/ #define ADC_OFR4_OFFSET4_Pos (0U) #define ADC_OFR4_OFFSET4_Msk (0x3FFFFFFUL << ADC_OFR4_OFFSET4_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR4_OFFSET4 ADC_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET4_CH[4:0] */ #define ADC_OFR4_OFFSET4_0 (0x0000001UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000001 */ #define ADC_OFR4_OFFSET4_1 (0x0000002UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000002 */ #define ADC_OFR4_OFFSET4_2 (0x0000004UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000004 */ #define ADC_OFR4_OFFSET4_3 (0x0000008UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000008 */ #define ADC_OFR4_OFFSET4_4 (0x0000010UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000010 */ #define ADC_OFR4_OFFSET4_5 (0x0000020UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000020 */ #define ADC_OFR4_OFFSET4_6 (0x0000040UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000040 */ #define ADC_OFR4_OFFSET4_7 (0x0000080UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000080 */ #define ADC_OFR4_OFFSET4_8 (0x0000100UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000100 */ #define ADC_OFR4_OFFSET4_9 (0x0000200UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000200 */ #define ADC_OFR4_OFFSET4_10 (0x0000400UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000400 */ #define ADC_OFR4_OFFSET4_11 (0x0000800UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000800 */ #define ADC_OFR4_OFFSET4_12 (0x0001000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00001000 */ #define ADC_OFR4_OFFSET4_13 (0x0002000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00002000 */ #define ADC_OFR4_OFFSET4_14 (0x0004000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00004000 */ #define ADC_OFR4_OFFSET4_15 (0x0008000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00008000 */ #define ADC_OFR4_OFFSET4_16 (0x0010000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00010000 */ #define ADC_OFR4_OFFSET4_17 (0x0020000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00020000 */ #define ADC_OFR4_OFFSET4_18 (0x0040000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00040000 */ #define ADC_OFR4_OFFSET4_19 (0x0080000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00080000 */ #define ADC_OFR4_OFFSET4_20 (0x0100000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00100000 */ #define ADC_OFR4_OFFSET4_21 (0x0200000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00200000 */ #define ADC_OFR4_OFFSET4_22 (0x0400000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00400000 */ #define ADC_OFR4_OFFSET4_23 (0x0800000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00800000 */ #define ADC_OFR4_OFFSET4_24 (0x1000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x01000000 */ #define ADC_OFR4_OFFSET4_25 (0x2000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x02000000 */ #define ADC_OFR4_OFFSET4_CH_Pos (26U) #define ADC_OFR4_OFFSET4_CH_Msk (0x1FUL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR4_OFFSET4_CH ADC_OFR4_OFFSET4_CH_Msk /*!< ADC Channel selection for the data offset 4 */ #define ADC_OFR4_OFFSET4_CH_0 (0x01UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR4_OFFSET4_CH_1 (0x02UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR4_OFFSET4_CH_2 (0x04UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR4_OFFSET4_CH_3 (0x08UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR4_OFFSET4_CH_4 (0x10UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR4_SSATE_Pos (31U) #define ADC_OFR4_SSATE_Msk (0x1UL << ADC_OFR4_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR4_SSATE ADC_OFR4_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR4_OFFSET4_Pos (0U) #define ADC3_OFR4_OFFSET4_Msk (0xFFFUL << ADC3_OFR4_OFFSET4_Pos) /*!< 0x00000FFF */ #define ADC3_OFR4_OFFSET4 ADC3_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR4_OFFSETPOS_Pos (24U) #define ADC3_OFR4_OFFSETPOS_Msk (0x1UL << ADC3_OFR4_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR4_OFFSETPOS ADC3_OFR4_OFFSETPOS_Msk /*!< ADC offset number 4 positive */ #define ADC3_OFR4_SATEN_Pos (25U) #define ADC3_OFR4_SATEN_Msk (0x1UL << ADC3_OFR4_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR4_SATEN ADC3_OFR4_SATEN_Msk /*!< ADC offset number 4 saturation enable */ #define ADC3_OFR4_OFFSET4_EN_Pos (31U) #define ADC3_OFR4_OFFSET4_EN_Msk (0x1UL << ADC3_OFR4_OFFSET4_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR4_OFFSET4_EN ADC3_OFR4_OFFSET4_EN_Msk /*!< ADC offset number 4 enable */ /******************** Bit definition for ADC_JDR1 register ********************/ #define ADC_JDR1_JDATA_Pos (0U) #define ADC_JDR1_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR1_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR1_JDATA ADC_JDR1_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR1_JDATA_0 (0x00000001UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR1_JDATA_1 (0x00000002UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR1_JDATA_2 (0x00000004UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR1_JDATA_3 (0x00000008UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR1_JDATA_4 (0x00000010UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR1_JDATA_5 (0x00000020UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR1_JDATA_6 (0x00000040UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR1_JDATA_7 (0x00000080UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR1_JDATA_8 (0x00000100UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR1_JDATA_9 (0x00000200UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR1_JDATA_10 (0x00000400UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR1_JDATA_11 (0x00000800UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR1_JDATA_12 (0x00001000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR1_JDATA_13 (0x00002000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR1_JDATA_14 (0x00004000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR1_JDATA_15 (0x00008000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR1_JDATA_16 (0x00010000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR1_JDATA_17 (0x00020000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR1_JDATA_18 (0x00040000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR1_JDATA_19 (0x00080000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR1_JDATA_20 (0x00100000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR1_JDATA_21 (0x00200000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR1_JDATA_22 (0x00400000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR1_JDATA_23 (0x00800000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR1_JDATA_24 (0x01000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR1_JDATA_25 (0x02000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR1_JDATA_26 (0x04000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR1_JDATA_27 (0x08000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR1_JDATA_28 (0x10000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR1_JDATA_29 (0x20000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR1_JDATA_30 (0x40000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR1_JDATA_31 (0x80000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_JDR2 register ********************/ #define ADC_JDR2_JDATA_Pos (0U) #define ADC_JDR2_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR2_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR2_JDATA ADC_JDR2_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR2_JDATA_0 (0x00000001UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR2_JDATA_1 (0x00000002UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR2_JDATA_2 (0x00000004UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR2_JDATA_3 (0x00000008UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR2_JDATA_4 (0x00000010UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR2_JDATA_5 (0x00000020UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR2_JDATA_6 (0x00000040UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR2_JDATA_7 (0x00000080UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR2_JDATA_8 (0x00000100UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR2_JDATA_9 (0x00000200UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR2_JDATA_10 (0x00000400UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR2_JDATA_11 (0x00000800UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR2_JDATA_12 (0x00001000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR2_JDATA_13 (0x00002000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR2_JDATA_14 (0x00004000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR2_JDATA_15 (0x00008000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR2_JDATA_16 (0x00010000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR2_JDATA_17 (0x00020000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR2_JDATA_18 (0x00040000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR2_JDATA_19 (0x00080000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR2_JDATA_20 (0x00100000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR2_JDATA_21 (0x00200000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR2_JDATA_22 (0x00400000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR2_JDATA_23 (0x00800000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR2_JDATA_24 (0x01000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR2_JDATA_25 (0x02000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR2_JDATA_26 (0x04000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR2_JDATA_27 (0x08000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR2_JDATA_28 (0x10000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR2_JDATA_29 (0x20000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR2_JDATA_30 (0x40000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR2_JDATA_31 (0x80000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_JDR3 register ********************/ #define ADC_JDR3_JDATA_Pos (0U) #define ADC_JDR3_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR3_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR3_JDATA ADC_JDR3_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR3_JDATA_0 (0x00000001UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR3_JDATA_1 (0x00000002UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR3_JDATA_2 (0x00000004UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR3_JDATA_3 (0x00000008UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR3_JDATA_4 (0x00000010UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR3_JDATA_5 (0x00000020UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR3_JDATA_6 (0x00000040UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR3_JDATA_7 (0x00000080UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR3_JDATA_8 (0x00000100UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR3_JDATA_9 (0x00000200UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR3_JDATA_10 (0x00000400UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR3_JDATA_11 (0x00000800UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR3_JDATA_12 (0x00001000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR3_JDATA_13 (0x00002000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR3_JDATA_14 (0x00004000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR3_JDATA_15 (0x00008000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR3_JDATA_16 (0x00010000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR3_JDATA_17 (0x00020000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR3_JDATA_18 (0x00040000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR3_JDATA_19 (0x00080000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR3_JDATA_20 (0x00100000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR3_JDATA_21 (0x00200000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR3_JDATA_22 (0x00400000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR3_JDATA_23 (0x00800000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR3_JDATA_24 (0x01000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR3_JDATA_25 (0x02000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR3_JDATA_26 (0x04000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR3_JDATA_27 (0x08000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR3_JDATA_28 (0x10000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR3_JDATA_29 (0x20000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR3_JDATA_30 (0x40000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR3_JDATA_31 (0x80000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_JDR4 register ********************/ #define ADC_JDR4_JDATA_Pos (0U) #define ADC_JDR4_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR4_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR4_JDATA ADC_JDR4_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR4_JDATA_0 (0x00000001UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR4_JDATA_1 (0x00000002UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR4_JDATA_2 (0x00000004UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR4_JDATA_3 (0x00000008UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR4_JDATA_4 (0x00000010UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR4_JDATA_5 (0x00000020UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR4_JDATA_6 (0x00000040UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR4_JDATA_7 (0x00000080UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR4_JDATA_8 (0x00000100UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR4_JDATA_9 (0x00000200UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR4_JDATA_10 (0x00000400UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR4_JDATA_11 (0x00000800UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR4_JDATA_12 (0x00001000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR4_JDATA_13 (0x00002000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR4_JDATA_14 (0x00004000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR4_JDATA_15 (0x00008000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR4_JDATA_16 (0x00010000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR4_JDATA_17 (0x00020000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR4_JDATA_18 (0x00040000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR4_JDATA_19 (0x00080000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR4_JDATA_20 (0x00100000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR4_JDATA_21 (0x00200000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR4_JDATA_22 (0x00400000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR4_JDATA_23 (0x00800000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR4_JDATA_24 (0x01000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR4_JDATA_25 (0x02000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR4_JDATA_26 (0x04000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR4_JDATA_27 (0x08000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR4_JDATA_28 (0x10000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR4_JDATA_29 (0x20000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR4_JDATA_30 (0x40000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR4_JDATA_31 (0x80000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_AWD2CR register ********************/ #define ADC_AWD2CR_AWD2CH_Pos (0U) #define ADC_AWD2CR_AWD2CH_Msk (0xFFFFFUL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x000FFFFF */ #define ADC_AWD2CR_AWD2CH ADC_AWD2CR_AWD2CH_Msk /*!< ADC Analog watchdog 2 channel selection */ #define ADC_AWD2CR_AWD2CH_0 (0x00001UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000001 */ #define ADC_AWD2CR_AWD2CH_1 (0x00002UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000002 */ #define ADC_AWD2CR_AWD2CH_2 (0x00004UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000004 */ #define ADC_AWD2CR_AWD2CH_3 (0x00008UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000008 */ #define ADC_AWD2CR_AWD2CH_4 (0x00010UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000010 */ #define ADC_AWD2CR_AWD2CH_5 (0x00020UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000020 */ #define ADC_AWD2CR_AWD2CH_6 (0x00040UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000040 */ #define ADC_AWD2CR_AWD2CH_7 (0x00080UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000080 */ #define ADC_AWD2CR_AWD2CH_8 (0x00100UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000100 */ #define ADC_AWD2CR_AWD2CH_9 (0x00200UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000200 */ #define ADC_AWD2CR_AWD2CH_10 (0x00400UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000400 */ #define ADC_AWD2CR_AWD2CH_11 (0x00800UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000800 */ #define ADC_AWD2CR_AWD2CH_12 (0x01000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00001000 */ #define ADC_AWD2CR_AWD2CH_13 (0x02000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00002000 */ #define ADC_AWD2CR_AWD2CH_14 (0x04000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00004000 */ #define ADC_AWD2CR_AWD2CH_15 (0x08000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00008000 */ #define ADC_AWD2CR_AWD2CH_16 (0x10000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00010000 */ #define ADC_AWD2CR_AWD2CH_17 (0x20000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00020000 */ #define ADC_AWD2CR_AWD2CH_18 (0x40000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00040000 */ #define ADC_AWD2CR_AWD2CH_19 (0x80000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00080000 */ /******************** Bit definition for ADC_AWD3CR register ********************/ #define ADC_AWD3CR_AWD3CH_Pos (0U) #define ADC_AWD3CR_AWD3CH_Msk (0xFFFFFUL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x000FFFFF */ #define ADC_AWD3CR_AWD3CH ADC_AWD3CR_AWD3CH_Msk /*!< ADC Analog watchdog 2 channel selection */ #define ADC_AWD3CR_AWD3CH_0 (0x00001UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000001 */ #define ADC_AWD3CR_AWD3CH_1 (0x00002UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000002 */ #define ADC_AWD3CR_AWD3CH_2 (0x00004UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000004 */ #define ADC_AWD3CR_AWD3CH_3 (0x00008UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000008 */ #define ADC_AWD3CR_AWD3CH_4 (0x00010UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000010 */ #define ADC_AWD3CR_AWD3CH_5 (0x00020UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000020 */ #define ADC_AWD3CR_AWD3CH_6 (0x00040UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000040 */ #define ADC_AWD3CR_AWD3CH_7 (0x00080UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000080 */ #define ADC_AWD3CR_AWD3CH_8 (0x00100UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000100 */ #define ADC_AWD3CR_AWD3CH_9 (0x00200UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000200 */ #define ADC_AWD3CR_AWD3CH_10 (0x00400UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000400 */ #define ADC_AWD3CR_AWD3CH_11 (0x00800UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000800 */ #define ADC_AWD3CR_AWD3CH_12 (0x01000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00001000 */ #define ADC_AWD3CR_AWD3CH_13 (0x02000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00002000 */ #define ADC_AWD3CR_AWD3CH_14 (0x04000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00004000 */ #define ADC_AWD3CR_AWD3CH_15 (0x08000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00008000 */ #define ADC_AWD3CR_AWD3CH_16 (0x10000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00010000 */ #define ADC_AWD3CR_AWD3CH_17 (0x20000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00020000 */ #define ADC_AWD3CR_AWD3CH_18 (0x40000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00040000 */ #define ADC_AWD3CR_AWD3CH_19 (0x80000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00080000 */ /******************** Bit definition for ADC_DIFSEL register ********************/ #define ADC_DIFSEL_DIFSEL_Pos (0U) #define ADC_DIFSEL_DIFSEL_Msk (0xFFFFFUL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x000FFFFF */ #define ADC_DIFSEL_DIFSEL ADC_DIFSEL_DIFSEL_Msk /*!< ADC differential modes for channels 1 to 18 */ #define ADC_DIFSEL_DIFSEL_0 (0x00001UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000001 */ #define ADC_DIFSEL_DIFSEL_1 (0x00002UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000002 */ #define ADC_DIFSEL_DIFSEL_2 (0x00004UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000004 */ #define ADC_DIFSEL_DIFSEL_3 (0x00008UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000008 */ #define ADC_DIFSEL_DIFSEL_4 (0x00010UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000010 */ #define ADC_DIFSEL_DIFSEL_5 (0x00020UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000020 */ #define ADC_DIFSEL_DIFSEL_6 (0x00040UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000040 */ #define ADC_DIFSEL_DIFSEL_7 (0x00080UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000080 */ #define ADC_DIFSEL_DIFSEL_8 (0x00100UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000100 */ #define ADC_DIFSEL_DIFSEL_9 (0x00200UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000200 */ #define ADC_DIFSEL_DIFSEL_10 (0x00400UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000400 */ #define ADC_DIFSEL_DIFSEL_11 (0x00800UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000800 */ #define ADC_DIFSEL_DIFSEL_12 (0x01000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00001000 */ #define ADC_DIFSEL_DIFSEL_13 (0x02000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00002000 */ #define ADC_DIFSEL_DIFSEL_14 (0x04000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00004000 */ #define ADC_DIFSEL_DIFSEL_15 (0x08000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00008000 */ #define ADC_DIFSEL_DIFSEL_16 (0x10000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00010000 */ #define ADC_DIFSEL_DIFSEL_17 (0x20000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00020000 */ #define ADC_DIFSEL_DIFSEL_18 (0x40000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00040000 */ #define ADC_DIFSEL_DIFSEL_19 (0x80000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00080000 */ /******************** Bit definition for ADC_CALFACT register ********************/ #define ADC_CALFACT_CALFACT_S_Pos (0U) #define ADC_CALFACT_CALFACT_S_Msk (0x7FFUL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x000007FF */ #define ADC_CALFACT_CALFACT_S ADC_CALFACT_CALFACT_S_Msk /*!< ADC calibration factors in single-ended mode */ #define ADC_CALFACT_CALFACT_S_0 (0x001UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000001 */ #define ADC_CALFACT_CALFACT_S_1 (0x002UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000002 */ #define ADC_CALFACT_CALFACT_S_2 (0x004UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000004 */ #define ADC_CALFACT_CALFACT_S_3 (0x008UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000008 */ #define ADC_CALFACT_CALFACT_S_4 (0x010UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000010 */ #define ADC_CALFACT_CALFACT_S_5 (0x020UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000020 */ #define ADC_CALFACT_CALFACT_S_6 (0x040UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000040 */ #define ADC_CALFACT_CALFACT_S_7 (0x080UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000080 */ #define ADC_CALFACT_CALFACT_S_8 (0x100UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000100 */ #define ADC_CALFACT_CALFACT_S_9 (0x200UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000200 */ #define ADC_CALFACT_CALFACT_S_10 (0x400UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000400 */ #define ADC_CALFACT_CALFACT_D_Pos (16U) #define ADC_CALFACT_CALFACT_D_Msk (0x7FFUL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x07FF0000 */ #define ADC_CALFACT_CALFACT_D ADC_CALFACT_CALFACT_D_Msk /*!< ADC calibration factors in differential mode */ #define ADC_CALFACT_CALFACT_D_0 (0x001UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00010000 */ #define ADC_CALFACT_CALFACT_D_1 (0x002UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00020000 */ #define ADC_CALFACT_CALFACT_D_2 (0x004UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00040000 */ #define ADC_CALFACT_CALFACT_D_3 (0x008UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00080000 */ #define ADC_CALFACT_CALFACT_D_4 (0x010UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00100000 */ #define ADC_CALFACT_CALFACT_D_5 (0x020UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00200000 */ #define ADC_CALFACT_CALFACT_D_6 (0x040UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00400000 */ #define ADC_CALFACT_CALFACT_D_7 (0x080UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00800000 */ #define ADC_CALFACT_CALFACT_D_8 (0x100UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x01000000 */ #define ADC_CALFACT_CALFACT_D_9 (0x200UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x02000000 */ #define ADC_CALFACT_CALFACT_D_10 (0x400UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x04000000 */ /******************** Bit definition for ADC_CALFACT2 register ********************/ #define ADC_CALFACT2_LINCALFACT_Pos (0U) #define ADC_CALFACT2_LINCALFACT_Msk (0x3FFFFFFFUL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x3FFFFFFF */ #define ADC_CALFACT2_LINCALFACT ADC_CALFACT2_LINCALFACT_Msk /*!< ADC Linearity calibration factors */ #define ADC_CALFACT2_LINCALFACT_0 (0x00000001UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000001 */ #define ADC_CALFACT2_LINCALFACT_1 (0x00000002UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000002 */ #define ADC_CALFACT2_LINCALFACT_2 (0x00000004UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000004 */ #define ADC_CALFACT2_LINCALFACT_3 (0x00000008UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000008 */ #define ADC_CALFACT2_LINCALFACT_4 (0x00000010UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000010 */ #define ADC_CALFACT2_LINCALFACT_5 (0x00000020UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000020 */ #define ADC_CALFACT2_LINCALFACT_6 (0x00000040UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000040 */ #define ADC_CALFACT2_LINCALFACT_7 (0x00000080UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000080 */ #define ADC_CALFACT2_LINCALFACT_8 (0x00000100UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000100 */ #define ADC_CALFACT2_LINCALFACT_9 (0x00000200UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000200 */ #define ADC_CALFACT2_LINCALFACT_10 (0x00000400UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000400 */ #define ADC_CALFACT2_LINCALFACT_11 (0x00000800UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000800 */ #define ADC_CALFACT2_LINCALFACT_12 (0x00001000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00001000 */ #define ADC_CALFACT2_LINCALFACT_13 (0x00002000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00002000 */ #define ADC_CALFACT2_LINCALFACT_14 (0x00004000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00004000 */ #define ADC_CALFACT2_LINCALFACT_15 (0x00008000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00008000 */ #define ADC_CALFACT2_LINCALFACT_16 (0x00010000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00010000 */ #define ADC_CALFACT2_LINCALFACT_17 (0x00020000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00020000 */ #define ADC_CALFACT2_LINCALFACT_18 (0x00040000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00040000 */ #define ADC_CALFACT2_LINCALFACT_19 (0x00080000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00080000 */ #define ADC_CALFACT2_LINCALFACT_20 (0x00100000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00100000 */ #define ADC_CALFACT2_LINCALFACT_21 (0x00200000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00200000 */ #define ADC_CALFACT2_LINCALFACT_22 (0x00400000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00400000 */ #define ADC_CALFACT2_LINCALFACT_23 (0x00800000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00800000 */ #define ADC_CALFACT2_LINCALFACT_24 (0x01000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x01000000 */ #define ADC_CALFACT2_LINCALFACT_25 (0x02000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x02000000 */ #define ADC_CALFACT2_LINCALFACT_26 (0x04000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x04000000 */ #define ADC_CALFACT2_LINCALFACT_27 (0x08000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x08000000 */ #define ADC_CALFACT2_LINCALFACT_28 (0x10000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x10000000 */ #define ADC_CALFACT2_LINCALFACT_29 (0x20000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x20000000 */ /************************* ADC Common registers *****************************/ /******************** Bit definition for ADC_CSR register ********************/ #define ADC_CSR_ADRDY_MST_Pos (0U) #define ADC_CSR_ADRDY_MST_Msk (0x1UL << ADC_CSR_ADRDY_MST_Pos) /*!< 0x00000001 */ #define ADC_CSR_ADRDY_MST ADC_CSR_ADRDY_MST_Msk /*!< Master ADC ready */ #define ADC_CSR_EOSMP_MST_Pos (1U) #define ADC_CSR_EOSMP_MST_Msk (0x1UL << ADC_CSR_EOSMP_MST_Pos) /*!< 0x00000002 */ #define ADC_CSR_EOSMP_MST ADC_CSR_EOSMP_MST_Msk /*!< End of sampling phase flag of the master ADC */ #define ADC_CSR_EOC_MST_Pos (2U) #define ADC_CSR_EOC_MST_Msk (0x1UL << ADC_CSR_EOC_MST_Pos) /*!< 0x00000004 */ #define ADC_CSR_EOC_MST ADC_CSR_EOC_MST_Msk /*!< End of regular conversion of the master ADC */ #define ADC_CSR_EOS_MST_Pos (3U) #define ADC_CSR_EOS_MST_Msk (0x1UL << ADC_CSR_EOS_MST_Pos) /*!< 0x00000008 */ #define ADC_CSR_EOS_MST ADC_CSR_EOS_MST_Msk /*!< End of regular sequence flag of the master ADC */ #define ADC_CSR_OVR_MST_Pos (4U) #define ADC_CSR_OVR_MST_Msk (0x1UL << ADC_CSR_OVR_MST_Pos) /*!< 0x00000010 */ #define ADC_CSR_OVR_MST ADC_CSR_OVR_MST_Msk /*!< Overrun flag of the master ADC */ #define ADC_CSR_JEOC_MST_Pos (5U) #define ADC_CSR_JEOC_MST_Msk (0x1UL << ADC_CSR_JEOC_MST_Pos) /*!< 0x00000020 */ #define ADC_CSR_JEOC_MST ADC_CSR_JEOC_MST_Msk /*!< End of injected conversion of the master ADC */ #define ADC_CSR_JEOS_MST_Pos (6U) #define ADC_CSR_JEOS_MST_Msk (0x1UL << ADC_CSR_JEOS_MST_Pos) /*!< 0x00000040 */ #define ADC_CSR_JEOS_MST ADC_CSR_JEOS_MST_Msk /*!< End of injected sequence flag of the master ADC */ #define ADC_CSR_AWD1_MST_Pos (7U) #define ADC_CSR_AWD1_MST_Msk (0x1UL << ADC_CSR_AWD1_MST_Pos) /*!< 0x00000080 */ #define ADC_CSR_AWD1_MST ADC_CSR_AWD1_MST_Msk /*!< Analog watchdog 1 flag of the master ADC */ #define ADC_CSR_AWD2_MST_Pos (8U) #define ADC_CSR_AWD2_MST_Msk (0x1UL << ADC_CSR_AWD2_MST_Pos) /*!< 0x00000100 */ #define ADC_CSR_AWD2_MST ADC_CSR_AWD2_MST_Msk /*!< Analog watchdog 2 flag of the master ADC */ #define ADC_CSR_AWD3_MST_Pos (9U) #define ADC_CSR_AWD3_MST_Msk (0x1UL << ADC_CSR_AWD3_MST_Pos) /*!< 0x00000200 */ #define ADC_CSR_AWD3_MST ADC_CSR_AWD3_MST_Msk /*!< Analog watchdog 3 flag of the master ADC */ #define ADC_CSR_JQOVF_MST_Pos (10U) #define ADC_CSR_JQOVF_MST_Msk (0x1UL << ADC_CSR_JQOVF_MST_Pos) /*!< 0x00000400 */ #define ADC_CSR_JQOVF_MST ADC_CSR_JQOVF_MST_Msk /*!< Injected context queue overflow flag of the master ADC */ #define ADC_CSR_ADRDY_SLV_Pos (16U) #define ADC_CSR_ADRDY_SLV_Msk (0x1UL << ADC_CSR_ADRDY_SLV_Pos) /*!< 0x00010000 */ #define ADC_CSR_ADRDY_SLV ADC_CSR_ADRDY_SLV_Msk /*!< Slave ADC ready */ #define ADC_CSR_EOSMP_SLV_Pos (17U) #define ADC_CSR_EOSMP_SLV_Msk (0x1UL << ADC_CSR_EOSMP_SLV_Pos) /*!< 0x00020000 */ #define ADC_CSR_EOSMP_SLV ADC_CSR_EOSMP_SLV_Msk /*!< End of sampling phase flag of the slave ADC */ #define ADC_CSR_EOC_SLV_Pos (18U) #define ADC_CSR_EOC_SLV_Msk (0x1UL << ADC_CSR_EOC_SLV_Pos) /*!< 0x00040000 */ #define ADC_CSR_EOC_SLV ADC_CSR_EOC_SLV_Msk /*!< End of regular conversion of the slave ADC */ #define ADC_CSR_EOS_SLV_Pos (19U) #define ADC_CSR_EOS_SLV_Msk (0x1UL << ADC_CSR_EOS_SLV_Pos) /*!< 0x00080000 */ #define ADC_CSR_EOS_SLV ADC_CSR_EOS_SLV_Msk /*!< End of regular sequence flag of the slave ADC */ #define ADC_CSR_OVR_SLV_Pos (20U) #define ADC_CSR_OVR_SLV_Msk (0x1UL << ADC_CSR_OVR_SLV_Pos) /*!< 0x00100000 */ #define ADC_CSR_OVR_SLV ADC_CSR_OVR_SLV_Msk /*!< Overrun flag of the slave ADC */ #define ADC_CSR_JEOC_SLV_Pos (21U) #define ADC_CSR_JEOC_SLV_Msk (0x1UL << ADC_CSR_JEOC_SLV_Pos) /*!< 0x00200000 */ #define ADC_CSR_JEOC_SLV ADC_CSR_JEOC_SLV_Msk /*!< End of injected conversion of the slave ADC */ #define ADC_CSR_JEOS_SLV_Pos (22U) #define ADC_CSR_JEOS_SLV_Msk (0x1UL << ADC_CSR_JEOS_SLV_Pos) /*!< 0x00400000 */ #define ADC_CSR_JEOS_SLV ADC_CSR_JEOS_SLV_Msk /*!< End of injected sequence flag of the slave ADC */ #define ADC_CSR_AWD1_SLV_Pos (23U) #define ADC_CSR_AWD1_SLV_Msk (0x1UL << ADC_CSR_AWD1_SLV_Pos) /*!< 0x00800000 */ #define ADC_CSR_AWD1_SLV ADC_CSR_AWD1_SLV_Msk /*!< Analog watchdog 1 flag of the slave ADC */ #define ADC_CSR_AWD2_SLV_Pos (24U) #define ADC_CSR_AWD2_SLV_Msk (0x1UL << ADC_CSR_AWD2_SLV_Pos) /*!< 0x01000000 */ #define ADC_CSR_AWD2_SLV ADC_CSR_AWD2_SLV_Msk /*!< Analog watchdog 2 flag of the slave ADC */ #define ADC_CSR_AWD3_SLV_Pos (25U) #define ADC_CSR_AWD3_SLV_Msk (0x1UL << ADC_CSR_AWD3_SLV_Pos) /*!< 0x02000000 */ #define ADC_CSR_AWD3_SLV ADC_CSR_AWD3_SLV_Msk /*!< Analog watchdog 3 flag of the slave ADC */ #define ADC_CSR_JQOVF_SLV_Pos (26U) #define ADC_CSR_JQOVF_SLV_Msk (0x1UL << ADC_CSR_JQOVF_SLV_Pos) /*!< 0x04000000 */ #define ADC_CSR_JQOVF_SLV ADC_CSR_JQOVF_SLV_Msk /*!< Injected context queue overflow flag of the slave ADC */ /******************** Bit definition for ADC_CCR register ********************/ #define ADC_CCR_DUAL_Pos (0U) #define ADC_CCR_DUAL_Msk (0x1FUL << ADC_CCR_DUAL_Pos) /*!< 0x0000001F */ #define ADC_CCR_DUAL ADC_CCR_DUAL_Msk /*!< Dual ADC mode selection */ #define ADC_CCR_DUAL_0 (0x01UL << ADC_CCR_DUAL_Pos) /*!< 0x00000001 */ #define ADC_CCR_DUAL_1 (0x02UL << ADC_CCR_DUAL_Pos) /*!< 0x00000002 */ #define ADC_CCR_DUAL_2 (0x04UL << ADC_CCR_DUAL_Pos) /*!< 0x00000004 */ #define ADC_CCR_DUAL_3 (0x08UL << ADC_CCR_DUAL_Pos) /*!< 0x00000008 */ #define ADC_CCR_DUAL_4 (0x10UL << ADC_CCR_DUAL_Pos) /*!< 0x00000010 */ #define ADC_CCR_DELAY_Pos (8U) #define ADC_CCR_DELAY_Msk (0xFUL << ADC_CCR_DELAY_Pos) /*!< 0x00000F00 */ #define ADC_CCR_DELAY ADC_CCR_DELAY_Msk /*!< Delay between 2 sampling phases */ #define ADC_CCR_DELAY_0 (0x1UL << ADC_CCR_DELAY_Pos) /*!< 0x00000100 */ #define ADC_CCR_DELAY_1 (0x2UL << ADC_CCR_DELAY_Pos) /*!< 0x00000200 */ #define ADC_CCR_DELAY_2 (0x4UL << ADC_CCR_DELAY_Pos) /*!< 0x00000400 */ #define ADC_CCR_DELAY_3 (0x8UL << ADC_CCR_DELAY_Pos) /*!< 0x00000800 */ #define ADC_CCR_DAMDF_Pos (14U) #define ADC_CCR_DAMDF_Msk (0x3UL << ADC_CCR_DAMDF_Pos) /*!< 0x0000C000 */ #define ADC_CCR_DAMDF ADC_CCR_DAMDF_Msk /*!< Dual ADC mode Data format */ #define ADC_CCR_DAMDF_0 (0x1UL << ADC_CCR_DAMDF_Pos) /*!< 0x00004000 */ #define ADC_CCR_DAMDF_1 (0x2UL << ADC_CCR_DAMDF_Pos) /*!< 0x00008000 */ #define ADC_CCR_CKMODE_Pos (16U) #define ADC_CCR_CKMODE_Msk (0x3UL << ADC_CCR_CKMODE_Pos) /*!< 0x00030000 */ #define ADC_CCR_CKMODE ADC_CCR_CKMODE_Msk /*!< ADC clock mode */ #define ADC_CCR_CKMODE_0 (0x1UL << ADC_CCR_CKMODE_Pos) /*!< 0x00010000 */ #define ADC_CCR_CKMODE_1 (0x2UL << ADC_CCR_CKMODE_Pos) /*!< 0x00020000 */ #define ADC_CCR_PRESC_Pos (18U) #define ADC_CCR_PRESC_Msk (0xFUL << ADC_CCR_PRESC_Pos) /*!< 0x003C0000 */ #define ADC_CCR_PRESC ADC_CCR_PRESC_Msk /*!< ADC prescaler */ #define ADC_CCR_PRESC_0 (0x1UL << ADC_CCR_PRESC_Pos) /*!< 0x00040000 */ #define ADC_CCR_PRESC_1 (0x2UL << ADC_CCR_PRESC_Pos) /*!< 0x00080000 */ #define ADC_CCR_PRESC_2 (0x4UL << ADC_CCR_PRESC_Pos) /*!< 0x00100000 */ #define ADC_CCR_PRESC_3 (0x8UL << ADC_CCR_PRESC_Pos) /*!< 0x00200000 */ #define ADC_CCR_VREFEN_Pos (22U) #define ADC_CCR_VREFEN_Msk (0x1UL << ADC_CCR_VREFEN_Pos) /*!< 0x00400000 */ #define ADC_CCR_VREFEN ADC_CCR_VREFEN_Msk /*!< VREFINT enable */ #define ADC_CCR_TSEN_Pos (23U) #define ADC_CCR_TSEN_Msk (0x1UL << ADC_CCR_TSEN_Pos) /*!< 0x00800000 */ #define ADC_CCR_TSEN ADC_CCR_TSEN_Msk /*!< Temperature sensor enable */ #define ADC_CCR_VBATEN_Pos (24U) #define ADC_CCR_VBATEN_Msk (0x1UL << ADC_CCR_VBATEN_Pos) /*!< 0x01000000 */ #define ADC_CCR_VBATEN ADC_CCR_VBATEN_Msk /*!< VBAT enable */ /******************** Bit definition for ADC_CDR register *******************/ #define ADC_CDR_RDATA_MST_Pos (0U) #define ADC_CDR_RDATA_MST_Msk (0xFFFFUL << ADC_CDR_RDATA_MST_Pos) /*!< 0x0000FFFF */ #define ADC_CDR_RDATA_MST ADC_CDR_RDATA_MST_Msk /*!< ADC multimode master group regular conversion data */ #define ADC_CDR_RDATA_SLV_Pos (16U) #define ADC_CDR_RDATA_SLV_Msk (0xFFFFUL << ADC_CDR_RDATA_SLV_Pos) /*!< 0xFFFF0000 */ #define ADC_CDR_RDATA_SLV ADC_CDR_RDATA_SLV_Msk /*!< ADC multimode slave group regular conversion data */ /******************** Bit definition for ADC_CDR2 register ******************/ #define ADC_CDR2_RDATA_ALT_Pos (0U) #define ADC_CDR2_RDATA_ALT_Msk (0xFFFFFFFFUL << ADC_CDR2_RDATA_ALT_Pos) /*!< 0xFFFFFFFF */ #define ADC_CDR2_RDATA_ALT ADC_CDR2_RDATA_ALT_Msk /*!< Regular data of the master/slave alternated ADCs */ /******************************************************************************/ /* */ /* VREFBUF */ /* */ /******************************************************************************/ /******************* Bit definition for VREFBUF_CSR register ****************/ #define VREFBUF_CSR_ENVR_Pos (0U) #define VREFBUF_CSR_ENVR_Msk (0x1UL << VREFBUF_CSR_ENVR_Pos) /*!< 0x00000001 */ #define VREFBUF_CSR_ENVR VREFBUF_CSR_ENVR_Msk /*!*/ #define DAC_CR_CEN1_Pos (14U) #define DAC_CR_CEN1_Msk (0x1UL << DAC_CR_CEN1_Pos) /*!< 0x00004000 */ #define DAC_CR_CEN1 DAC_CR_CEN1_Msk /*!*/ #define DAC_CR_EN2_Pos (16U) #define DAC_CR_EN2_Msk (0x1UL << DAC_CR_EN2_Pos) /*!< 0x00010000 */ #define DAC_CR_EN2 DAC_CR_EN2_Msk /*!*/ #define DAC_CR_CEN2_Pos (30U) #define DAC_CR_CEN2_Msk (0x1UL << DAC_CR_CEN2_Pos) /*!< 0x40000000 */ #define DAC_CR_CEN2 DAC_CR_CEN2_Msk /*!*/ /***************** Bit definition for DAC_SWTRIGR register ******************/ #define DAC_SWTRIGR_SWTRIG1_Pos (0U) #define DAC_SWTRIGR_SWTRIG1_Msk (0x1UL << DAC_SWTRIGR_SWTRIG1_Pos) /*!< 0x00000001 */ #define DAC_SWTRIGR_SWTRIG1 DAC_SWTRIGR_SWTRIG1_Msk /*!
© Copyright (c) 2019 STMicroelectronics. * All rights reserved.
* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /** @addtogroup CMSIS_Device * @{ */ /** @addtogroup stm32h735xx * @{ */ #ifndef STM32H735xx_H #define STM32H735xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Peripheral_interrupt_number_definition * @{ */ /** * @brief STM32H7XX Interrupt Number Definition, according to the selected device * in @ref Library_configuration_section */ typedef enum { /****** Cortex-M Processor Exceptions Numbers *****************************************************************/ NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ HardFault_IRQn = -13, /*!< 4 Cortex-M Memory Management Interrupt */ MemoryManagement_IRQn = -12, /*!< 4 Cortex-M Memory Management Interrupt */ BusFault_IRQn = -11, /*!< 5 Cortex-M Bus Fault Interrupt */ UsageFault_IRQn = -10, /*!< 6 Cortex-M Usage Fault Interrupt */ SVCall_IRQn = -5, /*!< 11 Cortex-M SV Call Interrupt */ DebugMonitor_IRQn = -4, /*!< 12 Cortex-M Debug Monitor Interrupt */ PendSV_IRQn = -2, /*!< 14 Cortex-M Pend SV Interrupt */ SysTick_IRQn = -1, /*!< 15 Cortex-M System Tick Interrupt */ /****** STM32 specific Interrupt Numbers **********************************************************************/ WWDG_IRQn = 0, /*!< Window WatchDog Interrupt ( wwdg1_it, wwdg2_it) */ PVD_AVD_IRQn = 1, /*!< PVD/AVD through EXTI Line detection Interrupt */ TAMP_STAMP_IRQn = 2, /*!< Tamper and TimeStamp interrupts through the EXTI line */ RTC_WKUP_IRQn = 3, /*!< RTC Wakeup interrupt through the EXTI line */ FLASH_IRQn = 4, /*!< FLASH global Interrupt */ RCC_IRQn = 5, /*!< RCC global Interrupt */ EXTI0_IRQn = 6, /*!< EXTI Line0 Interrupt */ EXTI1_IRQn = 7, /*!< EXTI Line1 Interrupt */ EXTI2_IRQn = 8, /*!< EXTI Line2 Interrupt */ EXTI3_IRQn = 9, /*!< EXTI Line3 Interrupt */ EXTI4_IRQn = 10, /*!< EXTI Line4 Interrupt */ DMA1_Stream0_IRQn = 11, /*!< DMA1 Stream 0 global Interrupt */ DMA1_Stream1_IRQn = 12, /*!< DMA1 Stream 1 global Interrupt */ DMA1_Stream2_IRQn = 13, /*!< DMA1 Stream 2 global Interrupt */ DMA1_Stream3_IRQn = 14, /*!< DMA1 Stream 3 global Interrupt */ DMA1_Stream4_IRQn = 15, /*!< DMA1 Stream 4 global Interrupt */ DMA1_Stream5_IRQn = 16, /*!< DMA1 Stream 5 global Interrupt */ DMA1_Stream6_IRQn = 17, /*!< DMA1 Stream 6 global Interrupt */ ADC_IRQn = 18, /*!< ADC1 and ADC2 global Interrupts */ FDCAN1_IT0_IRQn = 19, /*!< FDCAN1 Interrupt line 0 */ FDCAN2_IT0_IRQn = 20, /*!< FDCAN2 Interrupt line 0 */ FDCAN1_IT1_IRQn = 21, /*!< FDCAN1 Interrupt line 1 */ FDCAN2_IT1_IRQn = 22, /*!< FDCAN2 Interrupt line 1 */ EXTI9_5_IRQn = 23, /*!< External Line[9:5] Interrupts */ TIM1_BRK_IRQn = 24, /*!< TIM1 Break Interrupt */ TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */ TIM1_TRG_COM_IRQn = 26, /*!< TIM1 Trigger and Commutation Interrupt */ TIM1_CC_IRQn = 27, /*!< TIM1 Capture Compare Interrupt */ TIM2_IRQn = 28, /*!< TIM2 global Interrupt */ TIM3_IRQn = 29, /*!< TIM3 global Interrupt */ TIM4_IRQn = 30, /*!< TIM4 global Interrupt */ I2C1_EV_IRQn = 31, /*!< I2C1 Event Interrupt */ I2C1_ER_IRQn = 32, /*!< I2C1 Error Interrupt */ I2C2_EV_IRQn = 33, /*!< I2C2 Event Interrupt */ I2C2_ER_IRQn = 34, /*!< I2C2 Error Interrupt */ SPI1_IRQn = 35, /*!< SPI1 global Interrupt */ SPI2_IRQn = 36, /*!< SPI2 global Interrupt */ USART1_IRQn = 37, /*!< USART1 global Interrupt */ USART2_IRQn = 38, /*!< USART2 global Interrupt */ USART3_IRQn = 39, /*!< USART3 global Interrupt */ EXTI15_10_IRQn = 40, /*!< External Line[15:10] Interrupts */ RTC_Alarm_IRQn = 41, /*!< RTC Alarm (A and B) through EXTI Line Interrupt */ TIM8_BRK_TIM12_IRQn = 43, /*!< TIM8 Break Interrupt and TIM12 global interrupt */ TIM8_UP_TIM13_IRQn = 44, /*!< TIM8 Update Interrupt and TIM13 global interrupt */ TIM8_TRG_COM_TIM14_IRQn = 45, /*!< TIM8 Trigger and Commutation Interrupt and TIM14 global interrupt */ TIM8_CC_IRQn = 46, /*!< TIM8 Capture Compare Interrupt */ DMA1_Stream7_IRQn = 47, /*!< DMA1 Stream7 Interrupt */ FMC_IRQn = 48, /*!< FMC global Interrupt */ SDMMC1_IRQn = 49, /*!< SDMMC1 global Interrupt */ TIM5_IRQn = 50, /*!< TIM5 global Interrupt */ SPI3_IRQn = 51, /*!< SPI3 global Interrupt */ UART4_IRQn = 52, /*!< UART4 global Interrupt */ UART5_IRQn = 53, /*!< UART5 global Interrupt */ TIM6_DAC_IRQn = 54, /*!< TIM6 global and DAC1&2 underrun error interrupts */ TIM7_IRQn = 55, /*!< TIM7 global interrupt */ DMA2_Stream0_IRQn = 56, /*!< DMA2 Stream 0 global Interrupt */ DMA2_Stream1_IRQn = 57, /*!< DMA2 Stream 1 global Interrupt */ DMA2_Stream2_IRQn = 58, /*!< DMA2 Stream 2 global Interrupt */ DMA2_Stream3_IRQn = 59, /*!< DMA2 Stream 3 global Interrupt */ DMA2_Stream4_IRQn = 60, /*!< DMA2 Stream 4 global Interrupt */ ETH_IRQn = 61, /*!< Ethernet global Interrupt */ ETH_WKUP_IRQn = 62, /*!< Ethernet Wakeup through EXTI line Interrupt */ FDCAN_CAL_IRQn = 63, /*!< FDCAN Calibration unit Interrupt */ DMA2_Stream5_IRQn = 68, /*!< DMA2 Stream 5 global interrupt */ DMA2_Stream6_IRQn = 69, /*!< DMA2 Stream 6 global interrupt */ DMA2_Stream7_IRQn = 70, /*!< DMA2 Stream 7 global interrupt */ USART6_IRQn = 71, /*!< USART6 global interrupt */ I2C3_EV_IRQn = 72, /*!< I2C3 event interrupt */ I2C3_ER_IRQn = 73, /*!< I2C3 error interrupt */ OTG_HS_EP1_OUT_IRQn = 74, /*!< USB OTG HS End Point 1 Out global interrupt */ OTG_HS_EP1_IN_IRQn = 75, /*!< USB OTG HS End Point 1 In global interrupt */ OTG_HS_WKUP_IRQn = 76, /*!< USB OTG HS Wakeup through EXTI interrupt */ OTG_HS_IRQn = 77, /*!< USB OTG HS global interrupt */ DCMI_PSSI_IRQn = 78, /*!< DCMI and PSSI global interrupt */ CRYP_IRQn = 79, /*!< CRYP crypto global interrupt */ HASH_RNG_IRQn = 80, /*!< HASH and RNG global interrupt */ FPU_IRQn = 81, /*!< FPU global interrupt */ UART7_IRQn = 82, /*!< UART7 global interrupt */ UART8_IRQn = 83, /*!< UART8 global interrupt */ SPI4_IRQn = 84, /*!< SPI4 global Interrupt */ SPI5_IRQn = 85, /*!< SPI5 global Interrupt */ SPI6_IRQn = 86, /*!< SPI6 global Interrupt */ SAI1_IRQn = 87, /*!< SAI1 global Interrupt */ LTDC_IRQn = 88, /*!< LTDC global Interrupt */ LTDC_ER_IRQn = 89, /*!< LTDC Error global Interrupt */ DMA2D_IRQn = 90, /*!< DMA2D global Interrupt */ OCTOSPI1_IRQn = 92, /*!< OCTOSPI1 global interrupt */ LPTIM1_IRQn = 93, /*!< LP TIM1 interrupt */ CEC_IRQn = 94, /*!< HDMI-CEC global Interrupt */ I2C4_EV_IRQn = 95, /*!< I2C4 Event Interrupt */ I2C4_ER_IRQn = 96, /*!< I2C4 Error Interrupt */ SPDIF_RX_IRQn = 97, /*!< SPDIF-RX global Interrupt */ DMAMUX1_OVR_IRQn = 102, /*! /** @addtogroup Peripheral_registers_structures * @{ */ /** * @brief Analog to Digital Converter */ typedef struct { __IO uint32_t ISR; /*!< ADC Interrupt and Status Register, Address offset: 0x00 */ __IO uint32_t IER; /*!< ADC Interrupt Enable Register, Address offset: 0x04 */ __IO uint32_t CR; /*!< ADC control register, Address offset: 0x08 */ __IO uint32_t CFGR; /*!< ADC Configuration register, Address offset: 0x0C */ __IO uint32_t CFGR2; /*!< ADC Configuration register 2, Address offset: 0x10 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x14 */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x18 */ __IO uint32_t PCSEL_RES0; /*!< Rserved for ADC3, ADC1/2 pre-channel selection, Address offset: 0x1C */ __IO uint32_t LTR1_TR1; /*!< ADC watchdog Lower threshold register 1, Address offset: 0x20 */ __IO uint32_t HTR1_TR2; /*!< ADC watchdog higher threshold register 1, Address offset: 0x24 */ __IO uint32_t RES1_TR3; /*!< Rserved for ADC1/2, ADC3 threshold register, Address offset: 0x28 */ uint32_t RESERVED2; /*!< Reserved, 0x02C */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x30 */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x34 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x38 */ __IO uint32_t SQR4; /*!< ADC regular sequence register 4, Address offset: 0x3C */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x40 */ uint32_t RESERVED3; /*!< Reserved, 0x044 */ uint32_t RESERVED4; /*!< Reserved, 0x048 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x4C */ uint32_t RESERVED5[4]; /*!< Reserved, 0x050 - 0x05C */ __IO uint32_t OFR1; /*!< ADC offset register 1, Address offset: 0x60 */ __IO uint32_t OFR2; /*!< ADC offset register 2, Address offset: 0x64 */ __IO uint32_t OFR3; /*!< ADC offset register 3, Address offset: 0x68 */ __IO uint32_t OFR4; /*!< ADC offset register 4, Address offset: 0x6C */ uint32_t RESERVED6[4]; /*!< Reserved, 0x070 - 0x07C */ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x80 */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x84 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x88 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x8C */ uint32_t RESERVED7[4]; /*!< Reserved, 0x090 - 0x09C */ __IO uint32_t AWD2CR; /*!< ADC Analog Watchdog 2 Configuration Register, Address offset: 0xA0 */ __IO uint32_t AWD3CR; /*!< ADC Analog Watchdog 3 Configuration Register, Address offset: 0xA4 */ uint32_t RESERVED8; /*!< Reserved, 0x0A8 */ uint32_t RESERVED9; /*!< Reserved, 0x0AC */ __IO uint32_t LTR2_DIFSEL; /*!< ADC watchdog Lower threshold register 2, Difsel for ADC3, Address offset: 0xB0 */ __IO uint32_t HTR2_CALFACT; /*!< ADC watchdog Higher threshold register 2, Calfact for ADC3, Address offset: 0xB4 */ __IO uint32_t LTR3_RES10; /*!< ADC watchdog Lower threshold register 3, specific ADC1/2, Address offset: 0xB8 */ __IO uint32_t HTR3_RES11; /*!< ADC watchdog Higher threshold register 3, specific ADC1/2, Address offset: 0xBC */ __IO uint32_t DIFSEL_RES12; /*!< ADC Differential Mode Selection Register specific ADC1/2, Address offset: 0xC0 */ __IO uint32_t CALFACT_RES13; /*!< ADC Calibration Factors specific ADC1/2, Address offset: 0xC4 */ __IO uint32_t CALFACT2_RES14; /*!< ADC Linearity Calibration Factors specific ADC1/2, Address offset: 0xC8 */ } ADC_TypeDef; typedef struct { __IO uint32_t CSR; /*!< ADC Common status register, Address offset: ADC1/3 base address + 0x300 */ uint32_t RESERVED; /*!< Reserved, ADC1/3 base address + 0x304 */ __IO uint32_t CCR; /*!< ADC common control register, Address offset: ADC1/3 base address + 0x308 */ __IO uint32_t CDR; /*!< ADC common regular data register for dual Address offset: ADC1/3 base address + 0x30C */ __IO uint32_t CDR2; /*!< ADC common regular data register for 32-bit dual mode Address offset: ADC1/3 base address + 0x310 */ } ADC_Common_TypeDef; /** * @brief VREFBUF */ typedef struct { __IO uint32_t CSR; /*!< VREFBUF control and status register, Address offset: 0x00 */ __IO uint32_t CCR; /*!< VREFBUF calibration and control register, Address offset: 0x04 */ } VREFBUF_TypeDef; /** * @brief FD Controller Area Network */ typedef struct { __IO uint32_t CREL; /*!< FDCAN Core Release register, Address offset: 0x000 */ __IO uint32_t ENDN; /*!< FDCAN Endian register, Address offset: 0x004 */ __IO uint32_t RESERVED1; /*!< Reserved, 0x008 */ __IO uint32_t DBTP; /*!< FDCAN Data Bit Timing & Prescaler register, Address offset: 0x00C */ __IO uint32_t TEST; /*!< FDCAN Test register, Address offset: 0x010 */ __IO uint32_t RWD; /*!< FDCAN RAM Watchdog register, Address offset: 0x014 */ __IO uint32_t CCCR; /*!< FDCAN CC Control register, Address offset: 0x018 */ __IO uint32_t NBTP; /*!< FDCAN Nominal Bit Timing & Prescaler register, Address offset: 0x01C */ __IO uint32_t TSCC; /*!< FDCAN Timestamp Counter Configuration register, Address offset: 0x020 */ __IO uint32_t TSCV; /*!< FDCAN Timestamp Counter Value register, Address offset: 0x024 */ __IO uint32_t TOCC; /*!< FDCAN Timeout Counter Configuration register, Address offset: 0x028 */ __IO uint32_t TOCV; /*!< FDCAN Timeout Counter Value register, Address offset: 0x02C */ __IO uint32_t RESERVED2[4]; /*!< Reserved, 0x030 - 0x03C */ __IO uint32_t ECR; /*!< FDCAN Error Counter register, Address offset: 0x040 */ __IO uint32_t PSR; /*!< FDCAN Protocol Status register, Address offset: 0x044 */ __IO uint32_t TDCR; /*!< FDCAN Transmitter Delay Compensation register, Address offset: 0x048 */ __IO uint32_t RESERVED3; /*!< Reserved, 0x04C */ __IO uint32_t IR; /*!< FDCAN Interrupt register, Address offset: 0x050 */ __IO uint32_t IE; /*!< FDCAN Interrupt Enable register, Address offset: 0x054 */ __IO uint32_t ILS; /*!< FDCAN Interrupt Line Select register, Address offset: 0x058 */ __IO uint32_t ILE; /*!< FDCAN Interrupt Line Enable register, Address offset: 0x05C */ __IO uint32_t RESERVED4[8]; /*!< Reserved, 0x060 - 0x07C */ __IO uint32_t GFC; /*!< FDCAN Global Filter Configuration register, Address offset: 0x080 */ __IO uint32_t SIDFC; /*!< FDCAN Standard ID Filter Configuration register, Address offset: 0x084 */ __IO uint32_t XIDFC; /*!< FDCAN Extended ID Filter Configuration register, Address offset: 0x088 */ __IO uint32_t RESERVED5; /*!< Reserved, 0x08C */ __IO uint32_t XIDAM; /*!< FDCAN Extended ID AND Mask register, Address offset: 0x090 */ __IO uint32_t HPMS; /*!< FDCAN High Priority Message Status register, Address offset: 0x094 */ __IO uint32_t NDAT1; /*!< FDCAN New Data 1 register, Address offset: 0x098 */ __IO uint32_t NDAT2; /*!< FDCAN New Data 2 register, Address offset: 0x09C */ __IO uint32_t RXF0C; /*!< FDCAN Rx FIFO 0 Configuration register, Address offset: 0x0A0 */ __IO uint32_t RXF0S; /*!< FDCAN Rx FIFO 0 Status register, Address offset: 0x0A4 */ __IO uint32_t RXF0A; /*!< FDCAN Rx FIFO 0 Acknowledge register, Address offset: 0x0A8 */ __IO uint32_t RXBC; /*!< FDCAN Rx Buffer Configuration register, Address offset: 0x0AC */ __IO uint32_t RXF1C; /*!< FDCAN Rx FIFO 1 Configuration register, Address offset: 0x0B0 */ __IO uint32_t RXF1S; /*!< FDCAN Rx FIFO 1 Status register, Address offset: 0x0B4 */ __IO uint32_t RXF1A; /*!< FDCAN Rx FIFO 1 Acknowledge register, Address offset: 0x0B8 */ __IO uint32_t RXESC; /*!< FDCAN Rx Buffer/FIFO Element Size Configuration register, Address offset: 0x0BC */ __IO uint32_t TXBC; /*!< FDCAN Tx Buffer Configuration register, Address offset: 0x0C0 */ __IO uint32_t TXFQS; /*!< FDCAN Tx FIFO/Queue Status register, Address offset: 0x0C4 */ __IO uint32_t TXESC; /*!< FDCAN Tx Buffer Element Size Configuration register, Address offset: 0x0C8 */ __IO uint32_t TXBRP; /*!< FDCAN Tx Buffer Request Pending register, Address offset: 0x0CC */ __IO uint32_t TXBAR; /*!< FDCAN Tx Buffer Add Request register, Address offset: 0x0D0 */ __IO uint32_t TXBCR; /*!< FDCAN Tx Buffer Cancellation Request register, Address offset: 0x0D4 */ __IO uint32_t TXBTO; /*!< FDCAN Tx Buffer Transmission Occurred register, Address offset: 0x0D8 */ __IO uint32_t TXBCF; /*!< FDCAN Tx Buffer Cancellation Finished register, Address offset: 0x0DC */ __IO uint32_t TXBTIE; /*!< FDCAN Tx Buffer Transmission Interrupt Enable register, Address offset: 0x0E0 */ __IO uint32_t TXBCIE; /*!< FDCAN Tx Buffer Cancellation Finished Interrupt Enable register, Address offset: 0x0E4 */ __IO uint32_t RESERVED6[2]; /*!< Reserved, 0x0E8 - 0x0EC */ __IO uint32_t TXEFC; /*!< FDCAN Tx Event FIFO Configuration register, Address offset: 0x0F0 */ __IO uint32_t TXEFS; /*!< FDCAN Tx Event FIFO Status register, Address offset: 0x0F4 */ __IO uint32_t TXEFA; /*!< FDCAN Tx Event FIFO Acknowledge register, Address offset: 0x0F8 */ __IO uint32_t RESERVED7; /*!< Reserved, 0x0FC */ } FDCAN_GlobalTypeDef; /** * @brief TTFD Controller Area Network */ typedef struct { __IO uint32_t TTTMC; /*!< TT Trigger Memory Configuration register, Address offset: 0x100 */ __IO uint32_t TTRMC; /*!< TT Reference Message Configuration register, Address offset: 0x104 */ __IO uint32_t TTOCF; /*!< TT Operation Configuration register, Address offset: 0x108 */ __IO uint32_t TTMLM; /*!< TT Matrix Limits register, Address offset: 0x10C */ __IO uint32_t TURCF; /*!< TUR Configuration register, Address offset: 0x110 */ __IO uint32_t TTOCN; /*!< TT Operation Control register, Address offset: 0x114 */ __IO uint32_t TTGTP; /*!< TT Global Time Preset register, Address offset: 0x118 */ __IO uint32_t TTTMK; /*!< TT Time Mark register, Address offset: 0x11C */ __IO uint32_t TTIR; /*!< TT Interrupt register, Address offset: 0x120 */ __IO uint32_t TTIE; /*!< TT Interrupt Enable register, Address offset: 0x124 */ __IO uint32_t TTILS; /*!< TT Interrupt Line Select register, Address offset: 0x128 */ __IO uint32_t TTOST; /*!< TT Operation Status register, Address offset: 0x12C */ __IO uint32_t TURNA; /*!< TT TUR Numerator Actual register, Address offset: 0x130 */ __IO uint32_t TTLGT; /*!< TT Local and Global Time register, Address offset: 0x134 */ __IO uint32_t TTCTC; /*!< TT Cycle Time and Count register, Address offset: 0x138 */ __IO uint32_t TTCPT; /*!< TT Capture Time register, Address offset: 0x13C */ __IO uint32_t TTCSM; /*!< TT Cycle Sync Mark register, Address offset: 0x140 */ __IO uint32_t RESERVED1[111]; /*!< Reserved, 0x144 - 0x2FC */ __IO uint32_t TTTS; /*!< TT Trigger Select register, Address offset: 0x300 */ } TTCAN_TypeDef; /** * @brief FD Controller Area Network */ typedef struct { __IO uint32_t CREL; /*!< Clock Calibration Unit Core Release register, Address offset: 0x00 */ __IO uint32_t CCFG; /*!< Calibration Configuration register, Address offset: 0x04 */ __IO uint32_t CSTAT; /*!< Calibration Status register, Address offset: 0x08 */ __IO uint32_t CWD; /*!< Calibration Watchdog register, Address offset: 0x0C */ __IO uint32_t IR; /*!< CCU Interrupt register, Address offset: 0x10 */ __IO uint32_t IE; /*!< CCU Interrupt Enable register, Address offset: 0x14 */ } FDCAN_ClockCalibrationUnit_TypeDef; /** * @brief Consumer Electronics Control */ typedef struct { __IO uint32_t CR; /*!< CEC control register, Address offset:0x00 */ __IO uint32_t CFGR; /*!< CEC configuration register, Address offset:0x04 */ __IO uint32_t TXDR; /*!< CEC Tx data register , Address offset:0x08 */ __IO uint32_t RXDR; /*!< CEC Rx Data Register, Address offset:0x0C */ __IO uint32_t ISR; /*!< CEC Interrupt and Status Register, Address offset:0x10 */ __IO uint32_t IER; /*!< CEC interrupt enable register, Address offset:0x14 */ }CEC_TypeDef; /** * @brief COordincate Rotation DIgital Computer */ typedef struct { __IO uint32_t CSR; /*!< CORDIC control and status register, Address offset: 0x00 */ __IO uint32_t WDATA; /*!< CORDIC argument register, Address offset: 0x04 */ __IO uint32_t RDATA; /*!< CORDIC result register, Address offset: 0x08 */ } CORDIC_TypeDef; /** * @brief CRC calculation unit */ typedef struct { __IO uint32_t DR; /*!< CRC Data register, Address offset: 0x00 */ __IO uint32_t IDR; /*!< CRC Independent data register, Address offset: 0x04 */ __IO uint32_t CR; /*!< CRC Control register, Address offset: 0x08 */ uint32_t RESERVED2; /*!< Reserved, 0x0C */ __IO uint32_t INIT; /*!< Initial CRC value register, Address offset: 0x10 */ __IO uint32_t POL; /*!< CRC polynomial register, Address offset: 0x14 */ } CRC_TypeDef; /** * @brief Clock Recovery System */ typedef struct { __IO uint32_t CR; /*!< CRS ccontrol register, Address offset: 0x00 */ __IO uint32_t CFGR; /*!< CRS configuration register, Address offset: 0x04 */ __IO uint32_t ISR; /*!< CRS interrupt and status register, Address offset: 0x08 */ __IO uint32_t ICR; /*!< CRS interrupt flag clear register, Address offset: 0x0C */ } CRS_TypeDef; /** * @brief Digital to Analog Converter */ typedef struct { __IO uint32_t CR; /*!< DAC control register, Address offset: 0x00 */ __IO uint32_t SWTRIGR; /*!< DAC software trigger register, Address offset: 0x04 */ __IO uint32_t DHR12R1; /*!< DAC channel1 12-bit right-aligned data holding register, Address offset: 0x08 */ __IO uint32_t DHR12L1; /*!< DAC channel1 12-bit left aligned data holding register, Address offset: 0x0C */ __IO uint32_t DHR8R1; /*!< DAC channel1 8-bit right aligned data holding register, Address offset: 0x10 */ __IO uint32_t DHR12R2; /*!< DAC channel2 12-bit right aligned data holding register, Address offset: 0x14 */ __IO uint32_t DHR12L2; /*!< DAC channel2 12-bit left aligned data holding register, Address offset: 0x18 */ __IO uint32_t DHR8R2; /*!< DAC channel2 8-bit right-aligned data holding register, Address offset: 0x1C */ __IO uint32_t DHR12RD; /*!< Dual DAC 12-bit right-aligned data holding register, Address offset: 0x20 */ __IO uint32_t DHR12LD; /*!< DUAL DAC 12-bit left aligned data holding register, Address offset: 0x24 */ __IO uint32_t DHR8RD; /*!< DUAL DAC 8-bit right aligned data holding register, Address offset: 0x28 */ __IO uint32_t DOR1; /*!< DAC channel1 data output register, Address offset: 0x2C */ __IO uint32_t DOR2; /*!< DAC channel2 data output register, Address offset: 0x30 */ __IO uint32_t SR; /*!< DAC status register, Address offset: 0x34 */ __IO uint32_t CCR; /*!< DAC calibration control register, Address offset: 0x38 */ __IO uint32_t MCR; /*!< DAC mode control register, Address offset: 0x3C */ __IO uint32_t SHSR1; /*!< DAC Sample and Hold sample time register 1, Address offset: 0x40 */ __IO uint32_t SHSR2; /*!< DAC Sample and Hold sample time register 2, Address offset: 0x44 */ __IO uint32_t SHHR; /*!< DAC Sample and Hold hold time register, Address offset: 0x48 */ __IO uint32_t SHRR; /*!< DAC Sample and Hold refresh time register, Address offset: 0x4C */ } DAC_TypeDef; /** * @brief DFSDM module registers */ typedef struct { __IO uint32_t FLTCR1; /*!< DFSDM control register1, Address offset: 0x100 */ __IO uint32_t FLTCR2; /*!< DFSDM control register2, Address offset: 0x104 */ __IO uint32_t FLTISR; /*!< DFSDM interrupt and status register, Address offset: 0x108 */ __IO uint32_t FLTICR; /*!< DFSDM interrupt flag clear register, Address offset: 0x10C */ __IO uint32_t FLTJCHGR; /*!< DFSDM injected channel group selection register, Address offset: 0x110 */ __IO uint32_t FLTFCR; /*!< DFSDM filter control register, Address offset: 0x114 */ __IO uint32_t FLTJDATAR; /*!< DFSDM data register for injected group, Address offset: 0x118 */ __IO uint32_t FLTRDATAR; /*!< DFSDM data register for regular group, Address offset: 0x11C */ __IO uint32_t FLTAWHTR; /*!< DFSDM analog watchdog high threshold register, Address offset: 0x120 */ __IO uint32_t FLTAWLTR; /*!< DFSDM analog watchdog low threshold register, Address offset: 0x124 */ __IO uint32_t FLTAWSR; /*!< DFSDM analog watchdog status register Address offset: 0x128 */ __IO uint32_t FLTAWCFR; /*!< DFSDM analog watchdog clear flag register Address offset: 0x12C */ __IO uint32_t FLTEXMAX; /*!< DFSDM extreme detector maximum register, Address offset: 0x130 */ __IO uint32_t FLTEXMIN; /*!< DFSDM extreme detector minimum register Address offset: 0x134 */ __IO uint32_t FLTCNVTIMR; /*!< DFSDM conversion timer, Address offset: 0x138 */ } DFSDM_Filter_TypeDef; /** * @brief DFSDM channel configuration registers */ typedef struct { __IO uint32_t CHCFGR1; /*!< DFSDM channel configuration register1, Address offset: 0x00 */ __IO uint32_t CHCFGR2; /*!< DFSDM channel configuration register2, Address offset: 0x04 */ __IO uint32_t CHAWSCDR; /*!< DFSDM channel analog watchdog and short circuit detector register, Address offset: 0x08 */ __IO uint32_t CHWDATAR; /*!< DFSDM channel watchdog filter data register, Address offset: 0x0C */ __IO uint32_t CHDATINR; /*!< DFSDM channel data input register, Address offset: 0x10 */ } DFSDM_Channel_TypeDef; /** * @brief Debug MCU */ typedef struct { __IO uint32_t IDCODE; /*!< MCU device ID code, Address offset: 0x00 */ __IO uint32_t CR; /*!< Debug MCU configuration register, Address offset: 0x04 */ uint32_t RESERVED4[11]; /*!< Reserved, Address offset: 0x08 */ __IO uint32_t APB3FZ1; /*!< Debug MCU APB3FZ1 freeze register, Address offset: 0x34 */ uint32_t RESERVED5; /*!< Reserved, Address offset: 0x38 */ __IO uint32_t APB1LFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x3C */ uint32_t RESERVED6; /*!< Reserved, Address offset: 0x40 */ __IO uint32_t APB1HFZ1; /*!< Debug MCU APB1LFZ1 freeze register, Address offset: 0x44 */ uint32_t RESERVED7; /*!< Reserved, Address offset: 0x48 */ __IO uint32_t APB2FZ1; /*!< Debug MCU APB2FZ1 freeze register, Address offset: 0x4C */ uint32_t RESERVED8; /*!< Reserved, Address offset: 0x50 */ __IO uint32_t APB4FZ1; /*!< Debug MCU APB4FZ1 freeze register, Address offset: 0x54 */ __IO uint32_t RESERVED9[990]; /*!< Reserved, Address offset: 0x58-0xFCC */ __IO uint32_t PIDR4; /*!< Debug MCU peripheral identity register 4, Address offset: 0xFD0 */ __IO uint32_t RESERVED10[3];/*!< Reserved, Address offset: 0xFD4-0xFDC */ __IO uint32_t PIDR0; /*!< Debug MCU peripheral identity register 0, Address offset: 0xFE0 */ __IO uint32_t PIDR1; /*!< Debug MCU peripheral identity register 1, Address offset: 0xFE4 */ __IO uint32_t PIDR2; /*!< Debug MCU peripheral identity register 2, Address offset: 0xFE8 */ __IO uint32_t PIDR3; /*!< Debug MCU peripheral identity register 3, Address offset: 0xFEC */ __IO uint32_t CIDR0; /*!< Debug MCU component identity register 0, Address offset: 0xFF0 */ __IO uint32_t CIDR1; /*!< Debug MCU component identity register 1, Address offset: 0xFF4 */ __IO uint32_t CIDR2; /*!< Debug MCU component identity register 2, Address offset: 0xFF8 */ __IO uint32_t CIDR3; /*!< Debug MCU component identity register 3, Address offset: 0xFFC */ }DBGMCU_TypeDef; /** * @brief DCMI */ typedef struct { __IO uint32_t CR; /*!< DCMI control register 1, Address offset: 0x00 */ __IO uint32_t SR; /*!< DCMI status register, Address offset: 0x04 */ __IO uint32_t RISR; /*!< DCMI raw interrupt status register, Address offset: 0x08 */ __IO uint32_t IER; /*!< DCMI interrupt enable register, Address offset: 0x0C */ __IO uint32_t MISR; /*!< DCMI masked interrupt status register, Address offset: 0x10 */ __IO uint32_t ICR; /*!< DCMI interrupt clear register, Address offset: 0x14 */ __IO uint32_t ESCR; /*!< DCMI embedded synchronization code register, Address offset: 0x18 */ __IO uint32_t ESUR; /*!< DCMI embedded synchronization unmask register, Address offset: 0x1C */ __IO uint32_t CWSTRTR; /*!< DCMI crop window start, Address offset: 0x20 */ __IO uint32_t CWSIZER; /*!< DCMI crop window size, Address offset: 0x24 */ __IO uint32_t DR; /*!< DCMI data register, Address offset: 0x28 */ } DCMI_TypeDef; /** * @brief PSSI */ typedef struct { __IO uint32_t CR; /*!< PSSI control register 1, Address offset: 0x000 */ __IO uint32_t SR; /*!< PSSI status register, Address offset: 0x004 */ __IO uint32_t RIS; /*!< PSSI raw interrupt status register, Address offset: 0x008 */ __IO uint32_t IER; /*!< PSSI interrupt enable register, Address offset: 0x00C */ __IO uint32_t MIS; /*!< PSSI masked interrupt status register, Address offset: 0x010 */ __IO uint32_t ICR; /*!< PSSI interrupt clear register, Address offset: 0x014 */ __IO uint32_t RESERVED1[4]; /*!< Reserved, 0x018 - 0x024 */ __IO uint32_t DR; /*!< PSSI data register, Address offset: 0x028 */ __IO uint32_t RESERVED2[241]; /*!< Reserved, 0x02C - 0x3EC */ __IO uint32_t HWCFGR; /*!< PSSI IP HW configuration register, Address offset: 0x3F0 */ __IO uint32_t VERR; /*!< PSSI IP version register, Address offset: 0x3F4 */ __IO uint32_t IPIDR; /*!< PSSI IP ID register, Address offset: 0x3F8 */ __IO uint32_t SIDR; /*!< PSSI SIZE ID register, Address offset: 0x3FC */ } PSSI_TypeDef; /** * @brief DMA Controller */ typedef struct { __IO uint32_t CR; /*!< DMA stream x configuration register */ __IO uint32_t NDTR; /*!< DMA stream x number of data register */ __IO uint32_t PAR; /*!< DMA stream x peripheral address register */ __IO uint32_t M0AR; /*!< DMA stream x memory 0 address register */ __IO uint32_t M1AR; /*!< DMA stream x memory 1 address register */ __IO uint32_t FCR; /*!< DMA stream x FIFO control register */ } DMA_Stream_TypeDef; typedef struct { __IO uint32_t LISR; /*!< DMA low interrupt status register, Address offset: 0x00 */ __IO uint32_t HISR; /*!< DMA high interrupt status register, Address offset: 0x04 */ __IO uint32_t LIFCR; /*!< DMA low interrupt flag clear register, Address offset: 0x08 */ __IO uint32_t HIFCR; /*!< DMA high interrupt flag clear register, Address offset: 0x0C */ } DMA_TypeDef; typedef struct { __IO uint32_t CCR; /*!< DMA channel x configuration register */ __IO uint32_t CNDTR; /*!< DMA channel x number of data register */ __IO uint32_t CPAR; /*!< DMA channel x peripheral address register */ __IO uint32_t CM0AR; /*!< DMA channel x memory 0 address register */ __IO uint32_t CM1AR; /*!< DMA channel x memory 1 address register */ } BDMA_Channel_TypeDef; typedef struct { __IO uint32_t ISR; /*!< DMA interrupt status register, Address offset: 0x00 */ __IO uint32_t IFCR; /*!< DMA interrupt flag clear register, Address offset: 0x04 */ } BDMA_TypeDef; typedef struct { __IO uint32_t CCR; /*!< DMA Multiplexer Channel x Control Register */ }DMAMUX_Channel_TypeDef; typedef struct { __IO uint32_t CSR; /*!< DMA Channel Status Register */ __IO uint32_t CFR; /*!< DMA Channel Clear Flag Register */ }DMAMUX_ChannelStatus_TypeDef; typedef struct { __IO uint32_t RGCR; /*!< DMA Request Generator x Control Register */ }DMAMUX_RequestGen_TypeDef; typedef struct { __IO uint32_t RGSR; /*!< DMA Request Generator Status Register */ __IO uint32_t RGCFR; /*!< DMA Request Generator Clear Flag Register */ }DMAMUX_RequestGenStatus_TypeDef; /** * @brief MDMA Controller */ typedef struct { __IO uint32_t GISR0; /*!< MDMA Global Interrupt/Status Register 0, Address offset: 0x00 */ }MDMA_TypeDef; typedef struct { __IO uint32_t CISR; /*!< MDMA channel x interrupt/status register, Address offset: 0x40 */ __IO uint32_t CIFCR; /*!< MDMA channel x interrupt flag clear register, Address offset: 0x44 */ __IO uint32_t CESR; /*!< MDMA Channel x error status register, Address offset: 0x48 */ __IO uint32_t CCR; /*!< MDMA channel x control register, Address offset: 0x4C */ __IO uint32_t CTCR; /*!< MDMA channel x Transfer Configuration register, Address offset: 0x50 */ __IO uint32_t CBNDTR; /*!< MDMA Channel x block number of data register, Address offset: 0x54 */ __IO uint32_t CSAR; /*!< MDMA channel x source address register, Address offset: 0x58 */ __IO uint32_t CDAR; /*!< MDMA channel x destination address register, Address offset: 0x5C */ __IO uint32_t CBRUR; /*!< MDMA channel x Block Repeat address Update register, Address offset: 0x60 */ __IO uint32_t CLAR; /*!< MDMA channel x Link Address register, Address offset: 0x64 */ __IO uint32_t CTBR; /*!< MDMA channel x Trigger and Bus selection Register, Address offset: 0x68 */ uint32_t RESERVED0; /*!< Reserved, 0x6C */ __IO uint32_t CMAR; /*!< MDMA channel x Mask address register, Address offset: 0x70 */ __IO uint32_t CMDR; /*!< MDMA channel x Mask Data register, Address offset: 0x74 */ }MDMA_Channel_TypeDef; /** * @brief DMA2D Controller */ typedef struct { __IO uint32_t CR; /*!< DMA2D Control Register, Address offset: 0x00 */ __IO uint32_t ISR; /*!< DMA2D Interrupt Status Register, Address offset: 0x04 */ __IO uint32_t IFCR; /*!< DMA2D Interrupt Flag Clear Register, Address offset: 0x08 */ __IO uint32_t FGMAR; /*!< DMA2D Foreground Memory Address Register, Address offset: 0x0C */ __IO uint32_t FGOR; /*!< DMA2D Foreground Offset Register, Address offset: 0x10 */ __IO uint32_t BGMAR; /*!< DMA2D Background Memory Address Register, Address offset: 0x14 */ __IO uint32_t BGOR; /*!< DMA2D Background Offset Register, Address offset: 0x18 */ __IO uint32_t FGPFCCR; /*!< DMA2D Foreground PFC Control Register, Address offset: 0x1C */ __IO uint32_t FGCOLR; /*!< DMA2D Foreground Color Register, Address offset: 0x20 */ __IO uint32_t BGPFCCR; /*!< DMA2D Background PFC Control Register, Address offset: 0x24 */ __IO uint32_t BGCOLR; /*!< DMA2D Background Color Register, Address offset: 0x28 */ __IO uint32_t FGCMAR; /*!< DMA2D Foreground CLUT Memory Address Register, Address offset: 0x2C */ __IO uint32_t BGCMAR; /*!< DMA2D Background CLUT Memory Address Register, Address offset: 0x30 */ __IO uint32_t OPFCCR; /*!< DMA2D Output PFC Control Register, Address offset: 0x34 */ __IO uint32_t OCOLR; /*!< DMA2D Output Color Register, Address offset: 0x38 */ __IO uint32_t OMAR; /*!< DMA2D Output Memory Address Register, Address offset: 0x3C */ __IO uint32_t OOR; /*!< DMA2D Output Offset Register, Address offset: 0x40 */ __IO uint32_t NLR; /*!< DMA2D Number of Line Register, Address offset: 0x44 */ __IO uint32_t LWR; /*!< DMA2D Line Watermark Register, Address offset: 0x48 */ __IO uint32_t AMTCR; /*!< DMA2D AHB Master Timer Configuration Register, Address offset: 0x4C */ uint32_t RESERVED[236]; /*!< Reserved, 0x50-0x3FF */ __IO uint32_t FGCLUT[256]; /*!< DMA2D Foreground CLUT, Address offset:400-7FF */ __IO uint32_t BGCLUT[256]; /*!< DMA2D Background CLUT, Address offset:800-BFF */ } DMA2D_TypeDef; /** * @brief Ethernet MAC */ typedef struct { __IO uint32_t MACCR; __IO uint32_t MACECR; __IO uint32_t MACPFR; __IO uint32_t MACWTR; __IO uint32_t MACHT0R; __IO uint32_t MACHT1R; uint32_t RESERVED1[14]; __IO uint32_t MACVTR; uint32_t RESERVED2; __IO uint32_t MACVHTR; uint32_t RESERVED3; __IO uint32_t MACVIR; __IO uint32_t MACIVIR; uint32_t RESERVED4[2]; __IO uint32_t MACTFCR; uint32_t RESERVED5[7]; __IO uint32_t MACRFCR; uint32_t RESERVED6[7]; __IO uint32_t MACISR; __IO uint32_t MACIER; __IO uint32_t MACRXTXSR; uint32_t RESERVED7; __IO uint32_t MACPCSR; __IO uint32_t MACRWKPFR; uint32_t RESERVED8[2]; __IO uint32_t MACLCSR; __IO uint32_t MACLTCR; __IO uint32_t MACLETR; __IO uint32_t MAC1USTCR; uint32_t RESERVED9[12]; __IO uint32_t MACVR; __IO uint32_t MACDR; uint32_t RESERVED10; __IO uint32_t MACHWF0R; __IO uint32_t MACHWF1R; __IO uint32_t MACHWF2R; uint32_t RESERVED11[54]; __IO uint32_t MACMDIOAR; __IO uint32_t MACMDIODR; uint32_t RESERVED12[2]; __IO uint32_t MACARPAR; uint32_t RESERVED13[59]; __IO uint32_t MACA0HR; __IO uint32_t MACA0LR; __IO uint32_t MACA1HR; __IO uint32_t MACA1LR; __IO uint32_t MACA2HR; __IO uint32_t MACA2LR; __IO uint32_t MACA3HR; __IO uint32_t MACA3LR; uint32_t RESERVED14[248]; __IO uint32_t MMCCR; __IO uint32_t MMCRIR; __IO uint32_t MMCTIR; __IO uint32_t MMCRIMR; __IO uint32_t MMCTIMR; uint32_t RESERVED15[14]; __IO uint32_t MMCTSCGPR; __IO uint32_t MMCTMCGPR; uint32_t RESERVED16[5]; __IO uint32_t MMCTPCGR; uint32_t RESERVED17[10]; __IO uint32_t MMCRCRCEPR; __IO uint32_t MMCRAEPR; uint32_t RESERVED18[10]; __IO uint32_t MMCRUPGR; uint32_t RESERVED19[9]; __IO uint32_t MMCTLPIMSTR; __IO uint32_t MMCTLPITCR; __IO uint32_t MMCRLPIMSTR; __IO uint32_t MMCRLPITCR; uint32_t RESERVED20[65]; __IO uint32_t MACL3L4C0R; __IO uint32_t MACL4A0R; uint32_t RESERVED21[2]; __IO uint32_t MACL3A0R0R; __IO uint32_t MACL3A1R0R; __IO uint32_t MACL3A2R0R; __IO uint32_t MACL3A3R0R; uint32_t RESERVED22[4]; __IO uint32_t MACL3L4C1R; __IO uint32_t MACL4A1R; uint32_t RESERVED23[2]; __IO uint32_t MACL3A0R1R; __IO uint32_t MACL3A1R1R; __IO uint32_t MACL3A2R1R; __IO uint32_t MACL3A3R1R; uint32_t RESERVED24[108]; __IO uint32_t MACTSCR; __IO uint32_t MACSSIR; __IO uint32_t MACSTSR; __IO uint32_t MACSTNR; __IO uint32_t MACSTSUR; __IO uint32_t MACSTNUR; __IO uint32_t MACTSAR; uint32_t RESERVED25; __IO uint32_t MACTSSR; uint32_t RESERVED26[3]; __IO uint32_t MACTTSSNR; __IO uint32_t MACTTSSSR; uint32_t RESERVED27[2]; __IO uint32_t MACACR; uint32_t RESERVED28; __IO uint32_t MACATSNR; __IO uint32_t MACATSSR; __IO uint32_t MACTSIACR; __IO uint32_t MACTSEACR; __IO uint32_t MACTSICNR; __IO uint32_t MACTSECNR; uint32_t RESERVED29[4]; __IO uint32_t MACPPSCR; uint32_t RESERVED30[3]; __IO uint32_t MACPPSTTSR; __IO uint32_t MACPPSTTNR; __IO uint32_t MACPPSIR; __IO uint32_t MACPPSWR; uint32_t RESERVED31[12]; __IO uint32_t MACPOCR; __IO uint32_t MACSPI0R; __IO uint32_t MACSPI1R; __IO uint32_t MACSPI2R; __IO uint32_t MACLMIR; uint32_t RESERVED32[11]; __IO uint32_t MTLOMR; uint32_t RESERVED33[7]; __IO uint32_t MTLISR; uint32_t RESERVED34[55]; __IO uint32_t MTLTQOMR; __IO uint32_t MTLTQUR; __IO uint32_t MTLTQDR; uint32_t RESERVED35[8]; __IO uint32_t MTLQICSR; __IO uint32_t MTLRQOMR; __IO uint32_t MTLRQMPOCR; __IO uint32_t MTLRQDR; uint32_t RESERVED36[177]; __IO uint32_t DMAMR; __IO uint32_t DMASBMR; __IO uint32_t DMAISR; __IO uint32_t DMADSR; uint32_t RESERVED37[60]; __IO uint32_t DMACCR; __IO uint32_t DMACTCR; __IO uint32_t DMACRCR; uint32_t RESERVED38[2]; __IO uint32_t DMACTDLAR; uint32_t RESERVED39; __IO uint32_t DMACRDLAR; __IO uint32_t DMACTDTPR; uint32_t RESERVED40; __IO uint32_t DMACRDTPR; __IO uint32_t DMACTDRLR; __IO uint32_t DMACRDRLR; __IO uint32_t DMACIER; __IO uint32_t DMACRIWTR; __IO uint32_t DMACSFCSR; uint32_t RESERVED41; __IO uint32_t DMACCATDR; uint32_t RESERVED42; __IO uint32_t DMACCARDR; uint32_t RESERVED43; __IO uint32_t DMACCATBR; uint32_t RESERVED44; __IO uint32_t DMACCARBR; __IO uint32_t DMACSR; uint32_t RESERVED45[2]; __IO uint32_t DMACMFCR; }ETH_TypeDef; /** * @brief External Interrupt/Event Controller */ typedef struct { __IO uint32_t RTSR1; /*!< EXTI Rising trigger selection register, Address offset: 0x00 */ __IO uint32_t FTSR1; /*!< EXTI Falling trigger selection register, Address offset: 0x04 */ __IO uint32_t SWIER1; /*!< EXTI Software interrupt event register, Address offset: 0x08 */ __IO uint32_t D3PMR1; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR1) Address offset: 0x0C */ __IO uint32_t D3PCR1L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR1L) Address offset: 0x10 */ __IO uint32_t D3PCR1H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR1H) Address offset: 0x14 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x18 to 0x1C */ __IO uint32_t RTSR2; /*!< EXTI Rising trigger selection register, Address offset: 0x20 */ __IO uint32_t FTSR2; /*!< EXTI Falling trigger selection register, Address offset: 0x24 */ __IO uint32_t SWIER2; /*!< EXTI Software interrupt event register, Address offset: 0x28 */ __IO uint32_t D3PMR2; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR2) Address offset: 0x2C */ __IO uint32_t D3PCR2L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR2L) Address offset: 0x30 */ __IO uint32_t D3PCR2H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR2H) Address offset: 0x34 */ uint32_t RESERVED2[2]; /*!< Reserved, 0x38 to 0x3C */ __IO uint32_t RTSR3; /*!< EXTI Rising trigger selection register, Address offset: 0x40 */ __IO uint32_t FTSR3; /*!< EXTI Falling trigger selection register, Address offset: 0x44 */ __IO uint32_t SWIER3; /*!< EXTI Software interrupt event register, Address offset: 0x48 */ __IO uint32_t D3PMR3; /*!< EXTI D3 Pending mask register, (same register as to SRDPMR3) Address offset: 0x4C */ __IO uint32_t D3PCR3L; /*!< EXTI D3 Pending clear selection register low, (same register as to SRDPCR3L) Address offset: 0x50 */ __IO uint32_t D3PCR3H; /*!< EXTI D3 Pending clear selection register High, (same register as to SRDPCR3H) Address offset: 0x54 */ uint32_t RESERVED3[10]; /*!< Reserved, 0x58 to 0x7C */ __IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x80 */ __IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x84 */ __IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x88 */ uint32_t RESERVED4; /*!< Reserved, 0x8C */ __IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x90 */ __IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x94 */ __IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x98 */ uint32_t RESERVED5; /*!< Reserved, 0x9C */ __IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0xA0 */ __IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0xA4 */ __IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0xA8 */ }EXTI_TypeDef; /** * @brief This structure registers corresponds to EXTI_Typdef CPU1/CPU2 registers subset (IMRx, EMRx and PRx), allowing to define EXTI_D1/EXTI_D2 * with rapid/common access to these IMRx, EMRx, PRx registers for CPU1 and CPU2. * Note that EXTI_D1 and EXTI_D2 bases addresses are calculated to point to CPUx first register: * IMR1 in case of EXTI_D1 that is addressing CPU1 (Coretx-M7) * C2IMR1 in case of EXTI_D2 that is addressing CPU2 (Coretx-M4) * Note: EXTI_D2 and corresponding C2IMRx, C2EMRx and C2PRx registers are available for Dual Core devices only */ typedef struct { __IO uint32_t IMR1; /*!< EXTI Interrupt mask register, Address offset: 0x00 */ __IO uint32_t EMR1; /*!< EXTI Event mask register, Address offset: 0x04 */ __IO uint32_t PR1; /*!< EXTI Pending register, Address offset: 0x08 */ uint32_t RESERVED1; /*!< Reserved, 0x0C */ __IO uint32_t IMR2; /*!< EXTI Interrupt mask register, Address offset: 0x10 */ __IO uint32_t EMR2; /*!< EXTI Event mask register, Address offset: 0x14 */ __IO uint32_t PR2; /*!< EXTI Pending register, Address offset: 0x18 */ uint32_t RESERVED2; /*!< Reserved, 0x1C */ __IO uint32_t IMR3; /*!< EXTI Interrupt mask register, Address offset: 0x20 */ __IO uint32_t EMR3; /*!< EXTI Event mask register, Address offset: 0x24 */ __IO uint32_t PR3; /*!< EXTI Pending register, Address offset: 0x28 */ }EXTI_Core_TypeDef; /** * @brief FLASH Registers */ typedef struct { __IO uint32_t ACR; /*!< FLASH access control register, Address offset: 0x00 */ __IO uint32_t KEYR1; /*!< Flash Key Register for bank1, Address offset: 0x04 */ __IO uint32_t OPTKEYR; /*!< Flash Option Key Register, Address offset: 0x08 */ __IO uint32_t CR1; /*!< Flash Control Register for bank1, Address offset: 0x0C */ __IO uint32_t SR1; /*!< Flash Status Register for bank1, Address offset: 0x10 */ __IO uint32_t CCR1; /*!< Flash Control Register for bank1, Address offset: 0x14 */ __IO uint32_t OPTCR; /*!< Flash Option Control Register, Address offset: 0x18 */ __IO uint32_t OPTSR_CUR; /*!< Flash Option Status Current Register, Address offset: 0x1C */ __IO uint32_t OPTSR_PRG; /*!< Flash Option Status to Program Register, Address offset: 0x20 */ __IO uint32_t OPTCCR; /*!< Flash Option Clear Control Register, Address offset: 0x24 */ __IO uint32_t PRAR_CUR1; /*!< Flash Current Protection Address Register for bank1, Address offset: 0x28 */ __IO uint32_t PRAR_PRG1; /*!< Flash Protection Address to Program Register for bank1, Address offset: 0x2C */ __IO uint32_t SCAR_CUR1; /*!< Flash Current Secure Address Register for bank1, Address offset: 0x30 */ __IO uint32_t SCAR_PRG1; /*!< Flash Secure Address to Program Register for bank1, Address offset: 0x34 */ __IO uint32_t WPSN_CUR1; /*!< Flash Current Write Protection Register on bank1, Address offset: 0x38 */ __IO uint32_t WPSN_PRG1; /*!< Flash Write Protection to Program Register on bank1, Address offset: 0x3C */ __IO uint32_t BOOT_CUR; /*!< Flash Current Boot Address for Pelican Core Register, Address offset: 0x40 */ __IO uint32_t BOOT_PRG; /*!< Flash Boot Address to Program for Pelican Core Register, Address offset: 0x44 */ uint32_t RESERVED0[2]; /*!< Reserved, 0x48 to 0x4C */ __IO uint32_t CRCCR1; /*!< Flash CRC Control register For Bank1 Register , Address offset: 0x50 */ __IO uint32_t CRCSADD1; /*!< Flash CRC Start Address Register for Bank1 , Address offset: 0x54 */ __IO uint32_t CRCEADD1; /*!< Flash CRC End Address Register for Bank1 , Address offset: 0x58 */ __IO uint32_t CRCDATA; /*!< Flash CRC Data Register for Bank1 , Address offset: 0x5C */ __IO uint32_t ECC_FA1; /*!< Flash ECC Fail Address For Bank1 Register , Address offset: 0x60 */ uint32_t RESERVED[3]; /*!< Reserved, 0x64 to 0x6C */ __IO uint32_t OPTSR2_CUR; /*!< Flash Option Status Current Register 2, Address offset: 0x70 */ __IO uint32_t OPTSR2_PRG; /*!< Flash Option Status to Program Register 2, Address offset: 0x74 */ } FLASH_TypeDef; /** * @brief Filter and Mathematical ACcelerator */ typedef struct { __IO uint32_t X1BUFCFG; /*!< FMAC X1 Buffer Configuration register, Address offset: 0x00 */ __IO uint32_t X2BUFCFG; /*!< FMAC X2 Buffer Configuration register, Address offset: 0x04 */ __IO uint32_t YBUFCFG; /*!< FMAC Y Buffer Configuration register, Address offset: 0x08 */ __IO uint32_t PARAM; /*!< FMAC Parameter register, Address offset: 0x0C */ __IO uint32_t CR; /*!< FMAC Control register, Address offset: 0x10 */ __IO uint32_t SR; /*!< FMAC Status register, Address offset: 0x14 */ __IO uint32_t WDATA; /*!< FMAC Write Data register, Address offset: 0x18 */ __IO uint32_t RDATA; /*!< FMAC Read Data register, Address offset: 0x1C */ } FMAC_TypeDef; /** * @brief Flexible Memory Controller */ typedef struct { __IO uint32_t BTCR[8]; /*!< NOR/PSRAM chip-select control register(BCR) and chip-select timing register(BTR), Address offset: 0x00-1C */ } FMC_Bank1_TypeDef; /** * @brief Flexible Memory Controller Bank1E */ typedef struct { __IO uint32_t BWTR[7]; /*!< NOR/PSRAM write timing registers, Address offset: 0x104-0x11C */ } FMC_Bank1E_TypeDef; /** * @brief Flexible Memory Controller Bank2 */ typedef struct { __IO uint32_t PCR2; /*!< NAND Flash control register 2, Address offset: 0x60 */ __IO uint32_t SR2; /*!< NAND Flash FIFO status and interrupt register 2, Address offset: 0x64 */ __IO uint32_t PMEM2; /*!< NAND Flash Common memory space timing register 2, Address offset: 0x68 */ __IO uint32_t PATT2; /*!< NAND Flash Attribute memory space timing register 2, Address offset: 0x6C */ uint32_t RESERVED0; /*!< Reserved, 0x70 */ __IO uint32_t ECCR2; /*!< NAND Flash ECC result registers 2, Address offset: 0x74 */ } FMC_Bank2_TypeDef; /** * @brief Flexible Memory Controller Bank3 */ typedef struct { __IO uint32_t PCR; /*!< NAND Flash control register 3, Address offset: 0x80 */ __IO uint32_t SR; /*!< NAND Flash FIFO status and interrupt register 3, Address offset: 0x84 */ __IO uint32_t PMEM; /*!< NAND Flash Common memory space timing register 3, Address offset: 0x88 */ __IO uint32_t PATT; /*!< NAND Flash Attribute memory space timing register 3, Address offset: 0x8C */ uint32_t RESERVED; /*!< Reserved, 0x90 */ __IO uint32_t ECCR; /*!< NAND Flash ECC result registers 3, Address offset: 0x94 */ } FMC_Bank3_TypeDef; /** * @brief Flexible Memory Controller Bank5 and 6 */ typedef struct { __IO uint32_t SDCR[2]; /*!< SDRAM Control registers , Address offset: 0x140-0x144 */ __IO uint32_t SDTR[2]; /*!< SDRAM Timing registers , Address offset: 0x148-0x14C */ __IO uint32_t SDCMR; /*!< SDRAM Command Mode register, Address offset: 0x150 */ __IO uint32_t SDRTR; /*!< SDRAM Refresh Timer register, Address offset: 0x154 */ __IO uint32_t SDSR; /*!< SDRAM Status register, Address offset: 0x158 */ } FMC_Bank5_6_TypeDef; /** * @brief General Purpose I/O */ typedef struct { __IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */ __IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */ __IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */ __IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */ __IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */ __IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */ __IO uint32_t BSRR; /*!< GPIO port bit set/reset, Address offset: 0x18 */ __IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */ __IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x20-0x24 */ } GPIO_TypeDef; /** * @brief Operational Amplifier (OPAMP) */ typedef struct { __IO uint32_t CSR; /*!< OPAMP control/status register, Address offset: 0x00 */ __IO uint32_t OTR; /*!< OPAMP offset trimming register for normal mode, Address offset: 0x04 */ __IO uint32_t HSOTR; /*!< OPAMP offset trimming register for high speed mode, Address offset: 0x08 */ } OPAMP_TypeDef; /** * @brief System configuration controller */ typedef struct { uint32_t RESERVED1; /*!< Reserved, Address offset: 0x00 */ __IO uint32_t PMCR; /*!< SYSCFG peripheral mode configuration register, Address offset: 0x04 */ __IO uint32_t EXTICR[4]; /*!< SYSCFG external interrupt configuration registers, Address offset: 0x08-0x14 */ __IO uint32_t CFGR; /*!< SYSCFG configuration registers, Address offset: 0x18 */ uint32_t RESERVED2; /*!< Reserved, Address offset: 0x1C */ __IO uint32_t CCCSR; /*!< SYSCFG compensation cell control/status register, Address offset: 0x20 */ __IO uint32_t CCVR; /*!< SYSCFG compensation cell value register, Address offset: 0x24 */ __IO uint32_t CCCR; /*!< SYSCFG compensation cell code register, Address offset: 0x28 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2C */ __IO uint32_t ADC2ALT; /*!< ADC2 internal input alternate connection register, Address offset: 0x30 */ uint32_t RESERVED4[60]; /*!< Reserved, 0x34-0x120 */ __IO uint32_t PKGR; /*!< SYSCFG package register, Address offset: 0x124 */ uint32_t RESERVED5[118]; /*!< Reserved, 0x128-0x2FC */ __IO uint32_t UR0; /*!< SYSCFG user register 0, Address offset: 0x300 */ __IO uint32_t UR1; /*!< SYSCFG user register 1, Address offset: 0x304 */ __IO uint32_t UR2; /*!< SYSCFG user register 2, Address offset: 0x308 */ __IO uint32_t UR3; /*!< SYSCFG user register 3, Address offset: 0x30C */ __IO uint32_t UR4; /*!< SYSCFG user register 4, Address offset: 0x310 */ __IO uint32_t UR5; /*!< SYSCFG user register 5, Address offset: 0x314 */ __IO uint32_t UR6; /*!< SYSCFG user register 6, Address offset: 0x318 */ __IO uint32_t UR7; /*!< SYSCFG user register 7, Address offset: 0x31C */ uint32_t RESERVED6[3]; /*!< Reserved, Address offset: 0x320-0x328 */ __IO uint32_t UR11; /*!< SYSCFG user register 11, Address offset: 0x32C */ __IO uint32_t UR12; /*!< SYSCFG user register 12, Address offset: 0x330 */ __IO uint32_t UR13; /*!< SYSCFG user register 13, Address offset: 0x334 */ __IO uint32_t UR14; /*!< SYSCFG user register 14, Address offset: 0x338 */ __IO uint32_t UR15; /*!< SYSCFG user register 15, Address offset: 0x33C */ __IO uint32_t UR16; /*!< SYSCFG user register 16, Address offset: 0x340 */ __IO uint32_t UR17; /*!< SYSCFG user register 17, Address offset: 0x344 */ __IO uint32_t UR18; /*!< SYSCFG user register 18, Address offset: 0x348 */ } SYSCFG_TypeDef; /** * @brief Inter-integrated Circuit Interface */ typedef struct { __IO uint32_t CR1; /*!< I2C Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< I2C Control register 2, Address offset: 0x04 */ __IO uint32_t OAR1; /*!< I2C Own address 1 register, Address offset: 0x08 */ __IO uint32_t OAR2; /*!< I2C Own address 2 register, Address offset: 0x0C */ __IO uint32_t TIMINGR; /*!< I2C Timing register, Address offset: 0x10 */ __IO uint32_t TIMEOUTR; /*!< I2C Timeout register, Address offset: 0x14 */ __IO uint32_t ISR; /*!< I2C Interrupt and status register, Address offset: 0x18 */ __IO uint32_t ICR; /*!< I2C Interrupt clear register, Address offset: 0x1C */ __IO uint32_t PECR; /*!< I2C PEC register, Address offset: 0x20 */ __IO uint32_t RXDR; /*!< I2C Receive data register, Address offset: 0x24 */ __IO uint32_t TXDR; /*!< I2C Transmit data register, Address offset: 0x28 */ } I2C_TypeDef; /** * @brief Independent WATCHDOG */ typedef struct { __IO uint32_t KR; /*!< IWDG Key register, Address offset: 0x00 */ __IO uint32_t PR; /*!< IWDG Prescaler register, Address offset: 0x04 */ __IO uint32_t RLR; /*!< IWDG Reload register, Address offset: 0x08 */ __IO uint32_t SR; /*!< IWDG Status register, Address offset: 0x0C */ __IO uint32_t WINR; /*!< IWDG Window register, Address offset: 0x10 */ } IWDG_TypeDef; /** * @brief LCD-TFT Display Controller */ typedef struct { uint32_t RESERVED0[2]; /*!< Reserved, 0x00-0x04 */ __IO uint32_t SSCR; /*!< LTDC Synchronization Size Configuration Register, Address offset: 0x08 */ __IO uint32_t BPCR; /*!< LTDC Back Porch Configuration Register, Address offset: 0x0C */ __IO uint32_t AWCR; /*!< LTDC Active Width Configuration Register, Address offset: 0x10 */ __IO uint32_t TWCR; /*!< LTDC Total Width Configuration Register, Address offset: 0x14 */ __IO uint32_t GCR; /*!< LTDC Global Control Register, Address offset: 0x18 */ uint32_t RESERVED1[2]; /*!< Reserved, 0x1C-0x20 */ __IO uint32_t SRCR; /*!< LTDC Shadow Reload Configuration Register, Address offset: 0x24 */ uint32_t RESERVED2[1]; /*!< Reserved, 0x28 */ __IO uint32_t BCCR; /*!< LTDC Background Color Configuration Register, Address offset: 0x2C */ uint32_t RESERVED3[1]; /*!< Reserved, 0x30 */ __IO uint32_t IER; /*!< LTDC Interrupt Enable Register, Address offset: 0x34 */ __IO uint32_t ISR; /*!< LTDC Interrupt Status Register, Address offset: 0x38 */ __IO uint32_t ICR; /*!< LTDC Interrupt Clear Register, Address offset: 0x3C */ __IO uint32_t LIPCR; /*!< LTDC Line Interrupt Position Configuration Register, Address offset: 0x40 */ __IO uint32_t CPSR; /*!< LTDC Current Position Status Register, Address offset: 0x44 */ __IO uint32_t CDSR; /*!< LTDC Current Display Status Register, Address offset: 0x48 */ } LTDC_TypeDef; /** * @brief LCD-TFT Display layer x Controller */ typedef struct { __IO uint32_t CR; /*!< LTDC Layerx Control Register Address offset: 0x84 */ __IO uint32_t WHPCR; /*!< LTDC Layerx Window Horizontal Position Configuration Register Address offset: 0x88 */ __IO uint32_t WVPCR; /*!< LTDC Layerx Window Vertical Position Configuration Register Address offset: 0x8C */ __IO uint32_t CKCR; /*!< LTDC Layerx Color Keying Configuration Register Address offset: 0x90 */ __IO uint32_t PFCR; /*!< LTDC Layerx Pixel Format Configuration Register Address offset: 0x94 */ __IO uint32_t CACR; /*!< LTDC Layerx Constant Alpha Configuration Register Address offset: 0x98 */ __IO uint32_t DCCR; /*!< LTDC Layerx Default Color Configuration Register Address offset: 0x9C */ __IO uint32_t BFCR; /*!< LTDC Layerx Blending Factors Configuration Register Address offset: 0xA0 */ uint32_t RESERVED0[2]; /*!< Reserved */ __IO uint32_t CFBAR; /*!< LTDC Layerx Color Frame Buffer Address Register Address offset: 0xAC */ __IO uint32_t CFBLR; /*!< LTDC Layerx Color Frame Buffer Length Register Address offset: 0xB0 */ __IO uint32_t CFBLNR; /*!< LTDC Layerx ColorFrame Buffer Line Number Register Address offset: 0xB4 */ uint32_t RESERVED1[3]; /*!< Reserved */ __IO uint32_t CLUTWR; /*!< LTDC Layerx CLUT Write Register Address offset: 0x144 */ } LTDC_Layer_TypeDef; /** * @brief Power Control */ typedef struct { __IO uint32_t CR1; /*!< PWR power control register 1, Address offset: 0x00 */ __IO uint32_t CSR1; /*!< PWR power control status register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< PWR power control register 2, Address offset: 0x08 */ __IO uint32_t CR3; /*!< PWR power control register 3, Address offset: 0x0C */ __IO uint32_t CPUCR; /*!< PWR CPU control register, Address offset: 0x10 */ uint32_t RESERVED0; /*!< Reserved, Address offset: 0x14 */ __IO uint32_t D3CR; /*!< PWR D3 domain control register, Address offset: 0x18 */ uint32_t RESERVED1; /*!< Reserved, Address offset: 0x1C */ __IO uint32_t WKUPCR; /*!< PWR wakeup clear register, Address offset: 0x20 */ __IO uint32_t WKUPFR; /*!< PWR wakeup flag register, Address offset: 0x24 */ __IO uint32_t WKUPEPR; /*!< PWR wakeup enable and polarity register, Address offset: 0x28 */ } PWR_TypeDef; /** * @brief Reset and Clock Control */ typedef struct { __IO uint32_t CR; /*!< RCC clock control register, Address offset: 0x00 */ __IO uint32_t HSICFGR; /*!< HSI Clock Calibration Register, Address offset: 0x04 */ __IO uint32_t CRRCR; /*!< Clock Recovery RC Register, Address offset: 0x08 */ __IO uint32_t CSICFGR; /*!< CSI Clock Calibration Register, Address offset: 0x0C */ __IO uint32_t CFGR; /*!< RCC clock configuration register, Address offset: 0x10 */ uint32_t RESERVED1; /*!< Reserved, Address offset: 0x14 */ __IO uint32_t D1CFGR; /*!< RCC Domain 1 configuration register, Address offset: 0x18 */ __IO uint32_t D2CFGR; /*!< RCC Domain 2 configuration register, Address offset: 0x1C */ __IO uint32_t D3CFGR; /*!< RCC Domain 3 configuration register, Address offset: 0x20 */ uint32_t RESERVED2; /*!< Reserved, Address offset: 0x24 */ __IO uint32_t PLLCKSELR; /*!< RCC PLLs Clock Source Selection Register, Address offset: 0x28 */ __IO uint32_t PLLCFGR; /*!< RCC PLLs Configuration Register, Address offset: 0x2C */ __IO uint32_t PLL1DIVR; /*!< RCC PLL1 Dividers Configuration Register, Address offset: 0x30 */ __IO uint32_t PLL1FRACR; /*!< RCC PLL1 Fractional Divider Configuration Register, Address offset: 0x34 */ __IO uint32_t PLL2DIVR; /*!< RCC PLL2 Dividers Configuration Register, Address offset: 0x38 */ __IO uint32_t PLL2FRACR; /*!< RCC PLL2 Fractional Divider Configuration Register, Address offset: 0x3C */ __IO uint32_t PLL3DIVR; /*!< RCC PLL3 Dividers Configuration Register, Address offset: 0x40 */ __IO uint32_t PLL3FRACR; /*!< RCC PLL3 Fractional Divider Configuration Register, Address offset: 0x44 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x48 */ __IO uint32_t D1CCIPR; /*!< RCC Domain 1 Kernel Clock Configuration Register Address offset: 0x4C */ __IO uint32_t D2CCIP1R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x50 */ __IO uint32_t D2CCIP2R; /*!< RCC Domain 2 Kernel Clock Configuration Register Address offset: 0x54 */ __IO uint32_t D3CCIPR; /*!< RCC Domain 3 Kernel Clock Configuration Register Address offset: 0x58 */ uint32_t RESERVED4; /*!< Reserved, Address offset: 0x5C */ __IO uint32_t CIER; /*!< RCC Clock Source Interrupt Enable Register Address offset: 0x60 */ __IO uint32_t CIFR; /*!< RCC Clock Source Interrupt Flag Register Address offset: 0x64 */ __IO uint32_t CICR; /*!< RCC Clock Source Interrupt Clear Register Address offset: 0x68 */ uint32_t RESERVED5; /*!< Reserved, Address offset: 0x6C */ __IO uint32_t BDCR; /*!< RCC Vswitch Backup Domain Control Register, Address offset: 0x70 */ __IO uint32_t CSR; /*!< RCC clock control & status register, Address offset: 0x74 */ uint32_t RESERVED6; /*!< Reserved, Address offset: 0x78 */ __IO uint32_t AHB3RSTR; /*!< RCC AHB3 peripheral reset register, Address offset: 0x7C */ __IO uint32_t AHB1RSTR; /*!< RCC AHB1 peripheral reset register, Address offset: 0x80 */ __IO uint32_t AHB2RSTR; /*!< RCC AHB2 peripheral reset register, Address offset: 0x84 */ __IO uint32_t AHB4RSTR; /*!< RCC AHB4 peripheral reset register, Address offset: 0x88 */ __IO uint32_t APB3RSTR; /*!< RCC APB3 peripheral reset register, Address offset: 0x8C */ __IO uint32_t APB1LRSTR; /*!< RCC APB1 peripheral reset Low Word register, Address offset: 0x90 */ __IO uint32_t APB1HRSTR; /*!< RCC APB1 peripheral reset High Word register, Address offset: 0x94 */ __IO uint32_t APB2RSTR; /*!< RCC APB2 peripheral reset register, Address offset: 0x98 */ __IO uint32_t APB4RSTR; /*!< RCC APB4 peripheral reset register, Address offset: 0x9C */ __IO uint32_t GCR; /*!< RCC RCC Global Control Register, Address offset: 0xA0 */ uint32_t RESERVED8; /*!< Reserved, Address offset: 0xA4 */ __IO uint32_t D3AMR; /*!< RCC Domain 3 Autonomous Mode Register, Address offset: 0xA8 */ uint32_t RESERVED11[9]; /*!< Reserved, 0xAC-0xCC Address offset: 0xAC */ __IO uint32_t RSR; /*!< RCC Reset status register, Address offset: 0xD0 */ __IO uint32_t AHB3ENR; /*!< RCC AHB3 peripheral clock register, Address offset: 0xD4 */ __IO uint32_t AHB1ENR; /*!< RCC AHB1 peripheral clock register, Address offset: 0xD8 */ __IO uint32_t AHB2ENR; /*!< RCC AHB2 peripheral clock register, Address offset: 0xDC */ __IO uint32_t AHB4ENR; /*!< RCC AHB4 peripheral clock register, Address offset: 0xE0 */ __IO uint32_t APB3ENR; /*!< RCC APB3 peripheral clock register, Address offset: 0xE4 */ __IO uint32_t APB1LENR; /*!< RCC APB1 peripheral clock Low Word register, Address offset: 0xE8 */ __IO uint32_t APB1HENR; /*!< RCC APB1 peripheral clock High Word register, Address offset: 0xEC */ __IO uint32_t APB2ENR; /*!< RCC APB2 peripheral clock register, Address offset: 0xF0 */ __IO uint32_t APB4ENR; /*!< RCC APB4 peripheral clock register, Address offset: 0xF4 */ uint32_t RESERVED12; /*!< Reserved, Address offset: 0xF8 */ __IO uint32_t AHB3LPENR; /*!< RCC AHB3 peripheral sleep clock register, Address offset: 0xFC */ __IO uint32_t AHB1LPENR; /*!< RCC AHB1 peripheral sleep clock register, Address offset: 0x100 */ __IO uint32_t AHB2LPENR; /*!< RCC AHB2 peripheral sleep clock register, Address offset: 0x104 */ __IO uint32_t AHB4LPENR; /*!< RCC AHB4 peripheral sleep clock register, Address offset: 0x108 */ __IO uint32_t APB3LPENR; /*!< RCC APB3 peripheral sleep clock register, Address offset: 0x10C */ __IO uint32_t APB1LLPENR; /*!< RCC APB1 peripheral sleep clock Low Word register, Address offset: 0x110 */ __IO uint32_t APB1HLPENR; /*!< RCC APB1 peripheral sleep clock High Word register, Address offset: 0x114 */ __IO uint32_t APB2LPENR; /*!< RCC APB2 peripheral sleep clock register, Address offset: 0x118 */ __IO uint32_t APB4LPENR; /*!< RCC APB4 peripheral sleep clock register, Address offset: 0x11C */ uint32_t RESERVED13[4]; /*!< Reserved, 0x120-0x12C Address offset: 0x120 */ } RCC_TypeDef; /** * @brief Real-Time Clock */ typedef struct { __IO uint32_t TR; /*!< RTC time register, Address offset: 0x00 */ __IO uint32_t DR; /*!< RTC date register, Address offset: 0x04 */ __IO uint32_t CR; /*!< RTC control register, Address offset: 0x08 */ __IO uint32_t ISR; /*!< RTC initialization and status register, Address offset: 0x0C */ __IO uint32_t PRER; /*!< RTC prescaler register, Address offset: 0x10 */ __IO uint32_t WUTR; /*!< RTC wakeup timer register, Address offset: 0x14 */ uint32_t RESERVED; /*!< Reserved, Address offset: 0x18 */ __IO uint32_t ALRMAR; /*!< RTC alarm A register, Address offset: 0x1C */ __IO uint32_t ALRMBR; /*!< RTC alarm B register, Address offset: 0x20 */ __IO uint32_t WPR; /*!< RTC write protection register, Address offset: 0x24 */ __IO uint32_t SSR; /*!< RTC sub second register, Address offset: 0x28 */ __IO uint32_t SHIFTR; /*!< RTC shift control register, Address offset: 0x2C */ __IO uint32_t TSTR; /*!< RTC time stamp time register, Address offset: 0x30 */ __IO uint32_t TSDR; /*!< RTC time stamp date register, Address offset: 0x34 */ __IO uint32_t TSSSR; /*!< RTC time-stamp sub second register, Address offset: 0x38 */ __IO uint32_t CALR; /*!< RTC calibration register, Address offset: 0x3C */ __IO uint32_t TAMPCR; /*!< RTC tamper configuration register, Address offset: 0x40 */ __IO uint32_t ALRMASSR; /*!< RTC alarm A sub second register, Address offset: 0x44 */ __IO uint32_t ALRMBSSR; /*!< RTC alarm B sub second register, Address offset: 0x48 */ __IO uint32_t OR; /*!< RTC option register, Address offset: 0x4C */ __IO uint32_t BKP0R; /*!< RTC backup register 0, Address offset: 0x50 */ __IO uint32_t BKP1R; /*!< RTC backup register 1, Address offset: 0x54 */ __IO uint32_t BKP2R; /*!< RTC backup register 2, Address offset: 0x58 */ __IO uint32_t BKP3R; /*!< RTC backup register 3, Address offset: 0x5C */ __IO uint32_t BKP4R; /*!< RTC backup register 4, Address offset: 0x60 */ __IO uint32_t BKP5R; /*!< RTC backup register 5, Address offset: 0x64 */ __IO uint32_t BKP6R; /*!< RTC backup register 6, Address offset: 0x68 */ __IO uint32_t BKP7R; /*!< RTC backup register 7, Address offset: 0x6C */ __IO uint32_t BKP8R; /*!< RTC backup register 8, Address offset: 0x70 */ __IO uint32_t BKP9R; /*!< RTC backup register 9, Address offset: 0x74 */ __IO uint32_t BKP10R; /*!< RTC backup register 10, Address offset: 0x78 */ __IO uint32_t BKP11R; /*!< RTC backup register 11, Address offset: 0x7C */ __IO uint32_t BKP12R; /*!< RTC backup register 12, Address offset: 0x80 */ __IO uint32_t BKP13R; /*!< RTC backup register 13, Address offset: 0x84 */ __IO uint32_t BKP14R; /*!< RTC backup register 14, Address offset: 0x88 */ __IO uint32_t BKP15R; /*!< RTC backup register 15, Address offset: 0x8C */ __IO uint32_t BKP16R; /*!< RTC backup register 16, Address offset: 0x90 */ __IO uint32_t BKP17R; /*!< RTC backup register 17, Address offset: 0x94 */ __IO uint32_t BKP18R; /*!< RTC backup register 18, Address offset: 0x98 */ __IO uint32_t BKP19R; /*!< RTC backup register 19, Address offset: 0x9C */ __IO uint32_t BKP20R; /*!< RTC backup register 20, Address offset: 0xA0 */ __IO uint32_t BKP21R; /*!< RTC backup register 21, Address offset: 0xA4 */ __IO uint32_t BKP22R; /*!< RTC backup register 22, Address offset: 0xA8 */ __IO uint32_t BKP23R; /*!< RTC backup register 23, Address offset: 0xAC */ __IO uint32_t BKP24R; /*!< RTC backup register 24, Address offset: 0xB0 */ __IO uint32_t BKP25R; /*!< RTC backup register 25, Address offset: 0xB4 */ __IO uint32_t BKP26R; /*!< RTC backup register 26, Address offset: 0xB8 */ __IO uint32_t BKP27R; /*!< RTC backup register 27, Address offset: 0xBC */ __IO uint32_t BKP28R; /*!< RTC backup register 28, Address offset: 0xC0 */ __IO uint32_t BKP29R; /*!< RTC backup register 29, Address offset: 0xC4 */ __IO uint32_t BKP30R; /*!< RTC backup register 30, Address offset: 0xC8 */ __IO uint32_t BKP31R; /*!< RTC backup register 31, Address offset: 0xCC */ } RTC_TypeDef; /** * @brief Serial Audio Interface */ typedef struct { __IO uint32_t GCR; /*!< SAI global configuration register, Address offset: 0x00 */ uint32_t RESERVED0[16]; /*!< Reserved, 0x04 - 0x43 */ __IO uint32_t PDMCR; /*!< SAI PDM control register, Address offset: 0x44 */ __IO uint32_t PDMDLY; /*!< SAI PDM delay register, Address offset: 0x48 */ } SAI_TypeDef; typedef struct { __IO uint32_t CR1; /*!< SAI block x configuration register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< SAI block x configuration register 2, Address offset: 0x08 */ __IO uint32_t FRCR; /*!< SAI block x frame configuration register, Address offset: 0x0C */ __IO uint32_t SLOTR; /*!< SAI block x slot register, Address offset: 0x10 */ __IO uint32_t IMR; /*!< SAI block x interrupt mask register, Address offset: 0x14 */ __IO uint32_t SR; /*!< SAI block x status register, Address offset: 0x18 */ __IO uint32_t CLRFR; /*!< SAI block x clear flag register, Address offset: 0x1C */ __IO uint32_t DR; /*!< SAI block x data register, Address offset: 0x20 */ } SAI_Block_TypeDef; /** * @brief SPDIF-RX Interface */ typedef struct { __IO uint32_t CR; /*!< Control register, Address offset: 0x00 */ __IO uint32_t IMR; /*!< Interrupt mask register, Address offset: 0x04 */ __IO uint32_t SR; /*!< Status register, Address offset: 0x08 */ __IO uint32_t IFCR; /*!< Interrupt Flag Clear register, Address offset: 0x0C */ __IO uint32_t DR; /*!< Data input register, Address offset: 0x10 */ __IO uint32_t CSR; /*!< Channel Status register, Address offset: 0x14 */ __IO uint32_t DIR; /*!< Debug Information register, Address offset: 0x18 */ uint32_t RESERVED2; /*!< Reserved, 0x1A */ } SPDIFRX_TypeDef; /** * @brief Secure digital input/output Interface */ typedef struct { __IO uint32_t POWER; /*!< SDMMC power control register, Address offset: 0x00 */ __IO uint32_t CLKCR; /*!< SDMMC clock control register, Address offset: 0x04 */ __IO uint32_t ARG; /*!< SDMMC argument register, Address offset: 0x08 */ __IO uint32_t CMD; /*!< SDMMC command register, Address offset: 0x0C */ __I uint32_t RESPCMD; /*!< SDMMC command response register, Address offset: 0x10 */ __I uint32_t RESP1; /*!< SDMMC response 1 register, Address offset: 0x14 */ __I uint32_t RESP2; /*!< SDMMC response 2 register, Address offset: 0x18 */ __I uint32_t RESP3; /*!< SDMMC response 3 register, Address offset: 0x1C */ __I uint32_t RESP4; /*!< SDMMC response 4 register, Address offset: 0x20 */ __IO uint32_t DTIMER; /*!< SDMMC data timer register, Address offset: 0x24 */ __IO uint32_t DLEN; /*!< SDMMC data length register, Address offset: 0x28 */ __IO uint32_t DCTRL; /*!< SDMMC data control register, Address offset: 0x2C */ __I uint32_t DCOUNT; /*!< SDMMC data counter register, Address offset: 0x30 */ __I uint32_t STA; /*!< SDMMC status register, Address offset: 0x34 */ __IO uint32_t ICR; /*!< SDMMC interrupt clear register, Address offset: 0x38 */ __IO uint32_t MASK; /*!< SDMMC mask register, Address offset: 0x3C */ __IO uint32_t ACKTIME; /*!< SDMMC Acknowledgement timer register, Address offset: 0x40 */ uint32_t RESERVED0[3]; /*!< Reserved, 0x44 - 0x4C - 0x4C */ __IO uint32_t IDMACTRL; /*!< SDMMC DMA control register, Address offset: 0x50 */ __IO uint32_t IDMABSIZE; /*!< SDMMC DMA buffer size register, Address offset: 0x54 */ __IO uint32_t IDMABASE0; /*!< SDMMC DMA buffer 0 base address register, Address offset: 0x58 */ __IO uint32_t IDMABASE1; /*!< SDMMC DMA buffer 1 base address register, Address offset: 0x5C */ uint32_t RESERVED1[8]; /*!< Reserved, 0x60-0x7C */ __IO uint32_t FIFO; /*!< SDMMC data FIFO register, Address offset: 0x80 */ uint32_t RESERVED2[222]; /*!< Reserved, 0x84-0x3F8 */ __IO uint32_t IPVR; /*!< SDMMC data FIFO register, Address offset: 0x3FC */ } SDMMC_TypeDef; /** * @brief Delay Block DLYB */ typedef struct { __IO uint32_t CR; /*!< DELAY BLOCK control register, Address offset: 0x00 */ __IO uint32_t CFGR; /*!< DELAY BLOCK configuration register, Address offset: 0x04 */ } DLYB_TypeDef; /** * @brief HW Semaphore HSEM */ typedef struct { __IO uint32_t R[32]; /*!< 2-step write lock and read back registers, Address offset: 00h-7Ch */ __IO uint32_t RLR[32]; /*!< 1-step read lock registers, Address offset: 80h-FCh */ __IO uint32_t C1IER; /*!< HSEM Interrupt enable register , Address offset: 100h */ __IO uint32_t C1ICR; /*!< HSEM Interrupt clear register , Address offset: 104h */ __IO uint32_t C1ISR; /*!< HSEM Interrupt Status register , Address offset: 108h */ __IO uint32_t C1MISR; /*!< HSEM Interrupt Masked Status register , Address offset: 10Ch */ uint32_t Reserved[12]; /* Reserved Address offset: 110h-13Ch */ __IO uint32_t CR; /*!< HSEM Semaphore clear register , Address offset: 140h */ __IO uint32_t KEYR; /*!< HSEM Semaphore clear key register , Address offset: 144h */ } HSEM_TypeDef; typedef struct { __IO uint32_t IER; /*!< HSEM interrupt enable register , Address offset: 0h */ __IO uint32_t ICR; /*!< HSEM interrupt clear register , Address offset: 4h */ __IO uint32_t ISR; /*!< HSEM interrupt status register , Address offset: 8h */ __IO uint32_t MISR; /*!< HSEM masked interrupt status register , Address offset: Ch */ } HSEM_Common_TypeDef; /** * @brief Serial Peripheral Interface */ typedef struct { __IO uint32_t CR1; /*!< SPI/I2S Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI Control register 2, Address offset: 0x04 */ __IO uint32_t CFG1; /*!< SPI Configuration register 1, Address offset: 0x08 */ __IO uint32_t CFG2; /*!< SPI Configuration register 2, Address offset: 0x0C */ __IO uint32_t IER; /*!< SPI/I2S Interrupt Enable register, Address offset: 0x10 */ __IO uint32_t SR; /*!< SPI/I2S Status register, Address offset: 0x14 */ __IO uint32_t IFCR; /*!< SPI/I2S Interrupt/Status flags clear register, Address offset: 0x18 */ uint32_t RESERVED0; /*!< Reserved, 0x1C */ __IO uint32_t TXDR; /*!< SPI/I2S Transmit data register, Address offset: 0x20 */ uint32_t RESERVED1[3]; /*!< Reserved, 0x24-0x2C */ __IO uint32_t RXDR; /*!< SPI/I2S Receive data register, Address offset: 0x30 */ uint32_t RESERVED2[3]; /*!< Reserved, 0x34-0x3C */ __IO uint32_t CRCPOLY; /*!< SPI CRC Polynomial register, Address offset: 0x40 */ __IO uint32_t TXCRC; /*!< SPI Transmitter CRC register, Address offset: 0x44 */ __IO uint32_t RXCRC; /*!< SPI Receiver CRC register, Address offset: 0x48 */ __IO uint32_t UDRDR; /*!< SPI Underrun data register, Address offset: 0x4C */ __IO uint32_t I2SCFGR; /*!< I2S Configuration register, Address offset: 0x50 */ } SPI_TypeDef; /** * @brief DTS */ typedef struct { __IO uint32_t CFGR1; /*!< DTS configuration register, Address offset: 0x00 */ uint32_t RESERVED0; /*!< Reserved, Address offset: 0x04 */ __IO uint32_t T0VALR1; /*!< DTS T0 Value register, Address offset: 0x08 */ uint32_t RESERVED1; /*!< Reserved, Address offset: 0x0C */ __IO uint32_t RAMPVALR; /*!< DTS Ramp value register, Address offset: 0x10 */ __IO uint32_t ITR1; /*!< DTS Interrupt threshold register, Address offset: 0x14 */ uint32_t RESERVED2; /*!< Reserved, Address offset: 0x18 */ __IO uint32_t DR; /*!< DTS data register, Address offset: 0x1C */ __IO uint32_t SR; /*!< DTS status register Address offset: 0x20 */ __IO uint32_t ITENR; /*!< DTS Interrupt enable register, Address offset: 0x24 */ __IO uint32_t ICIFR; /*!< DTS Clear Interrupt flag register, Address offset: 0x28 */ __IO uint32_t OR; /*!< DTS option register 1, Address offset: 0x2C */ } DTS_TypeDef; /** * @brief TIM */ typedef struct { __IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */ __IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */ __IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */ __IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */ __IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */ __IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */ __IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */ __IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */ __IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */ __IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */ __IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */ __IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */ __IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */ __IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */ __IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */ __IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */ __IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */ __IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */ __IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */ uint32_t RESERVED1; /*!< Reserved, 0x50 */ __IO uint32_t CCMR3; /*!< TIM capture/compare mode register 3, Address offset: 0x54 */ __IO uint32_t CCR5; /*!< TIM capture/compare register5, Address offset: 0x58 */ __IO uint32_t CCR6; /*!< TIM capture/compare register6, Address offset: 0x5C */ __IO uint32_t AF1; /*!< TIM alternate function option register 1, Address offset: 0x60 */ __IO uint32_t AF2; /*!< TIM alternate function option register 2, Address offset: 0x64 */ __IO uint32_t TISEL; /*!< TIM Input Selection register, Address offset: 0x68 */ } TIM_TypeDef; /** * @brief LPTIMIMER */ typedef struct { __IO uint32_t ISR; /*!< LPTIM Interrupt and Status register, Address offset: 0x00 */ __IO uint32_t ICR; /*!< LPTIM Interrupt Clear register, Address offset: 0x04 */ __IO uint32_t IER; /*!< LPTIM Interrupt Enable register, Address offset: 0x08 */ __IO uint32_t CFGR; /*!< LPTIM Configuration register, Address offset: 0x0C */ __IO uint32_t CR; /*!< LPTIM Control register, Address offset: 0x10 */ __IO uint32_t CMP; /*!< LPTIM Compare register, Address offset: 0x14 */ __IO uint32_t ARR; /*!< LPTIM Autoreload register, Address offset: 0x18 */ __IO uint32_t CNT; /*!< LPTIM Counter register, Address offset: 0x1C */ uint32_t RESERVED1; /*!< Reserved, 0x20 */ __IO uint32_t CFGR2; /*!< LPTIM Configuration register, Address offset: 0x24 */ } LPTIM_TypeDef; /** * @brief Comparator */ typedef struct { __IO uint32_t SR; /*!< Comparator status register, Address offset: 0x00 */ __IO uint32_t ICFR; /*!< Comparator interrupt clear flag register, Address offset: 0x04 */ __IO uint32_t OR; /*!< Comparator option register, Address offset: 0x08 */ } COMPOPT_TypeDef; typedef struct { __IO uint32_t CFGR; /*!< Comparator configuration register , Address offset: 0x00 */ } COMP_TypeDef; typedef struct { __IO uint32_t CFGR; /*!< COMP control and status register, used for bits common to several COMP instances, Address offset: 0x00 */ } COMP_Common_TypeDef; /** * @brief Universal Synchronous Asynchronous Receiver Transmitter */ typedef struct { __IO uint32_t CR1; /*!< USART Control register 1, Address offset: 0x00 */ __IO uint32_t CR2; /*!< USART Control register 2, Address offset: 0x04 */ __IO uint32_t CR3; /*!< USART Control register 3, Address offset: 0x08 */ __IO uint32_t BRR; /*!< USART Baud rate register, Address offset: 0x0C */ __IO uint32_t GTPR; /*!< USART Guard time and prescaler register, Address offset: 0x10 */ __IO uint32_t RTOR; /*!< USART Receiver Time Out register, Address offset: 0x14 */ __IO uint32_t RQR; /*!< USART Request register, Address offset: 0x18 */ __IO uint32_t ISR; /*!< USART Interrupt and status register, Address offset: 0x1C */ __IO uint32_t ICR; /*!< USART Interrupt flag Clear register, Address offset: 0x20 */ __IO uint32_t RDR; /*!< USART Receive Data register, Address offset: 0x24 */ __IO uint32_t TDR; /*!< USART Transmit Data register, Address offset: 0x28 */ __IO uint32_t PRESC; /*!< USART clock Prescaler register, Address offset: 0x2C */ } USART_TypeDef; /** * @brief Single Wire Protocol Master Interface SPWMI */ typedef struct { __IO uint32_t CR; /*!< SWPMI Configuration/Control register, Address offset: 0x00 */ __IO uint32_t BRR; /*!< SWPMI bitrate register, Address offset: 0x04 */ uint32_t RESERVED1; /*!< Reserved, 0x08 */ __IO uint32_t ISR; /*!< SWPMI Interrupt and Status register, Address offset: 0x0C */ __IO uint32_t ICR; /*!< SWPMI Interrupt Flag Clear register, Address offset: 0x10 */ __IO uint32_t IER; /*!< SWPMI Interrupt Enable register, Address offset: 0x14 */ __IO uint32_t RFL; /*!< SWPMI Receive Frame Length register, Address offset: 0x18 */ __IO uint32_t TDR; /*!< SWPMI Transmit data register, Address offset: 0x1C */ __IO uint32_t RDR; /*!< SWPMI Receive data register, Address offset: 0x20 */ __IO uint32_t OR; /*!< SWPMI Option register, Address offset: 0x24 */ } SWPMI_TypeDef; /** * @brief Window WATCHDOG */ typedef struct { __IO uint32_t CR; /*!< WWDG Control register, Address offset: 0x00 */ __IO uint32_t CFR; /*!< WWDG Configuration register, Address offset: 0x04 */ __IO uint32_t SR; /*!< WWDG Status register, Address offset: 0x08 */ } WWDG_TypeDef; /** * @brief RAM_ECC_Specific_Registers */ typedef struct { __IO uint32_t CR; /*!< RAMECC monitor configuration register */ __IO uint32_t SR; /*!< RAMECC monitor status register */ __IO uint32_t FAR; /*!< RAMECC monitor failing address register */ __IO uint32_t FDRL; /*!< RAMECC monitor failing data low register */ __IO uint32_t FDRH; /*!< RAMECC monitor failing data high register */ __IO uint32_t FECR; /*!< RAMECC monitor failing ECC error code register */ } RAMECC_MonitorTypeDef; typedef struct { __IO uint32_t IER; /*!< RAMECC interrupt enable register */ } RAMECC_TypeDef; /** * @} */ /** * @brief Crypto Processor */ typedef struct { __IO uint32_t CR; /*!< CRYP control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< CRYP status register, Address offset: 0x04 */ __IO uint32_t DIN; /*!< CRYP data input register, Address offset: 0x08 */ __IO uint32_t DOUT; /*!< CRYP data output register, Address offset: 0x0C */ __IO uint32_t DMACR; /*!< CRYP DMA control register, Address offset: 0x10 */ __IO uint32_t IMSCR; /*!< CRYP interrupt mask set/clear register, Address offset: 0x14 */ __IO uint32_t RISR; /*!< CRYP raw interrupt status register, Address offset: 0x18 */ __IO uint32_t MISR; /*!< CRYP masked interrupt status register, Address offset: 0x1C */ __IO uint32_t K0LR; /*!< CRYP key left register 0, Address offset: 0x20 */ __IO uint32_t K0RR; /*!< CRYP key right register 0, Address offset: 0x24 */ __IO uint32_t K1LR; /*!< CRYP key left register 1, Address offset: 0x28 */ __IO uint32_t K1RR; /*!< CRYP key right register 1, Address offset: 0x2C */ __IO uint32_t K2LR; /*!< CRYP key left register 2, Address offset: 0x30 */ __IO uint32_t K2RR; /*!< CRYP key right register 2, Address offset: 0x34 */ __IO uint32_t K3LR; /*!< CRYP key left register 3, Address offset: 0x38 */ __IO uint32_t K3RR; /*!< CRYP key right register 3, Address offset: 0x3C */ __IO uint32_t IV0LR; /*!< CRYP initialization vector left-word register 0, Address offset: 0x40 */ __IO uint32_t IV0RR; /*!< CRYP initialization vector right-word register 0, Address offset: 0x44 */ __IO uint32_t IV1LR; /*!< CRYP initialization vector left-word register 1, Address offset: 0x48 */ __IO uint32_t IV1RR; /*!< CRYP initialization vector right-word register 1, Address offset: 0x4C */ __IO uint32_t CSGCMCCM0R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 0, Address offset: 0x50 */ __IO uint32_t CSGCMCCM1R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 1, Address offset: 0x54 */ __IO uint32_t CSGCMCCM2R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 2, Address offset: 0x58 */ __IO uint32_t CSGCMCCM3R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 3, Address offset: 0x5C */ __IO uint32_t CSGCMCCM4R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 4, Address offset: 0x60 */ __IO uint32_t CSGCMCCM5R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 5, Address offset: 0x64 */ __IO uint32_t CSGCMCCM6R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 6, Address offset: 0x68 */ __IO uint32_t CSGCMCCM7R; /*!< CRYP GCM/GMAC or CCM/CMAC context swap register 7, Address offset: 0x6C */ __IO uint32_t CSGCM0R; /*!< CRYP GCM/GMAC context swap register 0, Address offset: 0x70 */ __IO uint32_t CSGCM1R; /*!< CRYP GCM/GMAC context swap register 1, Address offset: 0x74 */ __IO uint32_t CSGCM2R; /*!< CRYP GCM/GMAC context swap register 2, Address offset: 0x78 */ __IO uint32_t CSGCM3R; /*!< CRYP GCM/GMAC context swap register 3, Address offset: 0x7C */ __IO uint32_t CSGCM4R; /*!< CRYP GCM/GMAC context swap register 4, Address offset: 0x80 */ __IO uint32_t CSGCM5R; /*!< CRYP GCM/GMAC context swap register 5, Address offset: 0x84 */ __IO uint32_t CSGCM6R; /*!< CRYP GCM/GMAC context swap register 6, Address offset: 0x88 */ __IO uint32_t CSGCM7R; /*!< CRYP GCM/GMAC context swap register 7, Address offset: 0x8C */ } CRYP_TypeDef; /** * @brief HASH */ typedef struct { __IO uint32_t CR; /*!< HASH control register, Address offset: 0x00 */ __IO uint32_t DIN; /*!< HASH data input register, Address offset: 0x04 */ __IO uint32_t STR; /*!< HASH start register, Address offset: 0x08 */ __IO uint32_t HR[5]; /*!< HASH digest registers, Address offset: 0x0C-0x1C */ __IO uint32_t IMR; /*!< HASH interrupt enable register, Address offset: 0x20 */ __IO uint32_t SR; /*!< HASH status register, Address offset: 0x24 */ uint32_t RESERVED[52]; /*!< Reserved, 0x28-0xF4 */ __IO uint32_t CSR[54]; /*!< HASH context swap registers, Address offset: 0x0F8-0x1CC */ } HASH_TypeDef; /** * @brief HASH_DIGEST */ typedef struct { __IO uint32_t HR[8]; /*!< HASH digest registers, Address offset: 0x310-0x32C */ } HASH_DIGEST_TypeDef; /** * @brief RNG */ typedef struct { __IO uint32_t CR; /*!< RNG control register, Address offset: 0x00 */ __IO uint32_t SR; /*!< RNG status register, Address offset: 0x04 */ __IO uint32_t DR; /*!< RNG data register, Address offset: 0x08 */ uint32_t RESERVED; __IO uint32_t HTCR; /*!< RNG health test configuration register, Address offset: 0x10 */ } RNG_TypeDef; /** * @brief MDIOS */ typedef struct { __IO uint32_t CR; __IO uint32_t WRFR; __IO uint32_t CWRFR; __IO uint32_t RDFR; __IO uint32_t CRDFR; __IO uint32_t SR; __IO uint32_t CLRFR; uint32_t RESERVED[57]; __IO uint32_t DINR0; __IO uint32_t DINR1; __IO uint32_t DINR2; __IO uint32_t DINR3; __IO uint32_t DINR4; __IO uint32_t DINR5; __IO uint32_t DINR6; __IO uint32_t DINR7; __IO uint32_t DINR8; __IO uint32_t DINR9; __IO uint32_t DINR10; __IO uint32_t DINR11; __IO uint32_t DINR12; __IO uint32_t DINR13; __IO uint32_t DINR14; __IO uint32_t DINR15; __IO uint32_t DINR16; __IO uint32_t DINR17; __IO uint32_t DINR18; __IO uint32_t DINR19; __IO uint32_t DINR20; __IO uint32_t DINR21; __IO uint32_t DINR22; __IO uint32_t DINR23; __IO uint32_t DINR24; __IO uint32_t DINR25; __IO uint32_t DINR26; __IO uint32_t DINR27; __IO uint32_t DINR28; __IO uint32_t DINR29; __IO uint32_t DINR30; __IO uint32_t DINR31; __IO uint32_t DOUTR0; __IO uint32_t DOUTR1; __IO uint32_t DOUTR2; __IO uint32_t DOUTR3; __IO uint32_t DOUTR4; __IO uint32_t DOUTR5; __IO uint32_t DOUTR6; __IO uint32_t DOUTR7; __IO uint32_t DOUTR8; __IO uint32_t DOUTR9; __IO uint32_t DOUTR10; __IO uint32_t DOUTR11; __IO uint32_t DOUTR12; __IO uint32_t DOUTR13; __IO uint32_t DOUTR14; __IO uint32_t DOUTR15; __IO uint32_t DOUTR16; __IO uint32_t DOUTR17; __IO uint32_t DOUTR18; __IO uint32_t DOUTR19; __IO uint32_t DOUTR20; __IO uint32_t DOUTR21; __IO uint32_t DOUTR22; __IO uint32_t DOUTR23; __IO uint32_t DOUTR24; __IO uint32_t DOUTR25; __IO uint32_t DOUTR26; __IO uint32_t DOUTR27; __IO uint32_t DOUTR28; __IO uint32_t DOUTR29; __IO uint32_t DOUTR30; __IO uint32_t DOUTR31; } MDIOS_TypeDef; /** * @brief USB_OTG_Core_Registers */ typedef struct { __IO uint32_t GOTGCTL; /*!< USB_OTG Control and Status Register 000h */ __IO uint32_t GOTGINT; /*!< USB_OTG Interrupt Register 004h */ __IO uint32_t GAHBCFG; /*!< Core AHB Configuration Register 008h */ __IO uint32_t GUSBCFG; /*!< Core USB Configuration Register 00Ch */ __IO uint32_t GRSTCTL; /*!< Core Reset Register 010h */ __IO uint32_t GINTSTS; /*!< Core Interrupt Register 014h */ __IO uint32_t GINTMSK; /*!< Core Interrupt Mask Register 018h */ __IO uint32_t GRXSTSR; /*!< Receive Sts Q Read Register 01Ch */ __IO uint32_t GRXSTSP; /*!< Receive Sts Q Read & POP Register 020h */ __IO uint32_t GRXFSIZ; /*!< Receive FIFO Size Register 024h */ __IO uint32_t DIEPTXF0_HNPTXFSIZ; /*!< EP0 / Non Periodic Tx FIFO Size Register 028h */ __IO uint32_t HNPTXSTS; /*!< Non Periodic Tx FIFO/Queue Sts reg 02Ch */ uint32_t Reserved30[2]; /*!< Reserved 030h */ __IO uint32_t GCCFG; /*!< General Purpose IO Register 038h */ __IO uint32_t CID; /*!< User ID Register 03Ch */ __IO uint32_t GSNPSID; /* USB_OTG core ID 040h*/ __IO uint32_t GHWCFG1; /* User HW config1 044h*/ __IO uint32_t GHWCFG2; /* User HW config2 048h*/ __IO uint32_t GHWCFG3; /*!< User HW config3 04Ch */ uint32_t Reserved6; /*!< Reserved 050h */ __IO uint32_t GLPMCFG; /*!< LPM Register 054h */ __IO uint32_t GPWRDN; /*!< Power Down Register 058h */ __IO uint32_t GDFIFOCFG; /*!< DFIFO Software Config Register 05Ch */ __IO uint32_t GADPCTL; /*!< ADP Timer, Control and Status Register 60Ch */ uint32_t Reserved43[39]; /*!< Reserved 058h-0FFh */ __IO uint32_t HPTXFSIZ; /*!< Host Periodic Tx FIFO Size Reg 100h */ __IO uint32_t DIEPTXF[0x0F]; /*!< dev Periodic Transmit FIFO */ } USB_OTG_GlobalTypeDef; /** * @brief USB_OTG_device_Registers */ typedef struct { __IO uint32_t DCFG; /*!< dev Configuration Register 800h */ __IO uint32_t DCTL; /*!< dev Control Register 804h */ __IO uint32_t DSTS; /*!< dev Status Register (RO) 808h */ uint32_t Reserved0C; /*!< Reserved 80Ch */ __IO uint32_t DIEPMSK; /*!< dev IN Endpoint Mask 810h */ __IO uint32_t DOEPMSK; /*!< dev OUT Endpoint Mask 814h */ __IO uint32_t DAINT; /*!< dev All Endpoints Itr Reg 818h */ __IO uint32_t DAINTMSK; /*!< dev All Endpoints Itr Mask 81Ch */ uint32_t Reserved20; /*!< Reserved 820h */ uint32_t Reserved9; /*!< Reserved 824h */ __IO uint32_t DVBUSDIS; /*!< dev VBUS discharge Register 828h */ __IO uint32_t DVBUSPULSE; /*!< dev VBUS Pulse Register 82Ch */ __IO uint32_t DTHRCTL; /*!< dev threshold 830h */ __IO uint32_t DIEPEMPMSK; /*!< dev empty msk 834h */ __IO uint32_t DEACHINT; /*!< dedicated EP interrupt 838h */ __IO uint32_t DEACHMSK; /*!< dedicated EP msk 83Ch */ uint32_t Reserved40; /*!< dedicated EP mask 840h */ __IO uint32_t DINEP1MSK; /*!< dedicated EP mask 844h */ uint32_t Reserved44[15]; /*!< Reserved 844-87Ch */ __IO uint32_t DOUTEP1MSK; /*!< dedicated EP msk 884h */ } USB_OTG_DeviceTypeDef; /** * @brief USB_OTG_IN_Endpoint-Specific_Register */ typedef struct { __IO uint32_t DIEPCTL; /*!< dev IN Endpoint Control Reg 900h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved 900h + (ep_num * 20h) + 04h */ __IO uint32_t DIEPINT; /*!< dev IN Endpoint Itr Reg 900h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved 900h + (ep_num * 20h) + 0Ch */ __IO uint32_t DIEPTSIZ; /*!< IN Endpoint Txfer Size 900h + (ep_num * 20h) + 10h */ __IO uint32_t DIEPDMA; /*!< IN Endpoint DMA Address Reg 900h + (ep_num * 20h) + 14h */ __IO uint32_t DTXFSTS; /*!< IN Endpoint Tx FIFO Status Reg 900h + (ep_num * 20h) + 18h */ uint32_t Reserved18; /*!< Reserved 900h+(ep_num*20h)+1Ch-900h+ (ep_num * 20h) + 1Ch */ } USB_OTG_INEndpointTypeDef; /** * @brief USB_OTG_OUT_Endpoint-Specific_Registers */ typedef struct { __IO uint32_t DOEPCTL; /*!< dev OUT Endpoint Control Reg B00h + (ep_num * 20h) + 00h */ uint32_t Reserved04; /*!< Reserved B00h + (ep_num * 20h) + 04h */ __IO uint32_t DOEPINT; /*!< dev OUT Endpoint Itr Reg B00h + (ep_num * 20h) + 08h */ uint32_t Reserved0C; /*!< Reserved B00h + (ep_num * 20h) + 0Ch */ __IO uint32_t DOEPTSIZ; /*!< dev OUT Endpoint Txfer Size B00h + (ep_num * 20h) + 10h */ __IO uint32_t DOEPDMA; /*!< dev OUT Endpoint DMA Address B00h + (ep_num * 20h) + 14h */ uint32_t Reserved18[2]; /*!< Reserved B00h + (ep_num * 20h) + 18h - B00h + (ep_num * 20h) + 1Ch */ } USB_OTG_OUTEndpointTypeDef; /** * @brief USB_OTG_Host_Mode_Register_Structures */ typedef struct { __IO uint32_t HCFG; /*!< Host Configuration Register 400h */ __IO uint32_t HFIR; /*!< Host Frame Interval Register 404h */ __IO uint32_t HFNUM; /*!< Host Frame Nbr/Frame Remaining 408h */ uint32_t Reserved40C; /*!< Reserved 40Ch */ __IO uint32_t HPTXSTS; /*!< Host Periodic Tx FIFO/ Queue Status 410h */ __IO uint32_t HAINT; /*!< Host All Channels Interrupt Register 414h */ __IO uint32_t HAINTMSK; /*!< Host All Channels Interrupt Mask 418h */ } USB_OTG_HostTypeDef; /** * @brief USB_OTG_Host_Channel_Specific_Registers */ typedef struct { __IO uint32_t HCCHAR; /*!< Host Channel Characteristics Register 500h */ __IO uint32_t HCSPLT; /*!< Host Channel Split Control Register 504h */ __IO uint32_t HCINT; /*!< Host Channel Interrupt Register 508h */ __IO uint32_t HCINTMSK; /*!< Host Channel Interrupt Mask Register 50Ch */ __IO uint32_t HCTSIZ; /*!< Host Channel Transfer Size Register 510h */ __IO uint32_t HCDMA; /*!< Host Channel DMA Address Register 514h */ uint32_t Reserved[2]; /*!< Reserved */ } USB_OTG_HostChannelTypeDef; /** * @} */ /** * @brief OCTO Serial Peripheral Interface */ typedef struct { __IO uint32_t CR; /*!< OCTOSPI Control register, Address offset: 0x000 */ uint32_t RESERVED; /*!< Reserved, Address offset: 0x004 */ __IO uint32_t DCR1; /*!< OCTOSPI Device Configuration register 1, Address offset: 0x008 */ __IO uint32_t DCR2; /*!< OCTOSPI Device Configuration register 2, Address offset: 0x00C */ __IO uint32_t DCR3; /*!< OCTOSPI Device Configuration register 3, Address offset: 0x010 */ __IO uint32_t DCR4; /*!< OCTOSPI Device Configuration register 4, Address offset: 0x014 */ uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x018-0x01C */ __IO uint32_t SR; /*!< OCTOSPI Status register, Address offset: 0x020 */ __IO uint32_t FCR; /*!< OCTOSPI Flag Clear register, Address offset: 0x024 */ uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x028-0x03C */ __IO uint32_t DLR; /*!< OCTOSPI Data Length register, Address offset: 0x040 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x044 */ __IO uint32_t AR; /*!< OCTOSPI Address register, Address offset: 0x048 */ uint32_t RESERVED4; /*!< Reserved, Address offset: 0x04C */ __IO uint32_t DR; /*!< OCTOSPI Data register, Address offset: 0x050 */ uint32_t RESERVED5[11]; /*!< Reserved, Address offset: 0x054-0x07C */ __IO uint32_t PSMKR; /*!< OCTOSPI Polling Status Mask register, Address offset: 0x080 */ uint32_t RESERVED6; /*!< Reserved, Address offset: 0x084 */ __IO uint32_t PSMAR; /*!< OCTOSPI Polling Status Match register, Address offset: 0x088 */ uint32_t RESERVED7; /*!< Reserved, Address offset: 0x08C */ __IO uint32_t PIR; /*!< OCTOSPI Polling Interval register, Address offset: 0x090 */ uint32_t RESERVED8[27]; /*!< Reserved, Address offset: 0x094-0x0FC */ __IO uint32_t CCR; /*!< OCTOSPI Communication Configuration register, Address offset: 0x100 */ uint32_t RESERVED9; /*!< Reserved, Address offset: 0x104 */ __IO uint32_t TCR; /*!< OCTOSPI Timing Configuration register, Address offset: 0x108 */ uint32_t RESERVED10; /*!< Reserved, Address offset: 0x10C */ __IO uint32_t IR; /*!< OCTOSPI Instruction register, Address offset: 0x110 */ uint32_t RESERVED11[3]; /*!< Reserved, Address offset: 0x114-0x11C */ __IO uint32_t ABR; /*!< OCTOSPI Alternate Bytes register, Address offset: 0x120 */ uint32_t RESERVED12[3]; /*!< Reserved, Address offset: 0x124-0x12C */ __IO uint32_t LPTR; /*!< OCTOSPI Low Power Timeout register, Address offset: 0x130 */ uint32_t RESERVED13[3]; /*!< Reserved, Address offset: 0x134-0x13C */ __IO uint32_t WPCCR; /*!< OCTOSPI Wrap Communication Configuration register, Address offset: 0x140 */ uint32_t RESERVED14; /*!< Reserved, Address offset: 0x144 */ __IO uint32_t WPTCR; /*!< OCTOSPI Wrap Timing Configuration register, Address offset: 0x148 */ uint32_t RESERVED15; /*!< Reserved, Address offset: 0x14C */ __IO uint32_t WPIR; /*!< OCTOSPI Wrap Instruction register, Address offset: 0x150 */ uint32_t RESERVED16[3]; /*!< Reserved, Address offset: 0x154-0x15C */ __IO uint32_t WPABR; /*!< OCTOSPI Wrap Alternate Bytes register, Address offset: 0x160 */ uint32_t RESERVED17[7]; /*!< Reserved, Address offset: 0x164-0x17C */ __IO uint32_t WCCR; /*!< OCTOSPI Write Communication Configuration register, Address offset: 0x180 */ uint32_t RESERVED18; /*!< Reserved, Address offset: 0x184 */ __IO uint32_t WTCR; /*!< OCTOSPI Write Timing Configuration register, Address offset: 0x188 */ uint32_t RESERVED19; /*!< Reserved, Address offset: 0x18C */ __IO uint32_t WIR; /*!< OCTOSPI Write Instruction register, Address offset: 0x190 */ uint32_t RESERVED20[3]; /*!< Reserved, Address offset: 0x194-0x19C */ __IO uint32_t WABR; /*!< OCTOSPI Write Alternate Bytes register, Address offset: 0x1A0 */ uint32_t RESERVED21[23]; /*!< Reserved, Address offset: 0x1A4-0x1FC */ __IO uint32_t HLCR; /*!< OCTOSPI Hyperbus Latency Configuration register, Address offset: 0x200 */ uint32_t RESERVED22[122]; /*!< Reserved, Address offset: 0x204-0x3EC */ __IO uint32_t HWCFGR; /*!< OCTOSPI HW Configuration register, Address offset: 0x3F0 */ __IO uint32_t VER; /*!< OCTOSPI Version register, Address offset: 0x3F4 */ __IO uint32_t ID; /*!< OCTOSPI Identification register, Address offset: 0x3F8 */ __IO uint32_t MID; /*!< OCTOPSI HW Magic ID register, Address offset: 0x3FC */ } OCTOSPI_TypeDef; /** * @} */ /** * @brief OCTO Serial Peripheral Interface IO Manager */ typedef struct { __IO uint32_t CR; /*!< OCTOSPI IO Manager Control register, Address offset: 0x00 */ __IO uint32_t PCR[3]; /*!< OCTOSPI IO Manager Port[1:3] Configuration register, Address offset: 0x04-0x20 */ } OCTOSPIM_TypeDef; /** * @} */ /** * @brief OTFD register */ typedef struct { __IO uint32_t REG_CONFIGR; __IO uint32_t REG_START_ADDR; __IO uint32_t REG_END_ADDR; __IO uint32_t REG_NONCER0; __IO uint32_t REG_NONCER1; __IO uint32_t REG_KEYR0; __IO uint32_t REG_KEYR1; __IO uint32_t REG_KEYR2; __IO uint32_t REG_KEYR3; } OTFDEC_Region_TypeDef; typedef struct { __IO uint32_t CR; uint32_t RESERVED1[191]; __IO uint32_t ISR; __IO uint32_t ICR; __IO uint32_t IER; uint32_t RESERVED2[56]; __IO uint32_t HWCFGR2; __IO uint32_t HWCFGR1; __IO uint32_t VERR; __IO uint32_t IPIDR; __IO uint32_t SIDR; } OTFDEC_TypeDef; /** * @} */ /** * @brief Global Programmer View */ typedef struct { uint32_t RESERVED0[2036]; /*!< Reserved, Address offset: 0x00-0x1FCC */ __IO uint32_t AXI_PERIPH_ID_4; /*!< AXI interconnect - peripheral ID4 register, Address offset: 0x1FD0 */ uint32_t AXI_PERIPH_ID_5; /*!< Reserved, Address offset: 0x1FD4 */ uint32_t AXI_PERIPH_ID_6; /*!< Reserved, Address offset: 0x1FD8 */ uint32_t AXI_PERIPH_ID_7; /*!< Reserved, Address offset: 0x1FDC */ __IO uint32_t AXI_PERIPH_ID_0; /*!< AXI interconnect - peripheral ID0 register, Address offset: 0x1FE0 */ __IO uint32_t AXI_PERIPH_ID_1; /*!< AXI interconnect - peripheral ID1 register, Address offset: 0x1FE4 */ __IO uint32_t AXI_PERIPH_ID_2; /*!< AXI interconnect - peripheral ID2 register, Address offset: 0x1FE8 */ __IO uint32_t AXI_PERIPH_ID_3; /*!< AXI interconnect - peripheral ID3 register, Address offset: 0x1FEC */ __IO uint32_t AXI_COMP_ID_0; /*!< AXI interconnect - component ID0 register, Address offset: 0x1FF0 */ __IO uint32_t AXI_COMP_ID_1; /*!< AXI interconnect - component ID1 register, Address offset: 0x1FF4 */ __IO uint32_t AXI_COMP_ID_2; /*!< AXI interconnect - component ID2 register, Address offset: 0x1FF8 */ __IO uint32_t AXI_COMP_ID_3; /*!< AXI interconnect - component ID3 register, Address offset: 0x1FFC */ uint32_t RESERVED1[2]; /*!< Reserved, Address offset: 0x2000-0x2004 */ __IO uint32_t AXI_TARG1_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 1 bus matrix issuing functionality register, Address offset: 0x2008 */ uint32_t RESERVED2[6]; /*!< Reserved, Address offset: 0x200C-0x2020 */ __IO uint32_t AXI_TARG1_FN_MOD2; /*!< AXI interconnect - TARG 1 bus matrix functionality 2 register, Address offset: 0x2024 */ uint32_t RESERVED3; /*!< Reserved, Address offset: 0x2028 */ __IO uint32_t AXI_TARG1_FN_MOD_LB; /*!< AXI interconnect - TARG 1 long burst functionality modification register, Address offset: 0x202C */ uint32_t RESERVED4[54]; /*!< Reserved, Address offset: 0x2030-0x2104 */ __IO uint32_t AXI_TARG1_FN_MOD; /*!< AXI interconnect - TARG 1 issuing functionality modification register, Address offset: 0x2108 */ uint32_t RESERVED5[959]; /*!< Reserved, Address offset: 0x210C-0x3004 */ __IO uint32_t AXI_TARG2_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 2 bus matrix issuing functionality register, Address offset: 0x3008 */ uint32_t RESERVED6[6]; /*!< Reserved, Address offset: 0x300C-0x3020 */ __IO uint32_t AXI_TARG2_FN_MOD2; /*!< AXI interconnect - TARG 2 bus matrix functionality 2 register, Address offset: 0x3024 */ uint32_t RESERVED7; /*!< Reserved, Address offset: 0x3028 */ __IO uint32_t AXI_TARG2_FN_MOD_LB; /*!< AXI interconnect - TARG 2 long burst functionality modification register, Address offset: 0x302C */ uint32_t RESERVED8[54]; /*!< Reserved, Address offset: 0x3030-0x3104 */ __IO uint32_t AXI_TARG2_FN_MOD; /*!< AXI interconnect - TARG 2 issuing functionality modification register, Address offset: 0x3108 */ uint32_t RESERVED9[959]; /*!< Reserved, Address offset: 0x310C-0x4004 */ __IO uint32_t AXI_TARG3_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 3 bus matrix issuing functionality register, Address offset: 0x4008 */ uint32_t RESERVED10[1023]; /*!< Reserved, Address offset: 0x400C-0x5004 */ __IO uint32_t AXI_TARG4_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 4 bus matrix issuing functionality register, Address offset: 0x5008 */ uint32_t RESERVED11[1023]; /*!< Reserved, Address offset: 0x500C-0x6004 */ __IO uint32_t AXI_TARG5_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 5 bus matrix issuing functionality register, Address offset: 0x6008 */ uint32_t RESERVED12[1023]; /*!< Reserved, Address offset: 0x600C-0x7004 */ __IO uint32_t AXI_TARG6_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 6 bus matrix issuing functionality register, Address offset: 0x7008 */ uint32_t RESERVED13[1023]; /*!< Reserved, Address offset: 0x700C-0x8004 */ __IO uint32_t AXI_TARG7_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 7 bus matrix issuing functionality register, Address offset: 0x8008 */ uint32_t RESERVED14[6]; /*!< Reserved, Address offset: 0x800C-0x8020 */ __IO uint32_t AXI_TARG7_FN_MOD2; /*!< AXI interconnect - TARG 7 bus matrix functionality 2 register, Address offset: 0x8024 */ uint32_t RESERVED15; /*!< Reserved, Address offset: 0x8028 */ __IO uint32_t AXI_TARG7_FN_MOD_LB; /*!< AXI interconnect - TARG 7 long burst functionality modification register, Address offset: 0x802C */ uint32_t RESERVED16[54]; /*!< Reserved, Address offset: 0x8030-0x8104 */ __IO uint32_t AXI_TARG7_FN_MOD; /*!< AXI interconnect - TARG 7 issuing functionality modification register, Address offset: 0x8108 */ uint32_t RESERVED17[959]; /*!< Reserved, Address offset: 0x810C-0x9004 */ __IO uint32_t AXI_TARG8_FN_MOD_ISS_BM; /*!< AXI interconnect - TARG 8 bus matrix issuing functionality register, Address offset: 0x9008 */ uint32_t RESERVED117[6]; /*!< Reserved, Address offset: 0x900C-0x9020 */ __IO uint32_t AXI_TARG8_FN_MOD2; /*!< AXI interconnect - TARG 8 bus matrix functionality 2 register, Address offset: 0x9024 */ uint32_t RESERVED118[56]; /*!< Reserved, Address offset: 0x9028-0x9104 */ __IO uint32_t AXI_TARG8_FN_MOD; /*!< AXI interconnect - TARG 8 issuing functionality modification register, Address offset: 0x9108 */ uint32_t RESERVED119[58310]; /*!< Reserved, Address offset: 0x910C-0x42020 */ __IO uint32_t AXI_INI1_FN_MOD2; /*!< AXI interconnect - INI 1 functionality modification 2 register, Address offset: 0x42024 */ __IO uint32_t AXI_INI1_FN_MOD_AHB; /*!< AXI interconnect - INI 1 AHB functionality modification register, Address offset: 0x42028 */ uint32_t RESERVED18[53]; /*!< Reserved, Address offset: 0x4202C-0x420FC */ __IO uint32_t AXI_INI1_READ_QOS; /*!< AXI interconnect - INI 1 read QoS register, Address offset: 0x42100 */ __IO uint32_t AXI_INI1_WRITE_QOS; /*!< AXI interconnect - INI 1 write QoS register, Address offset: 0x42104 */ __IO uint32_t AXI_INI1_FN_MOD; /*!< AXI interconnect - INI 1 issuing functionality modification register, Address offset: 0x42108 */ uint32_t RESERVED19[1021]; /*!< Reserved, Address offset: 0x4210C-0x430FC */ __IO uint32_t AXI_INI2_READ_QOS; /*!< AXI interconnect - INI 2 read QoS register, Address offset: 0x43100 */ __IO uint32_t AXI_INI2_WRITE_QOS; /*!< AXI interconnect - INI 2 write QoS register, Address offset: 0x43104 */ __IO uint32_t AXI_INI2_FN_MOD; /*!< AXI interconnect - INI 2 issuing functionality modification register, Address offset: 0x43108 */ uint32_t RESERVED20[966]; /*!< Reserved, Address offset: 0x4310C-0x44020 */ __IO uint32_t AXI_INI3_FN_MOD2; /*!< AXI interconnect - INI 3 functionality modification 2 register, Address offset: 0x44024 */ __IO uint32_t AXI_INI3_FN_MOD_AHB; /*!< AXI interconnect - INI 3 AHB functionality modification register, Address offset: 0x44028 */ uint32_t RESERVED21[53]; /*!< Reserved, Address offset: 0x4402C-0x440FC */ __IO uint32_t AXI_INI3_READ_QOS; /*!< AXI interconnect - INI 3 read QoS register, Address offset: 0x44100 */ __IO uint32_t AXI_INI3_WRITE_QOS; /*!< AXI interconnect - INI 3 write QoS register, Address offset: 0x44104 */ __IO uint32_t AXI_INI3_FN_MOD; /*!< AXI interconnect - INI 3 issuing functionality modification register, Address offset: 0x44108 */ uint32_t RESERVED22[1021]; /*!< Reserved, Address offset: 0x4410C-0x450FC */ __IO uint32_t AXI_INI4_READ_QOS; /*!< AXI interconnect - INI 4 read QoS register, Address offset: 0x45100 */ __IO uint32_t AXI_INI4_WRITE_QOS; /*!< AXI interconnect - INI 4 write QoS register, Address offset: 0x45104 */ __IO uint32_t AXI_INI4_FN_MOD; /*!< AXI interconnect - INI 4 issuing functionality modification register, Address offset: 0x45108 */ uint32_t RESERVED23[1021]; /*!< Reserved, Address offset: 0x4510C-0x460FC */ __IO uint32_t AXI_INI5_READ_QOS; /*!< AXI interconnect - INI 5 read QoS register, Address offset: 0x46100 */ __IO uint32_t AXI_INI5_WRITE_QOS; /*!< AXI interconnect - INI 5 write QoS register, Address offset: 0x46104 */ __IO uint32_t AXI_INI5_FN_MOD; /*!< AXI interconnect - INI 5 issuing functionality modification register, Address offset: 0x46108 */ uint32_t RESERVED24[1021]; /*!< Reserved, Address offset: 0x4610C-0x470FC */ __IO uint32_t AXI_INI6_READ_QOS; /*!< AXI interconnect - INI 6 read QoS register, Address offset: 0x47100 */ __IO uint32_t AXI_INI6_WRITE_QOS; /*!< AXI interconnect - INI 6 write QoS register, Address offset: 0x47104 */ __IO uint32_t AXI_INI6_FN_MOD; /*!< AXI interconnect - INI 6 issuing functionality modification register, Address offset: 0x47108 */ } GPV_TypeDef; /** @addtogroup Peripheral_memory_map * @{ */ #define D1_ITCMRAM_BASE (0x00000000UL) /*!< Base address of : 64KB RAM reserved for CPU execution/instruction accessible over ITCM */ #define D1_ITCMICP_BASE (0x00100000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over ITCM */ #define D1_DTCMRAM_BASE (0x20000000UL) /*!< Base address of : 128KB system data RAM accessible over DTCM */ #define D1_AXIFLASH_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) embedded FLASH memory accessible over AXI */ #define D1_AXIICP_BASE (0x1FF00000UL) /*!< Base address of : (up to 128KB) embedded Test FLASH memory accessible over AXI */ #define D1_AXISRAM1_BASE (0x24000000UL) /*!< Base address of : (up to 128KB) system data RAM1 accessible over over AXI */ #define D1_AXISRAM2_BASE (0x24020000UL) /*!< Base address of : (up to 192KB) system data RAM2 accessible over over AXI to be shared with ITCM (64K granularity) */ #define D1_AXISRAM_BASE D1_AXISRAM1_BASE /*!< Base address of : (up to 320KB) system data RAM1/2 accessible over over AXI */ #define D2_AHBSRAM1_BASE (0x30000000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ #define D2_AHBSRAM2_BASE (0x30004000UL) /*!< Base address of : (up to 16KB) system data RAM accessible over over AXI->AHB Bridge */ #define D2_AHBSRAM_BASE D2_AHBSRAM1_BASE /*!< Base address of : (up to 32KB) system data RAM1/2 accessible over over AXI->AHB Bridge */ #define D3_BKPSRAM_BASE (0x38800000UL) /*!< Base address of : Backup SRAM(4 KB) over AXI->AHB Bridge */ #define D3_SRAM_BASE (0x38000000UL) /*!< Base address of : Backup SRAM(16 KB) over AXI->AHB Bridge */ #define PERIPH_BASE (0x40000000UL) /*!< Base address of : AHB/APB Peripherals */ #define OCTOSPI1_BASE (0x90000000UL) /*!< Base address of : OCTOSPI1 memories accessible over AXI */ #define OCTOSPI2_BASE (0x70000000UL) /*!< Base address of : OCTOSPI2 memories accessible over AXI */ #define FLASH_BANK1_BASE (0x08000000UL) /*!< Base address of : (up to 1 MB) Flash Bank1 accessible over AXI */ #define FLASH_END (0x080FFFFFUL) /*!< FLASH end address */ /* Legacy define */ #define FLASH_BASE FLASH_BANK1_BASE /*!< Device electronic signature memory map */ #define UID_BASE (0x1FF1E800UL) /*!< Unique device ID register base address */ #define FLASHSIZE_BASE (0x1FF1E880UL) /*!< FLASH Size register base address */ /*!< Peripheral memory map */ #define D2_APB1PERIPH_BASE PERIPH_BASE #define D2_APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define D2_AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define D2_AHB2PERIPH_BASE (PERIPH_BASE + 0x08020000UL) #define D1_APB1PERIPH_BASE (PERIPH_BASE + 0x10000000UL) #define D1_AHB1PERIPH_BASE (PERIPH_BASE + 0x12000000UL) #define D3_APB1PERIPH_BASE (PERIPH_BASE + 0x18000000UL) #define D3_AHB1PERIPH_BASE (PERIPH_BASE + 0x18020000UL) /*!< Legacy Peripheral memory map */ #define APB1PERIPH_BASE PERIPH_BASE #define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL) #define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL) #define AHB2PERIPH_BASE (PERIPH_BASE + 0x08000000UL) /*!< D1_AHB1PERIPH peripherals */ #define MDMA_BASE (D1_AHB1PERIPH_BASE + 0x0000UL) #define DMA2D_BASE (D1_AHB1PERIPH_BASE + 0x1000UL) #define FLASH_R_BASE (D1_AHB1PERIPH_BASE + 0x2000UL) #define FMC_R_BASE (D1_AHB1PERIPH_BASE + 0x4000UL) #define OCTOSPI1_R_BASE (D1_AHB1PERIPH_BASE + 0x5000UL) #define DLYB_OCTOSPI1_BASE (D1_AHB1PERIPH_BASE + 0x6000UL) #define SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x7000UL) #define DLYB_SDMMC1_BASE (D1_AHB1PERIPH_BASE + 0x8000UL) #define RAMECC1_BASE (D1_AHB1PERIPH_BASE + 0x9000UL) #define OCTOSPI2_R_BASE (D1_AHB1PERIPH_BASE + 0xA000UL) #define DLYB_OCTOSPI2_BASE (D1_AHB1PERIPH_BASE + 0xB000UL) #define OCTOSPIM_BASE (D1_AHB1PERIPH_BASE + 0xB400UL) #define OTFDEC1_BASE (D1_AHB1PERIPH_BASE + 0xB800UL) #define OTFDEC1_REGION1_BASE (OTFDEC1_BASE + 0x20UL) #define OTFDEC1_REGION2_BASE (OTFDEC1_BASE + 0x50UL) #define OTFDEC1_REGION3_BASE (OTFDEC1_BASE + 0x80UL) #define OTFDEC1_REGION4_BASE (OTFDEC1_BASE + 0xB0UL) #define OTFDEC2_BASE (D1_AHB1PERIPH_BASE + 0xBC00UL) #define OTFDEC2_REGION1_BASE (OTFDEC2_BASE + 0x20UL) #define OTFDEC2_REGION2_BASE (OTFDEC2_BASE + 0x50UL) #define OTFDEC2_REGION3_BASE (OTFDEC2_BASE + 0x80UL) #define OTFDEC2_REGION4_BASE (OTFDEC2_BASE + 0xB0UL) /*!< D2_AHB1PERIPH peripherals */ #define DMA1_BASE (D2_AHB1PERIPH_BASE + 0x0000UL) #define DMA2_BASE (D2_AHB1PERIPH_BASE + 0x0400UL) #define DMAMUX1_BASE (D2_AHB1PERIPH_BASE + 0x0800UL) #define ADC1_BASE (D2_AHB1PERIPH_BASE + 0x2000UL) #define ADC2_BASE (D2_AHB1PERIPH_BASE + 0x2100UL) #define ADC12_COMMON_BASE (D2_AHB1PERIPH_BASE + 0x2300UL) #define ETH_BASE (D2_AHB1PERIPH_BASE + 0x8000UL) #define ETH_MAC_BASE (ETH_BASE) /*!< USB registers base address */ #define USB1_OTG_HS_PERIPH_BASE (0x40040000UL) #define USB_OTG_GLOBAL_BASE (0x000UL) #define USB_OTG_DEVICE_BASE (0x800UL) #define USB_OTG_IN_ENDPOINT_BASE (0x900UL) #define USB_OTG_OUT_ENDPOINT_BASE (0xB00UL) #define USB_OTG_EP_REG_SIZE (0x20UL) #define USB_OTG_HOST_BASE (0x400UL) #define USB_OTG_HOST_PORT_BASE (0x440UL) #define USB_OTG_HOST_CHANNEL_BASE (0x500UL) #define USB_OTG_HOST_CHANNEL_SIZE (0x20UL) #define USB_OTG_PCGCCTL_BASE (0xE00UL) #define USB_OTG_FIFO_BASE (0x1000UL) #define USB_OTG_FIFO_SIZE (0x1000UL) /*!< D2_AHB2PERIPH peripherals */ #define DCMI_BASE (D2_AHB2PERIPH_BASE + 0x0000UL) #define PSSI_BASE (D2_AHB2PERIPH_BASE + 0x0400UL) #define CRYP_BASE (D2_AHB2PERIPH_BASE + 0x1000UL) #define HASH_BASE (D2_AHB2PERIPH_BASE + 0x1400UL) #define HASH_DIGEST_BASE (D2_AHB2PERIPH_BASE + 0x1710UL) #define RNG_BASE (D2_AHB2PERIPH_BASE + 0x1800UL) #define SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2400UL) #define DLYB_SDMMC2_BASE (D2_AHB2PERIPH_BASE + 0x2800UL) #define RAMECC2_BASE (D2_AHB2PERIPH_BASE + 0x3000UL) #define FMAC_BASE (D2_AHB2PERIPH_BASE + 0x4000UL) #define CORDIC_BASE (D2_AHB2PERIPH_BASE + 0x4400UL) /*!< D3_AHB1PERIPH peripherals */ #define GPIOA_BASE (D3_AHB1PERIPH_BASE + 0x0000UL) #define GPIOB_BASE (D3_AHB1PERIPH_BASE + 0x0400UL) #define GPIOC_BASE (D3_AHB1PERIPH_BASE + 0x0800UL) #define GPIOD_BASE (D3_AHB1PERIPH_BASE + 0x0C00UL) #define GPIOE_BASE (D3_AHB1PERIPH_BASE + 0x1000UL) #define GPIOF_BASE (D3_AHB1PERIPH_BASE + 0x1400UL) #define GPIOG_BASE (D3_AHB1PERIPH_BASE + 0x1800UL) #define GPIOH_BASE (D3_AHB1PERIPH_BASE + 0x1C00UL) #define GPIOJ_BASE (D3_AHB1PERIPH_BASE + 0x2400UL) #define GPIOK_BASE (D3_AHB1PERIPH_BASE + 0x2800UL) #define RCC_BASE (D3_AHB1PERIPH_BASE + 0x4400UL) #define PWR_BASE (D3_AHB1PERIPH_BASE + 0x4800UL) #define CRC_BASE (D3_AHB1PERIPH_BASE + 0x4C00UL) #define BDMA_BASE (D3_AHB1PERIPH_BASE + 0x5400UL) #define DMAMUX2_BASE (D3_AHB1PERIPH_BASE + 0x5800UL) #define ADC3_BASE (D3_AHB1PERIPH_BASE + 0x6000UL) #define ADC3_COMMON_BASE (D3_AHB1PERIPH_BASE + 0x6300UL) #define HSEM_BASE (D3_AHB1PERIPH_BASE + 0x6400UL) #define RAMECC3_BASE (D3_AHB1PERIPH_BASE + 0x7000UL) /*!< D1_APB1PERIPH peripherals */ #define LTDC_BASE (D1_APB1PERIPH_BASE + 0x1000UL) #define LTDC_Layer1_BASE (LTDC_BASE + 0x84UL) #define LTDC_Layer2_BASE (LTDC_BASE + 0x104UL) #define WWDG1_BASE (D1_APB1PERIPH_BASE + 0x3000UL) /*!< D2_APB1PERIPH peripherals */ #define TIM2_BASE (D2_APB1PERIPH_BASE + 0x0000UL) #define TIM3_BASE (D2_APB1PERIPH_BASE + 0x0400UL) #define TIM4_BASE (D2_APB1PERIPH_BASE + 0x0800UL) #define TIM5_BASE (D2_APB1PERIPH_BASE + 0x0C00UL) #define TIM6_BASE (D2_APB1PERIPH_BASE + 0x1000UL) #define TIM7_BASE (D2_APB1PERIPH_BASE + 0x1400UL) #define TIM12_BASE (D2_APB1PERIPH_BASE + 0x1800UL) #define TIM13_BASE (D2_APB1PERIPH_BASE + 0x1C00UL) #define TIM14_BASE (D2_APB1PERIPH_BASE + 0x2000UL) #define LPTIM1_BASE (D2_APB1PERIPH_BASE + 0x2400UL) #define SPI2_BASE (D2_APB1PERIPH_BASE + 0x3800UL) #define SPI3_BASE (D2_APB1PERIPH_BASE + 0x3C00UL) #define SPDIFRX_BASE (D2_APB1PERIPH_BASE + 0x4000UL) #define USART2_BASE (D2_APB1PERIPH_BASE + 0x4400UL) #define USART3_BASE (D2_APB1PERIPH_BASE + 0x4800UL) #define UART4_BASE (D2_APB1PERIPH_BASE + 0x4C00UL) #define UART5_BASE (D2_APB1PERIPH_BASE + 0x5000UL) #define I2C1_BASE (D2_APB1PERIPH_BASE + 0x5400UL) #define I2C2_BASE (D2_APB1PERIPH_BASE + 0x5800UL) #define I2C3_BASE (D2_APB1PERIPH_BASE + 0x5C00UL) #define I2C5_BASE (D2_APB1PERIPH_BASE + 0x6400UL) #define CEC_BASE (D2_APB1PERIPH_BASE + 0x6C00UL) #define DAC1_BASE (D2_APB1PERIPH_BASE + 0x7400UL) #define UART7_BASE (D2_APB1PERIPH_BASE + 0x7800UL) #define UART8_BASE (D2_APB1PERIPH_BASE + 0x7C00UL) #define CRS_BASE (D2_APB1PERIPH_BASE + 0x8400UL) #define SWPMI1_BASE (D2_APB1PERIPH_BASE + 0x8800UL) #define OPAMP_BASE (D2_APB1PERIPH_BASE + 0x9000UL) #define OPAMP1_BASE (D2_APB1PERIPH_BASE + 0x9000UL) #define OPAMP2_BASE (D2_APB1PERIPH_BASE + 0x9010UL) #define MDIOS_BASE (D2_APB1PERIPH_BASE + 0x9400UL) #define FDCAN1_BASE (D2_APB1PERIPH_BASE + 0xA000UL) #define FDCAN2_BASE (D2_APB1PERIPH_BASE + 0xA400UL) #define FDCAN_CCU_BASE (D2_APB1PERIPH_BASE + 0xA800UL) #define SRAMCAN_BASE (D2_APB1PERIPH_BASE + 0xAC00UL) #define FDCAN3_BASE (D2_APB1PERIPH_BASE + 0xD400UL) #define TIM23_BASE (D2_APB1PERIPH_BASE + 0xE000UL) #define TIM24_BASE (D2_APB1PERIPH_BASE + 0xE400UL) /*!< D2_APB2PERIPH peripherals */ #define TIM1_BASE (D2_APB2PERIPH_BASE + 0x0000UL) #define TIM8_BASE (D2_APB2PERIPH_BASE + 0x0400UL) #define USART1_BASE (D2_APB2PERIPH_BASE + 0x1000UL) #define USART6_BASE (D2_APB2PERIPH_BASE + 0x1400UL) #define UART9_BASE (D2_APB2PERIPH_BASE + 0x1800UL) #define USART10_BASE (D2_APB2PERIPH_BASE + 0x1C00UL) #define SPI1_BASE (D2_APB2PERIPH_BASE + 0x3000UL) #define SPI4_BASE (D2_APB2PERIPH_BASE + 0x3400UL) #define TIM15_BASE (D2_APB2PERIPH_BASE + 0x4000UL) #define TIM16_BASE (D2_APB2PERIPH_BASE + 0x4400UL) #define TIM17_BASE (D2_APB2PERIPH_BASE + 0x4800UL) #define SPI5_BASE (D2_APB2PERIPH_BASE + 0x5000UL) #define SAI1_BASE (D2_APB2PERIPH_BASE + 0x5800UL) #define SAI1_Block_A_BASE (SAI1_BASE + 0x004UL) #define SAI1_Block_B_BASE (SAI1_BASE + 0x024UL) #define DFSDM1_BASE (D2_APB2PERIPH_BASE + 0x7800UL) #define DFSDM1_Channel0_BASE (DFSDM1_BASE + 0x00UL) #define DFSDM1_Channel1_BASE (DFSDM1_BASE + 0x20UL) #define DFSDM1_Channel2_BASE (DFSDM1_BASE + 0x40UL) #define DFSDM1_Channel3_BASE (DFSDM1_BASE + 0x60UL) #define DFSDM1_Channel4_BASE (DFSDM1_BASE + 0x80UL) #define DFSDM1_Channel5_BASE (DFSDM1_BASE + 0xA0UL) #define DFSDM1_Channel6_BASE (DFSDM1_BASE + 0xC0UL) #define DFSDM1_Channel7_BASE (DFSDM1_BASE + 0xE0UL) #define DFSDM1_Filter0_BASE (DFSDM1_BASE + 0x100UL) #define DFSDM1_Filter1_BASE (DFSDM1_BASE + 0x180UL) #define DFSDM1_Filter2_BASE (DFSDM1_BASE + 0x200UL) #define DFSDM1_Filter3_BASE (DFSDM1_BASE + 0x280UL) /*!< D3_APB1PERIPH peripherals */ #define EXTI_BASE (D3_APB1PERIPH_BASE + 0x0000UL) #define EXTI_D1_BASE (EXTI_BASE + 0x0080UL) #define EXTI_D2_BASE (EXTI_BASE + 0x00C0UL) #define SYSCFG_BASE (D3_APB1PERIPH_BASE + 0x0400UL) #define LPUART1_BASE (D3_APB1PERIPH_BASE + 0x0C00UL) #define SPI6_BASE (D3_APB1PERIPH_BASE + 0x1400UL) #define I2C4_BASE (D3_APB1PERIPH_BASE + 0x1C00UL) #define LPTIM2_BASE (D3_APB1PERIPH_BASE + 0x2400UL) #define LPTIM3_BASE (D3_APB1PERIPH_BASE + 0x2800UL) #define LPTIM4_BASE (D3_APB1PERIPH_BASE + 0x2C00UL) #define LPTIM5_BASE (D3_APB1PERIPH_BASE + 0x3000UL) #define COMP12_BASE (D3_APB1PERIPH_BASE + 0x3800UL) #define COMP1_BASE (COMP12_BASE + 0x0CUL) #define COMP2_BASE (COMP12_BASE + 0x10UL) #define VREFBUF_BASE (D3_APB1PERIPH_BASE + 0x3C00UL) #define RTC_BASE (D3_APB1PERIPH_BASE + 0x4000UL) #define IWDG1_BASE (D3_APB1PERIPH_BASE + 0x4800UL) #define SAI4_BASE (D3_APB1PERIPH_BASE + 0x5400UL) #define SAI4_Block_A_BASE (SAI4_BASE + 0x004UL) #define SAI4_Block_B_BASE (SAI4_BASE + 0x024UL) #define DTS_BASE (D3_APB1PERIPH_BASE + 0x6800UL) #define BDMA_Channel0_BASE (BDMA_BASE + 0x0008UL) #define BDMA_Channel1_BASE (BDMA_BASE + 0x001CUL) #define BDMA_Channel2_BASE (BDMA_BASE + 0x0030UL) #define BDMA_Channel3_BASE (BDMA_BASE + 0x0044UL) #define BDMA_Channel4_BASE (BDMA_BASE + 0x0058UL) #define BDMA_Channel5_BASE (BDMA_BASE + 0x006CUL) #define BDMA_Channel6_BASE (BDMA_BASE + 0x0080UL) #define BDMA_Channel7_BASE (BDMA_BASE + 0x0094UL) #define DMAMUX2_Channel0_BASE (DMAMUX2_BASE) #define DMAMUX2_Channel1_BASE (DMAMUX2_BASE + 0x0004UL) #define DMAMUX2_Channel2_BASE (DMAMUX2_BASE + 0x0008UL) #define DMAMUX2_Channel3_BASE (DMAMUX2_BASE + 0x000CUL) #define DMAMUX2_Channel4_BASE (DMAMUX2_BASE + 0x0010UL) #define DMAMUX2_Channel5_BASE (DMAMUX2_BASE + 0x0014UL) #define DMAMUX2_Channel6_BASE (DMAMUX2_BASE + 0x0018UL) #define DMAMUX2_Channel7_BASE (DMAMUX2_BASE + 0x001CUL) #define DMAMUX2_RequestGenerator0_BASE (DMAMUX2_BASE + 0x0100UL) #define DMAMUX2_RequestGenerator1_BASE (DMAMUX2_BASE + 0x0104UL) #define DMAMUX2_RequestGenerator2_BASE (DMAMUX2_BASE + 0x0108UL) #define DMAMUX2_RequestGenerator3_BASE (DMAMUX2_BASE + 0x010CUL) #define DMAMUX2_RequestGenerator4_BASE (DMAMUX2_BASE + 0x0110UL) #define DMAMUX2_RequestGenerator5_BASE (DMAMUX2_BASE + 0x0114UL) #define DMAMUX2_RequestGenerator6_BASE (DMAMUX2_BASE + 0x0118UL) #define DMAMUX2_RequestGenerator7_BASE (DMAMUX2_BASE + 0x011CUL) #define DMAMUX2_ChannelStatus_BASE (DMAMUX2_BASE + 0x0080UL) #define DMAMUX2_RequestGenStatus_BASE (DMAMUX2_BASE + 0x0140UL) #define DMA1_Stream0_BASE (DMA1_BASE + 0x010UL) #define DMA1_Stream1_BASE (DMA1_BASE + 0x028UL) #define DMA1_Stream2_BASE (DMA1_BASE + 0x040UL) #define DMA1_Stream3_BASE (DMA1_BASE + 0x058UL) #define DMA1_Stream4_BASE (DMA1_BASE + 0x070UL) #define DMA1_Stream5_BASE (DMA1_BASE + 0x088UL) #define DMA1_Stream6_BASE (DMA1_BASE + 0x0A0UL) #define DMA1_Stream7_BASE (DMA1_BASE + 0x0B8UL) #define DMA2_Stream0_BASE (DMA2_BASE + 0x010UL) #define DMA2_Stream1_BASE (DMA2_BASE + 0x028UL) #define DMA2_Stream2_BASE (DMA2_BASE + 0x040UL) #define DMA2_Stream3_BASE (DMA2_BASE + 0x058UL) #define DMA2_Stream4_BASE (DMA2_BASE + 0x070UL) #define DMA2_Stream5_BASE (DMA2_BASE + 0x088UL) #define DMA2_Stream6_BASE (DMA2_BASE + 0x0A0UL) #define DMA2_Stream7_BASE (DMA2_BASE + 0x0B8UL) #define DMAMUX1_Channel0_BASE (DMAMUX1_BASE) #define DMAMUX1_Channel1_BASE (DMAMUX1_BASE + 0x0004UL) #define DMAMUX1_Channel2_BASE (DMAMUX1_BASE + 0x0008UL) #define DMAMUX1_Channel3_BASE (DMAMUX1_BASE + 0x000CUL) #define DMAMUX1_Channel4_BASE (DMAMUX1_BASE + 0x0010UL) #define DMAMUX1_Channel5_BASE (DMAMUX1_BASE + 0x0014UL) #define DMAMUX1_Channel6_BASE (DMAMUX1_BASE + 0x0018UL) #define DMAMUX1_Channel7_BASE (DMAMUX1_BASE + 0x001CUL) #define DMAMUX1_Channel8_BASE (DMAMUX1_BASE + 0x0020UL) #define DMAMUX1_Channel9_BASE (DMAMUX1_BASE + 0x0024UL) #define DMAMUX1_Channel10_BASE (DMAMUX1_BASE + 0x0028UL) #define DMAMUX1_Channel11_BASE (DMAMUX1_BASE + 0x002CUL) #define DMAMUX1_Channel12_BASE (DMAMUX1_BASE + 0x0030UL) #define DMAMUX1_Channel13_BASE (DMAMUX1_BASE + 0x0034UL) #define DMAMUX1_Channel14_BASE (DMAMUX1_BASE + 0x0038UL) #define DMAMUX1_Channel15_BASE (DMAMUX1_BASE + 0x003CUL) #define DMAMUX1_RequestGenerator0_BASE (DMAMUX1_BASE + 0x0100UL) #define DMAMUX1_RequestGenerator1_BASE (DMAMUX1_BASE + 0x0104UL) #define DMAMUX1_RequestGenerator2_BASE (DMAMUX1_BASE + 0x0108UL) #define DMAMUX1_RequestGenerator3_BASE (DMAMUX1_BASE + 0x010CUL) #define DMAMUX1_RequestGenerator4_BASE (DMAMUX1_BASE + 0x0110UL) #define DMAMUX1_RequestGenerator5_BASE (DMAMUX1_BASE + 0x0114UL) #define DMAMUX1_RequestGenerator6_BASE (DMAMUX1_BASE + 0x0118UL) #define DMAMUX1_RequestGenerator7_BASE (DMAMUX1_BASE + 0x011CUL) #define DMAMUX1_ChannelStatus_BASE (DMAMUX1_BASE + 0x0080UL) #define DMAMUX1_RequestGenStatus_BASE (DMAMUX1_BASE + 0x0140UL) /*!< FMC Banks registers base address */ #define FMC_Bank1_R_BASE (FMC_R_BASE + 0x0000UL) #define FMC_Bank1E_R_BASE (FMC_R_BASE + 0x0104UL) #define FMC_Bank2_R_BASE (FMC_R_BASE + 0x0060UL) #define FMC_Bank3_R_BASE (FMC_R_BASE + 0x0080UL) #define FMC_Bank5_6_R_BASE (FMC_R_BASE + 0x0140UL) /* Debug MCU registers base address */ #define DBGMCU_BASE (0x5C001000UL) #define MDMA_Channel0_BASE (MDMA_BASE + 0x00000040UL) #define MDMA_Channel1_BASE (MDMA_BASE + 0x00000080UL) #define MDMA_Channel2_BASE (MDMA_BASE + 0x000000C0UL) #define MDMA_Channel3_BASE (MDMA_BASE + 0x00000100UL) #define MDMA_Channel4_BASE (MDMA_BASE + 0x00000140UL) #define MDMA_Channel5_BASE (MDMA_BASE + 0x00000180UL) #define MDMA_Channel6_BASE (MDMA_BASE + 0x000001C0UL) #define MDMA_Channel7_BASE (MDMA_BASE + 0x00000200UL) #define MDMA_Channel8_BASE (MDMA_BASE + 0x00000240UL) #define MDMA_Channel9_BASE (MDMA_BASE + 0x00000280UL) #define MDMA_Channel10_BASE (MDMA_BASE + 0x000002C0UL) #define MDMA_Channel11_BASE (MDMA_BASE + 0x00000300UL) #define MDMA_Channel12_BASE (MDMA_BASE + 0x00000340UL) #define MDMA_Channel13_BASE (MDMA_BASE + 0x00000380UL) #define MDMA_Channel14_BASE (MDMA_BASE + 0x000003C0UL) #define MDMA_Channel15_BASE (MDMA_BASE + 0x00000400UL) #define RAMECC1_Monitor1_BASE (RAMECC1_BASE + 0x20UL) #define RAMECC1_Monitor2_BASE (RAMECC1_BASE + 0x40UL) #define RAMECC1_Monitor3_BASE (RAMECC1_BASE + 0x60UL) #define RAMECC1_Monitor4_BASE (RAMECC1_BASE + 0x80UL) #define RAMECC1_Monitor5_BASE (RAMECC1_BASE + 0xA0UL) #define RAMECC1_Monitor6_BASE (RAMECC1_BASE + 0xC0UL) #define RAMECC2_Monitor1_BASE (RAMECC2_BASE + 0x20UL) #define RAMECC2_Monitor2_BASE (RAMECC2_BASE + 0x40UL) #define RAMECC2_Monitor3_BASE (RAMECC2_BASE + 0x60UL) #define RAMECC3_Monitor1_BASE (RAMECC3_BASE + 0x20UL) #define RAMECC3_Monitor2_BASE (RAMECC3_BASE + 0x40UL) #define GPV_BASE (PERIPH_BASE + 0x11000000UL) /*!< GPV_BASE (PERIPH_BASE + 0x11000000UL) */ /** * @} */ /** @addtogroup Peripheral_declaration * @{ */ #define TIM2 ((TIM_TypeDef *) TIM2_BASE) #define TIM3 ((TIM_TypeDef *) TIM3_BASE) #define TIM4 ((TIM_TypeDef *) TIM4_BASE) #define TIM5 ((TIM_TypeDef *) TIM5_BASE) #define TIM6 ((TIM_TypeDef *) TIM6_BASE) #define TIM7 ((TIM_TypeDef *) TIM7_BASE) #define TIM13 ((TIM_TypeDef *) TIM13_BASE) #define TIM14 ((TIM_TypeDef *) TIM14_BASE) #define VREFBUF ((VREFBUF_TypeDef *) VREFBUF_BASE) #define RTC ((RTC_TypeDef *) RTC_BASE) #define WWDG1 ((WWDG_TypeDef *) WWDG1_BASE) #define IWDG1 ((IWDG_TypeDef *) IWDG1_BASE) #define SPI2 ((SPI_TypeDef *) SPI2_BASE) #define SPI3 ((SPI_TypeDef *) SPI3_BASE) #define SPI4 ((SPI_TypeDef *) SPI4_BASE) #define SPI5 ((SPI_TypeDef *) SPI5_BASE) #define SPI6 ((SPI_TypeDef *) SPI6_BASE) #define USART2 ((USART_TypeDef *) USART2_BASE) #define USART3 ((USART_TypeDef *) USART3_BASE) #define USART6 ((USART_TypeDef *) USART6_BASE) #define USART10 ((USART_TypeDef *) USART10_BASE) #define UART7 ((USART_TypeDef *) UART7_BASE) #define UART8 ((USART_TypeDef *) UART8_BASE) #define UART9 ((USART_TypeDef *) UART9_BASE) #define CRS ((CRS_TypeDef *) CRS_BASE) #define UART4 ((USART_TypeDef *) UART4_BASE) #define UART5 ((USART_TypeDef *) UART5_BASE) #define I2C1 ((I2C_TypeDef *) I2C1_BASE) #define I2C2 ((I2C_TypeDef *) I2C2_BASE) #define I2C3 ((I2C_TypeDef *) I2C3_BASE) #define I2C4 ((I2C_TypeDef *) I2C4_BASE) #define I2C5 ((I2C_TypeDef *) I2C5_BASE) #define FDCAN1 ((FDCAN_GlobalTypeDef *) FDCAN1_BASE) #define FDCAN2 ((FDCAN_GlobalTypeDef *) FDCAN2_BASE) #define FDCAN_CCU ((FDCAN_ClockCalibrationUnit_TypeDef *) FDCAN_CCU_BASE) #define FDCAN3 ((FDCAN_GlobalTypeDef *) FDCAN3_BASE) #define TIM23 ((TIM_TypeDef *) TIM23_BASE) #define TIM24 ((TIM_TypeDef *) TIM24_BASE) #define CEC ((CEC_TypeDef *) CEC_BASE) #define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE) #define PWR ((PWR_TypeDef *) PWR_BASE) #define DAC1 ((DAC_TypeDef *) DAC1_BASE) #define LPUART1 ((USART_TypeDef *) LPUART1_BASE) #define SWPMI1 ((SWPMI_TypeDef *) SWPMI1_BASE) #define LPTIM2 ((LPTIM_TypeDef *) LPTIM2_BASE) #define LPTIM3 ((LPTIM_TypeDef *) LPTIM3_BASE) #define DTS ((DTS_TypeDef *) DTS_BASE) #define LPTIM4 ((LPTIM_TypeDef *) LPTIM4_BASE) #define LPTIM5 ((LPTIM_TypeDef *) LPTIM5_BASE) #define SYSCFG ((SYSCFG_TypeDef *) SYSCFG_BASE) #define COMP12 ((COMPOPT_TypeDef *) COMP12_BASE) #define COMP1 ((COMP_TypeDef *) COMP1_BASE) #define COMP2 ((COMP_TypeDef *) COMP2_BASE) #define COMP12_COMMON ((COMP_Common_TypeDef *) COMP2_BASE) #define OPAMP ((OPAMP_TypeDef *) OPAMP_BASE) #define OPAMP1 ((OPAMP_TypeDef *) OPAMP1_BASE) #define OPAMP2 ((OPAMP_TypeDef *) OPAMP2_BASE) #define EXTI ((EXTI_TypeDef *) EXTI_BASE) #define EXTI_D1 ((EXTI_Core_TypeDef *) EXTI_D1_BASE) #define EXTI_D2 ((EXTI_Core_TypeDef *) EXTI_D2_BASE) #define TIM1 ((TIM_TypeDef *) TIM1_BASE) #define SPI1 ((SPI_TypeDef *) SPI1_BASE) #define TIM8 ((TIM_TypeDef *) TIM8_BASE) #define USART1 ((USART_TypeDef *) USART1_BASE) #define TIM12 ((TIM_TypeDef *) TIM12_BASE) #define TIM15 ((TIM_TypeDef *) TIM15_BASE) #define TIM16 ((TIM_TypeDef *) TIM16_BASE) #define TIM17 ((TIM_TypeDef *) TIM17_BASE) #define SAI1 ((SAI_TypeDef *) SAI1_BASE) #define SAI1_Block_A ((SAI_Block_TypeDef *)SAI1_Block_A_BASE) #define SAI1_Block_B ((SAI_Block_TypeDef *)SAI1_Block_B_BASE) #define SAI4 ((SAI_TypeDef *) SAI4_BASE) #define SAI4_Block_A ((SAI_Block_TypeDef *)SAI4_Block_A_BASE) #define SAI4_Block_B ((SAI_Block_TypeDef *)SAI4_Block_B_BASE) #define SPDIFRX ((SPDIFRX_TypeDef *) SPDIFRX_BASE) #define DFSDM1_Channel0 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel0_BASE) #define DFSDM1_Channel1 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel1_BASE) #define DFSDM1_Channel2 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel2_BASE) #define DFSDM1_Channel3 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel3_BASE) #define DFSDM1_Channel4 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel4_BASE) #define DFSDM1_Channel5 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel5_BASE) #define DFSDM1_Channel6 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel6_BASE) #define DFSDM1_Channel7 ((DFSDM_Channel_TypeDef *) DFSDM1_Channel7_BASE) #define DFSDM1_Filter0 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter0_BASE) #define DFSDM1_Filter1 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter1_BASE) #define DFSDM1_Filter2 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter2_BASE) #define DFSDM1_Filter3 ((DFSDM_Filter_TypeDef *) DFSDM1_Filter3_BASE) #define DMA2D ((DMA2D_TypeDef *) DMA2D_BASE) #define DCMI ((DCMI_TypeDef *) DCMI_BASE) #define PSSI ((PSSI_TypeDef *) PSSI_BASE) #define RCC ((RCC_TypeDef *) RCC_BASE) #define FLASH ((FLASH_TypeDef *) FLASH_R_BASE) #define CRC ((CRC_TypeDef *) CRC_BASE) #define GPIOA ((GPIO_TypeDef *) GPIOA_BASE) #define GPIOB ((GPIO_TypeDef *) GPIOB_BASE) #define GPIOC ((GPIO_TypeDef *) GPIOC_BASE) #define GPIOD ((GPIO_TypeDef *) GPIOD_BASE) #define GPIOE ((GPIO_TypeDef *) GPIOE_BASE) #define GPIOF ((GPIO_TypeDef *) GPIOF_BASE) #define GPIOG ((GPIO_TypeDef *) GPIOG_BASE) #define GPIOH ((GPIO_TypeDef *) GPIOH_BASE) #define GPIOJ ((GPIO_TypeDef *) GPIOJ_BASE) #define GPIOK ((GPIO_TypeDef *) GPIOK_BASE) #define ADC1 ((ADC_TypeDef *) ADC1_BASE) #define ADC2 ((ADC_TypeDef *) ADC2_BASE) #define ADC3 ((ADC_TypeDef *) ADC3_BASE) #define ADC3_COMMON ((ADC_Common_TypeDef *) ADC3_COMMON_BASE) #define ADC12_COMMON ((ADC_Common_TypeDef *) ADC12_COMMON_BASE) #define CRYP ((CRYP_TypeDef *) CRYP_BASE) #define HASH ((HASH_TypeDef *) HASH_BASE) #define HASH_DIGEST ((HASH_DIGEST_TypeDef *) HASH_DIGEST_BASE) #define RNG ((RNG_TypeDef *) RNG_BASE) #define SDMMC2 ((SDMMC_TypeDef *) SDMMC2_BASE) #define DLYB_SDMMC2 ((DLYB_TypeDef *) DLYB_SDMMC2_BASE) #define FMAC ((FMAC_TypeDef *) FMAC_BASE) #define CORDIC ((CORDIC_TypeDef *) CORDIC_BASE) #define BDMA ((BDMA_TypeDef *) BDMA_BASE) #define BDMA_Channel0 ((BDMA_Channel_TypeDef *) BDMA_Channel0_BASE) #define BDMA_Channel1 ((BDMA_Channel_TypeDef *) BDMA_Channel1_BASE) #define BDMA_Channel2 ((BDMA_Channel_TypeDef *) BDMA_Channel2_BASE) #define BDMA_Channel3 ((BDMA_Channel_TypeDef *) BDMA_Channel3_BASE) #define BDMA_Channel4 ((BDMA_Channel_TypeDef *) BDMA_Channel4_BASE) #define BDMA_Channel5 ((BDMA_Channel_TypeDef *) BDMA_Channel5_BASE) #define BDMA_Channel6 ((BDMA_Channel_TypeDef *) BDMA_Channel6_BASE) #define BDMA_Channel7 ((BDMA_Channel_TypeDef *) BDMA_Channel7_BASE) #define RAMECC1 ((RAMECC_TypeDef *)RAMECC1_BASE) #define RAMECC1_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor1_BASE) #define RAMECC1_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor2_BASE) #define RAMECC1_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor3_BASE) #define RAMECC1_Monitor4 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor4_BASE) #define RAMECC1_Monitor5 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor5_BASE) #define RAMECC1_Monitor6 ((RAMECC_MonitorTypeDef *)RAMECC1_Monitor6_BASE) #define RAMECC2 ((RAMECC_TypeDef *)RAMECC2_BASE) #define RAMECC2_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor1_BASE) #define RAMECC2_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor2_BASE) #define RAMECC2_Monitor3 ((RAMECC_MonitorTypeDef *)RAMECC2_Monitor3_BASE) #define RAMECC3 ((RAMECC_TypeDef *)RAMECC3_BASE) #define RAMECC3_Monitor1 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor1_BASE) #define RAMECC3_Monitor2 ((RAMECC_MonitorTypeDef *)RAMECC3_Monitor2_BASE) #define DMAMUX2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_BASE) #define DMAMUX2_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel0_BASE) #define DMAMUX2_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel1_BASE) #define DMAMUX2_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel2_BASE) #define DMAMUX2_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel3_BASE) #define DMAMUX2_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel4_BASE) #define DMAMUX2_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel5_BASE) #define DMAMUX2_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel6_BASE) #define DMAMUX2_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX2_Channel7_BASE) #define DMAMUX2_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator0_BASE) #define DMAMUX2_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator1_BASE) #define DMAMUX2_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator2_BASE) #define DMAMUX2_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator3_BASE) #define DMAMUX2_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator4_BASE) #define DMAMUX2_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator5_BASE) #define DMAMUX2_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator6_BASE) #define DMAMUX2_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX2_RequestGenerator7_BASE) #define DMAMUX2_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX2_ChannelStatus_BASE) #define DMAMUX2_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX2_RequestGenStatus_BASE) #define DMA2 ((DMA_TypeDef *) DMA2_BASE) #define DMA2_Stream0 ((DMA_Stream_TypeDef *) DMA2_Stream0_BASE) #define DMA2_Stream1 ((DMA_Stream_TypeDef *) DMA2_Stream1_BASE) #define DMA2_Stream2 ((DMA_Stream_TypeDef *) DMA2_Stream2_BASE) #define DMA2_Stream3 ((DMA_Stream_TypeDef *) DMA2_Stream3_BASE) #define DMA2_Stream4 ((DMA_Stream_TypeDef *) DMA2_Stream4_BASE) #define DMA2_Stream5 ((DMA_Stream_TypeDef *) DMA2_Stream5_BASE) #define DMA2_Stream6 ((DMA_Stream_TypeDef *) DMA2_Stream6_BASE) #define DMA2_Stream7 ((DMA_Stream_TypeDef *) DMA2_Stream7_BASE) #define DMA1 ((DMA_TypeDef *) DMA1_BASE) #define DMA1_Stream0 ((DMA_Stream_TypeDef *) DMA1_Stream0_BASE) #define DMA1_Stream1 ((DMA_Stream_TypeDef *) DMA1_Stream1_BASE) #define DMA1_Stream2 ((DMA_Stream_TypeDef *) DMA1_Stream2_BASE) #define DMA1_Stream3 ((DMA_Stream_TypeDef *) DMA1_Stream3_BASE) #define DMA1_Stream4 ((DMA_Stream_TypeDef *) DMA1_Stream4_BASE) #define DMA1_Stream5 ((DMA_Stream_TypeDef *) DMA1_Stream5_BASE) #define DMA1_Stream6 ((DMA_Stream_TypeDef *) DMA1_Stream6_BASE) #define DMA1_Stream7 ((DMA_Stream_TypeDef *) DMA1_Stream7_BASE) #define DMAMUX1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_BASE) #define DMAMUX1_Channel0 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel0_BASE) #define DMAMUX1_Channel1 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel1_BASE) #define DMAMUX1_Channel2 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel2_BASE) #define DMAMUX1_Channel3 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel3_BASE) #define DMAMUX1_Channel4 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel4_BASE) #define DMAMUX1_Channel5 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel5_BASE) #define DMAMUX1_Channel6 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel6_BASE) #define DMAMUX1_Channel7 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel7_BASE) #define DMAMUX1_Channel8 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel8_BASE) #define DMAMUX1_Channel9 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel9_BASE) #define DMAMUX1_Channel10 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel10_BASE) #define DMAMUX1_Channel11 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel11_BASE) #define DMAMUX1_Channel12 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel12_BASE) #define DMAMUX1_Channel13 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel13_BASE) #define DMAMUX1_Channel14 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel14_BASE) #define DMAMUX1_Channel15 ((DMAMUX_Channel_TypeDef *) DMAMUX1_Channel15_BASE) #define DMAMUX1_RequestGenerator0 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator0_BASE) #define DMAMUX1_RequestGenerator1 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator1_BASE) #define DMAMUX1_RequestGenerator2 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator2_BASE) #define DMAMUX1_RequestGenerator3 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator3_BASE) #define DMAMUX1_RequestGenerator4 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator4_BASE) #define DMAMUX1_RequestGenerator5 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator5_BASE) #define DMAMUX1_RequestGenerator6 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator6_BASE) #define DMAMUX1_RequestGenerator7 ((DMAMUX_RequestGen_TypeDef *) DMAMUX1_RequestGenerator7_BASE) #define DMAMUX1_ChannelStatus ((DMAMUX_ChannelStatus_TypeDef *) DMAMUX1_ChannelStatus_BASE) #define DMAMUX1_RequestGenStatus ((DMAMUX_RequestGenStatus_TypeDef *) DMAMUX1_RequestGenStatus_BASE) #define FMC_Bank1_R ((FMC_Bank1_TypeDef *) FMC_Bank1_R_BASE) #define FMC_Bank1E_R ((FMC_Bank1E_TypeDef *) FMC_Bank1E_R_BASE) #define FMC_Bank2_R ((FMC_Bank2_TypeDef *) FMC_Bank2_R_BASE) #define FMC_Bank3_R ((FMC_Bank3_TypeDef *) FMC_Bank3_R_BASE) #define FMC_Bank5_6_R ((FMC_Bank5_6_TypeDef *) FMC_Bank5_6_R_BASE) #define OCTOSPI1 ((OCTOSPI_TypeDef *) OCTOSPI1_R_BASE) #define DLYB_OCTOSPI1 ((DLYB_TypeDef *) DLYB_OCTOSPI1_BASE) #define OCTOSPI2 ((OCTOSPI_TypeDef *) OCTOSPI2_R_BASE) #define DLYB_OCTOSPI2 ((DLYB_TypeDef *) DLYB_OCTOSPI2_BASE) #define OCTOSPIM ((OCTOSPIM_TypeDef *) OCTOSPIM_BASE) #define OTFDEC1 ((OTFDEC_TypeDef *) OTFDEC1_BASE) #define OTFDEC1_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION1_BASE) #define OTFDEC1_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION2_BASE) #define OTFDEC1_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION3_BASE) #define OTFDEC1_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC1_REGION4_BASE) #define OTFDEC2 ((OTFDEC_TypeDef *) OTFDEC2_BASE) #define OTFDEC2_REGION1 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION1_BASE) #define OTFDEC2_REGION2 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION2_BASE) #define OTFDEC2_REGION3 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION3_BASE) #define OTFDEC2_REGION4 ((OTFDEC_Region_TypeDef *) OTFDEC2_REGION4_BASE) #define SDMMC1 ((SDMMC_TypeDef *) SDMMC1_BASE) #define DLYB_SDMMC1 ((DLYB_TypeDef *) DLYB_SDMMC1_BASE) #define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE) #define HSEM ((HSEM_TypeDef *) HSEM_BASE) #define HSEM_COMMON ((HSEM_Common_TypeDef *) (HSEM_BASE + 0x100UL)) #define LTDC ((LTDC_TypeDef *)LTDC_BASE) #define LTDC_Layer1 ((LTDC_Layer_TypeDef *)LTDC_Layer1_BASE) #define LTDC_Layer2 ((LTDC_Layer_TypeDef *)LTDC_Layer2_BASE) #define MDIOS ((MDIOS_TypeDef *) MDIOS_BASE) #define ETH ((ETH_TypeDef *)ETH_BASE) #define MDMA ((MDMA_TypeDef *)MDMA_BASE) #define MDMA_Channel0 ((MDMA_Channel_TypeDef *)MDMA_Channel0_BASE) #define MDMA_Channel1 ((MDMA_Channel_TypeDef *)MDMA_Channel1_BASE) #define MDMA_Channel2 ((MDMA_Channel_TypeDef *)MDMA_Channel2_BASE) #define MDMA_Channel3 ((MDMA_Channel_TypeDef *)MDMA_Channel3_BASE) #define MDMA_Channel4 ((MDMA_Channel_TypeDef *)MDMA_Channel4_BASE) #define MDMA_Channel5 ((MDMA_Channel_TypeDef *)MDMA_Channel5_BASE) #define MDMA_Channel6 ((MDMA_Channel_TypeDef *)MDMA_Channel6_BASE) #define MDMA_Channel7 ((MDMA_Channel_TypeDef *)MDMA_Channel7_BASE) #define MDMA_Channel8 ((MDMA_Channel_TypeDef *)MDMA_Channel8_BASE) #define MDMA_Channel9 ((MDMA_Channel_TypeDef *)MDMA_Channel9_BASE) #define MDMA_Channel10 ((MDMA_Channel_TypeDef *)MDMA_Channel10_BASE) #define MDMA_Channel11 ((MDMA_Channel_TypeDef *)MDMA_Channel11_BASE) #define MDMA_Channel12 ((MDMA_Channel_TypeDef *)MDMA_Channel12_BASE) #define MDMA_Channel13 ((MDMA_Channel_TypeDef *)MDMA_Channel13_BASE) #define MDMA_Channel14 ((MDMA_Channel_TypeDef *)MDMA_Channel14_BASE) #define MDMA_Channel15 ((MDMA_Channel_TypeDef *)MDMA_Channel15_BASE) #define USB1_OTG_HS ((USB_OTG_GlobalTypeDef *) USB1_OTG_HS_PERIPH_BASE) /* Legacy defines */ #define USB_OTG_HS USB1_OTG_HS #define USB_OTG_HS_PERIPH_BASE USB1_OTG_HS_PERIPH_BASE #define GPV ((GPV_TypeDef *) GPV_BASE) /** * @} */ /** @addtogroup Exported_constants * @{ */ /** @addtogroup Peripheral_Registers_Bits_Definition * @{ */ /******************************************************************************/ /* Peripheral Registers_Bits_Definition */ /******************************************************************************/ /******************************************************************************/ /* */ /* Analog to Digital Converter */ /* */ /******************************************************************************/ /******************************* ADC VERSION ********************************/ #define ADC_VER_V5_V90 /******************** Bit definition for ADC_ISR register ********************/ #define ADC_ISR_ADRDY_Pos (0U) #define ADC_ISR_ADRDY_Msk (0x1UL << ADC_ISR_ADRDY_Pos) /*!< 0x00000001 */ #define ADC_ISR_ADRDY ADC_ISR_ADRDY_Msk /*!< ADC Ready (ADRDY) flag */ #define ADC_ISR_EOSMP_Pos (1U) #define ADC_ISR_EOSMP_Msk (0x1UL << ADC_ISR_EOSMP_Pos) /*!< 0x00000002 */ #define ADC_ISR_EOSMP ADC_ISR_EOSMP_Msk /*!< ADC End of Sampling flag */ #define ADC_ISR_EOC_Pos (2U) #define ADC_ISR_EOC_Msk (0x1UL << ADC_ISR_EOC_Pos) /*!< 0x00000004 */ #define ADC_ISR_EOC ADC_ISR_EOC_Msk /*!< ADC End of Regular Conversion flag */ #define ADC_ISR_EOS_Pos (3U) #define ADC_ISR_EOS_Msk (0x1UL << ADC_ISR_EOS_Pos) /*!< 0x00000008 */ #define ADC_ISR_EOS ADC_ISR_EOS_Msk /*!< ADC End of Regular sequence of Conversions flag */ #define ADC_ISR_OVR_Pos (4U) #define ADC_ISR_OVR_Msk (0x1UL << ADC_ISR_OVR_Pos) /*!< 0x00000010 */ #define ADC_ISR_OVR ADC_ISR_OVR_Msk /*!< ADC overrun flag */ #define ADC_ISR_JEOC_Pos (5U) #define ADC_ISR_JEOC_Msk (0x1UL << ADC_ISR_JEOC_Pos) /*!< 0x00000020 */ #define ADC_ISR_JEOC ADC_ISR_JEOC_Msk /*!< ADC End of Injected Conversion flag */ #define ADC_ISR_JEOS_Pos (6U) #define ADC_ISR_JEOS_Msk (0x1UL << ADC_ISR_JEOS_Pos) /*!< 0x00000040 */ #define ADC_ISR_JEOS ADC_ISR_JEOS_Msk /*!< ADC End of Injected sequence of Conversions flag */ #define ADC_ISR_AWD1_Pos (7U) #define ADC_ISR_AWD1_Msk (0x1UL << ADC_ISR_AWD1_Pos) /*!< 0x00000080 */ #define ADC_ISR_AWD1 ADC_ISR_AWD1_Msk /*!< ADC Analog watchdog 1 flag */ #define ADC_ISR_AWD2_Pos (8U) #define ADC_ISR_AWD2_Msk (0x1UL << ADC_ISR_AWD2_Pos) /*!< 0x00000100 */ #define ADC_ISR_AWD2 ADC_ISR_AWD2_Msk /*!< ADC Analog watchdog 2 flag */ #define ADC_ISR_AWD3_Pos (9U) #define ADC_ISR_AWD3_Msk (0x1UL << ADC_ISR_AWD3_Pos) /*!< 0x00000200 */ #define ADC_ISR_AWD3 ADC_ISR_AWD3_Msk /*!< ADC Analog watchdog 3 flag */ #define ADC_ISR_JQOVF_Pos (10U) #define ADC_ISR_JQOVF_Msk (0x1UL << ADC_ISR_JQOVF_Pos) /*!< 0x00000400 */ #define ADC_ISR_JQOVF ADC_ISR_JQOVF_Msk /*!< ADC Injected Context Queue Overflow flag */ #define ADC_ISR_LDORDY_Pos (12U) #define ADC_ISR_LDORDY_Msk (0x1UL << ADC_ISR_LDORDY_Pos) /*!< 0x00001000 */ #define ADC_ISR_LDORDY ADC_ISR_LDORDY_Msk /*!< ADC LDO Ready (LDORDY) flag */ /******************** Bit definition for ADC_IER register ********************/ #define ADC_IER_ADRDYIE_Pos (0U) #define ADC_IER_ADRDYIE_Msk (0x1UL << ADC_IER_ADRDYIE_Pos) /*!< 0x00000001 */ #define ADC_IER_ADRDYIE ADC_IER_ADRDYIE_Msk /*!< ADC Ready (ADRDY) interrupt source */ #define ADC_IER_EOSMPIE_Pos (1U) #define ADC_IER_EOSMPIE_Msk (0x1UL << ADC_IER_EOSMPIE_Pos) /*!< 0x00000002 */ #define ADC_IER_EOSMPIE ADC_IER_EOSMPIE_Msk /*!< ADC End of Sampling interrupt source */ #define ADC_IER_EOCIE_Pos (2U) #define ADC_IER_EOCIE_Msk (0x1UL << ADC_IER_EOCIE_Pos) /*!< 0x00000004 */ #define ADC_IER_EOCIE ADC_IER_EOCIE_Msk /*!< ADC End of Regular Conversion interrupt source */ #define ADC_IER_EOSIE_Pos (3U) #define ADC_IER_EOSIE_Msk (0x1UL << ADC_IER_EOSIE_Pos) /*!< 0x00000008 */ #define ADC_IER_EOSIE ADC_IER_EOSIE_Msk /*!< ADC End of Regular sequence of Conversions interrupt source */ #define ADC_IER_OVRIE_Pos (4U) #define ADC_IER_OVRIE_Msk (0x1UL << ADC_IER_OVRIE_Pos) /*!< 0x00000010 */ #define ADC_IER_OVRIE ADC_IER_OVRIE_Msk /*!< ADC overrun interrupt source */ #define ADC_IER_JEOCIE_Pos (5U) #define ADC_IER_JEOCIE_Msk (0x1UL << ADC_IER_JEOCIE_Pos) /*!< 0x00000020 */ #define ADC_IER_JEOCIE ADC_IER_JEOCIE_Msk /*!< ADC End of Injected Conversion interrupt source */ #define ADC_IER_JEOSIE_Pos (6U) #define ADC_IER_JEOSIE_Msk (0x1UL << ADC_IER_JEOSIE_Pos) /*!< 0x00000040 */ #define ADC_IER_JEOSIE ADC_IER_JEOSIE_Msk /*!< ADC End of Injected sequence of Conversions interrupt source */ #define ADC_IER_AWD1IE_Pos (7U) #define ADC_IER_AWD1IE_Msk (0x1UL << ADC_IER_AWD1IE_Pos) /*!< 0x00000080 */ #define ADC_IER_AWD1IE ADC_IER_AWD1IE_Msk /*!< ADC Analog watchdog 1 interrupt source */ #define ADC_IER_AWD2IE_Pos (8U) #define ADC_IER_AWD2IE_Msk (0x1UL << ADC_IER_AWD2IE_Pos) /*!< 0x00000100 */ #define ADC_IER_AWD2IE ADC_IER_AWD2IE_Msk /*!< ADC Analog watchdog 2 interrupt source */ #define ADC_IER_AWD3IE_Pos (9U) #define ADC_IER_AWD3IE_Msk (0x1UL << ADC_IER_AWD3IE_Pos) /*!< 0x00000200 */ #define ADC_IER_AWD3IE ADC_IER_AWD3IE_Msk /*!< ADC Analog watchdog 3 interrupt source */ #define ADC_IER_JQOVFIE_Pos (10U) #define ADC_IER_JQOVFIE_Msk (0x1UL << ADC_IER_JQOVFIE_Pos) /*!< 0x00000400 */ #define ADC_IER_JQOVFIE ADC_IER_JQOVFIE_Msk /*!< ADC Injected Context Queue Overflow interrupt source */ /******************** Bit definition for ADC_CR register ********************/ #define ADC_CR_ADEN_Pos (0U) #define ADC_CR_ADEN_Msk (0x1UL << ADC_CR_ADEN_Pos) /*!< 0x00000001 */ #define ADC_CR_ADEN ADC_CR_ADEN_Msk /*!< ADC Enable control */ #define ADC_CR_ADDIS_Pos (1U) #define ADC_CR_ADDIS_Msk (0x1UL << ADC_CR_ADDIS_Pos) /*!< 0x00000002 */ #define ADC_CR_ADDIS ADC_CR_ADDIS_Msk /*!< ADC Disable command */ #define ADC_CR_ADSTART_Pos (2U) #define ADC_CR_ADSTART_Msk (0x1UL << ADC_CR_ADSTART_Pos) /*!< 0x00000004 */ #define ADC_CR_ADSTART ADC_CR_ADSTART_Msk /*!< ADC Start of Regular conversion */ #define ADC_CR_JADSTART_Pos (3U) #define ADC_CR_JADSTART_Msk (0x1UL << ADC_CR_JADSTART_Pos) /*!< 0x00000008 */ #define ADC_CR_JADSTART ADC_CR_JADSTART_Msk /*!< ADC Start of injected conversion */ #define ADC_CR_ADSTP_Pos (4U) #define ADC_CR_ADSTP_Msk (0x1UL << ADC_CR_ADSTP_Pos) /*!< 0x00000010 */ #define ADC_CR_ADSTP ADC_CR_ADSTP_Msk /*!< ADC Stop of Regular conversion */ #define ADC_CR_JADSTP_Pos (5U) #define ADC_CR_JADSTP_Msk (0x1UL << ADC_CR_JADSTP_Pos) /*!< 0x00000020 */ #define ADC_CR_JADSTP ADC_CR_JADSTP_Msk /*!< ADC Stop of injected conversion */ #define ADC_CR_BOOST_Pos (8U) #define ADC_CR_BOOST_Msk (0x3UL << ADC_CR_BOOST_Pos) /*!< 0x00000300 */ #define ADC_CR_BOOST ADC_CR_BOOST_Msk /*!< ADC Boost Mode configuration */ #define ADC_CR_BOOST_0 (0x1UL << ADC_CR_BOOST_Pos) /*!< 0x00000100 */ #define ADC_CR_BOOST_1 (0x2UL << ADC_CR_BOOST_Pos) /*!< 0x00000200 */ #define ADC_CR_ADCALLIN_Pos (16U) #define ADC_CR_ADCALLIN_Msk (0x1UL << ADC_CR_ADCALLIN_Pos) /*!< 0x00010000 */ #define ADC_CR_ADCALLIN ADC_CR_ADCALLIN_Msk /*!< ADC Linearity calibration */ #define ADC_CR_LINCALRDYW1_Pos (22U) #define ADC_CR_LINCALRDYW1_Msk (0x1UL << ADC_CR_LINCALRDYW1_Pos) /*!< 0x00400000 */ #define ADC_CR_LINCALRDYW1 ADC_CR_LINCALRDYW1_Msk /*!< ADC Linearity calibration ready Word 1 */ #define ADC_CR_LINCALRDYW2_Pos (23U) #define ADC_CR_LINCALRDYW2_Msk (0x1UL << ADC_CR_LINCALRDYW2_Pos) /*!< 0x00800000 */ #define ADC_CR_LINCALRDYW2 ADC_CR_LINCALRDYW2_Msk /*!< ADC Linearity calibration ready Word 2 */ #define ADC_CR_LINCALRDYW3_Pos (24U) #define ADC_CR_LINCALRDYW3_Msk (0x1UL << ADC_CR_LINCALRDYW3_Pos) /*!< 0x01000000 */ #define ADC_CR_LINCALRDYW3 ADC_CR_LINCALRDYW3_Msk /*!< ADC Linearity calibration ready Word 3 */ #define ADC_CR_LINCALRDYW4_Pos (25U) #define ADC_CR_LINCALRDYW4_Msk (0x1UL << ADC_CR_LINCALRDYW4_Pos) /*!< 0x02000000 */ #define ADC_CR_LINCALRDYW4 ADC_CR_LINCALRDYW4_Msk /*!< ADC Linearity calibration ready Word 4 */ #define ADC_CR_LINCALRDYW5_Pos (26U) #define ADC_CR_LINCALRDYW5_Msk (0x1UL << ADC_CR_LINCALRDYW5_Pos) /*!< 0x04000000 */ #define ADC_CR_LINCALRDYW5 ADC_CR_LINCALRDYW5_Msk /*!< ADC Linearity calibration ready Word 5 */ #define ADC_CR_LINCALRDYW6_Pos (27U) #define ADC_CR_LINCALRDYW6_Msk (0x1UL << ADC_CR_LINCALRDYW6_Pos) /*!< 0x08000000 */ #define ADC_CR_LINCALRDYW6 ADC_CR_LINCALRDYW6_Msk /*!< ADC Linearity calibration ready Word 6 */ #define ADC_CR_ADVREGEN_Pos (28U) #define ADC_CR_ADVREGEN_Msk (0x1UL << ADC_CR_ADVREGEN_Pos) /*!< 0x10000000 */ #define ADC_CR_ADVREGEN ADC_CR_ADVREGEN_Msk /*!< ADC Voltage regulator Enable */ #define ADC_CR_DEEPPWD_Pos (29U) #define ADC_CR_DEEPPWD_Msk (0x1UL << ADC_CR_DEEPPWD_Pos) /*!< 0x20000000 */ #define ADC_CR_DEEPPWD ADC_CR_DEEPPWD_Msk /*!< ADC Deep power down Enable */ #define ADC_CR_ADCALDIF_Pos (30U) #define ADC_CR_ADCALDIF_Msk (0x1UL << ADC_CR_ADCALDIF_Pos) /*!< 0x40000000 */ #define ADC_CR_ADCALDIF ADC_CR_ADCALDIF_Msk /*!< ADC Differential Mode for calibration */ #define ADC_CR_ADCAL_Pos (31U) #define ADC_CR_ADCAL_Msk (0x1UL << ADC_CR_ADCAL_Pos) /*!< 0x80000000 */ #define ADC_CR_ADCAL ADC_CR_ADCAL_Msk /*!< ADC Calibration */ /******************** Bit definition for ADC_CFGR register ********************/ #define ADC_CFGR_DMNGT_Pos (0U) #define ADC_CFGR_DMNGT_Msk (0x3UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000003 */ #define ADC_CFGR_DMNGT ADC_CFGR_DMNGT_Msk /*!< ADC Data Management configuration */ #define ADC_CFGR_DMNGT_0 (0x1UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000001 */ #define ADC_CFGR_DMNGT_1 (0x2UL << ADC_CFGR_DMNGT_Pos) /*!< 0x00000002 */ #define ADC_CFGR_RES_Pos (2U) #define ADC_CFGR_RES_Msk (0x7UL << ADC_CFGR_RES_Pos) /*!< 0x0000001C */ #define ADC_CFGR_RES ADC_CFGR_RES_Msk /*!< ADC Data resolution */ #define ADC_CFGR_RES_0 (0x1UL << ADC_CFGR_RES_Pos) /*!< 0x00000004 */ #define ADC_CFGR_RES_1 (0x2UL << ADC_CFGR_RES_Pos) /*!< 0x00000008 */ #define ADC_CFGR_RES_2 (0x4UL << ADC_CFGR_RES_Pos) /*!< 0x00000010 */ #define ADC_CFGR_EXTSEL_Pos (5U) #define ADC_CFGR_EXTSEL_Msk (0x1FUL << ADC_CFGR_EXTSEL_Pos) /*!< 0x000003E0 */ #define ADC_CFGR_EXTSEL ADC_CFGR_EXTSEL_Msk /*!< ADC External trigger selection for regular group */ #define ADC_CFGR_EXTSEL_0 (0x01UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000020 */ #define ADC_CFGR_EXTSEL_1 (0x02UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000040 */ #define ADC_CFGR_EXTSEL_2 (0x04UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000080 */ #define ADC_CFGR_EXTSEL_3 (0x08UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000100 */ #define ADC_CFGR_EXTSEL_4 (0x10UL << ADC_CFGR_EXTSEL_Pos) /*!< 0x00000200 */ #define ADC_CFGR_EXTEN_Pos (10U) #define ADC_CFGR_EXTEN_Msk (0x3UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000C00 */ #define ADC_CFGR_EXTEN ADC_CFGR_EXTEN_Msk /*!< ADC External trigger enable and polarity selection for regular channels */ #define ADC_CFGR_EXTEN_0 (0x1UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000400 */ #define ADC_CFGR_EXTEN_1 (0x2UL << ADC_CFGR_EXTEN_Pos) /*!< 0x00000800 */ #define ADC_CFGR_OVRMOD_Pos (12U) #define ADC_CFGR_OVRMOD_Msk (0x1UL << ADC_CFGR_OVRMOD_Pos) /*!< 0x00001000 */ #define ADC_CFGR_OVRMOD ADC_CFGR_OVRMOD_Msk /*!< ADC overrun mode */ #define ADC_CFGR_CONT_Pos (13U) #define ADC_CFGR_CONT_Msk (0x1UL << ADC_CFGR_CONT_Pos) /*!< 0x00002000 */ #define ADC_CFGR_CONT ADC_CFGR_CONT_Msk /*!< ADC Single/continuous conversion mode for regular conversion */ #define ADC_CFGR_AUTDLY_Pos (14U) #define ADC_CFGR_AUTDLY_Msk (0x1UL << ADC_CFGR_AUTDLY_Pos) /*!< 0x00004000 */ #define ADC_CFGR_AUTDLY ADC_CFGR_AUTDLY_Msk /*!< ADC Delayed conversion mode */ #define ADC_CFGR_DISCEN_Pos (16U) #define ADC_CFGR_DISCEN_Msk (0x1UL << ADC_CFGR_DISCEN_Pos) /*!< 0x00010000 */ #define ADC_CFGR_DISCEN ADC_CFGR_DISCEN_Msk /*!< ADC Discontinuous mode for regular channels */ #define ADC_CFGR_DISCNUM_Pos (17U) #define ADC_CFGR_DISCNUM_Msk (0x7UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x000E0000 */ #define ADC_CFGR_DISCNUM ADC_CFGR_DISCNUM_Msk /*!< ADC Discontinuous mode channel count */ #define ADC_CFGR_DISCNUM_0 (0x1UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00020000 */ #define ADC_CFGR_DISCNUM_1 (0x2UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00040000 */ #define ADC_CFGR_DISCNUM_2 (0x4UL << ADC_CFGR_DISCNUM_Pos) /*!< 0x00080000 */ #define ADC_CFGR_JDISCEN_Pos (20U) #define ADC_CFGR_JDISCEN_Msk (0x1UL << ADC_CFGR_JDISCEN_Pos) /*!< 0x00100000 */ #define ADC_CFGR_JDISCEN ADC_CFGR_JDISCEN_Msk /*!< ADC Discontinuous mode on injected channels */ #define ADC_CFGR_JQM_Pos (21U) #define ADC_CFGR_JQM_Msk (0x1UL << ADC_CFGR_JQM_Pos) /*!< 0x00200000 */ #define ADC_CFGR_JQM ADC_CFGR_JQM_Msk /*!< ADC JSQR Queue mode */ #define ADC_CFGR_AWD1SGL_Pos (22U) #define ADC_CFGR_AWD1SGL_Msk (0x1UL << ADC_CFGR_AWD1SGL_Pos) /*!< 0x00400000 */ #define ADC_CFGR_AWD1SGL ADC_CFGR_AWD1SGL_Msk /*!< Enable the watchdog 1 on a single channel or on all channels */ #define ADC_CFGR_AWD1EN_Pos (23U) #define ADC_CFGR_AWD1EN_Msk (0x1UL << ADC_CFGR_AWD1EN_Pos) /*!< 0x00800000 */ #define ADC_CFGR_AWD1EN ADC_CFGR_AWD1EN_Msk /*!< ADC Analog watchdog 1 enable on regular Channels */ #define ADC_CFGR_JAWD1EN_Pos (24U) #define ADC_CFGR_JAWD1EN_Msk (0x1UL << ADC_CFGR_JAWD1EN_Pos) /*!< 0x01000000 */ #define ADC_CFGR_JAWD1EN ADC_CFGR_JAWD1EN_Msk /*!< ADC Analog watchdog 1 enable on injected Channels */ #define ADC_CFGR_JAUTO_Pos (25U) #define ADC_CFGR_JAUTO_Msk (0x1UL << ADC_CFGR_JAUTO_Pos) /*!< 0x02000000 */ #define ADC_CFGR_JAUTO ADC_CFGR_JAUTO_Msk /*!< ADC Automatic injected group conversion */ #define ADC_CFGR_AWD1CH_Pos (26U) #define ADC_CFGR_AWD1CH_Msk (0x1FUL << ADC_CFGR_AWD1CH_Pos) /*!< 0x7C000000 */ #define ADC_CFGR_AWD1CH ADC_CFGR_AWD1CH_Msk /*!< ADC Analog watchdog 1 Channel selection */ #define ADC_CFGR_AWD1CH_0 (0x01UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x04000000 */ #define ADC_CFGR_AWD1CH_1 (0x02UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x08000000 */ #define ADC_CFGR_AWD1CH_2 (0x04UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x10000000 */ #define ADC_CFGR_AWD1CH_3 (0x08UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x20000000 */ #define ADC_CFGR_AWD1CH_4 (0x10UL << ADC_CFGR_AWD1CH_Pos) /*!< 0x40000000 */ #define ADC_CFGR_JQDIS_Pos (31U) #define ADC_CFGR_JQDIS_Msk (0x1UL << ADC_CFGR_JQDIS_Pos) /*!< 0x80000000 */ #define ADC_CFGR_JQDIS ADC_CFGR_JQDIS_Msk /*!< ADC Injected queue disable */ #define ADC3_CFGR_DMAEN_Pos (0U) #define ADC3_CFGR_DMAEN_Msk (0x1UL << ADC3_CFGR_DMAEN_Pos) /*!< 0x00000001 */ #define ADC3_CFGR_DMAEN ADC3_CFGR_DMAEN_Msk /*!< ADC DMA transfer enable */ #define ADC3_CFGR_DMACFG_Pos (1U) #define ADC3_CFGR_DMACFG_Msk (0x1UL << ADC3_CFGR_DMACFG_Pos) /*!< 0x00000002 */ #define ADC3_CFGR_DMACFG ADC3_CFGR_DMACFG_Msk /*!< ADC DMA transfer configuration */ #define ADC3_CFGR_RES_Pos (3U) #define ADC3_CFGR_RES_Msk (0x3UL << ADC3_CFGR_RES_Pos) /*!< 0x00000018 */ #define ADC3_CFGR_RES ADC3_CFGR_RES_Msk /*!< ADC data resolution */ #define ADC3_CFGR_RES_0 (0x1UL << ADC3_CFGR_RES_Pos) /*!< 0x00000008 */ #define ADC3_CFGR_RES_1 (0x2UL << ADC3_CFGR_RES_Pos) /*!< 0x00000010 */ #define ADC3_CFGR_ALIGN_Pos (15U) #define ADC3_CFGR_ALIGN_Msk (0x1UL << ADC3_CFGR_ALIGN_Pos) /*!< 0x00008000 */ #define ADC3_CFGR_ALIGN ADC3_CFGR_ALIGN_Msk /*!< ADC data alignment */ /******************** Bit definition for ADC_CFGR2 register ********************/ #define ADC_CFGR2_ROVSE_Pos (0U) #define ADC_CFGR2_ROVSE_Msk (0x1UL << ADC_CFGR2_ROVSE_Pos) /*!< 0x00000001 */ #define ADC_CFGR2_ROVSE ADC_CFGR2_ROVSE_Msk /*!< ADC Regular group oversampler enable */ #define ADC_CFGR2_JOVSE_Pos (1U) #define ADC_CFGR2_JOVSE_Msk (0x1UL << ADC_CFGR2_JOVSE_Pos) /*!< 0x00000002 */ #define ADC_CFGR2_JOVSE ADC_CFGR2_JOVSE_Msk /*!< ADC Injected group oversampler enable */ #define ADC_CFGR2_OVSS_Pos (5U) #define ADC_CFGR2_OVSS_Msk (0xFUL << ADC_CFGR2_OVSS_Pos) /*!< 0x000001E0 */ #define ADC_CFGR2_OVSS ADC_CFGR2_OVSS_Msk /*!< ADC Regular Oversampling shift */ #define ADC_CFGR2_OVSS_0 (0x1UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000020 */ #define ADC_CFGR2_OVSS_1 (0x2UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000040 */ #define ADC_CFGR2_OVSS_2 (0x4UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000080 */ #define ADC_CFGR2_OVSS_3 (0x8UL << ADC_CFGR2_OVSS_Pos) /*!< 0x00000100 */ #define ADC_CFGR2_TROVS_Pos (9U) #define ADC_CFGR2_TROVS_Msk (0x1UL << ADC_CFGR2_TROVS_Pos) /*!< 0x00000200 */ #define ADC_CFGR2_TROVS ADC_CFGR2_TROVS_Msk /*!< ADC Triggered regular Oversampling */ #define ADC_CFGR2_ROVSM_Pos (10U) #define ADC_CFGR2_ROVSM_Msk (0x1UL << ADC_CFGR2_ROVSM_Pos) /*!< 0x00000400 */ #define ADC_CFGR2_ROVSM ADC_CFGR2_ROVSM_Msk /*!< ADC Regular oversampling mode */ #define ADC_CFGR2_RSHIFT1_Pos (11U) #define ADC_CFGR2_RSHIFT1_Msk (0x1UL << ADC_CFGR2_RSHIFT1_Pos) /*!< 0x00000800 */ #define ADC_CFGR2_RSHIFT1 ADC_CFGR2_RSHIFT1_Msk /*!< ADC Right-shift data after Offset 1 correction */ #define ADC_CFGR2_RSHIFT2_Pos (12U) #define ADC_CFGR2_RSHIFT2_Msk (0x1UL << ADC_CFGR2_RSHIFT2_Pos) /*!< 0x00001000 */ #define ADC_CFGR2_RSHIFT2 ADC_CFGR2_RSHIFT2_Msk /*!< ADC Right-shift data after Offset 2 correction */ #define ADC_CFGR2_RSHIFT3_Pos (13U) #define ADC_CFGR2_RSHIFT3_Msk (0x1UL << ADC_CFGR2_RSHIFT3_Pos) /*!< 0x00002000 */ #define ADC_CFGR2_RSHIFT3 ADC_CFGR2_RSHIFT3_Msk /*!< ADC Right-shift data after Offset 3 correction */ #define ADC_CFGR2_RSHIFT4_Pos (14U) #define ADC_CFGR2_RSHIFT4_Msk (0x1UL << ADC_CFGR2_RSHIFT4_Pos) /*!< 0x00004000 */ #define ADC_CFGR2_RSHIFT4 ADC_CFGR2_RSHIFT4_Msk /*!< ADC Right-shift data after Offset 4 correction */ #define ADC_CFGR2_OVSR_Pos (16U) #define ADC_CFGR2_OVSR_Msk (0x3FFUL << ADC_CFGR2_OVSR_Pos) /*!< 0x03FF0000 */ #define ADC_CFGR2_OVSR ADC_CFGR2_OVSR_Msk /*!< ADC oversampling Ratio */ #define ADC_CFGR2_OVSR_0 (0x001UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00010000 */ #define ADC_CFGR2_OVSR_1 (0x002UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00020000 */ #define ADC_CFGR2_OVSR_2 (0x004UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00040000 */ #define ADC_CFGR2_OVSR_3 (0x008UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00080000 */ #define ADC_CFGR2_OVSR_4 (0x010UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00100000 */ #define ADC_CFGR2_OVSR_5 (0x020UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00200000 */ #define ADC_CFGR2_OVSR_6 (0x040UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00400000 */ #define ADC_CFGR2_OVSR_7 (0x080UL << ADC_CFGR2_OVSR_Pos) /*!< 0x00800000 */ #define ADC_CFGR2_OVSR_8 (0x100UL << ADC_CFGR2_OVSR_Pos) /*!< 0x01000000 */ #define ADC_CFGR2_OVSR_9 (0x200UL << ADC_CFGR2_OVSR_Pos) /*!< 0x02000000 */ #define ADC_CFGR2_LSHIFT_Pos (28U) #define ADC_CFGR2_LSHIFT_Msk (0xFUL << ADC_CFGR2_LSHIFT_Pos) /*!< 0xF0000000 */ #define ADC_CFGR2_LSHIFT ADC_CFGR2_LSHIFT_Msk /*!< ADC Left shift factor */ #define ADC_CFGR2_LSHIFT_0 (0x1UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x10000000 */ #define ADC_CFGR2_LSHIFT_1 (0x2UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x20000000 */ #define ADC_CFGR2_LSHIFT_2 (0x4UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x40000000 */ #define ADC_CFGR2_LSHIFT_3 (0x8UL << ADC_CFGR2_LSHIFT_Pos) /*!< 0x80000000 */ #define ADC3_CFGR2_OVSR_Pos (2U) #define ADC3_CFGR2_OVSR_Msk (0x7UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x0000001C */ #define ADC3_CFGR2_OVSR ADC3_CFGR2_OVSR_Msk /*!< ADC oversampling ratio */ #define ADC3_CFGR2_OVSR_0 (0x1UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000004 */ #define ADC3_CFGR2_OVSR_1 (0x2UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000008 */ #define ADC3_CFGR2_OVSR_2 (0x4UL << ADC3_CFGR2_OVSR_Pos) /*!< 0x00000010 */ #define ADC3_CFGR2_SWTRIG_Pos (25U) #define ADC3_CFGR2_SWTRIG_Msk (0x1UL << ADC3_CFGR2_SWTRIG_Pos) /*!< 0x02000000 */ #define ADC3_CFGR2_SWTRIG ADC3_CFGR2_SWTRIG_Msk /*!< ADC Software Trigger Bit for Sample time control trigger mode */ #define ADC3_CFGR2_BULB_Pos (26U) #define ADC3_CFGR2_BULB_Msk (0x1UL << ADC3_CFGR2_BULB_Pos) /*!< 0x04000000 */ #define ADC3_CFGR2_BULB ADC3_CFGR2_BULB_Msk /*!< ADC Bulb sampling mode */ #define ADC3_CFGR2_SMPTRIG_Pos (27U) #define ADC3_CFGR2_SMPTRIG_Msk (0x1UL << ADC3_CFGR2_SMPTRIG_Pos) /*!< 0x08000000 */ #define ADC3_CFGR2_SMPTRIG ADC3_CFGR2_SMPTRIG_Msk /*!< ADC Sample Time Control Trigger mode */ /******************** Bit definition for ADC_SMPR1 register ********************/ #define ADC_SMPR1_SMP0_Pos (0U) #define ADC_SMPR1_SMP0_Msk (0x7UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000007 */ #define ADC_SMPR1_SMP0 ADC_SMPR1_SMP0_Msk /*!< ADC Channel 0 Sampling time selection */ #define ADC_SMPR1_SMP0_0 (0x1UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000001 */ #define ADC_SMPR1_SMP0_1 (0x2UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000002 */ #define ADC_SMPR1_SMP0_2 (0x4UL << ADC_SMPR1_SMP0_Pos) /*!< 0x00000004 */ #define ADC_SMPR1_SMP1_Pos (3U) #define ADC_SMPR1_SMP1_Msk (0x7UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000038 */ #define ADC_SMPR1_SMP1 ADC_SMPR1_SMP1_Msk /*!< ADC Channel 1 Sampling time selection */ #define ADC_SMPR1_SMP1_0 (0x1UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000008 */ #define ADC_SMPR1_SMP1_1 (0x2UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000010 */ #define ADC_SMPR1_SMP1_2 (0x4UL << ADC_SMPR1_SMP1_Pos) /*!< 0x00000020 */ #define ADC_SMPR1_SMP2_Pos (6U) #define ADC_SMPR1_SMP2_Msk (0x7UL << ADC_SMPR1_SMP2_Pos) /*!< 0x000001C0 */ #define ADC_SMPR1_SMP2 ADC_SMPR1_SMP2_Msk /*!< ADC Channel 2 Sampling time selection */ #define ADC_SMPR1_SMP2_0 (0x1UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000040 */ #define ADC_SMPR1_SMP2_1 (0x2UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000080 */ #define ADC_SMPR1_SMP2_2 (0x4UL << ADC_SMPR1_SMP2_Pos) /*!< 0x00000100 */ #define ADC_SMPR1_SMP3_Pos (9U) #define ADC_SMPR1_SMP3_Msk (0x7UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000E00 */ #define ADC_SMPR1_SMP3 ADC_SMPR1_SMP3_Msk /*!< ADC Channel 3 Sampling time selection */ #define ADC_SMPR1_SMP3_0 (0x1UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000200 */ #define ADC_SMPR1_SMP3_1 (0x2UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000400 */ #define ADC_SMPR1_SMP3_2 (0x4UL << ADC_SMPR1_SMP3_Pos) /*!< 0x00000800 */ #define ADC_SMPR1_SMP4_Pos (12U) #define ADC_SMPR1_SMP4_Msk (0x7UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00007000 */ #define ADC_SMPR1_SMP4 ADC_SMPR1_SMP4_Msk /*!< ADC Channel 4 Sampling time selection */ #define ADC_SMPR1_SMP4_0 (0x1UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00001000 */ #define ADC_SMPR1_SMP4_1 (0x2UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00002000 */ #define ADC_SMPR1_SMP4_2 (0x4UL << ADC_SMPR1_SMP4_Pos) /*!< 0x00004000 */ #define ADC_SMPR1_SMP5_Pos (15U) #define ADC_SMPR1_SMP5_Msk (0x7UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00038000 */ #define ADC_SMPR1_SMP5 ADC_SMPR1_SMP5_Msk /*!< ADC Channel 5 Sampling time selection */ #define ADC_SMPR1_SMP5_0 (0x1UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00008000 */ #define ADC_SMPR1_SMP5_1 (0x2UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00010000 */ #define ADC_SMPR1_SMP5_2 (0x4UL << ADC_SMPR1_SMP5_Pos) /*!< 0x00020000 */ #define ADC_SMPR1_SMP6_Pos (18U) #define ADC_SMPR1_SMP6_Msk (0x7UL << ADC_SMPR1_SMP6_Pos) /*!< 0x001C0000 */ #define ADC_SMPR1_SMP6 ADC_SMPR1_SMP6_Msk /*!< ADC Channel 6 Sampling time selection */ #define ADC_SMPR1_SMP6_0 (0x1UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00040000 */ #define ADC_SMPR1_SMP6_1 (0x2UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00080000 */ #define ADC_SMPR1_SMP6_2 (0x4UL << ADC_SMPR1_SMP6_Pos) /*!< 0x00100000 */ #define ADC_SMPR1_SMP7_Pos (21U) #define ADC_SMPR1_SMP7_Msk (0x7UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00E00000 */ #define ADC_SMPR1_SMP7 ADC_SMPR1_SMP7_Msk /*!< ADC Channel 7 Sampling time selection */ #define ADC_SMPR1_SMP7_0 (0x1UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00200000 */ #define ADC_SMPR1_SMP7_1 (0x2UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00400000 */ #define ADC_SMPR1_SMP7_2 (0x4UL << ADC_SMPR1_SMP7_Pos) /*!< 0x00800000 */ #define ADC_SMPR1_SMP8_Pos (24U) #define ADC_SMPR1_SMP8_Msk (0x7UL << ADC_SMPR1_SMP8_Pos) /*!< 0x07000000 */ #define ADC_SMPR1_SMP8 ADC_SMPR1_SMP8_Msk /*!< ADC Channel 8 Sampling time selection */ #define ADC_SMPR1_SMP8_0 (0x1UL << ADC_SMPR1_SMP8_Pos) /*!< 0x01000000 */ #define ADC_SMPR1_SMP8_1 (0x2UL << ADC_SMPR1_SMP8_Pos) /*!< 0x02000000 */ #define ADC_SMPR1_SMP8_2 (0x4UL << ADC_SMPR1_SMP8_Pos) /*!< 0x04000000 */ #define ADC_SMPR1_SMP9_Pos (27U) #define ADC_SMPR1_SMP9_Msk (0x7UL << ADC_SMPR1_SMP9_Pos) /*!< 0x38000000 */ #define ADC_SMPR1_SMP9 ADC_SMPR1_SMP9_Msk /*!< ADC Channel 9 Sampling time selection */ #define ADC_SMPR1_SMP9_0 (0x1UL << ADC_SMPR1_SMP9_Pos) /*!< 0x08000000 */ #define ADC_SMPR1_SMP9_1 (0x2UL << ADC_SMPR1_SMP9_Pos) /*!< 0x10000000 */ #define ADC_SMPR1_SMP9_2 (0x4UL << ADC_SMPR1_SMP9_Pos) /*!< 0x20000000 */ /******************** Bit definition for ADC_SMPR2 register ********************/ #define ADC_SMPR2_SMP10_Pos (0U) #define ADC_SMPR2_SMP10_Msk (0x7UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000007 */ #define ADC_SMPR2_SMP10 ADC_SMPR2_SMP10_Msk /*!< ADC Channel 10 Sampling time selection */ #define ADC_SMPR2_SMP10_0 (0x1UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000001 */ #define ADC_SMPR2_SMP10_1 (0x2UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000002 */ #define ADC_SMPR2_SMP10_2 (0x4UL << ADC_SMPR2_SMP10_Pos) /*!< 0x00000004 */ #define ADC_SMPR2_SMP11_Pos (3U) #define ADC_SMPR2_SMP11_Msk (0x7UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000038 */ #define ADC_SMPR2_SMP11 ADC_SMPR2_SMP11_Msk /*!< ADC Channel 11 Sampling time selection */ #define ADC_SMPR2_SMP11_0 (0x1UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000008 */ #define ADC_SMPR2_SMP11_1 (0x2UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000010 */ #define ADC_SMPR2_SMP11_2 (0x4UL << ADC_SMPR2_SMP11_Pos) /*!< 0x00000020 */ #define ADC_SMPR2_SMP12_Pos (6U) #define ADC_SMPR2_SMP12_Msk (0x7UL << ADC_SMPR2_SMP12_Pos) /*!< 0x000001C0 */ #define ADC_SMPR2_SMP12 ADC_SMPR2_SMP12_Msk /*!< ADC Channel 12 Sampling time selection */ #define ADC_SMPR2_SMP12_0 (0x1UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000040 */ #define ADC_SMPR2_SMP12_1 (0x2UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000080 */ #define ADC_SMPR2_SMP12_2 (0x4UL << ADC_SMPR2_SMP12_Pos) /*!< 0x00000100 */ #define ADC_SMPR2_SMP13_Pos (9U) #define ADC_SMPR2_SMP13_Msk (0x7UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000E00 */ #define ADC_SMPR2_SMP13 ADC_SMPR2_SMP13_Msk /*!< ADC Channel 13 Sampling time selection */ #define ADC_SMPR2_SMP13_0 (0x1UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000200 */ #define ADC_SMPR2_SMP13_1 (0x2UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000400 */ #define ADC_SMPR2_SMP13_2 (0x4UL << ADC_SMPR2_SMP13_Pos) /*!< 0x00000800 */ #define ADC_SMPR2_SMP14_Pos (12U) #define ADC_SMPR2_SMP14_Msk (0x7UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00007000 */ #define ADC_SMPR2_SMP14 ADC_SMPR2_SMP14_Msk /*!< ADC Channel 14 Sampling time selection */ #define ADC_SMPR2_SMP14_0 (0x1UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00001000 */ #define ADC_SMPR2_SMP14_1 (0x2UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00002000 */ #define ADC_SMPR2_SMP14_2 (0x4UL << ADC_SMPR2_SMP14_Pos) /*!< 0x00004000 */ #define ADC_SMPR2_SMP15_Pos (15U) #define ADC_SMPR2_SMP15_Msk (0x7UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00038000 */ #define ADC_SMPR2_SMP15 ADC_SMPR2_SMP15_Msk /*!< ADC Channel 15 Sampling time selection */ #define ADC_SMPR2_SMP15_0 (0x1UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00008000 */ #define ADC_SMPR2_SMP15_1 (0x2UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00010000 */ #define ADC_SMPR2_SMP15_2 (0x4UL << ADC_SMPR2_SMP15_Pos) /*!< 0x00020000 */ #define ADC_SMPR2_SMP16_Pos (18U) #define ADC_SMPR2_SMP16_Msk (0x7UL << ADC_SMPR2_SMP16_Pos) /*!< 0x001C0000 */ #define ADC_SMPR2_SMP16 ADC_SMPR2_SMP16_Msk /*!< ADC Channel 16 Sampling time selection */ #define ADC_SMPR2_SMP16_0 (0x1UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00040000 */ #define ADC_SMPR2_SMP16_1 (0x2UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00080000 */ #define ADC_SMPR2_SMP16_2 (0x4UL << ADC_SMPR2_SMP16_Pos) /*!< 0x00100000 */ #define ADC_SMPR2_SMP17_Pos (21U) #define ADC_SMPR2_SMP17_Msk (0x7UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00E00000 */ #define ADC_SMPR2_SMP17 ADC_SMPR2_SMP17_Msk /*!< ADC Channel 17 Sampling time selection */ #define ADC_SMPR2_SMP17_0 (0x1UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00200000 */ #define ADC_SMPR2_SMP17_1 (0x2UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00400000 */ #define ADC_SMPR2_SMP17_2 (0x4UL << ADC_SMPR2_SMP17_Pos) /*!< 0x00800000 */ #define ADC_SMPR2_SMP18_Pos (24U) #define ADC_SMPR2_SMP18_Msk (0x7UL << ADC_SMPR2_SMP18_Pos) /*!< 0x07000000 */ #define ADC_SMPR2_SMP18 ADC_SMPR2_SMP18_Msk /*!< ADC Channel 18 Sampling time selection */ #define ADC_SMPR2_SMP18_0 (0x1UL << ADC_SMPR2_SMP18_Pos) /*!< 0x01000000 */ #define ADC_SMPR2_SMP18_1 (0x2UL << ADC_SMPR2_SMP18_Pos) /*!< 0x02000000 */ #define ADC_SMPR2_SMP18_2 (0x4UL << ADC_SMPR2_SMP18_Pos) /*!< 0x04000000 */ #define ADC_SMPR2_SMP19_Pos (27U) #define ADC_SMPR2_SMP19_Msk (0x7UL << ADC_SMPR2_SMP19_Pos) /*!< 0x38000000 */ #define ADC_SMPR2_SMP19 ADC_SMPR2_SMP19_Msk /*!< ADC Channel 19 Sampling time selection */ #define ADC_SMPR2_SMP19_0 (0x1UL << ADC_SMPR2_SMP19_Pos) /*!< 0x08000000 */ #define ADC_SMPR2_SMP19_1 (0x2UL << ADC_SMPR2_SMP19_Pos) /*!< 0x10000000 */ #define ADC_SMPR2_SMP19_2 (0x4UL << ADC_SMPR2_SMP19_Pos) /*!< 0x20000000 */ /******************** Bit definition for ADC_PCSEL register ********************/ #define ADC_PCSEL_PCSEL_Pos (0U) #define ADC_PCSEL_PCSEL_Msk (0xFFFFFUL << ADC_PCSEL_PCSEL_Pos) /*!< 0x000FFFFF */ #define ADC_PCSEL_PCSEL ADC_PCSEL_PCSEL_Msk /*!< ADC pre channel selection */ #define ADC_PCSEL_PCSEL_0 (0x00001UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000001 */ #define ADC_PCSEL_PCSEL_1 (0x00002UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000002 */ #define ADC_PCSEL_PCSEL_2 (0x00004UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000004 */ #define ADC_PCSEL_PCSEL_3 (0x00008UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000008 */ #define ADC_PCSEL_PCSEL_4 (0x00010UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000010 */ #define ADC_PCSEL_PCSEL_5 (0x00020UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000020 */ #define ADC_PCSEL_PCSEL_6 (0x00040UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000040 */ #define ADC_PCSEL_PCSEL_7 (0x00080UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000080 */ #define ADC_PCSEL_PCSEL_8 (0x00100UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000100 */ #define ADC_PCSEL_PCSEL_9 (0x00200UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000200 */ #define ADC_PCSEL_PCSEL_10 (0x00400UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000400 */ #define ADC_PCSEL_PCSEL_11 (0x00800UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00000800 */ #define ADC_PCSEL_PCSEL_12 (0x01000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00001000 */ #define ADC_PCSEL_PCSEL_13 (0x02000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00002000 */ #define ADC_PCSEL_PCSEL_14 (0x04000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00004000 */ #define ADC_PCSEL_PCSEL_15 (0x08000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00008000 */ #define ADC_PCSEL_PCSEL_16 (0x10000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00010000 */ #define ADC_PCSEL_PCSEL_17 (0x20000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00020000 */ #define ADC_PCSEL_PCSEL_18 (0x40000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00040000 */ #define ADC_PCSEL_PCSEL_19 (0x80000UL << ADC_PCSEL_PCSEL_Pos) /*!< 0x00080000 */ /***************** Bit definition for ADC_LTR1, 2, 3 registers *****************/ #define ADC_LTR_LT_Pos (0U) #define ADC_LTR_LT_Msk (0x3FFFFFFUL << ADC_LTR_LT_Pos) /*!< 0x03FFFFFF */ #define ADC_LTR_LT ADC_LTR_LT_Msk /*!< ADC Analog watchdog 1, 2 and 3 lower threshold */ /***************** Bit definition for ADC_HTR1, 2, 3 registers ****************/ #define ADC_HTR_HT_Pos (0U) #define ADC_HTR_HT_Msk (0x3FFFFFFUL << ADC_HTR_HT_Pos) /*!< 0x03FFFFFF */ #define ADC_HTR_HT ADC_HTR_HT_Msk /*!< ADC Analog watchdog 1,2 and 3 higher threshold */ /******************** Bit definition for ADC3_TR1 register *******************/ #define ADC3_TR1_LT1_Pos (0U) #define ADC3_TR1_LT1_Msk (0xFFFUL << ADC3_TR1_LT1_Pos) /*!< 0x00000FFF */ #define ADC3_TR1_LT1 ADC3_TR1_LT1_Msk /*!< ADC analog watchdog 1 threshold low */ #define ADC3_TR1_AWDFILT_Pos (12U) #define ADC3_TR1_AWDFILT_Msk (0x7UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00007000 */ #define ADC3_TR1_AWDFILT ADC3_TR1_AWDFILT_Msk /*!< ADC analog watchdog filtering parameter */ #define ADC3_TR1_AWDFILT_0 (0x1UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00001000 */ #define ADC3_TR1_AWDFILT_1 (0x2UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00002000 */ #define ADC3_TR1_AWDFILT_2 (0x4UL << ADC3_TR1_AWDFILT_Pos) /*!< 0x00004000 */ #define ADC3_TR1_HT1_Pos (16U) #define ADC3_TR1_HT1_Msk (0xFFFUL << ADC3_TR1_HT1_Pos) /*!< 0x0FFF0000 */ #define ADC3_TR1_HT1 ADC3_TR1_HT1_Msk /*!< ADC analog watchdog 1 threshold high */ /******************** Bit definition for ADC3_TR2 register *******************/ #define ADC3_TR2_LT2_Pos (0U) #define ADC3_TR2_LT2_Msk (0xFFUL << ADC3_TR2_LT2_Pos) /*!< 0x000000FF */ #define ADC3_TR2_LT2 ADC3_TR2_LT2_Msk /*!< ADC analog watchdog 2 threshold low */ #define ADC3_TR2_HT2_Pos (16U) #define ADC3_TR2_HT2_Msk (0xFFUL << ADC3_TR2_HT2_Pos) /*!< 0x00FF0000 */ #define ADC3_TR2_HT2 ADC3_TR2_HT2_Msk /*!< ADC analog watchdog 2 threshold high */ /******************** Bit definition for ADC3_TR3 register *******************/ #define ADC3_TR3_LT3_Pos (0U) #define ADC3_TR3_LT3_Msk (0xFFUL << ADC3_TR3_LT3_Pos) /*!< 0x000000FF */ #define ADC3_TR3_LT3 ADC3_TR3_LT3_Msk /*!< ADC analog watchdog 3 threshold low */ #define ADC3_TR3_HT3_Pos (16U) #define ADC3_TR3_HT3_Msk (0xFFUL << ADC3_TR3_HT3_Pos) /*!< 0x00FF0000 */ #define ADC3_TR3_HT3 ADC3_TR3_HT3_Msk /*!< ADC analog watchdog 3 threshold high */ /******************** Bit definition for ADC_SQR1 register ********************/ #define ADC_SQR1_L_Pos (0U) #define ADC_SQR1_L_Msk (0xFUL << ADC_SQR1_L_Pos) /*!< 0x0000000F */ #define ADC_SQR1_L ADC_SQR1_L_Msk /*!< ADC regular channel sequence length */ #define ADC_SQR1_L_0 (0x1UL << ADC_SQR1_L_Pos) /*!< 0x00000001 */ #define ADC_SQR1_L_1 (0x2UL << ADC_SQR1_L_Pos) /*!< 0x00000002 */ #define ADC_SQR1_L_2 (0x4UL << ADC_SQR1_L_Pos) /*!< 0x00000004 */ #define ADC_SQR1_L_3 (0x8UL << ADC_SQR1_L_Pos) /*!< 0x00000008 */ #define ADC_SQR1_SQ1_Pos (6U) #define ADC_SQR1_SQ1_Msk (0x1FUL << ADC_SQR1_SQ1_Pos) /*!< 0x000007C0 */ #define ADC_SQR1_SQ1 ADC_SQR1_SQ1_Msk /*!< ADC 1st conversion in regular sequence */ #define ADC_SQR1_SQ1_0 (0x01UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000040 */ #define ADC_SQR1_SQ1_1 (0x02UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000080 */ #define ADC_SQR1_SQ1_2 (0x04UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000100 */ #define ADC_SQR1_SQ1_3 (0x08UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000200 */ #define ADC_SQR1_SQ1_4 (0x10UL << ADC_SQR1_SQ1_Pos) /*!< 0x00000400 */ #define ADC_SQR1_SQ2_Pos (12U) #define ADC_SQR1_SQ2_Msk (0x1FUL << ADC_SQR1_SQ2_Pos) /*!< 0x0001F000 */ #define ADC_SQR1_SQ2 ADC_SQR1_SQ2_Msk /*!< ADC 2nd conversion in regular sequence */ #define ADC_SQR1_SQ2_0 (0x01UL << ADC_SQR1_SQ2_Pos) /*!< 0x00001000 */ #define ADC_SQR1_SQ2_1 (0x02UL << ADC_SQR1_SQ2_Pos) /*!< 0x00002000 */ #define ADC_SQR1_SQ2_2 (0x04UL << ADC_SQR1_SQ2_Pos) /*!< 0x00004000 */ #define ADC_SQR1_SQ2_3 (0x08UL << ADC_SQR1_SQ2_Pos) /*!< 0x00008000 */ #define ADC_SQR1_SQ2_4 (0x10UL << ADC_SQR1_SQ2_Pos) /*!< 0x00010000 */ #define ADC_SQR1_SQ3_Pos (18U) #define ADC_SQR1_SQ3_Msk (0x1FUL << ADC_SQR1_SQ3_Pos) /*!< 0x007C0000 */ #define ADC_SQR1_SQ3 ADC_SQR1_SQ3_Msk /*!< ADC 3rd conversion in regular sequence */ #define ADC_SQR1_SQ3_0 (0x01UL << ADC_SQR1_SQ3_Pos) /*!< 0x00040000 */ #define ADC_SQR1_SQ3_1 (0x02UL << ADC_SQR1_SQ3_Pos) /*!< 0x00080000 */ #define ADC_SQR1_SQ3_2 (0x04UL << ADC_SQR1_SQ3_Pos) /*!< 0x00100000 */ #define ADC_SQR1_SQ3_3 (0x08UL << ADC_SQR1_SQ3_Pos) /*!< 0x00200000 */ #define ADC_SQR1_SQ3_4 (0x10UL << ADC_SQR1_SQ3_Pos) /*!< 0x00400000 */ #define ADC_SQR1_SQ4_Pos (24U) #define ADC_SQR1_SQ4_Msk (0x1FUL << ADC_SQR1_SQ4_Pos) /*!< 0x1F000000 */ #define ADC_SQR1_SQ4 ADC_SQR1_SQ4_Msk /*!< ADC 4th conversion in regular sequence */ #define ADC_SQR1_SQ4_0 (0x01UL << ADC_SQR1_SQ4_Pos) /*!< 0x01000000 */ #define ADC_SQR1_SQ4_1 (0x02UL << ADC_SQR1_SQ4_Pos) /*!< 0x02000000 */ #define ADC_SQR1_SQ4_2 (0x04UL << ADC_SQR1_SQ4_Pos) /*!< 0x04000000 */ #define ADC_SQR1_SQ4_3 (0x08UL << ADC_SQR1_SQ4_Pos) /*!< 0x08000000 */ #define ADC_SQR1_SQ4_4 (0x10UL << ADC_SQR1_SQ4_Pos) /*!< 0x10000000 */ /******************** Bit definition for ADC_SQR2 register ********************/ #define ADC_SQR2_SQ5_Pos (0U) #define ADC_SQR2_SQ5_Msk (0x1FUL << ADC_SQR2_SQ5_Pos) /*!< 0x0000001F */ #define ADC_SQR2_SQ5 ADC_SQR2_SQ5_Msk /*!< ADC 5th conversion in regular sequence */ #define ADC_SQR2_SQ5_0 (0x01UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000001 */ #define ADC_SQR2_SQ5_1 (0x02UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000002 */ #define ADC_SQR2_SQ5_2 (0x04UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000004 */ #define ADC_SQR2_SQ5_3 (0x08UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000008 */ #define ADC_SQR2_SQ5_4 (0x10UL << ADC_SQR2_SQ5_Pos) /*!< 0x00000010 */ #define ADC_SQR2_SQ6_Pos (6U) #define ADC_SQR2_SQ6_Msk (0x1FUL << ADC_SQR2_SQ6_Pos) /*!< 0x000007C0 */ #define ADC_SQR2_SQ6 ADC_SQR2_SQ6_Msk /*!< ADC 6th conversion in regular sequence */ #define ADC_SQR2_SQ6_0 (0x01UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000040 */ #define ADC_SQR2_SQ6_1 (0x02UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000080 */ #define ADC_SQR2_SQ6_2 (0x04UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000100 */ #define ADC_SQR2_SQ6_3 (0x08UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000200 */ #define ADC_SQR2_SQ6_4 (0x10UL << ADC_SQR2_SQ6_Pos) /*!< 0x00000400 */ #define ADC_SQR2_SQ7_Pos (12U) #define ADC_SQR2_SQ7_Msk (0x1FUL << ADC_SQR2_SQ7_Pos) /*!< 0x0001F000 */ #define ADC_SQR2_SQ7 ADC_SQR2_SQ7_Msk /*!< ADC 7th conversion in regular sequence */ #define ADC_SQR2_SQ7_0 (0x01UL << ADC_SQR2_SQ7_Pos) /*!< 0x00001000 */ #define ADC_SQR2_SQ7_1 (0x02UL << ADC_SQR2_SQ7_Pos) /*!< 0x00002000 */ #define ADC_SQR2_SQ7_2 (0x04UL << ADC_SQR2_SQ7_Pos) /*!< 0x00004000 */ #define ADC_SQR2_SQ7_3 (0x08UL << ADC_SQR2_SQ7_Pos) /*!< 0x00008000 */ #define ADC_SQR2_SQ7_4 (0x10UL << ADC_SQR2_SQ7_Pos) /*!< 0x00010000 */ #define ADC_SQR2_SQ8_Pos (18U) #define ADC_SQR2_SQ8_Msk (0x1FUL << ADC_SQR2_SQ8_Pos) /*!< 0x007C0000 */ #define ADC_SQR2_SQ8 ADC_SQR2_SQ8_Msk /*!< ADC 8th conversion in regular sequence */ #define ADC_SQR2_SQ8_0 (0x01UL << ADC_SQR2_SQ8_Pos) /*!< 0x00040000 */ #define ADC_SQR2_SQ8_1 (0x02UL << ADC_SQR2_SQ8_Pos) /*!< 0x00080000 */ #define ADC_SQR2_SQ8_2 (0x04UL << ADC_SQR2_SQ8_Pos) /*!< 0x00100000 */ #define ADC_SQR2_SQ8_3 (0x08UL << ADC_SQR2_SQ8_Pos) /*!< 0x00200000 */ #define ADC_SQR2_SQ8_4 (0x10UL << ADC_SQR2_SQ8_Pos) /*!< 0x00400000 */ #define ADC_SQR2_SQ9_Pos (24U) #define ADC_SQR2_SQ9_Msk (0x1FUL << ADC_SQR2_SQ9_Pos) /*!< 0x1F000000 */ #define ADC_SQR2_SQ9 ADC_SQR2_SQ9_Msk /*!< ADC 9th conversion in regular sequence */ #define ADC_SQR2_SQ9_0 (0x01UL << ADC_SQR2_SQ9_Pos) /*!< 0x01000000 */ #define ADC_SQR2_SQ9_1 (0x02UL << ADC_SQR2_SQ9_Pos) /*!< 0x02000000 */ #define ADC_SQR2_SQ9_2 (0x04UL << ADC_SQR2_SQ9_Pos) /*!< 0x04000000 */ #define ADC_SQR2_SQ9_3 (0x08UL << ADC_SQR2_SQ9_Pos) /*!< 0x08000000 */ #define ADC_SQR2_SQ9_4 (0x10UL << ADC_SQR2_SQ9_Pos) /*!< 0x10000000 */ /******************** Bit definition for ADC_SQR3 register ********************/ #define ADC_SQR3_SQ10_Pos (0U) #define ADC_SQR3_SQ10_Msk (0x1FUL << ADC_SQR3_SQ10_Pos) /*!< 0x0000001F */ #define ADC_SQR3_SQ10 ADC_SQR3_SQ10_Msk /*!< ADC 10th conversion in regular sequence */ #define ADC_SQR3_SQ10_0 (0x01UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000001 */ #define ADC_SQR3_SQ10_1 (0x02UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000002 */ #define ADC_SQR3_SQ10_2 (0x04UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000004 */ #define ADC_SQR3_SQ10_3 (0x08UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000008 */ #define ADC_SQR3_SQ10_4 (0x10UL << ADC_SQR3_SQ10_Pos) /*!< 0x00000010 */ #define ADC_SQR3_SQ11_Pos (6U) #define ADC_SQR3_SQ11_Msk (0x1FUL << ADC_SQR3_SQ11_Pos) /*!< 0x000007C0 */ #define ADC_SQR3_SQ11 ADC_SQR3_SQ11_Msk /*!< ADC 11th conversion in regular sequence */ #define ADC_SQR3_SQ11_0 (0x01UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000040 */ #define ADC_SQR3_SQ11_1 (0x02UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000080 */ #define ADC_SQR3_SQ11_2 (0x04UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000100 */ #define ADC_SQR3_SQ11_3 (0x08UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000200 */ #define ADC_SQR3_SQ11_4 (0x10UL << ADC_SQR3_SQ11_Pos) /*!< 0x00000400 */ #define ADC_SQR3_SQ12_Pos (12U) #define ADC_SQR3_SQ12_Msk (0x1FUL << ADC_SQR3_SQ12_Pos) /*!< 0x0001F000 */ #define ADC_SQR3_SQ12 ADC_SQR3_SQ12_Msk /*!< ADC 12th conversion in regular sequence */ #define ADC_SQR3_SQ12_0 (0x01UL << ADC_SQR3_SQ12_Pos) /*!< 0x00001000 */ #define ADC_SQR3_SQ12_1 (0x02UL << ADC_SQR3_SQ12_Pos) /*!< 0x00002000 */ #define ADC_SQR3_SQ12_2 (0x04UL << ADC_SQR3_SQ12_Pos) /*!< 0x00004000 */ #define ADC_SQR3_SQ12_3 (0x08UL << ADC_SQR3_SQ12_Pos) /*!< 0x00008000 */ #define ADC_SQR3_SQ12_4 (0x10UL << ADC_SQR3_SQ12_Pos) /*!< 0x00010000 */ #define ADC_SQR3_SQ13_Pos (18U) #define ADC_SQR3_SQ13_Msk (0x1FUL << ADC_SQR3_SQ13_Pos) /*!< 0x007C0000 */ #define ADC_SQR3_SQ13 ADC_SQR3_SQ13_Msk /*!< ADC 13th conversion in regular sequence */ #define ADC_SQR3_SQ13_0 (0x01UL << ADC_SQR3_SQ13_Pos) /*!< 0x00040000 */ #define ADC_SQR3_SQ13_1 (0x02UL << ADC_SQR3_SQ13_Pos) /*!< 0x00080000 */ #define ADC_SQR3_SQ13_2 (0x04UL << ADC_SQR3_SQ13_Pos) /*!< 0x00100000 */ #define ADC_SQR3_SQ13_3 (0x08UL << ADC_SQR3_SQ13_Pos) /*!< 0x00200000 */ #define ADC_SQR3_SQ13_4 (0x10UL << ADC_SQR3_SQ13_Pos) /*!< 0x00400000 */ #define ADC_SQR3_SQ14_Pos (24U) #define ADC_SQR3_SQ14_Msk (0x1FUL << ADC_SQR3_SQ14_Pos) /*!< 0x1F000000 */ #define ADC_SQR3_SQ14 ADC_SQR3_SQ14_Msk /*!< ADC 14th conversion in regular sequence */ #define ADC_SQR3_SQ14_0 (0x01UL << ADC_SQR3_SQ14_Pos) /*!< 0x01000000 */ #define ADC_SQR3_SQ14_1 (0x02UL << ADC_SQR3_SQ14_Pos) /*!< 0x02000000 */ #define ADC_SQR3_SQ14_2 (0x04UL << ADC_SQR3_SQ14_Pos) /*!< 0x04000000 */ #define ADC_SQR3_SQ14_3 (0x08UL << ADC_SQR3_SQ14_Pos) /*!< 0x08000000 */ #define ADC_SQR3_SQ14_4 (0x10UL << ADC_SQR3_SQ14_Pos) /*!< 0x10000000 */ /******************** Bit definition for ADC_SQR4 register ********************/ #define ADC_SQR4_SQ15_Pos (0U) #define ADC_SQR4_SQ15_Msk (0x1FUL << ADC_SQR4_SQ15_Pos) /*!< 0x0000001F */ #define ADC_SQR4_SQ15 ADC_SQR4_SQ15_Msk /*!< ADC 15th conversion in regular sequence */ #define ADC_SQR4_SQ15_0 (0x01UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000001 */ #define ADC_SQR4_SQ15_1 (0x02UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000002 */ #define ADC_SQR4_SQ15_2 (0x04UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000004 */ #define ADC_SQR4_SQ15_3 (0x08UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000008 */ #define ADC_SQR4_SQ15_4 (0x10UL << ADC_SQR4_SQ15_Pos) /*!< 0x00000010 */ #define ADC_SQR4_SQ16_Pos (6U) #define ADC_SQR4_SQ16_Msk (0x1FUL << ADC_SQR4_SQ16_Pos) /*!< 0x000007C0 */ #define ADC_SQR4_SQ16 ADC_SQR4_SQ16_Msk /*!< ADC 16th conversion in regular sequence */ #define ADC_SQR4_SQ16_0 (0x01UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000040 */ #define ADC_SQR4_SQ16_1 (0x02UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000080 */ #define ADC_SQR4_SQ16_2 (0x04UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000100 */ #define ADC_SQR4_SQ16_3 (0x08UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000200 */ #define ADC_SQR4_SQ16_4 (0x10UL << ADC_SQR4_SQ16_Pos) /*!< 0x00000400 */ /******************** Bit definition for ADC_DR register ********************/ #define ADC_DR_RDATA_Pos (0U) #define ADC_DR_RDATA_Msk (0xFFFFFFFFUL << ADC_DR_RDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_DR_RDATA ADC_DR_RDATA_Msk /*!< ADC regular Data converted */ /******************** Bit definition for ADC_JSQR register ********************/ #define ADC_JSQR_JL_Pos (0U) #define ADC_JSQR_JL_Msk (0x3UL << ADC_JSQR_JL_Pos) /*!< 0x00000003 */ #define ADC_JSQR_JL ADC_JSQR_JL_Msk /*!< ADC injected channel sequence length */ #define ADC_JSQR_JL_0 (0x1UL << ADC_JSQR_JL_Pos) /*!< 0x00000001 */ #define ADC_JSQR_JL_1 (0x2UL << ADC_JSQR_JL_Pos) /*!< 0x00000002 */ #define ADC_JSQR_JEXTSEL_Pos (2U) #define ADC_JSQR_JEXTSEL_Msk (0x1FUL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x0000007C */ #define ADC_JSQR_JEXTSEL ADC_JSQR_JEXTSEL_Msk /*!< ADC external trigger selection for injected group */ #define ADC_JSQR_JEXTSEL_0 (0x01UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000004 */ #define ADC_JSQR_JEXTSEL_1 (0x02UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000008 */ #define ADC_JSQR_JEXTSEL_2 (0x04UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000010 */ #define ADC_JSQR_JEXTSEL_3 (0x08UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000020 */ #define ADC_JSQR_JEXTSEL_4 (0x10UL << ADC_JSQR_JEXTSEL_Pos) /*!< 0x00000040 */ #define ADC_JSQR_JEXTEN_Pos (7U) #define ADC_JSQR_JEXTEN_Msk (0x3UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000180 */ #define ADC_JSQR_JEXTEN ADC_JSQR_JEXTEN_Msk /*!< ADC external trigger enable and polarity selection for injected channels */ #define ADC_JSQR_JEXTEN_0 (0x1UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000080 */ #define ADC_JSQR_JEXTEN_1 (0x2UL << ADC_JSQR_JEXTEN_Pos) /*!< 0x00000100 */ #define ADC_JSQR_JSQ1_Pos (9U) #define ADC_JSQR_JSQ1_Msk (0x1FUL << ADC_JSQR_JSQ1_Pos) /*!< 0x00003E00 */ #define ADC_JSQR_JSQ1 ADC_JSQR_JSQ1_Msk /*!< ADC 1st conversion in injected sequence */ #define ADC_JSQR_JSQ1_0 (0x01UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000200 */ #define ADC_JSQR_JSQ1_1 (0x02UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000400 */ #define ADC_JSQR_JSQ1_2 (0x04UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00000800 */ #define ADC_JSQR_JSQ1_3 (0x08UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00001000 */ #define ADC_JSQR_JSQ1_4 (0x10UL << ADC_JSQR_JSQ1_Pos) /*!< 0x00002000 */ #define ADC_JSQR_JSQ2_Pos (15U) #define ADC_JSQR_JSQ2_Msk (0x1FUL << ADC_JSQR_JSQ2_Pos) /*!< 0x000F8000 */ #define ADC_JSQR_JSQ2 ADC_JSQR_JSQ2_Msk /*!< ADC 2nd conversion in injected sequence */ #define ADC_JSQR_JSQ2_0 (0x01UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00008000 */ #define ADC_JSQR_JSQ2_1 (0x02UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00010000 */ #define ADC_JSQR_JSQ2_2 (0x04UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00020000 */ #define ADC_JSQR_JSQ2_3 (0x08UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00040000 */ #define ADC_JSQR_JSQ2_4 (0x10UL << ADC_JSQR_JSQ2_Pos) /*!< 0x00080000 */ #define ADC_JSQR_JSQ3_Pos (21U) #define ADC_JSQR_JSQ3_Msk (0x1FUL << ADC_JSQR_JSQ3_Pos) /*!< 0x03E00000 */ #define ADC_JSQR_JSQ3 ADC_JSQR_JSQ3_Msk /*!< ADC 3rd conversion in injected sequence */ #define ADC_JSQR_JSQ3_0 (0x01UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00200000 */ #define ADC_JSQR_JSQ3_1 (0x02UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00400000 */ #define ADC_JSQR_JSQ3_2 (0x04UL << ADC_JSQR_JSQ3_Pos) /*!< 0x00800000 */ #define ADC_JSQR_JSQ3_3 (0x08UL << ADC_JSQR_JSQ3_Pos) /*!< 0x01000000 */ #define ADC_JSQR_JSQ3_4 (0x10UL << ADC_JSQR_JSQ3_Pos) /*!< 0x02000000 */ #define ADC_JSQR_JSQ4_Pos (27U) #define ADC_JSQR_JSQ4_Msk (0x1FUL << ADC_JSQR_JSQ4_Pos) /*!< 0xF8000000 */ #define ADC_JSQR_JSQ4 ADC_JSQR_JSQ4_Msk /*!< ADC 4th conversion in injected sequence */ #define ADC_JSQR_JSQ4_0 (0x01UL << ADC_JSQR_JSQ4_Pos) /*!< 0x08000000 */ #define ADC_JSQR_JSQ4_1 (0x02UL << ADC_JSQR_JSQ4_Pos) /*!< 0x10000000 */ #define ADC_JSQR_JSQ4_2 (0x04UL << ADC_JSQR_JSQ4_Pos) /*!< 0x20000000 */ #define ADC_JSQR_JSQ4_3 (0x08UL << ADC_JSQR_JSQ4_Pos) /*!< 0x40000000 */ #define ADC_JSQR_JSQ4_4 (0x10UL << ADC_JSQR_JSQ4_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_OFR1 register ********************/ #define ADC_OFR1_OFFSET1_Pos (0U) #define ADC_OFR1_OFFSET1_Msk (0x3FFFFFFUL << ADC_OFR1_OFFSET1_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR1_OFFSET1 ADC_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC_OFR1_OFFSET1_0 (0x0000001UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000001 */ #define ADC_OFR1_OFFSET1_1 (0x0000002UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000002 */ #define ADC_OFR1_OFFSET1_2 (0x0000004UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000004 */ #define ADC_OFR1_OFFSET1_3 (0x0000008UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000008 */ #define ADC_OFR1_OFFSET1_4 (0x0000010UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000010 */ #define ADC_OFR1_OFFSET1_5 (0x0000020UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000020 */ #define ADC_OFR1_OFFSET1_6 (0x0000040UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000040 */ #define ADC_OFR1_OFFSET1_7 (0x0000080UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000080 */ #define ADC_OFR1_OFFSET1_8 (0x0000100UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000100 */ #define ADC_OFR1_OFFSET1_9 (0x0000200UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000200 */ #define ADC_OFR1_OFFSET1_10 (0x0000400UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000400 */ #define ADC_OFR1_OFFSET1_11 (0x0000800UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00000800 */ #define ADC_OFR1_OFFSET1_12 (0x0001000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00001000 */ #define ADC_OFR1_OFFSET1_13 (0x0002000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00002000 */ #define ADC_OFR1_OFFSET1_14 (0x0004000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00004000 */ #define ADC_OFR1_OFFSET1_15 (0x0008000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00008000 */ #define ADC_OFR1_OFFSET1_16 (0x0010000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00010000 */ #define ADC_OFR1_OFFSET1_17 (0x0020000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00020000 */ #define ADC_OFR1_OFFSET1_18 (0x0040000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00040000 */ #define ADC_OFR1_OFFSET1_19 (0x0080000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00080000 */ #define ADC_OFR1_OFFSET1_20 (0x0100000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00100000 */ #define ADC_OFR1_OFFSET1_21 (0x0200000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00200000 */ #define ADC_OFR1_OFFSET1_22 (0x0400000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00400000 */ #define ADC_OFR1_OFFSET1_23 (0x0800000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x00800000 */ #define ADC_OFR1_OFFSET1_24 (0x1000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x01000000 */ #define ADC_OFR1_OFFSET1_25 (0x2000000UL << ADC_OFR1_OFFSET1_Pos) /*!< 0x02000000 */ #define ADC_OFR1_OFFSET1_CH_Pos (26U) #define ADC_OFR1_OFFSET1_CH_Msk (0x1FUL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR1_OFFSET1_CH ADC_OFR1_OFFSET1_CH_Msk /*!< ADC Channel selection for the data offset 1 */ #define ADC_OFR1_OFFSET1_CH_0 (0x01UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR1_OFFSET1_CH_1 (0x02UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR1_OFFSET1_CH_2 (0x04UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR1_OFFSET1_CH_3 (0x08UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR1_OFFSET1_CH_4 (0x10UL << ADC_OFR1_OFFSET1_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR1_SSATE_Pos (31U) #define ADC_OFR1_SSATE_Msk (0x1UL << ADC_OFR1_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR1_SSATE ADC_OFR1_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR1_OFFSET1_Pos (0U) #define ADC3_OFR1_OFFSET1_Msk (0xFFFUL << ADC3_OFR1_OFFSET1_Pos) /*!< 0x00000FFF */ #define ADC3_OFR1_OFFSET1 ADC3_OFR1_OFFSET1_Msk /*!< ADC data offset 1 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR1_OFFSETPOS_Pos (24U) #define ADC3_OFR1_OFFSETPOS_Msk (0x1UL << ADC3_OFR1_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR1_OFFSETPOS ADC3_OFR1_OFFSETPOS_Msk /*!< ADC offset number 1 positive */ #define ADC3_OFR1_SATEN_Pos (25U) #define ADC3_OFR1_SATEN_Msk (0x1UL << ADC3_OFR1_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR1_SATEN ADC3_OFR1_SATEN_Msk /*!< ADC offset number 1 saturation enable */ #define ADC3_OFR1_OFFSET1_EN_Pos (31U) #define ADC3_OFR1_OFFSET1_EN_Msk (0x1UL << ADC3_OFR1_OFFSET1_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR1_OFFSET1_EN ADC3_OFR1_OFFSET1_EN_Msk /*!< ADC offset number 1 enable */ /******************** Bit definition for ADC_OFR2 register ********************/ #define ADC_OFR2_OFFSET2_Pos (0U) #define ADC_OFR2_OFFSET2_Msk (0x3FFFFFFUL << ADC_OFR2_OFFSET2_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR2_OFFSET2 ADC_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET2_CH[4:0] */ #define ADC_OFR2_OFFSET2_0 (0x0000001UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000001 */ #define ADC_OFR2_OFFSET2_1 (0x0000002UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000002 */ #define ADC_OFR2_OFFSET2_2 (0x0000004UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000004 */ #define ADC_OFR2_OFFSET2_3 (0x0000008UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000008 */ #define ADC_OFR2_OFFSET2_4 (0x0000010UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000010 */ #define ADC_OFR2_OFFSET2_5 (0x0000020UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000020 */ #define ADC_OFR2_OFFSET2_6 (0x0000040UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000040 */ #define ADC_OFR2_OFFSET2_7 (0x0000080UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000080 */ #define ADC_OFR2_OFFSET2_8 (0x0000100UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000100 */ #define ADC_OFR2_OFFSET2_9 (0x0000200UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000200 */ #define ADC_OFR2_OFFSET2_10 (0x0000400UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000400 */ #define ADC_OFR2_OFFSET2_11 (0x0000800UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00000800 */ #define ADC_OFR2_OFFSET2_12 (0x0001000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00001000 */ #define ADC_OFR2_OFFSET2_13 (0x0002000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00002000 */ #define ADC_OFR2_OFFSET2_14 (0x0004000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00004000 */ #define ADC_OFR2_OFFSET2_15 (0x0008000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00008000 */ #define ADC_OFR2_OFFSET2_16 (0x0010000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00010000 */ #define ADC_OFR2_OFFSET2_17 (0x0020000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00020000 */ #define ADC_OFR2_OFFSET2_18 (0x0040000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00040000 */ #define ADC_OFR2_OFFSET2_19 (0x0080000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00080000 */ #define ADC_OFR2_OFFSET2_20 (0x0100000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00100000 */ #define ADC_OFR2_OFFSET2_21 (0x0200000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00200000 */ #define ADC_OFR2_OFFSET2_22 (0x0400000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00400000 */ #define ADC_OFR2_OFFSET2_23 (0x0800000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x00800000 */ #define ADC_OFR2_OFFSET2_24 (0x1000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x01000000 */ #define ADC_OFR2_OFFSET2_25 (0x2000000UL << ADC_OFR2_OFFSET2_Pos) /*!< 0x02000000 */ #define ADC_OFR2_OFFSET2_CH_Pos (26U) #define ADC_OFR2_OFFSET2_CH_Msk (0x1FUL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR2_OFFSET2_CH ADC_OFR2_OFFSET2_CH_Msk /*!< ADC Channel selection for the data offset 2 */ #define ADC_OFR2_OFFSET2_CH_0 (0x01UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR2_OFFSET2_CH_1 (0x02UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR2_OFFSET2_CH_2 (0x04UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR2_OFFSET2_CH_3 (0x08UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR2_OFFSET2_CH_4 (0x10UL << ADC_OFR2_OFFSET2_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR2_SSATE_Pos (31U) #define ADC_OFR2_SSATE_Msk (0x1UL << ADC_OFR2_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR2_SSATE ADC_OFR2_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR2_OFFSET2_Pos (0U) #define ADC3_OFR2_OFFSET2_Msk (0xFFFUL << ADC3_OFR2_OFFSET2_Pos) /*!< 0x00000FFF */ #define ADC3_OFR2_OFFSET2 ADC3_OFR2_OFFSET2_Msk /*!< ADC data offset 2 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR2_OFFSETPOS_Pos (24U) #define ADC3_OFR2_OFFSETPOS_Msk (0x1UL << ADC3_OFR2_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR2_OFFSETPOS ADC3_OFR2_OFFSETPOS_Msk /*!< ADC offset number 2 positive */ #define ADC3_OFR2_SATEN_Pos (25U) #define ADC3_OFR2_SATEN_Msk (0x1UL << ADC3_OFR2_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR2_SATEN ADC3_OFR2_SATEN_Msk /*!< ADC offset number 2 saturation enable */ #define ADC3_OFR2_OFFSET2_EN_Pos (31U) #define ADC3_OFR2_OFFSET2_EN_Msk (0x1UL << ADC3_OFR2_OFFSET2_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR2_OFFSET2_EN ADC3_OFR2_OFFSET2_EN_Msk /*!< ADC offset number 2 enable */ /******************** Bit definition for ADC_OFR3 register ********************/ #define ADC_OFR3_OFFSET3_Pos (0U) #define ADC_OFR3_OFFSET3_Msk (0x3FFFFFFUL << ADC_OFR3_OFFSET3_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR3_OFFSET3 ADC_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET3_CH[4:0] */ #define ADC_OFR3_OFFSET3_0 (0x0000001UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000001 */ #define ADC_OFR3_OFFSET3_1 (0x0000002UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000002 */ #define ADC_OFR3_OFFSET3_2 (0x0000004UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000004 */ #define ADC_OFR3_OFFSET3_3 (0x0000008UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000008 */ #define ADC_OFR3_OFFSET3_4 (0x0000010UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000010 */ #define ADC_OFR3_OFFSET3_5 (0x0000020UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000020 */ #define ADC_OFR3_OFFSET3_6 (0x0000040UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000040 */ #define ADC_OFR3_OFFSET3_7 (0x0000080UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000080 */ #define ADC_OFR3_OFFSET3_8 (0x0000100UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000100 */ #define ADC_OFR3_OFFSET3_9 (0x0000200UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000200 */ #define ADC_OFR3_OFFSET3_10 (0x0000400UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000400 */ #define ADC_OFR3_OFFSET3_11 (0x0000800UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00000800 */ #define ADC_OFR3_OFFSET3_12 (0x0001000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00001000 */ #define ADC_OFR3_OFFSET3_13 (0x0002000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00002000 */ #define ADC_OFR3_OFFSET3_14 (0x0004000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00004000 */ #define ADC_OFR3_OFFSET3_15 (0x0008000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00008000 */ #define ADC_OFR3_OFFSET3_16 (0x0010000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00010000 */ #define ADC_OFR3_OFFSET3_17 (0x0020000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00020000 */ #define ADC_OFR3_OFFSET3_18 (0x0040000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00040000 */ #define ADC_OFR3_OFFSET3_19 (0x0080000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00080000 */ #define ADC_OFR3_OFFSET3_20 (0x0100000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00100000 */ #define ADC_OFR3_OFFSET3_21 (0x0200000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00200000 */ #define ADC_OFR3_OFFSET3_22 (0x0400000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00400000 */ #define ADC_OFR3_OFFSET3_23 (0x0800000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x00800000 */ #define ADC_OFR3_OFFSET3_24 (0x1000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x01000000 */ #define ADC_OFR3_OFFSET3_25 (0x2000000UL << ADC_OFR3_OFFSET3_Pos) /*!< 0x02000000 */ #define ADC_OFR3_OFFSET3_CH_Pos (26U) #define ADC_OFR3_OFFSET3_CH_Msk (0x1FUL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR3_OFFSET3_CH ADC_OFR3_OFFSET3_CH_Msk /*!< ADC Channel selection for the data offset 3 */ #define ADC_OFR3_OFFSET3_CH_0 (0x01UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR3_OFFSET3_CH_1 (0x02UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR3_OFFSET3_CH_2 (0x04UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR3_OFFSET3_CH_3 (0x08UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR3_OFFSET3_CH_4 (0x10UL << ADC_OFR3_OFFSET3_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR3_SSATE_Pos (31U) #define ADC_OFR3_SSATE_Msk (0x1UL << ADC_OFR3_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR3_SSATE ADC_OFR3_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR3_OFFSET3_Pos (0U) #define ADC3_OFR3_OFFSET3_Msk (0xFFFUL << ADC3_OFR3_OFFSET3_Pos) /*!< 0x00000FFF */ #define ADC3_OFR3_OFFSET3 ADC3_OFR3_OFFSET3_Msk /*!< ADC data offset 3 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR3_OFFSETPOS_Pos (24U) #define ADC3_OFR3_OFFSETPOS_Msk (0x1UL << ADC3_OFR3_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR3_OFFSETPOS ADC3_OFR3_OFFSETPOS_Msk /*!< ADC offset number 3 positive */ #define ADC3_OFR3_SATEN_Pos (25U) #define ADC3_OFR3_SATEN_Msk (0x1UL << ADC3_OFR3_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR3_SATEN ADC3_OFR3_SATEN_Msk /*!< ADC offset number 3 saturation enable */ #define ADC3_OFR3_OFFSET3_EN_Pos (31U) #define ADC3_OFR3_OFFSET3_EN_Msk (0x1UL << ADC3_OFR3_OFFSET3_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR3_OFFSET3_EN ADC3_OFR3_OFFSET3_EN_Msk /*!< ADC offset number 3 enable */ /******************** Bit definition for ADC_OFR4 register ********************/ #define ADC_OFR4_OFFSET4_Pos (0U) #define ADC_OFR4_OFFSET4_Msk (0x3FFFFFFUL << ADC_OFR4_OFFSET4_Pos) /*!< 0x03FFFFFF */ #define ADC_OFR4_OFFSET4 ADC_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET4_CH[4:0] */ #define ADC_OFR4_OFFSET4_0 (0x0000001UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000001 */ #define ADC_OFR4_OFFSET4_1 (0x0000002UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000002 */ #define ADC_OFR4_OFFSET4_2 (0x0000004UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000004 */ #define ADC_OFR4_OFFSET4_3 (0x0000008UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000008 */ #define ADC_OFR4_OFFSET4_4 (0x0000010UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000010 */ #define ADC_OFR4_OFFSET4_5 (0x0000020UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000020 */ #define ADC_OFR4_OFFSET4_6 (0x0000040UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000040 */ #define ADC_OFR4_OFFSET4_7 (0x0000080UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000080 */ #define ADC_OFR4_OFFSET4_8 (0x0000100UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000100 */ #define ADC_OFR4_OFFSET4_9 (0x0000200UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000200 */ #define ADC_OFR4_OFFSET4_10 (0x0000400UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000400 */ #define ADC_OFR4_OFFSET4_11 (0x0000800UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00000800 */ #define ADC_OFR4_OFFSET4_12 (0x0001000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00001000 */ #define ADC_OFR4_OFFSET4_13 (0x0002000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00002000 */ #define ADC_OFR4_OFFSET4_14 (0x0004000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00004000 */ #define ADC_OFR4_OFFSET4_15 (0x0008000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00008000 */ #define ADC_OFR4_OFFSET4_16 (0x0010000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00010000 */ #define ADC_OFR4_OFFSET4_17 (0x0020000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00020000 */ #define ADC_OFR4_OFFSET4_18 (0x0040000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00040000 */ #define ADC_OFR4_OFFSET4_19 (0x0080000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00080000 */ #define ADC_OFR4_OFFSET4_20 (0x0100000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00100000 */ #define ADC_OFR4_OFFSET4_21 (0x0200000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00200000 */ #define ADC_OFR4_OFFSET4_22 (0x0400000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00400000 */ #define ADC_OFR4_OFFSET4_23 (0x0800000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x00800000 */ #define ADC_OFR4_OFFSET4_24 (0x1000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x01000000 */ #define ADC_OFR4_OFFSET4_25 (0x2000000UL << ADC_OFR4_OFFSET4_Pos) /*!< 0x02000000 */ #define ADC_OFR4_OFFSET4_CH_Pos (26U) #define ADC_OFR4_OFFSET4_CH_Msk (0x1FUL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x7C000000 */ #define ADC_OFR4_OFFSET4_CH ADC_OFR4_OFFSET4_CH_Msk /*!< ADC Channel selection for the data offset 4 */ #define ADC_OFR4_OFFSET4_CH_0 (0x01UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x04000000 */ #define ADC_OFR4_OFFSET4_CH_1 (0x02UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x08000000 */ #define ADC_OFR4_OFFSET4_CH_2 (0x04UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x10000000 */ #define ADC_OFR4_OFFSET4_CH_3 (0x08UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x20000000 */ #define ADC_OFR4_OFFSET4_CH_4 (0x10UL << ADC_OFR4_OFFSET4_CH_Pos) /*!< 0x40000000 */ #define ADC_OFR4_SSATE_Pos (31U) #define ADC_OFR4_SSATE_Msk (0x1UL << ADC_OFR4_SSATE_Pos) /*!< 0x80000000 */ #define ADC_OFR4_SSATE ADC_OFR4_SSATE_Msk /*!< ADC Signed saturation Enable */ #define ADC3_OFR4_OFFSET4_Pos (0U) #define ADC3_OFR4_OFFSET4_Msk (0xFFFUL << ADC3_OFR4_OFFSET4_Pos) /*!< 0x00000FFF */ #define ADC3_OFR4_OFFSET4 ADC3_OFR4_OFFSET4_Msk /*!< ADC data offset 4 for channel programmed into bits OFFSET1_CH[4:0] */ #define ADC3_OFR4_OFFSETPOS_Pos (24U) #define ADC3_OFR4_OFFSETPOS_Msk (0x1UL << ADC3_OFR4_OFFSETPOS_Pos) /*!< 0x01000000 */ #define ADC3_OFR4_OFFSETPOS ADC3_OFR4_OFFSETPOS_Msk /*!< ADC offset number 4 positive */ #define ADC3_OFR4_SATEN_Pos (25U) #define ADC3_OFR4_SATEN_Msk (0x1UL << ADC3_OFR4_SATEN_Pos) /*!< 0x02000000 */ #define ADC3_OFR4_SATEN ADC3_OFR4_SATEN_Msk /*!< ADC offset number 4 saturation enable */ #define ADC3_OFR4_OFFSET4_EN_Pos (31U) #define ADC3_OFR4_OFFSET4_EN_Msk (0x1UL << ADC3_OFR4_OFFSET4_EN_Pos) /*!< 0x80000000 */ #define ADC3_OFR4_OFFSET4_EN ADC3_OFR4_OFFSET4_EN_Msk /*!< ADC offset number 4 enable */ /******************** Bit definition for ADC_JDR1 register ********************/ #define ADC_JDR1_JDATA_Pos (0U) #define ADC_JDR1_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR1_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR1_JDATA ADC_JDR1_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR1_JDATA_0 (0x00000001UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR1_JDATA_1 (0x00000002UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR1_JDATA_2 (0x00000004UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR1_JDATA_3 (0x00000008UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR1_JDATA_4 (0x00000010UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR1_JDATA_5 (0x00000020UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR1_JDATA_6 (0x00000040UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR1_JDATA_7 (0x00000080UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR1_JDATA_8 (0x00000100UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR1_JDATA_9 (0x00000200UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR1_JDATA_10 (0x00000400UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR1_JDATA_11 (0x00000800UL << ADC_JDR1_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR1_JDATA_12 (0x00001000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR1_JDATA_13 (0x00002000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR1_JDATA_14 (0x00004000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR1_JDATA_15 (0x00008000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR1_JDATA_16 (0x00010000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR1_JDATA_17 (0x00020000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR1_JDATA_18 (0x00040000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR1_JDATA_19 (0x00080000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR1_JDATA_20 (0x00100000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR1_JDATA_21 (0x00200000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR1_JDATA_22 (0x00400000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR1_JDATA_23 (0x00800000UL << ADC_JDR1_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR1_JDATA_24 (0x01000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR1_JDATA_25 (0x02000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR1_JDATA_26 (0x04000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR1_JDATA_27 (0x08000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR1_JDATA_28 (0x10000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR1_JDATA_29 (0x20000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR1_JDATA_30 (0x40000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR1_JDATA_31 (0x80000000UL << ADC_JDR1_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_JDR2 register ********************/ #define ADC_JDR2_JDATA_Pos (0U) #define ADC_JDR2_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR2_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR2_JDATA ADC_JDR2_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR2_JDATA_0 (0x00000001UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR2_JDATA_1 (0x00000002UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR2_JDATA_2 (0x00000004UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR2_JDATA_3 (0x00000008UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR2_JDATA_4 (0x00000010UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR2_JDATA_5 (0x00000020UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR2_JDATA_6 (0x00000040UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR2_JDATA_7 (0x00000080UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR2_JDATA_8 (0x00000100UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR2_JDATA_9 (0x00000200UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR2_JDATA_10 (0x00000400UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR2_JDATA_11 (0x00000800UL << ADC_JDR2_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR2_JDATA_12 (0x00001000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR2_JDATA_13 (0x00002000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR2_JDATA_14 (0x00004000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR2_JDATA_15 (0x00008000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR2_JDATA_16 (0x00010000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR2_JDATA_17 (0x00020000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR2_JDATA_18 (0x00040000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR2_JDATA_19 (0x00080000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR2_JDATA_20 (0x00100000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR2_JDATA_21 (0x00200000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR2_JDATA_22 (0x00400000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR2_JDATA_23 (0x00800000UL << ADC_JDR2_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR2_JDATA_24 (0x01000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR2_JDATA_25 (0x02000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR2_JDATA_26 (0x04000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR2_JDATA_27 (0x08000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR2_JDATA_28 (0x10000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR2_JDATA_29 (0x20000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR2_JDATA_30 (0x40000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR2_JDATA_31 (0x80000000UL << ADC_JDR2_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_JDR3 register ********************/ #define ADC_JDR3_JDATA_Pos (0U) #define ADC_JDR3_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR3_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR3_JDATA ADC_JDR3_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR3_JDATA_0 (0x00000001UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR3_JDATA_1 (0x00000002UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR3_JDATA_2 (0x00000004UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR3_JDATA_3 (0x00000008UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR3_JDATA_4 (0x00000010UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR3_JDATA_5 (0x00000020UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR3_JDATA_6 (0x00000040UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR3_JDATA_7 (0x00000080UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR3_JDATA_8 (0x00000100UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR3_JDATA_9 (0x00000200UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR3_JDATA_10 (0x00000400UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR3_JDATA_11 (0x00000800UL << ADC_JDR3_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR3_JDATA_12 (0x00001000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR3_JDATA_13 (0x00002000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR3_JDATA_14 (0x00004000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR3_JDATA_15 (0x00008000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR3_JDATA_16 (0x00010000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR3_JDATA_17 (0x00020000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR3_JDATA_18 (0x00040000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR3_JDATA_19 (0x00080000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR3_JDATA_20 (0x00100000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR3_JDATA_21 (0x00200000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR3_JDATA_22 (0x00400000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR3_JDATA_23 (0x00800000UL << ADC_JDR3_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR3_JDATA_24 (0x01000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR3_JDATA_25 (0x02000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR3_JDATA_26 (0x04000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR3_JDATA_27 (0x08000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR3_JDATA_28 (0x10000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR3_JDATA_29 (0x20000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR3_JDATA_30 (0x40000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR3_JDATA_31 (0x80000000UL << ADC_JDR3_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_JDR4 register ********************/ #define ADC_JDR4_JDATA_Pos (0U) #define ADC_JDR4_JDATA_Msk (0xFFFFFFFFUL << ADC_JDR4_JDATA_Pos) /*!< 0xFFFFFFFF */ #define ADC_JDR4_JDATA ADC_JDR4_JDATA_Msk /*!< ADC Injected DATA */ #define ADC_JDR4_JDATA_0 (0x00000001UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000001 */ #define ADC_JDR4_JDATA_1 (0x00000002UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000002 */ #define ADC_JDR4_JDATA_2 (0x00000004UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000004 */ #define ADC_JDR4_JDATA_3 (0x00000008UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000008 */ #define ADC_JDR4_JDATA_4 (0x00000010UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000010 */ #define ADC_JDR4_JDATA_5 (0x00000020UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000020 */ #define ADC_JDR4_JDATA_6 (0x00000040UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000040 */ #define ADC_JDR4_JDATA_7 (0x00000080UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000080 */ #define ADC_JDR4_JDATA_8 (0x00000100UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000100 */ #define ADC_JDR4_JDATA_9 (0x00000200UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000200 */ #define ADC_JDR4_JDATA_10 (0x00000400UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000400 */ #define ADC_JDR4_JDATA_11 (0x00000800UL << ADC_JDR4_JDATA_Pos) /*!< 0x00000800 */ #define ADC_JDR4_JDATA_12 (0x00001000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00001000 */ #define ADC_JDR4_JDATA_13 (0x00002000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00002000 */ #define ADC_JDR4_JDATA_14 (0x00004000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00004000 */ #define ADC_JDR4_JDATA_15 (0x00008000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00008000 */ #define ADC_JDR4_JDATA_16 (0x00010000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00010000 */ #define ADC_JDR4_JDATA_17 (0x00020000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00020000 */ #define ADC_JDR4_JDATA_18 (0x00040000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00040000 */ #define ADC_JDR4_JDATA_19 (0x00080000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00080000 */ #define ADC_JDR4_JDATA_20 (0x00100000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00100000 */ #define ADC_JDR4_JDATA_21 (0x00200000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00200000 */ #define ADC_JDR4_JDATA_22 (0x00400000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00400000 */ #define ADC_JDR4_JDATA_23 (0x00800000UL << ADC_JDR4_JDATA_Pos) /*!< 0x00800000 */ #define ADC_JDR4_JDATA_24 (0x01000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x01000000 */ #define ADC_JDR4_JDATA_25 (0x02000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x02000000 */ #define ADC_JDR4_JDATA_26 (0x04000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x04000000 */ #define ADC_JDR4_JDATA_27 (0x08000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x08000000 */ #define ADC_JDR4_JDATA_28 (0x10000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x10000000 */ #define ADC_JDR4_JDATA_29 (0x20000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x20000000 */ #define ADC_JDR4_JDATA_30 (0x40000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x40000000 */ #define ADC_JDR4_JDATA_31 (0x80000000UL << ADC_JDR4_JDATA_Pos) /*!< 0x80000000 */ /******************** Bit definition for ADC_AWD2CR register ********************/ #define ADC_AWD2CR_AWD2CH_Pos (0U) #define ADC_AWD2CR_AWD2CH_Msk (0xFFFFFUL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x000FFFFF */ #define ADC_AWD2CR_AWD2CH ADC_AWD2CR_AWD2CH_Msk /*!< ADC Analog watchdog 2 channel selection */ #define ADC_AWD2CR_AWD2CH_0 (0x00001UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000001 */ #define ADC_AWD2CR_AWD2CH_1 (0x00002UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000002 */ #define ADC_AWD2CR_AWD2CH_2 (0x00004UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000004 */ #define ADC_AWD2CR_AWD2CH_3 (0x00008UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000008 */ #define ADC_AWD2CR_AWD2CH_4 (0x00010UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000010 */ #define ADC_AWD2CR_AWD2CH_5 (0x00020UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000020 */ #define ADC_AWD2CR_AWD2CH_6 (0x00040UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000040 */ #define ADC_AWD2CR_AWD2CH_7 (0x00080UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000080 */ #define ADC_AWD2CR_AWD2CH_8 (0x00100UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000100 */ #define ADC_AWD2CR_AWD2CH_9 (0x00200UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000200 */ #define ADC_AWD2CR_AWD2CH_10 (0x00400UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000400 */ #define ADC_AWD2CR_AWD2CH_11 (0x00800UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00000800 */ #define ADC_AWD2CR_AWD2CH_12 (0x01000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00001000 */ #define ADC_AWD2CR_AWD2CH_13 (0x02000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00002000 */ #define ADC_AWD2CR_AWD2CH_14 (0x04000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00004000 */ #define ADC_AWD2CR_AWD2CH_15 (0x08000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00008000 */ #define ADC_AWD2CR_AWD2CH_16 (0x10000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00010000 */ #define ADC_AWD2CR_AWD2CH_17 (0x20000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00020000 */ #define ADC_AWD2CR_AWD2CH_18 (0x40000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00040000 */ #define ADC_AWD2CR_AWD2CH_19 (0x80000UL << ADC_AWD2CR_AWD2CH_Pos) /*!< 0x00080000 */ /******************** Bit definition for ADC_AWD3CR register ********************/ #define ADC_AWD3CR_AWD3CH_Pos (0U) #define ADC_AWD3CR_AWD3CH_Msk (0xFFFFFUL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x000FFFFF */ #define ADC_AWD3CR_AWD3CH ADC_AWD3CR_AWD3CH_Msk /*!< ADC Analog watchdog 2 channel selection */ #define ADC_AWD3CR_AWD3CH_0 (0x00001UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000001 */ #define ADC_AWD3CR_AWD3CH_1 (0x00002UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000002 */ #define ADC_AWD3CR_AWD3CH_2 (0x00004UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000004 */ #define ADC_AWD3CR_AWD3CH_3 (0x00008UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000008 */ #define ADC_AWD3CR_AWD3CH_4 (0x00010UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000010 */ #define ADC_AWD3CR_AWD3CH_5 (0x00020UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000020 */ #define ADC_AWD3CR_AWD3CH_6 (0x00040UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000040 */ #define ADC_AWD3CR_AWD3CH_7 (0x00080UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000080 */ #define ADC_AWD3CR_AWD3CH_8 (0x00100UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000100 */ #define ADC_AWD3CR_AWD3CH_9 (0x00200UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000200 */ #define ADC_AWD3CR_AWD3CH_10 (0x00400UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000400 */ #define ADC_AWD3CR_AWD3CH_11 (0x00800UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00000800 */ #define ADC_AWD3CR_AWD3CH_12 (0x01000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00001000 */ #define ADC_AWD3CR_AWD3CH_13 (0x02000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00002000 */ #define ADC_AWD3CR_AWD3CH_14 (0x04000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00004000 */ #define ADC_AWD3CR_AWD3CH_15 (0x08000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00008000 */ #define ADC_AWD3CR_AWD3CH_16 (0x10000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00010000 */ #define ADC_AWD3CR_AWD3CH_17 (0x20000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00020000 */ #define ADC_AWD3CR_AWD3CH_18 (0x40000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00040000 */ #define ADC_AWD3CR_AWD3CH_19 (0x80000UL << ADC_AWD3CR_AWD3CH_Pos) /*!< 0x00080000 */ /******************** Bit definition for ADC_DIFSEL register ********************/ #define ADC_DIFSEL_DIFSEL_Pos (0U) #define ADC_DIFSEL_DIFSEL_Msk (0xFFFFFUL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x000FFFFF */ #define ADC_DIFSEL_DIFSEL ADC_DIFSEL_DIFSEL_Msk /*!< ADC differential modes for channels 1 to 18 */ #define ADC_DIFSEL_DIFSEL_0 (0x00001UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000001 */ #define ADC_DIFSEL_DIFSEL_1 (0x00002UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000002 */ #define ADC_DIFSEL_DIFSEL_2 (0x00004UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000004 */ #define ADC_DIFSEL_DIFSEL_3 (0x00008UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000008 */ #define ADC_DIFSEL_DIFSEL_4 (0x00010UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000010 */ #define ADC_DIFSEL_DIFSEL_5 (0x00020UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000020 */ #define ADC_DIFSEL_DIFSEL_6 (0x00040UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000040 */ #define ADC_DIFSEL_DIFSEL_7 (0x00080UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000080 */ #define ADC_DIFSEL_DIFSEL_8 (0x00100UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000100 */ #define ADC_DIFSEL_DIFSEL_9 (0x00200UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000200 */ #define ADC_DIFSEL_DIFSEL_10 (0x00400UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000400 */ #define ADC_DIFSEL_DIFSEL_11 (0x00800UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00000800 */ #define ADC_DIFSEL_DIFSEL_12 (0x01000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00001000 */ #define ADC_DIFSEL_DIFSEL_13 (0x02000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00002000 */ #define ADC_DIFSEL_DIFSEL_14 (0x04000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00004000 */ #define ADC_DIFSEL_DIFSEL_15 (0x08000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00008000 */ #define ADC_DIFSEL_DIFSEL_16 (0x10000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00010000 */ #define ADC_DIFSEL_DIFSEL_17 (0x20000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00020000 */ #define ADC_DIFSEL_DIFSEL_18 (0x40000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00040000 */ #define ADC_DIFSEL_DIFSEL_19 (0x80000UL << ADC_DIFSEL_DIFSEL_Pos) /*!< 0x00080000 */ /******************** Bit definition for ADC_CALFACT register ********************/ #define ADC_CALFACT_CALFACT_S_Pos (0U) #define ADC_CALFACT_CALFACT_S_Msk (0x7FFUL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x000007FF */ #define ADC_CALFACT_CALFACT_S ADC_CALFACT_CALFACT_S_Msk /*!< ADC calibration factors in single-ended mode */ #define ADC_CALFACT_CALFACT_S_0 (0x001UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000001 */ #define ADC_CALFACT_CALFACT_S_1 (0x002UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000002 */ #define ADC_CALFACT_CALFACT_S_2 (0x004UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000004 */ #define ADC_CALFACT_CALFACT_S_3 (0x008UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000008 */ #define ADC_CALFACT_CALFACT_S_4 (0x010UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000010 */ #define ADC_CALFACT_CALFACT_S_5 (0x020UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000020 */ #define ADC_CALFACT_CALFACT_S_6 (0x040UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000040 */ #define ADC_CALFACT_CALFACT_S_7 (0x080UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000080 */ #define ADC_CALFACT_CALFACT_S_8 (0x100UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000100 */ #define ADC_CALFACT_CALFACT_S_9 (0x200UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000200 */ #define ADC_CALFACT_CALFACT_S_10 (0x400UL << ADC_CALFACT_CALFACT_S_Pos) /*!< 0x00000400 */ #define ADC_CALFACT_CALFACT_D_Pos (16U) #define ADC_CALFACT_CALFACT_D_Msk (0x7FFUL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x07FF0000 */ #define ADC_CALFACT_CALFACT_D ADC_CALFACT_CALFACT_D_Msk /*!< ADC calibration factors in differential mode */ #define ADC_CALFACT_CALFACT_D_0 (0x001UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00010000 */ #define ADC_CALFACT_CALFACT_D_1 (0x002UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00020000 */ #define ADC_CALFACT_CALFACT_D_2 (0x004UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00040000 */ #define ADC_CALFACT_CALFACT_D_3 (0x008UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00080000 */ #define ADC_CALFACT_CALFACT_D_4 (0x010UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00100000 */ #define ADC_CALFACT_CALFACT_D_5 (0x020UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00200000 */ #define ADC_CALFACT_CALFACT_D_6 (0x040UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00400000 */ #define ADC_CALFACT_CALFACT_D_7 (0x080UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x00800000 */ #define ADC_CALFACT_CALFACT_D_8 (0x100UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x01000000 */ #define ADC_CALFACT_CALFACT_D_9 (0x200UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x02000000 */ #define ADC_CALFACT_CALFACT_D_10 (0x400UL << ADC_CALFACT_CALFACT_D_Pos) /*!< 0x04000000 */ /******************** Bit definition for ADC_CALFACT2 register ********************/ #define ADC_CALFACT2_LINCALFACT_Pos (0U) #define ADC_CALFACT2_LINCALFACT_Msk (0x3FFFFFFFUL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x3FFFFFFF */ #define ADC_CALFACT2_LINCALFACT ADC_CALFACT2_LINCALFACT_Msk /*!< ADC Linearity calibration factors */ #define ADC_CALFACT2_LINCALFACT_0 (0x00000001UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000001 */ #define ADC_CALFACT2_LINCALFACT_1 (0x00000002UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000002 */ #define ADC_CALFACT2_LINCALFACT_2 (0x00000004UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000004 */ #define ADC_CALFACT2_LINCALFACT_3 (0x00000008UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000008 */ #define ADC_CALFACT2_LINCALFACT_4 (0x00000010UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000010 */ #define ADC_CALFACT2_LINCALFACT_5 (0x00000020UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000020 */ #define ADC_CALFACT2_LINCALFACT_6 (0x00000040UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000040 */ #define ADC_CALFACT2_LINCALFACT_7 (0x00000080UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000080 */ #define ADC_CALFACT2_LINCALFACT_8 (0x00000100UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000100 */ #define ADC_CALFACT2_LINCALFACT_9 (0x00000200UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000200 */ #define ADC_CALFACT2_LINCALFACT_10 (0x00000400UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000400 */ #define ADC_CALFACT2_LINCALFACT_11 (0x00000800UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00000800 */ #define ADC_CALFACT2_LINCALFACT_12 (0x00001000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00001000 */ #define ADC_CALFACT2_LINCALFACT_13 (0x00002000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00002000 */ #define ADC_CALFACT2_LINCALFACT_14 (0x00004000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00004000 */ #define ADC_CALFACT2_LINCALFACT_15 (0x00008000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00008000 */ #define ADC_CALFACT2_LINCALFACT_16 (0x00010000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00010000 */ #define ADC_CALFACT2_LINCALFACT_17 (0x00020000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00020000 */ #define ADC_CALFACT2_LINCALFACT_18 (0x00040000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00040000 */ #define ADC_CALFACT2_LINCALFACT_19 (0x00080000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00080000 */ #define ADC_CALFACT2_LINCALFACT_20 (0x00100000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00100000 */ #define ADC_CALFACT2_LINCALFACT_21 (0x00200000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00200000 */ #define ADC_CALFACT2_LINCALFACT_22 (0x00400000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00400000 */ #define ADC_CALFACT2_LINCALFACT_23 (0x00800000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x00800000 */ #define ADC_CALFACT2_LINCALFACT_24 (0x01000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x01000000 */ #define ADC_CALFACT2_LINCALFACT_25 (0x02000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x02000000 */ #define ADC_CALFACT2_LINCALFACT_26 (0x04000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x04000000 */ #define ADC_CALFACT2_LINCALFACT_27 (0x08000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x08000000 */ #define ADC_CALFACT2_LINCALFACT_28 (0x10000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x10000000 */ #define ADC_CALFACT2_LINCALFACT_29 (0x20000000UL << ADC_CALFACT2_LINCALFACT_Pos) /*!< 0x20000000 */ /************************* ADC Common registers *****************************/ /******************** Bit definition for ADC_CSR register ********************/ #define ADC_CSR_ADRDY_MST_Pos (0U) #define ADC_CSR_ADRDY_MST_Msk (0x1UL << ADC_CSR_ADRDY_MST_Pos) /*!< 0x00000001 */ #define ADC_CSR_ADRDY_MST ADC_CSR_ADRDY_MST_Msk /*!< Master ADC ready */ #define ADC_CSR_EOSMP_MST_Pos (1U) #define ADC_CSR_EOSMP_MST_Msk (0x1UL << ADC_CSR_EOSMP_MST_Pos) /*!< 0x00000002 */ #define ADC_CSR_EOSMP_MST ADC_CSR_EOSMP_MST_Msk /*!< End of sampling phase flag of the master ADC */ #define ADC_CSR_EOC_MST_Pos (2U) #define ADC_CSR_EOC_MST_Msk (0x1UL << ADC_CSR_EOC_MST_Pos) /*!< 0x00000004 */ #define ADC_CSR_EOC_MST ADC_CSR_EOC_MST_Msk /*!< End of regular conversion of the master ADC */ #define ADC_CSR_EOS_MST_Pos (3U) #define ADC_CSR_EOS_MST_Msk (0x1UL << ADC_CSR_EOS_MST_Pos) /*!< 0x00000008 */ #define ADC_CSR_EOS_MST ADC_CSR_EOS_MST_Msk /*!< End of regular sequence flag of the master ADC */ #define ADC_CSR_OVR_MST_Pos (4U) #define ADC_CSR_OVR_MST_Msk (0x1UL << ADC_CSR_OVR_MST_Pos) /*!< 0x00000010 */ #define ADC_CSR_OVR_MST ADC_CSR_OVR_MST_Msk /*!< Overrun flag of the master ADC */ #define ADC_CSR_JEOC_MST_Pos (5U) #define ADC_CSR_JEOC_MST_Msk (0x1UL << ADC_CSR_JEOC_MST_Pos) /*!< 0x00000020 */ #define ADC_CSR_JEOC_MST ADC_CSR_JEOC_MST_Msk /*!< End of injected conversion of the master ADC */ #define ADC_CSR_JEOS_MST_Pos (6U) #define ADC_CSR_JEOS_MST_Msk (0x1UL << ADC_CSR_JEOS_MST_Pos) /*!< 0x00000040 */ #define ADC_CSR_JEOS_MST ADC_CSR_JEOS_MST_Msk /*!< End of injected sequence flag of the master ADC */ #define ADC_CSR_AWD1_MST_Pos (7U) #define ADC_CSR_AWD1_MST_Msk (0x1UL << ADC_CSR_AWD1_MST_Pos) /*!< 0x00000080 */ #define ADC_CSR_AWD1_MST ADC_CSR_AWD1_MST_Msk /*!< Analog watchdog 1 flag of the master ADC */ #define ADC_CSR_AWD2_MST_Pos (8U) #define ADC_CSR_AWD2_MST_Msk (0x1UL << ADC_CSR_AWD2_MST_Pos) /*!< 0x00000100 */ #define ADC_CSR_AWD2_MST ADC_CSR_AWD2_MST_Msk /*!< Analog watchdog 2 flag of the master ADC */ #define ADC_CSR_AWD3_MST_Pos (9U) #define ADC_CSR_AWD3_MST_Msk (0x1UL << ADC_CSR_AWD3_MST_Pos) /*!< 0x00000200 */ #define ADC_CSR_AWD3_MST ADC_CSR_AWD3_MST_Msk /*!< Analog watchdog 3 flag of the master ADC */ #define ADC_CSR_JQOVF_MST_Pos (10U) #define ADC_CSR_JQOVF_MST_Msk (0x1UL << ADC_CSR_JQOVF_MST_Pos) /*!< 0x00000400 */ #define ADC_CSR_JQOVF_MST ADC_CSR_JQOVF_MST_Msk /*!< Injected context queue overflow flag of the master ADC */ #define ADC_CSR_ADRDY_SLV_Pos (16U) #define ADC_CSR_ADRDY_SLV_Msk (0x1UL << ADC_CSR_ADRDY_SLV_Pos) /*!< 0x00010000 */ #define ADC_CSR_ADRDY_SLV ADC_CSR_ADRDY_SLV_Msk /*!< Slave ADC ready */ #define ADC_CSR_EOSMP_SLV_Pos (17U) #define ADC_CSR_EOSMP_SLV_Msk (0x1UL << ADC_CSR_EOSMP_SLV_Pos) /*!< 0x00020000 */ #define ADC_CSR_EOSMP_SLV ADC_CSR_EOSMP_SLV_Msk /*!< End of sampling phase flag of the slave ADC */ #define ADC_CSR_EOC_SLV_Pos (18U) #define ADC_CSR_EOC_SLV_Msk (0x1UL << ADC_CSR_EOC_SLV_Pos) /*!< 0x00040000 */ #define ADC_CSR_EOC_SLV ADC_CSR_EOC_SLV_Msk /*!< End of regular conversion of the slave ADC */ #define ADC_CSR_EOS_SLV_Pos (19U) #define ADC_CSR_EOS_SLV_Msk (0x1UL << ADC_CSR_EOS_SLV_Pos) /*!< 0x00080000 */ #define ADC_CSR_EOS_SLV ADC_CSR_EOS_SLV_Msk /*!< End of regular sequence flag of the slave ADC */ #define ADC_CSR_OVR_SLV_Pos (20U) #define ADC_CSR_OVR_SLV_Msk (0x1UL << ADC_CSR_OVR_SLV_Pos) /*!< 0x00100000 */ #define ADC_CSR_OVR_SLV ADC_CSR_OVR_SLV_Msk /*!< Overrun flag of the slave ADC */ #define ADC_CSR_JEOC_SLV_Pos (21U) #define ADC_CSR_JEOC_SLV_Msk (0x1UL << ADC_CSR_JEOC_SLV_Pos) /*!< 0x00200000 */ #define ADC_CSR_JEOC_SLV ADC_CSR_JEOC_SLV_Msk /*!< End of injected conversion of the slave ADC */ #define ADC_CSR_JEOS_SLV_Pos (22U) #define ADC_CSR_JEOS_SLV_Msk (0x1UL << ADC_CSR_JEOS_SLV_Pos) /*!< 0x00400000 */ #define ADC_CSR_JEOS_SLV ADC_CSR_JEOS_SLV_Msk /*!< End of injected sequence flag of the slave ADC */ #define ADC_CSR_AWD1_SLV_Pos (23U) #define ADC_CSR_AWD1_SLV_Msk (0x1UL << ADC_CSR_AWD1_SLV_Pos) /*!< 0x00800000 */ #define ADC_CSR_AWD1_SLV ADC_CSR_AWD1_SLV_Msk /*!< Analog watchdog 1 flag of the slave ADC */ #define ADC_CSR_AWD2_SLV_Pos (24U) #define ADC_CSR_AWD2_SLV_Msk (0x1UL << ADC_CSR_AWD2_SLV_Pos) /*!< 0x01000000 */ #define ADC_CSR_AWD2_SLV ADC_CSR_AWD2_SLV_Msk /*!< Analog watchdog 2 flag of the slave ADC */ #define ADC_CSR_AWD3_SLV_Pos (25U) #define ADC_CSR_AWD3_SLV_Msk (0x1UL << ADC_CSR_AWD3_SLV_Pos) /*!< 0x02000000 */ #define ADC_CSR_AWD3_SLV ADC_CSR_AWD3_SLV_Msk /*!< Analog watchdog 3 flag of the slave ADC */ #define ADC_CSR_JQOVF_SLV_Pos (26U) #define ADC_CSR_JQOVF_SLV_Msk (0x1UL << ADC_CSR_JQOVF_SLV_Pos) /*!< 0x04000000 */ #define ADC_CSR_JQOVF_SLV ADC_CSR_JQOVF_SLV_Msk /*!< Injected context queue overflow flag of the slave ADC */ /******************** Bit definition for ADC_CCR register ********************/ #define ADC_CCR_DUAL_Pos (0U) #define ADC_CCR_DUAL_Msk (0x1FUL << ADC_CCR_DUAL_Pos) /*!< 0x0000001F */ #define ADC_CCR_DUAL ADC_CCR_DUAL_Msk /*!< Dual ADC mode selection */ #define ADC_CCR_DUAL_0 (0x01UL << ADC_CCR_DUAL_Pos) /*!< 0x00000001 */ #define ADC_CCR_DUAL_1 (0x02UL << ADC_CCR_DUAL_Pos) /*!< 0x00000002 */ #define ADC_CCR_DUAL_2 (0x04UL << ADC_CCR_DUAL_Pos) /*!< 0x00000004 */ #define ADC_CCR_DUAL_3 (0x08UL << ADC_CCR_DUAL_Pos) /*!< 0x00000008 */ #define ADC_CCR_DUAL_4 (0x10UL << ADC_CCR_DUAL_Pos) /*!< 0x00000010 */ #define ADC_CCR_DELAY_Pos (8U) #define ADC_CCR_DELAY_Msk (0xFUL << ADC_CCR_DELAY_Pos) /*!< 0x00000F00 */ #define ADC_CCR_DELAY ADC_CCR_DELAY_Msk /*!< Delay between 2 sampling phases */ #define ADC_CCR_DELAY_0 (0x1UL << ADC_CCR_DELAY_Pos) /*!< 0x00000100 */ #define ADC_CCR_DELAY_1 (0x2UL << ADC_CCR_DELAY_Pos) /*!< 0x00000200 */ #define ADC_CCR_DELAY_2 (0x4UL << ADC_CCR_DELAY_Pos) /*!< 0x00000400 */ #define ADC_CCR_DELAY_3 (0x8UL << ADC_CCR_DELAY_Pos) /*!< 0x00000800 */ #define ADC_CCR_DAMDF_Pos (14U) #define ADC_CCR_DAMDF_Msk (0x3UL << ADC_CCR_DAMDF_Pos) /*!< 0x0000C000 */ #define ADC_CCR_DAMDF ADC_CCR_DAMDF_Msk /*!< Dual ADC mode Data format */ #define ADC_CCR_DAMDF_0 (0x1UL << ADC_CCR_DAMDF_Pos) /*!< 0x00004000 */ #define ADC_CCR_DAMDF_1 (0x2UL << ADC_CCR_DAMDF_Pos) /*!< 0x00008000 */ #define ADC_CCR_CKMODE_Pos (16U) #define ADC_CCR_CKMODE_Msk (0x3UL << ADC_CCR_CKMODE_Pos) /*!< 0x00030000 */ #define ADC_CCR_CKMODE ADC_CCR_CKMODE_Msk /*!< ADC clock mode */ #define ADC_CCR_CKMODE_0 (0x1UL << ADC_CCR_CKMODE_Pos) /*!< 0x00010000 */ #define ADC_CCR_CKMODE_1 (0x2UL << ADC_CCR_CKMODE_Pos) /*!< 0x00020000 */ #define ADC_CCR_PRESC_Pos (18U) #define ADC_CCR_PRESC_Msk (0xFUL << ADC_CCR_PRESC_Pos) /*!< 0x003C0000 */ #define ADC_CCR_PRESC ADC_CCR_PRESC_Msk /*!< ADC prescaler */ #define ADC_CCR_PRESC_0 (0x1UL << ADC_CCR_PRESC_Pos) /*!< 0x00040000 */ #define ADC_CCR_PRESC_1 (0x2UL << ADC_CCR_PRESC_Pos) /*!< 0x00080000 */ #define ADC_CCR_PRESC_2 (0x4UL << ADC_CCR_PRESC_Pos) /*!< 0x00100000 */ #define ADC_CCR_PRESC_3 (0x8UL << ADC_CCR_PRESC_Pos) /*!< 0x00200000 */ #define ADC_CCR_VREFEN_Pos (22U) #define ADC_CCR_VREFEN_Msk (0x1UL << ADC_CCR_VREFEN_Pos) /*!< 0x00400000 */ #define ADC_CCR_VREFEN ADC_CCR_VREFEN_Msk /*!< VREFINT enable */ #define ADC_CCR_TSEN_Pos (23U) #define ADC_CCR_TSEN_Msk (0x1UL << ADC_CCR_TSEN_Pos) /*!< 0x00800000 */ #define ADC_CCR_TSEN ADC_CCR_TSEN_Msk /*!< Temperature sensor enable */ #define ADC_CCR_VBATEN_Pos (24U) #define ADC_CCR_VBATEN_Msk (0x1UL << ADC_CCR_VBATEN_Pos) /*!< 0x01000000 */ #define ADC_CCR_VBATEN ADC_CCR_VBATEN_Msk /*!< VBAT enable */ /******************** Bit definition for ADC_CDR register *******************/ #define ADC_CDR_RDATA_MST_Pos (0U) #define ADC_CDR_RDATA_MST_Msk (0xFFFFUL << ADC_CDR_RDATA_MST_Pos) /*!< 0x0000FFFF */ #define ADC_CDR_RDATA_MST ADC_CDR_RDATA_MST_Msk /*!< ADC multimode master group regular conversion data */ #define ADC_CDR_RDATA_SLV_Pos (16U) #define ADC_CDR_RDATA_SLV_Msk (0xFFFFUL << ADC_CDR_RDATA_SLV_Pos) /*!< 0xFFFF0000 */ #define ADC_CDR_RDATA_SLV ADC_CDR_RDATA_SLV_Msk /*!< ADC multimode slave group regular conversion data */ /******************** Bit definition for ADC_CDR2 register ******************/ #define ADC_CDR2_RDATA_ALT_Pos (0U) #define ADC_CDR2_RDATA_ALT_Msk (0xFFFFFFFFUL << ADC_CDR2_RDATA_ALT_Pos) /*!< 0xFFFFFFFF */ #define ADC_CDR2_RDATA_ALT ADC_CDR2_RDATA_ALT_Msk /*!< Regular data of the master/slave alternated ADCs */ /******************************************************************************/ /* */ /* VREFBUF */ /* */ /******************************************************************************/ /******************* Bit definition for VREFBUF_CSR register ****************/ #define VREFBUF_CSR_ENVR_Pos (0U) #define VREFBUF_CSR_ENVR_Msk (0x1UL << VREFBUF_CSR_ENVR_Pos) /*!< 0x00000001 */ #define VREFBUF_CSR_ENVR VREFBUF_CSR_ENVR_Msk /*!*/ #define DAC_CR_CEN1_Pos (14U) #define DAC_CR_CEN1_Msk (0x1UL << DAC_CR_CEN1_Pos) /*!< 0x00004000 */ #define DAC_CR_CEN1 DAC_CR_CEN1_Msk /*!*/ #define DAC_CR_EN2_Pos (16U) #define DAC_CR_EN2_Msk (0x1UL << DAC_CR_EN2_Pos) /*!< 0x00010000 */ #define DAC_CR_EN2 DAC_CR_EN2_Msk /*!*/ #define DAC_CR_CEN2_Pos (30U) #define DAC_CR_CEN2_Msk (0x1UL << DAC_CR_CEN2_Pos) /*!< 0x40000000 */ #define DAC_CR_CEN2 DAC_CR_CEN2_Msk /*!*/ /***************** Bit definition for DAC_SWTRIGR register ******************/ #define DAC_SWTRIGR_SWTRIG1_Pos (0U) #define DAC_SWTRIGR_SWTRIG1_Msk (0x1UL << DAC_SWTRIGR_SWTRIG1_Pos) /*!< 0x00000001 */ #define DAC_SWTRIGR_SWTRIG1 DAC_SWTRIGR_SWTRIG1_Msk /*!
© Copyright (c) 2017 STMicroelectronics. * All rights reserved.
* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32h7xx * @{ */ #ifndef STM32H7xx_H #define STM32H7xx_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** @addtogroup Library_configuration_section * @{ */ /** * @brief STM32 Family */ #if !defined (STM32H7) #define STM32H7 #endif /* STM32H7 */ /* Uncomment the line below according to the target STM32H7 device used in your application */ /* #if !defined (STM32H743xx) && !defined (STM32H753xx) && !defined (STM32H750xx) && !defined (STM32H742xx) && \ !defined (STM32H745xx) && !defined (STM32H755xx) && !defined (STM32H747xx) && !defined (STM32H757xx) && \ !defined (STM32H7A3xx) && !defined (STM32H7A3xxQ) && !defined (STM32H7B3xx) && !defined (STM32H7B3xxQ) && !defined (STM32H7B0xx) && !defined (STM32H7B0xxQ) && \ !defined (STM32H735xx) && !defined (STM32H733xx) && !defined (STM32H730xx) && !defined (STM32H730xxQ) && !defined (STM32H725xx) && !defined (STM32H723xx) */ /* #define STM32H742xx */ /*!< STM32H742VI, STM32H742ZI, STM32H742AI, STM32H742II, STM32H742BI, STM32H742XI Devices */ /* #define STM32H743xx */ /*!< STM32H743VI, STM32H743ZI, STM32H743AI, STM32H743II, STM32H743BI, STM32H743XI Devices */ /* #define STM32H753xx */ /*!< STM32H753VI, STM32H753ZI, STM32H753AI, STM32H753II, STM32H753BI, STM32H753XI Devices */ /* #define STM32H750xx */ /*!< STM32H750V, STM32H750I, STM32H750X Devices */ /* #define STM32H747xx */ /*!< STM32H747ZI, STM32H747AI, STM32H747II, STM32H747BI, STM32H747XI Devices */ /* #define STM32H757xx */ /*!< STM32H757ZI, STM32H757AI, STM32H757II, STM32H757BI, STM32H757XI Devices */ /* #define STM32H745xx */ /*!< STM32H745ZI, STM32H745II, STM32H745BI, STM32H745XI Devices */ /* #define STM32H755xx */ /*!< STM32H755ZI, STM32H755II, STM32H755BI, STM32H755XI Devices */ /* #define STM32H7B0xx */ /*!< STM32H7B0ABIxQ, STM32H7B0IBTx, STM32H7B0RBTx, STM32H7B0VBTx, STM32H7B0ZBTx, STM32H7B0IBKxQ */ /* #define STM32H7A3xx */ /*!< STM32H7A3IIK6, STM32H7A3IIT6, STM32H7A3NIH6, STM32H7A3RIT6, STM32H7A3VIH6, STM32H7A3VIT6, STM32H7A3ZIT6 */ /* #define STM32H7A3xxQ */ /*!< STM32H7A3QIY6Q, STM32H7A3IIK6Q, STM32H7A3IIT6Q, STM32H7A3LIH6Q, STM32H7A3VIH6Q, STM32H7A3VIT6Q, STM32H7A3AII6Q, STM32H7A3ZIT6Q */ /* #define STM32H7B3xx */ /*!< STM32H7B3IIK6, STM32H7B3IIT6, STM32H7B3NIH6, STM32H7B3RIT6, STM32H7B3VIH6, STM32H7B3VIT6, STM32H7B3ZIT6 */ /* #define STM32H7B3xxQ */ /*!< STM32H7B3QIY6Q, STM32H7B3IIK6Q, STM32H7B3IIT6Q, STM32H7B3LIH6Q, STM32H7B3VIH6Q, STM32H7B3VIT6Q, STM32H7B3AII6Q, STM32H7B3ZIT6Q */ /* #define STM32H735xx */ /*!< STM32H735AGI6, STM32H735IGK6, STM32H735RGV6, STM32H735VGT6, STM32H735VGY6, STM32H735ZGT6 Devices */ /* #define STM32H733xx */ /*!< STM32H733VGH6, STM32H733VGT6, STM32H733ZGI6, STM32H733ZGT6, Devices */ /* #define STM32H730xx */ /*!< STM32H730VBH6, STM32H730VBT6, STM32H730ZBT6, STM32H730ZBI6 Devices */ /* #define STM32H730xxQ */ /*!< STM32H730IBT6Q, STM32H730ABI6Q, STM32H730IBK6Q Devices */ /* #define STM32H725xx */ /*!< STM32H725AGI6, STM32H725IGK6, STM32H725IGT6, STM32H725RGV6, STM32H725VGT6, STM32H725VGY6, STM32H725ZGT6, STM32H725REV6, SM32H725VET6, STM32H725ZET6, STM32H725AEI6, STM32H725IET6, STM32H725IEK6 Devices */ /* #define STM32H723xx */ /*!< STM32H723VGH6, STM32H723VGT6, STM32H723ZGI6, STM32H723ZGT6, STM32H723VET6, STM32H723VEH6, STM32H723ZET6, STM32H723ZEI6 Devices */ /* #endif */ /* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. */ #if defined(DUAL_CORE) && !defined(CORE_CM4) && !defined(CORE_CM7) #error "Dual core device, please select CORE_CM4 or CORE_CM7" #endif #if !defined (USE_HAL_DRIVER) /** * @brief Comment the line below if you will not use the peripherals drivers. In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ /*#define USE_HAL_DRIVER */ #endif /* USE_HAL_DRIVER */ /** * @brief CMSIS Device version number V1.10.0 */ #define __STM32H7xx_CMSIS_DEVICE_VERSION_MAIN (0x01) /*!< [31:24] main version */ #define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 (0x0A) /*!< [23:16] sub1 version */ #define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */ #define __STM32H7xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */ #define __STM32H7xx_CMSIS_DEVICE_VERSION ((__STM32H7xx_CMSIS_DEVICE_VERSION_MAIN << 24)\ |(__STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 << 16)\ |(__STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 << 8 )\ |(__STM32H7xx_CMSIS_DEVICE_VERSION_RC)) /** * @} */ /** @addtogroup Device_Included * @{ */ #if defined(STM32H743xx) #include "stm32h743xx.h" // #elif defined(STM32H753xx) // #include "stm32h753xx.h" // #elif defined(STM32H750xx) // #include "stm32h750xx.h" // #elif defined(STM32H742xx) // #include "stm32h742xx.h" // #elif defined(STM32H745xx) // #include "stm32h745xx.h" // #elif defined(STM32H755xx) // #include "stm32h755xx.h" // #elif defined(STM32H747xx) // #include "stm32h747xx.h" // #elif defined(STM32H757xx) // #include "stm32h757xx.h" // #elif defined(STM32H7B0xx) // #include "stm32h7b0xx.h" // #elif defined(STM32H7B0xxQ) // #include "stm32h7b0xxq.h" // #elif defined(STM32H7A3xx) // #include "stm32h7a3xx.h" // #elif defined(STM32H7B3xx) // #include "stm32h7b3xx.h" // #elif defined(STM32H7A3xxQ) // #include "stm32h7a3xxq.h" // #elif defined(STM32H7B3xxQ) // #include "stm32h7b3xxq.h" #elif defined(STM32H735xx) #include "stm32h735xx.h" // #elif defined(STM32H733xx) // #include "stm32h733xx.h" // #elif defined(STM32H730xx) // #include "stm32h730xx.h" // #elif defined(STM32H730xxQ) // #include "stm32h730xxq.h" #elif defined(STM32H725xx) #include "stm32h725xx.h" // #elif defined(STM32H723xx) // #include "stm32h723xx.h" #else #error "Please select first the target STM32H7xx device used in your application (in stm32h7xx.h file)" #endif /** * @} */ /** @addtogroup Exported_types * @{ */ typedef enum { RESET = 0, SET = !RESET } FlagStatus, ITStatus; typedef enum { DISABLE = 0, ENABLE = !DISABLE } FunctionalState; #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) typedef enum { SUCCESS = 0, ERROR = !SUCCESS } ErrorStatus; /** * @} */ /** @addtogroup Exported_macros * @{ */ #define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) #define READ_BIT(REG, BIT) ((REG) & (BIT)) #define CLEAR_REG(REG) ((REG) = (0x0)) #define WRITE_REG(REG, VAL) ((REG) = (VAL)) #define READ_REG(REG) ((REG)) #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) /** * @} */ #if defined (USE_HAL_DRIVER) #include "stm32h7xx_hal.h" #endif /* USE_HAL_DRIVER */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* STM32H7xx_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32h7/inc/stm32h7xx_hal_def.h ================================================ /** ****************************************************************************** * @file stm32h7xx_hal_def.h * @author MCD Application Team * @brief This file contains HAL common defines, enumeration, macros and * structures definitions. ****************************************************************************** * @attention * *

© Copyright (c) 2017 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32H7xx_HAL_DEF #define STM32H7xx_HAL_DEF #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32h7xx.h" //#include "Legacy/stm32_hal_legacy.h" //#include //#include /* Exported types ------------------------------------------------------------*/ /** * @brief HAL Status structures definition */ typedef enum { HAL_OK = 0x00, HAL_ERROR = 0x01, HAL_BUSY = 0x02, HAL_TIMEOUT = 0x03 } HAL_StatusTypeDef; /** * @brief HAL Lock structures definition */ typedef enum { HAL_UNLOCKED = 0x00, HAL_LOCKED = 0x01 } HAL_LockTypeDef; /* Exported macro ------------------------------------------------------------*/ #define HAL_MAX_DELAY 0xFFFFFFFFU #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ do{ \ (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ (__DMA_HANDLE__).Parent = (__HANDLE__); \ } while(0) #define UNUSED(x) ((void)(x)) /** @brief Reset the Handle's State field. * @param __HANDLE__: specifies the Peripheral Handle. * @note This macro can be used for the following purpose: * - When the Handle is declared as local variable; before passing it as parameter * to HAL_PPP_Init() for the first time, it is mandatory to use this macro * to set to 0 the Handle's "State" field. * Otherwise, "State" field may have any random value and the first time the function * HAL_PPP_Init() is called, the low level hardware initialization will be missed * (i.e. HAL_PPP_MspInit() will not be executed). * - When there is a need to reconfigure the low level hardware: instead of calling * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). * In this later function, when the Handle's "State" field is set to 0, it will execute the function * HAL_PPP_MspInit() which will reconfigure the low level hardware. * @retval None */ #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) #if (USE_RTOS == 1) #error " USE_RTOS should be 0 in the current HAL release " #else #define __HAL_LOCK(__HANDLE__) \ do{ \ if((__HANDLE__)->Lock == HAL_LOCKED) \ { \ return HAL_BUSY; \ } \ else \ { \ (__HANDLE__)->Lock = HAL_LOCKED; \ } \ }while (0) #define __HAL_UNLOCK(__HANDLE__) \ do{ \ (__HANDLE__)->Lock = HAL_UNLOCKED; \ }while (0) #endif /* USE_RTOS */ #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ #ifndef __weak #define __weak __attribute__((weak)) #endif #ifndef __packed #define __packed __attribute__((packed)) #endif #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ #ifndef __weak #define __weak __attribute__((weak)) #endif /* __weak */ #ifndef __packed #define __packed __attribute__((__packed__)) #endif /* __packed */ #endif /* __GNUC__ */ /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ #ifndef __ALIGN_BEGIN #define __ALIGN_BEGIN #endif #ifndef __ALIGN_END #define __ALIGN_END __attribute__ ((aligned (4))) #endif #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ #ifndef __ALIGN_END #define __ALIGN_END __attribute__ ((aligned (4))) #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #define __ALIGN_BEGIN #endif /* __ALIGN_BEGIN */ #else #ifndef __ALIGN_END #define __ALIGN_END #endif /* __ALIGN_END */ #ifndef __ALIGN_BEGIN #if defined (__CC_ARM) /* ARM Compiler V5 */ #define __ALIGN_BEGIN __align(4) #elif defined (__ICCARM__) /* IAR Compiler */ #define __ALIGN_BEGIN #endif /* __CC_ARM */ #endif /* __ALIGN_BEGIN */ #endif /* __GNUC__ */ /* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */ #if defined (__GNUC__) /* GNU Compiler */ #define ALIGN_32BYTES(buf) buf __attribute__ ((aligned (32))) #elif defined (__ICCARM__) /* IAR Compiler */ #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf #elif defined (__CC_ARM) /* ARM Compiler */ #define ALIGN_32BYTES(buf) __align(32) buf #endif /** * @brief __RAM_FUNC definition */ #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) /* ARM Compiler V4/V5 and V6 -------------------------- RAM functions are defined using the toolchain options. Functions that are executed in RAM should reside in a separate source module. Using the 'Options for File' dialog you can simply change the 'Code / Const' area of a module to a memory space in physical RAM. Available memory areas are declared in the 'Target' tab of the 'Options for Target' dialog. */ #define __RAM_FUNC #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- RAM functions are defined using a specific toolchain keyword "__ramfunc". */ #define __RAM_FUNC __ramfunc #elif defined ( __GNUC__ ) /* GNU Compiler ------------ RAM functions are defined using a specific toolchain attribute "__attribute__((section(".RamFunc")))". */ #define __RAM_FUNC __attribute__((section(".RamFunc"))) #endif /** * @brief __NOINLINE definition */ #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) /* ARM V4/V5 and V6 & GNU Compiler ------------------------------- */ #define __NOINLINE __attribute__ ( (noinline) ) #elif defined ( __ICCARM__ ) /* ICCARM Compiler --------------- */ #define __NOINLINE _Pragma("optimize = no_inline") #endif #ifdef __cplusplus } #endif #endif /* STM32H7xx_HAL_DEF */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32h7/inc/stm32h7xx_hal_gpio_ex.h ================================================ /** ****************************************************************************** * @file stm32h7xx_hal_gpio_ex.h * @author MCD Application Team * @brief Header file of GPIO HAL Extension module. ****************************************************************************** * @attention * *

© COPYRIGHT(c) 2017 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef STM32H7xx_HAL_GPIO_EX_H #define STM32H7xx_HAL_GPIO_EX_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32h7xx_hal_def.h" /** @addtogroup STM32H7xx_HAL_Driver * @{ */ /** @addtogroup GPIOEx GPIOEx * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Constants GPIO Exported Constants * @{ */ /** @defgroup GPIO_Alternate_function_selection GPIO Alternate Function Selection * @{ */ /** * @brief AF 0 selection */ #define GPIO_AF0_RTC_50Hz ((uint8_t)0x00) /* RTC_50Hz Alternate Function mapping */ #define GPIO_AF0_MCO ((uint8_t)0x00) /* MCO (MCO1 and MCO2) Alternate Function mapping */ #define GPIO_AF0_SWJ ((uint8_t)0x00) /* SWJ (SWD and JTAG) Alternate Function mapping */ #define GPIO_AF0_LCDBIAS ((uint8_t)0x00) /* LCDBIAS Alternate Function mapping */ #define GPIO_AF0_TRACE ((uint8_t)0x00) /* TRACE Alternate Function mapping */ #if defined (PWR_CPUCR_PDDS_D2) /* PWR D1 and D2 domains exists */ #define GPIO_AF0_C1DSLEEP ((uint8_t)0x00) /* Cortex-M7 Deep Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ #define GPIO_AF0_C1SLEEP ((uint8_t)0x00) /* Cortex-M7 Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ #define GPIO_AF0_D1PWREN ((uint8_t)0x00) /* Domain 1 PWR enable Alternate Function mapping : available on STM32H7 Rev.B and above */ #define GPIO_AF0_D2PWREN ((uint8_t)0x00) /* Domain 2 PWR enable Alternate Function mapping : available on STM32H7 Rev.B and above */ #if defined(DUAL_CORE) #define GPIO_AF0_C2DSLEEP ((uint8_t)0x00) /* Cortex-M4 Deep Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ #define GPIO_AF0_C2SLEEP ((uint8_t)0x00) /* Cortex-M4 Sleep Alternate Function mapping : available on STM32H7 Rev.B and above */ #endif /* DUAL_CORE */ #endif /* PWR_CPUCR_PDDS_D2 */ /** * @brief AF 1 selection */ #define GPIO_AF1_TIM1 ((uint8_t)0x01) /* TIM1 Alternate Function mapping */ #define GPIO_AF1_TIM2 ((uint8_t)0x01) /* TIM2 Alternate Function mapping */ #define GPIO_AF1_TIM16 ((uint8_t)0x01) /* TIM16 Alternate Function mapping */ #define GPIO_AF1_TIM17 ((uint8_t)0x01) /* TIM17 Alternate Function mapping */ #define GPIO_AF1_LPTIM1 ((uint8_t)0x01) /* LPTIM1 Alternate Function mapping */ #if defined(HRTIM1) #define GPIO_AF1_HRTIM1 ((uint8_t)0x01) /* HRTIM1 Alternate Function mapping */ #endif /* HRTIM1 */ #if defined(SAI4) #define GPIO_AF1_SAI4 ((uint8_t)0x01) /* SAI4 Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ #endif /* SAI4 */ #define GPIO_AF1_FMC ((uint8_t)0x01) /* FMC Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ /** * @brief AF 2 selection */ #define GPIO_AF2_TIM3 ((uint8_t)0x02) /* TIM3 Alternate Function mapping */ #define GPIO_AF2_TIM4 ((uint8_t)0x02) /* TIM4 Alternate Function mapping */ #define GPIO_AF2_TIM5 ((uint8_t)0x02) /* TIM5 Alternate Function mapping */ #define GPIO_AF2_TIM12 ((uint8_t)0x02) /* TIM12 Alternate Function mapping */ #define GPIO_AF2_SAI1 ((uint8_t)0x02) /* SAI1 Alternate Function mapping */ #if defined(HRTIM1) #define GPIO_AF2_HRTIM1 ((uint8_t)0x02) /* HRTIM1 Alternate Function mapping */ #endif /* HRTIM1 */ #define GPIO_AF2_TIM15 ((uint8_t)0x02) /* TIM15 Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ #if defined(FDCAN3) #define GPIO_AF2_FDCAN3 ((uint8_t)0x02) /* FDCAN3 Alternate Function mapping */ #endif /*FDCAN3*/ /** * @brief AF 3 selection */ #define GPIO_AF3_TIM8 ((uint8_t)0x03) /* TIM8 Alternate Function mapping */ #define GPIO_AF3_LPTIM2 ((uint8_t)0x03) /* LPTIM2 Alternate Function mapping */ #define GPIO_AF3_DFSDM1 ((uint8_t)0x03) /* DFSDM Alternate Function mapping */ #define GPIO_AF3_LPTIM3 ((uint8_t)0x03) /* LPTIM3 Alternate Function mapping */ #define GPIO_AF3_LPTIM4 ((uint8_t)0x03) /* LPTIM4 Alternate Function mapping */ #define GPIO_AF3_LPTIM5 ((uint8_t)0x03) /* LPTIM5 Alternate Function mapping */ #define GPIO_AF3_LPUART ((uint8_t)0x03) /* LPUART Alternate Function mapping */ #if defined(OCTOSPIM) #define GPIO_AF3_OCTOSPIM_P1 ((uint8_t)0x03) /* OCTOSPI Manager Port 1 Alternate Function mapping */ #define GPIO_AF3_OCTOSPIM_P2 ((uint8_t)0x03) /* OCTOSPI Manager Port 2 Alternate Function mapping */ #endif /* OCTOSPIM */ #if defined(HRTIM1) #define GPIO_AF3_HRTIM1 ((uint8_t)0x03) /* HRTIM1 Alternate Function mapping */ #endif /* HRTIM1 */ #define GPIO_AF3_LTDC ((uint8_t)0x03) /* LTDC Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ /** * @brief AF 4 selection */ #define GPIO_AF4_I2C1 ((uint8_t)0x04) /* I2C1 Alternate Function mapping */ #define GPIO_AF4_I2C2 ((uint8_t)0x04) /* I2C2 Alternate Function mapping */ #define GPIO_AF4_I2C3 ((uint8_t)0x04) /* I2C3 Alternate Function mapping */ #define GPIO_AF4_I2C4 ((uint8_t)0x04) /* I2C4 Alternate Function mapping */ #if defined(I2C5) #define GPIO_AF4_I2C5 ((uint8_t)0x04) /* I2C5 Alternate Function mapping */ #endif /* I2C5*/ #define GPIO_AF4_TIM15 ((uint8_t)0x04) /* TIM15 Alternate Function mapping */ #define GPIO_AF4_CEC ((uint8_t)0x04) /* CEC Alternate Function mapping */ #define GPIO_AF4_LPTIM2 ((uint8_t)0x04) /* LPTIM2 Alternate Function mapping */ #define GPIO_AF4_USART1 ((uint8_t)0x04) /* USART1 Alternate Function mapping */ #if defined(USART10) #define GPIO_AF4_USART10 ((uint8_t)0x04) /* USART10 Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ #endif /*USART10*/ #define GPIO_AF4_DFSDM1 ((uint8_t)0x04) /* DFSDM Alternate Function mapping */ #if defined(DFSDM2_BASE) #define GPIO_AF4_DFSDM2 ((uint8_t)0x04) /* DFSDM2 Alternate Function mapping */ #endif /* DFSDM2_BASE */ #define GPIO_AF4_DCMI ((uint8_t)0x04) /* DCMI Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ #if defined(PSSI) #define GPIO_AF4_PSSI ((uint8_t)0x04) /* PSSI Alternate Function mapping */ #endif /* PSSI */ #if defined(OCTOSPIM) #define GPIO_AF4_OCTOSPIM_P1 ((uint8_t)0x04) /* OCTOSPI Manager Port 1 Alternate Function mapping : available on STM32H72xxx/STM32H73xxx */ #endif /* OCTOSPIM */ /** * @brief AF 5 selection */ #define GPIO_AF5_SPI1 ((uint8_t)0x05) /* SPI1 Alternate Function mapping */ #define GPIO_AF5_SPI2 ((uint8_t)0x05) /* SPI2 Alternate Function mapping */ #define GPIO_AF5_SPI3 ((uint8_t)0x05) /* SPI3 Alternate Function mapping */ #define GPIO_AF5_SPI4 ((uint8_t)0x05) /* SPI4 Alternate Function mapping */ #define GPIO_AF5_SPI5 ((uint8_t)0x05) /* SPI5 Alternate Function mapping */ #define GPIO_AF5_SPI6 ((uint8_t)0x05) /* SPI6 Alternate Function mapping */ #define GPIO_AF5_CEC ((uint8_t)0x05) /* CEC Alternate Function mapping */ #if defined(FDCAN3) #define GPIO_AF5_FDCAN3 ((uint8_t)0x05) /* FDCAN3 Alternate Function mapping */ #endif /*FDCAN3*/ /** * @brief AF 6 selection */ #define GPIO_AF6_SPI2 ((uint8_t)0x06) /* SPI2 Alternate Function mapping */ #define GPIO_AF6_SPI3 ((uint8_t)0x06) /* SPI3 Alternate Function mapping */ #define GPIO_AF6_SAI1 ((uint8_t)0x06) /* SAI1 Alternate Function mapping */ #define GPIO_AF6_I2C4 ((uint8_t)0x06) /* I2C4 Alternate Function mapping */ #if defined(I2C5) #define GPIO_AF6_I2C5 ((uint8_t)0x06) /* I2C5 Alternate Function mapping */ #endif /* I2C5*/ #define GPIO_AF6_DFSDM1 ((uint8_t)0x06) /* DFSDM Alternate Function mapping */ #define GPIO_AF6_UART4 ((uint8_t)0x06) /* UART4 Alternate Function mapping */ #if defined(DFSDM2_BASE) #define GPIO_AF6_DFSDM2 ((uint8_t)0x06) /* DFSDM2 Alternate Function mapping */ #endif /* DFSDM2_BASE */ #if defined(SAI3) #define GPIO_AF6_SAI3 ((uint8_t)0x06) /* SAI3 Alternate Function mapping */ #endif /* SAI3 */ #if defined(OCTOSPIM) #define GPIO_AF6_OCTOSPIM_P1 ((uint8_t)0x06) /* OCTOSPI Manager Port 1 Alternate Function mapping */ #endif /* OCTOSPIM */ /** * @brief AF 7 selection */ #define GPIO_AF7_SPI2 ((uint8_t)0x07) /* SPI2 Alternate Function mapping */ #define GPIO_AF7_SPI3 ((uint8_t)0x07) /* SPI3 Alternate Function mapping */ #define GPIO_AF7_SPI6 ((uint8_t)0x07) /* SPI6 Alternate Function mapping */ #define GPIO_AF7_USART1 ((uint8_t)0x07) /* USART1 Alternate Function mapping */ #define GPIO_AF7_USART2 ((uint8_t)0x07) /* USART2 Alternate Function mapping */ #define GPIO_AF7_USART3 ((uint8_t)0x07) /* USART3 Alternate Function mapping */ #define GPIO_AF7_USART6 ((uint8_t)0x07) /* USART6 Alternate Function mapping */ #define GPIO_AF7_UART7 ((uint8_t)0x07) /* UART7 Alternate Function mapping */ #define GPIO_AF7_SDMMC1 ((uint8_t)0x07) /* SDMMC1 Alternate Function mapping */ /** * @brief AF 8 selection */ #define GPIO_AF8_SPI6 ((uint8_t)0x08) /* SPI6 Alternate Function mapping */ #if defined(SAI2) #define GPIO_AF8_SAI2 ((uint8_t)0x08) /* SAI2 Alternate Function mapping */ #endif /*SAI2*/ #define GPIO_AF8_UART4 ((uint8_t)0x08) /* UART4 Alternate Function mapping */ #define GPIO_AF8_UART5 ((uint8_t)0x08) /* UART5 Alternate Function mapping */ #define GPIO_AF8_UART8 ((uint8_t)0x08) /* UART8 Alternate Function mapping */ #define GPIO_AF8_SPDIF ((uint8_t)0x08) /* SPDIF Alternate Function mapping */ #define GPIO_AF8_LPUART ((uint8_t)0x08) /* LPUART Alternate Function mapping */ #define GPIO_AF8_SDMMC1 ((uint8_t)0x08) /* SDMMC1 Alternate Function mapping */ #if defined(SAI4) #define GPIO_AF8_SAI4 ((uint8_t)0x08) /* SAI4 Alternate Function mapping */ #endif /* SAI4 */ /** * @brief AF 9 selection */ #define GPIO_AF9_FDCAN1 ((uint8_t)0x09) /* FDCAN1 Alternate Function mapping */ #define GPIO_AF9_FDCAN2 ((uint8_t)0x09) /* FDCAN2 Alternate Function mapping */ #define GPIO_AF9_TIM13 ((uint8_t)0x09) /* TIM13 Alternate Function mapping */ #define GPIO_AF9_TIM14 ((uint8_t)0x09) /* TIM14 Alternate Function mapping */ #define GPIO_AF9_SDMMC2 ((uint8_t)0x09) /* SDMMC2 Alternate Function mapping */ #define GPIO_AF9_LTDC ((uint8_t)0x09) /* LTDC Alternate Function mapping */ #define GPIO_AF9_SPDIF ((uint8_t)0x09) /* SPDIF Alternate Function mapping */ #define GPIO_AF9_FMC ((uint8_t)0x09) /* FMC Alternate Function mapping */ #if defined(QUADSPI) #define GPIO_AF9_QUADSPI ((uint8_t)0x09) /* QUADSPI Alternate Function mapping */ #endif /* QUADSPI */ #if defined(SAI4) #define GPIO_AF9_SAI4 ((uint8_t)0x09) /* SAI4 Alternate Function mapping */ #endif /* SAI4 */ #if defined(OCTOSPIM) #define GPIO_AF9_OCTOSPIM_P1 ((uint8_t)0x09) /* OCTOSPI Manager Port 1 Alternate Function mapping */ #define GPIO_AF9_OCTOSPIM_P2 ((uint8_t)0x09) /* OCTOSPI Manager Port 2 Alternate Function mapping */ #endif /* OCTOSPIM */ /** * @brief AF 10 selection */ #if defined(SAI2) #define GPIO_AF10_SAI2 ((uint8_t)0x0A) /* SAI2 Alternate Function mapping */ #endif /*SAI2*/ #define GPIO_AF10_SDMMC2 ((uint8_t)0x0A) /* SDMMC2 Alternate Function mapping */ #if defined(USB2_OTG_FS) #define GPIO_AF10_OTG2_FS ((uint8_t)0x0A) /* OTG2_FS Alternate Function mapping */ #endif /*USB2_OTG_FS*/ #define GPIO_AF10_COMP1 ((uint8_t)0x0A) /* COMP1 Alternate Function mapping */ #define GPIO_AF10_COMP2 ((uint8_t)0x0A) /* COMP2 Alternate Function mapping */ #if defined(LTDC) #define GPIO_AF10_LTDC ((uint8_t)0x0A) /* LTDC Alternate Function mapping */ #endif /*LTDC*/ #define GPIO_AF10_CRS_SYNC ((uint8_t)0x0A) /* CRS Sync Alternate Function mapping : available on STM32H7 Rev.B and above */ #if defined(QUADSPI) #define GPIO_AF10_QUADSPI ((uint8_t)0x0A) /* QUADSPI Alternate Function mapping */ #endif /* QUADSPI */ #if defined(SAI4) #define GPIO_AF10_SAI4 ((uint8_t)0x0A) /* SAI4 Alternate Function mapping */ #endif /* SAI4 */ #if !defined(USB2_OTG_FS) #define GPIO_AF10_OTG1_FS ((uint8_t)0x0A) /* OTG1_FS Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ #endif /* !USB2_OTG_FS */ #define GPIO_AF10_OTG1_HS ((uint8_t)0x0A) /* OTG1_HS Alternate Function mapping */ #if defined(OCTOSPIM) #define GPIO_AF10_OCTOSPIM_P1 ((uint8_t)0x0A) /* OCTOSPI Manager Port 1 Alternate Function mapping */ #endif /* OCTOSPIM */ #define GPIO_AF10_TIM8 ((uint8_t)0x0A) /* TIM8 Alternate Function mapping */ #define GPIO_AF10_FMC ((uint8_t)0x0A) /* FMC Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ /** * @brief AF 11 selection */ #define GPIO_AF11_SWP ((uint8_t)0x0B) /* SWP Alternate Function mapping */ #define GPIO_AF11_MDIOS ((uint8_t)0x0B) /* MDIOS Alternate Function mapping */ #define GPIO_AF11_UART7 ((uint8_t)0x0B) /* UART7 Alternate Function mapping */ #define GPIO_AF11_SDMMC2 ((uint8_t)0x0B) /* SDMMC2 Alternate Function mapping */ #define GPIO_AF11_DFSDM1 ((uint8_t)0x0B) /* DFSDM1 Alternate Function mapping */ #define GPIO_AF11_COMP1 ((uint8_t)0x0B) /* COMP1 Alternate Function mapping */ #define GPIO_AF11_COMP2 ((uint8_t)0x0B) /* COMP2 Alternate Function mapping */ #define GPIO_AF11_TIM1 ((uint8_t)0x0B) /* TIM1 Alternate Function mapping */ #define GPIO_AF11_TIM8 ((uint8_t)0x0B) /* TIM8 Alternate Function mapping */ #define GPIO_AF11_I2C4 ((uint8_t)0x0B) /* I2C4 Alternate Function mapping */ #if defined(DFSDM2_BASE) #define GPIO_AF11_DFSDM2 ((uint8_t)0x0B) /* DFSDM2 Alternate Function mapping */ #endif /* DFSDM2_BASE */ #if defined(USART10) #define GPIO_AF11_USART10 ((uint8_t)0x0B) /* USART10 Alternate Function mapping */ #endif /* USART10 */ #if defined(UART9) #define GPIO_AF11_UART9 ((uint8_t)0x0B) /* UART9 Alternate Function mapping */ #endif /* UART9 */ #if defined(ETH) #define GPIO_AF11_ETH ((uint8_t)0x0B) /* ETH Alternate Function mapping */ #endif /* ETH */ #if defined(LTDC) #define GPIO_AF11_LTDC ((uint8_t)0x0B) /* LTDC Alternate Function mapping : available on STM32H7A3xxx/STM32H7B3xxx/STM32H7B0xxx and STM32H72xxx/STM32H73xxx */ #endif /*LTDC*/ #if defined(OCTOSPIM) #define GPIO_AF11_OCTOSPIM_P1 ((uint8_t)0x0B) /* OCTOSPI Manager Port 1 Alternate Function mapping */ #endif /* OCTOSPIM */ /** * @brief AF 12 selection */ #define GPIO_AF12_FMC ((uint8_t)0x0C) /* FMC Alternate Function mapping */ #define GPIO_AF12_SDMMC1 ((uint8_t)0x0C) /* SDMMC1 Alternate Function mapping */ #define GPIO_AF12_MDIOS ((uint8_t)0x0C) /* MDIOS Alternate Function mapping */ #define GPIO_AF12_COMP1 ((uint8_t)0x0C) /* COMP1 Alternate Function mapping */ #define GPIO_AF12_COMP2 ((uint8_t)0x0C) /* COMP2 Alternate Function mapping */ #define GPIO_AF12_TIM1 ((uint8_t)0x0C) /* TIM1 Alternate Function mapping */ #define GPIO_AF12_TIM8 ((uint8_t)0x0C) /* TIM8 Alternate Function mapping */ #if defined(LTDC) #define GPIO_AF12_LTDC ((uint8_t)0x0C) /* LTDC Alternate Function mapping */ #endif /*LTDC*/ #if defined(USB2_OTG_FS) #define GPIO_AF12_OTG1_FS ((uint8_t)0x0C) /* OTG1_FS Alternate Function mapping */ #endif /* USB2_OTG_FS */ #if defined(OCTOSPIM) #define GPIO_AF12_OCTOSPIM_P1 ((uint8_t)0x0C) /* OCTOSPI Manager Port 1 Alternate Function mapping */ #endif /* OCTOSPIM */ /** * @brief AF 13 selection */ #define GPIO_AF13_DCMI ((uint8_t)0x0D) /* DCMI Alternate Function mapping */ #define GPIO_AF13_COMP1 ((uint8_t)0x0D) /* COMP1 Alternate Function mapping */ #define GPIO_AF13_COMP2 ((uint8_t)0x0D) /* COMP2 Alternate Function mapping */ #if defined(LTDC) #define GPIO_AF13_LTDC ((uint8_t)0x0D) /* LTDC Alternate Function mapping */ #endif /*LTDC*/ #if defined(DSI) #define GPIO_AF13_DSI ((uint8_t)0x0D) /* DSI Alternate Function mapping */ #endif /* DSI */ #if defined(PSSI) #define GPIO_AF13_PSSI ((uint8_t)0x0D) /* PSSI Alternate Function mapping */ #endif /* PSSI */ #define GPIO_AF13_TIM1 ((uint8_t)0x0D) /* TIM1 Alternate Function mapping */ #if defined(TIM23) #define GPIO_AF13_TIM23 ((uint8_t)0x0D) /* TIM23 Alternate Function mapping */ #endif /*TIM23*/ /** * @brief AF 14 selection */ #define GPIO_AF14_LTDC ((uint8_t)0x0E) /* LTDC Alternate Function mapping */ #define GPIO_AF14_UART5 ((uint8_t)0x0E) /* UART5 Alternate Function mapping */ #if defined(TIM24) #define GPIO_AF14_TIM24 ((uint8_t)0x0E) /* TIM24 Alternate Function mapping */ #endif /*TIM24*/ /** * @brief AF 15 selection */ #define GPIO_AF15_EVENTOUT ((uint8_t)0x0F) /* EVENTOUT Alternate Function mapping */ #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0F) /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Macros GPIO Exported Macros * @{ */ /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @defgroup GPIOEx_Exported_Functions GPIO Exported Functions * @{ */ /** * @} */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Constants GPIO Private Constants * @{ */ /** * @brief GPIO pin available on the platform */ /* Defines the available pins per GPIOs */ #define GPIOA_PIN_AVAILABLE GPIO_PIN_All #define GPIOB_PIN_AVAILABLE GPIO_PIN_All #define GPIOC_PIN_AVAILABLE GPIO_PIN_All #define GPIOD_PIN_AVAILABLE GPIO_PIN_All #define GPIOE_PIN_AVAILABLE GPIO_PIN_All #define GPIOF_PIN_AVAILABLE GPIO_PIN_All #define GPIOG_PIN_AVAILABLE GPIO_PIN_All #if defined(GPIOI) #define GPIOI_PIN_AVAILABLE GPIO_PIN_All #endif /*GPIOI*/ #if defined(GPIOI) #define GPIOJ_PIN_AVAILABLE GPIO_PIN_All #else #define GPIOJ_PIN_AVAILABLE (GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 ) #endif /* GPIOI */ #define GPIOH_PIN_AVAILABLE GPIO_PIN_All #if defined(GPIOI) #define GPIOK_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | \ GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7) #else #define GPIOK_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 ) #endif /* GPIOI */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Macros GPIO Private Macros * @{ */ /** @defgroup GPIOEx_Get_Port_Index GPIO Get Port Index * @{ */ #if defined(GPIOI) #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ ((__GPIOx__) == (GPIOB))? 1UL :\ ((__GPIOx__) == (GPIOC))? 2UL :\ ((__GPIOx__) == (GPIOD))? 3UL :\ ((__GPIOx__) == (GPIOE))? 4UL :\ ((__GPIOx__) == (GPIOF))? 5UL :\ ((__GPIOx__) == (GPIOG))? 6UL :\ ((__GPIOx__) == (GPIOH))? 7UL :\ ((__GPIOx__) == (GPIOI))? 8UL :\ ((__GPIOx__) == (GPIOJ))? 9UL : 10UL) #else #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0UL :\ ((__GPIOx__) == (GPIOB))? 1UL :\ ((__GPIOx__) == (GPIOC))? 2UL :\ ((__GPIOx__) == (GPIOD))? 3UL :\ ((__GPIOx__) == (GPIOE))? 4UL :\ ((__GPIOx__) == (GPIOF))? 5UL :\ ((__GPIOx__) == (GPIOG))? 6UL :\ ((__GPIOx__) == (GPIOH))? 7UL :\ ((__GPIOx__) == (GPIOJ))? 9UL : 10UL) #endif /* GPIOI */ /** * @} */ /** @defgroup GPIOEx_IS_Alternat_function_selection GPIO Check Alternate Function * @{ */ /** * @} */ /** * @} */ /* Private functions ---------------------------------------------------------*/ /** @defgroup GPIOEx_Private_Functions GPIO Private Functions * @{ */ /** * @} */ /** * @} */ /** * @} */ #ifdef __cplusplus } #endif #endif /* STM32H7xx_HAL_GPIO_EX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32h7/inc/system_stm32h7xx.h ================================================ /** ****************************************************************************** * @file system_stm32h7xx.h * @author MCD Application Team * @brief CMSIS Cortex-Mx Device System Source File for STM32H7xx devices. ****************************************************************************** * @attention * *

© Copyright (c) 2017 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /** @addtogroup CMSIS * @{ */ /** @addtogroup stm32h7xx_system * @{ */ /** * @brief Define to prevent recursive inclusion */ #ifndef SYSTEM_STM32H7XX_H #define SYSTEM_STM32H7XX_H #ifdef __cplusplus extern "C" { #endif /** @addtogroup STM32H7xx_System_Includes * @{ */ /** * @} */ /** @addtogroup STM32H7xx_System_Exported_types * @{ */ /* This variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetSysClockFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency Note: If you use this function to configure the system clock; then there is no need to call the 2 first functions listed above, since SystemCoreClock variable is updated automatically. */ extern uint32_t SystemCoreClock; /*!< System Domain1 Clock Frequency */ extern uint32_t SystemD2Clock; /*!< System Domain2 Clock Frequency */ extern const uint8_t D1CorePrescTable[16] ; /*!< D1CorePrescTable prescalers table values */ /** * @} */ /** @addtogroup STM32H7xx_System_Exported_Constants * @{ */ /** * @} */ /** @addtogroup STM32H7xx_System_Exported_Macros * @{ */ /** * @} */ /** @addtogroup STM32H7xx_System_Exported_Functions * @{ */ extern void SystemInit(void); extern void SystemCoreClockUpdate(void); /** * @} */ #ifdef __cplusplus } #endif #endif /* SYSTEM_STM32H7XX_H */ /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32h7/interrupt_handlers.h ================================================ // ********************* Bare interrupt handlers ********************* // Interrupts for STM32H7x5 void WWDG_IRQHandler(void) {handle_interrupt(WWDG_IRQn);} void PVD_AVD_IRQHandler(void) {handle_interrupt(PVD_AVD_IRQn);} void TAMP_STAMP_IRQHandler(void) {handle_interrupt(TAMP_STAMP_IRQn);} void RTC_WKUP_IRQHandler(void) {handle_interrupt(RTC_WKUP_IRQn);} void FLASH_IRQHandler(void) {handle_interrupt(FLASH_IRQn);} void RCC_IRQHandler(void) {handle_interrupt(RCC_IRQn);} void EXTI0_IRQHandler(void) {handle_interrupt(EXTI0_IRQn);} void EXTI1_IRQHandler(void) {handle_interrupt(EXTI1_IRQn);} void EXTI2_IRQHandler(void) {handle_interrupt(EXTI2_IRQn);} void EXTI3_IRQHandler(void) {handle_interrupt(EXTI3_IRQn);} void EXTI4_IRQHandler(void) {handle_interrupt(EXTI4_IRQn);} void DMA1_Stream0_IRQHandler(void) {handle_interrupt(DMA1_Stream0_IRQn);} void DMA1_Stream1_IRQHandler(void) {handle_interrupt(DMA1_Stream1_IRQn);} void DMA1_Stream2_IRQHandler(void) {handle_interrupt(DMA1_Stream2_IRQn);} void DMA1_Stream3_IRQHandler(void) {handle_interrupt(DMA1_Stream3_IRQn);} void DMA1_Stream4_IRQHandler(void) {handle_interrupt(DMA1_Stream4_IRQn);} void DMA1_Stream5_IRQHandler(void) {handle_interrupt(DMA1_Stream5_IRQn);} void DMA1_Stream6_IRQHandler(void) {handle_interrupt(DMA1_Stream6_IRQn);} void ADC_IRQHandler(void) {handle_interrupt(ADC_IRQn);} void EXTI9_5_IRQHandler(void) {handle_interrupt(EXTI9_5_IRQn);} void TIM1_BRK_IRQHandler(void) {handle_interrupt(TIM1_BRK_IRQn);} void TIM1_UP_TIM10_IRQHandler(void) {handle_interrupt(TIM1_UP_TIM10_IRQn);} void TIM1_TRG_COM_IRQHandler(void) {handle_interrupt(TIM1_TRG_COM_IRQn);} void TIM1_CC_IRQHandler(void) {handle_interrupt(TIM1_CC_IRQn);} void TIM2_IRQHandler(void) {handle_interrupt(TIM2_IRQn);} void TIM3_IRQHandler(void) {handle_interrupt(TIM3_IRQn);} void TIM4_IRQHandler(void) {handle_interrupt(TIM4_IRQn);} void I2C1_EV_IRQHandler(void) {handle_interrupt(I2C1_EV_IRQn);} void I2C1_ER_IRQHandler(void) {handle_interrupt(I2C1_ER_IRQn);} void I2C2_EV_IRQHandler(void) {handle_interrupt(I2C2_EV_IRQn);} void I2C2_ER_IRQHandler(void) {handle_interrupt(I2C2_ER_IRQn);} void SPI1_IRQHandler(void) {handle_interrupt(SPI1_IRQn);} void SPI2_IRQHandler(void) {handle_interrupt(SPI2_IRQn);} void USART1_IRQHandler(void) {handle_interrupt(USART1_IRQn);} void USART2_IRQHandler(void) {handle_interrupt(USART2_IRQn);} void USART3_IRQHandler(void) {handle_interrupt(USART3_IRQn);} void EXTI15_10_IRQHandler(void) {handle_interrupt(EXTI15_10_IRQn);} void RTC_Alarm_IRQHandler(void) {handle_interrupt(RTC_Alarm_IRQn);} void TIM8_BRK_TIM12_IRQHandler(void) {handle_interrupt(TIM8_BRK_TIM12_IRQn);} void TIM8_UP_TIM13_IRQHandler(void) {handle_interrupt(TIM8_UP_TIM13_IRQn);} void TIM8_TRG_COM_TIM14_IRQHandler(void) {handle_interrupt(TIM8_TRG_COM_TIM14_IRQn);} void TIM8_CC_IRQHandler(void) {handle_interrupt(TIM8_CC_IRQn);} void DMA1_Stream7_IRQHandler(void) {handle_interrupt(DMA1_Stream7_IRQn);} void TIM5_IRQHandler(void) {handle_interrupt(TIM5_IRQn);} void SPI3_IRQHandler(void) {handle_interrupt(SPI3_IRQn);} void UART4_IRQHandler(void) {handle_interrupt(UART4_IRQn);} void UART5_IRQHandler(void) {handle_interrupt(UART5_IRQn);} void TIM6_DAC_IRQHandler(void) {handle_interrupt(TIM6_DAC_IRQn);} void TIM7_IRQHandler(void) {handle_interrupt(TIM7_IRQn);} void DMA2_Stream0_IRQHandler(void) {handle_interrupt(DMA2_Stream0_IRQn);} void DMA2_Stream1_IRQHandler(void) {handle_interrupt(DMA2_Stream1_IRQn);} void DMA2_Stream2_IRQHandler(void) {handle_interrupt(DMA2_Stream2_IRQn);} void DMA2_Stream3_IRQHandler(void) {handle_interrupt(DMA2_Stream3_IRQn);} void DMA2_Stream4_IRQHandler(void) {handle_interrupt(DMA2_Stream4_IRQn);} void DMA2_Stream5_IRQHandler(void) {handle_interrupt(DMA2_Stream5_IRQn);} void DMA2_Stream6_IRQHandler(void) {handle_interrupt(DMA2_Stream6_IRQn);} void DMA2_Stream7_IRQHandler(void) {handle_interrupt(DMA2_Stream7_IRQn);} void USART6_IRQHandler(void) {handle_interrupt(USART6_IRQn);} void I2C3_EV_IRQHandler(void) {handle_interrupt(I2C3_EV_IRQn);} void I2C3_ER_IRQHandler(void) {handle_interrupt(I2C3_ER_IRQn);} void FDCAN1_IT0_IRQHandler(void) {handle_interrupt(FDCAN1_IT0_IRQn);} void FDCAN1_IT1_IRQHandler(void) {handle_interrupt(FDCAN1_IT1_IRQn);} void FDCAN2_IT0_IRQHandler(void) {handle_interrupt(FDCAN2_IT0_IRQn);} void FDCAN2_IT1_IRQHandler(void) {handle_interrupt(FDCAN2_IT1_IRQn);} void FDCAN3_IT0_IRQHandler(void) {handle_interrupt(FDCAN3_IT0_IRQn);} void FDCAN3_IT1_IRQHandler(void) {handle_interrupt(FDCAN3_IT1_IRQn);} void FDCAN_CAL_IRQHandler(void) {handle_interrupt(FDCAN_CAL_IRQn);} void OTG_HS_EP1_OUT_IRQHandler(void) {handle_interrupt(OTG_HS_EP1_OUT_IRQn);} void OTG_HS_EP1_IN_IRQHandler(void) {handle_interrupt(OTG_HS_EP1_IN_IRQn);} void OTG_HS_WKUP_IRQHandler(void) {handle_interrupt(OTG_HS_WKUP_IRQn);} void OTG_HS_IRQHandler(void) {handle_interrupt(OTG_HS_IRQn);} ================================================ FILE: panda/board/stm32h7/lladc.h ================================================ // 5VOUT_S = ADC12_INP5 // VOLT_S = ADC1_INP2 #define ADCCHAN_VOLTAGE 2 void adc_init(void) { ADC1->CR &= ~(ADC_CR_DEEPPWD); //Reset deep-power-down mode ADC1->CR |= ADC_CR_ADVREGEN; // Enable ADC regulator while(!(ADC1->ISR & ADC_ISR_LDORDY)); ADC1->CR &= ~(ADC_CR_ADCALDIF); // Choose single-ended calibration ADC1->CR |= ADC_CR_ADCALLIN; // Lineriality calibration ADC1->CR |= ADC_CR_ADCAL; // Start calibrtation while((ADC1->CR & ADC_CR_ADCAL) != 0); ADC1->ISR |= ADC_ISR_ADRDY; ADC1->CR |= ADC_CR_ADEN; while(!(ADC1->ISR & ADC_ISR_ADRDY)); } uint32_t adc_get(unsigned int channel) { ADC1->SQR1 &= ~(ADC_SQR1_L); ADC1->SQR1 = (channel << 6U); ADC1->SMPR1 = (0x7U << (channel * 3U) ); ADC1->PCSEL_RES0 = (0x1U << channel); ADC1->CR |= ADC_CR_ADSTART; while (!(ADC1->ISR & ADC_ISR_EOC)); uint16_t res = ADC1->DR; while (!(ADC1->ISR & ADC_ISR_EOS)); ADC1->ISR |= ADC_ISR_EOS; return res; } uint32_t adc_get_voltage(void) { // REVC has a 10, 1 (1/11) voltage divider // Here is the calculation for the scale (s) // ADCV = VIN_S * (1/11) * (65535/3.3) // RETVAL = ADCV * s = VIN_S*1000 // s = 1000/((65535/3.3)*(1/11)) = 0.553902494 // Avoid needing floating point math, so output in mV return (adc_get(ADCCHAN_VOLTAGE) * 5539U) / 10000U; } ================================================ FILE: panda/board/stm32h7/llfan.h ================================================ void EXTI2_IRQ_Handler(void) { } void fan_init(void){ } ================================================ FILE: panda/board/stm32h7/llfdcan.h ================================================ #define FDCAN_MESSAGE_RAM_SIZE 0x2800UL #define FDCAN_START_ADDRESS 0x4000AC00UL #define FDCAN_OFFSET 3412UL // bytes for each FDCAN module #define FDCAN_OFFSET_W 853UL // words for each FDCAN module #define FDCAN_END_ADDRESS 0x4000D3FCUL // Message RAM has a width of 4 Bytes // With this settings we can go up to 6Mbit/s #define CAN_SYNC_JW 1U // 1 to 4 #define CAN_PHASE_SEG1 6U // =(PROP_SEG + PHASE_SEG1) , 1 to 16 #define CAN_PHASE_SEG2 1U // 1 to 8 #define CAN_PCLK 48000U // Sourced from PLL1Q #define CAN_QUANTA (1U + CAN_PHASE_SEG1 + CAN_PHASE_SEG2) // Valid speeds in kbps and their prescalers: // 10=600, 20=300, 50=120, 83.333=72, 100=60, 125=48, 250=24, 500=12, 1000=6, 2000=3, 3000=2, 6000=1 #define can_speed_to_prescaler(x) (CAN_PCLK / CAN_QUANTA * 10U / (x)) // RX FIFO 0 #define FDCAN_RX_FIFO_0_EL_CNT 32UL #define FDCAN_RX_FIFO_0_HEAD_SIZE 8UL // bytes #define FDCAN_RX_FIFO_0_DATA_SIZE 8UL // bytes #define FDCAN_RX_FIFO_0_EL_SIZE (FDCAN_RX_FIFO_0_HEAD_SIZE + FDCAN_RX_FIFO_0_DATA_SIZE) #define FDCAN_RX_FIFO_0_EL_W_SIZE (FDCAN_RX_FIFO_0_EL_SIZE / 4UL) #define FDCAN_RX_FIFO_0_OFFSET 0UL // TX FIFO #define FDCAN_TX_FIFO_EL_CNT 32UL #define FDCAN_TX_FIFO_HEAD_SIZE 8UL // bytes #define FDCAN_TX_FIFO_DATA_SIZE 8UL // bytes #define FDCAN_TX_FIFO_EL_SIZE (FDCAN_TX_FIFO_HEAD_SIZE + FDCAN_TX_FIFO_DATA_SIZE) #define FDCAN_TX_FIFO_EL_W_SIZE (FDCAN_TX_FIFO_EL_SIZE / 4UL) #define FDCAN_TX_FIFO_OFFSET (FDCAN_RX_FIFO_0_OFFSET + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_W_SIZE)) #define CAN_NAME_FROM_CANIF(CAN_DEV) (((CAN_DEV)==FDCAN1) ? "FDCAN1" : (((CAN_DEV) == FDCAN2) ? "FDCAN2" : "FDCAN3")) #define CAN_NUM_FROM_CANIF(CAN_DEV) (((CAN_DEV)==FDCAN1) ? 0UL : (((CAN_DEV) == FDCAN2) ? 1UL : 2UL)) // For backwards compatibility with safety code typedef struct { __IO uint32_t RIR; /*!< CAN receive FIFO mailbox identifier register */ __IO uint32_t RDTR; /*!< CAN receive FIFO mailbox data length control and time stamp register */ __IO uint32_t RDLR; /*!< CAN receive FIFO mailbox data low register */ __IO uint32_t RDHR; /*!< CAN receive FIFO mailbox data high register */ } CAN_FIFOMailBox_TypeDef; void puts(const char *a); bool fdcan_request_init(FDCAN_GlobalTypeDef *CANx) { bool ret = true; // Exit from sleep mode CANx->CCCR &= ~(FDCAN_CCCR_CSR); while ((CANx->CCCR & FDCAN_CCCR_CSA) == FDCAN_CCCR_CSA); // Request init uint32_t timeout_counter = 0U; CANx->CCCR |= FDCAN_CCCR_INIT; while ((CANx->CCCR & FDCAN_CCCR_INIT) == 0) { // Delay for about 1ms delay(10000); timeout_counter++; if (timeout_counter >= CAN_INIT_TIMEOUT_MS){ ret = false; break; } } return ret; } bool fdcan_exit_init(FDCAN_GlobalTypeDef *CANx) { bool ret = true; CANx->CCCR &= ~(FDCAN_CCCR_INIT); uint32_t timeout_counter = 0U; while ((CANx->CCCR & FDCAN_CCCR_INIT) != 0) { // Delay for about 1ms delay(10000); timeout_counter++; if (timeout_counter >= CAN_INIT_TIMEOUT_MS) { ret = false; break; } } return ret; } bool llcan_set_speed(FDCAN_GlobalTypeDef *CANx, uint32_t speed, uint32_t data_speed, bool loopback, bool silent) { bool ret = fdcan_request_init(CANx); if (ret) { // Enable config change CANx->CCCR |= FDCAN_CCCR_CCE; //Reset operation mode to Normal CANx->CCCR &= ~(FDCAN_CCCR_TEST); CANx->TEST &= ~(FDCAN_TEST_LBCK); CANx->CCCR &= ~(FDCAN_CCCR_MON); CANx->CCCR &= ~(FDCAN_CCCR_ASM); // Set the nominal bit timing register CANx->NBTP = ((CAN_SYNC_JW-1U)<DBTP = ((CAN_SYNC_JW-1U)<CCCR |= FDCAN_CCCR_TEST; CANx->TEST |= FDCAN_TEST_LBCK; CANx->CCCR |= FDCAN_CCCR_MON; } // Silent is known as bus monitoring in the docs if (silent) { CANx->CCCR |= FDCAN_CCCR_MON; } ret = fdcan_exit_init(CANx); if (!ret) { puts(CAN_NAME_FROM_CANIF(CANx)); puts(" set_speed timed out! (2)\n"); } } else { puts(CAN_NAME_FROM_CANIF(CANx)); puts(" set_speed timed out! (1)\n"); } return ret; } bool llcan_init(FDCAN_GlobalTypeDef *CANx) { uint32_t can_number = CAN_NUM_FROM_CANIF(CANx); bool ret = fdcan_request_init(CANx); if (ret) { // Enable config change CANx->CCCR |= FDCAN_CCCR_CCE; // Enable automatic retransmission CANx->CCCR &= ~(FDCAN_CCCR_DAR); // Enable transmission pause feature CANx->CCCR |= FDCAN_CCCR_TXP; // Disable protocol exception handling CANx->CCCR |= FDCAN_CCCR_PXHD; // FD with BRS CANx->CCCR |= (FDCAN_CCCR_FDOE | FDCAN_CCCR_BRSE); // Set TX mode to FIFO CANx->TXBC &= ~(FDCAN_TXBC_TFQM); // Configure TX element size (for now 8 bytes, no need to change) //CANx->TXESC |= 0x000U; //Configure RX FIFO0, FIFO1, RX buffer element sizes (no need for now, using classic 8 bytes) register_set(&(CANx->RXESC), 0x0U, (FDCAN_RXESC_F0DS | FDCAN_RXESC_F1DS | FDCAN_RXESC_RBDS)); // Disable filtering, accept all valid frames received CANx->XIDFC &= ~(FDCAN_XIDFC_LSE); // No extended filters CANx->SIDFC &= ~(FDCAN_SIDFC_LSS); // No standard filters CANx->GFC &= ~(FDCAN_GFC_RRFE); // Accept extended remote frames CANx->GFC &= ~(FDCAN_GFC_RRFS); // Accept standard remote frames CANx->GFC &= ~(FDCAN_GFC_ANFE); // Accept extended frames to FIFO 0 CANx->GFC &= ~(FDCAN_GFC_ANFS); // Accept standard frames to FIFO 0 uint32_t RxFIFO0SA = FDCAN_START_ADDRESS + (can_number * FDCAN_OFFSET); uint32_t TxFIFOSA = RxFIFO0SA + (FDCAN_RX_FIFO_0_EL_CNT * FDCAN_RX_FIFO_0_EL_SIZE); // RX FIFO 0 CANx->RXF0C = (FDCAN_RX_FIFO_0_OFFSET + (can_number * FDCAN_OFFSET_W)) << FDCAN_RXF0C_F0SA_Pos; CANx->RXF0C |= FDCAN_RX_FIFO_0_EL_CNT << FDCAN_RXF0C_F0S_Pos; // RX FIFO 0 switch to non-blocking (overwrite) mode CANx->RXF0C |= FDCAN_RXF0C_F0OM; // TX FIFO (mode set earlier) CANx->TXBC = (FDCAN_TX_FIFO_OFFSET + (can_number * FDCAN_OFFSET_W)) << FDCAN_TXBC_TBSA_Pos; CANx->TXBC |= FDCAN_TX_FIFO_EL_CNT << FDCAN_TXBC_TFQS_Pos; // Flush allocated RAM uint32_t EndAddress = TxFIFOSA + (FDCAN_TX_FIFO_EL_CNT * FDCAN_TX_FIFO_EL_SIZE); for (uint32_t RAMcounter = RxFIFO0SA; RAMcounter < EndAddress; RAMcounter += 4U) { *(uint32_t *)(RAMcounter) = 0x00000000; } // Enable both interrupts for each module CANx->ILE = (FDCAN_ILE_EINT0 | FDCAN_ILE_EINT1); CANx->IE &= 0x0U; // Reset all interrupts // Messages for INT0 CANx->IE |= FDCAN_IE_RF0NE; // Rx FIFO 0 new message // Messages for INT1 (Only TFE works??) CANx->ILS |= FDCAN_ILS_TFEL; CANx->IE |= FDCAN_IE_TFEE; // Tx FIFO empty ret = fdcan_exit_init(CANx); if(!ret) { puts(CAN_NAME_FROM_CANIF(CANx)); puts(" llcan_init timed out (2)!\n"); } if (CANx == FDCAN1) { NVIC_EnableIRQ(FDCAN1_IT0_IRQn); NVIC_EnableIRQ(FDCAN1_IT1_IRQn); } else if (CANx == FDCAN2) { NVIC_EnableIRQ(FDCAN2_IT0_IRQn); NVIC_EnableIRQ(FDCAN2_IT1_IRQn); } else if (CANx == FDCAN3) { NVIC_EnableIRQ(FDCAN3_IT0_IRQn); NVIC_EnableIRQ(FDCAN3_IT1_IRQn); } else { puts("Invalid CAN: initialization failed\n"); } } else { puts(CAN_NAME_FROM_CANIF(CANx)); puts(" llcan_init timed out (1)!\n"); } return ret; } void llcan_clear_send(FDCAN_GlobalTypeDef *CANx) { // From H7 datasheet: Transmit cancellation is not intended for Tx FIFO operation. UNUSED(CANx); } ================================================ FILE: panda/board/stm32h7/llflash.h ================================================ bool flash_is_locked(void) { return (FLASH->CR1 & FLASH_CR_LOCK); } void flash_unlock(void) { FLASH->KEYR1 = 0x45670123; FLASH->KEYR1 = 0xCDEF89AB; } bool flash_erase_sector(uint8_t sector, bool unlocked) { // don't erase the bootloader(sector 0) if (sector != 0 && sector < 8 && unlocked) { FLASH->CR1 = (sector << 8) | FLASH_CR_SER; FLASH->CR1 |= FLASH_CR_START; while (FLASH->SR1 & FLASH_SR_QW); return true; } return false; } void flash_write_word(void *prog_ptr, uint32_t data) { uint32_t *pp = prog_ptr; FLASH->CR1 |= FLASH_CR_PG; *pp = data; while (FLASH->SR1 & FLASH_SR_QW); } void flush_write_buffer(void) { if (FLASH->SR1 & FLASH_SR_WBNE) { FLASH->CR1 |= FLASH_CR_FW; while (FLASH->SR1 & FLASH_CR_FW); } } ================================================ FILE: panda/board/stm32h7/llrtc.h ================================================ #define RCC_BDCR_MASK (RCC_BDCR_RTCEN | RCC_BDCR_RTCSEL | RCC_BDCR_LSEDRV | RCC_BDCR_LSEBYP | RCC_BDCR_LSEON) void enable_bdomain_protection(void) { register_clear_bits(&(PWR->CR1), PWR_CR1_DBP); } void disable_bdomain_protection(void) { register_set_bits(&(PWR->CR1), PWR_CR1_DBP); } ================================================ FILE: panda/board/stm32h7/lluart.h ================================================ void uart_init(uart_ring *q, int baud) { UNUSED(q); UNUSED(baud); } void uart_set_baud(USART_TypeDef *u, unsigned int baud) { UNUSED(u); UNUSED(baud); } void dma_pointer_handler(uart_ring *q, uint32_t dma_ndtr) { UNUSED(q); UNUSED(dma_ndtr); } void uart_rx_ring(uart_ring *q) { UNUSED(q); } void uart_tx_ring(uart_ring *q) { UNUSED(q); } ================================================ FILE: panda/board/stm32h7/llusb.h ================================================ typedef struct { __IO uint32_t HPRT; } USB_OTG_HostPortTypeDef; USB_OTG_GlobalTypeDef *USBx = USB_OTG_HS; #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t)USBx + USB_OTG_HOST_BASE)) #define USBx_HOST_PORT ((USB_OTG_HostPortTypeDef *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE)) #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t)USBx + USB_OTG_DEVICE_BASE)) #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) #define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE) #define USBD_FS_TRDT_VALUE 6U #define USB_OTG_SPEED_FULL 3U #define DCFG_FRAME_INTERVAL_80 0U void usb_irqhandler(void); void OTG_HS_IRQ_Handler(void) { NVIC_DisableIRQ(OTG_HS_IRQn); usb_irqhandler(); NVIC_EnableIRQ(OTG_HS_IRQn); } void usb_init(void) { REGISTER_INTERRUPT(OTG_HS_IRQn, OTG_HS_IRQ_Handler, 1500000U, FAULT_INTERRUPT_RATE_USB) // TODO: Find out a better rate limit for USB. Now it's the 1.5MB/s rate // Disable global interrupt USBx->GAHBCFG &= ~(USB_OTG_GAHBCFG_GINT); // Select FS Embedded PHY USBx->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL; // Force device mode USBx->GUSBCFG &= ~(USB_OTG_GUSBCFG_FHMOD | USB_OTG_GUSBCFG_FDMOD); USBx->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; delay(250000); // Wait for about 25ms (explicitly stated in H7 ref manual) // Wait for AHB master IDLE state. while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0); // Core Soft Reset USBx->GRSTCTL |= USB_OTG_GRSTCTL_CSRST; while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_CSRST) == USB_OTG_GRSTCTL_CSRST); // Activate the USB Transceiver USBx->GCCFG |= USB_OTG_GCCFG_PWRDWN; for (uint8_t i = 0U; i < 15U; i++) { USBx->DIEPTXF[i] = 0U; } // VBUS Sensing setup USBx_DEVICE->DCTL |= USB_OTG_DCTL_SDIS; // Deactivate VBUS Sensing B USBx->GCCFG &= ~(USB_OTG_GCCFG_VBDEN); // B-peripheral session valid override enable USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; USBx->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; // Restart the Phy Clock USBx_PCGCCTL = 0U; // Device mode configuration USBx_DEVICE->DCFG |= DCFG_FRAME_INTERVAL_80; USBx_DEVICE->DCFG |= USB_OTG_SPEED_FULL | USB_OTG_DCFG_NZLSOHSK; // Flush FIFOs USBx->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (0x10U << 6)); while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH); USBx->GRSTCTL = USB_OTG_GRSTCTL_RXFFLSH; while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_RXFFLSH) == USB_OTG_GRSTCTL_RXFFLSH); // Clear all pending Device Interrupts USBx_DEVICE->DIEPMSK = 0U; USBx_DEVICE->DOEPMSK = 0U; USBx_DEVICE->DAINTMSK = 0U; USBx_DEVICE->DIEPMSK &= ~(USB_OTG_DIEPMSK_TXFURM); // Disable all interrupts. USBx->GINTMSK = 0U; // Clear any pending interrupts USBx->GINTSTS = 0xBFFFFFFFU; // Enable interrupts matching to the Device mode ONLY USBx->GINTMSK = USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_OTGINT | USB_OTG_GINTMSK_RXFLVLM | USB_OTG_GINTMSK_GONAKEFFM | USB_OTG_GINTMSK_GINAKEFFM | USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IEPINT | USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_CIDSCHGM | USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_MMISM | USB_OTG_GINTMSK_EOPFM; // Set USB Turnaround time USBx->GUSBCFG |= ((USBD_FS_TRDT_VALUE << 10) & USB_OTG_GUSBCFG_TRDT); // Enables the controller's Global Int in the AHB Config reg USBx->GAHBCFG |= USB_OTG_GAHBCFG_GINT; // Soft disconnect disable: USBx_DEVICE->DCTL &= ~(USB_OTG_DCTL_SDIS); // enable the IRQ NVIC_EnableIRQ(OTG_HS_IRQn); } ================================================ FILE: panda/board/stm32h7/peripherals.h ================================================ void gpio_usb_init(void) { // A11,A12: USB: set_gpio_alternate(GPIOA, 11, GPIO_AF10_OTG1_FS); set_gpio_alternate(GPIOA, 12, GPIO_AF10_OTG1_FS); GPIOA->OSPEEDR = GPIO_OSPEEDR_OSPEED11 | GPIO_OSPEEDR_OSPEED12; } void gpio_usart2_init(void) { // A2,A3: USART 2 for debugging set_gpio_alternate(GPIOA, 2, GPIO_AF7_USART2); set_gpio_alternate(GPIOA, 3, GPIO_AF7_USART2); } // Common GPIO initialization void common_init_gpio(void) { /// E2,E3,E4: RGB LED set_gpio_pullup(GPIOE, 2, PULL_NONE); set_gpio_mode(GPIOE, 2, MODE_OUTPUT); set_gpio_pullup(GPIOE, 3, PULL_NONE); set_gpio_mode(GPIOE, 3, MODE_OUTPUT); set_gpio_pullup(GPIOE, 4, PULL_NONE); set_gpio_mode(GPIOE, 4, MODE_OUTPUT); // F7,F8,F9,F10: BOARD ID set_gpio_pullup(GPIOF, 7, PULL_NONE); set_gpio_mode(GPIOF, 7, MODE_INPUT); set_gpio_pullup(GPIOF, 8, PULL_NONE); set_gpio_mode(GPIOF, 8, MODE_INPUT); set_gpio_pullup(GPIOF, 9, PULL_NONE); set_gpio_mode(GPIOF, 9, MODE_INPUT); set_gpio_pullup(GPIOF, 10, PULL_NONE); set_gpio_mode(GPIOF, 10, MODE_INPUT); // G11,B3,D7,B4: transceiver enable set_gpio_pullup(GPIOG, 11, PULL_NONE); set_gpio_mode(GPIOG, 11, MODE_OUTPUT); // Speed was set to high by default after reset, changing to low GPIOB->OSPEEDR = GPIO_OSPEEDR_OSPEED3; set_gpio_pullup(GPIOB, 3, PULL_NONE); set_gpio_mode(GPIOB, 3, MODE_OUTPUT); set_gpio_pullup(GPIOD, 7, PULL_NONE); set_gpio_mode(GPIOD, 7, MODE_OUTPUT); set_gpio_pullup(GPIOB, 4, PULL_NONE); set_gpio_mode(GPIOB, 4, MODE_OUTPUT); // B14: usb load switch set_gpio_pullup(GPIOB, 14, PULL_NONE); set_gpio_mode(GPIOB, 14, MODE_OUTPUT); //B1,F11 5VOUT_S, VOLT_S set_gpio_pullup(GPIOB, 1, PULL_NONE); set_gpio_mode(GPIOB, 1, MODE_ANALOG); set_gpio_pullup(GPIOF, 11, PULL_NONE); set_gpio_mode(GPIOF, 11, MODE_ANALOG); gpio_usb_init(); // B8,B9: FDCAN1 set_gpio_pullup(GPIOB, 8, PULL_NONE); set_gpio_alternate(GPIOB, 8, GPIO_AF9_FDCAN1); set_gpio_pullup(GPIOB, 9, PULL_NONE); set_gpio_alternate(GPIOB, 9, GPIO_AF9_FDCAN1); // B5,B6 (mplex to B12,B13): FDCAN2 set_gpio_pullup(GPIOB, 12, PULL_NONE); set_gpio_pullup(GPIOB, 13, PULL_NONE); set_gpio_pullup(GPIOB, 5, PULL_NONE); set_gpio_alternate(GPIOB, 5, GPIO_AF9_FDCAN2); set_gpio_pullup(GPIOB, 6, PULL_NONE); set_gpio_alternate(GPIOB, 6, GPIO_AF9_FDCAN2); // G9,G10: FDCAN3 set_gpio_pullup(GPIOG, 9, PULL_NONE); set_gpio_alternate(GPIOG, 9, GPIO_AF2_FDCAN3); set_gpio_pullup(GPIOG, 10, PULL_NONE); set_gpio_alternate(GPIOG, 10, GPIO_AF2_FDCAN3); } void flasher_peripherals_init(void) { RCC->AHB1ENR |= RCC_AHB1ENR_USB1OTGHSEN; } // Peripheral initialization void peripherals_init(void) { // enable GPIO(A,B,C,D,E,F,G,H) RCC->AHB4ENR |= RCC_AHB4ENR_GPIOAEN; RCC->AHB4ENR |= RCC_AHB4ENR_GPIOBEN; RCC->AHB4ENR |= RCC_AHB4ENR_GPIOCEN; RCC->AHB4ENR |= RCC_AHB4ENR_GPIODEN; RCC->AHB4ENR |= RCC_AHB4ENR_GPIOEEN; RCC->AHB4ENR |= RCC_AHB4ENR_GPIOFEN; RCC->AHB4ENR |= RCC_AHB4ENR_GPIOGEN; RCC->APB1LENR |= RCC_APB1LENR_TIM2EN; // main counter RCC->APB1LENR |= RCC_APB1LENR_TIM6EN; // interrupt timer RCC->APB2ENR |= RCC_APB2ENR_TIM8EN; // clock source timer RCC->APB1LENR |= RCC_APB1LENR_TIM12EN; // slow loop RCC->APB1HENR |= RCC_APB1HENR_FDCANEN; // FDCAN core enable RCC->AHB1ENR |= RCC_AHB1ENR_ADC12EN; // Enable ADC clocks // HS USB enable, also LP is needed for CSleep state(__WFI()) RCC->AHB1ENR |= RCC_AHB1ENR_USB1OTGHSEN; RCC->AHB1LPENR |= RCC_AHB1LPENR_USB1OTGHSLPEN; RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_USB1OTGHSULPILPEN); } void enable_interrupt_timer(void) { register_set_bits(&(RCC->APB1LENR), RCC_APB1LENR_TIM6EN); // Enable interrupt timer peripheral } ================================================ FILE: panda/board/stm32h7/startup_stm32h7x5xx.s ================================================ /** ****************************************************************************** * @file startup_stm32h735xx.s * @author MCD Application Team * @brief STM32H735xx Devices vector table for GCC based toolchain. * This module performs: * - Set the initial SP * - Set the initial PC == Reset_Handler, * - Set the vector table entries with the exceptions ISR address * - Branches to main in the C library (which eventually * calls main()). * After Reset the Cortex-M processor is in Thread mode, * priority is Privileged, and the Stack is set to Main. ****************************************************************************** * @attention * *

© Copyright (c) 2019 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ .syntax unified .cpu cortex-m7 .fpu softvfp .thumb .global g_pfnVectors .global Default_Handler /* start address for the initialization values of the .data section. defined in linker script */ .word _sidata /* start address for the .data section. defined in linker script */ .word _sdata /* end address for the .data section. defined in linker script */ .word _edata /* start address for the .bss section. defined in linker script */ .word _sbss /* end address for the .bss section. defined in linker script */ .word _ebss /* stack used for SystemInit_ExtMemCtl; always internal RAM used */ /** * @brief This is the code that gets called when the processor first * starts execution following a reset event. Only the absolutely * necessary set is performed, after which the application * supplied main() routine is called. * @param None * @retval : None */ .section .text.Reset_Handler .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: ldr sp, =_estack /* set stack pointer */ bl __initialize_hardware_early /* Copy the data segment initializers from flash to SRAM */ ldr r0, =_sdata ldr r1, =_edata ldr r2, =_sidata movs r3, #0 b LoopCopyDataInit CopyDataInit: ldr r4, [r2, r3] str r4, [r0, r3] adds r3, r3, #4 LoopCopyDataInit: adds r4, r0, r3 cmp r4, r1 bcc CopyDataInit /* Zero fill the bss segment. */ ldr r2, =_sbss ldr r4, =_ebss movs r3, #0 b LoopFillZerobss FillZerobss: str r3, [r2] adds r2, r2, #4 LoopFillZerobss: cmp r2, r4 bcc FillZerobss /* Call the clock system intitialization function.*/ /* bl SystemInit */ /* Call static constructors */ /* bl __libc_init_array */ /* Call the application's entry point.*/ bl main bx lr .size Reset_Handler, .-Reset_Handler /** * @brief This is the code that gets called when the processor receives an * unexpected interrupt. This simply enters an infinite loop, preserving * the system state for examination by a debugger. * @param None * @retval None */ .section .text.Default_Handler,"ax",%progbits Default_Handler: Infinite_Loop: b Infinite_Loop .size Default_Handler, .-Default_Handler /****************************************************************************** * * The minimal vector table for a Cortex M. Note that the proper constructs * must be placed on this to ensure that it ends up at physical address * 0x0000.0000. * *******************************************************************************/ .section .isr_vector,"a",%progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler .word MemManage_Handler .word BusFault_Handler .word UsageFault_Handler .word 0 .word 0 .word 0 .word 0 .word SVC_Handler .word DebugMon_Handler .word 0 .word PendSV_Handler .word SysTick_Handler /* External Interrupts */ .word WWDG_IRQHandler /* Window WatchDog */ .word PVD_AVD_IRQHandler /* PVD/AVD through EXTI Line detection */ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */ .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */ .word FLASH_IRQHandler /* FLASH */ .word RCC_IRQHandler /* RCC */ .word EXTI0_IRQHandler /* EXTI Line0 */ .word EXTI1_IRQHandler /* EXTI Line1 */ .word EXTI2_IRQHandler /* EXTI Line2 */ .word EXTI3_IRQHandler /* EXTI Line3 */ .word EXTI4_IRQHandler /* EXTI Line4 */ .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */ .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */ .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */ .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */ .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */ .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */ .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */ .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */ .word FDCAN1_IT0_IRQHandler /* FDCAN1 interrupt line 0 */ .word FDCAN2_IT0_IRQHandler /* FDCAN2 interrupt line 0 */ .word FDCAN1_IT1_IRQHandler /* FDCAN1 interrupt line 1 */ .word FDCAN2_IT1_IRQHandler /* FDCAN2 interrupt line 1 */ .word EXTI9_5_IRQHandler /* External Line[9:5]s */ .word TIM1_BRK_IRQHandler /* TIM1 Break interrupt */ .word TIM1_UP_IRQHandler /* TIM1 Update interrupt */ .word TIM1_TRG_COM_IRQHandler /* TIM1 Trigger and Commutation interrupt */ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */ .word TIM2_IRQHandler /* TIM2 */ .word TIM3_IRQHandler /* TIM3 */ .word TIM4_IRQHandler /* TIM4 */ .word I2C1_EV_IRQHandler /* I2C1 Event */ .word I2C1_ER_IRQHandler /* I2C1 Error */ .word I2C2_EV_IRQHandler /* I2C2 Event */ .word I2C2_ER_IRQHandler /* I2C2 Error */ .word SPI1_IRQHandler /* SPI1 */ .word SPI2_IRQHandler /* SPI2 */ .word USART1_IRQHandler /* USART1 */ .word USART2_IRQHandler /* USART2 */ .word USART3_IRQHandler /* USART3 */ .word EXTI15_10_IRQHandler /* External Line[15:10]s */ .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */ .word 0 /* Reserved */ .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */ .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */ .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */ .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */ .word FMC_IRQHandler /* FMC */ .word SDMMC1_IRQHandler /* SDMMC1 */ .word TIM5_IRQHandler /* TIM5 */ .word SPI3_IRQHandler /* SPI3 */ .word UART4_IRQHandler /* UART4 */ .word UART5_IRQHandler /* UART5 */ .word TIM6_DAC_IRQHandler /* TIM6 and DAC1&2 underrun errors */ .word TIM7_IRQHandler /* TIM7 */ .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */ .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */ .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */ .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */ .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */ .word ETH_IRQHandler /* Ethernet */ .word ETH_WKUP_IRQHandler /* Ethernet Wakeup through EXTI line */ .word FDCAN_CAL_IRQHandler /* FDCAN calibration unit interrupt*/ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */ .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */ .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */ .word USART6_IRQHandler /* USART6 */ .word I2C3_EV_IRQHandler /* I2C3 event */ .word I2C3_ER_IRQHandler /* I2C3 error */ .word OTG_HS_EP1_OUT_IRQHandler /* USB OTG HS End Point 1 Out */ .word OTG_HS_EP1_IN_IRQHandler /* USB OTG HS End Point 1 In */ .word OTG_HS_WKUP_IRQHandler /* USB OTG HS Wakeup through EXTI */ .word OTG_HS_IRQHandler /* USB OTG HS */ .word DCMI_PSSI_IRQHandler /* DCMI, PSSI */ .word CRYP_IRQHandler /* CRYP */ .word HASH_RNG_IRQHandler /* Hash and Rng */ .word FPU_IRQHandler /* FPU */ .word UART7_IRQHandler /* UART7 */ .word UART8_IRQHandler /* UART8 */ .word SPI4_IRQHandler /* SPI4 */ .word SPI5_IRQHandler /* SPI5 */ .word SPI6_IRQHandler /* SPI6 */ .word SAI1_IRQHandler /* SAI1 */ .word LTDC_IRQHandler /* LTDC */ .word LTDC_ER_IRQHandler /* LTDC error */ .word DMA2D_IRQHandler /* DMA2D */ .word 0 /* Reserved */ .word OCTOSPI1_IRQHandler /* OCTOSPI1 */ .word LPTIM1_IRQHandler /* LPTIM1 */ .word CEC_IRQHandler /* HDMI_CEC */ .word I2C4_EV_IRQHandler /* I2C4 Event */ .word I2C4_ER_IRQHandler /* I2C4 Error */ .word SPDIF_RX_IRQHandler /* SPDIF_RX */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word DMAMUX1_OVR_IRQHandler /* DMAMUX1 Overrun interrupt */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word 0 /* Reserved */ .word DFSDM1_FLT0_IRQHandler /* DFSDM Filter0 Interrupt */ .word DFSDM1_FLT1_IRQHandler /* DFSDM Filter1 Interrupt */ .word DFSDM1_FLT2_IRQHandler /* DFSDM Filter2 Interrupt */ .word DFSDM1_FLT3_IRQHandler /* DFSDM Filter3 Interrupt */ .word 0 /* Reserved */ .word SWPMI1_IRQHandler /* Serial Wire Interface 1 global interrupt */ .word TIM15_IRQHandler /* TIM15 global Interrupt */ .word TIM16_IRQHandler /* TIM16 global Interrupt */ .word TIM17_IRQHandler /* TIM17 global Interrupt */ .word MDIOS_WKUP_IRQHandler /* MDIOS Wakeup Interrupt */ .word MDIOS_IRQHandler /* MDIOS global Interrupt */ .word 0 /* Reserved */ .word MDMA_IRQHandler /* MDMA global Interrupt */ .word 0 /* Reserved */ .word SDMMC2_IRQHandler /* SDMMC2 global Interrupt */ .word HSEM1_IRQHandler /* HSEM1 global Interrupt */ .word 0 /* Reserved */ .word ADC3_IRQHandler /* ADC3 global Interrupt */ .word DMAMUX2_OVR_IRQHandler /* DMAMUX Overrun interrupt */ .word BDMA_Channel0_IRQHandler /* BDMA Channel 0 global Interrupt */ .word BDMA_Channel1_IRQHandler /* BDMA Channel 1 global Interrupt */ .word BDMA_Channel2_IRQHandler /* BDMA Channel 2 global Interrupt */ .word BDMA_Channel3_IRQHandler /* BDMA Channel 3 global Interrupt */ .word BDMA_Channel4_IRQHandler /* BDMA Channel 4 global Interrupt */ .word BDMA_Channel5_IRQHandler /* BDMA Channel 5 global Interrupt */ .word BDMA_Channel6_IRQHandler /* BDMA Channel 6 global Interrupt */ .word BDMA_Channel7_IRQHandler /* BDMA Channel 7 global Interrupt */ .word COMP1_IRQHandler /* COMP1 global Interrupt */ .word LPTIM2_IRQHandler /* LP TIM2 global interrupt */ .word LPTIM3_IRQHandler /* LP TIM3 global interrupt */ .word LPTIM4_IRQHandler /* LP TIM4 global interrupt */ .word LPTIM5_IRQHandler /* LP TIM5 global interrupt */ .word LPUART1_IRQHandler /* LP UART1 interrupt */ .word 0 /* Reserved */ .word CRS_IRQHandler /* Clock Recovery Global Interrupt */ .word ECC_IRQHandler /* ECC diagnostic Global Interrupt */ .word SAI4_IRQHandler /* SAI4 global interrupt */ .word DTS_IRQHandler /* Digital Temperature Sensor interrupt */ .word 0 /* Reserved */ .word WAKEUP_PIN_IRQHandler /* Interrupt for all 6 wake-up pins */ .word OCTOSPI2_IRQHandler /* OCTOSPI2 Interrupt */ .word OTFDEC1_IRQHandler /* OTFDEC1 Interrupt */ .word OTFDEC2_IRQHandler /* OTFDEC2 Interrupt */ .word FMAC_IRQHandler /* FMAC Interrupt */ .word CORDIC_IRQHandler /* CORDIC Interrupt */ .word UART9_IRQHandler /* UART9 Interrupt */ .word USART10_IRQHandler /* UART10 Interrupt */ .word I2C5_EV_IRQHandler /* I2C5 Event Interrupt */ .word I2C5_ER_IRQHandler /* I2C5 Error Interrupt */ .word FDCAN3_IT0_IRQHandler /* FDCAN3 interrupt line 0 */ .word FDCAN3_IT1_IRQHandler /* FDCAN3 interrupt line 1 */ .word TIM23_IRQHandler /* TIM23 global interrupt */ .word TIM24_IRQHandler /* TIM24 global interrupt */ /******************************************************************************* * * Provide weak aliases for each Exception handler to the Default_Handler. * As they are weak aliases, any function with the same name will override * this definition. * *******************************************************************************/ .weak NMI_Handler .thumb_set NMI_Handler,Default_Handler .weak HardFault_Handler .thumb_set HardFault_Handler,Default_Handler .weak MemManage_Handler .thumb_set MemManage_Handler,Default_Handler .weak BusFault_Handler .thumb_set BusFault_Handler,Default_Handler .weak UsageFault_Handler .thumb_set UsageFault_Handler,Default_Handler .weak SVC_Handler .thumb_set SVC_Handler,Default_Handler .weak DebugMon_Handler .thumb_set DebugMon_Handler,Default_Handler .weak PendSV_Handler .thumb_set PendSV_Handler,Default_Handler .weak SysTick_Handler .thumb_set SysTick_Handler,Default_Handler .weak WWDG_IRQHandler .thumb_set WWDG_IRQHandler,Default_Handler .weak PVD_AVD_IRQHandler .thumb_set PVD_AVD_IRQHandler,Default_Handler .weak TAMP_STAMP_IRQHandler .thumb_set TAMP_STAMP_IRQHandler,Default_Handler .weak RTC_WKUP_IRQHandler .thumb_set RTC_WKUP_IRQHandler,Default_Handler .weak FLASH_IRQHandler .thumb_set FLASH_IRQHandler,Default_Handler .weak RCC_IRQHandler .thumb_set RCC_IRQHandler,Default_Handler .weak EXTI0_IRQHandler .thumb_set EXTI0_IRQHandler,Default_Handler .weak EXTI1_IRQHandler .thumb_set EXTI1_IRQHandler,Default_Handler .weak EXTI2_IRQHandler .thumb_set EXTI2_IRQHandler,Default_Handler .weak EXTI3_IRQHandler .thumb_set EXTI3_IRQHandler,Default_Handler .weak EXTI4_IRQHandler .thumb_set EXTI4_IRQHandler,Default_Handler .weak DMA1_Stream0_IRQHandler .thumb_set DMA1_Stream0_IRQHandler,Default_Handler .weak DMA1_Stream1_IRQHandler .thumb_set DMA1_Stream1_IRQHandler,Default_Handler .weak DMA1_Stream2_IRQHandler .thumb_set DMA1_Stream2_IRQHandler,Default_Handler .weak DMA1_Stream3_IRQHandler .thumb_set DMA1_Stream3_IRQHandler,Default_Handler .weak DMA1_Stream4_IRQHandler .thumb_set DMA1_Stream4_IRQHandler,Default_Handler .weak DMA1_Stream5_IRQHandler .thumb_set DMA1_Stream5_IRQHandler,Default_Handler .weak DMA1_Stream6_IRQHandler .thumb_set DMA1_Stream6_IRQHandler,Default_Handler .weak ADC_IRQHandler .thumb_set ADC_IRQHandler,Default_Handler .weak FDCAN1_IT0_IRQHandler .thumb_set FDCAN1_IT0_IRQHandler,Default_Handler .weak FDCAN2_IT0_IRQHandler .thumb_set FDCAN2_IT0_IRQHandler,Default_Handler .weak FDCAN1_IT1_IRQHandler .thumb_set FDCAN1_IT1_IRQHandler,Default_Handler .weak FDCAN2_IT1_IRQHandler .thumb_set FDCAN2_IT1_IRQHandler,Default_Handler .weak EXTI9_5_IRQHandler .thumb_set EXTI9_5_IRQHandler,Default_Handler .weak TIM1_BRK_IRQHandler .thumb_set TIM1_BRK_IRQHandler,Default_Handler .weak TIM1_UP_IRQHandler .thumb_set TIM1_UP_IRQHandler,Default_Handler .weak TIM1_TRG_COM_IRQHandler .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler .weak TIM1_CC_IRQHandler .thumb_set TIM1_CC_IRQHandler,Default_Handler .weak TIM2_IRQHandler .thumb_set TIM2_IRQHandler,Default_Handler .weak TIM3_IRQHandler .thumb_set TIM3_IRQHandler,Default_Handler .weak TIM4_IRQHandler .thumb_set TIM4_IRQHandler,Default_Handler .weak I2C1_EV_IRQHandler .thumb_set I2C1_EV_IRQHandler,Default_Handler .weak I2C1_ER_IRQHandler .thumb_set I2C1_ER_IRQHandler,Default_Handler .weak I2C2_EV_IRQHandler .thumb_set I2C2_EV_IRQHandler,Default_Handler .weak I2C2_ER_IRQHandler .thumb_set I2C2_ER_IRQHandler,Default_Handler .weak SPI1_IRQHandler .thumb_set SPI1_IRQHandler,Default_Handler .weak SPI2_IRQHandler .thumb_set SPI2_IRQHandler,Default_Handler .weak USART1_IRQHandler .thumb_set USART1_IRQHandler,Default_Handler .weak USART2_IRQHandler .thumb_set USART2_IRQHandler,Default_Handler .weak USART3_IRQHandler .thumb_set USART3_IRQHandler,Default_Handler .weak EXTI15_10_IRQHandler .thumb_set EXTI15_10_IRQHandler,Default_Handler .weak RTC_Alarm_IRQHandler .thumb_set RTC_Alarm_IRQHandler,Default_Handler .weak TIM8_BRK_TIM12_IRQHandler .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler .weak TIM8_UP_TIM13_IRQHandler .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler .weak TIM8_TRG_COM_TIM14_IRQHandler .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler .weak TIM8_CC_IRQHandler .thumb_set TIM8_CC_IRQHandler,Default_Handler .weak DMA1_Stream7_IRQHandler .thumb_set DMA1_Stream7_IRQHandler,Default_Handler .weak FMC_IRQHandler .thumb_set FMC_IRQHandler,Default_Handler .weak SDMMC1_IRQHandler .thumb_set SDMMC1_IRQHandler,Default_Handler .weak TIM5_IRQHandler .thumb_set TIM5_IRQHandler,Default_Handler .weak SPI3_IRQHandler .thumb_set SPI3_IRQHandler,Default_Handler .weak UART4_IRQHandler .thumb_set UART4_IRQHandler,Default_Handler .weak UART5_IRQHandler .thumb_set UART5_IRQHandler,Default_Handler .weak TIM6_DAC_IRQHandler .thumb_set TIM6_DAC_IRQHandler,Default_Handler .weak TIM7_IRQHandler .thumb_set TIM7_IRQHandler,Default_Handler .weak DMA2_Stream0_IRQHandler .thumb_set DMA2_Stream0_IRQHandler,Default_Handler .weak DMA2_Stream1_IRQHandler .thumb_set DMA2_Stream1_IRQHandler,Default_Handler .weak DMA2_Stream2_IRQHandler .thumb_set DMA2_Stream2_IRQHandler,Default_Handler .weak DMA2_Stream3_IRQHandler .thumb_set DMA2_Stream3_IRQHandler,Default_Handler .weak DMA2_Stream4_IRQHandler .thumb_set DMA2_Stream4_IRQHandler,Default_Handler .weak ETH_IRQHandler .thumb_set ETH_IRQHandler,Default_Handler .weak ETH_WKUP_IRQHandler .thumb_set ETH_WKUP_IRQHandler,Default_Handler .weak FDCAN_CAL_IRQHandler .thumb_set FDCAN_CAL_IRQHandler,Default_Handler .weak DMA2_Stream5_IRQHandler .thumb_set DMA2_Stream5_IRQHandler,Default_Handler .weak DMA2_Stream6_IRQHandler .thumb_set DMA2_Stream6_IRQHandler,Default_Handler .weak DMA2_Stream7_IRQHandler .thumb_set DMA2_Stream7_IRQHandler,Default_Handler .weak USART6_IRQHandler .thumb_set USART6_IRQHandler,Default_Handler .weak I2C3_EV_IRQHandler .thumb_set I2C3_EV_IRQHandler,Default_Handler .weak I2C3_ER_IRQHandler .thumb_set I2C3_ER_IRQHandler,Default_Handler .weak OTG_HS_EP1_OUT_IRQHandler .thumb_set OTG_HS_EP1_OUT_IRQHandler,Default_Handler .weak OTG_HS_EP1_IN_IRQHandler .thumb_set OTG_HS_EP1_IN_IRQHandler,Default_Handler .weak OTG_HS_WKUP_IRQHandler .thumb_set OTG_HS_WKUP_IRQHandler,Default_Handler .weak OTG_HS_IRQHandler .thumb_set OTG_HS_IRQHandler,Default_Handler .weak DCMI_PSSI_IRQHandler .thumb_set DCMI_PSSI_IRQHandler,Default_Handler .weak CRYP_IRQHandler .thumb_set CRYP_IRQHandler,Default_Handler .weak HASH_RNG_IRQHandler .thumb_set HASH_RNG_IRQHandler,Default_Handler .weak FPU_IRQHandler .thumb_set FPU_IRQHandler,Default_Handler .weak UART7_IRQHandler .thumb_set UART7_IRQHandler,Default_Handler .weak UART8_IRQHandler .thumb_set UART8_IRQHandler,Default_Handler .weak SPI4_IRQHandler .thumb_set SPI4_IRQHandler,Default_Handler .weak SPI5_IRQHandler .thumb_set SPI5_IRQHandler,Default_Handler .weak SPI6_IRQHandler .thumb_set SPI6_IRQHandler,Default_Handler .weak SAI1_IRQHandler .thumb_set SAI1_IRQHandler,Default_Handler .weak LTDC_IRQHandler .thumb_set LTDC_IRQHandler,Default_Handler .weak LTDC_ER_IRQHandler .thumb_set LTDC_ER_IRQHandler,Default_Handler .weak DMA2D_IRQHandler .thumb_set DMA2D_IRQHandler,Default_Handler .weak OCTOSPI1_IRQHandler .thumb_set OCTOSPI1_IRQHandler,Default_Handler .weak LPTIM1_IRQHandler .thumb_set LPTIM1_IRQHandler,Default_Handler .weak CEC_IRQHandler .thumb_set CEC_IRQHandler,Default_Handler .weak I2C4_EV_IRQHandler .thumb_set I2C4_EV_IRQHandler,Default_Handler .weak I2C4_ER_IRQHandler .thumb_set I2C4_ER_IRQHandler,Default_Handler .weak SPDIF_RX_IRQHandler .thumb_set SPDIF_RX_IRQHandler,Default_Handler .weak DMAMUX1_OVR_IRQHandler .thumb_set DMAMUX1_OVR_IRQHandler,Default_Handler .weak DFSDM1_FLT0_IRQHandler .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler .weak DFSDM1_FLT1_IRQHandler .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler .weak DFSDM1_FLT2_IRQHandler .thumb_set DFSDM1_FLT2_IRQHandler,Default_Handler .weak DFSDM1_FLT3_IRQHandler .thumb_set DFSDM1_FLT3_IRQHandler,Default_Handler .weak SWPMI1_IRQHandler .thumb_set SWPMI1_IRQHandler,Default_Handler .weak TIM15_IRQHandler .thumb_set TIM15_IRQHandler,Default_Handler .weak TIM16_IRQHandler .thumb_set TIM16_IRQHandler,Default_Handler .weak TIM17_IRQHandler .thumb_set TIM17_IRQHandler,Default_Handler .weak MDIOS_WKUP_IRQHandler .thumb_set MDIOS_WKUP_IRQHandler,Default_Handler .weak MDIOS_IRQHandler .thumb_set MDIOS_IRQHandler,Default_Handler .weak MDMA_IRQHandler .thumb_set MDMA_IRQHandler,Default_Handler .weak SDMMC2_IRQHandler .thumb_set SDMMC2_IRQHandler,Default_Handler .weak HSEM1_IRQHandler .thumb_set HSEM1_IRQHandler,Default_Handler .weak ADC3_IRQHandler .thumb_set ADC3_IRQHandler,Default_Handler .weak DMAMUX2_OVR_IRQHandler .thumb_set DMAMUX2_OVR_IRQHandler,Default_Handler .weak BDMA_Channel0_IRQHandler .thumb_set BDMA_Channel0_IRQHandler,Default_Handler .weak BDMA_Channel1_IRQHandler .thumb_set BDMA_Channel1_IRQHandler,Default_Handler .weak BDMA_Channel2_IRQHandler .thumb_set BDMA_Channel2_IRQHandler,Default_Handler .weak BDMA_Channel3_IRQHandler .thumb_set BDMA_Channel3_IRQHandler,Default_Handler .weak BDMA_Channel4_IRQHandler .thumb_set BDMA_Channel4_IRQHandler,Default_Handler .weak BDMA_Channel5_IRQHandler .thumb_set BDMA_Channel5_IRQHandler,Default_Handler .weak BDMA_Channel6_IRQHandler .thumb_set BDMA_Channel6_IRQHandler,Default_Handler .weak BDMA_Channel7_IRQHandler .thumb_set BDMA_Channel7_IRQHandler,Default_Handler .weak COMP1_IRQHandler .thumb_set COMP1_IRQHandler,Default_Handler .weak LPTIM2_IRQHandler .thumb_set LPTIM2_IRQHandler,Default_Handler .weak LPTIM3_IRQHandler .thumb_set LPTIM3_IRQHandler,Default_Handler .weak LPTIM4_IRQHandler .thumb_set LPTIM4_IRQHandler,Default_Handler .weak LPTIM5_IRQHandler .thumb_set LPTIM5_IRQHandler,Default_Handler .weak LPUART1_IRQHandler .thumb_set LPUART1_IRQHandler,Default_Handler .weak CRS_IRQHandler .thumb_set CRS_IRQHandler,Default_Handler .weak ECC_IRQHandler .thumb_set ECC_IRQHandler,Default_Handler .weak SAI4_IRQHandler .thumb_set SAI4_IRQHandler,Default_Handler .weak DTS_IRQHandler .thumb_set DTS_IRQHandler,Default_Handler .weak WAKEUP_PIN_IRQHandler .thumb_set WAKEUP_PIN_IRQHandler,Default_Handler .weak OCTOSPI2_IRQHandler .thumb_set OCTOSPI2_IRQHandler,Default_Handler .weak OTFDEC1_IRQHandler .thumb_set OTFDEC1_IRQHandler,Default_Handler .weak OTFDEC2_IRQHandler .thumb_set OTFDEC2_IRQHandler,Default_Handler .weak FMAC_IRQHandler .thumb_set FMAC_IRQHandler,Default_Handler .weak CORDIC_IRQHandler .thumb_set CORDIC_IRQHandler,Default_Handler .weak UART9_IRQHandler .thumb_set UART9_IRQHandler,Default_Handler .weak USART10_IRQHandler .thumb_set USART10_IRQHandler,Default_Handler .weak I2C5_EV_IRQHandler .thumb_set I2C5_EV_IRQHandler,Default_Handler .weak I2C5_ER_IRQHandler .thumb_set I2C5_ER_IRQHandler,Default_Handler .weak FDCAN3_IT0_IRQHandler .thumb_set FDCAN3_IT0_IRQHandler,Default_Handler .weak FDCAN3_IT1_IRQHandler .thumb_set FDCAN3_IT1_IRQHandler,Default_Handler .weak TIM23_IRQHandler .thumb_set TIM23_IRQHandler,Default_Handler .weak TIM24_IRQHandler .thumb_set TIM24_IRQHandler,Default_Handler /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ ================================================ FILE: panda/board/stm32h7/stm32h7_config.h ================================================ #include "stm32h7/inc/stm32h7xx.h" #include "stm32h7/inc/stm32h7xx_hal_gpio_ex.h" #define MCU_IDCODE 0x483U // from the linker script #define APP_START_ADDRESS 0x8020000U #define CORE_FREQ 240U // in Mhz //APB1 - 120Mhz, APB2 - 120Mhz #define APB1_FREQ CORE_FREQ/2U #define APB2_FREQ CORE_FREQ/2U #define BOOTLOADER_ADDRESS 0x1FF09804U // Around (1Mbps / 8 bits/byte / 12 bytes per message) #define CAN_INTERRUPT_RATE 12000U // FIXME: should raise to 16000 ? #define MAX_LED_FADE 10240U // Threshold voltage (mV) for either of the SBUs to be below before deciding harness is connected #define HARNESS_CONNECTED_THRESHOLD 40000U // There are 163 external interrupt sources (see stm32f735xx.h) #define NUM_INTERRUPTS 163U #define TICK_TIMER_IRQ TIM8_BRK_TIM12_IRQn #define TICK_TIMER TIM12 #define MICROSECOND_TIMER TIM2 #define INTERRUPT_TIMER_IRQ TIM6_DAC_IRQn #define INTERRUPT_TIMER TIM6 #define PROVISION_CHUNK_ADDRESS 0x080FFFE0U #define DEVICE_SERIAL_NUMBER_ADDRESS 0x080FFFC0U #ifndef BOOTSTUB #include "main_declarations.h" #else #include "bootstub_declarations.h" #endif #include "libc.h" #include "critical.h" #include "faults.h" #include "drivers/registers.h" #include "drivers/interrupts.h" #include "drivers/gpio.h" #include "stm32h7/peripherals.h" #include "stm32h7/interrupt_handlers.h" #include "drivers/timers.h" #include "stm32h7/lladc.h" #include "stm32h7/board.h" #include "stm32h7/clock.h" #if !defined (BOOTSTUB) && defined(PANDA) #include "drivers/uart.h" #include "stm32h7/lluart.h" #endif #ifdef BOOTSTUB #include "stm32h7/llflash.h" #else #include "stm32h7/llfdcan.h" #endif #include "stm32h7/llusb.h" void early_gpio_float(void) { RCC->AHB4ENR = RCC_AHB4ENR_GPIOAEN | RCC_AHB4ENR_GPIOBEN | RCC_AHB4ENR_GPIOCEN | RCC_AHB4ENR_GPIODEN | RCC_AHB4ENR_GPIOEEN | RCC_AHB4ENR_GPIOFEN | RCC_AHB4ENR_GPIOGEN | RCC_AHB4ENR_GPIOHEN; GPIOA->MODER = 0; GPIOB->MODER = 0; GPIOC->MODER = 0; GPIOD->MODER = 0; GPIOE->MODER = 0; GPIOF->MODER = 0; GPIOG->MODER = 0; GPIOH->MODER = 0; GPIOA->ODR = 0; GPIOB->ODR = 0; GPIOC->ODR = 0; GPIOD->ODR = 0; GPIOE->ODR = 0; GPIOF->ODR = 0; GPIOG->ODR = 0; GPIOH->ODR = 0; GPIOA->PUPDR = 0; GPIOB->PUPDR = 0; GPIOC->PUPDR = 0; GPIOD->PUPDR = 0; GPIOE->PUPDR = 0; GPIOF->PUPDR = 0; GPIOG->PUPDR = 0; GPIOH->PUPDR = 0; } ================================================ FILE: panda/board/stm32h7/stm32h7x5_flash.ld ================================================ /* ****************************************************************************** ** ** File : LinkerScript.ld ** ** Author : Auto-generated by System Workbench for STM32 ** ** Abstract : Linker script for STM32H735ZGTx series ** 1024Kbytes FLASH and 560Kbytes RAM ** ** Set heap size, stack size and stack location according ** to application requirements. ** ** Set memory bank area and size if external memory is used. ** ** Target : STMicroelectronics STM32 ** ** Distribution: The file is distributed “as is,” without any warranty ** of any kind. ** ***************************************************************************** ** @attention ** **

© COPYRIGHT(c) 2019 STMicroelectronics

** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: ** 1. Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright notice, ** this list of conditions and the following disclaimer in the documentation ** and/or other materials provided with the distribution. ** 3. Neither the name of STMicroelectronics nor the names of its contributors ** may be used to endorse or promote products derived from this software ** without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ***************************************************************************** */ /* Entry Point */ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ enter_bootloader_mode = 0x38001FFC; _estack = 0x20020000; /* end of RAM */ _app_start = 0x08020000; /* Reserve Sector 0(128K) for bootloader */ /* Generate a link error if heap and stack don't fit into RAM */ _Min_Heap_Size = 0x200; /* required amount of heap */ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 320K RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 32K RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 16K ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K } /* Define output sections */ SECTIONS { /* The startup code goes first into FLASH */ .isr_vector : { . = ALIGN(4); KEEP(*(.isr_vector)) /* Startup code */ . = ALIGN(4); } >FLASH /* The program code and other data goes into FLASH */ .text : { . = ALIGN(4); *(.text) /* .text sections (code) */ *(.text*) /* .text* sections (code) */ *(.glue_7) /* glue arm to thumb code */ *(.glue_7t) /* glue thumb to arm code */ *(.eh_frame) KEEP (*(.init)) KEEP (*(.fini)) . = ALIGN(4); _etext = .; /* define a global symbols at end of code */ } >FLASH /* Constant data goes into FLASH */ .rodata : { . = ALIGN(4); *(.rodata) /* .rodata sections (constants, strings, etc.) */ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ . = ALIGN(4); } >FLASH .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH .ARM : { __exidx_start = .; *(.ARM.exidx*) __exidx_end = .; } >FLASH .preinit_array : { PROVIDE_HIDDEN (__preinit_array_start = .); KEEP (*(.preinit_array*)) PROVIDE_HIDDEN (__preinit_array_end = .); } >FLASH .init_array : { PROVIDE_HIDDEN (__init_array_start = .); KEEP (*(SORT(.init_array.*))) KEEP (*(.init_array*)) PROVIDE_HIDDEN (__init_array_end = .); } >FLASH .fini_array : { PROVIDE_HIDDEN (__fini_array_start = .); KEEP (*(SORT(.fini_array.*))) KEEP (*(.fini_array*)) PROVIDE_HIDDEN (__fini_array_end = .); } >FLASH /* used by the startup to initialize data */ _sidata = LOADADDR(.data); /* Initialized data sections goes into RAM, load LMA copy after code */ .data : { . = ALIGN(4); _sdata = .; /* create a global symbol at data start */ *(.data) /* .data sections */ *(.data*) /* .data* sections */ . = ALIGN(4); _edata = .; /* define a global symbol at data end */ } >DTCMRAM AT> FLASH /* Uninitialized data section */ . = ALIGN(4); .bss : { /* This is used by the startup in order to initialize the .bss secion */ _sbss = .; /* define a global symbol at bss start */ __bss_start__ = _sbss; *(.bss) *(.bss*) *(COMMON) . = ALIGN(4); _ebss = .; /* define a global symbol at bss end */ __bss_end__ = _ebss; } >DTCMRAM /* User_heap_stack section, used to check that there is enough RAM left */ ._user_heap_stack : { . = ALIGN(8); PROVIDE ( end = . ); PROVIDE ( _end = . ); . = . + _Min_Heap_Size; . = . + _Min_Stack_Size; . = ALIGN(8); } >DTCMRAM .ARM.attributes 0 : { *(.ARM.attributes) } } ================================================ FILE: panda/board/tests/test_rsa.c ================================================ /* gcc -DTEST_RSA test_rsa.c ../crypto/rsa.c ../crypto/sha.c && ./a.out */ #include #include #define MAX_LEN 0x40000 char buf[MAX_LEN]; #include "../crypto/sha.h" #include "../crypto/rsa.h" #include "../obj/cert.h" int main() { FILE *f = fopen("../obj/panda.bin", "rb"); int tlen = fread(buf, 1, MAX_LEN, f); fclose(f); printf("read %d\n", tlen); uint32_t *_app_start = (uint32_t *)buf; int len = _app_start[0]; char digest[SHA_DIGEST_SIZE]; SHA_hash(&_app_start[1], len-4, digest); printf("SHA hash done\n"); if (!RSA_verify(&rsa_key, ((void*)&_app_start[0]) + len, RSANUMBYTES, digest, SHA_DIGEST_SIZE)) { printf("RSA fail\n"); } else { printf("RSA match!!!\n"); } return 0; } ================================================ FILE: panda/certs/debug ================================================ -----BEGIN RSA PRIVATE KEY----- MIICXQIBAAKBgQC948lnRo4x44Rd7Y8bQAML4aKDC4XRx958fHV8K6+FbCaP1Z42 U2kX0yygak0LjoDutpgObmGHZA+Iz3HeUD6VGjr/teN24vPk+A95cRsjt8rgmGQ9 6HNjaNgjR+gl1F9XxFimMzir82Xpl1ekTueJNXa7ia5HVH1nFdiksOKHGQIDAQAB AoGAQuPw2I6EHJLW1/eNB75e1FqhUqRGeYV8nEGDaUBCTi+wzc4kM2LijF/5QnDv vvht9qkfm0XK2VSoHDtnEzcVM/l1ksb68n4R/1nUooAWY6cQI7dCSk/A6yS1EJFg BXsgGbT/65khw9pzBW2zVtMVcVNWFayqfCO1I9WcDdA1x1kCQQDfrhoZTZNoDEUE JKM4fiUdWr1h3Aw8KLJFFexSWeGDwo+qqnujYcKWkHa9qaH1RG5x8Kir9s9Oi4Js mzKwov8fAkEA2VPJPWxJ4vVQpXle6wC1nyoL7s739yxMWFcabvkzDDhlIVBNdVJd gZKsFWV7QnVNdDMjn9D27FwKu3i2D+kKxwJBANp1SMojqO765MEKI1t+YDNONx6H cm+i85Fjuv4nCIjOEdCGVuCYDxtMFpxgO2y3HAMuHx5sm8XDnWsDHLvFRdMCQD7V XqWHnYUk8AAnqy2+ssQl3/VXmZG5GQmhhV74Za3u0C5ljT+SZL6FrYMyKAT67T3f WzllrT6BDglNyTWoZxkCQQCt0XSoGM3603GGYNt6AUlGSgtXSo/2Px7odGUtQoKA FH9q6FVMYpQJ38spZxIGufZJmLP8LLg6YIWJj1F+akxr -----END RSA PRIVATE KEY----- ================================================ FILE: panda/certs/debug.pub ================================================ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC948lnRo4x44Rd7Y8bQAML4aKDC4XRx958fHV8K6+FbCaP1Z42U2kX0yygak0LjoDutpgObmGHZA+Iz3HeUD6VGjr/teN24vPk+A95cRsjt8rgmGQ96HNjaNgjR+gl1F9XxFimMzir82Xpl1ekTueJNXa7ia5HVH1nFdiksOKHGQ== batman@y840 ================================================ FILE: panda/certs/release.pub ================================================ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDGN9GU2nOc0kKq6vdZI5qUMzHt234ngqofrgCFFxL0D2Whex0zACp9gar0HZp+bvtpoSgU/Ev8wexNKr+A9QTradljiuxi5ctrOra9k+wxqNj63Wrcu4+wU5UnJEVf/buV4jCOFffMT8z3PO4imt8LzHuEIC/m/ASKVYyvuvBRQQ== batman@y840 ================================================ FILE: panda/crypto/hash-internal.h ================================================ /* * Copyright 2007 The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Google Inc. nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SYSTEM_CORE_INCLUDE_MINCRYPT_HASH_INTERNAL_H_ #define SYSTEM_CORE_INCLUDE_MINCRYPT_HASH_INTERNAL_H_ #include "stdint.h" #ifdef __cplusplus extern "C" { #endif // __cplusplus struct HASH_CTX; // forward decl typedef struct HASH_VTAB { void (* const init)(struct HASH_CTX*); void (* const update)(struct HASH_CTX*, const void*, int); const uint8_t* (* const final)(struct HASH_CTX*); const uint8_t* (* const hash)(const void*, int, uint8_t*); int size; } HASH_VTAB; typedef struct HASH_CTX { const HASH_VTAB * f; uint64_t count; uint8_t buf[64]; uint32_t state[8]; // upto SHA2 } HASH_CTX; #define HASH_init(ctx) (ctx)->f->init(ctx) #define HASH_update(ctx, data, len) (ctx)->f->update(ctx, data, len) #define HASH_final(ctx) (ctx)->f->final(ctx) #define HASH_hash(data, len, digest) (ctx)->f->hash(data, len, digest) #define HASH_size(ctx) (ctx)->f->size #ifdef __cplusplus } #endif // __cplusplus #endif // SYSTEM_CORE_INCLUDE_MINCRYPT_HASH_INTERNAL_H_ ================================================ FILE: panda/crypto/rsa.c ================================================ /* rsa.c ** ** Copyright 2012, The Android Open Source Project ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** * Neither the name of Google Inc. nor the names of its contributors may ** be used to endorse or promote products derived from this software ** without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO ** EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rsa.h" #include "sha.h" // a[] -= mod static void subM(const RSAPublicKey* key, uint32_t* a) { int64_t A = 0; int i; for (i = 0; i < key->len; ++i) { A += (uint64_t)a[i] - key->n[i]; a[i] = (uint32_t)A; A >>= 32; } } // return a[] >= mod static int geM(const RSAPublicKey* key, const uint32_t* a) { int i; for (i = key->len; i;) { --i; if (a[i] < key->n[i]) return 0; if (a[i] > key->n[i]) return 1; } return 1; // equal } // montgomery c[] += a * b[] / R % mod static void montMulAdd(const RSAPublicKey* key, uint32_t* c, const uint32_t a, const uint32_t* b) { uint64_t A = (uint64_t)a * b[0] + c[0]; uint32_t d0 = (uint32_t)A * key->n0inv; uint64_t B = (uint64_t)d0 * key->n[0] + (uint32_t)A; int i; for (i = 1; i < key->len; ++i) { A = (A >> 32) + (uint64_t)a * b[i] + c[i]; B = (B >> 32) + (uint64_t)d0 * key->n[i] + (uint32_t)A; c[i - 1] = (uint32_t)B; } A = (A >> 32) + (B >> 32); c[i - 1] = (uint32_t)A; if (A >> 32) { subM(key, c); } } // montgomery c[] = a[] * b[] / R % mod static void montMul(const RSAPublicKey* key, uint32_t* c, const uint32_t* a, const uint32_t* b) { int i; for (i = 0; i < key->len; ++i) { c[i] = 0; } for (i = 0; i < key->len; ++i) { montMulAdd(key, c, a[i], b); } } // In-place public exponentiation. // Input and output big-endian byte array in inout. static void modpow(const RSAPublicKey* key, uint8_t* inout) { uint32_t a[RSANUMWORDS]; uint32_t aR[RSANUMWORDS]; uint32_t aaR[RSANUMWORDS]; uint32_t* aaa = 0; int i; // Convert from big endian byte array to little endian word array. for (i = 0; i < key->len; ++i) { uint32_t tmp = (inout[((key->len - 1 - i) * 4) + 0] << 24) | (inout[((key->len - 1 - i) * 4) + 1] << 16) | (inout[((key->len - 1 - i) * 4) + 2] << 8) | (inout[((key->len - 1 - i) * 4) + 3] << 0); a[i] = tmp; } if (key->exponent == 65537) { aaa = aaR; // Re-use location. montMul(key, aR, a, key->rr); // aR = a * RR / R mod M for (i = 0; i < 16; i += 2) { montMul(key, aaR, aR, aR); // aaR = aR * aR / R mod M montMul(key, aR, aaR, aaR); // aR = aaR * aaR / R mod M } montMul(key, aaa, aR, a); // aaa = aR * a / R mod M } else if (key->exponent == 3) { aaa = aR; // Re-use location. montMul(key, aR, a, key->rr); /* aR = a * RR / R mod M */ montMul(key, aaR, aR, aR); /* aaR = aR * aR / R mod M */ montMul(key, aaa, aaR, a); /* aaa = aaR * a / R mod M */ } // Make sure aaa < mod; aaa is at most 1x mod too large. if (geM(key, aaa)) { subM(key, aaa); } // Convert to bigendian byte array for (i = key->len - 1; i >= 0; --i) { uint32_t tmp = aaa[i]; *inout++ = tmp >> 24; *inout++ = tmp >> 16; *inout++ = tmp >> 8; *inout++ = tmp >> 0; } } // Expected PKCS1.5 signature padding bytes, for a keytool RSA signature. // Has the 0-length optional parameter encoded in the ASN1 (as opposed to the // other flavor which omits the optional parameter entirely). This code does not // accept signatures without the optional parameter. /* static const uint8_t sha_padding[RSANUMBYTES] = { 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14, // 20 bytes of hash go here. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; */ static const uint8_t sha_padding_1024[RSANUMBYTES] = { 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, // 20 bytes of hash go here. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; // SHA-1 of PKCS1.5 signature sha_padding for 2048 bit, as above. // At the location of the bytes of the hash all 00 are hashed. /*static const uint8_t kExpectedPadShaRsa2048[SHA_DIGEST_SIZE] = { 0xdc, 0xbd, 0xbe, 0x42, 0xd5, 0xf5, 0xa7, 0x2e, 0x6e, 0xfc, 0xf5, 0x5d, 0xaf, 0x9d, 0xea, 0x68, 0x7c, 0xfb, 0xf1, 0x67 };*/ // Verify a 2048-bit RSA PKCS1.5 signature against an expected hash. // Both e=3 and e=65537 are supported. hash_len may be // SHA_DIGEST_SIZE (== 20) to indicate a SHA-1 hash, or // SHA256_DIGEST_SIZE (== 32) to indicate a SHA-256 hash. No other // values are supported. // // Returns 1 on successful verification, 0 on failure. int RSA_verify(const RSAPublicKey *key, const uint8_t *signature, const int len, const uint8_t *hash, const int hash_len) { uint8_t buf[RSANUMBYTES]; int i; //const uint8_t* padding_hash; if (key->len != RSANUMWORDS) { return 0; // Wrong key passed in. } if (len != sizeof(buf)) { return 0; // Wrong input length. } if (hash_len != SHA_DIGEST_SIZE) { return 0; // Unsupported hash. } if (key->exponent != 3 && key->exponent != 65537) { return 0; // Unsupported exponent. } for (i = 0; i < len; ++i) { // Copy input to local workspace. buf[i] = signature[i]; } modpow(key, buf); // In-place exponentiation. #ifdef TEST_RSA printf("sig\n"); for (i=0;i> (32 - (bits)))) static void SHA1_Transform(SHA_CTX* ctx) { uint32_t W[80]; uint32_t A, B, C, D, E; uint8_t* p = ctx->buf; int t; for(t = 0; t < 16; ++t) { uint32_t tmp = *p++ << 24; tmp |= *p++ << 16; tmp |= *p++ << 8; tmp |= *p++; W[t] = tmp; } for(; t < 80; t++) { W[t] = rol(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]); } A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; E = ctx->state[4]; for(t = 0; t < 80; t++) { uint32_t tmp = rol(5,A) + E + W[t]; if (t < 20) tmp += (D^(B&(C^D))) + 0x5A827999; else if ( t < 40) tmp += (B^C^D) + 0x6ED9EBA1; else if ( t < 60) tmp += ((B&C)|(D&(B|C))) + 0x8F1BBCDC; else tmp += (B^C^D) + 0xCA62C1D6; E = D; D = C; C = rol(30,B); B = A; A = tmp; } ctx->state[0] += A; ctx->state[1] += B; ctx->state[2] += C; ctx->state[3] += D; ctx->state[4] += E; } static const HASH_VTAB SHA_VTAB = { SHA_init, SHA_update, SHA_final, SHA_hash, SHA_DIGEST_SIZE }; void SHA_init(SHA_CTX* ctx) { ctx->f = &SHA_VTAB; ctx->state[0] = 0x67452301; ctx->state[1] = 0xEFCDAB89; ctx->state[2] = 0x98BADCFE; ctx->state[3] = 0x10325476; ctx->state[4] = 0xC3D2E1F0; ctx->count = 0; } void SHA_update(SHA_CTX* ctx, const void* data, int len) { int i = (int) (ctx->count & 63); const uint8_t* p = (const uint8_t*)data; ctx->count += len; while (len--) { ctx->buf[i++] = *p++; if (i == 64) { SHA1_Transform(ctx); i = 0; } } } const uint8_t* SHA_final(SHA_CTX* ctx) { uint8_t *p = ctx->buf; uint64_t cnt = ctx->count * 8; int i; SHA_update(ctx, (uint8_t*)"\x80", 1); while ((ctx->count & 63) != 56) { SHA_update(ctx, (uint8_t*)"\0", 1); } /* Hack - right shift operator with non const argument requires * libgcc.a which is missing in EON * thus expanding for loop from for (i = 0; i < 8; ++i) { uint8_t tmp = (uint8_t) (cnt >> ((7 - i) * 8)); SHA_update(ctx, &tmp, 1); } to */ uint8_t tmp = 0; tmp = (uint8_t) (cnt >> ((7 - 0) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 1) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 2) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 3) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 4) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 5) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 6) * 8)); SHA_update(ctx, &tmp, 1); tmp = (uint8_t) (cnt >> ((7 - 7) * 8)); SHA_update(ctx, &tmp, 1); for (i = 0; i < 5; i++) { uint32_t tmp = ctx->state[i]; *p++ = tmp >> 24; *p++ = tmp >> 16; *p++ = tmp >> 8; *p++ = tmp >> 0; } return ctx->buf; } /* Convenience function */ const uint8_t* SHA_hash(const void* data, int len, uint8_t* digest) { SHA_CTX ctx; SHA_init(&ctx); SHA_update(&ctx, data, len); memcpy(digest, SHA_final(&ctx), SHA_DIGEST_SIZE); return digest; } ================================================ FILE: panda/crypto/sha.h ================================================ /* * Copyright 2005 The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Google Inc. nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO * EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SYSTEM_CORE_INCLUDE_MINCRYPT_SHA1_H_ #define SYSTEM_CORE_INCLUDE_MINCRYPT_SHA1_H_ #include "hash-internal.h" #ifdef __cplusplus extern "C" { #endif // __cplusplus typedef HASH_CTX SHA_CTX; void SHA_init(SHA_CTX* ctx); void SHA_update(SHA_CTX* ctx, const void* data, int len); const uint8_t* SHA_final(SHA_CTX* ctx); // Convenience method. Returns digest address. // NOTE: *digest needs to hold SHA_DIGEST_SIZE bytes. const uint8_t* SHA_hash(const void* data, int len, uint8_t* digest); #define SHA_DIGEST_SIZE 20 #ifdef __cplusplus } #endif // __cplusplus #endif // SYSTEM_CORE_INCLUDE_MINCRYPT_SHA1_H_ ================================================ FILE: panda/crypto/sign.py ================================================ #!/usr/bin/env python3 import os import sys import struct import hashlib from Crypto.PublicKey import RSA import binascii # increment this to make new hardware not run old versions VERSION = 2 rsa = RSA.importKey(open(sys.argv[3]).read()) with open(sys.argv[1], "rb") as f: dat = f.read() print("signing", len(dat), "bytes") with open(sys.argv[2], "wb") as f: if os.getenv("SETLEN") is not None: # add the version at the end dat += b"VERS" + struct.pack("I", VERSION) # add the length at the beginning x = struct.pack("I", len(dat)) + dat[4:] # mock signature of dat[4:] dd = hashlib.sha1(dat[4:]).digest() else: x = dat dd = hashlib.sha1(dat).digest() print("hash:", str(binascii.hexlify(dd), "utf-8")) dd = b"\x00\x01" + b"\xff" * 0x69 + b"\x00" + dd rsa_out = pow(int.from_bytes(dd, byteorder='big', signed=False), rsa.d, rsa.n) sig = (hex(rsa_out)[2:].rjust(0x100, '0')) x += binascii.unhexlify(sig) f.write(x) ================================================ FILE: panda/crypto/stdint.h ================================================ #define uint8_t unsigned char #define uint32_t unsigned int #define int64_t long long #define uint64_t unsigned long long ================================================ FILE: panda/examples/query_fw_versions.py ================================================ #!/usr/bin/env python3 import argparse from tqdm import tqdm from panda import Panda from panda.python.uds import UdsClient, MessageTimeoutError, NegativeResponseError, SESSION_TYPE, DATA_IDENTIFIER_TYPE if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--rxoffset', default="0x8") parser.add_argument('--nonstandard', action='store_true') parser.add_argument('--debug', action='store_true') parser.add_argument('--addr') args = parser.parse_args() if args.addr: addrs = [int(args.addr, base=16)] else: addrs = [0x700 + i for i in range(256)] addrs += [0x18da0000 + (i << 8) + 0xf1 for i in range(256)] results = {} uds_data_ids = {} for std_id in DATA_IDENTIFIER_TYPE: uds_data_ids[std_id.value] = std_id.name if args.nonstandard: for uds_id in range(0xf100,0xf180): uds_data_ids[uds_id] = "IDENTIFICATION_OPTION_VEHICLE_MANUFACTURER_SPECIFIC_DATA_IDENTIFIER" for uds_id in range(0xf1a0,0xf1f0): uds_data_ids[uds_id] = "IDENTIFICATION_OPTION_VEHICLE_MANUFACTURER_SPECIFIC" for uds_id in range(0xf1f0,0xf200): uds_data_ids[uds_id] = "IDENTIFICATION_OPTION_SYSTEM_SUPPLIER_SPECIFIC" panda = Panda() panda.set_safety_mode(Panda.SAFETY_ELM327) panda.set_power_save(0) print("querying addresses ...") with tqdm(addrs) as t: for addr in t: # skip functional broadcast addrs if addr == 0x7df or addr == 0x18db33f1: continue t.set_description(hex(addr)) uds_client = UdsClient(panda, addr, addr + int(args.rxoffset, base=16), bus=1 if panda.has_obd() else 0, timeout=0.2, debug=args.debug) # Check for anything alive at this address, and switch to the highest # available diagnostic session without security access try: uds_client.tester_present() uds_client.diagnostic_session_control(SESSION_TYPE.DEFAULT) uds_client.diagnostic_session_control(SESSION_TYPE.EXTENDED_DIAGNOSTIC) except NegativeResponseError: pass except MessageTimeoutError: continue # Run queries against all standard UDS data identifiers, plus selected # non-standardized identifier ranges if requested resp = {} for uds_data_id in sorted(uds_data_ids): try: data = uds_client.read_data_by_identifier(uds_data_id) # type: ignore if data: resp[uds_data_id] = data except (NegativeResponseError, MessageTimeoutError): pass if resp.keys(): results[addr] = resp if len(results.items()): for addr, resp in results.items(): print(f"\n\n*** Results for address 0x{addr:X} ***\n\n") for rid, dat in resp.items(): print(f"0x{rid:02X} {uds_data_ids[rid]}: {dat}") else: print("no fw versions found!") ================================================ FILE: panda/python/__init__.py ================================================ # python library to interface with panda import datetime import struct import hashlib import socket import usb1 import os import time import traceback import sys from .dfu import PandaDFU, MCU_TYPE_F2, MCU_TYPE_F4, MCU_TYPE_H7 # pylint: disable=import-error from .flash_release import flash_release # noqa pylint: disable=import-error from .update import ensure_st_up_to_date # noqa pylint: disable=import-error from .serial import PandaSerial # noqa pylint: disable=import-error from .isotp import isotp_send, isotp_recv # pylint: disable=import-error from .config import DEFAULT_FW_FN, DEFAULT_H7_FW_FN # noqa pylint: disable=import-error __version__ = '0.0.9' BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../") DEBUG = os.getenv("PANDADEBUG") is not None def parse_can_buffer(dat): ret = [] for j in range(0, len(dat), 0x10): ddat = dat[j:j + 0x10] f1, f2 = struct.unpack("II", ddat[0:8]) extended = 4 if f1 & extended: address = f1 >> 3 else: address = f1 >> 21 dddat = ddat[8:8 + (f2 & 0xF)] if DEBUG: print(f" R 0x{address:x}: 0x{dddat.hex()}") ret.append((address, f2 >> 16, dddat, (f2 >> 4) & 0xFF)) return ret class PandaWifiStreaming(object): def __init__(self, ip="192.168.0.10", port=1338): self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.sock.setblocking(0) self.ip = ip self.port = port self.kick() def kick(self): # must be called at least every 5 seconds self.sock.sendto("hello", (self.ip, self.port)) def can_recv(self): ret = [] while True: try: dat, addr = self.sock.recvfrom(0x200 * 0x10) if addr == (self.ip, self.port): ret += parse_can_buffer(dat) except socket.error as e: if e.errno != 35 and e.errno != 11: traceback.print_exc() break return ret # stupid tunneling of USB over wifi and SPI class WifiHandle(object): def __init__(self, ip="192.168.0.10", port=1337): self.sock = socket.create_connection((ip, port)) def __recv(self): ret = self.sock.recv(0x44) length = struct.unpack("I", ret[0:4])[0] return ret[4:4 + length] def controlWrite(self, request_type, request, value, index, data, timeout=0): # ignore data in reply, panda doesn't use it return self.controlRead(request_type, request, value, index, 0, timeout) def controlRead(self, request_type, request, value, index, length, timeout=0): self.sock.send(struct.pack("HHBBHHH", 0, 0, request_type, request, value, index, length)) return self.__recv() def bulkWrite(self, endpoint, data, timeout=0): if len(data) > 0x10: raise ValueError("Data must not be longer than 0x10") self.sock.send(struct.pack("HH", endpoint, len(data)) + data) self.__recv() # to /dev/null def bulkRead(self, endpoint, length, timeout=0): self.sock.send(struct.pack("HH", endpoint, 0)) return self.__recv() def close(self): self.sock.close() # *** normal mode *** class Panda(object): # matches cereal.car.CarParams.SafetyModel SAFETY_SILENT = 0 SAFETY_HONDA_NIDEC = 1 SAFETY_TOYOTA = 2 SAFETY_ELM327 = 3 SAFETY_GM = 4 SAFETY_HONDA_BOSCH_GIRAFFE = 5 SAFETY_FORD = 6 SAFETY_HYUNDAI = 8 SAFETY_CHRYSLER = 9 SAFETY_TESLA = 10 SAFETY_SUBARU = 11 SAFETY_MAZDA = 13 SAFETY_NISSAN = 14 SAFETY_VOLKSWAGEN_MQB = 15 SAFETY_ALLOUTPUT = 17 SAFETY_GM_ASCM = 18 SAFETY_NOOUTPUT = 19 SAFETY_HONDA_BOSCH_HARNESS = 20 SAFETY_VOLKSWAGEN_PQ = 21 SAFETY_SUBARU_LEGACY = 22 SAFETY_HYUNDAI_LEGACY = 23 SERIAL_DEBUG = 0 SERIAL_ESP = 1 SERIAL_LIN1 = 2 SERIAL_LIN2 = 3 GMLAN_CAN2 = 1 GMLAN_CAN3 = 2 REQUEST_IN = usb1.ENDPOINT_IN | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE REQUEST_OUT = usb1.ENDPOINT_OUT | usb1.TYPE_VENDOR | usb1.RECIPIENT_DEVICE HW_TYPE_UNKNOWN = b'\x00' HW_TYPE_WHITE_PANDA = b'\x01' HW_TYPE_GREY_PANDA = b'\x02' HW_TYPE_BLACK_PANDA = b'\x03' HW_TYPE_PEDAL = b'\x04' HW_TYPE_UNO = b'\x05' HW_TYPE_DOS = b'\x06' HW_TYPE_RED_PANDA = b'\x07' F2_DEVICES = [HW_TYPE_PEDAL] F4_DEVICES = [HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS] H7_DEVICES = [HW_TYPE_RED_PANDA] CLOCK_SOURCE_MODE_DISABLED = 0 CLOCK_SOURCE_MODE_FREE_RUNNING = 1 CLOCK_SOURCE_MODE_EXTERNAL_SYNC = 2 FLAG_HONDA_ALT_BRAKE = 1 FLAG_HONDA_BOSCH_LONG = 2 def __init__(self, serial=None, claim=True): self._serial = serial self._handle = None self.connect(claim) self._mcu_type = self.get_mcu_type() def close(self): self._handle.close() self._handle = None def connect(self, claim=True, wait=False): if self._handle is not None: self.close() if self._serial == "WIFI": self._handle = WifiHandle() print("opening WIFI device") self.wifi = True else: context = usb1.USBContext() self._handle = None self.wifi = False while 1: try: for device in context.getDeviceList(skip_on_error=True): if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]: try: this_serial = device.getSerialNumber() except Exception: continue if self._serial is None or this_serial == self._serial: self._serial = this_serial print("opening device", self._serial, hex(device.getProductID())) self.bootstub = device.getProductID() == 0xddee self._handle = device.open() if sys.platform not in ["win32", "cygwin", "msys", "darwin"]: self._handle.setAutoDetachKernelDriver(True) if claim: self._handle.claimInterface(0) # self._handle.setInterfaceAltSetting(0, 0) # Issue in USB stack break except Exception as e: print("exception", e) traceback.print_exc() if not wait or self._handle is not None: break context = usb1.USBContext() # New context needed so new devices show up assert(self._handle is not None) print("connected") def reset(self, enter_bootstub=False, enter_bootloader=False): # reset try: if enter_bootloader: self._handle.controlWrite(Panda.REQUEST_IN, 0xd1, 0, 0, b'') else: if enter_bootstub: self._handle.controlWrite(Panda.REQUEST_IN, 0xd1, 1, 0, b'') else: self._handle.controlWrite(Panda.REQUEST_IN, 0xd8, 0, 0, b'') except Exception: pass if not enter_bootloader: self.reconnect() def reconnect(self): self.close() time.sleep(1.0) success = False # wait up to 15 seconds for i in range(0, 15): try: self.connect() success = True break except Exception: print("reconnecting is taking %d seconds..." % (i + 1)) try: dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type)) dfu.recover() except Exception: pass time.sleep(1.0) if not success: raise Exception("reconnect failed") @staticmethod def flash_static(handle, code): # confirm flasher is present fr = handle.controlRead(Panda.REQUEST_IN, 0xb0, 0, 0, 0xc) assert fr[4:8] == b"\xde\xad\xd0\x0d" # unlock flash print("flash: unlocking") handle.controlWrite(Panda.REQUEST_IN, 0xb1, 0, 0, b'') # erase sectors 1 through 3 print("flash: erasing") for i in range(1, 4): handle.controlWrite(Panda.REQUEST_IN, 0xb2, i, 0, b'') # flash over EP2 STEP = 0x10 print("flash: flashing") for i in range(0, len(code), STEP): handle.bulkWrite(2, code[i:i + STEP]) # reset print("flash: resetting") try: handle.controlWrite(Panda.REQUEST_IN, 0xd8, 0, 0, b'') except Exception: pass def flash(self, fn=DEFAULT_FW_FN, code=None, reconnect=True): if self._mcu_type == MCU_TYPE_H7 and fn == DEFAULT_FW_FN: fn = DEFAULT_H7_FW_FN print("flash: main version is " + self.get_version()) if not self.bootstub: self.reset(enter_bootstub=True) assert(self.bootstub) if code is None: with open(fn, "rb") as f: code = f.read() # get version print("flash: bootstub version is " + self.get_version()) # do flash Panda.flash_static(self._handle, code) # reconnect if reconnect: self.reconnect() def recover(self, timeout=None): self.reset(enter_bootstub=True) self.reset(enter_bootloader=True) t_start = time.time() while len(PandaDFU.list()) == 0: print("waiting for DFU...") time.sleep(0.1) if timeout is not None and (time.time() - t_start) > timeout: return False dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(self._serial, self._mcu_type)) dfu.recover() # reflash after recover self.connect(True, True) self.flash() return True @staticmethod def flash_ota_st(): ret = os.system("cd %s && make clean && make ota" % (os.path.join(BASEDIR, "board"))) time.sleep(1) return ret == 0 @staticmethod def flash_ota_wifi(release=False): release_str = "RELEASE=1" if release else "" ret = os.system("cd {} && make clean && {} make ota".format(os.path.join(BASEDIR, "boardesp"), release_str)) time.sleep(1) return ret == 0 @staticmethod def list(): context = usb1.USBContext() ret = [] try: for device in context.getDeviceList(skip_on_error=True): if device.getVendorID() == 0xbbaa and device.getProductID() in [0xddcc, 0xddee]: try: ret.append(device.getSerialNumber()) except Exception: continue except Exception: pass # TODO: detect if this is real # ret += ["WIFI"] return ret def call_control_api(self, msg): self._handle.controlWrite(Panda.REQUEST_OUT, msg, 0, 0, b'') # ******************* health ******************* def health(self): dat = self._handle.controlRead(Panda.REQUEST_IN, 0xd2, 0, 0, 44) a = struct.unpack("= 0x800: rir = (addr << 3) | transmit | extended else: rir = (addr << 21) | transmit snd = struct.pack("II", rir, len(dat) | (bus << 4)) + dat snd = snd.ljust(0x10, b'\x00') snds.append(snd) while True: try: if self.wifi: for s in snds: self._handle.bulkWrite(3, s) else: self._handle.bulkWrite(3, b''.join(snds), timeout=timeout) break except (usb1.USBErrorIO, usb1.USBErrorOverflow): print("CAN: BAD SEND MANY, RETRYING") def can_send(self, addr, dat, bus, timeout=CAN_SEND_TIMEOUT_MS): self.can_send_many([[addr, None, dat, bus]], timeout=timeout) def can_recv(self): dat = bytearray() while True: try: dat = self._handle.bulkRead(1, 0x10 * 256) break except (usb1.USBErrorIO, usb1.USBErrorOverflow): print("CAN: BAD RECV, RETRYING") time.sleep(0.1) return parse_can_buffer(dat) def can_clear(self, bus): """Clears all messages from the specified internal CAN ringbuffer as though it were drained. Args: bus (int): can bus number to clear a tx queue, or 0xFFFF to clear the global can rx queue. """ self._handle.controlWrite(Panda.REQUEST_OUT, 0xf1, bus, 0, b'') # ******************* isotp ******************* def isotp_send(self, addr, dat, bus, recvaddr=None, subaddr=None): return isotp_send(self, dat, addr, bus, recvaddr, subaddr) def isotp_recv(self, addr, bus=0, sendaddr=None, subaddr=None): return isotp_recv(self, addr, bus, sendaddr, subaddr) # ******************* serial ******************* def serial_read(self, port_number): ret = [] while 1: lret = bytes(self._handle.controlRead(Panda.REQUEST_IN, 0xe0, port_number, 0, 0x40)) if len(lret) == 0: break ret.append(lret) return b''.join(ret) def serial_write(self, port_number, ln): ret = 0 for i in range(0, len(ln), 0x20): ret += self._handle.bulkWrite(2, struct.pack("B", port_number) + ln[i:i + 0x20]) return ret def serial_clear(self, port_number): """Clears all messages (tx and rx) from the specified internal uart ringbuffer as though it were drained. Args: port_number (int): port number of the uart to clear. """ self._handle.controlWrite(Panda.REQUEST_OUT, 0xf2, port_number, 0, b'') # ******************* kline ******************* # pulse low for wakeup def kline_wakeup(self, k=True, l=True): assert k or l, "must specify k-line, l-line, or both" if DEBUG: print("kline wakeup...") self._handle.controlWrite(Panda.REQUEST_OUT, 0xf0, 2 if k and l else int(l), 0, b'') if DEBUG: print("kline wakeup done") def kline_5baud(self, addr, k=True, l=True): assert k or l, "must specify k-line, l-line, or both" if DEBUG: print("kline 5 baud...") self._handle.controlWrite(Panda.REQUEST_OUT, 0xf4, 2 if k and l else int(l), addr, b'') if DEBUG: print("kline 5 baud done") def kline_drain(self, bus=2): # drain buffer bret = bytearray() while True: ret = self._handle.controlRead(Panda.REQUEST_IN, 0xe0, bus, 0, 0x40) if len(ret) == 0: break elif DEBUG: print(f"kline drain: 0x{ret.hex()}") bret += ret return bytes(bret) def kline_ll_recv(self, cnt, bus=2): echo = bytearray() while len(echo) != cnt: ret = self._handle.controlRead(Panda.REQUEST_OUT, 0xe0, bus, 0, cnt - len(echo)) if DEBUG and len(ret) > 0: print(f"kline recv: 0x{ret.hex()}") echo += ret return bytes(echo) def kline_send(self, x, bus=2, checksum=True): self.kline_drain(bus=bus) if checksum: x += bytes([sum(x) % 0x100]) for i in range(0, len(x), 0xf): ts = x[i:i + 0xf] if DEBUG: print(f"kline send: 0x{ts.hex()}") self._handle.bulkWrite(2, bytes([bus]) + ts) echo = self.kline_ll_recv(len(ts), bus=bus) if echo != ts: print(f"**** ECHO ERROR {i} ****") print(f"0x{echo.hex()}") print(f"0x{ts.hex()}") assert echo == ts def kline_recv(self, bus=2, header_len=4): # read header (last byte is length) msg = self.kline_ll_recv(header_len, bus=bus) # read data (add one byte to length for checksum) msg += self.kline_ll_recv(msg[-1]+1, bus=bus) return msg def send_heartbeat(self): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf3, 0, 0, b'') # disable heartbeat checks for use outside of openpilot # sending a heartbeat will reenable the checks def set_heartbeat_disabled(self): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf8, 0, 0, b'') # ******************* RTC ******************* def set_datetime(self, dt): self._handle.controlWrite(Panda.REQUEST_OUT, 0xa1, int(dt.year), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xa2, int(dt.month), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xa3, int(dt.day), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xa4, int(dt.isoweekday()), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xa5, int(dt.hour), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xa6, int(dt.minute), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xa7, int(dt.second), 0, b'') def get_datetime(self): dat = self._handle.controlRead(Panda.REQUEST_IN, 0xa0, 0, 0, 8) a = struct.unpack("HBBBBBB", dat) return datetime.datetime(a[0], a[1], a[2], a[4], a[5], a[6]) # ******************* IR ******************* def set_ir_power(self, percentage): self._handle.controlWrite(Panda.REQUEST_OUT, 0xb0, int(percentage), 0, b'') # ******************* Fan ****************** def set_fan_power(self, percentage): self._handle.controlWrite(Panda.REQUEST_OUT, 0xb1, int(percentage), 0, b'') def get_fan_rpm(self): dat = self._handle.controlRead(Panda.REQUEST_IN, 0xb2, 0, 0, 2) a = struct.unpack("H", dat) return a[0] # ****************** Phone ***************** def set_phone_power(self, enabled): self._handle.controlWrite(Panda.REQUEST_OUT, 0xb3, int(enabled), 0, b'') # ************** Clock Source ************** def set_clock_source_mode(self, mode): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf5, int(mode), 0, b'') # ****************** Siren ***************** def set_siren(self, enabled): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf6, int(enabled), 0, b'') # ****************** Debug ***************** def set_green_led(self, enabled): self._handle.controlWrite(Panda.REQUEST_OUT, 0xf7, int(enabled), 0, b'') ================================================ FILE: panda/python/config.py ================================================ import os BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../") BOOTSTUB_ADDRESS = 0x8000000 BLOCK_SIZE_FX = 0x800 APP_ADDRESS_FX = 0x8004000 DEVICE_SERIAL_NUMBER_ADDR_FX = 0x1FFF79C0 DEFAULT_FW_FN = os.path.join(BASEDIR, "board", "obj", "panda.bin.signed") DEFAULT_BOOTSTUB_FN = os.path.join(BASEDIR, "board", "obj", "bootstub.panda.bin") BLOCK_SIZE_H7 = 0x400 APP_ADDRESS_H7 = 0x8020000 DEVICE_SERIAL_NUMBER_ADDR_H7 = 0x080FFFC0 DEFAULT_H7_FW_FN = os.path.join(BASEDIR, "board", "obj", "panda_h7.bin.signed") DEFAULT_H7_BOOTSTUB_FN = os.path.join(BASEDIR, "board", "obj", "bootstub.panda_h7.bin") ================================================ FILE: panda/python/dfu.py ================================================ import usb1 import struct import binascii from .config import BOOTSTUB_ADDRESS, APP_ADDRESS_H7, APP_ADDRESS_FX, BLOCK_SIZE_H7, BLOCK_SIZE_FX, DEFAULT_H7_BOOTSTUB_FN, DEFAULT_BOOTSTUB_FN MCU_TYPE_F2 = 0 MCU_TYPE_F4 = 1 MCU_TYPE_H7 = 2 # *** DFU mode *** DFU_DNLOAD = 1 DFU_UPLOAD = 2 DFU_GETSTATUS = 3 DFU_CLRSTATUS = 4 DFU_ABORT = 6 class PandaDFU(object): def __init__(self, dfu_serial): context = usb1.USBContext() for device in context.getDeviceList(skip_on_error=True): if device.getVendorID() == 0x0483 and device.getProductID() == 0xdf11: try: this_dfu_serial = device.open().getASCIIStringDescriptor(3) except Exception: continue if this_dfu_serial == dfu_serial or dfu_serial is None: self._mcu_type = self.get_mcu_type(device) self._handle = device.open() return raise Exception("failed to open " + dfu_serial if dfu_serial is not None else "DFU device") @staticmethod def list(): context = usb1.USBContext() dfu_serials = [] try: for device in context.getDeviceList(skip_on_error=True): if device.getVendorID() == 0x0483 and device.getProductID() == 0xdf11: try: dfu_serials.append(device.open().getASCIIStringDescriptor(3)) except Exception: pass except Exception: pass return dfu_serials @staticmethod def st_serial_to_dfu_serial(st, mcu_type=MCU_TYPE_F4): if st is None or st == "none": return None uid_base = struct.unpack("H" * 6, bytes.fromhex(st)) if mcu_type == MCU_TYPE_H7: return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4], uid_base[3])).upper().decode("utf-8") else: return binascii.hexlify(struct.pack("!HHH", uid_base[1] + uid_base[5], uid_base[0] + uid_base[4] + 0xA, uid_base[3])).upper().decode("utf-8") # TODO: Find a way to detect F4 vs F2 def get_mcu_type(self, dev): return MCU_TYPE_H7 if dev.getbcdDevice() == 512 else MCU_TYPE_F4 def status(self): while 1: dat = self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6) if dat[1] == 0: break def clear_status(self): # Clear status stat = self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6) if stat[4] == 0xa: self._handle.controlRead(0x21, DFU_CLRSTATUS, 0, 0, 0) elif stat[4] == 0x9: self._handle.controlWrite(0x21, DFU_ABORT, 0, 0, b"") self.status() stat = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) def erase(self, address): self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, b"\x41" + struct.pack("I", address)) self.status() def program(self, address, dat, block_size=None): if block_size is None: block_size = len(dat) # Set Address Pointer self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, b"\x21" + struct.pack("I", address)) self.status() # Program dat += b"\xFF" * ((block_size - len(dat)) % block_size) for i in range(0, len(dat) // block_size): ldat = dat[i * block_size:(i + 1) * block_size] print("programming %d with length %d" % (i, len(ldat))) self._handle.controlWrite(0x21, DFU_DNLOAD, 2 + i, 0, ldat) self.status() def program_bootstub(self, code_bootstub): self.clear_status() self.erase(BOOTSTUB_ADDRESS) if self._mcu_type == MCU_TYPE_H7: self.erase(APP_ADDRESS_H7) self.program(BOOTSTUB_ADDRESS, code_bootstub, BLOCK_SIZE_H7) else: self.erase(APP_ADDRESS_FX) self.program(BOOTSTUB_ADDRESS, code_bootstub, BLOCK_SIZE_FX) self.reset() def recover(self): fn = DEFAULT_H7_BOOTSTUB_FN if self._mcu_type == MCU_TYPE_H7 else DEFAULT_BOOTSTUB_FN with open(fn, "rb") as f: code = f.read() self.program_bootstub(code) def reset(self): # **** Reset **** self._handle.controlWrite(0x21, DFU_DNLOAD, 0, 0, b"\x21" + struct.pack("I", BOOTSTUB_ADDRESS)) self.status() try: self._handle.controlWrite(0x21, DFU_DNLOAD, 2, 0, b"") _ = str(self._handle.controlRead(0x21, DFU_GETSTATUS, 0, 0, 6)) except Exception: pass ================================================ FILE: panda/python/flash_release.py ================================================ #!/usr/bin/env python3 import sys import time import requests import json import io def flash_release(path=None, st_serial=None): from panda import Panda, PandaDFU from zipfile import ZipFile def status(x): print("\033[1;32;40m" + x + "\033[00m") if st_serial is not None: # look for Panda panda_list = Panda.list() if len(panda_list) == 0: raise Exception("panda not found, make sure it's connected and your user can access it") elif len(panda_list) > 1: raise Exception("Please only connect one panda") st_serial = panda_list[0] print("Using panda with serial %s" % st_serial) if path is None: print("Fetching latest firmware from github.com/commaai/panda-artifacts") r = requests.get("https://raw.githubusercontent.com/commaai/panda-artifacts/master/latest.json") url = json.loads(r.text)['url'] r = requests.get(url) print("Fetching firmware from %s" % url) path = io.BytesIO(r.content) zf = ZipFile(path) zf.printdir() version = zf.read("version").decode() status("0. Preparing to flash " + str(version)) code_bootstub = zf.read("bootstub.panda.bin") code_panda = zf.read("panda.bin") # enter DFU mode status("1. Entering DFU mode") panda = Panda(st_serial) panda.reset(enter_bootstub=True) panda.reset(enter_bootloader=True) time.sleep(1) # program bootstub status("2. Programming bootstub") dfu = PandaDFU(PandaDFU.st_serial_to_dfu_serial(st_serial)) dfu.program_bootstub(code_bootstub) time.sleep(1) # flash main code status("3. Flashing main code") panda = Panda(st_serial) panda.flash(code=code_panda) panda.close() # check for connection status("4. Verifying version") panda = Panda(st_serial) my_version = panda.get_version() print("dongle id: %s" % panda.get_serial()[0]) print(my_version, "should be", version) assert(str(version) == str(my_version)) # done! status("6. Success!") if __name__ == "__main__": flash_release(*sys.argv[1:]) ================================================ FILE: panda/python/isotp.py ================================================ import binascii import time DEBUG = False def msg(x): if DEBUG: print("S:", binascii.hexlify(x)) if len(x) <= 7: ret = bytes([len(x)]) + x else: assert False return ret.ljust(8, b"\x00") kmsgs = [] def recv(panda, cnt, addr, nbus): global kmsgs ret = [] while len(ret) < cnt: kmsgs += panda.can_recv() nmsgs = [] for ids, ts, dat, bus in kmsgs: if ids == addr and bus == nbus and len(ret) < cnt: ret.append(dat) else: # leave around nmsgs.append((ids, ts, dat, bus)) kmsgs = nmsgs[-256:] return ret def isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr): msg = recv(panda, 1, addr, bus)[0] # TODO: handle other subaddr also communicating assert msg[0] == subaddr if msg[1] & 0xf0 == 0x10: # first tlen = ((msg[1] & 0xf) << 8) | msg[2] dat = msg[3:] # 0 block size? CONTINUE = bytes([subaddr]) + b"\x30" + b"\x00" * 6 panda.can_send(sendaddr, CONTINUE, bus) idx = 1 for mm in recv(panda, (tlen - len(dat) + 5) // 6, addr, bus): assert mm[0] == subaddr assert mm[1] == (0x20 | (idx & 0xF)) dat += mm[2:] idx += 1 elif msg[1] & 0xf0 == 0x00: # single tlen = msg[1] & 0xf dat = msg[2:] else: print(binascii.hexlify(msg)) assert False return dat[0:tlen] # **** import below this line **** def isotp_send(panda, x, addr, bus=0, recvaddr=None, subaddr=None, rate=None): if recvaddr is None: recvaddr = addr + 8 if len(x) <= 7 and subaddr is None: panda.can_send(addr, msg(x), bus) elif len(x) <= 6 and subaddr is not None: panda.can_send(addr, bytes([subaddr]) + msg(x)[0:7], bus) else: if subaddr: ss = bytes([subaddr, 0x10 + (len(x) >> 8), len(x) & 0xFF]) + x[0:5] x = x[5:] else: ss = bytes([0x10 + (len(x) >> 8), len(x) & 0xFF]) + x[0:6] x = x[6:] idx = 1 sends = [] while len(x) > 0: if subaddr: sends.append(((bytes([subaddr, 0x20 + (idx & 0xF)]) + x[0:6]).ljust(8, b"\x00"))) x = x[6:] else: sends.append(((bytes([0x20 + (idx & 0xF)]) + x[0:7]).ljust(8, b"\x00"))) x = x[7:] idx += 1 # actually send panda.can_send(addr, ss, bus) rr = recv(panda, 1, recvaddr, bus)[0] if rr.find(b"\x30\x01") != -1: for s in sends[:-1]: panda.can_send(addr, s, 0) rr = recv(panda, 1, recvaddr, bus)[0] panda.can_send(addr, sends[-1], 0) else: if rate is None: panda.can_send_many([(addr, None, s, bus) for s in sends]) else: for dat in sends: panda.can_send(addr, dat, bus) time.sleep(rate) def isotp_recv(panda, addr, bus=0, sendaddr=None, subaddr=None): if sendaddr is None: sendaddr = addr - 8 if subaddr is not None: dat = isotp_recv_subaddr(panda, addr, bus, sendaddr, subaddr) else: msg = recv(panda, 1, addr, bus)[0] if msg[0] & 0xf0 == 0x10: # first tlen = ((msg[0] & 0xf) << 8) | msg[1] dat = msg[2:] # 0 block size? CONTINUE = b"\x30" + b"\x00" * 7 panda.can_send(sendaddr, CONTINUE, bus) idx = 1 for mm in recv(panda, (tlen - len(dat) + 6) // 7, addr, bus): assert mm[0] == (0x20 | (idx & 0xF)) dat += mm[1:] idx += 1 elif msg[0] & 0xf0 == 0x00: # single tlen = msg[0] & 0xf dat = msg[1:] else: assert False dat = dat[0:tlen] if DEBUG: print("R:", binascii.hexlify(dat)) return dat ================================================ FILE: panda/python/serial.py ================================================ # mimic a python serial port class PandaSerial(object): def __init__(self, panda, port, baud): self.panda = panda self.port = port self.panda.set_uart_parity(self.port, 0) self._baudrate = baud self.panda.set_uart_baud(self.port, baud) self.buf = b"" def read(self, l=1): # noqa: E741 tt = self.panda.serial_read(self.port) if len(tt) > 0: self.buf += tt ret = self.buf[0:l] self.buf = self.buf[l:] return ret def write(self, dat): return self.panda.serial_write(self.port, dat) def close(self): pass def flush(self): pass @property def baudrate(self): return self._baudrate @baudrate.setter def baudrate(self, value): self.panda.set_uart_baud(self.port, value) self._baudrate = value ================================================ FILE: panda/python/uds.py ================================================ #!/usr/bin/env python3 import time import struct from collections import deque from typing import Callable, NamedTuple, Tuple, List, Deque, Generator, Optional, cast from enum import IntEnum class SERVICE_TYPE(IntEnum): DIAGNOSTIC_SESSION_CONTROL = 0x10 ECU_RESET = 0x11 SECURITY_ACCESS = 0x27 COMMUNICATION_CONTROL = 0x28 TESTER_PRESENT = 0x3E ACCESS_TIMING_PARAMETER = 0x83 SECURED_DATA_TRANSMISSION = 0x84 CONTROL_DTC_SETTING = 0x85 RESPONSE_ON_EVENT = 0x86 LINK_CONTROL = 0x87 READ_DATA_BY_IDENTIFIER = 0x22 READ_MEMORY_BY_ADDRESS = 0x23 READ_SCALING_DATA_BY_IDENTIFIER = 0x24 READ_DATA_BY_PERIODIC_IDENTIFIER = 0x2A DYNAMICALLY_DEFINE_DATA_IDENTIFIER = 0x2C WRITE_DATA_BY_IDENTIFIER = 0x2E WRITE_MEMORY_BY_ADDRESS = 0x3D CLEAR_DIAGNOSTIC_INFORMATION = 0x14 READ_DTC_INFORMATION = 0x19 INPUT_OUTPUT_CONTROL_BY_IDENTIFIER = 0x2F ROUTINE_CONTROL = 0x31 REQUEST_DOWNLOAD = 0x34 REQUEST_UPLOAD = 0x35 TRANSFER_DATA = 0x36 REQUEST_TRANSFER_EXIT = 0x37 class SESSION_TYPE(IntEnum): DEFAULT = 1 PROGRAMMING = 2 EXTENDED_DIAGNOSTIC = 3 SAFETY_SYSTEM_DIAGNOSTIC = 4 class RESET_TYPE(IntEnum): HARD = 1 KEY_OFF_ON = 2 SOFT = 3 ENABLE_RAPID_POWER_SHUTDOWN = 4 DISABLE_RAPID_POWER_SHUTDOWN = 5 class ACCESS_TYPE(IntEnum): REQUEST_SEED = 1 SEND_KEY = 2 class CONTROL_TYPE(IntEnum): ENABLE_RX_ENABLE_TX = 0 ENABLE_RX_DISABLE_TX = 1 DISABLE_RX_ENABLE_TX = 2 DISABLE_RX_DISABLE_TX = 3 class MESSAGE_TYPE(IntEnum): NORMAL = 1 NETWORK_MANAGEMENT = 2 NORMAL_AND_NETWORK_MANAGEMENT = 3 class TIMING_PARAMETER_TYPE(IntEnum): READ_EXTENDED_SET = 1 SET_TO_DEFAULT_VALUES = 2 READ_CURRENTLY_ACTIVE = 3 SET_TO_GIVEN_VALUES = 4 class DTC_SETTING_TYPE(IntEnum): ON = 1 OFF = 2 class RESPONSE_EVENT_TYPE(IntEnum): STOP_RESPONSE_ON_EVENT = 0 ON_DTC_STATUS_CHANGE = 1 ON_TIMER_INTERRUPT = 2 ON_CHANGE_OF_DATA_IDENTIFIER = 3 REPORT_ACTIVATED_EVENTS = 4 START_RESPONSE_ON_EVENT = 5 CLEAR_RESPONSE_ON_EVENT = 6 ON_COMPARISON_OF_VALUES = 7 class LINK_CONTROL_TYPE(IntEnum): VERIFY_BAUDRATE_TRANSITION_WITH_FIXED_BAUDRATE = 1 VERIFY_BAUDRATE_TRANSITION_WITH_SPECIFIC_BAUDRATE = 2 TRANSITION_BAUDRATE = 3 class BAUD_RATE_TYPE(IntEnum): PC9600 = 1 PC19200 = 2 PC38400 = 3 PC57600 = 4 PC115200 = 5 CAN125000 = 16 CAN250000 = 17 CAN500000 = 18 CAN1000000 = 19 class DATA_IDENTIFIER_TYPE(IntEnum): BOOT_SOFTWARE_IDENTIFICATION = 0xF180 APPLICATION_SOFTWARE_IDENTIFICATION = 0xF181 APPLICATION_DATA_IDENTIFICATION = 0xF182 BOOT_SOFTWARE_FINGERPRINT = 0xF183 APPLICATION_SOFTWARE_FINGERPRINT = 0xF184 APPLICATION_DATA_FINGERPRINT = 0xF185 ACTIVE_DIAGNOSTIC_SESSION = 0xF186 VEHICLE_MANUFACTURER_SPARE_PART_NUMBER = 0xF187 VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER = 0xF188 VEHICLE_MANUFACTURER_ECU_SOFTWARE_VERSION_NUMBER = 0xF189 SYSTEM_SUPPLIER_IDENTIFIER = 0xF18A ECU_MANUFACTURING_DATE = 0xF18B ECU_SERIAL_NUMBER = 0xF18C SUPPORTED_FUNCTIONAL_UNITS = 0xF18D VEHICLE_MANUFACTURER_KIT_ASSEMBLY_PART_NUMBER = 0xF18E VIN = 0xF190 VEHICLE_MANUFACTURER_ECU_HARDWARE_NUMBER = 0xF191 SYSTEM_SUPPLIER_ECU_HARDWARE_NUMBER = 0xF192 SYSTEM_SUPPLIER_ECU_HARDWARE_VERSION_NUMBER = 0xF193 SYSTEM_SUPPLIER_ECU_SOFTWARE_NUMBER = 0xF194 SYSTEM_SUPPLIER_ECU_SOFTWARE_VERSION_NUMBER = 0xF195 EXHAUST_REGULATION_OR_TYPE_APPROVAL_NUMBER = 0xF196 SYSTEM_NAME_OR_ENGINE_TYPE = 0xF197 REPAIR_SHOP_CODE_OR_TESTER_SERIAL_NUMBER = 0xF198 PROGRAMMING_DATE = 0xF199 CALIBRATION_REPAIR_SHOP_CODE_OR_CALIBRATION_EQUIPMENT_SERIAL_NUMBER = 0xF19A CALIBRATION_DATE = 0xF19B CALIBRATION_EQUIPMENT_SOFTWARE_NUMBER = 0xF19C ECU_INSTALLATION_DATE = 0xF19D ODX_FILE = 0xF19E ENTITY = 0xF19F class TRANSMISSION_MODE_TYPE(IntEnum): SEND_AT_SLOW_RATE = 1 SEND_AT_MEDIUM_RATE = 2 SEND_AT_FAST_RATE = 3 STOP_SENDING = 4 class DYNAMIC_DEFINITION_TYPE(IntEnum): DEFINE_BY_IDENTIFIER = 1 DEFINE_BY_MEMORY_ADDRESS = 2 CLEAR_DYNAMICALLY_DEFINED_DATA_IDENTIFIER = 3 class DynamicSourceDefinition(NamedTuple): data_identifier: int position: int memory_size: int memory_address: int class DTC_GROUP_TYPE(IntEnum): EMISSIONS = 0x000000 ALL = 0xFFFFFF class DTC_REPORT_TYPE(IntEnum): NUMBER_OF_DTC_BY_STATUS_MASK = 0x01 DTC_BY_STATUS_MASK = 0x02 DTC_SNAPSHOT_IDENTIFICATION = 0x03 DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER = 0x04 DTC_SNAPSHOT_RECORD_BY_RECORD_NUMBER = 0x05 DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER = 0x06 NUMBER_OF_DTC_BY_SEVERITY_MASK_RECORD = 0x07 DTC_BY_SEVERITY_MASK_RECORD = 0x08 SEVERITY_INFORMATION_OF_DTC = 0x09 SUPPORTED_DTC = 0x0A FIRST_TEST_FAILED_DTC = 0x0B FIRST_CONFIRMED_DTC = 0x0C MOST_RECENT_TEST_FAILED_DTC = 0x0D MOST_RECENT_CONFIRMED_DTC = 0x0E MIRROR_MEMORY_DTC_BY_STATUS_MASK = 0x0F MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER = 0x10 NUMBER_OF_MIRROR_MEMORY_DTC_BY_STATUS_MASK = 0x11 NUMBER_OF_EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK = 0x12 EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK = 0x13 DTC_FAULT_DETECTION_COUNTER = 0x14 DTC_WITH_PERMANENT_STATUS = 0x15 class DTC_STATUS_MASK_TYPE(IntEnum): TEST_FAILED = 0x01 TEST_FAILED_THIS_OPERATION_CYCLE = 0x02 PENDING_DTC = 0x04 CONFIRMED_DTC = 0x08 TEST_NOT_COMPLETED_SINCE_LAST_CLEAR = 0x10 TEST_FAILED_SINCE_LAST_CLEAR = 0x20 TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE = 0x40 WARNING_INDICATOR_REQUESTED = 0x80 ALL = 0xFF class DTC_SEVERITY_MASK_TYPE(IntEnum): MAINTENANCE_ONLY = 0x20 CHECK_AT_NEXT_HALT = 0x40 CHECK_IMMEDIATELY = 0x80 ALL = 0xE0 class CONTROL_PARAMETER_TYPE(IntEnum): RETURN_CONTROL_TO_ECU = 0 RESET_TO_DEFAULT = 1 FREEZE_CURRENT_STATE = 2 SHORT_TERM_ADJUSTMENT = 3 class ROUTINE_CONTROL_TYPE(IntEnum): START = 1 STOP = 2 REQUEST_RESULTS = 3 class ROUTINE_IDENTIFIER_TYPE(IntEnum): ERASE_MEMORY = 0xFF00 CHECK_PROGRAMMING_DEPENDENCIES = 0xFF01 ERASE_MIRROR_MEMORY_DTCS = 0xFF02 class MessageTimeoutError(Exception): pass class NegativeResponseError(Exception): def __init__(self, message, service_id, error_code): super().__init__() self.message = message self.service_id = service_id self.error_code = error_code def __str__(self): return self.message class InvalidServiceIdError(Exception): pass class InvalidSubFunctioneError(Exception): pass _negative_response_codes = { 0x00: 'positive response', 0x10: 'general reject', 0x11: 'service not supported', 0x12: 'sub-function not supported', 0x13: 'incorrect message length or invalid format', 0x14: 'response too long', 0x21: 'busy repeat request', 0x22: 'conditions not correct', 0x24: 'request sequence error', 0x25: 'no response from subnet component', 0x26: 'failure prevents execution of requested action', 0x31: 'request out of range', 0x33: 'security access denied', 0x35: 'invalid key', 0x36: 'exceed number of attempts', 0x37: 'required time delay not expired', 0x70: 'upload download not accepted', 0x71: 'transfer data suspended', 0x72: 'general programming failure', 0x73: 'wrong block sequence counter', 0x78: 'request correctly received - response pending', 0x7e: 'sub-function not supported in active session', 0x7f: 'service not supported in active session', 0x81: 'rpm too high', 0x82: 'rpm too low', 0x83: 'engine is running', 0x84: 'engine is not running', 0x85: 'engine run time too low', 0x86: 'temperature too high', 0x87: 'temperature too low', 0x88: 'vehicle speed too high', 0x89: 'vehicle speed too low', 0x8a: 'throttle/pedal too high', 0x8b: 'throttle/pedal too low', 0x8c: 'transmission not in neutral', 0x8d: 'transmission not in gear', 0x8f: 'brake switch(es) not closed', 0x90: 'shifter lever not in park', 0x91: 'torque converter clutch locked', 0x92: 'voltage too high', 0x93: 'voltage too low', } class CanClient(): def __init__(self, can_send: Callable[[int, bytes, int], None], can_recv: Callable[[], List[Tuple[int, int, bytes, int]]], tx_addr: int, rx_addr: int, bus: int, sub_addr: int = None, debug: bool = False): self.tx = can_send self.rx = can_recv self.tx_addr = tx_addr self.rx_addr = rx_addr self.rx_buff = deque() # type: Deque[bytes] self.sub_addr = sub_addr self.bus = bus self.debug = debug def _recv_filter(self, bus: int, addr: int) -> bool: # handle functional addresses (switch to first addr to respond) if self.tx_addr == 0x7DF: is_response = addr >= 0x7E8 and addr <= 0x7EF if is_response: if self.debug: print(f"switch to physical addr {hex(addr)}") self.tx_addr = addr - 8 self.rx_addr = addr return is_response if self.tx_addr == 0x18DB33F1: is_response = addr >= 0x18DAF100 and addr <= 0x18DAF1FF if is_response: if self.debug: print(f"switch to physical addr {hex(addr)}") self.tx_addr = 0x18DA00F1 + (addr << 8 & 0xFF00) self.rx_addr = addr return bus == self.bus and addr == self.rx_addr def _recv_buffer(self, drain: bool = False) -> None: while True: msgs = self.rx() if drain: if self.debug: print("CAN-RX: drain - {}".format(len(msgs))) self.rx_buff.clear() else: for rx_addr, _, rx_data, rx_bus in msgs or []: if self._recv_filter(rx_bus, rx_addr) and len(rx_data) > 0: rx_data = bytes(rx_data) # convert bytearray to bytes if self.debug: print(f"CAN-RX: {hex(rx_addr)} - 0x{bytes.hex(rx_data)}") # Cut off sub addr in first byte if self.sub_addr is not None: rx_data = rx_data[1:] self.rx_buff.append(rx_data) # break when non-full buffer is processed if len(msgs) < 254: return def recv(self, drain: bool = False) -> Generator[bytes, None, None]: # buffer rx messages in case two response messages are received at once # (e.g. response pending and success/failure response) self._recv_buffer(drain) try: while True: yield self.rx_buff.popleft() except IndexError: pass # empty def send(self, msgs: List[bytes], delay: float = 0) -> None: for i, msg in enumerate(msgs): if delay and i != 0: if self.debug: print(f"CAN-TX: delay - {delay}") time.sleep(delay) if self.sub_addr is not None: msg = bytes([self.sub_addr]) + msg if self.debug: print(f"CAN-TX: {hex(self.tx_addr)} - 0x{bytes.hex(msg)}") assert len(msg) <= 8 self.tx(self.tx_addr, msg, self.bus) # prevent rx buffer from overflowing on large tx if i % 10 == 9: self._recv_buffer() class IsoTpMessage(): def __init__(self, can_client: CanClient, timeout: float = 1, debug: bool = False, max_len: int = 8): self._can_client = can_client self.timeout = timeout self.debug = debug self.max_len = max_len def send(self, dat: bytes) -> None: # throw away any stale data self._can_client.recv(drain=True) self.tx_dat = dat self.tx_len = len(dat) self.tx_idx = 0 self.tx_done = False self.rx_dat = b"" self.rx_len = 0 self.rx_idx = 0 self.rx_done = False if self.debug: print(f"ISO-TP: REQUEST - 0x{bytes.hex(self.tx_dat)}") self._tx_first_frame() def _tx_first_frame(self) -> None: if self.tx_len < self.max_len: # single frame (send all bytes) if self.debug: print("ISO-TP: TX - single frame") msg = (bytes([self.tx_len]) + self.tx_dat).ljust(self.max_len, b"\x00") self.tx_done = True else: # first frame (send first 6 bytes) if self.debug: print("ISO-TP: TX - first frame") msg = (struct.pack("!H", 0x1000 | self.tx_len) + self.tx_dat[:self.max_len - 2]).ljust(self.max_len - 2, b"\x00") self._can_client.send([msg]) def recv(self) -> Optional[bytes]: start_time = time.time() try: while True: for msg in self._can_client.recv(): self._isotp_rx_next(msg) if self.tx_done and self.rx_done: return self.rx_dat # no timeout indicates non-blocking if self.timeout == 0: return None if time.time() - start_time > self.timeout: raise MessageTimeoutError("timeout waiting for response") finally: if self.debug and self.rx_dat: print(f"ISO-TP: RESPONSE - 0x{bytes.hex(self.rx_dat)}") def _isotp_rx_next(self, rx_data: bytes) -> None: # single rx_frame if rx_data[0] >> 4 == 0x0: self.rx_len = rx_data[0] & 0xFF self.rx_dat = rx_data[1:1 + self.rx_len] self.rx_idx = 0 self.rx_done = True if self.debug: print(f"ISO-TP: RX - single frame - idx={self.rx_idx} done={self.rx_done}") return # first rx_frame if rx_data[0] >> 4 == 0x1: self.rx_len = ((rx_data[0] & 0x0F) << 8) + rx_data[1] self.rx_dat = rx_data[2:] self.rx_idx = 0 self.rx_done = False if self.debug: print(f"ISO-TP: RX - first frame - idx={self.rx_idx} done={self.rx_done}") if self.debug: print("ISO-TP: TX - flow control continue") # send flow control message (send all bytes) msg = b"\x30\x00\x00".ljust(self.max_len, b"\x00") self._can_client.send([msg]) return # consecutive rx frame if rx_data[0] >> 4 == 0x2: assert not self.rx_done, "isotp - rx: consecutive frame with no active frame" self.rx_idx += 1 assert self.rx_idx & 0xF == rx_data[0] & 0xF, "isotp - rx: invalid consecutive frame index" rx_size = self.rx_len - len(self.rx_dat) self.rx_dat += rx_data[1:1 + rx_size] if self.rx_len == len(self.rx_dat): self.rx_done = True if self.debug: print(f"ISO-TP: RX - consecutive frame - idx={self.rx_idx} done={self.rx_done}") return # flow control if rx_data[0] >> 4 == 0x3: assert not self.tx_done, "isotp - rx: flow control with no active frame" assert rx_data[0] != 0x32, "isotp - rx: flow-control overflow/abort" assert rx_data[0] == 0x30 or rx_data[0] == 0x31, "isotp - rx: flow-control transfer state indicator invalid" if rx_data[0] == 0x30: if self.debug: print("ISO-TP: RX - flow control continue") delay_ts = rx_data[2] & 0x7F # scale is 1 milliseconds if first bit == 0, 100 micro seconds if first bit == 1 delay_div = 1000. if rx_data[2] & 0x80 == 0 else 10000. delay_sec = delay_ts / delay_div # first frame = 6 bytes, each consecutive frame = 7 bytes num_bytes = self.max_len - 1 start = 6 + self.tx_idx * num_bytes count = rx_data[1] end = start + count * num_bytes if count > 0 else self.tx_len tx_msgs = [] for i in range(start, end, num_bytes): self.tx_idx += 1 # consecutive tx messages msg = (bytes([0x20 | (self.tx_idx & 0xF)]) + self.tx_dat[i:i + num_bytes]).ljust(self.max_len, b"\x00") tx_msgs.append(msg) # send consecutive tx messages self._can_client.send(tx_msgs, delay=delay_sec) if end >= self.tx_len: self.tx_done = True if self.debug: print(f"ISO-TP: TX - consecutive frame - idx={self.tx_idx} done={self.tx_done}") elif rx_data[0] == 0x31: # wait (do nothing until next flow control message) if self.debug: print("ISO-TP: TX - flow control wait") FUNCTIONAL_ADDRS = [0x7DF, 0x18DB33F1] def get_rx_addr_for_tx_addr(tx_addr, rx_offset=0x8): if tx_addr in FUNCTIONAL_ADDRS: return None if tx_addr < 0xFFF8: # pseudo-standard 11 bit response addr (add 8) works for most manufacturers # allow override; some manufacturers use other offsets for non-OBD2 access return tx_addr + rx_offset if tx_addr > 0x10000000 and tx_addr < 0xFFFFFFFF: # standard 29 bit response addr (flip last two bytes) return (tx_addr & 0xFFFF0000) + (tx_addr << 8 & 0xFF00) + (tx_addr >> 8 & 0xFF) raise ValueError("invalid tx_addr: {}".format(tx_addr)) class UdsClient(): def __init__(self, panda, tx_addr: int, rx_addr: int = None, bus: int = 0, timeout: float = 1, debug: bool = False): self.bus = bus self.tx_addr = tx_addr self.rx_addr = rx_addr if rx_addr is not None else get_rx_addr_for_tx_addr(tx_addr) self.timeout = timeout self.debug = debug self._can_client = CanClient(panda.can_send, panda.can_recv, self.tx_addr, self.rx_addr, self.bus, debug=self.debug) # generic uds request def _uds_request(self, service_type: SERVICE_TYPE, subfunction: int = None, data: bytes = None) -> bytes: req = bytes([service_type]) if subfunction is not None: req += bytes([subfunction]) if data is not None: req += data # send request, wait for response isotp_msg = IsoTpMessage(self._can_client, self.timeout, self.debug) isotp_msg.send(req) while True: resp = isotp_msg.recv() if resp is None: continue resp_sid = resp[0] if len(resp) > 0 else None # negative response if resp_sid == 0x7F: service_id = resp[1] if len(resp) > 1 else -1 try: service_desc = SERVICE_TYPE(service_id).name except BaseException: service_desc = 'NON_STANDARD_SERVICE' error_code = resp[2] if len(resp) > 2 else -1 try: error_desc = _negative_response_codes[error_code] except BaseException: error_desc = resp[3:].hex() # wait for another message if response pending if error_code == 0x78: if self.debug: print("UDS-RX: response pending") continue raise NegativeResponseError('{} - {}'.format(service_desc, error_desc), service_id, error_code) # positive response if service_type + 0x40 != resp_sid: resp_sid_hex = hex(resp_sid) if resp_sid is not None else None raise InvalidServiceIdError('invalid response service id: {}'.format(resp_sid_hex)) if subfunction is not None: resp_sfn = resp[1] if len(resp) > 1 else None if subfunction != resp_sfn: resp_sfn_hex = hex(resp_sfn) if resp_sfn is not None else None raise InvalidSubFunctioneError(f'invalid response subfunction: {resp_sfn_hex:x}') # return data (exclude service id and sub-function id) return resp[(1 if subfunction is None else 2):] # services def diagnostic_session_control(self, session_type: SESSION_TYPE): self._uds_request(SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, subfunction=session_type) def ecu_reset(self, reset_type: RESET_TYPE): resp = self._uds_request(SERVICE_TYPE.ECU_RESET, subfunction=reset_type) power_down_time = None if reset_type == RESET_TYPE.ENABLE_RAPID_POWER_SHUTDOWN: power_down_time = resp[0] return power_down_time def security_access(self, access_type: ACCESS_TYPE, security_key: bytes = None): request_seed = access_type % 2 != 0 if request_seed and security_key is not None: raise ValueError('security_key not allowed') if not request_seed and security_key is None: raise ValueError('security_key is missing') resp = self._uds_request(SERVICE_TYPE.SECURITY_ACCESS, subfunction=access_type, data=security_key) if request_seed: security_seed = resp return security_seed def communication_control(self, control_type: CONTROL_TYPE, message_type: MESSAGE_TYPE): data = bytes([message_type]) self._uds_request(SERVICE_TYPE.COMMUNICATION_CONTROL, subfunction=control_type, data=data) def tester_present(self, ): self._uds_request(SERVICE_TYPE.TESTER_PRESENT, subfunction=0x00) def access_timing_parameter(self, timing_parameter_type: TIMING_PARAMETER_TYPE, parameter_values: bytes = None): write_custom_values = timing_parameter_type == TIMING_PARAMETER_TYPE.SET_TO_GIVEN_VALUES read_values = (timing_parameter_type == TIMING_PARAMETER_TYPE.READ_CURRENTLY_ACTIVE or timing_parameter_type == TIMING_PARAMETER_TYPE.READ_EXTENDED_SET) if not write_custom_values and parameter_values is not None: raise ValueError('parameter_values not allowed') if write_custom_values and parameter_values is None: raise ValueError('parameter_values is missing') resp = self._uds_request(SERVICE_TYPE.ACCESS_TIMING_PARAMETER, subfunction=timing_parameter_type, data=parameter_values) if read_values: # TODO: parse response into values? parameter_values = resp return parameter_values def secured_data_transmission(self, data: bytes): # TODO: split data into multiple input parameters? resp = self._uds_request(SERVICE_TYPE.SECURED_DATA_TRANSMISSION, subfunction=None, data=data) # TODO: parse response into multiple output values? return resp def control_dtc_setting(self, dtc_setting_type: DTC_SETTING_TYPE): self._uds_request(SERVICE_TYPE.CONTROL_DTC_SETTING, subfunction=dtc_setting_type) def response_on_event(self, response_event_type: RESPONSE_EVENT_TYPE, store_event: bool, window_time: int, event_type_record: int, service_response_record: int): if store_event: response_event_type |= 0x20 # type: ignore # TODO: split record parameters into arrays data = bytes([window_time, event_type_record, service_response_record]) resp = self._uds_request(SERVICE_TYPE.RESPONSE_ON_EVENT, subfunction=response_event_type, data=data) if response_event_type == RESPONSE_EVENT_TYPE.REPORT_ACTIVATED_EVENTS: return { "num_of_activated_events": resp[0], "data": resp[1:], # TODO: parse the reset of response } return { "num_of_identified_events": resp[0], "event_window_time": resp[1], "data": resp[2:], # TODO: parse the reset of response } def link_control(self, link_control_type: LINK_CONTROL_TYPE, baud_rate_type: BAUD_RATE_TYPE = None): data: Optional[bytes] if link_control_type == LINK_CONTROL_TYPE.VERIFY_BAUDRATE_TRANSITION_WITH_FIXED_BAUDRATE: # baud_rate_type = BAUD_RATE_TYPE data = bytes([cast(int, baud_rate_type)]) elif link_control_type == LINK_CONTROL_TYPE.VERIFY_BAUDRATE_TRANSITION_WITH_SPECIFIC_BAUDRATE: # baud_rate_type = custom value (3 bytes big-endian) data = struct.pack('!I', baud_rate_type)[1:] else: data = None self._uds_request(SERVICE_TYPE.LINK_CONTROL, subfunction=link_control_type, data=data) def read_data_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE): # TODO: support list of identifiers data = struct.pack('!H', data_identifier_type) resp = self._uds_request(SERVICE_TYPE.READ_DATA_BY_IDENTIFIER, subfunction=None, data=data) resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None if resp_id != data_identifier_type: raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) return resp[2:] def read_memory_by_address(self, memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 1): if memory_address_bytes < 1 or memory_address_bytes > 4: raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) if memory_size_bytes < 1 or memory_size_bytes > 4: raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) data = bytes([memory_size_bytes << 4 | memory_address_bytes]) if memory_address >= 1 << (memory_address_bytes * 8): raise ValueError('invalid memory_address: {}'.format(memory_address)) data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] if memory_size >= 1 << (memory_size_bytes * 8): raise ValueError('invalid memory_size: {}'.format(memory_size)) data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] resp = self._uds_request(SERVICE_TYPE.READ_MEMORY_BY_ADDRESS, subfunction=None, data=data) return resp def read_scaling_data_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE): data = struct.pack('!H', data_identifier_type) resp = self._uds_request(SERVICE_TYPE.READ_SCALING_DATA_BY_IDENTIFIER, subfunction=None, data=data) resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None if resp_id != data_identifier_type: raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) return resp[2:] # TODO: parse the response def read_data_by_periodic_identifier(self, transmission_mode_type: TRANSMISSION_MODE_TYPE, periodic_data_identifier: int): # TODO: support list of identifiers data = bytes([transmission_mode_type, periodic_data_identifier]) self._uds_request(SERVICE_TYPE.READ_DATA_BY_PERIODIC_IDENTIFIER, subfunction=None, data=data) def dynamically_define_data_identifier(self, dynamic_definition_type: DYNAMIC_DEFINITION_TYPE, dynamic_data_identifier: int, source_definitions: List[DynamicSourceDefinition], memory_address_bytes: int = 4, memory_size_bytes: int = 1): if memory_address_bytes < 1 or memory_address_bytes > 4: raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) if memory_size_bytes < 1 or memory_size_bytes > 4: raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) data = struct.pack('!H', dynamic_data_identifier) if dynamic_definition_type == DYNAMIC_DEFINITION_TYPE.DEFINE_BY_IDENTIFIER: for s in source_definitions: data += struct.pack('!H', s.data_identifier) + bytes([s.position, s.memory_size]) elif dynamic_definition_type == DYNAMIC_DEFINITION_TYPE.DEFINE_BY_MEMORY_ADDRESS: data += bytes([memory_size_bytes << 4 | memory_address_bytes]) for s in source_definitions: if s.memory_address >= 1 << (memory_address_bytes * 8): raise ValueError('invalid memory_address: {}'.format(s.memory_address)) data += struct.pack('!I', s.memory_address)[4 - memory_address_bytes:] if s.memory_size >= 1 << (memory_size_bytes * 8): raise ValueError('invalid memory_size: {}'.format(s.memory_size)) data += struct.pack('!I', s.memory_size)[4 - memory_size_bytes:] elif dynamic_definition_type == DYNAMIC_DEFINITION_TYPE.CLEAR_DYNAMICALLY_DEFINED_DATA_IDENTIFIER: pass else: raise ValueError('invalid dynamic identifier type: {}'.format(hex(dynamic_definition_type))) self._uds_request(SERVICE_TYPE.DYNAMICALLY_DEFINE_DATA_IDENTIFIER, subfunction=dynamic_definition_type, data=data) def write_data_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE, data_record: bytes): data = struct.pack('!H', data_identifier_type) + data_record resp = self._uds_request(SERVICE_TYPE.WRITE_DATA_BY_IDENTIFIER, subfunction=None, data=data) resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None if resp_id != data_identifier_type: raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) def write_memory_by_address(self, memory_address: int, memory_size: int, data_record: bytes, memory_address_bytes: int = 4, memory_size_bytes: int = 1): if memory_address_bytes < 1 or memory_address_bytes > 4: raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) if memory_size_bytes < 1 or memory_size_bytes > 4: raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) data = bytes([memory_size_bytes << 4 | memory_address_bytes]) if memory_address >= 1 << (memory_address_bytes * 8): raise ValueError('invalid memory_address: {}'.format(memory_address)) data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] if memory_size >= 1 << (memory_size_bytes * 8): raise ValueError('invalid memory_size: {}'.format(memory_size)) data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] data += data_record self._uds_request(SERVICE_TYPE.WRITE_MEMORY_BY_ADDRESS, subfunction=0x00, data=data) def clear_diagnostic_information(self, dtc_group_type: DTC_GROUP_TYPE): data = struct.pack('!I', dtc_group_type)[1:] # 3 bytes self._uds_request(SERVICE_TYPE.CLEAR_DIAGNOSTIC_INFORMATION, subfunction=None, data=data) def read_dtc_information(self, dtc_report_type: DTC_REPORT_TYPE, dtc_status_mask_type: DTC_STATUS_MASK_TYPE = DTC_STATUS_MASK_TYPE.ALL, dtc_severity_mask_type: DTC_SEVERITY_MASK_TYPE = DTC_SEVERITY_MASK_TYPE.ALL, dtc_mask_record: int = 0xFFFFFF, dtc_snapshot_record_num: int = 0xFF, dtc_extended_record_num: int = 0xFF): data = b'' # dtc_status_mask_type if dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_DTC_BY_STATUS_MASK or \ dtc_report_type == DTC_REPORT_TYPE.DTC_BY_STATUS_MASK or \ dtc_report_type == DTC_REPORT_TYPE.MIRROR_MEMORY_DTC_BY_STATUS_MASK or \ dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_MIRROR_MEMORY_DTC_BY_STATUS_MASK or \ dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK or \ dtc_report_type == DTC_REPORT_TYPE.EMISSIONS_RELATED_OBD_DTC_BY_STATUS_MASK: data += bytes([dtc_status_mask_type]) # dtc_mask_record if dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_IDENTIFICATION or \ dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER or \ dtc_report_type == DTC_REPORT_TYPE.DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER or \ dtc_report_type == DTC_REPORT_TYPE.MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER or \ dtc_report_type == DTC_REPORT_TYPE.SEVERITY_INFORMATION_OF_DTC: data += struct.pack('!I', dtc_mask_record)[1:] # 3 bytes # dtc_snapshot_record_num if dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_IDENTIFICATION or \ dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_RECORD_BY_DTC_NUMBER or \ dtc_report_type == DTC_REPORT_TYPE.DTC_SNAPSHOT_RECORD_BY_RECORD_NUMBER: data += bytes([dtc_snapshot_record_num]) # dtc_extended_record_num if dtc_report_type == DTC_REPORT_TYPE.DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER or \ dtc_report_type == DTC_REPORT_TYPE.MIRROR_MEMORY_DTC_EXTENDED_DATA_RECORD_BY_DTC_NUMBER: data += bytes([dtc_extended_record_num]) # dtc_severity_mask_type if dtc_report_type == DTC_REPORT_TYPE.NUMBER_OF_DTC_BY_SEVERITY_MASK_RECORD or \ dtc_report_type == DTC_REPORT_TYPE.DTC_BY_SEVERITY_MASK_RECORD: data += bytes([dtc_severity_mask_type, dtc_status_mask_type]) resp = self._uds_request(SERVICE_TYPE.READ_DTC_INFORMATION, subfunction=dtc_report_type, data=data) # TODO: parse response return resp def input_output_control_by_identifier(self, data_identifier_type: DATA_IDENTIFIER_TYPE, control_parameter_type: CONTROL_PARAMETER_TYPE, control_option_record: bytes, control_enable_mask_record: bytes = b''): data = struct.pack('!H', data_identifier_type) + bytes([control_parameter_type]) + control_option_record + control_enable_mask_record resp = self._uds_request(SERVICE_TYPE.INPUT_OUTPUT_CONTROL_BY_IDENTIFIER, subfunction=None, data=data) resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None if resp_id != data_identifier_type: raise ValueError('invalid response data identifier: {}'.format(hex(resp_id))) return resp[2:] def routine_control(self, routine_control_type: ROUTINE_CONTROL_TYPE, routine_identifier_type: ROUTINE_IDENTIFIER_TYPE, routine_option_record: bytes = b''): data = struct.pack('!H', routine_identifier_type) + routine_option_record resp = self._uds_request(SERVICE_TYPE.ROUTINE_CONTROL, subfunction=routine_control_type, data=data) resp_id = struct.unpack('!H', resp[0:2])[0] if len(resp) >= 2 else None if resp_id != routine_identifier_type: raise ValueError('invalid response routine identifier: {}'.format(hex(resp_id))) return resp[2:] def request_download(self, memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 4, data_format: int = 0x00): data = bytes([data_format]) if memory_address_bytes < 1 or memory_address_bytes > 4: raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) if memory_size_bytes < 1 or memory_size_bytes > 4: raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) data += bytes([memory_size_bytes << 4 | memory_address_bytes]) if memory_address >= 1 << (memory_address_bytes * 8): raise ValueError('invalid memory_address: {}'.format(memory_address)) data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] if memory_size >= 1 << (memory_size_bytes * 8): raise ValueError('invalid memory_size: {}'.format(memory_size)) data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] resp = self._uds_request(SERVICE_TYPE.REQUEST_DOWNLOAD, subfunction=None, data=data) max_num_bytes_len = resp[0] >> 4 if len(resp) > 0 else 0 if max_num_bytes_len >= 1 and max_num_bytes_len <= 4: max_num_bytes = struct.unpack('!I', (b"\x00" * (4 - max_num_bytes_len)) + resp[1:max_num_bytes_len + 1])[0] else: raise ValueError('invalid max_num_bytes_len: {}'.format(max_num_bytes_len)) return max_num_bytes # max number of bytes per transfer data request def request_upload(self, memory_address: int, memory_size: int, memory_address_bytes: int = 4, memory_size_bytes: int = 4, data_format: int = 0x00): data = bytes([data_format]) if memory_address_bytes < 1 or memory_address_bytes > 4: raise ValueError('invalid memory_address_bytes: {}'.format(memory_address_bytes)) if memory_size_bytes < 1 or memory_size_bytes > 4: raise ValueError('invalid memory_size_bytes: {}'.format(memory_size_bytes)) data += bytes([memory_size_bytes << 4 | memory_address_bytes]) if memory_address >= 1 << (memory_address_bytes * 8): raise ValueError('invalid memory_address: {}'.format(memory_address)) data += struct.pack('!I', memory_address)[4 - memory_address_bytes:] if memory_size >= 1 << (memory_size_bytes * 8): raise ValueError('invalid memory_size: {}'.format(memory_size)) data += struct.pack('!I', memory_size)[4 - memory_size_bytes:] resp = self._uds_request(SERVICE_TYPE.REQUEST_UPLOAD, subfunction=None, data=data) max_num_bytes_len = resp[0] >> 4 if len(resp) > 0 else 0 if max_num_bytes_len >= 1 and max_num_bytes_len <= 4: max_num_bytes = struct.unpack('!I', (b"\x00" * (4 - max_num_bytes_len)) + resp[1:max_num_bytes_len + 1])[0] else: raise ValueError('invalid max_num_bytes_len: {}'.format(max_num_bytes_len)) return max_num_bytes # max number of bytes per transfer data request def transfer_data(self, block_sequence_count: int, data: bytes = b''): data = bytes([block_sequence_count]) + data resp = self._uds_request(SERVICE_TYPE.TRANSFER_DATA, subfunction=None, data=data) resp_id = resp[0] if len(resp) > 0 else None if resp_id != block_sequence_count: raise ValueError('invalid block_sequence_count: {}'.format(resp_id)) return resp[1:] def request_transfer_exit(self): self._uds_request(SERVICE_TYPE.REQUEST_TRANSFER_EXIT, subfunction=None) ================================================ FILE: panda/python/update.py ================================================ #!/usr/bin/env python3 import os import time def ensure_st_up_to_date(): from panda import Panda, PandaDFU, BASEDIR with open(os.path.join(BASEDIR, "VERSION")) as f: repo_version = f.read() repo_version += "-EON" if os.path.isfile('/EON') else "-DEV" panda = None panda_dfu = None while 1: # break on normal mode Panda panda_list = Panda.list() if len(panda_list) > 0: panda = Panda(panda_list[0]) break # flash on DFU mode Panda panda_dfu = PandaDFU.list() if len(panda_dfu) > 0: panda_dfu = PandaDFU(panda_dfu[0]) panda_dfu.recover() print("waiting for board...") time.sleep(1) if panda.bootstub or not panda.get_version().startswith(repo_version): panda.flash() if panda.bootstub: panda.recover() assert(not panda.bootstub) version = str(panda.get_version()) print("%s should be %s" % (version, repo_version)) assert(version.startswith(repo_version)) if __name__ == "__main__": ensure_st_up_to_date() ================================================ FILE: phonelibs/SConscript ================================================ Import('env') env.Library('json11', ['json11/json11.cpp']) env.Append(CPPPATH=[Dir('json11')]) env.Library('kaitai', ['kaitai/kaitaistream.cpp'], CPPDEFINES=['KS_STR_ENCODING_NONE']) ================================================ FILE: phonelibs/android_frameworks_native/get.txt ================================================ git clone https://github.com/CyanogenMod/android_frameworks_native.git && cd android_frameworks_native git reset --hard b22bca465e55618a949d9cbdea665a1a3a831241 cp -r include ~/one/phonelibs/android_frameworks_native/ ================================================ FILE: phonelibs/android_frameworks_native/include/android/asset_manager.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Asset * @{ */ /** * @file asset_manager.h */ #ifndef ANDROID_ASSET_MANAGER_H #define ANDROID_ASSET_MANAGER_H #ifdef __cplusplus extern "C" { #endif struct AAssetManager; /** * {@link AAssetManager} provides access to an application's raw assets by * creating {@link AAsset} objects. * * AAssetManager is a wrapper to the low-level native implementation * of the java {@link AAssetManager}, a pointer can be obtained using * AAssetManager_fromJava(). * * The asset hierarchy may be examined like a filesystem, using * {@link AAssetDir} objects to peruse a single directory. * * A native {@link AAssetManager} pointer may be shared across multiple threads. */ typedef struct AAssetManager AAssetManager; struct AAssetDir; /** * {@link AAssetDir} provides access to a chunk of the asset hierarchy as if * it were a single directory. The contents are populated by the * {@link AAssetManager}. * * The list of files will be sorted in ascending order by ASCII value. */ typedef struct AAssetDir AAssetDir; struct AAsset; /** * {@link AAsset} provides access to a read-only asset. * * {@link AAsset} objects are NOT thread-safe, and should not be shared across * threads. */ typedef struct AAsset AAsset; /** Available access modes for opening assets with {@link AAssetManager_open} */ enum { /** No specific information about how data will be accessed. **/ AASSET_MODE_UNKNOWN = 0, /** Read chunks, and seek forward and backward. */ AASSET_MODE_RANDOM = 1, /** Read sequentially, with an occasional forward seek. */ AASSET_MODE_STREAMING = 2, /** Caller plans to ask for a read-only buffer with all data. */ AASSET_MODE_BUFFER = 3 }; /** * Open the named directory within the asset hierarchy. The directory can then * be inspected with the AAssetDir functions. To open the top-level directory, * pass in "" as the dirName. * * The object returned here should be freed by calling AAssetDir_close(). */ AAssetDir* AAssetManager_openDir(AAssetManager* mgr, const char* dirName); /** * Open an asset. * * The object returned here should be freed by calling AAsset_close(). */ AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode); /** * Iterate over the files in an asset directory. A NULL string is returned * when all the file names have been returned. * * The returned file name is suitable for passing to AAssetManager_open(). * * The string returned here is owned by the AssetDir implementation and is not * guaranteed to remain valid if any other calls are made on this AAssetDir * instance. */ const char* AAssetDir_getNextFileName(AAssetDir* assetDir); /** * Reset the iteration state of AAssetDir_getNextFileName() to the beginning. */ void AAssetDir_rewind(AAssetDir* assetDir); /** * Close an opened AAssetDir, freeing any related resources. */ void AAssetDir_close(AAssetDir* assetDir); /** * Attempt to read 'count' bytes of data from the current offset. * * Returns the number of bytes read, zero on EOF, or < 0 on error. */ int AAsset_read(AAsset* asset, void* buf, size_t count); /** * Seek to the specified offset within the asset data. 'whence' uses the * same constants as lseek()/fseek(). * * Returns the new position on success, or (off_t) -1 on error. */ off_t AAsset_seek(AAsset* asset, off_t offset, int whence); /** * Seek to the specified offset within the asset data. 'whence' uses the * same constants as lseek()/fseek(). * * Uses 64-bit data type for large files as opposed to the 32-bit type used * by AAsset_seek. * * Returns the new position on success, or (off64_t) -1 on error. */ off64_t AAsset_seek64(AAsset* asset, off64_t offset, int whence); /** * Close the asset, freeing all associated resources. */ void AAsset_close(AAsset* asset); /** * Get a pointer to a buffer holding the entire contents of the assset. * * Returns NULL on failure. */ const void* AAsset_getBuffer(AAsset* asset); /** * Report the total size of the asset data. */ off_t AAsset_getLength(AAsset* asset); /** * Report the total size of the asset data. Reports the size using a 64-bit * number insted of 32-bit as AAsset_getLength. */ off64_t AAsset_getLength64(AAsset* asset); /** * Report the total amount of asset data that can be read from the current position. */ off_t AAsset_getRemainingLength(AAsset* asset); /** * Report the total amount of asset data that can be read from the current position. * * Uses a 64-bit number instead of a 32-bit number as AAsset_getRemainingLength does. */ off64_t AAsset_getRemainingLength64(AAsset* asset); /** * Open a new file descriptor that can be used to read the asset data. If the * start or length cannot be represented by a 32-bit number, it will be * truncated. If the file is large, use AAsset_openFileDescriptor64 instead. * * Returns < 0 if direct fd access is not possible (for example, if the asset is * compressed). */ int AAsset_openFileDescriptor(AAsset* asset, off_t* outStart, off_t* outLength); /** * Open a new file descriptor that can be used to read the asset data. * * Uses a 64-bit number for the offset and length instead of 32-bit instead of * as AAsset_openFileDescriptor does. * * Returns < 0 if direct fd access is not possible (for example, if the asset is * compressed). */ int AAsset_openFileDescriptor64(AAsset* asset, off64_t* outStart, off64_t* outLength); /** * Returns whether this asset's internal buffer is allocated in ordinary RAM (i.e. not * mmapped). */ int AAsset_isAllocated(AAsset* asset); #ifdef __cplusplus }; #endif #endif // ANDROID_ASSET_MANAGER_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/asset_manager_jni.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Asset * @{ */ /** * @file asset_manager_jni.h */ #ifndef ANDROID_ASSET_MANAGER_JNI_H #define ANDROID_ASSET_MANAGER_JNI_H #include #include #ifdef __cplusplus extern "C" { #endif /** * Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager * object. Note that the caller is responsible for obtaining and holding a VM reference * to the jobject to prevent its being garbage collected while the native object is * in use. */ AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager); #ifdef __cplusplus }; #endif #endif // ANDROID_ASSET_MANAGER_JNI_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/bitmap.h ================================================ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Bitmap * @{ */ /** * @file bitmap.h */ #ifndef ANDROID_BITMAP_H #define ANDROID_BITMAP_H #include #include #ifdef __cplusplus extern "C" { #endif /** AndroidBitmap functions result code. */ enum { /** Operation was successful. */ ANDROID_BITMAP_RESULT_SUCCESS = 0, /** Bad parameter. */ ANDROID_BITMAP_RESULT_BAD_PARAMETER = -1, /** JNI exception occured. */ ANDROID_BITMAP_RESULT_JNI_EXCEPTION = -2, /** Allocation failed. */ ANDROID_BITMAP_RESULT_ALLOCATION_FAILED = -3, }; /** Backward compatibility: this macro used to be misspelled. */ #define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS /** Bitmap pixel format. */ enum AndroidBitmapFormat { /** No format. */ ANDROID_BITMAP_FORMAT_NONE = 0, /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ ANDROID_BITMAP_FORMAT_RGBA_8888 = 1, /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ ANDROID_BITMAP_FORMAT_RGB_565 = 4, /** Red: 4 bits, Green: 4 bits, Blue: 4 bits, Alpha: 4 bits. **/ ANDROID_BITMAP_FORMAT_RGBA_4444 = 7, /** Deprecated. */ ANDROID_BITMAP_FORMAT_A_8 = 8, }; /** Bitmap info, see AndroidBitmap_getInfo(). */ typedef struct { /** The bitmap width in pixels. */ uint32_t width; /** The bitmap height in pixels. */ uint32_t height; /** The number of byte per row. */ uint32_t stride; /** The bitmap pixel format. See {@link AndroidBitmapFormat} */ int32_t format; /** Unused. */ uint32_t flags; // 0 for now } AndroidBitmapInfo; /** * Given a java bitmap object, fill out the AndroidBitmapInfo struct for it. * If the call fails, the info parameter will be ignored. */ int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info); /** * Given a java bitmap object, attempt to lock the pixel address. * Locking will ensure that the memory for the pixels will not move * until the unlockPixels call, and ensure that, if the pixels had been * previously purged, they will have been restored. * * If this call succeeds, it must be balanced by a call to * AndroidBitmap_unlockPixels, after which time the address of the pixels should * no longer be used. * * If this succeeds, *addrPtr will be set to the pixel address. If the call * fails, addrPtr will be ignored. */ int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr); /** * Call this to balance a successful call to AndroidBitmap_lockPixels. */ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap); #ifdef __cplusplus } #endif #endif /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/configuration.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Configuration * @{ */ /** * @file configuration.h */ #ifndef ANDROID_CONFIGURATION_H #define ANDROID_CONFIGURATION_H #include #ifdef __cplusplus extern "C" { #endif struct AConfiguration; /** * {@link AConfiguration} is an opaque type used to get and set * various subsystem configurations. * * A {@link AConfiguration} pointer can be obtained using: * - AConfiguration_new() * - AConfiguration_fromAssetManager() */ typedef struct AConfiguration AConfiguration; /** * Define flags and constants for various subsystem configurations. */ enum { /** Orientation: not specified. */ ACONFIGURATION_ORIENTATION_ANY = 0x0000, /** * Orientation: value corresponding to the * port * resource qualifier. */ ACONFIGURATION_ORIENTATION_PORT = 0x0001, /** * Orientation: value corresponding to the * land * resource qualifier. */ ACONFIGURATION_ORIENTATION_LAND = 0x0002, /** @deprecated Not currently supported or used. */ ACONFIGURATION_ORIENTATION_SQUARE = 0x0003, /** Touchscreen: not specified. */ ACONFIGURATION_TOUCHSCREEN_ANY = 0x0000, /** * Touchscreen: value corresponding to the * notouch * resource qualifier. */ ACONFIGURATION_TOUCHSCREEN_NOTOUCH = 0x0001, /** @deprecated Not currently supported or used. */ ACONFIGURATION_TOUCHSCREEN_STYLUS = 0x0002, /** * Touchscreen: value corresponding to the * finger * resource qualifier. */ ACONFIGURATION_TOUCHSCREEN_FINGER = 0x0003, /** Density: default density. */ ACONFIGURATION_DENSITY_DEFAULT = 0, /** * Density: value corresponding to the * ldpi * resource qualifier. */ ACONFIGURATION_DENSITY_LOW = 120, /** * Density: value corresponding to the * mdpi * resource qualifier. */ ACONFIGURATION_DENSITY_MEDIUM = 160, /** * Density: value corresponding to the * tvdpi * resource qualifier. */ ACONFIGURATION_DENSITY_TV = 213, /** * Density: value corresponding to the * hdpi * resource qualifier. */ ACONFIGURATION_DENSITY_HIGH = 240, /** * Density: value corresponding to the * xhdpi * resource qualifier. */ ACONFIGURATION_DENSITY_XHIGH = 320, /** * Density: value corresponding to the * xxhdpi * resource qualifier. */ ACONFIGURATION_DENSITY_XXHIGH = 480, /** * Density: value corresponding to the * xxxhdpi * resource qualifier. */ ACONFIGURATION_DENSITY_XXXHIGH = 640, /** Density: any density. */ ACONFIGURATION_DENSITY_ANY = 0xfffe, /** Density: no density specified. */ ACONFIGURATION_DENSITY_NONE = 0xffff, /** Keyboard: not specified. */ ACONFIGURATION_KEYBOARD_ANY = 0x0000, /** * Keyboard: value corresponding to the * nokeys * resource qualifier. */ ACONFIGURATION_KEYBOARD_NOKEYS = 0x0001, /** * Keyboard: value corresponding to the * qwerty * resource qualifier. */ ACONFIGURATION_KEYBOARD_QWERTY = 0x0002, /** * Keyboard: value corresponding to the * 12key * resource qualifier. */ ACONFIGURATION_KEYBOARD_12KEY = 0x0003, /** Navigation: not specified. */ ACONFIGURATION_NAVIGATION_ANY = 0x0000, /** * Navigation: value corresponding to the * nonav * resource qualifier. */ ACONFIGURATION_NAVIGATION_NONAV = 0x0001, /** * Navigation: value corresponding to the * dpad * resource qualifier. */ ACONFIGURATION_NAVIGATION_DPAD = 0x0002, /** * Navigation: value corresponding to the * trackball * resource qualifier. */ ACONFIGURATION_NAVIGATION_TRACKBALL = 0x0003, /** * Navigation: value corresponding to the * wheel * resource qualifier. */ ACONFIGURATION_NAVIGATION_WHEEL = 0x0004, /** Keyboard availability: not specified. */ ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000, /** * Keyboard availability: value corresponding to the * keysexposed * resource qualifier. */ ACONFIGURATION_KEYSHIDDEN_NO = 0x0001, /** * Keyboard availability: value corresponding to the * keyshidden * resource qualifier. */ ACONFIGURATION_KEYSHIDDEN_YES = 0x0002, /** * Keyboard availability: value corresponding to the * keyssoft * resource qualifier. */ ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003, /** Navigation availability: not specified. */ ACONFIGURATION_NAVHIDDEN_ANY = 0x0000, /** * Navigation availability: value corresponding to the * navexposed * resource qualifier. */ ACONFIGURATION_NAVHIDDEN_NO = 0x0001, /** * Navigation availability: value corresponding to the * navhidden * resource qualifier. */ ACONFIGURATION_NAVHIDDEN_YES = 0x0002, /** Screen size: not specified. */ ACONFIGURATION_SCREENSIZE_ANY = 0x00, /** * Screen size: value indicating the screen is at least * approximately 320x426 dp units, corresponding to the * small * resource qualifier. */ ACONFIGURATION_SCREENSIZE_SMALL = 0x01, /** * Screen size: value indicating the screen is at least * approximately 320x470 dp units, corresponding to the * normal * resource qualifier. */ ACONFIGURATION_SCREENSIZE_NORMAL = 0x02, /** * Screen size: value indicating the screen is at least * approximately 480x640 dp units, corresponding to the * large * resource qualifier. */ ACONFIGURATION_SCREENSIZE_LARGE = 0x03, /** * Screen size: value indicating the screen is at least * approximately 720x960 dp units, corresponding to the * xlarge * resource qualifier. */ ACONFIGURATION_SCREENSIZE_XLARGE = 0x04, /** Screen layout: not specified. */ ACONFIGURATION_SCREENLONG_ANY = 0x00, /** * Screen layout: value that corresponds to the * notlong * resource qualifier. */ ACONFIGURATION_SCREENLONG_NO = 0x1, /** * Screen layout: value that corresponds to the * long * resource qualifier. */ ACONFIGURATION_SCREENLONG_YES = 0x2, ACONFIGURATION_SCREENROUND_ANY = 0x00, ACONFIGURATION_SCREENROUND_NO = 0x1, ACONFIGURATION_SCREENROUND_YES = 0x2, /** UI mode: not specified. */ ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00, /** * UI mode: value that corresponds to * no * UI mode type resource qualifier specified. */ ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01, /** * UI mode: value that corresponds to * desk resource qualifier specified. */ ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02, /** * UI mode: value that corresponds to * car resource qualifier specified. */ ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03, /** * UI mode: value that corresponds to * television resource qualifier specified. */ ACONFIGURATION_UI_MODE_TYPE_TELEVISION = 0x04, /** * UI mode: value that corresponds to * appliance resource qualifier specified. */ ACONFIGURATION_UI_MODE_TYPE_APPLIANCE = 0x05, /** * UI mode: value that corresponds to * watch resource qualifier specified. */ ACONFIGURATION_UI_MODE_TYPE_WATCH = 0x06, /** UI night mode: not specified.*/ ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00, /** * UI night mode: value that corresponds to * notnight resource qualifier specified. */ ACONFIGURATION_UI_MODE_NIGHT_NO = 0x1, /** * UI night mode: value that corresponds to * night resource qualifier specified. */ ACONFIGURATION_UI_MODE_NIGHT_YES = 0x2, /** Screen width DPI: not specified. */ ACONFIGURATION_SCREEN_WIDTH_DP_ANY = 0x0000, /** Screen height DPI: not specified. */ ACONFIGURATION_SCREEN_HEIGHT_DP_ANY = 0x0000, /** Smallest screen width DPI: not specified.*/ ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY = 0x0000, /** Layout direction: not specified. */ ACONFIGURATION_LAYOUTDIR_ANY = 0x00, /** * Layout direction: value that corresponds to * ldltr resource qualifier specified. */ ACONFIGURATION_LAYOUTDIR_LTR = 0x01, /** * Layout direction: value that corresponds to * ldrtl resource qualifier specified. */ ACONFIGURATION_LAYOUTDIR_RTL = 0x02, /** * Bit mask for * mcc * configuration. */ ACONFIGURATION_MCC = 0x0001, /** * Bit mask for * mnc * configuration. */ ACONFIGURATION_MNC = 0x0002, /** * Bit mask for * locale * configuration. */ ACONFIGURATION_LOCALE = 0x0004, /** * Bit mask for * touchscreen * configuration. */ ACONFIGURATION_TOUCHSCREEN = 0x0008, /** * Bit mask for * keyboard * configuration. */ ACONFIGURATION_KEYBOARD = 0x0010, /** * Bit mask for * keyboardHidden * configuration. */ ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020, /** * Bit mask for * navigation * configuration. */ ACONFIGURATION_NAVIGATION = 0x0040, /** * Bit mask for * orientation * configuration. */ ACONFIGURATION_ORIENTATION = 0x0080, /** * Bit mask for * density * configuration. */ ACONFIGURATION_DENSITY = 0x0100, /** * Bit mask for * screen size * configuration. */ ACONFIGURATION_SCREEN_SIZE = 0x0200, /** * Bit mask for * platform version * configuration. */ ACONFIGURATION_VERSION = 0x0400, /** * Bit mask for screen layout configuration. */ ACONFIGURATION_SCREEN_LAYOUT = 0x0800, /** * Bit mask for * ui mode * configuration. */ ACONFIGURATION_UI_MODE = 0x1000, /** * Bit mask for * smallest screen width * configuration. */ ACONFIGURATION_SMALLEST_SCREEN_SIZE = 0x2000, /** * Bit mask for * layout direction * configuration. */ ACONFIGURATION_LAYOUTDIR = 0x4000, ACONFIGURATION_SCREEN_ROUND = 0x8000, /** * Constant used to to represent MNC (Mobile Network Code) zero. * 0 cannot be used, since it is used to represent an undefined MNC. */ ACONFIGURATION_MNC_ZERO = 0xffff, }; /** * Create a new AConfiguration, initialized with no values set. */ AConfiguration* AConfiguration_new(); /** * Free an AConfiguration that was previously created with * AConfiguration_new(). */ void AConfiguration_delete(AConfiguration* config); /** * Create and return a new AConfiguration based on the current configuration in * use in the given {@link AAssetManager}. */ void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am); /** * Copy the contents of 'src' to 'dest'. */ void AConfiguration_copy(AConfiguration* dest, AConfiguration* src); /** * Return the current MCC set in the configuration. 0 if not set. */ int32_t AConfiguration_getMcc(AConfiguration* config); /** * Set the current MCC in the configuration. 0 to clear. */ void AConfiguration_setMcc(AConfiguration* config, int32_t mcc); /** * Return the current MNC set in the configuration. 0 if not set. */ int32_t AConfiguration_getMnc(AConfiguration* config); /** * Set the current MNC in the configuration. 0 to clear. */ void AConfiguration_setMnc(AConfiguration* config, int32_t mnc); /** * Return the current language code set in the configuration. The output will * be filled with an array of two characters. They are not 0-terminated. If * a language is not set, they will be 0. */ void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage); /** * Set the current language code in the configuration, from the first two * characters in the string. */ void AConfiguration_setLanguage(AConfiguration* config, const char* language); /** * Return the current country code set in the configuration. The output will * be filled with an array of two characters. They are not 0-terminated. If * a country is not set, they will be 0. */ void AConfiguration_getCountry(AConfiguration* config, char* outCountry); /** * Set the current country code in the configuration, from the first two * characters in the string. */ void AConfiguration_setCountry(AConfiguration* config, const char* country); /** * Return the current ACONFIGURATION_ORIENTATION_* set in the configuration. */ int32_t AConfiguration_getOrientation(AConfiguration* config); /** * Set the current orientation in the configuration. */ void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation); /** * Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration. */ int32_t AConfiguration_getTouchscreen(AConfiguration* config); /** * Set the current touchscreen in the configuration. */ void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen); /** * Return the current ACONFIGURATION_DENSITY_* set in the configuration. */ int32_t AConfiguration_getDensity(AConfiguration* config); /** * Set the current density in the configuration. */ void AConfiguration_setDensity(AConfiguration* config, int32_t density); /** * Return the current ACONFIGURATION_KEYBOARD_* set in the configuration. */ int32_t AConfiguration_getKeyboard(AConfiguration* config); /** * Set the current keyboard in the configuration. */ void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard); /** * Return the current ACONFIGURATION_NAVIGATION_* set in the configuration. */ int32_t AConfiguration_getNavigation(AConfiguration* config); /** * Set the current navigation in the configuration. */ void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation); /** * Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration. */ int32_t AConfiguration_getKeysHidden(AConfiguration* config); /** * Set the current keys hidden in the configuration. */ void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden); /** * Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration. */ int32_t AConfiguration_getNavHidden(AConfiguration* config); /** * Set the current nav hidden in the configuration. */ void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden); /** * Return the current SDK (API) version set in the configuration. */ int32_t AConfiguration_getSdkVersion(AConfiguration* config); /** * Set the current SDK version in the configuration. */ void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion); /** * Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration. */ int32_t AConfiguration_getScreenSize(AConfiguration* config); /** * Set the current screen size in the configuration. */ void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize); /** * Return the current ACONFIGURATION_SCREENLONG_* set in the configuration. */ int32_t AConfiguration_getScreenLong(AConfiguration* config); /** * Set the current screen long in the configuration. */ void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong); /** * Return the current ACONFIGURATION_SCREENROUND_* set in the configuration. */ int32_t AConfiguration_getScreenRound(AConfiguration* config); /** * Set the current screen round in the configuration. */ void AConfiguration_setScreenRound(AConfiguration* config, int32_t screenRound); /** * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration. */ int32_t AConfiguration_getUiModeType(AConfiguration* config); /** * Set the current UI mode type in the configuration. */ void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType); /** * Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration. */ int32_t AConfiguration_getUiModeNight(AConfiguration* config); /** * Set the current UI mode night in the configuration. */ void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight); /** * Return the current configuration screen width in dp units, or * ACONFIGURATION_SCREEN_WIDTH_DP_ANY if not set. */ int32_t AConfiguration_getScreenWidthDp(AConfiguration* config); /** * Set the configuration's current screen width in dp units. */ void AConfiguration_setScreenWidthDp(AConfiguration* config, int32_t value); /** * Return the current configuration screen height in dp units, or * ACONFIGURATION_SCREEN_HEIGHT_DP_ANY if not set. */ int32_t AConfiguration_getScreenHeightDp(AConfiguration* config); /** * Set the configuration's current screen width in dp units. */ void AConfiguration_setScreenHeightDp(AConfiguration* config, int32_t value); /** * Return the configuration's smallest screen width in dp units, or * ACONFIGURATION_SMALLEST_SCREEN_WIDTH_DP_ANY if not set. */ int32_t AConfiguration_getSmallestScreenWidthDp(AConfiguration* config); /** * Set the configuration's smallest screen width in dp units. */ void AConfiguration_setSmallestScreenWidthDp(AConfiguration* config, int32_t value); /** * Return the configuration's layout direction, or * ACONFIGURATION_LAYOUTDIR_ANY if not set. */ int32_t AConfiguration_getLayoutDirection(AConfiguration* config); /** * Set the configuration's layout direction. */ void AConfiguration_setLayoutDirection(AConfiguration* config, int32_t value); /** * Perform a diff between two configurations. Returns a bit mask of * ACONFIGURATION_* constants, each bit set meaning that configuration element * is different between them. */ int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2); /** * Determine whether 'base' is a valid configuration for use within the * environment 'requested'. Returns 0 if there are any values in 'base' * that conflict with 'requested'. Returns 1 if it does not conflict. */ int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested); /** * Determine whether the configuration in 'test' is better than the existing * configuration in 'base'. If 'requested' is non-NULL, this decision is based * on the overall configuration given there. If it is NULL, this decision is * simply based on which configuration is more specific. Returns non-0 if * 'test' is better than 'base'. * * This assumes you have already filtered the configurations with * AConfiguration_match(). */ int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test, AConfiguration* requested); #ifdef __cplusplus }; #endif #endif // ANDROID_CONFIGURATION_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/input.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Input * @{ */ /** * @file input.h */ #ifndef _ANDROID_INPUT_H #define _ANDROID_INPUT_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit). * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ /* * Structures and functions to receive and process input events in * native code. * * NOTE: These functions MUST be implemented by /system/lib/libui.so */ #include #include #include #include #ifdef __cplusplus extern "C" { #endif /** * Key states (may be returned by queries about the current state of a * particular key code, scan code or switch). */ enum { /** The key state is unknown or the requested key itself is not supported. */ AKEY_STATE_UNKNOWN = -1, /** The key is up. */ AKEY_STATE_UP = 0, /** The key is down. */ AKEY_STATE_DOWN = 1, /** The key is down but is a virtual key press that is being emulated by the system. */ AKEY_STATE_VIRTUAL = 2 }; /** * Meta key / modifer state. */ enum { /** No meta keys are pressed. */ AMETA_NONE = 0, /** This mask is used to check whether one of the ALT meta keys is pressed. */ AMETA_ALT_ON = 0x02, /** This mask is used to check whether the left ALT meta key is pressed. */ AMETA_ALT_LEFT_ON = 0x10, /** This mask is used to check whether the right ALT meta key is pressed. */ AMETA_ALT_RIGHT_ON = 0x20, /** This mask is used to check whether one of the SHIFT meta keys is pressed. */ AMETA_SHIFT_ON = 0x01, /** This mask is used to check whether the left SHIFT meta key is pressed. */ AMETA_SHIFT_LEFT_ON = 0x40, /** This mask is used to check whether the right SHIFT meta key is pressed. */ AMETA_SHIFT_RIGHT_ON = 0x80, /** This mask is used to check whether the SYM meta key is pressed. */ AMETA_SYM_ON = 0x04, /** This mask is used to check whether the FUNCTION meta key is pressed. */ AMETA_FUNCTION_ON = 0x08, /** This mask is used to check whether one of the CTRL meta keys is pressed. */ AMETA_CTRL_ON = 0x1000, /** This mask is used to check whether the left CTRL meta key is pressed. */ AMETA_CTRL_LEFT_ON = 0x2000, /** This mask is used to check whether the right CTRL meta key is pressed. */ AMETA_CTRL_RIGHT_ON = 0x4000, /** This mask is used to check whether one of the META meta keys is pressed. */ AMETA_META_ON = 0x10000, /** This mask is used to check whether the left META meta key is pressed. */ AMETA_META_LEFT_ON = 0x20000, /** This mask is used to check whether the right META meta key is pressed. */ AMETA_META_RIGHT_ON = 0x40000, /** This mask is used to check whether the CAPS LOCK meta key is on. */ AMETA_CAPS_LOCK_ON = 0x100000, /** This mask is used to check whether the NUM LOCK meta key is on. */ AMETA_NUM_LOCK_ON = 0x200000, /** This mask is used to check whether the SCROLL LOCK meta key is on. */ AMETA_SCROLL_LOCK_ON = 0x400000, }; struct AInputEvent; /** * Input events. * * Input events are opaque structures. Use the provided accessors functions to * read their properties. */ typedef struct AInputEvent AInputEvent; /** * Input event types. */ enum { /** Indicates that the input event is a key event. */ AINPUT_EVENT_TYPE_KEY = 1, /** Indicates that the input event is a motion event. */ AINPUT_EVENT_TYPE_MOTION = 2 }; /** * Key event actions. */ enum { /** The key has been pressed down. */ AKEY_EVENT_ACTION_DOWN = 0, /** The key has been released. */ AKEY_EVENT_ACTION_UP = 1, /** * Multiple duplicate key events have occurred in a row, or a * complex string is being delivered. The repeat_count property * of the key event contains the number of times the given key * code should be executed. */ AKEY_EVENT_ACTION_MULTIPLE = 2 }; /** * Key event flags. */ enum { /** This mask is set if the device woke because of this key event. */ AKEY_EVENT_FLAG_WOKE_HERE = 0x1, /** This mask is set if the key event was generated by a software keyboard. */ AKEY_EVENT_FLAG_SOFT_KEYBOARD = 0x2, /** This mask is set if we don't want the key event to cause us to leave touch mode. */ AKEY_EVENT_FLAG_KEEP_TOUCH_MODE = 0x4, /** * This mask is set if an event was known to come from a trusted * part of the system. That is, the event is known to come from * the user, and could not have been spoofed by a third party * component. */ AKEY_EVENT_FLAG_FROM_SYSTEM = 0x8, /** * This mask is used for compatibility, to identify enter keys that are * coming from an IME whose enter key has been auto-labelled "next" or * "done". This allows TextView to dispatch these as normal enter keys * for old applications, but still do the appropriate action when * receiving them. */ AKEY_EVENT_FLAG_EDITOR_ACTION = 0x10, /** * When associated with up key events, this indicates that the key press * has been canceled. Typically this is used with virtual touch screen * keys, where the user can slide from the virtual key area on to the * display: in that case, the application will receive a canceled up * event and should not perform the action normally associated with the * key. Note that for this to work, the application can not perform an * action for a key until it receives an up or the long press timeout has * expired. */ AKEY_EVENT_FLAG_CANCELED = 0x20, /** * This key event was generated by a virtual (on-screen) hard key area. * Typically this is an area of the touchscreen, outside of the regular * display, dedicated to "hardware" buttons. */ AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY = 0x40, /** * This flag is set for the first key repeat that occurs after the * long press timeout. */ AKEY_EVENT_FLAG_LONG_PRESS = 0x80, /** * Set when a key event has AKEY_EVENT_FLAG_CANCELED set because a long * press action was executed while it was down. */ AKEY_EVENT_FLAG_CANCELED_LONG_PRESS = 0x100, /** * Set for AKEY_EVENT_ACTION_UP when this event's key code is still being * tracked from its initial down. That is, somebody requested that tracking * started on the key down and a long press has not caused * the tracking to be canceled. */ AKEY_EVENT_FLAG_TRACKING = 0x200, /** * Set when a key event has been synthesized to implement default behavior * for an event that the application did not handle. * Fallback key events are generated by unhandled trackball motions * (to emulate a directional keypad) and by certain unhandled key presses * that are declared in the key map (such as special function numeric keypad * keys when numlock is off). */ AKEY_EVENT_FLAG_FALLBACK = 0x400, }; /** * Bit shift for the action bits holding the pointer index as * defined by AMOTION_EVENT_ACTION_POINTER_INDEX_MASK. */ #define AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT 8 /** Motion event actions */ enum { /** Bit mask of the parts of the action code that are the action itself. */ AMOTION_EVENT_ACTION_MASK = 0xff, /** * Bits in the action code that represent a pointer index, used with * AMOTION_EVENT_ACTION_POINTER_DOWN and AMOTION_EVENT_ACTION_POINTER_UP. Shifting * down by AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT provides the actual pointer * index where the data for the pointer going up or down can be found. */ AMOTION_EVENT_ACTION_POINTER_INDEX_MASK = 0xff00, /** A pressed gesture has started, the motion contains the initial starting location. */ AMOTION_EVENT_ACTION_DOWN = 0, /** * A pressed gesture has finished, the motion contains the final release location * as well as any intermediate points since the last down or move event. */ AMOTION_EVENT_ACTION_UP = 1, /** * A change has happened during a press gesture (between AMOTION_EVENT_ACTION_DOWN and * AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as * any intermediate points since the last down or move event. */ AMOTION_EVENT_ACTION_MOVE = 2, /** * The current gesture has been aborted. * You will not receive any more points in it. You should treat this as * an up event, but not perform any action that you normally would. */ AMOTION_EVENT_ACTION_CANCEL = 3, /** * A movement has happened outside of the normal bounds of the UI element. * This does not provide a full gesture, but only the initial location of the movement/touch. */ AMOTION_EVENT_ACTION_OUTSIDE = 4, /** * A non-primary pointer has gone down. * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. */ AMOTION_EVENT_ACTION_POINTER_DOWN = 5, /** * A non-primary pointer has gone up. * The bits in AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed. */ AMOTION_EVENT_ACTION_POINTER_UP = 6, /** * A change happened but the pointer is not down (unlike AMOTION_EVENT_ACTION_MOVE). * The motion contains the most recent point, as well as any intermediate points since * the last hover move event. */ AMOTION_EVENT_ACTION_HOVER_MOVE = 7, /** * The motion event contains relative vertical and/or horizontal scroll offsets. * Use getAxisValue to retrieve the information from AMOTION_EVENT_AXIS_VSCROLL * and AMOTION_EVENT_AXIS_HSCROLL. * The pointer may or may not be down when this event is dispatched. * This action is always delivered to the winder under the pointer, which * may not be the window currently touched. */ AMOTION_EVENT_ACTION_SCROLL = 8, /** The pointer is not down but has entered the boundaries of a window or view. */ AMOTION_EVENT_ACTION_HOVER_ENTER = 9, /** The pointer is not down but has exited the boundaries of a window or view. */ AMOTION_EVENT_ACTION_HOVER_EXIT = 10, /* One or more buttons have been pressed. */ AMOTION_EVENT_ACTION_BUTTON_PRESS = 11, /* One or more buttons have been released. */ AMOTION_EVENT_ACTION_BUTTON_RELEASE = 12, }; /** * Motion event flags. */ enum { /** * This flag indicates that the window that received this motion event is partly * or wholly obscured by another visible window above it. This flag is set to true * even if the event did not directly pass through the obscured area. * A security sensitive application can check this flag to identify situations in which * a malicious application may have covered up part of its content for the purpose * of misleading the user or hijacking touches. An appropriate response might be * to drop the suspect touches or to take additional precautions to confirm the user's * actual intent. */ AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED = 0x1, }; /** * Motion event edge touch flags. */ enum { /** No edges intersected. */ AMOTION_EVENT_EDGE_FLAG_NONE = 0, /** Flag indicating the motion event intersected the top edge of the screen. */ AMOTION_EVENT_EDGE_FLAG_TOP = 0x01, /** Flag indicating the motion event intersected the bottom edge of the screen. */ AMOTION_EVENT_EDGE_FLAG_BOTTOM = 0x02, /** Flag indicating the motion event intersected the left edge of the screen. */ AMOTION_EVENT_EDGE_FLAG_LEFT = 0x04, /** Flag indicating the motion event intersected the right edge of the screen. */ AMOTION_EVENT_EDGE_FLAG_RIGHT = 0x08 }; /** * Constants that identify each individual axis of a motion event. * @anchor AMOTION_EVENT_AXIS */ enum { /** * Axis constant: X axis of a motion event. * * - For a touch screen, reports the absolute X screen position of the center of * the touch contact area. The units are display pixels. * - For a touch pad, reports the absolute X surface position of the center of the touch * contact area. The units are device-dependent. * - For a mouse, reports the absolute X screen position of the mouse pointer. * The units are display pixels. * - For a trackball, reports the relative horizontal displacement of the trackball. * The value is normalized to a range from -1.0 (left) to 1.0 (right). * - For a joystick, reports the absolute X position of the joystick. * The value is normalized to a range from -1.0 (left) to 1.0 (right). */ AMOTION_EVENT_AXIS_X = 0, /** * Axis constant: Y axis of a motion event. * * - For a touch screen, reports the absolute Y screen position of the center of * the touch contact area. The units are display pixels. * - For a touch pad, reports the absolute Y surface position of the center of the touch * contact area. The units are device-dependent. * - For a mouse, reports the absolute Y screen position of the mouse pointer. * The units are display pixels. * - For a trackball, reports the relative vertical displacement of the trackball. * The value is normalized to a range from -1.0 (up) to 1.0 (down). * - For a joystick, reports the absolute Y position of the joystick. * The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near). */ AMOTION_EVENT_AXIS_Y = 1, /** * Axis constant: Pressure axis of a motion event. * * - For a touch screen or touch pad, reports the approximate pressure applied to the surface * by a finger or other tool. The value is normalized to a range from * 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 * may be generated depending on the calibration of the input device. * - For a trackball, the value is set to 1 if the trackball button is pressed * or 0 otherwise. * - For a mouse, the value is set to 1 if the primary mouse button is pressed * or 0 otherwise. */ AMOTION_EVENT_AXIS_PRESSURE = 2, /** * Axis constant: Size axis of a motion event. * * - For a touch screen or touch pad, reports the approximate size of the contact area in * relation to the maximum detectable size for the device. The value is normalized * to a range from 0 (smallest detectable size) to 1 (largest detectable size), * although it is not a linear scale. This value is of limited use. * To obtain calibrated size information, see * {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}. */ AMOTION_EVENT_AXIS_SIZE = 3, /** * Axis constant: TouchMajor axis of a motion event. * * - For a touch screen, reports the length of the major axis of an ellipse that * represents the touch area at the point of contact. * The units are display pixels. * - For a touch pad, reports the length of the major axis of an ellipse that * represents the touch area at the point of contact. * The units are device-dependent. */ AMOTION_EVENT_AXIS_TOUCH_MAJOR = 4, /** * Axis constant: TouchMinor axis of a motion event. * * - For a touch screen, reports the length of the minor axis of an ellipse that * represents the touch area at the point of contact. * The units are display pixels. * - For a touch pad, reports the length of the minor axis of an ellipse that * represents the touch area at the point of contact. * The units are device-dependent. * * When the touch is circular, the major and minor axis lengths will be equal to one another. */ AMOTION_EVENT_AXIS_TOUCH_MINOR = 5, /** * Axis constant: ToolMajor axis of a motion event. * * - For a touch screen, reports the length of the major axis of an ellipse that * represents the size of the approaching finger or tool used to make contact. * - For a touch pad, reports the length of the major axis of an ellipse that * represents the size of the approaching finger or tool used to make contact. * The units are device-dependent. * * When the touch is circular, the major and minor axis lengths will be equal to one another. * * The tool size may be larger than the touch size since the tool may not be fully * in contact with the touch sensor. */ AMOTION_EVENT_AXIS_TOOL_MAJOR = 6, /** * Axis constant: ToolMinor axis of a motion event. * * - For a touch screen, reports the length of the minor axis of an ellipse that * represents the size of the approaching finger or tool used to make contact. * - For a touch pad, reports the length of the minor axis of an ellipse that * represents the size of the approaching finger or tool used to make contact. * The units are device-dependent. * * When the touch is circular, the major and minor axis lengths will be equal to one another. * * The tool size may be larger than the touch size since the tool may not be fully * in contact with the touch sensor. */ AMOTION_EVENT_AXIS_TOOL_MINOR = 7, /** * Axis constant: Orientation axis of a motion event. * * - For a touch screen or touch pad, reports the orientation of the finger * or tool in radians relative to the vertical plane of the device. * An angle of 0 radians indicates that the major axis of contact is oriented * upwards, is perfectly circular or is of unknown orientation. A positive angle * indicates that the major axis of contact is oriented to the right. A negative angle * indicates that the major axis of contact is oriented to the left. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians * (finger pointing fully right). * - For a stylus, the orientation indicates the direction in which the stylus * is pointing in relation to the vertical axis of the current orientation of the screen. * The range is from -PI radians to PI radians, where 0 is pointing up, * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians * is pointing right. See also {@link AMOTION_EVENT_AXIS_TILT}. */ AMOTION_EVENT_AXIS_ORIENTATION = 8, /** * Axis constant: Vertical Scroll axis of a motion event. * * - For a mouse, reports the relative movement of the vertical scroll wheel. * The value is normalized to a range from -1.0 (down) to 1.0 (up). * * This axis should be used to scroll views vertically. */ AMOTION_EVENT_AXIS_VSCROLL = 9, /** * Axis constant: Horizontal Scroll axis of a motion event. * * - For a mouse, reports the relative movement of the horizontal scroll wheel. * The value is normalized to a range from -1.0 (left) to 1.0 (right). * * This axis should be used to scroll views horizontally. */ AMOTION_EVENT_AXIS_HSCROLL = 10, /** * Axis constant: Z axis of a motion event. * * - For a joystick, reports the absolute Z position of the joystick. * The value is normalized to a range from -1.0 (high) to 1.0 (low). * On game pads with two analog joysticks, this axis is often reinterpreted * to report the absolute X position of the second joystick instead. */ AMOTION_EVENT_AXIS_Z = 11, /** * Axis constant: X Rotation axis of a motion event. * * - For a joystick, reports the absolute rotation angle about the X axis. * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). */ AMOTION_EVENT_AXIS_RX = 12, /** * Axis constant: Y Rotation axis of a motion event. * * - For a joystick, reports the absolute rotation angle about the Y axis. * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). */ AMOTION_EVENT_AXIS_RY = 13, /** * Axis constant: Z Rotation axis of a motion event. * * - For a joystick, reports the absolute rotation angle about the Z axis. * The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise). * On game pads with two analog joysticks, this axis is often reinterpreted * to report the absolute Y position of the second joystick instead. */ AMOTION_EVENT_AXIS_RZ = 14, /** * Axis constant: Hat X axis of a motion event. * * - For a joystick, reports the absolute X position of the directional hat control. * The value is normalized to a range from -1.0 (left) to 1.0 (right). */ AMOTION_EVENT_AXIS_HAT_X = 15, /** * Axis constant: Hat Y axis of a motion event. * * - For a joystick, reports the absolute Y position of the directional hat control. * The value is normalized to a range from -1.0 (up) to 1.0 (down). */ AMOTION_EVENT_AXIS_HAT_Y = 16, /** * Axis constant: Left Trigger axis of a motion event. * * - For a joystick, reports the absolute position of the left trigger control. * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). */ AMOTION_EVENT_AXIS_LTRIGGER = 17, /** * Axis constant: Right Trigger axis of a motion event. * * - For a joystick, reports the absolute position of the right trigger control. * The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed). */ AMOTION_EVENT_AXIS_RTRIGGER = 18, /** * Axis constant: Throttle axis of a motion event. * * - For a joystick, reports the absolute position of the throttle control. * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed). */ AMOTION_EVENT_AXIS_THROTTLE = 19, /** * Axis constant: Rudder axis of a motion event. * * - For a joystick, reports the absolute position of the rudder control. * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). */ AMOTION_EVENT_AXIS_RUDDER = 20, /** * Axis constant: Wheel axis of a motion event. * * - For a joystick, reports the absolute position of the steering wheel control. * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right). */ AMOTION_EVENT_AXIS_WHEEL = 21, /** * Axis constant: Gas axis of a motion event. * * - For a joystick, reports the absolute position of the gas (accelerator) control. * The value is normalized to a range from 0.0 (no acceleration) * to 1.0 (maximum acceleration). */ AMOTION_EVENT_AXIS_GAS = 22, /** * Axis constant: Brake axis of a motion event. * * - For a joystick, reports the absolute position of the brake control. * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking). */ AMOTION_EVENT_AXIS_BRAKE = 23, /** * Axis constant: Distance axis of a motion event. * * - For a stylus, reports the distance of the stylus from the screen. * A value of 0.0 indicates direct contact and larger values indicate increasing * distance from the surface. */ AMOTION_EVENT_AXIS_DISTANCE = 24, /** * Axis constant: Tilt axis of a motion event. * * - For a stylus, reports the tilt angle of the stylus in radians where * 0 radians indicates that the stylus is being held perpendicular to the * surface, and PI/2 radians indicates that the stylus is being held flat * against the surface. */ AMOTION_EVENT_AXIS_TILT = 25, /** * Axis constant: Generic 1 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_1 = 32, /** * Axis constant: Generic 2 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_2 = 33, /** * Axis constant: Generic 3 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_3 = 34, /** * Axis constant: Generic 4 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_4 = 35, /** * Axis constant: Generic 5 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_5 = 36, /** * Axis constant: Generic 6 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_6 = 37, /** * Axis constant: Generic 7 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_7 = 38, /** * Axis constant: Generic 8 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_8 = 39, /** * Axis constant: Generic 9 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_9 = 40, /** * Axis constant: Generic 10 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_10 = 41, /** * Axis constant: Generic 11 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_11 = 42, /** * Axis constant: Generic 12 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_12 = 43, /** * Axis constant: Generic 13 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_13 = 44, /** * Axis constant: Generic 14 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_14 = 45, /** * Axis constant: Generic 15 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_15 = 46, /** * Axis constant: Generic 16 axis of a motion event. * The interpretation of a generic axis is device-specific. */ AMOTION_EVENT_AXIS_GENERIC_16 = 47, // NOTE: If you add a new axis here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list. }; /** * Constants that identify buttons that are associated with motion events. * Refer to the documentation on the MotionEvent class for descriptions of each button. */ enum { /** primary */ AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0, /** secondary */ AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1, /** tertiary */ AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2, /** back */ AMOTION_EVENT_BUTTON_BACK = 1 << 3, /** forward */ AMOTION_EVENT_BUTTON_FORWARD = 1 << 4, AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5, AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6, }; /** * Constants that identify tool types. * Refer to the documentation on the MotionEvent class for descriptions of each tool type. */ enum { /** unknown */ AMOTION_EVENT_TOOL_TYPE_UNKNOWN = 0, /** finger */ AMOTION_EVENT_TOOL_TYPE_FINGER = 1, /** stylus */ AMOTION_EVENT_TOOL_TYPE_STYLUS = 2, /** mouse */ AMOTION_EVENT_TOOL_TYPE_MOUSE = 3, /** eraser */ AMOTION_EVENT_TOOL_TYPE_ERASER = 4, }; /** * Input source masks. * * Refer to the documentation on android.view.InputDevice for more details about input sources * and their correct interpretation. */ enum { /** mask */ AINPUT_SOURCE_CLASS_MASK = 0x000000ff, /** none */ AINPUT_SOURCE_CLASS_NONE = 0x00000000, /** button */ AINPUT_SOURCE_CLASS_BUTTON = 0x00000001, /** pointer */ AINPUT_SOURCE_CLASS_POINTER = 0x00000002, /** navigation */ AINPUT_SOURCE_CLASS_NAVIGATION = 0x00000004, /** position */ AINPUT_SOURCE_CLASS_POSITION = 0x00000008, /** joystick */ AINPUT_SOURCE_CLASS_JOYSTICK = 0x00000010, }; /** * Input sources. */ enum { /** unknown */ AINPUT_SOURCE_UNKNOWN = 0x00000000, /** keyboard */ AINPUT_SOURCE_KEYBOARD = 0x00000100 | AINPUT_SOURCE_CLASS_BUTTON, /** dpad */ AINPUT_SOURCE_DPAD = 0x00000200 | AINPUT_SOURCE_CLASS_BUTTON, /** gamepad */ AINPUT_SOURCE_GAMEPAD = 0x00000400 | AINPUT_SOURCE_CLASS_BUTTON, /** touchscreen */ AINPUT_SOURCE_TOUCHSCREEN = 0x00001000 | AINPUT_SOURCE_CLASS_POINTER, /** mouse */ AINPUT_SOURCE_MOUSE = 0x00002000 | AINPUT_SOURCE_CLASS_POINTER, /** stylus */ AINPUT_SOURCE_STYLUS = 0x00004000 | AINPUT_SOURCE_CLASS_POINTER, /** bluetooth stylus */ AINPUT_SOURCE_BLUETOOTH_STYLUS = 0x00008000 | AINPUT_SOURCE_STYLUS, /** trackball */ AINPUT_SOURCE_TRACKBALL = 0x00010000 | AINPUT_SOURCE_CLASS_NAVIGATION, /** touchpad */ AINPUT_SOURCE_TOUCHPAD = 0x00100000 | AINPUT_SOURCE_CLASS_POSITION, /** navigation */ AINPUT_SOURCE_TOUCH_NAVIGATION = 0x00200000 | AINPUT_SOURCE_CLASS_NONE, /** gesture sensor (?) */ AINPUT_SOURCE_GESTURE_SENSOR = 0x00400000 | AINPUT_SOURCE_CLASS_NONE, /** joystick */ AINPUT_SOURCE_JOYSTICK = 0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK, /** any */ AINPUT_SOURCE_ANY = 0xffffff00, }; /** * Keyboard types. * * Refer to the documentation on android.view.InputDevice for more details. */ enum { /** none */ AINPUT_KEYBOARD_TYPE_NONE = 0, /** non alphabetic */ AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC = 1, /** alphabetic */ AINPUT_KEYBOARD_TYPE_ALPHABETIC = 2, }; /** * Constants used to retrieve information about the range of motion for a particular * coordinate of a motion event. * * Refer to the documentation on android.view.InputDevice for more details about input sources * and their correct interpretation. * * @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*} constants instead. */ enum { /** x */ AINPUT_MOTION_RANGE_X = AMOTION_EVENT_AXIS_X, /** y */ AINPUT_MOTION_RANGE_Y = AMOTION_EVENT_AXIS_Y, /** pressure */ AINPUT_MOTION_RANGE_PRESSURE = AMOTION_EVENT_AXIS_PRESSURE, /** size */ AINPUT_MOTION_RANGE_SIZE = AMOTION_EVENT_AXIS_SIZE, /** touch major */ AINPUT_MOTION_RANGE_TOUCH_MAJOR = AMOTION_EVENT_AXIS_TOUCH_MAJOR, /** touch minor */ AINPUT_MOTION_RANGE_TOUCH_MINOR = AMOTION_EVENT_AXIS_TOUCH_MINOR, /** tool major */ AINPUT_MOTION_RANGE_TOOL_MAJOR = AMOTION_EVENT_AXIS_TOOL_MAJOR, /** tool minor */ AINPUT_MOTION_RANGE_TOOL_MINOR = AMOTION_EVENT_AXIS_TOOL_MINOR, /** orientation */ AINPUT_MOTION_RANGE_ORIENTATION = AMOTION_EVENT_AXIS_ORIENTATION, }; /** * Input event accessors. * * Note that most functions can only be used on input events that are of a given type. * Calling these functions on input events of other types will yield undefined behavior. */ /*** Accessors for all input events. ***/ /** Get the input event type. */ int32_t AInputEvent_getType(const AInputEvent* event); /** Get the id for the device that an input event came from. * * Input events can be generated by multiple different input devices. * Use the input device id to obtain information about the input * device that was responsible for generating a particular event. * * An input device id of 0 indicates that the event didn't come from a physical device; * other numbers are arbitrary and you shouldn't depend on the values. * Use the provided input device query API to obtain information about input devices. */ int32_t AInputEvent_getDeviceId(const AInputEvent* event); /** Get the input event source. */ int32_t AInputEvent_getSource(const AInputEvent* event); /*** Accessors for key events only. ***/ /** Get the key event action. */ int32_t AKeyEvent_getAction(const AInputEvent* key_event); /** Get the key event flags. */ int32_t AKeyEvent_getFlags(const AInputEvent* key_event); /** * Get the key code of the key event. * This is the physical key that was pressed, not the Unicode character. */ int32_t AKeyEvent_getKeyCode(const AInputEvent* key_event); /** * Get the hardware key id of this key event. * These values are not reliable and vary from device to device. */ int32_t AKeyEvent_getScanCode(const AInputEvent* key_event); /** Get the meta key state. */ int32_t AKeyEvent_getMetaState(const AInputEvent* key_event); /** * Get the repeat count of the event. * For both key up an key down events, this is the number of times the key has * repeated with the first down starting at 0 and counting up from there. For * multiple key events, this is the number of down/up pairs that have occurred. */ int32_t AKeyEvent_getRepeatCount(const AInputEvent* key_event); /** * Get the time of the most recent key down event, in the * java.lang.System.nanoTime() time base. If this is a down event, * this will be the same as eventTime. * Note that when chording keys, this value is the down time of the most recently * pressed key, which may not be the same physical key of this event. */ int64_t AKeyEvent_getDownTime(const AInputEvent* key_event); /** * Get the time this event occurred, in the * java.lang.System.nanoTime() time base. */ int64_t AKeyEvent_getEventTime(const AInputEvent* key_event); /*** Accessors for motion events only. ***/ /** Get the combined motion event action code and pointer index. */ int32_t AMotionEvent_getAction(const AInputEvent* motion_event); /** Get the motion event flags. */ int32_t AMotionEvent_getFlags(const AInputEvent* motion_event); /** * Get the state of any meta / modifier keys that were in effect when the * event was generated. */ int32_t AMotionEvent_getMetaState(const AInputEvent* motion_event); /** Get the button state of all buttons that are pressed. */ int32_t AMotionEvent_getButtonState(const AInputEvent* motion_event); /** * Get a bitfield indicating which edges, if any, were touched by this motion event. * For touch events, clients can use this to determine if the user's finger was * touching the edge of the display. */ int32_t AMotionEvent_getEdgeFlags(const AInputEvent* motion_event); /** * Get the time when the user originally pressed down to start a stream of * position events, in the java.lang.System.nanoTime() time base. */ int64_t AMotionEvent_getDownTime(const AInputEvent* motion_event); /** * Get the time when this specific event was generated, * in the java.lang.System.nanoTime() time base. */ int64_t AMotionEvent_getEventTime(const AInputEvent* motion_event); /** * Get the X coordinate offset. * For touch events on the screen, this is the delta that was added to the raw * screen coordinates to adjust for the absolute position of the containing windows * and views. */ float AMotionEvent_getXOffset(const AInputEvent* motion_event); /** * Get the Y coordinate offset. * For touch events on the screen, this is the delta that was added to the raw * screen coordinates to adjust for the absolute position of the containing windows * and views. */ float AMotionEvent_getYOffset(const AInputEvent* motion_event); /** * Get the precision of the X coordinates being reported. * You can multiply this number with an X coordinate sample to find the * actual hardware value of the X coordinate. */ float AMotionEvent_getXPrecision(const AInputEvent* motion_event); /** * Get the precision of the Y coordinates being reported. * You can multiply this number with a Y coordinate sample to find the * actual hardware value of the Y coordinate. */ float AMotionEvent_getYPrecision(const AInputEvent* motion_event); /** * Get the number of pointers of data contained in this event. * Always >= 1. */ size_t AMotionEvent_getPointerCount(const AInputEvent* motion_event); /** * Get the pointer identifier associated with a particular pointer * data index in this event. The identifier tells you the actual pointer * number associated with the data, accounting for individual pointers * going up and down since the start of the current gesture. */ int32_t AMotionEvent_getPointerId(const AInputEvent* motion_event, size_t pointer_index); /** * Get the tool type of a pointer for the given pointer index. * The tool type indicates the type of tool used to make contact such as a * finger or stylus, if known. */ int32_t AMotionEvent_getToolType(const AInputEvent* motion_event, size_t pointer_index); /** * Get the original raw X coordinate of this event. * For touch events on the screen, this is the original location of the event * on the screen, before it had been adjusted for the containing window * and views. */ float AMotionEvent_getRawX(const AInputEvent* motion_event, size_t pointer_index); /** * Get the original raw X coordinate of this event. * For touch events on the screen, this is the original location of the event * on the screen, before it had been adjusted for the containing window * and views. */ float AMotionEvent_getRawY(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current X coordinate of this event for the given pointer index. * Whole numbers are pixels; the value may have a fraction for input devices * that are sub-pixel precise. */ float AMotionEvent_getX(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current Y coordinate of this event for the given pointer index. * Whole numbers are pixels; the value may have a fraction for input devices * that are sub-pixel precise. */ float AMotionEvent_getY(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current pressure of this event for the given pointer index. * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), * although values higher than 1 may be generated depending on the calibration of * the input device. */ float AMotionEvent_getPressure(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current scaled value of the approximate size for the given pointer index. * This represents some approximation of the area of the screen being * pressed; the actual value in pixels corresponding to the * touch is normalized with the device specific range of values * and scaled to a value between 0 and 1. The value of size can be used to * determine fat touch events. */ float AMotionEvent_getSize(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current length of the major axis of an ellipse that describes the touch area * at the point of contact for the given pointer index. */ float AMotionEvent_getTouchMajor(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current length of the minor axis of an ellipse that describes the touch area * at the point of contact for the given pointer index. */ float AMotionEvent_getTouchMinor(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current length of the major axis of an ellipse that describes the size * of the approaching tool for the given pointer index. * The tool area represents the estimated size of the finger or pen that is * touching the device independent of its actual touch area at the point of contact. */ float AMotionEvent_getToolMajor(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current length of the minor axis of an ellipse that describes the size * of the approaching tool for the given pointer index. * The tool area represents the estimated size of the finger or pen that is * touching the device independent of its actual touch area at the point of contact. */ float AMotionEvent_getToolMinor(const AInputEvent* motion_event, size_t pointer_index); /** * Get the current orientation of the touch area and tool area in radians clockwise from * vertical for the given pointer index. * An angle of 0 degrees indicates that the major axis of contact is oriented * upwards, is perfectly circular or is of unknown orientation. A positive angle * indicates that the major axis of contact is oriented to the right. A negative angle * indicates that the major axis of contact is oriented to the left. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians * (finger pointing fully right). */ float AMotionEvent_getOrientation(const AInputEvent* motion_event, size_t pointer_index); /** Get the value of the request axis for the given pointer index. */ float AMotionEvent_getAxisValue(const AInputEvent* motion_event, int32_t axis, size_t pointer_index); /** * Get the number of historical points in this event. These are movements that * have occurred between this event and the previous event. This only applies * to AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0. * Historical samples are indexed from oldest to newest. */ size_t AMotionEvent_getHistorySize(const AInputEvent* motion_event); /** * Get the time that a historical movement occurred between this event and * the previous event, in the java.lang.System.nanoTime() time base. */ int64_t AMotionEvent_getHistoricalEventTime(const AInputEvent* motion_event, size_t history_index); /** * Get the historical raw X coordinate of this event for the given pointer index that * occurred between this event and the previous motion event. * For touch events on the screen, this is the original location of the event * on the screen, before it had been adjusted for the containing window * and views. * Whole numbers are pixels; the value may have a fraction for input devices * that are sub-pixel precise. */ float AMotionEvent_getHistoricalRawX(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical raw Y coordinate of this event for the given pointer index that * occurred between this event and the previous motion event. * For touch events on the screen, this is the original location of the event * on the screen, before it had been adjusted for the containing window * and views. * Whole numbers are pixels; the value may have a fraction for input devices * that are sub-pixel precise. */ float AMotionEvent_getHistoricalRawY(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical X coordinate of this event for the given pointer index that * occurred between this event and the previous motion event. * Whole numbers are pixels; the value may have a fraction for input devices * that are sub-pixel precise. */ float AMotionEvent_getHistoricalX(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical Y coordinate of this event for the given pointer index that * occurred between this event and the previous motion event. * Whole numbers are pixels; the value may have a fraction for input devices * that are sub-pixel precise. */ float AMotionEvent_getHistoricalY(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical pressure of this event for the given pointer index that * occurred between this event and the previous motion event. * The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), * although values higher than 1 may be generated depending on the calibration of * the input device. */ float AMotionEvent_getHistoricalPressure(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the current scaled value of the approximate size for the given pointer index that * occurred between this event and the previous motion event. * This represents some approximation of the area of the screen being * pressed; the actual value in pixels corresponding to the * touch is normalized with the device specific range of values * and scaled to a value between 0 and 1. The value of size can be used to * determine fat touch events. */ float AMotionEvent_getHistoricalSize(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical length of the major axis of an ellipse that describes the touch area * at the point of contact for the given pointer index that * occurred between this event and the previous motion event. */ float AMotionEvent_getHistoricalTouchMajor(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical length of the minor axis of an ellipse that describes the touch area * at the point of contact for the given pointer index that * occurred between this event and the previous motion event. */ float AMotionEvent_getHistoricalTouchMinor(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical length of the major axis of an ellipse that describes the size * of the approaching tool for the given pointer index that * occurred between this event and the previous motion event. * The tool area represents the estimated size of the finger or pen that is * touching the device independent of its actual touch area at the point of contact. */ float AMotionEvent_getHistoricalToolMajor(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical length of the minor axis of an ellipse that describes the size * of the approaching tool for the given pointer index that * occurred between this event and the previous motion event. * The tool area represents the estimated size of the finger or pen that is * touching the device independent of its actual touch area at the point of contact. */ float AMotionEvent_getHistoricalToolMinor(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical orientation of the touch area and tool area in radians clockwise from * vertical for the given pointer index that * occurred between this event and the previous motion event. * An angle of 0 degrees indicates that the major axis of contact is oriented * upwards, is perfectly circular or is of unknown orientation. A positive angle * indicates that the major axis of contact is oriented to the right. A negative angle * indicates that the major axis of contact is oriented to the left. * The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians * (finger pointing fully right). */ float AMotionEvent_getHistoricalOrientation(const AInputEvent* motion_event, size_t pointer_index, size_t history_index); /** * Get the historical value of the request axis for the given pointer index * that occurred between this event and the previous motion event. */ float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, int32_t axis, size_t pointer_index, size_t history_index); struct AInputQueue; /** * Input queue * * An input queue is the facility through which you retrieve input * events. */ typedef struct AInputQueue AInputQueue; /** * Add this input queue to a looper for processing. See * ALooper_addFd() for information on the ident, callback, and data params. */ void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, int ident, ALooper_callbackFunc callback, void* data); /** * Remove the input queue from the looper it is currently attached to. */ void AInputQueue_detachLooper(AInputQueue* queue); /** * Returns true if there are one or more events available in the * input queue. Returns 1 if the queue has events; 0 if * it does not have events; and a negative value if there is an error. */ int32_t AInputQueue_hasEvents(AInputQueue* queue); /** * Returns the next available event from the queue. Returns a negative * value if no events are available or an error has occurred. */ int32_t AInputQueue_getEvent(AInputQueue* queue, AInputEvent** outEvent); /** * Sends the key for standard pre-dispatching -- that is, possibly deliver * it to the current IME to be consumed before the app. Returns 0 if it * was not pre-dispatched, meaning you can process it right now. If non-zero * is returned, you must abandon the current event processing and allow the * event to appear again in the event queue (if it does not get consumed during * pre-dispatching). */ int32_t AInputQueue_preDispatchEvent(AInputQueue* queue, AInputEvent* event); /** * Report that dispatching has finished with the given event. * This must be called after receiving an event with AInputQueue_get_event(). */ void AInputQueue_finishEvent(AInputQueue* queue, AInputEvent* event, int handled); #ifdef __cplusplus } #endif #endif // _ANDROID_INPUT_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/keycodes.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Input * @{ */ /** * @file keycodes.h */ #ifndef _ANDROID_KEYCODES_H #define _ANDROID_KEYCODES_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit). * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ #include #ifdef __cplusplus extern "C" { #endif /** * Key codes. */ enum { /** Unknown key code. */ AKEYCODE_UNKNOWN = 0, /** Soft Left key. * Usually situated below the display on phones and used as a multi-function * feature key for selecting a software defined function shown on the bottom left * of the display. */ AKEYCODE_SOFT_LEFT = 1, /** Soft Right key. * Usually situated below the display on phones and used as a multi-function * feature key for selecting a software defined function shown on the bottom right * of the display. */ AKEYCODE_SOFT_RIGHT = 2, /** Home key. * This key is handled by the framework and is never delivered to applications. */ AKEYCODE_HOME = 3, /** Back key. */ AKEYCODE_BACK = 4, /** Call key. */ AKEYCODE_CALL = 5, /** End Call key. */ AKEYCODE_ENDCALL = 6, /** '0' key. */ AKEYCODE_0 = 7, /** '1' key. */ AKEYCODE_1 = 8, /** '2' key. */ AKEYCODE_2 = 9, /** '3' key. */ AKEYCODE_3 = 10, /** '4' key. */ AKEYCODE_4 = 11, /** '5' key. */ AKEYCODE_5 = 12, /** '6' key. */ AKEYCODE_6 = 13, /** '7' key. */ AKEYCODE_7 = 14, /** '8' key. */ AKEYCODE_8 = 15, /** '9' key. */ AKEYCODE_9 = 16, /** '*' key. */ AKEYCODE_STAR = 17, /** '#' key. */ AKEYCODE_POUND = 18, /** Directional Pad Up key. * May also be synthesized from trackball motions. */ AKEYCODE_DPAD_UP = 19, /** Directional Pad Down key. * May also be synthesized from trackball motions. */ AKEYCODE_DPAD_DOWN = 20, /** Directional Pad Left key. * May also be synthesized from trackball motions. */ AKEYCODE_DPAD_LEFT = 21, /** Directional Pad Right key. * May also be synthesized from trackball motions. */ AKEYCODE_DPAD_RIGHT = 22, /** Directional Pad Center key. * May also be synthesized from trackball motions. */ AKEYCODE_DPAD_CENTER = 23, /** Volume Up key. * Adjusts the speaker volume up. */ AKEYCODE_VOLUME_UP = 24, /** Volume Down key. * Adjusts the speaker volume down. */ AKEYCODE_VOLUME_DOWN = 25, /** Power key. */ AKEYCODE_POWER = 26, /** Camera key. * Used to launch a camera application or take pictures. */ AKEYCODE_CAMERA = 27, /** Clear key. */ AKEYCODE_CLEAR = 28, /** 'A' key. */ AKEYCODE_A = 29, /** 'B' key. */ AKEYCODE_B = 30, /** 'C' key. */ AKEYCODE_C = 31, /** 'D' key. */ AKEYCODE_D = 32, /** 'E' key. */ AKEYCODE_E = 33, /** 'F' key. */ AKEYCODE_F = 34, /** 'G' key. */ AKEYCODE_G = 35, /** 'H' key. */ AKEYCODE_H = 36, /** 'I' key. */ AKEYCODE_I = 37, /** 'J' key. */ AKEYCODE_J = 38, /** 'K' key. */ AKEYCODE_K = 39, /** 'L' key. */ AKEYCODE_L = 40, /** 'M' key. */ AKEYCODE_M = 41, /** 'N' key. */ AKEYCODE_N = 42, /** 'O' key. */ AKEYCODE_O = 43, /** 'P' key. */ AKEYCODE_P = 44, /** 'Q' key. */ AKEYCODE_Q = 45, /** 'R' key. */ AKEYCODE_R = 46, /** 'S' key. */ AKEYCODE_S = 47, /** 'T' key. */ AKEYCODE_T = 48, /** 'U' key. */ AKEYCODE_U = 49, /** 'V' key. */ AKEYCODE_V = 50, /** 'W' key. */ AKEYCODE_W = 51, /** 'X' key. */ AKEYCODE_X = 52, /** 'Y' key. */ AKEYCODE_Y = 53, /** 'Z' key. */ AKEYCODE_Z = 54, /** ',' key. */ AKEYCODE_COMMA = 55, /** '.' key. */ AKEYCODE_PERIOD = 56, /** Left Alt modifier key. */ AKEYCODE_ALT_LEFT = 57, /** Right Alt modifier key. */ AKEYCODE_ALT_RIGHT = 58, /** Left Shift modifier key. */ AKEYCODE_SHIFT_LEFT = 59, /** Right Shift modifier key. */ AKEYCODE_SHIFT_RIGHT = 60, /** Tab key. */ AKEYCODE_TAB = 61, /** Space key. */ AKEYCODE_SPACE = 62, /** Symbol modifier key. * Used to enter alternate symbols. */ AKEYCODE_SYM = 63, /** Explorer special function key. * Used to launch a browser application. */ AKEYCODE_EXPLORER = 64, /** Envelope special function key. * Used to launch a mail application. */ AKEYCODE_ENVELOPE = 65, /** Enter key. */ AKEYCODE_ENTER = 66, /** Backspace key. * Deletes characters before the insertion point, unlike {@link AKEYCODE_FORWARD_DEL}. */ AKEYCODE_DEL = 67, /** '`' (backtick) key. */ AKEYCODE_GRAVE = 68, /** '-'. */ AKEYCODE_MINUS = 69, /** '=' key. */ AKEYCODE_EQUALS = 70, /** '[' key. */ AKEYCODE_LEFT_BRACKET = 71, /** ']' key. */ AKEYCODE_RIGHT_BRACKET = 72, /** '\' key. */ AKEYCODE_BACKSLASH = 73, /** ';' key. */ AKEYCODE_SEMICOLON = 74, /** ''' (apostrophe) key. */ AKEYCODE_APOSTROPHE = 75, /** '/' key. */ AKEYCODE_SLASH = 76, /** '@' key. */ AKEYCODE_AT = 77, /** Number modifier key. * Used to enter numeric symbols. * This key is not {@link AKEYCODE_NUM_LOCK}; it is more like {@link AKEYCODE_ALT_LEFT}. */ AKEYCODE_NUM = 78, /** Headset Hook key. * Used to hang up calls and stop media. */ AKEYCODE_HEADSETHOOK = 79, /** Camera Focus key. * Used to focus the camera. */ AKEYCODE_FOCUS = 80, /** '+' key. */ AKEYCODE_PLUS = 81, /** Menu key. */ AKEYCODE_MENU = 82, /** Notification key. */ AKEYCODE_NOTIFICATION = 83, /** Search key. */ AKEYCODE_SEARCH = 84, /** Play/Pause media key. */ AKEYCODE_MEDIA_PLAY_PAUSE= 85, /** Stop media key. */ AKEYCODE_MEDIA_STOP = 86, /** Play Next media key. */ AKEYCODE_MEDIA_NEXT = 87, /** Play Previous media key. */ AKEYCODE_MEDIA_PREVIOUS = 88, /** Rewind media key. */ AKEYCODE_MEDIA_REWIND = 89, /** Fast Forward media key. */ AKEYCODE_MEDIA_FAST_FORWARD = 90, /** Mute key. * Mutes the microphone, unlike {@link AKEYCODE_VOLUME_MUTE}. */ AKEYCODE_MUTE = 91, /** Page Up key. */ AKEYCODE_PAGE_UP = 92, /** Page Down key. */ AKEYCODE_PAGE_DOWN = 93, /** Picture Symbols modifier key. * Used to switch symbol sets (Emoji, Kao-moji). */ AKEYCODE_PICTSYMBOLS = 94, /** Switch Charset modifier key. * Used to switch character sets (Kanji, Katakana). */ AKEYCODE_SWITCH_CHARSET = 95, /** A Button key. * On a game controller, the A button should be either the button labeled A * or the first button on the bottom row of controller buttons. */ AKEYCODE_BUTTON_A = 96, /** B Button key. * On a game controller, the B button should be either the button labeled B * or the second button on the bottom row of controller buttons. */ AKEYCODE_BUTTON_B = 97, /** C Button key. * On a game controller, the C button should be either the button labeled C * or the third button on the bottom row of controller buttons. */ AKEYCODE_BUTTON_C = 98, /** X Button key. * On a game controller, the X button should be either the button labeled X * or the first button on the upper row of controller buttons. */ AKEYCODE_BUTTON_X = 99, /** Y Button key. * On a game controller, the Y button should be either the button labeled Y * or the second button on the upper row of controller buttons. */ AKEYCODE_BUTTON_Y = 100, /** Z Button key. * On a game controller, the Z button should be either the button labeled Z * or the third button on the upper row of controller buttons. */ AKEYCODE_BUTTON_Z = 101, /** L1 Button key. * On a game controller, the L1 button should be either the button labeled L1 (or L) * or the top left trigger button. */ AKEYCODE_BUTTON_L1 = 102, /** R1 Button key. * On a game controller, the R1 button should be either the button labeled R1 (or R) * or the top right trigger button. */ AKEYCODE_BUTTON_R1 = 103, /** L2 Button key. * On a game controller, the L2 button should be either the button labeled L2 * or the bottom left trigger button. */ AKEYCODE_BUTTON_L2 = 104, /** R2 Button key. * On a game controller, the R2 button should be either the button labeled R2 * or the bottom right trigger button. */ AKEYCODE_BUTTON_R2 = 105, /** Left Thumb Button key. * On a game controller, the left thumb button indicates that the left (or only) * joystick is pressed. */ AKEYCODE_BUTTON_THUMBL = 106, /** Right Thumb Button key. * On a game controller, the right thumb button indicates that the right * joystick is pressed. */ AKEYCODE_BUTTON_THUMBR = 107, /** Start Button key. * On a game controller, the button labeled Start. */ AKEYCODE_BUTTON_START = 108, /** Select Button key. * On a game controller, the button labeled Select. */ AKEYCODE_BUTTON_SELECT = 109, /** Mode Button key. * On a game controller, the button labeled Mode. */ AKEYCODE_BUTTON_MODE = 110, /** Escape key. */ AKEYCODE_ESCAPE = 111, /** Forward Delete key. * Deletes characters ahead of the insertion point, unlike {@link AKEYCODE_DEL}. */ AKEYCODE_FORWARD_DEL = 112, /** Left Control modifier key. */ AKEYCODE_CTRL_LEFT = 113, /** Right Control modifier key. */ AKEYCODE_CTRL_RIGHT = 114, /** Caps Lock key. */ AKEYCODE_CAPS_LOCK = 115, /** Scroll Lock key. */ AKEYCODE_SCROLL_LOCK = 116, /** Left Meta modifier key. */ AKEYCODE_META_LEFT = 117, /** Right Meta modifier key. */ AKEYCODE_META_RIGHT = 118, /** Function modifier key. */ AKEYCODE_FUNCTION = 119, /** System Request / Print Screen key. */ AKEYCODE_SYSRQ = 120, /** Break / Pause key. */ AKEYCODE_BREAK = 121, /** Home Movement key. * Used for scrolling or moving the cursor around to the start of a line * or to the top of a list. */ AKEYCODE_MOVE_HOME = 122, /** End Movement key. * Used for scrolling or moving the cursor around to the end of a line * or to the bottom of a list. */ AKEYCODE_MOVE_END = 123, /** Insert key. * Toggles insert / overwrite edit mode. */ AKEYCODE_INSERT = 124, /** Forward key. * Navigates forward in the history stack. Complement of {@link AKEYCODE_BACK}. */ AKEYCODE_FORWARD = 125, /** Play media key. */ AKEYCODE_MEDIA_PLAY = 126, /** Pause media key. */ AKEYCODE_MEDIA_PAUSE = 127, /** Close media key. * May be used to close a CD tray, for example. */ AKEYCODE_MEDIA_CLOSE = 128, /** Eject media key. * May be used to eject a CD tray, for example. */ AKEYCODE_MEDIA_EJECT = 129, /** Record media key. */ AKEYCODE_MEDIA_RECORD = 130, /** F1 key. */ AKEYCODE_F1 = 131, /** F2 key. */ AKEYCODE_F2 = 132, /** F3 key. */ AKEYCODE_F3 = 133, /** F4 key. */ AKEYCODE_F4 = 134, /** F5 key. */ AKEYCODE_F5 = 135, /** F6 key. */ AKEYCODE_F6 = 136, /** F7 key. */ AKEYCODE_F7 = 137, /** F8 key. */ AKEYCODE_F8 = 138, /** F9 key. */ AKEYCODE_F9 = 139, /** F10 key. */ AKEYCODE_F10 = 140, /** F11 key. */ AKEYCODE_F11 = 141, /** F12 key. */ AKEYCODE_F12 = 142, /** Num Lock key. * This is the Num Lock key; it is different from {@link AKEYCODE_NUM}. * This key alters the behavior of other keys on the numeric keypad. */ AKEYCODE_NUM_LOCK = 143, /** Numeric keypad '0' key. */ AKEYCODE_NUMPAD_0 = 144, /** Numeric keypad '1' key. */ AKEYCODE_NUMPAD_1 = 145, /** Numeric keypad '2' key. */ AKEYCODE_NUMPAD_2 = 146, /** Numeric keypad '3' key. */ AKEYCODE_NUMPAD_3 = 147, /** Numeric keypad '4' key. */ AKEYCODE_NUMPAD_4 = 148, /** Numeric keypad '5' key. */ AKEYCODE_NUMPAD_5 = 149, /** Numeric keypad '6' key. */ AKEYCODE_NUMPAD_6 = 150, /** Numeric keypad '7' key. */ AKEYCODE_NUMPAD_7 = 151, /** Numeric keypad '8' key. */ AKEYCODE_NUMPAD_8 = 152, /** Numeric keypad '9' key. */ AKEYCODE_NUMPAD_9 = 153, /** Numeric keypad '/' key (for division). */ AKEYCODE_NUMPAD_DIVIDE = 154, /** Numeric keypad '*' key (for multiplication). */ AKEYCODE_NUMPAD_MULTIPLY = 155, /** Numeric keypad '-' key (for subtraction). */ AKEYCODE_NUMPAD_SUBTRACT = 156, /** Numeric keypad '+' key (for addition). */ AKEYCODE_NUMPAD_ADD = 157, /** Numeric keypad '.' key (for decimals or digit grouping). */ AKEYCODE_NUMPAD_DOT = 158, /** Numeric keypad ',' key (for decimals or digit grouping). */ AKEYCODE_NUMPAD_COMMA = 159, /** Numeric keypad Enter key. */ AKEYCODE_NUMPAD_ENTER = 160, /** Numeric keypad '=' key. */ AKEYCODE_NUMPAD_EQUALS = 161, /** Numeric keypad '(' key. */ AKEYCODE_NUMPAD_LEFT_PAREN = 162, /** Numeric keypad ')' key. */ AKEYCODE_NUMPAD_RIGHT_PAREN = 163, /** Volume Mute key. * Mutes the speaker, unlike {@link AKEYCODE_MUTE}. * This key should normally be implemented as a toggle such that the first press * mutes the speaker and the second press restores the original volume. */ AKEYCODE_VOLUME_MUTE = 164, /** Info key. * Common on TV remotes to show additional information related to what is * currently being viewed. */ AKEYCODE_INFO = 165, /** Channel up key. * On TV remotes, increments the television channel. */ AKEYCODE_CHANNEL_UP = 166, /** Channel down key. * On TV remotes, decrements the television channel. */ AKEYCODE_CHANNEL_DOWN = 167, /** Zoom in key. */ AKEYCODE_ZOOM_IN = 168, /** Zoom out key. */ AKEYCODE_ZOOM_OUT = 169, /** TV key. * On TV remotes, switches to viewing live TV. */ AKEYCODE_TV = 170, /** Window key. * On TV remotes, toggles picture-in-picture mode or other windowing functions. */ AKEYCODE_WINDOW = 171, /** Guide key. * On TV remotes, shows a programming guide. */ AKEYCODE_GUIDE = 172, /** DVR key. * On some TV remotes, switches to a DVR mode for recorded shows. */ AKEYCODE_DVR = 173, /** Bookmark key. * On some TV remotes, bookmarks content or web pages. */ AKEYCODE_BOOKMARK = 174, /** Toggle captions key. * Switches the mode for closed-captioning text, for example during television shows. */ AKEYCODE_CAPTIONS = 175, /** Settings key. * Starts the system settings activity. */ AKEYCODE_SETTINGS = 176, /** TV power key. * On TV remotes, toggles the power on a television screen. */ AKEYCODE_TV_POWER = 177, /** TV input key. * On TV remotes, switches the input on a television screen. */ AKEYCODE_TV_INPUT = 178, /** Set-top-box power key. * On TV remotes, toggles the power on an external Set-top-box. */ AKEYCODE_STB_POWER = 179, /** Set-top-box input key. * On TV remotes, switches the input mode on an external Set-top-box. */ AKEYCODE_STB_INPUT = 180, /** A/V Receiver power key. * On TV remotes, toggles the power on an external A/V Receiver. */ AKEYCODE_AVR_POWER = 181, /** A/V Receiver input key. * On TV remotes, switches the input mode on an external A/V Receiver. */ AKEYCODE_AVR_INPUT = 182, /** Red "programmable" key. * On TV remotes, acts as a contextual/programmable key. */ AKEYCODE_PROG_RED = 183, /** Green "programmable" key. * On TV remotes, actsas a contextual/programmable key. */ AKEYCODE_PROG_GREEN = 184, /** Yellow "programmable" key. * On TV remotes, acts as a contextual/programmable key. */ AKEYCODE_PROG_YELLOW = 185, /** Blue "programmable" key. * On TV remotes, acts as a contextual/programmable key. */ AKEYCODE_PROG_BLUE = 186, /** App switch key. * Should bring up the application switcher dialog. */ AKEYCODE_APP_SWITCH = 187, /** Generic Game Pad Button #1.*/ AKEYCODE_BUTTON_1 = 188, /** Generic Game Pad Button #2.*/ AKEYCODE_BUTTON_2 = 189, /** Generic Game Pad Button #3.*/ AKEYCODE_BUTTON_3 = 190, /** Generic Game Pad Button #4.*/ AKEYCODE_BUTTON_4 = 191, /** Generic Game Pad Button #5.*/ AKEYCODE_BUTTON_5 = 192, /** Generic Game Pad Button #6.*/ AKEYCODE_BUTTON_6 = 193, /** Generic Game Pad Button #7.*/ AKEYCODE_BUTTON_7 = 194, /** Generic Game Pad Button #8.*/ AKEYCODE_BUTTON_8 = 195, /** Generic Game Pad Button #9.*/ AKEYCODE_BUTTON_9 = 196, /** Generic Game Pad Button #10.*/ AKEYCODE_BUTTON_10 = 197, /** Generic Game Pad Button #11.*/ AKEYCODE_BUTTON_11 = 198, /** Generic Game Pad Button #12.*/ AKEYCODE_BUTTON_12 = 199, /** Generic Game Pad Button #13.*/ AKEYCODE_BUTTON_13 = 200, /** Generic Game Pad Button #14.*/ AKEYCODE_BUTTON_14 = 201, /** Generic Game Pad Button #15.*/ AKEYCODE_BUTTON_15 = 202, /** Generic Game Pad Button #16.*/ AKEYCODE_BUTTON_16 = 203, /** Language Switch key. * Toggles the current input language such as switching between English and Japanese on * a QWERTY keyboard. On some devices, the same function may be performed by * pressing Shift+Spacebar. */ AKEYCODE_LANGUAGE_SWITCH = 204, /** Manner Mode key. * Toggles silent or vibrate mode on and off to make the device behave more politely * in certain settings such as on a crowded train. On some devices, the key may only * operate when long-pressed. */ AKEYCODE_MANNER_MODE = 205, /** 3D Mode key. * Toggles the display between 2D and 3D mode. */ AKEYCODE_3D_MODE = 206, /** Contacts special function key. * Used to launch an address book application. */ AKEYCODE_CONTACTS = 207, /** Calendar special function key. * Used to launch a calendar application. */ AKEYCODE_CALENDAR = 208, /** Music special function key. * Used to launch a music player application. */ AKEYCODE_MUSIC = 209, /** Calculator special function key. * Used to launch a calculator application. */ AKEYCODE_CALCULATOR = 210, /** Japanese full-width / half-width key. */ AKEYCODE_ZENKAKU_HANKAKU = 211, /** Japanese alphanumeric key. */ AKEYCODE_EISU = 212, /** Japanese non-conversion key. */ AKEYCODE_MUHENKAN = 213, /** Japanese conversion key. */ AKEYCODE_HENKAN = 214, /** Japanese katakana / hiragana key. */ AKEYCODE_KATAKANA_HIRAGANA = 215, /** Japanese Yen key. */ AKEYCODE_YEN = 216, /** Japanese Ro key. */ AKEYCODE_RO = 217, /** Japanese kana key. */ AKEYCODE_KANA = 218, /** Assist key. * Launches the global assist activity. Not delivered to applications. */ AKEYCODE_ASSIST = 219, /** Brightness Down key. * Adjusts the screen brightness down. */ AKEYCODE_BRIGHTNESS_DOWN = 220, /** Brightness Up key. * Adjusts the screen brightness up. */ AKEYCODE_BRIGHTNESS_UP = 221, /** Audio Track key. * Switches the audio tracks. */ AKEYCODE_MEDIA_AUDIO_TRACK = 222, /** Sleep key. * Puts the device to sleep. Behaves somewhat like {@link AKEYCODE_POWER} but it * has no effect if the device is already asleep. */ AKEYCODE_SLEEP = 223, /** Wakeup key. * Wakes up the device. Behaves somewhat like {@link AKEYCODE_POWER} but it * has no effect if the device is already awake. */ AKEYCODE_WAKEUP = 224, /** Pairing key. * Initiates peripheral pairing mode. Useful for pairing remote control * devices or game controllers, especially if no other input mode is * available. */ AKEYCODE_PAIRING = 225, /** Media Top Menu key. * Goes to the top of media menu. */ AKEYCODE_MEDIA_TOP_MENU = 226, /** '11' key. */ AKEYCODE_11 = 227, /** '12' key. */ AKEYCODE_12 = 228, /** Last Channel key. * Goes to the last viewed channel. */ AKEYCODE_LAST_CHANNEL = 229, /** TV data service key. * Displays data services like weather, sports. */ AKEYCODE_TV_DATA_SERVICE = 230, /** Voice Assist key. * Launches the global voice assist activity. Not delivered to applications. */ AKEYCODE_VOICE_ASSIST = 231, /** Radio key. * Toggles TV service / Radio service. */ AKEYCODE_TV_RADIO_SERVICE = 232, /** Teletext key. * Displays Teletext service. */ AKEYCODE_TV_TELETEXT = 233, /** Number entry key. * Initiates to enter multi-digit channel nubmber when each digit key is assigned * for selecting separate channel. Corresponds to Number Entry Mode (0x1D) of CEC * User Control Code. */ AKEYCODE_TV_NUMBER_ENTRY = 234, /** Analog Terrestrial key. * Switches to analog terrestrial broadcast service. */ AKEYCODE_TV_TERRESTRIAL_ANALOG = 235, /** Digital Terrestrial key. * Switches to digital terrestrial broadcast service. */ AKEYCODE_TV_TERRESTRIAL_DIGITAL = 236, /** Satellite key. * Switches to digital satellite broadcast service. */ AKEYCODE_TV_SATELLITE = 237, /** BS key. * Switches to BS digital satellite broadcasting service available in Japan. */ AKEYCODE_TV_SATELLITE_BS = 238, /** CS key. * Switches to CS digital satellite broadcasting service available in Japan. */ AKEYCODE_TV_SATELLITE_CS = 239, /** BS/CS key. * Toggles between BS and CS digital satellite services. */ AKEYCODE_TV_SATELLITE_SERVICE = 240, /** Toggle Network key. * Toggles selecting broacast services. */ AKEYCODE_TV_NETWORK = 241, /** Antenna/Cable key. * Toggles broadcast input source between antenna and cable. */ AKEYCODE_TV_ANTENNA_CABLE = 242, /** HDMI #1 key. * Switches to HDMI input #1. */ AKEYCODE_TV_INPUT_HDMI_1 = 243, /** HDMI #2 key. * Switches to HDMI input #2. */ AKEYCODE_TV_INPUT_HDMI_2 = 244, /** HDMI #3 key. * Switches to HDMI input #3. */ AKEYCODE_TV_INPUT_HDMI_3 = 245, /** HDMI #4 key. * Switches to HDMI input #4. */ AKEYCODE_TV_INPUT_HDMI_4 = 246, /** Composite #1 key. * Switches to composite video input #1. */ AKEYCODE_TV_INPUT_COMPOSITE_1 = 247, /** Composite #2 key. * Switches to composite video input #2. */ AKEYCODE_TV_INPUT_COMPOSITE_2 = 248, /** Component #1 key. * Switches to component video input #1. */ AKEYCODE_TV_INPUT_COMPONENT_1 = 249, /** Component #2 key. * Switches to component video input #2. */ AKEYCODE_TV_INPUT_COMPONENT_2 = 250, /** VGA #1 key. * Switches to VGA (analog RGB) input #1. */ AKEYCODE_TV_INPUT_VGA_1 = 251, /** Audio description key. * Toggles audio description off / on. */ AKEYCODE_TV_AUDIO_DESCRIPTION = 252, /** Audio description mixing volume up key. * Louden audio description volume as compared with normal audio volume. */ AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP = 253, /** Audio description mixing volume down key. * Lessen audio description volume as compared with normal audio volume. */ AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN = 254, /** Zoom mode key. * Changes Zoom mode (Normal, Full, Zoom, Wide-zoom, etc.) */ AKEYCODE_TV_ZOOM_MODE = 255, /** Contents menu key. * Goes to the title list. Corresponds to Contents Menu (0x0B) of CEC User Control * Code */ AKEYCODE_TV_CONTENTS_MENU = 256, /** Media context menu key. * Goes to the context menu of media contents. Corresponds to Media Context-sensitive * Menu (0x11) of CEC User Control Code. */ AKEYCODE_TV_MEDIA_CONTEXT_MENU = 257, /** Timer programming key. * Goes to the timer recording menu. Corresponds to Timer Programming (0x54) of * CEC User Control Code. */ AKEYCODE_TV_TIMER_PROGRAMMING = 258, /** Help key. */ AKEYCODE_HELP = 259, AKEYCODE_NAVIGATE_PREVIOUS = 260, AKEYCODE_NAVIGATE_NEXT = 261, AKEYCODE_NAVIGATE_IN = 262, AKEYCODE_NAVIGATE_OUT = 263, /** Primary stem key for Wear * Main power/reset button on watch. */ AKEYCODE_STEM_PRIMARY = 264, /** Generic stem key 1 for Wear */ AKEYCODE_STEM_1 = 265, /** Generic stem key 2 for Wear */ AKEYCODE_STEM_2 = 266, /** Generic stem key 3 for Wear */ AKEYCODE_STEM_3 = 267, AKEYCODE_MEDIA_SKIP_FORWARD = 272, AKEYCODE_MEDIA_SKIP_BACKWARD = 273, AKEYCODE_MEDIA_STEP_FORWARD = 274, AKEYCODE_MEDIA_STEP_BACKWARD = 275, /** Put device to sleep unless a wakelock is held. */ AKEYCODE_SOFT_SLEEP = 276 // NOTE: If you add a new keycode here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. }; #ifdef __cplusplus } #endif #endif // _ANDROID_KEYCODES_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/looper.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Looper * @{ */ /** * @file looper.h */ #ifndef ANDROID_LOOPER_H #define ANDROID_LOOPER_H #ifdef __cplusplus extern "C" { #endif struct ALooper; /** * ALooper * * A looper is the state tracking an event loop for a thread. * Loopers do not define event structures or other such things; rather * they are a lower-level facility to attach one or more discrete objects * listening for an event. An "event" here is simply data available on * a file descriptor: each attached object has an associated file descriptor, * and waiting for "events" means (internally) polling on all of these file * descriptors until one or more of them have data available. * * A thread can have only one ALooper associated with it. */ typedef struct ALooper ALooper; /** * Returns the looper associated with the calling thread, or NULL if * there is not one. */ ALooper* ALooper_forThread(); /** Option for for ALooper_prepare(). */ enum { /** * This looper will accept calls to ALooper_addFd() that do not * have a callback (that is provide NULL for the callback). In * this case the caller of ALooper_pollOnce() or ALooper_pollAll() * MUST check the return from these functions to discover when * data is available on such fds and process it. */ ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0 }; /** * Prepares a looper associated with the calling thread, and returns it. * If the thread already has a looper, it is returned. Otherwise, a new * one is created, associated with the thread, and returned. * * The opts may be ALOOPER_PREPARE_ALLOW_NON_CALLBACKS or 0. */ ALooper* ALooper_prepare(int opts); /** Result from ALooper_pollOnce() and ALooper_pollAll(). */ enum { /** * The poll was awoken using wake() before the timeout expired * and no callbacks were executed and no other file descriptors were ready. */ ALOOPER_POLL_WAKE = -1, /** * Result from ALooper_pollOnce() and ALooper_pollAll(): * One or more callbacks were executed. */ ALOOPER_POLL_CALLBACK = -2, /** * Result from ALooper_pollOnce() and ALooper_pollAll(): * The timeout expired. */ ALOOPER_POLL_TIMEOUT = -3, /** * Result from ALooper_pollOnce() and ALooper_pollAll(): * An error occurred. */ ALOOPER_POLL_ERROR = -4, }; /** * Acquire a reference on the given ALooper object. This prevents the object * from being deleted until the reference is removed. This is only needed * to safely hand an ALooper from one thread to another. */ void ALooper_acquire(ALooper* looper); /** * Remove a reference that was previously acquired with ALooper_acquire(). */ void ALooper_release(ALooper* looper); /** * Flags for file descriptor events that a looper can monitor. * * These flag bits can be combined to monitor multiple events at once. */ enum { /** * The file descriptor is available for read operations. */ ALOOPER_EVENT_INPUT = 1 << 0, /** * The file descriptor is available for write operations. */ ALOOPER_EVENT_OUTPUT = 1 << 1, /** * The file descriptor has encountered an error condition. * * The looper always sends notifications about errors; it is not necessary * to specify this event flag in the requested event set. */ ALOOPER_EVENT_ERROR = 1 << 2, /** * The file descriptor was hung up. * For example, indicates that the remote end of a pipe or socket was closed. * * The looper always sends notifications about hangups; it is not necessary * to specify this event flag in the requested event set. */ ALOOPER_EVENT_HANGUP = 1 << 3, /** * The file descriptor is invalid. * For example, the file descriptor was closed prematurely. * * The looper always sends notifications about invalid file descriptors; it is not necessary * to specify this event flag in the requested event set. */ ALOOPER_EVENT_INVALID = 1 << 4, }; /** * For callback-based event loops, this is the prototype of the function * that is called when a file descriptor event occurs. * It is given the file descriptor it is associated with, * a bitmask of the poll events that were triggered (typically ALOOPER_EVENT_INPUT), * and the data pointer that was originally supplied. * * Implementations should return 1 to continue receiving callbacks, or 0 * to have this file descriptor and callback unregistered from the looper. */ typedef int (*ALooper_callbackFunc)(int fd, int events, void* data); /** * Waits for events to be available, with optional timeout in milliseconds. * Invokes callbacks for all file descriptors on which an event occurred. * * If the timeout is zero, returns immediately without blocking. * If the timeout is negative, waits indefinitely until an event appears. * * Returns ALOOPER_POLL_WAKE if the poll was awoken using wake() before * the timeout expired and no callbacks were invoked and no other file * descriptors were ready. * * Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked. * * Returns ALOOPER_POLL_TIMEOUT if there was no data before the given * timeout expired. * * Returns ALOOPER_POLL_ERROR if an error occurred. * * Returns a value >= 0 containing an identifier (the same identifier * `ident` passed to ALooper_addFd()) if its file descriptor has data * and it has no callback function (requiring the caller here to * handle it). In this (and only this) case outFd, outEvents and * outData will contain the poll events and data associated with the * fd, otherwise they will be set to NULL. * * This method does not return until it has finished invoking the appropriate callbacks * for all file descriptors that were signalled. */ int ALooper_pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData); /** * Like ALooper_pollOnce(), but performs all pending callbacks until all * data has been consumed or a file descriptor is available with no callback. * This function will never return ALOOPER_POLL_CALLBACK. */ int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); /** * Wakes the poll asynchronously. * * This method can be called on any thread. * This method returns immediately. */ void ALooper_wake(ALooper* looper); /** * Adds a new file descriptor to be polled by the looper. * If the same file descriptor was previously added, it is replaced. * * "fd" is the file descriptor to be added. * "ident" is an identifier for this event, which is returned from ALooper_pollOnce(). * The identifier must be >= 0, or ALOOPER_POLL_CALLBACK if providing a non-NULL callback. * "events" are the poll events to wake up on. Typically this is ALOOPER_EVENT_INPUT. * "callback" is the function to call when there is an event on the file descriptor. * "data" is a private data pointer to supply to the callback. * * There are two main uses of this function: * * (1) If "callback" is non-NULL, then this function will be called when there is * data on the file descriptor. It should execute any events it has pending, * appropriately reading from the file descriptor. The 'ident' is ignored in this case. * * (2) If "callback" is NULL, the 'ident' will be returned by ALooper_pollOnce * when its file descriptor has data available, requiring the caller to take * care of processing it. * * Returns 1 if the file descriptor was added or -1 if an error occurred. * * This method can be called on any thread. * This method may block briefly if it needs to wake the poll. */ int ALooper_addFd(ALooper* looper, int fd, int ident, int events, ALooper_callbackFunc callback, void* data); /** * Removes a previously added file descriptor from the looper. * * When this method returns, it is safe to close the file descriptor since the looper * will no longer have a reference to it. However, it is possible for the callback to * already be running or for it to run one last time if the file descriptor was already * signalled. Calling code is responsible for ensuring that this case is safely handled. * For example, if the callback takes care of removing itself during its own execution either * by returning 0 or by calling this method, then it can be guaranteed to not be invoked * again at any later time unless registered anew. * * Returns 1 if the file descriptor was removed, 0 if none was previously registered * or -1 if an error occurred. * * This method can be called on any thread. * This method may block briefly if it needs to wake the poll. */ int ALooper_removeFd(ALooper* looper, int fd); #ifdef __cplusplus }; #endif #endif // ANDROID_LOOPER_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/multinetwork.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_MULTINETWORK_H #define ANDROID_MULTINETWORK_H #include #include #include __BEGIN_DECLS /** * The corresponding C type for android.net.Network#getNetworkHandle() return * values. The Java signed long value can be safely cast to a net_handle_t: * * [C] ((net_handle_t) java_long_network_handle) * [C++] static_cast(java_long_network_handle) * * as appropriate. */ typedef uint64_t net_handle_t; /** * The value NETWORK_UNSPECIFIED indicates no specific network. * * For some functions (documented below), a previous binding may be cleared * by an invocation with NETWORK_UNSPECIFIED. * * Depending on the context it may indicate an error. It is expressly * not used to indicate some notion of the "current default network". */ #define NETWORK_UNSPECIFIED ((net_handle_t)0) /** * All functions below that return an int return 0 on success or -1 * on failure with an appropriate errno value set. */ /** * Set the network to be used by the given socket file descriptor. * * To clear a previous socket binding invoke with NETWORK_UNSPECIFIED. * * This is the equivalent of: * * [ android.net.Network#bindSocket() ] * https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket) */ int android_setsocknetwork(net_handle_t network, int fd); /** * Binds the current process to |network|. All sockets created in the future * (and not explicitly bound via android_setsocknetwork()) will be bound to * |network|. All host name resolutions will be limited to |network| as well. * Note that if the network identified by |network| ever disconnects, all * sockets created in this way will cease to work and all host name * resolutions will fail. This is by design so an application doesn't * accidentally use sockets it thinks are still bound to a particular network. * * To clear a previous process binding invoke with NETWORK_UNSPECIFIED. * * This is the equivalent of: * * [ android.net.ConnectivityManager#setProcessDefaultNetwork() ] * https://developer.android.com/reference/android/net/ConnectivityManager.html#setProcessDefaultNetwork(android.net.Network) */ int android_setprocnetwork(net_handle_t network); /** * Perform hostname resolution via the DNS servers associated with |network|. * * All arguments (apart from |network|) are used identically as those passed * to getaddrinfo(3). Return and error values are identical to those of * getaddrinfo(3), and in particular gai_strerror(3) can be used as expected. * Similar to getaddrinfo(3): * - |hints| may be NULL (in which case man page documented defaults apply) * - either |node| or |service| may be NULL, but not both * - |res| must not be NULL * * This is the equivalent of: * * [ android.net.Network#getAllByName() ] * https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String) */ int android_getaddrinfofornetwork(net_handle_t network, const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); __END_DECLS #endif // ANDROID_MULTINETWORK_H ================================================ FILE: phonelibs/android_frameworks_native/include/android/native_activity.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NativeActivity Native Activity * @{ */ /** * @file native_activity.h */ #ifndef ANDROID_NATIVE_ACTIVITY_H #define ANDROID_NATIVE_ACTIVITY_H #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif /** * {@link ANativeActivityCallbacks} */ struct ANativeActivityCallbacks; /** * This structure defines the native side of an android.app.NativeActivity. * It is created by the framework, and handed to the application's native * code as it is being launched. */ typedef struct ANativeActivity { /** * Pointer to the callback function table of the native application. * You can set the functions here to your own callbacks. The callbacks * pointer itself here should not be changed; it is allocated and managed * for you by the framework. */ struct ANativeActivityCallbacks* callbacks; /** * The global handle on the process's Java VM. */ JavaVM* vm; /** * JNI context for the main thread of the app. Note that this field * can ONLY be used from the main thread of the process; that is, the * thread that calls into the ANativeActivityCallbacks. */ JNIEnv* env; /** * The NativeActivity object handle. * * IMPORTANT NOTE: This member is mis-named. It should really be named * 'activity' instead of 'clazz', since it's a reference to the * NativeActivity instance created by the system for you. * * We unfortunately cannot change this without breaking NDK * source-compatibility. */ jobject clazz; /** * Path to this application's internal data directory. */ const char* internalDataPath; /** * Path to this application's external (removable/mountable) data directory. */ const char* externalDataPath; /** * The platform's SDK version code. */ int32_t sdkVersion; /** * This is the native instance of the application. It is not used by * the framework, but can be set by the application to its own instance * state. */ void* instance; /** * Pointer to the Asset Manager instance for the application. The application * uses this to access binary assets bundled inside its own .apk file. */ AAssetManager* assetManager; /** * Available starting with Honeycomb: path to the directory containing * the application's OBB files (if any). If the app doesn't have any * OBB files, this directory may not exist. */ const char* obbPath; } ANativeActivity; /** * These are the callbacks the framework makes into a native application. * All of these callbacks happen on the main thread of the application. * By default, all callbacks are NULL; set to a pointer to your own function * to have it called. */ typedef struct ANativeActivityCallbacks { /** * NativeActivity has started. See Java documentation for Activity.onStart() * for more information. */ void (*onStart)(ANativeActivity* activity); /** * NativeActivity has resumed. See Java documentation for Activity.onResume() * for more information. */ void (*onResume)(ANativeActivity* activity); /** * Framework is asking NativeActivity to save its current instance state. * See Java documentation for Activity.onSaveInstanceState() for more * information. The returned pointer needs to be created with malloc(); * the framework will call free() on it for you. You also must fill in * outSize with the number of bytes in the allocation. Note that the * saved state will be persisted, so it can not contain any active * entities (pointers to memory, file descriptors, etc). */ void* (*onSaveInstanceState)(ANativeActivity* activity, size_t* outSize); /** * NativeActivity has paused. See Java documentation for Activity.onPause() * for more information. */ void (*onPause)(ANativeActivity* activity); /** * NativeActivity has stopped. See Java documentation for Activity.onStop() * for more information. */ void (*onStop)(ANativeActivity* activity); /** * NativeActivity is being destroyed. See Java documentation for Activity.onDestroy() * for more information. */ void (*onDestroy)(ANativeActivity* activity); /** * Focus has changed in this NativeActivity's window. This is often used, * for example, to pause a game when it loses input focus. */ void (*onWindowFocusChanged)(ANativeActivity* activity, int hasFocus); /** * The drawing window for this native activity has been created. You * can use the given native window object to start drawing. */ void (*onNativeWindowCreated)(ANativeActivity* activity, ANativeWindow* window); /** * The drawing window for this native activity has been resized. You should * retrieve the new size from the window and ensure that your rendering in * it now matches. */ void (*onNativeWindowResized)(ANativeActivity* activity, ANativeWindow* window); /** * The drawing window for this native activity needs to be redrawn. To avoid * transient artifacts during screen changes (such resizing after rotation), * applications should not return from this function until they have finished * drawing their window in its current state. */ void (*onNativeWindowRedrawNeeded)(ANativeActivity* activity, ANativeWindow* window); /** * The drawing window for this native activity is going to be destroyed. * You MUST ensure that you do not touch the window object after returning * from this function: in the common case of drawing to the window from * another thread, that means the implementation of this callback must * properly synchronize with the other thread to stop its drawing before * returning from here. */ void (*onNativeWindowDestroyed)(ANativeActivity* activity, ANativeWindow* window); /** * The input queue for this native activity's window has been created. * You can use the given input queue to start retrieving input events. */ void (*onInputQueueCreated)(ANativeActivity* activity, AInputQueue* queue); /** * The input queue for this native activity's window is being destroyed. * You should no longer try to reference this object upon returning from this * function. */ void (*onInputQueueDestroyed)(ANativeActivity* activity, AInputQueue* queue); /** * The rectangle in the window in which content should be placed has changed. */ void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect); /** * The current device AConfiguration has changed. The new configuration can * be retrieved from assetManager. */ void (*onConfigurationChanged)(ANativeActivity* activity); /** * The system is running low on memory. Use this callback to release * resources you do not need, to help the system avoid killing more * important processes. */ void (*onLowMemory)(ANativeActivity* activity); } ANativeActivityCallbacks; /** * This is the function that must be in the native code to instantiate the * application's native activity. It is called with the activity instance (see * above); if the code is being instantiated from a previously saved instance, * the savedState will be non-NULL and point to the saved data. You must make * any copy of this data you need -- it will be released after you return from * this function. */ typedef void ANativeActivity_createFunc(ANativeActivity* activity, void* savedState, size_t savedStateSize); /** * The name of the function that NativeInstance looks for when launching its * native code. This is the default function that is used, you can specify * "android.app.func_name" string meta-data in your manifest to use a different * function. */ extern ANativeActivity_createFunc ANativeActivity_onCreate; /** * Finish the given activity. Its finish() method will be called, causing it * to be stopped and destroyed. Note that this method can be called from * *any* thread; it will send a message to the main thread of the process * where the Java finish call will take place. */ void ANativeActivity_finish(ANativeActivity* activity); /** * Change the window format of the given activity. Calls getWindow().setFormat() * of the given activity. Note that this method can be called from * *any* thread; it will send a message to the main thread of the process * where the Java finish call will take place. */ void ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format); /** * Change the window flags of the given activity. Calls getWindow().setFlags() * of the given activity. Note that this method can be called from * *any* thread; it will send a message to the main thread of the process * where the Java finish call will take place. See window.h for flag constants. */ void ANativeActivity_setWindowFlags(ANativeActivity* activity, uint32_t addFlags, uint32_t removeFlags); /** * Flags for ANativeActivity_showSoftInput; see the Java InputMethodManager * API for documentation. */ enum { /** * Implicit request to show the input window, not as the result * of a direct request by the user. */ ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT = 0x0001, /** * The user has forced the input method open (such as by * long-pressing menu) so it should not be closed until they * explicitly do so. */ ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002, }; /** * Show the IME while in the given activity. Calls InputMethodManager.showSoftInput() * for the given activity. Note that this method can be called from * *any* thread; it will send a message to the main thread of the process * where the Java finish call will take place. */ void ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags); /** * Flags for ANativeActivity_hideSoftInput; see the Java InputMethodManager * API for documentation. */ enum { /** * The soft input window should only be hidden if it was not * explicitly shown by the user. */ ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001, /** * The soft input window should normally be hidden, unless it was * originally shown with {@link ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED}. */ ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002, }; /** * Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput() * for the given activity. Note that this method can be called from * *any* thread; it will send a message to the main thread of the process * where the Java finish call will take place. */ void ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags); #ifdef __cplusplus }; #endif #endif // ANDROID_NATIVE_ACTIVITY_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/native_window.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NativeActivity Native Activity * @{ */ /** * @file native_window.h */ #ifndef ANDROID_NATIVE_WINDOW_H #define ANDROID_NATIVE_WINDOW_H #include #ifdef __cplusplus extern "C" { #endif /** * Pixel formats that a window can use. */ enum { /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/ WINDOW_FORMAT_RGBA_8888 = 1, /** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/ WINDOW_FORMAT_RGBX_8888 = 2, /** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/ WINDOW_FORMAT_RGB_565 = 4, }; struct ANativeWindow; /** * {@link ANativeWindow} is opaque type that provides access to a native window. * * A pointer can be obtained using ANativeWindow_fromSurface(). */ typedef struct ANativeWindow ANativeWindow; /** * {@link ANativeWindow} is a struct that represents a windows buffer. * * A pointer can be obtained using ANativeWindow_lock(). */ typedef struct ANativeWindow_Buffer { // The number of pixels that are show horizontally. int32_t width; // The number of pixels that are shown vertically. int32_t height; // The number of *pixels* that a line in the buffer takes in // memory. This may be >= width. int32_t stride; // The format of the buffer. One of WINDOW_FORMAT_* int32_t format; // The actual bits. void* bits; // Do not touch. uint32_t reserved[6]; } ANativeWindow_Buffer; /** * Acquire a reference on the given ANativeWindow object. This prevents the object * from being deleted until the reference is removed. */ void ANativeWindow_acquire(ANativeWindow* window); /** * Remove a reference that was previously acquired with ANativeWindow_acquire(). */ void ANativeWindow_release(ANativeWindow* window); /** * Return the current width in pixels of the window surface. Returns a * negative value on error. */ int32_t ANativeWindow_getWidth(ANativeWindow* window); /** * Return the current height in pixels of the window surface. Returns a * negative value on error. */ int32_t ANativeWindow_getHeight(ANativeWindow* window); /** * Return the current pixel format of the window surface. Returns a * negative value on error. */ int32_t ANativeWindow_getFormat(ANativeWindow* window); /** * Change the format and size of the window buffers. * * The width and height control the number of pixels in the buffers, not the * dimensions of the window on screen. If these are different than the * window's physical size, then it buffer will be scaled to match that size * when compositing it to the screen. * * For all of these parameters, if 0 is supplied then the window's base * value will come back in force. * * width and height must be either both zero or both non-zero. * */ int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, int32_t height, int32_t format); /** * Lock the window's next drawing surface for writing. * inOutDirtyBounds is used as an in/out parameter, upon entering the * function, it contains the dirty region, that is, the region the caller * intends to redraw. When the function returns, inOutDirtyBounds is updated * with the actual area the caller needs to redraw -- this region is often * extended by ANativeWindow_lock. */ int32_t ANativeWindow_lock(ANativeWindow* window, ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds); /** * Unlock the window's drawing surface after previously locking it, * posting the new buffer to the display. */ int32_t ANativeWindow_unlockAndPost(ANativeWindow* window); #ifdef __cplusplus }; #endif #endif // ANDROID_NATIVE_WINDOW_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/native_window_jni.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NativeActivity Native Activity * @{ */ /** * @file native_window_jni.h */ #ifndef ANDROID_NATIVE_WINDOW_JNI_H #define ANDROID_NATIVE_WINDOW_JNI_H #include #include #ifdef __cplusplus extern "C" { #endif /** * Return the ANativeWindow associated with a Java Surface object, * for interacting with it through native code. This acquires a reference * on the ANativeWindow that is returned; be sure to use ANativeWindow_release() * when done with it so that it doesn't leak. */ ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface); #ifdef __cplusplus }; #endif #endif // ANDROID_NATIVE_WINDOW_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/obb.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Storage * @{ */ /** * @file obb.h */ #ifndef ANDROID_OBB_H #define ANDROID_OBB_H #include #ifdef __cplusplus extern "C" { #endif struct AObbInfo; /** {@link AObbInfo} is an opaque type representing information for obb storage. */ typedef struct AObbInfo AObbInfo; /** Flag for an obb file, returned by AObbInfo_getFlags(). */ enum { /** overlay */ AOBBINFO_OVERLAY = 0x0001, }; /** * Scan an OBB and get information about it. */ AObbInfo* AObbScanner_getObbInfo(const char* filename); /** * Destroy the AObbInfo object. You must call this when finished with the object. */ void AObbInfo_delete(AObbInfo* obbInfo); /** * Get the package name for the OBB. */ const char* AObbInfo_getPackageName(AObbInfo* obbInfo); /** * Get the version of an OBB file. */ int32_t AObbInfo_getVersion(AObbInfo* obbInfo); /** * Get the flags of an OBB file. */ int32_t AObbInfo_getFlags(AObbInfo* obbInfo); #ifdef __cplusplus }; #endif #endif // ANDROID_OBB_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/rect.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NativeActivity Native Activity * @{ */ /** * @file rect.h */ #ifndef ANDROID_RECT_H #define ANDROID_RECT_H #include #ifdef __cplusplus extern "C" { #endif /** * {@link ARect} is a struct that represents a rectangular window area. * * It is used with {@link * ANativeActivityCallbacks::onContentRectChanged} event callback and * ANativeWindow_lock() function. */ typedef struct ARect { #ifdef __cplusplus typedef int32_t value_type; #endif /** left position */ int32_t left; /** top position */ int32_t top; /** left position */ int32_t right; /** bottom position */ int32_t bottom; } ARect; #ifdef __cplusplus }; #endif #endif // ANDROID_RECT_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/sensor.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Sensor * @{ */ /** * @file sensor.h */ #ifndef ANDROID_SENSOR_H #define ANDROID_SENSOR_H /****************************************************************** * * IMPORTANT NOTICE: * * This file is part of Android's set of stable system headers * exposed by the Android NDK (Native Development Kit). * * Third-party source AND binary code relies on the definitions * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. * * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ /** * Structures and functions to receive and process sensor events in * native code. * */ #include #include #ifdef __cplusplus extern "C" { #endif /** * Sensor types. * (keep in sync with hardware/sensor.h) */ enum { /** * {@link ASENSOR_TYPE_ACCELEROMETER} * reporting-mode: continuous * * All values are in SI units (m/s^2) and measure the acceleration of the * device minus the force of gravity. */ ASENSOR_TYPE_ACCELEROMETER = 1, /** * {@link ASENSOR_TYPE_MAGNETIC_FIELD} * reporting-mode: continuous * * All values are in micro-Tesla (uT) and measure the geomagnetic * field in the X, Y and Z axis. */ ASENSOR_TYPE_MAGNETIC_FIELD = 2, /** * {@link ASENSOR_TYPE_GYROSCOPE} * reporting-mode: continuous * * All values are in radians/second and measure the rate of rotation * around the X, Y and Z axis. */ ASENSOR_TYPE_GYROSCOPE = 4, /** * {@link ASENSOR_TYPE_LIGHT} * reporting-mode: on-change * * The light sensor value is returned in SI lux units. */ ASENSOR_TYPE_LIGHT = 5, /** * {@link ASENSOR_TYPE_PROXIMITY} * reporting-mode: on-change * * The proximity sensor which turns the screen off and back on during calls is the * wake-up proximity sensor. Implement wake-up proximity sensor before implementing * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag * SENSOR_FLAG_WAKE_UP. * The value corresponds to the distance to the nearest object in centimeters. */ ASENSOR_TYPE_PROXIMITY = 8 }; /** * Sensor accuracy measure. */ enum { /** no contact */ ASENSOR_STATUS_NO_CONTACT = -1, /** unreliable */ ASENSOR_STATUS_UNRELIABLE = 0, /** low accuracy */ ASENSOR_STATUS_ACCURACY_LOW = 1, /** medium accuracy */ ASENSOR_STATUS_ACCURACY_MEDIUM = 2, /** high accuracy */ ASENSOR_STATUS_ACCURACY_HIGH = 3 }; /** * Sensor Reporting Modes. */ enum { /** continuous reporting */ AREPORTING_MODE_CONTINUOUS = 0, /** reporting on change */ AREPORTING_MODE_ON_CHANGE = 1, /** on shot reporting */ AREPORTING_MODE_ONE_SHOT = 2, /** special trigger reporting */ AREPORTING_MODE_SPECIAL_TRIGGER = 3 }; /* * A few useful constants */ /** Earth's gravity in m/s^2 */ #define ASENSOR_STANDARD_GRAVITY (9.80665f) /** Maximum magnetic field on Earth's surface in uT */ #define ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f) /** Minimum magnetic field on Earth's surface in uT*/ #define ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f) /** * A sensor event. */ /* NOTE: Must match hardware/sensors.h */ typedef struct ASensorVector { union { float v[3]; struct { float x; float y; float z; }; struct { float azimuth; float pitch; float roll; }; }; int8_t status; uint8_t reserved[3]; } ASensorVector; typedef struct AMetaDataEvent { int32_t what; int32_t sensor; } AMetaDataEvent; typedef struct AUncalibratedEvent { union { float uncalib[3]; struct { float x_uncalib; float y_uncalib; float z_uncalib; }; }; union { float bias[3]; struct { float x_bias; float y_bias; float z_bias; }; }; } AUncalibratedEvent; typedef struct AHeartRateEvent { float bpm; int8_t status; } AHeartRateEvent; /* NOTE: Must match hardware/sensors.h */ typedef struct ASensorEvent { int32_t version; /* sizeof(struct ASensorEvent) */ int32_t sensor; int32_t type; int32_t reserved0; int64_t timestamp; union { union { float data[16]; ASensorVector vector; ASensorVector acceleration; ASensorVector magnetic; float temperature; float distance; float light; float pressure; float relative_humidity; AUncalibratedEvent uncalibrated_gyro; AUncalibratedEvent uncalibrated_magnetic; AMetaDataEvent meta_data; AHeartRateEvent heart_rate; }; union { uint64_t data[8]; uint64_t step_counter; } u64; }; uint32_t flags; int32_t reserved1[3]; } ASensorEvent; struct ASensorManager; /** * {@link ASensorManager} is an opaque type to manage sensors and * events queues. * * {@link ASensorManager} is a singleton that can be obtained using * ASensorManager_getInstance(). * * This file provides a set of functions that uses {@link * ASensorManager} to access and list hardware sensors, and * create and destroy event queues: * - ASensorManager_getSensorList() * - ASensorManager_getDefaultSensor() * - ASensorManager_getDefaultSensorEx() * - ASensorManager_createEventQueue() * - ASensorManager_destroyEventQueue() */ typedef struct ASensorManager ASensorManager; struct ASensorEventQueue; /** * {@link ASensorEventQueue} is an opaque type that provides access to * {@link ASensorEvent} from hardware sensors. * * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue(). * * This file provides a set of functions to enable and disable * sensors, check and get events, and set event rates on a {@link * ASensorEventQueue}. * - ASensorEventQueue_enableSensor() * - ASensorEventQueue_disableSensor() * - ASensorEventQueue_hasEvents() * - ASensorEventQueue_getEvents() * - ASensorEventQueue_setEventRate() */ typedef struct ASensorEventQueue ASensorEventQueue; struct ASensor; /** * {@link ASensor} is an opaque type that provides information about * an hardware sensors. * * A {@link ASensor} pointer can be obtained using * ASensorManager_getDefaultSensor(), * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}. * * This file provides a set of functions to access properties of a * {@link ASensor}: * - ASensor_getName() * - ASensor_getVendor() * - ASensor_getType() * - ASensor_getResolution() * - ASensor_getMinDelay() * - ASensor_getFifoMaxEventCount() * - ASensor_getFifoReservedEventCount() * - ASensor_getStringType() * - ASensor_getReportingMode() * - ASensor_isWakeUpSensor() */ typedef struct ASensor ASensor; /** * {@link ASensorRef} is a type for constant pointers to {@link ASensor}. * * This is used to define entry in {@link ASensorList} arrays. */ typedef ASensor const* ASensorRef; /** * {@link ASensorList} is an array of reference to {@link ASensor}. * * A {@link ASensorList} can be initialized using ASensorManager_getSensorList(). */ typedef ASensorRef const* ASensorList; /*****************************************************************************/ /** * Get a reference to the sensor manager. ASensorManager is a singleton * per package as different packages may have access to different sensors. * * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead. * * Example: * * ASensorManager* sensorManager = ASensorManager_getInstance(); * */ __attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance(); /* * Get a reference to the sensor manager. ASensorManager is a singleton * per package as different packages may have access to different sensors. * * Example: * * ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz"); * */ ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName); /** * Returns the list of available sensors. */ int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list); /** * Returns the default sensor for the given type, or NULL if no sensor * of that type exists. */ ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type); /** * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor * of this type and wakeUp properties exists. */ ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp); /** * Creates a new sensor event queue and associate it with a looper. * * "ident" is a identifier for the events that will be returned when * calling ALooper_pollOnce(). The identifier must be >= 0, or * ALOOPER_POLL_CALLBACK if providing a non-NULL callback. */ ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager, ALooper* looper, int ident, ALooper_callbackFunc callback, void* data); /** * Destroys the event queue and free all resources associated to it. */ int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue); /*****************************************************************************/ /** * Enable the selected sensor. Returns a negative error code on failure. */ int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor); /** * Disable the selected sensor. Returns a negative error code on failure. */ int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor); /** * Sets the delivery rate of events in microseconds for the given sensor. * Note that this is a hint only, generally event will arrive at a higher * rate. It is an error to set a rate inferior to the value returned by * ASensor_getMinDelay(). * Returns a negative error code on failure. */ int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec); /** * Returns true if there are one or more events available in the * sensor queue. Returns 1 if the queue has events; 0 if * it does not have events; and a negative value if there is an error. */ int ASensorEventQueue_hasEvents(ASensorEventQueue* queue); /** * Returns the next available events from the queue. Returns a negative * value if no events are available or an error has occurred, otherwise * the number of events returned. * * Examples: * ASensorEvent event; * ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1); * * ASensorEvent eventBuffer[8]; * ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8); * */ ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, ASensorEvent* events, size_t count); /*****************************************************************************/ /** * Returns this sensor's name (non localized) */ const char* ASensor_getName(ASensor const* sensor); /** * Returns this sensor's vendor's name (non localized) */ const char* ASensor_getVendor(ASensor const* sensor); /** * Return this sensor's type */ int ASensor_getType(ASensor const* sensor); /** * Returns this sensors's resolution */ float ASensor_getResolution(ASensor const* sensor); /** * Returns the minimum delay allowed between events in microseconds. * A value of zero means that this sensor doesn't report events at a * constant rate, but rather only when a new data is available. */ int ASensor_getMinDelay(ASensor const* sensor); /** * Returns the maximum size of batches for this sensor. Batches will often be * smaller, as the hardware fifo might be used for other sensors. */ int ASensor_getFifoMaxEventCount(ASensor const* sensor); /** * Returns the hardware batch fifo size reserved to this sensor. */ int ASensor_getFifoReservedEventCount(ASensor const* sensor); /** * Returns this sensor's string type. */ const char* ASensor_getStringType(ASensor const* sensor); /** * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants. */ int ASensor_getReportingMode(ASensor const* sensor); /** * Returns true if this is a wake up sensor, false otherwise. */ bool ASensor_isWakeUpSensor(ASensor const* sensor); #ifdef __cplusplus }; #endif #endif // ANDROID_SENSOR_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/storage_manager.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup Storage * @{ */ /** * @file storage_manager.h */ #ifndef ANDROID_STORAGE_MANAGER_H #define ANDROID_STORAGE_MANAGER_H #include #ifdef __cplusplus extern "C" { #endif struct AStorageManager; /** * {@link AStorageManager} manages application OBB storage, a pointer * can be obtained with AStorageManager_new(). */ typedef struct AStorageManager AStorageManager; /** * The different states of a OBB storage passed to AStorageManager_obbCallbackFunc(). */ enum { /** * The OBB container is now mounted and ready for use. Can be returned * as the status for callbacks made during asynchronous OBB actions. */ AOBB_STATE_MOUNTED = 1, /** * The OBB container is now unmounted and not usable. Can be returned * as the status for callbacks made during asynchronous OBB actions. */ AOBB_STATE_UNMOUNTED = 2, /** * There was an internal system error encountered while trying to * mount the OBB. Can be returned as the status for callbacks made * during asynchronous OBB actions. */ AOBB_STATE_ERROR_INTERNAL = 20, /** * The OBB could not be mounted by the system. Can be returned as the * status for callbacks made during asynchronous OBB actions. */ AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21, /** * The OBB could not be unmounted. This most likely indicates that a * file is in use on the OBB. Can be returned as the status for * callbacks made during asynchronous OBB actions. */ AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22, /** * A call was made to unmount the OBB when it was not mounted. Can be * returned as the status for callbacks made during asynchronous OBB * actions. */ AOBB_STATE_ERROR_NOT_MOUNTED = 23, /** * The OBB has already been mounted. Can be returned as the status for * callbacks made during asynchronous OBB actions. */ AOBB_STATE_ERROR_ALREADY_MOUNTED = 24, /** * The current application does not have permission to use this OBB. * This could be because the OBB indicates it's owned by a different * package. Can be returned as the status for callbacks made during * asynchronous OBB actions. */ AOBB_STATE_ERROR_PERMISSION_DENIED = 25, }; /** * Obtains a new instance of AStorageManager. */ AStorageManager* AStorageManager_new(); /** * Release AStorageManager instance. */ void AStorageManager_delete(AStorageManager* mgr); /** * Callback function for asynchronous calls made on OBB files. * * "state" is one of the following constants: * - {@link AOBB_STATE_MOUNTED} * - {@link AOBB_STATE_UNMOUNTED} * - {@link AOBB_STATE_ERROR_INTERNAL} * - {@link AOBB_STATE_ERROR_COULD_NOT_MOUNT} * - {@link AOBB_STATE_ERROR_COULD_NOT_UNMOUNT} * - {@link AOBB_STATE_ERROR_NOT_MOUNTED} * - {@link AOBB_STATE_ERROR_ALREADY_MOUNTED} * - {@link AOBB_STATE_ERROR_PERMISSION_DENIED} */ typedef void (*AStorageManager_obbCallbackFunc)(const char* filename, const int32_t state, void* data); /** * Attempts to mount an OBB file. This is an asynchronous operation. */ void AStorageManager_mountObb(AStorageManager* mgr, const char* filename, const char* key, AStorageManager_obbCallbackFunc cb, void* data); /** * Attempts to unmount an OBB file. This is an asynchronous operation. */ void AStorageManager_unmountObb(AStorageManager* mgr, const char* filename, const int force, AStorageManager_obbCallbackFunc cb, void* data); /** * Check whether an OBB is mounted. */ int AStorageManager_isObbMounted(AStorageManager* mgr, const char* filename); /** * Get the mounted path for an OBB. */ const char* AStorageManager_getMountedObbPath(AStorageManager* mgr, const char* filename); #ifdef __cplusplus }; #endif #endif // ANDROID_STORAGE_MANAGER_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/android/trace.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_NATIVE_TRACE_H #define ANDROID_NATIVE_TRACE_H #include #ifdef __cplusplus extern "C" { #endif /** * Returns true if tracing is enabled. Use this signal to avoid expensive computation only necessary * when tracing is enabled. */ bool ATrace_isEnabled(); /** * Writes a tracing message to indicate that the given section of code has begun. This call must be * followed by a corresponding call to endSection() on the same thread. * * Note: At this time the vertical bar character '|' and newline character '\n' are used internally * by the tracing mechanism. If sectionName contains these characters they will be replaced with a * space character in the trace. */ void ATrace_beginSection(const char* sectionName); /** * Writes a tracing message to indicate that a given section of code has ended. This call must be * preceeded by a corresponding call to beginSection(char*) on the same thread. Calling this method * will mark the end of the most recently begun section of code, so care must be taken to ensure * that beginSection / endSection pairs are properly nested and called from the same thread. */ void ATrace_endSection(); #ifdef __cplusplus }; #endif #endif // ANDROID_NATIVE_TRACE_H ================================================ FILE: phonelibs/android_frameworks_native/include/android/window.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @addtogroup NativeActivity Native Activity * @{ */ /** * @file window.h */ #ifndef ANDROID_WINDOW_H #define ANDROID_WINDOW_H #ifdef __cplusplus extern "C" { #endif /** * Window flags, as per the Java API at android.view.WindowManager.LayoutParams. */ enum { /** * As long as this window is visible to the user, allow the lock * screen to activate while the screen is on. This can be used * independently, or in combination with {@link * AWINDOW_FLAG_KEEP_SCREEN_ON} and/or {@link * AWINDOW_FLAG_SHOW_WHEN_LOCKED} */ AWINDOW_FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, /** Everything behind this window will be dimmed. */ AWINDOW_FLAG_DIM_BEHIND = 0x00000002, /** * Blur everything behind this window. * @deprecated Blurring is no longer supported. */ AWINDOW_FLAG_BLUR_BEHIND = 0x00000004, /** * This window won't ever get key input focus, so the * user can not send key or other button events to it. Those will * instead go to whatever focusable window is behind it. This flag * will also enable {@link AWINDOW_FLAG_NOT_TOUCH_MODAL} whether or not that * is explicitly set. * * Setting this flag also implies that the window will not need to * interact with * a soft input method, so it will be Z-ordered and positioned * independently of any active input method (typically this means it * gets Z-ordered on top of the input method, so it can use the full * screen for its content and cover the input method if needed. You * can use {@link AWINDOW_FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ AWINDOW_FLAG_NOT_FOCUSABLE = 0x00000008, /** this window can never receive touch events. */ AWINDOW_FLAG_NOT_TOUCHABLE = 0x00000010, /** * Even when this window is focusable (its * {@link AWINDOW_FLAG_NOT_FOCUSABLE} is not set), allow any pointer events * outside of the window to be sent to the windows behind it. Otherwise * it will consume all pointer events itself, regardless of whether they * are inside of the window. */ AWINDOW_FLAG_NOT_TOUCH_MODAL = 0x00000020, /** * When set, if the device is asleep when the touch * screen is pressed, you will receive this first touch event. Usually * the first touch event is consumed by the system since the user can * not see what they are pressing on. * * @deprecated This flag has no effect. */ AWINDOW_FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040, /** * As long as this window is visible to the user, keep * the device's screen turned on and bright. */ AWINDOW_FLAG_KEEP_SCREEN_ON = 0x00000080, /** * Place the window within the entire screen, ignoring * decorations around the border (such as the status bar). The * window must correctly position its contents to take the screen * decoration into account. */ AWINDOW_FLAG_LAYOUT_IN_SCREEN = 0x00000100, /** allow window to extend outside of the screen. */ AWINDOW_FLAG_LAYOUT_NO_LIMITS = 0x00000200, /** * Hide all screen decorations (such as the status * bar) while this window is displayed. This allows the window to * use the entire display space for itself -- the status bar will * be hidden when an app window with this flag set is on the top * layer. A fullscreen window will ignore a value of {@link * AWINDOW_SOFT_INPUT_ADJUST_RESIZE}; the window will stay * fullscreen and will not resize. */ AWINDOW_FLAG_FULLSCREEN = 0x00000400, /** * Override {@link AWINDOW_FLAG_FULLSCREEN} and force the * screen decorations (such as the status bar) to be shown. */ AWINDOW_FLAG_FORCE_NOT_FULLSCREEN = 0x00000800, /** * Turn on dithering when compositing this window to * the screen. * @deprecated This flag is no longer used. */ AWINDOW_FLAG_DITHER = 0x00001000, /** * Treat the content of the window as secure, preventing * it from appearing in screenshots or from being viewed on non-secure * displays. */ AWINDOW_FLAG_SECURE = 0x00002000, /** * A special mode where the layout parameters are used * to perform scaling of the surface when it is composited to the * screen. */ AWINDOW_FLAG_SCALED = 0x00004000, /** * Intended for windows that will often be used when the user is * holding the screen against their face, it will aggressively * filter the event stream to prevent unintended presses in this * situation that may not be desired for a particular window, when * such an event stream is detected, the application will receive * a {@link AMOTION_EVENT_ACTION_CANCEL} to indicate this so * applications can handle this accordingly by taking no action on * the event until the finger is released. */ AWINDOW_FLAG_IGNORE_CHEEK_PRESSES = 0x00008000, /** * A special option only for use in combination with * {@link AWINDOW_FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the * screen your window may appear on top of or behind screen decorations * such as the status bar. By also including this flag, the window * manager will report the inset rectangle needed to ensure your * content is not covered by screen decorations. */ AWINDOW_FLAG_LAYOUT_INSET_DECOR = 0x00010000, /** * Invert the state of {@link AWINDOW_FLAG_NOT_FOCUSABLE} with * respect to how this window interacts with the current method. * That is, if FLAG_NOT_FOCUSABLE is set and this flag is set, * then the window will behave as if it needs to interact with the * input method and thus be placed behind/away from it; if {@link * AWINDOW_FLAG_NOT_FOCUSABLE} is not set and this flag is set, * then the window will behave as if it doesn't need to interact * with the input method and can be placed to use more space and * cover the input method. */ AWINDOW_FLAG_ALT_FOCUSABLE_IM = 0x00020000, /** * If you have set {@link AWINDOW_FLAG_NOT_TOUCH_MODAL}, you * can set this flag to receive a single special MotionEvent with * the action * {@link AMOTION_EVENT_ACTION_OUTSIDE} for * touches that occur outside of your window. Note that you will not * receive the full down/move/up gesture, only the location of the * first down as an {@link AMOTION_EVENT_ACTION_OUTSIDE}. */ AWINDOW_FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000, /** * Special flag to let windows be shown when the screen * is locked. This will let application windows take precedence over * key guard or any other lock screens. Can be used with * {@link AWINDOW_FLAG_KEEP_SCREEN_ON} to turn screen on and display windows * directly before showing the key guard window. Can be used with * {@link AWINDOW_FLAG_DISMISS_KEYGUARD} to automatically fully dismisss * non-secure keyguards. This flag only applies to the top-most * full-screen window. */ AWINDOW_FLAG_SHOW_WHEN_LOCKED = 0x00080000, /** * Ask that the system wallpaper be shown behind * your window. The window surface must be translucent to be able * to actually see the wallpaper behind it; this flag just ensures * that the wallpaper surface will be there if this window actually * has translucent regions. */ AWINDOW_FLAG_SHOW_WALLPAPER = 0x00100000, /** * When set as a window is being added or made * visible, once the window has been shown then the system will * poke the power manager's user activity (as if the user had woken * up the device) to turn the screen on. */ AWINDOW_FLAG_TURN_SCREEN_ON = 0x00200000, /** * When set the window will cause the keyguard to * be dismissed, only if it is not a secure lock keyguard. Because such * a keyguard is not needed for security, it will never re-appear if * the user navigates to another window (in contrast to * {@link AWINDOW_FLAG_SHOW_WHEN_LOCKED}, which will only temporarily * hide both secure and non-secure keyguards but ensure they reappear * when the user moves to another UI that doesn't hide them). * If the keyguard is currently active and is secure (requires an * unlock pattern) than the user will still need to confirm it before * seeing this window, unless {@link AWINDOW_FLAG_SHOW_WHEN_LOCKED} has * also been set. */ AWINDOW_FLAG_DISMISS_KEYGUARD = 0x00400000, }; #ifdef __cplusplus }; #endif #endif // ANDROID_WINDOW_H /** @} */ ================================================ FILE: phonelibs/android_frameworks_native/include/binder/AppOpsManager.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_APP_OPS_MANAGER_H #define ANDROID_APP_OPS_MANAGER_H #include #include // --------------------------------------------------------------------------- namespace android { class AppOpsManager { public: enum { MODE_ALLOWED = IAppOpsService::MODE_ALLOWED, MODE_IGNORED = IAppOpsService::MODE_IGNORED, MODE_ERRORED = IAppOpsService::MODE_ERRORED }; enum { OP_NONE = -1, OP_COARSE_LOCATION = 0, OP_FINE_LOCATION = 1, OP_GPS = 2, OP_VIBRATE = 3, OP_READ_CONTACTS = 4, OP_WRITE_CONTACTS = 5, OP_READ_CALL_LOG = 6, OP_WRITE_CALL_LOG = 7, OP_READ_CALENDAR = 8, OP_WRITE_CALENDAR = 9, OP_WIFI_SCAN = 10, OP_POST_NOTIFICATION = 11, OP_NEIGHBORING_CELLS = 12, OP_CALL_PHONE = 13, OP_READ_SMS = 14, OP_WRITE_SMS = 15, OP_RECEIVE_SMS = 16, OP_RECEIVE_EMERGECY_SMS = 17, OP_RECEIVE_MMS = 18, OP_RECEIVE_WAP_PUSH = 19, OP_SEND_SMS = 20, OP_READ_ICC_SMS = 21, OP_WRITE_ICC_SMS = 22, OP_WRITE_SETTINGS = 23, OP_SYSTEM_ALERT_WINDOW = 24, OP_ACCESS_NOTIFICATIONS = 25, OP_CAMERA = 26, OP_RECORD_AUDIO = 27, OP_PLAY_AUDIO = 28, OP_READ_CLIPBOARD = 29, OP_WRITE_CLIPBOARD = 30, OP_TAKE_MEDIA_BUTTONS = 31, OP_TAKE_AUDIO_FOCUS = 32, OP_AUDIO_MASTER_VOLUME = 33, OP_AUDIO_VOICE_VOLUME = 34, OP_AUDIO_RING_VOLUME = 35, OP_AUDIO_MEDIA_VOLUME = 36, OP_AUDIO_ALARM_VOLUME = 37, OP_AUDIO_NOTIFICATION_VOLUME = 38, OP_AUDIO_BLUETOOTH_VOLUME = 39, OP_WAKE_LOCK = 40, OP_MONITOR_LOCATION = 41, OP_MONITOR_HIGH_POWER_LOCATION = 42, OP_GET_USAGE_STATS = 43, OP_MUTE_MICROPHONE = 44, OP_TOAST_WINDOW = 45, OP_PROJECT_MEDIA = 46, OP_ACTIVATE_VPN = 47, OP_WRITE_WALLPAPER = 48, OP_ASSIST_STRUCTURE = 49, OP_ASSIST_SCREENSHOT = 50, OP_READ_PHONE_STATE = 51, OP_ADD_VOICEMAIL = 52, OP_USE_SIP = 53, OP_PROCESS_OUTGOING_CALLS = 54, OP_USE_FINGERPRINT = 55, OP_BODY_SENSORS = 56, OP_READ_CELL_BROADCASTS = 57, OP_MOCK_LOCATION = 58, OP_READ_EXTERNAL_STORAGE = 59, OP_WRITE_EXTERNAL_STORAGE = 60, OP_TURN_SCREEN_ON = 61, OP_GET_ACCOUNTS = 62, OP_WIFI_CHANGE = 63, OP_BLUETOOTH_CHANGE = 64, OP_BOOT_COMPLETED = 65, OP_NFC_CHANGE = 66, OP_DATA_CONNECT_CHANGE = 67, OP_SU = 68 }; AppOpsManager(); int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage); int32_t noteOp(int32_t op, int32_t uid, const String16& callingPackage); int32_t startOp(int32_t op, int32_t uid, const String16& callingPackage); void finishOp(int32_t op, int32_t uid, const String16& callingPackage); void startWatchingMode(int32_t op, const String16& packageName, const sp& callback); void stopWatchingMode(const sp& callback); int32_t permissionToOpCode(const String16& permission); private: Mutex mLock; sp mService; sp getService(); }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_APP_OPS_MANAGER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/Binder.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_BINDER_H #define ANDROID_BINDER_H #include #include #include // --------------------------------------------------------------------------- namespace android { class BBinder : public IBinder { public: BBinder(); virtual const String16& getInterfaceDescriptor() const; virtual bool isBinderAlive() const; virtual status_t pingBinder(); virtual status_t dump(int fd, const Vector& args); virtual status_t transact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); virtual status_t linkToDeath(const sp& recipient, void* cookie = NULL, uint32_t flags = 0); virtual status_t unlinkToDeath( const wp& recipient, void* cookie = NULL, uint32_t flags = 0, wp* outRecipient = NULL); virtual void attachObject( const void* objectID, void* object, void* cleanupCookie, object_cleanup_func func); virtual void* findObject(const void* objectID) const; virtual void detachObject(const void* objectID); virtual BBinder* localBinder(); protected: virtual ~BBinder(); virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); private: BBinder(const BBinder& o); BBinder& operator=(const BBinder& o); class Extras; atomic_uintptr_t mExtras; // should be atomic void* mReserved0; }; // --------------------------------------------------------------------------- class BpRefBase : public virtual RefBase { protected: BpRefBase(const sp& o); virtual ~BpRefBase(); virtual void onFirstRef(); virtual void onLastStrongRef(const void* id); virtual bool onIncStrongAttempted(uint32_t flags, const void* id); inline IBinder* remote() { return mRemote; } inline IBinder* remote() const { return mRemote; } private: BpRefBase(const BpRefBase& o); BpRefBase& operator=(const BpRefBase& o); IBinder* const mRemote; RefBase::weakref_type* mRefs; volatile int32_t mState; }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_BINDER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/BinderService.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_BINDER_SERVICE_H #define ANDROID_BINDER_SERVICE_H #include #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { template class BinderService { public: static status_t publish(bool allowIsolated = false) { sp sm(defaultServiceManager()); return sm->addService( String16(SERVICE::getServiceName()), new SERVICE(), allowIsolated); } static void publishAndJoinThreadPool(bool allowIsolated = false) { publish(allowIsolated); joinThreadPool(); } static void instantiate() { publish(); } static status_t shutdown() { return NO_ERROR; } private: static void joinThreadPool() { sp ps(ProcessState::self()); ps->startThreadPool(); ps->giveThreadPoolName(); IPCThreadState::self()->joinThreadPool(); } }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_BINDER_SERVICE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/BpBinder.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_BPBINDER_H #define ANDROID_BPBINDER_H #include #include #include // --------------------------------------------------------------------------- namespace android { class BpBinder : public IBinder { public: BpBinder(int32_t handle); inline int32_t handle() const { return mHandle; } virtual const String16& getInterfaceDescriptor() const; virtual bool isBinderAlive() const; virtual status_t pingBinder(); virtual status_t dump(int fd, const Vector& args); virtual status_t transact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); virtual status_t linkToDeath(const sp& recipient, void* cookie = NULL, uint32_t flags = 0); virtual status_t unlinkToDeath( const wp& recipient, void* cookie = NULL, uint32_t flags = 0, wp* outRecipient = NULL); virtual void attachObject( const void* objectID, void* object, void* cleanupCookie, object_cleanup_func func); virtual void* findObject(const void* objectID) const; virtual void detachObject(const void* objectID); virtual BpBinder* remoteBinder(); status_t setConstantData(const void* data, size_t size); void sendObituary(); class ObjectManager { public: ObjectManager(); ~ObjectManager(); void attach( const void* objectID, void* object, void* cleanupCookie, IBinder::object_cleanup_func func); void* find(const void* objectID) const; void detach(const void* objectID); void kill(); private: ObjectManager(const ObjectManager&); ObjectManager& operator=(const ObjectManager&); struct entry_t { void* object; void* cleanupCookie; IBinder::object_cleanup_func func; }; KeyedVector mObjects; }; protected: virtual ~BpBinder(); virtual void onFirstRef(); virtual void onLastStrongRef(const void* id); virtual bool onIncStrongAttempted(uint32_t flags, const void* id); private: const int32_t mHandle; struct Obituary { wp recipient; void* cookie; uint32_t flags; }; void reportOneDeath(const Obituary& obit); bool isDescriptorCached() const; mutable Mutex mLock; volatile int32_t mAlive; volatile int32_t mObitsSent; Vector* mObituaries; ObjectManager mObjects; Parcel* mConstantData; mutable String16 mDescriptorCache; }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_BPBINDER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/BufferedTextOutput.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_BUFFEREDTEXTOUTPUT_H #define ANDROID_BUFFEREDTEXTOUTPUT_H #include #include #include // --------------------------------------------------------------------------- namespace android { class BufferedTextOutput : public TextOutput { public: //** Flags for constructor */ enum { MULTITHREADED = 0x0001 }; BufferedTextOutput(uint32_t flags = 0); virtual ~BufferedTextOutput(); virtual status_t print(const char* txt, size_t len); virtual void moveIndent(int delta); virtual void pushBundle(); virtual void popBundle(); protected: virtual status_t writeLines(const struct iovec& vec, size_t N) = 0; private: struct BufferState; struct ThreadState; static ThreadState*getThreadState(); static void threadDestructor(void *st); BufferState*getBuffer() const; uint32_t mFlags; const int32_t mSeq; const int32_t mIndex; Mutex mLock; BufferState* mGlobalState; }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_BUFFEREDTEXTOUTPUT_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/Debug.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_BINDER_DEBUG_H #define ANDROID_BINDER_DEBUG_H #include #include namespace android { // --------------------------------------------------------------------------- #ifdef __cplusplus extern "C" { #endif const char* stringForIndent(int32_t indentLevel); typedef void (*debugPrintFunc)(void* cookie, const char* txt); void printTypeCode(uint32_t typeCode, debugPrintFunc func = 0, void* cookie = 0); void printHexData(int32_t indent, const void *buf, size_t length, size_t bytesPerLine=16, int32_t singleLineBytesCutoff=16, size_t alignment=0, bool cArrayStyle=false, debugPrintFunc func = 0, void* cookie = 0); #ifdef __cplusplus } #endif // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_BINDER_DEBUG_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IAppOpsCallback.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #ifndef ANDROID_IAPP_OPS_CALLBACK_H #define ANDROID_IAPP_OPS_CALLBACK_H #include namespace android { // ---------------------------------------------------------------------- class IAppOpsCallback : public IInterface { public: DECLARE_META_INTERFACE(AppOpsCallback); virtual void opChanged(int32_t op, const String16& packageName) = 0; enum { OP_CHANGED_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION }; }; // ---------------------------------------------------------------------- class BnAppOpsCallback : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_IAPP_OPS_CALLBACK_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IAppOpsService.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #ifndef ANDROID_IAPP_OPS_SERVICE_H #define ANDROID_IAPP_OPS_SERVICE_H #include #include namespace android { // ---------------------------------------------------------------------- class IAppOpsService : public IInterface { public: DECLARE_META_INTERFACE(AppOpsService); virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0; virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) = 0; virtual int32_t startOperation(const sp& token, int32_t code, int32_t uid, const String16& packageName) = 0; virtual void finishOperation(const sp& token, int32_t code, int32_t uid, const String16& packageName) = 0; virtual void startWatchingMode(int32_t op, const String16& packageName, const sp& callback) = 0; virtual void stopWatchingMode(const sp& callback) = 0; virtual sp getToken(const sp& clientToken) = 0; virtual int32_t permissionToOpCode(const String16& permission) = 0; enum { CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1, START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2, FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3, START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, }; enum { MODE_ALLOWED = 0, MODE_IGNORED = 1, MODE_ERRORED = 2 }; }; // ---------------------------------------------------------------------- class BnAppOpsService : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_IAPP_OPS_SERVICE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IBatteryStats.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_IBATTERYSTATS_H #define ANDROID_IBATTERYSTATS_H #include namespace android { // ---------------------------------------------------------------------- class IBatteryStats : public IInterface { public: DECLARE_META_INTERFACE(BatteryStats); virtual void noteStartSensor(int uid, int sensor) = 0; virtual void noteStopSensor(int uid, int sensor) = 0; virtual void noteStartVideo(int uid) = 0; virtual void noteStopVideo(int uid) = 0; virtual void noteStartAudio(int uid) = 0; virtual void noteStopAudio(int uid) = 0; virtual void noteResetVideo() = 0; virtual void noteResetAudio() = 0; virtual void noteFlashlightOn(int uid) = 0; virtual void noteFlashlightOff(int uid) = 0; virtual void noteStartCamera(int uid) = 0; virtual void noteStopCamera(int uid) = 0; virtual void noteResetCamera() = 0; virtual void noteResetFlashlight() = 0; enum { NOTE_START_SENSOR_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, NOTE_STOP_SENSOR_TRANSACTION, NOTE_START_VIDEO_TRANSACTION, NOTE_STOP_VIDEO_TRANSACTION, NOTE_START_AUDIO_TRANSACTION, NOTE_STOP_AUDIO_TRANSACTION, NOTE_RESET_VIDEO_TRANSACTION, NOTE_RESET_AUDIO_TRANSACTION, NOTE_FLASHLIGHT_ON_TRANSACTION, NOTE_FLASHLIGHT_OFF_TRANSACTION, NOTE_START_CAMERA_TRANSACTION, NOTE_STOP_CAMERA_TRANSACTION, NOTE_RESET_CAMERA_TRANSACTION, NOTE_RESET_FLASHLIGHT_TRANSACTION }; }; // ---------------------------------------------------------------------- class BnBatteryStats : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_IBATTERYSTATS_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IBinder.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_IBINDER_H #define ANDROID_IBINDER_H #include #include #include #include #define B_PACK_CHARS(c1, c2, c3, c4) \ ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4)) // --------------------------------------------------------------------------- namespace android { class BBinder; class BpBinder; class IInterface; class Parcel; /** * Base class and low-level protocol for a remotable object. * You can derive from this class to create an object for which other * processes can hold references to it. Communication between processes * (method calls, property get and set) is down through a low-level * protocol implemented on top of the transact() API. */ class IBinder : public virtual RefBase { public: enum { FIRST_CALL_TRANSACTION = 0x00000001, LAST_CALL_TRANSACTION = 0x00ffffff, PING_TRANSACTION = B_PACK_CHARS('_','P','N','G'), DUMP_TRANSACTION = B_PACK_CHARS('_','D','M','P'), INTERFACE_TRANSACTION = B_PACK_CHARS('_', 'N', 'T', 'F'), SYSPROPS_TRANSACTION = B_PACK_CHARS('_', 'S', 'P', 'R'), // Corresponds to TF_ONE_WAY -- an asynchronous call. FLAG_ONEWAY = 0x00000001 }; IBinder(); /** * Check if this IBinder implements the interface named by * @a descriptor. If it does, the base pointer to it is returned, * which you can safely static_cast<> to the concrete C++ interface. */ virtual sp queryLocalInterface(const String16& descriptor); /** * Return the canonical name of the interface provided by this IBinder * object. */ virtual const String16& getInterfaceDescriptor() const = 0; virtual bool isBinderAlive() const = 0; virtual status_t pingBinder() = 0; virtual status_t dump(int fd, const Vector& args) = 0; virtual status_t transact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0) = 0; class DeathRecipient : public virtual RefBase { public: virtual void binderDied(const wp& who) = 0; }; /** * Register the @a recipient for a notification if this binder * goes away. If this binder object unexpectedly goes away * (typically because its hosting process has been killed), * then DeathRecipient::binderDied() will be called with a reference * to this. * * The @a cookie is optional -- if non-NULL, it should be a * memory address that you own (that is, you know it is unique). * * @note You will only receive death notifications for remote binders, * as local binders by definition can't die without you dying as well. * Trying to use this function on a local binder will result in an * INVALID_OPERATION code being returned and nothing happening. * * @note This link always holds a weak reference to its recipient. * * @note You will only receive a weak reference to the dead * binder. You should not try to promote this to a strong reference. * (Nor should you need to, as there is nothing useful you can * directly do with it now that it has passed on.) */ virtual status_t linkToDeath(const sp& recipient, void* cookie = NULL, uint32_t flags = 0) = 0; /** * Remove a previously registered death notification. * The @a recipient will no longer be called if this object * dies. The @a cookie is optional. If non-NULL, you can * supply a NULL @a recipient, and the recipient previously * added with that cookie will be unlinked. */ virtual status_t unlinkToDeath( const wp& recipient, void* cookie = NULL, uint32_t flags = 0, wp* outRecipient = NULL) = 0; virtual bool checkSubclass(const void* subclassID) const; typedef void (*object_cleanup_func)(const void* id, void* obj, void* cleanupCookie); virtual void attachObject( const void* objectID, void* object, void* cleanupCookie, object_cleanup_func func) = 0; virtual void* findObject(const void* objectID) const = 0; virtual void detachObject(const void* objectID) = 0; virtual BBinder* localBinder(); virtual BpBinder* remoteBinder(); protected: virtual ~IBinder(); private: }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_IBINDER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IInterface.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #ifndef ANDROID_IINTERFACE_H #define ANDROID_IINTERFACE_H #include namespace android { // ---------------------------------------------------------------------- class IInterface : public virtual RefBase { public: IInterface(); static sp asBinder(const IInterface*); static sp asBinder(const sp&); protected: virtual ~IInterface(); virtual IBinder* onAsBinder() = 0; }; // ---------------------------------------------------------------------- template inline sp interface_cast(const sp& obj) { return INTERFACE::asInterface(obj); } // ---------------------------------------------------------------------- template class BnInterface : public INTERFACE, public BBinder { public: virtual sp queryLocalInterface(const String16& _descriptor); virtual const String16& getInterfaceDescriptor() const; protected: virtual IBinder* onAsBinder(); }; // ---------------------------------------------------------------------- template class BpInterface : public INTERFACE, public BpRefBase { public: BpInterface(const sp& remote); protected: virtual IBinder* onAsBinder(); }; // ---------------------------------------------------------------------- #define DECLARE_META_INTERFACE(INTERFACE) \ static const android::String16 descriptor; \ static android::sp asInterface( \ const android::sp& obj); \ virtual const android::String16& getInterfaceDescriptor() const; \ I##INTERFACE(); \ virtual ~I##INTERFACE(); \ #define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ const android::String16 I##INTERFACE::descriptor(NAME); \ const android::String16& \ I##INTERFACE::getInterfaceDescriptor() const { \ return I##INTERFACE::descriptor; \ } \ android::sp I##INTERFACE::asInterface( \ const android::sp& obj) \ { \ android::sp intr; \ if (obj != NULL) { \ intr = static_cast( \ obj->queryLocalInterface( \ I##INTERFACE::descriptor).get()); \ if (intr == NULL) { \ intr = new Bp##INTERFACE(obj); \ } \ } \ return intr; \ } \ I##INTERFACE::I##INTERFACE() { } \ I##INTERFACE::~I##INTERFACE() { } \ #define CHECK_INTERFACE(interface, data, reply) \ if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \ // ---------------------------------------------------------------------- // No user-serviceable parts after this... template inline sp BnInterface::queryLocalInterface( const String16& _descriptor) { if (_descriptor == INTERFACE::descriptor) return this; return NULL; } template inline const String16& BnInterface::getInterfaceDescriptor() const { return INTERFACE::getInterfaceDescriptor(); } template IBinder* BnInterface::onAsBinder() { return this; } template inline BpInterface::BpInterface(const sp& remote) : BpRefBase(remote) { } template inline IBinder* BpInterface::onAsBinder() { return remote(); } // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_IINTERFACE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IMemory.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_IMEMORY_H #define ANDROID_IMEMORY_H #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class IMemoryHeap : public IInterface { public: DECLARE_META_INTERFACE(MemoryHeap); // flags returned by getFlags() enum { READ_ONLY = 0x00000001, #ifdef USE_MEMORY_HEAP_ION USE_ION_FD = 0x00008000 #else USE_ION_FD = 0x00000008 #endif }; virtual int getHeapID() const = 0; virtual void* getBase() const = 0; virtual size_t getSize() const = 0; virtual uint32_t getFlags() const = 0; virtual uint32_t getOffset() const = 0; // these are there just for backward source compatibility int32_t heapID() const { return getHeapID(); } void* base() const { return getBase(); } size_t virtualSize() const { return getSize(); } }; class BnMemoryHeap : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); BnMemoryHeap(); protected: virtual ~BnMemoryHeap(); }; // ---------------------------------------------------------------------------- class IMemory : public IInterface { public: DECLARE_META_INTERFACE(Memory); virtual sp getMemory(ssize_t* offset=0, size_t* size=0) const = 0; // helpers void* fastPointer(const sp& heap, ssize_t offset) const; void* pointer() const; size_t size() const; ssize_t offset() const; }; class BnMemory : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); BnMemory(); protected: virtual ~BnMemory(); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_IMEMORY_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IPCThreadState.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_IPC_THREAD_STATE_H #define ANDROID_IPC_THREAD_STATE_H #include #include #include #include #if defined(_WIN32) typedef int uid_t; #endif // --------------------------------------------------------------------------- namespace android { class IPCThreadState { public: static IPCThreadState* self(); static IPCThreadState* selfOrNull(); // self(), but won't instantiate sp process(); status_t clearLastError(); pid_t getCallingPid() const; uid_t getCallingUid() const; void setStrictModePolicy(int32_t policy); int32_t getStrictModePolicy() const; void setLastTransactionBinderFlags(int32_t flags); int32_t getLastTransactionBinderFlags() const; int64_t clearCallingIdentity(); void restoreCallingIdentity(int64_t token); int setupPolling(int* fd); status_t handlePolledCommands(); void flushCommands(); void joinThreadPool(bool isMain = true); // Stop the local process. void stopProcess(bool immediate = true); status_t transact(int32_t handle, uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); void incStrongHandle(int32_t handle); void decStrongHandle(int32_t handle); void incWeakHandle(int32_t handle); void decWeakHandle(int32_t handle); status_t attemptIncStrongHandle(int32_t handle); static void expungeHandle(int32_t handle, IBinder* binder); status_t requestDeathNotification( int32_t handle, BpBinder* proxy); status_t clearDeathNotification( int32_t handle, BpBinder* proxy); static void shutdown(); // Call this to disable switching threads to background scheduling when // receiving incoming IPC calls. This is specifically here for the // Android system process, since it expects to have background apps calling // in to it but doesn't want to acquire locks in its services while in // the background. static void disableBackgroundScheduling(bool disable); // Call blocks until the number of executing binder threads is less than // the maximum number of binder threads threads allowed for this process. void blockUntilThreadAvailable(); private: IPCThreadState(); ~IPCThreadState(); status_t sendReply(const Parcel& reply, uint32_t flags); status_t waitForResponse(Parcel *reply, status_t *acquireResult=NULL); status_t talkWithDriver(bool doReceive=true); status_t writeTransactionData(int32_t cmd, uint32_t binderFlags, int32_t handle, uint32_t code, const Parcel& data, status_t* statusBuffer); status_t getAndExecuteCommand(); status_t executeCommand(int32_t command); void processPendingDerefs(); void clearCaller(); static void threadDestructor(void *st); static void freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize, const binder_size_t* objects, size_t objectsSize, void* cookie); const sp mProcess; const pid_t mMyThreadId; Vector mPendingStrongDerefs; Vector mPendingWeakDerefs; Parcel mIn; Parcel mOut; status_t mLastError; pid_t mCallingPid; uid_t mCallingUid; int32_t mStrictModePolicy; int32_t mLastTransactionBinderFlags; }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_IPC_THREAD_STATE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IPermissionController.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #ifndef ANDROID_IPERMISSION_CONTROLLER_H #define ANDROID_IPERMISSION_CONTROLLER_H #include #include namespace android { // ---------------------------------------------------------------------- class IPermissionController : public IInterface { public: DECLARE_META_INTERFACE(PermissionController); virtual bool checkPermission(const String16& permission, int32_t pid, int32_t uid) = 0; virtual void getPackagesForUid(const uid_t uid, Vector &packages) = 0; virtual bool isRuntimePermission(const String16& permission) = 0; enum { CHECK_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, GET_PACKAGES_FOR_UID_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 1, IS_RUNTIME_PERMISSION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION + 2 }; }; // ---------------------------------------------------------------------- class BnPermissionController : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_IPERMISSION_CONTROLLER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IProcessInfoService.h ================================================ /* * Copyright 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_I_PROCESS_INFO_SERVICE_H #define ANDROID_I_PROCESS_INFO_SERVICE_H #include namespace android { // ---------------------------------------------------------------------- class IProcessInfoService : public IInterface { public: DECLARE_META_INTERFACE(ProcessInfoService); virtual status_t getProcessStatesFromPids( size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states) = 0; enum { GET_PROCESS_STATES_FROM_PIDS = IBinder::FIRST_CALL_TRANSACTION, }; }; // ---------------------------------------------------------------------- class BnProcessInfoService : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_I_PROCESS_INFO_SERVICE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/IServiceManager.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #ifndef ANDROID_ISERVICE_MANAGER_H #define ANDROID_ISERVICE_MANAGER_H #include #include #include #include namespace android { // ---------------------------------------------------------------------- class IServiceManager : public IInterface { public: DECLARE_META_INTERFACE(ServiceManager); /** * Retrieve an existing service, blocking for a few seconds * if it doesn't yet exist. */ virtual sp getService( const String16& name) const = 0; /** * Retrieve an existing service, non-blocking. */ virtual sp checkService( const String16& name) const = 0; /** * Register a service. */ virtual status_t addService( const String16& name, const sp& service, bool allowIsolated = false) = 0; /** * Return list of all existing services. */ virtual Vector listServices() = 0; enum { GET_SERVICE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, CHECK_SERVICE_TRANSACTION, ADD_SERVICE_TRANSACTION, LIST_SERVICES_TRANSACTION, }; }; sp defaultServiceManager(); template status_t getService(const String16& name, sp* outService) { const sp sm = defaultServiceManager(); if (sm != NULL) { *outService = interface_cast(sm->getService(name)); if ((*outService) != NULL) return NO_ERROR; } return NAME_NOT_FOUND; } bool checkCallingPermission(const String16& permission); bool checkCallingPermission(const String16& permission, int32_t* outPid, int32_t* outUid); bool checkPermission(const String16& permission, pid_t pid, uid_t uid); // ---------------------------------------------------------------------- class BnServiceManager : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_ISERVICE_MANAGER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/MemoryBase.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_MEMORY_BASE_H #define ANDROID_MEMORY_BASE_H #include #include #include namespace android { // --------------------------------------------------------------------------- class MemoryBase : public BnMemory { public: MemoryBase(const sp& heap, ssize_t offset, size_t size); virtual ~MemoryBase(); virtual sp getMemory(ssize_t* offset, size_t* size) const; protected: size_t getSize() const { return mSize; } ssize_t getOffset() const { return mOffset; } const sp& getHeap() const { return mHeap; } private: size_t mSize; ssize_t mOffset; sp mHeap; }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_MEMORY_BASE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/MemoryDealer.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_MEMORY_DEALER_H #define ANDROID_MEMORY_DEALER_H #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class SimpleBestFitAllocator; // ---------------------------------------------------------------------------- class MemoryDealer : public RefBase { public: MemoryDealer(size_t size, const char* name = 0, uint32_t flags = 0 /* or bits such as MemoryHeapBase::READ_ONLY */ ); virtual sp allocate(size_t size); virtual void deallocate(size_t offset); virtual void dump(const char* what) const; sp getMemoryHeap() const { return heap(); } protected: virtual ~MemoryDealer(); private: const sp& heap() const; SimpleBestFitAllocator* allocator() const; sp mHeap; SimpleBestFitAllocator* mAllocator; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_MEMORY_DEALER_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/MemoryHeapBase.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_MEMORY_HEAP_BASE_H #define ANDROID_MEMORY_HEAP_BASE_H #include #include #include namespace android { // --------------------------------------------------------------------------- class MemoryHeapBase : public virtual BnMemoryHeap { public: enum { READ_ONLY = IMemoryHeap::READ_ONLY, // memory won't be mapped locally, but will be mapped in the remote // process. DONT_MAP_LOCALLY = 0x00000100, NO_CACHING = 0x00000200 }; /* * maps the memory referenced by fd. but DOESN'T take ownership * of the filedescriptor (it makes a copy with dup() */ MemoryHeapBase(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0); /* * maps memory from the given device */ MemoryHeapBase(const char* device, size_t size = 0, uint32_t flags = 0); /* * maps memory from ashmem, with the given name for debugging */ MemoryHeapBase(size_t size, uint32_t flags = 0, char const* name = NULL); virtual ~MemoryHeapBase(); /* implement IMemoryHeap interface */ virtual int getHeapID() const; /* virtual address of the heap. returns MAP_FAILED in case of error */ virtual void* getBase() const; virtual size_t getSize() const; virtual uint32_t getFlags() const; virtual uint32_t getOffset() const; const char* getDevice() const; /* this closes this heap -- use carefully */ void dispose(); /* this is only needed as a workaround, use only if you know * what you are doing */ status_t setDevice(const char* device) { if (mDevice == 0) mDevice = device; return mDevice ? NO_ERROR : ALREADY_EXISTS; } protected: MemoryHeapBase(); // init() takes ownership of fd status_t init(int fd, void *base, int size, int flags = 0, const char* device = NULL); private: status_t mapfd(int fd, size_t size, uint32_t offset = 0); int mFD; size_t mSize; void* mBase; uint32_t mFlags; const char* mDevice; bool mNeedUnmap; uint32_t mOffset; }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_MEMORY_HEAP_BASE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/MemoryHeapIon.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * Copyright 2011, Samsung Electronics Co. LTD * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /*! * \file MemoryHeapIon.h * \brief header file for MemoryHeapIon * \author MinGu, Jeon(mingu85.jeon) * \date 2011/11/20 * * Revision History: * - 2011/11/21 : MinGu, Jeon(mingu85.jeon)) \n * Initial version * - 2012/11/29 : MinGu, Jeon(mingu85.jeon)) \n * Change name */ #ifndef ANDROID_MEMORY_HEAP_ION_H #define ANDROID_MEMORY_HEAP_ION_H #include #include #include #define MHB_ION_HEAP_SYSTEM_CONTIG_MASK (1 << 1) #define MHB_ION_HEAP_EXYNOS_CONTIG_MASK (1 << 4) #define MHB_ION_HEAP_EXYNOS_MASK (1 << 5) #define MHB_ION_HEAP_SYSTEM_MASK (1 << 6) #define MHB_ION_FLAG_CACHED (1 << 16) #define MHB_ION_FLAG_CACHED_NEEDS_SYNC (1 << 17) #define MHB_ION_FLAG_PRESERVE_KMAP (1 << 18) #define MHB_ION_EXYNOS_VIDEO_MASK (1 << 21) #define MHB_ION_EXYNOS_MFC_INPUT_MASK (1 << 25) #define MHB_ION_EXYNOS_MFC_OUTPUT_MASK (1 << 26) #define MHB_ION_EXYNOS_GSC_MASK (1 << 27) #define MHB_ION_EXYNOS_FIMD_VIDEO_MASK (1 << 28) namespace android { class MemoryHeapIon : public MemoryHeapBase { public: enum { USE_ION_FD = IMemoryHeap::USE_ION_FD }; MemoryHeapIon(size_t size, uint32_t flags = 0, char const* name = NULL); MemoryHeapIon(int fd, size_t size, uint32_t flags = 0, uint32_t offset = 0); ~MemoryHeapIon(); private: int mIonClient; }; }; #endif ================================================ FILE: phonelibs/android_frameworks_native/include/binder/Parcel.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_PARCEL_H #define ANDROID_PARCEL_H #include #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { template class Flattenable; template class LightFlattenable; class IBinder; class IPCThreadState; class ProcessState; class String8; class TextOutput; class Parcel { friend class IPCThreadState; public: class ReadableBlob; class WritableBlob; Parcel(); ~Parcel(); const uint8_t* data() const; size_t dataSize() const; size_t dataAvail() const; size_t dataPosition() const; size_t dataCapacity() const; status_t setDataSize(size_t size); void setDataPosition(size_t pos) const; status_t setDataCapacity(size_t size); status_t setData(const uint8_t* buffer, size_t len); status_t appendFrom(const Parcel *parcel, size_t start, size_t len); bool allowFds() const; bool pushAllowFds(bool allowFds); void restoreAllowFds(bool lastValue); bool hasFileDescriptors() const; // Writes the RPC header. status_t writeInterfaceToken(const String16& interface); // Parses the RPC header, returning true if the interface name // in the header matches the expected interface from the caller. // // Additionally, enforceInterface does part of the work of // propagating the StrictMode policy mask, populating the current // IPCThreadState, which as an optimization may optionally be // passed in. bool enforceInterface(const String16& interface, IPCThreadState* threadState = NULL) const; bool checkInterface(IBinder*) const; void freeData(); private: const binder_size_t* objects() const; public: size_t objectsCount() const; status_t errorCheck() const; void setError(status_t err); status_t write(const void* data, size_t len); void* writeInplace(size_t len); status_t writeUnpadded(const void* data, size_t len); status_t writeInt32(int32_t val); status_t writeUint32(uint32_t val); status_t writeInt64(int64_t val); status_t writeUint64(uint64_t val); status_t writeFloat(float val); status_t writeDouble(double val); status_t writeCString(const char* str); status_t writeString8(const String8& str); status_t writeString16(const String16& str); status_t writeString16(const char16_t* str, size_t len); status_t writeStrongBinder(const sp& val); status_t writeWeakBinder(const wp& val); status_t writeInt32Array(size_t len, const int32_t *val); status_t writeByteArray(size_t len, const uint8_t *val); template status_t write(const Flattenable& val); template status_t write(const LightFlattenable& val); // Place a native_handle into the parcel (the native_handle's file- // descriptors are dup'ed, so it is safe to delete the native_handle // when this function returns). // Doesn't take ownership of the native_handle. status_t writeNativeHandle(const native_handle* handle); // Place a file descriptor into the parcel. The given fd must remain // valid for the lifetime of the parcel. // The Parcel does not take ownership of the given fd unless you ask it to. status_t writeFileDescriptor(int fd, bool takeOwnership = false); // Place a file descriptor into the parcel. A dup of the fd is made, which // will be closed once the parcel is destroyed. status_t writeDupFileDescriptor(int fd); // Writes a blob to the parcel. // If the blob is small, then it is stored in-place, otherwise it is // transferred by way of an anonymous shared memory region. Prefer sending // immutable blobs if possible since they may be subsequently transferred between // processes without further copying whereas mutable blobs always need to be copied. // The caller should call release() on the blob after writing its contents. status_t writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob); // Write an existing immutable blob file descriptor to the parcel. // This allows the client to send the same blob to multiple processes // as long as it keeps a dup of the blob file descriptor handy for later. status_t writeDupImmutableBlobFileDescriptor(int fd); status_t writeObject(const flat_binder_object& val, bool nullMetaData); // Like Parcel.java's writeNoException(). Just writes a zero int32. // Currently the native implementation doesn't do any of the StrictMode // stack gathering and serialization that the Java implementation does. status_t writeNoException(); void remove(size_t start, size_t amt); status_t read(void* outData, size_t len) const; const void* readInplace(size_t len) const; int32_t readInt32() const; status_t readInt32(int32_t *pArg) const; uint32_t readUint32() const; status_t readUint32(uint32_t *pArg) const; int64_t readInt64() const; status_t readInt64(int64_t *pArg) const; uint64_t readUint64() const; status_t readUint64(uint64_t *pArg) const; float readFloat() const; status_t readFloat(float *pArg) const; double readDouble() const; status_t readDouble(double *pArg) const; intptr_t readIntPtr() const; status_t readIntPtr(intptr_t *pArg) const; const char* readCString() const; String8 readString8() const; String16 readString16() const; const char16_t* readString16Inplace(size_t* outLen) const; sp readStrongBinder() const; wp readWeakBinder() const; template status_t read(Flattenable& val) const; template status_t read(LightFlattenable& val) const; // Like Parcel.java's readExceptionCode(). Reads the first int32 // off of a Parcel's header, returning 0 or the negative error // code on exceptions, but also deals with skipping over rich // response headers. Callers should use this to read & parse the // response headers rather than doing it by hand. int32_t readExceptionCode() const; // Retrieve native_handle from the parcel. This returns a copy of the // parcel's native_handle (the caller takes ownership). The caller // must free the native_handle with native_handle_close() and // native_handle_delete(). native_handle* readNativeHandle() const; // Retrieve a file descriptor from the parcel. This returns the raw fd // in the parcel, which you do not own -- use dup() to get your own copy. int readFileDescriptor() const; // Reads a blob from the parcel. // The caller should call release() on the blob after reading its contents. status_t readBlob(size_t len, ReadableBlob* outBlob) const; const flat_binder_object* readObject(bool nullMetaData) const; // Explicitly close all file descriptors in the parcel. void closeFileDescriptors(); // Debugging: get metrics on current allocations. static size_t getGlobalAllocSize(); static size_t getGlobalAllocCount(); private: typedef void (*release_func)(Parcel* parcel, const uint8_t* data, size_t dataSize, const binder_size_t* objects, size_t objectsSize, void* cookie); uintptr_t ipcData() const; size_t ipcDataSize() const; uintptr_t ipcObjects() const; size_t ipcObjectsCount() const; void ipcSetDataReference(const uint8_t* data, size_t dataSize, const binder_size_t* objects, size_t objectsCount, release_func relFunc, void* relCookie); public: void print(TextOutput& to, uint32_t flags = 0) const; private: Parcel(const Parcel& o); Parcel& operator=(const Parcel& o); status_t finishWrite(size_t len); void releaseObjects(); void acquireObjects(); status_t growData(size_t len); status_t restartWrite(size_t desired); status_t continueWrite(size_t desired); status_t writePointer(uintptr_t val); status_t readPointer(uintptr_t *pArg) const; uintptr_t readPointer() const; void freeDataNoInit(); void initState(); void scanForFds() const; template status_t readAligned(T *pArg) const; template T readAligned() const; template status_t writeAligned(T val); status_t mError; uint8_t* mData; size_t mDataSize; size_t mDataCapacity; mutable size_t mDataPos; binder_size_t* mObjects; size_t mObjectsSize; size_t mObjectsCapacity; mutable size_t mNextObjectHint; mutable bool mFdsKnown; mutable bool mHasFds; bool mAllowFds; release_func mOwner; void* mOwnerCookie; class Blob { public: Blob(); ~Blob(); void clear(); void release(); inline size_t size() const { return mSize; } inline int fd() const { return mFd; }; inline bool isMutable() const { return mMutable; } protected: void init(int fd, void* data, size_t size, bool isMutable); int mFd; // owned by parcel so not closed when released void* mData; size_t mSize; bool mMutable; }; class FlattenableHelperInterface { protected: ~FlattenableHelperInterface() { } public: virtual size_t getFlattenedSize() const = 0; virtual size_t getFdCount() const = 0; virtual status_t flatten(void* buffer, size_t size, int* fds, size_t count) const = 0; virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) = 0; }; template class FlattenableHelper : public FlattenableHelperInterface { friend class Parcel; const Flattenable& val; explicit FlattenableHelper(const Flattenable& val) : val(val) { } public: virtual size_t getFlattenedSize() const { return val.getFlattenedSize(); } virtual size_t getFdCount() const { return val.getFdCount(); } virtual status_t flatten(void* buffer, size_t size, int* fds, size_t count) const { return val.flatten(buffer, size, fds, count); } virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) { return const_cast&>(val).unflatten(buffer, size, fds, count); } }; status_t write(const FlattenableHelperInterface& val); status_t read(FlattenableHelperInterface& val) const; public: class ReadableBlob : public Blob { friend class Parcel; public: inline const void* data() const { return mData; } inline void* mutableData() { return isMutable() ? mData : NULL; } }; class WritableBlob : public Blob { friend class Parcel; public: inline void* data() { return mData; } }; #ifndef DISABLE_ASHMEM_TRACKING private: size_t mOpenAshmemSize; #endif public: // TODO: Remove once ABI can be changed. size_t getBlobAshmemSize() const; size_t getOpenAshmemSize() const; }; // --------------------------------------------------------------------------- template status_t Parcel::write(const Flattenable& val) { const FlattenableHelper helper(val); return write(helper); } template status_t Parcel::write(const LightFlattenable& val) { size_t size(val.getFlattenedSize()); if (!val.isFixedSize()) { status_t err = writeInt32(size); if (err != NO_ERROR) { return err; } } if (size) { void* buffer = writeInplace(size); if (buffer == NULL) return NO_MEMORY; return val.flatten(buffer, size); } return NO_ERROR; } template status_t Parcel::read(Flattenable& val) const { FlattenableHelper helper(val); return read(helper); } template status_t Parcel::read(LightFlattenable& val) const { size_t size; if (val.isFixedSize()) { size = val.getFlattenedSize(); } else { int32_t s; status_t err = readInt32(&s); if (err != NO_ERROR) { return err; } size = s; } if (size) { void const* buffer = readInplace(size); return buffer == NULL ? NO_MEMORY : val.unflatten(buffer, size); } return NO_ERROR; } // --------------------------------------------------------------------------- inline TextOutput& operator<<(TextOutput& to, const Parcel& parcel) { parcel.print(to); return to; } // --------------------------------------------------------------------------- // Generic acquire and release of objects. void acquire_object(const sp& proc, const flat_binder_object& obj, const void* who); void release_object(const sp& proc, const flat_binder_object& obj, const void* who); void flatten_binder(const sp& proc, const sp& binder, flat_binder_object* out); void flatten_binder(const sp& proc, const wp& binder, flat_binder_object* out); status_t unflatten_binder(const sp& proc, const flat_binder_object& flat, sp* out); status_t unflatten_binder(const sp& proc, const flat_binder_object& flat, wp* out); }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_PARCEL_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/PermissionCache.h ================================================ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef BINDER_PERMISSION_H #define BINDER_PERMISSION_H #include #include #include #include #include namespace android { // --------------------------------------------------------------------------- /* * PermissionCache caches permission checks for a given uid. * * Currently the cache is not updated when there is a permission change, * for instance when an application is uninstalled. * * IMPORTANT: for the reason stated above, only system permissions are safe * to cache. This restriction may be lifted at a later time. * */ class PermissionCache : Singleton { struct Entry { String16 name; uid_t uid; bool granted; inline bool operator < (const Entry& e) const { return (uid == e.uid) ? (name < e.name) : (uid < e.uid); } }; mutable Mutex mLock; // we pool all the permission names we see, as many permissions checks // will have identical names SortedVector< String16 > mPermissionNamesPool; // this is our cache per say. it stores pooled names. SortedVector< Entry > mCache; // free the whole cache, but keep the permission name pool void purge(); status_t check(bool* granted, const String16& permission, uid_t uid) const; void cache(const String16& permission, uid_t uid, bool granted); public: PermissionCache(); static bool checkCallingPermission(const String16& permission); static bool checkCallingPermission(const String16& permission, int32_t* outPid, int32_t* outUid); static bool checkPermission(const String16& permission, pid_t pid, uid_t uid); }; // --------------------------------------------------------------------------- }; // namespace android #endif /* BINDER_PERMISSION_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/binder/ProcessInfoService.h ================================================ /* * Copyright 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_PROCESS_INFO_SERVICE_H #define ANDROID_PROCESS_INFO_SERVICE_H #include #include #include #include namespace android { // ---------------------------------------------------------------------- class ProcessInfoService : public Singleton { friend class Singleton; sp mProcessInfoService; Mutex mProcessInfoLock; ProcessInfoService(); status_t getProcessStatesImpl(size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states); void updateBinderLocked(); static const int BINDER_ATTEMPT_LIMIT = 5; public: /** * For each PID in the given "pids" input array, write the current process state * for that process into the "states" output array, or * ActivityManager.PROCESS_STATE_NONEXISTENT * to indicate that no process with the given PID * exists. * * Returns NO_ERROR if this operation was successful, or a negative error code otherwise. */ static status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states) { return ProcessInfoService::getInstance().getProcessStatesImpl(length, /*in*/ pids, /*out*/ states); } }; // ---------------------------------------------------------------------- }; // namespace android #endif // ANDROID_PROCESS_INFO_SERVICE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/ProcessState.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_PROCESS_STATE_H #define ANDROID_PROCESS_STATE_H #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { class IPCThreadState; class ProcessState : public virtual RefBase { public: static sp self(); void setContextObject(const sp& object); sp getContextObject(const sp& caller); void setContextObject(const sp& object, const String16& name); sp getContextObject(const String16& name, const sp& caller); void startThreadPool(); typedef bool (*context_check_func)(const String16& name, const sp& caller, void* userData); bool isContextManager(void) const; bool becomeContextManager( context_check_func checkFunc, void* userData); sp getStrongProxyForHandle(int32_t handle); wp getWeakProxyForHandle(int32_t handle); void expungeHandle(int32_t handle, IBinder* binder); void spawnPooledThread(bool isMain); status_t setThreadPoolMaxThreadCount(size_t maxThreads); void giveThreadPoolName(); private: friend class IPCThreadState; ProcessState(); ~ProcessState(); ProcessState(const ProcessState& o); ProcessState& operator=(const ProcessState& o); String8 makeBinderThreadName(); struct handle_entry { IBinder* binder; RefBase::weakref_type* refs; }; handle_entry* lookupHandleLocked(int32_t handle); int mDriverFD; void* mVMStart; // Protects thread count variable below. pthread_mutex_t mThreadCountLock; pthread_cond_t mThreadCountDecrement; // Number of binder threads current executing a command. size_t mExecutingThreadsCount; // Maximum number for binder threads allowed for this process. size_t mMaxThreads; mutable Mutex mLock; // protects everything below. VectormHandleToObject; bool mManagesContexts; context_check_func mBinderContextCheckFunc; void* mBinderContextUserData; KeyedVector > mContexts; String8 mRootDir; bool mThreadPoolStarted; volatile int32_t mThreadPoolSeq; }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_PROCESS_STATE_H ================================================ FILE: phonelibs/android_frameworks_native/include/binder/TextOutput.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_TEXTOUTPUT_H #define ANDROID_TEXTOUTPUT_H #include #include #include // --------------------------------------------------------------------------- namespace android { class String8; class String16; class TextOutput { public: TextOutput(); virtual ~TextOutput(); virtual status_t print(const char* txt, size_t len) = 0; virtual void moveIndent(int delta) = 0; class Bundle { public: inline Bundle(TextOutput& to) : mTO(to) { to.pushBundle(); } inline ~Bundle() { mTO.popBundle(); } private: TextOutput& mTO; }; virtual void pushBundle() = 0; virtual void popBundle() = 0; }; // --------------------------------------------------------------------------- // Text output stream for printing to the log (via utils/Log.h). extern TextOutput& alog; // Text output stream for printing to stdout. extern TextOutput& aout; // Text output stream for printing to stderr. extern TextOutput& aerr; typedef TextOutput& (*TextOutputManipFunc)(TextOutput&); TextOutput& endl(TextOutput& to); TextOutput& indent(TextOutput& to); TextOutput& dedent(TextOutput& to); TextOutput& operator<<(TextOutput& to, const char* str); TextOutput& operator<<(TextOutput& to, char); // writes raw character TextOutput& operator<<(TextOutput& to, bool); TextOutput& operator<<(TextOutput& to, int); TextOutput& operator<<(TextOutput& to, long); TextOutput& operator<<(TextOutput& to, unsigned int); TextOutput& operator<<(TextOutput& to, unsigned long); TextOutput& operator<<(TextOutput& to, long long); TextOutput& operator<<(TextOutput& to, unsigned long long); TextOutput& operator<<(TextOutput& to, float); TextOutput& operator<<(TextOutput& to, double); TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func); TextOutput& operator<<(TextOutput& to, const void*); TextOutput& operator<<(TextOutput& to, const String8& val); TextOutput& operator<<(TextOutput& to, const String16& val); class TypeCode { public: inline TypeCode(uint32_t code); inline ~TypeCode(); inline uint32_t typeCode() const; private: uint32_t mCode; }; TextOutput& operator<<(TextOutput& to, const TypeCode& val); class HexDump { public: HexDump(const void *buf, size_t size, size_t bytesPerLine=16); inline ~HexDump(); inline HexDump& setBytesPerLine(size_t bytesPerLine); inline HexDump& setSingleLineCutoff(int32_t bytes); inline HexDump& setAlignment(size_t alignment); inline HexDump& setCArrayStyle(bool enabled); inline const void* buffer() const; inline size_t size() const; inline size_t bytesPerLine() const; inline int32_t singleLineCutoff() const; inline size_t alignment() const; inline bool carrayStyle() const; private: const void* mBuffer; size_t mSize; size_t mBytesPerLine; int32_t mSingleLineCutoff; size_t mAlignment; bool mCArrayStyle; }; TextOutput& operator<<(TextOutput& to, const HexDump& val); // --------------------------------------------------------------------------- // No user servicable parts below. inline TextOutput& endl(TextOutput& to) { to.print("\n", 1); return to; } inline TextOutput& indent(TextOutput& to) { to.moveIndent(1); return to; } inline TextOutput& dedent(TextOutput& to) { to.moveIndent(-1); return to; } inline TextOutput& operator<<(TextOutput& to, const char* str) { to.print(str, strlen(str)); return to; } inline TextOutput& operator<<(TextOutput& to, char c) { to.print(&c, 1); return to; } inline TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func) { return (*func)(to); } inline TypeCode::TypeCode(uint32_t code) : mCode(code) { } inline TypeCode::~TypeCode() { } inline uint32_t TypeCode::typeCode() const { return mCode; } inline HexDump::~HexDump() { } inline HexDump& HexDump::setBytesPerLine(size_t bytesPerLine) { mBytesPerLine = bytesPerLine; return *this; } inline HexDump& HexDump::setSingleLineCutoff(int32_t bytes) { mSingleLineCutoff = bytes; return *this; } inline HexDump& HexDump::setAlignment(size_t alignment) { mAlignment = alignment; return *this; } inline HexDump& HexDump::setCArrayStyle(bool enabled) { mCArrayStyle = enabled; return *this; } inline const void* HexDump::buffer() const { return mBuffer; } inline size_t HexDump::size() const { return mSize; } inline size_t HexDump::bytesPerLine() const { return mBytesPerLine; } inline int32_t HexDump::singleLineCutoff() const { return mSingleLineCutoff; } inline size_t HexDump::alignment() const { return mAlignment; } inline bool HexDump::carrayStyle() const { return mCArrayStyle; } // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_TEXTOUTPUT_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BitTube.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SENSOR_CHANNEL_H #define ANDROID_GUI_SENSOR_CHANNEL_H #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class Parcel; class BitTube : public RefBase { public: // creates a BitTube with a default (4KB) send buffer BitTube(); // creates a BitTube with a a specified send and receive buffer size explicit BitTube(size_t bufsize); explicit BitTube(const Parcel& data); virtual ~BitTube(); // check state after construction status_t initCheck() const; // get receive file-descriptor int getFd() const; // get the send file-descriptor. int getSendFd() const; // send objects (sized blobs). All objects are guaranteed to be written or the call fails. template static ssize_t sendObjects(const sp& tube, T const* events, size_t count) { return sendObjects(tube, events, count, sizeof(T)); } // receive objects (sized blobs). If the receiving buffer isn't large enough, // excess messages are silently discarded. template static ssize_t recvObjects(const sp& tube, T* events, size_t count) { return recvObjects(tube, events, count, sizeof(T)); } // parcels this BitTube status_t writeToParcel(Parcel* reply) const; private: void init(size_t rcvbuf, size_t sndbuf); // send a message. The write is guaranteed to send the whole message or fail. ssize_t write(void const* vaddr, size_t size); // receive a message. the passed buffer must be at least as large as the // write call used to send the message, excess data is silently discarded. ssize_t read(void* vaddr, size_t size); int mSendFd; mutable int mReceiveFd; static ssize_t sendObjects(const sp& tube, void const* events, size_t count, size_t objSize); static ssize_t recvObjects(const sp& tube, void* events, size_t count, size_t objSize); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_SENSOR_CHANNEL_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferItem.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERITEM_H #define ANDROID_GUI_BUFFERITEM_H #include #include #include #include #include #include #include namespace android { class Fence; class GraphicBuffer; class BufferItem : public Flattenable { friend class Flattenable; size_t getPodSize() const; size_t getFlattenedSize() const; size_t getFdCount() const; status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); public: // The default value of mBuf, used to indicate this doesn't correspond to a slot. enum { INVALID_BUFFER_SLOT = -1 }; BufferItem(); ~BufferItem(); static const char* scalingModeName(uint32_t scalingMode); // mGraphicBuffer points to the buffer allocated for this slot, or is NULL // if the buffer in this slot has been acquired in the past (see // BufferSlot.mAcquireCalled). sp mGraphicBuffer; // mFence is a fence that will signal when the buffer is idle. sp mFence; // mCrop is the current crop rectangle for this buffer slot. Rect mCrop; // mTransform is the current transform flags for this buffer slot. // refer to NATIVE_WINDOW_TRANSFORM_* in uint32_t mTransform; // mScalingMode is the current scaling mode for this buffer slot. // refer to NATIVE_WINDOW_SCALING_* in uint32_t mScalingMode; // mTimestamp is the current timestamp for this buffer slot. This gets // to set by queueBuffer each time this slot is queued. This value // is guaranteed to be monotonically increasing for each newly // acquired buffer. union { int64_t mTimestamp; struct { uint32_t mTimestampLo; uint32_t mTimestampHi; }; }; // mIsAutoTimestamp indicates whether mTimestamp was generated // automatically when the buffer was queued. bool mIsAutoTimestamp; // mDataSpace is the current dataSpace value for this buffer slot. This gets // set by queueBuffer each time this slot is queued. The meaning of the // dataSpace is format-dependent. android_dataspace mDataSpace; // mFrameNumber is the number of the queued frame for this slot. union { uint64_t mFrameNumber; struct { uint32_t mFrameNumberLo; uint32_t mFrameNumberHi; }; }; union { // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT). int mSlot; // mBuf is the former name for mSlot int mBuf; }; // mIsDroppable whether this buffer was queued with the // property that it can be replaced by a new buffer for the purpose of // making sure dequeueBuffer() won't block. // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer // was queued. bool mIsDroppable; // Indicates whether this buffer has been seen by a consumer yet bool mAcquireCalled; // Indicates this buffer must be transformed by the inverse transform of the screen // it is displayed onto. This is applied after mTransform. bool mTransformToDisplayInverse; // Describes the portion of the surface that has been modified since the // previous frame Region mSurfaceDamage; }; } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferItemConsumer.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERITEMCONSUMER_H #define ANDROID_GUI_BUFFERITEMCONSUMER_H #include #include #include #include #include #define ANDROID_GRAPHICS_BUFFERITEMCONSUMER_JNI_ID "mBufferItemConsumer" namespace android { class BufferQueue; /** * BufferItemConsumer is a BufferQueue consumer endpoint that allows clients * access to the whole BufferItem entry from BufferQueue. Multiple buffers may * be acquired at once, to be used concurrently by the client. This consumer can * operate either in synchronous or asynchronous mode. */ class BufferItemConsumer: public ConsumerBase { public: typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; enum { DEFAULT_MAX_BUFFERS = -1 }; enum { INVALID_BUFFER_SLOT = BufferQueue::INVALID_BUFFER_SLOT }; enum { NO_BUFFER_AVAILABLE = BufferQueue::NO_BUFFER_AVAILABLE }; // Create a new buffer item consumer. The consumerUsage parameter determines // the consumer usage flags passed to the graphics allocator. The // bufferCount parameter specifies how many buffers can be locked for user // access at the same time. // controlledByApp tells whether this consumer is controlled by the // application. BufferItemConsumer(const sp& consumer, uint32_t consumerUsage, int bufferCount = DEFAULT_MAX_BUFFERS, bool controlledByApp = false); virtual ~BufferItemConsumer(); // set the name of the BufferItemConsumer that will be used to identify it in // log messages. void setName(const String8& name); // Gets the next graphics buffer from the producer, filling out the // passed-in BufferItem structure. Returns NO_BUFFER_AVAILABLE if the queue // of buffers is empty, and INVALID_OPERATION if the maximum number of // buffers is already acquired. // // Only a fixed number of buffers can be acquired at a time, determined by // the construction-time bufferCount parameter. If INVALID_OPERATION is // returned by acquireBuffer, then old buffers must be returned to the // queue by calling releaseBuffer before more buffers can be acquired. // // If waitForFence is true, and the acquired BufferItem has a valid fence object, // acquireBuffer will wait on the fence with no timeout before returning. status_t acquireBuffer(BufferItem* item, nsecs_t presentWhen, bool waitForFence = true); // Returns an acquired buffer to the queue, allowing it to be reused. Since // only a fixed number of buffers may be acquired at a time, old buffers // must be released by calling releaseBuffer to ensure new buffers can be // acquired by acquireBuffer. Once a BufferItem is released, the caller must // not access any members of the BufferItem, and should immediately remove // all of its references to the BufferItem itself. status_t releaseBuffer(const BufferItem &item, const sp& releaseFence = Fence::NO_FENCE); }; } // namespace android #endif // ANDROID_GUI_CPUCONSUMER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferQueue.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERQUEUE_H #define ANDROID_GUI_BUFFERQUEUE_H #include #include #include #include #include // These are only required to keep other parts of the framework with incomplete // dependencies building successfully #include namespace android { class BufferQueue { public: // BufferQueue will keep track of at most this value of buffers. // Attempts at runtime to increase the number of buffers past this will fail. enum { NUM_BUFFER_SLOTS = BufferQueueDefs::NUM_BUFFER_SLOTS }; // Used as a placeholder slot# when the value isn't pointing to an existing buffer. enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT }; // Alias to -- please scope from there in future code! enum { NO_BUFFER_AVAILABLE = IGraphicBufferConsumer::NO_BUFFER_AVAILABLE, PRESENT_LATER = IGraphicBufferConsumer::PRESENT_LATER, }; // When in async mode we reserve two slots in order to guarantee that the // producer and consumer can run asynchronously. enum { MAX_MAX_ACQUIRED_BUFFERS = NUM_BUFFER_SLOTS - 2 }; // for backward source compatibility typedef ::android::ConsumerListener ConsumerListener; // ProxyConsumerListener is a ConsumerListener implementation that keeps a weak // reference to the actual consumer object. It forwards all calls to that // consumer object so long as it exists. // // This class exists to avoid having a circular reference between the // BufferQueue object and the consumer object. The reason this can't be a weak // reference in the BufferQueue class is because we're planning to expose the // consumer side of a BufferQueue as a binder interface, which doesn't support // weak references. class ProxyConsumerListener : public BnConsumerListener { public: ProxyConsumerListener(const wp& consumerListener); virtual ~ProxyConsumerListener(); virtual void onFrameAvailable(const BufferItem& item) override; virtual void onFrameReplaced(const BufferItem& item) override; virtual void onBuffersReleased() override; virtual void onSidebandStreamChanged() override; private: // mConsumerListener is a weak reference to the IConsumerListener. This is // the raison d'etre of ProxyConsumerListener. wp mConsumerListener; }; // BufferQueue manages a pool of gralloc memory slots to be used by // producers and consumers. allocator is used to allocate all the // needed gralloc buffers. static void createBufferQueue(sp* outProducer, sp* outConsumer, const sp& allocator = NULL); private: BufferQueue(); // Create through createBufferQueue }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_BUFFERQUEUE_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferQueueConsumer.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERQUEUECONSUMER_H #define ANDROID_GUI_BUFFERQUEUECONSUMER_H #include #include #include #include namespace android { class BufferQueueCore; class BufferQueueConsumer : public BnGraphicBufferConsumer { public: BufferQueueConsumer(const sp& core); virtual ~BufferQueueConsumer(); // acquireBuffer attempts to acquire ownership of the next pending buffer in // the BufferQueue. If no buffer is pending then it returns // NO_BUFFER_AVAILABLE. If a buffer is successfully acquired, the // information about the buffer is returned in BufferItem. If the buffer // returned had previously been acquired then the BufferItem::mGraphicBuffer // field of buffer is set to NULL and it is assumed that the consumer still // holds a reference to the buffer. // // If expectedPresent is nonzero, it indicates the time when the buffer // will be displayed on screen. If the buffer's timestamp is farther in the // future, the buffer won't be acquired, and PRESENT_LATER will be // returned. The presentation time is in nanoseconds, and the time base // is CLOCK_MONOTONIC. virtual status_t acquireBuffer(BufferItem* outBuffer, nsecs_t expectedPresent, uint64_t maxFrameNumber = 0) override; // See IGraphicBufferConsumer::detachBuffer virtual status_t detachBuffer(int slot); // See IGraphicBufferConsumer::attachBuffer virtual status_t attachBuffer(int* slot, const sp& buffer); // releaseBuffer releases a buffer slot from the consumer back to the // BufferQueue. This may be done while the buffer's contents are still // being accessed. The fence will signal when the buffer is no longer // in use. frameNumber is used to indentify the exact buffer returned. // // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free // any references to the just-released buffer that it might have, as if it // had received a onBuffersReleased() call with a mask set for the released // buffer. // // Note that the dependencies on EGL will be removed once we switch to using // the Android HW Sync HAL. virtual status_t releaseBuffer(int slot, uint64_t frameNumber, const sp& releaseFence, EGLDisplay display, EGLSyncKHR fence); // connect connects a consumer to the BufferQueue. Only one // consumer may be connected, and when that consumer disconnects the // BufferQueue is placed into the "abandoned" state, causing most // interactions with the BufferQueue by the producer to fail. // controlledByApp indicates whether the consumer is controlled by // the application. // // consumerListener may not be NULL. virtual status_t connect(const sp& consumerListener, bool controlledByApp); // disconnect disconnects a consumer from the BufferQueue. All // buffers will be freed and the BufferQueue is placed in the "abandoned" // state, causing most interactions with the BufferQueue by the producer to // fail. virtual status_t disconnect(); // getReleasedBuffers sets the value pointed to by outSlotMask to a bit mask // indicating which buffer slots have been released by the BufferQueue // but have not yet been released by the consumer. // // This should be called from the onBuffersReleased() callback. virtual status_t getReleasedBuffers(uint64_t* outSlotMask); // setDefaultBufferSize is used to set the size of buffers returned by // dequeueBuffer when a width and height of zero is requested. Default // is 1x1. virtual status_t setDefaultBufferSize(uint32_t width, uint32_t height); // setDefaultMaxBufferCount sets the default value for the maximum buffer // count (the initial default is 2). If the producer has requested a // buffer count using setBufferCount, the default buffer count will only // take effect if the producer sets the count back to zero. // // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. virtual status_t setDefaultMaxBufferCount(int bufferCount); // disableAsyncBuffer disables the extra buffer used in async mode // (when both producer and consumer have set their "isControlledByApp" // flag) and has dequeueBuffer() return WOULD_BLOCK instead. // // This can only be called before connect(). virtual status_t disableAsyncBuffer(); // setMaxAcquiredBufferCount sets the maximum number of buffers that can // be acquired by the consumer at one time (default 1). This call will // fail if a producer is connected to the BufferQueue. virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers); // setConsumerName sets the name used in logging virtual void setConsumerName(const String8& name); // setDefaultBufferFormat allows the BufferQueue to create // GraphicBuffers of a defaultFormat if no format is specified // in dequeueBuffer. The initial default is HAL_PIXEL_FORMAT_RGBA_8888. virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat); // setDefaultBufferDataSpace allows the BufferQueue to create // GraphicBuffers of a defaultDataSpace if no data space is specified // in queueBuffer. // The initial default is HAL_DATASPACE_UNKNOWN virtual status_t setDefaultBufferDataSpace( android_dataspace defaultDataSpace); // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. // These are merged with the bits passed to dequeueBuffer. The values are // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0. virtual status_t setConsumerUsageBits(uint32_t usage); // setTransformHint bakes in rotation to buffers so overlays can be used. // The values are enumerated in window.h, e.g. // NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform). virtual status_t setTransformHint(uint32_t hint); // Retrieve the sideband buffer stream, if any. virtual sp getSidebandStream() const; // dump our state in a String virtual void dump(String8& result, const char* prefix) const; // Functions required for backwards compatibility. // These will be modified/renamed in IGraphicBufferConsumer and will be // removed from this class at that time. See b/13306289. virtual status_t releaseBuffer(int buf, uint64_t frameNumber, EGLDisplay display, EGLSyncKHR fence, const sp& releaseFence) { return releaseBuffer(buf, frameNumber, releaseFence, display, fence); } virtual status_t consumerConnect(const sp& consumer, bool controlledByApp) { return connect(consumer, controlledByApp); } virtual status_t consumerDisconnect() { return disconnect(); } // End functions required for backwards compatibility private: sp mCore; // This references mCore->mSlots. Lock mCore->mMutex while accessing. BufferQueueDefs::SlotsType& mSlots; // This is a cached copy of the name stored in the BufferQueueCore. // It's updated during setConsumerName. String8 mConsumerName; }; // class BufferQueueConsumer } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferQueueCore.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERQUEUECORE_H #define ANDROID_GUI_BUFFERQUEUECORE_H #include #include #include #include #include #include #include #include #include #include #include #include #include #define BQ_LOGV(x, ...) ALOGV("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGD(x, ...) ALOGD("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGI(x, ...) ALOGI("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGW(x, ...) ALOGW("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define BQ_LOGE(x, ...) ALOGE("[%s] " x, mConsumerName.string(), ##__VA_ARGS__) #define ATRACE_BUFFER_INDEX(index) \ if (ATRACE_ENABLED()) { \ char ___traceBuf[1024]; \ snprintf(___traceBuf, 1024, "%s: %d", \ mCore->mConsumerName.string(), (index)); \ android::ScopedTrace ___bufTracer(ATRACE_TAG, ___traceBuf); \ } namespace android { class IConsumerListener; class IGraphicBufferAlloc; class IProducerListener; class BufferQueueCore : public virtual RefBase { friend class BufferQueueProducer; friend class BufferQueueConsumer; public: // Used as a placeholder slot number when the value isn't pointing to an // existing buffer. enum { INVALID_BUFFER_SLOT = BufferItem::INVALID_BUFFER_SLOT }; // We reserve two slots in order to guarantee that the producer and // consumer can run asynchronously. enum { MAX_MAX_ACQUIRED_BUFFERS = BufferQueueDefs::NUM_BUFFER_SLOTS - 2 }; // The default API number used to indicate that no producer is connected enum { NO_CONNECTED_API = 0 }; typedef Vector Fifo; // BufferQueueCore manages a pool of gralloc memory slots to be used by // producers and consumers. allocator is used to allocate all the needed // gralloc buffers. BufferQueueCore(const sp& allocator = NULL); virtual ~BufferQueueCore(); private: // Dump our state in a string void dump(String8& result, const char* prefix) const; // getMinUndequeuedBufferCountLocked returns the minimum number of buffers // that must remain in a state other than DEQUEUED. The async parameter // tells whether we're in asynchronous mode. int getMinUndequeuedBufferCountLocked(bool async) const; // getMinMaxBufferCountLocked returns the minimum number of buffers allowed // given the current BufferQueue state. The async parameter tells whether // we're in asynchonous mode. int getMinMaxBufferCountLocked(bool async) const; // getMaxBufferCountLocked returns the maximum number of buffers that can be // allocated at once. This value depends on the following member variables: // // mDequeueBufferCannotBlock // mMaxAcquiredBufferCount // mDefaultMaxBufferCount // mOverrideMaxBufferCount // async parameter // // Any time one of these member variables is changed while a producer is // connected, mDequeueCondition must be broadcast. int getMaxBufferCountLocked(bool async) const; // setDefaultMaxBufferCountLocked sets the maximum number of buffer slots // that will be used if the producer does not override the buffer slot // count. The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. The // initial default is 2. status_t setDefaultMaxBufferCountLocked(int count); // freeBufferLocked frees the GraphicBuffer and sync resources for the // given slot. void freeBufferLocked(int slot); // freeAllBuffersLocked frees the GraphicBuffer and sync resources for // all slots. void freeAllBuffersLocked(); // stillTracking returns true iff the buffer item is still being tracked // in one of the slots. bool stillTracking(const BufferItem* item) const; // waitWhileAllocatingLocked blocks until mIsAllocating is false. void waitWhileAllocatingLocked() const; // validateConsistencyLocked ensures that the free lists are in sync with // the information stored in mSlots void validateConsistencyLocked() const; // mAllocator is the connection to SurfaceFlinger that is used to allocate // new GraphicBuffer objects. sp mAllocator; // mMutex is the mutex used to prevent concurrent access to the member // variables of BufferQueueCore objects. It must be locked whenever any // member variable is accessed. mutable Mutex mMutex; // mIsAbandoned indicates that the BufferQueue will no longer be used to // consume image buffers pushed to it using the IGraphicBufferProducer // interface. It is initialized to false, and set to true in the // consumerDisconnect method. A BufferQueue that is abandoned will return // the NO_INIT error from all IGraphicBufferProducer methods capable of // returning an error. bool mIsAbandoned; // mConsumerControlledByApp indicates whether the connected consumer is // controlled by the application. bool mConsumerControlledByApp; // mConsumerName is a string used to identify the BufferQueue in log // messages. It is set by the IGraphicBufferConsumer::setConsumerName // method. String8 mConsumerName; // mConsumerListener is used to notify the connected consumer of // asynchronous events that it may wish to react to. It is initially // set to NULL and is written by consumerConnect and consumerDisconnect. sp mConsumerListener; // mConsumerUsageBits contains flags that the consumer wants for // GraphicBuffers. uint32_t mConsumerUsageBits; // mConnectedApi indicates the producer API that is currently connected // to this BufferQueue. It defaults to NO_CONNECTED_API, and gets updated // by the connect and disconnect methods. int mConnectedApi; // mConnectedProducerToken is used to set a binder death notification on // the producer. sp mConnectedProducerListener; // mSlots is an array of buffer slots that must be mirrored on the producer // side. This allows buffer ownership to be transferred between the producer // and consumer without sending a GraphicBuffer over Binder. The entire // array is initialized to NULL at construction time, and buffers are // allocated for a slot when requestBuffer is called with that slot's index. BufferQueueDefs::SlotsType mSlots; // mQueue is a FIFO of queued buffers used in synchronous mode. Fifo mQueue; // mFreeSlots contains all of the slots which are FREE and do not currently // have a buffer attached std::set mFreeSlots; // mFreeBuffers contains all of the slots which are FREE and currently have // a buffer attached std::list mFreeBuffers; // mOverrideMaxBufferCount is the limit on the number of buffers that will // be allocated at one time. This value is set by the producer by calling // setBufferCount. The default is 0, which means that the producer doesn't // care about the number of buffers in the pool. In that case, // mDefaultMaxBufferCount is used as the limit. int mOverrideMaxBufferCount; // mDequeueCondition is a condition variable used for dequeueBuffer in // synchronous mode. mutable Condition mDequeueCondition; // mUseAsyncBuffer indicates whether an extra buffer is used in async mode // to prevent dequeueBuffer from blocking. bool mUseAsyncBuffer; // mDequeueBufferCannotBlock indicates whether dequeueBuffer is allowed to // block. This flag is set during connect when both the producer and // consumer are controlled by the application. bool mDequeueBufferCannotBlock; // mDefaultBufferFormat can be set so it will override the buffer format // when it isn't specified in dequeueBuffer. PixelFormat mDefaultBufferFormat; // mDefaultWidth holds the default width of allocated buffers. It is used // in dequeueBuffer if a width and height of 0 are specified. uint32_t mDefaultWidth; // mDefaultHeight holds the default height of allocated buffers. It is used // in dequeueBuffer if a width and height of 0 are specified. uint32_t mDefaultHeight; // mDefaultBufferDataSpace holds the default dataSpace of queued buffers. // It is used in queueBuffer if a dataspace of 0 (HAL_DATASPACE_UNKNOWN) // is specified. android_dataspace mDefaultBufferDataSpace; // mDefaultMaxBufferCount is the default limit on the number of buffers that // will be allocated at one time. This default limit is set by the consumer. // The limit (as opposed to the default limit) may be overriden by the // producer. int mDefaultMaxBufferCount; // mMaxAcquiredBufferCount is the number of buffers that the consumer may // acquire at one time. It defaults to 1, and can be changed by the consumer // via setMaxAcquiredBufferCount, but this may only be done while no // producer is connected to the BufferQueue. This value is used to derive // the value returned for the MIN_UNDEQUEUED_BUFFERS query to the producer. int mMaxAcquiredBufferCount; // mBufferHasBeenQueued is true once a buffer has been queued. It is reset // when something causes all buffers to be freed (e.g., changing the buffer // count). bool mBufferHasBeenQueued; // mFrameCounter is the free running counter, incremented on every // successful queueBuffer call and buffer allocation. uint64_t mFrameCounter; // mTransformHint is used to optimize for screen rotations. uint32_t mTransformHint; // mSidebandStream is a handle to the sideband buffer stream, if any sp mSidebandStream; // mIsAllocating indicates whether a producer is currently trying to allocate buffers (which // releases mMutex while doing the allocation proper). Producers should not modify any of the // FREE slots while this is true. mIsAllocatingCondition is signaled when this value changes to // false. bool mIsAllocating; // mIsAllocatingCondition is a condition variable used by producers to wait until mIsAllocating // becomes false. mutable Condition mIsAllocatingCondition; // mAllowAllocation determines whether dequeueBuffer is allowed to allocate // new buffers bool mAllowAllocation; // mBufferAge tracks the age of the contents of the most recently dequeued // buffer as the number of frames that have elapsed since it was last queued uint64_t mBufferAge; // mGenerationNumber stores the current generation number of the attached // producer. Any attempt to attach a buffer with a different generation // number will fail. uint32_t mGenerationNumber; }; // class BufferQueueCore } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferQueueDefs.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERQUEUECOREDEFS_H #define ANDROID_GUI_BUFFERQUEUECOREDEFS_H #include namespace android { class BufferQueueCore; namespace BufferQueueDefs { // BufferQueue will keep track of at most this value of buffers. // Attempts at runtime to increase the number of buffers past this // will fail. enum { NUM_BUFFER_SLOTS = 64 }; typedef BufferSlot SlotsType[NUM_BUFFER_SLOTS]; } // namespace BufferQueueDefs } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferQueueProducer.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERQUEUEPRODUCER_H #define ANDROID_GUI_BUFFERQUEUEPRODUCER_H #include #include namespace android { class BufferSlot; class BufferQueueProducer : public BnGraphicBufferProducer, private IBinder::DeathRecipient { public: friend class BufferQueue; // Needed to access binderDied BufferQueueProducer(const sp& core); virtual ~BufferQueueProducer(); // requestBuffer returns the GraphicBuffer for slot N. // // In normal operation, this is called the first time slot N is returned // by dequeueBuffer. It must be called again if dequeueBuffer returns // flags indicating that previously-returned buffers are no longer valid. virtual status_t requestBuffer(int slot, sp* buf); // setBufferCount updates the number of available buffer slots. If this // method succeeds, buffer slots will be both unallocated and owned by // the BufferQueue object (i.e. they are not owned by the producer or // consumer). // // This will fail if the producer has dequeued any buffers, or if // bufferCount is invalid. bufferCount must generally be a value // between the minimum undequeued buffer count (exclusive) and NUM_BUFFER_SLOTS // (inclusive). It may also be set to zero (the default) to indicate // that the producer does not wish to set a value. The minimum value // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, // ...). // // This may only be called by the producer. The consumer will be told // to discard buffers through the onBuffersReleased callback. virtual status_t setBufferCount(int bufferCount); // dequeueBuffer gets the next buffer slot index for the producer to use. // If a buffer slot is available then that slot index is written to the // location pointed to by the buf argument and a status of OK is returned. // If no slot is available then a status of -EBUSY is returned and buf is // unmodified. // // The outFence parameter will be updated to hold the fence associated with // the buffer. The contents of the buffer must not be overwritten until the // fence signals. If the fence is Fence::NO_FENCE, the buffer may be // written immediately. // // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. If width and height are both zero, the // default values specified by setDefaultBufferSize() are used instead. // // If the format is 0, the default format will be used. // // The usage argument specifies gralloc buffer usage flags. The values // are enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER. These // will be merged with the usage flags specified by setConsumerUsageBits. // // The return value may be a negative error value or a non-negative // collection of flags. If the flags are set, the return values are // valid, but additional actions must be performed. // // If IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION is set, the // producer must discard cached GraphicBuffer references for the slot // returned in buf. // If IGraphicBufferProducer::RELEASE_ALL_BUFFERS is set, the producer // must discard cached GraphicBuffer references for all slots. // // In both cases, the producer will need to call requestBuffer to get a // GraphicBuffer handle for the returned slot. virtual status_t dequeueBuffer(int *outSlot, sp* outFence, bool async, uint32_t width, uint32_t height, PixelFormat format, uint32_t usage); // See IGraphicBufferProducer::detachBuffer virtual status_t detachBuffer(int slot); // See IGraphicBufferProducer::detachNextBuffer virtual status_t detachNextBuffer(sp* outBuffer, sp* outFence); // See IGraphicBufferProducer::attachBuffer virtual status_t attachBuffer(int* outSlot, const sp& buffer); // queueBuffer returns a filled buffer to the BufferQueue. // // Additional data is provided in the QueueBufferInput struct. Notably, // a timestamp must be provided for the buffer. The timestamp is in // nanoseconds, and must be monotonically increasing. Its other semantics // (zero point, etc) are producer-specific and should be documented by the // producer. // // The caller may provide a fence that signals when all rendering // operations have completed. Alternatively, NO_FENCE may be used, // indicating that the buffer is ready immediately. // // Some values are returned in the output struct: the current settings // for default width and height, the current transform hint, and the // number of queued buffers. virtual status_t queueBuffer(int slot, const QueueBufferInput& input, QueueBufferOutput* output); // cancelBuffer returns a dequeued buffer to the BufferQueue, but doesn't // queue it for use by the consumer. // // The buffer will not be overwritten until the fence signals. The fence // will usually be the one obtained from dequeueBuffer. virtual void cancelBuffer(int slot, const sp& fence); // Query native window attributes. The "what" values are enumerated in // window.h (e.g. NATIVE_WINDOW_FORMAT). virtual int query(int what, int* outValue); // connect attempts to connect a producer API to the BufferQueue. This // must be called before any other IGraphicBufferProducer methods are // called except for getAllocator. A consumer must already be connected. // // This method will fail if connect was previously called on the // BufferQueue and no corresponding disconnect call was made (i.e. if // it's still connected to a producer). // // APIs are enumerated in window.h (e.g. NATIVE_WINDOW_API_CPU). virtual status_t connect(const sp& listener, int api, bool producerControlledByApp, QueueBufferOutput* output); // disconnect attempts to disconnect a producer API from the BufferQueue. // Calling this method will cause any subsequent calls to other // IGraphicBufferProducer methods to fail except for getAllocator and connect. // Successfully calling connect after this will allow the other methods to // succeed again. // // This method will fail if the the BufferQueue is not currently // connected to the specified producer API. virtual status_t disconnect(int api); // Attaches a sideband buffer stream to the IGraphicBufferProducer. // // A sideband stream is a device-specific mechanism for passing buffers // from the producer to the consumer without using dequeueBuffer/ // queueBuffer. If a sideband stream is present, the consumer can choose // whether to acquire buffers from the sideband stream or from the queued // buffers. // // Passing NULL or a different stream handle will detach the previous // handle if any. virtual status_t setSidebandStream(const sp& stream); // See IGraphicBufferProducer::allocateBuffers virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, PixelFormat format, uint32_t usage); // See IGraphicBufferProducer::allowAllocation virtual status_t allowAllocation(bool allow); // See IGraphicBufferProducer::setGenerationNumber virtual status_t setGenerationNumber(uint32_t generationNumber); // See IGraphicBufferProducer::getConsumerName virtual String8 getConsumerName() const override; private: // This is required by the IBinder::DeathRecipient interface virtual void binderDied(const wp& who); // waitForFreeSlotThenRelock finds the oldest slot in the FREE state. It may // block if there are no available slots and we are not in non-blocking // mode (producer and consumer controlled by the application). If it blocks, // it will release mCore->mMutex while blocked so that other operations on // the BufferQueue may succeed. status_t waitForFreeSlotThenRelock(const char* caller, bool async, int* found, status_t* returnFlags) const; sp mCore; // This references mCore->mSlots. Lock mCore->mMutex while accessing. BufferQueueDefs::SlotsType& mSlots; // This is a cached copy of the name stored in the BufferQueueCore. // It's updated during connect and dequeueBuffer (which should catch // most updates). String8 mConsumerName; uint32_t mStickyTransform; // This saves the fence from the last queueBuffer, such that the // next queueBuffer call can throttle buffer production. The prior // queueBuffer's fence is not nessessarily available elsewhere, // since the previous buffer might have already been acquired. sp mLastQueueBufferFence; // Take-a-ticket system for ensuring that onFrame* callbacks are called in // the order that frames are queued. While the BufferQueue lock // (mCore->mMutex) is held, a ticket is retained by the producer. After // dropping the BufferQueue lock, the producer must wait on the condition // variable until the current callback ticket matches its retained ticket. Mutex mCallbackMutex; int mNextCallbackTicket; // Protected by mCore->mMutex int mCurrentCallbackTicket; // Protected by mCallbackMutex Condition mCallbackCondition; }; // class BufferQueueProducer } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/BufferSlot.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_BUFFERSLOT_H #define ANDROID_GUI_BUFFERSLOT_H #include #include #include #include #include namespace android { class Fence; struct BufferSlot { BufferSlot() : mEglDisplay(EGL_NO_DISPLAY), mBufferState(BufferSlot::FREE), mRequestBufferCalled(false), mFrameNumber(0), mEglFence(EGL_NO_SYNC_KHR), mAcquireCalled(false), mNeedsCleanupOnRelease(false), mAttachedByConsumer(false) { } // mGraphicBuffer points to the buffer allocated for this slot or is NULL // if no buffer has been allocated. sp mGraphicBuffer; // mEglDisplay is the EGLDisplay used to create EGLSyncKHR objects. EGLDisplay mEglDisplay; // BufferState represents the different states in which a buffer slot // can be. All slots are initially FREE. enum BufferState { // FREE indicates that the buffer is available to be dequeued // by the producer. The buffer may be in use by the consumer for // a finite time, so the buffer must not be modified until the // associated fence is signaled. // // The slot is "owned" by BufferQueue. It transitions to DEQUEUED // when dequeueBuffer is called. FREE = 0, // DEQUEUED indicates that the buffer has been dequeued by the // producer, but has not yet been queued or canceled. The // producer may modify the buffer's contents as soon as the // associated ready fence is signaled. // // The slot is "owned" by the producer. It can transition to // QUEUED (via queueBuffer) or back to FREE (via cancelBuffer). DEQUEUED = 1, // QUEUED indicates that the buffer has been filled by the // producer and queued for use by the consumer. The buffer // contents may continue to be modified for a finite time, so // the contents must not be accessed until the associated fence // is signaled. // // The slot is "owned" by BufferQueue. It can transition to // ACQUIRED (via acquireBuffer) or to FREE (if another buffer is // queued in asynchronous mode). QUEUED = 2, // ACQUIRED indicates that the buffer has been acquired by the // consumer. As with QUEUED, the contents must not be accessed // by the consumer until the fence is signaled. // // The slot is "owned" by the consumer. It transitions to FREE // when releaseBuffer is called. ACQUIRED = 3 }; static const char* bufferStateName(BufferState state); // mBufferState is the current state of this buffer slot. BufferState mBufferState; // mRequestBufferCalled is used for validating that the producer did // call requestBuffer() when told to do so. Technically this is not // needed but useful for debugging and catching producer bugs. bool mRequestBufferCalled; // mFrameNumber is the number of the queued frame for this slot. This // is used to dequeue buffers in LRU order (useful because buffers // may be released before their release fence is signaled). uint64_t mFrameNumber; // mEglFence is the EGL sync object that must signal before the buffer // associated with this buffer slot may be dequeued. It is initialized // to EGL_NO_SYNC_KHR when the buffer is created and may be set to a // new sync object in releaseBuffer. (This is deprecated in favor of // mFence, below.) EGLSyncKHR mEglFence; // mFence is a fence which will signal when work initiated by the // previous owner of the buffer is finished. When the buffer is FREE, // the fence indicates when the consumer has finished reading // from the buffer, or when the producer has finished writing if it // called cancelBuffer after queueing some writes. When the buffer is // QUEUED, it indicates when the producer has finished filling the // buffer. When the buffer is DEQUEUED or ACQUIRED, the fence has been // passed to the consumer or producer along with ownership of the // buffer, and mFence is set to NO_FENCE. sp mFence; // Indicates whether this buffer has been seen by a consumer yet bool mAcquireCalled; // Indicates whether this buffer needs to be cleaned up by the // consumer. This is set when a buffer in ACQUIRED state is freed. // It causes releaseBuffer to return STALE_BUFFER_SLOT. bool mNeedsCleanupOnRelease; // Indicates whether the buffer was attached on the consumer side. // If so, it needs to set the BUFFER_NEEDS_REALLOCATION flag when dequeued // to prevent the producer from using a stale cached buffer. bool mAttachedByConsumer; }; } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/ConsumerBase.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_CONSUMERBASE_H #define ANDROID_GUI_CONSUMERBASE_H #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class String8; // ConsumerBase is a base class for BufferQueue consumer end-points. It // handles common tasks like management of the connection to the BufferQueue // and the buffer pool. class ConsumerBase : public virtual RefBase, protected ConsumerListener { public: struct FrameAvailableListener : public virtual RefBase { // See IConsumerListener::onFrame{Available,Replaced} virtual void onFrameAvailable(const BufferItem& item) = 0; virtual void onFrameReplaced(const BufferItem& /* item */) {} }; virtual ~ConsumerBase(); // abandon frees all the buffers and puts the ConsumerBase into the // 'abandoned' state. Once put in this state the ConsumerBase can never // leave it. When in the 'abandoned' state, all methods of the // IGraphicBufferProducer interface will fail with the NO_INIT error. // // Note that while calling this method causes all the buffers to be freed // from the perspective of the the ConsumerBase, if there are additional // references on the buffers (e.g. if a buffer is referenced by a client // or by OpenGL ES as a texture) then those buffer will remain allocated. void abandon(); // Returns true if the ConsumerBase is in the 'abandoned' state bool isAbandoned(); // set the name of the ConsumerBase that will be used to identify it in // log messages. void setName(const String8& name); // dump writes the current state to a string. Child classes should add // their state to the dump by overriding the dumpLocked method, which is // called by these methods after locking the mutex. void dump(String8& result) const; void dump(String8& result, const char* prefix) const; // setFrameAvailableListener sets the listener object that will be notified // when a new frame becomes available. void setFrameAvailableListener(const wp& listener); // See IGraphicBufferConsumer::detachBuffer status_t detachBuffer(int slot); // See IGraphicBufferConsumer::setDefaultBufferSize status_t setDefaultBufferSize(uint32_t width, uint32_t height); // See IGraphicBufferConsumer::setDefaultBufferFormat status_t setDefaultBufferFormat(PixelFormat defaultFormat); // See IGraphicBufferConsumer::setDefaultBufferDataSpace status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); private: ConsumerBase(const ConsumerBase&); void operator=(const ConsumerBase&); protected: // ConsumerBase constructs a new ConsumerBase object to consume image // buffers from the given IGraphicBufferConsumer. // The controlledByApp flag indicates that this consumer is under the application's // control. ConsumerBase(const sp& consumer, bool controlledByApp = false); // onLastStrongRef gets called by RefBase just before the dtor of the most // derived class. It is used to clean up the buffers so that ConsumerBase // can coordinate the clean-up by calling into virtual methods implemented // by the derived classes. This would not be possible from the // ConsuemrBase dtor because by the time that gets called the derived // classes have already been destructed. // // This methods should not need to be overridden by derived classes, but // if they are overridden the ConsumerBase implementation must be called // from the derived class. virtual void onLastStrongRef(const void* id); // Implementation of the IConsumerListener interface. These // calls are used to notify the ConsumerBase of asynchronous events in the // BufferQueue. The onFrameAvailable, onFrameReplaced, and // onBuffersReleased methods should not need to be overridden by derived // classes, but if they are overridden the ConsumerBase implementation must // be called from the derived class. The ConsumerBase version of // onSidebandStreamChanged does nothing and can be overriden by derived // classes if they want the notification. virtual void onFrameAvailable(const BufferItem& item) override; virtual void onFrameReplaced(const BufferItem& item) override; virtual void onBuffersReleased() override; virtual void onSidebandStreamChanged() override; // freeBufferLocked frees up the given buffer slot. If the slot has been // initialized this will release the reference to the GraphicBuffer in that // slot. Otherwise it has no effect. // // Derived classes should override this method to clean up any state they // keep per slot. If it is overridden, the derived class's implementation // must call ConsumerBase::freeBufferLocked. // // This method must be called with mMutex locked. virtual void freeBufferLocked(int slotIndex); // abandonLocked puts the BufferQueue into the abandoned state, causing // all future operations on it to fail. This method rather than the public // abandon method should be overridden by child classes to add abandon- // time behavior. // // Derived classes should override this method to clean up any object // state they keep (as opposed to per-slot state). If it is overridden, // the derived class's implementation must call ConsumerBase::abandonLocked. // // This method must be called with mMutex locked. virtual void abandonLocked(); // dumpLocked dumps the current state of the ConsumerBase object to the // result string. Each line is prefixed with the string pointed to by the // prefix argument. The buffer argument points to a buffer that may be // used for intermediate formatting data, and the size of that buffer is // indicated by the size argument. // // Derived classes should override this method to dump their internal // state. If this method is overridden the derived class's implementation // should call ConsumerBase::dumpLocked. // // This method must be called with mMutex locked. virtual void dumpLocked(String8& result, const char* prefix) const; // acquireBufferLocked fetches the next buffer from the BufferQueue and // updates the buffer slot for the buffer returned. // // Derived classes should override this method to perform any // initialization that must take place the first time a buffer is assigned // to a slot. If it is overridden the derived class's implementation must // call ConsumerBase::acquireBufferLocked. virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen, uint64_t maxFrameNumber = 0); // releaseBufferLocked relinquishes control over a buffer, returning that // control to the BufferQueue. // // Derived classes should override this method to perform any cleanup that // must take place when a buffer is released back to the BufferQueue. If // it is overridden the derived class's implementation must call // ConsumerBase::releaseBufferLocked.e virtual status_t releaseBufferLocked(int slot, const sp graphicBuffer, EGLDisplay display, EGLSyncKHR eglFence); // returns true iff the slot still has the graphicBuffer in it. bool stillTracking(int slot, const sp graphicBuffer); // addReleaseFence* adds the sync points associated with a fence to the set // of sync points that must be reached before the buffer in the given slot // may be used after the slot has been released. This should be called by // derived classes each time some asynchronous work is kicked off that // references the buffer. status_t addReleaseFence(int slot, const sp graphicBuffer, const sp& fence); status_t addReleaseFenceLocked(int slot, const sp graphicBuffer, const sp& fence); // Slot contains the information and object references that // ConsumerBase maintains about a BufferQueue buffer slot. struct Slot { // mGraphicBuffer is the Gralloc buffer store in the slot or NULL if // no Gralloc buffer is in the slot. sp mGraphicBuffer; // mFence is a fence which will signal when the buffer associated with // this buffer slot is no longer being used by the consumer and can be // overwritten. The buffer can be dequeued before the fence signals; // the producer is responsible for delaying writes until it signals. sp mFence; // the frame number of the last acquired frame for this slot uint64_t mFrameNumber; }; // mSlots stores the buffers that have been allocated by the BufferQueue // for each buffer slot. It is initialized to null pointers, and gets // filled in with the result of BufferQueue::acquire when the // client dequeues a buffer from a // slot that has not yet been used. The buffer allocated to a slot will also // be replaced if the requested buffer usage or geometry differs from that // of the buffer allocated to a slot. Slot mSlots[BufferQueue::NUM_BUFFER_SLOTS]; // mAbandoned indicates that the BufferQueue will no longer be used to // consume images buffers pushed to it using the IGraphicBufferProducer // interface. It is initialized to false, and set to true in the abandon // method. A BufferQueue that has been abandoned will return the NO_INIT // error from all IConsumerBase methods capable of returning an error. bool mAbandoned; // mName is a string used to identify the ConsumerBase in log messages. // It can be set by the setName method. String8 mName; // mFrameAvailableListener is the listener object that will be called when a // new frame becomes available. If it is not NULL it will be called from // queueBuffer. wp mFrameAvailableListener; // The ConsumerBase has-a BufferQueue and is responsible for creating this object // if none is supplied sp mConsumer; // mMutex is the mutex used to prevent concurrent access to the member // variables of ConsumerBase objects. It must be locked whenever the // member variables are accessed or when any of the *Locked methods are // called. // // This mutex is intended to be locked by derived classes. mutable Mutex mMutex; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_CONSUMERBASE_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/CpuConsumer.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_CPUCONSUMER_H #define ANDROID_GUI_CPUCONSUMER_H #include #include #include #include #include namespace android { class BufferQueue; /** * CpuConsumer is a BufferQueue consumer endpoint that allows direct CPU * access to the underlying gralloc buffers provided by BufferQueue. Multiple * buffers may be acquired by it at once, to be used concurrently by the * CpuConsumer owner. Sets gralloc usage flags to be software-read-only. * This queue is synchronous by default. */ class CpuConsumer : public ConsumerBase { public: typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; struct LockedBuffer { uint8_t *data; uint32_t width; uint32_t height; PixelFormat format; uint32_t stride; Rect crop; uint32_t transform; uint32_t scalingMode; int64_t timestamp; android_dataspace dataSpace; uint64_t frameNumber; // this is the same as format, except for formats that are compatible with // a flexible format (e.g. HAL_PIXEL_FORMAT_YCbCr_420_888). In the latter // case this contains that flexible format PixelFormat flexFormat; // Values below are only valid when using HAL_PIXEL_FORMAT_YCbCr_420_888 // or compatible format, in which case LockedBuffer::data // contains the Y channel, and stride is the Y channel stride. For other // formats, these will all be 0. uint8_t *dataCb; uint8_t *dataCr; uint32_t chromaStride; uint32_t chromaStep; }; // Create a new CPU consumer. The maxLockedBuffers parameter specifies // how many buffers can be locked for user access at the same time. CpuConsumer(const sp& bq, size_t maxLockedBuffers, bool controlledByApp = false); virtual ~CpuConsumer(); // set the name of the CpuConsumer that will be used to identify it in // log messages. void setName(const String8& name); // Gets the next graphics buffer from the producer and locks it for CPU use, // filling out the passed-in locked buffer structure with the native pointer // and metadata. Returns BAD_VALUE if no new buffer is available, and // NOT_ENOUGH_DATA if the maximum number of buffers is already locked. // // Only a fixed number of buffers can be locked at a time, determined by the // construction-time maxLockedBuffers parameter. If INVALID_OPERATION is // returned by lockNextBuffer, then old buffers must be returned to the queue // by calling unlockBuffer before more buffers can be acquired. status_t lockNextBuffer(LockedBuffer *nativeBuffer); // Returns a locked buffer to the queue, allowing it to be reused. Since // only a fixed number of buffers may be locked at a time, old buffers must // be released by calling unlockBuffer to ensure new buffers can be acquired by // lockNextBuffer. status_t unlockBuffer(const LockedBuffer &nativeBuffer); private: // Maximum number of buffers that can be locked at a time size_t mMaxLockedBuffers; status_t releaseAcquiredBufferLocked(size_t lockedIdx); virtual void freeBufferLocked(int slotIndex); // Tracking for buffers acquired by the user struct AcquiredBuffer { // Need to track the original mSlot index and the buffer itself because // the mSlot entry may be freed/reused before the acquired buffer is // released. int mSlot; sp mGraphicBuffer; void *mBufferPointer; AcquiredBuffer() : mSlot(BufferQueue::INVALID_BUFFER_SLOT), mBufferPointer(NULL) { } }; Vector mAcquiredBuffers; // Count of currently locked buffers size_t mCurrentLockedBuffers; }; } // namespace android #endif // ANDROID_GUI_CPUCONSUMER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/DisplayEventReceiver.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_DISPLAY_EVENT_H #define ANDROID_GUI_DISPLAY_EVENT_H #include #include #include #include #include #include // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- class BitTube; class IDisplayEventConnection; // ---------------------------------------------------------------------------- class DisplayEventReceiver { public: enum { DISPLAY_EVENT_VSYNC = 'vsyn', DISPLAY_EVENT_HOTPLUG = 'plug' }; struct Event { struct Header { uint32_t type; uint32_t id; nsecs_t timestamp __attribute__((aligned(8))); }; struct VSync { uint32_t count; }; struct Hotplug { bool connected; }; Header header; union { VSync vsync; Hotplug hotplug; }; }; public: /* * DisplayEventReceiver creates and registers an event connection with * SurfaceFlinger. VSync events are disabled by default. Call setVSyncRate * or requestNextVsync to receive them. * Other events start being delivered immediately. */ DisplayEventReceiver(); /* * ~DisplayEventReceiver severs the connection with SurfaceFlinger, new events * stop being delivered immediately. Note that the queue could have * some events pending. These will be delivered. */ ~DisplayEventReceiver(); /* * initCheck returns the state of DisplayEventReceiver after construction. */ status_t initCheck() const; /* * getFd returns the file descriptor to use to receive events. * OWNERSHIP IS RETAINED by DisplayEventReceiver. DO NOT CLOSE this * file-descriptor. */ int getFd() const; /* * getEvents reads events from the queue and returns how many events were * read. Returns 0 if there are no more events or a negative error code. * If NOT_ENOUGH_DATA is returned, the object has become invalid forever, it * should be destroyed and getEvents() shouldn't be called again. */ ssize_t getEvents(Event* events, size_t count); static ssize_t getEvents(const sp& dataChannel, Event* events, size_t count); /* * sendEvents write events to the queue and returns how many events were * written. */ static ssize_t sendEvents(const sp& dataChannel, Event const* events, size_t count); /* * setVsyncRate() sets the Event::VSync delivery rate. A value of * 1 returns every Event::VSync. A value of 2 returns every other event, * etc... a value of 0 returns no event unless requestNextVsync() has * been called. */ status_t setVsyncRate(uint32_t count); /* * requestNextVsync() schedules the next Event::VSync. It has no effect * if the vsync rate is > 0. */ status_t requestNextVsync(); private: sp mEventConnection; sp mDataChannel; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_DISPLAY_EVENT_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/GLConsumer.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_CONSUMER_H #define ANDROID_GUI_CONSUMER_H #include #include #include #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class String8; /* * GLConsumer consumes buffers of graphics data from a BufferQueue, * and makes them available to OpenGL as a texture. * * A typical usage pattern is to set up the GLConsumer with the * desired options, and call updateTexImage() when a new frame is desired. * If a new frame is available, the texture will be updated. If not, * the previous contents are retained. * * By default, the texture is attached to the GL_TEXTURE_EXTERNAL_OES * texture target, in the EGL context of the first thread that calls * updateTexImage(). * * This class was previously called SurfaceTexture. */ class GLConsumer : public ConsumerBase { public: enum { TEXTURE_EXTERNAL = 0x8D65 }; // GL_TEXTURE_EXTERNAL_OES typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; // GLConsumer constructs a new GLConsumer object. If the constructor with // the tex parameter is used, tex indicates the name of the OpenGL ES // texture to which images are to be streamed. texTarget specifies the // OpenGL ES texture target to which the texture will be bound in // updateTexImage. useFenceSync specifies whether fences should be used to // synchronize access to buffers if that behavior is enabled at // compile-time. // // A GLConsumer may be detached from one OpenGL ES context and then // attached to a different context using the detachFromContext and // attachToContext methods, respectively. The intention of these methods is // purely to allow a GLConsumer to be transferred from one consumer // context to another. If such a transfer is not needed there is no // requirement that either of these methods be called. // // If the constructor with the tex parameter is used, the GLConsumer is // created in a state where it is considered attached to an OpenGL ES // context for the purposes of the attachToContext and detachFromContext // methods. However, despite being considered "attached" to a context, the // specific OpenGL ES context doesn't get latched until the first call to // updateTexImage. After that point, all calls to updateTexImage must be // made with the same OpenGL ES context current. // // If the constructor without the tex parameter is used, the GLConsumer is // created in a detached state, and attachToContext must be called before // calls to updateTexImage. GLConsumer(const sp& bq, uint32_t tex, uint32_t texureTarget, bool useFenceSync, bool isControlledByApp); GLConsumer(const sp& bq, uint32_t texureTarget, bool useFenceSync, bool isControlledByApp); // updateTexImage acquires the most recently queued buffer, and sets the // image contents of the target texture to it. // // This call may only be made while the OpenGL ES context to which the // target texture belongs is bound to the calling thread. // // This calls doGLFenceWait to ensure proper synchronization. status_t updateTexImage(); // releaseTexImage releases the texture acquired in updateTexImage(). // This is intended to be used in single buffer mode. // // This call may only be made while the OpenGL ES context to which the // target texture belongs is bound to the calling thread. status_t releaseTexImage(); // setReleaseFence stores a fence that will signal when the current buffer // is no longer being read. This fence will be returned to the producer // when the current buffer is released by updateTexImage(). Multiple // fences can be set for a given buffer; they will be merged into a single // union fence. void setReleaseFence(const sp& fence); // setDefaultMaxBufferCount sets the default limit on the maximum number // of buffers that will be allocated at one time. The image producer may // override the limit. status_t setDefaultMaxBufferCount(int bufferCount); // getTransformMatrix retrieves the 4x4 texture coordinate transform matrix // associated with the texture image set by the most recent call to // updateTexImage. // // This transform matrix maps 2D homogeneous texture coordinates of the form // (s, t, 0, 1) with s and t in the inclusive range [0, 1] to the texture // coordinate that should be used to sample that location from the texture. // Sampling the texture outside of the range of this transform is undefined. // // This transform is necessary to compensate for transforms that the stream // content producer may implicitly apply to the content. By forcing users of // a GLConsumer to apply this transform we avoid performing an extra // copy of the data that would be needed to hide the transform from the // user. // // The matrix is stored in column-major order so that it may be passed // directly to OpenGL ES via the glLoadMatrixf or glUniformMatrix4fv // functions. void getTransformMatrix(float mtx[16]); // getTimestamp retrieves the timestamp associated with the texture image // set by the most recent call to updateTexImage. // // The timestamp is in nanoseconds, and is monotonically increasing. Its // other semantics (zero point, etc) are source-dependent and should be // documented by the source. int64_t getTimestamp(); // getFrameNumber retrieves the frame number associated with the texture // image set by the most recent call to updateTexImage. // // The frame number is an incrementing counter set to 0 at the creation of // the BufferQueue associated with this consumer. uint64_t getFrameNumber(); // setDefaultBufferSize is used to set the size of buffers returned by // requestBuffers when a with and height of zero is requested. // A call to setDefaultBufferSize() may trigger requestBuffers() to // be called from the client. // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. status_t setDefaultBufferSize(uint32_t width, uint32_t height); // setFilteringEnabled sets whether the transform matrix should be computed // for use with bilinear filtering. void setFilteringEnabled(bool enabled); // getCurrentBuffer returns the buffer associated with the current image. sp getCurrentBuffer() const; // getCurrentTextureTarget returns the texture target of the current // texture as returned by updateTexImage(). uint32_t getCurrentTextureTarget() const; // getCurrentCrop returns the cropping rectangle of the current buffer. Rect getCurrentCrop() const; // getCurrentTransform returns the transform of the current buffer. uint32_t getCurrentTransform() const; // getCurrentScalingMode returns the scaling mode of the current buffer. uint32_t getCurrentScalingMode() const; // getCurrentFence returns the fence indicating when the current buffer is // ready to be read from. sp getCurrentFence() const; // doGLFenceWait inserts a wait command into the OpenGL ES command stream // to ensure that it is safe for future OpenGL ES commands to access the // current texture buffer. status_t doGLFenceWait() const; // set the name of the GLConsumer that will be used to identify it in // log messages. void setName(const String8& name); // These functions call the corresponding BufferQueue implementation // so the refactoring can proceed smoothly status_t setDefaultBufferFormat(PixelFormat defaultFormat); status_t setDefaultBufferDataSpace(android_dataspace defaultDataSpace); status_t setConsumerUsageBits(uint32_t usage); status_t setTransformHint(uint32_t hint); // detachFromContext detaches the GLConsumer from the calling thread's // current OpenGL ES context. This context must be the same as the context // that was current for previous calls to updateTexImage. // // Detaching a GLConsumer from an OpenGL ES context will result in the // deletion of the OpenGL ES texture object into which the images were being // streamed. After a GLConsumer has been detached from the OpenGL ES // context calls to updateTexImage will fail returning INVALID_OPERATION // until the GLConsumer is attached to a new OpenGL ES context using the // attachToContext method. status_t detachFromContext(); // attachToContext attaches a GLConsumer that is currently in the // 'detached' state to the current OpenGL ES context. A GLConsumer is // in the 'detached' state iff detachFromContext has successfully been // called and no calls to attachToContext have succeeded since the last // detachFromContext call. Calls to attachToContext made on a // GLConsumer that is not in the 'detached' state will result in an // INVALID_OPERATION error. // // The tex argument specifies the OpenGL ES texture object name in the // new context into which the image contents will be streamed. A successful // call to attachToContext will result in this texture object being bound to // the texture target and populated with the image contents that were // current at the time of the last call to detachFromContext. status_t attachToContext(uint32_t tex); protected: // abandonLocked overrides the ConsumerBase method to clear // mCurrentTextureImage in addition to the ConsumerBase behavior. virtual void abandonLocked(); // dumpLocked overrides the ConsumerBase method to dump GLConsumer- // specific info in addition to the ConsumerBase behavior. virtual void dumpLocked(String8& result, const char* prefix) const; // acquireBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase behavior. virtual status_t acquireBufferLocked(BufferItem *item, nsecs_t presentWhen, uint64_t maxFrameNumber = 0) override; // releaseBufferLocked overrides the ConsumerBase method to update the // mEglSlots array in addition to the ConsumerBase. virtual status_t releaseBufferLocked(int slot, const sp graphicBuffer, EGLDisplay display, EGLSyncKHR eglFence); status_t releaseBufferLocked(int slot, const sp graphicBuffer, EGLSyncKHR eglFence) { return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence); } static bool isExternalFormat(PixelFormat format); // This releases the buffer in the slot referenced by mCurrentTexture, // then updates state to refer to the BufferItem, which must be a // newly-acquired buffer. status_t updateAndReleaseLocked(const BufferItem& item); // Binds mTexName and the current buffer to mTexTarget. Uses // mCurrentTexture if it's set, mCurrentTextureImage if not. If the // bind succeeds, this calls doGLFenceWait. status_t bindTextureImageLocked(); // Gets the current EGLDisplay and EGLContext values, and compares them // to mEglDisplay and mEglContext. If the fields have been previously // set, the values must match; if not, the fields are set to the current // values. // The contextCheck argument is used to ensure that a GL context is // properly set; when set to false, the check is not performed. status_t checkAndUpdateEglStateLocked(bool contextCheck = false); private: // EglImage is a utility class for tracking and creating EGLImageKHRs. There // is primarily just one image per slot, but there is also special cases: // - For releaseTexImage, we use a debug image (mReleasedTexImage) // - After freeBuffer, we must still keep the current image/buffer // Reference counting EGLImages lets us handle all these cases easily while // also only creating new EGLImages from buffers when required. class EglImage : public LightRefBase { public: EglImage(sp graphicBuffer); // createIfNeeded creates an EGLImage if required (we haven't created // one yet, or the EGLDisplay or crop-rect has changed). status_t createIfNeeded(EGLDisplay display, const Rect& cropRect, bool forceCreate = false); // This calls glEGLImageTargetTexture2DOES to bind the image to the // texture in the specified texture target. void bindToTextureTarget(uint32_t texTarget); const sp& graphicBuffer() { return mGraphicBuffer; } const native_handle* graphicBufferHandle() { return mGraphicBuffer == NULL ? NULL : mGraphicBuffer->handle; } private: // Only allow instantiation using ref counting. friend class LightRefBase; virtual ~EglImage(); // createImage creates a new EGLImage from a GraphicBuffer. EGLImageKHR createImage(EGLDisplay dpy, const sp& graphicBuffer, const Rect& crop); // Disallow copying EglImage(const EglImage& rhs); void operator = (const EglImage& rhs); // mGraphicBuffer is the buffer that was used to create this image. sp mGraphicBuffer; // mEglImage is the EGLImage created from mGraphicBuffer. EGLImageKHR mEglImage; // mEGLDisplay is the EGLDisplay that was used to create mEglImage. EGLDisplay mEglDisplay; // mCropRect is the crop rectangle passed to EGL when mEglImage // was created. Rect mCropRect; }; // freeBufferLocked frees up the given buffer slot. If the slot has been // initialized this will release the reference to the GraphicBuffer in that // slot and destroy the EGLImage in that slot. Otherwise it has no effect. // // This method must be called with mMutex locked. virtual void freeBufferLocked(int slotIndex); // computeCurrentTransformMatrixLocked computes the transform matrix for the // current texture. It uses mCurrentTransform and the current GraphicBuffer // to compute this matrix and stores it in mCurrentTransformMatrix. // mCurrentTextureImage must not be NULL. void computeCurrentTransformMatrixLocked(); // doGLFenceWaitLocked inserts a wait command into the OpenGL ES command // stream to ensure that it is safe for future OpenGL ES commands to // access the current texture buffer. status_t doGLFenceWaitLocked() const; // syncForReleaseLocked performs the synchronization needed to release the // current slot from an OpenGL ES context. If needed it will set the // current slot's fence to guard against a producer accessing the buffer // before the outstanding accesses have completed. status_t syncForReleaseLocked(EGLDisplay dpy); // returns a graphic buffer used when the texture image has been released static sp getDebugTexImageBuffer(); // The default consumer usage flags that GLConsumer always sets on its // BufferQueue instance; these will be OR:d with any additional flags passed // from the GLConsumer user. In particular, GLConsumer will always // consume buffers as hardware textures. static const uint32_t DEFAULT_USAGE_FLAGS = GraphicBuffer::USAGE_HW_TEXTURE; // mCurrentTextureImage is the EglImage/buffer of the current texture. It's // possible that this buffer is not associated with any buffer slot, so we // must track it separately in order to support the getCurrentBuffer method. sp mCurrentTextureImage; // mCurrentCrop is the crop rectangle that applies to the current texture. // It gets set each time updateTexImage is called. Rect mCurrentCrop; // mCurrentTransform is the transform identifier for the current texture. It // gets set each time updateTexImage is called. uint32_t mCurrentTransform; // mCurrentScalingMode is the scaling mode for the current texture. It gets // set each time updateTexImage is called. uint32_t mCurrentScalingMode; // mCurrentFence is the fence received from BufferQueue in updateTexImage. sp mCurrentFence; // mCurrentTransformMatrix is the transform matrix for the current texture. // It gets computed by computeTransformMatrix each time updateTexImage is // called. float mCurrentTransformMatrix[16]; // mCurrentTimestamp is the timestamp for the current texture. It // gets set each time updateTexImage is called. int64_t mCurrentTimestamp; // mCurrentFrameNumber is the frame counter for the current texture. // It gets set each time updateTexImage is called. uint64_t mCurrentFrameNumber; uint32_t mDefaultWidth, mDefaultHeight; // mFilteringEnabled indicates whether the transform matrix is computed for // use with bilinear filtering. It defaults to true and is changed by // setFilteringEnabled(). bool mFilteringEnabled; // mTexName is the name of the OpenGL texture to which streamed images will // be bound when updateTexImage is called. It is set at construction time // and can be changed with a call to attachToContext. uint32_t mTexName; // mUseFenceSync indicates whether creation of the EGL_KHR_fence_sync // extension should be used to prevent buffers from being dequeued before // it's safe for them to be written. It gets set at construction time and // never changes. const bool mUseFenceSync; // mTexTarget is the GL texture target with which the GL texture object is // associated. It is set in the constructor and never changed. It is // almost always GL_TEXTURE_EXTERNAL_OES except for one use case in Android // Browser. In that case it is set to GL_TEXTURE_2D to allow // glCopyTexSubImage to read from the texture. This is a hack to work // around a GL driver limitation on the number of FBO attachments, which the // browser's tile cache exceeds. const uint32_t mTexTarget; // EGLSlot contains the information and object references that // GLConsumer maintains about a BufferQueue buffer slot. struct EglSlot { EglSlot() : mEglFence(EGL_NO_SYNC_KHR) {} // mEglImage is the EGLImage created from mGraphicBuffer. sp mEglImage; // mFence is the EGL sync object that must signal before the buffer // associated with this buffer slot may be dequeued. It is initialized // to EGL_NO_SYNC_KHR when the buffer is created and (optionally, based // on a compile-time option) set to a new sync object in updateTexImage. EGLSyncKHR mEglFence; }; // mEglDisplay is the EGLDisplay with which this GLConsumer is currently // associated. It is intialized to EGL_NO_DISPLAY and gets set to the // current display when updateTexImage is called for the first time and when // attachToContext is called. EGLDisplay mEglDisplay; // mEglContext is the OpenGL ES context with which this GLConsumer is // currently associated. It is initialized to EGL_NO_CONTEXT and gets set // to the current GL context when updateTexImage is called for the first // time and when attachToContext is called. EGLContext mEglContext; // mEGLSlots stores the buffers that have been allocated by the BufferQueue // for each buffer slot. It is initialized to null pointers, and gets // filled in with the result of BufferQueue::acquire when the // client dequeues a buffer from a // slot that has not yet been used. The buffer allocated to a slot will also // be replaced if the requested buffer usage or geometry differs from that // of the buffer allocated to a slot. EglSlot mEglSlots[BufferQueue::NUM_BUFFER_SLOTS]; // mCurrentTexture is the buffer slot index of the buffer that is currently // bound to the OpenGL texture. It is initialized to INVALID_BUFFER_SLOT, // indicating that no buffer slot is currently bound to the texture. Note, // however, that a value of INVALID_BUFFER_SLOT does not necessarily mean // that no buffer is bound to the texture. A call to setBufferCount will // reset mCurrentTexture to INVALID_BUFFER_SLOT. int mCurrentTexture; // mAttached indicates whether the ConsumerBase is currently attached to // an OpenGL ES context. For legacy reasons, this is initialized to true, // indicating that the ConsumerBase is considered to be attached to // whatever context is current at the time of the first updateTexImage call. // It is set to false by detachFromContext, and then set to true again by // attachToContext. bool mAttached; // protects static initialization static Mutex sStaticInitLock; // mReleasedTexImageBuffer is a dummy buffer used when in single buffer // mode and releaseTexImage() has been called static sp sReleasedTexImageBuffer; sp mReleasedTexImage; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_CONSUMER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/GraphicBufferAlloc.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_SF_GRAPHIC_BUFFER_ALLOC_H #define ANDROID_SF_GRAPHIC_BUFFER_ALLOC_H #include #include #include #include #include namespace android { // --------------------------------------------------------------------------- class GraphicBuffer; class GraphicBufferAlloc : public BnGraphicBufferAlloc { public: GraphicBufferAlloc(); virtual ~GraphicBufferAlloc(); virtual sp createGraphicBuffer(uint32_t width, uint32_t height, PixelFormat format, uint32_t usage, status_t* error); }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_SF_GRAPHIC_BUFFER_ALLOC_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/GuiConfig.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_CONFIG_H #define ANDROID_GUI_CONFIG_H #include namespace android { // Append the libgui configuration details to configStr. void appendGuiConfigString(String8& configStr); }; // namespace android #endif /*ANDROID_GUI_CONFIG_H*/ ================================================ FILE: phonelibs/android_frameworks_native/include/gui/IConsumerListener.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_ICONSUMERLISTENER_H #define ANDROID_GUI_ICONSUMERLISTENER_H #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class BufferItem; // ConsumerListener is the interface through which the BufferQueue notifies // the consumer of events that the consumer may wish to react to. Because // the consumer will generally have a mutex that is locked during calls from // the consumer to the BufferQueue, these calls from the BufferQueue to the // consumer *MUST* be called only when the BufferQueue mutex is NOT locked. class ConsumerListener : public virtual RefBase { public: ConsumerListener() { } virtual ~ConsumerListener() { } // onFrameAvailable is called from queueBuffer each time an additional // frame becomes available for consumption. This means that frames that // are queued while in asynchronous mode only trigger the callback if no // previous frames are pending. Frames queued while in synchronous mode // always trigger the callback. The item passed to the callback will contain // all of the information about the queued frame except for its // GraphicBuffer pointer, which will always be null. // // This is called without any lock held and can be called concurrently // by multiple threads. virtual void onFrameAvailable(const BufferItem& item) = 0; /* Asynchronous */ // onFrameReplaced is called from queueBuffer if the frame being queued is // replacing an existing slot in the queue. Any call to queueBuffer that // doesn't call onFrameAvailable will call this callback instead. The item // passed to the callback will contain all of the information about the // queued frame except for its GraphicBuffer pointer, which will always be // null. // // This is called without any lock held and can be called concurrently // by multiple threads. virtual void onFrameReplaced(const BufferItem& /* item */) {} /* Asynchronous */ // onBuffersReleased is called to notify the buffer consumer that the // BufferQueue has released its references to one or more GraphicBuffers // contained in its slots. The buffer consumer should then call // BufferQueue::getReleasedBuffers to retrieve the list of buffers // // This is called without any lock held and can be called concurrently // by multiple threads. virtual void onBuffersReleased() = 0; /* Asynchronous */ // onSidebandStreamChanged is called to notify the buffer consumer that the // BufferQueue's sideband buffer stream has changed. This is called when a // stream is first attached and when it is either detached or replaced by a // different stream. virtual void onSidebandStreamChanged() = 0; /* Asynchronous */ }; class IConsumerListener : public ConsumerListener, public IInterface { public: DECLARE_META_INTERFACE(ConsumerListener); }; // ---------------------------------------------------------------------------- class BnConsumerListener : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_ICONSUMERLISTENER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/IDisplayEventConnection.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_IDISPLAY_EVENT_CONNECTION_H #define ANDROID_GUI_IDISPLAY_EVENT_CONNECTION_H #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class BitTube; class IDisplayEventConnection : public IInterface { public: DECLARE_META_INTERFACE(DisplayEventConnection); /* * getDataChannel() returns a BitTube where to receive the events from */ virtual sp getDataChannel() const = 0; /* * setVsyncRate() sets the vsync event delivery rate. A value of * 1 returns every vsync events. A value of 2 returns every other events, * etc... a value of 0 returns no event unless requestNextVsync() has * been called. */ virtual void setVsyncRate(uint32_t count) = 0; /* * requestNextVsync() schedules the next vsync event. It has no effect * if the vsync rate is > 0. */ virtual void requestNextVsync() = 0; // asynchronous }; // ---------------------------------------------------------------------------- class BnDisplayEventConnection : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_IDISPLAY_EVENT_CONNECTION_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/IGraphicBufferAlloc.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H #define ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class GraphicBuffer; class IGraphicBufferAlloc : public IInterface { public: DECLARE_META_INTERFACE(GraphicBufferAlloc); /* Create a new GraphicBuffer for the client to use. */ virtual sp createGraphicBuffer(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage, status_t* error) = 0; }; // ---------------------------------------------------------------------------- class BnGraphicBufferAlloc : public BnInterface { public: virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_IGRAPHIC_BUFFER_ALLOC_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/IGraphicBufferConsumer.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_IGRAPHICBUFFERCONSUMER_H #define ANDROID_GUI_IGRAPHICBUFFERCONSUMER_H #include #include #include #include #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class BufferItem; class Fence; class GraphicBuffer; class IConsumerListener; class NativeHandle; class IGraphicBufferConsumer : public IInterface { public: enum { // Returned by releaseBuffer, after which the consumer must // free any references to the just-released buffer that it might have. STALE_BUFFER_SLOT = 1, // Returned by dequeueBuffer if there are no pending buffers available. NO_BUFFER_AVAILABLE, // Returned by dequeueBuffer if it's too early for the buffer to be acquired. PRESENT_LATER, }; // acquireBuffer attempts to acquire ownership of the next pending buffer in // the BufferQueue. If no buffer is pending then it returns // NO_BUFFER_AVAILABLE. If a buffer is successfully acquired, the // information about the buffer is returned in BufferItem. // // If the buffer returned had previously been // acquired then the BufferItem::mGraphicBuffer field of buffer is set to // NULL and it is assumed that the consumer still holds a reference to the // buffer. // // If presentWhen is non-zero, it indicates the time when the buffer will // be displayed on screen. If the buffer's timestamp is farther in the // future, the buffer won't be acquired, and PRESENT_LATER will be // returned. The presentation time is in nanoseconds, and the time base // is CLOCK_MONOTONIC. // // If maxFrameNumber is non-zero, it indicates that acquireBuffer should // only return a buffer with a frame number less than or equal to // maxFrameNumber. If no such frame is available (such as when a buffer has // been replaced but the consumer has not received the onFrameReplaced // callback), then PRESENT_LATER will be returned. // // Return of NO_ERROR means the operation completed as normal. // // Return of a positive value means the operation could not be completed // at this time, but the user should try again later: // * NO_BUFFER_AVAILABLE - no buffer is pending (nothing queued by producer) // * PRESENT_LATER - the buffer's timestamp is farther in the future // // Return of a negative value means an error has occurred: // * INVALID_OPERATION - too many buffers have been acquired virtual status_t acquireBuffer(BufferItem* buffer, nsecs_t presentWhen, uint64_t maxFrameNumber = 0) = 0; // detachBuffer attempts to remove all ownership of the buffer in the given // slot from the buffer queue. If this call succeeds, the slot will be // freed, and there will be no way to obtain the buffer from this interface. // The freed slot will remain unallocated until either it is selected to // hold a freshly allocated buffer in dequeueBuffer or a buffer is attached // to the slot. The buffer must have already been acquired. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - the given slot number is invalid, either because it is // out of the range [0, NUM_BUFFER_SLOTS) or because the slot // it refers to is not currently acquired. virtual status_t detachBuffer(int slot) = 0; // attachBuffer attempts to transfer ownership of a buffer to the buffer // queue. If this call succeeds, it will be as if this buffer was acquired // from the returned slot number. As such, this call will fail if attaching // this buffer would cause too many buffers to be simultaneously acquired. // // If the buffer is successfully attached, its frameNumber is initialized // to 0. This must be passed into the releaseBuffer call or else the buffer // will be deallocated as stale. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - outSlot or buffer were NULL, or the generation number of // the buffer did not match the buffer queue. // * INVALID_OPERATION - cannot attach the buffer because it would cause too // many buffers to be acquired. // * NO_MEMORY - no free slots available virtual status_t attachBuffer(int *outSlot, const sp& buffer) = 0; // releaseBuffer releases a buffer slot from the consumer back to the // BufferQueue. This may be done while the buffer's contents are still // being accessed. The fence will signal when the buffer is no longer // in use. frameNumber is used to indentify the exact buffer returned. // // If releaseBuffer returns STALE_BUFFER_SLOT, then the consumer must free // any references to the just-released buffer that it might have, as if it // had received a onBuffersReleased() call with a mask set for the released // buffer. // // Note that the dependencies on EGL will be removed once we switch to using // the Android HW Sync HAL. // // Return of NO_ERROR means the operation completed as normal. // // Return of a positive value means the operation could not be completed // at this time, but the user should try again later: // * STALE_BUFFER_SLOT - see above (second paragraph) // // Return of a negative value means an error has occurred: // * BAD_VALUE - one of the following could've happened: // * the buffer slot was invalid // * the fence was NULL // * the buffer slot specified is not in the acquired state virtual status_t releaseBuffer(int buf, uint64_t frameNumber, EGLDisplay display, EGLSyncKHR fence, const sp& releaseFence) = 0; // consumerConnect connects a consumer to the BufferQueue. Only one // consumer may be connected, and when that consumer disconnects the // BufferQueue is placed into the "abandoned" state, causing most // interactions with the BufferQueue by the producer to fail. // controlledByApp indicates whether the consumer is controlled by // the application. // // consumer may not be NULL. // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned // * BAD_VALUE - a NULL consumer was provided virtual status_t consumerConnect(const sp& consumer, bool controlledByApp) = 0; // consumerDisconnect disconnects a consumer from the BufferQueue. All // buffers will be freed and the BufferQueue is placed in the "abandoned" // state, causing most interactions with the BufferQueue by the producer to // fail. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - no consumer is currently connected virtual status_t consumerDisconnect() = 0; // getReleasedBuffers sets the value pointed to by slotMask to a bit set. // Each bit index with a 1 corresponds to a released buffer slot with that // index value. In particular, a released buffer is one that has // been released by the BufferQueue but have not yet been released by the consumer. // // This should be called from the onBuffersReleased() callback. // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. virtual status_t getReleasedBuffers(uint64_t* slotMask) = 0; // setDefaultBufferSize is used to set the size of buffers returned by // dequeueBuffer when a width and height of zero is requested. Default // is 1x1. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - either w or h was zero virtual status_t setDefaultBufferSize(uint32_t w, uint32_t h) = 0; // setDefaultMaxBufferCount sets the default value for the maximum buffer // count (the initial default is 2). If the producer has requested a // buffer count using setBufferCount, the default buffer count will only // take effect if the producer sets the count back to zero. // // The count must be between 2 and NUM_BUFFER_SLOTS, inclusive. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - bufferCount was out of range (see above). virtual status_t setDefaultMaxBufferCount(int bufferCount) = 0; // disableAsyncBuffer disables the extra buffer used in async mode // (when both producer and consumer have set their "isControlledByApp" // flag) and has dequeueBuffer() return WOULD_BLOCK instead. // // This can only be called before consumerConnect(). // // Return of a value other than NO_ERROR means an error has occurred: // * INVALID_OPERATION - attempting to call this after consumerConnect. virtual status_t disableAsyncBuffer() = 0; // setMaxAcquiredBufferCount sets the maximum number of buffers that can // be acquired by the consumer at one time (default 1). This call will // fail if a producer is connected to the BufferQueue. // // maxAcquiredBuffers must be (inclusive) between 1 and MAX_MAX_ACQUIRED_BUFFERS. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - maxAcquiredBuffers was out of range (see above). // * INVALID_OPERATION - attempting to call this after a producer connected. virtual status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers) = 0; // setConsumerName sets the name used in logging virtual void setConsumerName(const String8& name) = 0; // setDefaultBufferFormat allows the BufferQueue to create // GraphicBuffers of a defaultFormat if no format is specified // in dequeueBuffer. // The initial default is PIXEL_FORMAT_RGBA_8888. // // Return of a value other than NO_ERROR means an unknown error has occurred. virtual status_t setDefaultBufferFormat(PixelFormat defaultFormat) = 0; // setDefaultBufferDataSpace is a request to the producer to provide buffers // of the indicated dataSpace. The producer may ignore this request. // The initial default is HAL_DATASPACE_UNKNOWN. // // Return of a value other than NO_ERROR means an unknown error has occurred. virtual status_t setDefaultBufferDataSpace( android_dataspace defaultDataSpace) = 0; // setConsumerUsageBits will turn on additional usage bits for dequeueBuffer. // These are merged with the bits passed to dequeueBuffer. The values are // enumerated in gralloc.h, e.g. GRALLOC_USAGE_HW_RENDER; the default is 0. // // Return of a value other than NO_ERROR means an unknown error has occurred. virtual status_t setConsumerUsageBits(uint32_t usage) = 0; // setTransformHint bakes in rotation to buffers so overlays can be used. // The values are enumerated in window.h, e.g. // NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform). // // Return of a value other than NO_ERROR means an unknown error has occurred. virtual status_t setTransformHint(uint32_t hint) = 0; // Retrieve the sideband buffer stream, if any. virtual sp getSidebandStream() const = 0; // dump state into a string virtual void dump(String8& result, const char* prefix) const = 0; public: DECLARE_META_INTERFACE(GraphicBufferConsumer); }; // ---------------------------------------------------------------------------- class BnGraphicBufferConsumer : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_IGRAPHICBUFFERCONSUMER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/IGraphicBufferProducer.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H #define ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H #include #include #include #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class IProducerListener; class NativeHandle; class Surface; /* * This class defines the Binder IPC interface for the producer side of * a queue of graphics buffers. It's used to send graphics data from one * component to another. For example, a class that decodes video for * playback might use this to provide frames. This is typically done * indirectly, through Surface. * * The underlying mechanism is a BufferQueue, which implements * BnGraphicBufferProducer. In normal operation, the producer calls * dequeueBuffer() to get an empty buffer, fills it with data, then * calls queueBuffer() to make it available to the consumer. * * This class was previously called ISurfaceTexture. */ class IGraphicBufferProducer : public IInterface { public: DECLARE_META_INTERFACE(GraphicBufferProducer); enum { // A flag returned by dequeueBuffer when the client needs to call // requestBuffer immediately thereafter. BUFFER_NEEDS_REALLOCATION = 0x1, // A flag returned by dequeueBuffer when all mirrored slots should be // released by the client. This flag should always be processed first. RELEASE_ALL_BUFFERS = 0x2, }; // requestBuffer requests a new buffer for the given index. The server (i.e. // the IGraphicBufferProducer implementation) assigns the newly created // buffer to the given slot index, and the client is expected to mirror the // slot->buffer mapping so that it's not necessary to transfer a // GraphicBuffer for every dequeue operation. // // The slot must be in the range of [0, NUM_BUFFER_SLOTS). // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - one of the two conditions occurred: // * slot was out of range (see above) // * buffer specified by the slot is not dequeued virtual status_t requestBuffer(int slot, sp* buf) = 0; // setBufferCount sets the number of buffer slots available. Calling this // will also cause all buffer slots to be emptied. The caller should empty // its mirrored copy of the buffer slots when calling this method. // // This function should not be called when there are any dequeued buffer // slots, doing so will result in a BAD_VALUE error returned. // // The buffer count should be at most NUM_BUFFER_SLOTS (inclusive), but at least // the minimum undequeued buffer count (exclusive). The minimum value // can be obtained by calling query(NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS). // In particular the range is (minUndequeudBuffers, NUM_BUFFER_SLOTS]. // // The buffer count may also be set to 0 (the default), to indicate that // the producer does not wish to set a value. // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - one of the below conditions occurred: // * bufferCount was out of range (see above) // * client has one or more buffers dequeued virtual status_t setBufferCount(int bufferCount) = 0; // dequeueBuffer requests a new buffer slot for the client to use. Ownership // of the slot is transfered to the client, meaning that the server will not // use the contents of the buffer associated with that slot. // // The slot index returned may or may not contain a buffer (client-side). // If the slot is empty the client should call requestBuffer to assign a new // buffer to that slot. // // Once the client is done filling this buffer, it is expected to transfer // buffer ownership back to the server with either cancelBuffer on // the dequeued slot or to fill in the contents of its associated buffer // contents and call queueBuffer. // // If dequeueBuffer returns the BUFFER_NEEDS_REALLOCATION flag, the client is // expected to call requestBuffer immediately. // // If dequeueBuffer returns the RELEASE_ALL_BUFFERS flag, the client is // expected to release all of the mirrored slot->buffer mappings. // // The fence parameter will be updated to hold the fence associated with // the buffer. The contents of the buffer must not be overwritten until the // fence signals. If the fence is Fence::NO_FENCE, the buffer may be written // immediately. // // The async parameter sets whether we're in asynchronous mode for this // dequeueBuffer() call. // // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. If width and height are both zero, the // default values specified by setDefaultBufferSize() are used instead. // // If the format is 0, the default format will be used. // // The usage argument specifies gralloc buffer usage flags. The values // are enumerated in , e.g. GRALLOC_USAGE_HW_RENDER. These // will be merged with the usage flags specified by // IGraphicBufferConsumer::setConsumerUsageBits. // // This call will block until a buffer is available to be dequeued. If // both the producer and consumer are controlled by the app, then this call // can never block and will return WOULD_BLOCK if no buffer is available. // // A non-negative value with flags set (see above) will be returned upon // success. // // Return of a negative means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - both in async mode and buffer count was less than the // max numbers of buffers that can be allocated at once. // * INVALID_OPERATION - cannot attach the buffer because it would cause // too many buffers to be dequeued, either because // the producer already has a single buffer dequeued // and did not set a buffer count, or because a // buffer count was set and this call would cause // it to be exceeded. // * WOULD_BLOCK - no buffer is currently available, and blocking is disabled // since both the producer/consumer are controlled by app // * NO_MEMORY - out of memory, cannot allocate the graphics buffer. // // All other negative values are an unknown error returned downstream // from the graphics allocator (typically errno). virtual status_t dequeueBuffer(int* slot, sp* fence, bool async, uint32_t w, uint32_t h, PixelFormat format, uint32_t usage) = 0; // detachBuffer attempts to remove all ownership of the buffer in the given // slot from the buffer queue. If this call succeeds, the slot will be // freed, and there will be no way to obtain the buffer from this interface. // The freed slot will remain unallocated until either it is selected to // hold a freshly allocated buffer in dequeueBuffer or a buffer is attached // to the slot. The buffer must have already been dequeued, and the caller // must already possesses the sp (i.e., must have called // requestBuffer). // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - the given slot number is invalid, either because it is // out of the range [0, NUM_BUFFER_SLOTS), or because the slot // it refers to is not currently dequeued and requested. virtual status_t detachBuffer(int slot) = 0; // detachNextBuffer is equivalent to calling dequeueBuffer, requestBuffer, // and detachBuffer in sequence, except for two things: // // 1) It is unnecessary to know the dimensions, format, or usage of the // next buffer. // 2) It will not block, since if it cannot find an appropriate buffer to // return, it will return an error instead. // // Only slots that are free but still contain a GraphicBuffer will be // considered, and the oldest of those will be returned. outBuffer is // equivalent to outBuffer from the requestBuffer call, and outFence is // equivalent to fence from the dequeueBuffer call. // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - either outBuffer or outFence were NULL. // * NO_MEMORY - no slots were found that were both free and contained a // GraphicBuffer. virtual status_t detachNextBuffer(sp* outBuffer, sp* outFence) = 0; // attachBuffer attempts to transfer ownership of a buffer to the buffer // queue. If this call succeeds, it will be as if this buffer was dequeued // from the returned slot number. As such, this call will fail if attaching // this buffer would cause too many buffers to be simultaneously dequeued. // // If attachBuffer returns the RELEASE_ALL_BUFFERS flag, the caller is // expected to release all of the mirrored slot->buffer mappings. // // A non-negative value with flags set (see above) will be returned upon // success. // // Return of a negative value means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - outSlot or buffer were NULL, invalid combination of // async mode and buffer count override, or the generation // number of the buffer did not match the buffer queue. // * INVALID_OPERATION - cannot attach the buffer because it would cause // too many buffers to be dequeued, either because // the producer already has a single buffer dequeued // and did not set a buffer count, or because a // buffer count was set and this call would cause // it to be exceeded. // * WOULD_BLOCK - no buffer slot is currently available, and blocking is // disabled since both the producer/consumer are // controlled by the app. virtual status_t attachBuffer(int* outSlot, const sp& buffer) = 0; // queueBuffer indicates that the client has finished filling in the // contents of the buffer associated with slot and transfers ownership of // that slot back to the server. // // It is not valid to call queueBuffer on a slot that is not owned // by the client or one for which a buffer associated via requestBuffer // (an attempt to do so will fail with a return value of BAD_VALUE). // // In addition, the input must be described by the client (as documented // below). Any other properties (zero point, etc) // are client-dependent, and should be documented by the client. // // The slot must be in the range of [0, NUM_BUFFER_SLOTS). // // Upon success, the output will be filled with meaningful values // (refer to the documentation below). // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - one of the below conditions occurred: // * fence was NULL // * scaling mode was unknown // * both in async mode and buffer count was less than the // max numbers of buffers that can be allocated at once // * slot index was out of range (see above). // * the slot was not in the dequeued state // * the slot was enqueued without requesting a buffer // * crop rect is out of bounds of the buffer dimensions struct QueueBufferInput : public Flattenable { friend class Flattenable; inline QueueBufferInput(const Parcel& parcel); // timestamp - a monotonically increasing value in nanoseconds // isAutoTimestamp - if the timestamp was synthesized at queue time // dataSpace - description of the contents, interpretation depends on format // crop - a crop rectangle that's used as a hint to the consumer // scalingMode - a set of flags from NATIVE_WINDOW_SCALING_* in // transform - a set of flags from NATIVE_WINDOW_TRANSFORM_* in // async - if the buffer is queued in asynchronous mode // fence - a fence that the consumer must wait on before reading the buffer, // set this to Fence::NO_FENCE if the buffer is ready immediately // sticky - the sticky transform set in Surface (only used by the LEGACY // camera mode). inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp, android_dataspace dataSpace, const Rect& crop, int scalingMode, uint32_t transform, bool async, const sp& fence, uint32_t sticky = 0) : timestamp(timestamp), isAutoTimestamp(isAutoTimestamp), dataSpace(dataSpace), crop(crop), scalingMode(scalingMode), transform(transform), stickyTransform(sticky), async(async), fence(fence), surfaceDamage() { } inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp, android_dataspace* outDataSpace, Rect* outCrop, int* outScalingMode, uint32_t* outTransform, bool* outAsync, sp* outFence, uint32_t* outStickyTransform = NULL) const { *outTimestamp = timestamp; *outIsAutoTimestamp = bool(isAutoTimestamp); *outDataSpace = dataSpace; *outCrop = crop; *outScalingMode = scalingMode; *outTransform = transform; *outAsync = bool(async); *outFence = fence; if (outStickyTransform != NULL) { *outStickyTransform = stickyTransform; } } // Flattenable protocol size_t getFlattenedSize() const; size_t getFdCount() const; status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); const Region& getSurfaceDamage() const { return surfaceDamage; } void setSurfaceDamage(const Region& damage) { surfaceDamage = damage; } private: int64_t timestamp; int isAutoTimestamp; android_dataspace dataSpace; Rect crop; int scalingMode; uint32_t transform; uint32_t stickyTransform; int async; sp fence; Region surfaceDamage; }; // QueueBufferOutput must be a POD structure struct __attribute__ ((__packed__)) QueueBufferOutput { inline QueueBufferOutput() { } // outWidth - filled with default width applied to the buffer // outHeight - filled with default height applied to the buffer // outTransformHint - filled with default transform applied to the buffer // outNumPendingBuffers - num buffers queued that haven't yet been acquired // (counting the currently queued buffer) inline void deflate(uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransformHint, uint32_t* outNumPendingBuffers) const { *outWidth = width; *outHeight = height; *outTransformHint = transformHint; *outNumPendingBuffers = numPendingBuffers; } inline void inflate(uint32_t inWidth, uint32_t inHeight, uint32_t inTransformHint, uint32_t inNumPendingBuffers) { width = inWidth; height = inHeight; transformHint = inTransformHint; numPendingBuffers = inNumPendingBuffers; } private: uint32_t width; uint32_t height; uint32_t transformHint; uint32_t numPendingBuffers; }; virtual status_t queueBuffer(int slot, const QueueBufferInput& input, QueueBufferOutput* output) = 0; // cancelBuffer indicates that the client does not wish to fill in the // buffer associated with slot and transfers ownership of the slot back to // the server. // // The buffer is not queued for use by the consumer. // // The buffer will not be overwritten until the fence signals. The fence // will usually be the one obtained from dequeueBuffer. virtual void cancelBuffer(int slot, const sp& fence) = 0; // query retrieves some information for this surface // 'what' tokens allowed are that of NATIVE_WINDOW_* in // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - the buffer queue has been abandoned. // * BAD_VALUE - what was out of range virtual int query(int what, int* value) = 0; // connect attempts to connect a client API to the IGraphicBufferProducer. // This must be called before any other IGraphicBufferProducer methods are // called except for getAllocator. A consumer must be already connected. // // This method will fail if the connect was previously called on the // IGraphicBufferProducer and no corresponding disconnect call was made. // // The listener is an optional binder callback object that can be used if // the producer wants to be notified when the consumer releases a buffer // back to the BufferQueue. It is also used to detect the death of the // producer. If only the latter functionality is desired, there is a // DummyProducerListener class in IProducerListener.h that can be used. // // The api should be one of the NATIVE_WINDOW_API_* values in // // The producerControlledByApp should be set to true if the producer is hosted // by an untrusted process (typically app_process-forked processes). If both // the producer and the consumer are app-controlled then all buffer queues // will operate in async mode regardless of the async flag. // // Upon success, the output will be filled with meaningful data // (refer to QueueBufferOutput documentation above). // // Return of a value other than NO_ERROR means an error has occurred: // * NO_INIT - one of the following occurred: // * the buffer queue was abandoned // * no consumer has yet connected // * BAD_VALUE - one of the following has occurred: // * the producer is already connected // * api was out of range (see above). // * output was NULL. // * DEAD_OBJECT - the token is hosted by an already-dead process // // Additional negative errors may be returned by the internals, they // should be treated as opaque fatal unrecoverable errors. virtual status_t connect(const sp& listener, int api, bool producerControlledByApp, QueueBufferOutput* output) = 0; // disconnect attempts to disconnect a client API from the // IGraphicBufferProducer. Calling this method will cause any subsequent // calls to other IGraphicBufferProducer methods to fail except for // getAllocator and connect. Successfully calling connect after this will // allow the other methods to succeed again. // // This method will fail if the the IGraphicBufferProducer is not currently // connected to the specified client API. // // The api should be one of the NATIVE_WINDOW_API_* values in // // Disconnecting from an abandoned IGraphicBufferProducer is legal and // is considered a no-op. // // Return of a value other than NO_ERROR means an error has occurred: // * BAD_VALUE - one of the following has occurred: // * the api specified does not match the one that was connected // * api was out of range (see above). // * DEAD_OBJECT - the token is hosted by an already-dead process virtual status_t disconnect(int api) = 0; // Attaches a sideband buffer stream to the IGraphicBufferProducer. // // A sideband stream is a device-specific mechanism for passing buffers // from the producer to the consumer without using dequeueBuffer/ // queueBuffer. If a sideband stream is present, the consumer can choose // whether to acquire buffers from the sideband stream or from the queued // buffers. // // Passing NULL or a different stream handle will detach the previous // handle if any. virtual status_t setSidebandStream(const sp& stream) = 0; // Allocates buffers based on the given dimensions/format. // // This function will allocate up to the maximum number of buffers // permitted by the current BufferQueue configuration. It will use the // given format, dimensions, and usage bits, which are interpreted in the // same way as for dequeueBuffer, and the async flag must be set the same // way as for dequeueBuffer to ensure that the correct number of buffers are // allocated. This is most useful to avoid an allocation delay during // dequeueBuffer. If there are already the maximum number of buffers // allocated, this function has no effect. virtual void allocateBuffers(bool async, uint32_t width, uint32_t height, PixelFormat format, uint32_t usage) = 0; // Sets whether dequeueBuffer is allowed to allocate new buffers. // // Normally dequeueBuffer does not discriminate between free slots which // already have an allocated buffer and those which do not, and will // allocate a new buffer if the slot doesn't have a buffer or if the slot's // buffer doesn't match the requested size, format, or usage. This method // allows the producer to restrict the eligible slots to those which already // have an allocated buffer of the correct size, format, and usage. If no // eligible slot is available, dequeueBuffer will block or return an error // as usual. virtual status_t allowAllocation(bool allow) = 0; // Sets the current generation number of the BufferQueue. // // This generation number will be inserted into any buffers allocated by the // BufferQueue, and any attempts to attach a buffer with a different // generation number will fail. Buffers already in the queue are not // affected and will retain their current generation number. The generation // number defaults to 0. virtual status_t setGenerationNumber(uint32_t generationNumber) = 0; // Returns the name of the connected consumer. virtual String8 getConsumerName() const = 0; }; // ---------------------------------------------------------------------------- class BnGraphicBufferProducer : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/IProducerListener.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_IPRODUCERLISTENER_H #define ANDROID_GUI_IPRODUCERLISTENER_H #include #include namespace android { // ProducerListener is the interface through which the BufferQueue notifies the // producer of events that the producer may wish to react to. Because the // producer will generally have a mutex that is locked during calls from the // producer to the BufferQueue, these calls from the BufferQueue to the // producer *MUST* be called only when the BufferQueue mutex is NOT locked. class ProducerListener : public virtual RefBase { public: ProducerListener() {} virtual ~ProducerListener() {} // onBufferReleased is called from IGraphicBufferConsumer::releaseBuffer to // notify the producer that a new buffer is free and ready to be dequeued. // // This is called without any lock held and can be called concurrently by // multiple threads. virtual void onBufferReleased() = 0; // Asynchronous }; class IProducerListener : public ProducerListener, public IInterface { public: DECLARE_META_INTERFACE(ProducerListener) }; class BnProducerListener : public BnInterface { public: virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; class DummyProducerListener : public BnProducerListener { public: virtual void onBufferReleased() {} }; } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/ISensorEventConnection.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H #define ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class BitTube; class ISensorEventConnection : public IInterface { public: DECLARE_META_INTERFACE(SensorEventConnection); virtual sp getSensorChannel() const = 0; virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs, nsecs_t maxBatchReportLatencyNs, int reservedFlags) = 0; virtual status_t setEventRate(int handle, nsecs_t ns) = 0; virtual status_t flush() = 0; }; // ---------------------------------------------------------------------------- class BnSensorEventConnection : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_ISENSOR_EVENT_CONNECTION_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/ISensorServer.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_ISENSORSERVER_H #define ANDROID_GUI_ISENSORSERVER_H #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class Sensor; class ISensorEventConnection; class String8; class ISensorServer : public IInterface { public: DECLARE_META_INTERFACE(SensorServer); virtual Vector getSensorList(const String16& opPackageName) = 0; virtual sp createSensorEventConnection(const String8& packageName, int mode, const String16& opPackageName) = 0; virtual int32_t isDataInjectionEnabled() = 0; }; // ---------------------------------------------------------------------------- class BnSensorServer : public BnInterface { public: virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_ISENSORSERVER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/ISurfaceComposer.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_ISURFACE_COMPOSER_H #define ANDROID_GUI_ISURFACE_COMPOSER_H #include #include #include #include #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class ComposerState; class DisplayState; struct DisplayInfo; struct DisplayStatInfo; class IDisplayEventConnection; class IMemoryHeap; class Rect; /* * This class defines the Binder IPC interface for accessing various * SurfaceFlinger features. */ class ISurfaceComposer: public IInterface { public: DECLARE_META_INTERFACE(SurfaceComposer); // flags for setTransactionState() enum { eSynchronous = 0x01, eAnimation = 0x02, }; enum { eDisplayIdMain = 0, eDisplayIdHdmi = 1, #ifdef QTI_BSP eDisplayIdTertiary = 2 #endif }; enum Rotation { eRotateNone = 0, eRotate90 = 1, eRotate180 = 2, eRotate270 = 3 }; /* create connection with surface flinger, requires * ACCESS_SURFACE_FLINGER permission */ virtual sp createConnection() = 0; /* create a graphic buffer allocator */ virtual sp createGraphicBufferAlloc() = 0; /* return an IDisplayEventConnection */ virtual sp createDisplayEventConnection() = 0; /* create a virtual display * requires ACCESS_SURFACE_FLINGER permission. */ virtual sp createDisplay(const String8& displayName, bool secure) = 0; /* destroy a virtual display * requires ACCESS_SURFACE_FLINGER permission. */ virtual void destroyDisplay(const sp& display) = 0; /* get the token for the existing default displays. possible values * for id are eDisplayIdMain and eDisplayIdHdmi. */ virtual sp getBuiltInDisplay(int32_t id) = 0; /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */ virtual void setTransactionState(const Vector& state, const Vector& displays, uint32_t flags) = 0; /* signal that we're done booting. * Requires ACCESS_SURFACE_FLINGER permission */ virtual void bootFinished() = 0; /* verify that an IGraphicBufferProducer was created by SurfaceFlinger. */ virtual bool authenticateSurfaceTexture( const sp& surface) const = 0; /* set display power mode. depending on the mode, it can either trigger * screen on, off or low power mode and wait for it to complete. * requires ACCESS_SURFACE_FLINGER permission. */ virtual void setPowerMode(const sp& display, int mode) = 0; /* returns information for each configuration of the given display * intended to be used to get information about built-in displays */ virtual status_t getDisplayConfigs(const sp& display, Vector* configs) = 0; /* returns display statistics for a given display * intended to be used by the media framework to properly schedule * video frames */ virtual status_t getDisplayStats(const sp& display, DisplayStatInfo* stats) = 0; /* indicates which of the configurations returned by getDisplayInfo is * currently active */ virtual int getActiveConfig(const sp& display) = 0; /* specifies which configuration (of those returned by getDisplayInfo) * should be used */ virtual status_t setActiveConfig(const sp& display, int id) = 0; /* Capture the specified screen. requires READ_FRAME_BUFFER permission * This function will fail if there is a secure window on screen. */ virtual status_t captureScreen(const sp& display, const sp& producer, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform, Rotation rotation = eRotateNone, bool isCpuConsumer = false) = 0; /* Clears the frame statistics for animations. * * Requires the ACCESS_SURFACE_FLINGER permission. */ virtual status_t clearAnimationFrameStats() = 0; /* Gets the frame statistics for animations. * * Requires the ACCESS_SURFACE_FLINGER permission. */ virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0; }; // ---------------------------------------------------------------------------- class BnSurfaceComposer: public BnInterface { public: enum { // Note: BOOT_FINISHED must remain this value, it is called from // Java by ActivityManagerService. BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION, CREATE_CONNECTION, CREATE_GRAPHIC_BUFFER_ALLOC, CREATE_DISPLAY_EVENT_CONNECTION, CREATE_DISPLAY, DESTROY_DISPLAY, GET_BUILT_IN_DISPLAY, SET_TRANSACTION_STATE, AUTHENTICATE_SURFACE, GET_DISPLAY_CONFIGS, GET_ACTIVE_CONFIG, SET_ACTIVE_CONFIG, CONNECT_DISPLAY, CAPTURE_SCREEN, CLEAR_ANIMATION_FRAME_STATS, GET_ANIMATION_FRAME_STATS, SET_POWER_MODE, GET_DISPLAY_STATS, }; virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_ISURFACE_COMPOSER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/ISurfaceComposerClient.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H #define ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H #include #include #include #include #include #include #include namespace android { // ---------------------------------------------------------------------------- class IGraphicBufferProducer; class ISurfaceComposerClient : public IInterface { public: DECLARE_META_INTERFACE(SurfaceComposerClient); // flags for createSurface() enum { // (keep in sync with Surface.java) eHidden = 0x00000004, eDestroyBackbuffer = 0x00000020, eSecure = 0x00000080, eNonPremultiplied = 0x00000100, eOpaque = 0x00000400, eProtectedByApp = 0x00000800, eProtectedByDRM = 0x00001000, eCursorWindow = 0x00002000, eFXSurfaceNormal = 0x00000000, eFXSurfaceBlur = 0x00010000, eFXSurfaceDim = 0x00020000, eFXSurfaceMask = 0x000F0000, }; /* * Requires ACCESS_SURFACE_FLINGER permission */ virtual status_t createSurface( const String8& name, uint32_t w, uint32_t h, PixelFormat format, uint32_t flags, sp* handle, sp* gbp) = 0; /* * Requires ACCESS_SURFACE_FLINGER permission */ virtual status_t destroySurface(const sp& handle) = 0; /* * Requires ACCESS_SURFACE_FLINGER permission */ virtual status_t clearLayerFrameStats(const sp& handle) const = 0; /* * Requires ACCESS_SURFACE_FLINGER permission */ virtual status_t getLayerFrameStats(const sp& handle, FrameStats* outStats) const = 0; }; // ---------------------------------------------------------------------------- class BnSurfaceComposerClient: public BnInterface { public: virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_ISURFACE_COMPOSER_CLIENT_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/Sensor.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SENSOR_H #define ANDROID_GUI_SENSOR_H #include #include #include #include #include #include #include #include // ---------------------------------------------------------------------------- // Concrete types for the NDK struct ASensor { }; // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- class Parcel; // ---------------------------------------------------------------------------- class Sensor : public ASensor, public LightFlattenable { public: enum { TYPE_ACCELEROMETER = ASENSOR_TYPE_ACCELEROMETER, TYPE_MAGNETIC_FIELD = ASENSOR_TYPE_MAGNETIC_FIELD, TYPE_GYROSCOPE = ASENSOR_TYPE_GYROSCOPE, TYPE_LIGHT = ASENSOR_TYPE_LIGHT, TYPE_PROXIMITY = ASENSOR_TYPE_PROXIMITY }; Sensor(); Sensor(struct sensor_t const* hwSensor, int halVersion = 0); ~Sensor(); const String8& getName() const; const String8& getVendor() const; int32_t getHandle() const; int32_t getType() const; float getMinValue() const; float getMaxValue() const; float getResolution() const; float getPowerUsage() const; int32_t getMinDelay() const; nsecs_t getMinDelayNs() const; int32_t getVersion() const; uint32_t getFifoReservedEventCount() const; uint32_t getFifoMaxEventCount() const; const String8& getStringType() const; const String8& getRequiredPermission() const; bool isRequiredPermissionRuntime() const; int32_t getRequiredAppOp() const; int32_t getMaxDelay() const; uint32_t getFlags() const; bool isWakeUpSensor() const; int32_t getReportingMode() const; // LightFlattenable protocol inline bool isFixedSize() const { return false; } size_t getFlattenedSize() const; status_t flatten(void* buffer, size_t size) const; status_t unflatten(void const* buffer, size_t size); private: String8 mName; String8 mVendor; int32_t mHandle; int32_t mType; float mMinValue; float mMaxValue; float mResolution; float mPower; int32_t mMinDelay; int32_t mVersion; uint32_t mFifoReservedEventCount; uint32_t mFifoMaxEventCount; String8 mStringType; String8 mRequiredPermission; bool mRequiredPermissionRuntime = false; int32_t mRequiredAppOp; int32_t mMaxDelay; uint32_t mFlags; static void flattenString8(void*& buffer, size_t& size, const String8& string8); static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8); }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_SENSOR_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/SensorEventQueue.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_SENSOR_EVENT_QUEUE_H #define ANDROID_SENSOR_EVENT_QUEUE_H #include #include #include #include #include #include #include // ---------------------------------------------------------------------------- #define WAKE_UP_SENSOR_EVENT_NEEDS_ACK (1U << 31) struct ALooper; struct ASensorEvent; // Concrete types for the NDK struct ASensorEventQueue { ALooper* looper; }; // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- class ISensorEventConnection; class Sensor; class Looper; // ---------------------------------------------------------------------------- class SensorEventQueue : public ASensorEventQueue, public RefBase { public: enum { MAX_RECEIVE_BUFFER_EVENT_COUNT = 256 }; SensorEventQueue(const sp& connection); virtual ~SensorEventQueue(); virtual void onFirstRef(); int getFd() const; static ssize_t write(const sp& tube, ASensorEvent const* events, size_t numEvents); ssize_t read(ASensorEvent* events, size_t numEvents); status_t waitForEvent() const; status_t wake() const; status_t enableSensor(Sensor const* sensor) const; status_t disableSensor(Sensor const* sensor) const; status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; // these are here only to support SensorManager.java status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs, int reservedFlags) const; status_t disableSensor(int32_t handle) const; status_t flush() const; // Send an ack for every wake_up sensor event that is set to WAKE_UP_SENSOR_EVENT_NEEDS_ACK. void sendAck(const ASensorEvent* events, int count); status_t injectSensorEvent(const ASensorEvent& event); private: sp getLooper() const; sp mSensorEventConnection; sp mSensorChannel; mutable Mutex mLock; mutable sp mLooper; ASensorEvent* mRecBuffer; size_t mAvailable; size_t mConsumed; uint32_t mNumAcksToSend; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_SENSOR_EVENT_QUEUE_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/SensorManager.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SENSOR_MANAGER_H #define ANDROID_GUI_SENSOR_MANAGER_H #include #include #include #include #include #include #include #include #include #include #include #include // ---------------------------------------------------------------------------- // Concrete types for the NDK struct ASensorManager { }; // ---------------------------------------------------------------------------- namespace android { // ---------------------------------------------------------------------------- class ISensorServer; class Sensor; class SensorEventQueue; // ---------------------------------------------------------------------------- class SensorManager : public ASensorManager { public: static SensorManager& getInstanceForPackage(const String16& packageName); ~SensorManager(); ssize_t getSensorList(Sensor const* const** list) const; Sensor const* getDefaultSensor(int type); sp createEventQueue(String8 packageName = String8(""), int mode = 0); bool isDataInjectionEnabled(); private: // DeathRecipient interface void sensorManagerDied(); SensorManager(const String16& opPackageName); status_t assertStateLocked() const; private: static Mutex sLock; static std::map sPackageInstances; mutable Mutex mLock; mutable sp mSensorServer; mutable Sensor const** mSensorList; mutable Vector mSensors; mutable sp mDeathObserver; const String16 mOpPackageName; }; // ---------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_SENSOR_MANAGER_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/StreamSplitter.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_STREAMSPLITTER_H #define ANDROID_GUI_STREAMSPLITTER_H #include #include #include #include #include #include namespace android { class GraphicBuffer; class IGraphicBufferConsumer; class IGraphicBufferProducer; // StreamSplitter is an autonomous class that manages one input BufferQueue // and multiple output BufferQueues. By using the buffer attach and detach logic // in BufferQueue, it is able to present the illusion of a single split // BufferQueue, where each buffer queued to the input is available to be // acquired by each of the outputs, and is able to be dequeued by the input // again only once all of the outputs have released it. class StreamSplitter : public BnConsumerListener { public: // createSplitter creates a new splitter, outSplitter, using inputQueue as // the input BufferQueue. Output BufferQueues must be added using addOutput // before queueing any buffers to the input. // // A return value other than NO_ERROR means that an error has occurred and // outSplitter has not been modified. BAD_VALUE is returned if inputQueue or // outSplitter is NULL. See IGraphicBufferConsumer::consumerConnect for // explanations of other error codes. static status_t createSplitter(const sp& inputQueue, sp* outSplitter); // addOutput adds an output BufferQueue to the splitter. The splitter // connects to outputQueue as a CPU producer, and any buffers queued // to the input will be queued to each output. It is assumed that all of the // outputs are added before any buffers are queued on the input. If any // output is abandoned by its consumer, the splitter will abandon its input // queue (see onAbandoned). // // A return value other than NO_ERROR means that an error has occurred and // outputQueue has not been added to the splitter. BAD_VALUE is returned if // outputQueue is NULL. See IGraphicBufferProducer::connect for explanations // of other error codes. status_t addOutput(const sp& outputQueue); // setName sets the consumer name of the input queue void setName(const String8& name); private: // From IConsumerListener // // During this callback, we store some tracking information, detach the // buffer from the input, and attach it to each of the outputs. This call // can block if there are too many outstanding buffers. If it blocks, it // will resume when onBufferReleasedByOutput releases a buffer back to the // input. virtual void onFrameAvailable(const BufferItem& item); // From IConsumerListener // We don't care about released buffers because we detach each buffer as // soon as we acquire it. See the comment for onBufferReleased below for // some clarifying notes about the name. virtual void onBuffersReleased() {} // From IConsumerListener // We don't care about sideband streams, since we won't be splitting them virtual void onSidebandStreamChanged() {} // This is the implementation of the onBufferReleased callback from // IProducerListener. It gets called from an OutputListener (see below), and // 'from' is which producer interface from which the callback was received. // // During this callback, we detach the buffer from the output queue that // generated the callback, update our state tracking to see if this is the // last output releasing the buffer, and if so, release it to the input. // If we release the buffer to the input, we allow a blocked // onFrameAvailable call to proceed. void onBufferReleasedByOutput(const sp& from); // When this is called, the splitter disconnects from (i.e., abandons) its // input queue and signals any waiting onFrameAvailable calls to wake up. // It still processes callbacks from other outputs, but only detaches their // buffers so they can continue operating until they run out of buffers to // acquire. This must be called with mMutex locked. void onAbandonedLocked(); // This is a thin wrapper class that lets us determine which BufferQueue // the IProducerListener::onBufferReleased callback is associated with. We // create one of these per output BufferQueue, and then pass the producer // into onBufferReleasedByOutput above. class OutputListener : public BnProducerListener, public IBinder::DeathRecipient { public: OutputListener(const sp& splitter, const sp& output); virtual ~OutputListener(); // From IProducerListener virtual void onBufferReleased(); // From IBinder::DeathRecipient virtual void binderDied(const wp& who); private: sp mSplitter; sp mOutput; }; class BufferTracker : public LightRefBase { public: BufferTracker(const sp& buffer); const sp& getBuffer() const { return mBuffer; } const sp& getMergedFence() const { return mMergedFence; } void mergeFence(const sp& with); // Returns the new value // Only called while mMutex is held size_t incrementReleaseCountLocked() { return ++mReleaseCount; } private: // Only destroy through LightRefBase friend LightRefBase; ~BufferTracker(); // Disallow copying BufferTracker(const BufferTracker& other); BufferTracker& operator=(const BufferTracker& other); sp mBuffer; // One instance that holds this native handle sp mMergedFence; size_t mReleaseCount; }; // Only called from createSplitter StreamSplitter(const sp& inputQueue); // Must be accessed through RefBase virtual ~StreamSplitter(); static const int MAX_OUTSTANDING_BUFFERS = 2; // mIsAbandoned is set to true when an output dies. Once the StreamSplitter // has been abandoned, it will continue to detach buffers from other // outputs, but it will disconnect from the input and not attempt to // communicate with it further. bool mIsAbandoned; Mutex mMutex; Condition mReleaseCondition; int mOutstandingBuffers; sp mInput; Vector > mOutputs; // Map of GraphicBuffer IDs (GraphicBuffer::getId()) to buffer tracking // objects (which are mostly for counting how many outputs have released the // buffer, but also contain merged release fences). KeyedVector > mBuffers; }; } // namespace android #endif ================================================ FILE: phonelibs/android_frameworks_native/include/gui/Surface.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SURFACE_H #define ANDROID_GUI_SURFACE_H #include #include #include #include #include #include #include struct ANativeWindow_Buffer; namespace android { /* * An implementation of ANativeWindow that feeds graphics buffers into a * BufferQueue. * * This is typically used by programs that want to render frames through * some means (maybe OpenGL, a software renderer, or a hardware decoder) * and have the frames they create forwarded to SurfaceFlinger for * compositing. For example, a video decoder could render a frame and call * eglSwapBuffers(), which invokes ANativeWindow callbacks defined by * Surface. Surface then forwards the buffers through Binder IPC * to the BufferQueue's producer interface, providing the new frame to a * consumer such as GLConsumer. */ class Surface : public ANativeObjectBase { public: /* * creates a Surface from the given IGraphicBufferProducer (which concrete * implementation is a BufferQueue). * * Surface is mainly state-less while it's disconnected, it can be * viewed as a glorified IGraphicBufferProducer holder. It's therefore * safe to create other Surfaces from the same IGraphicBufferProducer. * * However, once a Surface is connected, it'll prevent other Surfaces * referring to the same IGraphicBufferProducer to become connected and * therefore prevent them to be used as actual producers of buffers. * * the controlledByApp flag indicates that this Surface (producer) is * controlled by the application. This flag is used at connect time. */ Surface(const sp& bufferProducer, bool controlledByApp = false); /* getIGraphicBufferProducer() returns the IGraphicBufferProducer this * Surface was created with. Usually it's an error to use the * IGraphicBufferProducer while the Surface is connected. */ sp getIGraphicBufferProducer() const; /* convenience function to check that the given surface is non NULL as * well as its IGraphicBufferProducer */ static bool isValid(const sp& surface) { return surface != NULL && surface->getIGraphicBufferProducer() != NULL; } /* Attaches a sideband buffer stream to the Surface's IGraphicBufferProducer. * * A sideband stream is a device-specific mechanism for passing buffers * from the producer to the consumer without using dequeueBuffer/ * queueBuffer. If a sideband stream is present, the consumer can choose * whether to acquire buffers from the sideband stream or from the queued * buffers. * * Passing NULL or a different stream handle will detach the previous * handle if any. */ void setSidebandStream(const sp& stream); /* Allocates buffers based on the current dimensions/format. * * This function will allocate up to the maximum number of buffers * permitted by the current BufferQueue configuration. It will use the * default format and dimensions. This is most useful to avoid an allocation * delay during dequeueBuffer. If there are already the maximum number of * buffers allocated, this function has no effect. */ void allocateBuffers(); /* Sets the generation number on the IGraphicBufferProducer and updates the * generation number on any buffers attached to the Surface after this call. * See IGBP::setGenerationNumber for more information. */ status_t setGenerationNumber(uint32_t generationNumber); // See IGraphicBufferProducer::getConsumerName String8 getConsumerName() const; protected: virtual ~Surface(); private: // can't be copied Surface& operator = (const Surface& rhs); Surface(const Surface& rhs); // ANativeWindow hooks static int hook_cancelBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int hook_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); static int hook_perform(ANativeWindow* window, int operation, ...); static int hook_query(const ANativeWindow* window, int what, int* value); static int hook_queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int hook_setSwapInterval(ANativeWindow* window, int interval); static int hook_cancelBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); static int hook_dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer); static int hook_lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); static int hook_queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); int dispatchConnect(va_list args); int dispatchDisconnect(va_list args); int dispatchSetBufferCount(va_list args); int dispatchSetBuffersGeometry(va_list args); int dispatchSetBuffersDimensions(va_list args); int dispatchSetBuffersUserDimensions(va_list args); int dispatchSetBuffersFormat(va_list args); int dispatchSetScalingMode(va_list args); int dispatchSetBuffersTransform(va_list args); int dispatchSetBuffersStickyTransform(va_list args); int dispatchSetBuffersTimestamp(va_list args); int dispatchSetCrop(va_list args); int dispatchSetPostTransformCrop(va_list args); int dispatchSetUsage(va_list args); int dispatchLock(va_list args); int dispatchUnlockAndPost(va_list args); int dispatchSetSidebandStream(va_list args); int dispatchSetBuffersDataSpace(va_list args); int dispatchSetSurfaceDamage(va_list args); protected: virtual int dequeueBuffer(ANativeWindowBuffer** buffer, int* fenceFd); virtual int cancelBuffer(ANativeWindowBuffer* buffer, int fenceFd); virtual int queueBuffer(ANativeWindowBuffer* buffer, int fenceFd); virtual int perform(int operation, va_list args); virtual int query(int what, int* value) const; virtual int setSwapInterval(int interval); virtual int lockBuffer_DEPRECATED(ANativeWindowBuffer* buffer); virtual int connect(int api); virtual int disconnect(int api); virtual int setBufferCount(int bufferCount); virtual int setBuffersDimensions(uint32_t width, uint32_t height); virtual int setBuffersUserDimensions(uint32_t width, uint32_t height); virtual int setBuffersFormat(PixelFormat format); virtual int setScalingMode(int mode); virtual int setBuffersTransform(uint32_t transform); virtual int setBuffersStickyTransform(uint32_t transform); virtual int setBuffersTimestamp(int64_t timestamp); virtual int setBuffersDataSpace(android_dataspace dataSpace); virtual int setCrop(Rect const* rect); virtual int setUsage(uint32_t reqUsage); virtual void setSurfaceDamage(android_native_rect_t* rects, size_t numRects); public: virtual int lock(ANativeWindow_Buffer* outBuffer, ARect* inOutDirtyBounds); virtual int unlockAndPost(); virtual int connect(int api, const sp& listener); virtual int detachNextBuffer(sp* outBuffer, sp* outFence); virtual int attachBuffer(ANativeWindowBuffer*); protected: enum { NUM_BUFFER_SLOTS = BufferQueue::NUM_BUFFER_SLOTS }; enum { DEFAULT_FORMAT = PIXEL_FORMAT_RGBA_8888 }; private: void freeAllBuffers(); int getSlotFromBufferLocked(android_native_buffer_t* buffer) const; struct BufferSlot { sp buffer; Region dirtyRegion; }; // mSurfaceTexture is the interface to the surface texture server. All // operations on the surface texture client ultimately translate into // interactions with the server using this interface. // TODO: rename to mBufferProducer sp mGraphicBufferProducer; // mSlots stores the buffers that have been allocated for each buffer slot. // It is initialized to null pointers, and gets filled in with the result of // IGraphicBufferProducer::requestBuffer when the client dequeues a buffer from a // slot that has not yet been used. The buffer allocated to a slot will also // be replaced if the requested buffer usage or geometry differs from that // of the buffer allocated to a slot. BufferSlot mSlots[NUM_BUFFER_SLOTS]; // mReqWidth is the buffer width that will be requested at the next dequeue // operation. It is initialized to 1. uint32_t mReqWidth; // mReqHeight is the buffer height that will be requested at the next // dequeue operation. It is initialized to 1. uint32_t mReqHeight; // mReqFormat is the buffer pixel format that will be requested at the next // deuque operation. It is initialized to PIXEL_FORMAT_RGBA_8888. PixelFormat mReqFormat; // mReqUsage is the set of buffer usage flags that will be requested // at the next deuque operation. It is initialized to 0. uint32_t mReqUsage; // mTimestamp is the timestamp that will be used for the next buffer queue // operation. It defaults to NATIVE_WINDOW_TIMESTAMP_AUTO, which means that // a timestamp is auto-generated when queueBuffer is called. int64_t mTimestamp; // mDataSpace is the buffer dataSpace that will be used for the next buffer // queue operation. It defaults to HAL_DATASPACE_UNKNOWN, which // means that the buffer contains some type of color data. android_dataspace mDataSpace; // mCrop is the crop rectangle that will be used for the next buffer // that gets queued. It is set by calling setCrop. Rect mCrop; // mScalingMode is the scaling mode that will be used for the next // buffers that get queued. It is set by calling setScalingMode. int mScalingMode; // mTransform is the transform identifier that will be used for the next // buffer that gets queued. It is set by calling setTransform. uint32_t mTransform; // mStickyTransform is a transform that is applied on top of mTransform // in each buffer that is queued. This is typically used to force the // compositor to apply a transform, and will prevent the transform hint // from being set by the compositor. uint32_t mStickyTransform; // mDefaultWidth is default width of the buffers, regardless of the // native_window_set_buffers_dimensions call. uint32_t mDefaultWidth; // mDefaultHeight is default height of the buffers, regardless of the // native_window_set_buffers_dimensions call. uint32_t mDefaultHeight; // mUserWidth, if non-zero, is an application-specified override // of mDefaultWidth. This is lower priority than the width set by // native_window_set_buffers_dimensions. uint32_t mUserWidth; // mUserHeight, if non-zero, is an application-specified override // of mDefaultHeight. This is lower priority than the height set // by native_window_set_buffers_dimensions. uint32_t mUserHeight; // mTransformHint is the transform probably applied to buffers of this // window. this is only a hint, actual transform may differ. uint32_t mTransformHint; // mProducerControlledByApp whether this buffer producer is controlled // by the application bool mProducerControlledByApp; // mSwapIntervalZero set if we should drop buffers at queue() time to // achieve an asynchronous swap interval bool mSwapIntervalZero; // mConsumerRunningBehind whether the consumer is running more than // one buffer behind the producer. mutable bool mConsumerRunningBehind; // mMutex is the mutex used to prevent concurrent access to the member // variables of Surface objects. It must be locked whenever the // member variables are accessed. mutable Mutex mMutex; // must be used from the lock/unlock thread sp mLockedBuffer; sp mPostedBuffer; bool mConnectedToCpu; // When a CPU producer is attached, this reflects the region that the // producer wished to update as well as whether the Surface was able to copy // the previous buffer back to allow a partial update. // // When a non-CPU producer is attached, this reflects the surface damage // (the change since the previous frame) passed in by the producer. Region mDirtyRegion; // Stores the current generation number. See setGenerationNumber and // IGraphicBufferProducer::setGenerationNumber for more information. uint32_t mGenerationNumber; }; }; // namespace android #endif // ANDROID_GUI_SURFACE_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/SurfaceComposerClient.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H #define ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H #include #include #include #include #include #include #include #include #include #include #include #include namespace android { // --------------------------------------------------------------------------- class DisplayInfo; class Composer; class ISurfaceComposerClient; class IGraphicBufferProducer; class Region; // --------------------------------------------------------------------------- class SurfaceComposerClient : public RefBase { friend class Composer; public: SurfaceComposerClient(); virtual ~SurfaceComposerClient(); // Always make sure we could initialize status_t initCheck() const; // Return the connection of this client sp connection() const; // Forcibly remove connection before all references have gone away. void dispose(); // callback when the composer is dies status_t linkToComposerDeath(const sp& recipient, void* cookie = NULL, uint32_t flags = 0); // Get a list of supported configurations for a given display static status_t getDisplayConfigs(const sp& display, Vector* configs); // Get the DisplayInfo for the currently-active configuration static status_t getDisplayInfo(const sp& display, DisplayInfo* info); // Get the index of the current active configuration (relative to the list // returned by getDisplayInfo) static int getActiveConfig(const sp& display); // Set a new active configuration using an index relative to the list // returned by getDisplayInfo static status_t setActiveConfig(const sp& display, int id); /* Triggers screen on/off or low power mode and waits for it to complete */ static void setDisplayPowerMode(const sp& display, int mode); // ------------------------------------------------------------------------ // surface creation / destruction //! Create a surface sp createSurface( const String8& name,// name of the surface uint32_t w, // width in pixel uint32_t h, // height in pixel PixelFormat format, // pixel-format desired uint32_t flags = 0 // usage flags ); //! Create a virtual display static sp createDisplay(const String8& displayName, bool secure); //! Destroy a virtual display static void destroyDisplay(const sp& display); //! Get the token for the existing default displays. //! Possible values for id are eDisplayIdMain and eDisplayIdHdmi. static sp getBuiltInDisplay(int32_t id); // ------------------------------------------------------------------------ // Composer parameters // All composer parameters must be changed within a transaction // several surfaces can be updated in one transaction, all changes are // committed at once when the transaction is closed. // closeGlobalTransaction() requires an IPC with the server. //! Open a composer transaction on all active SurfaceComposerClients. static void openGlobalTransaction(); //! Close a composer transaction on all active SurfaceComposerClients. static void closeGlobalTransaction(bool synchronous = false); //! Flag the currently open transaction as an animation transaction. static void setAnimationTransaction(); status_t hide(const sp& id); status_t show(const sp& id); status_t setFlags(const sp& id, uint32_t flags, uint32_t mask); status_t setTransparentRegionHint(const sp& id, const Region& transparent); status_t setLayer(const sp& id, uint32_t layer); status_t setAlpha(const sp& id, float alpha=1.0f); status_t setMatrix(const sp& id, float dsdx, float dtdx, float dsdy, float dtdy); status_t setPosition(const sp& id, float x, float y); status_t setSize(const sp& id, uint32_t w, uint32_t h); status_t setCrop(const sp& id, const Rect& crop); status_t setLayerStack(const sp& id, uint32_t layerStack); status_t destroySurface(const sp& id); status_t clearLayerFrameStats(const sp& token) const; status_t getLayerFrameStats(const sp& token, FrameStats* outStats) const; static status_t clearAnimationFrameStats(); static status_t getAnimationFrameStats(FrameStats* outStats); static void setDisplaySurface(const sp& token, const sp& bufferProducer); static void setDisplayLayerStack(const sp& token, uint32_t layerStack); static void setDisplaySize(const sp& token, uint32_t width, uint32_t height); /* setDisplayProjection() defines the projection of layer stacks * to a given display. * * - orientation defines the display's orientation. * - layerStackRect defines which area of the window manager coordinate * space will be used. * - displayRect defines where on the display will layerStackRect be * mapped to. displayRect is specified post-orientation, that is * it uses the orientation seen by the end-user. */ static void setDisplayProjection(const sp& token, uint32_t orientation, const Rect& layerStackRect, const Rect& displayRect); status_t setBlur(const sp& id, float blur); status_t setBlurMaskSurface(const sp& id, const sp& maskSurfaceId); status_t setBlurMaskSampling(const sp& id, uint32_t blurMaskSampling); status_t setBlurMaskAlphaThreshold(const sp& id, float alpha); private: virtual void onFirstRef(); Composer& getComposer(); mutable Mutex mLock; status_t mStatus; sp mClient; Composer& mComposer; }; // --------------------------------------------------------------------------- class ScreenshotClient { public: // if cropping isn't required, callers may pass in a default Rect, e.g.: // capture(display, producer, Rect(), reqWidth, ...); static status_t capture( const sp& display, const sp& producer, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform); private: mutable sp mCpuConsumer; mutable sp mProducer; CpuConsumer::LockedBuffer mBuffer; bool mHaveBuffer; public: ScreenshotClient(); ~ScreenshotClient(); // frees the previous screenshot and captures a new one // if cropping isn't required, callers may pass in a default Rect, e.g.: // update(display, Rect(), useIdentityTransform); status_t update(const sp& display, Rect sourceCrop, bool useIdentityTransform); status_t update(const sp& display, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, bool useIdentityTransform); status_t update(const sp& display, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform); status_t update(const sp& display, Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, uint32_t minLayerZ, uint32_t maxLayerZ, bool useIdentityTransform, uint32_t rotation); sp getCpuConsumer() const; // release memory occupied by the screenshot void release(); // pixels are valid until this object is freed or // release() or update() is called void const* getPixels() const; uint32_t getWidth() const; uint32_t getHeight() const; PixelFormat getFormat() const; uint32_t getStride() const; // size of allocated memory in bytes size_t getSize() const; }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_GUI_SURFACE_COMPOSER_CLIENT_H ================================================ FILE: phonelibs/android_frameworks_native/include/gui/SurfaceControl.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GUI_SURFACE_CONTROL_H #define ANDROID_GUI_SURFACE_CONTROL_H #include #include #include #include #include #include #include #include #include namespace android { // --------------------------------------------------------------------------- class IGraphicBufferProducer; class Surface; class SurfaceComposerClient; // --------------------------------------------------------------------------- class SurfaceControl : public RefBase { public: static bool isValid(const sp& surface) { return (surface != 0) && surface->isValid(); } bool isValid() { return mHandle!=0 && mClient!=0; } static bool isSameSurface( const sp& lhs, const sp& rhs); // release surface data from java void clear(); status_t setLayerStack(uint32_t layerStack); status_t setLayer(uint32_t layer); status_t setPosition(float x, float y); status_t setSize(uint32_t w, uint32_t h); status_t hide(); status_t show(); status_t setFlags(uint32_t flags, uint32_t mask); status_t setTransparentRegionHint(const Region& transparent); status_t setAlpha(float alpha=1.0f); status_t setMatrix(float dsdx, float dtdx, float dsdy, float dtdy); status_t setCrop(const Rect& crop); static status_t writeSurfaceToParcel( const sp& control, Parcel* parcel); sp getSurface() const; status_t clearLayerFrameStats() const; status_t getLayerFrameStats(FrameStats* outStats) const; status_t setBlur(float blur = 0); status_t setBlurMaskSurface(const sp& maskSurface); status_t setBlurMaskSampling(uint32_t blurMaskSampling); status_t setBlurMaskAlphaThreshold(float alpha); private: // can't be copied SurfaceControl& operator = (SurfaceControl& rhs); SurfaceControl(const SurfaceControl& rhs); friend class SurfaceComposerClient; friend class Surface; SurfaceControl( const sp& client, const sp& handle, const sp& gbp); ~SurfaceControl(); status_t validate() const; void destroy(); sp mClient; sp mHandle; sp mGraphicBufferProducer; mutable Mutex mLock; mutable sp mSurfaceData; }; }; // namespace android #endif // ANDROID_GUI_SURFACE_CONTROL_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/ANativeObjectBase.h ================================================ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_ANDROID_NATIVES_H #define ANDROID_ANDROID_NATIVES_H #include #include #include #include // --------------------------------------------------------------------------- /* FIXME: this is legacy for pixmaps */ typedef struct egl_native_pixmap_t { int32_t version; /* must be 32 */ int32_t width; int32_t height; int32_t stride; uint8_t* data; uint8_t format; uint8_t rfu[3]; union { uint32_t compressedFormat; int32_t vstride; }; int32_t reserved; } egl_native_pixmap_t; /*****************************************************************************/ #ifdef __cplusplus #include namespace android { /* * This helper class turns a ANativeXXX object type into a C++ * reference-counted object; with proper type conversions. */ template class ANativeObjectBase : public NATIVE_TYPE, public REF { public: // Disambiguate between the incStrong in REF and NATIVE_TYPE void incStrong(const void* id) const { REF::incStrong(id); } void decStrong(const void* id) const { REF::decStrong(id); } protected: typedef ANativeObjectBase BASE; ANativeObjectBase() : NATIVE_TYPE(), REF() { NATIVE_TYPE::common.incRef = incRef; NATIVE_TYPE::common.decRef = decRef; } static inline TYPE* getSelf(NATIVE_TYPE* self) { return static_cast(self); } static inline TYPE const* getSelf(NATIVE_TYPE const* self) { return static_cast(self); } static inline TYPE* getSelf(android_native_base_t* base) { return getSelf(reinterpret_cast(base)); } static inline TYPE const * getSelf(android_native_base_t const* base) { return getSelf(reinterpret_cast(base)); } static void incRef(android_native_base_t* base) { ANativeObjectBase* self = getSelf(base); self->incStrong(self); } static void decRef(android_native_base_t* base) { ANativeObjectBase* self = getSelf(base); self->decStrong(self); } }; } // namespace android #endif // __cplusplus /*****************************************************************************/ #endif /* ANDROID_ANDROID_NATIVES_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/DisplayInfo.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_DISPLAY_INFO_H #define ANDROID_UI_DISPLAY_INFO_H #include #include #include #include namespace android { struct DisplayInfo { uint32_t w; uint32_t h; float xdpi; float ydpi; float fps; float density; uint8_t orientation; bool secure; nsecs_t appVsyncOffset; nsecs_t presentationDeadline; int colorTransform; }; /* Display orientations as defined in Surface.java and ISurfaceComposer.h. */ enum { DISPLAY_ORIENTATION_0 = 0, DISPLAY_ORIENTATION_90 = 1, DISPLAY_ORIENTATION_180 = 2, DISPLAY_ORIENTATION_270 = 3 }; }; // namespace android #endif // ANDROID_COMPOSER_DISPLAY_INFO_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/DisplayStatInfo.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_DISPLAY_STAT_INFO_H #define ANDROID_UI_DISPLAY_STAT_INFO_H #include namespace android { struct DisplayStatInfo { nsecs_t vsyncTime; nsecs_t vsyncPeriod; }; }; // namespace android #endif // ANDROID_COMPOSER_DISPLAY_STAT_INFO_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/Fence.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_FENCE_H #define ANDROID_FENCE_H #include #include #include #include #include #include #include #include struct ANativeWindowBuffer; namespace android { // =========================================================================== // Fence // =========================================================================== class Fence : public LightRefBase, public Flattenable { public: static const sp NO_FENCE; // TIMEOUT_NEVER may be passed to the wait method to indicate that it // should wait indefinitely for the fence to signal. enum { TIMEOUT_NEVER = -1 }; // Construct a new Fence object with an invalid file descriptor. This // should be done when the Fence object will be set up by unflattening // serialized data. Fence(); // Construct a new Fence object to manage a given fence file descriptor. // When the new Fence object is destructed the file descriptor will be // closed. Fence(int fenceFd); // Check whether the Fence has an open fence file descriptor. Most Fence // methods treat an invalid file descriptor just like a valid fence that // is already signalled, so using this is usually not necessary. bool isValid() const { return mFenceFd != -1; } // wait waits for up to timeout milliseconds for the fence to signal. If // the fence signals then NO_ERROR is returned. If the timeout expires // before the fence signals then -ETIME is returned. A timeout of // TIMEOUT_NEVER may be used to indicate that the call should wait // indefinitely for the fence to signal. status_t wait(int timeout); // waitForever is a convenience function for waiting forever for a fence to // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the // system log and fence state to the kernel log if the wait lasts longer // than a warning timeout. // The logname argument should be a string identifying // the caller and will be included in the log message. status_t waitForever(const char* logname); // merge combines two Fence objects, creating a new Fence object that // becomes signaled when both f1 and f2 are signaled (even if f1 or f2 is // destroyed before it becomes signaled). The name argument specifies the // human-readable name to associated with the new Fence object. static sp merge(const String8& name, const sp& f1, const sp& f2); // Return a duplicate of the fence file descriptor. The caller is // responsible for closing the returned file descriptor. On error, -1 will // be returned and errno will indicate the problem. int dup() const; // getSignalTime returns the system monotonic clock time at which the // fence transitioned to the signaled state. If the fence is not signaled // then INT64_MAX is returned. If the fence is invalid or if an error // occurs then -1 is returned. nsecs_t getSignalTime() const; // Flattenable interface size_t getFlattenedSize() const; size_t getFdCount() const; status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); private: // Only allow instantiation using ref counting. friend class LightRefBase; ~Fence(); // Disallow copying Fence(const Fence& rhs); Fence& operator = (const Fence& rhs); const Fence& operator = (const Fence& rhs) const; int mFenceFd; }; }; // namespace android #endif // ANDROID_FENCE_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/FrameStats.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_FRAME_STATS_H #define ANDROID_UI_FRAME_STATS_H #include #include #include namespace android { class FrameStats : public LightFlattenable { public: FrameStats() : refreshPeriodNano(0) {}; /* * Approximate refresh time, in nanoseconds. */ nsecs_t refreshPeriodNano; /* * The times in nanoseconds for when the frame contents were posted by the producer (e.g. * the application). They are either explicitly set or defaulted to the time when * Surface::queueBuffer() was called. */ Vector desiredPresentTimesNano; /* * The times in milliseconds for when the frame contents were presented on the screen. */ Vector actualPresentTimesNano; /* * The times in nanoseconds for when the frame contents were ready to be presented. Note that * a frame can be posted and still it contents being rendered asynchronously in GL. In such a * case these are the times when the frame contents were completely rendered (i.e. their fences * signaled). */ Vector frameReadyTimesNano; // LightFlattenable bool isFixedSize() const; size_t getFlattenedSize() const; status_t flatten(void* buffer, size_t size) const; status_t unflatten(void const* buffer, size_t size); }; }; // namespace android #endif // ANDROID_UI_FRAME_STATS_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/FramebufferNativeWindow.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef INCLUDED_FROM_FRAMEBUFFER_NATIVE_WINDOW_CPP #warning "FramebufferNativeWindow is deprecated" #endif #ifndef ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H #define ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H #include #include #include #include #include #include #include #define MIN_NUM_FRAME_BUFFERS 2 #define MAX_NUM_FRAME_BUFFERS 3 extern "C" EGLNativeWindowType android_createDisplaySurface(void); // --------------------------------------------------------------------------- namespace android { // --------------------------------------------------------------------------- class Surface; class NativeBuffer; // --------------------------------------------------------------------------- class FramebufferNativeWindow : public ANativeObjectBase< ANativeWindow, FramebufferNativeWindow, LightRefBase > { public: FramebufferNativeWindow(); framebuffer_device_t const * getDevice() const { return fbDev; } bool isUpdateOnDemand() const { return mUpdateOnDemand; } status_t setUpdateRectangle(const Rect& updateRect); status_t compositionComplete(); void dump(String8& result); // for debugging only int getCurrentBufferIndex() const; private: friend class LightRefBase; ~FramebufferNativeWindow(); // this class cannot be overloaded static int setSwapInterval(ANativeWindow* window, int interval); static int dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer, int* fenceFd); static int queueBuffer(ANativeWindow* window, ANativeWindowBuffer* buffer, int fenceFd); static int query(const ANativeWindow* window, int what, int* value); static int perform(ANativeWindow* window, int operation, ...); static int dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer); static int queueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); static int lockBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer* buffer); framebuffer_device_t* fbDev; alloc_device_t* grDev; sp buffers[MAX_NUM_FRAME_BUFFERS]; sp front; mutable Mutex mutex; Condition mCondition; int32_t mNumBuffers; int32_t mNumFreeBuffers; int32_t mBufferHead; int32_t mCurrentBufferIndex; bool mUpdateOnDemand; }; // --------------------------------------------------------------------------- }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_FRAMEBUFFER_NATIVE_WINDOW_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/GraphicBuffer.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GRAPHIC_BUFFER_H #define ANDROID_GRAPHIC_BUFFER_H #include #include #include #include #include #include #include struct ANativeWindowBuffer; namespace android { class GraphicBufferMapper; // =========================================================================== // GraphicBuffer // =========================================================================== class GraphicBuffer : public ANativeObjectBase< ANativeWindowBuffer, GraphicBuffer, RefBase >, public Flattenable { friend class Flattenable; public: enum { USAGE_SW_READ_NEVER = GRALLOC_USAGE_SW_READ_NEVER, USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY, USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN, USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK, USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER, USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY, USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN, USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK, USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK, USAGE_PROTECTED = GRALLOC_USAGE_PROTECTED, USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, USAGE_HW_2D = GRALLOC_USAGE_HW_2D, USAGE_HW_COMPOSER = GRALLOC_USAGE_HW_COMPOSER, USAGE_HW_VIDEO_ENCODER = GRALLOC_USAGE_HW_VIDEO_ENCODER, USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK, USAGE_CURSOR = GRALLOC_USAGE_CURSOR, }; GraphicBuffer(); // creates w * h buffer GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage); // create a buffer from an existing handle GraphicBuffer(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage, uint32_t inStride, native_handle_t* inHandle, bool keepOwnership); // create a buffer from an existing ANativeWindowBuffer GraphicBuffer(ANativeWindowBuffer* buffer, bool keepOwnership); // return status status_t initCheck() const; uint32_t getWidth() const { return static_cast(width); } uint32_t getHeight() const { return static_cast(height); } uint32_t getStride() const { return static_cast(stride); } uint32_t getUsage() const { return static_cast(usage); } PixelFormat getPixelFormat() const { return format; } Rect getBounds() const { return Rect(width, height); } uint64_t getId() const { return mId; } uint32_t getGenerationNumber() const { return mGenerationNumber; } void setGenerationNumber(uint32_t generation) { mGenerationNumber = generation; } status_t reallocate(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage); bool needsReallocation(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage); status_t lock(uint32_t inUsage, void** vaddr); status_t lock(uint32_t inUsage, const Rect& rect, void** vaddr); // For HAL_PIXEL_FORMAT_YCbCr_420_888 status_t lockYCbCr(uint32_t inUsage, android_ycbcr *ycbcr); status_t lockYCbCr(uint32_t inUsage, const Rect& rect, android_ycbcr *ycbcr); status_t unlock(); status_t lockAsync(uint32_t inUsage, void** vaddr, int fenceFd); status_t lockAsync(uint32_t inUsage, const Rect& rect, void** vaddr, int fenceFd); status_t lockAsyncYCbCr(uint32_t inUsage, android_ycbcr *ycbcr, int fenceFd); status_t lockAsyncYCbCr(uint32_t inUsage, const Rect& rect, android_ycbcr *ycbcr, int fenceFd); status_t unlockAsync(int *fenceFd); ANativeWindowBuffer* getNativeBuffer() const; // for debugging static void dumpAllocationsToSystemLog(); // Flattenable protocol size_t getFlattenedSize() const; size_t getFdCount() const; status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); private: ~GraphicBuffer(); enum { ownNone = 0, ownHandle = 1, ownData = 2, }; inline const GraphicBufferMapper& getBufferMapper() const { return mBufferMapper; } inline GraphicBufferMapper& getBufferMapper() { return mBufferMapper; } uint8_t mOwner; private: friend class Surface; friend class BpSurface; friend class BnSurface; friend class LightRefBase; GraphicBuffer(const GraphicBuffer& rhs); GraphicBuffer& operator = (const GraphicBuffer& rhs); const GraphicBuffer& operator = (const GraphicBuffer& rhs) const; status_t initSize(uint32_t inWidth, uint32_t inHeight, PixelFormat inFormat, uint32_t inUsage); void free_handle(); GraphicBufferMapper& mBufferMapper; ssize_t mInitCheck; // If we're wrapping another buffer then this reference will make sure it // doesn't get freed. sp mWrappedBuffer; uint64_t mId; // Stores the generation number of this buffer. If this number does not // match the BufferQueue's internal generation number (set through // IGBP::setGenerationNumber), attempts to attach the buffer will fail. uint32_t mGenerationNumber; }; }; // namespace android #endif // ANDROID_GRAPHIC_BUFFER_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/GraphicBufferAllocator.h ================================================ /* ** ** Copyright 2009, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifndef ANDROID_BUFFER_ALLOCATOR_H #define ANDROID_BUFFER_ALLOCATOR_H #include #include #include #include #include #include #include #include namespace android { // --------------------------------------------------------------------------- class String8; class GraphicBufferAllocator : public Singleton { public: enum { USAGE_SW_READ_NEVER = GRALLOC_USAGE_SW_READ_NEVER, USAGE_SW_READ_RARELY = GRALLOC_USAGE_SW_READ_RARELY, USAGE_SW_READ_OFTEN = GRALLOC_USAGE_SW_READ_OFTEN, USAGE_SW_READ_MASK = GRALLOC_USAGE_SW_READ_MASK, USAGE_SW_WRITE_NEVER = GRALLOC_USAGE_SW_WRITE_NEVER, USAGE_SW_WRITE_RARELY = GRALLOC_USAGE_SW_WRITE_RARELY, USAGE_SW_WRITE_OFTEN = GRALLOC_USAGE_SW_WRITE_OFTEN, USAGE_SW_WRITE_MASK = GRALLOC_USAGE_SW_WRITE_MASK, USAGE_SOFTWARE_MASK = USAGE_SW_READ_MASK|USAGE_SW_WRITE_MASK, USAGE_HW_TEXTURE = GRALLOC_USAGE_HW_TEXTURE, USAGE_HW_RENDER = GRALLOC_USAGE_HW_RENDER, USAGE_HW_2D = GRALLOC_USAGE_HW_2D, USAGE_HW_MASK = GRALLOC_USAGE_HW_MASK }; static inline GraphicBufferAllocator& get() { return getInstance(); } status_t alloc(uint32_t w, uint32_t h, PixelFormat format, uint32_t usage, buffer_handle_t* handle, uint32_t* stride); status_t free(buffer_handle_t handle); void dump(String8& res) const; static void dumpToSystemLog(); private: struct alloc_rec_t { uint32_t width; uint32_t height; uint32_t stride; PixelFormat format; uint32_t usage; size_t size; }; static Mutex sLock; static KeyedVector sAllocList; friend class Singleton; GraphicBufferAllocator(); ~GraphicBufferAllocator(); alloc_device_t *mAllocDev; }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_BUFFER_ALLOCATOR_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/GraphicBufferMapper.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_BUFFER_MAPPER_H #define ANDROID_UI_BUFFER_MAPPER_H #include #include #include #include struct gralloc_module_t; namespace android { // --------------------------------------------------------------------------- class Rect; class GraphicBufferMapper : public Singleton { public: static inline GraphicBufferMapper& get() { return getInstance(); } status_t registerBuffer(buffer_handle_t handle); status_t unregisterBuffer(buffer_handle_t handle); status_t lock(buffer_handle_t handle, uint32_t usage, const Rect& bounds, void** vaddr); status_t lockYCbCr(buffer_handle_t handle, uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr); status_t unlock(buffer_handle_t handle); status_t lockAsync(buffer_handle_t handle, uint32_t usage, const Rect& bounds, void** vaddr, int fenceFd); status_t lockAsyncYCbCr(buffer_handle_t handle, uint32_t usage, const Rect& bounds, android_ycbcr *ycbcr, int fenceFd); status_t unlockAsync(buffer_handle_t handle, int *fenceFd); #ifdef EXYNOS4_ENHANCEMENTS status_t getphys(buffer_handle_t handle, void** paddr); #endif // dumps information about the mapping of this handle void dump(buffer_handle_t handle); private: friend class Singleton; GraphicBufferMapper(); gralloc_module_t const *mAllocMod; }; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_UI_BUFFER_MAPPER_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/PixelFormat.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Pixel formats used across the system. // These formats might not all be supported by all renderers, for instance // skia or SurfaceFlinger are not required to support all of these formats // (either as source or destination) #ifndef UI_PIXELFORMAT_H #define UI_PIXELFORMAT_H #include namespace android { enum { // // these constants need to match those // in graphics/PixelFormat.java & pixelflinger/format.h // PIXEL_FORMAT_UNKNOWN = 0, PIXEL_FORMAT_NONE = 0, // logical pixel formats used by the SurfaceFlinger ----------------------- PIXEL_FORMAT_CUSTOM = -4, // Custom pixel-format described by a PixelFormatInfo structure PIXEL_FORMAT_TRANSLUCENT = -3, // System chooses a format that supports translucency (many alpha bits) PIXEL_FORMAT_TRANSPARENT = -2, // System chooses a format that supports transparency // (at least 1 alpha bit) PIXEL_FORMAT_OPAQUE = -1, // System chooses an opaque format (no alpha bits required) // real pixel formats supported for rendering ----------------------------- PIXEL_FORMAT_RGBA_8888 = HAL_PIXEL_FORMAT_RGBA_8888, // 4x8-bit RGBA PIXEL_FORMAT_RGBX_8888 = HAL_PIXEL_FORMAT_RGBX_8888, // 4x8-bit RGB0 PIXEL_FORMAT_RGB_888 = HAL_PIXEL_FORMAT_RGB_888, // 3x8-bit RGB PIXEL_FORMAT_RGB_565 = HAL_PIXEL_FORMAT_RGB_565, // 16-bit RGB PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB }; typedef int32_t PixelFormat; uint32_t bytesPerPixel(PixelFormat format); uint32_t bitsPerPixel(PixelFormat format); }; // namespace android #endif // UI_PIXELFORMAT_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/Point.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_POINT #define ANDROID_UI_POINT #include #include namespace android { class Point : public LightFlattenablePod { public: int x; int y; // we don't provide copy-ctor and operator= on purpose // because we want the compiler generated versions // Default constructor doesn't initialize the Point inline Point() { } inline Point(int x, int y) : x(x), y(y) { } inline bool operator == (const Point& rhs) const { return (x == rhs.x) && (y == rhs.y); } inline bool operator != (const Point& rhs) const { return !operator == (rhs); } inline bool isOrigin() const { return !(x|y); } // operator < defines an order which allows to use points in sorted // vectors. bool operator < (const Point& rhs) const { return y #include #include #include #include namespace android { class Rect : public ARect, public LightFlattenablePod { public: typedef ARect::value_type value_type; static const Rect INVALID_RECT; // we don't provide copy-ctor and operator= on purpose // because we want the compiler generated versions inline Rect() { left = right = top = bottom = 0; } inline Rect(int32_t w, int32_t h) { left = top = 0; right = w; bottom = h; } inline Rect(uint32_t w, uint32_t h) { if (w > INT32_MAX) { ALOG(LOG_WARN, "Rect", "Width %u too large for Rect class, clamping", w); w = INT32_MAX; } if (h > INT32_MAX) { ALOG(LOG_WARN, "Rect", "Height %u too large for Rect class, clamping", h); h = INT32_MAX; } left = top = 0; right = w; bottom = h; } inline Rect(int32_t l, int32_t t, int32_t r, int32_t b) { left = l; top = t; right = r; bottom = b; } inline Rect(const Point& lt, const Point& rb) { left = lt.x; top = lt.y; right = rb.x; bottom = rb.y; } void makeInvalid(); inline void clear() { left = top = right = bottom = 0; } // a valid rectangle has a non negative width and height inline bool isValid() const { return (getWidth() >= 0) && (getHeight() >= 0); } // an empty rect has a zero width or height, or is invalid inline bool isEmpty() const { return (getWidth() <= 0) || (getHeight() <= 0); } // rectangle's width inline int32_t getWidth() const { return right - left; } // rectangle's height inline int32_t getHeight() const { return bottom - top; } inline Rect getBounds() const { return Rect(right - left, bottom - top); } void setLeftTop(const Point& lt) { left = lt.x; top = lt.y; } void setRightBottom(const Point& rb) { right = rb.x; bottom = rb.y; } // the following 4 functions return the 4 corners of the rect as Point Point leftTop() const { return Point(left, top); } Point rightBottom() const { return Point(right, bottom); } Point rightTop() const { return Point(right, top); } Point leftBottom() const { return Point(left, bottom); } // comparisons inline bool operator == (const Rect& rhs) const { return (left == rhs.left) && (top == rhs.top) && (right == rhs.right) && (bottom == rhs.bottom); } inline bool operator != (const Rect& rhs) const { return !operator == (rhs); } // operator < defines an order which allows to use rectangles in sorted // vectors. bool operator < (const Rect& rhs) const; const Rect operator + (const Point& rhs) const; const Rect operator - (const Point& rhs) const; Rect& operator += (const Point& rhs) { return offsetBy(rhs.x, rhs.y); } Rect& operator -= (const Point& rhs) { return offsetBy(-rhs.x, -rhs.y); } Rect& offsetToOrigin() { right -= left; bottom -= top; left = top = 0; return *this; } Rect& offsetTo(const Point& p) { return offsetTo(p.x, p.y); } Rect& offsetBy(const Point& dp) { return offsetBy(dp.x, dp.y); } Rect& offsetTo(int32_t x, int32_t y); Rect& offsetBy(int32_t x, int32_t y); bool intersect(const Rect& with, Rect* result) const; // Create a new Rect by transforming this one using a graphics HAL // transform. This rectangle is defined in a coordinate space starting at // the origin and extending to (width, height). If the transform includes // a ROT90 then the output rectangle is defined in a space extending to // (height, width). Otherwise the output rectangle is in the same space as // the input. Rect transform(uint32_t xform, int32_t width, int32_t height) const; // this calculates (Region(*this) - exclude).bounds() efficiently Rect reduce(const Rect& exclude) const; // for backward compatibility inline int32_t width() const { return getWidth(); } inline int32_t height() const { return getHeight(); } inline void set(const Rect& rhs) { operator = (rhs); } }; ANDROID_BASIC_TYPES_TRAITS(Rect) }; // namespace android #endif // ANDROID_UI_RECT ================================================ FILE: phonelibs/android_frameworks_native/include/ui/Region.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_REGION_H #define ANDROID_UI_REGION_H #include #include #include #include #include namespace android { // --------------------------------------------------------------------------- class SharedBuffer; class String8; // --------------------------------------------------------------------------- class Region : public LightFlattenable { public: static const Region INVALID_REGION; Region(); Region(const Region& rhs); explicit Region(const Rect& rhs); ~Region(); static Region createTJunctionFreeRegion(const Region& r); Region& operator = (const Region& rhs); inline bool isEmpty() const { return getBounds().isEmpty(); } inline bool isRect() const { return mStorage.size() == 1; } inline Rect getBounds() const { return mStorage[mStorage.size() - 1]; } inline Rect bounds() const { return getBounds(); } bool contains(const Point& point) const; bool contains(int x, int y) const; // the region becomes its bounds Region& makeBoundsSelf(); void clear(); void set(const Rect& r); void set(int32_t w, int32_t h); void set(uint32_t w, uint32_t h); Region& orSelf(const Rect& rhs); Region& xorSelf(const Rect& rhs); Region& andSelf(const Rect& rhs); Region& subtractSelf(const Rect& rhs); // boolean operators, applied on this Region& orSelf(const Region& rhs); Region& xorSelf(const Region& rhs); Region& andSelf(const Region& rhs); Region& subtractSelf(const Region& rhs); // boolean operators const Region merge(const Rect& rhs) const; const Region mergeExclusive(const Rect& rhs) const; const Region intersect(const Rect& rhs) const; const Region subtract(const Rect& rhs) const; // boolean operators const Region merge(const Region& rhs) const; const Region mergeExclusive(const Region& rhs) const; const Region intersect(const Region& rhs) const; const Region subtract(const Region& rhs) const; // these translate rhs first Region& translateSelf(int dx, int dy); Region& orSelf(const Region& rhs, int dx, int dy); Region& xorSelf(const Region& rhs, int dx, int dy); Region& andSelf(const Region& rhs, int dx, int dy); Region& subtractSelf(const Region& rhs, int dx, int dy); // these translate rhs first const Region translate(int dx, int dy) const; const Region merge(const Region& rhs, int dx, int dy) const; const Region mergeExclusive(const Region& rhs, int dx, int dy) const; const Region intersect(const Region& rhs, int dx, int dy) const; const Region subtract(const Region& rhs, int dx, int dy) const; // convenience operators overloads inline const Region operator | (const Region& rhs) const; inline const Region operator ^ (const Region& rhs) const; inline const Region operator & (const Region& rhs) const; inline const Region operator - (const Region& rhs) const; inline const Region operator + (const Point& pt) const; inline Region& operator |= (const Region& rhs); inline Region& operator ^= (const Region& rhs); inline Region& operator &= (const Region& rhs); inline Region& operator -= (const Region& rhs); inline Region& operator += (const Point& pt); // returns true if the regions share the same underlying storage bool isTriviallyEqual(const Region& region) const; /* various ways to access the rectangle list */ // STL-like iterators typedef Rect const* const_iterator; const_iterator begin() const; const_iterator end() const; // returns an array of rect which has the same life-time has this // Region object. Rect const* getArray(size_t* count) const; // returns a SharedBuffer as well as the number of rects. // ownership is transfered to the caller. // the caller must call SharedBuffer::release() to free the memory. SharedBuffer const* getSharedBuffer(size_t* count) const; /* no user serviceable parts here... */ // add a rectangle to the internal list. This rectangle must // be sorted in Y and X and must not make the region invalid. void addRectUnchecked(int l, int t, int r, int b); inline bool isFixedSize() const { return false; } size_t getFlattenedSize() const; status_t flatten(void* buffer, size_t size) const; status_t unflatten(void const* buffer, size_t size); void dump(String8& out, const char* what, uint32_t flags=0) const; void dump(const char* what, uint32_t flags=0) const; private: class rasterizer; friend class rasterizer; Region& operationSelf(const Rect& r, int op); Region& operationSelf(const Region& r, int op); Region& operationSelf(const Region& r, int dx, int dy, int op); const Region operation(const Rect& rhs, int op) const; const Region operation(const Region& rhs, int op) const; const Region operation(const Region& rhs, int dx, int dy, int op) const; static void boolean_operation(int op, Region& dst, const Region& lhs, const Region& rhs, int dx, int dy); static void boolean_operation(int op, Region& dst, const Region& lhs, const Rect& rhs, int dx, int dy); static void boolean_operation(int op, Region& dst, const Region& lhs, const Region& rhs); static void boolean_operation(int op, Region& dst, const Region& lhs, const Rect& rhs); static void translate(Region& reg, int dx, int dy); static void translate(Region& dst, const Region& reg, int dx, int dy); static bool validate(const Region& reg, const char* name, bool silent = false); // mStorage is a (manually) sorted array of Rects describing the region // with an extra Rect as the last element which is set to the // bounds of the region. However, if the region is // a simple Rect then mStorage contains only that rect. Vector mStorage; }; const Region Region::operator | (const Region& rhs) const { return merge(rhs); } const Region Region::operator ^ (const Region& rhs) const { return mergeExclusive(rhs); } const Region Region::operator & (const Region& rhs) const { return intersect(rhs); } const Region Region::operator - (const Region& rhs) const { return subtract(rhs); } const Region Region::operator + (const Point& pt) const { return translate(pt.x, pt.y); } Region& Region::operator |= (const Region& rhs) { return orSelf(rhs); } Region& Region::operator ^= (const Region& rhs) { return xorSelf(rhs); } Region& Region::operator &= (const Region& rhs) { return andSelf(rhs); } Region& Region::operator -= (const Region& rhs) { return subtractSelf(rhs); } Region& Region::operator += (const Point& pt) { return translateSelf(pt.x, pt.y); } // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_UI_REGION_H ================================================ FILE: phonelibs/android_frameworks_native/include/ui/TMatHelpers.h ================================================ /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TMAT_IMPLEMENTATION #error "Don't include TMatHelpers.h directly. use ui/mat*.h instead" #else #undef TMAT_IMPLEMENTATION #endif #ifndef UI_TMAT_HELPERS_H #define UI_TMAT_HELPERS_H #include #include #include #include #include #define PURE __attribute__((pure)) namespace android { // ------------------------------------------------------------------------------------- /* * No user serviceable parts here. * * Don't use this file directly, instead include ui/mat*.h */ /* * Matrix utilities */ namespace matrix { inline int PURE transpose(int v) { return v; } inline float PURE transpose(float v) { return v; } inline double PURE transpose(double v) { return v; } inline int PURE trace(int v) { return v; } inline float PURE trace(float v) { return v; } inline double PURE trace(double v) { return v; } template MATRIX PURE inverse(const MATRIX& src) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::COL_SIZE == MATRIX::ROW_SIZE ); typename MATRIX::value_type t; const size_t N = MATRIX::col_size(); size_t swap; MATRIX tmp(src); MATRIX inverse(1); for (size_t i=0 ; i fabs(tmp[i][i])) { swap = j; } } if (swap != i) { /* swap rows. */ for (size_t k=0 ; k MATRIX_R PURE multiply(const MATRIX_A& lhs, const MATRIX_B& rhs) { // pre-requisite: // lhs : D columns, R rows // rhs : C columns, D rows // res : C columns, R rows COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX_A::ROW_SIZE == MATRIX_B::COL_SIZE ); COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX_R::ROW_SIZE == MATRIX_B::ROW_SIZE ); COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX_R::COL_SIZE == MATRIX_A::COL_SIZE ); MATRIX_R res(MATRIX_R::NO_INIT); for (size_t r=0 ; r MATRIX PURE transpose(const MATRIX& m) { // for now we only handle square matrix transpose COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::ROW_SIZE == MATRIX::COL_SIZE ); MATRIX result(MATRIX::NO_INIT); for (size_t r=0 ; r typename MATRIX::value_type PURE trace(const MATRIX& m) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::ROW_SIZE == MATRIX::COL_SIZE ); typename MATRIX::value_type result(0); for (size_t r=0 ; r typename MATRIX::col_type PURE diag(const MATRIX& m) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( MATRIX::ROW_SIZE == MATRIX::COL_SIZE ); typename MATRIX::col_type result(MATRIX::col_type::NO_INIT); for (size_t r=0 ; r String8 asString(const MATRIX& m) { String8 s; for (size_t c=0 ; c. * * BASE only needs to implement operator[] and size(). * By simply inheriting from TMatProductOperators BASE will automatically * get all the functionality here. */ template class BASE, typename T> class TMatProductOperators { public: // multiply by a scalar BASE& operator *= (T v) { BASE& lhs(static_cast< BASE& >(*this)); for (size_t r=0 ; r& operator /= (T v) { BASE& lhs(static_cast< BASE& >(*this)); for (size_t r=0 ; r friend BASE PURE operator *(const BASE& lhs, const BASE& rhs) { return matrix::multiply >(lhs, rhs); } }; /* * TMatSquareFunctions implements functions on a matrix of type BASE. * * BASE only needs to implement: * - operator[] * - col_type * - row_type * - COL_SIZE * - ROW_SIZE * * By simply inheriting from TMatSquareFunctions BASE will automatically * get all the functionality here. */ template class BASE, typename T> class TMatSquareFunctions { public: /* * NOTE: the functions below ARE NOT member methods. They are friend functions * with they definition inlined with their declaration. This makes these * template functions available to the compiler when (and only when) this class * is instantiated, at which point they're only templated on the 2nd parameter * (the first one, BASE being known). */ friend BASE PURE inverse(const BASE& m) { return matrix::inverse(m); } friend BASE PURE transpose(const BASE& m) { return matrix::transpose(m); } friend T PURE trace(const BASE& m) { return matrix::trace(m); } }; template class BASE, typename T> class TMatDebug { public: String8 asString() const { return matrix::asString( static_cast< const BASE& >(*this) ); } }; // ------------------------------------------------------------------------------------- }; // namespace android #undef PURE #endif /* UI_TMAT_HELPERS_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/TVecHelpers.h ================================================ /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef TVEC_IMPLEMENTATION #error "Don't include TVecHelpers.h directly. use ui/vec*.h instead" #else #undef TVEC_IMPLEMENTATION #endif #ifndef UI_TVEC_HELPERS_H #define UI_TVEC_HELPERS_H #include #include #define PURE __attribute__((pure)) namespace android { // ------------------------------------------------------------------------------------- /* * No user serviceable parts here. * * Don't use this file directly, instead include ui/vec{2|3|4}.h */ /* * This class casts itself into anything and assign itself from anything! * Use with caution! */ template struct Impersonator { Impersonator& operator = (const TYPE& rhs) { reinterpret_cast(*this) = rhs; return *this; } operator TYPE& () { return reinterpret_cast(*this); } operator TYPE const& () const { return reinterpret_cast(*this); } }; /* * TVec{Add|Product}Operators implements basic arithmetic and basic compound assignments * operators on a vector of type BASE. * * BASE only needs to implement operator[] and size(). * By simply inheriting from TVec{Add|Product}Operators BASE will automatically * get all the functionality here. */ template class BASE, typename T> class TVecAddOperators { public: /* compound assignment from a another vector of the same size but different * element type. */ template BASE& operator += (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] += v[i]; } return rhs; } template BASE& operator -= (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] -= v[i]; } return rhs; } /* compound assignment from a another vector of the same type. * These operators can be used for implicit conversion and handle operations * like "vector *= scalar" by letting the compiler implicitly convert a scalar * to a vector (assuming the BASE allows it). */ BASE& operator += (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] += v[i]; } return rhs; } BASE& operator -= (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] -= v[i]; } return rhs; } /* * NOTE: the functions below ARE NOT member methods. They are friend functions * with they definition inlined with their declaration. This makes these * template functions available to the compiler when (and only when) this class * is instantiated, at which point they're only templated on the 2nd parameter * (the first one, BASE being known). */ /* The operators below handle operation between vectors of the same side * but of a different element type. */ template friend inline BASE PURE operator +(const BASE& lv, const BASE& rv) { return BASE(lv) += rv; } template friend inline BASE PURE operator -(const BASE& lv, const BASE& rv) { return BASE(lv) -= rv; } /* The operators below (which are not templates once this class is instanced, * i.e.: BASE is known) can be used for implicit conversion on both sides. * These handle operations like "vector * scalar" and "scalar * vector" by * letting the compiler implicitly convert a scalar to a vector (assuming * the BASE allows it). */ friend inline BASE PURE operator +(const BASE& lv, const BASE& rv) { return BASE(lv) += rv; } friend inline BASE PURE operator -(const BASE& lv, const BASE& rv) { return BASE(lv) -= rv; } }; template class BASE, typename T> class TVecProductOperators { public: /* compound assignment from a another vector of the same size but different * element type. */ template BASE& operator *= (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] *= v[i]; } return rhs; } template BASE& operator /= (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] /= v[i]; } return rhs; } /* compound assignment from a another vector of the same type. * These operators can be used for implicit conversion and handle operations * like "vector *= scalar" by letting the compiler implicitly convert a scalar * to a vector (assuming the BASE allows it). */ BASE& operator *= (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] *= v[i]; } return rhs; } BASE& operator /= (const BASE& v) { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { rhs[i] /= v[i]; } return rhs; } /* * NOTE: the functions below ARE NOT member methods. They are friend functions * with they definition inlined with their declaration. This makes these * template functions available to the compiler when (and only when) this class * is instantiated, at which point they're only templated on the 2nd parameter * (the first one, BASE being known). */ /* The operators below handle operation between vectors of the same side * but of a different element type. */ template friend inline BASE PURE operator *(const BASE& lv, const BASE& rv) { return BASE(lv) *= rv; } template friend inline BASE PURE operator /(const BASE& lv, const BASE& rv) { return BASE(lv) /= rv; } /* The operators below (which are not templates once this class is instanced, * i.e.: BASE is known) can be used for implicit conversion on both sides. * These handle operations like "vector * scalar" and "scalar * vector" by * letting the compiler implicitly convert a scalar to a vector (assuming * the BASE allows it). */ friend inline BASE PURE operator *(const BASE& lv, const BASE& rv) { return BASE(lv) *= rv; } friend inline BASE PURE operator /(const BASE& lv, const BASE& rv) { return BASE(lv) /= rv; } }; /* * TVecUnaryOperators implements unary operators on a vector of type BASE. * * BASE only needs to implement operator[] and size(). * By simply inheriting from TVecUnaryOperators BASE will automatically * get all the functionality here. * * These operators are implemented as friend functions of TVecUnaryOperators */ template class BASE, typename T> class TVecUnaryOperators { public: BASE& operator ++ () { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { ++rhs[i]; } return rhs; } BASE& operator -- () { BASE& rhs = static_cast&>(*this); for (size_t i=0 ; i::size() ; i++) { --rhs[i]; } return rhs; } BASE operator - () const { BASE r(BASE::NO_INIT); BASE const& rv(static_cast const&>(*this)); for (size_t i=0 ; i::size() ; i++) { r[i] = -rv[i]; } return r; } }; /* * TVecComparisonOperators implements relational/comparison operators * on a vector of type BASE. * * BASE only needs to implement operator[] and size(). * By simply inheriting from TVecComparisonOperators BASE will automatically * get all the functionality here. */ template class BASE, typename T> class TVecComparisonOperators { public: /* * NOTE: the functions below ARE NOT member methods. They are friend functions * with they definition inlined with their declaration. This makes these * template functions available to the compiler when (and only when) this class * is instantiated, at which point they're only templated on the 2nd parameter * (the first one, BASE being known). */ template friend inline bool PURE operator ==(const BASE& lv, const BASE& rv) { for (size_t i = 0; i < BASE::size(); i++) if (lv[i] != rv[i]) return false; return true; } template friend inline bool PURE operator !=(const BASE& lv, const BASE& rv) { return !operator ==(lv, rv); } template friend inline bool PURE operator >(const BASE& lv, const BASE& rv) { for (size_t i = 0; i < BASE::size(); i++) if (lv[i] <= rv[i]) return false; return true; } template friend inline bool PURE operator <=(const BASE& lv, const BASE& rv) { return !(lv > rv); } template friend inline bool PURE operator <(const BASE& lv, const BASE& rv) { for (size_t i = 0; i < BASE::size(); i++) if (lv[i] >= rv[i]) return false; return true; } template friend inline bool PURE operator >=(const BASE& lv, const BASE& rv) { return !(lv < rv); } }; /* * TVecFunctions implements functions on a vector of type BASE. * * BASE only needs to implement operator[] and size(). * By simply inheriting from TVecFunctions BASE will automatically * get all the functionality here. */ template class BASE, typename T> class TVecFunctions { public: /* * NOTE: the functions below ARE NOT member methods. They are friend functions * with they definition inlined with their declaration. This makes these * template functions available to the compiler when (and only when) this class * is instantiated, at which point they're only templated on the 2nd parameter * (the first one, BASE being known). */ template friend inline T PURE dot(const BASE& lv, const BASE& rv) { T r(0); for (size_t i = 0; i < BASE::size(); i++) r += lv[i]*rv[i]; return r; } friend inline T PURE length(const BASE& lv) { return sqrt( dot(lv, lv) ); } template friend inline T PURE distance(const BASE& lv, const BASE& rv) { return length(rv - lv); } friend inline BASE PURE normalize(const BASE& lv) { return lv * (1 / length(lv)); } }; #undef PURE // ------------------------------------------------------------------------------------- }; // namespace android #endif /* UI_TVEC_HELPERS_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/UiConfig.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UI_CONFIG_H #define ANDROID_UI_CONFIG_H #include namespace android { // Append the libui configuration details to configStr. void appendUiConfigString(String8& configStr); }; // namespace android #endif /*ANDROID_UI_CONFIG_H*/ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/mat4.h ================================================ /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef UI_MAT4_H #define UI_MAT4_H #include #include #include #include #define TMAT_IMPLEMENTATION #include #define PURE __attribute__((pure)) namespace android { // ------------------------------------------------------------------------------------- template class tmat44 : public TVecUnaryOperators, public TVecComparisonOperators, public TVecAddOperators, public TMatProductOperators, public TMatSquareFunctions, public TMatDebug { public: enum no_init { NO_INIT }; typedef T value_type; typedef T& reference; typedef T const& const_reference; typedef size_t size_type; typedef tvec4 col_type; typedef tvec4 row_type; // size of a column (i.e.: number of rows) enum { COL_SIZE = col_type::SIZE }; static inline size_t col_size() { return COL_SIZE; } // size of a row (i.e.: number of columns) enum { ROW_SIZE = row_type::SIZE }; static inline size_t row_size() { return ROW_SIZE; } static inline size_t size() { return row_size(); } // for TVec*<> private: /* * <-- N columns --> * * a00 a10 a20 ... aN0 ^ * a01 a11 a21 ... aN1 | * a02 a12 a22 ... aN2 M rows * ... | * a0M a1M a2M ... aNM v * * COL_SIZE = M * ROW_SIZE = N * m[0] = [a00 a01 a02 ... a01M] */ col_type mValue[ROW_SIZE]; public: // array access inline col_type const& operator [] (size_t i) const { return mValue[i]; } inline col_type& operator [] (size_t i) { return mValue[i]; } T const* asArray() const { return &mValue[0][0]; } // ----------------------------------------------------------------------- // we don't provide copy-ctor and operator= on purpose // because we want the compiler generated versions /* * constructors */ // leaves object uninitialized. use with caution. explicit tmat44(no_init) { } // initialize to identity tmat44(); // initialize to Identity*scalar. template explicit tmat44(U v); // sets the diagonal to the passed vector template explicit tmat44(const tvec4& rhs); // construct from another matrix of the same size template explicit tmat44(const tmat44& rhs); // construct from 4 column vectors template tmat44(const tvec4& v0, const tvec4& v1, const tvec4& v2, const tvec4& v3); // construct from 16 scalars template < typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M, typename N, typename O, typename P> tmat44( A m00, B m01, C m02, D m03, E m10, F m11, G m12, H m13, I m20, J m21, K m22, L m23, M m30, N m31, O m32, P m33); // construct from a C array template explicit tmat44(U const* rawArray); /* * helpers */ static tmat44 ortho(T left, T right, T bottom, T top, T near, T far); static tmat44 frustum(T left, T right, T bottom, T top, T near, T far); template static tmat44 lookAt(const tvec3& eye, const tvec3& center, const tvec3& up); template static tmat44 translate(const tvec4& t); template static tmat44 scale(const tvec4& s); template static tmat44 rotate(A radian, const tvec3& about); }; // ---------------------------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------------------------- /* * Since the matrix code could become pretty big quickly, we don't inline most * operations. */ template tmat44::tmat44() { mValue[0] = col_type(1,0,0,0); mValue[1] = col_type(0,1,0,0); mValue[2] = col_type(0,0,1,0); mValue[3] = col_type(0,0,0,1); } template template tmat44::tmat44(U v) { mValue[0] = col_type(v,0,0,0); mValue[1] = col_type(0,v,0,0); mValue[2] = col_type(0,0,v,0); mValue[3] = col_type(0,0,0,v); } template template tmat44::tmat44(const tvec4& v) { mValue[0] = col_type(v.x,0,0,0); mValue[1] = col_type(0,v.y,0,0); mValue[2] = col_type(0,0,v.z,0); mValue[3] = col_type(0,0,0,v.w); } // construct from 16 scalars template template < typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J, typename K, typename L, typename M, typename N, typename O, typename P> tmat44::tmat44( A m00, B m01, C m02, D m03, E m10, F m11, G m12, H m13, I m20, J m21, K m22, L m23, M m30, N m31, O m32, P m33) { mValue[0] = col_type(m00, m01, m02, m03); mValue[1] = col_type(m10, m11, m12, m13); mValue[2] = col_type(m20, m21, m22, m23); mValue[3] = col_type(m30, m31, m32, m33); } template template tmat44::tmat44(const tmat44& rhs) { for (size_t r=0 ; r template tmat44::tmat44(const tvec4& v0, const tvec4& v1, const tvec4& v2, const tvec4& v3) { mValue[0] = v0; mValue[1] = v1; mValue[2] = v2; mValue[3] = v3; } template template tmat44::tmat44(U const* rawArray) { for (size_t r=0 ; r tmat44 tmat44::ortho(T left, T right, T bottom, T top, T near, T far) { tmat44 m; m[0][0] = 2 / (right - left); m[1][1] = 2 / (top - bottom); m[2][2] = -2 / (far - near); m[3][0] = -(right + left) / (right - left); m[3][1] = -(top + bottom) / (top - bottom); m[3][2] = -(far + near) / (far - near); return m; } template tmat44 tmat44::frustum(T left, T right, T bottom, T top, T near, T far) { tmat44 m; T A = (right + left) / (right - left); T B = (top + bottom) / (top - bottom); T C = (far + near) / (far - near); T D = (2 * far * near) / (far - near); m[0][0] = (2 * near) / (right - left); m[1][1] = (2 * near) / (top - bottom); m[2][0] = A; m[2][1] = B; m[2][2] = C; m[2][3] =-1; m[3][2] = D; m[3][3] = 0; return m; } template template tmat44 tmat44::lookAt(const tvec3& eye, const tvec3& center, const tvec3& up) { tvec3 L(normalize(center - eye)); tvec3 S(normalize( cross(L, up) )); tvec3 U(cross(S, L)); return tmat44( tvec4( S, 0), tvec4( U, 0), tvec4(-L, 0), tvec4(-eye, 1)); } template template tmat44 tmat44::translate(const tvec4& t) { tmat44 r; r[3] = t; return r; } template template tmat44 tmat44::scale(const tvec4& s) { tmat44 r; r[0][0] = s[0]; r[1][1] = s[1]; r[2][2] = s[2]; r[3][3] = s[3]; return r; } template template tmat44 tmat44::rotate(A radian, const tvec3& about) { tmat44 rotation; T* r = const_cast(rotation.asArray()); T c = cos(radian); T s = sin(radian); if (about.x==1 && about.y==0 && about.z==0) { r[5] = c; r[10]= c; r[6] = s; r[9] = -s; } else if (about.x==0 && about.y==1 && about.z==0) { r[0] = c; r[10]= c; r[8] = s; r[2] = -s; } else if (about.x==0 && about.y==0 && about.z==1) { r[0] = c; r[5] = c; r[1] = s; r[4] = -s; } else { tvec3 nabout = normalize(about); B x = nabout.x; B y = nabout.y; B z = nabout.z; T nc = 1 - c; T xy = x * y; T yz = y * z; T zx = z * x; T xs = x * s; T ys = y * s; T zs = z * s; r[ 0] = x*x*nc + c; r[ 4] = xy*nc - zs; r[ 8] = zx*nc + ys; r[ 1] = xy*nc + zs; r[ 5] = y*y*nc + c; r[ 9] = yz*nc - xs; r[ 2] = zx*nc - ys; r[ 6] = yz*nc + xs; r[10] = z*z*nc + c; } return rotation; } // ---------------------------------------------------------------------------------------- // Arithmetic operators outside of class // ---------------------------------------------------------------------------------------- /* We use non-friend functions here to prevent the compiler from using * implicit conversions, for instance of a scalar to a vector. The result would * not be what the caller expects. * * Also note that the order of the arguments in the inner loop is important since * it determines the output type (only relevant when T != U). */ // matrix * vector, result is a vector of the same type than the input vector template typename tmat44::col_type PURE operator *(const tmat44& lv, const tvec4& rv) { typename tmat44::col_type result; for (size_t r=0 ; r::row_size() ; r++) result += rv[r]*lv[r]; return result; } // vector * matrix, result is a vector of the same type than the input vector template typename tmat44::row_type PURE operator *(const tvec4& rv, const tmat44& lv) { typename tmat44::row_type result(tmat44::row_type::NO_INIT); for (size_t r=0 ; r::row_size() ; r++) result[r] = dot(rv, lv[r]); return result; } // matrix * scalar, result is a matrix of the same type than the input matrix template tmat44 PURE operator *(const tmat44& lv, U rv) { tmat44 result(tmat44::NO_INIT); for (size_t r=0 ; r::row_size() ; r++) result[r] = lv[r]*rv; return result; } // scalar * matrix, result is a matrix of the same type than the input matrix template tmat44 PURE operator *(U rv, const tmat44& lv) { tmat44 result(tmat44::NO_INIT); for (size_t r=0 ; r::row_size() ; r++) result[r] = lv[r]*rv; return result; } // ---------------------------------------------------------------------------------------- /* FIXME: this should go into TMatSquareFunctions<> but for some reason * BASE::col_type is not accessible from there (???) */ template typename tmat44::col_type PURE diag(const tmat44& m) { return matrix::diag(m); } // ---------------------------------------------------------------------------------------- typedef tmat44 mat4; // ---------------------------------------------------------------------------------------- }; // namespace android #undef PURE #endif /* UI_MAT4_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/vec2.h ================================================ /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef UI_VEC2_H #define UI_VEC2_H #include #include #define TVEC_IMPLEMENTATION #include namespace android { // ------------------------------------------------------------------------------------- template class tvec2 : public TVecProductOperators, public TVecAddOperators, public TVecUnaryOperators, public TVecComparisonOperators, public TVecFunctions { public: enum no_init { NO_INIT }; typedef T value_type; typedef T& reference; typedef T const& const_reference; typedef size_t size_type; union { struct { T x, y; }; struct { T s, t; }; struct { T r, g; }; }; enum { SIZE = 2 }; inline static size_type size() { return SIZE; } // array access inline T const& operator [] (size_t i) const { return (&x)[i]; } inline T& operator [] (size_t i) { return (&x)[i]; } // ----------------------------------------------------------------------- // we don't provide copy-ctor and operator= on purpose // because we want the compiler generated versions // constructors // leaves object uninitialized. use with caution. explicit tvec2(no_init) { } // default constructor tvec2() : x(0), y(0) { } // handles implicit conversion to a tvec4. must not be explicit. template tvec2(A v) : x(v), y(v) { } template tvec2(A x, B y) : x(x), y(y) { } template explicit tvec2(const tvec2& v) : x(v.x), y(v.y) { } template tvec2(const Impersonator< tvec2 >& v) : x(((const tvec2&)v).x), y(((const tvec2&)v).y) { } }; // ---------------------------------------------------------------------------------------- typedef tvec2 vec2; // ---------------------------------------------------------------------------------------- }; // namespace android #endif /* UI_VEC4_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/vec3.h ================================================ /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef UI_VEC3_H #define UI_VEC3_H #include #include #include namespace android { // ------------------------------------------------------------------------------------- template class tvec3 : public TVecProductOperators, public TVecAddOperators, public TVecUnaryOperators, public TVecComparisonOperators, public TVecFunctions { public: enum no_init { NO_INIT }; typedef T value_type; typedef T& reference; typedef T const& const_reference; typedef size_t size_type; union { struct { T x, y, z; }; struct { T s, t, p; }; struct { T r, g, b; }; Impersonator< tvec2 > xy; Impersonator< tvec2 > st; Impersonator< tvec2 > rg; }; enum { SIZE = 3 }; inline static size_type size() { return SIZE; } // array access inline T const& operator [] (size_t i) const { return (&x)[i]; } inline T& operator [] (size_t i) { return (&x)[i]; } // ----------------------------------------------------------------------- // we don't provide copy-ctor and operator= on purpose // because we want the compiler generated versions // constructors // leaves object uninitialized. use with caution. explicit tvec3(no_init) { } // default constructor tvec3() : x(0), y(0), z(0) { } // handles implicit conversion to a tvec4. must not be explicit. template tvec3(A v) : x(v), y(v), z(v) { } template tvec3(A x, B y, C z) : x(x), y(y), z(z) { } template tvec3(const tvec2& v, B z) : x(v.x), y(v.y), z(z) { } template explicit tvec3(const tvec3& v) : x(v.x), y(v.y), z(v.z) { } template tvec3(const Impersonator< tvec3 >& v) : x(((const tvec3&)v).x), y(((const tvec3&)v).y), z(((const tvec3&)v).z) { } template tvec3(const Impersonator< tvec2 >& v, B z) : x(((const tvec2&)v).x), y(((const tvec2&)v).y), z(z) { } // cross product works only on vectors of size 3 template friend inline tvec3 __attribute__((pure)) cross(const tvec3& u, const tvec3& v) { return tvec3( u.y*v.z - u.z*v.y, u.z*v.x - u.x*v.z, u.x*v.y - u.y*v.x); } }; // ---------------------------------------------------------------------------------------- typedef tvec3 vec3; // ---------------------------------------------------------------------------------------- }; // namespace android #endif /* UI_VEC4_H */ ================================================ FILE: phonelibs/android_frameworks_native/include/ui/vec4.h ================================================ /* * Copyright 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef UI_VEC4_H #define UI_VEC4_H #include #include #include namespace android { // ------------------------------------------------------------------------------------- template class tvec4 : public TVecProductOperators, public TVecAddOperators, public TVecUnaryOperators, public TVecComparisonOperators, public TVecFunctions { public: enum no_init { NO_INIT }; typedef T value_type; typedef T& reference; typedef T const& const_reference; typedef size_t size_type; union { struct { T x, y, z, w; }; struct { T s, t, p, q; }; struct { T r, g, b, a; }; Impersonator< tvec2 > xy; Impersonator< tvec2 > st; Impersonator< tvec2 > rg; Impersonator< tvec3 > xyz; Impersonator< tvec3 > stp; Impersonator< tvec3 > rgb; }; enum { SIZE = 4 }; inline static size_type size() { return SIZE; } // array access inline T const& operator [] (size_t i) const { return (&x)[i]; } inline T& operator [] (size_t i) { return (&x)[i]; } // ----------------------------------------------------------------------- // we don't provide copy-ctor and operator= on purpose // because we want the compiler generated versions // constructors // leaves object uninitialized. use with caution. explicit tvec4(no_init) { } // default constructor tvec4() : x(0), y(0), z(0), w(0) { } // handles implicit conversion to a tvec4. must not be explicit. template tvec4(A v) : x(v), y(v), z(v), w(v) { } template tvec4(A x, B y, C z, D w) : x(x), y(y), z(z), w(w) { } template tvec4(const tvec2& v, B z, C w) : x(v.x), y(v.y), z(z), w(w) { } template tvec4(const tvec3& v, B w) : x(v.x), y(v.y), z(v.z), w(w) { } template explicit tvec4(const tvec4& v) : x(v.x), y(v.y), z(v.z), w(v.w) { } template tvec4(const Impersonator< tvec4 >& v) : x(((const tvec4&)v).x), y(((const tvec4&)v).y), z(((const tvec4&)v).z), w(((const tvec4&)v).w) { } template tvec4(const Impersonator< tvec3 >& v, B w) : x(((const tvec3&)v).x), y(((const tvec3&)v).y), z(((const tvec3&)v).z), w(w) { } template tvec4(const Impersonator< tvec2 >& v, B z, C w) : x(((const tvec2&)v).x), y(((const tvec2&)v).y), z(z), w(w) { } }; // ---------------------------------------------------------------------------------------- typedef tvec4 vec4; // ---------------------------------------------------------------------------------------- }; // namespace android #endif /* UI_VEC4_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/activity_recognition.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Activity Recognition HAL. The goal is to provide low power, low latency, always-on activity * recognition implemented in hardware (i.e. these activity recognition algorithms/classifers * should NOT be run on the AP). By low power we mean that this may be activated 24/7 without * impacting the battery drain speed (goal in order of 1mW including the power for sensors). * This HAL does not specify the input sources that are used towards detecting these activities. * It has one monitor interface which can be used to batch activities for always-on * activity_recognition and if the latency is zero, the same interface can be used for low latency * detection. */ #ifndef ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #define ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H #include __BEGIN_DECLS #define ACTIVITY_RECOGNITION_HEADER_VERSION 1 #define ACTIVITY_RECOGNITION_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, ACTIVITY_RECOGNITION_HEADER_VERSION) #define ACTIVITY_RECOGNITION_HARDWARE_MODULE_ID "activity_recognition" #define ACTIVITY_RECOGNITION_HARDWARE_INTERFACE "activity_recognition_hw_if" /* * Define types for various activities. Multiple activities may be active at the same time and * sometimes none of these activities may be active. * * Each activity has a corresponding type. Only activities that are defined here should use * android.activity_recognition.* prefix. OEM defined activities should not use this prefix. * Activity type of OEM-defined activities should start with the reverse domain name of the entity * defining the activity. * * When android introduces a new activity type that can potentially replace an OEM-defined activity * type, the OEM must use the official activity type on versions of the HAL that support this new * official activity type. * * Example (made up): Suppose Google's Glass team wants to detect nodding activity. * - Such an activity is not officially supported in android L * - Glass devices launching on L can implement a custom activity with * type = "com.google.glass.nodding" * - In M android release, if android decides to define ACITIVITY_TYPE_NODDING, those types * should replace the Glass-team-specific types in all future launches. * - When launching glass on the M release, Google should now use the official activity type * - This way, other applications can use this activity. */ #define ACTIVITY_TYPE_IN_VEHICLE "android.activity_recognition.in_vehicle" #define ACTIVITY_TYPE_ON_BICYCLE "android.activity_recognition.on_bicycle" #define ACTIVITY_TYPE_WALKING "android.activity_recognition.walking" #define ACTIVITY_TYPE_RUNNING "android.activity_recognition.running" #define ACTIVITY_TYPE_STILL "android.activity_recognition.still" #define ACTIVITY_TYPE_TILTING "android.activity_recognition.tilting" /* Values for activity_event.event_types. */ enum { /* * A flush_complete event which indicates that a flush() has been successfully completed. This * does not correspond to any activity/event. An event of this type should be added to the end * of a batch FIFO and it indicates that all the events in the batch FIFO have been successfully * reported to the framework. An event of this type should be generated only if flush() has been * explicitly called and if the FIFO is empty at the time flush() is called it should trivially * return a flush_complete_event to indicate that the FIFO is empty. * * A flush complete event should have the following parameters set. * activity_event_t.event_type = ACTIVITY_EVENT_FLUSH_COMPLETE * activity_event_t.activity = 0 * activity_event_t.timestamp = 0 * activity_event_t.reserved = 0 * See (*flush)() for more details. */ ACTIVITY_EVENT_FLUSH_COMPLETE = 0, /* Signifies entering an activity. */ ACTIVITY_EVENT_ENTER = 1, /* Signifies exiting an activity. */ ACTIVITY_EVENT_EXIT = 2 }; /* * Each event is a separate activity with event_type indicating whether this activity has started * or ended. Eg event: (event_type="enter", activity="ON_FOOT", timestamp) */ typedef struct activity_event { /* One of the ACTIVITY_EVENT_* constants defined above. */ uint32_t event_type; /* * Index of the activity in the list returned by get_supported_activities_list. If this event * is a flush complete event, this should be set to zero. */ uint32_t activity; /* Time at which the transition/event has occurred in nanoseconds using elapsedRealTimeNano. */ int64_t timestamp; /* Set to zero. */ int32_t reserved[4]; } activity_event_t; typedef struct activity_recognition_module { /** * Common methods of the activity recognition module. This *must* be the first member of * activity_recognition_module as users of this structure will cast a hw_module_t to * activity_recognition_module pointer in contexts where it's known the hw_module_t * references an activity_recognition_module. */ hw_module_t common; /* * List of all activities supported by this module including OEM defined activities. Each * activity is represented using a string defined above. Each string should be null terminated. * The index of the activity in this array is used as a "handle" for enabling/disabling and * event delivery. * Return value is the size of this list. */ int (*get_supported_activities_list)(struct activity_recognition_module* module, char const* const* *activity_list); } activity_recognition_module_t; struct activity_recognition_device; typedef struct activity_recognition_callback_procs { // Callback for activity_data. This is guaranteed to not invoke any HAL methods. // Memory allocated for the events can be reused after this method returns. // events - Array of activity_event_t s that are reported. // count - size of the array. void (*activity_callback)(const struct activity_recognition_callback_procs* procs, const activity_event_t* events, int count); } activity_recognition_callback_procs_t; typedef struct activity_recognition_device { /** * Common methods of the activity recognition device. This *must* be the first member of * activity_recognition_device as users of this structure will cast a hw_device_t to * activity_recognition_device pointer in contexts where it's known the hw_device_t * references an activity_recognition_device. */ hw_device_t common; /* * Sets the callback to invoke when there are events to report. This call overwrites the * previously registered callback (if any). */ void (*register_activity_callback)(const struct activity_recognition_device* dev, const activity_recognition_callback_procs_t* callback); /* * Activates monitoring of activity transitions. Activities need not be reported as soon as they * are detected. The detected activities are stored in a FIFO and reported in batches when the * "max_batch_report_latency" expires or when the batch FIFO is full. The implementation should * allow the AP to go into suspend mode while the activities are detected and stored in the * batch FIFO. Whenever events need to be reported (like when the FIFO is full or when the * max_batch_report_latency has expired for an activity, event pair), it should wake_up the AP * so that no events are lost. Activities are stored as transitions and they are allowed to * overlap with each other. Each (activity, event_type) pair can be activated or deactivated * independently of the other. The HAL implementation needs to keep track of which pairs are * currently active and needs to detect only those pairs. * * activity_handle - Index of the specific activity that needs to be detected in the list * returned by get_supported_activities_list. * event_type - Specific transition of the activity that needs to be detected. * max_batch_report_latency_ns - a transition can be delayed by at most * “max_batch_report_latency” nanoseconds. * Return 0 on success, negative errno code otherwise. */ int (*enable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type, int64_t max_batch_report_latency_ns); /* * Disables detection of a specific (activity, event_type) pair. */ int (*disable_activity_event)(const struct activity_recognition_device* dev, uint32_t activity_handle, uint32_t event_type); /* * Flush all the batch FIFOs. Report all the activities that were stored in the FIFO so far as * if max_batch_report_latency had expired. This shouldn't change the latency in any way. Add * a flush_complete_event to indicate the end of the FIFO after all events are delivered. * See ACTIVITY_EVENT_FLUSH_COMPLETE for more details. * Return 0 on success, negative errno code otherwise. */ int (*flush)(const struct activity_recognition_device* dev); // Must be set to NULL. void (*reserved_procs[16 - 4])(void); } activity_recognition_device_t; static inline int activity_recognition_open(const hw_module_t* module, activity_recognition_device_t** device) { return module->methods->open(module, ACTIVITY_RECOGNITION_HARDWARE_INTERFACE, (hw_device_t**)device); } static inline int activity_recognition_close(activity_recognition_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/audio.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_AUDIO_HAL_INTERFACE_H #define ANDROID_AUDIO_HAL_INTERFACE_H #include #include #include #include #include #include #include #include #ifdef AUDIO_LISTEN_ENABLED #include #endif __BEGIN_DECLS /** * The id of this module */ #define AUDIO_HARDWARE_MODULE_ID "audio" /** * Name of the audio devices to open */ #define AUDIO_HARDWARE_INTERFACE "audio_hw_if" /* Use version 0.1 to be compatible with first generation of audio hw module with version_major * hardcoded to 1. No audio module API change. */ #define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 /* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 * will be considered of first generation API. */ #define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) #define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) #define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0 /* Minimal audio HAL version supported by the audio framework */ #define AUDIO_DEVICE_API_VERSION_MIN AUDIO_DEVICE_API_VERSION_2_0 /** * List of known audio HAL modules. This is the base name of the audio HAL * library composed of the "audio." prefix, one of the base names below and * a suffix specific to the device. * e.g: audio.primary.goldfish.so or audio.a2dp.default.so */ #define AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary" #define AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp" #define AUDIO_HARDWARE_MODULE_ID_USB "usb" #define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix" #define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload" /**************************************/ /** * standard audio parameters that the HAL may need to handle */ /** * audio device parameters */ /* BT SCO Noise Reduction + Echo Cancellation parameters */ #define AUDIO_PARAMETER_KEY_BT_NREC "bt_headset_nrec" #define AUDIO_PARAMETER_VALUE_ON "on" #define AUDIO_PARAMETER_VALUE_OFF "off" /* TTY mode selection */ #define AUDIO_PARAMETER_KEY_TTY_MODE "tty_mode" #define AUDIO_PARAMETER_VALUE_TTY_OFF "tty_off" #define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco" #define AUDIO_PARAMETER_VALUE_TTY_HCO "tty_hco" #define AUDIO_PARAMETER_VALUE_TTY_FULL "tty_full" /* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off Strings must be in sync with CallFeaturesSetting.java */ #define AUDIO_PARAMETER_KEY_HAC "HACSetting" #define AUDIO_PARAMETER_VALUE_HAC_ON "ON" #define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF" /* A2DP sink address set by framework */ #define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address" /* A2DP source address set by framework */ #define AUDIO_PARAMETER_A2DP_SOURCE_ADDRESS "a2dp_source_address" /* Screen state */ #define AUDIO_PARAMETER_KEY_SCREEN_STATE "screen_state" /* Bluetooth SCO wideband */ #define AUDIO_PARAMETER_KEY_BT_SCO_WB "bt_wbs" /* Get a new HW synchronization source identifier. * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs * or no HW sync is available. */ #define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync" /* Device state*/ #define AUDIO_PARAMETER_KEY_DEV_SHUTDOWN "dev_shutdown" /** * audio stream parameters */ #define AUDIO_PARAMETER_STREAM_ROUTING "routing" /* audio_devices_t */ #define AUDIO_PARAMETER_STREAM_FORMAT "format" /* audio_format_t */ #define AUDIO_PARAMETER_STREAM_CHANNELS "channels" /* audio_channel_mask_t */ #define AUDIO_PARAMETER_STREAM_FRAME_COUNT "frame_count" /* size_t */ #define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */ #define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */ #define AUDIO_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */ #define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */ /* Query supported formats. The response is a '|' separated list of strings from * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */ #define AUDIO_PARAMETER_STREAM_SUP_FORMATS "sup_formats" /* Query supported channel masks. The response is a '|' separated list of strings from * audio_channel_mask_t enum e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */ #define AUDIO_PARAMETER_STREAM_SUP_CHANNELS "sup_channels" /* Query supported sampling rates. The response is a '|' separated list of integer values e.g: * "sup_sampling_rates=44100|48000" */ #define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates" /* Set the HW synchronization source for an output stream. */ #define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync" /** * audio codec parameters */ #define AUDIO_OFFLOAD_CODEC_PARAMS "music_offload_codec_param" #define AUDIO_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample" #define AUDIO_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate" #define AUDIO_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate" #define AUDIO_OFFLOAD_CODEC_ID "music_offload_codec_id" #define AUDIO_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align" #define AUDIO_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate" #define AUDIO_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option" #define AUDIO_OFFLOAD_CODEC_NUM_CHANNEL "music_offload_num_channels" #define AUDIO_OFFLOAD_CODEC_DOWN_SAMPLING "music_offload_down_sampling" #define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES "delay_samples" #define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES "padding_samples" /**************************************/ /* common audio stream parameters and operations */ struct audio_stream { /** * Return the sampling rate in Hz - eg. 44100. */ uint32_t (*get_sample_rate)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_SAMPLING_RATE */ int (*set_sample_rate)(struct audio_stream *stream, uint32_t rate); /** * Return size of input/output buffer in bytes for this stream - eg. 4800. * It should be a multiple of the frame size. See also get_input_buffer_size. */ size_t (*get_buffer_size)(const struct audio_stream *stream); /** * Return the channel mask - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO */ audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); /** * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT */ audio_format_t (*get_format)(const struct audio_stream *stream); /* currently unused - use set_parameters with key * AUDIO_PARAMETER_STREAM_FORMAT */ int (*set_format)(struct audio_stream *stream, audio_format_t format); /** * Put the audio hardware input/output into standby mode. * Driver should exit from standby mode at the next I/O operation. * Returns 0 on success and <0 on failure. */ int (*standby)(struct audio_stream *stream); /** dump the state of the audio input/output device */ int (*dump)(const struct audio_stream *stream, int fd); /** Return the set of device(s) which this stream is connected to */ audio_devices_t (*get_device)(const struct audio_stream *stream); /** * Currently unused - set_device() corresponds to set_parameters() with key * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by * input streams only. */ int (*set_device)(struct audio_stream *stream, audio_devices_t device); /** * set/get audio stream parameters. The function accepts a list of * parameter key value pairs in the form: key1=value1;key2=value2;... * * Some keys are reserved for standard parameters (See AudioParameter class) * * If the implementation does not accept a parameter change while * the output is active but the parameter is acceptable otherwise, it must * return -ENOSYS. * * The audio flinger will put the stream in standby and then change the * parameter value. */ int (*set_parameters)(struct audio_stream *stream, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_stream *stream, const char *keys); int (*add_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); int (*remove_audio_effect)(const struct audio_stream *stream, effect_handle_t effect); }; typedef struct audio_stream audio_stream_t; /* type of asynchronous write callback events. Mutually exclusive */ typedef enum { STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */ STREAM_CBK_EVENT_DRAIN_READY /* drain completed */ } stream_callback_event_t; typedef int (*stream_callback_t)(stream_callback_event_t event, void *param, void *cookie); /* type of drain requested to audio_stream_out->drain(). Mutually exclusive */ typedef enum { AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data from the current track has been played to give time for gapless track switch */ } audio_drain_type_t; /** * audio_stream_out is the abstraction interface for the audio output hardware. * * It provides information about various properties of the audio output * hardware driver. */ struct audio_stream_out { /** * Common methods of the audio stream out. This *must* be the first member of audio_stream_out * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts * where it's known the audio_stream references an audio_stream_out. */ struct audio_stream common; /** * Return the audio hardware driver estimated latency in milliseconds. */ uint32_t (*get_latency)(const struct audio_stream_out *stream); /** * Use this method in situations where audio mixing is done in the * hardware. This method serves as a direct interface with hardware, * allowing you to directly set the volume as apposed to via the framework. * This method might produce multiple PCM outputs or hardware accelerated * codecs, such as MP3 or AAC. */ int (*set_volume)(struct audio_stream_out *stream, float left, float right); /** * Write audio buffer to driver. Returns number of bytes written, or a * negative status_t. If at least one frame was written successfully prior to the error, * it is suggested that the driver return that successful (short) byte count * and then return an error in the subsequent call. * * If set_callback() has previously been called to enable non-blocking mode * the write() is not allowed to block. It must write only the number of * bytes that currently fit in the driver/hardware buffer and then return * this byte count. If this is less than the requested write size the * callback function must be called when more space is available in the * driver/hardware buffer. */ ssize_t (*write)(struct audio_stream_out *stream, const void* buffer, size_t bytes); /* return the number of audio frames written by the audio dsp to DAC since * the output has exited standby */ int (*get_render_position)(const struct audio_stream_out *stream, uint32_t *dsp_frames); /** * get the local time at which the next write to the audio driver will be presented. * The units are microseconds, where the epoch is decided by the local audio HAL. */ int (*get_next_write_timestamp)(const struct audio_stream_out *stream, int64_t *timestamp); /** * set the callback function for notifying completion of non-blocking * write and drain. * Calling this function implies that all future write() and drain() * must be non-blocking and use the callback to signal completion. */ int (*set_callback)(struct audio_stream_out *stream, stream_callback_t callback, void *cookie); /** * Notifies to the audio driver to stop playback however the queued buffers are * retained by the hardware. Useful for implementing pause/resume. Empty implementation * if not supported however should be implemented for hardware with non-trivial * latency. In the pause state audio hardware could still be using power. User may * consider calling suspend after a timeout. * * Implementation of this function is mandatory for offloaded playback. */ int (*pause)(struct audio_stream_out* stream); /** * Notifies to the audio driver to resume playback following a pause. * Returns error if called without matching pause. * * Implementation of this function is mandatory for offloaded playback. */ int (*resume)(struct audio_stream_out* stream); /** * Requests notification when data buffered by the driver/hardware has * been played. If set_callback() has previously been called to enable * non-blocking mode, the drain() must not block, instead it should return * quickly and completion of the drain is notified through the callback. * If set_callback() has not been called, the drain() must block until * completion. * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written * data has been played. * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all * data for the current track has played to allow time for the framework * to perform a gapless track switch. * * Drain must return immediately on stop() and flush() call * * Implementation of this function is mandatory for offloaded playback. */ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); /** * Notifies to the audio driver to flush the queued data. Stream must already * be paused before calling flush(). * * Implementation of this function is mandatory for offloaded playback. */ int (*flush)(struct audio_stream_out* stream); /** * Return a recent count of the number of audio frames presented to an external observer. * This excludes frames which have been written but are still in the pipeline. * The count is not reset to zero when output enters standby. * Also returns the value of CLOCK_MONOTONIC as of this presentation count. * The returned count is expected to be 'recent', * but does not need to be the most recent possible value. * However, the associated time should correspond to whatever count is returned. * Example: assume that N+M frames have been presented, where M is a 'small' number. * Then it is permissible to return N instead of N+M, * and the timestamp should correspond to N rather than N+M. * The terms 'recent' and 'small' are not defined. * They reflect the quality of the implementation. * * 3.0 and higher only. */ int (*get_presentation_position)(const struct audio_stream_out *stream, uint64_t *frames, struct timespec *timestamp); }; typedef struct audio_stream_out audio_stream_out_t; struct audio_stream_in { /** * Common methods of the audio stream in. This *must* be the first member of audio_stream_in * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts * where it's known the audio_stream references an audio_stream_in. */ struct audio_stream common; /** set the input gain for the audio driver. This method is for * for future use */ int (*set_gain)(struct audio_stream_in *stream, float gain); /** Read audio buffer in from audio driver. Returns number of bytes read, or a * negative status_t. If at least one frame was read prior to the error, * read should return that byte count and then return an error in the subsequent call. */ ssize_t (*read)(struct audio_stream_in *stream, void* buffer, size_t bytes); /** * Return the amount of input frames lost in the audio driver since the * last call of this function. * Audio driver is expected to reset the value to 0 and restart counting * upon returning the current value by this function call. * Such loss typically occurs when the user space process is blocked * longer than the capacity of audio driver buffers. * * Unit: the number of input audio frames */ uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream); }; typedef struct audio_stream_in audio_stream_in_t; /** * return the frame size (number of bytes per sample). * * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead. */ __attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(const struct audio_stream *s) { size_t chan_samp_sz; audio_format_t format = s->get_format(s); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return popcount(s->get_channels(s)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an output stream. */ static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_t); } /** * return the frame size (number of bytes per sample) of an input stream. */ static inline size_t audio_stream_in_frame_size(const struct audio_stream_in *s) { size_t chan_samp_sz; audio_format_t format = s->common.get_format(&s->common); if (audio_is_linear_pcm(format)) { chan_samp_sz = audio_bytes_per_sample(format); return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz; } return sizeof(int8_t); } /**********************************************************************/ /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ struct audio_module { struct hw_module_t common; }; struct audio_hw_device { /** * Common methods of the audio device. This *must* be the first member of audio_hw_device * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts * where it's known the hw_device_t references an audio_hw_device. */ struct hw_device_t common; /** * used by audio flinger to enumerate what devices are supported by * each audio_hw_device implementation. * * Return value is a bitmask of 1 or more values of audio_devices_t * * NOTE: audio HAL implementations starting with * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. * All supported devices should be listed in audio_policy.conf * file and the audio policy manager must choose the appropriate * audio module based on information in this file. */ uint32_t (*get_supported_devices)(const struct audio_hw_device *dev); /** * check to see if the audio hardware interface has been initialized. * returns 0 on success, -ENODEV on failure. */ int (*init_check)(const struct audio_hw_device *dev); /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ int (*set_voice_volume)(struct audio_hw_device *dev, float volume); /** * set the audio volume for all audio activities other than voice call. * Range between 0.0 and 1.0. If any value other than 0 is returned, * the software mixer will emulate this capability. */ int (*set_master_volume)(struct audio_hw_device *dev, float volume); /** * Get the current master volume value for the HAL, if the HAL supports * master volume control. AudioFlinger will query this value from the * primary audio HAL when the service starts and use the value for setting * the initial master volume across all HALs. HALs which do not support * this method may leave it set to NULL. */ int (*get_master_volume)(struct audio_hw_device *dev, float *volume); /** * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is * playing, and AUDIO_MODE_IN_CALL when a call is in progress. */ int (*set_mode)(struct audio_hw_device *dev, audio_mode_t mode); /* mic mute */ int (*set_mic_mute)(struct audio_hw_device *dev, bool state); int (*get_mic_mute)(const struct audio_hw_device *dev, bool *state); /* set/get global audio parameters */ int (*set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); /* * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(const struct audio_hw_device *dev, const char *keys); /* Returns audio input buffer size according to parameters passed or * 0 if one of the parameters is not supported. * See also get_buffer_size which is for a particular stream. */ size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, const struct audio_config *config); /** This method creates and opens the audio hardware output stream. * The "address" parameter qualifies the "devices" audio device type if needed. * The format format depends on the device type: * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC" * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y" * - Other devices may use a number or any other string. */ int (*open_output_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, audio_output_flags_t flags, struct audio_config *config, struct audio_stream_out **stream_out, const char *address); void (*close_output_stream)(struct audio_hw_device *dev, struct audio_stream_out* stream_out); /** This method creates and opens the audio hardware input stream */ int (*open_input_stream)(struct audio_hw_device *dev, audio_io_handle_t handle, audio_devices_t devices, struct audio_config *config, struct audio_stream_in **stream_in, audio_input_flags_t flags, const char *address, audio_source_t source); void (*close_input_stream)(struct audio_hw_device *dev, struct audio_stream_in *stream_in); /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); /** * set the audio mute status for all audio activities. If any value other * than 0 is returned, the software mixer will emulate this capability. */ int (*set_master_mute)(struct audio_hw_device *dev, bool mute); /** * Get the current master mute status for the HAL, if the HAL supports * master mute control. AudioFlinger will query this value from the primary * audio HAL when the service starts and use the value for setting the * initial master mute across all HALs. HALs which do not support this * method may leave it set to NULL. */ int (*get_master_mute)(struct audio_hw_device *dev, bool *mute); /** * Routing control */ /* Creates an audio patch between several source and sink ports. * The handle is allocated by the HAL and should be unique for this * audio HAL module. */ int (*create_audio_patch)(struct audio_hw_device *dev, unsigned int num_sources, const struct audio_port_config *sources, unsigned int num_sinks, const struct audio_port_config *sinks, audio_patch_handle_t *handle); /* Release an audio patch */ int (*release_audio_patch)(struct audio_hw_device *dev, audio_patch_handle_t handle); /* Fills the list of supported attributes for a given audio port. * As input, "port" contains the information (type, role, address etc...) * needed by the HAL to identify the port. * As output, "port" contains possible attributes (sampling rates, formats, * channel masks, gain controllers...) for this port. */ int (*get_audio_port)(struct audio_hw_device *dev, struct audio_port *port); /* Set audio port configuration */ int (*set_audio_port_config)(struct audio_hw_device *dev, const struct audio_port_config *config); #ifdef AUDIO_LISTEN_ENABLED /** This method creates the listen session and returns handle */ int (*open_listen_session)(struct audio_hw_device *dev, listen_open_params_t *params, struct listen_session** handle); /** This method closes the listen session */ int (*close_listen_session)(struct audio_hw_device *dev, struct listen_session* handle); /** This method sets the mad observer callback */ int (*set_mad_observer)(struct audio_hw_device *dev, listen_callback_t cb_func); /** * This method is used for setting listen hal specfic parameters. * If multiple paramets are set in one call and setting any one of them * fails it will return failure. */ int (*listen_set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); #endif }; typedef struct audio_hw_device audio_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int audio_hw_device_open(const struct hw_module_t* module, struct audio_hw_device** device) { return module->methods->open(module, AUDIO_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int audio_hw_device_close(struct audio_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/audio_alsaops.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* This file contains shared utility functions to handle the tinyalsa * implementation for Android internal audio, generally in the hardware layer. * Some routines may log a fatal error on failure, as noted. */ #ifndef ANDROID_AUDIO_ALSAOPS_H #define ANDROID_AUDIO_ALSAOPS_H #include #include #include __BEGIN_DECLS /* Converts audio_format to pcm_format. * Parameters: * format the audio_format_t to convert * * Logs a fatal error if format is not a valid convertible audio_format_t. */ static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_BE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3BE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_BE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_BE; #else case AUDIO_FORMAT_PCM_16_BIT: return PCM_FORMAT_S16_LE; case AUDIO_FORMAT_PCM_24_BIT_PACKED: return PCM_FORMAT_S24_3LE; case AUDIO_FORMAT_PCM_32_BIT: return PCM_FORMAT_S32_LE; case AUDIO_FORMAT_PCM_8_24_BIT: return PCM_FORMAT_S24_LE; #endif case AUDIO_FORMAT_PCM_FLOAT: /* there is no equivalent for float */ default: LOG_ALWAYS_FATAL("pcm_format_from_audio_format: invalid audio format %#x", format); return 0; } } /* Converts pcm_format to audio_format. * Parameters: * format the pcm_format to convert * * Logs a fatal error if format is not a valid convertible pcm_format. */ static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) { switch (format) { #ifdef HAVE_BIG_ENDIAN case PCM_FORMAT_S16_BE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3BE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_BE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_BE: return AUDIO_FORMAT_PCM_32_BIT; #else case PCM_FORMAT_S16_LE: return AUDIO_FORMAT_PCM_16_BIT; case PCM_FORMAT_S24_3LE: return AUDIO_FORMAT_PCM_24_BIT_PACKED; case PCM_FORMAT_S24_LE: return AUDIO_FORMAT_PCM_8_24_BIT; case PCM_FORMAT_S32_LE: return AUDIO_FORMAT_PCM_32_BIT; #endif default: LOG_ALWAYS_FATAL("audio_format_from_pcm_format: invalid pcm format %#x", format); return 0; } } __END_DECLS #endif /* ANDROID_AUDIO_ALSAOPS_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/audio_amplifier.h ================================================ /* * Copyright (C) 2015, The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef CM_AUDIO_AMPLIFIER_INTERFACE_H #define CM_AUDIO_AMPLIFIER_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS #define AMPLIFIER_HARDWARE_MODULE_ID "audio_amplifier" #define AMPLIFIER_HARDWARE_INTERFACE "audio_amplifier_hw_if" #define AMPLIFIER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define AMPLIFIER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define AMPLIFIER_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define AMPLIFIER_DEVICE_API_VERSION_CURRENT AMPLIFIER_DEVICE_API_VERSION_2_0 struct str_parms; typedef struct amplifier_device { /** * Common methods of the amplifier device. This *must* be the first member * of amplifier_device as users of this structure will cast a hw_device_t * to amplifier_device pointer in contexts where it's known * the hw_device_t references a amplifier_device. */ struct hw_device_t common; /** * Notify amplifier device of current input devices * * This function should handle only input devices. */ int (*set_input_devices)(struct amplifier_device *device, uint32_t devices); /** * Notify amplifier device of current output devices * * This function should handle only output devices. */ int (*set_output_devices)(struct amplifier_device *device, uint32_t devices); /** * Notify amplifier device of output device enable/disable * * This function should handle only output devices. */ int (*enable_output_devices)(struct amplifier_device *device, uint32_t devices, bool enable); /** * Notify amplifier device of input device enable/disable * * This function should handle only input devices. */ int (*enable_input_devices)(struct amplifier_device *device, uint32_t devices, bool enable); /** * Notify amplifier device about current audio mode */ int (*set_mode)(struct amplifier_device *device, audio_mode_t mode); /** * Notify amplifier device that an output stream has started */ int (*output_stream_start)(struct amplifier_device *device, struct audio_stream_out *stream, bool offload); /** * Notify amplifier device that an input stream has started */ int (*input_stream_start)(struct amplifier_device *device, struct audio_stream_in *stream); /** * Notify amplifier device that an output stream has stopped */ int (*output_stream_standby)(struct amplifier_device *device, struct audio_stream_out *stream); /** * Notify amplifier device that an input stream has stopped */ int (*input_stream_standby)(struct amplifier_device *device, struct audio_stream_in *stream); /** * set/get output audio device parameters. */ int (*set_parameters)(struct amplifier_device *device, struct str_parms *parms); } amplifier_device_t; typedef struct amplifier_module { /** * Common methods of the amplifier module. This *must* be the first member * of amplifier_module as users of this structure will cast a hw_module_t * to amplifier_module pointer in contexts where it's known * the hw_module_t references a amplifier_module. */ struct hw_module_t common; } amplifier_module_t; /** convenience API for opening and closing a supported device */ static inline int amplifier_device_open(const struct hw_module_t *module, struct amplifier_device **device) { return module->methods->open(module, AMPLIFIER_HARDWARE_INTERFACE, (struct hw_device_t **) device); } static inline int amplifier_device_close(struct amplifier_device *device) { return device->common.close(&device->common); } __END_DECLS #endif // CM_AUDIO_AMPLIFIER_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/audio_effect.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_AUDIO_EFFECT_H #define ANDROID_AUDIO_EFFECT_H #include #include #include #include #include #include #include __BEGIN_DECLS ///////////////////////////////////////////////// // Common Definitions ///////////////////////////////////////////////// // //--- Effect descriptor structure effect_descriptor_t // // Unique effect ID (can be generated from the following site: // http://www.itu.int/ITU-T/asn1/uuid.html) // This format is used for both "type" and "uuid" fields of the effect descriptor structure. // - When used for effect type and the engine is implementing and effect corresponding to a standard // OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface. // - When used as uuid, it should be a unique UUID for this particular implementation. typedef struct effect_uuid_s { uint32_t timeLow; uint16_t timeMid; uint16_t timeHiAndVersion; uint16_t clockSeq; uint8_t node[6]; } effect_uuid_t; // Maximum length of character strings in structures defines by this API. #define EFFECT_STRING_LEN_MAX 64 // NULL UUID definition (matches SL_IID_NULL_) #define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \ { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } } static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER; static const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_; static const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210"; // The effect descriptor contains necessary information to facilitate the enumeration of the effect // engines present in a library. typedef struct effect_descriptor_s { effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect effect_uuid_t uuid; // UUID for this particular implementation uint32_t apiVersion; // Version of the effect control API implemented uint32_t flags; // effect engine capabilities/requirements flags (see below) uint16_t cpuLoad; // CPU load indication (see below) uint16_t memoryUsage; // Data Memory usage (see below) char name[EFFECT_STRING_LEN_MAX]; // human readable effect name char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name } effect_descriptor_t; // CPU load and memory usage indication: each effect implementation must provide an indication of // its CPU and memory usage for the audio effect framework to limit the number of effects // instantiated at a given time on a given platform. // The CPU load is expressed in 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS. // The memory usage is expressed in KB and includes only dynamically allocated memory // Definitions for flags field of effect descriptor. // +---------------------------+-----------+----------------------------------- // | description | bits | values // +---------------------------+-----------+----------------------------------- // | connection mode | 0..2 | 0 insert: after track process // | | | 1 auxiliary: connect to track auxiliary // | | | output and use send level // | | | 2 replace: replaces track process function; // | | | must implement SRC, volume and mono to stereo. // | | | 3 pre processing: applied below audio HAL on input // | | | 4 post processing: applied below audio HAL on output // | | | 5 - 7 reserved // +---------------------------+-----------+----------------------------------- // | insertion preference | 3..5 | 0 none // | | | 1 first of the chain // | | | 2 last of the chain // | | | 3 exclusive (only effect in the insert chain) // | | | 4..7 reserved // +---------------------------+-----------+----------------------------------- // | Volume management | 6..8 | 0 none // | | | 1 implements volume control // | | | 2 requires volume indication // | | | 4 reserved // +---------------------------+-----------+----------------------------------- // | Device indication | 9..11 | 0 none // | | | 1 requires device updates // | | | 2, 4 reserved // +---------------------------+-----------+----------------------------------- // | Sample input mode | 12..13 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG // | | | command must specify a buffer descriptor // | | | 2 provider: process() function uses the // | | | bufferProvider indicated by the // | | | EFFECT_CMD_SET_CONFIG command to request input. // | | | buffers. // | | | 3 both: both input modes are supported // +---------------------------+-----------+----------------------------------- // | Sample output mode | 14..15 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG // | | | command must specify a buffer descriptor // | | | 2 provider: process() function uses the // | | | bufferProvider indicated by the // | | | EFFECT_CMD_SET_CONFIG command to request output // | | | buffers. // | | | 3 both: both output modes are supported // +---------------------------+-----------+----------------------------------- // | Hardware acceleration | 16..17 | 0 No hardware acceleration // | | | 1 non tunneled hw acceleration: the process() function // | | | reads the samples, send them to HW accelerated // | | | effect processor, reads back the processed samples // | | | and returns them to the output buffer. // | | | 2 tunneled hw acceleration: the process() function is // | | | transparent. The effect interface is only used to // | | | control the effect engine. This mode is relevant for // | | | global effects actually applied by the audio // | | | hardware on the output stream. // +---------------------------+-----------+----------------------------------- // | Audio Mode indication | 18..19 | 0 none // | | | 1 requires audio mode updates // | | | 2..3 reserved // +---------------------------+-----------+----------------------------------- // | Audio source indication | 20..21 | 0 none // | | | 1 requires audio source updates // | | | 2..3 reserved // +---------------------------+-----------+----------------------------------- // | Effect offload supported | 22 | 0 The effect cannot be offloaded to an audio DSP // | | | 1 The effect can be offloaded to an audio DSP // +---------------------------+-----------+----------------------------------- // Insert mode #define EFFECT_FLAG_TYPE_SHIFT 0 #define EFFECT_FLAG_TYPE_SIZE 3 #define EFFECT_FLAG_TYPE_MASK (((1 << EFFECT_FLAG_TYPE_SIZE) -1) \ << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_INSERT (0 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_AUXILIARY (1 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_REPLACE (2 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_PRE_PROC (3 << EFFECT_FLAG_TYPE_SHIFT) #define EFFECT_FLAG_TYPE_POST_PROC (4 << EFFECT_FLAG_TYPE_SHIFT) // Insert preference #define EFFECT_FLAG_INSERT_SHIFT (EFFECT_FLAG_TYPE_SHIFT + EFFECT_FLAG_TYPE_SIZE) #define EFFECT_FLAG_INSERT_SIZE 3 #define EFFECT_FLAG_INSERT_MASK (((1 << EFFECT_FLAG_INSERT_SIZE) -1) \ << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_ANY (0 << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_FIRST (1 << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_LAST (2 << EFFECT_FLAG_INSERT_SHIFT) #define EFFECT_FLAG_INSERT_EXCLUSIVE (3 << EFFECT_FLAG_INSERT_SHIFT) // Volume control #define EFFECT_FLAG_VOLUME_SHIFT (EFFECT_FLAG_INSERT_SHIFT + EFFECT_FLAG_INSERT_SIZE) #define EFFECT_FLAG_VOLUME_SIZE 3 #define EFFECT_FLAG_VOLUME_MASK (((1 << EFFECT_FLAG_VOLUME_SIZE) -1) \ << EFFECT_FLAG_VOLUME_SHIFT) #define EFFECT_FLAG_VOLUME_CTRL (1 << EFFECT_FLAG_VOLUME_SHIFT) #define EFFECT_FLAG_VOLUME_IND (2 << EFFECT_FLAG_VOLUME_SHIFT) #define EFFECT_FLAG_VOLUME_NONE (0 << EFFECT_FLAG_VOLUME_SHIFT) // Device indication #define EFFECT_FLAG_DEVICE_SHIFT (EFFECT_FLAG_VOLUME_SHIFT + EFFECT_FLAG_VOLUME_SIZE) #define EFFECT_FLAG_DEVICE_SIZE 3 #define EFFECT_FLAG_DEVICE_MASK (((1 << EFFECT_FLAG_DEVICE_SIZE) -1) \ << EFFECT_FLAG_DEVICE_SHIFT) #define EFFECT_FLAG_DEVICE_IND (1 << EFFECT_FLAG_DEVICE_SHIFT) #define EFFECT_FLAG_DEVICE_NONE (0 << EFFECT_FLAG_DEVICE_SHIFT) // Sample input modes #define EFFECT_FLAG_INPUT_SHIFT (EFFECT_FLAG_DEVICE_SHIFT + EFFECT_FLAG_DEVICE_SIZE) #define EFFECT_FLAG_INPUT_SIZE 2 #define EFFECT_FLAG_INPUT_MASK (((1 << EFFECT_FLAG_INPUT_SIZE) -1) \ << EFFECT_FLAG_INPUT_SHIFT) #define EFFECT_FLAG_INPUT_DIRECT (1 << EFFECT_FLAG_INPUT_SHIFT) #define EFFECT_FLAG_INPUT_PROVIDER (2 << EFFECT_FLAG_INPUT_SHIFT) #define EFFECT_FLAG_INPUT_BOTH (3 << EFFECT_FLAG_INPUT_SHIFT) // Sample output modes #define EFFECT_FLAG_OUTPUT_SHIFT (EFFECT_FLAG_INPUT_SHIFT + EFFECT_FLAG_INPUT_SIZE) #define EFFECT_FLAG_OUTPUT_SIZE 2 #define EFFECT_FLAG_OUTPUT_MASK (((1 << EFFECT_FLAG_OUTPUT_SIZE) -1) \ << EFFECT_FLAG_OUTPUT_SHIFT) #define EFFECT_FLAG_OUTPUT_DIRECT (1 << EFFECT_FLAG_OUTPUT_SHIFT) #define EFFECT_FLAG_OUTPUT_PROVIDER (2 << EFFECT_FLAG_OUTPUT_SHIFT) #define EFFECT_FLAG_OUTPUT_BOTH (3 << EFFECT_FLAG_OUTPUT_SHIFT) // Hardware acceleration mode #define EFFECT_FLAG_HW_ACC_SHIFT (EFFECT_FLAG_OUTPUT_SHIFT + EFFECT_FLAG_OUTPUT_SIZE) #define EFFECT_FLAG_HW_ACC_SIZE 2 #define EFFECT_FLAG_HW_ACC_MASK (((1 << EFFECT_FLAG_HW_ACC_SIZE) -1) \ << EFFECT_FLAG_HW_ACC_SHIFT) #define EFFECT_FLAG_HW_ACC_SIMPLE (1 << EFFECT_FLAG_HW_ACC_SHIFT) #define EFFECT_FLAG_HW_ACC_TUNNEL (2 << EFFECT_FLAG_HW_ACC_SHIFT) // Audio mode indication #define EFFECT_FLAG_AUDIO_MODE_SHIFT (EFFECT_FLAG_HW_ACC_SHIFT + EFFECT_FLAG_HW_ACC_SIZE) #define EFFECT_FLAG_AUDIO_MODE_SIZE 2 #define EFFECT_FLAG_AUDIO_MODE_MASK (((1 << EFFECT_FLAG_AUDIO_MODE_SIZE) -1) \ << EFFECT_FLAG_AUDIO_MODE_SHIFT) #define EFFECT_FLAG_AUDIO_MODE_IND (1 << EFFECT_FLAG_AUDIO_MODE_SHIFT) #define EFFECT_FLAG_AUDIO_MODE_NONE (0 << EFFECT_FLAG_AUDIO_MODE_SHIFT) // Audio source indication #define EFFECT_FLAG_AUDIO_SOURCE_SHIFT (EFFECT_FLAG_AUDIO_MODE_SHIFT + EFFECT_FLAG_AUDIO_MODE_SIZE) #define EFFECT_FLAG_AUDIO_SOURCE_SIZE 2 #define EFFECT_FLAG_AUDIO_SOURCE_MASK (((1 << EFFECT_FLAG_AUDIO_SOURCE_SIZE) -1) \ << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) #define EFFECT_FLAG_AUDIO_SOURCE_IND (1 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) #define EFFECT_FLAG_AUDIO_SOURCE_NONE (0 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) // Effect offload indication #define EFFECT_FLAG_OFFLOAD_SHIFT (EFFECT_FLAG_AUDIO_SOURCE_SHIFT + \ EFFECT_FLAG_AUDIO_SOURCE_SIZE) #define EFFECT_FLAG_OFFLOAD_SIZE 1 #define EFFECT_FLAG_OFFLOAD_MASK (((1 << EFFECT_FLAG_OFFLOAD_SIZE) -1) \ << EFFECT_FLAG_OFFLOAD_SHIFT) #define EFFECT_FLAG_OFFLOAD_SUPPORTED (1 << EFFECT_FLAG_OFFLOAD_SHIFT) #define EFFECT_MAKE_API_VERSION(M, m) (((M)<<16) | ((m) & 0xFFFF)) #define EFFECT_API_VERSION_MAJOR(v) ((v)>>16) #define EFFECT_API_VERSION_MINOR(v) ((m) & 0xFFFF) ///////////////////////////////////////////////// // Effect control interface ///////////////////////////////////////////////// // Effect control interface version 2.0 #define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) // Effect control interface structure: effect_interface_s // The effect control interface is exposed by each effect engine implementation. It consists of // a set of functions controlling the configuration, activation and process of the engine. // The functions are grouped in a structure of type effect_interface_s. // // Effect control interface handle: effect_handle_t // The effect_handle_t serves two purposes regarding the implementation of the effect engine: // - 1 it is the address of a pointer to an effect_interface_s structure where the functions // of the effect control API for a particular effect are located. // - 2 it is the address of the context of a particular effect instance. // A typical implementation in the effect library would define a structure as follows: // struct effect_module_s { // const struct effect_interface_s *itfe; // effect_config_t config; // effect_context_t context; // } // The implementation of EffectCreate() function would then allocate a structure of this // type and return its address as effect_handle_t typedef struct effect_interface_s **effect_handle_t; // Forward definition of type audio_buffer_t typedef struct audio_buffer_s audio_buffer_t; // Effect control interface definition struct effect_interface_s { //////////////////////////////////////////////////////////////////////////////// // // Function: process // // Description: Effect process function. Takes input samples as specified // (count and location) in input buffer descriptor and output processed // samples as specified in output buffer descriptor. If the buffer descriptor // is not specified the function must use either the buffer or the // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. // The effect framework will call the process() function after the EFFECT_CMD_ENABLE // command is received and until the EFFECT_CMD_DISABLE is received. When the engine // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully // and when done indicate that it is OK to stop calling the process() function by // returning the -ENODATA status. // // NOTE: the process() function implementation should be "real-time safe" that is // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, // pthread_cond_wait/pthread_mutex_lock... // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); //////////////////////////////////////////////////////////////////////////////// // // Function: command // // Description: Send a command and receive a response to/from effect engine. // // Input: // self: handle to the effect interface this function // is called on. // cmdCode: command code: the command can be a standardized command defined in // effect_command_e (see below) or a proprietary command. // cmdSize: size of command in bytes // pCmdData: pointer to command data // pReplyData: pointer to reply data // // Input/Output: // replySize: maximum size of reply data as input // actual size of reply data as output // // Output: // returned value: 0 successful operation // -EINVAL invalid interface handle or // invalid command/reply size or format according to // command code // The return code should be restricted to indicate problems related to this API // specification. Status related to the execution of a particular command should be // indicated as part of the reply field. // // *pReplyData updated with command response // //////////////////////////////////////////////////////////////////////////////// int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t *replySize, void *pReplyData); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the effect descriptor // // Input: // self: handle to the effect interface this function // is called on. // // Input/Output: // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -EINVAL invalid interface handle or invalid pDescriptor // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t *pDescriptor); //////////////////////////////////////////////////////////////////////////////// // // Function: process_reverse // // Description: Process reverse stream function. This function is used to pass // a reference stream to the effect engine. If the engine does not need a reference // stream, this function pointer can be set to NULL. // This function would typically implemented by an Echo Canceler. // // Input: // self: handle to the effect interface this function // is called on. // inBuffer: buffer descriptor indicating where to read samples to process. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // // outBuffer: buffer descriptor indicating where to write processed samples. // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. // If the buffer and buffer provider in the configuration received by // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse // stream data // // Output: // returned value: 0 successful operation // -ENODATA the engine has finished the disable phase and the framework // can stop calling process_reverse() // -EINVAL invalid interface handle or // invalid input/output buffer description //////////////////////////////////////////////////////////////////////////////// int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t *inBuffer, audio_buffer_t *outBuffer); }; // //--- Standardized command codes for command() function // enum effect_command_e { EFFECT_CMD_INIT, // initialize effect engine EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t) EFFECT_CMD_RESET, // reset effect engine EFFECT_CMD_ENABLE, // enable effect process EFFECT_CMD_DISABLE, // disable effect process EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t) EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred EFFECT_CMD_GET_PARAM, // get parameter EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t) EFFECT_CMD_SET_VOLUME, // set volume EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...) EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t) EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t) EFFECT_CMD_GET_CONFIG, // read effect engine configuration EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature. EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t) EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one, // send the ioHandle of the effect thread EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code }; //================================================================================================== // command: EFFECT_CMD_INIT //-------------------------------------------------------------------------------------------------- // description: // Initialize effect engine: All configurations return to default //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Apply new audio parameters configurations for input and output buffers //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_config_t) // data: effect_config_t //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_RESET //-------------------------------------------------------------------------------------------------- // description: // Reset the effect engine. Keep configuration but resets state and buffer content //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_ENABLE //-------------------------------------------------------------------------------------------------- // description: // Enable the process. Called by the framework before the first call to process() //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_DISABLE //-------------------------------------------------------------------------------------------------- // description: // Disable the process. Called by the framework after the last call to process() //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_PARAM //-------------------------------------------------------------------------------------------------- // description: // Set a parameter and apply it immediately //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_param_t) + size of param and value // data: effect_param_t + param + value. See effect_param_t definition below for value offset //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_PARAM_DEFERRED //-------------------------------------------------------------------------------------------------- // description: // Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_param_t) + size of param and value // data: effect_param_t + param + value. See effect_param_t definition below for value offset //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_SET_PARAM_COMMIT //-------------------------------------------------------------------------------------------------- // description: // Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_GET_PARAM //-------------------------------------------------------------------------------------------------- // description: // Get a parameter value //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_param_t) + size of param // data: effect_param_t + param //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(effect_param_t) + size of param and value // data: effect_param_t + param + value. See effect_param_t definition below for value offset //================================================================================================== // command: EFFECT_CMD_SET_DEVICE //-------------------------------------------------------------------------------------------------- // description: // Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t // for device values. // The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this // command when the device changes //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_SET_VOLUME //-------------------------------------------------------------------------------------------------- // description: // Set and get volume. Used by audio framework to delegate volume control to effect engine. // The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in // its descriptor to receive this command before every call to process() function // If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return // the volume that should be applied before the effect is processed. The overall volume (the volume // actually applied by the effect engine multiplied by the returned value) should match the value // indicated in the command. //-------------------------------------------------------------------------------------------------- // command format: // size: n * sizeof(uint32_t) // data: volume for each channel defined in effect_config_t for output buffer expressed in // 8.24 fixed point format //-------------------------------------------------------------------------------------------------- // reply format: // size: n * sizeof(uint32_t) / 0 // data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor: // volume for each channel defined in effect_config_t for output buffer expressed in // 8.24 fixed point format // - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor: // N/A // It is legal to receive a null pointer as pReplyData in which case the effect framework has // delegated volume control to another effect //================================================================================================== // command: EFFECT_CMD_SET_AUDIO_MODE //-------------------------------------------------------------------------------------------------- // description: // Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its // descriptor to receive this command when the audio mode changes. //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: audio_mode_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_SET_CONFIG_REVERSE //-------------------------------------------------------------------------------------------------- // description: // Apply new audio parameters configurations for input and output buffers of reverse stream. // An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler. //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_config_t) // data: effect_config_t //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(int) // data: status //================================================================================================== // command: EFFECT_CMD_SET_INPUT_DEVICE //-------------------------------------------------------------------------------------------------- // description: // Set the capture device the audio input path is connected to. See audio.h, audio_devices_t // for device values. // The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this // command when the device changes //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_GET_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Read audio parameters configurations for input and output buffers //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(effect_config_t) // data: effect_config_t //================================================================================================== // command: EFFECT_CMD_GET_CONFIG_REVERSE //-------------------------------------------------------------------------------------------------- // description: // Read audio parameters configurations for input and output buffers of reverse stream //-------------------------------------------------------------------------------------------------- // command format: // size: 0 // data: N/A //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(effect_config_t) // data: effect_config_t //================================================================================================== // command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS //-------------------------------------------------------------------------------------------------- // description: // Queries for supported configurations for a particular feature (e.g. get the supported // combinations of main and auxiliary channels for a noise suppressor). // The command parameter is the feature identifier (See effect_feature_e for a list of defined // features) followed by the maximum number of configuration descriptor to return. // The reply is composed of: // - status (uint32_t): // - 0 if feature is supported // - -ENOSYS if the feature is not supported, // - -ENOMEM if the feature is supported but the total number of supported configurations // exceeds the maximum number indicated by the caller. // - total number of supported configurations (uint32_t) // - an array of configuration descriptors. // The actual number of descriptors returned must not exceed the maximum number indicated by // the caller. //-------------------------------------------------------------------------------------------------- // command format: // size: 2 x sizeof(uint32_t) // data: effect_feature_e + maximum number of configurations to return //-------------------------------------------------------------------------------------------------- // reply format: // size: 2 x sizeof(uint32_t) + n x sizeof () // data: status + total number of configurations supported + array of n config descriptors //================================================================================================== // command: EFFECT_CMD_GET_FEATURE_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Retrieves current configuration for a given feature. // The reply status is: // - 0 if feature is supported // - -ENOSYS if the feature is not supported, //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: effect_feature_e //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(uint32_t) + sizeof () // data: status + config descriptor //================================================================================================== // command: EFFECT_CMD_SET_FEATURE_CONFIG //-------------------------------------------------------------------------------------------------- // description: // Sets current configuration for a given feature. // The reply status is: // - 0 if feature is supported // - -ENOSYS if the feature is not supported, // - -EINVAL if the configuration is invalid //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) + sizeof () // data: effect_feature_e + config descriptor //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(uint32_t) // data: status //================================================================================================== // command: EFFECT_CMD_SET_AUDIO_SOURCE //-------------------------------------------------------------------------------------------------- // description: // Set the audio source the capture path is configured for (Camcorder, voice recognition...). // See audio.h, audio_source_t for values. //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // reply format: // size: 0 // data: N/A //================================================================================================== // command: EFFECT_CMD_OFFLOAD //-------------------------------------------------------------------------------------------------- // description: // 1.indicate if the playback thread the effect is attached to is offloaded or not // 2.update the io handle of the playback thread the effect is attached to //-------------------------------------------------------------------------------------------------- // command format: // size: sizeof(effect_offload_param_t) // data: effect_offload_param_t //-------------------------------------------------------------------------------------------------- // reply format: // size: sizeof(uint32_t) // data: uint32_t //-------------------------------------------------------------------------------------------------- // command: EFFECT_CMD_FIRST_PROPRIETARY //-------------------------------------------------------------------------------------------------- // description: // All proprietary effect commands must use command codes above this value. The size and format of // command and response fields is free in this case //================================================================================================== // Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t // structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with // regard to the channel mask definition in audio.h, audio_channel_mask_t e.g : // Stereo: left, right // 5 point 1: front left, front right, front center, low frequency, back left, back right // The buffer size is expressed in frame count, a frame being composed of samples for all // channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by // definition struct audio_buffer_s { size_t frameCount; // number of frames in buffer union { void* raw; // raw pointer to start of buffer int32_t* s32; // pointer to signed 32 bit data at start of buffer int16_t* s16; // pointer to signed 16 bit data at start of buffer uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer }; }; // The buffer_provider_s structure contains functions that can be used // by the effect engine process() function to query and release input // or output audio buffer. // The getBuffer() function is called to retrieve a buffer where data // should read from or written to by process() function. // The releaseBuffer() function MUST be called when the buffer retrieved // with getBuffer() is not needed anymore. // The process function should use the buffer provider mechanism to retrieve // input or output buffer if the inBuffer or outBuffer passed as argument is NULL // and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_SET_CONFIG // command did not specify an audio buffer. typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer); typedef struct buffer_provider_s { buffer_function_t getBuffer; // retrieve next buffer buffer_function_t releaseBuffer; // release used buffer void *cookie; // for use by client of buffer provider functions } buffer_provider_t; // The buffer_config_s structure specifies the input or output audio format // to be used by the effect engine. It is part of the effect_config_t // structure that defines both input and output buffer configurations and is // passed by the EFFECT_CMD_SET_CONFIG or EFFECT_CMD_SET_CONFIG_REVERSE command. typedef struct buffer_config_s { audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly uint32_t samplingRate; // sampling rate uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h) buffer_provider_t bufferProvider; // buffer provider uint8_t format; // Audio format (see audio_format_t in audio.h) uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e) uint16_t mask; // indicates which of the above fields is valid } buffer_config_t; // Values for "accessMode" field of buffer_config_t: // overwrite, read only, accumulate (read/modify/write) enum effect_buffer_access_e { EFFECT_BUFFER_ACCESS_WRITE, EFFECT_BUFFER_ACCESS_READ, EFFECT_BUFFER_ACCESS_ACCUMULATE }; // feature identifiers for EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS command enum effect_feature_e { EFFECT_FEATURE_AUX_CHANNELS, // supports auxiliary channels (e.g. dual mic noise suppressor) EFFECT_FEATURE_CNT }; // EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combination // of main and auxiliary channels supported typedef struct channel_config_s { audio_channel_mask_t main_channels; // channel mask for main channels audio_channel_mask_t aux_channels; // channel mask for auxiliary channels } channel_config_t; // Values for bit field "mask" in buffer_config_t. If a bit is set, the corresponding field // in buffer_config_t must be taken into account when executing the EFFECT_CMD_SET_CONFIG command #define EFFECT_CONFIG_BUFFER 0x0001 // buffer field must be taken into account #define EFFECT_CONFIG_SMP_RATE 0x0002 // samplingRate field must be taken into account #define EFFECT_CONFIG_CHANNELS 0x0004 // channels field must be taken into account #define EFFECT_CONFIG_FORMAT 0x0008 // format field must be taken into account #define EFFECT_CONFIG_ACC_MODE 0x0010 // accessMode field must be taken into account #define EFFECT_CONFIG_PROVIDER 0x0020 // bufferProvider field must be taken into account #define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE | \ EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT | \ EFFECT_CONFIG_ACC_MODE | EFFECT_CONFIG_PROVIDER) // effect_config_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_CONFIG // command to configure audio parameters and buffers for effect engine input and output. typedef struct effect_config_s { buffer_config_t inputCfg; buffer_config_t outputCfg; } effect_config_t; // effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM // command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command. // psize and vsize represent the actual size of parameter and value. // // NOTE: the start of value field inside the data field is always on a 32 bit boundary: // // +-----------+ // | status | sizeof(int) // +-----------+ // | psize | sizeof(int) // +-----------+ // | vsize | sizeof(int) // +-----------+ // | | | | // ~ parameter ~ > psize | // | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int) // +-----------+ | // | padding | | // +-----------+ // | | | // ~ value ~ > vsize // | | | // +-----------+ typedef struct effect_param_s { int32_t status; // Transaction status (unused for command, used for reply) uint32_t psize; // Parameter size uint32_t vsize; // Value size char data[]; // Start of Parameter + Value data } effect_param_t; // structure used by EFFECT_CMD_OFFLOAD command typedef struct effect_offload_param_s { bool isOffload; // true if the playback thread the effect is attached to is offloaded int ioHandle; // io handle of the playback thread the effect is attached to } effect_offload_param_t; ///////////////////////////////////////////////// // Effect library interface ///////////////////////////////////////////////// // Effect library interface version 3.0 // Note that EffectsFactory.c only checks the major version component, so changes to the minor // number can only be used for fully backwards compatible changes #define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) #define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) // Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM // and the fields of this data structure must begin with audio_effect_library_t typedef struct audio_effect_library_s { // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG uint32_t tag; // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor uint32_t version; // Name of this library const char *name; // Author/owner/implementor of the library const char *implementor; //////////////////////////////////////////////////////////////////////////////// // // Function: create_effect // // Description: Creates an effect engine of the specified implementation uuid and // returns an effect control interface on this engine. The function will allocate the // resources for an instance of the requested effect engine and return // a handle on the effect control interface. // // Input: // uuid: pointer to the effect uuid. // sessionId: audio session to which this effect instance will be attached. // All effects created with the same session ID are connected in series and process // the same signal stream. Knowing that two effects are part of the same effect // chain can help the library implement some kind of optimizations. // ioId: identifies the output or input stream this effect is directed to in // audio HAL. // For future use especially with tunneled HW accelerated effects // // Input/Output: // pHandle: address where to return the effect interface handle. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pEffectUuid or pHandle // -ENOENT no effect with this uuid found // *pHandle: updated with the effect interface handle. // //////////////////////////////////////////////////////////////////////////////// int32_t (*create_effect)(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle); //////////////////////////////////////////////////////////////////////////////// // // Function: release_effect // // Description: Releases the effect engine whose handle is given as argument. // All resources allocated to this particular instance of the effect are // released. // // Input: // handle: handle on the effect interface to be released. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid interface handle // //////////////////////////////////////////////////////////////////////////////// int32_t (*release_effect)(effect_handle_t handle); //////////////////////////////////////////////////////////////////////////////// // // Function: get_descriptor // // Description: Returns the descriptor of the effect engine which implementation UUID is // given as argument. // // Input/Output: // uuid: pointer to the effect uuid. // pDescriptor: address where to return the effect descriptor. // // Output: // returned value: 0 successful operation. // -ENODEV library failed to initialize // -EINVAL invalid pDescriptor or uuid // *pDescriptor: updated with the effect descriptor. // //////////////////////////////////////////////////////////////////////////////// int32_t (*get_descriptor)(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor); } audio_effect_library_t; // Name of the hal_module_info #define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI // Name of the hal_module_info as a string #define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" __END_DECLS #endif // ANDROID_AUDIO_EFFECT_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/audio_policy.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_AUDIO_POLICY_INTERFACE_H #define ANDROID_AUDIO_POLICY_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy" /** * Name of the audio devices to open */ #define AUDIO_POLICY_INTERFACE "policy" /* ---------------------------------------------------------------------------- */ /* * The audio_policy and audio_policy_service_ops structs define the * communication interfaces between the platform specific audio policy manager * and Android generic audio policy manager. * The platform specific audio policy manager must implement methods of the * audio_policy struct. * This implementation makes use of the audio_policy_service_ops to control * the activity and configuration of audio input and output streams. * * The platform specific audio policy manager is in charge of the audio * routing and volume control policies for a given platform. * The main roles of this module are: * - keep track of current system state (removable device connections, phone * state, user requests...). * System state changes and user actions are notified to audio policy * manager with methods of the audio_policy. * * - process get_output() queries received when AudioTrack objects are * created: Those queries return a handler on an output that has been * selected, configured and opened by the audio policy manager and that * must be used by the AudioTrack when registering to the AudioFlinger * with the createTrack() method. * When the AudioTrack object is released, a release_output() query * is received and the audio policy manager can decide to close or * reconfigure the output depending on other streams using this output and * current system state. * * - similarly process get_input() and release_input() queries received from * AudioRecord objects and configure audio inputs. * - process volume control requests: the stream volume is converted from * an index value (received from UI) to a float value applicable to each * output as a function of platform specific settings and current output * route (destination device). It also make sure that streams are not * muted if not allowed (e.g. camera shutter sound in some countries). */ /* XXX: this should be defined OUTSIDE of frameworks/base */ struct effect_descriptor_s; struct audio_policy { /* * configuration functions */ /* indicate a change in device connection status */ int (*set_device_connection_state)(struct audio_policy *pol, audio_devices_t device, audio_policy_dev_state_t state, const char *device_address); /* retrieve a device connection status */ audio_policy_dev_state_t (*get_device_connection_state)( const struct audio_policy *pol, audio_devices_t device, const char *device_address); /* indicate a change in phone state. Valid phones states are defined * by audio_mode_t */ void (*set_phone_state)(struct audio_policy *pol, audio_mode_t state); /* deprecated, never called (was "indicate a change in ringer mode") */ void (*set_ringer_mode)(struct audio_policy *pol, uint32_t mode, uint32_t mask); /* force using a specific device category for the specified usage */ void (*set_force_use)(struct audio_policy *pol, audio_policy_force_use_t usage, audio_policy_forced_cfg_t config); /* retrieve current device category forced for a given usage */ audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol, audio_policy_force_use_t usage); /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE * can still be muted. */ void (*set_can_mute_enforced_audible)(struct audio_policy *pol, bool can_mute); /* check proper initialization */ int (*init_check)(const struct audio_policy *pol); /* * Audio routing query functions */ /* request an output appropriate for playback of the supplied stream type and * parameters */ audio_io_handle_t (*get_output)(struct audio_policy *pol, audio_stream_type_t stream, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* indicates to the audio policy manager that the output starts being used * by corresponding stream. */ int (*start_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* indicates to the audio policy manager that the output stops being used * by corresponding stream. */ int (*stop_output)(struct audio_policy *pol, audio_io_handle_t output, audio_stream_type_t stream, int session); /* releases the output. */ void (*release_output)(struct audio_policy *pol, audio_io_handle_t output); /* request an input appropriate for record from the supplied device with * supplied parameters. */ audio_io_handle_t (*get_input)(struct audio_policy *pol, audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, audio_in_acoustics_t acoustics); /* indicates to the audio policy manager that the input starts being used */ int (*start_input)(struct audio_policy *pol, audio_io_handle_t input); /* indicates to the audio policy manager that the input stops being used. */ int (*stop_input)(struct audio_policy *pol, audio_io_handle_t input); /* releases the input. */ void (*release_input)(struct audio_policy *pol, audio_io_handle_t input); /* * volume control functions */ /* initialises stream volume conversion parameters by specifying volume * index range. The index range for each stream is defined by AudioService. */ void (*init_stream_volume)(struct audio_policy *pol, audio_stream_type_t stream, int index_min, int index_max); /* sets the new stream volume at a level corresponding to the supplied * index. The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index)(struct audio_policy *pol, audio_stream_type_t stream, int index); /* retrieve current volume index for the specified stream */ int (*get_stream_volume_index)(const struct audio_policy *pol, audio_stream_type_t stream, int *index); /* sets the new stream volume at a level corresponding to the supplied * index for the specified device. * The index is within the range specified by init_stream_volume() */ int (*set_stream_volume_index_for_device)(struct audio_policy *pol, audio_stream_type_t stream, int index, audio_devices_t device); /* retrieve current volume index for the specified stream for the specified device */ int (*get_stream_volume_index_for_device)(const struct audio_policy *pol, audio_stream_type_t stream, int *index, audio_devices_t device); /* return the strategy corresponding to a given stream type */ uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* return the enabled output devices for the given stream type */ audio_devices_t (*get_devices_for_stream)(const struct audio_policy *pol, audio_stream_type_t stream); /* Audio effect management */ audio_io_handle_t (*get_output_for_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc); int (*register_effect)(struct audio_policy *pol, const struct effect_descriptor_s *desc, audio_io_handle_t output, uint32_t strategy, int session, int id); int (*unregister_effect)(struct audio_policy *pol, int id); int (*set_effect_enabled)(struct audio_policy *pol, int id, bool enabled); bool (*is_stream_active)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_stream_active_remotely)(const struct audio_policy *pol, audio_stream_type_t stream, uint32_t in_past_ms); bool (*is_source_active)(const struct audio_policy *pol, audio_source_t source); /* dump state */ int (*dump)(const struct audio_policy *pol, int fd); /* check if offload is possible for given sample rate, bitrate, duration, ... */ bool (*is_offload_supported)(const struct audio_policy *pol, const audio_offload_info_t *info); }; struct audio_policy_service_ops { /* * Audio output Control functions */ /* Opens an audio output with the requested parameters. * * The parameter values can indicate to use the default values in case the * audio policy manager has no specific requirements for the output being * opened. * * When the function returns, the parameter values reflect the actual * values used by the audio hardware output stream. * * The audio policy manager can check if the proposed parameters are * suitable or not and act accordingly. */ audio_io_handle_t (*open_output)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags); /* creates a special output that is duplicated to the two outputs passed as * arguments. The duplication is performed by * a special mixer thread in the AudioFlinger. */ audio_io_handle_t (*open_duplicate_output)(void *service, audio_io_handle_t output1, audio_io_handle_t output2); /* closes the output stream */ int (*close_output)(void *service, audio_io_handle_t output); /* suspends the output. * * When an output is suspended, the corresponding audio hardware output * stream is placed in standby and the AudioTracks attached to the mixer * thread are still processed but the output mix is discarded. */ int (*suspend_output)(void *service, audio_io_handle_t output); /* restores a suspended output. */ int (*restore_output)(void *service, audio_io_handle_t output); /* */ /* Audio input Control functions */ /* */ /* opens an audio input * deprecated - new implementations should use open_input_on_module, * and the acoustics parameter is ignored */ audio_io_handle_t (*open_input)(void *service, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, audio_in_acoustics_t acoustics); /* closes an audio input */ int (*close_input)(void *service, audio_io_handle_t input); /* */ /* misc control functions */ /* */ /* set a stream volume for a particular output. * * For the same user setting, a given stream type can have different * volumes for each output (destination device) it is attached to. */ int (*set_stream_volume)(void *service, audio_stream_type_t stream, float volume, audio_io_handle_t output, int delay_ms); /* invalidate a stream type, causing a reroute to an unspecified new output */ int (*invalidate_stream)(void *service, audio_stream_type_t stream); /* function enabling to send proprietary informations directly from audio * policy manager to audio hardware interface. */ void (*set_parameters)(void *service, audio_io_handle_t io_handle, const char *kv_pairs, int delay_ms); /* function enabling to receive proprietary informations directly from * audio hardware interface to audio policy manager. * * Returns a pointer to a heap allocated string. The caller is responsible * for freeing the memory for it using free(). */ char * (*get_parameters)(void *service, audio_io_handle_t io_handle, const char *keys); /* request the playback of a tone on the specified stream. * used for instance to replace notification sounds when playing over a * telephony device during a phone call. */ int (*start_tone)(void *service, audio_policy_tone_t tone, audio_stream_type_t stream); int (*stop_tone)(void *service); /* set down link audio volume. */ int (*set_voice_volume)(void *service, float volume, int delay_ms); /* move effect to the specified output */ int (*move_effects)(void *service, int session, audio_io_handle_t src_output, audio_io_handle_t dst_output); /* loads an audio hw module. * * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp". * The function returns a handle on the module that will be used to specify a particular * module when calling open_output_on_module() or open_input_on_module() */ audio_module_handle_t (*load_hw_module)(void *service, const char *name); /* Opens an audio output on a particular HW module. * * Same as open_output() but specifying a specific HW module on which the output must be opened. */ audio_io_handle_t (*open_output_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask, uint32_t *pLatencyMs, audio_output_flags_t flags, const audio_offload_info_t *offloadInfo); /* Opens an audio input on a particular HW module. * * Same as open_input() but specifying a specific HW module on which the input must be opened. * Also removed deprecated acoustics parameter */ audio_io_handle_t (*open_input_on_module)(void *service, audio_module_handle_t module, audio_devices_t *pDevices, uint32_t *pSamplingRate, audio_format_t *pFormat, audio_channel_mask_t *pChannelMask); }; /**********************************************************************/ /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct audio_policy_module { struct hw_module_t common; } audio_policy_module_t; struct audio_policy_device { /** * Common methods of the audio policy device. This *must* be the first member of * audio_policy_device as users of this structure will cast a hw_device_t to * audio_policy_device pointer in contexts where it's known the hw_device_t references an * audio_policy_device. */ struct hw_device_t common; int (*create_audio_policy)(const struct audio_policy_device *device, struct audio_policy_service_ops *aps_ops, void *service, struct audio_policy **ap); int (*destroy_audio_policy)(const struct audio_policy_device *device, struct audio_policy *ap); }; /** convenience API for opening and closing a supported device */ static inline int audio_policy_dev_open(const hw_module_t* module, struct audio_policy_device** device) { return module->methods->open(module, AUDIO_POLICY_INTERFACE, (hw_device_t**)device); } static inline int audio_policy_dev_close(struct audio_policy_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_AUDIO_POLICY_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bluetooth.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BLUETOOTH_H #define ANDROID_INCLUDE_BLUETOOTH_H #include #include #include #include #include __BEGIN_DECLS /** * The Bluetooth Hardware Module ID */ #define BT_HARDWARE_MODULE_ID "bluetooth" #define BT_STACK_MODULE_ID "bluetooth" #define BT_STACK_TEST_MODULE_ID "bluetooth_test" /* Bluetooth profile interface IDs */ #define BT_PROFILE_HANDSFREE_ID "handsfree" #define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client" #define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp" #define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink" #define BT_PROFILE_HEALTH_ID "health" #define BT_PROFILE_SOCKETS_ID "socket" #define BT_PROFILE_HIDHOST_ID "hidhost" #define BT_PROFILE_HIDDEV_ID "hiddev" #define BT_PROFILE_PAN_ID "pan" #define BT_PROFILE_MAP_CLIENT_ID "map_client" #define BT_PROFILE_SDP_CLIENT_ID "sdp" #define BT_PROFILE_GATT_ID "gatt" #define BT_PROFILE_AV_RC_ID "avrcp" #define WIPOWER_PROFILE_ID "wipower" #define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl" /** Bluetooth Address */ typedef struct { uint8_t address[6]; } __attribute__((packed))bt_bdaddr_t; /** Bluetooth Device Name */ typedef struct { uint8_t name[249]; } __attribute__((packed))bt_bdname_t; /** Bluetooth Adapter Visibility Modes*/ typedef enum { BT_SCAN_MODE_NONE, BT_SCAN_MODE_CONNECTABLE, BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE } bt_scan_mode_t; /** Bluetooth Adapter State */ typedef enum { BT_STATE_OFF, BT_STATE_ON } bt_state_t; /** Bluetooth Error Status */ /** We need to build on this */ typedef enum { BT_STATUS_SUCCESS, BT_STATUS_FAIL, BT_STATUS_NOT_READY, BT_STATUS_NOMEM, BT_STATUS_BUSY, BT_STATUS_DONE, /* request already completed */ BT_STATUS_UNSUPPORTED, BT_STATUS_PARM_INVALID, BT_STATUS_UNHANDLED, BT_STATUS_AUTH_FAILURE, BT_STATUS_RMT_DEV_DOWN, BT_STATUS_AUTH_REJECTED } bt_status_t; /** Bluetooth PinKey Code */ typedef struct { uint8_t pin[16]; } __attribute__((packed))bt_pin_code_t; typedef struct { uint8_t status; uint8_t ctrl_state; /* stack reported state */ uint64_t tx_time; /* in ms */ uint64_t rx_time; /* in ms */ uint64_t idle_time; /* in ms */ uint64_t energy_used; /* a product of mA, V and ms */ } __attribute__((packed))bt_activity_energy_info; /** Bluetooth Adapter Discovery state */ typedef enum { BT_DISCOVERY_STOPPED, BT_DISCOVERY_STARTED } bt_discovery_state_t; /** Bluetooth ACL connection state */ typedef enum { BT_ACL_STATE_CONNECTED, BT_ACL_STATE_DISCONNECTED } bt_acl_state_t; /** Bluetooth 128-bit UUID */ typedef struct { uint8_t uu[16]; } bt_uuid_t; /** Bluetooth SDP service record */ typedef struct { bt_uuid_t uuid; uint16_t channel; char name[256]; // what's the maximum length } bt_service_record_t; /** Bluetooth Remote Version info */ typedef struct { int version; int sub_ver; int manufacturer; } bt_remote_version_t; typedef struct { uint16_t version_supported; uint8_t local_privacy_enabled; uint8_t max_adv_instance; uint8_t rpa_offload_supported; uint8_t max_irk_list_size; uint8_t max_adv_filter_supported; uint8_t activity_energy_info_supported; uint16_t scan_result_storage_size; uint16_t total_trackable_advertisers; bool extended_scan_support; bool debug_logging_supported; }bt_local_le_features_t; /* Bluetooth Adapter and Remote Device property types */ typedef enum { /* Properties common to both adapter and remote device */ /** * Description - Bluetooth Device Name * Access mode - Adapter name can be GET/SET. Remote device can be GET * Data type - bt_bdname_t */ BT_PROPERTY_BDNAME = 0x1, /** * Description - Bluetooth Device Address * Access mode - Only GET. * Data type - bt_bdaddr_t */ BT_PROPERTY_BDADDR, /** * Description - Bluetooth Service 128-bit UUIDs * Access mode - Only GET. * Data type - Array of bt_uuid_t (Array size inferred from property length). */ BT_PROPERTY_UUIDS, /** * Description - Bluetooth Class of Device as found in Assigned Numbers * Access mode - Only GET. * Data type - uint32_t. */ BT_PROPERTY_CLASS_OF_DEVICE, /** * Description - Device Type - BREDR, BLE or DUAL Mode * Access mode - Only GET. * Data type - bt_device_type_t */ BT_PROPERTY_TYPE_OF_DEVICE, /** * Description - Bluetooth Service Record * Access mode - Only GET. * Data type - bt_service_record_t */ BT_PROPERTY_SERVICE_RECORD, /* Properties unique to adapter */ /** * Description - Bluetooth Adapter scan mode * Access mode - GET and SET * Data type - bt_scan_mode_t. */ BT_PROPERTY_ADAPTER_SCAN_MODE, /** * Description - List of bonded devices * Access mode - Only GET. * Data type - Array of bt_bdaddr_t of the bonded remote devices * (Array size inferred from property length). */ BT_PROPERTY_ADAPTER_BONDED_DEVICES, /** * Description - Bluetooth Adapter Discovery timeout (in seconds) * Access mode - GET and SET * Data type - uint32_t */ BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT, /* Properties unique to remote device */ /** * Description - User defined friendly name of the remote device * Access mode - GET and SET * Data type - bt_bdname_t. */ BT_PROPERTY_REMOTE_FRIENDLY_NAME, /** * Description - RSSI value of the inquired remote device * Access mode - Only GET. * Data type - int32_t. */ BT_PROPERTY_REMOTE_RSSI, /** * Description - Remote version info * Access mode - SET/GET. * Data type - bt_remote_version_t. */ BT_PROPERTY_REMOTE_VERSION_INFO, /** * Description - Local LE features * Access mode - GET. * Data type - bt_local_le_features_t. */ BT_PROPERTY_LOCAL_LE_FEATURES, BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF, } bt_property_type_t; /** Bluetooth Adapter Property data structure */ typedef struct { bt_property_type_t type; int len; void *val; } bt_property_t; /** Bluetooth Device Type */ typedef enum { BT_DEVICE_DEVTYPE_BREDR = 0x1, BT_DEVICE_DEVTYPE_BLE, BT_DEVICE_DEVTYPE_DUAL } bt_device_type_t; /** Bluetooth Bond state */ typedef enum { BT_BOND_STATE_NONE, BT_BOND_STATE_BONDING, BT_BOND_STATE_BONDED } bt_bond_state_t; /** Bluetooth SSP Bonding Variant */ typedef enum { BT_SSP_VARIANT_PASSKEY_CONFIRMATION, BT_SSP_VARIANT_PASSKEY_ENTRY, BT_SSP_VARIANT_CONSENT, BT_SSP_VARIANT_PASSKEY_NOTIFICATION } bt_ssp_variant_t; #define BT_MAX_NUM_UUIDS 32 /** Bluetooth Interface callbacks */ /** Bluetooth Enable/Disable Callback. */ typedef void (*adapter_state_changed_callback)(bt_state_t state); /** GET/SET Adapter Properties callback */ /* TODO: For the GET/SET property APIs/callbacks, we may need a session * identifier to associate the call with the callback. This would be needed * whenever more than one simultaneous instance of the same adapter_type * is get/set. * * If this is going to be handled in the Java framework, then we do not need * to manage sessions here. */ typedef void (*adapter_properties_callback)(bt_status_t status, int num_properties, bt_property_t *properties); /** GET/SET Remote Device Properties callback */ /** TODO: For remote device properties, do not see a need to get/set * multiple properties - num_properties shall be 1 */ typedef void (*remote_device_properties_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties); /** New device discovered callback */ /** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1 * respectively */ typedef void (*device_found_callback)(int num_properties, bt_property_t *properties); /** Discovery state changed callback */ typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state); /** Bluetooth Legacy PinKey Request callback */ typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit); /** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ /** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT & * BT_SSP_PAIRING_PASSKEY_ENTRY */ /* TODO: Passkey request callback shall not be needed for devices with display * capability. We still need support this in the stack for completeness */ typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name, uint32_t cod, bt_ssp_variant_t pairing_variant, uint32_t pass_key); /** Bluetooth Bond state changed callback */ /* Invoked in response to create_bond, cancel_bond or remove_bond */ typedef void (*bond_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state); /** Bluetooth ACL connection state changed callback */ typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr, bt_acl_state_t state); typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM } bt_cb_thread_evt; /** Thread Associate/Disassociate JVM Callback */ /* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from * the JVM */ typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /** Bluetooth Test Mode Callback */ /* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */ typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len); /** Bluetooth HCI event Callback */ /* Receive any HCI event from controller for raw commands */ typedef void (*hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len); /* LE Test mode callbacks * This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked * The num_packets is valid only for le_test_end command */ typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets); /** Callback invoked when energy details are obtained */ /* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec. * If the ctrl_state value is 0, it means the API call failed * Time values-In milliseconds as returned by the controller * Energy used-Value as returned by the controller * Status-Provides the status of the read_energy_info API call */ typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info); /** TODO: Add callbacks for Link Up/Down and other generic * notifications/callbacks */ /** Bluetooth DM callback structure. */ typedef struct { /** set to sizeof(bt_callbacks_t) */ size_t size; adapter_state_changed_callback adapter_state_changed_cb; adapter_properties_callback adapter_properties_cb; remote_device_properties_callback remote_device_properties_cb; device_found_callback device_found_cb; discovery_state_changed_callback discovery_state_changed_cb; pin_request_callback pin_request_cb; ssp_request_callback ssp_request_cb; bond_state_changed_callback bond_state_changed_cb; acl_state_changed_callback acl_state_changed_cb; callback_thread_event thread_evt_cb; dut_mode_recv_callback dut_mode_recv_cb; le_test_mode_callback le_test_mode_cb; energy_info_callback energy_info_cb; hci_event_recv_callback hci_event_recv_cb; } bt_callbacks_t; typedef void (*alarm_cb)(void *data); typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data); typedef int (*acquire_wake_lock_callout)(const char *lock_name); typedef int (*release_wake_lock_callout)(const char *lock_name); /** The set of functions required by bluedroid to set wake alarms and * grab wake locks. This struct is passed into the stack through the * |set_os_callouts| function on |bt_interface_t|. */ typedef struct { /* set to sizeof(bt_os_callouts_t) */ size_t size; set_wake_alarm_callout set_wake_alarm; acquire_wake_lock_callout acquire_wake_lock; release_wake_lock_callout release_wake_lock; } bt_os_callouts_t; /** NOTE: By default, no profiles are initialized at the time of init/enable. * Whenever the application invokes the 'init' API of a profile, then one of * the following shall occur: * * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the * profile as enabled. Subsequently, when the application invokes the * Bluetooth 'enable', as part of the enable sequence the profile that were * marked shall be enabled by calling appropriate stack APIs. The * 'adapter_properties_cb' shall return the list of UUIDs of the * enabled profiles. * * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack * profile API to initialize the profile and trigger a * 'adapter_properties_cb' with the current list of UUIDs including the * newly added profile's UUID. * * The reverse shall occur whenever the profile 'cleanup' APIs are invoked */ /** Represents the standard Bluetooth DM interface. */ typedef struct { /** set to sizeof(bt_interface_t) */ size_t size; /** * Opens the interface and provides the callback routines * to the implemenation of this interface. */ int (*init)(bt_callbacks_t* callbacks ); /** Enable Bluetooth. */ int (*enable)(bool guest_mode); /** Disable Bluetooth. */ int (*disable)(void); /** Closes the interface. */ void (*cleanup)(void); /** SSR cleanup. */ void (*ssrcleanup)(void); /** Get all Bluetooth Adapter properties at init */ int (*get_adapter_properties)(void); /** Get Bluetooth Adapter property of 'type' */ int (*get_adapter_property)(bt_property_type_t type); /** Set Bluetooth Adapter property of 'type' */ /* Based on the type, val shall be one of * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc */ int (*set_adapter_property)(const bt_property_t *property); /** Get all Remote Device properties */ int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); /** Get Remote Device property of 'type' */ int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, bt_property_type_t type); /** Set Remote Device property of 'type' */ int (*set_remote_device_property)(bt_bdaddr_t *remote_addr, const bt_property_t *property); /** Get Remote Device's service record for the given UUID */ int (*get_remote_service_record)(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid); /** Start SDP to get remote services */ int (*get_remote_services)(bt_bdaddr_t *remote_addr); /** Start Discovery */ int (*start_discovery)(void); /** Cancel Discovery */ int (*cancel_discovery)(void); /** Create Bluetooth Bonding */ int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport); /** Remove Bond */ int (*remove_bond)(const bt_bdaddr_t *bd_addr); /** Cancel Bond */ int (*cancel_bond)(const bt_bdaddr_t *bd_addr); /** * Get the connection status for a given remote device. * return value of 0 means the device is not connected, * non-zero return status indicates an active connection. */ int (*get_connection_state)(const bt_bdaddr_t *bd_addr); /** BT Legacy PinKey Reply */ /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */ int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept, uint8_t pin_len, bt_pin_code_t *pin_code); /** BT SSP Reply - Just Works, Numeric Comparison and Passkey * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON & * BT_SSP_VARIANT_CONSENT * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey * shall be zero */ int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant, uint8_t accept, uint32_t passkey); /** Get Bluetooth profile interface */ const void* (*get_profile_interface) (const char *profile_id); /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */ /* Configure DUT Mode - Use this mode to enter/exit DUT mode */ int (*dut_mode_configure)(uint8_t enable); /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */ int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len); /* Send any test HCI command to the controller. */ int (*hci_cmd_send)(uint16_t opcode, uint8_t *buf, uint8_t len); /** BLE Test Mode APIs */ /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */ int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len); /* enable or disable bluetooth HCI snoop log */ int (*config_hci_snoop_log)(uint8_t enable); /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks. * This should be called immediately after a successful |init|. */ int (*set_os_callouts)(bt_os_callouts_t *callouts); /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY * Success indicates that the VSC command was sent to controller */ int (*read_energy_info)(); /** * Native support for dumpsys function * Function is synchronous and |fd| is owned by caller. */ void (*dump)(int fd); /** * Clear /data/misc/bt_config.conf and erase all stored connections */ int (*config_clear)(void); /** BT stack Test interface */ const void* (*get_testapp_interface)(int test_app_profile); /** * Clear (reset) the dynamic portion of the device interoperability database. */ void (*interop_database_clear)(void); /** * Add a new device interoperability workaround for a remote device whose * first |len| bytes of the its device address match |addr|. * NOTE: |feature| has to match an item defined in interop_feature_t (interop.h). */ void (*interop_database_add)(uint16_t feature, const bt_bdaddr_t *addr, size_t len); } bt_interface_t; /** TODO: Need to add APIs for Service Discovery, Service authorization and * connection management. Also need to add APIs for configuring * properties of remote bonded devices such as name, UUID etc. */ typedef struct { struct hw_device_t common; const bt_interface_t* (*get_bluetooth_interface)(); } bluetooth_device_t; typedef bluetooth_device_t bluetooth_module_t; __END_DECLS #endif /* ANDROID_INCLUDE_BLUETOOTH_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_av.h ================================================ /* * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_AV_H #define ANDROID_INCLUDE_BT_AV_H __BEGIN_DECLS /* Bluetooth AV connection states */ typedef enum { BTAV_CONNECTION_STATE_DISCONNECTED = 0, BTAV_CONNECTION_STATE_CONNECTING, BTAV_CONNECTION_STATE_CONNECTED, BTAV_CONNECTION_STATE_DISCONNECTING } btav_connection_state_t; /* Bluetooth AV datapath states */ typedef enum { BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0, BTAV_AUDIO_STATE_STOPPED, BTAV_AUDIO_STATE_STARTED, } btav_audio_state_t; /** Callback for connection state change. * state will have one of the values from btav_connection_state_t */ typedef void (* btav_connection_state_callback)(btav_connection_state_t state, bt_bdaddr_t *bd_addr); /** Callback for audiopath state change. * state will have one of the values from btav_audio_state_t */ typedef void (* btav_audio_state_callback)(btav_audio_state_t state, bt_bdaddr_t *bd_addr); /** Callback for connection priority of device for incoming connection * btav_connection_priority_t */ typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr); /** Callback for audio configuration change. * Used only for the A2DP sink interface. * state will have one of the values from btav_audio_state_t * sample_rate: sample rate in Hz * channel_count: number of channels (1 for mono, 2 for stereo) */ typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr, uint32_t sample_rate, uint8_t channel_count); /** Callback for updating apps for A2dp multicast state. */ typedef void (* btav_is_multicast_enabled_callback)(int state); /* * Callback for audio focus request to be used only in * case of A2DP Sink. This is required because we are using * AudioTrack approach for audio data rendering. */ typedef void (* btav_audio_focus_request_callback)(bt_bdaddr_t *bd_addr); /** BT-AV callback structure. */ typedef struct { /** set to sizeof(btav_callbacks_t) */ size_t size; btav_connection_state_callback connection_state_cb; btav_audio_state_callback audio_state_cb; btav_audio_config_callback audio_config_cb; btav_connection_priority_callback connection_priority_cb; btav_is_multicast_enabled_callback multicast_state_cb; btav_audio_focus_request_callback audio_focus_request_cb; } btav_callbacks_t; /** * NOTE: * * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands * shall be handled internally via uinput * * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger * android_audio_hw library and the Bluetooth stack. * */ /** Represents the standard BT-AV interface. * Used for both the A2DP source and sink interfaces. */ typedef struct { /** set to sizeof(btav_interface_t) */ size_t size; /** * Register the BtAv callbacks */ bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections, int a2dp_multicast_state); /** connect to headset */ bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); /** dis-connect from headset */ bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); /** Closes the interface. */ void (*cleanup)( void ); /** Send priority of device to stack*/ void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr); /** Sends Audio Focus State. */ void (*audio_focus_state)( int focus_state ); } btav_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_AV_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_common_types.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /****************************************************************************** * * This file contains constants and definitions that can be used commonly between JNI and stack layer * ******************************************************************************/ #ifndef ANDROID_INCLUDE_BT_COMMON_TYPES_H #define ANDROID_INCLUDE_BT_COMMON_TYPES_H #include "bluetooth.h" typedef struct { uint8_t client_if; uint8_t filt_index; uint8_t advertiser_state; uint8_t advertiser_info_present; uint8_t addr_type; uint8_t tx_power; int8_t rssi_value; uint16_t time_stamp; bt_bdaddr_t bd_addr; uint8_t adv_pkt_len; uint8_t *p_adv_pkt_data; uint8_t scan_rsp_len; uint8_t *p_scan_rsp_data; } btgatt_track_adv_info_t; #endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_gatt.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_GATT_H #define ANDROID_INCLUDE_BT_GATT_H #include #include "bt_gatt_client.h" #include "bt_gatt_server.h" __BEGIN_DECLS /** BT-GATT callbacks */ typedef struct { /** Set to sizeof(btgatt_callbacks_t) */ size_t size; /** GATT Client callbacks */ const btgatt_client_callbacks_t* client; /** GATT Server callbacks */ const btgatt_server_callbacks_t* server; } btgatt_callbacks_t; /** Represents the standard Bluetooth GATT interface. */ typedef struct { /** Set to sizeof(btgatt_interface_t) */ size_t size; /** * Initializes the interface and provides callback routines */ bt_status_t (*init)( const btgatt_callbacks_t* callbacks ); /** Closes the interface */ void (*cleanup)( void ); /** Pointer to the GATT client interface methods.*/ const btgatt_client_interface_t* client; /** Pointer to the GATT server interface methods.*/ const btgatt_server_interface_t* server; } btgatt_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_client.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_GATT_CLIENT_H #define ANDROID_INCLUDE_BT_GATT_CLIENT_H #include #include "bt_gatt_types.h" #include "bt_common_types.h" __BEGIN_DECLS /** * Buffer sizes for maximum attribute length and maximum read/write * operation buffer size. */ #define BTGATT_MAX_ATTR_LEN 600 /** Buffer type for unformatted reads/writes */ typedef struct { uint8_t value[BTGATT_MAX_ATTR_LEN]; uint16_t len; } btgatt_unformatted_value_t; /** Parameters for GATT read operations */ typedef struct { btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; btgatt_gatt_id_t descr_id; btgatt_unformatted_value_t value; uint16_t value_type; uint8_t status; } btgatt_read_params_t; /** Parameters for GATT write operations */ typedef struct { btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; btgatt_gatt_id_t descr_id; uint8_t status; } btgatt_write_params_t; /** Attribute change notification parameters */ typedef struct { uint8_t value[BTGATT_MAX_ATTR_LEN]; bt_bdaddr_t bda; btgatt_srvc_id_t srvc_id; btgatt_gatt_id_t char_id; uint16_t len; uint8_t is_notify; } btgatt_notify_params_t; typedef struct { uint8_t client_if; uint8_t action; uint8_t filt_index; uint16_t feat_seln; uint16_t list_logic_type; uint8_t filt_logic_type; uint8_t rssi_high_thres; uint8_t rssi_low_thres; uint8_t dely_mode; uint16_t found_timeout; uint16_t lost_timeout; uint8_t found_timeout_cnt; uint16_t num_of_tracking_entries; } btgatt_filt_param_setup_t; typedef struct { bt_bdaddr_t *bda1; bt_uuid_t *uuid1; uint16_t u1; uint16_t u2; uint16_t u3; uint16_t u4; uint16_t u5; } btgatt_test_params_t; /* BT GATT client error codes */ typedef enum { BT_GATTC_COMMAND_SUCCESS = 0, /* 0 Command succeeded */ BT_GATTC_COMMAND_STARTED, /* 1 Command started OK. */ BT_GATTC_COMMAND_BUSY, /* 2 Device busy with another command */ BT_GATTC_COMMAND_STORED, /* 3 request is stored in control block */ BT_GATTC_NO_RESOURCES, /* 4 No resources to issue command */ BT_GATTC_MODE_UNSUPPORTED, /* 5 Request for 1 or more unsupported modes */ BT_GATTC_ILLEGAL_VALUE, /* 6 Illegal command /parameter value */ BT_GATTC_INCORRECT_STATE, /* 7 Device in wrong state for request */ BT_GATTC_UNKNOWN_ADDR, /* 8 Unknown remote BD address */ BT_GATTC_DEVICE_TIMEOUT, /* 9 Device timeout */ BT_GATTC_INVALID_CONTROLLER_OUTPUT,/* 10 An incorrect value was received from HCI */ BT_GATTC_SECURITY_ERROR, /* 11 Authorization or security failure or not authorized */ BT_GATTC_DELAYED_ENCRYPTION_CHECK, /*12 Delayed encryption check */ BT_GATTC_ERR_PROCESSING /* 12 Generic error */ } btgattc_error_t; /** BT-GATT Client callback structure. */ /** Callback invoked in response to register_client */ typedef void (*register_client_callback)(int status, int client_if, bt_uuid_t *app_uuid); /** Callback for scan results */ typedef void (*scan_result_callback)(bt_bdaddr_t* bda, int rssi, uint8_t* adv_data); /** GATT open callback invoked in response to open */ typedef void (*connect_callback)(int conn_id, int status, int client_if, bt_bdaddr_t* bda); /** Callback invoked in response to close */ typedef void (*disconnect_callback)(int conn_id, int status, int client_if, bt_bdaddr_t* bda); /** * Invoked in response to search_service when the GATT service search * has been completed. */ typedef void (*search_complete_callback)(int conn_id, int status); /** Reports GATT services on a remote device */ typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id); /** GATT characteristic enumeration result callback */ typedef void (*get_characteristic_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int char_prop); /** GATT descriptor enumeration result callback */ typedef void (*get_descriptor_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id); /** GATT included service enumeration result callback */ typedef void (*get_included_service_callback)(int conn_id, int status, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id); /** Callback invoked in response to [de]register_for_notification */ typedef void (*register_for_notification_callback)(int conn_id, int registered, int status, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** * Remote device notification callback, invoked when a remote device sends * a notification or indication that a client has registered for. */ typedef void (*notify_callback)(int conn_id, btgatt_notify_params_t *p_data); /** Reports result of a GATT read operation */ typedef void (*read_characteristic_callback)(int conn_id, int status, btgatt_read_params_t *p_data); /** GATT write characteristic operation callback */ typedef void (*write_characteristic_callback)(int conn_id, int status, btgatt_write_params_t *p_data); /** GATT execute prepared write callback */ typedef void (*execute_write_callback)(int conn_id, int status); /** Callback invoked in response to read_descriptor */ typedef void (*read_descriptor_callback)(int conn_id, int status, btgatt_read_params_t *p_data); /** Callback invoked in response to write_descriptor */ typedef void (*write_descriptor_callback)(int conn_id, int status, btgatt_write_params_t *p_data); /** Callback triggered in response to read_remote_rssi */ typedef void (*read_remote_rssi_callback)(int client_if, bt_bdaddr_t* bda, int rssi, int status); /** * Callback indicating the status of a listen() operation */ typedef void (*listen_callback)(int status, int server_if); /** Callback invoked when the MTU for a given connection changes */ typedef void (*configure_mtu_callback)(int conn_id, int status, int mtu); /** Callback invoked when a scan filter configuration command has completed */ typedef void (*scan_filter_cfg_callback)(int action, int client_if, int status, int filt_type, int avbl_space); /** Callback invoked when scan param has been added, cleared, or deleted */ typedef void (*scan_filter_param_callback)(int action, int client_if, int status, int avbl_space); /** Callback invoked when a scan filter configuration command has completed */ typedef void (*scan_filter_status_callback)(int enable, int client_if, int status); /** Callback invoked when multi-adv enable operation has completed */ typedef void (*multi_adv_enable_callback)(int client_if, int status); /** Callback invoked when multi-adv param update operation has completed */ typedef void (*multi_adv_update_callback)(int client_if, int status); /** Callback invoked when multi-adv instance data set operation has completed */ typedef void (*multi_adv_data_callback)(int client_if, int status); /** Callback invoked when multi-adv disable operation has completed */ typedef void (*multi_adv_disable_callback)(int client_if, int status); /** * Callback notifying an application that a remote device connection is currently congested * and cannot receive any more data. An application should avoid sending more data until * a further callback is received indicating the congestion status has been cleared. */ typedef void (*congestion_callback)(int conn_id, bool congested); /** Callback invoked when batchscan storage config operation has completed */ typedef void (*batchscan_cfg_storage_callback)(int client_if, int status); /** Callback invoked when batchscan enable / disable operation has completed */ typedef void (*batchscan_enable_disable_callback)(int action, int client_if, int status); /** Callback invoked when batchscan reports are obtained */ typedef void (*batchscan_reports_callback)(int client_if, int status, int report_format, int num_records, int data_len, uint8_t* rep_data); /** Callback invoked when batchscan storage threshold limit is crossed */ typedef void (*batchscan_threshold_callback)(int client_if); /** Track ADV VSE callback invoked when tracked device is found or lost */ typedef void (*track_adv_event_callback)(btgatt_track_adv_info_t *p_track_adv_info); /** Callback invoked when scan parameter setup has completed */ typedef void (*scan_parameter_setup_completed_callback)(int client_if, btgattc_error_t status); typedef struct { register_client_callback register_client_cb; scan_result_callback scan_result_cb; connect_callback open_cb; disconnect_callback close_cb; search_complete_callback search_complete_cb; search_result_callback search_result_cb; get_characteristic_callback get_characteristic_cb; get_descriptor_callback get_descriptor_cb; get_included_service_callback get_included_service_cb; register_for_notification_callback register_for_notification_cb; notify_callback notify_cb; read_characteristic_callback read_characteristic_cb; write_characteristic_callback write_characteristic_cb; read_descriptor_callback read_descriptor_cb; write_descriptor_callback write_descriptor_cb; execute_write_callback execute_write_cb; read_remote_rssi_callback read_remote_rssi_cb; listen_callback listen_cb; configure_mtu_callback configure_mtu_cb; scan_filter_cfg_callback scan_filter_cfg_cb; scan_filter_param_callback scan_filter_param_cb; scan_filter_status_callback scan_filter_status_cb; multi_adv_enable_callback multi_adv_enable_cb; multi_adv_update_callback multi_adv_update_cb; multi_adv_data_callback multi_adv_data_cb; multi_adv_disable_callback multi_adv_disable_cb; congestion_callback congestion_cb; batchscan_cfg_storage_callback batchscan_cfg_storage_cb; batchscan_enable_disable_callback batchscan_enb_disable_cb; batchscan_reports_callback batchscan_reports_cb; batchscan_threshold_callback batchscan_threshold_cb; track_adv_event_callback track_adv_event_cb; scan_parameter_setup_completed_callback scan_parameter_setup_completed_cb; } btgatt_client_callbacks_t; /** Represents the standard BT-GATT client interface. */ typedef struct { /** Registers a GATT client application with the stack */ bt_status_t (*register_client)( bt_uuid_t *uuid ); /** Unregister a client application from the stack */ bt_status_t (*unregister_client)(int client_if ); /** Start or stop LE device scanning */ bt_status_t (*scan)( bool start ); /** Create a connection to a remote LE or dual-mode device */ bt_status_t (*connect)( int client_if, const bt_bdaddr_t *bd_addr, bool is_direct, int transport ); /** Disconnect a remote device or cancel a pending connection */ bt_status_t (*disconnect)( int client_if, const bt_bdaddr_t *bd_addr, int conn_id); /** Start or stop advertisements to listen for incoming connections */ bt_status_t (*listen)(int client_if, bool start); /** Clear the attribute cache for a given device */ bt_status_t (*refresh)( int client_if, const bt_bdaddr_t *bd_addr ); /** * Enumerate all GATT services on a connected device. * Optionally, the results can be filtered for a given UUID. */ bt_status_t (*search_service)(int conn_id, bt_uuid_t *filter_uuid ); /** * Enumerate included services for a given service. * Set start_incl_srvc_id to NULL to get the first included service. */ bt_status_t (*get_included_service)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *start_incl_srvc_id); /** * Enumerate characteristics for a given service. * Set start_char_id to NULL to get the first characteristic. */ bt_status_t (*get_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id); /** * Enumerate descriptors for a given characteristic. * Set start_descr_id to NULL to get the first descriptor. */ bt_status_t (*get_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *start_descr_id); /** Read a characteristic on a remote device */ bt_status_t (*read_characteristic)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int auth_req ); /** Write a remote characteristic */ bt_status_t (*write_characteristic)(int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, int write_type, int len, int auth_req, char* p_value); /** Read the descriptor for a given characteristic */ bt_status_t (*read_descriptor)(int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, int auth_req); /** Write a remote descriptor for a given characteristic */ bt_status_t (*write_descriptor)( int conn_id, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, btgatt_gatt_id_t *descr_id, int write_type, int len, int auth_req, char* p_value); /** Execute a prepared write operation */ bt_status_t (*execute_write)(int conn_id, int execute); /** * Register to receive notifications or indications for a given * characteristic */ bt_status_t (*register_for_notification)( int client_if, const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Deregister a previous request for notifications/indications */ bt_status_t (*deregister_for_notification)( int client_if, const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id); /** Request RSSI for a given remote device */ bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr); /** Setup scan filter params */ bt_status_t (*scan_filter_param_setup)(btgatt_filt_param_setup_t filt_param); /** Configure a scan filter condition */ bt_status_t (*scan_filter_add_remove)(int client_if, int action, int filt_type, int filt_index, int company_id, int company_id_mask, const bt_uuid_t *p_uuid, const bt_uuid_t *p_uuid_mask, const bt_bdaddr_t *bd_addr, char addr_type, int data_len, char* p_data, int mask_len, char* p_mask); /** Clear all scan filter conditions for specific filter index*/ bt_status_t (*scan_filter_clear)(int client_if, int filt_index); /** Enable / disable scan filter feature*/ bt_status_t (*scan_filter_enable)(int client_if, bool enable); /** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */ int (*get_device_type)( const bt_bdaddr_t *bd_addr ); /** Set the advertising data or scan response data */ bt_status_t (*set_adv_data)(int client_if, bool set_scan_rsp, bool include_name, bool include_txpower, int min_interval, int max_interval, int appearance, uint16_t manufacturer_len, char* manufacturer_data, uint16_t service_data_len, char* service_data, uint16_t service_uuid_len, char* service_uuid); /** Configure the MTU for a given connection */ bt_status_t (*configure_mtu)(int conn_id, int mtu); /** Request a connection parameter update */ bt_status_t (*conn_parameter_update)(const bt_bdaddr_t *bd_addr, int min_interval, int max_interval, int latency, int timeout); /** Sets the LE scan interval and window in units of N*0.625 msec */ bt_status_t (*set_scan_parameters)(int client_if, int scan_interval, int scan_window); /* Setup the parameters as per spec, user manual specified values and enable multi ADV */ bt_status_t (*multi_adv_enable)(int client_if, int min_interval,int max_interval,int adv_type, int chnl_map, int tx_power, int timeout_s); /* Update the parameters as per spec, user manual specified values and restart multi ADV */ bt_status_t (*multi_adv_update)(int client_if, int min_interval,int max_interval,int adv_type, int chnl_map, int tx_power, int timeout_s); /* Setup the data for the specified instance */ bt_status_t (*multi_adv_set_inst_data)(int client_if, bool set_scan_rsp, bool include_name, bool incl_txpower, int appearance, int manufacturer_len, char* manufacturer_data, int service_data_len, char* service_data, int service_uuid_len, char* service_uuid); /* Disable the multi adv instance */ bt_status_t (*multi_adv_disable)(int client_if); /* Configure the batchscan storage */ bt_status_t (*batchscan_cfg_storage)(int client_if, int batch_scan_full_max, int batch_scan_trunc_max, int batch_scan_notify_threshold); /* Enable batchscan */ bt_status_t (*batchscan_enb_batch_scan)(int client_if, int scan_mode, int scan_interval, int scan_window, int addr_type, int discard_rule); /* Disable batchscan */ bt_status_t (*batchscan_dis_batch_scan)(int client_if); /* Read out batchscan reports */ bt_status_t (*batchscan_read_reports)(int client_if, int scan_mode); /** Test mode interface */ bt_status_t (*test_command)( int command, btgatt_test_params_t* params); } btgatt_client_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_server.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_GATT_SERVER_H #define ANDROID_INCLUDE_BT_GATT_SERVER_H #include #include "bt_gatt_types.h" __BEGIN_DECLS /** GATT value type used in response to remote read requests */ typedef struct { uint8_t value[BTGATT_MAX_ATTR_LEN]; uint16_t handle; uint16_t offset; uint16_t len; uint8_t auth_req; } btgatt_value_t; /** GATT remote read request response type */ typedef union { btgatt_value_t attr_value; uint16_t handle; } btgatt_response_t; /** BT-GATT Server callback structure. */ /** Callback invoked in response to register_server */ typedef void (*register_server_callback)(int status, int server_if, bt_uuid_t *app_uuid); /** Callback indicating that a remote device has connected or been disconnected */ typedef void (*connection_callback)(int conn_id, int server_if, int connected, bt_bdaddr_t *bda); /** Callback invoked in response to create_service */ typedef void (*service_added_callback)(int status, int server_if, btgatt_srvc_id_t *srvc_id, int srvc_handle); /** Callback indicating that an included service has been added to a service */ typedef void (*included_service_added_callback)(int status, int server_if, int srvc_handle, int incl_srvc_handle); /** Callback invoked when a characteristic has been added to a service */ typedef void (*characteristic_added_callback)(int status, int server_if, bt_uuid_t *uuid, int srvc_handle, int char_handle); /** Callback invoked when a descriptor has been added to a characteristic */ typedef void (*descriptor_added_callback)(int status, int server_if, bt_uuid_t *uuid, int srvc_handle, int descr_handle); /** Callback invoked in response to start_service */ typedef void (*service_started_callback)(int status, int server_if, int srvc_handle); /** Callback invoked in response to stop_service */ typedef void (*service_stopped_callback)(int status, int server_if, int srvc_handle); /** Callback triggered when a service has been deleted */ typedef void (*service_deleted_callback)(int status, int server_if, int srvc_handle); /** * Callback invoked when a remote device has requested to read a characteristic * or descriptor. The application must respond by calling send_response */ typedef void (*request_read_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, int attr_handle, int offset, bool is_long); /** * Callback invoked when a remote device has requested to write to a * characteristic or descriptor. */ typedef void (*request_write_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, int attr_handle, int offset, int length, bool need_rsp, bool is_prep, uint8_t* value); /** Callback invoked when a previously prepared write is to be executed */ typedef void (*request_exec_write_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, int exec_write); /** * Callback triggered in response to send_response if the remote device * sends a confirmation. */ typedef void (*response_confirmation_callback)(int status, int handle); /** * Callback confirming that a notification or indication has been sent * to a remote device. */ typedef void (*indication_sent_callback)(int conn_id, int status); /** * Callback notifying an application that a remote device connection is currently congested * and cannot receive any more data. An application should avoid sending more data until * a further callback is received indicating the congestion status has been cleared. */ typedef void (*congestion_callback)(int conn_id, bool congested); /** Callback invoked when the MTU for a given connection changes */ typedef void (*mtu_changed_callback)(int conn_id, int mtu); typedef struct { register_server_callback register_server_cb; connection_callback connection_cb; service_added_callback service_added_cb; included_service_added_callback included_service_added_cb; characteristic_added_callback characteristic_added_cb; descriptor_added_callback descriptor_added_cb; service_started_callback service_started_cb; service_stopped_callback service_stopped_cb; service_deleted_callback service_deleted_cb; request_read_callback request_read_cb; request_write_callback request_write_cb; request_exec_write_callback request_exec_write_cb; response_confirmation_callback response_confirmation_cb; indication_sent_callback indication_sent_cb; congestion_callback congestion_cb; mtu_changed_callback mtu_changed_cb; } btgatt_server_callbacks_t; /** Represents the standard BT-GATT server interface. */ typedef struct { /** Registers a GATT server application with the stack */ bt_status_t (*register_server)( bt_uuid_t *uuid ); /** Unregister a server application from the stack */ bt_status_t (*unregister_server)(int server_if ); /** Create a connection to a remote peripheral */ bt_status_t (*connect)(int server_if, const bt_bdaddr_t *bd_addr, bool is_direct, int transport); /** Disconnect an established connection or cancel a pending one */ bt_status_t (*disconnect)(int server_if, const bt_bdaddr_t *bd_addr, int conn_id ); /** Create a new service */ bt_status_t (*add_service)( int server_if, btgatt_srvc_id_t *srvc_id, int num_handles); /** Assign an included service to it's parent service */ bt_status_t (*add_included_service)( int server_if, int service_handle, int included_handle); /** Add a characteristic to a service */ bt_status_t (*add_characteristic)( int server_if, int service_handle, bt_uuid_t *uuid, int properties, int permissions); /** Add a descriptor to a given service */ bt_status_t (*add_descriptor)(int server_if, int service_handle, bt_uuid_t *uuid, int permissions); /** Starts a local service */ bt_status_t (*start_service)(int server_if, int service_handle, int transport); /** Stops a local service */ bt_status_t (*stop_service)(int server_if, int service_handle); /** Delete a local service */ bt_status_t (*delete_service)(int server_if, int service_handle); /** Send value indication to a remote device */ bt_status_t (*send_indication)(int server_if, int attribute_handle, int conn_id, int len, int confirm, char* p_value); /** Send a response to a read/write operation */ bt_status_t (*send_response)(int conn_id, int trans_id, int status, btgatt_response_t *response); } btgatt_server_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_gatt_types.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_GATT_TYPES_H #define ANDROID_INCLUDE_BT_GATT_TYPES_H #include #include __BEGIN_DECLS /** * GATT Service types */ #define BTGATT_SERVICE_TYPE_PRIMARY 0 #define BTGATT_SERVICE_TYPE_SECONDARY 1 /** GATT ID adding instance id tracking to the UUID */ typedef struct { bt_uuid_t uuid; uint8_t inst_id; } btgatt_gatt_id_t; /** GATT Service ID also identifies the service type (primary/secondary) */ typedef struct { btgatt_gatt_id_t id; uint8_t is_primary; } btgatt_srvc_id_t; /** Preferred physical Transport for GATT connection */ typedef enum { GATT_TRANSPORT_AUTO, GATT_TRANSPORT_BREDR, GATT_TRANSPORT_LE } btgatt_transport_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_GATT_TYPES_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_hd.h ================================================ /* * Copyright (c) 2013, The Linux Foundation. All rights reserved. * Not a Contribution * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HD_H #define ANDROID_INCLUDE_BT_HD_H #include __BEGIN_DECLS typedef enum { BTHD_REPORT_TYPE_OTHER = 0, BTHD_REPORT_TYPE_INPUT, BTHD_REPORT_TYPE_OUTPUT, BTHD_REPORT_TYPE_FEATURE, BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed) } bthd_report_type_t; typedef enum { BTHD_APP_STATE_NOT_REGISTERED, BTHD_APP_STATE_REGISTERED } bthd_application_state_t; typedef enum { BTHD_CONN_STATE_CONNECTED, BTHD_CONN_STATE_CONNECTING, BTHD_CONN_STATE_DISCONNECTED, BTHD_CONN_STATE_DISCONNECTING, BTHD_CONN_STATE_UNKNOWN } bthd_connection_state_t; typedef struct { const char *name; const char *description; const char *provider; uint8_t subclass; uint8_t *desc_list; int desc_list_len; } bthd_app_param_t; typedef struct { uint8_t service_type; uint32_t token_rate; uint32_t token_bucket_size; uint32_t peak_bandwidth; uint32_t access_latency; uint32_t delay_variation; } bthd_qos_param_t; typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state); typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state); typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size); typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data); typedef void (* bthd_set_protocol_callback)(uint8_t protocol); typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data); typedef void (* bthd_vc_unplug_callback)(void); /** BT-HD callbacks */ typedef struct { size_t size; bthd_application_state_callback application_state_cb; bthd_connection_state_callback connection_state_cb; bthd_get_report_callback get_report_cb; bthd_set_report_callback set_report_cb; bthd_set_protocol_callback set_protocol_cb; bthd_intr_data_callback intr_data_cb; bthd_vc_unplug_callback vc_unplug_cb; } bthd_callbacks_t; /** BT-HD interface */ typedef struct { size_t size; /** init interface and register callbacks */ bt_status_t (*init)(bthd_callbacks_t* callbacks); /** close interface */ void (*cleanup)(void); /** register application */ bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos, bthd_qos_param_t *out_qos); /** unregister application */ bt_status_t (*unregister_app)(void); /** connects to host with virtual cable */ bt_status_t (*connect)(void); /** disconnects from currently connected host */ bt_status_t (*disconnect)(void); /** send report */ bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data); /** notifies error for invalid SET_REPORT */ bt_status_t (*report_error)(uint8_t error); /** send Virtual Cable Unplug */ bt_status_t (*virtual_cable_unplug)(void); } bthd_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HD_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_hf.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HF_H #define ANDROID_INCLUDE_BT_HF_H __BEGIN_DECLS /* AT response code - OK/Error */ typedef enum { BTHF_AT_RESPONSE_ERROR = 0, BTHF_AT_RESPONSE_OK } bthf_at_response_t; typedef enum { BTHF_CONNECTION_STATE_DISCONNECTED = 0, BTHF_CONNECTION_STATE_CONNECTING, BTHF_CONNECTION_STATE_CONNECTED, BTHF_CONNECTION_STATE_SLC_CONNECTED, BTHF_CONNECTION_STATE_DISCONNECTING } bthf_connection_state_t; typedef enum { BTHF_AUDIO_STATE_DISCONNECTED = 0, BTHF_AUDIO_STATE_CONNECTING, BTHF_AUDIO_STATE_CONNECTED, BTHF_AUDIO_STATE_DISCONNECTING } bthf_audio_state_t; typedef enum { BTHF_VR_STATE_STOPPED = 0, BTHF_VR_STATE_STARTED } bthf_vr_state_t; typedef enum { BTHF_VOLUME_TYPE_SPK = 0, BTHF_VOLUME_TYPE_MIC } bthf_volume_type_t; /* Noise Reduction and Echo Cancellation */ typedef enum { BTHF_NREC_STOP, BTHF_NREC_START } bthf_nrec_t; /* WBS codec setting */ typedef enum { BTHF_WBS_NONE, BTHF_WBS_NO, BTHF_WBS_YES }bthf_wbs_config_t; /* BIND type*/ typedef enum { BTHF_BIND_SET, BTHF_BIND_READ, BTHF_BIND_TEST }bthf_bind_type_t; /* CHLD - Call held handling */ typedef enum { BTHF_CHLD_TYPE_RELEASEHELD, // Terminate all held or set UDUB("busy") to a waiting call BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD, // Terminate all active calls and accepts a waiting/held call BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD, // Hold all active calls and accepts a waiting/held call BTHF_CHLD_TYPE_ADDHELDTOCONF, // Add all held calls to a conference } bthf_chld_type_t; /** Callback for connection state change. * state will have one of the values from BtHfConnectionState */ typedef void (* bthf_connection_state_callback)(bthf_connection_state_t state, bt_bdaddr_t *bd_addr); /** Callback for audio connection state change. * state will have one of the values from BtHfAudioState */ typedef void (* bthf_audio_state_callback)(bthf_audio_state_t state, bt_bdaddr_t *bd_addr); /** Callback for VR connection state change. * state will have one of the values from BtHfVRState */ typedef void (* bthf_vr_cmd_callback)(bthf_vr_state_t state, bt_bdaddr_t *bd_addr); /** Callback for answer incoming call (ATA) */ typedef void (* bthf_answer_call_cmd_callback)(bt_bdaddr_t *bd_addr); /** Callback for disconnect call (AT+CHUP) */ typedef void (* bthf_hangup_call_cmd_callback)(bt_bdaddr_t *bd_addr); /** Callback for disconnect call (AT+CHUP) * type will denote Speaker/Mic gain (BtHfVolumeControl). */ typedef void (* bthf_volume_cmd_callback)(bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr); /** Callback for dialing an outgoing call * If number is NULL, redial */ typedef void (* bthf_dial_call_cmd_callback)(char *number, bt_bdaddr_t *bd_addr); /** Callback for sending DTMF tones * tone contains the dtmf character to be sent */ typedef void (* bthf_dtmf_cmd_callback)(char tone, bt_bdaddr_t *bd_addr); /** Callback for enabling/disabling noise reduction/echo cancellation * value will be 1 to enable, 0 to disable */ typedef void (* bthf_nrec_cmd_callback)(bthf_nrec_t nrec, bt_bdaddr_t *bd_addr); /** Callback for AT+BCS and event from BAC * WBS enable, WBS disable */ typedef void (* bthf_wbs_callback)(bthf_wbs_config_t wbs, bt_bdaddr_t *bd_addr); /** Callback for call hold handling (AT+CHLD) * value will contain the call hold command (0, 1, 2, 3) */ typedef void (* bthf_chld_cmd_callback)(bthf_chld_type_t chld, bt_bdaddr_t *bd_addr); /** Callback for CNUM (subscriber number) */ typedef void (* bthf_cnum_cmd_callback)(bt_bdaddr_t *bd_addr); /** Callback for indicators (CIND) */ typedef void (* bthf_cind_cmd_callback)(bt_bdaddr_t *bd_addr); /** Callback for operator selection (COPS) */ typedef void (* bthf_cops_cmd_callback)(bt_bdaddr_t *bd_addr); /** Callback for call list (AT+CLCC) */ typedef void (* bthf_clcc_cmd_callback) (bt_bdaddr_t *bd_addr); /** Callback for unknown AT command recd from HF * at_string will contain the unparsed AT string */ typedef void (* bthf_unknown_at_cmd_callback)(char *at_string, bt_bdaddr_t *bd_addr); /** Callback for keypressed (HSP) event. */ typedef void (* bthf_key_pressed_cmd_callback)(bt_bdaddr_t *bd_addr); /** Callback for HF indicators (BIND) */ typedef void (* bthf_bind_cmd_callback)(char* hf_ind, bthf_bind_type_t type, bt_bdaddr_t *bd_addr); /** Callback for HF indicator value (BIEV) */ typedef void (* bthf_biev_cmd_callback)(char* hf_ind_val, bt_bdaddr_t *bd_addr); /** BT-HF callback structure. */ typedef struct { /** set to sizeof(BtHfCallbacks) */ size_t size; bthf_connection_state_callback connection_state_cb; bthf_audio_state_callback audio_state_cb; bthf_vr_cmd_callback vr_cmd_cb; bthf_answer_call_cmd_callback answer_call_cmd_cb; bthf_hangup_call_cmd_callback hangup_call_cmd_cb; bthf_volume_cmd_callback volume_cmd_cb; bthf_dial_call_cmd_callback dial_call_cmd_cb; bthf_dtmf_cmd_callback dtmf_cmd_cb; bthf_nrec_cmd_callback nrec_cmd_cb; bthf_wbs_callback wbs_cb; bthf_chld_cmd_callback chld_cmd_cb; bthf_cnum_cmd_callback cnum_cmd_cb; bthf_cind_cmd_callback cind_cmd_cb; bthf_cops_cmd_callback cops_cmd_cb; bthf_clcc_cmd_callback clcc_cmd_cb; bthf_unknown_at_cmd_callback unknown_at_cmd_cb; bthf_key_pressed_cmd_callback key_pressed_cmd_cb; bthf_bind_cmd_callback bind_cmd_cb; bthf_biev_cmd_callback biev_cmd_cb; } bthf_callbacks_t; /** Network Status */ typedef enum { BTHF_NETWORK_STATE_NOT_AVAILABLE = 0, BTHF_NETWORK_STATE_AVAILABLE } bthf_network_state_t; /** Service type */ typedef enum { BTHF_SERVICE_TYPE_HOME = 0, BTHF_SERVICE_TYPE_ROAMING } bthf_service_type_t; typedef enum { BTHF_CALL_STATE_ACTIVE = 0, BTHF_CALL_STATE_HELD, BTHF_CALL_STATE_DIALING, BTHF_CALL_STATE_ALERTING, BTHF_CALL_STATE_INCOMING, BTHF_CALL_STATE_WAITING, BTHF_CALL_STATE_IDLE } bthf_call_state_t; typedef enum { BTHF_CALL_DIRECTION_OUTGOING = 0, BTHF_CALL_DIRECTION_INCOMING } bthf_call_direction_t; typedef enum { BTHF_CALL_TYPE_VOICE = 0, BTHF_CALL_TYPE_DATA, BTHF_CALL_TYPE_FAX } bthf_call_mode_t; typedef enum { BTHF_CALL_MPTY_TYPE_SINGLE = 0, BTHF_CALL_MPTY_TYPE_MULTI } bthf_call_mpty_type_t; typedef enum { BTHF_HF_INDICATOR_STATE_DISABLED = 0, BTHF_HF_INDICATOR_STATE_ENABLED } bthf_hf_indicator_status_t; typedef enum { BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81, BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 } bthf_call_addrtype_t; typedef enum { BTHF_VOIP_CALL_NETWORK_TYPE_MOBILE = 0, BTHF_VOIP_CALL_NETWORK_TYPE_WIFI } bthf_voip_call_network_type_t; typedef enum { BTHF_VOIP_STATE_STOPPED = 0, BTHF_VOIP_STATE_STARTED } bthf_voip_state_t; /** Represents the standard BT-HF interface. */ typedef struct { /** set to sizeof(BtHfInterface) */ size_t size; /** * Register the BtHf callbacks */ bt_status_t (*init)( bthf_callbacks_t* callbacks, int max_hf_clients); /** connect to headset */ bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); /** dis-connect from headset */ bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); /** create an audio connection */ bt_status_t (*connect_audio)( bt_bdaddr_t *bd_addr ); /** close the audio connection */ bt_status_t (*disconnect_audio)( bt_bdaddr_t *bd_addr ); /** start voice recognition */ bt_status_t (*start_voice_recognition)( bt_bdaddr_t *bd_addr ); /** stop voice recognition */ bt_status_t (*stop_voice_recognition)( bt_bdaddr_t *bd_addr ); /** volume control */ bt_status_t (*volume_control) (bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr ); /** Combined device status change notification */ bt_status_t (*device_status_notification)(bthf_network_state_t ntk_state, bthf_service_type_t svc_type, int signal, int batt_chg); /** Response for COPS command */ bt_status_t (*cops_response)(const char *cops, bt_bdaddr_t *bd_addr ); /** Response for CIND command */ bt_status_t (*cind_response)(int svc, int num_active, int num_held, bthf_call_state_t call_setup_state, int signal, int roam, int batt_chg, bt_bdaddr_t *bd_addr ); /** Pre-formatted AT response, typically in response to unknown AT cmd */ bt_status_t (*formatted_at_response)(const char *rsp, bt_bdaddr_t *bd_addr ); /** ok/error response * ERROR (0) * OK (1) */ bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code, bt_bdaddr_t *bd_addr ); /** response for CLCC command * Can be iteratively called for each call index * Call index of 0 will be treated as NULL termination (Completes response) */ bt_status_t (*clcc_response) (int index, bthf_call_direction_t dir, bthf_call_state_t state, bthf_call_mode_t mode, bthf_call_mpty_type_t mpty, const char *number, bthf_call_addrtype_t type, bt_bdaddr_t *bd_addr ); /** notify of a call state change * Each update notifies * 1. Number of active/held/ringing calls * 2. call_state: This denotes the state change that triggered this msg * This will take one of the values from BtHfCallState * 3. number & type: valid only for incoming & waiting call */ bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state, const char *number, bthf_call_addrtype_t type); /** Closes the interface. */ void (*cleanup)( void ); /** configureation for the SCO codec */ bt_status_t (*configure_wbs)( bt_bdaddr_t *bd_addr ,bthf_wbs_config_t config ); /** Response for BIND READ command and activation/deactivation of HF indicator */ bt_status_t (*bind_response) (int anum, bthf_hf_indicator_status_t status, bt_bdaddr_t *bd_addr); /** Response for BIND TEST command */ bt_status_t (*bind_string_response) (const char* result, bt_bdaddr_t *bd_addr); /** Sends connectivity network type used by Voip currently to stack */ bt_status_t (*voip_network_type_wifi) (bthf_voip_state_t is_voip_started, bthf_voip_call_network_type_t is_network_wifi); } bthf_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HF_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_hf_client.h ================================================ /* * Copyright (C) 2012-2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H #define ANDROID_INCLUDE_BT_HF_CLIENT_H __BEGIN_DECLS typedef enum { BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0, BTHF_CLIENT_CONNECTION_STATE_CONNECTING, BTHF_CLIENT_CONNECTION_STATE_CONNECTED, BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED, BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING } bthf_client_connection_state_t; typedef enum { BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0, BTHF_CLIENT_AUDIO_STATE_CONNECTING, BTHF_CLIENT_AUDIO_STATE_CONNECTED, BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, } bthf_client_audio_state_t; typedef enum { BTHF_CLIENT_VR_STATE_STOPPED = 0, BTHF_CLIENT_VR_STATE_STARTED } bthf_client_vr_state_t; typedef enum { BTHF_CLIENT_VOLUME_TYPE_SPK = 0, BTHF_CLIENT_VOLUME_TYPE_MIC } bthf_client_volume_type_t; typedef enum { BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0, BTHF_CLIENT_NETWORK_STATE_AVAILABLE } bthf_client_network_state_t; typedef enum { BTHF_CLIENT_SERVICE_TYPE_HOME = 0, BTHF_CLIENT_SERVICE_TYPE_ROAMING } bthf_client_service_type_t; typedef enum { BTHF_CLIENT_CALL_STATE_ACTIVE = 0, BTHF_CLIENT_CALL_STATE_HELD, BTHF_CLIENT_CALL_STATE_DIALING, BTHF_CLIENT_CALL_STATE_ALERTING, BTHF_CLIENT_CALL_STATE_INCOMING, BTHF_CLIENT_CALL_STATE_WAITING, BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD, } bthf_client_call_state_t; typedef enum { BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0, BTHF_CLIENT_CALL_CALLS_IN_PROGRESS } bthf_client_call_t; typedef enum { BTHF_CLIENT_CALLSETUP_NONE = 0, BTHF_CLIENT_CALLSETUP_INCOMING, BTHF_CLIENT_CALLSETUP_OUTGOING, BTHF_CLIENT_CALLSETUP_ALERTING } bthf_client_callsetup_t; typedef enum { BTHF_CLIENT_CALLHELD_NONE = 0, BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE, BTHF_CLIENT_CALLHELD_HOLD, } bthf_client_callheld_t; typedef enum { BTHF_CLIENT_RESP_AND_HOLD_HELD = 0, BTRH_CLIENT_RESP_AND_HOLD_ACCEPT, BTRH_CLIENT_RESP_AND_HOLD_REJECT, } bthf_client_resp_and_hold_t; typedef enum { BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0, BTHF_CLIENT_CALL_DIRECTION_INCOMING } bthf_client_call_direction_t; typedef enum { BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0, BTHF_CLIENT_CALL_MPTY_TYPE_MULTI } bthf_client_call_mpty_type_t; typedef enum { BTHF_CLIENT_CMD_COMPLETE_OK = 0, BTHF_CLIENT_CMD_COMPLETE_ERROR, BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER, BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY, BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER, BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED, BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED, BTHF_CLIENT_CMD_COMPLETE_ERROR_CME } bthf_client_cmd_complete_t; typedef enum { BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0, BTHF_CLIENT_CALL_ACTION_CHLD_1, BTHF_CLIENT_CALL_ACTION_CHLD_2, BTHF_CLIENT_CALL_ACTION_CHLD_3, BTHF_CLIENT_CALL_ACTION_CHLD_4, BTHF_CLIENT_CALL_ACTION_CHLD_1x, BTHF_CLIENT_CALL_ACTION_CHLD_2x, BTHF_CLIENT_CALL_ACTION_ATA, BTHF_CLIENT_CALL_ACTION_CHUP, BTHF_CLIENT_CALL_ACTION_BTRH_0, BTHF_CLIENT_CALL_ACTION_BTRH_1, BTHF_CLIENT_CALL_ACTION_BTRH_2, } bthf_client_call_action_t; typedef enum { BTHF_CLIENT_SERVICE_UNKNOWN = 0, BTHF_CLIENT_SERVICE_VOICE, BTHF_CLIENT_SERVICE_FAX } bthf_client_subscriber_service_type_t; typedef enum { BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0, BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED, } bthf_client_in_band_ring_state_t; /* Peer features masks */ #define BTHF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */ #define BTHF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */ #define BTHF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */ #define BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008 /* In-band ring tone */ #define BTHF_CLIENT_PEER_FEAT_VTAG 0x00000010 /* Attach a phone number to a voice tag */ #define BTHF_CLIENT_PEER_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */ #define BTHF_CLIENT_PEER_FEAT_ECS 0x00000040 /* Enhanced Call Status */ #define BTHF_CLIENT_PEER_FEAT_ECC 0x00000080 /* Enhanced Call Control */ #define BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100 /* Extended error codes */ #define BTHF_CLIENT_PEER_FEAT_CODEC 0x00000200 /* Codec Negotiation */ /* Peer call handling features masks */ #define BTHF_CLIENT_CHLD_FEAT_REL 0x00000001 /* 0 Release waiting call or held calls */ #define BTHF_CLIENT_CHLD_FEAT_REL_ACC 0x00000002 /* 1 Release active calls and accept other (waiting or held) cal */ #define BTHF_CLIENT_CHLD_FEAT_REL_X 0x00000004 /* 1x Release specified active call only */ #define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other (waiting or held) call */ #define BTHF_CLIENT_CHLD_FEAT_PRIV_X 0x00000010 /* 2x Request private mode with specified call (put the rest on hold) */ #define BTHF_CLIENT_CHLD_FEAT_MERGE 0x00000020 /* 3 Add held call to multiparty */ #define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH 0x00000040 /* 4 Connect two calls and leave (disconnect from) multiparty */ /** Callback for connection state change. * state will have one of the values from BtHfConnectionState * peer/chld_features are valid only for BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state */ typedef void (* bthf_client_connection_state_callback)(bthf_client_connection_state_t state, unsigned int peer_feat, unsigned int chld_feat, bt_bdaddr_t *bd_addr); /** Callback for audio connection state change. * state will have one of the values from BtHfAudioState */ typedef void (* bthf_client_audio_state_callback)(bthf_client_audio_state_t state, bt_bdaddr_t *bd_addr); /** Callback for VR connection state change. * state will have one of the values from BtHfVRState */ typedef void (* bthf_client_vr_cmd_callback)(bthf_client_vr_state_t state); /** Callback for network state change */ typedef void (* bthf_client_network_state_callback) (bthf_client_network_state_t state); /** Callback for network roaming status change */ typedef void (* bthf_client_network_roaming_callback) (bthf_client_service_type_t type); /** Callback for signal strength indication */ typedef void (* bthf_client_network_signal_callback) (int signal_strength); /** Callback for battery level indication */ typedef void (* bthf_client_battery_level_callback) (int battery_level); /** Callback for current operator name */ typedef void (* bthf_client_current_operator_callback) (const char *name); /** Callback for call indicator */ typedef void (* bthf_client_call_callback) (bthf_client_call_t call); /** Callback for callsetup indicator */ typedef void (* bthf_client_callsetup_callback) (bthf_client_callsetup_t callsetup); /** Callback for callheld indicator */ typedef void (* bthf_client_callheld_callback) (bthf_client_callheld_t callheld); /** Callback for response and hold */ typedef void (* bthf_client_resp_and_hold_callback) (bthf_client_resp_and_hold_t resp_and_hold); /** Callback for Calling Line Identification notification * Will be called only when there is an incoming call and number is provided. */ typedef void (* bthf_client_clip_callback) (const char *number); /** * Callback for Call Waiting notification */ typedef void (* bthf_client_call_waiting_callback) (const char *number); /** * Callback for listing current calls. Can be called multiple time. * If number is unknown NULL is passed. */ typedef void (*bthf_client_current_calls) (int index, bthf_client_call_direction_t dir, bthf_client_call_state_t state, bthf_client_call_mpty_type_t mpty, const char *number); /** Callback for audio volume change */ typedef void (*bthf_client_volume_change_callback) (bthf_client_volume_type_t type, int volume); /** Callback for command complete event * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type */ typedef void (*bthf_client_cmd_complete_callback) (bthf_client_cmd_complete_t type, int cme); /** Callback for subscriber information */ typedef void (* bthf_client_subscriber_info_callback) (const char *name, bthf_client_subscriber_service_type_t type); /** Callback for in-band ring tone settings */ typedef void (* bthf_client_in_band_ring_tone_callback) (bthf_client_in_band_ring_state_t state); /** * Callback for requested number from AG */ typedef void (* bthf_client_last_voice_tag_number_callback) (const char *number); /** * Callback for sending ring indication to app */ typedef void (* bthf_client_ring_indication_callback) (void); /** * Callback for sending cgmi indication to app */ typedef void (* bthf_client_cgmi_indication_callback) (const char *str); /** * Callback for sending cgmm indication to app */ typedef void (* bthf_client_cgmm_indication_callback) (const char *str); /** BT-HF callback structure. */ typedef struct { /** set to sizeof(BtHfClientCallbacks) */ size_t size; bthf_client_connection_state_callback connection_state_cb; bthf_client_audio_state_callback audio_state_cb; bthf_client_vr_cmd_callback vr_cmd_cb; bthf_client_network_state_callback network_state_cb; bthf_client_network_roaming_callback network_roaming_cb; bthf_client_network_signal_callback network_signal_cb; bthf_client_battery_level_callback battery_level_cb; bthf_client_current_operator_callback current_operator_cb; bthf_client_call_callback call_cb; bthf_client_callsetup_callback callsetup_cb; bthf_client_callheld_callback callheld_cb; bthf_client_resp_and_hold_callback resp_and_hold_cb; bthf_client_clip_callback clip_cb; bthf_client_call_waiting_callback call_waiting_cb; bthf_client_current_calls current_calls_cb; bthf_client_volume_change_callback volume_change_cb; bthf_client_cmd_complete_callback cmd_complete_cb; bthf_client_subscriber_info_callback subscriber_info_cb; bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb; bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback; bthf_client_ring_indication_callback ring_indication_cb; bthf_client_cgmi_indication_callback cgmi_cb; bthf_client_cgmm_indication_callback cgmm_cb; } bthf_client_callbacks_t; /** Represents the standard BT-HF interface. */ typedef struct { /** set to sizeof(BtHfClientInterface) */ size_t size; /** * Register the BtHf callbacks */ bt_status_t (*init)(bthf_client_callbacks_t* callbacks); /** connect to audio gateway */ bt_status_t (*connect)(bt_bdaddr_t *bd_addr); /** disconnect from audio gateway */ bt_status_t (*disconnect)(bt_bdaddr_t *bd_addr); /** create an audio connection */ bt_status_t (*connect_audio)(bt_bdaddr_t *bd_addr); /** close the audio connection */ bt_status_t (*disconnect_audio)(bt_bdaddr_t *bd_addr); /** start voice recognition */ bt_status_t (*start_voice_recognition)(void); /** stop voice recognition */ bt_status_t (*stop_voice_recognition)(void); /** volume control */ bt_status_t (*volume_control) (bthf_client_volume_type_t type, int volume); /** place a call with number a number * if number is NULL last called number is called (aka re-dial)*/ bt_status_t (*dial) (const char *number); /** place a call with number specified by location (speed dial) */ bt_status_t (*dial_memory) (int location); /** perform specified call related action * idx is limited only for enhanced call control related action */ bt_status_t (*handle_call_action) (bthf_client_call_action_t action, int idx); /** query list of current calls */ bt_status_t (*query_current_calls) (void); /** query name of current selected operator */ bt_status_t (*query_current_operator_name) (void); /** Retrieve subscriber information */ bt_status_t (*retrieve_subscriber_info) (void); /** Send DTMF code*/ bt_status_t (*send_dtmf) (char code); /** Request a phone number from AG corresponding to last voice tag recorded */ bt_status_t (*request_last_voice_tag_number) (void); /** Closes the interface. */ void (*cleanup)(void); /** Send AT Command. */ bt_status_t (*send_at_cmd) (int cmd, int val1, int val2, const char *arg); } bthf_client_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_hh.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HH_H #define ANDROID_INCLUDE_BT_HH_H #include __BEGIN_DECLS #define BTHH_MAX_DSC_LEN 884 /* HH connection states */ typedef enum { BTHH_CONN_STATE_CONNECTED = 0, BTHH_CONN_STATE_CONNECTING, BTHH_CONN_STATE_DISCONNECTED, BTHH_CONN_STATE_DISCONNECTING, BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST, BTHH_CONN_STATE_FAILED_KBD_FROM_HOST, BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES, BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER, BTHH_CONN_STATE_FAILED_GENERIC, BTHH_CONN_STATE_UNKNOWN } bthh_connection_state_t; typedef enum { BTHH_OK = 0, BTHH_HS_HID_NOT_READY, /* handshake error : device not ready */ BTHH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */ BTHH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */ BTHH_HS_INVALID_PARAM, /* handshake error : invalid paremter */ BTHH_HS_ERROR, /* handshake error : unspecified HS error */ BTHH_ERR, /* general BTA HH error */ BTHH_ERR_SDP, /* SDP error */ BTHH_ERR_PROTO, /* SET_Protocol error, only used in BTA_HH_OPEN_EVT callback */ BTHH_ERR_DB_FULL, /* device database full error, used */ BTHH_ERR_TOD_UNSPT, /* type of device not supported */ BTHH_ERR_NO_RES, /* out of system resources */ BTHH_ERR_AUTH_FAILED, /* authentication fail */ BTHH_ERR_HDL }bthh_status_t; /* Protocol modes */ typedef enum { BTHH_REPORT_MODE = 0x00, BTHH_BOOT_MODE = 0x01, BTHH_UNSUPPORTED_MODE = 0xff }bthh_protocol_mode_t; /* Report types */ typedef enum { BTHH_INPUT_REPORT = 1, BTHH_OUTPUT_REPORT, BTHH_FEATURE_REPORT }bthh_report_type_t; typedef struct { int attr_mask; uint8_t sub_class; uint8_t app_id; int vendor_id; int product_id; int version; uint8_t ctry_code; int dl_len; uint8_t dsc_list[BTHH_MAX_DSC_LEN]; } bthh_hid_info_t; /** Callback for connection state change. * state will have one of the values from bthh_connection_state_t */ typedef void (* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state); /** Callback for vitual unplug api. * the status of the vitual unplug */ typedef void (* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status); /** Callback for get hid info * hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id, version, ctry_code, len */ typedef void (* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info); /** Callback for get protocol api. * the protocol mode is one of the value from bthh_protocol_mode_t */ typedef void (* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode); /** Callback for get/set_idle_time api. */ typedef void (* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate); /** Callback for get report api. * if staus is ok rpt_data contains the report data */ typedef void (* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size); /** Callback for set_report/set_protocol api and if error * occurs for get_report/get_protocol api. */ typedef void (* bthh_handshake_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status); /** BT-HH callback structure. */ typedef struct { /** set to sizeof(BtHfCallbacks) */ size_t size; bthh_connection_state_callback connection_state_cb; bthh_hid_info_callback hid_info_cb; bthh_protocol_mode_callback protocol_mode_cb; bthh_idle_time_callback idle_time_cb; bthh_get_report_callback get_report_cb; bthh_virtual_unplug_callback virtual_unplug_cb; bthh_handshake_callback handshake_cb; } bthh_callbacks_t; /** Represents the standard BT-HH interface. */ typedef struct { /** set to sizeof(BtHhInterface) */ size_t size; /** * Register the BtHh callbacks */ bt_status_t (*init)( bthh_callbacks_t* callbacks ); /** connect to hid device */ bt_status_t (*connect)( bt_bdaddr_t *bd_addr); /** dis-connect from hid device */ bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); /** Virtual UnPlug (VUP) the specified HID device */ bt_status_t (*virtual_unplug)(bt_bdaddr_t *bd_addr); /** Set the HID device descriptor for the specified HID device. */ bt_status_t (*set_info)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info ); /** Get the HID proto mode. */ bt_status_t (*get_protocol) (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode); /** Set the HID proto mode. */ bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode); /** Get the HID Idle Time */ bt_status_t (*get_idle_time)(bt_bdaddr_t *bd_addr); /** Set the HID Idle Time */ bt_status_t (*set_idle_time)(bt_bdaddr_t *bd_addr, uint8_t idleTime); /** Send a GET_REPORT to HID device. */ bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize); /** Send a SET_REPORT to HID device. */ bt_status_t (*set_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, char* report); /** Send data to HID device. */ bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data); /** Closes the interface. */ void (*cleanup)( void ); } bthh_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HH_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_hl.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_HL_H #define ANDROID_INCLUDE_BT_HL_H __BEGIN_DECLS /* HL connection states */ typedef enum { BTHL_MDEP_ROLE_SOURCE, BTHL_MDEP_ROLE_SINK } bthl_mdep_role_t; typedef enum { BTHL_APP_REG_STATE_REG_SUCCESS, BTHL_APP_REG_STATE_REG_FAILED, BTHL_APP_REG_STATE_DEREG_SUCCESS, BTHL_APP_REG_STATE_DEREG_FAILED } bthl_app_reg_state_t; typedef enum { BTHL_CHANNEL_TYPE_RELIABLE, BTHL_CHANNEL_TYPE_STREAMING, BTHL_CHANNEL_TYPE_ANY } bthl_channel_type_t; /* HL connection states */ typedef enum { BTHL_CONN_STATE_CONNECTING, BTHL_CONN_STATE_CONNECTED, BTHL_CONN_STATE_DISCONNECTING, BTHL_CONN_STATE_DISCONNECTED, BTHL_CONN_STATE_DESTROYED } bthl_channel_state_t; typedef struct { bthl_mdep_role_t mdep_role; int data_type; bthl_channel_type_t channel_type; const char *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */ } bthl_mdep_cfg_t; typedef struct { const char *application_name; const char *provider_name; /* provider name to be used in the SDP (optional); null terminated */ const char *srv_name; /* service name to be used in the SDP (optional); null terminated*/ const char *srv_desp; /* service description to be used in the SDP (optional); null terminated */ int number_of_mdeps; bthl_mdep_cfg_t *mdep_cfg; /* Dynamic array */ } bthl_reg_param_t; /** Callback for application registration status. * state will have one of the values from bthl_app_reg_state_t */ typedef void (* bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state); /** Callback for channel connection state change. * state will have one of the values from * bthl_connection_state_t and fd (file descriptor) */ typedef void (* bthl_channel_state_callback)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd); /** BT-HL callback structure. */ typedef struct { /** set to sizeof(bthl_callbacks_t) */ size_t size; bthl_app_reg_state_callback app_reg_state_cb; bthl_channel_state_callback channel_state_cb; } bthl_callbacks_t; /** Represents the standard BT-HL interface. */ typedef struct { /** set to sizeof(bthl_interface_t) */ size_t size; /** * Register the Bthl callbacks */ bt_status_t (*init)( bthl_callbacks_t* callbacks ); /** Register HL application */ bt_status_t (*register_application) ( bthl_reg_param_t *p_reg_param, int *app_id); /** Unregister HL application */ bt_status_t (*unregister_application) (int app_id); /** connect channel */ bt_status_t (*connect_channel)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int *channel_id); /** destroy channel */ bt_status_t (*destroy_channel)(int channel_id); /** Close the Bthl callback **/ void (*cleanup)(void); } bthl_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_HL_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_mce.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_MCE_H #define ANDROID_INCLUDE_BT_MCE_H __BEGIN_DECLS /** MAS instance description */ typedef struct { int id; int scn; int msg_types; char *p_name; } btmce_mas_instance_t; /** callback for get_remote_mas_instances */ typedef void (*btmce_remote_mas_instances_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, int num_instances, btmce_mas_instance_t *instances); typedef struct { /** set to sizeof(btmce_callbacks_t) */ size_t size; btmce_remote_mas_instances_callback remote_mas_instances_cb; } btmce_callbacks_t; typedef struct { /** set to size of this struct */ size_t size; /** register BT MCE callbacks */ bt_status_t (*init)(btmce_callbacks_t *callbacks); /** search for MAS instances on remote device */ bt_status_t (*get_remote_mas_instances)(bt_bdaddr_t *bd_addr); } btmce_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_MCE_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_pan.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_PAN_H #define ANDROID_INCLUDE_BT_PAN_H __BEGIN_DECLS #define BTPAN_ROLE_NONE 0 #define BTPAN_ROLE_PANNAP 1 #define BTPAN_ROLE_PANU 2 typedef enum { BTPAN_STATE_CONNECTED = 0, BTPAN_STATE_CONNECTING = 1, BTPAN_STATE_DISCONNECTED = 2, BTPAN_STATE_DISCONNECTING = 3 } btpan_connection_state_t; typedef enum { BTPAN_STATE_ENABLED = 0, BTPAN_STATE_DISABLED = 1 } btpan_control_state_t; /** * Callback for pan connection state */ typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error, const bt_bdaddr_t *bd_addr, int local_role, int remote_role); typedef void (*btpan_control_state_callback)(btpan_control_state_t state, int local_role, bt_status_t error, const char* ifname); typedef struct { size_t size; btpan_control_state_callback control_state_cb; btpan_connection_state_callback connection_state_cb; } btpan_callbacks_t; typedef struct { /** set to size of this struct*/ size_t size; /** * Initialize the pan interface and register the btpan callbacks */ bt_status_t (*init)(const btpan_callbacks_t* callbacks); /* * enable the pan service by specified role. The result state of * enabl will be returned by btpan_control_state_callback. when pan-nap is enabled, * the state of connecting panu device will be notified by btpan_connection_state_callback */ bt_status_t (*enable)(int local_role); /* * get current pan local role */ int (*get_local_role)(void); /** * start bluetooth pan connection to the remote device by specified pan role. The result state will be * returned by btpan_connection_state_callback */ bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, int local_role, int remote_role); /** * stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback */ bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr); /** * Cleanup the pan interface */ void (*cleanup)(void); } btpan_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_PAN_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_rc.h ================================================ /* * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_BT_RC_H #define ANDROID_INCLUDE_BT_RC_H __BEGIN_DECLS /* Macros */ #define BTRC_MAX_ATTR_STR_LEN 255 #define BTRC_UID_SIZE 8 #define BTRC_MAX_APP_SETTINGS 8 #define BTRC_MAX_FOLDER_DEPTH 4 #define BTRC_MAX_APP_ATTR_SIZE 16 #define BTRC_MAX_ELEM_ATTR_SIZE 7 #define BTRC_CHARSET_UTF8 0x006A typedef uint8_t btrc_uid_t[BTRC_UID_SIZE]; typedef enum { BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */ BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */ BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */ BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */ } btrc_remote_features_t; typedef enum { BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */ BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */ BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */ BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/ BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/ BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */ } btrc_play_status_t; typedef enum { BTRC_EVT_PLAY_STATUS_CHANGED = 0x01, BTRC_EVT_TRACK_CHANGE = 0x02, BTRC_EVT_TRACK_REACHED_END = 0x03, BTRC_EVT_TRACK_REACHED_START = 0x04, BTRC_EVT_PLAY_POS_CHANGED = 0x05, BTRC_EVT_APP_SETTINGS_CHANGED = 0x08, BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09, BTRC_EVT_AVAILABLE_PLAYERS_CHANGED = 0x0a, BTRC_EVT_ADDRESSED_PLAYER_CHANGED = 0x0b, } btrc_event_id_t; //used for Scope typedef enum { BTRC_EVT_MEDIA_PLAYLIST = 0, BTRC_EVT_MEDIA_VIRTUALFILESYST = 1, BTRC_EVT_SEARCH = 2, BTRC_EVT_NOWPLAYING = 3, BTRC_EVT_MAX_BROWSE = 4, } btrc_browse_folderitem_t; typedef enum { BTRC_NOTIFICATION_TYPE_INTERIM = 0, BTRC_NOTIFICATION_TYPE_CHANGED = 1, BTRC_NOTIFICATION_TYPE_REJECT = 2, } btrc_notification_type_t; typedef enum { BTRC_PLAYER_ATTR_EQUALIZER = 0x01, BTRC_PLAYER_ATTR_REPEAT = 0x02, BTRC_PLAYER_ATTR_SHUFFLE = 0x03, BTRC_PLAYER_ATTR_SCAN = 0x04, } btrc_player_attr_t; typedef enum { BTRC_MEDIA_ATTR_TITLE = 0x01, BTRC_MEDIA_ATTR_ARTIST = 0x02, BTRC_MEDIA_ATTR_ALBUM = 0x03, BTRC_MEDIA_ATTR_TRACK_NUM = 0x04, BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05, BTRC_MEDIA_ATTR_GENRE = 0x06, BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07, } btrc_media_attr_t; typedef enum { BTRC_PLAYER_VAL_OFF_REPEAT = 0x01, BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02, BTRC_PLAYER_VAL_ALL_REPEAT = 0x03, BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04 } btrc_player_repeat_val_t; typedef enum { BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01, BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02, BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03 } btrc_player_shuffle_val_t; typedef enum { BTRC_STS_BAD_CMD = 0x00, /* Invalid command */ BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */ BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */ BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */ BTRC_STS_NO_ERROR = 0x04 /* Operation Success */ } btrc_status_t; typedef enum { BTRC_TYPE_MEDIA_PLAYER = 0x01, BTRC_TYPE_FOLDER = 0x02, BTRC_TYPE_MEDIA_ELEMENT = 0x03 } btrc_folder_list_item_type_t; typedef struct { uint8_t num_attr; uint8_t attr_ids[BTRC_MAX_APP_SETTINGS]; uint8_t attr_values[BTRC_MAX_APP_SETTINGS]; } btrc_player_settings_t; typedef struct { uint32_t start_item; uint32_t end_item; uint32_t size; uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE]; uint8_t attr_count; }btrc_getfolderitem_t; typedef union { btrc_play_status_t play_status; btrc_uid_t track; /* queue position in NowPlaying */ uint32_t song_pos; btrc_player_settings_t player_setting; uint16_t player_id; } btrc_register_notification_t; typedef struct { uint8_t id; /* can be attr_id or value_id */ uint8_t text[BTRC_MAX_ATTR_STR_LEN]; } btrc_player_setting_text_t; typedef struct { uint32_t attr_id; uint8_t text[BTRC_MAX_ATTR_STR_LEN]; } btrc_element_attr_val_t; /** Callback for the controller's supported feautres */ typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr, btrc_remote_features_t features); #define BTRC_FEATURE_MASK_SIZE 16 typedef uint8_t btrc_feature_mask_t[BTRC_FEATURE_MASK_SIZE]; typedef struct { uint16_t charset_id; uint16_t str_len; uint8_t *p_str; } btrc_player_full_name_t; typedef struct { uint32_t sub_type; uint16_t player_id; uint8_t major_type; uint8_t play_status; btrc_feature_mask_t features; /* Supported feature bit mask*/ btrc_player_full_name_t name; /* The player name, name length and character set id.*/ } btrc_folder_list_item_player_t; typedef struct { uint64_t uid; uint8_t type; uint8_t playable; btrc_player_full_name_t name; } btrc_folder_list_item_folder_t; typedef struct { uint32_t attr_id; btrc_player_full_name_t name; } btrc_attr_entry_t; typedef struct { uint64_t uid; uint8_t type; uint8_t attr_count; btrc_player_full_name_t name; btrc_attr_entry_t* p_attr_list; } btrc_folder_list_item_media_t; typedef struct { uint16_t str_len; uint8_t *p_str; } btrc_name_t; /* SetBrowsedPlayer */ typedef struct { uint32_t num_items; uint16_t uid_counter; uint16_t charset_id; uint8_t status; uint8_t folder_depth; btrc_name_t *p_folders; } btrc_set_browsed_player_rsp_t; typedef struct { uint8_t item_type; union { btrc_folder_list_item_player_t player; btrc_folder_list_item_folder_t folder; btrc_folder_list_item_media_t media; } u; } btrc_folder_list_item_t; /* GetFolderItems */ typedef struct { uint16_t uid_counter; uint16_t item_count; uint8_t status; btrc_folder_list_item_t *p_item_list; } btrc_folder_list_entries_t; /** Callback for play status request */ typedef void (* btrc_get_play_status_callback)(bt_bdaddr_t *bd_addr); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_attr_callback)(bt_bdaddr_t *bd_addr); /** Callback for list player application attributes (Shuffle, Repeat,...) */ typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id, bt_bdaddr_t *bd_addr); /** Callback for getting the current player application settings value ** num_attr: specifies the number of attribute ids contained in p_attrs */ typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs, bt_bdaddr_t *bd_addr); /** Callback for getting the player application settings attributes' text ** num_attr: specifies the number of attribute ids contained in p_attrs */ typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs, bt_bdaddr_t *bd_addr); /** Callback for getting the player application settings values' text ** num_attr: specifies the number of value ids contained in p_vals */ typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals, bt_bdaddr_t *bd_addr); /** Callback for setting the player application settings values */ typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals, bt_bdaddr_t *bd_addr); /** Callback to fetch the get element attributes of the current song ** num_attr: specifies the number of attributes requested in p_attrs */ typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs, bt_bdaddr_t *bd_addr); /** Callback for register notification (Play state change/track change/...) ** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED */ typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param, bt_bdaddr_t *bd_addr); /* AVRCP 1.4 Enhancements */ /** Callback for volume change on CT ** volume: Current volume setting on the CT (0-127) */ typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype, bt_bdaddr_t *bd_addr); /** Callback for passthrough commands */ typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state, bt_bdaddr_t *bd_addr); /** BT-RC Target callback structure. */ typedef void (* btrc_get_folder_items_callback) (btrc_browse_folderitem_t id, btrc_getfolderitem_t *param, bt_bdaddr_t *bd_addr); typedef void (* btrc_set_addressed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr); typedef void (* btrc_set_browsed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr); typedef void (* btrc_change_path_callback) (uint8_t direction, uint64_t uid, bt_bdaddr_t *bd_addr); typedef void (* btrc_play_item_callback) (uint8_t scope, uint64_t uid, bt_bdaddr_t *bd_addr); typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint64_t uid, uint8_t num_attr, btrc_media_attr_t *p_attrs, bt_bdaddr_t *bd_addr); typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); typedef struct { /** set to sizeof(BtRcCallbacks) */ size_t size; btrc_remote_features_callback remote_features_cb; btrc_get_play_status_callback get_play_status_cb; btrc_list_player_app_attr_callback list_player_app_attr_cb; btrc_list_player_app_values_callback list_player_app_values_cb; btrc_get_player_app_value_callback get_player_app_value_cb; btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb; btrc_get_player_app_values_text_callback get_player_app_values_text_cb; btrc_set_player_app_value_callback set_player_app_value_cb; btrc_get_element_attr_callback get_element_attr_cb; btrc_register_notification_callback register_notification_cb; btrc_volume_change_callback volume_change_cb; btrc_passthrough_cmd_callback passthrough_cmd_cb; btrc_get_folder_items_callback get_folderitems_cb; btrc_set_addressed_player_callback set_addrplayer_cb; btrc_set_browsed_player_callback set_browsed_player_cb; btrc_change_path_callback change_path_cb; btrc_play_item_callback play_item_cb; btrc_get_item_attr_callback get_item_attr_cb; btrc_connection_state_callback connection_state_cb; } btrc_callbacks_t; /** Represents the standard BT-RC AVRCP Target interface. */ typedef struct { /** set to sizeof(BtRcInterface) */ size_t size; /** * Register the BtRc callbacks */ bt_status_t (*init)( btrc_callbacks_t* callbacks , int max_avrcp_connections); /** Respose to GetPlayStatus request. Contains the current ** 1. Play status ** 2. Song duration/length ** 3. Song position */ bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos, bt_bdaddr_t *bd_addr); /** Lists the support player application attributes (Shuffle/Repeat/...) ** num_attr: Specifies the number of attributes contained in the pointer p_attrs */ bt_status_t (*list_player_app_attr_rsp)( uint8_t num_attr, btrc_player_attr_t *p_attrs, bt_bdaddr_t *bd_addr); /** Lists the support player application attributes (Shuffle Off/On/Group) ** num_val: Specifies the number of values contained in the pointer p_vals */ bt_status_t (*list_player_app_value_rsp)( uint8_t num_val, uint8_t *p_vals, bt_bdaddr_t *bd_addr); /** Returns the current application attribute values for each of the specified attr_id */ bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals, bt_bdaddr_t *bd_addr); /** Returns the application attributes text ("Shuffle"/"Repeat"/...) ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs */ bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs, bt_bdaddr_t *bd_addr); /** Returns the application attributes text ("Shuffle"/"Repeat"/...) ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals */ bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals, bt_bdaddr_t *bd_addr); /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist") ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs */ bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs, bt_bdaddr_t *bd_addr); /** Response to set player attribute request ("Shuffle"/"Repeat") ** rsp_status: Status of setting the player attributes for the current media player */ bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status, bt_bdaddr_t *bd_addr); /* Response to the register notification request (Play state change/track change/...). ** event_id: Refers to the event_id this notification change corresponds too ** type: Response type - interim/changed ** p_params: Based on the event_id, this parameter should be populated */ bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id, btrc_notification_type_t type, btrc_register_notification_t *p_param, bt_bdaddr_t *bd_addr); /* AVRCP 1.4 enhancements */ /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume ** This can be enhanced to support Relative Volume (AVRCP 1.0). ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set */ bt_status_t (*set_volume)(uint8_t volume, bt_bdaddr_t *bd_addr); bt_status_t (*get_folder_items_rsp) (btrc_folder_list_entries_t *p_param, bt_bdaddr_t *bd_addr); bt_status_t (*set_addressed_player_rsp) (btrc_status_t status_code, bt_bdaddr_t *bd_addr); bt_status_t (*set_browsed_player_rsp) (btrc_set_browsed_player_rsp_t *p_param, bt_bdaddr_t *bd_addr); bt_status_t (*change_path_rsp) (uint8_t status_code, uint32_t item_count, bt_bdaddr_t *bd_addr); bt_status_t (*play_item_rsp) (uint8_t status_code, bt_bdaddr_t *bd_addr); bt_status_t (*get_item_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs, bt_bdaddr_t *bd_addr); bt_status_t (*is_device_active_in_handoff) (bt_bdaddr_t *bd_addr); /** Closes the interface. */ void (*cleanup)( void ); } btrc_interface_t; typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); typedef void (* btrc_ctrl_getrcfeatures_callback) (bt_bdaddr_t *bd_addr, int features); typedef void (* btrc_ctrl_getcapability_rsp_callback) (bt_bdaddr_t *bd_addr, int cap_id, uint32_t* supported_values, int num_supported, uint8_t rsp_type); typedef void (* btrc_ctrl_listplayerappsettingattrib_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t* supported_attribs, int num_attrib, uint8_t rsp_type); typedef void (* btrc_ctrl_listplayerappsettingvalue_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t* supported_val, uint8_t num_supported, uint8_t rsp_type); typedef void (* btrc_ctrl_currentplayerappsetting_rsp_callback) (bt_bdaddr_t *bd_addr,uint8_t* supported_ids, uint8_t* supported_val, uint8_t num_attrib, uint8_t rsp_type); typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (bt_bdaddr_t *bd_addr,uint8_t rsp_type); typedef void (* btrc_ctrl_notification_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t rsp_type, int rsp_len, uint8_t* notification_rsp); typedef void (* btrc_ctrl_getelementattrib_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t num_attributes, int rsp_len, uint8_t* attrib_rsp, uint8_t rsp_type); typedef void (* btrc_ctrl_getplaystatus_rsp_callback) (bt_bdaddr_t *bd_addr, int param_len, uint8_t* play_status_rsp ,uint8_t rsp_type); typedef void (* btrc_ctrl_setabsvol_cmd_callback) (bt_bdaddr_t *bd_addr, uint8_t abs_vol); typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (bt_bdaddr_t *bd_addr); /** BT-RC Controller callback structure. */ typedef struct { /** set to sizeof(BtRcCallbacks) */ size_t size; btrc_passthrough_rsp_callback passthrough_rsp_cb; btrc_connection_state_callback connection_state_cb; btrc_ctrl_getrcfeatures_callback getrcfeatures_cb; btrc_ctrl_getcapability_rsp_callback getcap_rsp_cb; btrc_ctrl_listplayerappsettingattrib_rsp_callback listplayerappsettingattrib_rsp_cb; btrc_ctrl_listplayerappsettingvalue_rsp_callback listplayerappsettingvalue_rsp_cb; btrc_ctrl_currentplayerappsetting_rsp_callback currentplayerappsetting_rsp_cb; btrc_ctrl_setplayerapplicationsetting_rsp_callback setplayerappsetting_rsp_cb; btrc_ctrl_notification_rsp_callback notification_rsp_cb; btrc_ctrl_getelementattrib_rsp_callback getelementattrib_rsp_cb; btrc_ctrl_getplaystatus_rsp_callback getplaystatus_rsp_cb; btrc_ctrl_setabsvol_cmd_callback setabsvol_cmd_cb; btrc_ctrl_registernotification_abs_vol_callback registernotification_absvol_cb; } btrc_ctrl_callbacks_t; /** Represents the standard BT-RC AVRCP Controller interface. */ typedef struct { /** set to sizeof(BtRcInterface) */ size_t size; /** * Register the BtRc callbacks */ bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks ); /** send pass through command to target */ bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code, uint8_t key_state ); /** send get_cap command to target */ bt_status_t (*getcapabilities_cmd) (uint8_t cap_id); /** send command to get supported player application settings to target */ bt_status_t (*list_player_app_setting_attrib_cmd) (void); /** send command to get supported values of player application settings for a * particular attribute to target */ bt_status_t (*list_player_app_setting_value_cmd) (uint8_t attrib_id); /** send command to get current player attributes to target */ bt_status_t (*get_player_app_setting_cmd) (uint8_t num_attrib, uint8_t* attrib_ids); /** send command to set player applicaiton setting attributes to target */ bt_status_t (*set_player_app_setting_cmd) (uint8_t num_attrib, uint8_t* attrib_ids, uint8_t* attrib_vals); /** send command to register for supported notificaiton events to target */ bt_status_t (*register_notification_cmd) (uint8_t event_id, uint32_t event_value); /** send command to get element attribute to target */ bt_status_t (*get_element_attribute_cmd) (uint8_t num_attribute, uint32_t attribute_id); /** send command to get play status to target */ bt_status_t (*get_play_status_cmd) (void); /** send rsp to set_abs_vol received from target */ bt_status_t (*send_abs_vol_rsp) (uint8_t abs_vol); /** send notificaiton rsp for abs vol to target */ bt_status_t (*send_register_abs_vol_rsp) (uint8_t rsp_type, uint8_t abs_vol); /** Closes the interface. */ void (*cleanup)( void ); } btrc_ctrl_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_BT_RC_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_sdp.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "bluetooth.h" #define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15 __BEGIN_DECLS /** * These events are handled by the state machine */ typedef enum { SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs SDP_TYPE_MAP_MAS, // Message Access Profile - Server SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server) SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client SDP_TYPE_OPP_SERVER, // Object Push Profile SDP_TYPE_SAP_SERVER // SIM Access Profile } bluetooth_sdp_types; typedef struct _bluetooth_sdp_hdr { bluetooth_sdp_types type; bt_uuid_t uuid; uint32_t service_name_length; char *service_name; int32_t rfcomm_channel_number; int32_t l2cap_psm; int32_t profile_version; } bluetooth_sdp_hdr; /** * Some signals need additional pointers, hence we introduce a * generic way to handle these pointers. */ typedef struct _bluetooth_sdp_hdr_overlay { bluetooth_sdp_types type; bt_uuid_t uuid; uint32_t service_name_length; char *service_name; int32_t rfcomm_channel_number; int32_t l2cap_psm; int32_t profile_version; // User pointers, only used for some signals - see bluetooth_sdp_ops_record int user1_ptr_len; uint8_t *user1_ptr; int user2_ptr_len; uint8_t *user2_ptr; } bluetooth_sdp_hdr_overlay; typedef struct _bluetooth_sdp_mas_record { bluetooth_sdp_hdr_overlay hdr; uint32_t mas_instance_id; uint32_t supported_features; uint32_t supported_message_types; } bluetooth_sdp_mas_record; typedef struct _bluetooth_sdp_mns_record { bluetooth_sdp_hdr_overlay hdr; uint32_t supported_features; } bluetooth_sdp_mns_record; typedef struct _bluetooth_sdp_pse_record { bluetooth_sdp_hdr_overlay hdr; uint32_t supported_features; uint32_t supported_repositories; } bluetooth_sdp_pse_record; typedef struct _bluetooth_sdp_pce_record { bluetooth_sdp_hdr_overlay hdr; } bluetooth_sdp_pce_record; typedef struct _bluetooth_sdp_ops_record { bluetooth_sdp_hdr_overlay hdr; int supported_formats_list_len; uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; } bluetooth_sdp_ops_record; typedef struct _bluetooth_sdp_sap_record { bluetooth_sdp_hdr_overlay hdr; } bluetooth_sdp_sap_record; typedef union { bluetooth_sdp_hdr_overlay hdr; bluetooth_sdp_mas_record mas; bluetooth_sdp_mns_record mns; bluetooth_sdp_pse_record pse; bluetooth_sdp_pce_record pce; bluetooth_sdp_ops_record ops; bluetooth_sdp_sap_record sap; } bluetooth_sdp_record; /** Callback for SDP search */ typedef void (*btsdp_search_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, uint8_t* uuid, int num_records, bluetooth_sdp_record *records); typedef struct { /** Set to sizeof(btsdp_callbacks_t) */ size_t size; btsdp_search_callback sdp_search_cb; } btsdp_callbacks_t; typedef struct { /** Set to size of this struct */ size_t size; /** Register BT SDP search callbacks */ bt_status_t (*init)(btsdp_callbacks_t *callbacks); /** Unregister BT SDP */ bt_status_t (*deinit)(); /** Search for SDP records with specific uuid on remote device */ bt_status_t (*sdp_search)(bt_bdaddr_t *bd_addr, const uint8_t* uuid); /** * Use listen in the socket interface to create rfcomm and/or l2cap PSM channels, * (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP flag in flags). * Then use createSdpRecord to create the SDP record associated with the rfcomm/l2cap channels. * * Returns a handle to the SDP record, which can be parsed to remove_sdp_record. * * record (in) The SDP record to create * record_handle (out)The corresponding record handle will be written to this pointer. */ bt_status_t (*create_sdp_record)(bluetooth_sdp_record *record, int* record_handle); /** Remove a SDP record created by createSdpRecord */ bt_status_t (*remove_sdp_record)(int sdp_handle); } btsdp_interface_t; __END_DECLS ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/bt_sock.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once __BEGIN_DECLS #define BTSOCK_FLAG_ENCRYPT 1 #define BTSOCK_FLAG_AUTH (1 << 1) #define BTSOCK_FLAG_NO_SDP (1 << 2) #define BTSOCK_FLAG_AUTH_MITM (1 << 3) #define BTSOCK_FLAG_AUTH_16_DIGIT (1 << 4) typedef enum { BTSOCK_RFCOMM = 1, BTSOCK_SCO = 2, BTSOCK_L2CAP = 3 } btsock_type_t; typedef enum { BTSOCK_OPT_GET_MODEM_BITS = 1, BTSOCK_OPT_SET_MODEM_BITS = 2, BTSOCK_OPT_CLR_MODEM_BITS = 3, } btsock_option_type_t; /** Represents the standard BT SOCKET interface. */ typedef struct { short size; bt_bdaddr_t bd_addr; int channel; int status; // The writer must make writes using a buffer of this maximum size // to avoid loosing data. (L2CAP only) unsigned short max_tx_packet_size; // The reader must read using a buffer of at least this size to avoid // loosing data. (L2CAP only) unsigned short max_rx_packet_size; } __attribute__((packed)) sock_connect_signal_t; typedef struct { /** set to size of this struct*/ size_t size; /** * Listen to a RFCOMM UUID or channel. It returns the socket fd from which * btsock_connect_signal can be read out when a remote device connected. * If neither a UUID nor a channel is provided, a channel will be allocated * and a service record can be created providing the channel number to * create_sdp_record(...) in bt_sdp. */ bt_status_t (*listen)(btsock_type_t type, const char* service_name, const uint8_t* service_uuid, int channel, int* sock_fd, int flags); /** * Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected */ bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, int channel, int* sock_fd, int flags); /* * get socket option of rfcomm channel socket. */ bt_status_t (*get_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, void *option_value, int *option_len); /* * set socket option of rfcomm channel socket. */ bt_status_t (*set_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, void *option_value, int option_len); } btsock_interface_t; __END_DECLS ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/camera.h ================================================ /* * Copyright (C) 2010-2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_CAMERA_H #define ANDROID_INCLUDE_CAMERA_H #include "camera_common.h" /** * Camera device HAL, initial version [ CAMERA_DEVICE_API_VERSION_1_0 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return a value in * the range HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF) in * camera_device_t.common.version. CAMERA_DEVICE_API_VERSION_1_0 is the * recommended value. * * Camera modules that implement version 2.0 or higher of camera_module_t must * also return the value of camera_device_t.common.version in * camera_info_t.device_version. * * See camera_common.h for more details. */ __BEGIN_DECLS struct camera_memory; typedef void (*camera_release_memory)(struct camera_memory *mem); typedef struct camera_memory { void *data; size_t size; void *handle; camera_release_memory release; } camera_memory_t; typedef camera_memory_t* (*camera_request_memory)(int fd, size_t buf_size, unsigned int num_bufs, void *user); typedef void (*camera_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, void *user); typedef void (*camera_data_callback)(int32_t msg_type, const camera_memory_t *data, unsigned int index, camera_frame_metadata_t *metadata, void *user); typedef void (*camera_data_timestamp_callback)(int64_t timestamp, int32_t msg_type, const camera_memory_t *data, unsigned int index, void *user); #define HAL_CAMERA_PREVIEW_WINDOW_TAG 0xcafed00d typedef struct preview_stream_ops { int (*dequeue_buffer)(struct preview_stream_ops* w, buffer_handle_t** buffer, int *stride); int (*enqueue_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*cancel_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); int (*set_buffer_count)(struct preview_stream_ops* w, int count); int (*set_buffers_geometry)(struct preview_stream_ops* pw, int w, int h, int format); int (*set_crop)(struct preview_stream_ops *w, int left, int top, int right, int bottom); int (*set_usage)(struct preview_stream_ops* w, int usage); int (*set_swap_interval)(struct preview_stream_ops *w, int interval); int (*get_min_undequeued_buffer_count)(const struct preview_stream_ops *w, int *count); int (*lock_buffer)(struct preview_stream_ops* w, buffer_handle_t* buffer); // Timestamps are measured in nanoseconds, and must be comparable // and monotonically increasing between two frames in the same // preview stream. They do not need to be comparable between // consecutive or parallel preview streams, cameras, or app runs. int (*set_timestamp)(struct preview_stream_ops *w, int64_t timestamp); } preview_stream_ops_t; struct camera_device; typedef struct camera_device_ops { /** Set the ANativeWindow to which preview frames are sent */ int (*set_preview_window)(struct camera_device *, struct preview_stream_ops *window); /** Set the notification and data callbacks */ void (*set_callbacks)(struct camera_device *, camera_notify_callback notify_cb, camera_data_callback data_cb, camera_data_timestamp_callback data_cb_timestamp, camera_request_memory get_memory, void *user); /** * The following three functions all take a msg_type, which is a bitmask of * the messages defined in include/ui/Camera.h */ /** * Enable a message, or set of messages. */ void (*enable_msg_type)(struct camera_device *, int32_t msg_type); /** * Disable a message, or a set of messages. * * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera * HAL should not rely on its client to call releaseRecordingFrame() to * release video recording frames sent out by the cameral HAL before and * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL * clients must not modify/access any video recording frame after calling * disableMsgType(CAMERA_MSG_VIDEO_FRAME). */ void (*disable_msg_type)(struct camera_device *, int32_t msg_type); /** * Query whether a message, or a set of messages, is enabled. Note that * this is operates as an AND, if any of the messages queried are off, this * will return false. */ int (*msg_type_enabled)(struct camera_device *, int32_t msg_type); /** * Start preview mode. */ int (*start_preview)(struct camera_device *); /** * Stop a previously started preview. */ void (*stop_preview)(struct camera_device *); /** * Returns true if preview is enabled. */ int (*preview_enabled)(struct camera_device *); /** * Request the camera HAL to store meta data or real YUV data in the video * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If * it is not called, the default camera HAL behavior is to store real YUV * data in the video buffers. * * This method should be called before startRecording() in order to be * effective. * * If meta data is stored in the video buffers, it is up to the receiver of * the video buffers to interpret the contents and to find the actual frame * data with the help of the meta data in the buffer. How this is done is * outside of the scope of this method. * * Some camera HALs may not support storing meta data in the video buffers, * but all camera HALs should support storing real YUV data in the video * buffers. If the camera HAL does not support storing the meta data in the * video buffers when it is requested to do do, INVALID_OPERATION must be * returned. It is very useful for the camera HAL to pass meta data rather * than the actual frame data directly to the video encoder, since the * amount of the uncompressed frame data can be very large if video size is * large. * * @param enable if true to instruct the camera HAL to store * meta data in the video buffers; false to instruct * the camera HAL to store real YUV data in the video * buffers. * * @return OK on success. */ int (*store_meta_data_in_buffers)(struct camera_device *, int enable); /** * Start record mode. When a record image is available, a * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding * frame. Every record frame must be released by a camera HAL client via * releaseRecordingFrame() before the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames, * and the client must not modify/access any video recording frames. */ int (*start_recording)(struct camera_device *); /** * Stop a previously started recording. */ void (*stop_recording)(struct camera_device *); /** * Returns true if recording is enabled. */ int (*recording_enabled)(struct camera_device *); /** * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. * * It is camera HAL client's responsibility to release video recording * frames sent out by the camera HAL before the camera HAL receives a call * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's * responsibility to manage the life-cycle of the video recording frames. */ void (*release_recording_frame)(struct camera_device *, const void *opaque); /** * Start auto focus, the notification callback routine is called with * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be * called again if another auto focus is needed. */ int (*auto_focus)(struct camera_device *); /** * Cancels auto-focus function. If the auto-focus is still in progress, * this function will cancel it. Whether the auto-focus is in progress or * not, this function will return the focus position to the default. If * the camera does not support auto-focus, this is a no-op. */ int (*cancel_auto_focus)(struct camera_device *); /** * Take a picture. */ int (*take_picture)(struct camera_device *); /** * Cancel a picture that was started with takePicture. Calling this method * when no picture is being taken is a no-op. */ int (*cancel_picture)(struct camera_device *); /** * Set the camera parameters. This returns BAD_VALUE if any parameter is * invalid or not supported. */ int (*set_parameters)(struct camera_device *, const char *parms); /** Retrieve the camera parameters. The buffer returned by the camera HAL must be returned back to it with put_parameters, if put_parameters is not NULL. */ char *(*get_parameters)(struct camera_device *); /** The camera HAL uses its own memory to pass us the parameters when we call get_parameters. Use this function to return the memory back to the camera HAL, if put_parameters is not NULL. If put_parameters is NULL, then you have to use free() to release the memory. */ void (*put_parameters)(struct camera_device *, char *); /** * Send command to camera driver. */ int (*send_command)(struct camera_device *, int32_t cmd, int32_t arg1, int32_t arg2); /** * Release the hardware resources owned by this object. Note that this is * *not* done in the destructor. */ void (*release)(struct camera_device *); /** * Dump state of the camera hardware */ int (*dump)(struct camera_device *, int fd); } camera_device_ops_t; typedef struct camera_device { /** * camera_device.common.version must be in the range * HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF). CAMERA_DEVICE_API_VERSION_1_0 is * recommended. */ hw_device_t common; camera_device_ops_t *ops; void *priv; } camera_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/camera2.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_CAMERA2_H #define ANDROID_INCLUDE_CAMERA2_H #include "camera_common.h" #include "system/camera_metadata.h" /** * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ] * * DEPRECATED. New devices should use Camera HAL v3.2 or newer. * * Supports the android.hardware.Camera API, and the android.hardware.camera2 * API in legacy mode only. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_2_1 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * Camera modules that may contain version 2.x devices must implement at least * version 2.0 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Version history: * * 2.0: CAMERA_DEVICE_API_VERSION_2_0. Initial release (Android 4.2): * - Sufficient for implementing existing android.hardware.Camera API. * - Allows for ZSL queue in camera service layer * - Not tested for any new features such manual capture control, * Bayer RAW capture, reprocessing of RAW data. * * 2.1: CAMERA_DEVICE_API_VERSION_2_1. Support per-device static metadata: * - Add get_instance_metadata() method to retrieve metadata that is fixed * after device open, but may be variable between open() calls. */ __BEGIN_DECLS struct camera2_device; /********************************************************************** * * Input/output stream buffer queue interface definitions * */ /** * Output image stream queue interface. A set of these methods is provided to * the HAL device in allocate_stream(), and are used to interact with the * gralloc buffer queue for that stream. They may not be called until after * allocate_stream returns. */ typedef struct camera2_stream_ops { /** * Get a buffer to fill from the queue. The size and format of the buffer * are fixed for a given stream (defined in allocate_stream), and the stride * should be queried from the platform gralloc module. The gralloc buffer * will have been allocated based on the usage flags provided by * allocate_stream, and will be locked for use. */ int (*dequeue_buffer)(const struct camera2_stream_ops* w, buffer_handle_t** buffer); /** * Push a filled buffer to the stream to be used by the consumer. * * The timestamp represents the time at start of exposure of the first row * of the image; it must be from a monotonic clock, and is measured in * nanoseconds. The timestamps do not need to be comparable between * different cameras, or consecutive instances of the same camera. However, * they must be comparable between streams from the same camera. If one * capture produces buffers for multiple streams, each stream must have the * same timestamp for that buffer, and that timestamp must match the * timestamp in the output frame metadata. */ int (*enqueue_buffer)(const struct camera2_stream_ops* w, int64_t timestamp, buffer_handle_t* buffer); /** * Return a buffer to the queue without marking it as filled. */ int (*cancel_buffer)(const struct camera2_stream_ops* w, buffer_handle_t* buffer); /** * Set the crop window for subsequently enqueued buffers. The parameters are * measured in pixels relative to the buffer width and height. */ int (*set_crop)(const struct camera2_stream_ops *w, int left, int top, int right, int bottom); } camera2_stream_ops_t; /** * Temporary definition during transition. * * These formats will be removed and replaced with * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility, * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output * parameter of allocate_stream, allowing the gralloc module to select the * specific format based on the usage flags from the camera and the stream * consumer. */ enum { CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 }; /** * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is * used as the buffer size. Since compressed JPEG images are of variable size, * the HAL needs to include the final size of the compressed image using this * structure inside the output stream buffer. The JPEG blob ID field must be set * to CAMERA2_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must * account for it in android.jpeg.maxSize. The JPEG data itself starts at * byte[0] and should be jpeg_size bytes long. */ typedef struct camera2_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; }; enum { CAMERA2_JPEG_BLOB_ID = 0x00FF }; /** * Input reprocess stream queue management. A set of these methods is provided * to the HAL device in allocate_reprocess_stream(); they are used to interact * with the reprocess stream's input gralloc buffer queue. */ typedef struct camera2_stream_in_ops { /** * Get the next buffer of image data to reprocess. The width, height, and * format of the buffer is fixed in allocate_reprocess_stream(), and the * stride and other details should be queried from the platform gralloc * module as needed. The buffer will already be locked for use. */ int (*acquire_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t** buffer); /** * Return a used buffer to the buffer queue for reuse. */ int (*release_buffer)(const struct camera2_stream_in_ops *w, buffer_handle_t* buffer); } camera2_stream_in_ops_t; /********************************************************************** * * Metadata queue management, used for requests sent to HAL module, and for * frames produced by the HAL. * */ enum { CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 }; /** * Request input queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the first metadata buffer is placed into the queue, the framework * signals the device by calling notify_request_queue_not_empty(). * * 2. After receiving notify_request_queue_not_empty, the device must call * dequeue() once it's ready to handle the next buffer. * * 3. Once the device has processed a buffer, and is ready for the next buffer, * it must call dequeue() again instead of waiting for a notification. If * there are no more buffers available, dequeue() will return NULL. After * this point, when a buffer becomes available, the framework must call * notify_request_queue_not_empty() again. If the device receives a NULL * return from dequeue, it does not need to query the queue again until a * notify_request_queue_not_empty() call is received from the source. * * 4. If the device calls buffer_count() and receives 0, this does not mean that * the framework will provide a notify_request_queue_not_empty() call. The * framework will only provide such a notification after the device has * received a NULL from dequeue, or on initial startup. * * 5. The dequeue() call in response to notify_request_queue_not_empty() may be * on the same thread as the notify_request_queue_not_empty() call, and may * be performed from within the notify call. * * 6. All dequeued request buffers must be returned to the framework by calling * free_request, including when errors occur, a device flush is requested, or * when the device is shutting down. */ typedef struct camera2_request_queue_src_ops { /** * Get the count of request buffers pending in the queue. May return * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream * request) is currently configured. Calling this method has no effect on * whether the notify_request_queue_not_empty() method will be called by the * framework. */ int (*request_count)(const struct camera2_request_queue_src_ops *q); /** * Get a metadata buffer from the framework. Returns OK if there is no * error. If the queue is empty, returns NULL in buffer. In that case, the * device must wait for a notify_request_queue_not_empty() message before * attempting to dequeue again. Buffers obtained in this way must be * returned to the framework with free_request(). */ int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t **buffer); /** * Return a metadata buffer to the framework once it has been used, or if * an error or shutdown occurs. */ int (*free_request)(const struct camera2_request_queue_src_ops *q, camera_metadata_t *old_buffer); } camera2_request_queue_src_ops_t; /** * Frame output queue protocol: * * The framework holds the queue and its contents. At start, the queue is empty. * * 1. When the device is ready to fill an output metadata frame, it must dequeue * a metadata buffer of the required size. * * 2. It should then fill the metadata buffer, and place it on the frame queue * using enqueue_frame. The framework takes ownership of the frame. * * 3. In case of an error, a request to flush the pipeline, or shutdown, the * device must return any affected dequeued frames to the framework by * calling cancel_frame. */ typedef struct camera2_frame_queue_dst_ops { /** * Get an empty metadata buffer to fill from the framework. The new metadata * buffer will have room for entries number of metadata entries, plus * data_bytes worth of extra storage. Frames dequeued here must be returned * to the framework with either cancel_frame or enqueue_frame. */ int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, size_t entries, size_t data_bytes, camera_metadata_t **buffer); /** * Return a dequeued metadata buffer to the framework for reuse; do not mark it as * filled. Use when encountering errors, or flushing the internal request queue. */ int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); /** * Place a completed metadata frame on the frame output queue. */ int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, camera_metadata_t *buffer); } camera2_frame_queue_dst_ops_t; /********************************************************************** * * Notification callback and message definition, and trigger definitions * */ /** * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that require * specific timing. The user pointer must be the same one that was passed to the * device in set_notify_callback(). */ typedef void (*camera2_notify_callback)(int32_t msg_type, int32_t ext1, int32_t ext2, int32_t ext3, void *user); /** * Possible message types for camera2_notify_callback */ enum { /** * An error has occurred. Argument ext1 contains the error code, and * ext2 and ext3 contain any error-specific information. */ CAMERA2_MSG_ERROR = 0x0001, /** * The exposure of a given request has begun. Argument ext1 contains the * frame number, and ext2 and ext3 contain the low-order and high-order * bytes of the timestamp for when exposure began. * (timestamp = (ext3 << 32 | ext2)) */ CAMERA2_MSG_SHUTTER = 0x0010, /** * The autofocus routine has changed state. Argument ext1 contains the new * state; the values are the same as those for the metadata field * android.control.afState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not * been called with either of those actions. */ CAMERA2_MSG_AUTOFOCUS = 0x0020, /** * The autoexposure routine has changed state. Argument ext1 contains the * new state; the values are the same as those for the metadata field * android.control.aeState. Ext2 contains the latest trigger ID value passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOEXPOSURE = 0x0021, /** * The auto-whitebalance routine has changed state. Argument ext1 contains * the new state; the values are the same as those for the metadata field * android.control.awbState. Ext2 contains the latest trigger ID passed to * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method * has not been called. */ CAMERA2_MSG_AUTOWB = 0x0022 }; /** * Error codes for CAMERA_MSG_ERROR */ enum { /** * A serious failure occured. Camera device may not work without reboot, and * no further frames or buffer streams will be produced by the * device. Device should be treated as closed. */ CAMERA2_MSG_ERROR_HARDWARE = 0x0001, /** * A serious failure occured. No further frames or buffer streams will be * produced by the device. Device should be treated as closed. The client * must reopen the device to use it again. */ CAMERA2_MSG_ERROR_DEVICE, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. ext2 contains the frame * number of the request. Subsequent requests are unaffected, and the device * remains operational. */ CAMERA2_MSG_ERROR_REQUEST, /** * An error has occurred in producing an output frame metadata buffer for a * request, but image buffers for it will still be available. Subsequent * requests are unaffected, and the device remains operational. ext2 * contains the frame number of the request. */ CAMERA2_MSG_ERROR_FRAME, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. ext2 contains the frame number of the request, and ext3 * contains the stream id. */ CAMERA2_MSG_ERROR_STREAM, /** * Number of error types */ CAMERA2_MSG_NUM_ERRORS }; /** * Possible trigger ids for trigger_action() */ enum { /** * Trigger an autofocus cycle. The effect of the trigger depends on the * autofocus mode in effect when the trigger is received, which is the mode * listed in the latest capture request to be dequeued by the HAL. If the * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, * or CONTINUOUS_* modes, see below for the expected behavior. The state of * the autofocus cycle can be tracked in android.control.afMode and the * corresponding notifications. * ** * In AUTO or MACRO mode, the AF state transitions (and notifications) * when calling with trigger ID = N with the previous ID being K are: * * Initial state Transitions * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode * ** * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, that scan must complete and * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS * will allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * ** * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current * lens position and transition the AF state to either AF_FOCUSED or * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will * allow the AF to restart its operation. * * Initial state Transitions * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) * AF_FOCUSED (K) no effect except to change next notification ID to N * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, /** * Send a cancel message to the autofocus algorithm. The effect of the * cancellation depends on the autofocus mode in effect when the trigger is * received, which is the mode listed in the latest capture request to be * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no * effect. For other modes, the lens should return to its default position, * any current autofocus scan must be canceled, and the AF state should be * set to INACTIVE. * * The state of the autofocus cycle can be tracked in android.control.afMode * and the corresponding notification. Continuous autofocus modes may resume * focusing operations thereafter exactly as if the camera had just been set * to a continuous AF mode. * * Ext1 is an ID that must be returned in subsequent auto-focus state change * notifications through camera2_notify_callback() and stored in * android.control.afTriggerId. */ CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, /** * Trigger a pre-capture metering cycle, which may include firing the flash * to determine proper capture parameters. Typically, this trigger would be * fired for a half-depress of a camera shutter key, or before a snapshot * capture in general. The state of the metering cycle can be tracked in * android.control.aeMode and the corresponding notification. If the * auto-exposure mode is OFF, the trigger does nothing. * * Ext1 is an ID that must be returned in subsequent * auto-exposure/auto-white balance state change notifications through * camera2_notify_callback() and stored in android.control.aePrecaptureId. */ CAMERA2_TRIGGER_PRECAPTURE_METERING }; /** * Possible template types for construct_default_request() */ enum { /** * Standard camera preview operation with 3A on auto. */ CAMERA2_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA2_TEMPLATE_STILL_CAPTURE, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA2_TEMPLATE_VIDEO_RECORD, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, /* Total number of templates */ CAMERA2_TEMPLATE_COUNT }; /********************************************************************** * * Camera device operations * */ typedef struct camera2_device_ops { /********************************************************************** * Request and frame queue setup and management methods */ /** * Pass in input request queue interface methods. */ int (*set_request_queue_src_ops)(const struct camera2_device *, const camera2_request_queue_src_ops_t *request_src_ops); /** * Notify device that the request queue is no longer empty. Must only be * called when the first buffer is added a new queue, or after the source * has returned NULL in response to a dequeue call. */ int (*notify_request_queue_not_empty)(const struct camera2_device *); /** * Pass in output frame queue interface methods */ int (*set_frame_queue_dst_ops)(const struct camera2_device *, const camera2_frame_queue_dst_ops_t *frame_dst_ops); /** * Number of camera requests being processed by the device at the moment * (captures/reprocesses that have had their request dequeued, but have not * yet been enqueued onto output pipeline(s) ). No streams may be released * by the framework until the in-progress count is 0. */ int (*get_in_progress_count)(const struct camera2_device *); /** * Flush all in-progress captures. This includes all dequeued requests * (regular or reprocessing) that have not yet placed any outputs into a * stream or the frame queue. Partially completed captures must be completed * normally. No new requests may be dequeued from the request queue until * the flush completes. */ int (*flush_captures_in_progress)(const struct camera2_device *); /** * Create a filled-in default request for standard camera use cases. * * The device must return a complete request that is configured to meet the * requested use case, which must be one of the CAMERA2_TEMPLATE_* * enums. All request control fields must be included, except for * android.request.outputStreams. * * The metadata buffer returned must be allocated with * allocate_camera_metadata. The framework takes ownership of the buffer. */ int (*construct_default_request)(const struct camera2_device *, int request_template, camera_metadata_t **request); /********************************************************************** * Stream management */ /** * allocate_stream: * * Allocate a new output stream for use, defined by the output buffer width, * height, target, and possibly the pixel format. Returns the new stream's * ID, gralloc usage flags, minimum queue buffer count, and possibly the * pixel format, on success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many streams of a given format type (2 bayer raw * streams, for example). * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided * by the camera HAL and the consumer of the stream. The camera HAL should * inspect the buffers handed to it in the register_stream_buffers call to * obtain the implementation-specific format if necessary. * * - stream_ops: A structure of function pointers for obtaining and queuing * up buffers for this stream. The underlying stream will be configured * based on the usage and max_buffers outputs. The methods in this * structure may not be called until after allocate_stream returns. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. * * - usage: The gralloc usage mask needed by the HAL device for producing * the requested type of data. This is used in allocating new gralloc * buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have dequeued at the same time. The device may not dequeue more buffers * than this value at the same time. * */ int (*allocate_stream)( const struct camera2_device *, // inputs uint32_t width, uint32_t height, int format, const camera2_stream_ops_t *stream_ops, // outputs uint32_t *stream_id, uint32_t *format_actual, // IGNORED, will be removed uint32_t *usage, uint32_t *max_buffers); /** * Register buffers for a given stream. This is called after a successful * allocate_stream call, and before the first request referencing the stream * is enqueued. This method is intended to allow the HAL device to map or * otherwise prepare the buffers for later use. num_buffers is guaranteed to * be at least max_buffers (from allocate_stream), but may be larger. The * buffers will already be locked for use. At the end of the call, all the * buffers must be ready to be returned to the queue. If the stream format * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should * inspect the passed-in buffers here to determine any platform-private * pixel format information. */ int (*register_stream_buffers)( const struct camera2_device *, uint32_t stream_id, int num_buffers, buffer_handle_t *buffers); /** * Release a stream. Returns an error if called when get_in_progress_count * is non-zero, or if the stream id is invalid. */ int (*release_stream)( const struct camera2_device *, uint32_t stream_id); /** * allocate_reprocess_stream: * * Allocate a new input stream for use, defined by the output buffer width, * height, and the pixel format. Returns the new stream's ID, gralloc usage * flags, and required simultaneously acquirable buffer count, on * success. Error conditions: * * - Requesting a width/height/format combination not listed as * supported by the sensor's static characteristics * * - Asking for too many reprocessing streams to be configured at once. * * Input parameters: * * - width, height, format: Specification for the buffers to be sent through * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will be * configured based on the usage and max_buffers outputs. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * - consumer_usage: The gralloc usage mask needed by the HAL device for * consuming the requested type of data. This is used in allocating new * gralloc buffers for the stream buffer queue. * * - max_buffers: The maximum number of buffers the HAL device may need to * have acquired at the same time. The device may not have more buffers * acquired at the same time than this value. * */ int (*allocate_reprocess_stream)(const struct camera2_device *, uint32_t width, uint32_t height, uint32_t format, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id, uint32_t *consumer_usage, uint32_t *max_buffers); /** * allocate_reprocess_stream_from_stream: * * Allocate a new input stream for use, which will use the buffers allocated * for an existing output stream. That is, after the HAL enqueues a buffer * onto the output stream, it may see that same buffer handed to it from * this input reprocessing stream. After the HAL releases the buffer back to * the reprocessing stream, it will be returned to the output queue for * reuse. * * Error conditions: * * - Using an output stream of unsuitable size/format for the basis of the * reprocessing stream. * * - Attempting to allocatee too many reprocessing streams at once. * * Input parameters: * * - output_stream_id: The ID of an existing output stream which has * a size and format suitable for reprocessing. * * - reprocess_stream_ops: A structure of function pointers for acquiring * and releasing buffers for this stream. The underlying stream will use * the same graphics buffer handles as the output stream uses. * * Output parameters: * * - stream_id: An unsigned integer identifying this stream. This value is * used in incoming requests to identify the stream, and in releasing the * stream. These ids are numbered separately from the input stream ids. * * The HAL client must always release the reprocessing stream before it * releases the output stream it is based on. * */ int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, uint32_t output_stream_id, const camera2_stream_in_ops_t *reprocess_stream_ops, // outputs uint32_t *stream_id); /** * Release a reprocessing stream. Returns an error if called when * get_in_progress_count is non-zero, or if the stream id is not * valid. */ int (*release_reprocess_stream)( const struct camera2_device *, uint32_t stream_id); /********************************************************************** * Miscellaneous methods */ /** * Trigger asynchronous activity. This is used for triggering special * behaviors of the camera 3A routines when they are in use. See the * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids * and their arguments. */ int (*trigger_action)(const struct camera2_device *, uint32_t trigger_id, int32_t ext1, int32_t ext2); /** * Notification callback setup */ int (*set_notify_callback)(const struct camera2_device *, camera2_notify_callback notify_cb, void *user); /** * Get methods to query for vendor extension metadata tag infomation. May * set ops to NULL if no vendor extension tags are defined. */ int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, vendor_tag_query_ops_t **ops); /** * Dump state of the camera hardware */ int (*dump)(const struct camera2_device *, int fd); /** * Get device-instance-specific metadata. This metadata must be constant for * a single instance of the camera device, but may be different between * open() calls. The returned camera_metadata pointer must be valid until * the device close() method is called. * * Version information: * * CAMERA_DEVICE_API_VERSION_2_0: * * Not available. Framework may not access this function pointer. * * CAMERA_DEVICE_API_VERSION_2_1: * * Valid. Can be called by the framework. * */ int (*get_instance_metadata)(const struct camera2_device *, camera_metadata **instance_metadata); } camera2_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera2_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify * this device as implementing version 2.0 of the camera device HAL. */ hw_device_t common; camera2_device_ops_t *ops; void *priv; } camera2_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/camera3.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_CAMERA3_H #define ANDROID_INCLUDE_CAMERA3_H #include #include "camera_common.h" /** * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ] * * This is the current recommended version of the camera device HAL. * * Supports the android.hardware.Camera API, and as of v3.2, the * android.hardware.camera2 API in LIMITED or FULL modes. * * Camera devices that support this version of the HAL must return * CAMERA_DEVICE_API_VERSION_3_3 in camera_device_t.common.version and in * camera_info_t.device_version (from camera_module_t.get_camera_info). * * CAMERA_DEVICE_API_VERSION_3_3: * Camera modules that may contain version 3.3 devices must implement at * least version 2.2 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * CAMERA_DEVICE_API_VERSION_3_2: * Camera modules that may contain version 3.2 devices must implement at * least version 2.2 of the camera module interface (as defined by * camera_module_t.common.module_api_version). * * <= CAMERA_DEVICE_API_VERSION_3_1: * Camera modules that may contain version 3.1 (or 3.0) devices must * implement at least version 2.0 of the camera module interface * (as defined by camera_module_t.common.module_api_version). * * See camera_common.h for more versioning details. * * Documentation index: * S1. Version history * S2. Startup and operation sequencing * S3. Operational modes * S4. 3A modes and state machines * S5. Cropping * S6. Error management * S7. Key Performance Indicator (KPI) glossary * S8. Sample Use Cases * S9. Notes on Controls and Metadata * S10. Reprocessing flow and controls */ /** * S1. Version history: * * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: * * - Converted from C++ CameraHardwareInterface abstraction layer. * * - Supports android.hardware.Camera API. * * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: * * - Sufficient for implementing existing android.hardware.Camera API. * * - Allows for ZSL queue in camera service layer * * - Not tested for any new features such manual capture control, Bayer RAW * capture, reprocessing of RAW data. * * 3.0: First revision of expanded-capability HAL: * * - Major version change since the ABI is completely different. No change to * the required hardware capabilities or operational model from 2.0. * * - Reworked input request and stream queue interfaces: Framework calls into * HAL with next request and stream buffers already dequeued. Sync framework * support is included, necessary for efficient implementations. * * - Moved triggers into requests, most notifications into results. * * - Consolidated all callbacks into framework into one structure, and all * setup methods into a single initialize() call. * * - Made stream configuration into a single call to simplify stream * management. Bidirectional streams replace STREAM_FROM_STREAM construct. * * - Limited mode semantics for older/limited hardware devices. * * 3.1: Minor revision of expanded-capability HAL: * * - configure_streams passes consumer usage flags to the HAL. * * - flush call to drop all in-flight requests/buffers as fast as possible. * * 3.2: Minor revision of expanded-capability HAL: * * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops * in camera_common.h instead. * * - register_stream_buffers deprecated. All gralloc buffers provided * by framework to HAL in process_capture_request may be new at any time. * * - add partial result support. process_capture_result may be called * multiple times with a subset of the available result before the full * result is available. * * - add manual template to camera3_request_template. The applications may * use this template to control the capture settings directly. * * - Rework the bidirectional and input stream specifications. * * - change the input buffer return path. The buffer is returned in * process_capture_result instead of process_capture_request. * * 3.3: Minor revision of expanded-capability HAL: * * - OPAQUE and YUV reprocessing API updates. * * - Basic support for depth output buffers. * * - Addition of data_space field to camera3_stream_t. * * - Addition of rotation field to camera3_stream_t. * * - Addition of camera3 stream configuration operation mode to camera3_stream_configuration_t * */ /** * S2. Startup and general expected operation sequence: * * 1. Framework calls camera_module_t->common.open(), which returns a * hardware_device_t structure. * * 2. Framework inspects the hardware_device_t->version field, and instantiates * the appropriate handler for that version of the camera hardware device. In * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to * a camera3_device_t. * * 3. Framework calls camera3_device_t->ops->initialize() with the framework * callback function pointers. This will only be called this one time after * open(), before any other functions in the ops structure are called. * * 4. The framework calls camera3_device_t->ops->configure_streams() with a list * of input/output streams to the HAL device. * * 5. <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework allocates gralloc buffers and calls * camera3_device_t->ops->register_stream_buffers() for at least one of the * output streams listed in configure_streams. The same stream is registered * only once. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * camera3_device_t->ops->register_stream_buffers() is not called and must * be NULL. * * 6. The framework requests default settings for some number of use cases with * calls to camera3_device_t->ops->construct_default_request_settings(). This * may occur any time after step 3. * * 7. The framework constructs and sends the first capture request to the HAL, * with settings based on one of the sets of default settings, and with at * least one output stream, which has been registered earlier by the * framework. This is sent to the HAL with * camera3_device_t->ops->process_capture_request(). The HAL must block the * return of this call until it is ready for the next request to be sent. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffer_handle_t provided in the camera3_stream_buffer_t array * in the camera3_capture_request_t may be new and never-before-seen * by the HAL on any given new request. * * 8. The framework continues to submit requests, and call * construct_default_request_settings to get default settings buffers for * other use cases. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The framework may call register_stream_buffers() at this time for * not-yet-registered streams. * * 9. When the capture of a request begins (sensor starts exposing for the * capture) or processing a reprocess request begins, the HAL * calls camera3_callback_ops_t->notify() with the SHUTTER event, including * the frame number and the timestamp for start of exposure. For a reprocess * request, the timestamp must be the start of exposure of the input image * which can be looked up with android.sensor.timestamp from * camera3_capture_request_t.settings when process_capture_request() is * called. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * This notify call must be made before the first call to * process_capture_result() for that frame number. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The camera3_callback_ops_t->notify() call with the SHUTTER event should * be made as early as possible since the framework will be unable to * deliver gralloc buffers to the application layer (for that frame) until * it has a valid timestamp for the start of exposure (or the input image's * start of exposure for a reprocess request). * * Both partial metadata results and the gralloc buffers may be sent to the * framework at any time before or after the SHUTTER event. * * 10. After some pipeline delay, the HAL begins to return completed captures to * the framework with camera3_callback_ops_t->process_capture_result(). These * are returned in the same order as the requests were submitted. Multiple * requests can be in flight at once, depending on the pipeline depth of the * camera HAL device. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Once a buffer is returned by process_capture_result as part of the * camera3_stream_buffer_t array, and the fence specified by release_fence * has been signaled (this is a no-op for -1 fences), the ownership of that * buffer is considered to be transferred back to the framework. After that, * the HAL must no longer retain that particular buffer, and the * framework may clean up the memory for it immediately. * * process_capture_result may be called multiple times for a single frame, * each time with a new disjoint piece of metadata and/or set of gralloc * buffers. The framework will accumulate these partial metadata results * into one result. * * In particular, it is legal for a process_capture_result to be called * simultaneously for both a frame N and a frame N+1 as long as the * above rule holds for gralloc buffers (both input and output). * * 11. After some time, the framework may stop submitting new requests, wait for * the existing captures to complete (all buffers filled, all results * returned), and then call configure_streams() again. This resets the camera * hardware and pipeline for a new set of input/output streams. Some streams * may be reused from the previous configuration; if these streams' buffers * had already been registered with the HAL, they will not be registered * again. The framework then continues from step 7, if at least one * registered output stream remains (otherwise, step 5 is required first). * * 12. Alternatively, the framework may call camera3_device_t->common->close() * to end the camera session. This may be called at any time when no other * calls from the framework are active, although the call may block until all * in-flight captures have completed (all results returned, all buffers * filled). After the close call returns, no more calls to the * camera3_callback_ops_t functions are allowed from the HAL. Once the * close() call is underway, the framework may not call any other HAL device * functions. * * 13. In case of an error or other asynchronous event, the HAL must call * camera3_callback_ops_t->notify() with the appropriate error/event * message. After returning from a fatal device-wide error notification, the * HAL should act as if close() had been called on it. However, the HAL must * either cancel or complete all outstanding captures before calling * notify(), so that once notify() is called with a fatal error, the * framework will not receive further callbacks from the device. Methods * besides close() should return -ENODEV or NULL after the notify() method * returns from a fatal error message. */ /** * S3. Operational modes: * * The camera 3 HAL device can implement one of two possible operational modes; * limited and full. Full support is expected from new higher-end * devices. Limited mode has hardware requirements roughly in line with those * for a camera HAL device v1 implementation, and is expected from older or * inexpensive devices. Full is a strict superset of limited, and they share the * same essential operational flow, as documented above. * * The HAL must indicate its level of support with the * android.info.supportedHardwareLevel static metadata entry, with 0 indicating * limited mode, and 1 indicating full mode support. * * Roughly speaking, limited-mode devices do not allow for application control * of capture settings (3A control only), high-rate capture of high-resolution * images, raw sensor readout, or support for YUV output streams above maximum * recording resolution (JPEG only for large images). * * ** Details of limited mode behavior: * * - Limited-mode devices do not need to implement accurate synchronization * between capture request settings and the actual image data * captured. Instead, changes to settings may take effect some time in the * future, and possibly not for the same output frame for each settings * entry. Rapid changes in settings may result in some settings never being * used for a capture. However, captures that include high-resolution output * buffers ( > 1080p ) have to use the settings as specified (but see below * for processing rate). * * - Limited-mode devices do not need to support most of the * settings/result/static info metadata. Specifically, only the following settings * are expected to be consumed or produced by a limited-mode HAL device: * * android.control.aeAntibandingMode (controls and dynamic) * android.control.aeExposureCompensation (controls and dynamic) * android.control.aeLock (controls and dynamic) * android.control.aeMode (controls and dynamic) * android.control.aeRegions (controls and dynamic) * android.control.aeTargetFpsRange (controls and dynamic) * android.control.aePrecaptureTrigger (controls and dynamic) * android.control.afMode (controls and dynamic) * android.control.afRegions (controls and dynamic) * android.control.awbLock (controls and dynamic) * android.control.awbMode (controls and dynamic) * android.control.awbRegions (controls and dynamic) * android.control.captureIntent (controls and dynamic) * android.control.effectMode (controls and dynamic) * android.control.mode (controls and dynamic) * android.control.sceneMode (controls and dynamic) * android.control.videoStabilizationMode (controls and dynamic) * android.control.aeAvailableAntibandingModes (static) * android.control.aeAvailableModes (static) * android.control.aeAvailableTargetFpsRanges (static) * android.control.aeCompensationRange (static) * android.control.aeCompensationStep (static) * android.control.afAvailableModes (static) * android.control.availableEffects (static) * android.control.availableSceneModes (static) * android.control.availableVideoStabilizationModes (static) * android.control.awbAvailableModes (static) * android.control.maxRegions (static) * android.control.sceneModeOverrides (static) * android.control.aeState (dynamic) * android.control.afState (dynamic) * android.control.awbState (dynamic) * * android.flash.mode (controls and dynamic) * android.flash.info.available (static) * * android.info.supportedHardwareLevel (static) * * android.jpeg.gpsCoordinates (controls and dynamic) * android.jpeg.gpsProcessingMethod (controls and dynamic) * android.jpeg.gpsTimestamp (controls and dynamic) * android.jpeg.orientation (controls and dynamic) * android.jpeg.quality (controls and dynamic) * android.jpeg.thumbnailQuality (controls and dynamic) * android.jpeg.thumbnailSize (controls and dynamic) * android.jpeg.availableThumbnailSizes (static) * android.jpeg.maxSize (static) * * android.lens.info.minimumFocusDistance (static) * * android.request.id (controls and dynamic) * * android.scaler.cropRegion (controls and dynamic) * android.scaler.availableStreamConfigurations (static) * android.scaler.availableMinFrameDurations (static) * android.scaler.availableStallDurations (static) * android.scaler.availableMaxDigitalZoom (static) * android.scaler.maxDigitalZoom (static) * android.scaler.croppingType (static) * * android.sensor.orientation (static) * android.sensor.timestamp (dynamic) * * android.statistics.faceDetectMode (controls and dynamic) * android.statistics.info.availableFaceDetectModes (static) * android.statistics.faceIds (dynamic) * android.statistics.faceLandmarks (dynamic) * android.statistics.faceRectangles (dynamic) * android.statistics.faceScores (dynamic) * * android.sync.frameNumber (dynamic) * android.sync.maxLatency (static) * * - Captures in limited mode that include high-resolution (> 1080p) output * buffers may block in process_capture_request() until all the output buffers * have been filled. A full-mode HAL device must process sequences of * high-resolution requests at the rate indicated in the static metadata for * that pixel format. The HAL must still call process_capture_result() to * provide the output; the framework must simply be prepared for * process_capture_request() to block until after process_capture_result() for * that request completes for high-resolution captures for limited-mode * devices. * * - Full-mode devices must support below additional capabilities: * - 30fps at maximum resolution is preferred, more than 20fps is required. * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL). * - Sensor manual control metadata. See MANUAL_SENSOR defined in * android.request.availableCapabilities. * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined * in android.request.availableCapabilities. * */ /** * S4. 3A modes and state machines: * * While the actual 3A algorithms are up to the HAL implementation, a high-level * state machine description is defined by the HAL interface, to allow the HAL * device and the framework to communicate about the current state of 3A, and to * trigger 3A events. * * When the device is opened, all the individual 3A states must be * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked * focus must be maintained across the configure() call. * * Triggering a 3A action involves simply setting the relevant trigger entry in * the settings for the next request to indicate start of trigger. For example, * the trigger for starting an autofocus scan is setting the entry * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one * request, and cancelling an autofocus scan is triggered by setting * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each * request with a trigger entry set to a non-IDLE value will be treated as an * independent triggering event. * * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting * (ANDROID_CONTROL_USE_SCENE_MODE). * * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, * and none of the capture controls may be overridden by the 3A routines. * * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run * their own independent algorithms, and have their own mode, state, and * trigger metadata entries, as listed in the next section. * * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must * be used to determine the behavior of 3A routines. In SCENE_MODEs other than * FACE_PRIORITY, the HAL must override the values of * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene * must be ignored for these scene modes. * * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering * and focusing on any detected faces in the scene. * * S4.1. Auto-focus settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus * mode. Set by the framework in the request settings. * * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens * position. * * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is * triggered. * * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless * AF is triggered. * * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording * video. Triggering immediately locks focus in current * position. Canceling resumes cotinuous focusing. * * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for * zero-shutter-lag still capture. Triggering locks focus once currently * active sweep concludes. Canceling resumes continuous focusing. * * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no * autofocus scan, so triggering one or canceling one has no effect. * Images are focused automatically by the HAL. * * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF * algorithm state, reported by the HAL in the result metadata. * * AF_STATE_INACTIVE: No focusing has been done, or algorithm was * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. * When the device is opened, it must start in this state. * * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning * for good focus. The lens is moving. * * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is * well focused. The lens is not moving. The HAL may spontaneously leave * this state. * * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is * not well focused. The lens is not moving. The HAL may spontaneously * leave this state. * * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. * * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The * lens is not moving. * * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to * focus. The lens is not moving. * * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the * meaning of which is mode- and state- dependent. Set by the framework in * the request settings. * * AF_TRIGGER_IDLE: No current trigger. * * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state * dependent. * * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to * default. * * Additional metadata entries: * * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good focus. This applies to all AF * modes that scan for focus. Set by the framework in the request * settings. * * S4.2. Auto-exposure settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure * mode. Set by the framework in the request settings. * * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, * frame duration, and flash. * * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may * set flash to fire or to torch mode. * * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's * discretion for precapture and still capture. User control of flash * disabled. * * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired * for capture, and at HAL's discretion for precapture.. User control of * flash disabled. * * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at * HAL's discretion for precapture and still capture. Use a flash burst * at end of precapture sequence to reduce redeye in the final * picture. User control of flash disabled. * * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE * algorithm state, reported by the HAL in the result metadata. * * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is * opened, it must start in this state. * * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting * exposure parameters. * * AE_STATE_CONVERGED: AE has found good exposure values for the current * scene, and the exposure parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure * values are not changing. * * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes * flash is required for a sufficiently bright picture. Used for * determining if a zero-shutter-lag frame can be used. * * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture * sequence. Depending on AE mode, this mode may involve firing the * flash for metering, or a burst of flash pulses for redeye reduction. * * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering * sequence before capturing a high-quality image. Set by the framework in * the request settings. * * PRECAPTURE_TRIGGER_IDLE: No current trigger. * * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should * use the subsequent requests to measure good exposure/white balance * for an upcoming high-resolution capture. * * Additional metadata entries: * * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current * values * * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE * algorithm target brightness point. * * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame * rate range for the AE algorithm. The AE routine cannot change the frame * rate to be outside these bounds. * * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good exposure levels. This applies to * all AE modes besides OFF. * * S4.3. Auto-whitebalance settings and result entries: * * Main metadata entries: * * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance * mode. * * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. * * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color * transform, possibly using more complex transforms than a simple * matrix. * * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor * incandescent (tungsten) lighting, roughly 2700K. * * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent * lighting, roughly 5000K. * * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for * fluorescent lighting, roughly 3000K. * * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, * roughly 5500K. * * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded * daylight, roughly 6500K. * * AWB_MODE_TWILIGHT: Fixed white balance settings good for * near-sunset/sunrise, roughly 15000K. * * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly * lit by the sun, roughly 7500K. * * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB * algorithm state, reported by the HAL in the result metadata. * * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device * is opened, it must start in this state. * * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is * changing color adjustment parameters. * * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the * current scene, and the parameters are not changing. HAL may * spontaneously leave this state to search for better solution. * * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color * adjustment values are not changing. * * Additional metadata entries: * * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to * their current values. * * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV * that should be used to determine good color balance. This applies only * to auto-WB mode. * * S4.4. General state machine transition notes * * Switching between AF, AE, or AWB modes always resets the algorithm's state * to INACTIVE. Similarly, switching between CONTROL_MODE or * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the * algorithm states to INACTIVE. * * The tables below are per-mode. * * S4.5. AF state machines * * when enabling AF or changing AF mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | AF mode change| INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_OFF or AF_MODE_EDOF *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | Never changes | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_AUTO or AF_MODE_MACRO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | *| | | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| All states | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_VIDEO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | if focus is bad | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * mode = AF_MODE_CONTINUOUS_PICTURE *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | *| | current scan | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | *| | | | once focus good | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | *| | | | if cannot focus | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | *| | | | position | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | *| | new scan | | Lens now moving | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | *| | | | Lens now locked | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | *+--------------------+---------------+--------------------+------------------+ *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | *+--------------------+---------------+--------------------+------------------+ * * S4.6. AE and AWB state machines * * The AE and AWB state machines are mostly identical. AE has additional * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two * states should be ignored for the AWB state machine. * * when enabling AE/AWB or changing AE/AWB mode *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| Any | mode change | INACTIVE | | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_OFF / AWB mode not AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | | INACTIVE | AE/AWB disabled | *+--------------------+---------------+--------------------+------------------+ * * mode = AE_MODE_ON_* / AWB_MODE_AUTO *| state | trans. cause | new state | notes | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | HAL initiates | SEARCHING | | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | CONVERGED | good values, not | *| | AE/AWB scan | | changing | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| *| | AE scan | | dark w/o flash | *+--------------------+---------------+--------------------+------------------+ *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | *| | AE/AWB scan | | | *+--------------------+---------------+--------------------+------------------+ *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | *| | on | | | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | *| | off | | after unlock | *+--------------------+---------------+--------------------+------------------+ *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | *| | off | | but too dark | *+--------------------+---------------+--------------------+------------------+ *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | *| | START | | sequence | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | *| | AE_LOCK off | | quality capture | *+--------------------+---------------+--------------------+------------------+ *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | *| | AE_LOCK on | | quality capture | *+--------------------+---------------+--------------------+------------------+ * */ /** * S5. Cropping: * * Cropping of the full pixel array (for digital zoom and other use cases where * a smaller FOV is desirable) is communicated through the * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can * change on a per-request basis, which is critical for implementing smooth * digital zoom. * * The region is defined as a rectangle (x, y, width, height), with (x, y) * describing the top-left corner of the rectangle. The rectangle is defined on * the coordinate system of the sensor active pixel array, with (0,0) being the * top-left pixel of the active pixel array. Therefore, the width and height * cannot be larger than the dimensions reported in the * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed * width and height are reported by the HAL through the * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the * maximum supported zoom factor. Therefore, the minimum crop region width and * height are: * * {width, height} = * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM), * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } * * If the crop region needs to fulfill specific requirements (for example, it * needs to start on even coordinates, and its width/height needs to be even), * the HAL must do the necessary rounding and write out the final crop region * used in the output result metadata. Similarly, if the HAL implements video * stabilization, it must adjust the result crop region to describe the region * actually included in the output after video stabilization is applied. In * general, a camera-using application must be able to determine the field of * view it is receiving based on the crop region, the dimensions of the image * sensor, and the lens focal length. * * It is assumed that the cropping is applied after raw to other color space * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage, * and are not croppable. Therefore, the crop region must be ignored by the HAL * for raw streams. * * Since the crop region applies to all non-raw streams, which may have different aspect * ratios than the crop region, the exact sensor region used for each stream may * be smaller than the crop region. Specifically, each stream should maintain * square pixels and its aspect ratio by minimally further cropping the defined * crop region. If the stream's aspect ratio is wider than the crop region, the * stream should be further cropped vertically, and if the stream's aspect ratio * is narrower than the crop region, the stream should be further cropped * horizontally. * * In all cases, the stream crop must be centered within the full crop region, * and each stream is only either cropped horizontally or vertical relative to * the full crop region, never both. * * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x * 1500 pixel array) sensor. * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +-------------------+ + 375 * | | | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | | | * + +-------------------+ + 1125 * | Crop region, 640x480 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) * * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +---O==================O---+ + 375 * | | I 640x480 stream I | | * | | I I | | * | | I I | | * + | I I | + 750 * | | I I | | * | | I I | | * | | I I | | * + +---O==================O---+ + 1125 * | Crop region, 1280x720 stream | * | | * | | * +---------+---------+---------+----------+ 1500 * * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) * * 640x480 stream crop: (500, 469, 750, 562) (marked with =) * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | | * + +--------------+ + 375 * | O==============O | * | ################ | * | # # | * + # # + 750 * | # # | * | ################ 1280x720 | * | O==============O 640x480 | * + +--------------+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * * And a final example, a 1024x1024 square aspect ratio stream instead of the * 480p stream: * * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) * * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) * * 0 1000 2000 * +---------+---------+---------+----------+ * | Active pixel array | * | | * | 1024x1024 stream | * + +--###############--+ + 375 * | | # # | | * | O===================O | * | I 1280x720 stream I | * + I I + 750 * | I I | * | O===================O | * | | # # | | * + +--###############--+ + 1125 * | Crop region | * | | * | | * +---------+---------+---------+----------+ 1500 * */ /** * S6. Error management: * * Camera HAL device ops functions that have a return value will all return * -ENODEV / NULL in case of a serious error. This means the device cannot * continue operation, and must be closed by the framework. Once this error is * returned by some method, or if notify() is called with ERROR_DEVICE, only * the close() method can be called successfully. All other methods will return * -ENODEV / NULL. * * If a device op is called in the wrong sequence, for example if the framework * calls configure_streams() is called before initialize(), the device must * return -ENOSYS from the call, and do nothing. * * Transient errors in image capture must be reported through notify() as follows: * * - The failure of an entire capture to occur must be reported by the HAL by * calling notify() with ERROR_REQUEST. Individual errors for the result * metadata or the output buffers must not be reported in this case. * * - If the metadata for a capture cannot be produced, but some image buffers * were filled, the HAL must call notify() with ERROR_RESULT. * * - If an output image buffer could not be filled, but either the metadata was * produced or some other buffers were filled, the HAL must call notify() with * ERROR_BUFFER for each failed buffer. * * In each of these transient failure cases, the HAL must still call * process_capture_result, with valid output and input (if an input buffer was * submitted) buffer_handle_t. If the result metadata could not be produced, it * should be NULL. If some buffers could not be filled, they must be returned with * process_capture_result in the error state, their release fences must be set to * the acquire fences passed by the framework, or -1 if they have been waited on by * the HAL already. * * Invalid input arguments result in -EINVAL from the appropriate methods. In * that case, the framework must act as if that call had never been made. * */ /** * S7. Key Performance Indicator (KPI) glossary: * * This includes some critical definitions that are used by KPI metrics. * * Pipeline Latency: * For a given capture request, the duration from the framework calling * process_capture_request to the HAL sending capture result and all buffers * back by process_capture_result call. To make the Pipeline Latency measure * independent of frame rate, it is measured by frame count. * * For example, when frame rate is 30 (fps), the frame duration (time interval * between adjacent frame capture time) is 33 (ms). * If it takes 5 frames for framework to get the result and buffers back for * a given request, then the Pipeline Latency is 5 (frames), instead of * 5 x 33 = 165 (ms). * * The Pipeline Latency is determined by android.request.pipelineDepth and * android.request.pipelineMaxDepth, see their definitions for more details. * */ /** * S8. Sample Use Cases: * * This includes some typical use case examples the camera HAL may support. * * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream. * * For this use case, the bidirectional stream will be used by the framework as follows: * * 1. The framework includes a buffer from this stream as output buffer in a * request as normal. * * 2. Once the HAL device returns a filled output buffer to the framework, * the framework may do one of two things with the filled buffer: * * 2. a. The framework uses the filled data, and returns the now-used buffer * to the stream queue for reuse. This behavior exactly matches the * OUTPUT type of stream. * * 2. b. The framework wants to reprocess the filled data, and uses the * buffer as an input buffer for a request. Once the HAL device has * used the reprocessing buffer, it then returns it to the * framework. The framework then returns the now-used buffer to the * stream queue for reuse. * * 3. The HAL device will be given the buffer again as an output buffer for * a request at some future point. * * For ZSL use case, the pixel format for bidirectional stream will be * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it * is listed in android.scaler.availableInputOutputFormatsMap. When * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL. * A configuration stream list that has BIDIRECTIONAL stream used as input, will * usually also have a distinct OUTPUT stream to get the reprocessing data. For example, * for the ZSL use case, the stream list might be configured with the following: * * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used * as input. * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream. * * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream. * * CAMERA_DEVICE_API_VERSION_3_3: * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL). * This kind of stream will be used by the framework as follows: * * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is * used to produce the ZSL output buffers. The stream pixel format will be * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. * * 2. Application/framework configures an opaque format input stream that is used to * send the reprocessing ZSL buffers to the HAL. The stream pixel format will * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. * * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. * * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is * issued by the application, and sends the data back as an input buffer in a * reprocessing request, then sends to the HAL for reprocessing. * * 5. The HAL sends back the output YUV/JPEG result to framework. * * The HAL can select the actual opaque buffer format and configure the ISP pipeline * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL. * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream. * * When YUV reprocessing is supported by the HAL, the INPUT stream * can be used for the YUV reprocessing use cases like lucky-shot and image fusion. * This kind of stream will be used by the framework as follows: * * 1. Application/framework configures an YCbCr_420 format output stream that is * used to produce the output buffers. * * 2. Application/framework configures an YCbCr_420 format input stream that is used to * send the reprocessing YUV buffers to the HAL. * * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. * * 4. Application/framework processes the output buffers (could be as simple as picking * an output buffer directly) from the output stream when a capture is issued, and sends * the data back as an input buffer in a reprocessing request, then sends to the HAL * for reprocessing. * * 5. The HAL sends back the output YUV/JPEG result to framework. * */ /** * S9. Notes on Controls and Metadata * * This section contains notes about the interpretation and usage of various metadata tags. * * S9.1 HIGH_QUALITY and FAST modes. * * Many camera post-processing blocks may be listed as having HIGH_QUALITY, * FAST, and OFF operating modes. These blocks will typically also have an * 'available modes' tag representing which of these operating modes are * available on a given device. The general policy regarding implementing * these modes is as follows: * * 1. Operating mode controls of hardware blocks that cannot be disabled * must not list OFF in their corresponding 'available modes' tags. * * 2. OFF will always be included in their corresponding 'available modes' * tag if it is possible to disable that hardware block. * * 3. FAST must always be included in the 'available modes' tags for all * post-processing blocks supported on the device. If a post-processing * block also has a slower and higher quality operating mode that does * not meet the framerate requirements for FAST mode, HIGH_QUALITY should * be included in the 'available modes' tag to represent this operating * mode. */ /** * S10. Reprocessing flow and controls * * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing * uses an opaque format that is not directly application-visible, and the application can * only select some of the output buffers and send back to HAL for reprocessing, while YUV * reprocessing gives the application opportunity to process the buffers before reprocessing. * * S8 gives the stream configurations for the typical reprocessing uses cases, * this section specifies the buffer flow and controls in more details. * * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls * * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific * output and input streams, runtime buffer flow and controls are specified as below: * * 1. Application starts output streaming by sending repeating requests for output * opaque buffers and preview. The buffers are held by an application * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG * capture template, which should have all necessary settings that guarantee output * frame rate is not slowed down relative to sensor output frame rate. * * 2. When a capture is issued, the application selects one output buffer based * on application buffer selection logic, e.g. good AE and AF statistics etc. * Application then creates an reprocess request based on the capture result associated * with this selected buffer. The selected output buffer is now added to this reprocess * request as an input buffer, the output buffer of this reprocess request should be * either JPEG output buffer or YUV output buffer, or both, depending on the application * choice. * * 3. Application then alters the reprocess settings to get best image quality. The HAL must * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability: * - android.jpeg.* (if JPEG buffer is included as one of the output) * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported) * - android.edge.mode (change to HIGH_QUALITY if it is supported) * All other controls must be ignored by the HAL. * 4. HAL processed the input buffer and return the output buffers in the capture results * as normal. * * S10.2 YUV reprocessing flow and controls * * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference: * * 1. Application may want to have finer granularity control of the intermediate YUV images * (before reprocessing). For example, application may choose * - android.noiseReduction.mode == MINIMAL * to make sure the no YUV domain noise reduction has applied to the output YUV buffers, * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this * doesn't matter, as long as the final reprocessed image has the best quality. * 2. Application may modify the YUV output buffer data. For example, for image fusion use * case, where multiple output images are merged together to improve the signal-to-noise * ratio (SNR). The input buffer may be generated from multiple buffers by the application. * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement * being applied to the input buffer, the application can hint the HAL how much effective * exposure time improvement has been done by the application, then the HAL can adjust the * noise reduction and edge enhancement paramters to get best reprocessed image quality. * Below tag can be used for this purpose: * - android.reprocess.effectiveExposureFactor * The value would be exposure time increase factor applied to the original output image, * for example, if there are N image merged, the exposure time increase factor would be up * to sqrt(N). See this tag spec for more details. * * S10.3 Reprocessing pipeline characteristics * * Reprocessing pipeline has below different characteristics comparing with normal output * pipeline: * * 1. The reprocessing result can be returned ahead of the pending normal output results. But * the FIFO ordering must be maintained for all reprocessing results. For example, there are * below requests (A stands for output requests, B stands for reprocessing requests) * being processed by the HAL: * A1, A2, A3, A4, B1, A5, B2, A6... * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1. * 2. Single input rule: For a given reprocessing request, all output buffers must be from the * input buffer, rather than sensor output. For example, if a reprocess request include both * JPEG and preview buffers, all output buffers must be produced from the input buffer * included by the reprocessing request, rather than sensor. The HAL must not output preview * buffers from sensor, while output JPEG buffer from the input buffer. * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion * case). For the case where buffer is modified, the size will remain same. The HAL can * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent. * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy * of one of the output results with minor allowed setting changes. The HAL can notify * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued. * 5. Output buffers may not be used as inputs across the configure stream boundary, This is * because an opaque stream like the ZSL output stream may have different actual image size * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture. * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs. * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified * by flush() method. * */ __BEGIN_DECLS struct camera3_device; /********************************************************************** * * Camera3 stream and stream buffer definitions. * * These structs and enums define the handles and contents of the input and * output streams connecting the HAL to various framework and application buffer * consumers. Each stream is backed by a gralloc buffer queue. * */ /** * camera3_stream_type_t: * * The type of the camera stream, which defines whether the camera HAL device is * the producer or the consumer for that stream, and how the buffers of the * stream relate to the other streams. */ typedef enum camera3_stream_type { /** * This stream is an output stream; the camera HAL device will be * responsible for filling buffers from this stream with newly captured or * reprocessed image data. */ CAMERA3_STREAM_OUTPUT = 0, /** * This stream is an input stream; the camera HAL device will be responsible * for reading buffers from this stream and sending them through the camera * processing pipeline, as if the buffer was a newly captured image from the * imager. * * The pixel format for input stream can be any format reported by * android.scaler.availableInputOutputFormatsMap. The pixel format of the * output stream that is used to produce the reprocessing data may be any * format reported by android.scaler.availableStreamConfigurations. The * supported input/output stream combinations depends the camera device * capabilities, see android.scaler.availableInputOutputFormatsMap for * stream map details. * * This kind of stream is generally used to reprocess data into higher * quality images (that otherwise would cause a frame rate performance * loss), or to do off-line reprocessing. * * CAMERA_DEVICE_API_VERSION_3_3: * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing, * see S8.2, S8.3 and S10 for more details. */ CAMERA3_STREAM_INPUT = 1, /** * This stream can be used for input and output. Typically, the stream is * used as an output stream, but occasionally one already-filled buffer may * be sent back to the HAL device for reprocessing. * * This kind of stream is meant generally for Zero Shutter Lag (ZSL) * features, where copying the captured image from the output buffer to the * reprocessing input buffer would be expensive. See S8.1 for more details. * * Note that the HAL will always be reprocessing data it produced. * */ CAMERA3_STREAM_BIDIRECTIONAL = 2, /** * Total number of framework-defined stream types */ CAMERA3_NUM_STREAM_TYPES } camera3_stream_type_t; /** * camera3_stream_rotation_t: * * The required counterclockwise rotation of camera stream. */ typedef enum camera3_stream_rotation { /* No rotation */ CAMERA3_STREAM_ROTATION_0 = 0, /* Rotate by 90 degree counterclockwise */ CAMERA3_STREAM_ROTATION_90 = 1, /* Rotate by 180 degree counterclockwise */ CAMERA3_STREAM_ROTATION_180 = 2, /* Rotate by 270 degree counterclockwise */ CAMERA3_STREAM_ROTATION_270 = 3 } camera3_stream_rotation_t; /** * camera3_stream_configuration_mode_t: * * This defines the general operation mode for the HAL (for a given stream configuration), where * modes besides NORMAL have different semantics, and usually limit the generality of the API in * exchange for higher performance in some particular area. */ typedef enum camera3_stream_configuration_mode { /** * Normal stream configuration operation mode. This is the default camera operation mode, * where all semantics of HAL APIs and metadata controls apply. */ CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, /** * Special constrained high speed operation mode for devices that can not support high * speed output in NORMAL mode. All streams in this configuration are operating at high speed * mode and have different characteristics and limitations to achieve high speed output. * The NORMAL mode can still be used for high speed output if the HAL can support high speed * output while satisfying all the semantics of HAL APIs and metadata controls. It is * recommended for the HAL to support high speed output in NORMAL mode (by advertising the high * speed FPS ranges in android.control.aeAvailableTargetFpsRanges) if possible. * * This mode has below limitations/requirements: * * 1. The HAL must support up to 2 streams with sizes reported by * android.control.availableHighSpeedVideoConfigurations. * 2. In this mode, the HAL is expected to output up to 120fps or higher. This mode must * support the targeted FPS range and size configurations reported by * android.control.availableHighSpeedVideoConfigurations. * 3. The HAL must support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED output stream format. * 4. To achieve efficient high speed streaming, the HAL may have to aggregate * multiple frames together and send to camera device for processing where the request * controls are same for all the frames in this batch (batch mode). The HAL must support * max batch size and the max batch size requirements defined by * android.control.availableHighSpeedVideoConfigurations. * 5. In this mode, the HAL must override aeMode, awbMode, and afMode to ON, ON, and * CONTINUOUS_VIDEO, respectively. All post-processing block mode controls must be * overridden to be FAST. Therefore, no manual control of capture and post-processing * parameters is possible. All other controls operate the same as when * android.control.mode == AUTO. This means that all other android.control.* fields * must continue to work, such as * * android.control.aeTargetFpsRange * android.control.aeExposureCompensation * android.control.aeLock * android.control.awbLock * android.control.effectMode * android.control.aeRegions * android.control.afRegions * android.control.awbRegions * android.control.afTrigger * android.control.aePrecaptureTrigger * * Outside of android.control.*, the following controls must work: * * android.flash.mode (TORCH mode only, automatic flash for still capture will not work * since aeMode is ON) * android.lens.opticalStabilizationMode (if it is supported) * android.scaler.cropRegion * android.statistics.faceDetectMode (if it is supported) * * For more details about high speed stream requirements, see * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO * capability defined in android.request.availableCapabilities. * * This mode only needs to be supported by HALs that include CONSTRAINED_HIGH_SPEED_VIDEO in * the android.request.availableCapabilities static metadata. */ CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1, /** * First value for vendor-defined stream configuration modes. */ CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000 } camera3_stream_configuration_mode_t; /** * camera3_stream_t: * * A handle to a single camera input or output stream. A stream is defined by * the framework by its buffer resolution and format, and additionally by the * HAL with the gralloc usage flags and the maximum in-flight buffer count. * * The stream structures are owned by the framework, but pointers to a * camera3_stream passed into the HAL by configure_streams() are valid until the * end of the first subsequent configure_streams() call that _does not_ include * that camera3_stream as an argument, or until the end of the close() call. * * All camera3_stream framework-controlled members are immutable once the * camera3_stream is passed into configure_streams(). The HAL may only change * the HAL-controlled parameters during a configure_streams() call, except for * the contents of the private pointer. * * If a configure_streams() call returns a non-fatal error, all active streams * remain valid as if configure_streams() had not been called. * * The endpoint of the stream is not visible to the camera HAL device. * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream * types) see the usage field below. */ typedef struct camera3_stream { /***** * Set by framework before configure_streams() */ /** * The type of the stream, one of the camera3_stream_type_t values. */ int stream_type; /** * The width in pixels of the buffers in this stream */ uint32_t width; /** * The height in pixels of the buffers in this stream */ uint32_t height; /** * The pixel format for the buffers in this stream. Format is a value from * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or * from device-specific headers. * * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform * gralloc module will select a format based on the usage flags provided by * the camera device and the other endpoint of the stream. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The camera HAL device must inspect the buffers handed to it in the * subsequent register_stream_buffers() call to obtain the * implementation-specific format details, if necessary. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * register_stream_buffers() won't be called by the framework, so the HAL * should configure the ISP and sensor pipeline based purely on the sizes, * usage flags, and formats for the configured streams. */ int format; /***** * Set by HAL during configure_streams(). */ /** * The gralloc usage flags for this stream, as needed by the HAL. The usage * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific * headers. * * For output streams, these are the HAL's producer usage flags. For input * streams, these are the HAL's consumer usage flags. The usage flags from * the producer and the consumer will be combined together and then passed * to the platform gralloc HAL module for allocating the gralloc buffers for * each stream. * * Version information: * * == CAMERA_DEVICE_API_VERSION_3_0: * * No initial value guaranteed when passed via configure_streams(). * HAL may not use this field as input, and must write over this field * with its usage flags. * * >= CAMERA_DEVICE_API_VERSION_3_1: * * For stream_type OUTPUT and BIDIRECTIONAL, when passed via * configure_streams(), the initial value of this is the consumer's * usage flags. The HAL may use these consumer flags to decide stream * configuration. * For stream_type INPUT, when passed via configure_streams(), the initial * value of this is 0. * For all streams passed via configure_streams(), the HAL must write * over this field with its usage flags. */ uint32_t usage; /** * The maximum number of buffers the HAL device may need to have dequeued at * the same time. The HAL device may not have more buffers in-flight from * this stream than this value. */ uint32_t max_buffers; /** * A handle to HAL-private information for the stream. Will not be inspected * by the framework code. */ void *priv; /** * A field that describes the contents of the buffer. The format and buffer * dimensions define the memory layout and structure of the stream buffers, * while dataSpace defines the meaning of the data within the buffer. * * For most formats, dataSpace defines the color space of the image data. * In addition, for some formats, dataSpace indicates whether image- or * depth-based data is requested. See system/core/include/system/graphics.h * for details of formats and valid dataSpace values for each format. * * Version information: * * < CAMERA_DEVICE_API_VERSION_3_3: * * Not defined and should not be accessed. dataSpace should be assumed to * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should * be determined from the usage flags and the format. * * >= CAMERA_DEVICE_API_VERSION_3_3: * * Always set by the camera service. HAL must use this dataSpace to * configure the stream to the correct colorspace, or to select between * color and depth outputs if supported. */ android_dataspace_t data_space; /** * The required output rotation of the stream, one of * the camera3_stream_rotation_t values. This must be inspected by HAL along * with stream width and height. For example, if the rotation is 90 degree * and the stream width and height is 720 and 1280 respectively, camera service * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image * and rotate the image by 90 degree counterclockwise. The rotation field is * no-op when the stream type is input. Camera HAL must ignore the rotation * field for an input stream. * * <= CAMERA_DEVICE_API_VERSION_3_2: * * Not defined and must not be accessed. HAL must not apply any rotation * on output images. * * >= CAMERA_DEVICE_API_VERSION_3_3: * * Always set by camera service. HAL must inspect this field during stream * configuration and returns -EINVAL if HAL cannot perform such rotation. * HAL must always support CAMERA3_STREAM_ROTATION_0, so a * configure_streams() call must not fail for unsupported rotation if * rotation field of all streams is CAMERA3_STREAM_ROTATION_0. * */ int rotation; /* reserved for future use */ void *reserved[7]; } camera3_stream_t; /** * camera3_stream_configuration_t: * * A structure of stream definitions, used by configure_streams(). This * structure defines all the output streams and the reprocessing input * stream for the current camera use case. */ typedef struct camera3_stream_configuration { /** * The total number of streams requested by the framework. This includes * both input and output streams. The number of streams will be at least 1, * and there will be at least one output-capable stream. */ uint32_t num_streams; /** * An array of camera stream pointers, defining the input/output * configuration for the camera HAL device. * * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) * in a single configuration. * * At least one output-capable stream must be defined (OUTPUT or * BIDIRECTIONAL). */ camera3_stream_t **streams; /** * >= CAMERA_DEVICE_API_VERSION_3_3: * * The operation mode of streams in this configuration, one of the value defined in * camera3_stream_configuration_mode_t. * The HAL can use this mode as an indicator to set the stream property (e.g., * camera3_stream->max_buffers) appropriately. For example, if the configuration is * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may want to set aside more * buffers for batch mode operation (see android.control.availableHighSpeedVideoConfigurations * for batch mode definition). * */ uint32_t operation_mode; } camera3_stream_configuration_t; /** * camera3_buffer_status_t: * * The current status of a single stream buffer. */ typedef enum camera3_buffer_status { /** * The buffer is in a normal state, and can be used after waiting on its * sync fence. */ CAMERA3_BUFFER_STATUS_OK = 0, /** * The buffer does not contain valid data, and the data in it should not be * used. The sync fence must still be waited on before reusing the buffer. */ CAMERA3_BUFFER_STATUS_ERROR = 1 } camera3_buffer_status_t; /** * camera3_stream_buffer_t: * * A single buffer from a camera3 stream. It includes a handle to its parent * stream, the handle to the gralloc buffer itself, and sync fences * * The buffer does not specify whether it is to be used for input or output; * that is determined by its parent stream type and how the buffer is passed to * the HAL device. */ typedef struct camera3_stream_buffer { /** * The handle of the stream this buffer is associated with */ camera3_stream_t *stream; /** * The native handle to the buffer */ buffer_handle_t *buffer; /** * Current state of the buffer, one of the camera3_buffer_status_t * values. The framework will not pass buffers to the HAL that are in an * error state. In case a buffer could not be filled by the HAL, it must * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the * framework with process_capture_result(). */ int status; /** * The acquire sync fence for this buffer. The HAL must wait on this fence * fd before attempting to read from or write to this buffer. * * The framework may be set to -1 to indicate that no waiting is necessary * for this buffer. * * When the HAL returns an output buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on the acquire_fence due to an error in filling a buffer, * when calling process_capture_result() the HAL must set the release_fence * of the buffer to be the acquire_fence passed to it by the framework. This * will allow the framework to wait on the fence before reusing the buffer. * * For input buffers, the HAL must not change the acquire_fence field during * the process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * When the HAL returns an input buffer to the framework with * process_capture_result(), the acquire_fence must be set to -1. If the HAL * never waits on input buffer acquire fence due to an error, the sync * fences should be handled similarly to the way they are handled for output * buffers. */ int acquire_fence; /** * The release sync fence for this buffer. The HAL must set this fence when * returning buffers to the framework, or write -1 to indicate that no * waiting is required for this buffer. * * For the output buffers, the fences must be set in the output_buffers * array passed to process_capture_result(). * * <= CAMERA_DEVICE_API_VERSION_3_1: * * For the input buffer, the release fence must be set by the * process_capture_request() call. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * For the input buffer, the fences must be set in the input_buffer * passed to process_capture_result(). * * After signaling the release_fence for this buffer, the HAL * should not make any further attempts to access this buffer as the * ownership has been fully transferred back to the framework. * * If a fence of -1 was specified then the ownership of this buffer * is transferred back immediately upon the call of process_capture_result. */ int release_fence; } camera3_stream_buffer_t; /** * camera3_stream_buffer_set_t: * * The complete set of gralloc buffers for a stream. This structure is given to * register_stream_buffers() to allow the camera HAL device to register/map/etc * newly allocated stream buffers. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Deprecated (and not used). In particular, * register_stream_buffers is also deprecated and will never be invoked. * */ typedef struct camera3_stream_buffer_set { /** * The stream handle for the stream these buffers belong to */ camera3_stream_t *stream; /** * The number of buffers in this stream. It is guaranteed to be at least * stream->max_buffers. */ uint32_t num_buffers; /** * The array of gralloc buffer handles for this stream. If the stream format * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device * should inspect the passed-in buffers to determine any platform-private * pixel format information. */ buffer_handle_t **buffers; } camera3_stream_buffer_set_t; /** * camera3_jpeg_blob: * * Transport header for compressed JPEG buffers in output streams. * * To capture JPEG images, a stream is created using the pixel format * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the * framework, based on the static metadata field android.jpeg.maxSize. Since * compressed JPEG images are of variable size, the HAL needs to include the * final size of the compressed image using this structure inside the output * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID. * * Transport header should be at the end of the JPEG output stream buffer. That * means the jpeg_blob_id must start at byte[buffer_size - * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer. * Any HAL using this transport header must account for it in android.jpeg.maxSize * The JPEG data itself starts at the beginning of the buffer and should be * jpeg_size bytes long. */ typedef struct camera3_jpeg_blob { uint16_t jpeg_blob_id; uint32_t jpeg_size; } camera3_jpeg_blob_t; enum { CAMERA3_JPEG_BLOB_ID = 0x00FF }; /********************************************************************** * * Message definitions for the HAL notify() callback. * * These definitions are used for the HAL notify callback, to signal * asynchronous events from the HAL device to the Android framework. * */ /** * camera3_msg_type: * * Indicates the type of message sent, which specifies which member of the * message union is valid. * */ typedef enum camera3_msg_type { /** * An error has occurred. camera3_notify_msg.message.error contains the * error information. */ CAMERA3_MSG_ERROR = 1, /** * The exposure of a given request or processing a reprocess request has * begun. camera3_notify_msg.message.shutter contains the information * the capture. */ CAMERA3_MSG_SHUTTER = 2, /** * Number of framework message types */ CAMERA3_NUM_MESSAGES } camera3_msg_type_t; /** * Defined error codes for CAMERA_MSG_ERROR */ typedef enum camera3_error_msg_code { /** * A serious failure occured. No further frames or buffer streams will * be produced by the device. Device should be treated as closed. The * client must reopen the device to use it again. The frame_number field * is unused. */ CAMERA3_MSG_ERROR_DEVICE = 1, /** * An error has occurred in processing a request. No output (metadata or * buffers) will be produced for this request. The frame_number field * specifies which request has been dropped. Subsequent requests are * unaffected, and the device remains operational. */ CAMERA3_MSG_ERROR_REQUEST = 2, /** * An error has occurred in producing an output result metadata buffer * for a request, but output stream buffers for it will still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which * result metadata won't be available. */ CAMERA3_MSG_ERROR_RESULT = 3, /** * An error has occurred in placing an output buffer into a stream for a * request. The frame metadata and other buffers may still be * available. Subsequent requests are unaffected, and the device remains * operational. The frame_number field specifies the request for which the * buffer was dropped, and error_stream contains a pointer to the stream * that dropped the frame.u */ CAMERA3_MSG_ERROR_BUFFER = 4, /** * Number of error types */ CAMERA3_MSG_NUM_ERRORS } camera3_error_msg_code_t; /** * camera3_error_msg_t: * * Message contents for CAMERA3_MSG_ERROR */ typedef struct camera3_error_msg { /** * Frame number of the request the error applies to. 0 if the frame number * isn't applicable to the error. */ uint32_t frame_number; /** * Pointer to the stream that had a failure. NULL if the stream isn't * applicable to the error. */ camera3_stream_t *error_stream; /** * The code for this error; one of the CAMERA_MSG_ERROR enum values. */ int error_code; } camera3_error_msg_t; /** * camera3_shutter_msg_t: * * Message contents for CAMERA3_MSG_SHUTTER */ typedef struct camera3_shutter_msg { /** * Frame number of the request that has begun exposure or reprocessing. */ uint32_t frame_number; /** * Timestamp for the start of capture. For a reprocess request, this must * be input image's start of capture. This must match the capture result * metadata's sensor exposure start timestamp. */ uint64_t timestamp; } camera3_shutter_msg_t; /** * camera3_notify_msg_t: * * The message structure sent to camera3_callback_ops_t.notify() */ typedef struct camera3_notify_msg { /** * The message type. One of camera3_notify_msg_type, or a private extension. */ int type; union { /** * Error message contents. Valid if type is CAMERA3_MSG_ERROR */ camera3_error_msg_t error; /** * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER */ camera3_shutter_msg_t shutter; /** * Generic message contents. Used to ensure a minimum size for custom * message types. */ uint8_t generic[32]; } message; } camera3_notify_msg_t; /********************************************************************** * * Capture request/result definitions for the HAL process_capture_request() * method, and the process_capture_result() callback. * */ /** * camera3_request_template_t: * * Available template types for * camera3_device_ops.construct_default_request_settings() */ typedef enum camera3_request_template { /** * Standard camera preview operation with 3A on auto. */ CAMERA3_TEMPLATE_PREVIEW = 1, /** * Standard camera high-quality still capture with 3A and flash on auto. */ CAMERA3_TEMPLATE_STILL_CAPTURE = 2, /** * Standard video recording plus preview with 3A on auto, torch off. */ CAMERA3_TEMPLATE_VIDEO_RECORD = 3, /** * High-quality still capture while recording video. Application will * include preview, video record, and full-resolution YUV or JPEG streams in * request. Must not cause stuttering on video stream. 3A on auto. */ CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, /** * Zero-shutter-lag mode. Application will request preview and * full-resolution data for each frame, and reprocess it to JPEG when a * still image is requested by user. Settings should provide highest-quality * full-resolution images without compromising preview frame rate. 3A on * auto. */ CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, /** * A basic template for direct application control of capture * parameters. All automatic control is disabled (auto-exposure, auto-white * balance, auto-focus), and post-processing parameters are set to preview * quality. The manual capture parameters (exposure, sensitivity, etc.) * are set to reasonable defaults, but should be overridden by the * application depending on the intended use case. */ CAMERA3_TEMPLATE_MANUAL = 6, /* Total number of templates */ CAMERA3_TEMPLATE_COUNT, /** * First value for vendor-defined request templates */ CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 } camera3_request_template_t; /** * camera3_capture_request_t: * * A single request for image capture/buffer reprocessing, sent to the Camera * HAL device by the framework in process_capture_request(). * * The request contains the settings to be used for this capture, and the set of * output buffers to write the resulting image data in. It may optionally * contain an input buffer, in which case the request is for reprocessing that * input buffer instead of capturing a new image with the camera sensor. The * capture is identified by the frame_number. * * In response, the camera HAL device must send a camera3_capture_result * structure asynchronously to the framework, using the process_capture_result() * callback. */ typedef struct camera3_capture_request { /** * The frame number is an incrementing integer set by the framework to * uniquely identify this capture. It needs to be returned in the result * call, and is also used to identify the request in asynchronous * notifications sent to camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The settings buffer contains the capture and processing parameters for * the request. As a special case, a NULL settings buffer indicates that the * settings are identical to the most-recently submitted capture request. A * NULL buffer cannot be used as the first submitted request after a * configure_streams() call. */ const camera_metadata_t *settings; /** * The input stream buffer to use for this request, if any. * * If input_buffer is NULL, then the request is for a new capture from the * imager. If input_buffer is valid, the request is for reprocessing the * image contained in input_buffer. * * In the latter case, the HAL must set the release_fence of the * input_buffer to a valid sync fence, or to -1 if the HAL does not support * sync, before process_capture_request() returns. * * The HAL is required to wait on the acquire sync fence of the input buffer * before accessing it. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Any input buffer included here will have been registered with the HAL * through register_stream_buffers() before its inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The buffers will not have been pre-registered with the HAL. * Subsequent requests may reuse buffers, or provide entirely new buffers. */ camera3_stream_buffer_t *input_buffer; /** * The number of output buffers for this capture request. Must be at least * 1. */ uint32_t num_output_buffers; /** * An array of num_output_buffers stream buffers, to be filled with image * data from this capture/reprocess. The HAL must wait on the acquire fences * of each stream buffer before writing to them. * * The HAL takes ownership of the actual buffer_handle_t entries in * output_buffers; the framework does not access them until they are * returned in a camera3_capture_result_t. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * All the buffers included here will have been registered with the HAL * through register_stream_buffers() before their inclusion in a request. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Any or all of the buffers included here may be brand new in this * request (having never before seen by the HAL). */ const camera3_stream_buffer_t *output_buffers; } camera3_capture_request_t; /** * camera3_capture_result_t: * * The result of a single capture/reprocess by the camera HAL device. This is * sent to the framework asynchronously with process_capture_result(), in * response to a single capture request sent to the HAL with * process_capture_request(). Multiple process_capture_result() calls may be * performed by the HAL for each request. * * Each call, all with the same frame * number, may contain some subset of the output buffers, and/or the result * metadata. The metadata may only be provided once for a given frame number; * all other calls must set the result metadata to NULL. * * The result structure contains the output metadata from this capture, and the * set of output buffers that have been/will be filled for this capture. Each * output buffer may come with a release sync fence that the framework will wait * on before reading, in case the buffer has not yet been filled by the HAL. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The metadata may be provided multiple times for a single frame number. The * framework will accumulate together the final result set by combining each * partial result together into the total result set. * * If an input buffer is given in a request, the HAL must return it in one of * the process_capture_result calls, and the call may be to just return the input * buffer, without metadata and output buffers; the sync fences must be handled * the same way they are done for output buffers. * * * Performance considerations: * * Applications will also receive these partial results immediately, so sending * partial results is a highly recommended performance optimization to avoid * the total pipeline latency before sending the results for what is known very * early on in the pipeline. * * A typical use case might be calculating the AF state halfway through the * pipeline; by sending the state back to the framework immediately, we get a * 50% performance increase and perceived responsiveness of the auto-focus. * */ typedef struct camera3_capture_result { /** * The frame number is an incrementing integer set by the framework in the * submitted request to uniquely identify this capture. It is also used to * identify the request in asynchronous notifications sent to * camera3_callback_ops_t.notify(). */ uint32_t frame_number; /** * The result metadata for this capture. This contains information about the * final capture parameters, the state of the capture and post-processing * hardware, the state of the 3A algorithms, if enabled, and the output of * any enabled statistics units. * * Only one call to process_capture_result() with a given frame_number may * include the result metadata. All other calls for the same frame_number * must set this to NULL. * * If there was an error producing the result metadata, result must be an * empty metadata buffer, and notify() must be called with ERROR_RESULT. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Multiple calls to process_capture_result() with a given frame_number * may include the result metadata. * * Partial metadata submitted should not include any metadata key returned * in a previous partial result for a given frame. Each new partial result * for that frame must also set a distinct partial_result value. * * If notify has been called with ERROR_RESULT, all further partial * results for that frame are ignored by the framework. */ const camera_metadata_t *result; /** * The number of output buffers returned in this result structure. Must be * less than or equal to the matching capture request's count. If this is * less than the buffer count in the capture request, at least one more call * to process_capture_result with the same frame_number must be made, to * return the remaining output buffers to the framework. This may only be * zero if the structure includes valid result metadata or an input buffer * is returned in this result. */ uint32_t num_output_buffers; /** * The handles for the output stream buffers for this capture. They may not * yet be filled at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reading the buffers. * * The HAL must set the stream buffer's release sync fence to a valid sync * fd, or to -1 if the buffer has already been filled. * * If the HAL encounters an error while processing the buffer, and the * buffer is not filled, the buffer's status field must be set to * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence * before encountering the error, the acquire fence should be copied into * the release fence, to allow the framework to wait on the fence before * reusing the buffer. * * The acquire fence must be set to -1 for all output buffers. If * num_output_buffers is zero, this may be NULL. In that case, at least one * more process_capture_result call must be made by the HAL to provide the * output buffers. * * When process_capture_result is called with a new buffer for a frame, * all previous frames' buffers for that corresponding stream must have been * already delivered (the fences need not have yet been signaled). * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Gralloc buffers for a frame may be sent to framework before the * corresponding SHUTTER-notify. * * Performance considerations: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp has been received * via a SHUTTER notify() call. It is highly recommended to * dispatch that call as early as possible. */ const camera3_stream_buffer_t *output_buffers; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * The handle for the input stream buffer for this capture. It may not * yet be consumed at the time the HAL calls process_capture_result(); the * framework will wait on the release sync fences provided by the HAL before * reusing the buffer. * * The HAL should handle the sync fences the same way they are done for * output_buffers. * * Only one input buffer is allowed to be sent per request. Similarly to * output buffers, the ordering of returned input buffers must be * maintained by the HAL. * * Performance considerations: * * The input buffer should be returned as early as possible. If the HAL * supports sync fences, it can call process_capture_result to hand it back * with sync fences being set appropriately. If the sync fences are not * supported, the buffer can only be returned when it is consumed, which * may take long time; the HAL may choose to copy this input buffer to make * the buffer return sooner. */ const camera3_stream_buffer_t *input_buffer; /** * >= CAMERA_DEVICE_API_VERSION_3_2: * * In order to take advantage of partial results, the HAL must set the * static metadata android.request.partialResultCount to the number of * partial results it will send for each frame. * * Each new capture result with a partial result must set * this field (partial_result) to a distinct inclusive value between * 1 and android.request.partialResultCount. * * HALs not wishing to take advantage of this feature must not * set an android.request.partialResultCount or partial_result to a value * other than 1. * * This value must be set to 0 when a capture result contains buffers only * and no metadata. */ uint32_t partial_result; } camera3_capture_result_t; /********************************************************************** * * Callback methods for the HAL to call into the framework. * * These methods are used to return metadata and image buffers for a completed * or failed captures, and to notify the framework of asynchronous events such * as errors. * * The framework will not call back into the HAL from within these callbacks, * and these calls will not block for extended periods. * */ typedef struct camera3_callback_ops { /** * process_capture_result: * * Send results from a completed capture to the framework. * process_capture_result() may be invoked multiple times by the HAL in * response to a single capture request. This allows, for example, the * metadata and low-resolution buffers to be returned in one call, and * post-processed JPEG buffers in a later call, once it is available. Each * call must include the frame number of the request it is returning * metadata or buffers for. * * A component (buffer or metadata) of the complete result may only be * included in one process_capture_result call. A buffer for each stream, * and the result metadata, must be returned by the HAL for each request in * one of the process_capture_result calls, even in case of errors producing * some of the output. A call to process_capture_result() with neither * output buffers or result metadata is not allowed. * * The order of returning metadata and buffers for a single result does not * matter, but buffers for a given stream must be returned in FIFO order. So * the buffer for request 5 for stream A must always be returned before the * buffer for request 6 for stream A. This also applies to the result * metadata; the metadata for request 5 must be returned before the metadata * for request 6. * * However, different streams are independent of each other, so it is * acceptable and expected that the buffer for request 5 for stream A may be * returned after the buffer for request 6 for stream B is. And it is * acceptable that the result metadata for request 6 for stream B is * returned before the buffer for request 5 for stream A is. * * The HAL retains ownership of result structure, which only needs to be * valid to access during this call. The framework will copy whatever it * needs before this call returns. * * The output buffers do not need to be filled yet; the framework will wait * on the stream buffer release sync fence before reading the buffer * data. Therefore, this method should be called by the HAL as soon as * possible, even if some or all of the output buffers are still in * being filled. The HAL must include valid release sync fences into each * output_buffers stream buffer entry, or -1 if that stream buffer is * already filled. * * If the result buffer cannot be constructed for a request, the HAL should * return an empty metadata buffer, but still provide the output buffers and * their sync fences. In addition, notify() must be called with an * ERROR_RESULT message. * * If an output buffer cannot be filled, its status field must be set to * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER * message. * * If the entire capture has failed, then this method still needs to be * called to return the output buffers to the framework. All the buffer * statuses should be STATUS_ERROR, and the result metadata should be an * empty buffer. In addition, notify() must be called with a ERROR_REQUEST * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages * should not be sent. * * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. * * The pipeline latency (see S7 for definition) should be less than or equal to * 4 frame intervals, and must be less than or equal to 8 frame intervals. * */ void (*process_capture_result)(const struct camera3_callback_ops *, const camera3_capture_result_t *result); /** * notify: * * Asynchronous notification callback from the HAL, fired for various * reasons. Only for information independent of frame capture, or that * require specific timing. The ownership of the message structure remains * with the HAL, and the msg only needs to be valid for the duration of this * call. * * Multiple threads may call notify() simultaneously. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * The notification for the start of exposure for a given request must be * sent by the HAL before the first call to process_capture_result() for * that request is made. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * Buffers delivered to the framework will not be dispatched to the * application layer until a start of exposure timestamp (or input image's * start of exposure timestamp for a reprocess request) has been received * via a SHUTTER notify() call. It is highly recommended to dispatch this * call as early as possible. * * ------------------------------------------------------------------------ * Performance requirements: * * This is a non-blocking call. The framework will return this call in 5ms. */ void (*notify)(const struct camera3_callback_ops *, const camera3_notify_msg_t *msg); } camera3_callback_ops_t; /********************************************************************** * * Camera device operations * */ typedef struct camera3_device_ops { /** * initialize: * * One-time initialization to pass framework callback function pointers to * the HAL. Will be called once after a successful open() call, before any * other functions are called on the camera3_device_ops structure. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 5ms, and must return from this call in 10ms. * * Return values: * * 0: On successful initialization * * -ENODEV: If initialization fails. Only close() can be called successfully * by the framework after this. */ int (*initialize)(const struct camera3_device *, const camera3_callback_ops_t *callback_ops); /********************************************************************** * Stream management */ /** * configure_streams: * * CAMERA_DEVICE_API_VERSION_3_0 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, the usage, max_buffer, and private pointer fields * of the stream structure will all be set to 0. The HAL device must set * these fields before the configure_streams() call returns. These fields * are then used by the framework and the platform gralloc module to * allocate the gralloc buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * CAMERA_DEVICE_API_VERSION_3_1 only: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If such a stream has already had its buffers registered, * register_stream_buffers() will not be called again for the stream, and * buffers from the stream can be immediately included in input requests. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and will then reallocate the * stream buffers, and call register_stream_buffers() again before using * buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Before such a new stream can have its buffers included in a capture * request, the framework will call register_stream_buffers() with that * stream. However, the framework is not required to register buffers for * _all_ streams before submitting a request. This allows for quick startup * of (for example) a preview stream, with allocation for other streams * happening later or concurrently. * * ------------------------------------------------------------------------ * >= CAMERA_DEVICE_API_VERSION_3_2: * * Reset the HAL camera device processing pipeline and set up new input and * output streams. This call replaces any existing stream configuration with * the streams defined in the stream_list. This method will be called at * least once after initialize() before a request is submitted with * process_capture_request(). * * The stream_list must contain at least one output-capable stream, and may * not contain more than one input-capable stream. * * The stream_list may contain streams that are also in the currently-active * set of streams (from the previous call to configure_stream()). These * streams will already have valid values for usage, max_buffers, and the * private pointer. * * If the HAL needs to change the stream configuration for an existing * stream due to the new configuration, it may rewrite the values of usage * and/or max_buffers during the configure call. * * The framework will detect such a change, and may then reallocate the * stream buffers before using buffers from that stream in a request. * * If a currently-active stream is not included in stream_list, the HAL may * safely remove any references to that stream. It will not be reused in a * later configure() call by the framework, and all the gralloc buffers for * it will be freed after the configure_streams() call returns. * * The stream_list structure is owned by the framework, and may not be * accessed once this call completes. The address of an individual * camera3_stream_t structure will remain valid for access by the HAL until * the end of the first configure_stream() call which no longer includes * that camera3_stream_t in the stream_list argument. The HAL may not change * values in the stream structure outside of the private pointer, except for * the usage and max_buffers members during the configure_streams() call * itself. * * If the stream is new, max_buffer, and private pointer fields of the * stream structure will all be set to 0. The usage will be set to the * consumer usage flags. The HAL device must set these fields before the * configure_streams() call returns. These fields are then used by the * framework and the platform gralloc module to allocate the gralloc * buffers for each stream. * * Newly allocated buffers may be included in a capture request at any time * by the framework. Once a gralloc buffer is returned to the framework * with process_capture_result (and its respective release_fence has been * signaled) the framework may free or reuse it at any time. * * ------------------------------------------------------------------------ * * Preconditions: * * The framework will only call this method when no captures are being * processed. That is, all results have been returned to the framework, and * all in-flight input and output buffers have been returned and their * release sync fences have been signaled by the HAL. The framework will not * submit new requests for capture while the configure_streams() call is * underway. * * Postconditions: * * The HAL device must configure itself to provide maximum possible output * frame rate given the sizes and formats of the output streams, as * documented in the camera device's static metadata. * * Performance requirements: * * This call is expected to be heavyweight and possibly take several hundred * milliseconds to complete, since it may require resetting and * reconfiguring the image sensor and the camera processing pipeline. * Nevertheless, the HAL device should attempt to minimize the * reconfiguration delay to minimize the user-visible pauses during * application operational mode changes (such as switching from still * capture to video recording). * * The HAL should return from this call in 500ms, and must return from this * call in 1000ms. * * Return values: * * 0: On successful stream configuration * * -EINVAL: If the requested stream configuration is invalid. Some examples * of invalid stream configurations include: * * - Including more than 1 input-capable stream (INPUT or * BIDIRECTIONAL) * * - Not including any output-capable streams (OUTPUT or * BIDIRECTIONAL) * * - Including streams with unsupported formats, or an unsupported * size for that format. * * - Including too many output streams of a certain format. * * - Unsupported rotation configuration (only applies to * devices with version >= CAMERA_DEVICE_API_VERSION_3_3) * * - Stream sizes/formats don't satisfy the * camera3_stream_configuration_t->operation_mode requirements for non-NORMAL mode, * or the requested operation_mode is not supported by the HAL. * (only applies to devices with version >= CAMERA_DEVICE_API_VERSION_3_3) * * Note that the framework submitting an invalid stream * configuration is not normal operation, since stream * configurations are checked before configure. An invalid * configuration means that a bug exists in the framework code, or * there is a mismatch between the HAL's static metadata and the * requirements on streams. * * -ENODEV: If there has been a fatal error and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*configure_streams)(const struct camera3_device *, camera3_stream_configuration_t *stream_list); /** * register_stream_buffers: * * >= CAMERA_DEVICE_API_VERSION_3_2: * * DEPRECATED. This will not be called and must be set to NULL. * * <= CAMERA_DEVICE_API_VERSION_3_1: * * Register buffers for a given stream with the HAL device. This method is * called by the framework after a new stream is defined by * configure_streams, and before buffers from that stream are included in a * capture request. If the same stream is listed in a subsequent * configure_streams() call, register_stream_buffers will _not_ be called * again for that stream. * * The framework does not need to register buffers for all configured * streams before it submits the first capture request. This allows quick * startup for preview (or similar use cases) while other streams are still * being allocated. * * This method is intended to allow the HAL device to map or otherwise * prepare the buffers for later use. The buffers passed in will already be * locked for use. At the end of the call, all the buffers must be ready to * be returned to the stream. The buffer_set argument is only valid for the * duration of this call. * * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, * the camera HAL should inspect the passed-in buffers here to determine any * platform-private pixel format information. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * 0: On successful registration of the new stream buffers * * -EINVAL: If the stream_buffer_set does not refer to a valid active * stream, or if the buffers array is invalid. * * -ENOMEM: If there was a failure in registering the buffers. The framework * must consider all the stream buffers to be unregistered, and can * try to register again later. * * -ENODEV: If there is a fatal error, and the device is no longer * operational. Only close() can be called successfully by the * framework after this error is returned. */ int (*register_stream_buffers)(const struct camera3_device *, const camera3_stream_buffer_set_t *buffer_set); /********************************************************************** * Request creation and submission */ /** * construct_default_request_settings: * * Create capture settings for standard camera use cases. * * The device must return a settings buffer that is configured to meet the * requested use case, which must be one of the CAMERA3_TEMPLATE_* * enums. All request control fields must be included. * * The HAL retains ownership of this structure, but the pointer to the * structure must be valid until the device is closed. The framework and the * HAL may not modify the buffer once it is returned by this call. The same * buffer may be returned for subsequent calls for the same template, or for * other templates. * * Performance requirements: * * This should be a non-blocking call. The HAL should return from this call * in 1ms, and must return from this call in 5ms. * * Return values: * * Valid metadata: On successful creation of a default settings * buffer. * * NULL: In case of a fatal error. After this is returned, only * the close() method can be called successfully by the * framework. */ const camera_metadata_t* (*construct_default_request_settings)( const struct camera3_device *, int type); /** * process_capture_request: * * Send a new capture request to the HAL. The HAL should not return from * this call until it is ready to accept the next request to process. Only * one call to process_capture_request() will be made at a time by the * framework, and the calls will all be from the same thread. The next call * to process_capture_request() will be made as soon as a new request and * its associated buffers are available. In a normal preview scenario, this * means the function will be called again by the framework almost * instantly. * * The actual request processing is asynchronous, with the results of * capture being returned by the HAL through the process_capture_result() * call. This call requires the result metadata to be available, but output * buffers may simply provide sync fences to wait on. Multiple requests are * expected to be in flight at once, to maintain full output frame rate. * * The framework retains ownership of the request structure. It is only * guaranteed to be valid during this call. The HAL device must make copies * of the information it needs to retain for the capture processing. The HAL * is responsible for waiting on and closing the buffers' fences and * returning the buffer handles to the framework. * * The HAL must write the file descriptor for the input buffer's release * sync fence into input_buffer->release_fence, if input_buffer is not * NULL. If the HAL returns -1 for the input buffer release sync fence, the * framework is free to immediately reuse the input buffer. Otherwise, the * framework will wait on the sync fence before refilling and reusing the * input buffer. * * >= CAMERA_DEVICE_API_VERSION_3_2: * * The input/output buffers provided by the framework in each request * may be brand new (having never before seen by the HAL). * * ------------------------------------------------------------------------ * Performance considerations: * * Handling a new buffer should be extremely lightweight and there should be * no frame rate degradation or frame jitter introduced. * * This call must return fast enough to ensure that the requested frame * rate can be sustained, especially for streaming cases (post-processing * quality settings set to FAST). The HAL should return this call in 1 * frame interval, and must return from this call in 4 frame intervals. * * Return values: * * 0: On a successful start to processing the capture request * * -EINVAL: If the input is malformed (the settings are NULL when not * allowed, there are 0 output buffers, etc) and capture processing * cannot start. Failures during request processing should be * handled by calling camera3_callback_ops_t.notify(). In case of * this error, the framework will retain responsibility for the * stream buffers' fences and the buffer handles; the HAL should * not close the fences or return these buffers with * process_capture_result. * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. * */ int (*process_capture_request)(const struct camera3_device *, camera3_capture_request_t *request); /********************************************************************** * Miscellaneous methods */ /** * get_metadata_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The definition of vendor_tag_query_ops_t can be found in * system/media/camera/include/system/camera_metadata.h. * * >= CAMERA_DEVICE_API_VERSION_3_2: * DEPRECATED. This function has been deprecated and should be set to * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h * instead. */ void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, vendor_tag_query_ops_t* ops); /** * dump: * * Print out debugging state for the camera device. This will be called by * the framework when the camera service is asked for a debug dump, which * happens when using the dumpsys tool, or when capturing a bugreport. * * The passed-in file descriptor can be used to write debugging text using * dprintf() or write(). The text should be in ASCII encoding only. * * Performance requirements: * * This must be a non-blocking call. The HAL should return from this call * in 1ms, must return from this call in 10ms. This call must avoid * deadlocks, as it may be called at any point during camera operation. * Any synchronization primitives used (such as mutex locks or semaphores) * should be acquired with a timeout. */ void (*dump)(const struct camera3_device *, int fd); /** * flush: * * Flush all currently in-process captures and all buffers in the pipeline * on the given device. The framework will use this to dump all state as * quickly as possible in order to prepare for a configure_streams() call. * * No buffers are required to be successfully returned, so every buffer * held at the time of flush() (whether successfully filled or not) may be * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, * provided they are successfully filled. * * All requests currently in the HAL are expected to be returned as soon as * possible. Not-in-process requests should return errors immediately. Any * interruptible hardware blocks should be stopped, and any uninterruptible * blocks should be waited on. * * flush() may be called concurrently to process_capture_request(), with the expectation that * process_capture_request will return quickly and the request submitted in that * process_capture_request call is treated like all other in-flight requests. Due to * concurrency issues, it is possible that from the HAL's point of view, a * process_capture_request() call may be started after flush has been invoked but has not * returned yet. If such a call happens before flush() returns, the HAL should treat the new * capture request like other in-flight pending requests (see #4 below). * * More specifically, the HAL must follow below requirements for various cases: * * 1. For captures that are too late for the HAL to cancel/stop, and will be * completed normally by the HAL; i.e. the HAL can send shutter/notify and * process_capture_result and buffers as normal. * * 2. For pending requests that have not done any processing, the HAL must call notify * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR). * The HAL must not place the release fence into an error state, instead, * the release fences must be set to the acquire fences passed by the framework, * or -1 if they have been waited on by the HAL already. This is also the path * to follow for any captures for which the HAL already called notify() with * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for. * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or * process_capture_result with non-null metadata is allowed. * * 3. For partially completed pending requests that will not have all the output * buffers or perhaps missing metadata, the HAL should follow below: * * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result * metadata (i.e. one or more partial metadata) won't be available for the capture. * * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't * be produced for the capture. * * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before * any buffers/metadata are returned with process_capture_result. * * 3.4 For captures that will produce some results, the HAL must not call * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure. * * 3.5. Valid buffers/metadata should be passed to the framework as normal. * * 3.6. Failed buffers should be returned to the framework as described for case 2. * But failed buffers do not have to follow the strict ordering valid buffers do, * and may be out-of-order with respect to valid buffers. For example, if buffers * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable * return order. * * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no * need to call process_capture_result with NULL metadata or equivalent. * * 4. If a flush() is invoked while a process_capture_request() invocation is active, that * process call should return as soon as possible. In addition, if a process_capture_request() * call is made after flush() has been invoked but before flush() has returned, the * capture request provided by the late process_capture_request call should be treated like * a pending request in case #2 above. * * flush() should only return when there are no more outstanding buffers or * requests left in the HAL. The framework may call configure_streams (as * the HAL state is now quiesced) or may issue new requests. * * Note that it's sufficient to only support fully-succeeded and fully-failed result cases. * However, it is highly desirable to support the partial failure cases as well, as it * could help improve the flush call overall performance. * * Performance requirements: * * The HAL should return from this call in 100ms, and must return from this * call in 1000ms. And this call must not be blocked longer than pipeline * latency (see S7 for definition). * * Version information: * * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. * * Return values: * * 0: On a successful flush of the camera HAL. * * -EINVAL: If the input is malformed (the device is not valid). * * -ENODEV: If the camera device has encountered a serious error. After this * error is returned, only the close() method can be successfully * called by the framework. */ int (*flush)(const struct camera3_device *); /* reserved for future use */ void *reserved[8]; } camera3_device_ops_t; /********************************************************************** * * Camera device definition * */ typedef struct camera3_device { /** * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this * device as implementing version 3.0 of the camera device HAL. * * Performance requirements: * * Camera open (common.module->common.methods->open) should return in 200ms, and must return * in 500ms. * Camera close (common.close) should return in 200ms, and must return in 500ms. * */ hw_device_t common; camera3_device_ops_t *ops; void *priv; } camera3_device_t; __END_DECLS #endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/camera_common.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // FIXME: add well-defined names for cameras #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H #define ANDROID_INCLUDE_CAMERA_COMMON_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define CAMERA_HARDWARE_MODULE_ID "camera" /** * Module versioning information for the Camera hardware module, based on * camera_module_t.common.module_api_version. The two most significant hex * digits represent the major version, and the two least significant represent * the minor version. * ******************************************************************************* * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] * * Camera modules that report these version numbers implement the initial * camera module HAL interface. All camera devices openable through this * module support only version 1 of the camera device HAL. The device_version * and static_camera_characteristics fields of camera_info are not valid. Only * the android.hardware.Camera API can be supported by this module and its * devices. * ******************************************************************************* * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] * * Camera modules that report this version number implement the second version * of the camera module HAL interface. Camera devices openable through this * module may support either version 1.0 or version 2.0 of the camera device * HAL interface. The device_version field of camera_info is always valid; the * static_camera_characteristics field of camera_info is valid if the * device_version field is 2.0 or higher. * ******************************************************************************* * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] * * This camera module version adds support for asynchronous callbacks to the * framework from the camera HAL module, which is used to notify the framework * about changes to the camera module state. Modules that provide a valid * set_callbacks() method must report at least this version number. * ******************************************************************************* * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] * * This camera module version adds vendor tag support from the module, and * deprecates the old vendor_tag_query_ops that were previously only * accessible with a device open. * ******************************************************************************* * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] * * This camera module version adds open legacy camera HAL device support. * Framework can use it to open the camera device as lower device HAL version * HAL device if the same device can support multiple device API versions. * The standard hardware module open call (common.methods->open) continues * to open the camera device with the latest supported version, which is * also the version listed in camera_info_t.device_version. * ******************************************************************************* * Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4] * * This camera module version adds below API changes: * * 1. Torch mode support. The framework can use it to turn on torch mode for * any camera device that has a flash unit, without opening a camera device. The * camera device has a higher priority accessing the flash unit than the camera * module; opening a camera device will turn off the torch if it had been enabled * through the module interface. When there are any resource conflicts, such as * open() is called to open a camera device, the camera HAL module must notify the * framework through the torch mode status callback that the torch mode has been * turned off. * * 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that * the camera static info is only available when camera is connected and ready to * use for external hot-plug cameras. Calls to get static info will be invalid * calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks * will only count on device status change callbacks to manage the available external * camera list. * * 3. Camera arbitration hints. This module version adds support for explicitly * indicating the number of camera devices that can be simultaneously opened and used. * To specify valid combinations of devices, the resource_cost and conflicting_devices * fields should always be set in the camera_info structure returned by the * get_camera_info call. * * 4. Module initialization method. This will be called by the camera service * right after the HAL module is loaded, to allow for one-time initialization * of the HAL. It is called before any other module methods are invoked. */ /** * Predefined macros for currently-defined version numbers */ /** * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated * as CAMERA_MODULE_API_VERSION_1_0 */ #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) #define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) #define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) #define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4) #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4 /** * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated * as CAMERA_DEVICE_API_VERSION_1_0 */ #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) #define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) #define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) #define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2) #define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) // Device version 3.3 is current, older HAL camera device versions are not // recommended for new devices. #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3 /** * Defined in /system/media/camera/include/system/camera_metadata.h */ typedef struct camera_metadata camera_metadata_t; typedef struct camera_info { /** * The direction that the camera faces to. See system/core/include/system/camera.h * for camera facing definitions. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or * CAMERA_FACING_EXTERNAL. */ int facing; /** * The orientation of the camera image. The value is the angle that the * camera image needs to be rotated clockwise so it shows correctly on the * display in its natural orientation. It should be 0, 90, 180, or 270. * * For example, suppose a device has a naturally tall screen. The * back-facing camera sensor is mounted in landscape. You are looking at the * screen. If the top side of the camera sensor is aligned with the right * edge of the screen in natural orientation, the value should be 90. If the * top side of a front-facing camera sensor is aligned with the right of the * screen, the value should be 270. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Valid in all camera_module versions. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT, * not valid if camera facing is CAMERA_FACING_EXTERNAL. */ int orientation; /** * The value of camera_device_t.common.version. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do * not read this field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Always valid * */ uint32_t device_version; /** * The camera's fixed characteristics, which include all static camera metadata * specified in system/media/camera/docs/docs.html. This should be a sorted metadata * buffer, and may not be modified or freed by the caller. The pointer should remain * valid for the lifetime of the camera module, and values in it may not * change after it is returned by get_camera_info(). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0: * * Not valid. Extra characteristics are not available. Do not read this * field. * * CAMERA_MODULE_API_VERSION_2_0 or higher: * * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read * otherwise. * */ const camera_metadata_t *static_camera_characteristics; /** * The total resource "cost" of using this camera, represented as an integer * value in the range [0, 100] where 100 represents total usage of the shared * resource that is the limiting bottleneck of the camera subsystem. This may * be a very rough estimate, and is used as a hint to the camera service to * determine when to disallow multiple applications from simultaneously * opening different cameras advertised by the camera service. * * The camera service must be able to simultaneously open and use any * combination of camera devices exposed by the HAL where the sum of * the resource costs of these cameras is <= 100. For determining cost, * each camera device must be assumed to be configured and operating at * the maximally resource-consuming framerate and stream size settings * available in the configuration settings exposed for that device through * the camera metadata. * * The camera service may still attempt to simultaneously open combinations * of camera devices with a total resource cost > 100. This may succeed or * fail. If this succeeds, combinations of configurations that are not * supported due to resource constraints from having multiple open devices * should fail during the configure calls. If the total resource cost is * <= 100, open and configure should never fail for any stream configuration * settings or other device capabilities that would normally succeed for a * device when it is the only open camera device. * * This field will be used to determine whether background applications are * allowed to use this camera device while other applications are using other * camera devices. Note: multiple applications will never be allowed by the * camera service to simultaneously open the same camera device. * * Example use cases: * * Ex. 1: Camera Device 0 = Back Camera * Camera Device 1 = Front Camera * - Using both camera devices causes a large framerate slowdown due to * limited ISP bandwidth. * * Configuration: * * Camera Device 0 - resource_cost = 51 * conflicting_devices = null * Camera Device 1 - resource_cost = 51 * conflicting_devices = null * * Result: * * Since the sum of the resource costs is > 100, if a higher-priority * application has either device open, no lower-priority applications will be * allowed by the camera service to open either device. If a lower-priority * application is using a device that a higher-priority subsequently attempts * to open, the lower-priority application will be forced to disconnect the * the device. * * If the highest-priority application chooses, it may still attempt to open * both devices (since these devices are not listed as conflicting in the * conflicting_devices fields), but usage of these devices may fail in the * open or configure calls. * * Ex. 2: Camera Device 0 = Left Back Camera * Camera Device 1 = Right Back Camera * Camera Device 2 = Combined stereo camera using both right and left * back camera sensors used by devices 0, and 1 * Camera Device 3 = Front Camera * - Due to do hardware constraints, up to two cameras may be open at once. The * combined stereo camera may never be used at the same time as either of the * two back camera devices (device 0, 1), and typically requires too much * bandwidth to use at the same time as the front camera (device 3). * * Configuration: * * Camera Device 0 - resource_cost = 50 * conflicting_devices = { 2 } * Camera Device 1 - resource_cost = 50 * conflicting_devices = { 2 } * Camera Device 2 - resource_cost = 100 * conflicting_devices = { 0, 1 } * Camera Device 3 - resource_cost = 50 * conflicting_devices = null * * Result: * * Based on the conflicting_devices fields, the camera service guarantees that * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }. * * Based on the resource_cost fields, if a high-priority foreground application * is using camera device 0, a background application would be allowed to open * camera device 1 or 3 (but would be forced to disconnect it again if the * foreground application opened another device). * * The highest priority application may still attempt to simultaneously open * devices 0, 2, and 3, but the HAL may fail in open or configure calls for * this combination. * * Ex. 3: Camera Device 0 = Back Camera * Camera Device 1 = Front Camera * Camera Device 2 = Low-power Front Camera that uses the same * sensor as device 1, but only exposes image stream * resolutions that can be used in low-power mode * - Using both front cameras (device 1, 2) at the same time is impossible due * a shared physical sensor. Using the back and "high-power" front camera * (device 1) may be impossible for some stream configurations due to hardware * limitations, but the "low-power" front camera option may always be used as * it has special dedicated hardware. * * Configuration: * * Camera Device 0 - resource_cost = 100 * conflicting_devices = null * Camera Device 1 - resource_cost = 100 * conflicting_devices = { 2 } * Camera Device 2 - resource_cost = 0 * conflicting_devices = { 1 } * Result: * * Based on the conflicting_devices fields, the camera service guarantees that * the following sets of open devices will never be allowed: { 1, 2 }. * * Based on the resource_cost fields, only the highest priority application * may attempt to open both device 0 and 1 at the same time. If a higher-priority * application is not using device 1 or 2, a low-priority background application * may open device 2 (but will be forced to disconnect it if a higher-priority * application subsequently opens device 1 or 2). * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Not valid. Can be assumed to be 100. Do not read this field. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Always valid. */ int resource_cost; /** * An array of camera device IDs represented as NULL-terminated strings * indicating other devices that cannot be simultaneously opened while this * camera device is in use. * * This field is intended to be used to indicate that this camera device * is a composite of several other camera devices, or otherwise has * hardware dependencies that prohibit simultaneous usage. If there are no * dependencies, a NULL may be returned in this field to indicate this. * * The camera service will never simultaneously open any of the devices * in this list while this camera device is open. * * The strings pointed to in this field will not be cleaned up by the camera * service, and must remain while this device is plugged in. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Not valid. Can be assumed to be NULL. Do not read this field. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Always valid. */ char** conflicting_devices; /** * The length of the array given in the conflicting_devices field. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Not valid. Can be assumed to be 0. Do not read this field. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * Always valid. */ size_t conflicting_devices_length; } camera_info_t; /** * camera_device_status_t: * * The current status of the camera device, as provided by the HAL through the * camera_module_callbacks.camera_device_status_change() call. * * At module load time, the framework will assume all camera devices are in the * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke * camera_module_callbacks::camera_device_status_change to inform the framework * of any initially NOT_PRESENT devices. * * Allowed transitions: * PRESENT -> NOT_PRESENT * NOT_PRESENT -> ENUMERATING * NOT_PRESENT -> PRESENT * ENUMERATING -> PRESENT * ENUMERATING -> NOT_PRESENT */ typedef enum camera_device_status { /** * The camera device is not currently connected, and opening it will return * failure. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Calls to get_camera_info must still succeed, and provide the same information * it would if the camera were connected. * * CAMERA_MODULE_API_VERSION_2_4: * * The camera device at this status must return -EINVAL for get_camera_info call, * as the device is not connected. */ CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, /** * The camera device is connected, and opening it will succeed. * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * The information returned by get_camera_info cannot change due to this status * change. By default, the framework will assume all devices are in this state. * * CAMERA_MODULE_API_VERSION_2_4: * * The information returned by get_camera_info will become valid after a device's * status changes to this. By default, the framework will assume all devices are in * this state. */ CAMERA_DEVICE_STATUS_PRESENT = 1, /** * The camera device is connected, but it is undergoing an enumeration and * so opening the device will return -EBUSY. * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * Calls to get_camera_info must still succeed, as if the camera was in the * PRESENT status. * * CAMERA_MODULE_API_VERSION_2_4: * * The camera device at this status must return -EINVAL for get_camera_info for call, * as the device is not ready. */ CAMERA_DEVICE_STATUS_ENUMERATING = 2, } camera_device_status_t; /** * torch_mode_status_t: * * The current status of the torch mode, as provided by the HAL through the * camera_module_callbacks.torch_mode_status_change() call. * * The torch mode status of a camera device is applicable only when the camera * device is present. The framework will not call set_torch_mode() to turn on * torch mode of a camera device if the camera device is not present. At module * load time, the framework will assume torch modes are in the * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and * android.flash.info.available is reported as true via get_camera_info() call. * * The behaviors of the camera HAL module that the framework expects in the * following situations when a camera device's status changes: * 1. A previously-disconnected camera device becomes connected. * After camera_module_callbacks::camera_device_status_change() is invoked * to inform the framework that the camera device is present, the framework * will assume the camera device's torch mode is in * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need * to invoke camera_module_callbacks::torch_mode_status_change() unless the * flash unit is unavailable to use by set_torch_mode(). * * 2. A previously-connected camera becomes disconnected. * After camera_module_callbacks::camera_device_status_change() is invoked * to inform the framework that the camera device is not present, the * framework will not call set_torch_mode() for the disconnected camera * device until its flash unit becomes available again. The camera HAL * module does not need to invoke * camera_module_callbacks::torch_mode_status_change() separately to inform * that the flash unit has become unavailable. * * 3. open() is called to open a camera device. * The camera HAL module must invoke * camera_module_callbacks::torch_mode_status_change() for all flash units * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be * turned on by calling set_torch_mode() anymore due to this open() call. * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become * unavailable. * * 4. close() is called to close a camera device. * The camera HAL module must invoke * camera_module_callbacks::torch_mode_status_change() for all flash units * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned * on by calling set_torch_mode() again because of enough resources freed * up by this close() call. * * Note that the framework calling set_torch_mode() successfully must trigger * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback * for the given camera device. Additionally it must trigger * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch * modes if HAL cannot keep multiple torch modes on simultaneously. */ typedef enum torch_mode_status { /** * The flash unit is no longer available and the torch mode can not be * turned on by calling set_torch_mode(). If the torch mode is on, it * will be turned off by HAL before HAL calls torch_mode_status_change(). */ TORCH_MODE_STATUS_NOT_AVAILABLE = 0, /** * A torch mode has become off and available to be turned on via * set_torch_mode(). This may happen in the following * cases: * 1. After the resources to turn on the torch mode have become available. * 2. After set_torch_mode() is called to turn off the torch mode. * 3. After the framework turned on the torch mode of some other camera * device and HAL had to turn off the torch modes of any camera devices * that were previously on. */ TORCH_MODE_STATUS_AVAILABLE_OFF = 1, /** * A torch mode has become on and available to be turned off via * set_torch_mode(). This can happen only after set_torch_mode() is called * to turn on the torch mode. */ TORCH_MODE_STATUS_AVAILABLE_ON = 2, } torch_mode_status_t; /** * Callback functions for the camera HAL module to use to inform the framework * of changes to the camera subsystem. * * Version information (based on camera_module_t.common.module_api_version): * * Each callback is called only by HAL modules implementing the indicated * version or higher of the HAL module API interface. * * CAMERA_MODULE_API_VERSION_2_1: * camera_device_status_change() * * CAMERA_MODULE_API_VERSION_2_4: * torch_mode_status_change() */ typedef struct camera_module_callbacks { /** * camera_device_status_change: * * Callback to the framework to indicate that the state of a specific camera * device has changed. At module load time, the framework will assume all * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL * must call this method to inform the framework of any initially * NOT_PRESENT devices. * * This callback is added for CAMERA_MODULE_API_VERSION_2_1. * * camera_module_callbacks: The instance of camera_module_callbacks_t passed * to the module with set_callbacks. * * camera_id: The ID of the camera device that has a new status. * * new_status: The new status code, one of the camera_device_status_t enums, * or a platform-specific status. * */ void (*camera_device_status_change)(const struct camera_module_callbacks*, int camera_id, int new_status); /** * torch_mode_status_change: * * Callback to the framework to indicate that the state of the torch mode * of the flash unit associated with a specific camera device has changed. * At module load time, the framework will assume the torch modes are in * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available * is reported as true via get_camera_info() call. * * This callback is added for CAMERA_MODULE_API_VERSION_2_4. * * camera_module_callbacks: The instance of camera_module_callbacks_t * passed to the module with set_callbacks. * * camera_id: The ID of camera device whose flash unit has a new torch mode * status. * * new_status: The new status code, one of the torch_mode_status_t enums. */ void (*torch_mode_status_change)(const struct camera_module_callbacks*, const char* camera_id, int new_status); } camera_module_callbacks_t; typedef struct camera_module { /** * Common methods of the camera module. This *must* be the first member of * camera_module as users of this structure will cast a hw_module_t to * camera_module pointer in contexts where it's known the hw_module_t * references a camera_module. * * The return values for common.methods->open for camera_module are: * * 0: On a successful open of the camera device. * * -ENODEV: The camera device cannot be opened due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or open_legacy), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or the open_legacy method. * * All other return values from common.methods->open will be treated as * -ENODEV. */ hw_module_t common; /** * get_number_of_cameras: * * Returns the number of camera devices accessible through the camera * module. The camera devices are numbered 0 through N-1, where N is the * value returned by this call. The name of the camera device for open() is * simply the number converted to a string. That is, "0" for camera ID 0, * "1" for camera ID 1. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_3 or lower: * * The value here must be static, and cannot change after the first call * to this method. * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * The value here must be static, and must count only built-in cameras, * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values * (camera_info.facing). The HAL must not include the external cameras * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value * of this call. Frameworks will use camera_device_status_change callback * to manage number of external cameras. */ int (*get_number_of_cameras)(void); /** * get_camera_info: * * Return the static camera information for a given camera device. This * information may not change for a camera device. * * Return values: * * 0: On a successful operation * * -ENODEV: The information cannot be provided due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_2_4 or higher: * * When a camera is disconnected, its camera id becomes invalid. Calling this * this method with this invalid camera id will get -EINVAL and NULL camera * static metadata (camera_info.static_camera_characteristics). */ int (*get_camera_info)(int camera_id, struct camera_info *info); /** * set_callbacks: * * Provide callback function pointers to the HAL module to inform framework * of asynchronous camera module events. The framework will call this * function once after initial camera HAL module load, after the * get_number_of_cameras() method is called for the first time, and before * any other calls to the module. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: * * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_1: * * Valid to be called by the framework. * * Return values: * * 0: On a successful operation * * -ENODEV: The operation cannot be completed due to an internal * error. * * -EINVAL: The input arguments are invalid, i.e. the callbacks are * null */ int (*set_callbacks)(const camera_module_callbacks_t *callbacks); /** * get_vendor_tag_ops: * * Get methods to query for vendor extension metadata tag information. The * HAL should fill in all the vendor tag operation methods, or leave ops * unchanged if no vendor tags are defined. * * The vendor_tag_ops structure used here is defined in: * system/media/camera/include/system/vendor_tags.h * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: * Not provided by HAL module. Framework may not call this function. * * CAMERA_MODULE_API_VERSION_2_2: * Valid to be called by the framework. */ void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); /** * open_legacy: * * Open a specific legacy camera HAL device if multiple device HAL API * versions are supported by this camera HAL module. For example, if the * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, * framework can call this function to open the camera device as * CAMERA_DEVICE_API_VERSION_1_0 device. * * This is an optional method. A Camera HAL module does not need to support * more than one device HAL version per device, and such modules may return * -ENOSYS for all calls to this method. For all older HAL device API * versions that are not supported, it may return -EOPNOTSUPP. When above * cases occur, The normal open() method (common.methods->open) will be * used by the framework instead. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_3: * Valid to be called by the framework. * * Return values: * * 0: On a successful open of the camera device. * * -ENOSYS This method is not supported. * * -EOPNOTSUPP: The requested HAL version is not supported by this method. * * -EINVAL: The input arguments are invalid, i.e. the id is invalid, * and/or the module is invalid. * * -EBUSY: The camera device was already opened for this camera id * (by using this method or common.methods->open method), * regardless of the device HAL version it was opened as. * * -EUSERS: The maximal number of camera devices that can be * opened concurrently were opened already, either by * this method or common.methods->open method. */ int (*open_legacy)(const struct hw_module_t* module, const char* id, uint32_t halVersion, struct hw_device_t** device); /** * set_torch_mode: * * Turn on or off the torch mode of the flash unit associated with a given * camera ID. If the operation is successful, HAL must notify the framework * torch state by invoking * camera_module_callbacks.torch_mode_status_change() with the new state. * * The camera device has a higher priority accessing the flash unit. When * there are any resource conflicts, such as open() is called to open a * camera device, HAL module must notify the framework through * camera_module_callbacks.torch_mode_status_change() that the * torch mode has been turned off and the torch mode state has become * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode * become available again, HAL module must notify the framework through * camera_module_callbacks.torch_mode_status_change() that the torch mode * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to * be called. * * When the framework calls set_torch_mode() to turn on the torch mode of a * flash unit, if HAL cannot keep multiple torch modes on simultaneously, * HAL should turn off the torch mode that was turned on by * a previous set_torch_mode() call and notify the framework that the torch * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_4: * Valid to be called by the framework. * * Return values: * * 0: On a successful operation. * * -ENOSYS: The camera device does not support this operation. It is * returned if and only if android.flash.info.available is * false. * * -EBUSY: The camera device is already in use. * * -EUSERS: The resources needed to turn on the torch mode are not * available, typically because other camera devices are * holding the resources to make using the flash unit not * possible. * * -EINVAL: camera_id is invalid. * */ int (*set_torch_mode)(const char* camera_id, bool enabled); /** * init: * * This method is called by the camera service before any other methods * are invoked, right after the camera HAL library has been successfully * loaded. It may be left as NULL by the HAL module, if no initialization * in needed. * * It can be used by HAL implementations to perform initialization and * other one-time operations. * * Version information (based on camera_module_t.common.module_api_version): * * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: * Not provided by HAL module. Framework will not call this function. * * CAMERA_MODULE_API_VERSION_2_4: * If not NULL, will always be called by the framework once after the HAL * module is loaded, before any other HAL module method is called. * * Return values: * * 0: On a successful operation. * * -ENODEV: Initialization cannot be completed due to an internal * error. The HAL must be assumed to be in a nonfunctional * state. * */ int (*init)(); /* reserved for future use */ void* reserved[5]; } camera_module_t; __END_DECLS #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/consumerir.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H #define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H #include #include #include #include #define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define CONSUMERIR_HARDWARE_MODULE_ID "consumerir" #define CONSUMERIR_TRANSMITTER "transmitter" typedef struct consumerir_freq_range { int min; int max; } consumerir_freq_range_t; typedef struct consumerir_module { /** * Common methods of the consumer IR module. This *must* be the first member of * consumerir_module as users of this structure will cast a hw_module_t to * consumerir_module pointer in contexts where it's known the hw_module_t references a * consumerir_module. */ struct hw_module_t common; } consumerir_module_t; typedef struct consumerir_device { /** * Common methods of the consumer IR device. This *must* be the first member of * consumerir_device as users of this structure will cast a hw_device_t to * consumerir_device pointer in contexts where it's known the hw_device_t references a * consumerir_device. */ struct hw_device_t common; /* * (*transmit)() is called to by the ConsumerIrService to send an IR pattern * at a given carrier_freq. * * The pattern is alternating series of carrier on and off periods measured in * microseconds. The carrier should be turned off at the end of a transmit * even if there are and odd number of entries in the pattern array. * * This call should return when the transmit is complete or encounters an error. * * returns: 0 on success. A negative error code on error. */ int (*transmit)(struct consumerir_device *dev, int carrier_freq, const int pattern[], int pattern_len); /* * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the * number of carrier freqs to allocate space for, which is then filled by * a subsequent call to (*get_carrier_freqs)(). * * returns: the number of ranges on success. A negative error code on error. */ int (*get_num_carrier_freqs)(struct consumerir_device *dev); /* * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate * which frequencies the IR transmitter supports. The HAL implementation * should fill an array of consumerir_freq_range structs with the * appropriate values for the transmitter, up to len elements. * * returns: the number of ranges on success. A negative error code on error. */ int (*get_carrier_freqs)(struct consumerir_device *dev, size_t len, consumerir_freq_range_t *ranges); /* Reserved for future use. Must be NULL. */ void* reserved[8 - 3]; } consumerir_device_t; #endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/display_defs.h ================================================ /* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of The Linux Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ANDROID_INCLUDE_DISPLAY_DEFS_H #define ANDROID_INCLUDE_DISPLAY_DEFS_H #include #include #include __BEGIN_DECLS /* Will need to update below enums if hwcomposer_defs.h is updated */ /* Extended events for hwc_methods::eventControl() */ enum { HWC_EVENT_ORIENTATION = HWC_EVENT_VSYNC + 1 }; /* Extended hwc_layer_t::compositionType values */ enum { /* this layer will be handled in the HWC, using a blit engine */ HWC_BLIT = 0xFF }; /* Extended hwc_layer_t::flags values * Flags are set by SurfaceFlinger and read by the HAL */ enum { /* * HWC_SCREENSHOT_ANIMATOR_LAYER is set by surfaceflinger to indicate * that this layer is a screenshot animating layer. HWC uses this * info to disable rotation animation on External Display */ HWC_SCREENSHOT_ANIMATOR_LAYER = 0x00000004 }; __END_DECLS #endif /* ANDROID_INCLUDE_DISPLAY_DEFS_H*/ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/fb.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_FB_INTERFACE_H #define ANDROID_FB_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS #define GRALLOC_HARDWARE_FB0 "fb0" /*****************************************************************************/ /*****************************************************************************/ typedef struct framebuffer_device_t { /** * Common methods of the framebuffer device. This *must* be the first member of * framebuffer_device_t as users of this structure will cast a hw_device_t to * framebuffer_device_t pointer in contexts where it's known the hw_device_t references a * framebuffer_device_t. */ struct hw_device_t common; /* flags describing some attributes of the framebuffer */ const uint32_t flags; /* dimensions of the framebuffer in pixels */ const uint32_t width; const uint32_t height; /* frambuffer stride in pixels */ const int stride; /* framebuffer pixel format */ const int format; /* resolution of the framebuffer's display panel in pixel per inch*/ const float xdpi; const float ydpi; /* framebuffer's display panel refresh rate in frames per second */ const float fps; /* min swap interval supported by this framebuffer */ const int minSwapInterval; /* max swap interval supported by this framebuffer */ const int maxSwapInterval; /* Number of framebuffers supported*/ const int numFramebuffers; int reserved[7]; /* * requests a specific swap-interval (same definition than EGL) * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct framebuffer_device_t* window, int interval); /* * This hook is OPTIONAL. * * It is non NULL If the framebuffer driver supports "update-on-demand" * and the given rectangle is the area of the screen that gets * updated during (*post)(). * * This is useful on devices that are able to DMA only a portion of * the screen to the display panel, upon demand -- as opposed to * constantly refreshing the panel 60 times per second, for instance. * * Only the area defined by this rectangle is guaranteed to be valid, that * is, the driver is not allowed to post anything outside of this * rectangle. * * The rectangle evaluated during (*post)() and specifies which area * of the buffer passed in (*post)() shall to be posted. * * return -EINVAL if width or height <=0, or if left or top < 0 */ int (*setUpdateRect)(struct framebuffer_device_t* window, int left, int top, int width, int height); /* * Post to the display (display it on the screen) * The buffer must have been allocated with the * GRALLOC_USAGE_HW_FB usage flag. * buffer must be the same width and height as the display and must NOT * be locked. * * The buffer is shown during the next VSYNC. * * If the same buffer is posted again (possibly after some other buffer), * post() will block until the the first post is completed. * * Internally, post() is expected to lock the buffer so that a * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or * USAGE_*_WRITE will block until it is safe; that is typically once this * buffer is shown and another buffer has been posted. * * Returns 0 on success or -errno on error. */ int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); /* * The (*compositionComplete)() method must be called after the * compositor has finished issuing GL commands for client buffers. */ int (*compositionComplete)(struct framebuffer_device_t* dev); /* * This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); /* * (*enableScreen)() is used to either blank (enable=0) or * unblank (enable=1) the screen this framebuffer is attached to. * * Returns 0 on success or -errno on error. */ int (*enableScreen)(struct framebuffer_device_t* dev, int enable); void* reserved_proc[6]; } framebuffer_device_t; /** convenience API for opening and closing a supported device */ static inline int framebuffer_open(const struct hw_module_t* module, struct framebuffer_device_t** device) { return module->methods->open(module, GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device); } static inline int framebuffer_close(struct framebuffer_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_FB_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/fingerprint.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H #define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H #include #define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) #define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint" typedef enum fingerprint_msg_type { FINGERPRINT_ERROR = -1, FINGERPRINT_ACQUIRED = 1, FINGERPRINT_TEMPLATE_ENROLLING = 3, FINGERPRINT_TEMPLATE_REMOVED = 4, FINGERPRINT_AUTHENTICATED = 5 } fingerprint_msg_type_t; /* * Fingerprint errors are meant to tell the framework to terminate the current operation and ask * for the user to correct the situation. These will almost always result in messaging and user * interaction to correct the problem. * * For example, FINGERPRINT_ERROR_CANCELED should follow any acquisition message that results in * a situation where the current operation can't continue without user interaction. For example, * if the sensor is dirty during enrollment and no further enrollment progress can be made, * send FINGERPRINT_ACQUIRED_IMAGER_DIRTY followed by FINGERPRINT_ERROR_CANCELED. */ typedef enum fingerprint_error { FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, /* The hardware has an error that can't be resolved. */ FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2, /* Bad data; operation can't continue */ FINGERPRINT_ERROR_TIMEOUT = 3, /* The operation has timed out waiting for user input. */ FINGERPRINT_ERROR_NO_SPACE = 4, /* No space available to store a template */ FINGERPRINT_ERROR_CANCELED = 5, /* The current operation can't proceed. See above. */ FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint with given id can't be removed */ FINGERPRINT_ERROR_VENDOR_BASE = 1000 /* vendor-specific error messages start here */ } fingerprint_error_t; /* * Fingerprint acquisition info is meant as feedback for the current operation. Anything but * FINGERPRINT_ACQUIRED_GOOD will be shown to the user as feedback on how to take action on the * current operation. For example, FINGERPRINT_ACQUIRED_IMAGER_DIRTY can be used to tell the user * to clean the sensor. If this will cause the current operation to fail, an additional * FINGERPRINT_ERROR_CANCELED can be sent to stop the operation in progress (e.g. enrollment). * In general, these messages will result in a "Try again" message. */ typedef enum fingerprint_acquired_info { FINGERPRINT_ACQUIRED_GOOD = 0, FINGERPRINT_ACQUIRED_PARTIAL = 1, /* sensor needs more data, i.e. longer swipe. */ FINGERPRINT_ACQUIRED_INSUFFICIENT = 2, /* image doesn't contain enough detail for recognition*/ FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3, /* sensor needs to be cleaned */ FINGERPRINT_ACQUIRED_TOO_SLOW = 4, /* mostly swipe-type sensors; not enough data collected */ FINGERPRINT_ACQUIRED_TOO_FAST = 5, /* for swipe and area sensors; tell user to slow down*/ FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000 /* vendor-specific acquisition messages start here */ } fingerprint_acquired_info_t; typedef struct fingerprint_finger_id { uint32_t gid; uint32_t fid; } fingerprint_finger_id_t; typedef struct fingerprint_enroll { fingerprint_finger_id_t finger; /* samples_remaining goes from N (no data collected, but N scans needed) * to 0 (no more data is needed to build a template). */ uint32_t samples_remaining; uint64_t msg; /* Vendor specific message. Used for user guidance */ } fingerprint_enroll_t; typedef struct fingerprint_removed { fingerprint_finger_id_t finger; } fingerprint_removed_t; typedef struct fingerprint_acquired { fingerprint_acquired_info_t acquired_info; /* information about the image */ } fingerprint_acquired_t; typedef struct fingerprint_authenticated { fingerprint_finger_id_t finger; hw_auth_token_t hat; } fingerprint_authenticated_t; typedef struct fingerprint_msg { fingerprint_msg_type_t type; union { fingerprint_error_t error; fingerprint_enroll_t enroll; fingerprint_removed_t removed; fingerprint_acquired_t acquired; fingerprint_authenticated_t authenticated; } data; } fingerprint_msg_t; /* Callback function type */ typedef void (*fingerprint_notify_t)(const fingerprint_msg_t *msg); /* Synchronous operation */ typedef struct fingerprint_device { /** * Common methods of the fingerprint device. This *must* be the first member * of fingerprint_device as users of this structure will cast a hw_device_t * to fingerprint_device pointer in contexts where it's known * the hw_device_t references a fingerprint_device. */ struct hw_device_t common; /* * Client provided callback function to receive notifications. * Do not set by hand, use the function above instead. */ fingerprint_notify_t notify; /* * Set notification callback: * Registers a user function that would receive notifications from the HAL * The call will block if the HAL state machine is in busy state until HAL * leaves the busy state. * * Function return: 0 if callback function is successfuly registered * or a negative number in case of error, generally from the errno.h set. */ int (*set_notify)(struct fingerprint_device *dev, fingerprint_notify_t notify); /* * Fingerprint pre-enroll enroll request: * Generates a unique token to upper layers to indicate the start of an enrollment transaction. * This token will be wrapped by security for verification and passed to enroll() for * verification before enrollment will be allowed. This is to ensure adding a new fingerprint * template was preceded by some kind of credential confirmation (e.g. device password). * * Function return: 0 if function failed * otherwise, a uint64_t of token */ uint64_t (*pre_enroll)(struct fingerprint_device *dev); /* * Fingerprint enroll request: * Switches the HAL state machine to collect and store a new fingerprint * template. Switches back as soon as enroll is complete * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && * fingerprint_msg.data.enroll.samples_remaining == 0) * or after timeout_sec seconds. * The fingerprint template will be assigned to the group gid. User has a choice * to supply the gid or set it to 0 in which case a unique group id will be generated. * * Function return: 0 if enrollment process can be successfully started * or a negative number in case of error, generally from the errno.h set. * A notify() function may be called indicating the error condition. */ int (*enroll)(struct fingerprint_device *dev, const hw_auth_token_t *hat, uint32_t gid, uint32_t timeout_sec); /* * Finishes the enroll operation and invalidates the pre_enroll() generated challenge. * This will be called at the end of a multi-finger enrollment session to indicate * that no more fingers will be added. * * Function return: 0 if the request is accepted * or a negative number in case of error, generally from the errno.h set. */ int (*post_enroll)(struct fingerprint_device *dev); /* * get_authenticator_id: * Returns a token associated with the current fingerprint set. This value will * change whenever a new fingerprint is enrolled, thus creating a new fingerprint * set. * * Function return: current authenticator id or 0 if function failed. */ uint64_t (*get_authenticator_id)(struct fingerprint_device *dev); /* * Cancel pending enroll or authenticate, sending FINGERPRINT_ERROR_CANCELED * to all running clients. Switches the HAL state machine back to the idle state. * Unlike enroll_done() doesn't invalidate the pre_enroll() challenge. * * Function return: 0 if cancel request is accepted * or a negative number in case of error, generally from the errno.h set. */ int (*cancel)(struct fingerprint_device *dev); /* * Enumerate all the fingerprint templates found in the directory set by * set_active_group() * This is a synchronous call. The function takes: * - A pointer to an array of fingerprint_finger_id_t. * - The size of the array provided, in fingerprint_finger_id_t elements. * Max_size is a bi-directional parameter and returns the actual number * of elements copied to the caller supplied array. * In the absence of errors the function returns the total number of templates * in the user directory. * If the caller has no good guess on the size of the array he should call this * function witn *max_size == 0 and use the return value for the array allocation. * The caller of this function has a complete list of the templates when *max_size * is the same as the function return. * * Function return: Total number of fingerprint templates in the current storage directory. * or a negative number in case of error, generally from the errno.h set. */ int (*enumerate)(struct fingerprint_device *dev, fingerprint_finger_id_t *results, uint32_t *max_size); /* * Fingerprint remove request: * Deletes a fingerprint template. * Works only within a path set by set_active_group(). * notify() will be called with details on the template deleted. * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and * fingerprint_msg.data.removed.id indicating the template id removed. * * Function return: 0 if fingerprint template(s) can be successfully deleted * or a negative number in case of error, generally from the errno.h set. */ int (*remove)(struct fingerprint_device *dev, uint32_t gid, uint32_t fid); /* * Restricts the HAL operation to a set of fingerprints belonging to a * group provided. * The caller must provide a path to a storage location within the user's * data directory. * * Function return: 0 on success * or a negative number in case of error, generally from the errno.h set. */ int (*set_active_group)(struct fingerprint_device *dev, uint32_t gid, const char *store_path); /* * Authenticates an operation identifed by operation_id * * Function return: 0 on success * or a negative number in case of error, generally from the errno.h set. */ int (*authenticate)(struct fingerprint_device *dev, uint64_t operation_id, uint32_t gid); /* Reserved for backward binary compatibility */ void *reserved[4]; } fingerprint_device_t; typedef struct fingerprint_module { /** * Common methods of the fingerprint module. This *must* be the first member * of fingerprint_module as users of this structure will cast a hw_module_t * to fingerprint_module pointer in contexts where it's known * the hw_module_t references a fingerprint_module. */ struct hw_module_t common; } fingerprint_module_t; #endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/fused_location.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H #define ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H #include /** * This header file defines the interface of the Fused Location Provider. * Fused Location Provider is designed to fuse data from various sources * like GPS, Wifi, Cell, Sensors, Bluetooth etc to provide a fused location to the * upper layers. The advantage of doing fusion in hardware is power savings. * The goal is to do this without waking up the AP to get additional data. * The software implementation of FLP will decide when to use * the hardware fused location. Other location features like geofencing will * also be implemented using fusion in hardware. */ __BEGIN_DECLS #define FLP_HEADER_VERSION 1 #define FLP_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define FLP_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, FLP_HEADER_VERSION) /** * The id of this module */ #define FUSED_LOCATION_HARDWARE_MODULE_ID "flp" /** * Name for the FLP location interface */ #define FLP_LOCATION_INTERFACE "flp_location" /** * Name for the FLP location interface */ #define FLP_DIAGNOSTIC_INTERFACE "flp_diagnostic" /** * Name for the FLP_Geofencing interface. */ #define FLP_GEOFENCING_INTERFACE "flp_geofencing" /** * Name for the FLP_device context interface. */ #define FLP_DEVICE_CONTEXT_INTERFACE "flp_device_context" /** * Constants to indicate the various subsystems * that will be used. */ #define FLP_TECH_MASK_GNSS (1U<<0) #define FLP_TECH_MASK_WIFI (1U<<1) #define FLP_TECH_MASK_SENSORS (1U<<2) #define FLP_TECH_MASK_CELL (1U<<3) #define FLP_TECH_MASK_BLUETOOTH (1U<<4) /** * Set when your implementation can produce GNNS-derived locations, * for use with flp_capabilities_callback. * * GNNS is a required capability for a particular feature to be used * (batching or geofencing). If not supported that particular feature * won't be used by the upper layer. */ #define CAPABILITY_GNSS (1U<<0) /** * Set when your implementation can produce WiFi-derived locations, for * use with flp_capabilities_callback. */ #define CAPABILITY_WIFI (1U<<1) /** * Set when your implementation can produce cell-derived locations, for * use with flp_capabilities_callback. */ #define CAPABILITY_CELL (1U<<3) /** * Status to return in flp_status_callback when your implementation transitions * from being unsuccessful in determining location to being successful. */ #define FLP_STATUS_LOCATION_AVAILABLE 0 /** * Status to return in flp_status_callback when your implementation transitions * from being successful in determining location to being unsuccessful. */ #define FLP_STATUS_LOCATION_UNAVAILABLE 1 /** * This constant is used with the batched locations * APIs. Batching is mandatory when FLP implementation * is supported. If the flag is set, the hardware implementation * will wake up the application processor when the FIFO is full, * If the flag is not set, the hardware implementation will drop * the oldest data when the FIFO is full. */ #define FLP_BATCH_WAKEUP_ON_FIFO_FULL 0x0000001 /** * While batching, the implementation should not call the * flp_location_callback on every location fix. However, * sometimes in high power mode, the system might need * a location callback every single time the location * fix has been obtained. This flag controls that option. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. * When this bit is on amidst a batching session, batching should * continue while location fixes are reported in real time. */ #define FLP_BATCH_CALLBACK_ON_LOCATION_FIX 0x0000002 /** Flags to indicate which values are valid in a FlpLocation. */ typedef uint16_t FlpLocationFlags; // IMPORTANT: Note that the following values must match // constants in the corresponding java file. /** FlpLocation has valid latitude and longitude. */ #define FLP_LOCATION_HAS_LAT_LONG (1U<<0) /** FlpLocation has valid altitude. */ #define FLP_LOCATION_HAS_ALTITUDE (1U<<1) /** FlpLocation has valid speed. */ #define FLP_LOCATION_HAS_SPEED (1U<<2) /** FlpLocation has valid bearing. */ #define FLP_LOCATION_HAS_BEARING (1U<<4) /** FlpLocation has valid accuracy. */ #define FLP_LOCATION_HAS_ACCURACY (1U<<8) typedef int64_t FlpUtcTime; /** Represents a location. */ typedef struct { /** set to sizeof(FlpLocation) */ size_t size; /** Flags associated with the location object. */ FlpLocationFlags flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** * Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ FlpUtcTime timestamp; /** Sources used, will be Bitwise OR of the FLP_TECH_MASK bits. */ uint32_t sources_used; } FlpLocation; typedef enum { ASSOCIATE_JVM, DISASSOCIATE_JVM, } ThreadEvent; /** * Callback with location information. * Can only be called from a thread associated to JVM using set_thread_event_cb. * Parameters: * num_locations is the number of batched locations available. * location is the pointer to an array of pointers to location objects. */ typedef void (*flp_location_callback)(int32_t num_locations, FlpLocation** location); /** * Callback utility for acquiring a wakelock. * This can be used to prevent the CPU from suspending while handling FLP events. */ typedef void (*flp_acquire_wakelock)(); /** * Callback utility for releasing the FLP wakelock. */ typedef void (*flp_release_wakelock)(); /** * Callback for associating a thread that can call into the Java framework code. * This must be used to initialize any threads that report events up to the framework. * Return value: * FLP_RESULT_SUCCESS on success. * FLP_RESULT_ERROR if the association failed in the current thread. */ typedef int (*flp_set_thread_event)(ThreadEvent event); /** * Callback for technologies supported by this implementation. * * Parameters: capabilities is a bitmask of FLP_CAPABILITY_* values describing * which features your implementation supports. You should support * CAPABILITY_GNSS at a minimum for your implementation to be utilized. You can * return 0 in FlpGeofenceCallbacks to indicate you don't support geofencing, * or 0 in FlpCallbacks to indicate you don't support location batching. */ typedef void (*flp_capabilities_callback)(int capabilities); /** * Callback with status information on the ability to compute location. * To avoid waking up the application processor you should only send * changes in status (you shouldn't call this method twice in a row * with the same status value). As a guideline you should not call this * more frequently then the requested batch period set with period_ns * in FlpBatchOptions. For example if period_ns is set to 5 minutes and * the status changes many times in that interval, you should only report * one status change every 5 minutes. * * Parameters: * status is one of FLP_STATUS_LOCATION_AVAILABLE * or FLP_STATUS_LOCATION_UNAVAILABLE. */ typedef void (*flp_status_callback)(int32_t status); /** FLP callback structure. */ typedef struct { /** set to sizeof(FlpCallbacks) */ size_t size; flp_location_callback location_cb; flp_acquire_wakelock acquire_wakelock_cb; flp_release_wakelock release_wakelock_cb; flp_set_thread_event set_thread_event_cb; flp_capabilities_callback flp_capabilities_cb; flp_status_callback flp_status_cb; } FlpCallbacks; /** Options with the batching FLP APIs */ typedef struct { /** * Maximum power in mW that the underlying implementation * can use for this batching call. * If max_power_allocation_mW is 0, only fixes that are generated * at no additional cost of power shall be reported. */ double max_power_allocation_mW; /** Bitwise OR of the FLP_TECH_MASKS to use */ uint32_t sources_to_use; /** * FLP_BATCH_WAKEUP_ON_FIFO_FULL - If set the hardware * will wake up the AP when the buffer is full. If not set, the * hardware will drop the oldest location object. * * FLP_BATCH_CALLBACK_ON_LOCATION_FIX - If set the location * callback will be called every time there is a location fix. * Its the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. When this * bit is on amidst a batching session, batching should continue * while location fixes are reported in real time. * * Other flags to be bitwised ORed in the future. */ uint32_t flags; /** * Frequency with which location needs to be batched in nano * seconds. */ int64_t period_ns; /** * The smallest displacement between reported locations in meters. * * If set to 0, then you should report locations at the requested * interval even if the device is stationary. If positive, you * can use this parameter as a hint to save power (e.g. throttling * location period if the user hasn't traveled close to the displacement * threshold). Even small positive values can be interpreted to mean * that you don't have to compute location when the device is stationary. * * There is no need to filter location delivery based on this parameter. * Locations can be delivered even if they have a displacement smaller than * requested. This parameter can safely be ignored at the cost of potential * power savings. */ float smallest_displacement_meters; } FlpBatchOptions; #define FLP_RESULT_SUCCESS 0 #define FLP_RESULT_ERROR -1 #define FLP_RESULT_INSUFFICIENT_MEMORY -2 #define FLP_RESULT_TOO_MANY_GEOFENCES -3 #define FLP_RESULT_ID_EXISTS -4 #define FLP_RESULT_ID_UNKNOWN -5 #define FLP_RESULT_INVALID_GEOFENCE_TRANSITION -6 /** * Represents the standard FLP interface. */ typedef struct { /** * set to sizeof(FlpLocationInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implementation of this interface. Once called you should respond * by calling the flp_capabilities_callback in FlpCallbacks to * specify the capabilities that your implementation supports. */ int (*init)(FlpCallbacks* callbacks ); /** * Return the batch size (in number of FlpLocation objects) * available in the hardware. Note, different HW implementations * may have different sample sizes. This shall return number * of samples defined in the format of FlpLocation. * This will be used by the upper layer, to decide on the batching * interval and whether the AP should be woken up or not. */ int (*get_batch_size)(); /** * Start batching locations. This API is primarily used when the AP is * asleep and the device can batch locations in the hardware. * flp_location_callback is used to return the locations. When the buffer * is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is used, the AP is woken up. * When the buffer is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is not set, * the oldest location object is dropped. In this case the AP will not be * woken up. The upper layer will use get_batched_location * API to explicitly ask for the location. * If FLP_BATCH_CALLBACK_ON_LOCATION_FIX is set, the implementation * will call the flp_location_callback every single time there is a location * fix. This overrides FLP_BATCH_WAKEUP_ON_FIFO_FULL flag setting. * It's the responsibility of the upper layers (caller) to switch * it off, if it knows that the AP might go to sleep. This is useful * for nagivational applications when the system is in high power mode. * Parameters: * id - Id for the request. * options - See FlpBatchOptions struct definition. * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_INSUFFICIENT_MEMORY, * FLP_RESULT_ID_EXISTS, FLP_RESULT_ERROR on failure. */ int (*start_batching)(int id, FlpBatchOptions* options); /** * Update FlpBatchOptions associated with a batching request. * When a batching operation is in progress and a batching option * such as FLP_BATCH_WAKEUP_ON_FIFO_FULL needs to be updated, this API * will be used. For instance, this can happen when the AP is awake and * the maps application is being used. * Parameters: * id - Id of an existing batch request. * new_options - Updated FlpBatchOptions * Return value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN, * FLP_RESULT_ERROR on error. */ int (*update_batching_options)(int id, FlpBatchOptions* new_options); /** * Stop batching. * Parameters: * id - Id for the request. * Return Value: * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN or * FLP_RESULT_ERROR on failure. */ int (*stop_batching)(int id); /** * Closes the interface. If any batch operations are in progress, * they should be stopped. */ void (*cleanup)(); /** * Get the fused location that was batched. * flp_location_callback is used to return the location. The location object * is dropped from the buffer only when the buffer is full. Do not remove it * from the buffer just because it has been returned using the callback. * In other words, when there is no new location object, two calls to * get_batched_location(1) should return the same location object. * Parameters: * last_n_locations - Number of locations to get. This can be one or many. * If the last_n_locations is 1, you get the latest location known to the * hardware. */ void (*get_batched_location)(int last_n_locations); /** * Injects current location from another location provider * latitude and longitude are measured in degrees * expected accuracy is measured in meters * Parameters: * location - The location object being injected. * Return value: FLP_RESULT_SUCCESS or FLP_RESULT_ERROR. */ int (*inject_location)(FlpLocation* location); /** * Get a pointer to extension information. */ const void* (*get_extension)(const char* name); /** * Retrieve all batched locations currently stored and clear the buffer. * flp_location_callback MUST be called in response, even if there are * no locations to flush (in which case num_locations should be 0). * Subsequent calls to get_batched_location or flush_batched_locations * should not return any of the locations returned in this call. */ void (*flush_batched_locations)(); } FlpLocationInterface; struct flp_device_t { struct hw_device_t common; /** * Get a handle to the FLP Interface. */ const FlpLocationInterface* (*get_flp_interface)(struct flp_device_t* dev); }; /** * Callback for reports diagnostic data into the Java framework code. */ typedef void (*report_data)(char* data, int length); /** * FLP diagnostic callback structure. * Currently, not used - but this for future extension. */ typedef struct { /** set to sizeof(FlpDiagnosticCallbacks) */ size_t size; flp_set_thread_event set_thread_event_cb; /** reports diagnostic data into the Java framework code */ report_data data_cb; } FlpDiagnosticCallbacks; /** Extended interface for diagnostic support. */ typedef struct { /** set to sizeof(FlpDiagnosticInterface) */ size_t size; /** * Opens the diagnostic interface and provides the callback routines * to the implemenation of this interface. */ void (*init)(FlpDiagnosticCallbacks* callbacks); /** * Injects diagnostic data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_data)(char* data, int length ); } FlpDiagnosticInterface; /** * Context setting information. * All these settings shall be injected to FLP HAL at FLP init time. * Following that, only the changed setting need to be re-injected * upon changes. */ #define FLP_DEVICE_CONTEXT_GPS_ENABLED (1U<<0) #define FLP_DEVICE_CONTEXT_AGPS_ENABLED (1U<<1) #define FLP_DEVICE_CONTEXT_NETWORK_POSITIONING_ENABLED (1U<<2) #define FLP_DEVICE_CONTEXT_WIFI_CONNECTIVITY_ENABLED (1U<<3) #define FLP_DEVICE_CONTEXT_WIFI_POSITIONING_ENABLED (1U<<4) #define FLP_DEVICE_CONTEXT_HW_NETWORK_POSITIONING_ENABLED (1U<<5) #define FLP_DEVICE_CONTEXT_AIRPLANE_MODE_ON (1U<<6) #define FLP_DEVICE_CONTEXT_DATA_ENABLED (1U<<7) #define FLP_DEVICE_CONTEXT_ROAMING_ENABLED (1U<<8) #define FLP_DEVICE_CONTEXT_CURRENTLY_ROAMING (1U<<9) #define FLP_DEVICE_CONTEXT_SENSOR_ENABLED (1U<<10) #define FLP_DEVICE_CONTEXT_BLUETOOTH_ENABLED (1U<<11) #define FLP_DEVICE_CONTEXT_CHARGER_ON (1U<<12) /** Extended interface for device context support. */ typedef struct { /** set to sizeof(FlpDeviceContextInterface) */ size_t size; /** * Injects debug data into the FLP subsystem. * Return 0 on success, -1 on error. **/ int (*inject_device_context)(uint32_t enabledMask); } FlpDeviceContextInterface; /** * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the FLP subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * FLP subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the FLP system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate FLP location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the FLP system is unavailable, flp_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * */ #define FLP_GEOFENCE_TRANSITION_ENTERED (1L<<0) #define FLP_GEOFENCE_TRANSITION_EXITED (1L<<1) #define FLP_GEOFENCE_TRANSITION_UNCERTAIN (1L<<2) #define FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE (1L<<0) #define FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE (1L<<1) /** * The callback associated with the geofence. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current location as determined by the FLP subsystem. * transition - Can be one of FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED, * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * timestamp - Timestamp when the transition was detected; -1 if not available. * sources_used - Bitwise OR of FLP_TECH_MASK flags indicating which * subsystems were used. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*flp_geofence_transition_callback) (int32_t geofence_id, FlpLocation* location, int32_t transition, FlpUtcTime timestamp, uint32_t sources_used); /** * The callback associated with the availablity of one the sources used for geofence * monitoring by the FLP sub-system For example, if the GPS system determines that it cannot * monitor geofences because of lack of reliability or unavailability of the GPS signals, * it will call this callback with FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE parameter and the * source set to FLP_TECH_MASK_GNSS. * * Parameters: * status - FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE or FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE. * source - One of the FLP_TECH_MASKS * last_location - Last known location. */ typedef void (*flp_geofence_monitor_status_callback) (int32_t status, uint32_t source, FlpLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * FLP_RESULT_ID_EXISTS - geofence with id already exists * FLP_RESULT_INVALID_GEOFENCE_TRANSITION - the monitorTransition contains an * invalid transition * FLP_RESULT_ERROR - for other errors. */ typedef void (*flp_geofence_add_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_remove_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT__ID_UNKNOWN - for invalid id * FLP_RESULT_INVALID_TRANSITION - * when monitor_transitions is invalid * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_pause_callback) (int32_t geofence_id, int32_t result); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * result - FLP_RESULT_SUCCESS * FLP_RESULT_ID_UNKNOWN - for invalid id * FLP_RESULT_ERROR for others. */ typedef void (*flp_geofence_resume_callback) (int32_t geofence_id, int32_t result); typedef struct { /** set to sizeof(FlpGeofenceCallbacks) */ size_t size; flp_geofence_transition_callback geofence_transition_callback; flp_geofence_monitor_status_callback geofence_status_callback; flp_geofence_add_callback geofence_add_callback; flp_geofence_remove_callback geofence_remove_callback; flp_geofence_pause_callback geofence_pause_callback; flp_geofence_resume_callback geofence_resume_callback; flp_set_thread_event set_thread_event_cb; flp_capabilities_callback flp_capabilities_cb; } FlpGeofenceCallbacks; /** Type of geofence */ typedef enum { TYPE_CIRCLE = 0, } GeofenceType; /** Circular geofence is represented by lat / long / radius */ typedef struct { double latitude; double longitude; double radius_m; } GeofenceCircle; /** Represents the type of geofence and data */ typedef struct { GeofenceType type; union { GeofenceCircle circle; } geofence; } GeofenceData; /** Geofence Options */ typedef struct { /** * The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to FLP_GEOFENCE_TRANSITION_ENTERED. In most cases, it * will be FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int last_transition; /** * Transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ int monitor_transitions; /** * Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with FLP_GEOFENCE_TRANSITION_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. */ int notification_responsivenes_ms; /** * The time limit after which the UNCERTAIN transition * should be triggered. This paramter is defined in milliseconds. */ int unknown_timer_ms; /** * The sources to use for monitoring geofences. Its a BITWISE-OR * of FLP_TECH_MASK flags. */ uint32_t sources_to_use; } GeofenceOptions; /** Geofence struct */ typedef struct { int32_t geofence_id; GeofenceData* data; GeofenceOptions* options; } Geofence; /** Extended interface for FLP_Geofencing support */ typedef struct { /** set to sizeof(FlpGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implemenation of this interface. Once called you should respond * by calling the flp_capabilities_callback in FlpGeofenceCallbacks to * specify the capabilities that your implementation supports. */ void (*init)( FlpGeofenceCallbacks* callbacks ); /** * Add a list of geofences. * Parameters: * number_of_geofences - The number of geofences that needed to be added. * geofences - Pointer to array of pointers to Geofence structure. */ void (*add_geofences) (int32_t number_of_geofences, Geofence** geofences); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and * FLP_GEOFENCE_TRANSITION_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Modify a particular geofence option. * Parameters: * geofence_id - The id for the geofence. * options - Various options associated with the geofence. See * GeofenceOptions structure for details. */ void (*modify_geofence_option) (int32_t geofence_id, GeofenceOptions* options); /** * Remove a list of geofences. After the function returns, no notifications * should be sent. * Parameter: * number_of_geofences - The number of geofences that needed to be added. * geofence_id - Pointer to array of geofence_ids to be removed. */ void (*remove_geofences) (int32_t number_of_geofences, int32_t* geofence_id); } FlpGeofencingInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_FLP_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/gatekeeper.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_GATEKEEPER_H #define ANDROID_HARDWARE_GATEKEEPER_H #include #include #include __BEGIN_DECLS #define GATEKEEPER_HARDWARE_MODULE_ID "gatekeeper" #define GATEKEEPER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HARDWARE_GATEKEEPER "gatekeeper" struct gatekeeper_module { /** * Comon methods of the gatekeeper module. This *must* be the first member of * gatekeeper_module as users of this structure will cast a hw_module_t to * a gatekeeper_module pointer in the appropriate context. */ hw_module_t common; }; struct gatekeeper_device { /** * Common methods of the gatekeeper device. As above, this must be the first * member of keymaster_device. */ hw_device_t common; /** * Enrolls desired_password, which should be derived from a user selected pin or password, * with the authentication factor private key used only for enrolling authentication * factor data. * * If there was already a password enrolled, it should be provided in * current_password_handle, along with the current password in current_password * that should validate against current_password_handle. * * Parameters: * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * - uid: the Android user identifier * * - current_password_handle: the currently enrolled password handle the user * wants to replace. May be null if there's no currently enrolled password. * - current_password_handle_length: the length in bytes of the buffer pointed * at by current_password_handle. Must be 0 if current_password_handle is NULL. * * - current_password: the user's current password in plain text. If presented, * it MUST verify against current_password_handle. * - current_password_length: the size in bytes of the buffer pointed at by * current_password. Must be 0 if the current_password is NULL. * * - desired_password: the new password the user wishes to enroll in plain-text. * Cannot be NULL. * - desired_password_length: the length in bytes of the buffer pointed at by * desired_password. * * - enrolled_password_handle: on success, a buffer will be allocated with the * new password handle referencing the password provided in desired_password. * This buffer can be used on subsequent calls to enroll or verify. * The caller is responsible for deallocating this buffer via a call to delete[] * - enrolled_password_handle_length: pointer to the length in bytes of the buffer allocated * by this function and pointed to by *enrolled_password_handle_length. * * Returns: * - 0 on success * - An error code < 0 on failure, or * - A timeout value T > 0 if the call should not be re-attempted until T milliseconds * have elapsed. * * On error, enrolled_password_handle will not be allocated. */ int (*enroll)(const struct gatekeeper_device *dev, uint32_t uid, const uint8_t *current_password_handle, uint32_t current_password_handle_length, const uint8_t *current_password, uint32_t current_password_length, const uint8_t *desired_password, uint32_t desired_password_length, uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length); /** * Verifies provided_password matches enrolled_password_handle. * * Implementations of this module may retain the result of this call * to attest to the recency of authentication. * * On success, writes the address of a verification token to auth_token, * usable to attest password verification to other trusted services. Clients * may pass NULL for this value. * * Parameters: * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * - uid: the Android user identifier * * - challenge: An optional challenge to authenticate against, or 0. Used when a separate * authenticator requests password verification, or for transactional * password authentication. * * - enrolled_password_handle: the currently enrolled password handle that the * user wishes to verify against. * - enrolled_password_handle_length: the length in bytes of the buffer pointed * to by enrolled_password_handle * * - provided_password: the plaintext password to be verified against the * enrolled_password_handle * - provided_password_length: the length in bytes of the buffer pointed to by * provided_password * * - auth_token: on success, a buffer containing the authentication token * resulting from this verification is assigned to *auth_token. The caller * is responsible for deallocating this memory via a call to delete[] * - auth_token_length: on success, the length in bytes of the authentication * token assigned to *auth_token will be assigned to *auth_token_length * * - request_reenroll: a request to the upper layers to re-enroll the verified * password due to a version change. Not set if verification fails. * * Returns: * - 0 on success * - An error code < 0 on failure, or * - A timeout value T > 0 if the call should not be re-attempted until T milliseconds * have elapsed. * On error, auth token will not be allocated */ int (*verify)(const struct gatekeeper_device *dev, uint32_t uid, uint64_t challenge, const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length, const uint8_t *provided_password, uint32_t provided_password_length, uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll); /* * Deletes the enrolled_password_handle associated wth the uid. Once deleted * the user cannot be verified anymore. * This function is optional and should be set to NULL if it is not implemented. * * Parameters * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * - uid: the Android user identifier * * Returns: * - 0 on success * - An error code < 0 on failure */ int (*delete_user)(const struct gatekeeper_device *dev, uint32_t uid); /* * Deletes all the enrolled_password_handles for all uid's. Once called, * no users will be enrolled on the device. * This function is optional and should be set to NULL if it is not implemented. * * Parameters * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open * * Returns: * - 0 on success * - An error code < 0 on failure */ int (*delete_all_users)(const struct gatekeeper_device *dev); }; typedef struct gatekeeper_device gatekeeper_device_t; static inline int gatekeeper_open(const struct hw_module_t *module, gatekeeper_device_t **device) { return module->methods->open(module, HARDWARE_GATEKEEPER, (struct hw_device_t **) device); } static inline int gatekeeper_close(gatekeeper_device_t *device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_HARDWARE_GATEKEEPER_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/gps.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_GPS_H #define ANDROID_INCLUDE_HARDWARE_GPS_H #include #include #include #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define GPS_HARDWARE_MODULE_ID "gps" /** Milliseconds since January 1, 1970 */ typedef int64_t GpsUtcTime; /** Maximum number of SVs for gps_sv_status_callback(). */ #define GPS_MAX_SVS 32 /** Maximum number of Measurements in gps_measurement_callback(). */ #define GPS_MAX_MEASUREMENT 32 /** Requested operational mode for GPS operation. */ typedef uint32_t GpsPositionMode; // IMPORTANT: Note that the following values must match // constants in GpsLocationProvider.java. /** Mode for running GPS standalone (no assistance). */ #define GPS_POSITION_MODE_STANDALONE 0 /** AGPS MS-Based mode. */ #define GPS_POSITION_MODE_MS_BASED 1 /** * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. * It is strongly recommended to use GPS_POSITION_MODE_MS_BASE instead. */ #define GPS_POSITION_MODE_MS_ASSISTED 2 /** Requested recurrence mode for GPS operation. */ typedef uint32_t GpsPositionRecurrence; // IMPORTANT: Note that the following values must match // constants in GpsLocationProvider.java. /** Receive GPS fixes on a recurring basis at a specified period. */ #define GPS_POSITION_RECURRENCE_PERIODIC 0 /** Request a single shot GPS fix. */ #define GPS_POSITION_RECURRENCE_SINGLE 1 /** GPS status event values. */ typedef uint16_t GpsStatusValue; // IMPORTANT: Note that the following values must match // constants in GpsLocationProvider.java. /** GPS status unknown. */ #define GPS_STATUS_NONE 0 /** GPS has begun navigating. */ #define GPS_STATUS_SESSION_BEGIN 1 /** GPS has stopped navigating. */ #define GPS_STATUS_SESSION_END 2 /** GPS has powered on but is not navigating. */ #define GPS_STATUS_ENGINE_ON 3 /** GPS is powered off. */ #define GPS_STATUS_ENGINE_OFF 4 /** Flags to indicate which values are valid in a GpsLocation. */ typedef uint16_t GpsLocationFlags; // IMPORTANT: Note that the following values must match // constants in GpsLocationProvider.java. /** GpsLocation has valid latitude and longitude. */ #define GPS_LOCATION_HAS_LAT_LONG 0x0001 /** GpsLocation has valid altitude. */ #define GPS_LOCATION_HAS_ALTITUDE 0x0002 /** GpsLocation has valid speed. */ #define GPS_LOCATION_HAS_SPEED 0x0004 /** GpsLocation has valid bearing. */ #define GPS_LOCATION_HAS_BEARING 0x0008 /** GpsLocation has valid accuracy. */ #define GPS_LOCATION_HAS_ACCURACY 0x0010 /** Flags for the gps_set_capabilities callback. */ /** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. If this is not set, then the framework will use 1000ms for min_interval and will start and call start() and stop() to schedule the GPS. */ #define GPS_CAPABILITY_SCHEDULING 0x0000001 /** GPS supports MS-Based AGPS mode */ #define GPS_CAPABILITY_MSB 0x0000002 /** GPS supports MS-Assisted AGPS mode */ #define GPS_CAPABILITY_MSA 0x0000004 /** GPS supports single-shot fixes */ #define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 /** GPS supports on demand time injection */ #define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 /** GPS supports Geofencing */ #define GPS_CAPABILITY_GEOFENCING 0x0000020 /** GPS supports Measurements */ #define GPS_CAPABILITY_MEASUREMENTS 0x0000040 /** GPS supports Navigation Messages */ #define GPS_CAPABILITY_NAV_MESSAGES 0x0000080 /** Flags used to specify which aiding data to delete when calling delete_aiding_data(). */ typedef uint16_t GpsAidingData; // IMPORTANT: Note that the following values must match // constants in GpsLocationProvider.java. #define GPS_DELETE_EPHEMERIS 0x0001 #define GPS_DELETE_ALMANAC 0x0002 #define GPS_DELETE_POSITION 0x0004 #define GPS_DELETE_TIME 0x0008 #define GPS_DELETE_IONO 0x0010 #define GPS_DELETE_UTC 0x0020 #define GPS_DELETE_HEALTH 0x0040 #define GPS_DELETE_SVDIR 0x0080 #define GPS_DELETE_SVSTEER 0x0100 #define GPS_DELETE_SADATA 0x0200 #define GPS_DELETE_RTI 0x0400 #define GPS_DELETE_CELLDB_INFO 0x8000 #define GPS_DELETE_ALL 0xFFFF /** AGPS type */ typedef uint16_t AGpsType; #define AGPS_TYPE_SUPL 1 #define AGPS_TYPE_C2K 2 typedef uint16_t AGpsSetIDType; #define AGPS_SETID_TYPE_NONE 0 #define AGPS_SETID_TYPE_IMSI 1 #define AGPS_SETID_TYPE_MSISDN 2 typedef uint16_t ApnIpType; #define APN_IP_INVALID 0 #define APN_IP_IPV4 1 #define APN_IP_IPV6 2 #define APN_IP_IPV4V6 3 /** * String length constants */ #define GPS_NI_SHORT_STRING_MAXLEN 256 #define GPS_NI_LONG_STRING_MAXLEN 2048 /** * GpsNiType constants */ typedef uint32_t GpsNiType; #define GPS_NI_TYPE_VOICE 1 #define GPS_NI_TYPE_UMTS_SUPL 2 #define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 /** * GpsNiNotifyFlags constants */ typedef uint32_t GpsNiNotifyFlags; /** NI requires notification */ #define GPS_NI_NEED_NOTIFY 0x0001 /** NI requires verification */ #define GPS_NI_NEED_VERIFY 0x0002 /** NI requires privacy override, no notification/minimal trace */ #define GPS_NI_PRIVACY_OVERRIDE 0x0004 /** * GPS NI responses, used to define the response in * NI structures */ typedef int GpsUserResponseType; #define GPS_NI_RESPONSE_ACCEPT 1 #define GPS_NI_RESPONSE_DENY 2 #define GPS_NI_RESPONSE_NORESP 3 /** * NI data encoding scheme */ typedef int GpsNiEncodingType; #define GPS_ENC_NONE 0 #define GPS_ENC_SUPL_GSM_DEFAULT 1 #define GPS_ENC_SUPL_UTF8 2 #define GPS_ENC_SUPL_UCS2 3 #define GPS_ENC_UNKNOWN -1 /** AGPS status event values. */ typedef uint16_t AGpsStatusValue; /** GPS requests data connection for AGPS. */ #define GPS_REQUEST_AGPS_DATA_CONN 1 /** GPS releases the AGPS data connection. */ #define GPS_RELEASE_AGPS_DATA_CONN 2 /** AGPS data connection initiated */ #define GPS_AGPS_DATA_CONNECTED 3 /** AGPS data connection completed */ #define GPS_AGPS_DATA_CONN_DONE 4 /** AGPS data connection failed */ #define GPS_AGPS_DATA_CONN_FAILED 5 #define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 #define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 #define AGPS_REG_LOCATION_TYPE_MAC 3 /** Network types for update_network_state "type" parameter */ #define AGPS_RIL_NETWORK_TYPE_MOBILE 0 #define AGPS_RIL_NETWORK_TYPE_WIFI 1 #define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 #define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 #define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 #define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 #define AGPS_RIL_NETWORK_TTYPE_WIMAX 6 /** * Flags to indicate what fields in GpsClock are valid. */ typedef uint16_t GpsClockFlags; /** A valid 'leap second' is stored in the data structure. */ #define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) /** A valid 'time uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) /** A valid 'full bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_FULL_BIAS (1<<2) /** A valid 'bias' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS (1<<3) /** A valid 'bias uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) /** A valid 'drift' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT (1<<5) /** A valid 'drift uncertainty' is stored in the data structure. */ #define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) /** * Enumeration of the available values for the GPS Clock type. */ typedef uint8_t GpsClockType; /** The type is not available ot it is unknown. */ #define GPS_CLOCK_TYPE_UNKNOWN 0 /** The source of the time value reported by GPS clock is the local hardware clock. */ #define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 /** * The source of the time value reported by GPS clock is the GPS time derived from satellites * (epoch = Jan 6, 1980) */ #define GPS_CLOCK_TYPE_GPS_TIME 2 /** * Flags to indicate what fields in GpsMeasurement are valid. */ typedef uint32_t GpsMeasurementFlags; /** A valid 'snr' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_SNR (1<<0) /** A valid 'elevation' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) /** A valid 'elevation uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) /** A valid 'azimuth' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) /** A valid 'azimuth uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) /** A valid 'pseudorange' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) /** A valid 'pseudorange uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) /** A valid 'code phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) /** A valid 'code phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) /** A valid 'carrier frequency' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) /** A valid 'carrier cycles' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) /** A valid 'carrier phase' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) /** A valid 'carrier phase uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) /** A valid 'bit number' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) /** A valid 'time from last bit' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) /** A valid 'doppler shift' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) /** A valid 'doppler shift uncertainty' is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) /** A valid 'used in fix' flag is stored in the data structure. */ #define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) /** The value of 'pseudorange rate' is uncorrected. */ #define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) /** * Enumeration of the available values for the GPS Measurement's loss of lock. */ typedef uint8_t GpsLossOfLock; /** The indicator is not available or it is unknown. */ #define GPS_LOSS_OF_LOCK_UNKNOWN 0 /** The measurement does not present any indication of loss of lock. */ #define GPS_LOSS_OF_LOCK_OK 1 /** Loss of lock between previous and current observation: cycle slip possible. */ #define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 /** * Enumeration of available values for the GPS Measurement's multipath indicator. */ typedef uint8_t GpsMultipathIndicator; /** The indicator is not available or unknown. */ #define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 /** The measurement has been indicated to use multipath. */ #define GPS_MULTIPATH_INDICATOR_DETECTED 1 /** The measurement has been indicated Not to use multipath. */ #define GPS_MULTIPATH_INDICATOR_NOT_USED 2 /** * Flags indicating the GPS measurement state. * The expected behavior here is for GPS HAL to set all the flags that applies. For * example, if the state for a satellite is only C/A code locked and bit synchronized, * and there is still millisecond ambiguity, the state should be set as: * GPS_MEASUREMENT_STATE_CODE_LOCK|GPS_MEASUREMENT_STATE_BIT_SYNC|GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS * If GPS is still searching for a satellite, the corresponding state should be set to * GPS_MEASUREMENT_STATE_UNKNOWN(0). */ typedef uint16_t GpsMeasurementState; #define GPS_MEASUREMENT_STATE_UNKNOWN 0 #define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) #define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) #define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) #define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) #define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) /** * Flags indicating the Accumulated Delta Range's states. */ typedef uint16_t GpsAccumulatedDeltaRangeState; #define GPS_ADR_STATE_UNKNOWN 0 #define GPS_ADR_STATE_VALID (1<<0) #define GPS_ADR_STATE_RESET (1<<1) #define GPS_ADR_STATE_CYCLE_SLIP (1<<2) /** * Enumeration of available values to indicate the available GPS Navigation message types. */ typedef uint8_t GpsNavigationMessageType; /** The message type is unknown. */ #define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 /** L1 C/A message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 /** L2-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 /** L5-CNAV message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 /** CNAV-2 message contained in the structure. */ #define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 /** * Status of Navigation Message * When a message is received properly without any parity error in its navigation words, the * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received * with words that failed parity check, but GPS is able to correct those words, the status * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. * No need to send any navigation message that contains words with parity error and cannot be * corrected. */ typedef uint16_t NavigationMessageStatus; #define NAV_MESSAGE_STATUS_UNKONW 0 #define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) #define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) /** * Name for the GPS XTRA interface. */ #define GPS_XTRA_INTERFACE "gps-xtra" /** * Name for the GPS DEBUG interface. */ #define GPS_DEBUG_INTERFACE "gps-debug" /** * Name for the AGPS interface. */ #define AGPS_INTERFACE "agps" /** * Name of the Supl Certificate interface. */ #define SUPL_CERTIFICATE_INTERFACE "supl-certificate" /** * Name for NI interface */ #define GPS_NI_INTERFACE "gps-ni" /** * Name for the AGPS-RIL interface. */ #define AGPS_RIL_INTERFACE "agps_ril" /** * Name for the GPS_Geofencing interface. */ #define GPS_GEOFENCING_INTERFACE "gps_geofencing" /** * Name of the GPS Measurements interface. */ #define GPS_MEASUREMENT_INTERFACE "gps_measurement" /** * Name of the GPS navigation message interface. */ #define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" /** * Name of the GNSS/GPS configuration interface. */ #define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" /** Represents a location. */ typedef struct { /** set to sizeof(GpsLocation) */ size_t size; /** Contains GpsLocationFlags bits. */ uint16_t flags; /** Represents latitude in degrees. */ double latitude; /** Represents longitude in degrees. */ double longitude; /** Represents altitude in meters above the WGS 84 reference * ellipsoid. */ double altitude; /** Represents speed in meters per second. */ float speed; /** Represents heading in degrees. */ float bearing; /** Represents expected accuracy in meters. */ float accuracy; /** Timestamp for the location fix. */ GpsUtcTime timestamp; } GpsLocation; /** Represents the status. */ typedef struct { /** set to sizeof(GpsStatus) */ size_t size; GpsStatusValue status; } GpsStatus; /** Represents SV information. */ typedef struct { /** set to sizeof(GpsSvInfo) */ size_t size; /** Pseudo-random number for the SV. */ int prn; /** Signal to noise ratio. */ float snr; /** Elevation of SV in degrees. */ float elevation; /** Azimuth of SV in degrees. */ float azimuth; } GpsSvInfo; /** Represents SV status. */ typedef struct { /** set to sizeof(GpsSvStatus) */ size_t size; /** Number of SVs currently visible. */ int num_svs; /** Contains an array of SV information. */ GpsSvInfo sv_list[GPS_MAX_SVS]; /** Represents a bit mask indicating which SVs * have ephemeris data. */ uint32_t ephemeris_mask; /** Represents a bit mask indicating which SVs * have almanac data. */ uint32_t almanac_mask; /** * Represents a bit mask indicating which SVs * were used for computing the most recent position fix. */ uint32_t used_in_fix_mask; } GpsSvStatus; /* 2G and 3G */ /* In 3G lac is discarded */ typedef struct { uint16_t type; uint16_t mcc; uint16_t mnc; uint16_t lac; uint32_t cid; } AGpsRefLocationCellID; typedef struct { uint8_t mac[6]; } AGpsRefLocationMac; /** Represents ref locations */ typedef struct { uint16_t type; union { AGpsRefLocationCellID cellID; AGpsRefLocationMac mac; } u; } AGpsRefLocation; /** Callback with location information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_status_callback)(GpsStatus* status); /** * Callback with SV status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** Callback for reporting NMEA sentences. * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); /** Callback to inform framework of the GPS engine's capabilities. * Capability parameter is a bit field of GPS_CAPABILITY_* flags. */ typedef void (* gps_set_capabilities)(uint32_t capabilities); /** Callback utility for acquiring the GPS wakelock. * This can be used to prevent the CPU from suspending while handling GPS events. */ typedef void (* gps_acquire_wakelock)(); /** Callback utility for releasing the GPS wakelock. */ typedef void (* gps_release_wakelock)(); /** Callback for requesting NTP time */ typedef void (* gps_request_utc_time)(); /** Callback for creating a thread that can call into the Java framework code. * This must be used to create any threads that report events up to the framework. */ typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); /** GPS callback structure. */ typedef struct { /** set to sizeof(GpsCallbacks) */ size_t size; gps_location_callback location_cb; gps_status_callback status_cb; gps_sv_status_callback sv_status_cb; gps_nmea_callback nmea_cb; gps_set_capabilities set_capabilities_cb; gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; gps_create_thread create_thread_cb; gps_request_utc_time request_utc_time_cb; } GpsCallbacks; /** Represents the standard GPS interface. */ typedef struct { /** set to sizeof(GpsInterface) */ size_t size; /** * Opens the interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsCallbacks* callbacks ); /** Starts navigating. */ int (*start)( void ); /** Stops navigating. */ int (*stop)( void ); /** Closes the interface. */ void (*cleanup)( void ); /** Injects the current time. */ int (*inject_time)(GpsUtcTime time, int64_t timeReference, int uncertainty); /** Injects current location from another location provider * (typically cell ID). * latitude and longitude are measured in degrees * expected accuracy is measured in meters */ int (*inject_location)(double latitude, double longitude, float accuracy); /** * Specifies that the next call to start will not use the * information defined in the flags. GPS_DELETE_ALL is passed for * a cold start. */ void (*delete_aiding_data)(GpsAidingData flags); /** * min_interval represents the time between fixes in milliseconds. * preferred_accuracy represents the requested fix accuracy in meters. * preferred_time represents the requested time to first fix in milliseconds. * * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASE * or GPS_POSITION_MODE_STANDALONE. * It is allowed by the platform (and it is recommended) to fallback to * GPS_POSITION_MODE_MS_BASE if GPS_POSITION_MODE_MS_ASSISTED is passed in, and * GPS_POSITION_MODE_MS_BASED is supported. */ int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); /** Get a pointer to extension information. */ const void* (*get_extension)(const char* name); } GpsInterface; /** Callback to request the client to download XTRA data. * The client should download XTRA data and inject it by calling inject_xtra_data(). * Can only be called from a thread created by create_thread_cb. */ typedef void (* gps_xtra_download_request)(); /** Callback structure for the XTRA interface. */ typedef struct { gps_xtra_download_request download_request_cb; gps_create_thread create_thread_cb; } GpsXtraCallbacks; /** Extended interface for XTRA support. */ typedef struct { /** set to sizeof(GpsXtraInterface) */ size_t size; /** * Opens the XTRA interface and provides the callback routines * to the implementation of this interface. */ int (*init)( GpsXtraCallbacks* callbacks ); /** Injects XTRA data into the GPS. */ int (*inject_xtra_data)( char* data, int length ); } GpsXtraInterface; /** Extended interface for DEBUG support. */ typedef struct { /** set to sizeof(GpsDebugInterface) */ size_t size; /** * This function should return any information that the native * implementation wishes to include in a bugreport. */ size_t (*get_internal_state)(char* buffer, size_t bufferSize); } GpsDebugInterface; #pragma pack(push,4) // We need to keep the alignment of this data structure to 4-bytes, to ensure that in 64-bit // environments the size of this legacy definition does not collide with _v2. Implementations should // be using _v2 and _v3, so it's OK to pay the 'unaligned' penalty in 64-bit if an old // implementation is still in use. /** Represents the status of AGPS. */ typedef struct { /** set to sizeof(AGpsStatus_v1) */ size_t size; AGpsType type; AGpsStatusValue status; } AGpsStatus_v1; #pragma pack(pop) /** Represents the status of AGPS augmented with a IPv4 address field. */ typedef struct { /** set to sizeof(AGpsStatus_v2) */ size_t size; AGpsType type; AGpsStatusValue status; uint32_t ipaddr; } AGpsStatus_v2; /* Represents the status of AGPS augmented to support IPv4 and IPv6. */ typedef struct { /** set to sizeof(AGpsStatus_v3) */ size_t size; AGpsType type; AGpsStatusValue status; /** * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 * address, or set to INADDR_NONE otherwise. */ uint32_t ipaddr; /** * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. * Any other value of addr.ss_family will be rejected. * */ struct sockaddr_storage addr; } AGpsStatus_v3; typedef AGpsStatus_v3 AGpsStatus; /** Callback with AGPS status information. * Can only be called from a thread created by create_thread_cb. */ typedef void (* agps_status_callback)(AGpsStatus* status); /** Callback structure for the AGPS interface. */ typedef struct { agps_status_callback status_cb; gps_create_thread create_thread_cb; } AGpsCallbacks; /** Extended interface for AGPS support. */ typedef struct { /** set to sizeof(AGpsInterface_v1) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsCallbacks* callbacks ); /** * Notifies that a data connection is available and sets * the name of the APN to be used for SUPL. */ int (*data_conn_open)( const char* apn ); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)( AGpsType type, const char* hostname, int port ); } AGpsInterface_v1; /** * Extended interface for AGPS support, it is augmented to enable to pass * extra APN data. */ typedef struct { /** set to sizeof(AGpsInterface_v2) */ size_t size; /** * Opens the AGPS interface and provides the callback routines to the * implementation of this interface. */ void (*init)(AGpsCallbacks* callbacks); /** * Deprecated. * If the HAL supports AGpsInterface_v2 this API will not be used, see * data_conn_open_with_apn_ip_type for more information. */ int (*data_conn_open)(const char* apn); /** * Notifies that the AGPS data connection has been closed. */ int (*data_conn_closed)(); /** * Notifies that a data connection is not available for AGPS. */ int (*data_conn_failed)(); /** * Sets the hostname and port for the AGPS server. */ int (*set_server)(AGpsType type, const char* hostname, int port); /** * Notifies that a data connection is available and sets the name of the * APN, and its IP type, to be used for SUPL connections. */ int (*data_conn_open_with_apn_ip_type)( const char* apn, ApnIpType apnIpType); } AGpsInterface_v2; typedef AGpsInterface_v2 AGpsInterface; /** Error codes associated with certificate operations */ #define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 #define AGPS_CERTIFICATE_ERROR_GENERIC -100 #define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 /** A data structure that represents an X.509 certificate using DER encoding */ typedef struct { size_t length; u_char* data; } DerEncodedCertificate; /** * A type definition for SHA1 Fingerprints used to identify X.509 Certificates * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. */ typedef struct { u_char data[20]; } Sha1CertificateFingerprint; /** AGPS Interface to handle SUPL certificate operations */ typedef struct { /** set to sizeof(SuplCertificateInterface) */ size_t size; /** * Installs a set of Certificates used for SUPL connections to the AGPS server. * If needed the HAL should find out internally any certificates that need to be removed to * accommodate the certificates to install. * The certificates installed represent a full set of valid certificates needed to connect to * AGPS SUPL servers. * The list of certificates is required, and all must be available at the same time, when trying * to establish a connection with the AGPS Server. * * Parameters: * certificates - A pointer to an array of DER encoded certificates that are need to be * installed in the HAL. * length - The number of certificates to install. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of * certificates attempted to be installed, the state of the certificates stored should * remain the same as before on this error case. * * IMPORTANT: * If needed the HAL should find out internally the set of certificates that need to be * removed to accommodate the certificates to install. */ int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); /** * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is * expected that the given set of certificates is removed from the internal store of the HAL. * * Parameters: * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of * certificates to revoke. * length - The number of fingerprints provided. * Returns: * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. * * IMPORTANT: * If any of the certificates provided (through its fingerprint) is not known by the HAL, * it should be ignored and continue revoking/deleting the rest of them. */ int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); } SuplCertificateInterface; /** Represents an NI request */ typedef struct { /** set to sizeof(GpsNiNotification) */ size_t size; /** * An ID generated by HAL to associate NI notifications and UI * responses */ int notification_id; /** * An NI type used to distinguish different categories of NI * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... */ GpsNiType ni_type; /** * Notification/verification options, combinations of GpsNiNotifyFlags constants */ GpsNiNotifyFlags notify_flags; /** * Timeout period to wait for user response. * Set to 0 for no time out limit. */ int timeout; /** * Default response when time out. */ GpsUserResponseType default_response; /** * Requestor ID */ char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; /** * Notification message. It can also be used to store client_id in some cases */ char text[GPS_NI_LONG_STRING_MAXLEN]; /** * Client name decoding scheme */ GpsNiEncodingType requestor_id_encoding; /** * Client name decoding scheme */ GpsNiEncodingType text_encoding; /** * A pointer to extra data. Format: * key_1 = value_1 * key_2 = value_2 */ char extras[GPS_NI_LONG_STRING_MAXLEN]; } GpsNiNotification; /** Callback with NI notification. * Can only be called from a thread created by create_thread_cb. */ typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); /** GPS NI callback structure. */ typedef struct { /** * Sends the notification request from HAL to GPSLocationProvider. */ gps_ni_notify_callback notify_cb; gps_create_thread create_thread_cb; } GpsNiCallbacks; /** * Extended interface for Network-initiated (NI) support. */ typedef struct { /** set to sizeof(GpsNiInterface) */ size_t size; /** Registers the callbacks for HAL to use. */ void (*init) (GpsNiCallbacks *callbacks); /** Sends a response to HAL. */ void (*respond) (int notif_id, GpsUserResponseType user_response); } GpsNiInterface; struct gps_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); }; #define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) #define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) #define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) #define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) typedef void (*agps_ril_request_set_id)(uint32_t flags); typedef void (*agps_ril_request_ref_loc)(uint32_t flags); typedef struct { agps_ril_request_set_id request_setid; agps_ril_request_ref_loc request_refloc; gps_create_thread create_thread_cb; } AGpsRilCallbacks; /** Extended interface for AGPS_RIL support. */ typedef struct { /** set to sizeof(AGpsRilInterface) */ size_t size; /** * Opens the AGPS interface and provides the callback routines * to the implementation of this interface. */ void (*init)( AGpsRilCallbacks* callbacks ); /** * Sets the reference location. */ void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); /** * Sets the set ID. */ void (*set_set_id) (AGpsSetIDType type, const char* setid); /** * Send network initiated message. */ void (*ni_message) (uint8_t *msg, size_t len); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); /** * Notify GPS of network status changes. * These parameters match values in the android.net.NetworkInfo class. */ void (*update_network_availability) (int avaiable, const char* apn); } AGpsRilInterface; /** * GPS Geofence. * There are 3 states associated with a Geofence: Inside, Outside, Unknown. * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. * * An example state diagram with confidence level: 95% and Unknown time limit * set as 30 secs is shown below. (confidence level and Unknown time limit are * explained latter) * ____________________________ * | Unknown (30 secs) | * """""""""""""""""""""""""""" * ^ | | ^ * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN * | v v | * ________ EXITED _________ * | Inside | -----------> | Outside | * | | <----------- | | * """""""" ENTERED """"""""" * * Inside state: We are 95% confident that the user is inside the geofence. * Outside state: We are 95% confident that the user is outside the geofence * Unknown state: Rest of the time. * * The Unknown state is better explained with an example: * * __________ * | c| * | ___ | _______ * | |a| | | b | * | """ | """"""" * | | * """""""""" * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy * circle reported by the GPS subsystem. Now with regard to "b", the system is * confident that the user is outside. But with regard to "a" is not confident * whether it is inside or outside the geofence. If the accuracy remains the * same for a sufficient period of time, the UNCERTAIN transition would be * triggered with the state set to Unknown. If the accuracy improves later, an * appropriate transition should be triggered. This "sufficient period of time" * is defined by the parameter in the add_geofence_area API. * In other words, Unknown state can be interpreted as a state in which the * GPS subsystem isn't confident enough that the user is either inside or * outside the Geofence. It moves to Unknown state only after the expiry of the * timeout. * * The geofence callback needs to be triggered for the ENTERED and EXITED * transitions, when the GPS system is confident that the user has entered * (Inside state) or exited (Outside state) the Geofence. An implementation * which uses a value of 95% as the confidence is recommended. The callback * should be triggered only for the transitions requested by the * add_geofence_area call. * * Even though the diagram and explanation talks about states and transitions, * the callee is only interested in the transistions. The states are mentioned * here for illustrative purposes. * * Startup Scenario: When the device boots up, if an application adds geofences, * and then we get an accurate GPS location fix, it needs to trigger the * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. * By default, all the Geofences will be in the Unknown state. * * When the GPS system is unavailable, gps_geofence_status_callback should be * called to inform the upper layers of the same. Similarly, when it becomes * available the callback should be called. This is a global state while the * UNKNOWN transition described above is per geofence. * * An important aspect to note is that users of this API (framework), will use * other subsystems like wifi, sensors, cell to handle Unknown case and * hopefully provide a definitive state transition to the third party * application. GPS Geofence will just be a signal indicating what the GPS * subsystem knows about the Geofence. * */ #define GPS_GEOFENCE_ENTERED (1<<0L) #define GPS_GEOFENCE_EXITED (1<<1L) #define GPS_GEOFENCE_UNCERTAIN (1<<2L) #define GPS_GEOFENCE_UNAVAILABLE (1<<0L) #define GPS_GEOFENCE_AVAILABLE (1<<1L) #define GPS_GEOFENCE_OPERATION_SUCCESS 0 #define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100 #define GPS_GEOFENCE_ERROR_ID_EXISTS -101 #define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102 #define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103 #define GPS_GEOFENCE_ERROR_GENERIC -149 /** * The callback associated with the geofence. * Parameters: * geofence_id - The id associated with the add_geofence_area. * location - The current GPS location. * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, * GPS_GEOFENCE_UNCERTAIN. * timestamp - Timestamp when the transition was detected. * * The callback should only be called when the caller is interested in that * particular transition. For instance, if the caller is interested only in * ENTERED transition, then the callback should NOT be called with the EXITED * transition. * * IMPORTANT: If a transition is triggered resulting in this callback, the GPS * subsystem will wake up the application processor, if its in suspend state. */ typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, int32_t transition, GpsUtcTime timestamp); /** * The callback associated with the availability of the GPS system for geofencing * monitoring. If the GPS system determines that it cannot monitor geofences * because of lack of reliability or unavailability of the GPS signals, it will * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. * * Parameters: * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. * last_location - Last known location. */ typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); /** * The callback associated with the add_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an * invalid transition * GPS_GEOFENCE_ERROR_GENERIC - for other errors. */ typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the remove_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the pause_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - * when monitor_transitions is invalid * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); /** * The callback associated with the resume_geofence call. * * Parameter: * geofence_id - Id of the geofence. * status - GPS_GEOFENCE_OPERATION_SUCCESS * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id * GPS_GEOFENCE_ERROR_GENERIC for others. */ typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); typedef struct { gps_geofence_transition_callback geofence_transition_callback; gps_geofence_status_callback geofence_status_callback; gps_geofence_add_callback geofence_add_callback; gps_geofence_remove_callback geofence_remove_callback; gps_geofence_pause_callback geofence_pause_callback; gps_geofence_resume_callback geofence_resume_callback; gps_create_thread create_thread_cb; } GpsGeofenceCallbacks; /** Extended interface for GPS_Geofencing support */ typedef struct { /** set to sizeof(GpsGeofencingInterface) */ size_t size; /** * Opens the geofence interface and provides the callback routines * to the implementation of this interface. */ void (*init)( GpsGeofenceCallbacks* callbacks ); /** * Add a geofence area. This api currently supports circular geofences. * Parameters: * geofence_id - The id for the geofence. If a geofence with this id * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) * should be returned. * latitude, longtitude, radius_meters - The lat, long and radius * (in meters) for the geofence * last_transition - The current state of the geofence. For example, if * the system already knows that the user is inside the geofence, * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it * will be GPS_GEOFENCE_UNCERTAIN. * monitor_transition - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * notification_responsiveness_ms - Defines the best-effort description * of how soon should the callback be called when the transition * associated with the Geofence is triggered. For instance, if set * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback * should be called 1000 milliseconds within entering the geofence. * This parameter is defined in milliseconds. * NOTE: This is not to be confused with the rate that the GPS is * polled at. It is acceptable to dynamically vary the rate of * sampling the GPS for power-saving reasons; thus the rate of * sampling may be faster or slower than this. * unknown_timer_ms - The time limit after which the UNCERTAIN transition * should be triggered. This parameter is defined in milliseconds. * See above for a detailed explanation. */ void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, double radius_meters, int last_transition, int monitor_transitions, int notification_responsiveness_ms, int unknown_timer_ms); /** * Pause monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. */ void (*pause_geofence) (int32_t geofence_id); /** * Resume monitoring a particular geofence. * Parameters: * geofence_id - The id for the geofence. * monitor_transitions - Which transitions to monitor. Bitwise OR of * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and * GPS_GEOFENCE_UNCERTAIN. * This supersedes the value associated provided in the * add_geofence_area call. */ void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); /** * Remove a geofence area. After the function returns, no notifications * should be sent. * Parameter: * geofence_id - The id for the geofence. */ void (*remove_geofence_area) (int32_t geofence_id); } GpsGeofencingInterface; /** * Represents an estimate of the GPS clock time. */ typedef struct { /** set to sizeof(GpsClock) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsClockFlags flags; /** * Leap second data. * The sign of the value is defined by the following equation: * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 * * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND. */ int16_t leap_second; /** * Indicates the type of time reported by the 'time_ns' field. * This is a Mandatory field. */ GpsClockType type; /** * The GPS receiver internal clock value. This can be either the local hardware clock value * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported. * * For local hardware clock, this value is expected to be monotonically increasing during * the reporting session. The real GPS time can be derived by compensating the 'full bias' * (when it is available) from this value. * * For GPS time, this value is expected to be the best estimation of current GPS time that GPS * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified. * * Sub-nanosecond accuracy can be provided by means of the 'bias' field. * The value contains the 'time uncertainty' in it. * * This is a Mandatory field. */ int64_t time_ns; /** * 1-Sigma uncertainty associated with the clock's time in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set. * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY. */ double time_uncertainty_ns; /** * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS * time since 0000Z, January 6, 1980, in nanoseconds. * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver * has solved the clock for GPS time. * The caller is responsible for using the 'bias uncertainty' field for quality check. * * The sign of the value is defined by the following equation: * true time (GPS time) = time_ns + (full_bias_ns + bias_ns) * * This value contains the 'bias uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS. */ int64_t full_bias_ns; /** * Sub-nanosecond bias. * The value contains the 'bias uncertainty' in it. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS. */ double bias_ns; /** * 1-Sigma uncertainty associated with the clock's bias in nanoseconds. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY. */ double bias_uncertainty_ns; /** * The clock's drift in nanoseconds (per second). * A positive value means that the frequency is higher than the nominal frequency. * * The value contains the 'drift uncertainty' in it. * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. * * If GpsMeasurement's 'flags' field contains GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE, * it is encouraged that this field is also provided. */ double drift_nsps; /** * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). * The uncertainty is represented as an absolute (single sided) value. * * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY. */ double drift_uncertainty_nsps; } GpsClock; /** * Represents a GPS Measurement, it contains raw and computed information. */ typedef struct { /** set to sizeof(GpsMeasurement) */ size_t size; /** A set of flags indicating the validity of the fields in this data structure. */ GpsMeasurementFlags flags; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * Time offset at which the measurement was taken in nanoseconds. * The reference receiver's time is specified by GpsData::clock::time_ns and should be * interpreted in the same way as indicated by GpsClock::type. * * The sign of time_offset_ns is given by the following equation: * measurement time = GpsClock::time_ns + time_offset_ns * * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. * This is a Mandatory value. */ double time_offset_ns; /** * Per satellite sync state. It represents the current sync state for the associated satellite. * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. * * This is a Mandatory value. */ GpsMeasurementState state; /** * Received GPS Time-of-Week at the measurement time, in nanoseconds. * The value is relative to the beginning of the current GPS week. * * Given the highest sync state that can be achieved, per each satellite, valid range for * this field can be: * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN * C/A code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set * Subframe sync : [ 0 6s ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set * * However, if there is any ambiguity in integer millisecond, * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. * * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. */ int64_t received_gps_tow_ns; /** * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. * * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. */ int64_t received_gps_tow_uncertainty_ns; /** * Carrier-to-noise density in dB-Hz, in the range [0, 63]. * It contains the measured C/N0 value for the signal at the antenna input. * * This is a Mandatory value. */ double c_n0_dbhz; /** * Pseudorange rate at the timestamp in m/s. * The correction of a given Pseudorange Rate value includes corrections for receiver and * satellite clock frequency errors. * * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is set in 'flags' field, this field must * be populated with the 'uncorrected' reading. * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is not set in 'flags' field, this field * must be populated with the 'corrected' reading. This is the default behavior. * * It is encouraged to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's * 'drift' field as well. * * The value includes the 'pseudorange rate uncertainty' in it. * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. * * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler * shift' is given by the equation: * pseudorange rate = -k * doppler shift (where k is a constant) * * This is a Mandatory value. */ double pseudorange_rate_mps; /** * 1-Sigma uncertainty of the pseudurange rate in m/s. * The uncertainty is represented as an absolute (single sided) value. * * This is a Mandatory value. */ double pseudorange_rate_uncertainty_mps; /** * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip * (indicating loss of lock). * * This is a Mandatory value. */ GpsAccumulatedDeltaRangeState accumulated_delta_range_state; /** * Accumulated delta range since the last channel reset in meters. * A positive value indicates that the SV is moving away from the receiver. * * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' * is given by the equation: * accumulated delta range = -k * carrier phase (where k is a constant) * * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. * However, it is expected that the data is only accurate when: * 'accumulated delta range state' == GPS_ADR_STATE_VALID. */ double accumulated_delta_range_m; /** * 1-Sigma uncertainty of the accumulated delta range in meters. * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. */ double accumulated_delta_range_uncertainty_m; /** * Best derived Pseudorange by the chip-set, in meters. * The value contains the 'pseudorange uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE. */ double pseudorange_m; /** * 1-Sigma uncertainty of the pseudorange in meters. * The value contains the 'pseudorange' and 'clock' uncertainty in it. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY. */ double pseudorange_uncertainty_m; /** * A fraction of the current C/A code cycle, in the range [0.0, 1023.0] * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch). * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'code-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE. */ double code_phase_chips; /** * 1-Sigma uncertainty of the code-phase, in a fraction of chips. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY. */ double code_phase_uncertainty_chips; /** * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. * If the field is not set, the carrier frequency is assumed to be L1. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY. */ float carrier_frequency_hz; /** * The number of full carrier cycles between the satellite and the receiver. * The reference frequency is given by the field 'carrier_frequency_hz'. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES. */ int64_t carrier_cycles; /** * The RF phase detected by the receiver, in the range [0.0, 1.0]. * This is usually the fractional part of the complete carrier phase measurement. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'carrier-phase uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE. */ double carrier_phase; /** * 1-Sigma uncertainty of the carrier-phase. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. */ double carrier_phase_uncertainty; /** * An enumeration that indicates the 'loss of lock' state of the event. */ GpsLossOfLock loss_of_lock; /** * The number of GPS bits transmitted since Sat-Sun midnight (GPS week). * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER. */ int32_t bit_number; /** * The elapsed time since the last received bit in milliseconds, in the range [0, 20] * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT. */ int16_t time_from_last_bit_ms; /** * Doppler shift in Hz. * A positive value indicates that the SV is moving toward the receiver. * * The reference frequency is given by the field 'carrier_frequency_hz'. * The value contains the 'doppler shift uncertainty' in it. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT. */ double doppler_shift_hz; /** * 1-Sigma uncertainty of the doppler shift in Hz. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY. */ double doppler_shift_uncertainty_hz; /** * An enumeration that indicates the 'multipath' state of the event. */ GpsMultipathIndicator multipath_indicator; /** * Signal-to-noise ratio in dB. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR. */ double snr_db; /** * Elevation in degrees, the valid range is [-90, 90]. * The value contains the 'elevation uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION. */ double elevation_deg; /** * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90]. * The uncertainty is represented as the absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY. */ double elevation_uncertainty_deg; /** * Azimuth in degrees, in the range [0, 360). * The value contains the 'azimuth uncertainty' in it. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH. * */ double azimuth_deg; /** * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180]. * The uncertainty is represented as an absolute (single sided) value. * * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY. */ double azimuth_uncertainty_deg; /** * Whether the GPS represented by the measurement was used for computing the most recent fix. * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX. */ bool used_in_fix; } GpsMeasurement; /** Represents a reading of GPS measurements. */ typedef struct { /** set to sizeof(GpsData) */ size_t size; /** Number of measurements. */ size_t measurement_count; /** The array of measurements. */ GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; /** The GPS clock time reading. */ GpsClock clock; } GpsData; /** * The callback for to report measurements from the HAL. * * Parameters: * data - A data structure containing the measurements. */ typedef void (*gps_measurement_callback) (GpsData* data); typedef struct { /** set to sizeof(GpsMeasurementCallbacks) */ size_t size; gps_measurement_callback measurement_callback; } GpsMeasurementCallbacks; #define GPS_MEASUREMENT_OPERATION_SUCCESS 0 #define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100 #define GPS_MEASUREMENT_ERROR_GENERIC -101 /** * Extended interface for GPS Measurements support. */ typedef struct { /** Set to sizeof(GpsMeasurementInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates at its own phase. * * Status: * GPS_MEASUREMENT_OPERATION_SUCCESS * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a * corresponding call to 'close' * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL * will not generate any updates upon returning this error code. */ int (*init) (GpsMeasurementCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsMeasurementInterface; /** Represents a GPS navigation message (or a fragment of it). */ typedef struct { /** set to sizeof(GpsNavigationMessage) */ size_t size; /** * Pseudo-random number in the range of [1, 32] * This is a Mandatory value. */ int8_t prn; /** * The type of message contained in the structure. * This is a Mandatory value. */ GpsNavigationMessageType type; /** * The status of the received navigation message. * No need to send any navigation message that contains words with parity error and cannot be * corrected. */ NavigationMessageStatus status; /** * Message identifier. * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1. */ int16_t message_id; /** * Sub-message identifier. * If required by the message 'type', this value contains a sub-index within the current * message (or frame) that is being transmitted. * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message. */ int16_t submessage_id; /** * The length of the data (in bytes) contained in the current message. * If this value is different from zero, 'data' must point to an array of the same size. * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). * * This is a Mandatory value. */ size_t data_length; /** * The data of the reported GPS message. * The bytes (or words) specified using big endian format (MSB first). * * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first. */ uint8_t* data; } GpsNavigationMessage; /** * The callback to report an available fragment of a GPS navigation messages from the HAL. * * Parameters: * message - The GPS navigation submessage/subframe representation. */ typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); typedef struct { /** set to sizeof(GpsNavigationMessageCallbacks) */ size_t size; gps_navigation_message_callback navigation_message_callback; } GpsNavigationMessageCallbacks; #define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0 #define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100 #define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101 /** * Extended interface for GPS navigation message reporting support. */ typedef struct { /** Set to sizeof(GpsNavigationMessageInterface) */ size_t size; /** * Initializes the interface and registers the callback routines with the HAL. * After a successful call to 'init' the HAL must begin to provide updates as they become * available. * * Status: * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered * without a corresponding call to 'close'. * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that * the HAL will not generate any updates upon returning this error code. */ int (*init) (GpsNavigationMessageCallbacks* callbacks); /** * Stops updates from the HAL, and unregisters the callback routines. * After a call to stop, the previously registered callbacks must be considered invalid by the * HAL. * If stop is invoked without a previous 'init', this function should perform no work. */ void (*close) (); } GpsNavigationMessageInterface; /** * Interface for passing GNSS configuration contents from platform to HAL. */ typedef struct { /** Set to sizeof(GnssConfigurationInterface) */ size_t size; /** * Deliver GNSS configuration contents to HAL. * Parameters: * config_data - a pointer to a char array which holds what usually is expected from file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. * length - total number of UTF8 characters in configuraiton data. * * IMPORTANT: * GPS HAL should expect this function can be called multiple times. And it may be * called even when GpsLocationProvider is already constructed and enabled. GPS HAL * should maintain the existing requests for various callback regardless the change * in configuration data. */ void (*configuration_update) (const char* config_data, int32_t length); } GnssConfigurationInterface; __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/gralloc.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_GRALLOC_INTERFACE_H #define ANDROID_GRALLOC_INTERFACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * Module versioning information for the Gralloc hardware module, based on * gralloc_module_t.common.module_api_version. * * Version History: * * GRALLOC_MODULE_API_VERSION_0_1: * Initial Gralloc hardware module API. * * GRALLOC_MODULE_API_VERSION_0_2: * Add support for flexible YCbCr format with (*lock_ycbcr)() method. * * GRALLOC_MODULE_API_VERSION_0_3: * Add support for fence passing to/from lock/unlock. */ #define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) #define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /** * The id of this module */ #define GRALLOC_HARDWARE_MODULE_ID "gralloc" /** * Name of the graphics device to open */ #define GRALLOC_HARDWARE_GPU0 "gpu0" enum { /* buffer is never read in software */ GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, /* buffer is rarely read in software */ GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, /* buffer is often read in software */ GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, /* mask for the software read values */ GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, /* buffer is never written in software */ GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, /* buffer is rarely written in software */ GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, /* buffer is often written in software */ GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, /* mask for the software write values */ GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, /* buffer will be used as an OpenGL ES texture */ GRALLOC_USAGE_HW_TEXTURE = 0x00000100, /* buffer will be used as an OpenGL ES render target */ GRALLOC_USAGE_HW_RENDER = 0x00000200, /* buffer will be used by the 2D hardware blitter */ GRALLOC_USAGE_HW_2D = 0x00000400, /* buffer will be used by the HWComposer HAL module */ GRALLOC_USAGE_HW_COMPOSER = 0x00000800, /* buffer will be used with the framebuffer device */ GRALLOC_USAGE_HW_FB = 0x00001000, /* buffer should be displayed full-screen on an external display when * possible */ GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, /* Must have a hardware-protected path to external display sink for * this buffer. If a hardware-protected path is not available, then * either don't composite only this buffer (preferred) to the * external sink, or (less desirable) do not route the entire * composition to the external sink. */ GRALLOC_USAGE_PROTECTED = 0x00004000, /* buffer may be used as a cursor */ GRALLOC_USAGE_CURSOR = 0x00008000, /* buffer will be used with the HW video encoder */ GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, /* buffer will be written by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, /* buffer will be read by the HW camera pipeline */ GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, /* buffer will be used as part of zero-shutter-lag queue */ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, /* mask for the camera access values */ GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, /* mask for the software usage bit-mask */ GRALLOC_USAGE_HW_MASK = 0x00071F00, /* buffer will be used as a RenderScript Allocation */ GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, /* Set by the consumer to indicate to the producer that they may attach a * buffer that they did not detach from the BufferQueue. Will be filtered * out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to * handle this flag. */ GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000, /* Mask of all flags which could be passed to a gralloc module for buffer * allocation. Any flags not in this mask do not need to be handled by * gralloc modules. */ GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS), /* implementation-specific private usage flags */ GRALLOC_USAGE_PRIVATE_0 = 0x10000000, GRALLOC_USAGE_PRIVATE_1 = 0x20000000, GRALLOC_USAGE_PRIVATE_2 = 0x40000000, GRALLOC_USAGE_PRIVATE_3 = 0x80000000, GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000, #ifdef EXYNOS4_ENHANCEMENTS /* SAMSUNG */ GRALLOC_USAGE_PRIVATE_NONECACHE = 0x00800000, GRALLOC_USAGE_HW_FIMC1 = 0x01000000, GRALLOC_USAGE_HW_ION = 0x02000000, GRALLOC_USAGE_YUV_ADDR = 0x04000000, GRALLOC_USAGE_CAMERA = 0x08000000, /* SEC Private usage , for Overlay path at HWC */ GRALLOC_USAGE_HWC_HWOVERLAY = 0x20000000, #endif }; /*****************************************************************************/ /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct gralloc_module_t { struct hw_module_t common; /* * (*registerBuffer)() must be called before a buffer_handle_t that has not * been created with (*alloc_device_t::alloc)() can be used. * * This is intended to be used with buffer_handle_t's that have been * received in this process through IPC. * * This function checks that the handle is indeed a valid one and prepares * it for use with (*lock)() and (*unlock)(). * * It is not necessary to call (*registerBuffer)() on a handle created * with (*alloc_device_t::alloc)(). * * returns an error if this buffer_handle_t is not valid. */ int (*registerBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * (*unregisterBuffer)() is called once this handle is no longer needed in * this process. After this call, it is an error to call (*lock)(), * (*unlock)(), or (*registerBuffer)(). * * This function doesn't close or free the handle itself; this is done * by other means, usually through libcutils's native_handle_close() and * native_handle_free(). * * It is an error to call (*unregisterBuffer)() on a buffer that wasn't * explicitly registered first. */ int (*unregisterBuffer)(struct gralloc_module_t const* module, buffer_handle_t handle); /* * The (*lock)() method is called before a buffer is accessed for the * specified usage. This call may block, for instance if the h/w needs * to finish rendering or if CPU caches need to be synchronized. * * The caller promises to modify only pixels in the area specified * by (l,t,w,h). * * The content of the buffer outside of the specified area is NOT modified * by this call. * * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address * of the buffer in virtual memory. * * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() * instead. * * THREADING CONSIDERATIONS: * * It is legal for several different threads to lock a buffer from * read access, none of the threads are blocked. * * However, locking a buffer simultaneously for write or read/write is * undefined, but: * - shall not result in termination of the process * - shall not block the caller * It is acceptable to return an error or to leave the buffer's content * into an indeterminate state. * * If the buffer was created with a usage mask incompatible with the * requested usage flags here, -EINVAL is returned. * */ int (*lock)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr); /* * The (*unlock)() method must be called after all changes to the buffer * are completed. */ int (*unlock)(struct gralloc_module_t const* module, buffer_handle_t handle); #ifdef EXYNOS4_ENHANCEMENTS int (*getphys) (struct gralloc_module_t const* module, buffer_handle_t handle, void** paddr); #endif /* reserved for future use */ int (*perform)(struct gralloc_module_t const* module, int operation, ... ); /* * The (*lock_ycbcr)() method is like the (*lock)() method, with the * difference that it fills a struct ycbcr with a description of the buffer * layout, and zeroes out the reserved fields. * * If the buffer format is not compatible with a flexible YUV format (e.g. * the buffer layout cannot be represented with the ycbcr struct), it * will return -EINVAL. * * This method must work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888 * if supported by the device, as well as with any other format that is * requested by the multimedia codecs when they are configured with a * flexible-YUV-compatible color-format with android native buffers. * * Note that this method may also be called on buffers of other formats, * including non-YUV formats. * * Added in GRALLOC_MODULE_API_VERSION_0_2. */ int (*lock_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr); /* * The (*lockAsync)() method is like the (*lock)() method except * that the buffer's sync fence object is passed into the lock * call instead of requiring the caller to wait for completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr, int fenceFd); /* * The (*unlockAsync)() method is like the (*unlock)() method * except that a buffer sync fence object is returned from the * lock call, representing the completion of any pending work * performed by the gralloc implementation. * * The caller takes ownership of the fenceFd and is responsible * for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*unlockAsync)(struct gralloc_module_t const* module, buffer_handle_t handle, int* fenceFd); /* * The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)() * method except that the buffer's sync fence object is passed * into the lock call instead of requiring the caller to wait for * completion. * * The gralloc implementation takes ownership of the fenceFd and * is responsible for closing it when no longer needed. * * Added in GRALLOC_MODULE_API_VERSION_0_3. */ int (*lockAsync_ycbcr)(struct gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, struct android_ycbcr *ycbcr, int fenceFd); /* reserved for future use */ void* reserved_proc[3]; } gralloc_module_t; /*****************************************************************************/ /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct alloc_device_t { struct hw_device_t common; /* * (*alloc)() Allocates a buffer in graphic memory with the requested * parameters and returns a buffer_handle_t and the stride in pixels to * allow the implementation to satisfy hardware constraints on the width * of a pixmap (eg: it may have to be multiple of 8 pixels). * The CALLER TAKES OWNERSHIP of the buffer_handle_t. * * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be * 0, since the actual strides are available from the android_ycbcr * structure. * * Returns 0 on success or -errno on error. */ int (*alloc)(struct alloc_device_t* dev, int w, int h, int format, int usage, buffer_handle_t* handle, int* stride); /* * (*free)() Frees a previously allocated buffer. * Behavior is undefined if the buffer is still mapped in any process, * but shall not result in termination of the program or security breaches * (allowing a process to get access to another process' buffers). * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes * invalid after the call. * * Returns 0 on success or -errno on error. */ int (*free)(struct alloc_device_t* dev, buffer_handle_t handle); /* This hook is OPTIONAL. * * If non NULL it will be caused by SurfaceFlinger on dumpsys */ void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); void* reserved_proc[7]; } alloc_device_t; /** convenience API for opening and closing a supported device */ static inline int gralloc_open(const struct hw_module_t* module, struct alloc_device_t** device) { return module->methods->open(module, GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device); } static inline int gralloc_close(struct alloc_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_GRALLOC_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/hardware.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H #define ANDROID_INCLUDE_HARDWARE_HARDWARE_H #include #include #include #include __BEGIN_DECLS /* * Value for the hw_module_t.tag field */ #define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) #define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') #define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') #define HARDWARE_MAKE_API_VERSION(maj,min) \ ((((maj) & 0xff) << 8) | ((min) & 0xff)) #define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) #define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 #define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff /* * The current HAL API version. * * All module implementations must set the hw_module_t.hal_api_version field * to this value when declaring the module with HAL_MODULE_INFO_SYM. * * Note that previous implementations have always set this field to 0. * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 * to be 100% binary compatible. * */ #define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) /* * Helper macros for module implementors. * * The derived modules should provide convenience macros for supported * versions so that implementations can explicitly specify module/device * versions at definition time. * * Use this macro to set the hw_module_t.module_api_version field. */ #define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) /* * Use this macro to set the hw_device_t.version field */ #define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) #define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) struct hw_module_t; struct hw_module_methods_t; struct hw_device_t; /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct hw_module_t { /** tag must be initialized to HARDWARE_MODULE_TAG */ uint32_t tag; /** * The API version of the implemented module. The module owner is * responsible for updating the version when a module interface has * changed. * * The derived modules such as gralloc and audio own and manage this field. * The module user must interpret the version field to decide whether or * not to inter-operate with the supplied module implementation. * For example, SurfaceFlinger is responsible for making sure that * it knows how to manage different versions of the gralloc-module API, * and AudioFlinger must know how to do the same for audio-module API. * * The module API version should include a major and a minor component. * For example, version 1.0 could be represented as 0x0100. This format * implies that versions 0x0100-0x01ff are all API-compatible. * * In the future, libhardware will expose a hw_get_module_version() * (or equivalent) function that will take minimum/maximum supported * versions as arguments and would be able to reject modules with * versions outside of the supplied range. */ uint16_t module_api_version; #define version_major module_api_version /** * version_major/version_minor defines are supplied here for temporary * source code compatibility. They will be removed in the next version. * ALL clients must convert to the new version format. */ /** * The API version of the HAL module interface. This is meant to * version the hw_module_t, hw_module_methods_t, and hw_device_t * structures and definitions. * * The HAL interface owns this field. Module users/implementations * must NOT rely on this value for version information. * * Presently, 0 is the only valid value. */ uint16_t hal_api_version; #define version_minor hal_api_version /** Identifier of module */ const char *id; /** Name of this module */ const char *name; /** Author/owner/implementor of the module */ const char *author; /** Modules methods */ struct hw_module_methods_t* methods; /** module's dso */ void* dso; #ifdef __LP64__ uint64_t reserved[32-7]; #else /** padding to 128 bytes, reserved for future use */ uint32_t reserved[32-7]; #endif } hw_module_t; typedef struct hw_module_methods_t { /** Open a specific device */ int (*open)(const struct hw_module_t* module, const char* id, struct hw_device_t** device); } hw_module_methods_t; /** * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct hw_device_t { /** tag must be initialized to HARDWARE_DEVICE_TAG */ uint32_t tag; /** * Version of the module-specific device API. This value is used by * the derived-module user to manage different device implementations. * * The module user is responsible for checking the module_api_version * and device version fields to ensure that the user is capable of * communicating with the specific module implementation. * * One module can support multiple devices with different versions. This * can be useful when a device interface changes in an incompatible way * but it is still necessary to support older implementations at the same * time. One such example is the Camera 2.0 API. * * This field is interpreted by the module user and is ignored by the * HAL interface itself. */ uint32_t version; /** reference to the module this device belongs to */ struct hw_module_t* module; /** padding reserved for future use */ #ifdef __LP64__ uint64_t reserved[12]; #else uint32_t reserved[12]; #endif /** Close this device */ int (*close)(struct hw_device_t* device); } hw_device_t; /** * Name of the hal_module_info */ #define HAL_MODULE_INFO_SYM HMI /** * Name of the hal_module_info as a string */ #define HAL_MODULE_INFO_SYM_AS_STR "HMI" /** * Get the module info associated with a module by id. * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module(const char *id, const struct hw_module_t **module); /** * Get the module info associated with a module instance by class 'class_id' * and instance 'inst'. * * Some modules types necessitate multiple instances. For example audio supports * multiple concurrent interfaces and thus 'audio' is the module class * and 'primary' or 'a2dp' are module interfaces. This implies that the files * providing these modules would be named audio.primary..so and * audio.a2dp..so * * @return: 0 == success, <0 == error and *module == NULL */ int hw_get_module_by_class(const char *class_id, const char *inst, const struct hw_module_t **module); __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/hdmi_cec.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H #define ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H #include #include #include __BEGIN_DECLS #define HDMI_CEC_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define HDMI_CEC_MODULE_API_VERSION_CURRENT HDMI_MODULE_API_VERSION_1_0 #define HDMI_CEC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define HDMI_CEC_DEVICE_API_VERSION_CURRENT HDMI_DEVICE_API_VERSION_1_0 #define HDMI_CEC_HARDWARE_MODULE_ID "hdmi_cec" #define HDMI_CEC_HARDWARE_INTERFACE "hdmi_cec_hw_if" typedef enum cec_device_type { CEC_DEVICE_INACTIVE = -1, CEC_DEVICE_TV = 0, CEC_DEVICE_RECORDER = 1, CEC_DEVICE_RESERVED = 2, CEC_DEVICE_TUNER = 3, CEC_DEVICE_PLAYBACK = 4, CEC_DEVICE_AUDIO_SYSTEM = 5, CEC_DEVICE_MAX = CEC_DEVICE_AUDIO_SYSTEM } cec_device_type_t; typedef enum cec_logical_address { CEC_ADDR_TV = 0, CEC_ADDR_RECORDER_1 = 1, CEC_ADDR_RECORDER_2 = 2, CEC_ADDR_TUNER_1 = 3, CEC_ADDR_PLAYBACK_1 = 4, CEC_ADDR_AUDIO_SYSTEM = 5, CEC_ADDR_TUNER_2 = 6, CEC_ADDR_TUNER_3 = 7, CEC_ADDR_PLAYBACK_2 = 8, CEC_ADDR_RECORDER_3 = 9, CEC_ADDR_TUNER_4 = 10, CEC_ADDR_PLAYBACK_3 = 11, CEC_ADDR_RESERVED_1 = 12, CEC_ADDR_RESERVED_2 = 13, CEC_ADDR_FREE_USE = 14, CEC_ADDR_UNREGISTERED = 15, CEC_ADDR_BROADCAST = 15 } cec_logical_address_t; /* * HDMI CEC messages */ enum cec_message_type { CEC_MESSAGE_FEATURE_ABORT = 0x00, CEC_MESSAGE_IMAGE_VIEW_ON = 0x04, CEC_MESSAGE_TUNER_STEP_INCREMENT = 0x05, CEC_MESSAGE_TUNER_STEP_DECREMENT = 0x06, CEC_MESSAGE_TUNER_DEVICE_STATUS = 0x07, CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08, CEC_MESSAGE_RECORD_ON = 0x09, CEC_MESSAGE_RECORD_STATUS = 0x0A, CEC_MESSAGE_RECORD_OFF = 0x0B, CEC_MESSAGE_TEXT_VIEW_ON = 0x0D, CEC_MESSAGE_RECORD_TV_SCREEN = 0x0F, CEC_MESSAGE_GIVE_DECK_STATUS = 0x1A, CEC_MESSAGE_DECK_STATUS = 0x1B, CEC_MESSAGE_SET_MENU_LANGUAGE = 0x32, CEC_MESSAGE_CLEAR_ANALOG_TIMER = 0x33, CEC_MESSAGE_SET_ANALOG_TIMER = 0x34, CEC_MESSAGE_TIMER_STATUS = 0x35, CEC_MESSAGE_STANDBY = 0x36, CEC_MESSAGE_PLAY = 0x41, CEC_MESSAGE_DECK_CONTROL = 0x42, CEC_MESSAGE_TIMER_CLEARED_STATUS = 0x043, CEC_MESSAGE_USER_CONTROL_PRESSED = 0x44, CEC_MESSAGE_USER_CONTROL_RELEASED = 0x45, CEC_MESSAGE_GIVE_OSD_NAME = 0x46, CEC_MESSAGE_SET_OSD_NAME = 0x47, CEC_MESSAGE_SET_OSD_STRING = 0x64, CEC_MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67, CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, CEC_MESSAGE_GIVE_AUDIO_STATUS = 0x71, CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72, CEC_MESSAGE_REPORT_AUDIO_STATUS = 0x7A, CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, CEC_MESSAGE_ROUTING_CHANGE = 0x80, CEC_MESSAGE_ROUTING_INFORMATION = 0x81, CEC_MESSAGE_ACTIVE_SOURCE = 0x82, CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83, CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84, CEC_MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85, CEC_MESSAGE_SET_STREAM_PATH = 0x86, CEC_MESSAGE_DEVICE_VENDOR_ID = 0x87, CEC_MESSAGE_VENDOR_COMMAND = 0x89, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B, CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C, CEC_MESSAGE_MENU_REQUEST = 0x8D, CEC_MESSAGE_MENU_STATUS = 0x8E, CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F, CEC_MESSAGE_REPORT_POWER_STATUS = 0x90, CEC_MESSAGE_GET_MENU_LANGUAGE = 0x91, CEC_MESSAGE_SELECT_ANALOG_SERVICE = 0x92, CEC_MESSAGE_SELECT_DIGITAL_SERVICE = 0x93, CEC_MESSAGE_SET_DIGITAL_TIMER = 0x97, CEC_MESSAGE_CLEAR_DIGITAL_TIMER = 0x99, CEC_MESSAGE_SET_AUDIO_RATE = 0x9A, CEC_MESSAGE_INACTIVE_SOURCE = 0x9D, CEC_MESSAGE_CEC_VERSION = 0x9E, CEC_MESSAGE_GET_CEC_VERSION = 0x9F, CEC_MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0, CEC_MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1, CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2, CEC_MESSAGE_INITIATE_ARC = 0xC0, CEC_MESSAGE_REPORT_ARC_INITIATED = 0xC1, CEC_MESSAGE_REPORT_ARC_TERMINATED = 0xC2, CEC_MESSAGE_REQUEST_ARC_INITIATION = 0xC3, CEC_MESSAGE_REQUEST_ARC_TERMINATION = 0xC4, CEC_MESSAGE_TERMINATE_ARC = 0xC5, CEC_MESSAGE_ABORT = 0xFF }; /* * Operand description [Abort Reason] */ enum abort_reason { ABORT_UNRECOGNIZED_MODE = 0, ABORT_NOT_IN_CORRECT_MODE = 1, ABORT_CANNOT_PROVIDE_SOURCE = 2, ABORT_INVALID_OPERAND = 3, ABORT_REFUSED = 4, ABORT_UNABLE_TO_DETERMINE = 5 }; /* * HDMI event type. used for hdmi_event_t. */ enum { HDMI_EVENT_CEC_MESSAGE = 1, HDMI_EVENT_HOT_PLUG = 2, }; /* * HDMI hotplug event type. Used when the event * type is HDMI_EVENT_HOT_PLUG. */ enum { HDMI_NOT_CONNECTED = 0, HDMI_CONNECTED = 1 }; /* * error code used for send_message. */ enum { HDMI_RESULT_SUCCESS = 0, HDMI_RESULT_NACK = 1, /* not acknowledged */ HDMI_RESULT_BUSY = 2, /* bus is busy */ HDMI_RESULT_FAIL = 3, }; /* * HDMI port type. */ typedef enum hdmi_port_type { HDMI_INPUT = 0, HDMI_OUTPUT = 1 } hdmi_port_type_t; /* * Flags used for set_option() */ enum { /* When set to false, HAL does not wake up the system upon receiving * or . Used when user changes the TV * settings to disable the auto TV on functionality. * True by default. */ HDMI_OPTION_WAKEUP = 1, /* When set to false, all the CEC commands are discarded. Used when * user changes the TV settings to disable CEC functionality. * True by default. */ HDMI_OPTION_ENABLE_CEC = 2, /* Setting this flag to false means Android system will stop handling * CEC service and yield the control over to the microprocessor that is * powered on through the standby mode. When set to true, the system * will gain the control over, hence telling the microprocessor to stop * handling the cec commands. This is called when system goes * in and out of standby mode to notify the microprocessor that it should * start/stop handling CEC commands on behalf of the system. * False by default. */ HDMI_OPTION_SYSTEM_CEC_CONTROL = 3, /* Option 4 not used */ /* Passes the updated language information of Android system. * Contains 3-byte ASCII code as defined in ISO/FDIS 639-2. Can be * used for HAL to respond to while in standby mode. * English(eng), for example, is converted to 0x656e67. */ HDMI_OPTION_SET_LANG = 5, }; /* * Maximum length in bytes of cec message body (exclude header block), * should not exceed 16 (spec CEC 6 Frame Description) */ #define CEC_MESSAGE_BODY_MAX_LENGTH 16 typedef struct cec_message { /* logical address of sender */ cec_logical_address_t initiator; /* logical address of receiver */ cec_logical_address_t destination; /* Length in bytes of body, range [0, CEC_MESSAGE_BODY_MAX_LENGTH] */ size_t length; unsigned char body[CEC_MESSAGE_BODY_MAX_LENGTH]; } cec_message_t; typedef struct hotplug_event { /* * true if the cable is connected; otherwise false. */ int connected; int port_id; } hotplug_event_t; typedef struct tx_status_event { int status; int opcode; /* CEC opcode */ } tx_status_event_t; /* * HDMI event generated from HAL. */ typedef struct hdmi_event { int type; struct hdmi_cec_device* dev; union { cec_message_t cec; hotplug_event_t hotplug; }; } hdmi_event_t; /* * HDMI port descriptor */ typedef struct hdmi_port_info { hdmi_port_type_t type; // Port ID should start from 1 which corresponds to HDMI "port 1". int port_id; int cec_supported; int arc_supported; uint16_t physical_address; } hdmi_port_info_t; /* * Callback function type that will be called by HAL implementation. * Services can not close/open the device in the callback. */ typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg); typedef struct hdmi_cec_module { /** * Common methods of the HDMI CEC module. This *must* be the first member of * hdmi_cec_module as users of this structure will cast a hw_module_t to hdmi_cec_module * pointer in contexts where it's known the hw_module_t references a hdmi_cec_module. */ struct hw_module_t common; } hdmi_module_t; /* * HDMI-CEC HAL interface definition. */ typedef struct hdmi_cec_device { /** * Common methods of the HDMI CEC device. This *must* be the first member of * hdmi_cec_device as users of this structure will cast a hw_device_t to hdmi_cec_device * pointer in contexts where it's known the hw_device_t references a hdmi_cec_device. */ struct hw_device_t common; /* * (*add_logical_address)() passes the logical address that will be used * in this system. * * HAL may use it to configure the hardware so that the CEC commands addressed * the given logical address can be filtered in. This method can be called * as many times as necessary in order to support multiple logical devices. * addr should be in the range of valid logical addresses for the call * to succeed. * * Returns 0 on success or -errno on error. */ int (*add_logical_address)(const struct hdmi_cec_device* dev, cec_logical_address_t addr); /* * (*clear_logical_address)() tells HAL to reset all the logical addresses. * * It is used when the system doesn't need to process CEC command any more, * hence to tell HAL to stop receiving commands from the CEC bus, and change * the state back to the beginning. */ void (*clear_logical_address)(const struct hdmi_cec_device* dev); /* * (*get_physical_address)() returns the CEC physical address. The * address is written to addr. * * The physical address depends on the topology of the network formed * by connected HDMI devices. It is therefore likely to change if the cable * is plugged off and on again. It is advised to call get_physical_address * to get the updated address when hot plug event takes place. * * Returns 0 on success or -errno on error. */ int (*get_physical_address)(const struct hdmi_cec_device* dev, uint16_t* addr); /* * (*send_message)() transmits HDMI-CEC message to other HDMI device. * * The method should be designed to return in a certain amount of time not * hanging forever, which can happen if CEC signal line is pulled low for * some reason. HAL implementation should take the situation into account * so as not to wait forever for the message to get sent out. * * It should try retransmission at least once as specified in the standard. * * Returns error code. See HDMI_RESULT_SUCCESS, HDMI_RESULT_NACK, and * HDMI_RESULT_BUSY. */ int (*send_message)(const struct hdmi_cec_device* dev, const cec_message_t*); /* * (*register_event_callback)() registers a callback that HDMI-CEC HAL * can later use for incoming CEC messages or internal HDMI events. * When calling from C++, use the argument arg to pass the calling object. * It will be passed back when the callback is invoked so that the context * can be retrieved. */ void (*register_event_callback)(const struct hdmi_cec_device* dev, event_callback_t callback, void* arg); /* * (*get_version)() returns the CEC version supported by underlying hardware. */ void (*get_version)(const struct hdmi_cec_device* dev, int* version); /* * (*get_vendor_id)() returns the identifier of the vendor. It is * the 24-bit unique company ID obtained from the IEEE Registration * Authority Committee (RAC). */ void (*get_vendor_id)(const struct hdmi_cec_device* dev, uint32_t* vendor_id); /* * (*get_port_info)() returns the hdmi port information of underlying hardware. * info is the list of HDMI port information, and 'total' is the number of * HDMI ports in the system. */ void (*get_port_info)(const struct hdmi_cec_device* dev, struct hdmi_port_info* list[], int* total); /* * (*set_option)() passes flags controlling the way HDMI-CEC service works down * to HAL implementation. Those flags will be used in case the feature needs * update in HAL itself, firmware or microcontroller. */ void (*set_option)(const struct hdmi_cec_device* dev, int flag, int value); /* * (*set_audio_return_channel)() configures ARC circuit in the hardware logic * to start or stop the feature. Flag can be either 1 to start the feature * or 0 to stop it. * * Returns 0 on success or -errno on error. */ void (*set_audio_return_channel)(const struct hdmi_cec_device* dev, int port_id, int flag); /* * (*is_connected)() returns the connection status of the specified port. * Returns HDMI_CONNECTED if a device is connected, otherwise HDMI_NOT_CONNECTED. * The HAL should watch for +5V power signal to determine the status. */ int (*is_connected)(const struct hdmi_cec_device* dev, int port_id); /* Reserved for future use to maximum 16 functions. Must be NULL. */ void* reserved[16 - 11]; } hdmi_cec_device_t; /** convenience API for opening and closing a device */ static inline int hdmi_cec_open(const struct hw_module_t* module, struct hdmi_cec_device** device) { return module->methods->open(module, HDMI_CEC_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int hdmi_cec_close(struct hdmi_cec_device* device) { return device->common.close(&device->common); } __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/hw_auth_token.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H #define ANDROID_HARDWARE_HW_AUTH_TOKEN_H #ifdef __cplusplus extern "C" { #endif // __cplusplus const uint8_t HW_AUTH_TOKEN_VERSION = 0; typedef enum { HW_AUTH_NONE = 0, HW_AUTH_PASSWORD = 1 << 0, HW_AUTH_FINGERPRINT = 1 << 1, // Additional entries should be powers of 2. HW_AUTH_ANY = UINT32_MAX, } hw_authenticator_type_t; /** * Data format for an authentication record used to prove successful authentication. */ typedef struct __attribute__((__packed__)) { uint8_t version; // Current version is 0 uint64_t challenge; uint64_t user_id; // secure user ID, not Android user ID uint64_t authenticator_id; // secure authenticator ID uint32_t authenticator_type; // hw_authenticator_type_t, in network order uint64_t timestamp; // in network order uint8_t hmac[32]; } hw_auth_token_t; #ifdef __cplusplus } // extern "C" #endif // __cplusplus #endif // ANDROID_HARDWARE_HW_AUTH_TOKEN_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/hwcomposer.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H #include #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ /* for compatibility */ #define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 #define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 #define HWC_API_VERSION HWC_DEVICE_API_VERSION /*****************************************************************************/ /** * The id of this module */ #define HWC_HARDWARE_MODULE_ID "hwcomposer" /** * Name of the sensors device to open */ #define HWC_HARDWARE_COMPOSER "composer" typedef struct hwc_rect { int left; int top; int right; int bottom; } hwc_rect_t; typedef struct hwc_frect { float left; float top; float right; float bottom; } hwc_frect_t; typedef struct hwc_region { size_t numRects; hwc_rect_t const* rects; } hwc_region_t; typedef struct hwc_color { uint8_t r; uint8_t g; uint8_t b; uint8_t a; } hwc_color_t; typedef struct hwc_layer_1 { /* * compositionType is used to specify this layer's type and is set by either * the hardware composer implementation, or by the caller (see below). * * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is * also set, otherwise, this field is preserved between (*prepare)() * calls. * * HWC_BACKGROUND * Always set by the caller before calling (*prepare)(), this value * indicates this is a special "background" layer. The only valid field * is backgroundColor. * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT * handle the background color. * * * HWC_FRAMEBUFFER_TARGET * Always set by the caller before calling (*prepare)(), this value * indicates this layer is the framebuffer surface used as the target of * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and * this layer should be ignored during set(). * * This flag (and the framebuffer surface layer) will only be used if the * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, * the OpenGL ES target surface is communicated by the (dpy, sur) fields * in hwc_compositor_device_1_t. * * This value cannot be set by the HWC implementation. * * * HWC_FRAMEBUFFER * Set by the caller before calling (*prepare)() ONLY when the * HWC_GEOMETRY_CHANGED flag is also set. * * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be drawn into the framebuffer using OpenGL ES. * The HWC can toggle this value to HWC_OVERLAY to indicate it will * handle the layer. * * * HWC_OVERLAY * Set by the HWC implementation during (*prepare)(), this indicates * that the layer will be handled by the HWC (ie: it must not be * composited with OpenGL ES). * * * HWC_SIDEBAND * Set by the caller before calling (*prepare)(), this value indicates * the contents of this layer come from a sideband video stream. * * The h/w composer is responsible for receiving new image buffers from * the stream at the appropriate time (e.g. synchronized to a separate * audio stream), compositing them with the current contents of other * layers, and displaying the resulting image. This happens * independently of the normal prepare/set cycle. The prepare/set calls * only happen when other layers change, or when properties of the * sideband layer such as position or size change. * * If the h/w composer can't handle the layer as a sideband stream for * some reason (e.g. unsupported scaling/blending/rotation, or too many * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in * (*prepare)(). However, doing so will result in the layer being shown * as a solid color since the platform is not currently able to composite * sideband layers with the GPU. This may be improved in future * versions of the platform. * * * HWC_CURSOR_OVERLAY * Set by the HWC implementation during (*prepare)(), this value * indicates the layer's composition will now be handled by the HWC. * Additionally, the client can now asynchronously update the on-screen * position of this layer using the setCursorPositionAsync() api. */ int32_t compositionType; /* * hints is bit mask set by the HWC implementation during (*prepare)(). * It is preserved between (*prepare)() calls, unless the * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. * * see hwc_layer_t::hints */ uint32_t hints; /* see hwc_layer_t::flags */ uint32_t flags; union { /* color of the background. hwc_color_t.a is ignored */ hwc_color_t backgroundColor; struct { union { /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to * compose. This handle is guaranteed to have been allocated * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. * If the layer's handle is unchanged across two consecutive * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set * for the second call then the HWComposer implementation may * assume that the contents of the buffer have not changed. */ buffer_handle_t handle; /* When compositionType is HWC_SIDEBAND, this is the handle * of the sideband video stream to compose. */ const native_handle_t* sidebandStream; }; /* transformation to apply to the buffer during composition */ uint32_t transform; /* blending to apply during composition */ int32_t blending; /* area of the source to consider, the origin is the top-left corner of * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. * If the h/w can't support a non-integer source crop rectangle, it should * punt to OpenGL ES composition. */ union { // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) hwc_rect_t sourceCropi; hwc_rect_t sourceCrop; // just for source compatibility // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) hwc_frect_t sourceCropf; }; /* where to composite the sourceCrop onto the display. The sourceCrop * is scaled using linear filtering to the displayFrame. The origin is the * top-left corner of the screen. */ hwc_rect_t displayFrame; /* visible region in screen space. The origin is the * top-left corner of the screen. * The visible region INCLUDES areas overlapped by a translucent layer. */ hwc_region_t visibleRegionScreen; /* Sync fence object that will be signaled when the buffer's * contents are available. May be -1 if the contents are already * available. This field is only valid during set(), and should be * ignored during prepare(). The set() call must not wait for the * fence to be signaled before returning, but the HWC must wait for * all buffers to be signaled before reading from them. * * HWC_FRAMEBUFFER layers will never have an acquire fence, since * reads from them are complete before the framebuffer is ready for * display. * * HWC_SIDEBAND layers will never have an acquire fence, since * synchronization is handled through implementation-defined * sideband mechanisms. * * The HWC takes ownership of the acquireFenceFd and is responsible * for closing it when no longer needed. */ int acquireFenceFd; /* During set() the HWC must set this field to a file descriptor for * a sync fence object that will signal after the HWC has finished * reading from the buffer. The field is ignored by prepare(). Each * layer should have a unique file descriptor, even if more than one * refer to the same underlying fence object; this allows each to be * closed independently. * * If buffer reads can complete at significantly different times, * then using independent fences is preferred. For example, if the * HWC handles some layers with a blit engine and others with * overlays, then the blit layers can be reused immediately after * the blit completes, but the overlay layers can't be reused until * a subsequent frame has been displayed. * * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't * produce a release fence for them. The releaseFenceFd will be -1 * for these layers when set() is called. * * Since HWC_SIDEBAND buffers don't pass through the HWC client, * the HWC shouldn't produce a release fence for them. The * releaseFenceFd will be -1 for these layers when set() is called. * * The HWC client taks ownership of the releaseFenceFd and is * responsible for closing it when no longer needed. */ int releaseFenceFd; /* * Availability: HWC_DEVICE_API_VERSION_1_2 * * Alpha value applied to the whole layer. The effective * value of each pixel is computed as: * * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = pixel.a * planeAlpha / 255 * * Then blending proceeds as usual according to the "blending" * field above. * * NOTE: planeAlpha applies to YUV layers as well: * * pixel.rgb = yuv_to_rgb(pixel.yuv) * if (blending == HWC_BLENDING_PREMULT) * pixel.rgb = pixel.rgb * planeAlpha / 255 * pixel.a = planeAlpha * * * IMPLEMENTATION NOTE: * * If the source image doesn't have an alpha channel, then * the h/w can use the HWC_BLENDING_COVERAGE equations instead of * HWC_BLENDING_PREMULT and simply set the alpha channel to * planeAlpha. * * e.g.: * * if (blending == HWC_BLENDING_PREMULT) * blending = HWC_BLENDING_COVERAGE; * pixel.a = planeAlpha; * */ uint8_t planeAlpha; /* Pad to 32 bits */ uint8_t _pad[3]; /* * Availability: HWC_DEVICE_API_VERSION_1_5 * * This defines the region of the source buffer that has been * modified since the last frame. * * If surfaceDamage.numRects > 0, then it may be assumed that any * portion of the source buffer not covered by one of the rects has * not been modified this frame. If surfaceDamage.numRects == 0, * then the whole source buffer must be treated as if it had been * modified. * * If the layer's contents are not modified relative to the prior * prepare/set cycle, surfaceDamage will contain exactly one empty * rect ([0, 0, 0, 0]). * * The damage rects are relative to the pre-transformed buffer, and * their origin is the top-left corner. */ hwc_region_t surfaceDamage; }; }; #ifdef __LP64__ /* * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs * to be padded as such to maintain binary compatibility. */ uint8_t reserved[120 - 112]; #else /* * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such * to maintain binary compatibility. */ uint8_t reserved[96 - 84]; #endif } hwc_layer_1_t; /* This represents a display, typically an EGLDisplay object */ typedef void* hwc_display_t; /* This represents a surface, typically an EGLSurface object */ typedef void* hwc_surface_t; /* * hwc_display_contents_1_t::flags values */ enum { /* * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list * passed to (*prepare)() has changed by more than just the buffer handles * and acquire fences. */ HWC_GEOMETRY_CHANGED = 0x00000001, }; /* * Description of the contents to output on a display. * * This is the top-level structure passed to the prepare and set calls to * negotiate and commit the composition of a display image. */ typedef struct hwc_display_contents_1 { /* File descriptor referring to a Sync HAL fence object which will signal * when this composition is retired. For a physical display, a composition * is retired when it has been replaced on-screen by a subsequent set. For * a virtual display, the composition is retired when the writes to * outputBuffer are complete and can be read. The fence object is created * and returned by the set call; this field will be -1 on entry to prepare * and set. SurfaceFlinger will close the returned file descriptor. */ int retireFenceFd; union { /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ struct { /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to * prepare. The set call should commit this surface atomically to * the display along with any overlay layers. */ hwc_display_t dpy; hwc_surface_t sur; }; /* These fields are used for virtual displays when the h/w composer * version is at least HWC_DEVICE_VERSION_1_3. */ struct { /* outbuf is the buffer that receives the composed image for * virtual displays. Writes to the outbuf must wait until * outbufAcquireFenceFd signals. A fence that will signal when * writes to outbuf are complete should be returned in * retireFenceFd. * * This field is set before prepare(), so properties of the buffer * can be used to decide which layers can be handled by h/w * composer. * * If prepare() sets all layers to FRAMEBUFFER, then GLES * composition will happen directly to the output buffer. In this * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will * be the same, and set() has no work to do besides managing fences. * * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config * variable is defined (not the default), then this behavior is * changed: if all layers are marked for FRAMEBUFFER, GLES * composition will take place to a scratch framebuffer, and * h/w composer must copy it to the output buffer. This allows the * h/w composer to do format conversion if there are cases where * that is more desirable than doing it in the GLES driver or at the * virtual display consumer. * * If some or all layers are marked OVERLAY, then the framebuffer * and output buffer will be different. As with physical displays, * the framebuffer handle will not change between frames if all * layers are marked for OVERLAY. */ buffer_handle_t outbuf; /* File descriptor for a fence that will signal when outbuf is * ready to be written. The h/w composer is responsible for closing * this when no longer needed. * * Will be -1 whenever outbuf is NULL, or when the outbuf can be * written immediately. */ int outbufAcquireFenceFd; }; }; /* List of layers that will be composed on the display. The buffer handles * in the list will be unique. If numHwLayers is 0, all composition will be * performed by SurfaceFlinger. */ uint32_t flags; size_t numHwLayers; hwc_layer_1_t hwLayers[0]; } hwc_display_contents_1_t; /* see hwc_composer_device::registerProcs() * All of the callbacks are required and non-NULL unless otherwise noted. */ typedef struct hwc_procs { /* * (*invalidate)() triggers a screen refresh, in particular prepare and set * will be called shortly after this call is made. Note that there is * NO GUARANTEE that the screen refresh will happen after invalidate() * returns (in particular, it could happen before). * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and * it is safe to call invalidate() from any of hwc_composer_device * hooks, unless noted otherwise. */ void (*invalidate)(const struct hwc_procs* procs); /* * (*vsync)() is called by the h/w composer HAL when a vsync event is * received and HWC_EVENT_VSYNC is enabled on a display * (see: hwc_event_control). * * the "disp" parameter indicates which display the vsync event is for. * the "timestamp" parameter is the system monotonic clock timestamp in * nanosecond of when the vsync event happened. * * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. * * It is expected that vsync() is called from a thread of at least * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, * typically less than 0.5 ms. * * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation * can either stop or continue to process VSYNC events, but must not * crash or cause other problems. */ void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); /* * (*hotplug)() is called by the h/w composer HAL when a display is * connected or disconnected. The PRIMARY display is always connected and * the hotplug callback should not be called for it. * * The disp parameter indicates which display type this event is for. * The connected parameter indicates whether the display has just been * connected (1) or disconnected (0). * * The hotplug() callback may call back into the h/w composer on the same * thread to query refresh rate and dpi for the display. Additionally, * other threads may be calling into the h/w composer while the callback * is in progress. * * The h/w composer must serialize calls to the hotplug callback; only * one thread may call it at a time. * * This callback will be NULL if the h/w composer is using * HWC_DEVICE_API_VERSION_1_0. */ void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); } hwc_procs_t; /*****************************************************************************/ typedef struct hwc_module { /** * Common methods of the hardware composer module. This *must* be the first member of * hwc_module as users of this structure will cast a hw_module_t to * hwc_module pointer in contexts where it's known the hw_module_t references a * hwc_module. */ struct hw_module_t common; } hwc_module_t; typedef struct hwc_composer_device_1 { /** * Common methods of the hardware composer device. This *must* be the first member of * hwc_composer_device_1 as users of this structure will cast a hw_device_t to * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a * hwc_composer_device_1. */ struct hw_device_t common; /* * (*prepare)() is called for each frame before composition and is used by * SurfaceFlinger to determine what composition steps the HWC can handle. * * (*prepare)() can be called more than once, the last call prevails. * * The HWC responds by setting the compositionType field in each layer to * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the * HWC_FRAMEBUFFER type, composition for the layer is handled by * SurfaceFlinger with OpenGL ES. For the latter two overlay types, * the HWC will have to handle the layer's composition. compositionType * and hints are preserved between (*prepare)() calles unless the * HWC_GEOMETRY_CHANGED flag is set. * * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the * list's geometry has changed, that is, when more than just the buffer's * handles have been updated. Typically this happens (but is not limited to) * when a window is added, removed, resized or moved. In this case * compositionType and hints are reset to their default value. * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * returns: 0 on success. An negative error code on error. If an error is * returned, SurfaceFlinger will assume that none of the layer will be * handled by the HWC. */ int (*prepare)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * (*set)() is used in place of eglSwapBuffers(), and assumes the same * functionality, except it also commits the work list atomically with * the actual eglSwapBuffers(). * * The layer lists are guaranteed to be the same as the ones returned from * the last call to (*prepare)(). * * When this call returns the caller assumes that the displays will be * updated in the near future with the content of their work lists, without * artifacts during the transition from the previous frame. * * A display with zero layers indicates that the entire composition has * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() * behaves just like eglSwapBuffers(). * * For HWC 1.0, numDisplays will always be one, and displays[0] will be * non-NULL. * * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. * Entries for unsupported or disabled/disconnected display types will be * NULL. * * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra * entries correspond to enabled virtual displays, and will be non-NULL. * * IMPORTANT NOTE: There is an implicit layer containing opaque black * pixels behind all the layers in the list. It is the responsibility of * the hwcomposer module to make sure black pixels are output (or blended * from). * * IMPORTANT NOTE: In the event of an error this call *MUST* still cause * any fences returned in the previous call to set to eventually become * signaled. The caller may have already issued wait commands on these * fences, and having set return without causing those fences to signal * will likely result in a deadlock. * * returns: 0 on success. A negative error code on error: * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only * allowed prior to HWComposer 1.1) * Another code for non EGL errors. */ int (*set)(struct hwc_composer_device_1 *dev, size_t numDisplays, hwc_display_contents_1_t** displays); /* * eventControl(..., event, enabled) * Enables or disables h/w composer events for a display. * * eventControl can be called from any thread and takes effect * immediately. * * Supported events are: * HWC_EVENT_VSYNC * * returns -EINVAL if the "event" parameter is not one of the value above * or if the "enabled" parameter is not 0 or 1. */ int (*eventControl)(struct hwc_composer_device_1* dev, int disp, int event, int enabled); union { /* * For HWC 1.3 and earlier, the blank() interface is used. * * blank(..., blank) * Blanks or unblanks a display's screen. * * Turns the screen off when blank is nonzero, on when blank is zero. * Multiple sequential calls with the same blank value must be * supported. * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); /* * For HWC 1.4 and above, setPowerMode() will be used in place of * blank(). * * setPowerMode(..., mode) * Sets the display screen's power state. * * Refer to the documentation of the HWC_POWER_MODE_* constants * for information about each power mode. * * The functionality is similar to the blank() command in previous * versions of HWC, but with support for more power states. * * The display driver is expected to retain and restore the low power * state of the display while entering and exiting from suspend. * * Multiple sequential calls with the same mode value must be supported. * * The screen state transition must be be complete when the function * returns. * * returns 0 on success, negative on error. */ int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, int mode); }; /* * Used to retrieve information about the h/w composer * * Returns 0 on success or -errno on error. */ int (*query)(struct hwc_composer_device_1* dev, int what, int* value); /* * (*registerProcs)() registers callbacks that the h/w composer HAL can * later use. It will be called immediately after the composer device is * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks * from within registerProcs(). registerProcs() must save the hwc_procs_t * pointer which is needed when calling a registered callback. */ void (*registerProcs)(struct hwc_composer_device_1* dev, hwc_procs_t const* procs); /* * This field is OPTIONAL and can be NULL. * * If non NULL it will be called by SurfaceFlinger on dumpsys */ void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); /* * (*getDisplayConfigs)() returns handles for the configurations available * on the connected display. These handles must remain valid as long as the * display is connected. * * Configuration handles are written to configs. The number of entries * allocated by the caller is passed in *numConfigs; getDisplayConfigs must * not try to write more than this number of config handles. On return, the * total number of configurations available for the display is returned in * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. * * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior * shall choose one configuration to activate and report it as the first * entry in the returned list. Reporting the inactive configurations is not * required. * * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management * through SurfaceFlinger, and hardware composers implementing these APIs * must also provide getActiveConfig and setActiveConfig. Hardware composers * implementing these API versions may choose not to activate any * configuration, leaving configuration selection to higher levels of the * framework. * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, an error shall be * returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. */ int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, uint32_t* configs, size_t* numConfigs); /* * (*getDisplayAttributes)() returns attributes for a specific config of a * connected display. The config parameter is one of the config handles * returned by getDisplayConfigs. * * The list of attributes to return is provided in the attributes * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each * requested attribute is written in order to the values array. The * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values * array will have one less value than the attributes array. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. * It shall be NULL for previous versions. * * If disp is a hotpluggable display type and no display is connected, * or if config is not a valid configuration for the display, a negative * error code shall be returned. */ int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, uint32_t config, const uint32_t* attributes, int32_t* values); /* * (*getActiveConfig)() returns the index of the configuration that is * currently active on the connected display. The index is relative to * the list of configuration handles returned by getDisplayConfigs. If there * is no active configuration, -1 shall be returned. * * Returns the configuration index on success or -1 on error. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); /* * (*setActiveConfig)() instructs the hardware composer to switch to the * display configuration at the given index in the list of configuration * handles returned by getDisplayConfigs. * * If this function returns without error, any subsequent calls to * getActiveConfig shall return the index set by this function until one * of the following occurs: * 1) Another successful call of this function * 2) The display is disconnected * * Returns 0 on success or a negative error code on error. If disp is a * hotpluggable display type and no display is connected, or if index is * outside of the range of hardware configurations returned by * getDisplayConfigs, an error shall be returned. * * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. * It shall be NULL for previous versions. */ int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, int index); /* * Asynchronously update the location of the cursor layer. * * Within the standard prepare()/set() composition loop, the client * (surfaceflinger) can request that a given layer uses dedicated cursor * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only * one layer per display can have this flag set. If the layer is suitable * for the platform's cursor hardware, hwcomposer will return from prepare() * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates * not only that the client is not responsible for compositing that layer, * but also that the client can continue to update the position of that layer * after a call to set(). This can reduce the visible latency of mouse * movement to visible, on-screen cursor updates. Calls to * setCursorPositionAsync() may be made from a different thread doing the * prepare()/set() composition loop, but care must be taken to not interleave * calls of setCursorPositionAsync() between calls of set()/prepare(). * * Notes: * - Only one layer per display can be specified as a cursor layer with * HWC_IS_CURSOR_LAYER. * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY * - This returns 0 on success or -errno on error. * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It * should be null for previous versions. */ int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); /* * Reserved for future use. Must be NULL. */ void* reserved_proc[1]; } hwc_composer_device_1_t; /** convenience API for opening and closing a device */ static inline int hwc_open_1(const struct hw_module_t* module, hwc_composer_device_1_t** device) { return module->methods->open(module, HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); } static inline int hwc_close_1(hwc_composer_device_1_t* device) { return device->common.close(&device->common); } /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/hwcomposer_defs.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define HWC_HEADER_VERSION 1 #define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) #define HWC_DEVICE_API_VERSION_1_5 HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION) enum { /* hwc_composer_device_t::set failed in EGL */ HWC_EGL_ERROR = -1 }; /* * hwc_layer_t::hints values * Hints are set by the HAL and read by SurfaceFlinger */ enum { /* * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger * that it should triple buffer this layer. Typically HWC does this when * the layer will be unavailable for use for an extended period of time, * e.g. if the display will be fetching data directly from the layer and * the layer can not be modified until after the next set(). */ HWC_HINT_TRIPLE_BUFFER = 0x00000001, /* * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the * framebuffer with transparent pixels where this layer would be. * SurfaceFlinger will only honor this flag when the layer has no blending * */ HWC_HINT_CLEAR_FB = 0x00000002 }; /* * hwc_layer_t::flags values * Flags are set by SurfaceFlinger and read by the HAL */ enum { /* * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL * shall not consider this layer for composition as it will be handled * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY). */ HWC_SKIP_LAYER = 0x00000001, /* * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this * layer is being used as a cursor on this particular display, and that * surfaceflinger can potentially perform asynchronous position updates for * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the * composition type of this layer, then the hwcomposer will allow async * position updates to this layer via setCursorPositionAsync(). */ HWC_IS_CURSOR_LAYER = 0x00000002 }; /* * hwc_layer_t::compositionType values */ enum { /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ HWC_FRAMEBUFFER = 0, /* this layer will be handled in the HWC */ HWC_OVERLAY = 1, /* this is the background layer. it's used to set the background color. * there is only a single background layer */ HWC_BACKGROUND = 2, /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. * Added in HWC_DEVICE_API_VERSION_1_1. */ HWC_FRAMEBUFFER_TARGET = 3, /* this layer's contents are taken from a sideband buffer stream. * Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_SIDEBAND = 4, /* this layer's composition will be handled by hwcomposer by dedicated cursor overlay hardware. hwcomposer will also all async position updates of this layer outside of the normal prepare()/set() loop. Added in HWC_DEVICE_API_VERSION_1_4. */ HWC_CURSOR_OVERLAY = 5 }; /* * hwc_layer_t::blending values */ enum { /* no blending */ HWC_BLENDING_NONE = 0x0100, /* ONE / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_PREMULT = 0x0105, /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ HWC_BLENDING_COVERAGE = 0x0405 }; /* * hwc_layer_t::transform values */ enum { /* flip source image horizontally */ HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, /* flip source image vertically */ HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise */ HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, }; /* attributes queriable with query() */ enum { /* * Must return 1 if the background layer is supported, 0 otherwise. */ HWC_BACKGROUND_LAYER_SUPPORTED = 0, /* * Returns the vsync period in nanoseconds. * * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. */ HWC_VSYNC_PERIOD = 1, /* * Availability: HWC_DEVICE_API_VERSION_1_1 * Returns a mask of supported display types. */ HWC_DISPLAY_TYPES_SUPPORTED = 2, }; /* display attributes returned by getDisplayAttributes() */ enum { /* Indicates the end of an attribute list */ HWC_DISPLAY_NO_ATTRIBUTE = 0, /* The vsync period in nanoseconds */ HWC_DISPLAY_VSYNC_PERIOD = 1, /* The number of pixels in the horizontal and vertical directions. */ HWC_DISPLAY_WIDTH = 2, HWC_DISPLAY_HEIGHT = 3, /* The number of pixels per thousand inches of this configuration. * * Scaling DPI by 1000 allows it to be stored in an int without losing * too much precision. * * If the DPI for a configuration is unavailable or the HWC implementation * considers it unreliable, it should set these attributes to zero. */ HWC_DISPLAY_DPI_X = 4, HWC_DISPLAY_DPI_Y = 5, /* Indicates which of the vendor-defined color transforms is provided by * this configuration. */ HWC_DISPLAY_COLOR_TRANSFORM = 6, }; /* Allowed events for hwc_methods::eventControl() */ enum { HWC_EVENT_VSYNC = 0 }; /* Display types and associated mask bits. */ enum { HWC_DISPLAY_PRIMARY = 0, HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. #ifdef QTI_BSP HWC_DISPLAY_TERTIARY = 2, HWC_DISPLAY_VIRTUAL = 3, HWC_NUM_PHYSICAL_DISPLAY_TYPES = 3, HWC_NUM_DISPLAY_TYPES = 4, #else HWC_DISPLAY_VIRTUAL = 2, HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, HWC_NUM_DISPLAY_TYPES = 3, #endif }; enum { HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, #ifdef QTI_BSP HWC_DISPLAY_TERTIARY_BIT = 1 << HWC_DISPLAY_TERTIARY, #endif HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, }; /* Display power modes */ enum { /* The display is turned off (blanked). */ HWC_POWER_MODE_OFF = 0, /* The display is turned on and configured in a low power state * that is suitable for presenting ambient information to the user, * possibly with lower fidelity than normal but greater efficiency. */ HWC_POWER_MODE_DOZE = 1, /* The display is turned on normally. */ HWC_POWER_MODE_NORMAL = 2, /* The display is configured as in HWC_POWER_MODE_DOZE but may * stop applying frame buffer updates from the graphics subsystem. * This power mode is effectively a hint from the doze dream to * tell the hardware that it is done drawing to the display for the * time being and that the display should remain on in a low power * state and continue showing its current contents indefinitely * until the mode changes. * * This mode may also be used as a signal to enable hardware-based doze * functionality. In this case, the doze dream is effectively * indicating that the hardware is free to take over the display * and manage it autonomously to implement low power always-on display * functionality. */ HWC_POWER_MODE_DOZE_SUSPEND = 3, }; /*****************************************************************************/ __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/input.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_INPUT_H #define ANDROID_INCLUDE_HARDWARE_INPUT_H #include #include __BEGIN_DECLS #define INPUT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define INPUT_HARDWARE_MODULE_ID "input" #define INPUT_INSTANCE_EVDEV "evdev" typedef enum input_bus { INPUT_BUS_BT, INPUT_BUS_USB, INPUT_BUS_SERIAL, INPUT_BUS_BUILTIN } input_bus_t; typedef struct input_host input_host_t; typedef struct input_device_handle input_device_handle_t; typedef struct input_device_identifier input_device_identifier_t; typedef struct input_device_definition input_device_definition_t; typedef struct input_report_definition input_report_definition_t; typedef struct input_report input_report_t; typedef struct input_collection input_collection_t; typedef struct input_property_map input_property_map_t; typedef struct input_property input_property_t; typedef enum { // keycodes INPUT_USAGE_KEYCODE_UNKNOWN, INPUT_USAGE_KEYCODE_SOFT_LEFT, INPUT_USAGE_KEYCODE_SOFT_RIGHT, INPUT_USAGE_KEYCODE_HOME, INPUT_USAGE_KEYCODE_BACK, INPUT_USAGE_KEYCODE_CALL, INPUT_USAGE_KEYCODE_ENDCALL, INPUT_USAGE_KEYCODE_0, INPUT_USAGE_KEYCODE_1, INPUT_USAGE_KEYCODE_2, INPUT_USAGE_KEYCODE_3, INPUT_USAGE_KEYCODE_4, INPUT_USAGE_KEYCODE_5, INPUT_USAGE_KEYCODE_6, INPUT_USAGE_KEYCODE_7, INPUT_USAGE_KEYCODE_8, INPUT_USAGE_KEYCODE_9, INPUT_USAGE_KEYCODE_STAR, INPUT_USAGE_KEYCODE_POUND, INPUT_USAGE_KEYCODE_DPAD_UP, INPUT_USAGE_KEYCODE_DPAD_DOWN, INPUT_USAGE_KEYCODE_DPAD_LEFT, INPUT_USAGE_KEYCODE_DPAD_RIGHT, INPUT_USAGE_KEYCODE_DPAD_CENTER, INPUT_USAGE_KEYCODE_VOLUME_UP, INPUT_USAGE_KEYCODE_VOLUME_DOWN, INPUT_USAGE_KEYCODE_POWER, INPUT_USAGE_KEYCODE_CAMERA, INPUT_USAGE_KEYCODE_CLEAR, INPUT_USAGE_KEYCODE_A, INPUT_USAGE_KEYCODE_B, INPUT_USAGE_KEYCODE_C, INPUT_USAGE_KEYCODE_D, INPUT_USAGE_KEYCODE_E, INPUT_USAGE_KEYCODE_F, INPUT_USAGE_KEYCODE_G, INPUT_USAGE_KEYCODE_H, INPUT_USAGE_KEYCODE_I, INPUT_USAGE_KEYCODE_J, INPUT_USAGE_KEYCODE_K, INPUT_USAGE_KEYCODE_L, INPUT_USAGE_KEYCODE_M, INPUT_USAGE_KEYCODE_N, INPUT_USAGE_KEYCODE_O, INPUT_USAGE_KEYCODE_P, INPUT_USAGE_KEYCODE_Q, INPUT_USAGE_KEYCODE_R, INPUT_USAGE_KEYCODE_S, INPUT_USAGE_KEYCODE_T, INPUT_USAGE_KEYCODE_U, INPUT_USAGE_KEYCODE_V, INPUT_USAGE_KEYCODE_W, INPUT_USAGE_KEYCODE_X, INPUT_USAGE_KEYCODE_Y, INPUT_USAGE_KEYCODE_Z, INPUT_USAGE_KEYCODE_COMMA, INPUT_USAGE_KEYCODE_PERIOD, INPUT_USAGE_KEYCODE_ALT_LEFT, INPUT_USAGE_KEYCODE_ALT_RIGHT, INPUT_USAGE_KEYCODE_SHIFT_LEFT, INPUT_USAGE_KEYCODE_SHIFT_RIGHT, INPUT_USAGE_KEYCODE_TAB, INPUT_USAGE_KEYCODE_SPACE, INPUT_USAGE_KEYCODE_SYM, INPUT_USAGE_KEYCODE_EXPLORER, INPUT_USAGE_KEYCODE_ENVELOPE, INPUT_USAGE_KEYCODE_ENTER, INPUT_USAGE_KEYCODE_DEL, INPUT_USAGE_KEYCODE_GRAVE, INPUT_USAGE_KEYCODE_MINUS, INPUT_USAGE_KEYCODE_EQUALS, INPUT_USAGE_KEYCODE_LEFT_BRACKET, INPUT_USAGE_KEYCODE_RIGHT_BRACKET, INPUT_USAGE_KEYCODE_BACKSLASH, INPUT_USAGE_KEYCODE_SEMICOLON, INPUT_USAGE_KEYCODE_APOSTROPHE, INPUT_USAGE_KEYCODE_SLASH, INPUT_USAGE_KEYCODE_AT, INPUT_USAGE_KEYCODE_NUM, INPUT_USAGE_KEYCODE_HEADSETHOOK, INPUT_USAGE_KEYCODE_FOCUS, // *Camera* focus INPUT_USAGE_KEYCODE_PLUS, INPUT_USAGE_KEYCODE_MENU, INPUT_USAGE_KEYCODE_NOTIFICATION, INPUT_USAGE_KEYCODE_SEARCH, INPUT_USAGE_KEYCODE_MEDIA_PLAY_PAUSE, INPUT_USAGE_KEYCODE_MEDIA_STOP, INPUT_USAGE_KEYCODE_MEDIA_NEXT, INPUT_USAGE_KEYCODE_MEDIA_PREVIOUS, INPUT_USAGE_KEYCODE_MEDIA_REWIND, INPUT_USAGE_KEYCODE_MEDIA_FAST_FORWARD, INPUT_USAGE_KEYCODE_MUTE, INPUT_USAGE_KEYCODE_PAGE_UP, INPUT_USAGE_KEYCODE_PAGE_DOWN, INPUT_USAGE_KEYCODE_PICTSYMBOLS, INPUT_USAGE_KEYCODE_SWITCH_CHARSET, INPUT_USAGE_KEYCODE_BUTTON_A, INPUT_USAGE_KEYCODE_BUTTON_B, INPUT_USAGE_KEYCODE_BUTTON_C, INPUT_USAGE_KEYCODE_BUTTON_X, INPUT_USAGE_KEYCODE_BUTTON_Y, INPUT_USAGE_KEYCODE_BUTTON_Z, INPUT_USAGE_KEYCODE_BUTTON_L1, INPUT_USAGE_KEYCODE_BUTTON_R1, INPUT_USAGE_KEYCODE_BUTTON_L2, INPUT_USAGE_KEYCODE_BUTTON_R2, INPUT_USAGE_KEYCODE_BUTTON_THUMBL, INPUT_USAGE_KEYCODE_BUTTON_THUMBR, INPUT_USAGE_KEYCODE_BUTTON_START, INPUT_USAGE_KEYCODE_BUTTON_SELECT, INPUT_USAGE_KEYCODE_BUTTON_MODE, INPUT_USAGE_KEYCODE_ESCAPE, INPUT_USAGE_KEYCODE_FORWARD_DEL, INPUT_USAGE_KEYCODE_CTRL_LEFT, INPUT_USAGE_KEYCODE_CTRL_RIGHT, INPUT_USAGE_KEYCODE_CAPS_LOCK, INPUT_USAGE_KEYCODE_SCROLL_LOCK, INPUT_USAGE_KEYCODE_META_LEFT, INPUT_USAGE_KEYCODE_META_RIGHT, INPUT_USAGE_KEYCODE_FUNCTION, INPUT_USAGE_KEYCODE_SYSRQ, INPUT_USAGE_KEYCODE_BREAK, INPUT_USAGE_KEYCODE_MOVE_HOME, INPUT_USAGE_KEYCODE_MOVE_END, INPUT_USAGE_KEYCODE_INSERT, INPUT_USAGE_KEYCODE_FORWARD, INPUT_USAGE_KEYCODE_MEDIA_PLAY, INPUT_USAGE_KEYCODE_MEDIA_PAUSE, INPUT_USAGE_KEYCODE_MEDIA_CLOSE, INPUT_USAGE_KEYCODE_MEDIA_EJECT, INPUT_USAGE_KEYCODE_MEDIA_RECORD, INPUT_USAGE_KEYCODE_F1, INPUT_USAGE_KEYCODE_F2, INPUT_USAGE_KEYCODE_F3, INPUT_USAGE_KEYCODE_F4, INPUT_USAGE_KEYCODE_F5, INPUT_USAGE_KEYCODE_F6, INPUT_USAGE_KEYCODE_F7, INPUT_USAGE_KEYCODE_F8, INPUT_USAGE_KEYCODE_F9, INPUT_USAGE_KEYCODE_F10, INPUT_USAGE_KEYCODE_F11, INPUT_USAGE_KEYCODE_F12, INPUT_USAGE_KEYCODE_NUM_LOCK, INPUT_USAGE_KEYCODE_NUMPAD_0, INPUT_USAGE_KEYCODE_NUMPAD_1, INPUT_USAGE_KEYCODE_NUMPAD_2, INPUT_USAGE_KEYCODE_NUMPAD_3, INPUT_USAGE_KEYCODE_NUMPAD_4, INPUT_USAGE_KEYCODE_NUMPAD_5, INPUT_USAGE_KEYCODE_NUMPAD_6, INPUT_USAGE_KEYCODE_NUMPAD_7, INPUT_USAGE_KEYCODE_NUMPAD_8, INPUT_USAGE_KEYCODE_NUMPAD_9, INPUT_USAGE_KEYCODE_NUMPAD_DIVIDE, INPUT_USAGE_KEYCODE_NUMPAD_MULTIPLY, INPUT_USAGE_KEYCODE_NUMPAD_SUBTRACT, INPUT_USAGE_KEYCODE_NUMPAD_ADD, INPUT_USAGE_KEYCODE_NUMPAD_DOT, INPUT_USAGE_KEYCODE_NUMPAD_COMMA, INPUT_USAGE_KEYCODE_NUMPAD_ENTER, INPUT_USAGE_KEYCODE_NUMPAD_EQUALS, INPUT_USAGE_KEYCODE_NUMPAD_LEFT_PAREN, INPUT_USAGE_KEYCODE_NUMPAD_RIGHT_PAREN, INPUT_USAGE_KEYCODE_VOLUME_MUTE, INPUT_USAGE_KEYCODE_INFO, INPUT_USAGE_KEYCODE_CHANNEL_UP, INPUT_USAGE_KEYCODE_CHANNEL_DOWN, INPUT_USAGE_KEYCODE_ZOOM_IN, INPUT_USAGE_KEYCODE_ZOOM_OUT, INPUT_USAGE_KEYCODE_TV, INPUT_USAGE_KEYCODE_WINDOW, INPUT_USAGE_KEYCODE_GUIDE, INPUT_USAGE_KEYCODE_DVR, INPUT_USAGE_KEYCODE_BOOKMARK, INPUT_USAGE_KEYCODE_CAPTIONS, INPUT_USAGE_KEYCODE_SETTINGS, INPUT_USAGE_KEYCODE_TV_POWER, INPUT_USAGE_KEYCODE_TV_INPUT, INPUT_USAGE_KEYCODE_STB_POWER, INPUT_USAGE_KEYCODE_STB_INPUT, INPUT_USAGE_KEYCODE_AVR_POWER, INPUT_USAGE_KEYCODE_AVR_INPUT, INPUT_USAGE_KEYCODE_PROG_RED, INPUT_USAGE_KEYCODE_PROG_GREEN, INPUT_USAGE_KEYCODE_PROG_YELLOW, INPUT_USAGE_KEYCODE_PROG_BLUE, INPUT_USAGE_KEYCODE_APP_SWITCH, INPUT_USAGE_KEYCODE_BUTTON_1, INPUT_USAGE_KEYCODE_BUTTON_2, INPUT_USAGE_KEYCODE_BUTTON_3, INPUT_USAGE_KEYCODE_BUTTON_4, INPUT_USAGE_KEYCODE_BUTTON_5, INPUT_USAGE_KEYCODE_BUTTON_6, INPUT_USAGE_KEYCODE_BUTTON_7, INPUT_USAGE_KEYCODE_BUTTON_8, INPUT_USAGE_KEYCODE_BUTTON_9, INPUT_USAGE_KEYCODE_BUTTON_10, INPUT_USAGE_KEYCODE_BUTTON_11, INPUT_USAGE_KEYCODE_BUTTON_12, INPUT_USAGE_KEYCODE_BUTTON_13, INPUT_USAGE_KEYCODE_BUTTON_14, INPUT_USAGE_KEYCODE_BUTTON_15, INPUT_USAGE_KEYCODE_BUTTON_16, INPUT_USAGE_KEYCODE_LANGUAGE_SWITCH, INPUT_USAGE_KEYCODE_MANNER_MODE, INPUT_USAGE_KEYCODE_3D_MODE, INPUT_USAGE_KEYCODE_CONTACTS, INPUT_USAGE_KEYCODE_CALENDAR, INPUT_USAGE_KEYCODE_MUSIC, INPUT_USAGE_KEYCODE_CALCULATOR, INPUT_USAGE_KEYCODE_ZENKAKU_HANKAKU, INPUT_USAGE_KEYCODE_EISU, INPUT_USAGE_KEYCODE_MUHENKAN, INPUT_USAGE_KEYCODE_HENKAN, INPUT_USAGE_KEYCODE_KATAKANA_HIRAGANA, INPUT_USAGE_KEYCODE_YEN, INPUT_USAGE_KEYCODE_RO, INPUT_USAGE_KEYCODE_KANA, INPUT_USAGE_KEYCODE_ASSIST, INPUT_USAGE_KEYCODE_BRIGHTNESS_DOWN, INPUT_USAGE_KEYCODE_BRIGHTNESS_UP, INPUT_USAGE_KEYCODE_MEDIA_AUDIO_TRACK, INPUT_USAGE_KEYCODE_SLEEP, INPUT_USAGE_KEYCODE_WAKEUP, INPUT_USAGE_KEYCODE_PAIRING, INPUT_USAGE_KEYCODE_MEDIA_TOP_MENU, INPUT_USAGE_KEYCODE_11, INPUT_USAGE_KEYCODE_12, INPUT_USAGE_KEYCODE_LAST_CHANNEL, INPUT_USAGE_KEYCODE_TV_DATA_SERVICE, INPUT_USAGE_KEYCODE_VOICE_ASSIST, INPUT_USAGE_KEYCODE_TV_RADIO_SERVICE, INPUT_USAGE_KEYCODE_TV_TELETEXT, INPUT_USAGE_KEYCODE_TV_NUMBER_ENTRY, INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_ANALOG, INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_DIGITAL, INPUT_USAGE_KEYCODE_TV_SATELLITE, INPUT_USAGE_KEYCODE_TV_SATELLITE_BS, INPUT_USAGE_KEYCODE_TV_SATELLITE_CS, INPUT_USAGE_KEYCODE_TV_SATELLITE_SERVICE, INPUT_USAGE_KEYCODE_TV_NETWORK, INPUT_USAGE_KEYCODE_TV_ANTENNA_CABLE, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_1, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_2, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_3, INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_4, INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_1, INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_2, INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_1, INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_2, INPUT_USAGE_KEYCODE_TV_INPUT_VGA_1, INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION, INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP, INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN, INPUT_USAGE_KEYCODE_TV_ZOOM_MODE, INPUT_USAGE_KEYCODE_TV_CONTENTS_MENU, INPUT_USAGE_KEYCODE_TV_MEDIA_CONTEXT_MENU, INPUT_USAGE_KEYCODE_TV_TIMER_PROGRAMMING, INPUT_USAGE_KEYCODE_HELP, // axes INPUT_USAGE_AXIS_X, INPUT_USAGE_AXIS_Y, INPUT_USAGE_AXIS_PRESSURE, INPUT_USAGE_AXIS_SIZE, INPUT_USAGE_AXIS_TOUCH_MAJOR, INPUT_USAGE_AXIS_TOUCH_MINOR, INPUT_USAGE_AXIS_TOOL_MAJOR, INPUT_USAGE_AXIS_TOOL_MINOR, INPUT_USAGE_AXIS_ORIENTATION, INPUT_USAGE_AXIS_VSCROLL, INPUT_USAGE_AXIS_HSCROLL, INPUT_USAGE_AXIS_Z, INPUT_USAGE_AXIS_RX, INPUT_USAGE_AXIS_RY, INPUT_USAGE_AXIS_RZ, INPUT_USAGE_AXIS_HAT_X, INPUT_USAGE_AXIS_HAT_Y, INPUT_USAGE_AXIS_LTRIGGER, INPUT_USAGE_AXIS_RTRIGGER, INPUT_USAGE_AXIS_THROTTLE, INPUT_USAGE_AXIS_RUDDER, INPUT_USAGE_AXIS_WHEEL, INPUT_USAGE_AXIS_GAS, INPUT_USAGE_AXIS_BRAKE, INPUT_USAGE_AXIS_DISTANCE, INPUT_USAGE_AXIS_TILT, INPUT_USAGE_AXIS_GENERIC_1, INPUT_USAGE_AXIS_GENERIC_2, INPUT_USAGE_AXIS_GENERIC_3, INPUT_USAGE_AXIS_GENERIC_4, INPUT_USAGE_AXIS_GENERIC_5, INPUT_USAGE_AXIS_GENERIC_6, INPUT_USAGE_AXIS_GENERIC_7, INPUT_USAGE_AXIS_GENERIC_8, INPUT_USAGE_AXIS_GENERIC_9, INPUT_USAGE_AXIS_GENERIC_10, INPUT_USAGE_AXIS_GENERIC_11, INPUT_USAGE_AXIS_GENERIC_12, INPUT_USAGE_AXIS_GENERIC_13, INPUT_USAGE_AXIS_GENERIC_14, INPUT_USAGE_AXIS_GENERIC_15, INPUT_USAGE_AXIS_GENERIC_16, // leds INPUT_USAGE_LED_NUM_LOCK, INPUT_USAGE_LED_CAPS_LOCK, INPUT_USAGE_LED_SCROLL_LOCK, INPUT_USAGE_LED_COMPOSE, INPUT_USAGE_LED_KANA, INPUT_USAGE_LED_SLEEP, INPUT_USAGE_LED_SUSPEND, INPUT_USAGE_LED_MUTE, INPUT_USAGE_LED_MISC, INPUT_USAGE_LED_MAIL, INPUT_USAGE_LED_CHARGING, INPUT_USAGE_LED_CONTROLLER_1, INPUT_USAGE_LED_CONTROLLER_2, INPUT_USAGE_LED_CONTROLLER_3, INPUT_USAGE_LED_CONTROLLER_4, } input_usage_t; typedef enum { INPUT_COLLECTION_ID_TOUCH, INPUT_COLLECTION_ID_KEYBOARD, INPUT_COLLECTION_ID_MOUSE, INPUT_COLLECTION_ID_TOUCHPAD, // etc } input_collection_id_t; typedef struct input_message input_message_t; typedef struct input_host_callbacks { /** * Creates a device identifier with the given properties. * The unique ID should be a string that precisely identifies a given piece of hardware. For * example, an input device connected via Bluetooth could use its MAC address as its unique ID. */ input_device_identifier_t* (*create_device_identifier)(input_host_t* host, const char* name, int32_t product_id, int32_t vendor_id, input_bus_t bus, const char* unique_id); /** * Allocates the device definition which will describe the input capabilities of a device. A * device definition may be used to register as many devices as desired. */ input_device_definition_t* (*create_device_definition)(input_host_t* host); /** * Allocate either an input report, which the HAL will use to tell the host of incoming input * events, or an output report, which the host will use to tell the HAL of desired state * changes (e.g. setting an LED). */ input_report_definition_t* (*create_input_report_definition)(input_host_t* host); input_report_definition_t* (*create_output_report_definition)(input_host_t* host); /** * Append the report to the given input device. */ void (*input_device_definition_add_report)(input_host_t* host, input_device_definition_t* d, input_report_definition_t* r); /** * Add a collection with the given arity and ID. A collection describes a set * of logically grouped properties such as the X and Y coordinates of a single finger touch or * the set of keys on a keyboard. The arity declares how many repeated instances of this * collection will appear in whatever report it is attached to. The ID describes the type of * grouping being represented by the collection. For example, a touchscreen capable of * reporting up to 2 fingers simultaneously might have a collection with the X and Y * coordinates, an arity of 2, and an ID of INPUT_COLLECTION_USAGE_TOUCHSCREEN. Any given ID * may only be present once for a given report. */ void (*input_report_definition_add_collection)(input_host_t* host, input_report_definition_t* report, input_collection_id_t id, int32_t arity); /** * Declare an int usage with the given properties. The report and collection defines where the * usage is being declared. */ void (*input_report_definition_declare_usage_int)(input_host_t* host, input_report_definition_t* report, input_collection_id_t id, input_usage_t usage, int32_t min, int32_t max, float resolution); /** * Declare a set of boolean usages with the given properties. The report and collection * defines where the usages are being declared. */ void (*input_report_definition_declare_usages_bool)(input_host_t* host, input_report_definition_t* report, input_collection_id_t id, input_usage_t* usage, size_t usage_count); /** * Register a given input device definition. This notifies the host that an input device has * been connected and gives a description of all its capabilities. */ input_device_handle_t* (*register_device)(input_host_t* host, input_device_identifier_t* id, input_device_definition_t* d); /** Unregister the given device */ void (*unregister_device)(input_host_t* host, input_device_handle_t* handle); /** * Allocate a report that will contain all of the state as described by the given report. */ input_report_t* (*input_allocate_report)(input_host_t* host, input_report_definition_t* r); /** * Add an int usage value to a report. */ void (*input_report_set_usage_int)(input_host_t* host, input_report_t* r, input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index); /** * Add a boolean usage value to a report. */ void (*input_report_set_usage_bool)(input_host_t* host, input_report_t* r, input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index); void (*report_event)(input_host_t* host, input_device_handle_t* d, input_report_t* report); /** * Retrieve the set of properties for the device. The returned * input_property_map_t* may be used to query specific properties via the * input_get_device_property callback. */ input_property_map_t* (*input_get_device_property_map)(input_host_t* host, input_device_identifier_t* id); /** * Retrieve a property for the device with the given key. Returns NULL if * the key does not exist, or an input_property_t* that must be freed using * input_free_device_property(). Using an input_property_t after the * corresponding input_property_map_t is freed is undefined. */ input_property_t* (*input_get_device_property)(input_host_t* host, input_property_map_t* map, const char* key); /** * Get the key for the input property. Returns NULL if the property is NULL. * The returned const char* is owned by the input_property_t. */ const char* (*input_get_property_key)(input_host_t* host, input_property_t* property); /** * Get the value for the input property. Returns NULL if the property is * NULL. The returned const char* is owned by the input_property_t. */ const char* (*input_get_property_value)(input_host_t* host, input_property_t* property); /** * Frees the input_property_t*. */ void (*input_free_device_property)(input_host_t* host, input_property_t* property); /** * Frees the input_property_map_t*. */ void (*input_free_device_property_map)(input_host_t* host, input_property_map_t* map); } input_host_callbacks_t; typedef struct input_module input_module_t; struct input_module { /** * Common methods of the input module. This *must* be the first member * of input_module as users of this structure will cast a hw_module_t * to input_module pointer in contexts where it's known * the hw_module_t references a input_module. */ struct hw_module_t common; /** * Initialize the module with host callbacks. At this point the HAL should start up whatever * infrastructure it needs to in order to process input events. */ void (*init)(const input_module_t* module, input_host_t* host, input_host_callbacks_t cb); /** * Sends an output report with a new set of state the host would like the given device to * assume. */ void (*notify_report)(const input_module_t* module, input_report_t* report); }; static inline int input_open(const struct hw_module_t** module, const char* type) { return hw_get_module_by_class(INPUT_HARDWARE_MODULE_ID, type, module); } __END_DECLS #endif /* ANDROID_INCLUDE_HARDWARE_INPUT_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/keymaster0.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_KEYMASTER_0_H #define ANDROID_HARDWARE_KEYMASTER_0_H #include __BEGIN_DECLS /** * Keymaster0 device definition. */ struct keymaster0_device { /** * Common methods of the keymaster device. This *must* be the first member of * keymaster0_device as users of this structure will cast a hw_device_t to * keymaster0_device pointer in contexts where it's known the hw_device_t references a * keymaster0_device. */ struct hw_device_t common; /** * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version" * fields in the keymaster_module initialization instead. */ uint32_t client_version; /** * See flags defined for keymaster0_device::flags in keymaster_common.h */ uint32_t flags; void* context; /** * Generates a public and private key. The key-blob returned is opaque * and must subsequently provided for signing and verification. * * Returns: 0 on success or an error code less than 0. */ int (*generate_keypair)(const struct keymaster0_device* dev, const keymaster_keypair_t key_type, const void* key_params, uint8_t** key_blob, size_t* key_blob_length); /** * Imports a public and private key pair. The imported keys will be in * PKCS#8 format with DER encoding (Java standard). The key-blob * returned is opaque and will be subsequently provided for signing * and verification. * * Returns: 0 on success or an error code less than 0. */ int (*import_keypair)(const struct keymaster0_device* dev, const uint8_t* key, const size_t key_length, uint8_t** key_blob, size_t* key_blob_length); /** * Gets the public key part of a key pair. The public key must be in * X.509 format (Java standard) encoded byte array. * * Returns: 0 on success or an error code less than 0. * On error, x509_data should not be allocated. */ int (*get_keypair_public)(const struct keymaster0_device* dev, const uint8_t* key_blob, const size_t key_blob_length, uint8_t** x509_data, size_t* x509_data_length); /** * Deletes the key pair associated with the key blob. * * This function is optional and should be set to NULL if it is not * implemented. * * Returns 0 on success or an error code less than 0. */ int (*delete_keypair)(const struct keymaster0_device* dev, const uint8_t* key_blob, const size_t key_blob_length); /** * Deletes all keys in the hardware keystore. Used when keystore is * reset completely. * * This function is optional and should be set to NULL if it is not * implemented. * * Returns 0 on success or an error code less than 0. */ int (*delete_all)(const struct keymaster0_device* dev); /** * Signs data using a key-blob generated before. This can use either * an asymmetric key or a secret key. * * Returns: 0 on success or an error code less than 0. */ int (*sign_data)(const struct keymaster0_device* dev, const void* signing_params, const uint8_t* key_blob, const size_t key_blob_length, const uint8_t* data, const size_t data_length, uint8_t** signed_data, size_t* signed_data_length); /** * Verifies data signed with a key-blob. This can use either * an asymmetric key or a secret key. * * Returns: 0 on successful verification or an error code less than 0. */ int (*verify_data)(const struct keymaster0_device* dev, const void* signing_params, const uint8_t* key_blob, const size_t key_blob_length, const uint8_t* signed_data, const size_t signed_data_length, const uint8_t* signature, const size_t signature_length); }; typedef struct keymaster0_device keymaster0_device_t; /* Convenience API for opening and closing keymaster devices */ static inline int keymaster0_open(const struct hw_module_t* module, keymaster0_device_t** device) { int rc = module->methods->open(module, KEYSTORE_KEYMASTER, (struct hw_device_t**) device); return rc; } static inline int keymaster0_close(keymaster0_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_HARDWARE_KEYMASTER_0_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/keymaster1.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_KEYMASTER1_H #define ANDROID_HARDWARE_KEYMASTER1_H #include #include __BEGIN_DECLS /** * Keymaster1 device definition */ struct keymaster1_device { /** * Common methods of the keymaster device. This *must* be the first member of * keymaster_device as users of this structure will cast a hw_device_t to * keymaster_device pointer in contexts where it's known the hw_device_t references a * keymaster_device. */ struct hw_device_t common; /** * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version" * fields in the keymaster_module initialization instead. */ uint32_t client_version; /** * See flags defined for keymaster0_devices::flags in keymaster_common.h */ uint32_t flags; void* context; /** * \deprecated Generates a public and private key. The key-blob returned is opaque and must * subsequently provided for signing and verification. * * Returns: 0 on success or an error code less than 0. */ int (*generate_keypair)(const struct keymaster1_device* dev, const keymaster_keypair_t key_type, const void* key_params, uint8_t** key_blob, size_t* key_blob_length); /** * \deprecated Imports a public and private key pair. The imported keys will be in PKCS#8 format * with DER encoding (Java standard). The key-blob returned is opaque and will be subsequently * provided for signing and verification. * * Returns: 0 on success or an error code less than 0. */ int (*import_keypair)(const struct keymaster1_device* dev, const uint8_t* key, const size_t key_length, uint8_t** key_blob, size_t* key_blob_length); /** * \deprecated Gets the public key part of a key pair. The public key must be in X.509 format * (Java standard) encoded byte array. * * Returns: 0 on success or an error code less than 0. On error, x509_data * should not be allocated. */ int (*get_keypair_public)(const struct keymaster1_device* dev, const uint8_t* key_blob, const size_t key_blob_length, uint8_t** x509_data, size_t* x509_data_length); /** * \deprecated Deletes the key pair associated with the key blob. * * This function is optional and should be set to NULL if it is not * implemented. * * Returns 0 on success or an error code less than 0. */ int (*delete_keypair)(const struct keymaster1_device* dev, const uint8_t* key_blob, const size_t key_blob_length); /** * \deprecated Deletes all keys in the hardware keystore. Used when keystore is reset * completely. * * This function is optional and should be set to NULL if it is not * implemented. * * Returns 0 on success or an error code less than 0. */ int (*delete_all)(const struct keymaster1_device* dev); /** * \deprecated Signs data using a key-blob generated before. This can use either an asymmetric * key or a secret key. * * Returns: 0 on success or an error code less than 0. */ int (*sign_data)(const struct keymaster1_device* dev, const void* signing_params, const uint8_t* key_blob, const size_t key_blob_length, const uint8_t* data, const size_t data_length, uint8_t** signed_data, size_t* signed_data_length); /** * \deprecated Verifies data signed with a key-blob. This can use either an asymmetric key or a * secret key. * * Returns: 0 on successful verification or an error code less than 0. */ int (*verify_data)(const struct keymaster1_device* dev, const void* signing_params, const uint8_t* key_blob, const size_t key_blob_length, const uint8_t* signed_data, const size_t signed_data_length, const uint8_t* signature, const size_t signature_length); /** * Gets algorithms supported. * * \param[in] dev The keymaster device structure. * * \param[out] algorithms Array of algorithms supported. The caller takes ownership of the * array and must free() it. * * \param[out] algorithms_length Length of \p algorithms. */ keymaster_error_t (*get_supported_algorithms)(const struct keymaster1_device* dev, keymaster_algorithm_t** algorithms, size_t* algorithms_length); /** * Gets the block modes supported for the specified algorithm. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported modes will be returned. * * \param[out] modes Array of modes supported. The caller takes ownership of the array and must * free() it. * * \param[out] modes_length Length of \p modes. */ keymaster_error_t (*get_supported_block_modes)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_purpose_t purpose, keymaster_block_mode_t** modes, size_t* modes_length); /** * Gets the padding modes supported for the specified algorithm. Caller assumes ownership of * the allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported padding modes will be returned. * * \param[out] modes Array of padding modes supported. The caller takes ownership of the array * and must free() it. * * \param[out] modes_length Length of \p modes. */ keymaster_error_t (*get_supported_padding_modes)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_purpose_t purpose, keymaster_padding_t** modes, size_t* modes_length); /** * Gets the digests supported for the specified algorithm. Caller assumes ownership of the * allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported digests will be returned. * * \param[out] digests Array of digests supported. The caller takes ownership of the array and * must free() it. * * \param[out] digests_length Length of \p digests. */ keymaster_error_t (*get_supported_digests)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_purpose_t purpose, keymaster_digest_t** digests, size_t* digests_length); /** * Gets the key import formats supported for keys of the specified algorithm. Caller assumes * ownership of the allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported formats will be returned. * * \param[out] formats Array of formats supported. The caller takes ownership of the array and * must free() it. * * \param[out] formats_length Length of \p formats. */ keymaster_error_t (*get_supported_import_formats)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_key_format_t** formats, size_t* formats_length); /** * Gets the key export formats supported for keys of the specified algorithm. Caller assumes * ownership of the allocated array. * * \param[in] dev The keymaster device structure. * * \param[in] algorithm The algorithm for which supported formats will be returned. * * \param[out] formats Array of formats supported. The caller takes ownership of the array and * must free() it. * * \param[out] formats_length Length of \p formats. */ keymaster_error_t (*get_supported_export_formats)(const struct keymaster1_device* dev, keymaster_algorithm_t algorithm, keymaster_key_format_t** formats, size_t* formats_length); /** * Adds entropy to the RNG used by keymaster. Entropy added through this method is guaranteed * not to be the only source of entropy used, and the mixing function is required to be secure, * in the sense that if the RNG is seeded (from any source) with any data the attacker cannot * predict (or control), then the RNG output is indistinguishable from random. Thus, if the * entropy from any source is good, the output will be good. * * \param[in] dev The keymaster device structure. * * \param[in] data Random data to be mixed in. * * \param[in] data_length Length of \p data. */ keymaster_error_t (*add_rng_entropy)(const struct keymaster1_device* dev, const uint8_t* data, size_t data_length); /** * Generates a key, or key pair, returning a key blob and/or a description of the key. * * Key generation parameters are defined as keymaster tag/value pairs, provided in \p params. * See keymaster_tag_t for the full list. Some values that are always required for generation * of useful keys are: * * - KM_TAG_ALGORITHM; * - KM_TAG_PURPOSE; and * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED. * * KM_TAG_AUTH_TIMEOUT should generally be specified unless KM_TAG_NO_AUTH_REQUIRED is present, * or the user will have to authenticate for every use. * * KM_TAG_BLOCK_MODE, KM_TAG_PADDING, KM_TAG_MAC_LENGTH and KM_TAG_DIGEST must be specified for * algorithms that require them. * * The following tags may not be specified; their values will be provided by the implementation. * * - KM_TAG_ORIGIN, * - KM_TAG_ROLLBACK_RESISTANT, * - KM_TAG_CREATION_DATETIME * * \param[in] dev The keymaster device structure. * * \param[in] params Array of key generation parameters. * * \param[in] params_count Length of \p params. * * \param[out] key_blob returns the generated key. \p key_blob must not be NULL. The caller * assumes ownership key_blob->key_material and must free() it. * * \param[out] characteristics returns the characteristics of the key that was, generated, if * non-NULL. If non-NULL, the caller assumes ownership and must deallocate with * keymaster_free_characteristics(). Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and * KM_TAG_APPLICATION_DATA are never returned. */ keymaster_error_t (*generate_key)(const struct keymaster1_device* dev, const keymaster_key_param_set_t* params, keymaster_key_blob_t* key_blob, keymaster_key_characteristics_t** characteristics); /** * Returns the characteristics of the specified key, or KM_ERROR_INVALID_KEY_BLOB if the * key_blob is invalid (implementations must fully validate the integrity of the key). * client_id and app_data must be the ID and data provided when the key was generated or * imported, or empty if KM_TAG_APPLICATION_ID and/or KM_TAG_APPLICATION_DATA were not provided * during generation. Those values are not included in the returned characteristics. The * caller assumes ownership of the allocated characteristics object, which must be deallocated * with keymaster_free_characteristics(). * * Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never * returned. * * \param[in] dev The keymaster device structure. * * \param[in] key_blob The key to retreive characteristics from. * * \param[in] client_id The client ID data, or NULL if none associated. * * \param[in] app_id The app data, or NULL if none associated. * * \param[out] characteristics The key characteristics. */ keymaster_error_t (*get_key_characteristics)(const struct keymaster1_device* dev, const keymaster_key_blob_t* key_blob, const keymaster_blob_t* client_id, const keymaster_blob_t* app_data, keymaster_key_characteristics_t** characteristics); /** * Imports a key, or key pair, returning a key blob and/or a description of the key. * * Most key import parameters are defined as keymaster tag/value pairs, provided in "params". * See keymaster_tag_t for the full list. Values that are always required for import of useful * keys are: * * - KM_TAG_ALGORITHM; * - KM_TAG_PURPOSE; and * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED. * * KM_TAG_AUTH_TIMEOUT should generally be specified. If unspecified, the user will have to * authenticate for every use. * * The following tags will take default values if unspecified: * * - KM_TAG_KEY_SIZE will default to the size of the key provided. * - KM_TAG_RSA_PUBLIC_EXPONENT will default to the value in the key provided (for RSA keys) * * The following tags may not be specified; their values will be provided by the implementation. * * - KM_TAG_ORIGIN, * - KM_TAG_ROLLBACK_RESISTANT, * - KM_TAG_CREATION_DATETIME * * \param[in] dev The keymaster device structure. * * \param[in] params Parameters defining the imported key. * * \param[in] params_count The number of entries in \p params. * * \param[in] key_format specifies the format of the key data in key_data. * * \param[out] key_blob Used to return the opaque key blob. Must be non-NULL. The caller * assumes ownership of the contained key_material. * * \param[out] characteristics Used to return the characteristics of the imported key. May be * NULL, in which case no characteristics will be returned. If non-NULL, the caller assumes * ownership and must deallocate with keymaster_free_characteristics(). Note that * KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and * KM_TAG_APPLICATION_DATA are never returned. */ keymaster_error_t (*import_key)(const struct keymaster1_device* dev, const keymaster_key_param_set_t* params, keymaster_key_format_t key_format, const keymaster_blob_t* key_data, keymaster_key_blob_t* key_blob, keymaster_key_characteristics_t** characteristics); /** * Exports a public key, returning a byte array in the specified format. * * \param[in] dev The keymaster device structure. * * \param[in] export_format The format to be used for exporting the key. * * \param[in] key_to_export The key to export. * * \param[out] export_data The exported key material. The caller assumes ownership. * * \param[out] export_data_length The length of \p export_data. */ keymaster_error_t (*export_key)(const struct keymaster1_device* dev, keymaster_key_format_t export_format, const keymaster_key_blob_t* key_to_export, const keymaster_blob_t* client_id, const keymaster_blob_t* app_data, keymaster_blob_t* export_data); /** * Deletes the key, or key pair, associated with the key blob. After calling this function it * will be impossible to use the key for any other operations. May be applied to keys from * foreign roots of trust (keys not usable under the current root of trust). * * This function is optional and should be set to NULL if it is not implemented. * * \param[in] dev The keymaster device structure. * * \param[in] key The key to be deleted. */ keymaster_error_t (*delete_key)(const struct keymaster1_device* dev, const keymaster_key_blob_t* key); /** * Deletes all keys in the hardware keystore. Used when keystore is reset completely. After * calling this function it will be impossible to use any previously generated or imported key * blobs for any operations. * * This function is optional and should be set to NULL if it is not implemented. * * \param[in] dev The keymaster device structure. */ keymaster_error_t (*delete_all_keys)(const struct keymaster1_device* dev); /** * Begins a cryptographic operation using the specified key. If all is well, begin() will * return KM_ERROR_OK and create an operation handle which must be passed to subsequent calls to * update(), finish() or abort(). * * It is critical that each call to begin() be paired with a subsequent call to finish() or * abort(), to allow the keymaster implementation to clean up any internal operation state. * Failure to do this may leak internal state space or other internal resources and may * eventually cause begin() to return KM_ERROR_TOO_MANY_OPERATIONS when it runs out of space for * operations. Any result other than KM_ERROR_OK from begin(), update() or finish() implicitly * aborts the operation, in which case abort() need not be called (and will return * KM_ERROR_INVALID_OPERATION_HANDLE if called). * * \param[in] dev The keymaster device structure. * * \param[in] purpose The purpose of the operation, one of KM_PURPOSE_ENCRYPT, * KM_PURPOSE_DECRYPT, KM_PURPOSE_SIGN or KM_PURPOSE_VERIFY. Note that for AEAD modes, * encryption and decryption imply signing and verification, respectively, but should be * specified as KM_PURPOSE_ENCRYPT and KM_PURPOSE_DECRYPT. * * \param[in] key The key to be used for the operation. \p key must have a purpose compatible * with \p purpose and all of its usage requirements must be satisfied, or begin() will return * an appropriate error code. * * \param[in] in_params Additional parameters for the operation. This is typically used to * provide authentication data, with KM_TAG_AUTH_TOKEN. If KM_TAG_APPLICATION_ID or * KM_TAG_APPLICATION_DATA were provided during generation, they must be provided here, or the * operation will fail with KM_ERROR_INVALID_KEY_BLOB. For operations that require a nonce or * IV, on keys that were generated with KM_TAG_CALLER_NONCE, in_params may contain a tag * KM_TAG_NONCE. For AEAD operations KM_TAG_CHUNK_SIZE is specified here. * * \param[out] out_params Output parameters. Used to return additional data from the operation * initialization, notably to return the IV or nonce from operations that generate an IV or * nonce. The caller takes ownership of the output parameters array and must free it with * keymaster_free_param_set(). out_params may be set to NULL if no output parameters are * expected. If out_params is NULL, and output paramaters are generated, begin() will return * KM_ERROR_OUTPUT_PARAMETER_NULL. * * \param[out] operation_handle The newly-created operation handle which must be passed to * update(), finish() or abort(). If operation_handle is NULL, begin() will return * KM_ERROR_OUTPUT_PARAMETER_NULL. */ keymaster_error_t (*begin)(const struct keymaster1_device* dev, keymaster_purpose_t purpose, const keymaster_key_blob_t* key, const keymaster_key_param_set_t* in_params, keymaster_key_param_set_t* out_params, keymaster_operation_handle_t* operation_handle); /** * Provides data to, and possibly receives output from, an ongoing cryptographic operation begun * with begin(). * * If operation_handle is invalid, update() will return KM_ERROR_INVALID_OPERATION_HANDLE. * * update() may not consume all of the data provided in the data buffer. update() will return * the amount consumed in *data_consumed. The caller should provide the unconsumed data in a * subsequent call. * * \param[in] dev The keymaster device structure. * * \param[in] operation_handle The operation handle returned by begin(). * * \param[in] in_params Additional parameters for the operation. For AEAD modes, this is used * to specify KM_TAG_ADDITIONAL_DATA. Note that additional data may be provided in multiple * calls to update(), but only until input data has been provided. * * \param[in] input Data to be processed, per the parameters established in the call to begin(). * Note that update() may or may not consume all of the data provided. See \p input_consumed. * * \param[out] input_consumed Amount of data that was consumed by update(). If this is less * than the amount provided, the caller should provide the remainder in a subsequent call to * update(). * * \param[out] out_params Output parameters. Used to return additional data from the operation * The caller takes ownership of the output parameters array and must free it with * keymaster_free_param_set(). out_params may be set to NULL if no output parameters are * expected. If out_params is NULL, and output paramaters are generated, begin() will return * KM_ERROR_OUTPUT_PARAMETER_NULL. * * \param[out] output The output data, if any. The caller assumes ownership of the allocated * buffer. output must not be NULL. * * Note that update() may not provide any output, in which case output->data_length will be * zero, and output->data may be either NULL or zero-length (so the caller should always free() * it). */ keymaster_error_t (*update)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle, const keymaster_key_param_set_t* in_params, const keymaster_blob_t* input, size_t* input_consumed, keymaster_key_param_set_t* out_params, keymaster_blob_t* output); /** * Finalizes a cryptographic operation begun with begin() and invalidates \p operation_handle. * * \param[in] dev The keymaster device structure. * * \param[in] operation_handle The operation handle returned by begin(). This handle will be * invalidated. * * \param[in] params Additional parameters for the operation. For AEAD modes, this is used to * specify KM_TAG_ADDITIONAL_DATA, but only if no input data was provided to update(). * * \param[in] signature The signature to be verified if the purpose specified in the begin() * call was KM_PURPOSE_VERIFY. * * \param[out] output The output data, if any. The caller assumes ownership of the allocated * buffer. * * If the operation being finished is a signature verification or an AEAD-mode decryption and * verification fails then finish() will return KM_ERROR_VERIFICATION_FAILED. */ keymaster_error_t (*finish)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle, const keymaster_key_param_set_t* in_params, const keymaster_blob_t* signature, keymaster_key_param_set_t* out_params, keymaster_blob_t* output); /** * Aborts a cryptographic operation begun with begin(), freeing all internal resources and * invalidating \p operation_handle. */ keymaster_error_t (*abort)(const struct keymaster1_device* dev, keymaster_operation_handle_t operation_handle); /** * Generates a pair of ATTK defined in SOTER. Save the private key into RPMB. * Note that the ATTK generated will never be touched outside the keymaster. * * \param[in] dev The keymaster device structure. * * \param[in] copy_num The number of copies that will be saved in the RPMB. */ keymaster_error_t (*generate_attk_key_pair)(const struct keymaster1_device* dev, const uint8_t copy_num); /** * Verify the existance ATTK defined in SOTER. * * \param[in] dev The keymaster device structure. * * Returns: 0 if the ATTK exists. */ keymaster_error_t (*verify_attk_key_pair)(const struct keymaster1_device* dev); /** * Export the public key of ATTK in PEM format. * * \param[in] dev The keymaster device structure. * * \param[out] pub_key_data The public key data in X.509v3 format PEM encoded * * \param[out] pub_key_data_length The length of the public key data. */ keymaster_error_t (*export_attk_public_key)(const struct keymaster1_device* dev, const uint8_t* pub_key_data, const size_t pub_key_data_length); /** * Get Unique device ID. * * \param[in] dev The keymaster device structure. * * \param[out] device_id The unique id for each device, format as below: * 1.bytes 0-3: Identify each silicon provider id. * 2.bytes 4-7: SoC model ID, defined by each silicon provider * 3.bytes 8-15: Public Chip Serial *Number of SoC, defined by each silicon provider * * \param[out] device_id_length The length of the device id. */ keymaster_error_t (*get_device_id)(const struct keymaster1_device* dev, const uint8_t* device_id, const size_t device_id_length); }; typedef struct keymaster1_device keymaster1_device_t; /* Convenience API for opening and closing keymaster devices */ static inline int keymaster1_open(const struct hw_module_t* module, keymaster1_device_t** device) { return module->methods->open(module, KEYSTORE_KEYMASTER, (struct hw_device_t**)device); } static inline int keymaster1_close(keymaster1_device_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_HARDWARE_KEYMASTER1_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/keymaster_common.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_KEYMASTER_COMMON_H #define ANDROID_HARDWARE_KEYMASTER_COMMON_H #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define KEYSTORE_HARDWARE_MODULE_ID "keystore" #define KEYSTORE_KEYMASTER "keymaster" /** * Settings for "module_api_version" and "hal_api_version" * fields in the keymaster_module initialization. */ /** * Keymaster 0.X module version provide the same APIs, but later versions add more options * for algorithms and flags. */ #define KEYMASTER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define KEYMASTER_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION(0, 2) #define KEYMASTER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) #define KEYMASTER_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION(0, 3) /** * Keymaster 1.0 module version provides a completely different API, incompatible with 0.X. */ #define KEYMASTER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define KEYMASTER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) struct keystore_module { /** * Common methods of the keystore module. This *must* be the first member of keystore_module as * users of this structure will cast a hw_module_t to keystore_module pointer in contexts where * it's known the hw_module_t references a keystore_module. */ hw_module_t common; /* There are no keystore module methods other than the common ones. */ }; /** * Flags for keymaster0_device::flags */ enum { /* * Indicates this keymaster implementation does not have hardware that * keeps private keys out of user space. * * This should not be implemented on anything other than the default * implementation. */ KEYMASTER_SOFTWARE_ONLY = 1 << 0, /* * This indicates that the key blobs returned via all the primitives * are sufficient to operate on their own without the trusted OS * querying userspace to retrieve some other data. Key blobs of * this type are normally returned encrypted with a * Key Encryption Key (KEK). * * This is currently used by "vold" to know whether the whole disk * encryption secret can be unwrapped without having some external * service started up beforehand since the "/data" partition will * be unavailable at that point. */ KEYMASTER_BLOBS_ARE_STANDALONE = 1 << 1, /* * Indicates that the keymaster module supports DSA keys. */ KEYMASTER_SUPPORTS_DSA = 1 << 2, /* * Indicates that the keymaster module supports EC keys. */ KEYMASTER_SUPPORTS_EC = 1 << 3, }; /** * Asymmetric key pair types. */ typedef enum { TYPE_RSA = 1, TYPE_DSA = 2, TYPE_EC = 3, } keymaster_keypair_t; /** * Parameters needed to generate an RSA key. */ typedef struct { uint32_t modulus_size; uint64_t public_exponent; } keymaster_rsa_keygen_params_t; /** * Parameters needed to generate a DSA key. */ typedef struct { uint32_t key_size; uint32_t generator_len; uint32_t prime_p_len; uint32_t prime_q_len; const uint8_t* generator; const uint8_t* prime_p; const uint8_t* prime_q; } keymaster_dsa_keygen_params_t; /** * Parameters needed to generate an EC key. * * Field size is the only parameter in version 2. The sizes correspond to these required curves: * * 192 = NIST P-192 * 224 = NIST P-224 * 256 = NIST P-256 * 384 = NIST P-384 * 521 = NIST P-521 * * The parameters for these curves are available at: http://www.nsa.gov/ia/_files/nist-routines.pdf * in Chapter 4. */ typedef struct { uint32_t field_size; } keymaster_ec_keygen_params_t; /** * Digest type. */ typedef enum { DIGEST_NONE, } keymaster_digest_algorithm_t; /** * Type of padding used for RSA operations. */ typedef enum { PADDING_NONE, } keymaster_rsa_padding_t; typedef struct { keymaster_digest_algorithm_t digest_type; } keymaster_dsa_sign_params_t; typedef struct { keymaster_digest_algorithm_t digest_type; } keymaster_ec_sign_params_t; typedef struct { keymaster_digest_algorithm_t digest_type; keymaster_rsa_padding_t padding_type; } keymaster_rsa_sign_params_t; __END_DECLS #endif // ANDROID_HARDWARE_KEYMASTER_COMMON_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/keymaster_defs.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HARDWARE_KEYMASTER_DEFS_H #define ANDROID_HARDWARE_KEYMASTER_DEFS_H #include #include #include #ifdef __cplusplus extern "C" { #endif // __cplusplus /** * Authorization tags each have an associated type. This enumeration facilitates tagging each with * a type, by using the high four bits (of an implied 32-bit unsigned enum value) to specify up to * 16 data types. These values are ORed with tag IDs to generate the final tag ID values. */ typedef enum { KM_INVALID = 0 << 28, /* Invalid type, used to designate a tag as uninitialized */ KM_ENUM = 1 << 28, KM_ENUM_REP = 2 << 28, /* Repeatable enumeration value. */ KM_UINT = 3 << 28, KM_UINT_REP = 4 << 28, /* Repeatable integer value */ KM_ULONG = 5 << 28, KM_DATE = 6 << 28, KM_BOOL = 7 << 28, KM_BIGNUM = 8 << 28, KM_BYTES = 9 << 28, KM_ULONG_REP = 10 << 28, /* Repeatable long value */ } keymaster_tag_type_t; typedef enum { KM_TAG_INVALID = KM_INVALID | 0, /* * Tags that must be semantically enforced by hardware and software implementations. */ /* Crypto parameters */ KM_TAG_PURPOSE = KM_ENUM_REP | 1, /* keymaster_purpose_t. */ KM_TAG_ALGORITHM = KM_ENUM | 2, /* keymaster_algorithm_t. */ KM_TAG_KEY_SIZE = KM_UINT | 3, /* Key size in bits. */ KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4, /* keymaster_block_mode_t. */ KM_TAG_DIGEST = KM_ENUM_REP | 5, /* keymaster_digest_t. */ KM_TAG_PADDING = KM_ENUM_REP | 6, /* keymaster_padding_t. */ KM_TAG_CALLER_NONCE = KM_BOOL | 7, /* Allow caller to specify nonce or IV. */ KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8, /* Minimum length of MAC or AEAD authentication tag in * bits. */ /* Algorithm-specific. */ KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200, /* Other hardware-enforced. */ KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 301, /* keymaster_key_blob_usage_requirements_t */ KM_TAG_BOOTLOADER_ONLY = KM_BOOL | 302, /* Usable only by bootloader */ /* * Tags that should be semantically enforced by hardware if possible and will otherwise be * enforced by software (keystore). */ /* Key validity period */ KM_TAG_ACTIVE_DATETIME = KM_DATE | 400, /* Start of validity */ KM_TAG_ORIGINATION_EXPIRE_DATETIME = KM_DATE | 401, /* Date when new "messages" should no longer be created. */ KM_TAG_USAGE_EXPIRE_DATETIME = KM_DATE | 402, /* Date when existing "messages" should no longer be trusted. */ KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_UINT | 403, /* Minimum elapsed time between cryptographic operations with the key. */ KM_TAG_MAX_USES_PER_BOOT = KM_UINT | 404, /* Number of times the key can be used per boot. */ /* User authentication */ KM_TAG_ALL_USERS = KM_BOOL | 500, /* Reserved for future use -- ignore */ KM_TAG_USER_ID = KM_UINT | 501, /* Reserved for future use -- ignore */ KM_TAG_USER_SECURE_ID = KM_ULONG_REP | 502, /* Secure ID of authorized user or authenticator(s). Disallowed if KM_TAG_ALL_USERS or KM_TAG_NO_AUTH_REQUIRED is present. */ KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 503, /* If key is usable without authentication. */ KM_TAG_USER_AUTH_TYPE = KM_ENUM | 504, /* Bitmask of authenticator types allowed when * KM_TAG_USER_SECURE_ID contains a secure user ID, * rather than a secure authenticator ID. Defined in * hw_authenticator_type_t in hw_auth_token.h. */ KM_TAG_AUTH_TIMEOUT = KM_UINT | 505, /* Required freshness of user authentication for private/secret key operations, in seconds. Public key operations require no authentication. If absent, authentication is required for every use. Authentication state is lost when the device is powered off. */ /* Application access control */ KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Reserved for future use -- ignore */ KM_TAG_APPLICATION_ID = KM_BYTES | 601, /* Reserved for fugure use -- ignore */ /* * Semantically unenforceable tags, either because they have no specific meaning or because * they're informational only. */ KM_TAG_APPLICATION_DATA = KM_BYTES | 700, /* Data provided by authorized application. */ KM_TAG_CREATION_DATETIME = KM_DATE | 701, /* Key creation time */ KM_TAG_ORIGIN = KM_ENUM | 702, /* keymaster_key_origin_t. */ KM_TAG_ROLLBACK_RESISTANT = KM_BOOL | 703, /* Whether key is rollback-resistant. */ KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704, /* Root of trust ID. */ /* Tags used only to provide data to or receive data from operations */ KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000, /* Used to provide associated data for AEAD modes. */ KM_TAG_NONCE = KM_BYTES | 1001, /* Nonce or Initialization Vector */ KM_TAG_AUTH_TOKEN = KM_BYTES | 1002, /* Authentication token that proves secure user authentication has been performed. Structure defined in hw_auth_token_t in hw_auth_token.h. */ KM_TAG_MAC_LENGTH = KM_UINT | 1003, /* MAC or AEAD authentication tag length in bits. */ /* Tags used only for SOTER */ /* Tags used only to check if the key is for SOTER */ KM_TAG_SOTER_IS_FROM_SOTER = KM_BOOL | 11000, /* Attach signature signed with ATTK[pri] while exporting public key */ KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_ATTK_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11001, /* Attach signature signed with specified private key while exporting public key */ KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_COMMON_KEY_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11002, /* keyalias for the keypair of KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_COMMON_KEY_WHEN_GET_PUBLIC_KEY */ KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY = KM_BYTES | 11003, /* Attach counter while exporting publick key */ KM_TAG_SOTER_AUTO_ADD_COUNTER_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11004, /* Attach secmsg(TEE_Name, TEE_Version, Fingerprint_Sensor_Name, Fingerprint_Sensor_Version) fingerprint_id and counter while signing */ KM_TAG_SOTER_IS_SECMSG_FID_COUNTER_SIGNED_WHEN_SIGN = KM_BOOL | 11005, /* use and set ATTK index to next backup ATTK */ KM_TAG_SOTER_USE_NEXT_ATTK = KM_BOOL | 11006, /* attach soter uid */ KM_TAG_SOTER_UID = KM_UINT | 11007, /* attach key blob of KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY if needed */ KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY_BLOB = KM_BYTES | 11008, } keymaster_tag_t; /** * Algorithms that may be provided by keymaster implementations. Those that must be provided by all * implementations are tagged as "required". */ typedef enum { /* Asymmetric algorithms. */ KM_ALGORITHM_RSA = 1, // KM_ALGORITHM_DSA = 2, -- Removed, do not re-use value 2. KM_ALGORITHM_EC = 3, /* Block ciphers algorithms */ KM_ALGORITHM_AES = 32, /* MAC algorithms */ KM_ALGORITHM_HMAC = 128, } keymaster_algorithm_t; /** * Symmetric block cipher modes provided by keymaster implementations. */ typedef enum { /* Unauthenticated modes, usable only for encryption/decryption and not generally recommended * except for compatibility with existing other protocols. */ KM_MODE_ECB = 1, KM_MODE_CBC = 2, KM_MODE_CTR = 3, /* Authenticated modes, usable for encryption/decryption and signing/verification. Recommended * over unauthenticated modes for all purposes. */ KM_MODE_GCM = 32, } keymaster_block_mode_t; /** * Padding modes that may be applied to plaintext for encryption operations. This list includes * padding modes for both symmetric and asymmetric algorithms. Note that implementations should not * provide all possible combinations of algorithm and padding, only the * cryptographically-appropriate pairs. */ typedef enum { KM_PAD_NONE = 1, /* deprecated */ KM_PAD_RSA_OAEP = 2, KM_PAD_RSA_PSS = 3, KM_PAD_RSA_PKCS1_1_5_ENCRYPT = 4, KM_PAD_RSA_PKCS1_1_5_SIGN = 5, KM_PAD_PKCS7 = 64, } keymaster_padding_t; /** * Digests provided by keymaster implementations. */ typedef enum { KM_DIGEST_NONE = 0, KM_DIGEST_MD5 = 1, /* Optional, may not be implemented in hardware, will be handled in software * if needed. */ KM_DIGEST_SHA1 = 2, KM_DIGEST_SHA_2_224 = 3, KM_DIGEST_SHA_2_256 = 4, KM_DIGEST_SHA_2_384 = 5, KM_DIGEST_SHA_2_512 = 6, } keymaster_digest_t; /** * The origin of a key (or pair), i.e. where it was generated. Note that KM_TAG_ORIGIN can be found * in either the hardware-enforced or software-enforced list for a key, indicating whether the key * is hardware or software-based. Specifically, a key with KM_ORIGIN_GENERATED in the * hardware-enforced list is guaranteed never to have existed outide the secure hardware. */ typedef enum { KM_ORIGIN_GENERATED = 0, /* Generated in keymaster */ KM_ORIGIN_IMPORTED = 2, /* Imported, origin unknown */ KM_ORIGIN_UNKNOWN = 3, /* Keymaster did not record origin. This value can only be seen on * keys in a keymaster0 implementation. The keymaster0 adapter uses * this value to document the fact that it is unkown whether the key * was generated inside or imported into keymaster. */ } keymaster_key_origin_t; /** * Usability requirements of key blobs. This defines what system functionality must be available * for the key to function. For example, key "blobs" which are actually handles referencing * encrypted key material stored in the file system cannot be used until the file system is * available, and should have BLOB_REQUIRES_FILE_SYSTEM. Other requirements entries will be added * as needed for implementations. This type is new in 0_4. */ typedef enum { KM_BLOB_STANDALONE = 0, KM_BLOB_REQUIRES_FILE_SYSTEM = 1, } keymaster_key_blob_usage_requirements_t; /** * Possible purposes of a key (or pair). This type is new in 0_4. */ typedef enum { KM_PURPOSE_ENCRYPT = 0, KM_PURPOSE_DECRYPT = 1, KM_PURPOSE_SIGN = 2, KM_PURPOSE_VERIFY = 3, } keymaster_purpose_t; typedef struct { const uint8_t* data; size_t data_length; } keymaster_blob_t; typedef struct { keymaster_tag_t tag; union { uint32_t enumerated; /* KM_ENUM and KM_ENUM_REP */ bool boolean; /* KM_BOOL */ uint32_t integer; /* KM_INT and KM_INT_REP */ uint64_t long_integer; /* KM_LONG */ uint64_t date_time; /* KM_DATE */ keymaster_blob_t blob; /* KM_BIGNUM and KM_BYTES*/ }; } keymaster_key_param_t; typedef struct { keymaster_key_param_t* params; /* may be NULL if length == 0 */ size_t length; } keymaster_key_param_set_t; /** * Parameters that define a key's characteristics, including authorized modes of usage and access * control restrictions. The parameters are divided into two categories, those that are enforced by * secure hardware, and those that are not. For a software-only keymaster implementation the * enforced array must NULL. Hardware implementations must enforce everything in the enforced * array. */ typedef struct { keymaster_key_param_set_t hw_enforced; keymaster_key_param_set_t sw_enforced; } keymaster_key_characteristics_t; typedef struct { const uint8_t* key_material; size_t key_material_size; } keymaster_key_blob_t; /** * Formats for key import and export. At present, only asymmetric key import/export is supported. * In the future this list will expand greatly to accommodate asymmetric key import/export. */ typedef enum { KM_KEY_FORMAT_X509 = 0, /* for public key export */ KM_KEY_FORMAT_PKCS8 = 1, /* for asymmetric key pair import */ KM_KEY_FORMAT_RAW = 3, /* for symmetric key import */ } keymaster_key_format_t; /** * The keymaster operation API consists of begin, update, finish and abort. This is the type of the * handle used to tie the sequence of calls together. A 64-bit value is used because it's important * that handles not be predictable. Implementations must use strong random numbers for handle * values. */ typedef uint64_t keymaster_operation_handle_t; typedef enum { KM_ERROR_OK = 0, KM_ERROR_ROOT_OF_TRUST_ALREADY_SET = -1, KM_ERROR_UNSUPPORTED_PURPOSE = -2, KM_ERROR_INCOMPATIBLE_PURPOSE = -3, KM_ERROR_UNSUPPORTED_ALGORITHM = -4, KM_ERROR_INCOMPATIBLE_ALGORITHM = -5, KM_ERROR_UNSUPPORTED_KEY_SIZE = -6, KM_ERROR_UNSUPPORTED_BLOCK_MODE = -7, KM_ERROR_INCOMPATIBLE_BLOCK_MODE = -8, KM_ERROR_UNSUPPORTED_MAC_LENGTH = -9, KM_ERROR_UNSUPPORTED_PADDING_MODE = -10, KM_ERROR_INCOMPATIBLE_PADDING_MODE = -11, KM_ERROR_UNSUPPORTED_DIGEST = -12, KM_ERROR_INCOMPATIBLE_DIGEST = -13, KM_ERROR_INVALID_EXPIRATION_TIME = -14, KM_ERROR_INVALID_USER_ID = -15, KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT = -16, KM_ERROR_UNSUPPORTED_KEY_FORMAT = -17, KM_ERROR_INCOMPATIBLE_KEY_FORMAT = -18, KM_ERROR_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = -19, /* For PKCS8 & PKCS12 */ KM_ERROR_UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = -20, /* For PKCS8 & PKCS12 */ KM_ERROR_INVALID_INPUT_LENGTH = -21, KM_ERROR_KEY_EXPORT_OPTIONS_INVALID = -22, KM_ERROR_DELEGATION_NOT_ALLOWED = -23, KM_ERROR_KEY_NOT_YET_VALID = -24, KM_ERROR_KEY_EXPIRED = -25, KM_ERROR_KEY_USER_NOT_AUTHENTICATED = -26, KM_ERROR_OUTPUT_PARAMETER_NULL = -27, KM_ERROR_INVALID_OPERATION_HANDLE = -28, KM_ERROR_INSUFFICIENT_BUFFER_SPACE = -29, KM_ERROR_VERIFICATION_FAILED = -30, KM_ERROR_TOO_MANY_OPERATIONS = -31, KM_ERROR_UNEXPECTED_NULL_POINTER = -32, KM_ERROR_INVALID_KEY_BLOB = -33, KM_ERROR_IMPORTED_KEY_NOT_ENCRYPTED = -34, KM_ERROR_IMPORTED_KEY_DECRYPTION_FAILED = -35, KM_ERROR_IMPORTED_KEY_NOT_SIGNED = -36, KM_ERROR_IMPORTED_KEY_VERIFICATION_FAILED = -37, KM_ERROR_INVALID_ARGUMENT = -38, KM_ERROR_UNSUPPORTED_TAG = -39, KM_ERROR_INVALID_TAG = -40, KM_ERROR_MEMORY_ALLOCATION_FAILED = -41, KM_ERROR_IMPORT_PARAMETER_MISMATCH = -44, KM_ERROR_SECURE_HW_ACCESS_DENIED = -45, KM_ERROR_OPERATION_CANCELLED = -46, KM_ERROR_CONCURRENT_ACCESS_CONFLICT = -47, KM_ERROR_SECURE_HW_BUSY = -48, KM_ERROR_SECURE_HW_COMMUNICATION_FAILED = -49, KM_ERROR_UNSUPPORTED_EC_FIELD = -50, KM_ERROR_MISSING_NONCE = -51, KM_ERROR_INVALID_NONCE = -52, KM_ERROR_MISSING_MAC_LENGTH = -53, KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = -54, KM_ERROR_CALLER_NONCE_PROHIBITED = -55, KM_ERROR_KEY_MAX_OPS_EXCEEDED = -56, KM_ERROR_INVALID_MAC_LENGTH = -57, KM_ERROR_MISSING_MIN_MAC_LENGTH = -58, KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59, KM_ERROR_UNIMPLEMENTED = -100, KM_ERROR_VERSION_MISMATCH = -101, /* Additional error codes may be added by implementations, but implementers should coordinate * with Google to avoid code collision. */ KM_ERROR_UNKNOWN_ERROR = -1000, } keymaster_error_t; /* Convenience functions for manipulating keymaster tag types */ static inline keymaster_tag_type_t keymaster_tag_get_type(keymaster_tag_t tag) { return (keymaster_tag_type_t)(tag & (0xF << 28)); } static inline uint32_t keymaster_tag_mask_type(keymaster_tag_t tag) { return tag & 0x0FFFFFFF; } static inline bool keymaster_tag_type_repeatable(keymaster_tag_type_t type) { switch (type) { case KM_UINT_REP: case KM_ENUM_REP: return true; default: return false; } } static inline bool keymaster_tag_repeatable(keymaster_tag_t tag) { return keymaster_tag_type_repeatable(keymaster_tag_get_type(tag)); } /* Convenience functions for manipulating keymaster_key_param_t structs */ inline keymaster_key_param_t keymaster_param_enum(keymaster_tag_t tag, uint32_t value) { // assert(keymaster_tag_get_type(tag) == KM_ENUM || keymaster_tag_get_type(tag) == KM_ENUM_REP); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.enumerated = value; return param; } inline keymaster_key_param_t keymaster_param_int(keymaster_tag_t tag, uint32_t value) { // assert(keymaster_tag_get_type(tag) == KM_INT || keymaster_tag_get_type(tag) == KM_INT_REP); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.integer = value; return param; } inline keymaster_key_param_t keymaster_param_long(keymaster_tag_t tag, uint64_t value) { // assert(keymaster_tag_get_type(tag) == KM_LONG); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.long_integer = value; return param; } inline keymaster_key_param_t keymaster_param_blob(keymaster_tag_t tag, const uint8_t* bytes, size_t bytes_len) { // assert(keymaster_tag_get_type(tag) == KM_BYTES || keymaster_tag_get_type(tag) == KM_BIGNUM); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.blob.data = (uint8_t*)bytes; param.blob.data_length = bytes_len; return param; } inline keymaster_key_param_t keymaster_param_bool(keymaster_tag_t tag) { // assert(keymaster_tag_get_type(tag) == KM_BOOL); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.boolean = true; return param; } inline keymaster_key_param_t keymaster_param_date(keymaster_tag_t tag, uint64_t value) { // assert(keymaster_tag_get_type(tag) == KM_DATE); keymaster_key_param_t param; memset(¶m, 0, sizeof(param)); param.tag = tag; param.date_time = value; return param; } #define KEYMASTER_SIMPLE_COMPARE(a, b) (a < b) ? -1 : ((a > b) ? 1 : 0) inline int keymaster_param_compare(const keymaster_key_param_t* a, const keymaster_key_param_t* b) { int retval = KEYMASTER_SIMPLE_COMPARE(a->tag, b->tag); if (retval != 0) return retval; switch (keymaster_tag_get_type(a->tag)) { case KM_INVALID: case KM_BOOL: return 0; case KM_ENUM: case KM_ENUM_REP: return KEYMASTER_SIMPLE_COMPARE(a->enumerated, b->enumerated); case KM_UINT: case KM_UINT_REP: return KEYMASTER_SIMPLE_COMPARE(a->integer, b->integer); case KM_ULONG: case KM_ULONG_REP: return KEYMASTER_SIMPLE_COMPARE(a->long_integer, b->long_integer); case KM_DATE: return KEYMASTER_SIMPLE_COMPARE(a->date_time, b->date_time); case KM_BIGNUM: case KM_BYTES: // Handle the empty cases. if (a->blob.data_length != 0 && b->blob.data_length == 0) return -1; if (a->blob.data_length == 0 && b->blob.data_length == 0) return 0; if (a->blob.data_length == 0 && b->blob.data_length > 0) return 1; retval = memcmp(a->blob.data, b->blob.data, a->blob.data_length < b->blob.data_length ? a->blob.data_length : b->blob.data_length); if (retval != 0) return retval; else if (a->blob.data_length != b->blob.data_length) { // Equal up to the common length; longer one is larger. if (a->blob.data_length < b->blob.data_length) return -1; if (a->blob.data_length > b->blob.data_length) return 1; }; } return 0; } #undef KEYMASTER_SIMPLE_COMPARE inline void keymaster_free_param_values(keymaster_key_param_t* param, size_t param_count) { while (param_count-- > 0) { switch (keymaster_tag_get_type(param->tag)) { case KM_BIGNUM: case KM_BYTES: free((void*)param->blob.data); param->blob.data = NULL; break; default: // NOP break; } ++param; } } inline void keymaster_free_param_set(keymaster_key_param_set_t* set) { if (set) { keymaster_free_param_values(set->params, set->length); free(set->params); set->params = NULL; } } inline void keymaster_free_characteristics(keymaster_key_characteristics_t* characteristics) { if (characteristics) { keymaster_free_param_set(&characteristics->hw_enforced); keymaster_free_param_set(&characteristics->sw_enforced); } } #ifdef __cplusplus } // extern "C" #endif // __cplusplus #endif // ANDROID_HARDWARE_KEYMASTER_DEFS_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/lights.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_LIGHTS_INTERFACE_H #define ANDROID_LIGHTS_INTERFACE_H #include #include #include #include __BEGIN_DECLS /** * The id of this module */ #define LIGHTS_HARDWARE_MODULE_ID "lights" /* * These light IDs correspond to logical lights, not physical. * So for example, if your INDICATOR light is in line with your * BUTTONS, it might make sense to also light the INDICATOR * light to a reasonable color when the BUTTONS are lit. */ #define LIGHT_ID_BACKLIGHT "backlight" #define LIGHT_ID_KEYBOARD "keyboard" #define LIGHT_ID_BUTTONS "buttons" #define LIGHT_ID_BATTERY "battery" #define LIGHT_ID_NOTIFICATIONS "notifications" #define LIGHT_ID_ATTENTION "attention" /* * These lights aren't currently supported by the higher * layers, but could be someday, so we have the constants * here now. */ #define LIGHT_ID_BLUETOOTH "bluetooth" #define LIGHT_ID_WIFI "wifi" /* * Additional hardware-specific lights */ #define LIGHT_ID_CAPS "caps" #define LIGHT_ID_FUNC "func" /* ************************************************************************ * Flash modes for the flashMode field of light_state_t. */ #define LIGHT_FLASH_NONE 0 /** * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED, * and then flashOnMS should be set to the number of milliseconds to turn * the light on, followed by the number of milliseconds to turn the light * off. */ #define LIGHT_FLASH_TIMED 1 /** * To flash the light using hardware assist, set flashMode to * the hardware mode. */ #define LIGHT_FLASH_HARDWARE 2 /** * Light brightness is managed by a user setting. */ #define BRIGHTNESS_MODE_USER 0 /** * Light brightness is managed by a light sensor. */ #define BRIGHTNESS_MODE_SENSOR 1 /** * Light mode allows multiple LEDs */ #define LIGHT_MODE_MULTIPLE_LEDS 0x01 /** * The parameters that can be set for a given light. * * Not all lights must support all parameters. If you * can do something backward-compatible, you should. */ struct light_state_t { /** * The color of the LED in ARGB. * * Do your best here. * - If your light can only do red or green, if they ask for blue, * you should do green. * - If you can only do a brightness ramp, then use this formula: * unsigned char brightness = ((77*((color>>16)&0x00ff)) * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; * - If you can only do on or off, 0 is off, anything else is on. * * The high byte should be ignored. Callers will set it to 0xff (which * would correspond to 255 alpha). * * CyanogenMod: The high byte value can be implemented to control the LEDs * Brightness from the Lights settings. The value goes from 0x01 to 0xFF. */ unsigned int color; /** * See the LIGHT_FLASH_* constants */ int flashMode; int flashOnMS; int flashOffMS; /** * Policy used by the framework to manage the light's brightness. * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. */ int brightnessMode; /** * Define the LEDs modes (multiple, ...). * See the LIGHTS_MODE_* mask constants. */ unsigned int ledsModes; }; struct light_device_t { struct hw_device_t common; /** * Set the provided lights to the provided values. * * Returns: 0 on succes, error code on failure. */ int (*set_light)(struct light_device_t* dev, struct light_state_t const* state); }; __END_DECLS #endif // ANDROID_LIGHTS_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/local_time_hal.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_LOCAL_TIME_HAL_INTERFACE_H #define ANDROID_LOCAL_TIME_HAL_INTERFACE_H #include #include __BEGIN_DECLS /** * The id of this module */ #define LOCAL_TIME_HARDWARE_MODULE_ID "local_time" /** * Name of the local time devices to open */ #define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if" /**********************************************************************/ /** * A structure used to collect low level sync data in a lab environment. Most * HAL implementations will never need this structure. */ struct local_time_debug_event { int64_t local_timesync_event_id; int64_t local_time; }; /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ struct local_time_module { struct hw_module_t common; }; struct local_time_hw_device { /** * Common methods of the local time hardware device. This *must* be the first member of * local_time_hw_device as users of this structure will cast a hw_device_t to * local_time_hw_device pointer in contexts where it's known the hw_device_t references a * local_time_hw_device. */ struct hw_device_t common; /** * * Returns the current value of the system wide local time counter */ int64_t (*get_local_time)(struct local_time_hw_device* dev); /** * * Returns the nominal frequency (in hertz) of the system wide local time * counter */ uint64_t (*get_local_freq)(struct local_time_hw_device* dev); /** * * Sets the HW slew rate of oscillator which drives the system wide local * time counter. On success, platforms should return 0. Platforms which * do not support HW slew should leave this method set to NULL. * * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform * implementations should attempt map this range linearly to the min/max * slew rate of their hardware. */ int (*set_local_slew)(struct local_time_hw_device* dev, int16_t rate); /** * * A method used to collect low level sync data in a lab environments. * Most HAL implementations will simply set this member to NULL, or return * -EINVAL to indicate that this functionality is not supported. * Production HALs should never support this method. */ int (*get_debug_log)(struct local_time_hw_device* dev, struct local_time_debug_event* records, int max_records); }; typedef struct local_time_hw_device local_time_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int local_time_hw_device_open( const struct hw_module_t* module, struct local_time_hw_device** device) { return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int local_time_hw_device_close(struct local_time_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_LOCAL_TIME_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/memtrack.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_MEMTRACK_H #define ANDROID_INCLUDE_HARDWARE_MEMTRACK_H #include #include #include #include __BEGIN_DECLS #define MEMTRACK_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) /** * The id of this module */ #define MEMTRACK_HARDWARE_MODULE_ID "memtrack" /* * The Memory Tracker HAL is designed to return information about device-specific * memory usage. The primary goal is to be able to track memory that is not * trackable in any other way, for example texture memory that is allocated by * a process, but not mapped in to that process' address space. * A secondary goal is to be able to categorize memory used by a process into * GL, graphics, etc. All memory sizes should be in real memory usage, * accounting for stride, bit depth, rounding up to page size, etc. * * A process collecting memory statistics will call getMemory for each * combination of pid and memory type. For each memory type that it recognizes * the HAL should fill out an array of memtrack_record structures breaking * down the statistics of that memory type as much as possible. For example, * getMemory(, MEMTRACK_TYPE_GL) might return: * { { 4096, ACCOUNTED | PRIVATE | SYSTEM }, * { 40960, UNACCOUNTED | PRIVATE | SYSTEM }, * { 8192, ACCOUNTED | PRIVATE | DEDICATED }, * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } } * If the HAL could not differentiate between SYSTEM and DEDICATED memory, it * could return: * { { 12288, ACCOUNTED | PRIVATE }, * { 49152, UNACCOUNTED | PRIVATE } } * * Memory should not overlap between types. For example, a graphics buffer * that has been mapped into the GPU as a surface should show up when * MEMTRACK_TYPE_GRAPHICS is requested, and not when MEMTRACK_TYPE_GL * is requested. */ enum memtrack_type { MEMTRACK_TYPE_OTHER = 0, MEMTRACK_TYPE_GL = 1, MEMTRACK_TYPE_GRAPHICS = 2, MEMTRACK_TYPE_MULTIMEDIA = 3, MEMTRACK_TYPE_CAMERA = 4, MEMTRACK_NUM_TYPES, }; struct memtrack_record { size_t size_in_bytes; unsigned int flags; }; /** * Flags to differentiate memory that can already be accounted for in * /proc//smaps, * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size). * In general, memory mapped in to a userspace process is accounted unless * it was mapped with remap_pfn_range. * Exactly one of these should be set. */ #define MEMTRACK_FLAG_SMAPS_ACCOUNTED (1 << 1) #define MEMTRACK_FLAG_SMAPS_UNACCOUNTED (1 << 2) /** * Flags to differentiate memory shared across multiple processes vs. memory * used by a single process. Only zero or one of these may be set in a record. * If none are set, record is assumed to count shared + private memory. */ #define MEMTRACK_FLAG_SHARED (1 << 3) #define MEMTRACK_FLAG_SHARED_PSS (1 << 4) /* shared / num_procesess */ #define MEMTRACK_FLAG_PRIVATE (1 << 5) /** * Flags to differentiate memory taken from the kernel's allocation pool vs. * memory that is dedicated to non-kernel allocations, for example a carveout * or separate video memory. Only zero or one of these may be set in a record. * If none are set, record is assumed to count system + dedicated memory. */ #define MEMTRACK_FLAG_SYSTEM (1 << 6) #define MEMTRACK_FLAG_DEDICATED (1 << 7) /** * Flags to differentiate memory accessible by the CPU in non-secure mode vs. * memory that is protected. Only zero or one of these may be set in a record. * If none are set, record is assumed to count secure + nonsecure memory. */ #define MEMTRACK_FLAG_NONSECURE (1 << 8) #define MEMTRACK_FLAG_SECURE (1 << 9) /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct memtrack_module { struct hw_module_t common; /** * (*init)() performs memtrack management setup actions and is called * once before any calls to getMemory(). * Returns 0 on success, -errno on error. */ int (*init)(const struct memtrack_module *module); /** * (*getMemory)() expects an array of record objects and populates up to * *num_record structures with the sizes of memory plus associated flags for * that memory. It also updates *num_records with the total number of * records it could return if *num_records was large enough when passed in. * Returning records with size 0 is expected, the number of records should * not vary between calls to getMemory for the same memory type, even * for different pids. * * The caller will often call getMemory for a type and pid with * *num_records == 0 to determine how many records to allocate room for, * this case should be a fast-path in the HAL, returning a constant and * not querying any kernel files. If *num_records passed in is 0, * then records may be NULL. * * This function must be thread-safe, it may get called from multiple * threads at the same time. * * Returns 0 on success, -ENODEV if the type is not supported, -errno * on other errors. */ int (*getMemory)(const struct memtrack_module *module, pid_t pid, int type, struct memtrack_record *records, size_t *num_records); } memtrack_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_MEMTRACK_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/nfc.h ================================================ /* * Copyright (C) 2011, 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_NFC_HAL_INTERFACE_H #define ANDROID_NFC_HAL_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /* NFC device HAL for NCI-based NFC controllers. * * This HAL allows NCI silicon vendors to make use * of the core NCI stack in Android for their own silicon. * * The responibilities of the NCI HAL implementation * are as follows: * * - Implement the transport to the NFC controller * - Implement each of the HAL methods specified below as applicable to their silicon * - Pass up received NCI messages from the controller to the stack * * A simplified timeline of NCI HAL method calls: * 1) Core NCI stack calls open() * 2) Core NCI stack executes CORE_RESET and CORE_INIT through calls to write() * 3) Core NCI stack calls core_initialized() to allow HAL to do post-init configuration * 4) Core NCI stack calls pre_discover() to allow HAL to prepare for RF discovery * 5) Core NCI stack starts discovery through calls to write() * 6) Core NCI stack stops discovery through calls to write() (e.g. screen turns off) * 7) Core NCI stack calls pre_discover() to prepare for RF discovery (e.g. screen turned back on) * 8) Core NCI stack starts discovery through calls to write() * ... * ... * 9) Core NCI stack calls close() */ #define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" #define NFC_NCI_BCM2079X_HARDWARE_MODULE_ID "nfc_nci.bcm2079x" #define NFC_NCI_NXP_PN54X_HARDWARE_MODULE_ID "nfc_nci.pn54x" #define NFC_NCI_CONTROLLER "nci" /* * nfc_nci_module_t should contain module-specific parameters */ typedef struct nfc_nci_module_t { /** * Common methods of the NFC NCI module. This *must* be the first member of * nfc_nci_module_t as users of this structure will cast a hw_module_t to * nfc_nci_module_t pointer in contexts where it's known the hw_module_t references a * nfc_nci_module_t. */ struct hw_module_t common; } nfc_nci_module_t; /* * HAL events that can be passed back to the stack */ typedef uint8_t nfc_event_t; enum { HAL_NFC_OPEN_CPLT_EVT = 0x00, HAL_NFC_CLOSE_CPLT_EVT = 0x01, HAL_NFC_POST_INIT_CPLT_EVT = 0x02, HAL_NFC_PRE_DISCOVER_CPLT_EVT = 0x03, HAL_NFC_REQUEST_CONTROL_EVT = 0x04, HAL_NFC_RELEASE_CONTROL_EVT = 0x05, HAL_NFC_ERROR_EVT = 0x06 }; /* * Allowed status return values for each of the HAL methods */ typedef uint8_t nfc_status_t; enum { HAL_NFC_STATUS_OK = 0x00, HAL_NFC_STATUS_FAILED = 0x01, HAL_NFC_STATUS_ERR_TRANSPORT = 0x02, HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 0x03, HAL_NFC_STATUS_REFUSED = 0x04 }; /* * The callback passed in from the NFC stack that the HAL * can use to pass events back to the stack. */ typedef void (nfc_stack_callback_t) (nfc_event_t event, nfc_status_t event_status); /* * The callback passed in from the NFC stack that the HAL * can use to pass incomming data to the stack. */ typedef void (nfc_stack_data_callback_t) (uint16_t data_len, uint8_t* p_data); /* nfc_nci_device_t starts with a hw_device_t struct, * followed by device-specific methods and members. * * All methods in the NCI HAL are asynchronous. */ typedef struct nfc_nci_device { /** * Common methods of the NFC NCI device. This *must* be the first member of * nfc_nci_device_t as users of this structure will cast a hw_device_t to * nfc_nci_device_t pointer in contexts where it's known the hw_device_t references a * nfc_nci_device_t. */ struct hw_device_t common; /* * (*open)() Opens the NFC controller device and performs initialization. * This may include patch download and other vendor-specific initialization. * * If open completes successfully, the controller should be ready to perform * NCI initialization - ie accept CORE_RESET and subsequent commands through * the write() call. * * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT * before continuing. * * If open() returns any other value, the NCI stack will stop. * */ int (*open)(const struct nfc_nci_device *p_dev, nfc_stack_callback_t *p_cback, nfc_stack_data_callback_t *p_data_cback); /* * (*write)() Performs an NCI write. * * This method may queue writes and return immediately. The only * requirement is that the writes are executed in order. */ int (*write)(const struct nfc_nci_device *p_dev, uint16_t data_len, const uint8_t *p_data); /* * (*core_initialized)() is called after the CORE_INIT_RSP is received from the NFCC. * At this time, the HAL can do any chip-specific configuration. * * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT * before continuing. * * If core_initialized() returns any other value, the NCI stack will continue * immediately. */ int (*core_initialized)(const struct nfc_nci_device *p_dev, uint8_t* p_core_init_rsp_params); /* * (*pre_discover)() Is called every time before starting RF discovery. * It is a good place to do vendor-specific configuration that must be * performed every time RF discovery is about to be started. * * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT * before continuing. * * If pre_discover() returns any other value, the NCI stack will start * RF discovery immediately. */ int (*pre_discover)(const struct nfc_nci_device *p_dev); /* * (*close)() Closed the NFC controller. Should free all resources. */ int (*close)(const struct nfc_nci_device *p_dev); /* * (*control_granted)() Grant HAL the exclusive control to send NCI commands. * Called in response to HAL_REQUEST_CONTROL_EVT. * Must only be called when there are no NCI commands pending. * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control. */ int (*control_granted)(const struct nfc_nci_device *p_dev); /* * (*power_cycle)() Restart controller by power cyle; * HAL_OPEN_CPLT_EVT will notify when operation is complete. */ int (*power_cycle)(const struct nfc_nci_device *p_dev); } nfc_nci_device_t; /* * Convenience methods that the NFC stack can use to open * and close an NCI device */ static inline int nfc_nci_open(const struct hw_module_t* module, nfc_nci_device_t** dev) { return module->methods->open(module, NFC_NCI_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_nci_close(nfc_nci_device_t* dev) { return dev->common.close(&dev->common); } /* * End NFC NCI HAL */ /* * This is a limited NFC HAL for NXP PN544-based devices. * This HAL as Android is moving to * an NCI-based NFC stack. * * All NCI-based NFC controllers should use the NFC-NCI * HAL instead. * Begin PN544 specific HAL */ #define NFC_HARDWARE_MODULE_ID "nfc" #define NFC_PN544_CONTROLLER "pn544" typedef struct nfc_module_t { /** * Common methods of the NFC NXP PN544 module. This *must* be the first member of * nfc_module_t as users of this structure will cast a hw_module_t to * nfc_module_t pointer in contexts where it's known the hw_module_t references a * nfc_module_t. */ struct hw_module_t common; } nfc_module_t; /* * PN544 linktypes. * UART * I2C * USB (uses UART DAL) */ typedef enum { PN544_LINK_TYPE_UART, PN544_LINK_TYPE_I2C, PN544_LINK_TYPE_USB, PN544_LINK_TYPE_INVALID, } nfc_pn544_linktype; typedef struct { /** * Common methods of the NFC NXP PN544 device. This *must* be the first member of * nfc_pn544_device_t as users of this structure will cast a hw_device_t to * nfc_pn544_device_t pointer in contexts where it's known the hw_device_t references a * nfc_pn544_device_t. */ struct hw_device_t common; /* The number of EEPROM registers to write */ uint32_t num_eeprom_settings; /* The actual EEPROM settings * For PN544, each EEPROM setting is a 4-byte entry, * of the format [0x00, addr_msb, addr_lsb, value]. */ uint8_t* eeprom_settings; /* The link type to which the PN544 is connected */ nfc_pn544_linktype linktype; /* The device node to which the PN544 is connected */ const char* device_node; /* On Crespo we had an I2C issue that would cause us to sometimes read * the I2C slave address (0x57) over the bus. libnfc contains * a hack to ignore this byte and try to read the length byte * again. * Set to 0 to disable the workaround, 1 to enable it. */ uint8_t enable_i2c_workaround; /* I2C slave address. Multiple I2C addresses are * possible for PN544 module. Configure address according to * board design. */ uint8_t i2c_device_address; } nfc_pn544_device_t; static inline int nfc_pn544_open(const struct hw_module_t* module, nfc_pn544_device_t** dev) { return module->methods->open(module, NFC_PN544_CONTROLLER, (struct hw_device_t**) dev); } static inline int nfc_pn544_close(nfc_pn544_device_t* dev) { return dev->common.close(&dev->common); } /* * End PN544 specific HAL */ __END_DECLS #endif // ANDROID_NFC_HAL_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/nfc_tag.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_NFC_TAG_HAL_INTERFACE_H #define ANDROID_NFC_TAG_HAL_INTERFACE_H #include #include __BEGIN_DECLS /* * HAL for programmable NFC tags. * */ #define NFC_TAG_HARDWARE_MODULE_ID "nfc_tag" #define NFC_TAG_ID "tag" typedef struct nfc_tag_module_t { /** * Common methods of the NFC tag module. This *must* be the first member of * nfc_tag_module_t as users of this structure will cast a hw_module_t to * nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a * nfc_tag_module_t. */ struct hw_module_t common; } nfc_tag_module_t; typedef struct nfc_tag_device { /** * Common methods of the NFC tag device. This *must* be the first member of * nfc_tag_device_t as users of this structure will cast a hw_device_t to * nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a * nfc_tag_device_t. */ struct hw_device_t common; /** * Initialize the NFC tag. * * The driver must: * * Set the static lock bytes to read only * * Configure the Capability Container to disable write acess * eg: 0xE1 0x10 0x0F * * This function is called once before any calls to setContent(). * * Return 0 on success or -errno on error. */ int (*init)(const struct nfc_tag_device *dev); /** * Set the NFC tag content. * * The driver must write in the data area of the tag starting at * byte 0 of block 4 and zero the rest of the data area. * * Returns 0 on success or -errno on error. */ int (*setContent)(const struct nfc_tag_device *dev, const uint8_t *data, size_t len); /** * Returns the memory size of the data area. */ int (*getMemorySize)(const struct nfc_tag_device *dev); } nfc_tag_device_t; static inline int nfc_tag_open(const struct hw_module_t* module, nfc_tag_device_t** dev) { return module->methods->open(module, NFC_TAG_ID, (struct hw_device_t**)dev); } static inline int nfc_tag_close(nfc_tag_device_t* dev) { return dev->common.close(&dev->common); } __END_DECLS #endif // ANDROID_NFC_TAG_HAL_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/power.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_POWER_H #define ANDROID_INCLUDE_HARDWARE_POWER_H #include #include #include #include __BEGIN_DECLS #define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) #define POWER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) /** * The id of this module */ #define POWER_HARDWARE_MODULE_ID "power" /* * Power hint identifiers passed to (*powerHint) */ typedef enum { POWER_HINT_VSYNC = 0x00000001, POWER_HINT_INTERACTION = 0x00000002, /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in * KLP. */ POWER_HINT_VIDEO_ENCODE = 0x00000003, POWER_HINT_VIDEO_DECODE = 0x00000004, POWER_HINT_LOW_POWER = 0x00000005, POWER_HINT_CAM_PREVIEW = 0x00000006, POWER_HINT_CPU_BOOST = 0x00000010, POWER_HINT_LAUNCH_BOOST = 0x00000011, POWER_HINT_AUDIO = 0x00000020, POWER_HINT_SET_PROFILE = 0x00000030 } power_hint_t; typedef enum { POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001, POWER_FEATURE_SUPPORTED_PROFILES = 0x00001000 } feature_t; /** * Process info, passed as an opaque handle when * using POWER_HINT_LAUNCH_BOOST. */ typedef struct launch_boost_info { pid_t pid; const char* packageName; } launch_boost_info_t; /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct power_module { struct hw_module_t common; /* * (*init)() performs power management setup actions at runtime * startup, such as to set default cpufreq parameters. This is * called only by the Power HAL instance loaded by * PowerManagerService. */ void (*init)(struct power_module *module); /* * (*setInteractive)() performs power management actions upon the * system entering interactive state (that is, the system is awake * and ready for interaction, often with UI devices such as * display and touchscreen enabled) or non-interactive state (the * system appears asleep, display usually turned off). The * non-interactive state is usually entered after a period of * inactivity, in order to conserve battery power during * such inactive periods. * * Typical actions are to turn on or off devices and adjust * cpufreq parameters. This function may also call the * appropriate interfaces to allow the kernel to suspend the * system to low-power sleep state when entering non-interactive * state, and to disallow low-power suspend when the system is in * interactive state. When low-power suspend state is allowed, the * kernel may suspend the system whenever no wakelocks are held. * * on is non-zero when the system is transitioning to an * interactive / awake state, and zero when transitioning to a * non-interactive / asleep state. * * This function is called to enter non-interactive state after * turning off the screen (if present), and called to enter * interactive state prior to turning on the screen. */ void (*setInteractive)(struct power_module *module, int on); /* * (*powerHint) is called to pass hints on power requirements, which * may result in adjustment of power/performance parameters of the * cpufreq governor and other controls. The possible hints are: * * POWER_HINT_VSYNC * * Foreground app has started or stopped requesting a VSYNC pulse * from SurfaceFlinger. If the app has started requesting VSYNC * then CPU and GPU load is expected soon, and it may be appropriate * to raise speeds of CPU, memory bus, etc. The data parameter is * non-zero to indicate VSYNC pulse is now requested, or zero for * VSYNC pulse no longer requested. * * POWER_HINT_INTERACTION * * User is interacting with the device, for example, touchscreen * events are incoming. CPU and GPU load may be expected soon, * and it may be appropriate to raise speeds of CPU, memory bus, * etc. The data parameter is the estimated length of the interaction * in milliseconds, or 0 if unknown. * * POWER_HINT_LOW_POWER * * Low power mode is activated or deactivated. Low power mode * is intended to save battery at the cost of performance. The data * parameter is non-zero when low power mode is activated, and zero * when deactivated. * * POWER_HINT_CPU_BOOST * * An operation is happening where it would be ideal for the CPU to * be boosted for a specific duration. The data parameter is an * integer value of the boost duration in microseconds. * * A particular platform may choose to ignore any hint. * * availability: version 0.2 * */ void (*powerHint)(struct power_module *module, power_hint_t hint, void *data); /* * (*setFeature) is called to turn on or off a particular feature * depending on the state parameter. The possible features are: * * FEATURE_DOUBLE_TAP_TO_WAKE * * Enabling/Disabling this feature will allow/disallow the system * to wake up by tapping the screen twice. * * availability: version 0.3 * */ void (*setFeature)(struct power_module *module, feature_t feature, int state); /* * (*getFeature) is called to get the current value of a particular * feature or capability from the hardware or PowerHAL */ int (*getFeature)(struct power_module *module, feature_t feature); } power_module_t; __END_DECLS #endif // ANDROID_INCLUDE_HARDWARE_POWER_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/qemu_pipe.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H #define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H #include #include #include #include #include /* for pthread_once() */ #include #include #include #include #ifndef D # define D(...) do{}while(0) #endif /* Try to open a new Qemu fast-pipe. This function returns a file descriptor * that can be used to communicate with a named service managed by the * emulator. * * This file descriptor can be used as a standard pipe/socket descriptor. * * 'pipeName' is the name of the emulator service you want to connect to. * E.g. 'opengles' or 'camera'. * * On success, return a valid file descriptor * Returns -1 on error, and errno gives the error code, e.g.: * * EINVAL -> unknown/unsupported pipeName * ENOSYS -> fast pipes not available in this system. * * ENOSYS should never happen, except if you're trying to run within a * misconfigured emulator. * * You should be able to open several pipes to the same pipe service, * except for a few special cases (e.g. GSM modem), where EBUSY will be * returned if more than one client tries to connect to it. */ static __inline__ int qemu_pipe_open(const char* pipeName) { char buff[256]; int buffLen; int fd, ret; if (pipeName == NULL || pipeName[0] == '\0') { errno = EINVAL; return -1; } snprintf(buff, sizeof buff, "pipe:%s", pipeName); fd = open("/dev/qemu_pipe", O_RDWR); if (fd < 0 && errno == ENOENT) fd = open("/dev/goldfish_pipe", O_RDWR); if (fd < 0) { D("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__, strerror(errno)); //errno = ENOSYS; return -1; } buffLen = strlen(buff); ret = TEMP_FAILURE_RETRY(write(fd, buff, buffLen+1)); if (ret != buffLen+1) { D("%s: Could not connect to %s pipe service: %s", __FUNCTION__, pipeName, strerror(errno)); if (ret == 0) { errno = ECONNRESET; } else if (ret > 0) { errno = EINVAL; } return -1; } return fd; } #endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/qemud.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_INCLUDE_HARDWARE_QEMUD_H #define ANDROID_INCLUDE_HARDWARE_QEMUD_H #include #include "qemu_pipe.h" /* the following is helper code that is used by the QEMU-specific * hardware HAL modules to communicate with the emulator program * through the 'qemud' multiplexing daemon, or through the qemud * pipe. * * see the documentation comments for details in * development/emulator/qemud/qemud.c * * all definitions here are built into the HAL module to avoid * having to write a tiny shared library for this. */ /* we expect the D macro to be defined to a function macro * that sends its formatted string argument(s) to the log. * If not, ignore the traces. */ #ifndef D # define D(...) ((void)0) #endif static __inline__ int qemud_fd_write(int fd, const void* buff, int len) { int len2; do { len2 = write(fd, buff, len); } while (len2 < 0 && errno == EINTR); return len2; } static __inline__ int qemud_fd_read(int fd, void* buff, int len) { int len2; do { len2 = read(fd, buff, len); } while (len2 < 0 && errno == EINTR); return len2; } static __inline__ int qemud_channel_open(const char* name) { int fd; int namelen = strlen(name); char answer[2]; char pipe_name[256]; /* First, try to connect to the pipe. */ snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", name); fd = qemu_pipe_open(pipe_name); if (fd < 0) { D("QEMUD pipe is not available for %s: %s", name, strerror(errno)); /* If pipe is not available, connect to qemud control socket */ fd = socket_local_client( "qemud", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM ); if (fd < 0) { D("no qemud control socket: %s", strerror(errno)); return -1; } /* send service name to connect */ if (qemud_fd_write(fd, name, namelen) != namelen) { D("can't send service name to qemud: %s", strerror(errno)); close(fd); return -1; } /* read answer from daemon */ if (qemud_fd_read(fd, answer, 2) != 2 || answer[0] != 'O' || answer[1] != 'K') { D("cant' connect to %s service through qemud", name); close(fd); return -1; } } return fd; } static __inline__ int qemud_channel_send(int fd, const void* msg, int msglen) { char header[5]; if (msglen < 0) msglen = strlen((const char*)msg); if (msglen == 0) return 0; snprintf(header, sizeof header, "%04x", msglen); if (qemud_fd_write(fd, header, 4) != 4) { D("can't write qemud frame header: %s", strerror(errno)); return -1; } if (qemud_fd_write(fd, msg, msglen) != msglen) { D("can4t write qemud frame payload: %s", strerror(errno)); return -1; } return 0; } static __inline__ int qemud_channel_recv(int fd, void* msg, int msgsize) { char header[5]; int size, avail; if (qemud_fd_read(fd, header, 4) != 4) { D("can't read qemud frame header: %s", strerror(errno)); return -1; } header[4] = 0; if (sscanf(header, "%04x", &size) != 1) { D("malformed qemud frame header: '%.*s'", 4, header); return -1; } if (size > msgsize) return -1; if (qemud_fd_read(fd, msg, size) != size) { D("can't read qemud frame payload: %s", strerror(errno)); return -1; } return size; } #endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_H */ ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/radio.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #ifndef ANDROID_RADIO_HAL_H #define ANDROID_RADIO_HAL_H __BEGIN_DECLS /** * The id of this module */ #define RADIO_HARDWARE_MODULE_ID "radio" /** * Name of the audio devices to open */ #define RADIO_HARDWARE_DEVICE "radio_hw_device" #define RADIO_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define RADIO_MODULE_API_VERSION_CURRENT RADIO_MODULE_API_VERSION_1_0 #define RADIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define RADIO_DEVICE_API_VERSION_CURRENT RADIO_DEVICE_API_VERSION_1_0 /** * List of known radio HAL modules. This is the base name of the radio HAL * library composed of the "radio." prefix, one of the base names below and * a suffix specific to the device. * E.g: radio.fm.default.so */ #define RADIO_HARDWARE_MODULE_ID_FM "fm" /* corresponds to RADIO_CLASS_AM_FM */ #define RADIO_HARDWARE_MODULE_ID_SAT "sat" /* corresponds to RADIO_CLASS_SAT */ #define RADIO_HARDWARE_MODULE_ID_DT "dt" /* corresponds to RADIO_CLASS_DT */ /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ struct radio_module { struct hw_module_t common; }; /* * Callback function called by the HAL when one of the following occurs: * - event RADIO_EVENT_HW_FAILURE: radio chip of driver failure requiring * closing and reopening of the tuner interface. * - event RADIO_EVENT_CONFIG: new configuration applied in response to open_tuner(), * or set_configuration(). The event status is 0 (no error) if the configuration has been applied, * -EINVAL is not or -ETIMEDOUT in case of time out. * - event RADIO_EVENT_TUNED: tune locked on new station/frequency following scan(), * step(), tune() or auto AF switching. The event status is 0 (no error) if in tune, * -EINVAL is not tuned and data in radio_program_info is not valid or -ETIMEDOUT if scan() * timed out. * - event RADIO_EVENT_TA: at the beginning and end of traffic announcement if current * configuration enables TA. * - event RADIO_EVENT_AF: after automatic switching to alternate frequency if current * configuration enables AF switching. * - event RADIO_EVENT_ANTENNA: when the antenna is connected or disconnected. * - event RADIO_EVENT_METADATA: when new meta data are received from the tuned station. * The callback MUST NOT be called synchronously while executing a HAL function but from * a separate thread. */ typedef void (*radio_callback_t)(radio_hal_event_t *event, void *cookie); /* control interface for a radio tuner */ struct radio_tuner { /* * Apply current radio band configuration (band, range, channel spacing ...). * * arguments: * - config: the band configuration to apply * * returns: * 0 if configuration could be applied * -EINVAL if configuration requested is invalid * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_CONFIG MUST be called once the * configuration is applied or a failure occurs or after a time out. */ int (*set_configuration)(const struct radio_tuner *tuner, const radio_hal_band_config_t *config); /* * Retrieve current radio band configuration. * * arguments: * - config: where to return the band configuration * * returns: * 0 if valid configuration is returned * -EINVAL if invalid arguments are passed */ int (*get_configuration)(const struct radio_tuner *tuner, radio_hal_band_config_t *config); /* * Start scanning up to next valid station. * Must be called when a valid configuration has been applied. * * arguments: * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels * (e.g SPS for HD radio). * * returns: * 0 if scan successfully started * -ENOSYS if called out of sequence * -ENODEV if another error occurs * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_TUNED MUST be called once * locked on a station or after a time out or full frequency scan if * no station found. The event status should indicate if a valid station * is tuned or not. */ int (*scan)(const struct radio_tuner *tuner, radio_direction_t direction, bool skip_sub_channel); /* * Move one channel spacing up or down. * Must be called when a valid configuration has been applied. * * arguments: * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels * (e.g SPS for HD radio). * * returns: * 0 if step successfully started * -ENOSYS if called out of sequence * -ENODEV if another error occurs * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_TUNED MUST be called once * step completed or after a time out. The event status should indicate * if a valid station is tuned or not. */ int (*step)(const struct radio_tuner *tuner, radio_direction_t direction, bool skip_sub_channel); /* * Tune to specified frequency. * Must be called when a valid configuration has been applied. * * arguments: * - channel: channel to tune to. A frequency in kHz for AM/FM/HD Radio bands. * - sub_channel: valid for HD radio or digital radios only: (e.g SPS number for HD radio). * * returns: * 0 if tune successfully started * -ENOSYS if called out of sequence * -EINVAL if invalid arguments are passed * -ENODEV if another error occurs * * Automatically cancels pending scan, step or tune. * * Callback function with event RADIO_EVENT_TUNED MUST be called once * tuned or after a time out. The event status should indicate * if a valid station is tuned or not. */ int (*tune)(const struct radio_tuner *tuner, unsigned int channel, unsigned int sub_channel); /* * Cancel a scan, step or tune operation. * Must be called while a scan, step or tune operation is pending * (callback not yet sent). * * returns: * 0 if successful * -ENOSYS if called out of sequence * -ENODEV if another error occurs * * The callback is not sent. */ int (*cancel)(const struct radio_tuner *tuner); /* * Retrieve current station information. * * arguments: * - info: where to return the program info. * If info->metadata is NULL. no meta data should be returned. * If meta data must be returned, they should be added to or cloned to * info->metadata, not passed from a newly created meta data buffer. * * returns: * 0 if tuned and information available * -EINVAL if invalid arguments are passed * -ENODEV if another error occurs */ int (*get_program_information)(const struct radio_tuner *tuner, radio_program_info_t *info); }; struct radio_hw_device { struct hw_device_t common; /* * Retrieve implementation properties. * * arguments: * - properties: where to return the module properties * * returns: * 0 if no error * -EINVAL if invalid arguments are passed */ int (*get_properties)(const struct radio_hw_device *dev, radio_hal_properties_t *properties); /* * Open a tuner interface for the requested configuration. * If no other tuner is opened, this will activate the radio module. * * arguments: * - config: the band configuration to apply * - audio: this tuner will be used for live radio listening and should be connected to * the radio audio source. * - callback: the event callback * - cookie: the cookie to pass when calling the callback * - tuner: where to return the tuner interface * * returns: * 0 if HW was powered up and configuration could be applied * -EINVAL if configuration requested is invalid * -ENOSYS if called out of sequence * * Callback function with event RADIO_EVENT_CONFIG MUST be called once the * configuration is applied or a failure occurs or after a time out. */ int (*open_tuner)(const struct radio_hw_device *dev, const radio_hal_band_config_t *config, bool audio, radio_callback_t callback, void *cookie, const struct radio_tuner **tuner); /* * Close a tuner interface. * If the last tuner is closed, the radio module is deactivated. * * arguments: * - tuner: the tuner interface to close * * returns: * 0 if powered down successfully. * -EINVAL if an invalid argument is passed * -ENOSYS if called out of sequence */ int (*close_tuner)(const struct radio_hw_device *dev, const struct radio_tuner *tuner); }; typedef struct radio_hw_device radio_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int radio_hw_device_open(const struct hw_module_t* module, struct radio_hw_device** device) { return module->methods->open(module, RADIO_HARDWARE_DEVICE, (struct hw_device_t**)device); } static inline int radio_hw_device_close(const struct radio_hw_device* device) { return device->common.close((struct hw_device_t *)&device->common); } __END_DECLS #endif // ANDROID_RADIO_HAL_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/sensors.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_SENSORS_INTERFACE_H #define ANDROID_SENSORS_INTERFACE_H #include #include #include #include #include __BEGIN_DECLS /*****************************************************************************/ #define SENSORS_HEADER_VERSION 1 #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) #define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) /** * Please see the Sensors section of source.android.com for an * introduction to and detailed descriptions of Android sensor types: * http://source.android.com/devices/sensors/index.html */ /** * The id of this module */ #define SENSORS_HARDWARE_MODULE_ID "sensors" /** * Name of the sensors device to open */ #define SENSORS_HARDWARE_POLL "poll" /** * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. * A Handle identifies a given sensors. The handle is used to activate * and/or deactivate sensors. * In this version of the API there can only be 256 handles. */ #define SENSORS_HANDLE_BASE 0 #define SENSORS_HANDLE_BITS 8 #define SENSORS_HANDLE_COUNT (1< 35 degrees * * Large accelerations without a change in phone orientation should not trigger a tilt event. * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt * event, even though the angle of the average acceleration might vary by more than 35 degrees. * * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can * be used as well if they do not increase the power consumption significantly. This is a low power * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms * while reporting this event. The only allowed return value is 1.0. * * Implement only the wake-up version of this sensor. */ #define SENSOR_TYPE_TILT_DETECTOR (22) #define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" /* * SENSOR_TYPE_WAKE_GESTURE * reporting-mode: one-shot * * A sensor enabling waking up the device based on a device specific motion. * * When this sensor triggers, the device behaves as if the power button was * pressed, turning the screen on. This behavior (turning on the screen when * this sensor triggers) might be deactivated by the user in the device * settings. Changes in settings do not impact the behavior of the sensor: * only whether the framework turns the screen on when it triggers. * * The actual gesture to be detected is not specified, and can be chosen by * the manufacturer of the device. * This sensor must be low power, as it is likely to be activated 24/7. * The only allowed value to return is 1.0. * * Implement only the wake-up version of this sensor. */ #define SENSOR_TYPE_WAKE_GESTURE (23) #define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" /* * SENSOR_TYPE_GLANCE_GESTURE * reporting-mode: one-shot * * A sensor enabling briefly turning the screen on to enable the user to * glance content on screen based on a specific motion. The device should * turn the screen off after a few moments. * * When this sensor triggers, the device turns the screen on momentarily * to allow the user to glance notifications or other content while the * device remains locked in a non-interactive state (dozing). This behavior * (briefly turning on the screen when this sensor triggers) might be deactivated * by the user in the device settings. Changes in settings do not impact the * behavior of the sensor: only whether the framework briefly turns the screen on * when it triggers. * * The actual gesture to be detected is not specified, and can be chosen by * the manufacturer of the device. * This sensor must be low power, as it is likely to be activated 24/7. * The only allowed value to return is 1.0. * * Implement only the wake-up version of this sensor. */ #define SENSOR_TYPE_GLANCE_GESTURE (24) #define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" /** * SENSOR_TYPE_PICK_UP_GESTURE * reporting-mode: one-shot * * A sensor of this type triggers when the device is picked up regardless of wherever is was * before (desk, pocket, bag). The only allowed return value is 1.0. * This sensor de-activates itself immediately after it triggers. * * Implement only the wake-up version of this sensor. */ #define SENSOR_TYPE_PICK_UP_GESTURE (25) #define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" /* * SENSOR_TYPE_WRIST_TILT_GESTURE * trigger-mode: special * wake-up sensor: yes * * A sensor of this type triggers an event each time a tilt of the wrist-worn * device is detected. * * This sensor must be low power, as it is likely to be activated 24/7. * The only allowed value to return is 1.0. * * Implement only the wake-up version of this sensor. */ #define SENSOR_TYPE_WRIST_TILT_GESTURE (26) #define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture" /** * Values returned by the accelerometer in various locations in the universe. * all values are in SI units (m/s^2) */ #define GRAVITY_SUN (275.0f) #define GRAVITY_EARTH (9.80665f) /** Maximum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MAX (60.0f) /** Minimum magnetic field on Earth's surface */ #define MAGNETIC_FIELD_EARTH_MIN (30.0f) /** * Possible values of the status field of sensor events. */ #define SENSOR_STATUS_NO_CONTACT -1 #define SENSOR_STATUS_UNRELIABLE 0 #define SENSOR_STATUS_ACCURACY_LOW 1 #define SENSOR_STATUS_ACCURACY_MEDIUM 2 #define SENSOR_STATUS_ACCURACY_HIGH 3 /** * sensor event data */ typedef struct { union { float v[3]; struct { float x; float y; float z; }; struct { float azimuth; float pitch; float roll; }; }; int8_t status; uint8_t reserved[3]; } sensors_vec_t; /** * uncalibrated gyroscope and magnetometer event data */ typedef struct { union { float uncalib[3]; struct { float x_uncalib; float y_uncalib; float z_uncalib; }; }; union { float bias[3]; struct { float x_bias; float y_bias; float z_bias; }; }; } uncalibrated_event_t; /** * Meta data event data */ typedef struct meta_data_event { int32_t what; int32_t sensor; } meta_data_event_t; /** * Heart rate event data */ typedef struct { // Heart rate in beats per minute. // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT float bpm; // Status of the sensor for this reading. Set to one SENSOR_STATUS_... // Note that this value should only be set for sensors that explicitly define // the meaning of this field. This field is not piped through the framework // for other sensors. int8_t status; } heart_rate_event_t; /** * Union of the various types of sensor data * that can be returned. */ typedef struct sensors_event_t { /* must be sizeof(struct sensors_event_t) */ int32_t version; /* sensor identifier */ int32_t sensor; /* sensor type */ int32_t type; /* reserved */ int32_t reserved0; /* time is in nanosecond */ int64_t timestamp; union { union { float data[16]; /* acceleration values are in meter per second per second (m/s^2) */ sensors_vec_t acceleration; /* magnetic vector values are in micro-Tesla (uT) */ sensors_vec_t magnetic; /* orientation values are in degrees */ sensors_vec_t orientation; /* gyroscope values are in rad/s */ sensors_vec_t gyro; /* temperature is in degrees centigrade (Celsius) */ float temperature; /* distance in centimeters */ float distance; /* light in SI lux units */ float light; /* pressure in hectopascal (hPa) */ float pressure; /* relative humidity in percent */ float relative_humidity; /* uncalibrated gyroscope values are in rad/s */ uncalibrated_event_t uncalibrated_gyro; /* uncalibrated magnetometer values are in micro-Teslas */ uncalibrated_event_t uncalibrated_magnetic; /* heart rate data containing value in bpm and status */ heart_rate_event_t heart_rate; /* this is a special event. see SENSOR_TYPE_META_DATA above. * sensors_meta_data_event_t events are all reported with a type of * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. */ meta_data_event_t meta_data; }; union { uint64_t data[8]; /* step-counter */ uint64_t step_counter; } u64; }; /* Reserved flags for internal use. Set to zero. */ uint32_t flags; uint32_t reserved1[3]; } sensors_event_t; /* see SENSOR_TYPE_META_DATA */ typedef sensors_event_t sensors_meta_data_event_t; struct sensor_t; /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ struct sensors_module_t { struct hw_module_t common; /** * Enumerate all available sensors. The list is returned in "list". * @return number of sensors in the list */ int (*get_sensors_list)(struct sensors_module_t* module, struct sensor_t const** list); /** * Place the module in a specific mode. The following modes are defined * * 0 - Normal operation. Default state of the module. * 1 - Loopback mode. Data is injected for the the supported * sensors by the sensor service in this mode. * @return 0 on success * -EINVAL if requested mode is not supported * -EPERM if operation is not allowed */ int (*set_operation_mode)(unsigned int mode); }; struct sensor_t { /* Name of this sensor. * All sensors of the same "type" must have a different "name". */ const char* name; /* vendor of the hardware part */ const char* vendor; /* version of the hardware part + driver. The value of this field * must increase when the driver is updated in a way that changes the * output of this sensor. This is important for fused sensors when the * fusion algorithm is updated. */ int version; /* handle that identifies this sensors. This handle is used to reference * this sensor throughout the HAL API. */ int handle; /* this sensor's type. */ int type; /* maximum range of this sensor's value in SI units */ float maxRange; /* smallest difference between two values reported by this sensor */ float resolution; /* rough estimate of this sensor's power consumption in mA */ float power; /* this value depends on the reporting mode: * * continuous: minimum sample period allowed in microseconds * on-change : 0 * one-shot :-1 * special : 0, unless otherwise noted */ int32_t minDelay; /* number of events reserved for this sensor in the batch mode FIFO. * If there is a dedicated FIFO for this sensor, then this is the * size of this FIFO. If the FIFO is shared with other sensors, * this is the size reserved for that sensor and it can be zero. */ uint32_t fifoReservedEventCount; /* maximum number of events of this sensor that could be batched. * This is especially relevant when the FIFO is shared between * several sensors; this value is then set to the size of that FIFO. */ uint32_t fifoMaxEventCount; /* type of this sensor as a string. Set to corresponding * SENSOR_STRING_TYPE_*. * When defining an OEM specific sensor or sensor manufacturer specific * sensor, use your reserve domain name as a prefix. * ex: com.google.glass.onheaddetector * For sensors of known type, the android framework might overwrite this * string automatically. */ const char* stringType; /* permission required to see this sensor, register to it and receive data. * Set to "" if no permission is required. Some sensor types like the * heart rate monitor have a mandatory require_permission. * For sensors that always require a specific permission, like the heart * rate monitor, the android framework might overwrite this string * automatically. */ const char* requiredPermission; /* This value is defined only for continuous mode and on-change sensors. It is the delay between * two sensor events corresponding to the lowest frequency that this sensor supports. When lower * frequencies are requested through batch()/setDelay() the events will be generated at this * frequency instead. It can be used by the framework or applications to estimate when the batch * FIFO may be full. * * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. * continuous, on-change: maximum sampling period allowed in microseconds. * one-shot, special : 0 * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit * on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ int64_t maxDelay; #else int32_t maxDelay; #endif /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. * Availability: SENSORS_DEVICE_API_VERSION_1_3 */ #ifdef __LP64__ uint64_t flags; #else uint32_t flags; #endif /* reserved fields, must be zero */ void* reserved[2]; }; /* * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 * and is present for backward binary and source compatibility. * See the Sensors HAL interface section for complete descriptions of the * following functions: * http://source.android.com/devices/sensors/index.html#hal */ struct sensors_poll_device_t { struct hw_device_t common; int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; /* * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 */ typedef struct sensors_poll_device_1 { union { /* sensors_poll_device_1 is compatible with sensors_poll_device_t, * and can be down-cast to it */ struct sensors_poll_device_t v0; struct { struct hw_device_t common; /* Activate/de-activate one sensor. Return 0 on success, negative * * sensor_handle is the handle of the sensor to change. * enabled set to 1 to enable, or 0 to disable the sensor. * * Return 0 on success, negative errno code otherwise. */ int (*activate)(struct sensors_poll_device_t *dev, int sensor_handle, int enabled); /** * Set the events's period in nanoseconds for a given sensor. * If sampling_period_ns > max_delay it will be truncated to * max_delay and if sampling_period_ns < min_delay it will be * replaced by min_delay. */ int (*setDelay)(struct sensors_poll_device_t *dev, int sensor_handle, int64_t sampling_period_ns); /** * Returns an array of sensor data. */ int (*poll)(struct sensors_poll_device_t *dev, sensors_event_t* data, int count); }; }; /* * Sets a sensor’s parameters, including sampling frequency and maximum * report latency. This function can be called while the sensor is * activated, in which case it must not cause any sensor measurements to * be lost: transitioning from one sampling rate to the other cannot cause * lost events, nor can transitioning from a high maximum report latency to * a low maximum report latency. * See the Batching sensor results page for details: * http://source.android.com/devices/sensors/batching.html */ int (*batch)(struct sensors_poll_device_1* dev, int sensor_handle, int flags, int64_t sampling_period_ns, int64_t max_report_latency_ns); /* * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) * to the end of the "batch mode" FIFO for the specified sensor and flushes * the FIFO. * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the * event stream. This applies to all sensors other than one-shot sensors. * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate * any flush complete metadata. * If the sensor is not active at the time flush() is called, flush() should return * -EINVAL. */ int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); /* * Inject a single sensor sample to be to this device. * data points to the sensor event to be injected * @return 0 on success * -EPERM if operation is not allowed * -EINVAL if sensor event cannot be injected */ int (*inject_sensor_data)(struct sensors_poll_device_1 *dev, const sensors_event_t *data); void (*reserved_procs[7])(void); } sensors_poll_device_1_t; /** convenience API for opening and closing a device */ static inline int sensors_open(const struct hw_module_t* module, struct sensors_poll_device_t** device) { return module->methods->open(module, SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); } static inline int sensors_close(struct sensors_poll_device_t* device) { return device->common.close(&device->common); } static inline int sensors_open_1(const struct hw_module_t* module, sensors_poll_device_1_t** device) { return module->methods->open(module, SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); } static inline int sensors_close_1(sensors_poll_device_1_t* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SENSORS_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/sound_trigger.h ================================================ /* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #ifndef ANDROID_SOUND_TRIGGER_HAL_H #define ANDROID_SOUND_TRIGGER_HAL_H __BEGIN_DECLS /** * The id of this module */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger" /** * Name of the audio devices to open */ #define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if" #define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) #define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0 #define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) #define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0 /** * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL * library composed of the "sound_trigger." prefix, one of the base names below and * a suffix specific to the device. * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so */ #define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary" /** * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ struct sound_trigger_module { struct hw_module_t common; }; typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event *event, void *cookie); typedef void (*sound_model_callback_t)(struct sound_trigger_model_event *event, void *cookie); struct sound_trigger_hw_device { struct hw_device_t common; /* * Retrieve implementation properties. */ int (*get_properties)(const struct sound_trigger_hw_device *dev, struct sound_trigger_properties *properties); /* * Load a sound model. Once loaded, recognition of this model can be started and stopped. * Only one active recognition per model at a time. The SoundTrigger service will handle * concurrent recognition requests by different users/applications on the same model. * The implementation returns a unique handle used by other functions (unload_sound_model(), * start_recognition(), etc... */ int (*load_sound_model)(const struct sound_trigger_hw_device *dev, struct sound_trigger_sound_model *sound_model, sound_model_callback_t callback, void *cookie, sound_model_handle_t *handle); /* * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome * implementation limitations. */ int (*unload_sound_model)(const struct sound_trigger_hw_device *dev, sound_model_handle_t handle); /* Start recognition on a given model. Only one recognition active at a time per model. * Once recognition succeeds of fails, the callback is called. * TODO: group recognition configuration parameters into one struct and add key phrase options. */ int (*start_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle, const struct sound_trigger_recognition_config *config, recognition_callback_t callback, void *cookie); /* Stop recognition on a given model. * The implementation does not have to call the callback when stopped via this method. */ int (*stop_recognition)(const struct sound_trigger_hw_device *dev, sound_model_handle_t sound_model_handle); }; typedef struct sound_trigger_hw_device sound_trigger_hw_device_t; /** convenience API for opening and closing a supported device */ static inline int sound_trigger_hw_device_open(const struct hw_module_t* module, struct sound_trigger_hw_device** device) { return module->methods->open(module, SOUND_TRIGGER_HARDWARE_INTERFACE, (struct hw_device_t**)device); } static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) { return device->common.close(&device->common); } __END_DECLS #endif // ANDROID_SOUND_TRIGGER_HAL_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/tv_input.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_TV_INPUT_INTERFACE_H #define ANDROID_TV_INPUT_INTERFACE_H #include #include #include #include #include #include __BEGIN_DECLS /* * Module versioning information for the TV input hardware module, based on * tv_input_module_t.common.module_api_version. * * Version History: * * TV_INPUT_MODULE_API_VERSION_0_1: * Initial TV input hardware module API. * */ #define TV_INPUT_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) #define TV_INPUT_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) /* * The id of this module */ #define TV_INPUT_HARDWARE_MODULE_ID "tv_input" #define TV_INPUT_DEFAULT_DEVICE "default" /*****************************************************************************/ /* * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM * and the fields of this data structure must begin with hw_module_t * followed by module specific information. */ typedef struct tv_input_module { struct hw_module_t common; } tv_input_module_t; /*****************************************************************************/ enum { /* Generic hardware. */ TV_INPUT_TYPE_OTHER_HARDWARE = 1, /* Tuner. (e.g. built-in terrestrial tuner) */ TV_INPUT_TYPE_TUNER = 2, TV_INPUT_TYPE_COMPOSITE = 3, TV_INPUT_TYPE_SVIDEO = 4, TV_INPUT_TYPE_SCART = 5, TV_INPUT_TYPE_COMPONENT = 6, TV_INPUT_TYPE_VGA = 7, TV_INPUT_TYPE_DVI = 8, /* Physical HDMI port. (e.g. HDMI 1) */ TV_INPUT_TYPE_HDMI = 9, TV_INPUT_TYPE_DISPLAY_PORT = 10, }; typedef uint32_t tv_input_type_t; typedef struct tv_input_device_info { /* Device ID */ int device_id; /* Type of physical TV input. */ tv_input_type_t type; union { struct { /* HDMI port ID number */ uint32_t port_id; } hdmi; /* TODO: add other type specific information. */ int32_t type_info_reserved[16]; }; /* TODO: Add capability if necessary. */ /* * Audio info * * audio_type == AUDIO_DEVICE_NONE if this input has no audio. */ audio_devices_t audio_type; const char* audio_address; int32_t reserved[16]; } tv_input_device_info_t; /* See tv_input_event_t for more details. */ enum { /* * Hardware notifies the framework that a device is available. * * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent * hotplug events (i.e. plugging cable into or out of the physical port). * These events notify the framework whether the port is available or not. * For a concrete example, when a user plugs in or pulls out the HDMI cable * from a HDMI port, it does not generate DEVICE_AVAILABLE and/or * DEVICE_UNAVAILABLE events. However, if a user inserts a pluggable USB * tuner into the Android device, it will generate a DEVICE_AVAILABLE event * and when the port is removed, it should generate a DEVICE_UNAVAILABLE * event. * * For hotplug events, please see STREAM_CONFIGURATION_CHANGED for more * details. * * HAL implementation should register devices by using this event when the * device boots up. The framework will recognize device reported via this * event only. In addition, the implementation could use this event to * notify the framework that a removable TV input device (such as USB tuner * as stated in the example above) is attached. */ TV_INPUT_EVENT_DEVICE_AVAILABLE = 1, /* * Hardware notifies the framework that a device is unavailable. * * HAL implementation should generate this event when a device registered * by TV_INPUT_EVENT_DEVICE_AVAILABLE is no longer available. For example, * the event can indicate that a USB tuner is plugged out from the Android * device. * * Note that this event is not for indicating cable plugged out of the port; * for that purpose, the implementation should use * STREAM_CONFIGURATION_CHANGED event. This event represents the port itself * being no longer available. */ TV_INPUT_EVENT_DEVICE_UNAVAILABLE = 2, /* * Stream configurations are changed. Client should regard all open streams * at the specific device are closed, and should call * get_stream_configurations() again, opening some of them if necessary. * * HAL implementation should generate this event when the available stream * configurations change for any reason. A typical use case of this event * would be to notify the framework that the input signal has changed * resolution, or that the cable is plugged out so that the number of * available streams is 0. * * The implementation may use this event to indicate hotplug status of the * port. the framework regards input devices with no available streams as * disconnected, so the implementation can generate this event with no * available streams to indicate that this device is disconnected, and vice * versa. */ TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED = 3, /* * Hardware is done with capture request with the buffer. Client can assume * ownership of the buffer again. * * HAL implementation should generate this event after request_capture() if * it succeeded. The event shall have the buffer with the captured image. */ TV_INPUT_EVENT_CAPTURE_SUCCEEDED = 4, /* * Hardware met a failure while processing a capture request or client * canceled the request. Client can assume ownership of the buffer again. * * The event is similar to TV_INPUT_EVENT_CAPTURE_SUCCEEDED, but HAL * implementation generates this event upon a failure to process * request_capture(), or a request cancellation. */ TV_INPUT_EVENT_CAPTURE_FAILED = 5, }; typedef uint32_t tv_input_event_type_t; typedef struct tv_input_capture_result { /* Device ID */ int device_id; /* Stream ID */ int stream_id; /* Sequence number of the request */ uint32_t seq; /* * The buffer passed to hardware in request_capture(). The content of * buffer is undefined (although buffer itself is valid) for * TV_INPUT_CAPTURE_FAILED event. */ buffer_handle_t buffer; /* * Error code for the request. -ECANCELED if request is cancelled; other * error codes are unknown errors. */ int error_code; } tv_input_capture_result_t; typedef struct tv_input_event { tv_input_event_type_t type; union { /* * TV_INPUT_EVENT_DEVICE_AVAILABLE: all fields are relevant * TV_INPUT_EVENT_DEVICE_UNAVAILABLE: only device_id is relevant * TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED: only device_id is * relevant */ tv_input_device_info_t device_info; /* * TV_INPUT_EVENT_CAPTURE_SUCCEEDED: error_code is not relevant * TV_INPUT_EVENT_CAPTURE_FAILED: all fields are relevant */ tv_input_capture_result_t capture_result; }; } tv_input_event_t; typedef struct tv_input_callback_ops { /* * event contains the type of the event and additional data if necessary. * The event object is guaranteed to be valid only for the duration of the * call. * * data is an object supplied at device initialization, opaque to the * hardware.     */ void (*notify)(struct tv_input_device* dev, tv_input_event_t* event, void* data); } tv_input_callback_ops_t; enum { TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE = 1, TV_STREAM_TYPE_BUFFER_PRODUCER = 2, }; typedef uint32_t tv_stream_type_t; typedef struct tv_stream_config { /* * ID number of the stream. This value is used to identify the whole stream * configuration. */ int stream_id; /* Type of the stream */ tv_stream_type_t type; /* Max width/height of the stream. */ uint32_t max_video_width; uint32_t max_video_height; } tv_stream_config_t; typedef struct buffer_producer_stream { /* * IN/OUT: Width / height of the stream. Client may request for specific * size but hardware may change it. Client must allocate buffers with * specified width and height. */ uint32_t width; uint32_t height; /* OUT: Client must set this usage when allocating buffer. */ uint32_t usage; /* OUT: Client must allocate a buffer with this format. */ uint32_t format; /* OUT: Client must allocate buffers based on this count. */ uint32_t buffer_count; } buffer_producer_stream_t; typedef struct tv_stream { /* IN: ID in the stream configuration */ int stream_id; /* OUT: Type of the stream (for convenience) */ tv_stream_type_t type; /* Data associated with the stream for client's use */ union { /* OUT: A native handle describing the sideband stream source */ native_handle_t* sideband_stream_source_handle; /* IN/OUT: Details are in buffer_producer_stream_t */ buffer_producer_stream_t buffer_producer; }; } tv_stream_t; /* * Every device data structure must begin with hw_device_t * followed by module specific public methods and attributes. */ typedef struct tv_input_device { struct hw_device_t common; /* * initialize: * * Provide callbacks to the device and start operation. At first, no device * is available and after initialize() completes, currently available * devices including static devices should notify via callback. * * Framework owns callbacks object. * * data is a framework-owned object which would be sent back to the * framework for each callback notifications. * * Return 0 on success. */ int (*initialize)(struct tv_input_device* dev, const tv_input_callback_ops_t* callback, void* data); /* * get_stream_configurations: * * Get stream configurations for a specific device. An input device may have * multiple configurations. * * The configs object is guaranteed to be valid only until the next call to * get_stream_configurations() or STREAM_CONFIGURATIONS_CHANGED event. * * Return 0 on success. */ int (*get_stream_configurations)(const struct tv_input_device* dev, int device_id, int* num_configurations, const tv_stream_config_t** configs); /* * open_stream: * * Open a stream with given stream ID. Caller owns stream object, and the * populated data is only valid until the stream is closed. * * Return 0 on success; -EBUSY if the client should close other streams to * open the stream; -EEXIST if the stream with the given ID is already open; * -EINVAL if device_id and/or stream_id are invalid; other non-zero value * denotes unknown error. */ int (*open_stream)(struct tv_input_device* dev, int device_id, tv_stream_t* stream); /* * close_stream: * * Close a stream to a device. data in tv_stream_t* object associated with * the stream_id is obsolete once this call finishes. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid. */ int (*close_stream)(struct tv_input_device* dev, int device_id, int stream_id); /* * request_capture: * * Request buffer capture for a stream. This is only valid for buffer * producer streams. The buffer should be created with size, format and * usage specified in the stream. Framework provides seq in an * increasing sequence per each stream. Hardware should provide the picture * in a chronological order according to seq. For example, if two * requests are being processed at the same time, the request with the * smaller seq should get an earlier frame. * * The framework releases the ownership of the buffer upon calling this * function. When the buffer is filled, hardware notifies the framework * via TV_INPUT_EVENT_CAPTURE_FINISHED callback, and the ownership is * transferred back to framework at that time. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id and/or stream_id are invalid; -EWOULDBLOCK if HAL cannot take * additional requests until it releases a buffer. */ int (*request_capture)(struct tv_input_device* dev, int device_id, int stream_id, buffer_handle_t buffer, uint32_t seq); /* * cancel_capture: * * Cancel an ongoing capture. Hardware should release the buffer as soon as * possible via TV_INPUT_EVENT_CAPTURE_FAILED callback. * * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if * device_id, stream_id, and/or seq are invalid. */ int (*cancel_capture)(struct tv_input_device* dev, int device_id, int stream_id, uint32_t seq); void* reserved[16]; } tv_input_device_t; __END_DECLS #endif // ANDROID_TV_INPUT_INTERFACE_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/vibrator.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _HARDWARE_VIBRATOR_H #define _HARDWARE_VIBRATOR_H #include __BEGIN_DECLS #define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0) /** * The id of this module */ #define VIBRATOR_HARDWARE_MODULE_ID "vibrator" /** * The id of the main vibrator device */ #define VIBRATOR_DEVICE_ID_MAIN "main_vibrator" struct vibrator_device; typedef struct vibrator_device { /** * Common methods of the vibrator device. This *must* be the first member of * vibrator_device as users of this structure will cast a hw_device_t to * vibrator_device pointer in contexts where it's known the hw_device_t references a * vibrator_device. */ struct hw_device_t common; /** Turn on vibrator * * What happens when this function is called while the the timeout of a * previous call has not expired is implementation dependent. * * @param timeout_ms number of milliseconds to vibrate * * @return 0 in case of success, negative errno code else */ int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms); /** Turn off vibrator * * It is not guaranteed that the vibrator will be immediately stopped: the * behaviour is implementation dependent. * * @return 0 in case of success, negative errno code else */ int (*vibrator_off)(struct vibrator_device* vibradev); } vibrator_device_t; static inline int vibrator_open(const struct hw_module_t* module, vibrator_device_t** device) { return module->methods->open(module, VIBRATOR_DEVICE_ID_MAIN, (struct hw_device_t**)device); } __END_DECLS #endif // _HARDWARE_VIBRATOR_H ================================================ FILE: phonelibs/android_hardware_libhardware/include/hardware/wipower.h ================================================ /* * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of The Linux Foundation nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef ANDROID_INCLUDE_WIPOWER_H #define ANDROID_INCLUDE_WIPOWER_H #include #include #include #include #include #include __BEGIN_DECLS typedef enum { OFF =0, ON } wipower_state_t; typedef struct { unsigned char optional; unsigned short rect_voltage; unsigned short rect_current; unsigned short out_voltage; unsigned short out_current; unsigned char temp; unsigned short rect_voltage_min; unsigned short rect_voltage_set; unsigned short rect_voltage_max; unsigned char alert; unsigned short rfu1; unsigned char rfu2; }__attribute__((packed)) wipower_dyn_data_t; /** Bluetooth Enable/Disable Callback. */ typedef void (*wipower_state_changed_callback)(wipower_state_t state); typedef void (*wipower_alerts)(unsigned char alert); typedef void (*wipower_dynamic_data)(wipower_dyn_data_t* alert_data); typedef void (*wipower_power_apply)(unsigned char power_flag); typedef void (*callback_thread_event)(bt_cb_thread_evt evt); /** Bluetooth DM callback structure. */ typedef struct { /** set to sizeof(wipower_callbacks_t) */ size_t size; wipower_state_changed_callback wipower_state_changed_cb; wipower_alerts wipower_alert; wipower_dynamic_data wipower_data; wipower_power_apply wipower_power_event; callback_thread_event callback_thread_event; } wipower_callbacks_t; /** Represents the standard Wipower interface. */ typedef struct { /** set to sizeof(wipower_interface_t) */ size_t size; /** Initialize Wipower modules*/ int (*init)(wipower_callbacks_t *wp_callbacks); /** Enable/Disable Wipower charging */ int (*enable)(bool enable); int (*set_current_limit)(short value); unsigned char (*get_current_limit)(void); wipower_state_t (*get_state)(void); /** Enable/Disable Wipower charging */ int (*enable_alerts)(bool enable); int (*enable_data_notify)(bool enable); int (*enable_power_apply)(bool enable, bool on, bool time_flag); } wipower_interface_t; __END_DECLS #endif /* ANDROID_INCLUDE_WIPOWER_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/android_reboot.h ================================================ /* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_ANDROID_REBOOT_H__ #define __CUTILS_ANDROID_REBOOT_H__ #include __BEGIN_DECLS /* Commands */ #define ANDROID_RB_RESTART 0xDEAD0001 #define ANDROID_RB_POWEROFF 0xDEAD0002 #define ANDROID_RB_RESTART2 0xDEAD0003 /* Properties */ #define ANDROID_RB_PROPERTY "sys.powerctl" int android_reboot(int cmd, int flags, const char *arg); int android_reboot_with_callback( int cmd, int flags, const char *arg, void (*cb_on_remount)(const struct mntent*)); __END_DECLS #endif /* __CUTILS_ANDROID_REBOOT_H__ */ ================================================ FILE: phonelibs/android_system_core/include/cutils/aref.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _CUTILS_AREF_H_ #define _CUTILS_AREF_H_ #include #include #include __BEGIN_DECLS #define AREF_TO_ITEM(aref, container, member) \ (container *) (((char*) (aref)) - offsetof(container, member)) struct aref { volatile int32_t count; }; static inline void aref_init(struct aref *r) { r->count = 1; } static inline int32_t aref_count(struct aref *r) { return r->count; } static inline void aref_get(struct aref *r) { android_atomic_inc(&r->count); } static inline void aref_put(struct aref *r, void (*release)(struct aref *)) { if (android_atomic_dec(&r->count) == 1) release(r); } __END_DECLS #endif // _CUTILS_AREF_H_ ================================================ FILE: phonelibs/android_system_core/include/cutils/ashmem.h ================================================ /* cutils/ashmem.h ** ** Copyright 2008 The Android Open Source Project ** ** This file is dual licensed. It may be redistributed and/or modified ** under the terms of the Apache 2.0 License OR version 2 of the GNU ** General Public License. */ #ifndef _CUTILS_ASHMEM_H #define _CUTILS_ASHMEM_H #include #ifdef __cplusplus extern "C" { #endif int ashmem_create_region(const char *name, size_t size); int ashmem_set_prot_region(int fd, int prot); int ashmem_pin_region(int fd, size_t offset, size_t len); int ashmem_unpin_region(int fd, size_t offset, size_t len); int ashmem_get_size_region(int fd); #ifdef __cplusplus } #endif #ifndef __ASHMEMIOC /* in case someone included too */ #define ASHMEM_NAME_LEN 256 #define ASHMEM_NAME_DEF "dev/ashmem" /* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ #define ASHMEM_NOT_PURGED 0 #define ASHMEM_WAS_PURGED 1 /* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ #define ASHMEM_IS_UNPINNED 0 #define ASHMEM_IS_PINNED 1 #endif /* ! __ASHMEMIOC */ #endif /* _CUTILS_ASHMEM_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/atomic.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_CUTILS_ATOMIC_H #define ANDROID_CUTILS_ATOMIC_H #include #include #include #ifndef ANDROID_ATOMIC_INLINE #define ANDROID_ATOMIC_INLINE static inline #endif /* * A handful of basic atomic operations. * THESE ARE HERE FOR LEGACY REASONS ONLY. AVOID. * * PREFERRED ALTERNATIVES: * - Use C++/C/pthread locks/mutexes whenever there is not a * convincing reason to do otherwise. Note that very clever and * complicated, but correct, lock-free code is often slower than * using locks, especially where nontrivial data structures * are involved. * - C11 stdatomic.h. * - Where supported, C++11 std::atomic . * * PLEASE STOP READING HERE UNLESS YOU ARE TRYING TO UNDERSTAND * OR UPDATE OLD CODE. * * The "acquire" and "release" terms can be defined intuitively in terms * of the placement of memory barriers in a simple lock implementation: * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds * - barrier * - [do work] * - barrier * - store(lock-is-free) * In very crude terms, the initial (acquire) barrier prevents any of the * "work" from happening before the lock is held, and the later (release) * barrier ensures that all of the work happens before the lock is released. * (Think of cached writes, cache read-ahead, and instruction reordering * around the CAS and store instructions.) * * The barriers must apply to both the compiler and the CPU. Note it is * legal for instructions that occur before an "acquire" barrier to be * moved down below it, and for instructions that occur after a "release" * barrier to be moved up above it. * * The ARM-driven implementation we use here is short on subtlety, * and actually requests a full barrier from the compiler and the CPU. * The only difference between acquire and release is in whether they * are issued before or after the atomic operation with which they * are associated. To ease the transition to C/C++ atomic intrinsics, * you should not rely on this, and instead assume that only the minimal * acquire/release protection is provided. * * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. * If they are not, atomicity is not guaranteed. */ /* * Basic arithmetic and bitwise operations. These all provide a * barrier with "release" ordering, and return the previous value. * * These have the same characteristics (e.g. what happens on overflow) * as the equivalent non-atomic C operations. */ ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; /* Int32_t, if it exists, is the same as int_least32_t. */ return atomic_fetch_add_explicit(a, 1, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return atomic_fetch_sub_explicit(a, 1, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_add(int32_t value, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return atomic_fetch_add_explicit(a, value, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_and(int32_t value, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return atomic_fetch_and_explicit(a, value, memory_order_release); } ANDROID_ATOMIC_INLINE int32_t android_atomic_or(int32_t value, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return atomic_fetch_or_explicit(a, value, memory_order_release); } /* * Perform an atomic load with "acquire" or "release" ordering. * * Note that the notion of a "release" ordering for a load does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a leading * atomic_thread_fence (typically with memory_order_acquire, * not memory_order_release!) instead. If you do not understand * this comment, you are in the vast majority, and should not be * using release loads or replacing them with anything other than * locks or default sequentially consistent atomics. */ ANDROID_ATOMIC_INLINE int32_t android_atomic_acquire_load(volatile const int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return atomic_load_explicit(a, memory_order_acquire); } ANDROID_ATOMIC_INLINE int32_t android_atomic_release_load(volatile const int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; atomic_thread_fence(memory_order_seq_cst); /* Any reasonable clients of this interface would probably prefer */ /* something weaker. But some remaining clients seem to be */ /* abusing this API in strange ways, e.g. by using it as a fence. */ /* Thus we are conservative until we can get rid of remaining */ /* clients (and this function). */ return atomic_load_explicit(a, memory_order_relaxed); } /* * Perform an atomic store with "acquire" or "release" ordering. * * Note that the notion of an "acquire" ordering for a store does not * really fit into the C11 or C++11 memory model. The extra ordering * is normally observable only by code using memory_order_relaxed * atomics, or data races. In the rare cases in which such ordering * is called for, use memory_order_relaxed atomics and a trailing * atomic_thread_fence (typically with memory_order_release, * not memory_order_acquire!) instead. */ ANDROID_ATOMIC_INLINE void android_atomic_acquire_store(int32_t value, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; atomic_store_explicit(a, value, memory_order_relaxed); atomic_thread_fence(memory_order_seq_cst); /* Again overly conservative to accomodate weird clients. */ } ANDROID_ATOMIC_INLINE void android_atomic_release_store(int32_t value, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; atomic_store_explicit(a, value, memory_order_release); } /* * Compare-and-set operation with "acquire" or "release" ordering. * * This returns zero if the new value was successfully stored, which will * only happen when *addr == oldvalue. * * (The return value is inverted from implementations on other platforms, * but matches the ARM ldrex/strex result.) * * Implementations that use the release CAS in a loop may be less efficient * than possible, because we re-issue the memory barrier on each iteration. */ ANDROID_ATOMIC_INLINE int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return (int)(!atomic_compare_exchange_strong_explicit( a, &oldvalue, newvalue, memory_order_acquire, memory_order_acquire)); } ANDROID_ATOMIC_INLINE int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, volatile int32_t* addr) { volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; return (int)(!atomic_compare_exchange_strong_explicit( a, &oldvalue, newvalue, memory_order_release, memory_order_relaxed)); } /* * Fence primitives. */ ANDROID_ATOMIC_INLINE void android_compiler_barrier(void) { __asm__ __volatile__ ("" : : : "memory"); /* Could probably also be: */ /* atomic_signal_fence(memory_order_seq_cst); */ } ANDROID_ATOMIC_INLINE void android_memory_barrier(void) { atomic_thread_fence(memory_order_seq_cst); } /* * Aliases for code using an older version of this header. These are now * deprecated and should not be used. The definitions will be removed * in a future release. */ #define android_atomic_write android_atomic_release_store #define android_atomic_cmpxchg android_atomic_release_cas #endif // ANDROID_CUTILS_ATOMIC_H ================================================ FILE: phonelibs/android_system_core/include/cutils/bitops.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_BITOPS_H #define __CUTILS_BITOPS_H #include #include #include #include __BEGIN_DECLS /* * Bitmask Operations * * Note this doesn't provide any locking/exclusion, and isn't atomic. * Additionally no bounds checking is done on the bitmask array. * * Example: * * int num_resources; * unsigned int resource_bits[BITS_TO_WORDS(num_resources)]; * bitmask_init(resource_bits, num_resources); * ... * int bit = bitmask_ffz(resource_bits, num_resources); * bitmask_set(resource_bits, bit); * ... * if (bitmask_test(resource_bits, bit)) { ... } * ... * bitmask_clear(resource_bits, bit); * */ #define BITS_PER_WORD (sizeof(unsigned int) * 8) #define BITS_TO_WORDS(x) (((x) + BITS_PER_WORD - 1) / BITS_PER_WORD) #define BIT_IN_WORD(x) ((x) % BITS_PER_WORD) #define BIT_WORD(x) ((x) / BITS_PER_WORD) #define BIT_MASK(x) (1 << BIT_IN_WORD(x)) static inline void bitmask_init(unsigned int *bitmask, int num_bits) { memset(bitmask, 0, BITS_TO_WORDS(num_bits)*sizeof(unsigned int)); } static inline int bitmask_ffz(unsigned int *bitmask, int num_bits) { int bit, result; size_t i; for (i = 0; i < BITS_TO_WORDS(num_bits); i++) { bit = ffs(~bitmask[i]); if (bit) { // ffs is 1-indexed, return 0-indexed result bit--; result = BITS_PER_WORD * i + bit; if (result >= num_bits) return -1; return result; } } return -1; } static inline int bitmask_weight(unsigned int *bitmask, int num_bits) { size_t i; int weight = 0; for (i = 0; i < BITS_TO_WORDS(num_bits); i++) weight += __builtin_popcount(bitmask[i]); return weight; } static inline void bitmask_set(unsigned int *bitmask, int bit) { bitmask[BIT_WORD(bit)] |= BIT_MASK(bit); } static inline void bitmask_clear(unsigned int *bitmask, int bit) { bitmask[BIT_WORD(bit)] &= ~BIT_MASK(bit); } static inline bool bitmask_test(unsigned int *bitmask, int bit) { return bitmask[BIT_WORD(bit)] & BIT_MASK(bit); } static inline int popcount(unsigned int x) { return __builtin_popcount(x); } static inline int popcountl(unsigned long x) { return __builtin_popcountl(x); } static inline int popcountll(unsigned long long x) { return __builtin_popcountll(x); } __END_DECLS #endif /* __CUTILS_BITOPS_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/compiler.h ================================================ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_CUTILS_COMPILER_H #define ANDROID_CUTILS_COMPILER_H /* * helps the compiler's optimizer predicting branches */ #ifdef __cplusplus # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) #else # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) #endif /** * exports marked symbols * * if used on a C++ class declaration, this macro must be inserted * after the "class" keyword. For instance: * * template * class ANDROID_API Singleton { } */ #define ANDROID_API __attribute__((visibility("default"))) #endif // ANDROID_CUTILS_COMPILER_H ================================================ FILE: phonelibs/android_system_core/include/cutils/config_utils.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_CONFIG_UTILS_H #define __CUTILS_CONFIG_UTILS_H #ifdef __cplusplus extern "C" { #endif typedef struct cnode cnode; struct cnode { cnode *next; cnode *first_child; cnode *last_child; const char *name; const char *value; }; /* parse a text string into a config node tree */ void config_load(cnode *root, char *data); /* parse a file into a config node tree */ void config_load_file(cnode *root, const char *fn); /* create a single config node */ cnode* config_node(const char *name, const char *value); /* locate a named child of a config node */ cnode* config_find(cnode *root, const char *name); /* look up a child by name and return the boolean value */ int config_bool(cnode *root, const char *name, int _default); /* look up a child by name and return the string value */ const char* config_str(cnode *root, const char *name, const char *_default); /* add a named child to a config node (or modify it if it already exists) */ void config_set(cnode *root, const char *name, const char *value); /* free a config node tree */ void config_free(cnode *root); #ifdef __cplusplus } #endif #endif ================================================ FILE: phonelibs/android_system_core/include/cutils/debugger.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_DEBUGGER_H #define __CUTILS_DEBUGGER_H #include #include __BEGIN_DECLS #define DEBUGGER_SOCKET_NAME "android:debuggerd" #define DEBUGGER32_SOCKET_NAME "android:debuggerd32" #define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME typedef enum { // dump a crash DEBUGGER_ACTION_CRASH, // dump a tombstone file DEBUGGER_ACTION_DUMP_TOMBSTONE, // dump a backtrace only back to the socket DEBUGGER_ACTION_DUMP_BACKTRACE, } debugger_action_t; // Make sure that all values have a fixed size so that this structure // is the same for 32 bit and 64 bit processes. // NOTE: Any changes to this structure must also be reflected in // bionic/linker/debugger.cpp. typedef struct __attribute__((packed)) { int32_t action; pid_t tid; uint64_t abort_msg_address; int32_t original_si_code; } debugger_msg_t; /* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). * Stores the tombstone path in the provided buffer. * Returns 0 on success, -1 on error. */ int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); /* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). * Stores the tombstone path in the provided buffer. * If reading debugger data from debuggerd ever takes longer than timeout_secs * seconds, then stop and return an error. * Returns 0 on success, -1 on error. */ int dump_tombstone_timeout(pid_t tid, char* pathbuf, size_t pathlen, int timeout_secs); /* Dumps a process backtrace only to the specified file (requires root). * Returns 0 on success, -1 on error. */ int dump_backtrace_to_file(pid_t tid, int fd); /* Dumps a process backtrace only to the specified file (requires root). * If reading debugger data from debuggerd ever takes longer than timeout_secs * seconds, then stop and return an error. * Returns 0 on success, -1 on error. */ int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs); __END_DECLS #endif /* __CUTILS_DEBUGGER_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/fs.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_FS_H #define __CUTILS_FS_H #include #include /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * . (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #ifdef __cplusplus extern "C" { #endif /* * Ensure that directory exists with given mode and owners. */ extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); /* * Read single plaintext integer from given file, correctly handling files * partially written with fs_write_atomic_int(). */ extern int fs_read_atomic_int(const char* path, int* value); /* * Write single plaintext integer to given file, creating backup while * in progress. */ extern int fs_write_atomic_int(const char* path, int value); /* * Ensure that all directories along given path exist, creating parent * directories as needed. Validates that given path is absolute and that * it contains no relative "." or ".." paths or symlinks. Last path segment * is treated as filename and ignored, unless the path ends with "/". */ extern int fs_mkdirs(const char* path, mode_t mode); #ifdef __cplusplus } #endif #endif /* __CUTILS_FS_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/hashmap.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Hash map. */ #ifndef __HASHMAP_H #define __HASHMAP_H #include #include #ifdef __cplusplus extern "C" { #endif /** A hash map. */ typedef struct Hashmap Hashmap; /** * Creates a new hash map. Returns NULL if memory allocation fails. * * @param initialCapacity number of expected entries * @param hash function which hashes keys * @param equals function which compares keys for equality */ Hashmap* hashmapCreate(size_t initialCapacity, int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); /** * Frees the hash map. Does not free the keys or values themselves. */ void hashmapFree(Hashmap* map); /** * Hashes the memory pointed to by key with the given size. Useful for * implementing hash functions. */ int hashmapHash(void* key, size_t keySize); /** * Puts value for the given key in the map. Returns pre-existing value if * any. * * If memory allocation fails, this function returns NULL, the map's size * does not increase, and errno is set to ENOMEM. */ void* hashmapPut(Hashmap* map, void* key, void* value); /** * Gets a value from the map. Returns NULL if no entry for the given key is * found or if the value itself is NULL. */ void* hashmapGet(Hashmap* map, void* key); /** * Returns true if the map contains an entry for the given key. */ bool hashmapContainsKey(Hashmap* map, void* key); /** * Gets the value for a key. If a value is not found, this function gets a * value and creates an entry using the given callback. * * If memory allocation fails, the callback is not called, this function * returns NULL, and errno is set to ENOMEM. */ void* hashmapMemoize(Hashmap* map, void* key, void* (*initialValue)(void* key, void* context), void* context); /** * Removes an entry from the map. Returns the removed value or NULL if no * entry was present. */ void* hashmapRemove(Hashmap* map, void* key); /** * Gets the number of entries in this map. */ size_t hashmapSize(Hashmap* map); /** * Invokes the given callback on each entry in the map. Stops iterating if * the callback returns false. */ void hashmapForEach(Hashmap* map, bool (*callback)(void* key, void* value, void* context), void* context); /** * Concurrency support. */ /** * Locks the hash map so only the current thread can access it. */ void hashmapLock(Hashmap* map); /** * Unlocks the hash map so other threads can access it. */ void hashmapUnlock(Hashmap* map); /** * Key utilities. */ /** * Hashes int keys. 'key' is a pointer to int. */ int hashmapIntHash(void* key); /** * Compares two int keys for equality. */ bool hashmapIntEquals(void* keyA, void* keyB); /** * For debugging. */ /** * Gets current capacity. */ size_t hashmapCurrentCapacity(Hashmap* map); /** * Counts the number of entry collisions. */ size_t hashmapCountCollisions(Hashmap* map); #ifdef __cplusplus } #endif #endif /* __HASHMAP_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/iosched_policy.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_IOSCHED_POLICY_H #define __CUTILS_IOSCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif typedef enum { IoSchedClass_NONE, IoSchedClass_RT, IoSchedClass_BE, IoSchedClass_IDLE, } IoSchedClass; extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); extern int android_set_rt_ioprio(int pid, int rt); #ifdef __cplusplus } #endif #endif /* __CUTILS_IOSCHED_POLICY_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/jstring.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_STRING16_H #define __CUTILS_STRING16_H #include #include #ifdef __cplusplus extern "C" { #endif #if __STDC_VERSION__ < 201112L && __cplusplus < 201103L typedef uint16_t char16_t; #endif // otherwise char16_t is a keyword with the right semantics extern char * strndup16to8 (const char16_t* s, size_t n); extern size_t strnlen16to8 (const char16_t* s, size_t n); extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); extern char16_t * strdup8to16 (const char* s, size_t *out_len); extern size_t strlen8to16 (const char* utf8Str); extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, size_t *out_len); #ifdef __cplusplus } #endif #endif /* __CUTILS_STRING16_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/klog.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _CUTILS_KLOG_H_ #define _CUTILS_KLOG_H_ #include #include #include __BEGIN_DECLS void klog_init(void); int klog_get_level(void); void klog_set_level(int level); /* TODO: void klog_close(void); - and make klog_fd users thread safe. */ void klog_write(int level, const char *fmt, ...) __attribute__ ((format(printf, 2, 3))); void klog_writev(int level, const struct iovec* iov, int iov_count); __END_DECLS #define KLOG_ERROR_LEVEL 3 #define KLOG_WARNING_LEVEL 4 #define KLOG_NOTICE_LEVEL 5 #define KLOG_INFO_LEVEL 6 #define KLOG_DEBUG_LEVEL 7 #define KLOG_ERROR(tag,x...) klog_write(KLOG_ERROR_LEVEL, "<3>" tag ": " x) #define KLOG_WARNING(tag,x...) klog_write(KLOG_WARNING_LEVEL, "<4>" tag ": " x) #define KLOG_NOTICE(tag,x...) klog_write(KLOG_NOTICE_LEVEL, "<5>" tag ": " x) #define KLOG_INFO(tag,x...) klog_write(KLOG_INFO_LEVEL, "<6>" tag ": " x) #define KLOG_DEBUG(tag,x...) klog_write(KLOG_DEBUG_LEVEL, "<7>" tag ": " x) #define KLOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ #endif ================================================ FILE: phonelibs/android_system_core/include/cutils/list.h ================================================ /* * Copyright (C) 2008-2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _CUTILS_LIST_H_ #define _CUTILS_LIST_H_ #include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ struct listnode { struct listnode *next; struct listnode *prev; }; #define node_to_item(node, container, member) \ (container *) (((char*) (node)) - offsetof(container, member)) #define list_declare(name) \ struct listnode name = { \ .next = &name, \ .prev = &name, \ } #define list_for_each(node, list) \ for (node = (list)->next; node != (list); node = node->next) #define list_for_each_reverse(node, list) \ for (node = (list)->prev; node != (list); node = node->prev) #define list_for_each_safe(node, n, list) \ for (node = (list)->next, n = node->next; \ node != (list); \ node = n, n = node->next) static inline void list_init(struct listnode *node) { node->next = node; node->prev = node; } static inline void list_add_tail(struct listnode *head, struct listnode *item) { item->next = head; item->prev = head->prev; head->prev->next = item; head->prev = item; } static inline void list_add_head(struct listnode *head, struct listnode *item) { item->next = head->next; item->prev = head; head->next->prev = item; head->next = item; } static inline void list_remove(struct listnode *item) { item->next->prev = item->prev; item->prev->next = item->next; } #define list_empty(list) ((list) == (list)->next) #define list_head(list) ((list)->next) #define list_tail(list) ((list)->prev) #ifdef __cplusplus }; #endif /* __cplusplus */ #endif ================================================ FILE: phonelibs/android_system_core/include/cutils/log.h ================================================ #include ================================================ FILE: phonelibs/android_system_core/include/cutils/memory.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_CUTILS_MEMORY_H #define ANDROID_CUTILS_MEMORY_H #include #include #ifdef __cplusplus extern "C" { #endif /* size is given in bytes and must be multiple of 2 */ void android_memset16(uint16_t* dst, uint16_t value, size_t size); /* size is given in bytes and must be multiple of 4 */ void android_memset32(uint32_t* dst, uint32_t value, size_t size); #if defined(__GLIBC__) || defined(_WIN32) /* Declaration of strlcpy() for platforms that don't already have it. */ size_t strlcpy(char *dst, const char *src, size_t size); #endif #ifdef __cplusplus } // extern "C" #endif #endif // ANDROID_CUTILS_MEMORY_H ================================================ FILE: phonelibs/android_system_core/include/cutils/misc.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_MISC_H #define __CUTILS_MISC_H #ifdef __cplusplus extern "C" { #endif /* Load an entire file into a malloc'd chunk of memory * that is length_of_file + 1 (null terminator). If * sz is non-zero, return the size of the file via sz. * Returns 0 on failure. */ extern void *load_file(const char *fn, unsigned *sz); /* This is the range of UIDs (and GIDs) that are reserved * for assigning to applications. */ #define FIRST_APPLICATION_UID 10000 #define LAST_APPLICATION_UID 99999 #ifdef __cplusplus } #endif #endif /* __CUTILS_MISC_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/multiuser.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_MULTIUSER_H #define __CUTILS_MULTIUSER_H #include #ifdef __cplusplus extern "C" { #endif // NOTE: keep in sync with android.os.UserId #define MULTIUSER_APP_PER_USER_RANGE 100000 typedef uid_t userid_t; typedef uid_t appid_t; extern userid_t multiuser_get_user_id(uid_t uid); extern appid_t multiuser_get_app_id(uid_t uid); extern uid_t multiuser_get_uid(userid_t userId, appid_t appId); #ifdef __cplusplus } #endif #endif /* __CUTILS_MULTIUSER_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/native_handle.h ================================================ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NATIVE_HANDLE_H_ #define NATIVE_HANDLE_H_ #ifdef __cplusplus extern "C" { #endif typedef struct native_handle { int version; /* sizeof(native_handle_t) */ int numFds; /* number of file-descriptors at &data[0] */ int numInts; /* number of ints at &data[numFds] */ int data[0]; /* numFds + numInts ints */ } native_handle_t; /* * native_handle_close * * closes the file descriptors contained in this native_handle_t * * return 0 on success, or a negative error code on failure * */ int native_handle_close(const native_handle_t* h); /* * native_handle_create * * creates a native_handle_t and initializes it. must be destroyed with * native_handle_delete(). * */ native_handle_t* native_handle_create(int numFds, int numInts); /* * native_handle_delete * * frees a native_handle_t allocated with native_handle_create(). * This ONLY frees the memory allocated for the native_handle_t, but doesn't * close the file descriptors; which can be achieved with native_handle_close(). * * return 0 on success, or a negative error code on failure * */ int native_handle_delete(native_handle_t* h); #ifdef __cplusplus } #endif #endif /* NATIVE_HANDLE_H_ */ ================================================ FILE: phonelibs/android_system_core/include/cutils/open_memstream.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_OPEN_MEMSTREAM_H__ #define __CUTILS_OPEN_MEMSTREAM_H__ #include #if defined(__APPLE__) #ifdef __cplusplus extern "C" { #endif FILE* open_memstream(char** bufp, size_t* sizep); #ifdef __cplusplus } #endif #endif /* __APPLE__ */ #endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ ================================================ FILE: phonelibs/android_system_core/include/cutils/partition_utils.h ================================================ /* * Copyright 2011, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_PARTITION_WIPED_H__ #define __CUTILS_PARTITION_WIPED_H__ __BEGIN_DECLS int partition_wiped(char *source); __END_DECLS #endif /* __CUTILS_PARTITION_WIPED_H__ */ ================================================ FILE: phonelibs/android_system_core/include/cutils/process_name.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Gives the current process a name. */ #ifndef __PROCESS_NAME_H #define __PROCESS_NAME_H #ifdef __cplusplus extern "C" { #endif /** * Sets the current process name. * * Warning: This leaks a string every time you call it. Use judiciously! */ void set_process_name(const char* process_name); /** Gets the current process name. */ const char* get_process_name(void); #ifdef __cplusplus } #endif #endif /* __PROCESS_NAME_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/properties.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_PROPERTIES_H #define __CUTILS_PROPERTIES_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif /* System properties are *small* name value pairs managed by the ** property service. If your data doesn't fit in the provided ** space it is not appropriate for a system property. ** ** WARNING: system/bionic/include/sys/system_properties.h also defines ** these, but with different names. (TODO: fix that) */ #define PROPERTY_KEY_MAX PROP_NAME_MAX #define PROPERTY_VALUE_MAX PROP_VALUE_MAX /* property_get: returns the length of the value which will never be ** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. ** (the length does not include the terminating zero). ** ** If the property read fails or returns an empty value, the default ** value is used (if nonnull). */ int property_get(const char *key, char *value, const char *default_value); /* property_get_bool: returns the value of key coerced into a ** boolean. If the property is not set, then the default value is returned. ** * The following is considered to be true (1): ** "1", "true", "y", "yes", "on" ** ** The following is considered to be false (0): ** "0", "false", "n", "no", "off" ** ** The conversion is whitespace-sensitive (e.g. " off" will not be false). ** ** If no property with this key is set (or the key is NULL) or the boolean ** conversion fails, the default value is returned. **/ int8_t property_get_bool(const char *key, int8_t default_value); /* property_get_int64: returns the value of key truncated and coerced into a ** int64_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ int64_t property_get_int64(const char *key, int64_t default_value); /* property_get_int32: returns the value of key truncated and coerced into an ** int32_t. If the property is not set, then the default value is used. ** ** The numeric conversion is identical to strtoimax with the base inferred: ** - All digits up to the first non-digit characters are read ** - The longest consecutive prefix of digits is converted to a long ** ** Valid strings of digits are: ** - An optional sign character + or - ** - An optional prefix indicating the base (otherwise base 10 is assumed) ** -- 0 prefix is octal ** -- 0x / 0X prefix is hex ** ** Leading/trailing whitespace is ignored. Overflow/underflow will cause ** numeric conversion to fail. ** ** If no property with this key is set (or the key is NULL) or the numeric ** conversion fails, the default value is returned. **/ int32_t property_get_int32(const char *key, int32_t default_value); /* property_set: returns 0 on success, < 0 on failure */ int property_set(const char *key, const char *value); int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); #if defined(__BIONIC_FORTIFY) extern int __property_get_real(const char *, char *, const char *) __asm__(__USER_LABEL_PREFIX__ "property_get"); __errordecl(__property_get_too_small_error, "property_get() called with too small of a buffer"); __BIONIC_FORTIFY_INLINE int property_get(const char *key, char *value, const char *default_value) { size_t bos = __bos(value); if (bos < PROPERTY_VALUE_MAX) { __property_get_too_small_error(); } return __property_get_real(key, value, default_value); } #endif #ifdef __cplusplus } #endif #endif ================================================ FILE: phonelibs/android_system_core/include/cutils/qtaguid.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_QTAGUID_H #define __CUTILS_QTAGUID_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * Set tags (and owning UIDs) for network sockets. */ extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); /* * Untag a network socket before closing. */ extern int qtaguid_untagSocket(int sockfd); /* * For the given uid, switch counter sets. * The kernel only keeps a limited number of sets. * 2 for now. */ extern int qtaguid_setCounterSet(int counterSetNum, uid_t uid); /* * Delete all tag info that relates to the given tag an uid. * If the tag is 0, then ALL info about the uid is freeded. * The delete data also affects active tagged socketd, which are * then untagged. * The calling process can only operate on its own tags. * Unless it is part of the happy AID_NET_BW_ACCT group. * In which case it can clobber everything. */ extern int qtaguid_deleteTagData(int tag, uid_t uid); /* * Enable/disable qtaguid functionnality at a lower level. * When pacified, the kernel will accept commands but do nothing. */ extern int qtaguid_setPacifier(int on); #ifdef __cplusplus } #endif #endif /* __CUTILS_QTAG_UID_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/record_stream.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * A simple utility for reading fixed records out of a stream fd */ #ifndef _CUTILS_RECORD_STREAM_H #define _CUTILS_RECORD_STREAM_H #ifdef __cplusplus extern "C" { #endif typedef struct RecordStream RecordStream; extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); extern void record_stream_free(RecordStream *p_rs); extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, size_t *p_outRecordLen); #ifdef __cplusplus } #endif #endif /*_CUTILS_RECORD_STREAM_H*/ ================================================ FILE: phonelibs/android_system_core/include/cutils/sched_policy.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_SCHED_POLICY_H #define __CUTILS_SCHED_POLICY_H #ifdef __cplusplus extern "C" { #endif /* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ typedef enum { SP_DEFAULT = -1, SP_BACKGROUND = 0, SP_FOREGROUND = 1, SP_SYSTEM = 2, // can't be used with set_sched_policy() SP_AUDIO_APP = 3, SP_AUDIO_SYS = 4, SP_CNT, SP_MAX = SP_CNT - 1, SP_SYSTEM_DEFAULT = SP_FOREGROUND, } SchedPolicy; extern int set_cpuset_policy(int tid, SchedPolicy policy); /* Assign thread tid to the cgroup associated with the specified policy. * If the thread is a thread group leader, that is it's gettid() == getpid(), * then the other threads in the same thread group are _not_ affected. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -errno for error. */ extern int set_sched_policy(int tid, SchedPolicy policy); /* Return the policy associated with the cgroup of thread tid via policy pointer. * On platforms which support gettid(), zero tid means current thread. * Return value: 0 for success, or -1 for error and set errno. */ extern int get_sched_policy(int tid, SchedPolicy *policy); /* Return a displayable string corresponding to policy. * Return value: non-NULL NUL-terminated name of unspecified length; * the caller is responsible for displaying the useful part of the string. */ extern const char *get_sched_policy_name(SchedPolicy policy); #ifdef __cplusplus } #endif #endif /* __CUTILS_SCHED_POLICY_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/sockets.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_SOCKETS_H #define __CUTILS_SOCKETS_H #include #include #include #include #include #ifdef HAVE_WINSOCK #include typedef int socklen_t; #else #include #endif #define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" #define ANDROID_SOCKET_DIR "/dev/socket" #ifdef __cplusplus extern "C" { #endif /* * android_get_control_socket - simple helper function to get the file * descriptor of our init-managed Unix domain socket. `name' is the name of the * socket, as given in init.rc. Returns -1 on error. * * This is inline and not in libcutils proper because we want to use this in * third-party daemons with minimal modification. */ static inline int android_get_control_socket(const char *name) { char key[64]; snprintf(key, sizeof(key), ANDROID_SOCKET_ENV_PREFIX "%s", name); const char* val = getenv(key); if (!val) { return -1; } errno = 0; int fd = strtol(val, NULL, 10); if (errno) { return -1; } return fd; } /* * See also android.os.LocalSocketAddress.Namespace */ // Linux "abstract" (non-filesystem) namespace #define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 // Android "reserved" (/dev/socket) namespace #define ANDROID_SOCKET_NAMESPACE_RESERVED 1 // Normal filesystem namespace #define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 extern int socket_loopback_client(int port, int type); extern int socket_network_client(const char *host, int port, int type); extern int socket_network_client_timeout(const char *host, int port, int type, int timeout); extern int socket_loopback_server(int port, int type); extern int socket_local_server(const char *name, int namespaceId, int type); extern int socket_local_server_bind(int s, const char *name, int namespaceId); extern int socket_local_client_connect(int fd, const char *name, int namespaceId, int type); extern int socket_local_client(const char *name, int namespaceId, int type); extern int socket_inaddr_any_server(int port, int type); /* * socket_peer_is_trusted - Takes a socket which is presumed to be a * connected local socket (e.g. AF_LOCAL) and returns whether the peer * (the userid that owns the process on the other end of that socket) * is one of the two trusted userids, root or shell. * * Note: This only works as advertised on the Android OS and always * just returns true when called on other operating systems. */ extern bool socket_peer_is_trusted(int fd); #ifdef __cplusplus } #endif #endif /* __CUTILS_SOCKETS_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/str_parms.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_STR_PARMS_H #define __CUTILS_STR_PARMS_H #include #include __BEGIN_DECLS struct str_parms; struct str_parms *str_parms_create(void); struct str_parms *str_parms_create_str(const char *_string); void str_parms_destroy(struct str_parms *str_parms); void str_parms_del(struct str_parms *str_parms, const char *key); int str_parms_add_str(struct str_parms *str_parms, const char *key, const char *value); int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); int str_parms_add_float(struct str_parms *str_parms, const char *key, float value); // Returns non-zero if the str_parms contains the specified key. int str_parms_has_key(struct str_parms *str_parms, const char *key); // Gets value associated with the specified key (if present), placing it in the buffer // pointed to by the out_val parameter. Returns the length of the returned string value. // If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched. int str_parms_get_str(struct str_parms *str_parms, const char *key, char *out_val, int len); int str_parms_get_int(struct str_parms *str_parms, const char *key, int *out_val); int str_parms_get_float(struct str_parms *str_parms, const char *key, float *out_val); char *str_parms_to_str(struct str_parms *str_parms); /* debug */ void str_parms_dump(struct str_parms *str_parms); __END_DECLS #endif /* __CUTILS_STR_PARMS_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/threads.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_CUTILS_THREADS_H #define _LIBS_CUTILS_THREADS_H #include #if !defined(_WIN32) #include #else #include #endif #ifdef __cplusplus extern "C" { #endif /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** local thread storage *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ extern pid_t gettid(); #if !defined(_WIN32) typedef struct { pthread_mutex_t lock; int has_tls; pthread_key_t tls; } thread_store_t; #define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } #else // !defined(_WIN32) typedef struct { int lock_init; int has_tls; DWORD tls; CRITICAL_SECTION lock; } thread_store_t; #define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } #endif // !defined(_WIN32) typedef void (*thread_store_destruct_t)(void* value); extern void* thread_store_get(thread_store_t* store); extern void thread_store_set(thread_store_t* store, void* value, thread_store_destruct_t destroy); /***********************************************************************/ /***********************************************************************/ /***** *****/ /***** mutexes *****/ /***** *****/ /***********************************************************************/ /***********************************************************************/ #if !defined(_WIN32) typedef pthread_mutex_t mutex_t; #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER static __inline__ void mutex_lock(mutex_t* lock) { pthread_mutex_lock(lock); } static __inline__ void mutex_unlock(mutex_t* lock) { pthread_mutex_unlock(lock); } static __inline__ int mutex_init(mutex_t* lock) { return pthread_mutex_init(lock, NULL); } static __inline__ void mutex_destroy(mutex_t* lock) { pthread_mutex_destroy(lock); } #else // !defined(_WIN32) typedef struct { int init; CRITICAL_SECTION lock[1]; } mutex_t; #define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } static __inline__ void mutex_lock(mutex_t* lock) { if (!lock->init) { lock->init = 1; InitializeCriticalSection( lock->lock ); lock->init = 2; } else while (lock->init != 2) Sleep(10); EnterCriticalSection(lock->lock); } static __inline__ void mutex_unlock(mutex_t* lock) { LeaveCriticalSection(lock->lock); } static __inline__ int mutex_init(mutex_t* lock) { InitializeCriticalSection(lock->lock); lock->init = 2; return 0; } static __inline__ void mutex_destroy(mutex_t* lock) { if (lock->init) { lock->init = 0; DeleteCriticalSection(lock->lock); } } #endif // !defined(_WIN32) #ifdef __cplusplus } #endif #endif /* _LIBS_CUTILS_THREADS_H */ ================================================ FILE: phonelibs/android_system_core/include/cutils/trace.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_CUTILS_TRACE_H #define _LIBS_CUTILS_TRACE_H #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /** * The ATRACE_TAG macro can be defined before including this header to trace * using one of the tags defined below. It must be defined to one of the * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in * userland to avoid some of the runtime cost of tracing when it is not desired. * * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always * being enabled - this should ONLY be done for debug code, as userland tracing * has a performance cost even when the trace is not being recorded. Defining * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result * in the tracing always being disabled. * * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing * within a hardware module. For example a camera hardware module would set: * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) * * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. */ #define ATRACE_TAG_NEVER 0 // This tag is never enabled. #define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. #define ATRACE_TAG_GRAPHICS (1<<1) #define ATRACE_TAG_INPUT (1<<2) #define ATRACE_TAG_VIEW (1<<3) #define ATRACE_TAG_WEBVIEW (1<<4) #define ATRACE_TAG_WINDOW_MANAGER (1<<5) #define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) #define ATRACE_TAG_SYNC_MANAGER (1<<7) #define ATRACE_TAG_AUDIO (1<<8) #define ATRACE_TAG_VIDEO (1<<9) #define ATRACE_TAG_CAMERA (1<<10) #define ATRACE_TAG_HAL (1<<11) #define ATRACE_TAG_APP (1<<12) #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) #define ATRACE_TAG_RS (1<<15) #define ATRACE_TAG_BIONIC (1<<16) #define ATRACE_TAG_POWER (1<<17) #define ATRACE_TAG_LAST ATRACE_TAG_POWER // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) #define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) #ifndef ATRACE_TAG #define ATRACE_TAG ATRACE_TAG_NEVER #elif ATRACE_TAG > ATRACE_TAG_VALID_MASK #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal * trace function will cause it to be run safely. */ void atrace_setup(); /** * If tracing is ready, set atrace_enabled_tags to the system property * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. */ void atrace_update_tags(); /** * Set whether the process is debuggable. By default the process is not * considered debuggable. If the process is not debuggable then application- * level tracing is not allowed unless the ro.debuggable system property is * set to '1'. */ void atrace_set_debuggable(bool debuggable); /** * Set whether tracing is enabled for the current process. This is used to * prevent tracing within the Zygote process. */ void atrace_set_tracing_enabled(bool enabled); /** * Flag indicating whether setup has been completed, initialized to 0. * Nonzero indicates setup has completed. * Note: This does NOT indicate whether or not setup was successful. */ extern atomic_bool atrace_is_ready; /** * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. * A value of zero indicates setup has failed. * Any other nonzero value indicates setup has succeeded, and tracing is on. */ extern uint64_t atrace_enabled_tags; /** * Handle to the kernel's trace buffer, initialized to -1. * Any other value indicates setup has succeeded, and is a valid fd for tracing. */ extern int atrace_marker_fd; /** * atrace_init readies the process for tracing by opening the trace_marker file. * Calling any trace function causes this to be run, so calling it is optional. * This can be explicitly run to avoid setup delay on first trace function. */ #define ATRACE_INIT() atrace_init() static inline void atrace_init() { if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) { atrace_setup(); } } /** * Get the mask of all tags currently enabled. * It can be used as a guard condition around more expensive trace calculations. * Every trace function calls this, which ensures atrace_init is run. */ #define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() static inline uint64_t atrace_get_enabled_tags() { atrace_init(); return atrace_enabled_tags; } /** * Test if a given tag is currently enabled. * Returns nonzero if the tag is enabled, otherwise zero. * It can be used as a guard condition around more expensive trace calculations. */ #define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) static inline uint64_t atrace_is_tag_enabled(uint64_t tag) { return atrace_get_enabled_tags() & tag; } /** * Trace the beginning of a context. name is used to identify the context. * This is often used to time function execution. */ #define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_begin_body(const char*); atrace_begin_body(name); } } /** * Trace the end of a context. * This should match up (and occur after) a corresponding ATRACE_BEGIN. */ #define ATRACE_END() atrace_end(ATRACE_TAG) static inline void atrace_end(uint64_t tag) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { char c = 'E'; write(atrace_marker_fd, &c, 1); } } /** * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END * contexts, asynchronous events do not need to be nested. The name describes * the event, and the cookie provides a unique identifier for distinguishing * simultaneous events. The name and cookie used to begin an event must be * used to end it. */ #define ATRACE_ASYNC_BEGIN(name, cookie) \ atrace_async_begin(ATRACE_TAG, name, cookie) static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_async_begin_body(const char*, int32_t); atrace_async_begin_body(name, cookie); } } /** * Trace the end of an asynchronous event. * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_async_end_body(const char*, int32_t); atrace_async_end_body(name, cookie); } } /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. */ #define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_int_body(const char*, int32_t); atrace_int_body(name, value); } } /** * Traces a 64-bit integer counter value. name is used to identify the * counter. This can be used to track how a value changes over time. */ #define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { void atrace_int64_body(const char*, int64_t); atrace_int64_body(name, value); } } __END_DECLS #endif // _LIBS_CUTILS_TRACE_H ================================================ FILE: phonelibs/android_system_core/include/cutils/uevent.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CUTILS_UEVENT_H #define __CUTILS_UEVENT_H #include #include #ifdef __cplusplus extern "C" { #endif int uevent_open_socket(int buf_sz, bool passcred); ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); ssize_t uevent_kernel_recv(int socket, void *buffer, size_t length, bool require_group, uid_t *uid); #ifdef __cplusplus } #endif #endif /* __CUTILS_UEVENT_H */ ================================================ FILE: phonelibs/android_system_core/include/log/event_tag_map.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_CUTILS_EVENTTAGMAP_H #define _LIBS_CUTILS_EVENTTAGMAP_H #ifdef __cplusplus extern "C" { #endif #define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" struct EventTagMap; typedef struct EventTagMap EventTagMap; /* * Open the specified file as an event log tag map. * * Returns NULL on failure. */ EventTagMap* android_openEventTagMap(const char* fileName); /* * Close the map. */ void android_closeEventTagMap(EventTagMap* map); /* * Look up a tag by index. Returns the tag string, or NULL if not found. */ const char* android_lookupEventTag(const EventTagMap* map, int tag); #ifdef __cplusplus } #endif #endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ ================================================ FILE: phonelibs/android_system_core/include/log/log.h ================================================ /* * Copyright (C) 2005-2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // C/C++ logging functions. See the logging documentation for API details. // // We'd like these to be available from C code (in case we import some from // somewhere), so this has a C interface. // // The output will be correct when the log file is shared between multiple // threads and/or multiple processes so long as the operating system // supports O_APPEND. These calls have mutex-protected data structures // and so are NOT reentrant. Do not use LOG in a signal handler. // #ifndef _LIBS_LOG_LOG_H #define _LIBS_LOG_LOG_H #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif // --------------------------------------------------------------------- /* * Normally we strip ALOGV (VERBOSE messages) from release builds. * You can modify this (for example with "#define LOG_NDEBUG 0" * at the top of your source file) to change that behavior. */ #ifndef LOG_NDEBUG #ifdef NDEBUG #define LOG_NDEBUG 1 #else #define LOG_NDEBUG 0 #endif #endif /* * This is the local tag used for the following simplified * logging macros. You can change this preprocessor definition * before using the other macros to change the tag. */ #ifndef LOG_TAG #define LOG_TAG NULL #endif // --------------------------------------------------------------------- #ifndef __predict_false #define __predict_false(exp) __builtin_expect((exp) != 0, 0) #endif /* * -DLINT_RLOG in sources that you want to enforce that all logging * goes to the radio log buffer. If any logging goes to any of the other * log buffers, there will be a compile or link error to highlight the * problem. This is not a replacement for a full audit of the code since * this only catches compiled code, not ifdef'd debug code. Options to * defining this, either temporarily to do a spot check, or permanently * to enforce, in all the communications trees; We have hopes to ensure * that by supplying just the radio log buffer that the communications * teams will have their one-stop shop for triaging issues. */ #ifndef LINT_RLOG /* * Simplified macro to send a verbose log message using the current LOG_TAG. */ #ifndef ALOGV #define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #if LOG_NDEBUG #define ALOGV(...) do { if (0) { __ALOGV(__VA_ARGS__); } } while (0) #else #define ALOGV(...) __ALOGV(__VA_ARGS__) #endif #endif #ifndef ALOGV_IF #if LOG_NDEBUG #define ALOGV_IF(cond, ...) ((void)0) #else #define ALOGV_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif #endif /* * Simplified macro to send a debug log message using the current LOG_TAG. */ #ifndef ALOGD #define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #endif #ifndef ALOGD_IF #define ALOGD_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an info log message using the current LOG_TAG. */ #ifndef ALOGI #define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) #endif #ifndef ALOGI_IF #define ALOGI_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send a warning log message using the current LOG_TAG. */ #ifndef ALOGW #define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) #endif #ifndef ALOGW_IF #define ALOGW_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an error log message using the current LOG_TAG. */ #ifndef ALOGE #define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) #endif #ifndef ALOGE_IF #define ALOGE_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* * Conditional based on whether the current LOG_TAG is enabled at * verbose priority. */ #ifndef IF_ALOGV #if LOG_NDEBUG #define IF_ALOGV() if (false) #else #define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG) #endif #endif /* * Conditional based on whether the current LOG_TAG is enabled at * debug priority. */ #ifndef IF_ALOGD #define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG) #endif /* * Conditional based on whether the current LOG_TAG is enabled at * info priority. */ #ifndef IF_ALOGI #define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG) #endif /* * Conditional based on whether the current LOG_TAG is enabled at * warn priority. */ #ifndef IF_ALOGW #define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG) #endif /* * Conditional based on whether the current LOG_TAG is enabled at * error priority. */ #ifndef IF_ALOGE #define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG) #endif // --------------------------------------------------------------------- /* * Simplified macro to send a verbose system log message using the current LOG_TAG. */ #ifndef SLOGV #define __SLOGV(...) \ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #if LOG_NDEBUG #define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0) #else #define SLOGV(...) __SLOGV(__VA_ARGS__) #endif #endif #ifndef SLOGV_IF #if LOG_NDEBUG #define SLOGV_IF(cond, ...) ((void)0) #else #define SLOGV_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif #endif /* * Simplified macro to send a debug system log message using the current LOG_TAG. */ #ifndef SLOGD #define SLOGD(...) \ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGD_IF #define SLOGD_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an info system log message using the current LOG_TAG. */ #ifndef SLOGI #define SLOGI(...) \ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGI_IF #define SLOGI_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send a warning system log message using the current LOG_TAG. */ #ifndef SLOGW #define SLOGW(...) \ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGW_IF #define SLOGW_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an error system log message using the current LOG_TAG. */ #ifndef SLOGE #define SLOGE(...) \ ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) #endif #ifndef SLOGE_IF #define SLOGE_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif #endif /* !LINT_RLOG */ // --------------------------------------------------------------------- /* * Simplified macro to send a verbose radio log message using the current LOG_TAG. */ #ifndef RLOGV #define __RLOGV(...) \ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) #if LOG_NDEBUG #define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0) #else #define RLOGV(...) __RLOGV(__VA_ARGS__) #endif #endif #ifndef RLOGV_IF #if LOG_NDEBUG #define RLOGV_IF(cond, ...) ((void)0) #else #define RLOGV_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif #endif /* * Simplified macro to send a debug radio log message using the current LOG_TAG. */ #ifndef RLOGD #define RLOGD(...) \ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) #endif #ifndef RLOGD_IF #define RLOGD_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an info radio log message using the current LOG_TAG. */ #ifndef RLOGI #define RLOGI(...) \ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) #endif #ifndef RLOGI_IF #define RLOGI_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send a warning radio log message using the current LOG_TAG. */ #ifndef RLOGW #define RLOGW(...) \ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) #endif #ifndef RLOGW_IF #define RLOGW_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif /* * Simplified macro to send an error radio log message using the current LOG_TAG. */ #ifndef RLOGE #define RLOGE(...) \ ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) #endif #ifndef RLOGE_IF #define RLOGE_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ : (void)0 ) #endif // --------------------------------------------------------------------- /* * Log a fatal error. If the given condition fails, this stops program * execution like a normal assertion, but also generating the given message. * It is NOT stripped from release builds. Note that the condition test * is -inverted- from the normal assert() semantics. */ #ifndef LOG_ALWAYS_FATAL_IF #define LOG_ALWAYS_FATAL_IF(cond, ...) \ ( (__predict_false(cond)) \ ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \ : (void)0 ) #endif #ifndef LOG_ALWAYS_FATAL #define LOG_ALWAYS_FATAL(...) \ ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) ) #endif /* * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that * are stripped out of release builds. */ #if LOG_NDEBUG #ifndef LOG_FATAL_IF #define LOG_FATAL_IF(cond, ...) ((void)0) #endif #ifndef LOG_FATAL #define LOG_FATAL(...) ((void)0) #endif #else #ifndef LOG_FATAL_IF #define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) #endif #ifndef LOG_FATAL #define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__) #endif #endif /* * Assertion that generates a log message when the assertion fails. * Stripped out of release builds. Uses the current LOG_TAG. */ #ifndef ALOG_ASSERT #define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__) //#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) #endif // --------------------------------------------------------------------- /* * Basic log message macro. * * Example: * ALOG(LOG_WARN, NULL, "Failed with error %d", errno); * * The second argument may be NULL or "" to indicate the "global" tag. */ #ifndef ALOG #define ALOG(priority, tag, ...) \ LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) #endif /* * Log macro that allows you to specify a number for the priority. */ #ifndef LOG_PRI #define LOG_PRI(priority, tag, ...) \ android_printLog(priority, tag, __VA_ARGS__) #endif /* * Log macro that allows you to pass in a varargs ("args" is a va_list). */ #ifndef LOG_PRI_VA #define LOG_PRI_VA(priority, tag, fmt, args) \ android_vprintLog(priority, NULL, tag, fmt, args) #endif /* * Conditional given a desired logging priority and tag. */ #ifndef IF_ALOG #define IF_ALOG(priority, tag) \ if (android_testLog(ANDROID_##priority, tag)) #endif // --------------------------------------------------------------------- /* * Event logging. */ /* * Event log entry types. These must match up with the declarations in * java/android/android/util/EventLog.java. */ typedef enum { EVENT_TYPE_INT = 0, EVENT_TYPE_LONG = 1, EVENT_TYPE_STRING = 2, EVENT_TYPE_LIST = 3, EVENT_TYPE_FLOAT = 4, } AndroidEventLogType; #define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType) #define typeof_AndroidEventLogType unsigned char #ifndef LOG_EVENT_INT #define LOG_EVENT_INT(_tag, _value) { \ int intBuf = _value; \ (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \ sizeof(intBuf)); \ } #endif #ifndef LOG_EVENT_LONG #define LOG_EVENT_LONG(_tag, _value) { \ long long longBuf = _value; \ (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \ sizeof(longBuf)); \ } #endif #ifndef LOG_EVENT_FLOAT #define LOG_EVENT_FLOAT(_tag, _value) { \ float floatBuf = _value; \ (void) android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \ sizeof(floatBuf)); \ } #endif #ifndef LOG_EVENT_STRING #define LOG_EVENT_STRING(_tag, _value) \ (void) __android_log_bswrite(_tag, _value); #endif /* TODO: something for LIST */ /* * =========================================================================== * * The stuff in the rest of this file should not be used directly. */ #define android_printLog(prio, tag, fmt...) \ __android_log_print(prio, tag, fmt) #define android_vprintLog(prio, cond, tag, fmt...) \ __android_log_vprint(prio, tag, fmt) /* XXX Macros to work around syntax errors in places where format string * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF * (happens only in debug builds). */ /* Returns 2nd arg. Used to substitute default value if caller's vararg list * is empty. */ #define __android_second(dummy, second, ...) second /* If passed multiple args, returns ',' followed by all but 1st arg, otherwise * returns nothing. */ #define __android_rest(first, ...) , ## __VA_ARGS__ #define android_printAssert(cond, tag, fmt...) \ __android_log_assert(cond, tag, \ __android_second(0, ## fmt, NULL) __android_rest(fmt)) #define android_writeLog(prio, tag, text) \ __android_log_write(prio, tag, text) #define android_bWriteLog(tag, payload, len) \ __android_log_bwrite(tag, payload, len) #define android_btWriteLog(tag, type, payload, len) \ __android_log_btwrite(tag, type, payload, len) #define android_errorWriteLog(tag, subTag) \ __android_log_error_write(tag, subTag, -1, NULL, 0) #define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ __android_log_error_write(tag, subTag, uid, data, dataLen) /* * IF_ALOG uses android_testLog, but IF_ALOG can be overridden. * android_testLog will remain constant in its purpose as a wrapper * for Android logging filter policy, and can be subject to * change. It can be reused by the developers that override * IF_ALOG as a convenient means to reimplement their policy * over Android. */ #if LOG_NDEBUG /* Production */ #define android_testLog(prio, tag) \ (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0) #else #define android_testLog(prio, tag) \ (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0) #endif // TODO: remove these prototypes and their users #define android_writevLog(vec,num) do{}while(0) #define android_write1Log(str,len) do{}while (0) #define android_setMinPriority(tag, prio) do{}while(0) //#define android_logToCallback(func) do{}while(0) #define android_logToFile(tag, file) (0) #define android_logToFd(tag, fd) (0) #ifndef log_id_t_defined #define log_id_t_defined typedef enum log_id { LOG_ID_MIN = 0, #ifndef LINT_RLOG LOG_ID_MAIN = 0, #endif LOG_ID_RADIO = 1, #ifndef LINT_RLOG LOG_ID_EVENTS = 2, LOG_ID_SYSTEM = 3, LOG_ID_CRASH = 4, LOG_ID_KERNEL = 5, #endif LOG_ID_MAX } log_id_t; #endif #define sizeof_log_id_t sizeof(typeof_log_id_t) #define typeof_log_id_t unsigned char /* * Use the per-tag properties "log.tag." to generate a runtime * result of non-zero to expose a log. */ int __android_log_is_loggable(int prio, const char *tag, int def); int __android_log_error_write(int tag, const char *subTag, int32_t uid, const char *data, uint32_t dataLen); /* * Send a simple string to the log. */ int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text); int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...) #if defined(__GNUC__) __attribute__((__format__(printf, 4, 5))) #endif ; #ifdef __cplusplus } #endif #endif /* _LIBS_LOG_LOG_H */ ================================================ FILE: phonelibs/android_system_core/include/log/log_read.h ================================================ /* * Copyright (C) 2013-2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_LOG_LOG_READ_H #define _LIBS_LOG_LOG_READ_H #include #include /* struct log_time is a wire-format variant of struct timespec */ #define NS_PER_SEC 1000000000ULL #ifdef __cplusplus // NB: do NOT define a copy constructor. This will result in structure // no longer being compatible with pass-by-value which is desired // efficient behavior. Also, pass-by-reference breaks C/C++ ABI. struct log_time { public: uint32_t tv_sec; // good to Feb 5 2106 uint32_t tv_nsec; static const uint32_t tv_sec_max = 0xFFFFFFFFUL; static const uint32_t tv_nsec_max = 999999999UL; log_time(const timespec &T) { tv_sec = T.tv_sec; tv_nsec = T.tv_nsec; } log_time(uint32_t sec, uint32_t nsec) { tv_sec = sec; tv_nsec = nsec; } static const timespec EPOCH; log_time() { } log_time(clockid_t id) { timespec T; clock_gettime(id, &T); tv_sec = T.tv_sec; tv_nsec = T.tv_nsec; } log_time(const char *T) { const uint8_t *c = (const uint8_t *) T; tv_sec = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24); tv_nsec = c[4] | (c[5] << 8) | (c[6] << 16) | (c[7] << 24); } // timespec bool operator== (const timespec &T) const { return (tv_sec == static_cast(T.tv_sec)) && (tv_nsec == static_cast(T.tv_nsec)); } bool operator!= (const timespec &T) const { return !(*this == T); } bool operator< (const timespec &T) const { return (tv_sec < static_cast(T.tv_sec)) || ((tv_sec == static_cast(T.tv_sec)) && (tv_nsec < static_cast(T.tv_nsec))); } bool operator>= (const timespec &T) const { return !(*this < T); } bool operator> (const timespec &T) const { return (tv_sec > static_cast(T.tv_sec)) || ((tv_sec == static_cast(T.tv_sec)) && (tv_nsec > static_cast(T.tv_nsec))); } bool operator<= (const timespec &T) const { return !(*this > T); } log_time operator-= (const timespec &T); log_time operator- (const timespec &T) const { log_time local(*this); return local -= T; } log_time operator+= (const timespec &T); log_time operator+ (const timespec &T) const { log_time local(*this); return local += T; } // log_time bool operator== (const log_time &T) const { return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); } bool operator!= (const log_time &T) const { return !(*this == T); } bool operator< (const log_time &T) const { return (tv_sec < T.tv_sec) || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec)); } bool operator>= (const log_time &T) const { return !(*this < T); } bool operator> (const log_time &T) const { return (tv_sec > T.tv_sec) || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec)); } bool operator<= (const log_time &T) const { return !(*this > T); } log_time operator-= (const log_time &T); log_time operator- (const log_time &T) const { log_time local(*this); return local -= T; } log_time operator+= (const log_time &T); log_time operator+ (const log_time &T) const { log_time local(*this); return local += T; } uint64_t nsec() const { return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; } static const char default_format[]; // Add %#q for the fraction of a second to the standard library functions char *strptime(const char *s, const char *format = default_format); } __attribute__((__packed__)); #else typedef struct log_time { uint32_t tv_sec; uint32_t tv_nsec; } __attribute__((__packed__)) log_time; #endif #endif /* define _LIBS_LOG_LOG_READ_H */ ================================================ FILE: phonelibs/android_system_core/include/log/logd.h ================================================ /* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _ANDROID_CUTILS_LOGD_H #define _ANDROID_CUTILS_LOGD_H /* the stable/frozen log-related definitions have been * moved to this header, which is exposed by the NDK */ #include /* the rest is only used internally by the system */ #if !defined(_WIN32) #include #endif #include #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif int __android_log_bwrite(int32_t tag, const void *payload, size_t len); int __android_log_btwrite(int32_t tag, char type, const void *payload, size_t len); int __android_log_bswrite(int32_t tag, const char *payload); #ifdef __cplusplus } #endif #endif /* _LOGD_H */ ================================================ FILE: phonelibs/android_system_core/include/log/logger.h ================================================ /* ** ** Copyright 2007-2014, The Android Open Source Project ** ** This file is dual licensed. It may be redistributed and/or modified ** under the terms of the Apache 2.0 License OR version 2 of the GNU ** General Public License. */ #ifndef _LIBS_LOG_LOGGER_H #define _LIBS_LOG_LOGGER_H #include #include #include #ifdef __cplusplus extern "C" { #endif /* * The userspace structure for version 1 of the logger_entry ABI. * This structure is returned to userspace by the kernel logger * driver unless an upgrade to a newer ABI version is requested. */ struct logger_entry { uint16_t len; /* length of the payload */ uint16_t __pad; /* no matter what, we get 2 bytes of padding */ int32_t pid; /* generating process's pid */ int32_t tid; /* generating process's tid */ int32_t sec; /* seconds since Epoch */ int32_t nsec; /* nanoseconds */ char msg[0]; /* the entry's payload */ } __attribute__((__packed__)); /* * The userspace structure for version 2 of the logger_entry ABI. * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION) * is called with version==2; or used with the user space log daemon. */ struct logger_entry_v2 { uint16_t len; /* length of the payload */ uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */ int32_t pid; /* generating process's pid */ int32_t tid; /* generating process's tid */ int32_t sec; /* seconds since Epoch */ int32_t nsec; /* nanoseconds */ uint32_t euid; /* effective UID of logger */ char msg[0]; /* the entry's payload */ } __attribute__((__packed__)); struct logger_entry_v3 { uint16_t len; /* length of the payload */ uint16_t hdr_size; /* sizeof(struct logger_entry_v3) */ int32_t pid; /* generating process's pid */ int32_t tid; /* generating process's tid */ int32_t sec; /* seconds since Epoch */ int32_t nsec; /* nanoseconds */ uint32_t lid; /* log id of the payload */ char msg[0]; /* the entry's payload */ } __attribute__((__packed__)); /* * The maximum size of the log entry payload that can be * written to the logger. An attempt to write more than * this amount will result in a truncated log entry. */ #define LOGGER_ENTRY_MAX_PAYLOAD 4076 /* * The maximum size of a log entry which can be read from the * kernel logger driver. An attempt to read less than this amount * may result in read() returning EINVAL. */ #define LOGGER_ENTRY_MAX_LEN (5*1024) #define NS_PER_SEC 1000000000ULL struct log_msg { union { unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1]; struct logger_entry_v3 entry; struct logger_entry_v3 entry_v3; struct logger_entry_v2 entry_v2; struct logger_entry entry_v1; } __attribute__((aligned(4))); #ifdef __cplusplus /* Matching log_time operators */ bool operator== (const log_msg &T) const { return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec); } bool operator!= (const log_msg &T) const { return !(*this == T); } bool operator< (const log_msg &T) const { return (entry.sec < T.entry.sec) || ((entry.sec == T.entry.sec) && (entry.nsec < T.entry.nsec)); } bool operator>= (const log_msg &T) const { return !(*this < T); } bool operator> (const log_msg &T) const { return (entry.sec > T.entry.sec) || ((entry.sec == T.entry.sec) && (entry.nsec > T.entry.nsec)); } bool operator<= (const log_msg &T) const { return !(*this > T); } uint64_t nsec() const { return static_cast(entry.sec) * NS_PER_SEC + entry.nsec; } /* packet methods */ log_id_t id() { return (log_id_t) entry.lid; } char *msg() { return entry.hdr_size ? (char *) buf + entry.hdr_size : entry_v1.msg; } unsigned int len() { return (entry.hdr_size ? entry.hdr_size : sizeof(entry_v1)) + entry.len; } #endif }; struct logger; log_id_t android_logger_get_id(struct logger *logger); int android_logger_clear(struct logger *logger); long android_logger_get_log_size(struct logger *logger); int android_logger_set_log_size(struct logger *logger, unsigned long size); long android_logger_get_log_readable_size(struct logger *logger); int android_logger_get_log_version(struct logger *logger); struct logger_list; ssize_t android_logger_get_statistics(struct logger_list *logger_list, char *buf, size_t len); ssize_t android_logger_get_prune_list(struct logger_list *logger_list, char *buf, size_t len); int android_logger_set_prune_list(struct logger_list *logger_list, char *buf, size_t len); #define ANDROID_LOG_RDONLY O_RDONLY #define ANDROID_LOG_WRONLY O_WRONLY #define ANDROID_LOG_RDWR O_RDWR #define ANDROID_LOG_ACCMODE O_ACCMODE #define ANDROID_LOG_NONBLOCK O_NONBLOCK #define ANDROID_LOG_PSTORE 0x80000000 struct logger_list *android_logger_list_alloc(int mode, unsigned int tail, pid_t pid); struct logger_list *android_logger_list_alloc_time(int mode, log_time start, pid_t pid); void android_logger_list_free(struct logger_list *logger_list); /* In the purest sense, the following two are orthogonal interfaces */ int android_logger_list_read(struct logger_list *logger_list, struct log_msg *log_msg); /* Multiple log_id_t opens */ struct logger *android_logger_open(struct logger_list *logger_list, log_id_t id); #define android_logger_close android_logger_free /* Single log_id_t open */ struct logger_list *android_logger_list_open(log_id_t id, int mode, unsigned int tail, pid_t pid); #define android_logger_list_close android_logger_list_free /* * log_id_t helpers */ log_id_t android_name_to_log_id(const char *logName); const char *android_log_id_to_name(log_id_t log_id); #ifdef __cplusplus } #endif #endif /* _LIBS_LOG_LOGGER_H */ ================================================ FILE: phonelibs/android_system_core/include/log/logprint.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LOGPRINT_H #define _LOGPRINT_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef enum { FORMAT_OFF = 0, FORMAT_BRIEF, FORMAT_PROCESS, FORMAT_TAG, FORMAT_THREAD, FORMAT_RAW, FORMAT_TIME, FORMAT_THREADTIME, FORMAT_LONG, /* The following three are modifiers to above formats */ FORMAT_MODIFIER_COLOR, /* converts priority to color */ FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */ } AndroidLogPrintFormat; typedef struct AndroidLogFormat_t AndroidLogFormat; typedef struct AndroidLogEntry_t { time_t tv_sec; long tv_nsec; android_LogPriority priority; int32_t pid; int32_t tid; const char * tag; size_t messageLen; const char * message; } AndroidLogEntry; AndroidLogFormat *android_log_format_new(); void android_log_format_free(AndroidLogFormat *p_format); /* currently returns 0 if format is a modifier, 1 if not */ int android_log_setPrintFormat(AndroidLogFormat *p_format, AndroidLogPrintFormat format); /** * Returns FORMAT_OFF on invalid string */ AndroidLogPrintFormat android_log_formatFromString(const char *s); /** * filterExpression: a single filter expression * eg "AT:d" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ int android_log_addFilterRule(AndroidLogFormat *p_format, const char *filterExpression); /** * filterString: a whitespace-separated set of filter expressions * eg "AT:d *:i" * * returns 0 on success and -1 on invalid expression * * Assumes single threaded execution * */ int android_log_addFilterString(AndroidLogFormat *p_format, const char *filterString); /** * returns 1 if this log line should be printed based on its priority * and tag, and 0 if it should not */ int android_log_shouldPrintLine ( AndroidLogFormat *p_format, const char *tag, android_LogPriority pri); /** * Splits a wire-format buffer into an AndroidLogEntry * entry allocated by caller. Pointers will point directly into buf * * Returns 0 on success and -1 on invalid wire format (entry will be * in unspecified state) */ int android_log_processLogBuffer(struct logger_entry *buf, AndroidLogEntry *entry); /** * Like android_log_processLogBuffer, but for binary logs. * * If "map" is non-NULL, it will be used to convert the log tag number * into a string. */ int android_log_processBinaryLogBuffer(struct logger_entry *buf, AndroidLogEntry *entry, const EventTagMap* map, char* messageBuf, int messageBufLen); /** * Formats a log message into a buffer * * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer * If return value != defaultBuffer, caller must call free() * Returns NULL on malloc error */ char *android_log_formatLogLine ( AndroidLogFormat *p_format, char *defaultBuffer, size_t defaultBufferSize, const AndroidLogEntry *p_line, size_t *p_outLength); /** * Either print or do not print log line, based on filter * * Assumes single threaded execution * */ int android_log_printLogLine( AndroidLogFormat *p_format, int fd, const AndroidLogEntry *entry); #ifdef __cplusplus } #endif #endif /*_LOGPRINT_H*/ ================================================ FILE: phonelibs/android_system_core/include/log/uio.h ================================================ /* * Copyright (C) 2007-2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_CUTILS_UIO_H #define _LIBS_CUTILS_UIO_H #if !defined(_WIN32) #include #else #ifdef __cplusplus extern "C" { #endif // // Implementation of sys/uio.h for Win32. // #include struct iovec { void* iov_base; size_t iov_len; }; extern int readv( int fd, struct iovec* vecs, int count ); extern int writev( int fd, const struct iovec* vecs, int count ); #ifdef __cplusplus } #endif #endif #endif /* _LIBS_UTILS_UIO_H */ ================================================ FILE: phonelibs/android_system_core/include/system/camera.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H #include #include #include #include #include #include __BEGIN_DECLS /** * A set of bit masks for specifying how the received preview frames are * handled before the previewCallback() call. * * The least significant 3 bits of an "int" value are used for this purpose: * * ..... 0 0 0 * ^ ^ ^ * | | |---------> determine whether the callback is enabled or not * | |-----------> determine whether the callback is one-shot or not * |-------------> determine whether the frame is copied out or not * * WARNING: When a frame is sent directly without copying, it is the frame * receiver's responsiblity to make sure that the frame data won't get * corrupted by subsequent preview frames filled by the camera. This flag is * recommended only when copying out data brings significant performance price * and the handling/processing of the received frame data is always faster than * the preview frame rate so that data corruption won't occur. * * For instance, * 1. 0x00 disables the callback. In this case, copy out and one shot bits * are ignored. * 2. 0x01 enables a callback without copying out the received frames. A * typical use case is the Camcorder application to avoid making costly * frame copies. * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical * use case is the Camera application. * 4. 0x07 is enabling a callback with frame copied out only once. A typical * use case is the Barcode scanner application. */ enum { CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, /** Typical use cases */ CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 }; /** msgType in notifyCallback and dataCallback functions */ enum { CAMERA_MSG_ERROR = 0x0001, // notifyCallback CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback CAMERA_MSG_FOCUS = 0x0004, // notifyCallback CAMERA_MSG_ZOOM = 0x0008, // notifyCallback CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback // Preview frame metadata. This can be combined with // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can // request FRAME and METADATA. Or the apps can request only FRAME or only // METADATA. CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback // Notify on autofocus start and stop. This is useful in continuous // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback CAMERA_MSG_VENDOR_START = 0x1000, CAMERA_MSG_STATS_DATA = CAMERA_MSG_VENDOR_START, CAMERA_MSG_META_DATA = 0x2000, CAMERA_MSG_VENDOR_END = 0x8000, CAMERA_MSG_ALL_MSGS = 0xFFFF }; /** meta data type in CameraMetaDataCallback */ enum { CAMERA_META_DATA_ASD = 0x001, //ASD data CAMERA_META_DATA_FD = 0x002, //FD/FP data CAMERA_META_DATA_HDR = 0x003, //Auto HDR data }; /** cmdType in sendCommand functions */ enum { CAMERA_CMD_START_SMOOTH_ZOOM = 1, CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, /** * Set the clockwise rotation of preview display (setPreviewDisplay) in * degrees. This affects the preview frames and the picture displayed after * snapshot. This method is useful for portrait mode applications. Note * that preview display of front-facing cameras is flipped horizontally * before the rotation, that is, the image is reflected along the central * vertical axis of the camera sensor. So the users can see themselves as * looking into a mirror. * * This does not affect the order of byte array of * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview * since API level 14. */ CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, /** * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = * 0 will disable, while passing arg1 = 1 will enable the shutter sound. */ CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, /* cmdType to play recording sound */ CAMERA_CMD_PLAY_RECORDING_SOUND = 5, /** * Start the face detection. This should be called after preview is started. * The camera will notify the listener of CAMERA_MSG_FACE and the detected * faces in the preview frame. The detected faces may be the same as the * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop * the face detection. This method is supported if CameraParameters * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is * bigger than 0. Hardware and software face detection should not be running * at the same time. If the face detection has started, apps should not send * this again. * * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. * * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not * supported, the HAL must return BAD_VALUE. */ CAMERA_CMD_START_FACE_DETECTION = 6, /** * Stop the face detection. */ CAMERA_CMD_STOP_FACE_DETECTION = 7, /** * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. */ CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, /** * Ping camera service to see if camera hardware is released. * * When any camera method returns error, the client can use ping command * to see if the camera has been taken away by other clients. If the result * is NO_ERROR, it means the camera hardware is not released. If the result * is not NO_ERROR, the camera has been released and the existing client * can silently finish itself or show a dialog. */ CAMERA_CMD_PING = 9, /** * Configure the number of video buffers used for recording. The intended * video buffer count for recording is passed as arg1, which must be * greater than 0. This command must be sent before recording is started. * This command returns INVALID_OPERATION error if it is sent after video * recording is started, or the command is not supported at all. This * command also returns a BAD_VALUE error if the intended video buffer * count is non-positive or too big to be realized. */ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, /** * Configure an explicit format to use for video recording metadata mode. * This can be used to switch the format from the * default IMPLEMENTATION_DEFINED gralloc format to some other * device-supported format, and the default dataspace from the BT_709 color * space to some other device-supported dataspace. arg1 is the HAL pixel * format, and arg2 is the HAL dataSpace. This command returns * INVALID_OPERATION error if it is sent after video recording is started, * or the command is not supported at all. * * If the gralloc format is set to a format other than * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags * of SW_READ_OFTEN. */ #ifndef CAMERA_VENDOR_L_COMPAT CAMERA_CMD_SET_VIDEO_FORMAT = 11, CAMERA_CMD_VENDOR_START = 20, /** * Commands to enable/disable preview histogram * * Based on user's input to enable/disable histogram from the camera * UI, send the appropriate command to the HAL to turn on/off the histogram * stats and start sending the data to the application. */ CAMERA_CMD_HISTOGRAM_ON = CAMERA_CMD_VENDOR_START, CAMERA_CMD_HISTOGRAM_OFF = CAMERA_CMD_VENDOR_START + 1, CAMERA_CMD_HISTOGRAM_SEND_DATA = CAMERA_CMD_VENDOR_START + 2, CAMERA_CMD_LONGSHOT_ON = CAMERA_CMD_VENDOR_START + 3, CAMERA_CMD_LONGSHOT_OFF = CAMERA_CMD_VENDOR_START + 4, CAMERA_CMD_STOP_LONGSHOT = CAMERA_CMD_VENDOR_START + 5, CAMERA_CMD_METADATA_ON = CAMERA_CMD_VENDOR_START + 6, CAMERA_CMD_METADATA_OFF = CAMERA_CMD_VENDOR_START + 7, CAMERA_CMD_VENDOR_END = 200, #else /** * Values used by older HALs, provided as an option for compatibility */ CAMERA_CMD_HISTOGRAM_ON = 11, CAMERA_CMD_HISTOGRAM_OFF = 12, CAMERA_CMD_HISTOGRAM_SEND_DATA = 13, CAMERA_CMD_LONGSHOT_ON = 14, CAMERA_CMD_LONGSHOT_OFF = 15, CAMERA_CMD_STOP_LONGSHOT = 16, CAMERA_CMD_METADATA_ON = 100, CAMERA_CMD_METADATA_OFF = 101, CAMERA_CMD_SET_VIDEO_FORMAT = 102, #endif }; /** camera fatal errors */ enum { CAMERA_ERROR_UNKNOWN = 1, /** * Camera was released because another client has connected to the camera. * The original client should call Camera::disconnect immediately after * getting this notification. Otherwise, the camera will be released by * camera service in a short time. The client should not call any method * (except disconnect and sending CAMERA_CMD_PING) after getting this. */ CAMERA_ERROR_RELEASED = 2, CAMERA_ERROR_SERVER_DIED = 100 }; enum { /** The facing of the camera is opposite to that of the screen. */ CAMERA_FACING_BACK = 0, /** The facing of the camera is the same as that of the screen. */ CAMERA_FACING_FRONT = 1, /** * The facing of the camera is not fixed relative to the screen. * The cameras with this facing are external cameras, e.g. USB cameras. */ CAMERA_FACING_EXTERNAL = 2 }; enum { /** Hardware face detection. It does not use much CPU. */ CAMERA_FACE_DETECTION_HW = 0, /** * Software face detection. It uses some CPU. Applications must use * Camera.setPreviewTexture for preview in this mode. */ CAMERA_FACE_DETECTION_SW = 1 }; /** * The information of a face from camera face detection. */ typedef struct camera_face { /** * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents * the top-left of the camera field of view, and (1000, 1000) represents the * bottom-right of the field of view. The width and height cannot be 0 or * negative. This is supported by both hardware and software face detection. * * The direction is relative to the sensor orientation, that is, what the * sensor sees. The direction is not affected by the rotation or mirroring * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. */ int32_t rect[4]; /** * The confidence level of the face. The range is 1 to 100. 100 is the * highest confidence. This is supported by both hardware and software * face detection. */ int32_t score; /** * An unique id per face while the face is visible to the tracker. If * the face leaves the field-of-view and comes back, it will get a new * id. If the value is 0, id is not supported. */ int32_t id; /** * The coordinates of the center of the left eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t left_eye[2]; /** * The coordinates of the center of the right eye. The range is -1000 to * 1000. -2000, -2000 if this is not supported. */ int32_t right_eye[2]; /** * The coordinates of the center of the mouth. The range is -1000 to 1000. * -2000, -2000 if this is not supported. */ int32_t mouth[2]; int32_t smile_degree; int32_t smile_score; int32_t blink_detected; int32_t face_recognised; int32_t gaze_angle; int32_t updown_dir; int32_t leftright_dir; int32_t roll_dir; int32_t left_right_gaze; int32_t top_bottom_gaze; int32_t leye_blink; int32_t reye_blink; } camera_face_t; /** * The information of a data type received in a camera frame. */ typedef enum { /** Data buffer */ CAMERA_FRAME_DATA_BUF = 0x000, /** File descriptor */ CAMERA_FRAME_DATA_FD = 0x100 } camera_frame_data_type_t; /** * The metadata of the frame data. */ typedef struct camera_frame_metadata { /** * The number of detected faces in the frame. */ int32_t number_of_faces; /** * An array of the detected faces. The length is number_of_faces. */ camera_face_t *faces; } camera_frame_metadata_t; __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ ================================================ FILE: phonelibs/android_system_core/include/system/graphics.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H #include #ifdef __cplusplus extern "C" { #endif /* * If the HAL needs to create service threads to handle graphics related * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority * if they can block the main rendering thread in any way. * * the priority of the current thread can be set with: * * #include * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); * */ #define HAL_PRIORITY_URGENT_DISPLAY (-8) /** * pixel format definitions */ enum { /* * "linear" color pixel formats: * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer. * * The color space determines, for example, if the formats are linear or * gamma-corrected; or whether any special operations are performed when * reading or writing into a buffer in one of these formats. */ HAL_PIXEL_FORMAT_RGBA_8888 = 1, HAL_PIXEL_FORMAT_RGBX_8888 = 2, HAL_PIXEL_FORMAT_RGB_888 = 3, HAL_PIXEL_FORMAT_RGB_565 = 4, HAL_PIXEL_FORMAT_BGRA_8888 = 5, /* * 0x100 - 0x1FF * * This range is reserved for pixel formats that are specific to the HAL * implementation. Implementations can use any value in this range to * communicate video pixel formats between their HAL modules. These formats * must not have an alpha channel. Additionally, an EGLimage created from a * gralloc buffer of one of these formats must be supported for use with the * GL_OES_EGL_image_external OpenGL ES extension. */ /* * Android YUV format: * * This format is exposed outside of the HAL to software decoders and * applications. EGLImageKHR must support it in conjunction with the * OES_EGL_image_external extension. * * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed * by (W/2) x (H/2) Cr and Cb planes. * * This format assumes * - an even width * - an even height * - a horizontal stride multiple of 16 pixels * - a vertical stride equal to the height * * y_size = stride * height * c_stride = ALIGN(stride/2, 16) * c_size = c_stride * height/2 * size = y_size + c_size * 2 * cr_offset = y_size * cb_offset = y_size + c_size * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer. */ HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar /* * Android Y8 format: * * This format is exposed outside of the HAL to the framework. * The expected gralloc usage flags are SW_* and HW_CAMERA_*, * and no other HW_ flags will be used. * * Y8 is a YUV planar format comprised of a WxH Y plane, * with each pixel being represented by 8 bits. * * It is equivalent to just the Y plane from YV12. * * This format assumes * - an even width * - an even height * - a horizontal stride multiple of 16 pixels * - a vertical stride equal to the height * * size = stride * height * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer. */ HAL_PIXEL_FORMAT_Y8 = 0x20203859, /* * Android Y16 format: * * This format is exposed outside of the HAL to the framework. * The expected gralloc usage flags are SW_* and HW_CAMERA_*, * and no other HW_ flags will be used. * * Y16 is a YUV planar format comprised of a WxH Y plane, * with each pixel being represented by 16 bits. * * It is just like Y8, but has double the bits per pixel (little endian). * * This format assumes * - an even width * - an even height * - a horizontal stride multiple of 16 pixels * - a vertical stride equal to the height * - strides are specified in pixels, not in bytes * * size = stride * height * 2 * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer, except that dataSpace field * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth * image where each sample is a distance value measured by a depth camera, * plus an associated confidence value. */ HAL_PIXEL_FORMAT_Y16 = 0x20363159, /* * Android RAW sensor format: * * This format is exposed outside of the camera HAL to applications. * * RAW16 is a single-channel, 16-bit, little endian format, typically * representing raw Bayer-pattern images from an image sensor, with minimal * processing. * * The exact pixel layout of the data in the buffer is sensor-dependent, and * needs to be queried from the camera device. * * Generally, not all 16 bits are used; more common values are 10 or 12 * bits. If not all bits are used, the lower-order bits are filled first. * All parameters to interpret the raw data (black and white points, * color space, etc) must be queried from the camera device. * * This format assumes * - an even width * - an even height * - a horizontal stride multiple of 16 pixels * - a vertical stride equal to the height * - strides are specified in pixels, not in bytes * * size = stride * height * 2 * * This format must be accepted by the gralloc module when used with the * following usage flags: * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT * * When used with ANativeWindow, the dataSpace should be * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW16 = 0x20, /* * Android RAW10 format: * * This format is exposed outside of the camera HAL to applications. * * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, * unprocessed format, usually representing raw Bayer-pattern images coming from * an image sensor. * * In an image buffer with this format, starting from the first pixel of each * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte * contains the 2 least significant bits of the 4 pixels, the exact layout data * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth * bit of the ith pixel): * * bit 7 bit 0 * =====|=====|=====|=====|=====|=====|=====|=====| * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| * |-----|-----|-----|-----|-----|-----|-----|-----| * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| * |-----|-----|-----|-----|-----|-----|-----|-----| * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| * |-----|-----|-----|-----|-----|-----|-----|-----| * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| * |-----|-----|-----|-----|-----|-----|-----|-----| * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| * =============================================== * * This format assumes * - a width multiple of 4 pixels * - an even height * - a vertical stride equal to the height * - strides are specified in bytes, not in pixels * * size = stride * height * * When stride is equal to width * (10 / 8), there will be no padding bytes at * the end of each row, the entire image data is densely packed. When stride is * larger than width * (10 / 8), padding bytes will be present at the end of each * row (including the last row). * * This format must be accepted by the gralloc module when used with the * following usage flags: * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT * * When used with ANativeWindow, the dataSpace field should be * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW10 = 0x25, /* * Android RAW12 format: * * This format is exposed outside of camera HAL to applications. * * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, * unprocessed format, usually representing raw Bayer-pattern images coming from * an image sensor. * * In an image buffer with this format, starting from the first pixel of each * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first * and second byte contains the top 8 bits of first and second pixel. The third * byte contains the 4 least significant bits of the two pixels, the exact layout * data for each two consecutive pixels is illustrated below (Pi[j] stands for * the jth bit of the ith pixel): * * bit 7 bit 0 * ======|======|======|======|======|======|======|======| * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| * |------|------|------|------|------|------|------|------| * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| * |------|------|------|------|------|------|------|------| * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| * ======================================================= * * This format assumes: * - a width multiple of 4 pixels * - an even height * - a vertical stride equal to the height * - strides are specified in bytes, not in pixels * * size = stride * height * * When stride is equal to width * (12 / 8), there will be no padding bytes at * the end of each row, the entire image data is densely packed. When stride is * larger than width * (12 / 8), padding bytes will be present at the end of * each row (including the last row). * * This format must be accepted by the gralloc module when used with the * following usage flags: * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT * * When used with ANativeWindow, the dataSpace field should be * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW12 = 0x26, /* * Android opaque RAW format: * * This format is exposed outside of the camera HAL to applications. * * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an * image sensor. The actual structure of buffers of this format is * implementation-dependent. * * This format must be accepted by the gralloc module when used with the * following usage flags: * - GRALLOC_USAGE_HW_CAMERA_* * - GRALLOC_USAGE_SW_* * - GRALLOC_USAGE_RENDERSCRIPT * * When used with ANativeWindow, the dataSpace field should be * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial * extra metadata to define. */ HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24, /* * Android binary blob graphics buffer format: * * This format is used to carry task-specific data which does not have a * standard image structure. The details of the format are left to the two * endpoints. * * A typical use case is for transporting JPEG-compressed images from the * Camera HAL to the framework or to applications. * * Buffers of this format must have a height of 1, and width equal to their * size in bytes. * * When used with ANativeWindow, the mapping of the dataSpace field to * buffer contents for BLOB is as follows: * * dataSpace value | Buffer contents * -------------------------------+----------------------------------------- * HAL_DATASPACE_JFIF | An encoded JPEG image * HAL_DATASPACE_DEPTH | An android_depth_points buffer * Other | Unsupported * */ HAL_PIXEL_FORMAT_BLOB = 0x21, /* * Android format indicating that the choice of format is entirely up to the * device-specific Gralloc implementation. * * The Gralloc implementation should examine the usage bits passed in when * allocating a buffer with this format, and it should derive the pixel * format from those usage flags. This format will never be used with any * of the GRALLOC_USAGE_SW_* usage flags. * * If a buffer of this format is to be used as an OpenGL ES texture, the * framework will assume that sampling the texture will always return an * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values). * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer. */ HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, /* * Android flexible YCbCr 4:2:0 formats * * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 * buffer layout, while still describing the general format in a * layout-independent manner. While called YCbCr, it can be * used to describe formats with either chromatic ordering, as well as * whole planar or semiplanar layouts. * * struct android_ycbcr (below) is the the struct used to describe it. * * This format must be accepted by the gralloc module when * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set. * * This format is locked for use by gralloc's (*lock_ycbcr) method, and * locking with the (*lock) method will return an error. * * When used with ANativeWindow, the dataSpace field describes the color * space of the buffer. */ HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, /* * Android flexible YCbCr 4:2:2 formats * * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2 * buffer layout, while still describing the general format in a * layout-independent manner. While called YCbCr, it can be * used to describe formats with either chromatic ordering, as well as * whole planar or semiplanar layouts. * * This format is currently only used by SW readable buffers * produced by MediaCodecs, so the gralloc module can ignore this format. */ HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27, /* * Android flexible YCbCr 4:4:4 formats * * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4 * buffer layout, while still describing the general format in a * layout-independent manner. While called YCbCr, it can be * used to describe formats with either chromatic ordering, as well as * whole planar or semiplanar layouts. * * This format is currently only used by SW readable buffers * produced by MediaCodecs, so the gralloc module can ignore this format. */ HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28, /* * Android flexible RGB 888 formats * * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX * buffer layout, while still describing the general format in a * layout-independent manner. While called RGB, it can be * used to describe formats with either color ordering and optional * padding, as well as whole planar layout. * * This format is currently only used by SW readable buffers * produced by MediaCodecs, so the gralloc module can ignore this format. */ HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29, /* * Android flexible RGBA 8888 formats * * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR * buffer layout, while still describing the general format in a * layout-independent manner. While called RGBA, it can be * used to describe formats with any of the component orderings, as * well as whole planar layout. * * This format is currently only used by SW readable buffers * produced by MediaCodecs, so the gralloc module can ignore this format. */ HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A, /* Legacy formats (deprecated), used by ImageFormat.java */ HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 }; /* * Structure for describing YCbCr formats for consumption by applications. * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. * * Buffer chroma subsampling is defined in the format. * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. * * Buffers must have a 8 bit depth. * * @y, @cb, and @cr point to the first byte of their respective planes. * * Stride describes the distance in bytes from the first value of one row of * the image to the first value of the next row. It includes the width of the * image plus padding. * @ystride is the stride of the luma plane. * @cstride is the stride of the chroma planes. * * @chroma_step is the distance in bytes from one chroma pixel value to the * next. This is 2 bytes for semiplanar (because chroma values are interleaved * and each chroma value is one byte) and 1 for planar. */ struct android_ycbcr { void *y; void *cb; void *cr; size_t ystride; size_t cstride; size_t chroma_step; /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ uint32_t reserved[8]; }; /** * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB * with dataSpace value of HAL_DATASPACE_DEPTH. * When locking a native buffer of the above format and dataSpace value, * the vaddr pointer can be cast to this structure. * * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y, * z) represents a measured point's position, with the coordinate system defined * by the data source. Confidence represents the estimated likelihood that this * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f == * 100% confidence. * * @num_points is the number of points in the list * * @xyz_points is the flexible array of floating-point values. * It contains (num_points) * 4 floats. * * For example: * android_depth_points d = get_depth_buffer(); * struct { * float x; float y; float z; float confidence; * } firstPoint, lastPoint; * * firstPoint.x = d.xyzc_points[0]; * firstPoint.y = d.xyzc_points[1]; * firstPoint.z = d.xyzc_points[2]; * firstPoint.confidence = d.xyzc_points[3]; * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0]; * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1]; * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2]; * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3]; */ struct android_depth_points { uint32_t num_points; /** reserved for future use, set to 0 by gralloc's (*lock)() */ uint32_t reserved[8]; float xyzc_points[]; }; /** * Transformation definitions * * IMPORTANT NOTE: * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. * */ enum { /* flip source image horizontally (around the vertical axis) */ HAL_TRANSFORM_FLIP_H = 0x01, /* flip source image vertically (around the horizontal axis)*/ HAL_TRANSFORM_FLIP_V = 0x02, /* rotate source image 90 degrees clockwise */ HAL_TRANSFORM_ROT_90 = 0x04, /* rotate source image 180 degrees */ HAL_TRANSFORM_ROT_180 = 0x03, /* rotate source image 270 degrees clockwise */ HAL_TRANSFORM_ROT_270 = 0x07, /* don't use. see system/window.h */ HAL_TRANSFORM_RESERVED = 0x08, }; /** * Dataspace Definitions * ====================== * * Dataspace is the definition of how pixel values should be interpreted. * * For many formats, this is the colorspace of the image data, which includes * primaries (including white point) and the transfer characteristic function, * which describes both gamma curve and numeric range (within the bit depth). * * Other dataspaces include depth measurement data from a depth camera. */ typedef enum android_dataspace { /* * Default-assumption data space, when not explicitly specified. * * It is safest to assume the buffer is an image with sRGB primaries and * encoding ranges, but the consumer and/or the producer of the data may * simply be using defaults. No automatic gamma transform should be * expected, except for a possible display gamma transform when drawn to a * screen. */ HAL_DATASPACE_UNKNOWN = 0x0, /* * Arbitrary dataspace with manually defined characteristics. Definition * for colorspaces or other meaning must be communicated separately. * * This is used when specifying primaries, transfer characteristics, * etc. separately. * * A typical use case is in video encoding parameters (e.g. for H.264), * where a colorspace can have separately defined primaries, transfer * characteristics, etc. */ HAL_DATASPACE_ARBITRARY = 0x1, /* * RGB Colorspaces * ----------------- * * Primaries are given using (x,y) coordinates in the CIE 1931 definition * of x and y specified by ISO 11664-1. * * Transfer characteristics are the opto-electronic transfer characteristic * at the source as a function of linear optical intensity (luminance). */ /* * sRGB linear encoding: * * The red, green, and blue components are stored in sRGB space, but * are linear, not gamma-encoded. * The RGB primaries and the white point are the same as BT.709. * * The values are encoded using the full range ([0,255] for 8-bit) for all * components. */ HAL_DATASPACE_SRGB_LINEAR = 0x200, /* * sRGB gamma encoding: * * The red, green and blue components are stored in sRGB space, and * converted to linear space when read, using the standard sRGB to linear * equation: * * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 * * When written the inverse transformation is performed: * * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 * * * The alpha component, if present, is always stored in linear space and * is left unmodified when read or written. * * The RGB primaries and the white point are the same as BT.709. * * The values are encoded using the full range ([0,255] for 8-bit) for all * components. * */ HAL_DATASPACE_SRGB = 0x201, /* * YCbCr Colorspaces * ----------------- * * Primaries are given using (x,y) coordinates in the CIE 1931 definition * of x and y specified by ISO 11664-1. * * Transfer characteristics are the opto-electronic transfer characteristic * at the source as a function of linear optical intensity (luminance). */ /* * JPEG File Interchange Format (JFIF) * * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_JFIF = 0x101, /* * ITU-R Recommendation 601 (BT.601) - 625-line * * Standard-definition television, 625 Lines (PAL) * * For 8-bit-depth formats: * Luma (Y) samples should range from 16 to 235, inclusive * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive * * For 10-bit-depth formats: * Luma (Y) samples should range from 64 to 940, inclusive * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.290 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_BT601_625 = 0x102, /* * ITU-R Recommendation 601 (BT.601) - 525-line * * Standard-definition television, 525 Lines (NTSC) * * For 8-bit-depth formats: * Luma (Y) samples should range from 16 to 235, inclusive * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive * * For 10-bit-depth formats: * Luma (Y) samples should range from 64 to 940, inclusive * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive * * Transfer characteristic curve: * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 * E = 4.500 L, 0.018 > L >= 0 * L - luminance of image 0 <= L <= 1 for conventional colorimetry * E - corresponding electrical signal * * Primaries: x y * green 0.310 0.595 * blue 0.155 0.070 * red 0.630 0.340 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_BT601_525 = 0x103, /* * ITU-R Recommendation 709 (BT.709) * * High-definition television * * For 8-bit-depth formats: * Luma (Y) samples should range from 16 to 235, inclusive * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive * * For 10-bit-depth formats: * Luma (Y) samples should range from 64 to 940, inclusive * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive * * Primaries: x y * green 0.300 0.600 * blue 0.150 0.060 * red 0.640 0.330 * white (D65) 0.3127 0.3290 */ HAL_DATASPACE_BT709 = 0x104, /* * The buffer contains depth ranging measurements from a depth camera. * This value is valid with formats: * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement * and an associated confidence value. The 3 MSBs of the sample make * up the confidence value, and the low 13 LSBs of the sample make up * the depth measurement. * For the confidence section, 0 means 100% confidence, 1 means 0% * confidence. The mapping to a linear float confidence value between * 0.f and 1.f can be obtained with * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; * The depth measurement can be extracted simply with * uint16_t range = (depthSample & 0x1FFF); * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as * a variable-length float (x,y,z, confidence) coordinate point list. * The point cloud will be represented with the android_depth_points * structure. */ HAL_DATASPACE_DEPTH = 0x1000 } android_dataspace_t; #ifdef __cplusplus } #endif #endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ ================================================ FILE: phonelibs/android_system_core/include/system/radio.h ================================================ /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_RADIO_H #define ANDROID_RADIO_H #include #include #include #include #include #define RADIO_NUM_BANDS_MAX 16 #define RADIO_NUM_SPACINGS_MAX 16 #define RADIO_STRING_LEN_MAX 128 /* * Radio hardware module class. A given radio hardware module HAL is of one class * only. The platform can not have more than one hardware module of each class. * Current version of the framework only supports RADIO_CLASS_AM_FM. */ typedef enum { RADIO_CLASS_AM_FM = 0, /* FM (including HD radio) and AM */ RADIO_CLASS_SAT = 1, /* Satellite Radio */ RADIO_CLASS_DT = 2, /* Digital Radio (DAB) */ } radio_class_t; /* value for field "type" of radio band described in struct radio_hal_band_config */ typedef enum { RADIO_BAND_AM = 0, /* Amplitude Modulation band: LW, MW, SW */ RADIO_BAND_FM = 1, /* Frequency Modulation band: FM */ RADIO_BAND_FM_HD = 2, /* FM HD Radio / DRM (IBOC) */ RADIO_BAND_AM_HD = 3, /* AM HD Radio / DRM (IBOC) */ } radio_band_t; /* RDS variant implemented. A struct radio_hal_fm_band_config can list none or several. */ enum { RADIO_RDS_NONE = 0x0, RADIO_RDS_WORLD = 0x01, RADIO_RDS_US = 0x02, }; typedef unsigned int radio_rds_t; /* FM deemphasis variant implemented. A struct radio_hal_fm_band_config can list one or more. */ enum { RADIO_DEEMPHASIS_50 = 0x1, RADIO_DEEMPHASIS_75 = 0x2, }; typedef unsigned int radio_deemphasis_t; /* Region a particular radio band configuration corresponds to. Not used at the HAL. * Derived by the framework when converting the band descriptors retrieved from the HAL to * individual band descriptors for each supported region. */ typedef enum { RADIO_REGION_NONE = -1, RADIO_REGION_ITU_1 = 0, RADIO_REGION_ITU_2 = 1, RADIO_REGION_OIRT = 2, RADIO_REGION_JAPAN = 3, RADIO_REGION_KOREA = 4, } radio_region_t; /* scanning direction for scan() and step() tuner APIs */ typedef enum { RADIO_DIRECTION_UP, RADIO_DIRECTION_DOWN } radio_direction_t; /* unique handle allocated to a radio module */ typedef unsigned int radio_handle_t; /* Opaque meta data structure used by radio meta data API (see system/radio_metadata.h) */ typedef struct radio_medtadata radio_metadata_t; /* Additional attributes for an FM band configuration */ typedef struct radio_hal_fm_band_config { radio_deemphasis_t deemphasis; /* deemphasis variant */ bool stereo; /* stereo supported */ radio_rds_t rds; /* RDS variants supported */ bool ta; /* Traffic Announcement supported */ bool af; /* Alternate Frequency supported */ } radio_hal_fm_band_config_t; /* Additional attributes for an AM band configuration */ typedef struct radio_hal_am_band_config { bool stereo; /* stereo supported */ } radio_hal_am_band_config_t; /* Radio band configuration. Describes a given band supported by the radio module. * The HAL can expose only one band per type with the the maximum range supported and all options. * THe framework will derive the actual regions were this module can operate and expose separate * band configurations for applications to chose from. */ typedef struct radio_hal_band_config { radio_band_t type; bool antenna_connected; unsigned int lower_limit; unsigned int upper_limit; unsigned int num_spacings; unsigned int spacings[RADIO_NUM_SPACINGS_MAX]; union { radio_hal_fm_band_config_t fm; radio_hal_am_band_config_t am; }; } radio_hal_band_config_t; /* Used internally by the framework to represent a band for s specific region */ typedef struct radio_band_config { radio_region_t region; radio_hal_band_config_t band; } radio_band_config_t; /* Exposes properties of a given hardware radio module. * NOTE: current framework implementation supports only one audio source (num_audio_sources = 1). * The source corresponds to AUDIO_DEVICE_IN_FM_TUNER. * If more than one tuner is supported (num_tuners > 1), only one can be connected to the audio * source. */ typedef struct radio_hal_properties { radio_class_t class_id; /* Class of this module. E.g RADIO_CLASS_AM_FM */ char implementor[RADIO_STRING_LEN_MAX]; /* implementor name */ char product[RADIO_STRING_LEN_MAX]; /* product name */ char version[RADIO_STRING_LEN_MAX]; /* product version */ char serial[RADIO_STRING_LEN_MAX]; /* serial number (for subscription services) */ unsigned int num_tuners; /* number of tuners controllable independently */ unsigned int num_audio_sources; /* number of audio sources driven simultaneously */ bool supports_capture; /* the hardware supports capture of audio source audio HAL */ unsigned int num_bands; /* number of band descriptors */ radio_hal_band_config_t bands[RADIO_NUM_BANDS_MAX]; /* band descriptors */ } radio_hal_properties_t; /* Used internally by the framework. Same information as in struct radio_hal_properties plus a * unique handle and one band configuration per region. */ typedef struct radio_properties { radio_handle_t handle; radio_class_t class_id; char implementor[RADIO_STRING_LEN_MAX]; char product[RADIO_STRING_LEN_MAX]; char version[RADIO_STRING_LEN_MAX]; char serial[RADIO_STRING_LEN_MAX]; unsigned int num_tuners; unsigned int num_audio_sources; bool supports_capture; unsigned int num_bands; radio_band_config_t bands[RADIO_NUM_BANDS_MAX]; } radio_properties_t; /* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED. * Contains information on currently tuned channel. */ typedef struct radio_program_info { unsigned int channel; /* current channel. (e.g kHz for band type RADIO_BAND_FM) */ unsigned int sub_channel; /* current sub channel. (used for RADIO_BAND_FM_HD) */ bool tuned; /* tuned to a program or not */ bool stereo; /* program is stereo or not */ bool digital; /* digital program or not (e.g HD Radio program) */ unsigned int signal_strength; /* signal strength from 0 to 100 */ radio_metadata_t *metadata; /* non null if meta data are present (e.g PTY, song title ...) */ } radio_program_info_t; /* Events sent to the framework via the HAL callback. An event can notify the completion of an * asynchronous command (configuration, tune, scan ...) or a spontaneous change (antenna connection, * failure, AF switching, meta data reception... */ enum { RADIO_EVENT_HW_FAILURE = 0, /* hardware module failure. Requires reopening the tuner */ RADIO_EVENT_CONFIG = 1, /* configuration change completed */ RADIO_EVENT_ANTENNA = 2, /* Antenna connected, disconnected */ RADIO_EVENT_TUNED = 3, /* tune, step, scan completed */ RADIO_EVENT_METADATA = 4, /* New meta data received */ RADIO_EVENT_TA = 5, /* Traffic announcement start or stop */ RADIO_EVENT_AF_SWITCH = 6, /* Switch to Alternate Frequency */ // begin framework only events RADIO_EVENT_CONTROL = 100, /* loss/gain of tuner control */ RADIO_EVENT_SERVER_DIED = 101, /* radio service died */ }; typedef unsigned int radio_event_type_t; /* Event passed to the framework by the HAL callback */ typedef struct radio_hal_event { radio_event_type_t type; /* event type */ int status; /* used by RADIO_EVENT_CONFIG, RADIO_EVENT_TUNED */ union { bool on; /* RADIO_EVENT_ANTENNA, RADIO_EVENT_TA */ radio_hal_band_config_t config; /* RADIO_EVENT_CONFIG */ radio_program_info_t info; /* RADIO_EVENT_TUNED, RADIO_EVENT_AF_SWITCH */ radio_metadata_t *metadata; /* RADIO_EVENT_METADATA */ }; } radio_hal_event_t; /* Used internally by the framework. Same information as in struct radio_hal_event */ typedef struct radio_event { radio_event_type_t type; int status; union { bool on; radio_band_config_t config; radio_program_info_t info; radio_metadata_t *metadata; /* offset from start of struct when in shared memory */ }; } radio_event_t; static radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { if (!rds) return RADIO_RDS_NONE; switch(region) { case RADIO_REGION_ITU_1: case RADIO_REGION_OIRT: case RADIO_REGION_JAPAN: case RADIO_REGION_KOREA: return RADIO_RDS_WORLD; case RADIO_REGION_ITU_2: return RADIO_RDS_US; default: return RADIO_REGION_NONE; } } static radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) { switch(region) { case RADIO_REGION_KOREA: case RADIO_REGION_ITU_2: return RADIO_DEEMPHASIS_75; case RADIO_REGION_ITU_1: case RADIO_REGION_OIRT: case RADIO_REGION_JAPAN: default: return RADIO_DEEMPHASIS_50; } } #endif // ANDROID_RADIO_H ================================================ FILE: phonelibs/android_system_core/include/system/thread_defs.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_THREAD_DEFS_H #define ANDROID_THREAD_DEFS_H #include "graphics.h" #if defined(__cplusplus) extern "C" { #endif enum { /* * *********************************************** * ** Keep in sync with android.os.Process.java ** * *********************************************** * * This maps directly to the "nice" priorities we use in Android. * A thread priority should be chosen inverse-proportionally to * the amount of work the thread is expected to do. The more work * a thread will do, the less favorable priority it should get so that * it doesn't starve the system. Threads not behaving properly might * be "punished" by the kernel. * Use the levels below when appropriate. Intermediate values are * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. */ ANDROID_PRIORITY_LOWEST = 19, /* use for background tasks */ ANDROID_PRIORITY_BACKGROUND = 10, /* most threads run at normal priority */ ANDROID_PRIORITY_NORMAL = 0, /* threads currently running a UI that the user is interacting with */ ANDROID_PRIORITY_FOREGROUND = -2, /* the main UI thread has a slightly more favorable priority */ ANDROID_PRIORITY_DISPLAY = -4, /* ui service treads might want to run at a urgent display (uncommon) */ ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, /* all normal audio threads */ ANDROID_PRIORITY_AUDIO = -16, /* service audio threads (uncommon) */ ANDROID_PRIORITY_URGENT_AUDIO = -19, /* should never be used in practice. regular process might not * be allowed to use this level */ ANDROID_PRIORITY_HIGHEST = -20, ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, ANDROID_PRIORITY_MORE_FAVORABLE = -1, ANDROID_PRIORITY_LESS_FAVORABLE = +1, }; #if defined(__cplusplus) } #endif #endif /* ANDROID_THREAD_DEFS_H */ ================================================ FILE: phonelibs/android_system_core/include/system/window.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H #include #include #include #include #include #include #include #include #ifndef __UNUSED #define __UNUSED __attribute__((__unused__)) #endif #ifndef __deprecated #define __deprecated __attribute__((__deprecated__)) #endif __BEGIN_DECLS /*****************************************************************************/ #define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d)) #define ANDROID_NATIVE_WINDOW_MAGIC \ ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') #define ANDROID_NATIVE_BUFFER_MAGIC \ ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') // --------------------------------------------------------------------------- // This #define may be used to conditionally compile device-specific code to // support either the prior ANativeWindow interface, which did not pass libsync // fences around, or the new interface that does. This #define is only present // when the ANativeWindow interface does include libsync support. #define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 // --------------------------------------------------------------------------- typedef const native_handle_t* buffer_handle_t; // --------------------------------------------------------------------------- typedef struct android_native_rect_t { int32_t left; int32_t top; int32_t right; int32_t bottom; } android_native_rect_t; // --------------------------------------------------------------------------- typedef struct android_native_base_t { /* a magic value defined by the actual EGL native type */ int magic; /* the sizeof() of the actual EGL native type */ int version; void* reserved[4]; /* reference-counting interface */ void (*incRef)(struct android_native_base_t* base); void (*decRef)(struct android_native_base_t* base); } android_native_base_t; typedef struct ANativeWindowBuffer { #ifdef __cplusplus ANativeWindowBuffer() { common.magic = ANDROID_NATIVE_BUFFER_MAGIC; common.version = sizeof(ANativeWindowBuffer); memset(common.reserved, 0, sizeof(common.reserved)); } // Implement the methods that sp expects so that it // can be used to automatically refcount ANativeWindowBuffer's. void incStrong(const void* /*id*/) const { common.incRef(const_cast(&common)); } void decStrong(const void* /*id*/) const { common.decRef(const_cast(&common)); } #endif struct android_native_base_t common; int width; int height; int stride; int format; int usage; void* reserved[2]; buffer_handle_t handle; void* reserved_proc[8]; } ANativeWindowBuffer_t; // Old typedef for backwards compatibility. typedef ANativeWindowBuffer_t android_native_buffer_t; // --------------------------------------------------------------------------- /* attributes queriable with query() */ enum { NATIVE_WINDOW_WIDTH = 0, NATIVE_WINDOW_HEIGHT = 1, NATIVE_WINDOW_FORMAT = 2, /* The minimum number of buffers that must remain un-dequeued after a buffer * has been queued. This value applies only if set_buffer_count was used to * override the number of buffers and if a buffer has since been queued. * Users of the set_buffer_count ANativeWindow method should query this * value before calling set_buffer_count. If it is necessary to have N * buffers simultaneously dequeued as part of the steady-state operation, * and this query returns M then N+M buffers should be requested via * native_window_set_buffer_count. * * Note that this value does NOT apply until a single buffer has been * queued. In particular this means that it is possible to: * * 1. Query M = min undequeued buffers * 2. Set the buffer count to N + M * 3. Dequeue all N + M buffers * 4. Cancel M buffers * 5. Queue, dequeue, queue, dequeue, ad infinitum */ NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, /* Check whether queueBuffer operations on the ANativeWindow send the buffer * to the window compositor. The query sets the returned 'value' argument * to 1 if the ANativeWindow DOES send queued buffers directly to the window * compositor and 0 if the buffers do not go directly to the window * compositor. * * This can be used to determine whether protected buffer content should be * sent to the ANativeWindow. Note, however, that a result of 1 does NOT * indicate that queued buffers will be protected from applications or users * capturing their contents. If that behavior is desired then some other * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in * conjunction with this query. */ NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, /* Get the concrete type of a ANativeWindow. See below for the list of * possible return values. * * This query should not be used outside the Android framework and will * likely be removed in the near future. */ NATIVE_WINDOW_CONCRETE_TYPE = 5, /* * Default width and height of ANativeWindow buffers, these are the * dimensions of the window buffers irrespective of the * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. */ NATIVE_WINDOW_DEFAULT_WIDTH = 6, NATIVE_WINDOW_DEFAULT_HEIGHT = 7, /* * transformation that will most-likely be applied to buffers. This is only * a hint, the actual transformation applied might be different. * * INTENDED USE: * * The transform hint can be used by a producer, for instance the GLES * driver, to pre-rotate the rendering such that the final transformation * in the composer is identity. This can be very useful when used in * conjunction with the h/w composer HAL, in situations where it * cannot handle arbitrary rotations. * * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. * * 2. The GL driver overrides the width and height of the ANW to * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions * according to NATIVE_WINDOW_TRANSFORM_HINT and calling * native_window_set_buffers_dimensions(). * * 3. The GL driver dequeues a buffer of the new pre-rotated size. * * 4. The GL driver renders to the buffer such that the image is * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT * to the rendering. * * 5. The GL driver calls native_window_set_transform to apply * inverse transformation to the buffer it just rendered. * In order to do this, the GL driver needs * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is * done easily: * * int hintTransform, inverseTransform; * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); * inverseTransform = hintTransform; * if (hintTransform & HAL_TRANSFORM_ROT_90) * inverseTransform ^= HAL_TRANSFORM_ROT_180; * * * 6. The GL driver queues the pre-transformed buffer. * * 7. The composer combines the buffer transform with the display * transform. If the buffer transform happens to cancel out the * display transform then no rotation is needed. * */ NATIVE_WINDOW_TRANSFORM_HINT = 8, /* * Boolean that indicates whether the consumer is running more than * one buffer behind the producer. */ NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, /* * The consumer gralloc usage bits currently set by the consumer. * The values are defined in hardware/libhardware/include/gralloc.h. */ NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, /** * Transformation that will by applied to buffers by the hwcomposer. * This must not be set or checked by producer endpoints, and will * disable the transform hint set in SurfaceFlinger (see * NATIVE_WINDOW_TRANSFORM_HINT). * * INTENDED USE: * Temporary - Please do not use this. This is intended only to be used * by the camera's LEGACY mode. * * In situations where a SurfaceFlinger client wishes to set a transform * that is not visible to the producer, and will always be applied in the * hardware composer, the client can set this flag with * native_window_set_buffers_sticky_transform. This can be used to rotate * and flip buffers consumed by hardware composer without actually changing * the aspect ratio of the buffers produced. */ NATIVE_WINDOW_STICKY_TRANSFORM = 11, /** * The default data space for the buffers as set by the consumer. * The values are defined in graphics.h. */ NATIVE_WINDOW_DEFAULT_DATASPACE = 12, /* * Returns the age of the contents of the most recently dequeued buffer as * the number of frames that have elapsed since it was last queued. For * example, if the window is double-buffered, the age of any given buffer in * steady state will be 2. If the dequeued buffer has never been queued, its * age will be 0. */ NATIVE_WINDOW_BUFFER_AGE = 13, }; /* Valid operations for the (*perform)() hook. * * Values marked as 'deprecated' are supported, but have been superceded by * other functionality. * * Values marked as 'private' should be considered private to the framework. * HAL implementation code with access to an ANativeWindow should not use these, * as it may not interact properly with the framework's use of the * ANativeWindow. */ enum { NATIVE_WINDOW_SET_USAGE = 0, NATIVE_WINDOW_CONNECT = 1, /* deprecated */ NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ NATIVE_WINDOW_SET_CROP = 3, /* private */ NATIVE_WINDOW_SET_BUFFER_COUNT = 4, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ NATIVE_WINDOW_LOCK = 11, /* private */ NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ NATIVE_WINDOW_API_CONNECT = 13, /* private */ NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ }; /* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ enum { /* Buffers will be queued by EGL via eglSwapBuffers after being filled using * OpenGL ES. */ NATIVE_WINDOW_API_EGL = 1, /* Buffers will be queued after being filled using the CPU */ NATIVE_WINDOW_API_CPU = 2, /* Buffers will be queued by Stagefright after being filled by a video * decoder. The video decoder can either be a software or hardware decoder. */ NATIVE_WINDOW_API_MEDIA = 3, /* Buffers will be queued by the the camera HAL. */ NATIVE_WINDOW_API_CAMERA = 4, }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ enum { /* flip source image horizontally */ NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , /* flip source image vertically */ NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, /* rotate source image 180 degrees */ NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, /* rotate source image 270 degrees clock-wise */ NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, /* transforms source by the inverse transform of the screen it is displayed onto. This * transform is applied last */ NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 }; /* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ enum { /* the window content is not updated (frozen) until a buffer of * the window size is received (enqueued) */ NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, /* the buffer is scaled in both dimensions to match the window size */ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, /* the buffer is scaled uniformly such that the smaller dimension * of the buffer matches the window size (cropping in the process) */ NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, /* the window is clipped to the size of the buffer's crop rectangle; pixels * outside the crop rectangle are treated as if they are completely * transparent. */ NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, }; /* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ enum { NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ NATIVE_WINDOW_SURFACE = 1, /* Surface */ }; /* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP * * Special timestamp value to indicate that timestamps should be auto-generated * by the native window when queueBuffer is called. This is equal to INT64_MIN, * defined directly to avoid problems with C99/C++ inclusion of stdint.h. */ static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); struct ANativeWindow { #ifdef __cplusplus ANativeWindow() : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) { common.magic = ANDROID_NATIVE_WINDOW_MAGIC; common.version = sizeof(ANativeWindow); memset(common.reserved, 0, sizeof(common.reserved)); } /* Implement the methods that sp expects so that it can be used to automatically refcount ANativeWindow's. */ void incStrong(const void* /*id*/) const { common.incRef(const_cast(&common)); } void decStrong(const void* /*id*/) const { common.decRef(const_cast(&common)); } #endif struct android_native_base_t common; /* flags describing some attributes of this surface or its updater */ const uint32_t flags; /* min swap interval supported by this updated */ const int minSwapInterval; /* max swap interval supported by this updated */ const int maxSwapInterval; /* horizontal and vertical resolution in DPI */ const float xdpi; const float ydpi; /* Some storage reserved for the OEM's driver. */ intptr_t oem[4]; /* * Set the swap interval for this surface. * * Returns 0 on success or -errno on error. */ int (*setSwapInterval)(struct ANativeWindow* window, int interval); /* * Hook called by EGL to acquire a buffer. After this call, the buffer * is not locked, so its content cannot be modified. This call may block if * no buffers are available. * * The window holds a reference to the buffer between dequeueBuffer and * either queueBuffer or cancelBuffer, so clients only need their own * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new dequeueBuffer function that * outputs a fence file descriptor should be used in its place. */ int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer); /* * hook called by EGL to lock a buffer. This MUST be called before modifying * the content of a buffer. The buffer must have been acquired with * dequeueBuffer first. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but it is essentially a no-op, and calls * to it should be removed. */ int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * Hook called by EGL when modifications to the render buffer are done. * This unlocks and post the buffer. * * The window holds a reference to the buffer between dequeueBuffer and * either queueBuffer or cancelBuffer, so clients only need their own * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. * * Buffers MUST be queued in the same order than they were dequeued. * * Returns 0 on success or -errno on error. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new queueBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * hook used to retrieve information about the native window. * * Returns 0 on success or -errno on error. */ int (*query)(const struct ANativeWindow* window, int what, int* value); /* * hook used to perform various operations on the surface. * (*perform)() is a generic mechanism to add functionality to * ANativeWindow while keeping backward binary compatibility. * * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions * defined below. * * (*perform)() returns -ENOENT if the 'what' parameter is not supported * by the surface's implementation. * * See above for a list of valid operations, such as * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT */ int (*perform)(struct ANativeWindow* window, int operation, ... ); /* * Hook used to cancel a buffer that has been dequeued. * No synchronization is performed between dequeue() and cancel(), so * either external synchronization is needed, or these functions must be * called from the same thread. * * The window holds a reference to the buffer between dequeueBuffer and * either queueBuffer or cancelBuffer, so clients only need their own * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. * * XXX: This function is deprecated. It will continue to work for some * time for binary compatibility, but the new cancelBuffer function that * takes a fence file descriptor should be used in its place (pass a value * of -1 for the fence file descriptor if there is no valid one to pass). */ int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer); /* * Hook called by EGL to acquire a buffer. This call may block if no * buffers are available. * * The window holds a reference to the buffer between dequeueBuffer and * either queueBuffer or cancelBuffer, so clients only need their own * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. * * The libsync fence file descriptor returned in the int pointed to by the * fenceFd argument will refer to the fence that must signal before the * dequeued buffer may be written to. A value of -1 indicates that the * caller may access the buffer immediately without waiting on a fence. If * a valid file descriptor is returned (i.e. any value except -1) then the * caller is responsible for closing the file descriptor. * * Returns 0 on success or -errno on error. */ int (*dequeueBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer** buffer, int* fenceFd); /* * Hook called by EGL when modifications to the render buffer are done. * This unlocks and post the buffer. * * The window holds a reference to the buffer between dequeueBuffer and * either queueBuffer or cancelBuffer, so clients only need their own * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. * * The fenceFd argument specifies a libsync fence file descriptor for a * fence that must signal before the buffer can be accessed. If the buffer * can be accessed immediately then a value of -1 should be used. The * caller must not use the file descriptor after it is passed to * queueBuffer, and the ANativeWindow implementation is responsible for * closing it. * * Returns 0 on success or -errno on error. */ int (*queueBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer, int fenceFd); /* * Hook used to cancel a buffer that has been dequeued. * No synchronization is performed between dequeue() and cancel(), so * either external synchronization is needed, or these functions must be * called from the same thread. * * The window holds a reference to the buffer between dequeueBuffer and * either queueBuffer or cancelBuffer, so clients only need their own * reference if they might use the buffer after queueing or canceling it. * Holding a reference to a buffer after queueing or canceling it is only * allowed if a specific buffer count has been set. * * The fenceFd argument specifies a libsync fence file decsriptor for a * fence that must signal before the buffer can be accessed. If the buffer * can be accessed immediately then a value of -1 should be used. * * Note that if the client has not waited on the fence that was returned * from dequeueBuffer, that same fence should be passed to cancelBuffer to * ensure that future uses of the buffer are preceded by a wait on that * fence. The caller must not use the file descriptor after it is passed * to cancelBuffer, and the ANativeWindow implementation is responsible for * closing it. * * Returns 0 on success or -errno on error. */ int (*cancelBuffer)(struct ANativeWindow* window, struct ANativeWindowBuffer* buffer, int fenceFd); }; /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). * android_native_window_t is deprecated. */ typedef struct ANativeWindow ANativeWindow; typedef struct ANativeWindow android_native_window_t __deprecated; /* * native_window_set_usage(..., usage) * Sets the intended usage flags for the next buffers * acquired with (*lockBuffer)() and on. * By default (if this function is never called), a usage of * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE * is assumed. * Calling this function will usually cause following buffers to be * reallocated. */ static inline int native_window_set_usage( struct ANativeWindow* window, int usage) { return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_connect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* deprecated. Always returns 0. Don't call. */ static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; static inline int native_window_disconnect( struct ANativeWindow* window __UNUSED, int api __UNUSED) { return 0; } /* * native_window_set_crop(..., crop) * Sets which region of the next queued buffers needs to be considered. * Depending on the scaling mode, a buffer's crop region is scaled and/or * cropped to match the surface's size. This function sets the crop in * pre-transformed buffer pixel coordinates. * * The specified crop region applies to all buffers queued after it is called. * * If 'crop' is NULL, subsequently queued buffers won't be cropped. * * An error is returned if for instance the crop region is invalid, out of the * buffer's bound or if the window is invalid. */ static inline int native_window_set_crop( struct ANativeWindow* window, android_native_rect_t const * crop) { return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); } /* * native_window_set_post_transform_crop(..., crop) * Sets which region of the next queued buffers needs to be considered. * Depending on the scaling mode, a buffer's crop region is scaled and/or * cropped to match the surface's size. This function sets the crop in * post-transformed pixel coordinates. * * The specified crop region applies to all buffers queued after it is called. * * If 'crop' is NULL, subsequently queued buffers won't be cropped. * * An error is returned if for instance the crop region is invalid, out of the * buffer's bound or if the window is invalid. */ static inline int native_window_set_post_transform_crop( struct ANativeWindow* window, android_native_rect_t const * crop) { return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); } /* * native_window_set_active_rect(..., active_rect) * * This function is deprecated and will be removed soon. For now it simply * sets the post-transform crop for compatibility while multi-project commits * get checked. */ static inline int native_window_set_active_rect( struct ANativeWindow* window, android_native_rect_t const * active_rect) __deprecated; static inline int native_window_set_active_rect( struct ANativeWindow* window, android_native_rect_t const * active_rect) { return native_window_set_post_transform_crop(window, active_rect); } /* * native_window_set_buffer_count(..., count) * Sets the number of buffers associated with this native window. */ static inline int native_window_set_buffer_count( struct ANativeWindow* window, size_t bufferCount) { return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); } /* * native_window_set_buffers_geometry(..., int w, int h, int format) * All buffers dequeued after this call will have the dimensions and format * specified. A successful call to this function has the same effect as calling * native_window_set_buffers_size and native_window_set_buffers_format. * * XXX: This function is deprecated. The native_window_set_buffers_dimensions * and native_window_set_buffers_format functions should be used instead. */ static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) __deprecated; static inline int native_window_set_buffers_geometry( struct ANativeWindow* window, int w, int h, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, w, h, format); } /* * native_window_set_buffers_dimensions(..., int w, int h) * All buffers dequeued after this call will have the dimensions specified. * In particular, all buffers will have a fixed-size, independent from the * native-window size. They will be scaled according to the scaling mode * (see native_window_set_scaling_mode) upon window composition. * * If w and h are 0, the normal behavior is restored. That is, dequeued buffers * following this call will be sized to match the window's size. * * Calling this function will reset the window crop to a NULL value, which * disables cropping of the buffers. */ static inline int native_window_set_buffers_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, w, h); } /* * native_window_set_buffers_user_dimensions(..., int w, int h) * * Sets the user buffer size for the window, which overrides the * window's size. All buffers dequeued after this call will have the * dimensions specified unless overridden by * native_window_set_buffers_dimensions. All buffers will have a * fixed-size, independent from the native-window size. They will be * scaled according to the scaling mode (see * native_window_set_scaling_mode) upon window composition. * * If w and h are 0, the normal behavior is restored. That is, the * default buffer size will match the windows's size. * * Calling this function will reset the window crop to a NULL value, which * disables cropping of the buffers. */ static inline int native_window_set_buffers_user_dimensions( struct ANativeWindow* window, int w, int h) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, w, h); } /* * native_window_set_buffers_format(..., int format) * All buffers dequeued after this call will have the format specified. * * If the specified format is 0, the default buffer format will be used. */ static inline int native_window_set_buffers_format( struct ANativeWindow* window, int format) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); } /* * native_window_set_buffers_data_space(..., int dataSpace) * All buffers queued after this call will be associated with the dataSpace * parameter specified. * * dataSpace specifies additional information about the buffer that's dependent * on the buffer format and the endpoints. For example, it can be used to convey * the color space of the image data in the buffer, or it can be used to * indicate that the buffers contain depth measurement data instead of color * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been * overridden by the consumer. */ static inline int native_window_set_buffers_data_space( struct ANativeWindow* window, android_dataspace_t dataSpace) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, dataSpace); } /* * native_window_set_buffers_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified. */ static inline int native_window_set_buffers_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, transform); } /* * native_window_set_buffers_sticky_transform(..., int transform) * All buffers queued after this call will be displayed transformed according * to the transform parameter specified applied on top of the regular buffer * transform. Setting this transform will disable the transform hint. * * Temporary - This is only intended to be used by the LEGACY camera mode, do * not use this for anything else. */ static inline int native_window_set_buffers_sticky_transform( struct ANativeWindow* window, int transform) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, transform); } /* * native_window_set_buffers_timestamp(..., int64_t timestamp) * All buffers queued after this call will be associated with the timestamp * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO * (the default), timestamps will be generated automatically when queueBuffer is * called. The timestamp is measured in nanoseconds, and is normally monotonically * increasing. The timestamp should be unaffected by time-of-day adjustments, * and for a camera should be strictly monotonic but for a media player may be * reset when the position is set. */ static inline int native_window_set_buffers_timestamp( struct ANativeWindow* window, int64_t timestamp) { return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, timestamp); } /* * native_window_set_scaling_mode(..., int mode) * All buffers queued after this call will be associated with the scaling mode * specified. */ static inline int native_window_set_scaling_mode( struct ANativeWindow* window, int mode) { return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, mode); } /* * native_window_api_connect(..., int api) * connects an API to this window. only one API can be connected at a time. * Returns -EINVAL if for some reason the window cannot be connected, which * can happen if it's connected to some other API. */ static inline int native_window_api_connect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); } /* * native_window_api_disconnect(..., int api) * disconnect the API from this window. * An error is returned if for instance the window wasn't connected in the * first place. */ static inline int native_window_api_disconnect( struct ANativeWindow* window, int api) { return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); } /* * native_window_dequeue_buffer_and_wait(...) * Dequeue a buffer and wait on the fence associated with that buffer. The * buffer may safely be accessed immediately upon this function returning. An * error is returned if either of the dequeue or the wait operations fail. */ static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, struct ANativeWindowBuffer** anb) { return anw->dequeueBuffer_DEPRECATED(anw, anb); } /* * native_window_set_sideband_stream(..., native_handle_t*) * Attach a sideband buffer stream to a native window. */ static inline int native_window_set_sideband_stream( struct ANativeWindow* window, native_handle_t* sidebandHandle) { return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, sidebandHandle); } /* * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) * Set the surface damage (i.e., the region of the surface that has changed * since the previous frame). The damage set by this call will be reset (to the * default of full-surface damage) after calling queue, so this must be called * prior to every frame with damage that does not cover the whole surface if the * caller desires downstream consumers to use this optimization. * * The damage region is specified as an array of rectangles, with the important * caveat that the origin of the surface is considered to be the bottom-left * corner, as in OpenGL ES. * * If numRects is set to 0, rects may be NULL, and the surface damage will be * set to the full surface (the same as if this function had not been called for * this frame). */ static inline int native_window_set_surface_damage( struct ANativeWindow* window, const android_native_rect_t* rects, size_t numRects) { return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, rects, numRects); } __END_DECLS #endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ ================================================ FILE: phonelibs/android_system_core/include/utils/AndroidThreads.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_ANDROID_THREADS_H #define _LIBS_UTILS_ANDROID_THREADS_H #include #include #if !defined(_WIN32) # include #endif #include // --------------------------------------------------------------------------- // C API #ifdef __cplusplus extern "C" { #endif // Create and run a new thread. extern int androidCreateThread(android_thread_func_t, void *); // Create thread with lots of parameters extern int androidCreateThreadEtc(android_thread_func_t entryFunction, void *userData, const char* threadName, int32_t threadPriority, size_t threadStackSize, android_thread_id_t *threadId); // Get some sort of unique identifier for the current thread. extern android_thread_id_t androidGetThreadId(); // Low-level thread creation -- never creates threads that can // interact with the Java VM. extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction, void *userData, const char* threadName, int32_t threadPriority, size_t threadStackSize, android_thread_id_t *threadId); // set the same of the running thread extern void androidSetThreadName(const char* name); // Used by the Java Runtime to control how threads are created, so that // they can be proper and lovely Java threads. typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction, void *userData, const char* threadName, int32_t threadPriority, size_t threadStackSize, android_thread_id_t *threadId); extern void androidSetCreateThreadFunc(android_create_thread_fn func); // ------------------------------------------------------------------ // Extra functions working with raw pids. #ifdef HAVE_ANDROID_OS // Change the priority AND scheduling group of a particular thread. The priority // should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION // if the priority set failed, else another value if just the group set failed; // in either case errno is set. Thread ID zero means current thread. extern int androidSetThreadPriority(pid_t tid, int prio); // Get the current priority of a particular thread. Returns one of the // ANDROID_PRIORITY constants or a negative result in case of error. extern int androidGetThreadPriority(pid_t tid); #endif #ifdef __cplusplus } // extern "C" #endif // ---------------------------------------------------------------------------- // C++ API #ifdef __cplusplus namespace android { // ---------------------------------------------------------------------------- // Create and run a new thread. inline bool createThread(thread_func_t f, void *a) { return androidCreateThread(f, a) ? true : false; } // Create thread with lots of parameters inline bool createThreadEtc(thread_func_t entryFunction, void *userData, const char* threadName = "android:unnamed_thread", int32_t threadPriority = PRIORITY_DEFAULT, size_t threadStackSize = 0, thread_id_t *threadId = 0) { return androidCreateThreadEtc(entryFunction, userData, threadName, threadPriority, threadStackSize, threadId) ? true : false; } // Get some sort of unique identifier for the current thread. inline thread_id_t getThreadId() { return androidGetThreadId(); } // ---------------------------------------------------------------------------- }; // namespace android #endif // __cplusplus // ---------------------------------------------------------------------------- #endif // _LIBS_UTILS_ANDROID_THREADS_H ================================================ FILE: phonelibs/android_system_core/include/utils/Atomic.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UTILS_ATOMIC_H #define ANDROID_UTILS_ATOMIC_H #include #endif // ANDROID_UTILS_ATOMIC_H ================================================ FILE: phonelibs/android_system_core/include/utils/BasicHashtable.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_BASIC_HASHTABLE_H #define ANDROID_BASIC_HASHTABLE_H #include #include #include #include namespace android { /* Implementation type. Nothing to see here. */ class BasicHashtableImpl { protected: struct Bucket { // The collision flag indicates that the bucket is part of a collision chain // such that at least two entries both hash to this bucket. When true, we // may need to seek further along the chain to find the entry. static const uint32_t COLLISION = 0x80000000UL; // The present flag indicates that the bucket contains an initialized entry value. static const uint32_t PRESENT = 0x40000000UL; // Mask for 30 bits worth of the hash code that are stored within the bucket to // speed up lookups and rehashing by eliminating the need to recalculate the // hash code of the entry's key. static const uint32_t HASH_MASK = 0x3fffffffUL; // Combined value that stores the collision and present flags as well as // a 30 bit hash code. uint32_t cookie; // Storage for the entry begins here. char entry[0]; }; BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor, size_t minimumInitialCapacity, float loadFactor); BasicHashtableImpl(const BasicHashtableImpl& other); virtual ~BasicHashtableImpl(); void dispose(); inline void edit() { if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) { clone(); } } void setTo(const BasicHashtableImpl& other); void clear(); ssize_t next(ssize_t index) const; ssize_t find(ssize_t index, hash_t hash, const void* __restrict__ key) const; size_t add(hash_t hash, const void* __restrict__ entry); void removeAt(size_t index); void rehash(size_t minimumCapacity, float loadFactor); const size_t mBucketSize; // number of bytes per bucket including the entry const bool mHasTrivialDestructor; // true if the entry type does not require destruction size_t mCapacity; // number of buckets that can be filled before exceeding load factor float mLoadFactor; // load factor size_t mSize; // number of elements actually in the table size_t mFilledBuckets; // number of buckets for which collision or present is true size_t mBucketCount; // number of slots in the mBuckets array void* mBuckets; // array of buckets, as a SharedBuffer inline const Bucket& bucketAt(const void* __restrict__ buckets, size_t index) const { return *reinterpret_cast( static_cast(buckets) + index * mBucketSize); } inline Bucket& bucketAt(void* __restrict__ buckets, size_t index) const { return *reinterpret_cast(static_cast(buckets) + index * mBucketSize); } virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const = 0; virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const = 0; virtual void destroyBucketEntry(Bucket& bucket) const = 0; private: void clone(); // Allocates a bucket array as a SharedBuffer. void* allocateBuckets(size_t count) const; // Releases a bucket array's associated SharedBuffer. void releaseBuckets(void* __restrict__ buckets, size_t count) const; // Destroys the contents of buckets (invokes destroyBucketEntry for each // populated bucket if needed). void destroyBuckets(void* __restrict__ buckets, size_t count) const; // Copies the content of buckets (copies the cookie and invokes copyBucketEntry // for each populated bucket if needed). void copyBuckets(const void* __restrict__ fromBuckets, void* __restrict__ toBuckets, size_t count) const; // Determines the appropriate size of a bucket array to store a certain minimum // number of entries and returns its effective capacity. static void determineCapacity(size_t minimumCapacity, float loadFactor, size_t* __restrict__ outBucketCount, size_t* __restrict__ outCapacity); // Trim a hash code to 30 bits to match what we store in the bucket's cookie. inline static hash_t trimHash(hash_t hash) { return (hash & Bucket::HASH_MASK) ^ (hash >> 30); } // Returns the index of the first bucket that is in the collision chain // for the specified hash code, given the total number of buckets. // (Primary hash) inline static size_t chainStart(hash_t hash, size_t count) { return hash % count; } // Returns the increment to add to a bucket index to seek to the next bucket // in the collision chain for the specified hash code, given the total number of buckets. // (Secondary hash) inline static size_t chainIncrement(hash_t hash, size_t count) { return ((hash >> 7) | (hash << 25)) % (count - 1) + 1; } // Returns the index of the next bucket that is in the collision chain // that is defined by the specified increment, given the total number of buckets. inline static size_t chainSeek(size_t index, size_t increment, size_t count) { return (index + increment) % count; } }; /* * A BasicHashtable stores entries that are indexed by hash code in place * within an array. The basic operations are finding entries by key, * adding new entries and removing existing entries. * * This class provides a very limited set of operations with simple semantics. * It is intended to be used as a building block to construct more complex * and interesting data structures such as HashMap. Think very hard before * adding anything extra to BasicHashtable, it probably belongs at a * higher level of abstraction. * * TKey: The key type. * TEntry: The entry type which is what is actually stored in the array. * * TKey must support the following contract: * bool operator==(const TKey& other) const; // return true if equal * bool operator!=(const TKey& other) const; // return true if unequal * * TEntry must support the following contract: * const TKey& getKey() const; // get the key from the entry * * This class supports storing entries with duplicate keys. Of course, it can't * tell them apart during removal so only the first entry will be removed. * We do this because it means that operations like add() can't fail. */ template class BasicHashtable : private BasicHashtableImpl { public: /* Creates a hashtable with the specified minimum initial capacity. * The underlying array will be created when the first entry is added. * * minimumInitialCapacity: The minimum initial capacity for the hashtable. * Default is 0. * loadFactor: The desired load factor for the hashtable, between 0 and 1. * Default is 0.75. */ BasicHashtable(size_t minimumInitialCapacity = 0, float loadFactor = 0.75f); /* Copies a hashtable. * The underlying storage is shared copy-on-write. */ BasicHashtable(const BasicHashtable& other); /* Clears and destroys the hashtable. */ virtual ~BasicHashtable(); /* Making this hashtable a copy of the other hashtable. * The underlying storage is shared copy-on-write. * * other: The hashtable to copy. */ inline BasicHashtable& operator =(const BasicHashtable & other) { setTo(other); return *this; } /* Returns the number of entries in the hashtable. */ inline size_t size() const { return mSize; } /* Returns the capacity of the hashtable, which is the number of elements that can * added to the hashtable without requiring it to be grown. */ inline size_t capacity() const { return mCapacity; } /* Returns the number of buckets that the hashtable has, which is the size of its * underlying array. */ inline size_t bucketCount() const { return mBucketCount; } /* Returns the load factor of the hashtable. */ inline float loadFactor() const { return mLoadFactor; }; /* Returns a const reference to the entry at the specified index. * * index: The index of the entry to retrieve. Must be a valid index within * the bounds of the hashtable. */ inline const TEntry& entryAt(size_t index) const { return entryFor(bucketAt(mBuckets, index)); } /* Returns a non-const reference to the entry at the specified index. * * index: The index of the entry to edit. Must be a valid index within * the bounds of the hashtable. */ inline TEntry& editEntryAt(size_t index) { edit(); return entryFor(bucketAt(mBuckets, index)); } /* Clears the hashtable. * All entries in the hashtable are destroyed immediately. * If you need to do something special with the entries in the hashtable then iterate * over them and do what you need before clearing the hashtable. */ inline void clear() { BasicHashtableImpl::clear(); } /* Returns the index of the next entry in the hashtable given the index of a previous entry. * If the given index is -1, then returns the index of the first entry in the hashtable, * if there is one, or -1 otherwise. * If the given index is not -1, then returns the index of the next entry in the hashtable, * in strictly increasing order, or -1 if there are none left. * * index: The index of the previous entry that was iterated, or -1 to begin * iteration at the beginning of the hashtable. */ inline ssize_t next(ssize_t index) const { return BasicHashtableImpl::next(index); } /* Finds the index of an entry with the specified key. * If the given index is -1, then returns the index of the first matching entry, * otherwise returns the index of the next matching entry. * If the hashtable contains multiple entries with keys that match the requested * key, then the sequence of entries returned is arbitrary. * Returns -1 if no entry was found. * * index: The index of the previous entry with the specified key, or -1 to * find the first matching entry. * hash: The hashcode of the key. * key: The key. */ inline ssize_t find(ssize_t index, hash_t hash, const TKey& key) const { return BasicHashtableImpl::find(index, hash, &key); } /* Adds the entry to the hashtable. * Returns the index of the newly added entry. * If an entry with the same key already exists, then a duplicate entry is added. * If the entry will not fit, then the hashtable's capacity is increased and * its contents are rehashed. See rehash(). * * hash: The hashcode of the key. * entry: The entry to add. */ inline size_t add(hash_t hash, const TEntry& entry) { return BasicHashtableImpl::add(hash, &entry); } /* Removes the entry with the specified index from the hashtable. * The entry is destroyed immediately. * The index must be valid. * * The hashtable is not compacted after an item is removed, so it is legal * to continue iterating over the hashtable using next() or find(). * * index: The index of the entry to remove. Must be a valid index within the * bounds of the hashtable, and it must refer to an existing entry. */ inline void removeAt(size_t index) { BasicHashtableImpl::removeAt(index); } /* Rehashes the contents of the hashtable. * Grows the hashtable to at least the specified minimum capacity or the * current number of elements, whichever is larger. * * Rehashing causes all entries to be copied and the entry indices may change. * Although the hash codes are cached by the hashtable, rehashing can be an * expensive operation and should be avoided unless the hashtable's size * needs to be changed. * * Rehashing is the only way to change the capacity or load factor of the * hashtable once it has been created. It can be used to compact the * hashtable by choosing a minimum capacity that is smaller than the current * capacity (such as 0). * * minimumCapacity: The desired minimum capacity after rehashing. * loadFactor: The desired load factor after rehashing. */ inline void rehash(size_t minimumCapacity, float loadFactor) { BasicHashtableImpl::rehash(minimumCapacity, loadFactor); } /* Determines whether there is room to add another entry without rehashing. * When this returns true, a subsequent add() operation is guaranteed to * complete without performing a rehash. */ inline bool hasMoreRoom() const { return mCapacity > mFilledBuckets; } protected: static inline const TEntry& entryFor(const Bucket& bucket) { return reinterpret_cast(bucket.entry); } static inline TEntry& entryFor(Bucket& bucket) { return reinterpret_cast(bucket.entry); } virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const; virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const; virtual void destroyBucketEntry(Bucket& bucket) const; private: // For dumping the raw contents of a hashtable during testing. friend class BasicHashtableTest; inline uint32_t cookieAt(size_t index) const { return bucketAt(mBuckets, index).cookie; } }; template BasicHashtable::BasicHashtable(size_t minimumInitialCapacity, float loadFactor) : BasicHashtableImpl(sizeof(TEntry), traits::has_trivial_dtor, minimumInitialCapacity, loadFactor) { } template BasicHashtable::BasicHashtable(const BasicHashtable& other) : BasicHashtableImpl(other) { } template BasicHashtable::~BasicHashtable() { dispose(); } template bool BasicHashtable::compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const { return entryFor(bucket).getKey() == *static_cast(key); } template void BasicHashtable::initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const { if (!traits::has_trivial_copy) { new (&entryFor(bucket)) TEntry(*(static_cast(entry))); } else { memcpy(&entryFor(bucket), entry, sizeof(TEntry)); } } template void BasicHashtable::destroyBucketEntry(Bucket& bucket) const { if (!traits::has_trivial_dtor) { entryFor(bucket).~TEntry(); } } }; // namespace android #endif // ANDROID_BASIC_HASHTABLE_H ================================================ FILE: phonelibs/android_system_core/include/utils/BitSet.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef UTILS_BITSET_H #define UTILS_BITSET_H #include #include /* * Contains some bit manipulation helpers. */ namespace android { // A simple set of 32 bits that can be individually marked or cleared. struct BitSet32 { uint32_t value; inline BitSet32() : value(0UL) { } explicit inline BitSet32(uint32_t value) : value(value) { } // Gets the value associated with a particular bit index. static inline uint32_t valueForBit(uint32_t n) { return 0x80000000UL >> n; } // Clears the bit set. inline void clear() { clear(value); } static inline void clear(uint32_t& value) { value = 0UL; } // Returns the number of marked bits in the set. inline uint32_t count() const { return count(value); } static inline uint32_t count(uint32_t value) { return __builtin_popcountl(value); } // Returns true if the bit set does not contain any marked bits. inline bool isEmpty() const { return isEmpty(value); } static inline bool isEmpty(uint32_t value) { return ! value; } // Returns true if the bit set does not contain any unmarked bits. inline bool isFull() const { return isFull(value); } static inline bool isFull(uint32_t value) { return value == 0xffffffffUL; } // Returns true if the specified bit is marked. inline bool hasBit(uint32_t n) const { return hasBit(value, n); } static inline bool hasBit(uint32_t value, uint32_t n) { return value & valueForBit(n); } // Marks the specified bit. inline void markBit(uint32_t n) { markBit(value, n); } static inline void markBit (uint32_t& value, uint32_t n) { value |= valueForBit(n); } // Clears the specified bit. inline void clearBit(uint32_t n) { clearBit(value, n); } static inline void clearBit(uint32_t& value, uint32_t n) { value &= ~ valueForBit(n); } // Finds the first marked bit in the set. // Result is undefined if all bits are unmarked. inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } static uint32_t firstMarkedBit(uint32_t value) { return clz_checked(value); } // Finds the first unmarked bit in the set. // Result is undefined if all bits are marked. inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } static inline uint32_t firstUnmarkedBit(uint32_t value) { return clz_checked(~ value); } // Finds the last marked bit in the set. // Result is undefined if all bits are unmarked. inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } static inline uint32_t lastMarkedBit(uint32_t value) { return 31 - ctz_checked(value); } // Finds the first marked bit in the set and clears it. Returns the bit index. // Result is undefined if all bits are unmarked. inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } static inline uint32_t clearFirstMarkedBit(uint32_t& value) { uint32_t n = firstMarkedBit(value); clearBit(value, n); return n; } // Finds the first unmarked bit in the set and marks it. Returns the bit index. // Result is undefined if all bits are marked. inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } static inline uint32_t markFirstUnmarkedBit(uint32_t& value) { uint32_t n = firstUnmarkedBit(value); markBit(value, n); return n; } // Finds the last marked bit in the set and clears it. Returns the bit index. // Result is undefined if all bits are unmarked. inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } static inline uint32_t clearLastMarkedBit(uint32_t& value) { uint32_t n = lastMarkedBit(value); clearBit(value, n); return n; } // Gets the index of the specified bit in the set, which is the number of // marked bits that appear before the specified bit. inline uint32_t getIndexOfBit(uint32_t n) const { return getIndexOfBit(value, n); } static inline uint32_t getIndexOfBit(uint32_t value, uint32_t n) { return __builtin_popcountl(value & ~(0xffffffffUL >> n)); } inline bool operator== (const BitSet32& other) const { return value == other.value; } inline bool operator!= (const BitSet32& other) const { return value != other.value; } inline BitSet32 operator& (const BitSet32& other) const { return BitSet32(value & other.value); } inline BitSet32& operator&= (const BitSet32& other) { value &= other.value; return *this; } inline BitSet32 operator| (const BitSet32& other) const { return BitSet32(value | other.value); } inline BitSet32& operator|= (const BitSet32& other) { value |= other.value; return *this; } private: // We use these helpers as the signature of __builtin_c{l,t}z has "unsigned int" for the // input, which is only guaranteed to be 16b, not 32. The compiler should optimize this away. static inline uint32_t clz_checked(uint32_t value) { if (sizeof(unsigned int) == sizeof(uint32_t)) { return __builtin_clz(value); } else { return __builtin_clzl(value); } } static inline uint32_t ctz_checked(uint32_t value) { if (sizeof(unsigned int) == sizeof(uint32_t)) { return __builtin_ctz(value); } else { return __builtin_ctzl(value); } } }; ANDROID_BASIC_TYPES_TRAITS(BitSet32) // A simple set of 64 bits that can be individually marked or cleared. struct BitSet64 { uint64_t value; inline BitSet64() : value(0ULL) { } explicit inline BitSet64(uint64_t value) : value(value) { } // Gets the value associated with a particular bit index. static inline uint64_t valueForBit(uint32_t n) { return 0x8000000000000000ULL >> n; } // Clears the bit set. inline void clear() { clear(value); } static inline void clear(uint64_t& value) { value = 0ULL; } // Returns the number of marked bits in the set. inline uint32_t count() const { return count(value); } static inline uint32_t count(uint64_t value) { return __builtin_popcountll(value); } // Returns true if the bit set does not contain any marked bits. inline bool isEmpty() const { return isEmpty(value); } static inline bool isEmpty(uint64_t value) { return ! value; } // Returns true if the bit set does not contain any unmarked bits. inline bool isFull() const { return isFull(value); } static inline bool isFull(uint64_t value) { return value == 0xffffffffffffffffULL; } // Returns true if the specified bit is marked. inline bool hasBit(uint32_t n) const { return hasBit(value, n); } static inline bool hasBit(uint64_t value, uint32_t n) { return value & valueForBit(n); } // Marks the specified bit. inline void markBit(uint32_t n) { markBit(value, n); } static inline void markBit(uint64_t& value, uint32_t n) { value |= valueForBit(n); } // Clears the specified bit. inline void clearBit(uint32_t n) { clearBit(value, n); } static inline void clearBit(uint64_t& value, uint32_t n) { value &= ~ valueForBit(n); } // Finds the first marked bit in the set. // Result is undefined if all bits are unmarked. inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } static inline uint32_t firstMarkedBit(uint64_t value) { return __builtin_clzll(value); } // Finds the first unmarked bit in the set. // Result is undefined if all bits are marked. inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } static inline uint32_t firstUnmarkedBit(uint64_t value) { return __builtin_clzll(~ value); } // Finds the last marked bit in the set. // Result is undefined if all bits are unmarked. inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } static inline uint32_t lastMarkedBit(uint64_t value) { return 63 - __builtin_ctzll(value); } // Finds the first marked bit in the set and clears it. Returns the bit index. // Result is undefined if all bits are unmarked. inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } static inline uint32_t clearFirstMarkedBit(uint64_t& value) { uint64_t n = firstMarkedBit(value); clearBit(value, n); return n; } // Finds the first unmarked bit in the set and marks it. Returns the bit index. // Result is undefined if all bits are marked. inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } static inline uint32_t markFirstUnmarkedBit(uint64_t& value) { uint64_t n = firstUnmarkedBit(value); markBit(value, n); return n; } // Finds the last marked bit in the set and clears it. Returns the bit index. // Result is undefined if all bits are unmarked. inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } static inline uint32_t clearLastMarkedBit(uint64_t& value) { uint64_t n = lastMarkedBit(value); clearBit(value, n); return n; } // Gets the index of the specified bit in the set, which is the number of // marked bits that appear before the specified bit. inline uint32_t getIndexOfBit(uint32_t n) const { return getIndexOfBit(value, n); } static inline uint32_t getIndexOfBit(uint64_t value, uint32_t n) { return __builtin_popcountll(value & ~(0xffffffffffffffffULL >> n)); } inline bool operator== (const BitSet64& other) const { return value == other.value; } inline bool operator!= (const BitSet64& other) const { return value != other.value; } inline BitSet64 operator& (const BitSet64& other) const { return BitSet64(value & other.value); } inline BitSet64& operator&= (const BitSet64& other) { value &= other.value; return *this; } inline BitSet64 operator| (const BitSet64& other) const { return BitSet64(value | other.value); } inline BitSet64& operator|= (const BitSet64& other) { value |= other.value; return *this; } }; ANDROID_BASIC_TYPES_TRAITS(BitSet64) } // namespace android #endif // UTILS_BITSET_H ================================================ FILE: phonelibs/android_system_core/include/utils/BlobCache.h ================================================ /* ** Copyright 2011, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ #ifndef ANDROID_BLOB_CACHE_H #define ANDROID_BLOB_CACHE_H #include #include #include #include #include namespace android { // A BlobCache is an in-memory cache for binary key/value pairs. A BlobCache // does NOT provide any thread-safety guarantees. // // The cache contents can be serialized to an in-memory buffer or mmap'd file // and then reloaded in a subsequent execution of the program. This // serialization is non-portable and the data should only be used by the device // that generated it. class BlobCache : public RefBase { public: // Create an empty blob cache. The blob cache will cache key/value pairs // with key and value sizes less than or equal to maxKeySize and // maxValueSize, respectively. The total combined size of ALL cache entries // (key sizes plus value sizes) will not exceed maxTotalSize. BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize); // set inserts a new binary value into the cache and associates it with the // given binary key. If the key or value are too large for the cache then // the cache remains unchanged. This includes the case where a different // value was previously associated with the given key - the old value will // remain in the cache. If the given key and value are small enough to be // put in the cache (based on the maxKeySize, maxValueSize, and maxTotalSize // values specified to the BlobCache constructor), then the key/value pair // will be in the cache after set returns. Note, however, that a subsequent // call to set may evict old key/value pairs from the cache. // // Preconditions: // key != NULL // 0 < keySize // value != NULL // 0 < valueSize void set(const void* key, size_t keySize, const void* value, size_t valueSize); // get retrieves from the cache the binary value associated with a given // binary key. If the key is present in the cache then the length of the // binary value associated with that key is returned. If the value argument // is non-NULL and the size of the cached value is less than valueSize bytes // then the cached value is copied into the buffer pointed to by the value // argument. If the key is not present in the cache then 0 is returned and // the buffer pointed to by the value argument is not modified. // // Note that when calling get multiple times with the same key, the later // calls may fail, returning 0, even if earlier calls succeeded. The return // value must be checked for each call. // // Preconditions: // key != NULL // 0 < keySize // 0 <= valueSize size_t get(const void* key, size_t keySize, void* value, size_t valueSize); // getFlattenedSize returns the number of bytes needed to store the entire // serialized cache. size_t getFlattenedSize() const; // flatten serializes the current contents of the cache into the memory // pointed to by 'buffer'. The serialized cache contents can later be // loaded into a BlobCache object using the unflatten method. The contents // of the BlobCache object will not be modified. // // Preconditions: // size >= this.getFlattenedSize() status_t flatten(void* buffer, size_t size) const; // unflatten replaces the contents of the cache with the serialized cache // contents in the memory pointed to by 'buffer'. The previous contents of // the BlobCache will be evicted from the cache. If an error occurs while // unflattening the serialized cache contents then the BlobCache will be // left in an empty state. // status_t unflatten(void const* buffer, size_t size); private: // Copying is disallowed. BlobCache(const BlobCache&); void operator=(const BlobCache&); // A random function helper to get around MinGW not having nrand48() long int blob_random(); // clean evicts a randomly chosen set of entries from the cache such that // the total size of all remaining entries is less than mMaxTotalSize/2. void clean(); // isCleanable returns true if the cache is full enough for the clean method // to have some effect, and false otherwise. bool isCleanable() const; // A Blob is an immutable sized unstructured data blob. class Blob : public RefBase { public: Blob(const void* data, size_t size, bool copyData); ~Blob(); bool operator<(const Blob& rhs) const; const void* getData() const; size_t getSize() const; private: // Copying is not allowed. Blob(const Blob&); void operator=(const Blob&); // mData points to the buffer containing the blob data. const void* mData; // mSize is the size of the blob data in bytes. size_t mSize; // mOwnsData indicates whether or not this Blob object should free the // memory pointed to by mData when the Blob gets destructed. bool mOwnsData; }; // A CacheEntry is a single key/value pair in the cache. class CacheEntry { public: CacheEntry(); CacheEntry(const sp& key, const sp& value); CacheEntry(const CacheEntry& ce); bool operator<(const CacheEntry& rhs) const; const CacheEntry& operator=(const CacheEntry&); sp getKey() const; sp getValue() const; void setValue(const sp& value); private: // mKey is the key that identifies the cache entry. sp mKey; // mValue is the cached data associated with the key. sp mValue; }; // A Header is the header for the entire BlobCache serialization format. No // need to make this portable, so we simply write the struct out. struct Header { // mMagicNumber is the magic number that identifies the data as // serialized BlobCache contents. It must always contain 'Blb$'. uint32_t mMagicNumber; // mBlobCacheVersion is the serialization format version. uint32_t mBlobCacheVersion; // mDeviceVersion is the device-specific version of the cache. This can // be used to invalidate the cache. uint32_t mDeviceVersion; // mNumEntries is number of cache entries following the header in the // data. size_t mNumEntries; // mBuildId is the build id of the device when the cache was created. // When an update to the build happens (via an OTA or other update) this // is used to invalidate the cache. int mBuildIdLength; char mBuildId[]; }; // An EntryHeader is the header for a serialized cache entry. No need to // make this portable, so we simply write the struct out. Each EntryHeader // is followed imediately by the key data and then the value data. // // The beginning of each serialized EntryHeader is 4-byte aligned, so the // number of bytes that a serialized cache entry will occupy is: // // ((sizeof(EntryHeader) + keySize + valueSize) + 3) & ~3 // struct EntryHeader { // mKeySize is the size of the entry key in bytes. size_t mKeySize; // mValueSize is the size of the entry value in bytes. size_t mValueSize; // mData contains both the key and value data for the cache entry. The // key comes first followed immediately by the value. uint8_t mData[]; }; // mMaxKeySize is the maximum key size that will be cached. Calls to // BlobCache::set with a keySize parameter larger than mMaxKeySize will // simply not add the key/value pair to the cache. const size_t mMaxKeySize; // mMaxValueSize is the maximum value size that will be cached. Calls to // BlobCache::set with a valueSize parameter larger than mMaxValueSize will // simply not add the key/value pair to the cache. const size_t mMaxValueSize; // mMaxTotalSize is the maximum size that all cache entries can occupy. This // includes space for both keys and values. When a call to BlobCache::set // would otherwise cause this limit to be exceeded, either the key/value // pair passed to BlobCache::set will not be cached or other cache entries // will be evicted from the cache to make room for the new entry. const size_t mMaxTotalSize; // mTotalSize is the total combined size of all keys and values currently in // the cache. size_t mTotalSize; // mRandState is the pseudo-random number generator state. It is passed to // nrand48 to generate random numbers when needed. unsigned short mRandState[3]; // mCacheEntries stores all the cache entries that are resident in memory. // Cache entries are added to it by the 'set' method. SortedVector mCacheEntries; }; } #endif // ANDROID_BLOB_CACHE_H ================================================ FILE: phonelibs/android_system_core/include/utils/ByteOrder.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // #ifndef _LIBS_UTILS_BYTE_ORDER_H #define _LIBS_UTILS_BYTE_ORDER_H #include #include #ifdef HAVE_WINSOCK #include #else #include #endif /* * These macros are like the hton/ntoh byte swapping macros, * except they allow you to swap to and from the "device" byte * order. The device byte order is the endianness of the target * device -- for the ARM CPUs we use today, this is little endian. * * Note that the byte swapping functions have not been optimized * much; performance is currently not an issue for them since the * intent is to allow us to avoid byte swapping on the device. */ static inline uint32_t android_swap_long(uint32_t v) { return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); } static inline uint16_t android_swap_short(uint16_t v) { return (v<<8) | (v>>8); } #define DEVICE_BYTE_ORDER LITTLE_ENDIAN #if BYTE_ORDER == DEVICE_BYTE_ORDER #define dtohl(x) (x) #define dtohs(x) (x) #define htodl(x) (x) #define htods(x) (x) #else #define dtohl(x) (android_swap_long(x)) #define dtohs(x) (android_swap_short(x)) #define htodl(x) (android_swap_long(x)) #define htods(x) (android_swap_short(x)) #endif #if BYTE_ORDER == LITTLE_ENDIAN #define fromlel(x) (x) #define fromles(x) (x) #define tolel(x) (x) #define toles(x) (x) #else #define fromlel(x) (android_swap_long(x)) #define fromles(x) (android_swap_short(x)) #define tolel(x) (android_swap_long(x)) #define toles(x) (android_swap_short(x)) #endif #endif // _LIBS_UTILS_BYTE_ORDER_H ================================================ FILE: phonelibs/android_system_core/include/utils/CallStack.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_CALLSTACK_H #define ANDROID_CALLSTACK_H #include #include #include #include #include #include namespace android { class Printer; // Collect/print the call stack (function, file, line) traces for a single thread. class CallStack { public: // Create an empty call stack. No-op. CallStack(); // Create a callstack with the current thread's stack trace. // Immediately dump it to logcat using the given logtag. CallStack(const char* logtag, int32_t ignoreDepth=1); ~CallStack(); // Reset the stack frames (same as creating an empty call stack). void clear() { mFrameLines.clear(); } // Immediately collect the stack traces for the specified thread. // The default is to dump the stack of the current call. void update(int32_t ignoreDepth=1, pid_t tid=BACKTRACE_CURRENT_THREAD); // Dump a stack trace to the log using the supplied logtag. void log(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, const char* prefix = 0) const; // Dump a stack trace to the specified file descriptor. void dump(int fd, int indent = 0, const char* prefix = 0) const; // Return a string (possibly very long) containing the complete stack trace. String8 toString(const char* prefix = 0) const; // Dump a serialized representation of the stack trace to the specified printer. void print(Printer& printer) const; // Get the count of stack frames that are in this call stack. size_t size() const { return mFrameLines.size(); } private: Vector mFrameLines; }; }; // namespace android #endif // ANDROID_CALLSTACK_H ================================================ FILE: phonelibs/android_system_core/include/utils/Compat.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __LIB_UTILS_COMPAT_H #define __LIB_UTILS_COMPAT_H #include #if defined(__APPLE__) /* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ typedef off_t off64_t; static inline off64_t lseek64(int fd, off64_t offset, int whence) { return lseek(fd, offset, whence); } static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { return pread(fd, buf, nbytes, offset); } #endif /* __APPLE__ */ #if defined(_WIN32) #define O_CLOEXEC O_NOINHERIT #define O_NOFOLLOW 0 #define DEFFILEMODE 0666 #endif /* _WIN32 */ #if defined(_WIN32) #define ZD "%ld" #define ZD_TYPE long #else #define ZD "%zd" #define ZD_TYPE ssize_t #endif /* * Needed for cases where something should be constexpr if possible, but not * being constexpr is fine if in pre-C++11 code (such as a const static float * member variable). */ #if __cplusplus >= 201103L #define CONSTEXPR constexpr #else #define CONSTEXPR #endif /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * . (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #endif /* __LIB_UTILS_COMPAT_H */ ================================================ FILE: phonelibs/android_system_core/include/utils/Condition.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_CONDITION_H #define _LIBS_UTILS_CONDITION_H #include #include #include #if !defined(_WIN32) # include #endif #include #include #include // --------------------------------------------------------------------------- namespace android { // --------------------------------------------------------------------------- /* * Condition variable class. The implementation is system-dependent. * * Condition variables are paired up with mutexes. Lock the mutex, * call wait(), then either re-wait() if things aren't quite what you want, * or unlock the mutex and continue. All threads calling wait() must * use the same mutex for a given Condition. */ class Condition { public: enum { PRIVATE = 0, SHARED = 1 }; enum WakeUpType { WAKE_UP_ONE = 0, WAKE_UP_ALL = 1 }; Condition(); Condition(int type); ~Condition(); // Wait on the condition variable. Lock the mutex before calling. status_t wait(Mutex& mutex); // same with relative timeout status_t waitRelative(Mutex& mutex, nsecs_t reltime); // Signal the condition variable, allowing exactly one thread to continue. void signal(); // Signal the condition variable, allowing one or all threads to continue. void signal(WakeUpType type) { if (type == WAKE_UP_ONE) { signal(); } else { broadcast(); } } // Signal the condition variable, allowing all threads to continue. void broadcast(); private: #if !defined(_WIN32) pthread_cond_t mCond; #else void* mState; #endif }; // --------------------------------------------------------------------------- #if !defined(_WIN32) inline Condition::Condition() { pthread_cond_init(&mCond, NULL); } inline Condition::Condition(int type) { if (type == SHARED) { pthread_condattr_t attr; pthread_condattr_init(&attr); pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); pthread_cond_init(&mCond, &attr); pthread_condattr_destroy(&attr); } else { pthread_cond_init(&mCond, NULL); } } inline Condition::~Condition() { pthread_cond_destroy(&mCond); } inline status_t Condition::wait(Mutex& mutex) { return -pthread_cond_wait(&mCond, &mutex.mMutex); } inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { #if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE) struct timespec ts; ts.tv_sec = reltime/1000000000; ts.tv_nsec = reltime%1000000000; return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts); #else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE struct timespec ts; #if defined(__linux__) clock_gettime(CLOCK_REALTIME, &ts); #else // __APPLE__ // we don't support the clocks here. struct timeval t; gettimeofday(&t, NULL); ts.tv_sec = t.tv_sec; ts.tv_nsec= t.tv_usec*1000; #endif ts.tv_sec += reltime/1000000000; ts.tv_nsec+= reltime%1000000000; if (ts.tv_nsec >= 1000000000) { ts.tv_nsec -= 1000000000; ts.tv_sec += 1; } return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts); #endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE } inline void Condition::signal() { /* * POSIX says pthread_cond_signal wakes up "one or more" waiting threads. * However bionic follows the glibc guarantee which wakes up "exactly one" * waiting thread. * * man 3 pthread_cond_signal * pthread_cond_signal restarts one of the threads that are waiting on * the condition variable cond. If no threads are waiting on cond, * nothing happens. If several threads are waiting on cond, exactly one * is restarted, but it is not specified which. */ pthread_cond_signal(&mCond); } inline void Condition::broadcast() { pthread_cond_broadcast(&mCond); } #endif // !defined(_WIN32) // --------------------------------------------------------------------------- }; // namespace android // --------------------------------------------------------------------------- #endif // _LIBS_UTILS_CONDITON_H ================================================ FILE: phonelibs/android_system_core/include/utils/Debug.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UTILS_DEBUG_H #define ANDROID_UTILS_DEBUG_H #include #include namespace android { // --------------------------------------------------------------------------- #ifdef __cplusplus template struct CompileTimeAssert; template<> struct CompileTimeAssert {}; #define COMPILE_TIME_ASSERT(_exp) \ template class CompileTimeAssert< (_exp) >; #endif #define COMPILE_TIME_ASSERT_FUNCTION_SCOPE(_exp) \ CompileTimeAssert<( _exp )>(); // --------------------------------------------------------------------------- #ifdef __cplusplus template struct CompileTimeIfElse; template struct CompileTimeIfElse { typedef LHS TYPE; }; template struct CompileTimeIfElse { typedef RHS TYPE; }; #endif // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_UTILS_DEBUG_H ================================================ FILE: phonelibs/android_system_core/include/utils/Endian.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Android endian-ness defines. // #ifndef _LIBS_UTILS_ENDIAN_H #define _LIBS_UTILS_ENDIAN_H #if defined(__APPLE__) || defined(_WIN32) #define __BIG_ENDIAN 0x1000 #define __LITTLE_ENDIAN 0x0001 #define __BYTE_ORDER __LITTLE_ENDIAN #else #include #endif #endif /*_LIBS_UTILS_ENDIAN_H*/ ================================================ FILE: phonelibs/android_system_core/include/utils/Errors.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_ERRORS_H #define ANDROID_ERRORS_H #include #include namespace android { // use this type to return error codes #ifdef HAVE_MS_C_RUNTIME typedef int status_t; #else typedef int32_t status_t; #endif /* the MS C runtime lacks a few error codes */ /* * Error codes. * All error codes are negative values. */ // Win32 #defines NO_ERROR as well. It has the same value, so there's no // real conflict, though it's a bit awkward. #ifdef _WIN32 # undef NO_ERROR #endif enum { OK = 0, // Everything's swell. NO_ERROR = 0, // No errors. UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value NO_MEMORY = -ENOMEM, INVALID_OPERATION = -ENOSYS, BAD_VALUE = -EINVAL, BAD_TYPE = (UNKNOWN_ERROR + 1), NAME_NOT_FOUND = -ENOENT, PERMISSION_DENIED = -EPERM, NO_INIT = -ENODEV, ALREADY_EXISTS = -EEXIST, DEAD_OBJECT = -EPIPE, FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), JPARKS_BROKE_IT = -EPIPE, #if !defined(HAVE_MS_C_RUNTIME) BAD_INDEX = -EOVERFLOW, NOT_ENOUGH_DATA = -ENODATA, WOULD_BLOCK = -EWOULDBLOCK, TIMED_OUT = -ETIMEDOUT, UNKNOWN_TRANSACTION = -EBADMSG, #else BAD_INDEX = -E2BIG, NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), WOULD_BLOCK = (UNKNOWN_ERROR + 4), TIMED_OUT = (UNKNOWN_ERROR + 5), UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), #endif FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), }; // Restore define; enumeration is in "android" namespace, so the value defined // there won't work for Win32 code in a different namespace. #ifdef _WIN32 # define NO_ERROR 0L #endif }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_ERRORS_H ================================================ FILE: phonelibs/android_system_core/include/utils/FileMap.h ================================================ /* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Encapsulate a shared file mapping. // #ifndef __LIBS_FILE_MAP_H #define __LIBS_FILE_MAP_H #include #include #if defined(__MINGW32__) // Ensure that we always pull in winsock2.h before windows.h #ifdef HAVE_WINSOCK #include #endif #include #endif namespace android { /* * This represents a memory-mapped file. It might be the entire file or * only part of it. This requires a little bookkeeping because the mapping * needs to be aligned on page boundaries, and in some cases we'd like to * have multiple references to the mapped area without creating additional * maps. * * This always uses MAP_SHARED. * * TODO: we should be able to create a new FileMap that is a subset of * an existing FileMap and shares the underlying mapped pages. Requires * completing the refcounting stuff and possibly introducing the notion * of a FileMap hierarchy. */ class FileMap { public: FileMap(void); /* * Create a new mapping on an open file. * * Closing the file descriptor does not unmap the pages, so we don't * claim ownership of the fd. * * Returns "false" on failure. */ bool create(const char* origFileName, int fd, off64_t offset, size_t length, bool readOnly); ~FileMap(void); /* * Return the name of the file this map came from, if known. */ const char* getFileName(void) const { return mFileName; } /* * Get a pointer to the piece of the file we requested. */ void* getDataPtr(void) const { return mDataPtr; } /* * Get the length we requested. */ size_t getDataLength(void) const { return mDataLength; } /* * Get the data offset used to create this map. */ off64_t getDataOffset(void) const { return mDataOffset; } /* * This maps directly to madvise() values, but allows us to avoid * including everywhere. */ enum MapAdvice { NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED }; /* * Apply an madvise() call to the entire file. * * Returns 0 on success, -1 on failure. */ int advise(MapAdvice advice); protected: private: // these are not implemented FileMap(const FileMap& src); const FileMap& operator=(const FileMap& src); char* mFileName; // original file name, if known void* mBasePtr; // base of mmap area; page aligned size_t mBaseLength; // length, measured from "mBasePtr" off64_t mDataOffset; // offset used when map was created void* mDataPtr; // start of requested data, offset from base size_t mDataLength; // length, measured from "mDataPtr" #if defined(__MINGW32__) HANDLE mFileHandle; // Win32 file handle HANDLE mFileMapping; // Win32 file mapping handle #endif static long mPageSize; }; }; // namespace android #endif // __LIBS_FILE_MAP_H ================================================ FILE: phonelibs/android_system_core/include/utils/Flattenable.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UTILS_FLATTENABLE_H #define ANDROID_UTILS_FLATTENABLE_H #include #include #include #include namespace android { class FlattenableUtils { public: template static size_t align(size_t size) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); return (size + (N-1)) & ~(N-1); } template static size_t align(void const*& buffer) { COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); intptr_t b = intptr_t(buffer); buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); return size_t(intptr_t(buffer) - b); } template static size_t align(void*& buffer) { return align( const_cast(buffer) ); } static void advance(void*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast( intptr_t(buffer) + offset ); size -= offset; } static void advance(void const*& buffer, size_t& size, size_t offset) { buffer = reinterpret_cast( intptr_t(buffer) + offset ); size -= offset; } // write a POD structure template static void write(void*& buffer, size_t& size, const T& value) { *static_cast(buffer) = value; advance(buffer, size, sizeof(T)); } // read a POD structure template static void read(void const*& buffer, size_t& size, T& value) { value = *static_cast(buffer); advance(buffer, size, sizeof(T)); } }; /* * The Flattenable protocol allows an object to serialize itself out * to a byte-buffer and an array of file descriptors. * Flattenable objects must implement this protocol. */ template class Flattenable { public: // size in bytes of the flattened object inline size_t getFlattenedSize() const; // number of file descriptors to flatten inline size_t getFdCount() const; // flattens the object into buffer. // size should be at least of getFlattenedSize() // file descriptors are written in the fds[] array but ownership is // not transfered (ie: they must be dupped by the caller of // flatten() if needed). inline status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; // unflattens the object from buffer. // size should be equal to the value of getFlattenedSize() when the // object was flattened. // unflattened file descriptors are found in the fds[] array and // don't need to be dupped(). ie: the caller of unflatten doesn't // keep ownership. If a fd is not retained by unflatten() it must be // explicitly closed. inline status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); }; template inline size_t Flattenable::getFlattenedSize() const { return static_cast(this)->T::getFlattenedSize(); } template inline size_t Flattenable::getFdCount() const { return static_cast(this)->T::getFdCount(); } template inline status_t Flattenable::flatten( void*& buffer, size_t& size, int*& fds, size_t& count) const { return static_cast(this)->T::flatten(buffer, size, fds, count); } template inline status_t Flattenable::unflatten( void const*& buffer, size_t& size, int const*& fds, size_t& count) { return static_cast(this)->T::unflatten(buffer, size, fds, count); } /* * LightFlattenable is a protocol allowing object to serialize themselves out * to a byte-buffer. Because it doesn't handle file-descriptors, * LightFlattenable is usually more size efficient than Flattenable. * LightFlattenable objects must implement this protocol. */ template class LightFlattenable { public: // returns whether this object always flatten into the same size. // for efficiency, this should always be inline. inline bool isFixedSize() const; // returns size in bytes of the flattened object. must be a constant. inline size_t getFlattenedSize() const; // flattens the object into buffer. inline status_t flatten(void* buffer, size_t size) const; // unflattens the object from buffer of given size. inline status_t unflatten(void const* buffer, size_t size); }; template inline bool LightFlattenable::isFixedSize() const { return static_cast(this)->T::isFixedSize(); } template inline size_t LightFlattenable::getFlattenedSize() const { return static_cast(this)->T::getFlattenedSize(); } template inline status_t LightFlattenable::flatten(void* buffer, size_t size) const { return static_cast(this)->T::flatten(buffer, size); } template inline status_t LightFlattenable::unflatten(void const* buffer, size_t size) { return static_cast(this)->T::unflatten(buffer, size); } /* * LightFlattenablePod is an implementation of the LightFlattenable protocol * for POD (plain-old-data) objects. * Simply derive from LightFlattenablePod to make Foo flattenable; no * need to implement any methods; obviously Foo must be a POD structure. */ template class LightFlattenablePod : public LightFlattenable { public: inline bool isFixedSize() const { return true; } inline size_t getFlattenedSize() const { return sizeof(T); } inline status_t flatten(void* buffer, size_t size) const { if (size < sizeof(T)) return NO_MEMORY; *reinterpret_cast(buffer) = *static_cast(this); return NO_ERROR; } inline status_t unflatten(void const* buffer, size_t) { *static_cast(this) = *reinterpret_cast(buffer); return NO_ERROR; } }; }; // namespace android #endif /* ANDROID_UTILS_FLATTENABLE_H */ ================================================ FILE: phonelibs/android_system_core/include/utils/Functor.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_FUNCTOR_H #define ANDROID_FUNCTOR_H #include namespace android { class Functor { public: Functor() {} virtual ~Functor() {} virtual status_t operator ()(int /*what*/, void* /*data*/) { return NO_ERROR; } }; }; // namespace android #endif // ANDROID_FUNCTOR_H ================================================ FILE: phonelibs/android_system_core/include/utils/JenkinsHash.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Implementation of Jenkins one-at-a-time hash function. These choices are * optimized for code size and portability, rather than raw speed. But speed * should still be quite good. **/ #ifndef ANDROID_JENKINS_HASH_H #define ANDROID_JENKINS_HASH_H #include namespace android { /* The Jenkins hash of a sequence of 32 bit words A, B, C is: * Whiten(Mix(Mix(Mix(0, A), B), C)) */ inline uint32_t JenkinsHashMix(uint32_t hash, uint32_t data) { hash += data; hash += (hash << 10); hash ^= (hash >> 6); return hash; } hash_t JenkinsHashWhiten(uint32_t hash); /* Helpful utility functions for hashing data in 32 bit chunks */ uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size); uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size); } #endif // ANDROID_JENKINS_HASH_H ================================================ FILE: phonelibs/android_system_core/include/utils/KeyedVector.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_KEYED_VECTOR_H #define ANDROID_KEYED_VECTOR_H #include #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { template class KeyedVector { public: typedef KEY key_type; typedef VALUE value_type; inline KeyedVector(); /* * empty the vector */ inline void clear() { mVector.clear(); } /*! * vector stats */ //! returns number of items in the vector inline size_t size() const { return mVector.size(); } //! returns whether or not the vector is empty inline bool isEmpty() const { return mVector.isEmpty(); } //! returns how many items can be stored without reallocating the backing store inline size_t capacity() const { return mVector.capacity(); } //! sets the capacity. capacity can never be reduced less than size() inline ssize_t setCapacity(size_t size) { return mVector.setCapacity(size); } // returns true if the arguments is known to be identical to this vector inline bool isIdenticalTo(const KeyedVector& rhs) const; /*! * accessors */ const VALUE& valueFor(const KEY& key) const; const VALUE& valueAt(size_t index) const; const KEY& keyAt(size_t index) const; ssize_t indexOfKey(const KEY& key) const; const VALUE& operator[] (size_t index) const; /*! * modifying the array */ VALUE& editValueFor(const KEY& key); VALUE& editValueAt(size_t index); /*! * add/insert/replace items */ ssize_t add(const KEY& key, const VALUE& item); ssize_t replaceValueFor(const KEY& key, const VALUE& item); ssize_t replaceValueAt(size_t index, const VALUE& item); /*! * remove items */ ssize_t removeItem(const KEY& key); ssize_t removeItemsAt(size_t index, size_t count = 1); private: SortedVector< key_value_pair_t > mVector; }; // KeyedVector can be trivially moved using memcpy() because its // underlying SortedVector can be trivially moved. template struct trait_trivial_move > { enum { value = trait_trivial_move > >::value }; }; // --------------------------------------------------------------------------- /** * Variation of KeyedVector that holds a default value to return when * valueFor() is called with a key that doesn't exist. */ template class DefaultKeyedVector : public KeyedVector { public: inline DefaultKeyedVector(const VALUE& defValue = VALUE()); const VALUE& valueFor(const KEY& key) const; private: VALUE mDefault; }; // --------------------------------------------------------------------------- template inline KeyedVector::KeyedVector() { } template inline bool KeyedVector::isIdenticalTo(const KeyedVector& rhs) const { return mVector.array() == rhs.mVector.array(); } template inline ssize_t KeyedVector::indexOfKey(const KEY& key) const { return mVector.indexOf( key_value_pair_t(key) ); } template inline const VALUE& KeyedVector::valueFor(const KEY& key) const { ssize_t i = this->indexOfKey(key); LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); return mVector.itemAt(i).value; } template inline const VALUE& KeyedVector::valueAt(size_t index) const { return mVector.itemAt(index).value; } template inline const VALUE& KeyedVector::operator[] (size_t index) const { return valueAt(index); } template inline const KEY& KeyedVector::keyAt(size_t index) const { return mVector.itemAt(index).key; } template inline VALUE& KeyedVector::editValueFor(const KEY& key) { ssize_t i = this->indexOfKey(key); LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); return mVector.editItemAt(i).value; } template inline VALUE& KeyedVector::editValueAt(size_t index) { return mVector.editItemAt(index).value; } template inline ssize_t KeyedVector::add(const KEY& key, const VALUE& value) { return mVector.add( key_value_pair_t(key, value) ); } template inline ssize_t KeyedVector::replaceValueFor(const KEY& key, const VALUE& value) { key_value_pair_t pair(key, value); mVector.remove(pair); return mVector.add(pair); } template inline ssize_t KeyedVector::replaceValueAt(size_t index, const VALUE& item) { if (index inline ssize_t KeyedVector::removeItem(const KEY& key) { return mVector.remove(key_value_pair_t(key)); } template inline ssize_t KeyedVector::removeItemsAt(size_t index, size_t count) { return mVector.removeItemsAt(index, count); } // --------------------------------------------------------------------------- template inline DefaultKeyedVector::DefaultKeyedVector(const VALUE& defValue) : mDefault(defValue) { } template inline const VALUE& DefaultKeyedVector::valueFor(const KEY& key) const { ssize_t i = this->indexOfKey(key); return i >= 0 ? KeyedVector::valueAt(i) : mDefault; } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_KEYED_VECTOR_H ================================================ FILE: phonelibs/android_system_core/include/utils/LinearTransform.h ================================================ /* * Copyright (C) 2011 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_LINEAR_TRANSFORM_H #define _LIBS_UTILS_LINEAR_TRANSFORM_H #include namespace android { // LinearTransform defines a structure which hold the definition of a // transformation from single dimensional coordinate system A into coordinate // system B (and back again). Values in A and in B are 64 bit, the linear // scale factor is expressed as a rational number using two 32 bit values. // // Specifically, let // f(a) = b // F(b) = f^-1(b) = a // then // // f(a) = (((a - a_zero) * a_to_b_numer) / a_to_b_denom) + b_zero; // // and // // F(b) = (((b - b_zero) * a_to_b_denom) / a_to_b_numer) + a_zero; // struct LinearTransform { int64_t a_zero; int64_t b_zero; int32_t a_to_b_numer; uint32_t a_to_b_denom; // Transform from A->B // Returns true on success, or false in the case of a singularity or an // overflow. bool doForwardTransform(int64_t a_in, int64_t* b_out) const; // Transform from B->A // Returns true on success, or false in the case of a singularity or an // overflow. bool doReverseTransform(int64_t b_in, int64_t* a_out) const; // Helpers which will reduce the fraction N/D using Euclid's method. template static void reduce(T* N, T* D); static void reduce(int32_t* N, uint32_t* D); }; } #endif // _LIBS_UTILS_LINEAR_TRANSFORM_H ================================================ FILE: phonelibs/android_system_core/include/utils/List.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Templated list class. Normally we'd use STL, but we don't have that. // This class mimics STL's interfaces. // // Objects are copied into the list with the '=' operator or with copy- // construction, so if the compiler's auto-generated versions won't work for // you, define your own. // // The only class you want to use from here is "List". // #ifndef _LIBS_UTILS_LIST_H #define _LIBS_UTILS_LIST_H #include #include namespace android { /* * Doubly-linked list. Instantiate with "List myList". * * Objects added to the list are copied using the assignment operator, * so this must be defined. */ template class List { protected: /* * One element in the list. */ class _Node { public: explicit _Node(const T& val) : mVal(val) {} ~_Node() {} inline T& getRef() { return mVal; } inline const T& getRef() const { return mVal; } inline _Node* getPrev() const { return mpPrev; } inline _Node* getNext() const { return mpNext; } inline void setVal(const T& val) { mVal = val; } inline void setPrev(_Node* ptr) { mpPrev = ptr; } inline void setNext(_Node* ptr) { mpNext = ptr; } private: friend class List; friend class _ListIterator; T mVal; _Node* mpPrev; _Node* mpNext; }; /* * Iterator for walking through the list. */ template struct CONST_ITERATOR { typedef _Node const * NodePtr; typedef const TYPE Type; }; template struct NON_CONST_ITERATOR { typedef _Node* NodePtr; typedef TYPE Type; }; template< typename U, template class Constness > class _ListIterator { typedef _ListIterator _Iter; typedef typename Constness::NodePtr _NodePtr; typedef typename Constness::Type _Type; explicit _ListIterator(_NodePtr ptr) : mpNode(ptr) {} public: _ListIterator() {} _ListIterator(const _Iter& rhs) : mpNode(rhs.mpNode) {} ~_ListIterator() {} // this will handle conversions from iterator to const_iterator // (and also all convertible iterators) // Here, in this implementation, the iterators can be converted // if the nodes can be converted template explicit _ListIterator(const V& rhs) : mpNode(rhs.mpNode) {} /* * Dereference operator. Used to get at the juicy insides. */ _Type& operator*() const { return mpNode->getRef(); } _Type* operator->() const { return &(mpNode->getRef()); } /* * Iterator comparison. */ inline bool operator==(const _Iter& right) const { return mpNode == right.mpNode; } inline bool operator!=(const _Iter& right) const { return mpNode != right.mpNode; } /* * handle comparisons between iterator and const_iterator */ template inline bool operator==(const OTHER& right) const { return mpNode == right.mpNode; } template inline bool operator!=(const OTHER& right) const { return mpNode != right.mpNode; } /* * Incr/decr, used to move through the list. */ inline _Iter& operator++() { // pre-increment mpNode = mpNode->getNext(); return *this; } const _Iter operator++(int) { // post-increment _Iter tmp(*this); mpNode = mpNode->getNext(); return tmp; } inline _Iter& operator--() { // pre-increment mpNode = mpNode->getPrev(); return *this; } const _Iter operator--(int) { // post-increment _Iter tmp(*this); mpNode = mpNode->getPrev(); return tmp; } inline _NodePtr getNode() const { return mpNode; } _NodePtr mpNode; /* should be private, but older gcc fails */ private: friend class List; }; public: List() { prep(); } List(const List& src) { // copy-constructor prep(); insert(begin(), src.begin(), src.end()); } virtual ~List() { clear(); delete[] (unsigned char*) mpMiddle; } typedef _ListIterator iterator; typedef _ListIterator const_iterator; List& operator=(const List& right); /* returns true if the list is empty */ inline bool empty() const { return mpMiddle->getNext() == mpMiddle; } /* return #of elements in list */ size_t size() const { return size_t(distance(begin(), end())); } /* * Return the first element or one past the last element. The * _Node* we're returning is converted to an "iterator" by a * constructor in _ListIterator. */ inline iterator begin() { return iterator(mpMiddle->getNext()); } inline const_iterator begin() const { return const_iterator(const_cast<_Node const*>(mpMiddle->getNext())); } inline iterator end() { return iterator(mpMiddle); } inline const_iterator end() const { return const_iterator(const_cast<_Node const*>(mpMiddle)); } /* add the object to the head or tail of the list */ void push_front(const T& val) { insert(begin(), val); } void push_back(const T& val) { insert(end(), val); } /* insert before the current node; returns iterator at new node */ iterator insert(iterator posn, const T& val) { _Node* newNode = new _Node(val); // alloc & copy-construct newNode->setNext(posn.getNode()); newNode->setPrev(posn.getNode()->getPrev()); posn.getNode()->getPrev()->setNext(newNode); posn.getNode()->setPrev(newNode); return iterator(newNode); } /* insert a range of elements before the current node */ void insert(iterator posn, const_iterator first, const_iterator last) { for ( ; first != last; ++first) insert(posn, *first); } /* remove one entry; returns iterator at next node */ iterator erase(iterator posn) { _Node* pNext = posn.getNode()->getNext(); _Node* pPrev = posn.getNode()->getPrev(); pPrev->setNext(pNext); pNext->setPrev(pPrev); delete posn.getNode(); return iterator(pNext); } /* remove a range of elements */ iterator erase(iterator first, iterator last) { while (first != last) erase(first++); // don't erase than incr later! return iterator(last); } /* remove all contents of the list */ void clear() { _Node* pCurrent = mpMiddle->getNext(); _Node* pNext; while (pCurrent != mpMiddle) { pNext = pCurrent->getNext(); delete pCurrent; pCurrent = pNext; } mpMiddle->setPrev(mpMiddle); mpMiddle->setNext(mpMiddle); } /* * Measure the distance between two iterators. On exist, "first" * will be equal to "last". The iterators must refer to the same * list. * * FIXME: This is actually a generic iterator function. It should be a * template function at the top-level with specializations for things like * vector<>, which can just do pointer math). Here we limit it to * _ListIterator of the same type but different constness. */ template< typename U, template class CL, template class CR > ptrdiff_t distance( _ListIterator first, _ListIterator last) const { ptrdiff_t count = 0; while (first != last) { ++first; ++count; } return count; } private: /* * I want a _Node but don't need it to hold valid data. More * to the point, I don't want T's constructor to fire, since it * might have side-effects or require arguments. So, we do this * slightly uncouth storage alloc. */ void prep() { mpMiddle = (_Node*) new unsigned char[sizeof(_Node)]; mpMiddle->setPrev(mpMiddle); mpMiddle->setNext(mpMiddle); } /* * This node plays the role of "pointer to head" and "pointer to tail". * It sits in the middle of a circular list of nodes. The iterator * runs around the circle until it encounters this one. */ _Node* mpMiddle; }; /* * Assignment operator. * * The simplest way to do this would be to clear out the target list and * fill it with the source. However, we can speed things along by * re-using existing elements. */ template List& List::operator=(const List& right) { if (this == &right) return *this; // self-assignment iterator firstDst = begin(); iterator lastDst = end(); const_iterator firstSrc = right.begin(); const_iterator lastSrc = right.end(); while (firstSrc != lastSrc && firstDst != lastDst) *firstDst++ = *firstSrc++; if (firstSrc == lastSrc) // ran out of elements in source? erase(firstDst, lastDst); // yes, erase any extras else insert(lastDst, firstSrc, lastSrc); // copy remaining over return *this; } }; // namespace android #endif // _LIBS_UTILS_LIST_H ================================================ FILE: phonelibs/android_system_core/include/utils/Log.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // C/C++ logging functions. See the logging documentation for API details. // // We'd like these to be available from C code (in case we import some from // somewhere), so this has a C interface. // // The output will be correct when the log file is shared between multiple // threads and/or multiple processes so long as the operating system // supports O_APPEND. These calls have mutex-protected data structures // and so are NOT reentrant. Do not use LOG in a signal handler. // #ifndef _LIBS_UTILS_LOG_H #define _LIBS_UTILS_LOG_H #include #include #ifdef __cplusplus namespace android { /* * A very simple utility that yells in the log when an operation takes too long. */ class LogIfSlow { public: LogIfSlow(const char* tag, android_LogPriority priority, int timeoutMillis, const char* message); ~LogIfSlow(); private: const char* const mTag; const android_LogPriority mPriority; const int mTimeoutMillis; const char* const mMessage; const int64_t mStart; }; /* * Writes the specified debug log message if this block takes longer than the * specified number of milliseconds to run. Includes the time actually taken. * * { * ALOGD_IF_SLOW(50, "Excessive delay doing something."); * doSomething(); * } */ #define ALOGD_IF_SLOW(timeoutMillis, message) \ android::LogIfSlow _logIfSlow(LOG_TAG, ANDROID_LOG_DEBUG, timeoutMillis, message); } // namespace android #endif // __cplusplus #endif // _LIBS_UTILS_LOG_H ================================================ FILE: phonelibs/android_system_core/include/utils/Looper.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef UTILS_LOOPER_H #define UTILS_LOOPER_H #include #include #include #include #include namespace android { /* * NOTE: Since Looper is used to implement the NDK ALooper, the Looper * enums and the signature of Looper_callbackFunc need to align with * that implementation. */ /** * For callback-based event loops, this is the prototype of the function * that is called when a file descriptor event occurs. * It is given the file descriptor it is associated with, * a bitmask of the poll events that were triggered (typically EVENT_INPUT), * and the data pointer that was originally supplied. * * Implementations should return 1 to continue receiving callbacks, or 0 * to have this file descriptor and callback unregistered from the looper. */ typedef int (*Looper_callbackFunc)(int fd, int events, void* data); /** * A message that can be posted to a Looper. */ struct Message { Message() : what(0) { } Message(int what) : what(what) { } /* The message type. (interpretation is left up to the handler) */ int what; }; /** * Interface for a Looper message handler. * * The Looper holds a strong reference to the message handler whenever it has * a message to deliver to it. Make sure to call Looper::removeMessages * to remove any pending messages destined for the handler so that the handler * can be destroyed. */ class MessageHandler : public virtual RefBase { protected: virtual ~MessageHandler() { } public: /** * Handles a message. */ virtual void handleMessage(const Message& message) = 0; }; /** * A simple proxy that holds a weak reference to a message handler. */ class WeakMessageHandler : public MessageHandler { protected: virtual ~WeakMessageHandler(); public: WeakMessageHandler(const wp& handler); virtual void handleMessage(const Message& message); private: wp mHandler; }; /** * A looper callback. */ class LooperCallback : public virtual RefBase { protected: virtual ~LooperCallback() { } public: /** * Handles a poll event for the given file descriptor. * It is given the file descriptor it is associated with, * a bitmask of the poll events that were triggered (typically EVENT_INPUT), * and the data pointer that was originally supplied. * * Implementations should return 1 to continue receiving callbacks, or 0 * to have this file descriptor and callback unregistered from the looper. */ virtual int handleEvent(int fd, int events, void* data) = 0; }; /** * Wraps a Looper_callbackFunc function pointer. */ class SimpleLooperCallback : public LooperCallback { protected: virtual ~SimpleLooperCallback(); public: SimpleLooperCallback(Looper_callbackFunc callback); virtual int handleEvent(int fd, int events, void* data); private: Looper_callbackFunc mCallback; }; /** * A polling loop that supports monitoring file descriptor events, optionally * using callbacks. The implementation uses epoll() internally. * * A looper can be associated with a thread although there is no requirement that it must be. */ class Looper : public RefBase { protected: virtual ~Looper(); public: enum { /** * Result from Looper_pollOnce() and Looper_pollAll(): * The poll was awoken using wake() before the timeout expired * and no callbacks were executed and no other file descriptors were ready. */ POLL_WAKE = -1, /** * Result from Looper_pollOnce() and Looper_pollAll(): * One or more callbacks were executed. */ POLL_CALLBACK = -2, /** * Result from Looper_pollOnce() and Looper_pollAll(): * The timeout expired. */ POLL_TIMEOUT = -3, /** * Result from Looper_pollOnce() and Looper_pollAll(): * An error occurred. */ POLL_ERROR = -4, }; /** * Flags for file descriptor events that a looper can monitor. * * These flag bits can be combined to monitor multiple events at once. */ enum { /** * The file descriptor is available for read operations. */ EVENT_INPUT = 1 << 0, /** * The file descriptor is available for write operations. */ EVENT_OUTPUT = 1 << 1, /** * The file descriptor has encountered an error condition. * * The looper always sends notifications about errors; it is not necessary * to specify this event flag in the requested event set. */ EVENT_ERROR = 1 << 2, /** * The file descriptor was hung up. * For example, indicates that the remote end of a pipe or socket was closed. * * The looper always sends notifications about hangups; it is not necessary * to specify this event flag in the requested event set. */ EVENT_HANGUP = 1 << 3, /** * The file descriptor is invalid. * For example, the file descriptor was closed prematurely. * * The looper always sends notifications about invalid file descriptors; it is not necessary * to specify this event flag in the requested event set. */ EVENT_INVALID = 1 << 4, }; enum { /** * Option for Looper_prepare: this looper will accept calls to * Looper_addFd() that do not have a callback (that is provide NULL * for the callback). In this case the caller of Looper_pollOnce() * or Looper_pollAll() MUST check the return from these functions to * discover when data is available on such fds and process it. */ PREPARE_ALLOW_NON_CALLBACKS = 1<<0 }; /** * Creates a looper. * * If allowNonCallbaks is true, the looper will allow file descriptors to be * registered without associated callbacks. This assumes that the caller of * pollOnce() is prepared to handle callback-less events itself. */ Looper(bool allowNonCallbacks); /** * Returns whether this looper instance allows the registration of file descriptors * using identifiers instead of callbacks. */ bool getAllowNonCallbacks() const; /** * Waits for events to be available, with optional timeout in milliseconds. * Invokes callbacks for all file descriptors on which an event occurred. * * If the timeout is zero, returns immediately without blocking. * If the timeout is negative, waits indefinitely until an event appears. * * Returns POLL_WAKE if the poll was awoken using wake() before * the timeout expired and no callbacks were invoked and no other file * descriptors were ready. * * Returns POLL_CALLBACK if one or more callbacks were invoked. * * Returns POLL_TIMEOUT if there was no data before the given * timeout expired. * * Returns POLL_ERROR if an error occurred. * * Returns a value >= 0 containing an identifier if its file descriptor has data * and it has no callback function (requiring the caller here to handle it). * In this (and only this) case outFd, outEvents and outData will contain the poll * events and data associated with the fd, otherwise they will be set to NULL. * * This method does not return until it has finished invoking the appropriate callbacks * for all file descriptors that were signalled. */ int pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData); inline int pollOnce(int timeoutMillis) { return pollOnce(timeoutMillis, NULL, NULL, NULL); } /** * Like pollOnce(), but performs all pending callbacks until all * data has been consumed or a file descriptor is available with no callback. * This function will never return POLL_CALLBACK. */ int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); inline int pollAll(int timeoutMillis) { return pollAll(timeoutMillis, NULL, NULL, NULL); } /** * Wakes the poll asynchronously. * * This method can be called on any thread. * This method returns immediately. */ void wake(); /** * Adds a new file descriptor to be polled by the looper. * If the same file descriptor was previously added, it is replaced. * * "fd" is the file descriptor to be added. * "ident" is an identifier for this event, which is returned from pollOnce(). * The identifier must be >= 0, or POLL_CALLBACK if providing a non-NULL callback. * "events" are the poll events to wake up on. Typically this is EVENT_INPUT. * "callback" is the function to call when there is an event on the file descriptor. * "data" is a private data pointer to supply to the callback. * * There are two main uses of this function: * * (1) If "callback" is non-NULL, then this function will be called when there is * data on the file descriptor. It should execute any events it has pending, * appropriately reading from the file descriptor. The 'ident' is ignored in this case. * * (2) If "callback" is NULL, the 'ident' will be returned by Looper_pollOnce * when its file descriptor has data available, requiring the caller to take * care of processing it. * * Returns 1 if the file descriptor was added, 0 if the arguments were invalid. * * This method can be called on any thread. * This method may block briefly if it needs to wake the poll. * * The callback may either be specified as a bare function pointer or as a smart * pointer callback object. The smart pointer should be preferred because it is * easier to avoid races when the callback is removed from a different thread. * See removeFd() for details. */ int addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data); int addFd(int fd, int ident, int events, const sp& callback, void* data); /** * Removes a previously added file descriptor from the looper. * * When this method returns, it is safe to close the file descriptor since the looper * will no longer have a reference to it. However, it is possible for the callback to * already be running or for it to run one last time if the file descriptor was already * signalled. Calling code is responsible for ensuring that this case is safely handled. * For example, if the callback takes care of removing itself during its own execution either * by returning 0 or by calling this method, then it can be guaranteed to not be invoked * again at any later time unless registered anew. * * A simple way to avoid this problem is to use the version of addFd() that takes * a sp instead of a bare function pointer. The LooperCallback will * be released at the appropriate time by the Looper. * * Returns 1 if the file descriptor was removed, 0 if none was previously registered. * * This method can be called on any thread. * This method may block briefly if it needs to wake the poll. */ int removeFd(int fd); /** * Enqueues a message to be processed by the specified handler. * * The handler must not be null. * This method can be called on any thread. */ void sendMessage(const sp& handler, const Message& message); /** * Enqueues a message to be processed by the specified handler after all pending messages * after the specified delay. * * The time delay is specified in uptime nanoseconds. * The handler must not be null. * This method can be called on any thread. */ void sendMessageDelayed(nsecs_t uptimeDelay, const sp& handler, const Message& message); /** * Enqueues a message to be processed by the specified handler after all pending messages * at the specified time. * * The time is specified in uptime nanoseconds. * The handler must not be null. * This method can be called on any thread. */ void sendMessageAtTime(nsecs_t uptime, const sp& handler, const Message& message); /** * Removes all messages for the specified handler from the queue. * * The handler must not be null. * This method can be called on any thread. */ void removeMessages(const sp& handler); /** * Removes all messages of a particular type for the specified handler from the queue. * * The handler must not be null. * This method can be called on any thread. */ void removeMessages(const sp& handler, int what); /** * Returns whether this looper's thread is currently polling for more work to do. * This is a good signal that the loop is still alive rather than being stuck * handling a callback. Note that this method is intrinsically racy, since the * state of the loop can change before you get the result back. */ bool isPolling() const; /** * Prepares a looper associated with the calling thread, and returns it. * If the thread already has a looper, it is returned. Otherwise, a new * one is created, associated with the thread, and returned. * * The opts may be PREPARE_ALLOW_NON_CALLBACKS or 0. */ static sp prepare(int opts); /** * Sets the given looper to be associated with the calling thread. * If another looper is already associated with the thread, it is replaced. * * If "looper" is NULL, removes the currently associated looper. */ static void setForThread(const sp& looper); /** * Returns the looper associated with the calling thread, or NULL if * there is not one. */ static sp getForThread(); private: struct Request { int fd; int ident; int events; int seq; sp callback; void* data; void initEventItem(struct epoll_event* eventItem) const; }; struct Response { int events; Request request; }; struct MessageEnvelope { MessageEnvelope() : uptime(0) { } MessageEnvelope(nsecs_t uptime, const sp handler, const Message& message) : uptime(uptime), handler(handler), message(message) { } nsecs_t uptime; sp handler; Message message; }; const bool mAllowNonCallbacks; // immutable int mWakeEventFd; // immutable Mutex mLock; Vector mMessageEnvelopes; // guarded by mLock bool mSendingMessage; // guarded by mLock // Whether we are currently waiting for work. Not protected by a lock, // any use of it is racy anyway. volatile bool mPolling; int mEpollFd; // guarded by mLock but only modified on the looper thread bool mEpollRebuildRequired; // guarded by mLock // Locked list of file descriptor monitoring requests. KeyedVector mRequests; // guarded by mLock int mNextRequestSeq; // This state is only used privately by pollOnce and does not require a lock since // it runs on a single thread. Vector mResponses; size_t mResponseIndex; nsecs_t mNextMessageUptime; // set to LLONG_MAX when none int pollInner(int timeoutMillis); int removeFd(int fd, int seq); void awoken(); void pushResponse(int events, const Request& request); void rebuildEpollLocked(); void scheduleEpollRebuildLocked(); static void initTLSKey(); static void threadDestructor(void *st); static void initEpollEvent(struct epoll_event* eventItem); }; } // namespace android #endif // UTILS_LOOPER_H ================================================ FILE: phonelibs/android_system_core/include/utils/LruCache.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UTILS_LRU_CACHE_H #define ANDROID_UTILS_LRU_CACHE_H #include #include namespace android { /** * GenerationCache callback used when an item is removed */ template class OnEntryRemoved { public: virtual ~OnEntryRemoved() { }; virtual void operator()(EntryKey& key, EntryValue& value) = 0; }; // class OnEntryRemoved template class LruCache { public: explicit LruCache(uint32_t maxCapacity); enum Capacity { kUnlimitedCapacity, }; void setOnEntryRemovedListener(OnEntryRemoved* listener); size_t size() const; const TValue& get(const TKey& key); bool put(const TKey& key, const TValue& value); bool remove(const TKey& key); bool removeOldest(); void clear(); const TValue& peekOldestValue(); class Iterator { public: Iterator(const LruCache& cache): mCache(cache), mIndex(-1) { } bool next() { mIndex = mCache.mTable->next(mIndex); return (ssize_t)mIndex != -1; } size_t index() const { return mIndex; } const TValue& value() const { return mCache.mTable->entryAt(mIndex).value; } const TKey& key() const { return mCache.mTable->entryAt(mIndex).key; } private: const LruCache& mCache; size_t mIndex; }; private: LruCache(const LruCache& that); // disallow copy constructor struct Entry { TKey key; TValue value; Entry* parent; Entry* child; Entry(TKey key_, TValue value_) : key(key_), value(value_), parent(NULL), child(NULL) { } const TKey& getKey() const { return key; } }; void attachToCache(Entry& entry); void detachFromCache(Entry& entry); void rehash(size_t newCapacity); UniquePtr > mTable; OnEntryRemoved* mListener; Entry* mOldest; Entry* mYoungest; uint32_t mMaxCapacity; TValue mNullValue; }; // Implementation is here, because it's fully templated template LruCache::LruCache(uint32_t maxCapacity) : mTable(new BasicHashtable) , mListener(NULL) , mOldest(NULL) , mYoungest(NULL) , mMaxCapacity(maxCapacity) , mNullValue(NULL) { }; template void LruCache::setOnEntryRemovedListener(OnEntryRemoved* listener) { mListener = listener; } template size_t LruCache::size() const { return mTable->size(); } template const TValue& LruCache::get(const TKey& key) { hash_t hash = hash_type(key); ssize_t index = mTable->find(-1, hash, key); if (index == -1) { return mNullValue; } Entry& entry = mTable->editEntryAt(index); detachFromCache(entry); attachToCache(entry); return entry.value; } template bool LruCache::put(const TKey& key, const TValue& value) { if (mMaxCapacity != kUnlimitedCapacity && size() >= mMaxCapacity) { removeOldest(); } hash_t hash = hash_type(key); ssize_t index = mTable->find(-1, hash, key); if (index >= 0) { return false; } if (!mTable->hasMoreRoom()) { rehash(mTable->capacity() * 2); } // Would it be better to initialize a blank entry and assign key, value? Entry initEntry(key, value); index = mTable->add(hash, initEntry); Entry& entry = mTable->editEntryAt(index); attachToCache(entry); return true; } template bool LruCache::remove(const TKey& key) { hash_t hash = hash_type(key); ssize_t index = mTable->find(-1, hash, key); if (index < 0) { return false; } Entry& entry = mTable->editEntryAt(index); if (mListener) { (*mListener)(entry.key, entry.value); } detachFromCache(entry); mTable->removeAt(index); return true; } template bool LruCache::removeOldest() { if (mOldest != NULL) { return remove(mOldest->key); // TODO: should probably abort if false } return false; } template const TValue& LruCache::peekOldestValue() { if (mOldest) { return mOldest->value; } return mNullValue; } template void LruCache::clear() { if (mListener) { for (Entry* p = mOldest; p != NULL; p = p->child) { (*mListener)(p->key, p->value); } } mYoungest = NULL; mOldest = NULL; mTable->clear(); } template void LruCache::attachToCache(Entry& entry) { if (mYoungest == NULL) { mYoungest = mOldest = &entry; } else { entry.parent = mYoungest; mYoungest->child = &entry; mYoungest = &entry; } } template void LruCache::detachFromCache(Entry& entry) { if (entry.parent != NULL) { entry.parent->child = entry.child; } else { mOldest = entry.child; } if (entry.child != NULL) { entry.child->parent = entry.parent; } else { mYoungest = entry.parent; } entry.parent = NULL; entry.child = NULL; } template void LruCache::rehash(size_t newCapacity) { UniquePtr > oldTable(mTable.release()); Entry* oldest = mOldest; mOldest = NULL; mYoungest = NULL; mTable.reset(new BasicHashtable(newCapacity)); for (Entry* p = oldest; p != NULL; p = p->child) { put(p->key, p->value); } } } #endif // ANDROID_UTILS_LRU_CACHE_H ================================================ FILE: phonelibs/android_system_core/include/utils/Mutex.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_MUTEX_H #define _LIBS_UTILS_MUTEX_H #include #include #include #if !defined(_WIN32) # include #endif #include #include // --------------------------------------------------------------------------- namespace android { // --------------------------------------------------------------------------- class Condition; /* * Simple mutex class. The implementation is system-dependent. * * The mutex must be unlocked by the thread that locked it. They are not * recursive, i.e. the same thread can't lock it multiple times. */ class Mutex { public: enum { PRIVATE = 0, SHARED = 1 }; Mutex(); Mutex(const char* name); Mutex(int type, const char* name = NULL); ~Mutex(); // lock or unlock the mutex status_t lock(); void unlock(); // lock if possible; returns 0 on success, error otherwise status_t tryLock(); #if HAVE_ANDROID_OS // lock the mutex, but don't wait longer than timeoutMilliseconds. // Returns 0 on success, TIMED_OUT for failure due to timeout expiration. // // OSX doesn't have pthread_mutex_timedlock() or equivalent. To keep // capabilities consistent across host OSes, this method is only available // when building Android binaries. status_t timedLock(nsecs_t timeoutMilliseconds); #endif // Manages the mutex automatically. It'll be locked when Autolock is // constructed and released when Autolock goes out of scope. class Autolock { public: inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } inline ~Autolock() { mLock.unlock(); } private: Mutex& mLock; }; private: friend class Condition; // A mutex cannot be copied Mutex(const Mutex&); Mutex& operator = (const Mutex&); #if !defined(_WIN32) pthread_mutex_t mMutex; #else void _init(); void* mState; #endif }; // --------------------------------------------------------------------------- #if !defined(_WIN32) inline Mutex::Mutex() { pthread_mutex_init(&mMutex, NULL); } inline Mutex::Mutex(__attribute__((unused)) const char* name) { pthread_mutex_init(&mMutex, NULL); } inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) { if (type == SHARED) { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); pthread_mutex_init(&mMutex, &attr); pthread_mutexattr_destroy(&attr); } else { pthread_mutex_init(&mMutex, NULL); } } inline Mutex::~Mutex() { pthread_mutex_destroy(&mMutex); } inline status_t Mutex::lock() { return -pthread_mutex_lock(&mMutex); } inline void Mutex::unlock() { pthread_mutex_unlock(&mMutex); } inline status_t Mutex::tryLock() { return -pthread_mutex_trylock(&mMutex); } #if HAVE_ANDROID_OS inline status_t Mutex::timedLock(nsecs_t timeoutNs) { const struct timespec ts = { /* .tv_sec = */ static_cast(timeoutNs / 1000000000), /* .tv_nsec = */ static_cast(timeoutNs % 1000000000), }; return -pthread_mutex_timedlock(&mMutex, &ts); } #endif #endif // !defined(_WIN32) // --------------------------------------------------------------------------- /* * Automatic mutex. Declare one of these at the top of a function. * When the function returns, it will go out of scope, and release the * mutex. */ typedef Mutex::Autolock AutoMutex; // --------------------------------------------------------------------------- }; // namespace android // --------------------------------------------------------------------------- #endif // _LIBS_UTILS_MUTEX_H ================================================ FILE: phonelibs/android_system_core/include/utils/NativeHandle.h ================================================ /* * Copyright 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_NATIVE_HANDLE_H #define ANDROID_NATIVE_HANDLE_H #include #include typedef struct native_handle native_handle_t; namespace android { class NativeHandle: public LightRefBase { public: // Create a refcounted wrapper around a native_handle_t, and declare // whether the wrapper owns the handle (so that it should clean up the // handle upon destruction) or not. // If handle is NULL, no NativeHandle will be created. static sp create(native_handle_t* handle, bool ownsHandle); const native_handle_t* handle() const { return mHandle; } private: // for access to the destructor friend class LightRefBase; NativeHandle(native_handle_t* handle, bool ownsHandle); virtual ~NativeHandle(); native_handle_t* mHandle; bool mOwnsHandle; // non-copyable NativeHandle(const NativeHandle&); NativeHandle& operator=(const NativeHandle&); }; } // namespace android #endif // ANDROID_NATIVE_HANDLE_H ================================================ FILE: phonelibs/android_system_core/include/utils/Printer.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_PRINTER_H #define ANDROID_PRINTER_H #include namespace android { // Interface for printing to an arbitrary data stream class Printer { public: // Print a new line specified by 'string'. \n is appended automatically. // -- Assumes that the string has no new line in it. virtual void printLine(const char* string = "") = 0; // Print a new line specified by the format string. \n is appended automatically. // -- Assumes that the resulting string has no new line in it. virtual void printFormatLine(const char* format, ...) __attribute__((format (printf, 2, 3))); protected: Printer(); virtual ~Printer(); }; // class Printer // Print to logcat class LogPrinter : public Printer { public: // Create a printer using the specified logcat and log priority // - Unless ignoreBlankLines is false, print blank lines to logcat // (Note that the default ALOG behavior is to ignore blank lines) LogPrinter(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, const char* prefix = 0, bool ignoreBlankLines = false); // Print the specified line to logcat. No \n at the end is necessary. virtual void printLine(const char* string); private: void printRaw(const char* string); const char* mLogTag; android_LogPriority mPriority; const char* mPrefix; bool mIgnoreBlankLines; }; // class LogPrinter // Print to a file descriptor class FdPrinter : public Printer { public: // Create a printer using the specified file descriptor. // - Each line will be prefixed with 'indent' number of blank spaces. // - In addition, each line will be prefixed with the 'prefix' string. FdPrinter(int fd, unsigned int indent = 0, const char* prefix = 0); // Print the specified line to the file descriptor. \n is appended automatically. virtual void printLine(const char* string); private: enum { MAX_FORMAT_STRING = 20, }; int mFd; unsigned int mIndent; const char* mPrefix; char mFormatString[MAX_FORMAT_STRING]; }; // class FdPrinter class String8; // Print to a String8 class String8Printer : public Printer { public: // Create a printer using the specified String8 as the target. // - In addition, each line will be prefixed with the 'prefix' string. // - target's memory lifetime must be a superset of this String8Printer. String8Printer(String8* target, const char* prefix = 0); // Append the specified line to the String8. \n is appended automatically. virtual void printLine(const char* string); private: String8* mTarget; const char* mPrefix; }; // class String8Printer // Print to an existing Printer by adding a prefix to each line class PrefixPrinter : public Printer { public: // Create a printer using the specified printer as the target. PrefixPrinter(Printer& printer, const char* prefix); // Print the line (prefixed with prefix) using the printer. virtual void printLine(const char* string); private: Printer& mPrinter; const char* mPrefix; }; }; // namespace android #endif // ANDROID_PRINTER_H ================================================ FILE: phonelibs/android_system_core/include/utils/ProcessCallStack.h ================================================ /* * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_PROCESS_CALLSTACK_H #define ANDROID_PROCESS_CALLSTACK_H #include #include #include #include #include #include namespace android { class Printer; // Collect/print the call stack (function, file, line) traces for all threads in a process. class ProcessCallStack { public: // Create an empty call stack. No-op. ProcessCallStack(); // Copy the existing process callstack (no other side effects). ProcessCallStack(const ProcessCallStack& rhs); ~ProcessCallStack(); // Immediately collect the stack traces for all threads. void update(); // Print all stack traces to the log using the supplied logtag. void log(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, const char* prefix = 0) const; // Dump all stack traces to the specified file descriptor. void dump(int fd, int indent = 0, const char* prefix = 0) const; // Return a string (possibly very long) containing all the stack traces. String8 toString(const char* prefix = 0) const; // Dump a serialized representation of all the stack traces to the specified printer. void print(Printer& printer) const; // Get the number of threads whose stack traces were collected. size_t size() const; private: void printInternal(Printer& printer, Printer& csPrinter) const; // Reset the process's stack frames and metadata. void clear(); struct ThreadInfo { CallStack callStack; String8 threadName; }; // tid -> ThreadInfo KeyedVector mThreadMap; // Time that update() was last called struct tm mTimeUpdated; }; }; // namespace android #endif // ANDROID_PROCESS_CALLSTACK_H ================================================ FILE: phonelibs/android_system_core/include/utils/PropertyMap.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _UTILS_PROPERTY_MAP_H #define _UTILS_PROPERTY_MAP_H #include #include #include #include namespace android { /* * Provides a mechanism for passing around string-based property key / value pairs * and loading them from property files. * * The property files have the following simple structure: * * # Comment * key = value * * Keys and values are any sequence of printable ASCII characters. * The '=' separates the key from the value. * The key and value may not contain whitespace. * * The '\' character is reserved for escape sequences and is not currently supported. * The '"" character is reserved for quoting and is not currently supported. * Files that contain the '\' or '"' character will fail to parse. * * The file must not contain duplicate keys. * * TODO Support escape sequences and quoted values when needed. */ class PropertyMap { public: /* Creates an empty property map. */ PropertyMap(); ~PropertyMap(); /* Clears the property map. */ void clear(); /* Adds a property. * Replaces the property with the same key if it is already present. */ void addProperty(const String8& key, const String8& value); /* Returns true if the property map contains the specified key. */ bool hasProperty(const String8& key) const; /* Gets the value of a property and parses it. * Returns true and sets outValue if the key was found and its value was parsed successfully. * Otherwise returns false and does not modify outValue. (Also logs a warning.) */ bool tryGetProperty(const String8& key, String8& outValue) const; bool tryGetProperty(const String8& key, bool& outValue) const; bool tryGetProperty(const String8& key, int32_t& outValue) const; bool tryGetProperty(const String8& key, float& outValue) const; /* Adds all values from the specified property map. */ void addAll(const PropertyMap* map); /* Gets the underlying property map. */ inline const KeyedVector& getProperties() const { return mProperties; } /* Loads a property map from a file. */ static status_t load(const String8& filename, PropertyMap** outMap); private: class Parser { PropertyMap* mMap; Tokenizer* mTokenizer; public: Parser(PropertyMap* map, Tokenizer* tokenizer); ~Parser(); status_t parse(); private: status_t parseType(); status_t parseKey(); status_t parseKeyProperty(); status_t parseModifier(const String8& token, int32_t* outMetaState); status_t parseCharacterLiteral(char16_t* outCharacter); }; KeyedVector mProperties; }; } // namespace android #endif // _UTILS_PROPERTY_MAP_H ================================================ FILE: phonelibs/android_system_core/include/utils/RWLock.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_RWLOCK_H #define _LIBS_UTILS_RWLOCK_H #include #include #if !defined(_WIN32) # include #endif #include #include // --------------------------------------------------------------------------- namespace android { // --------------------------------------------------------------------------- #if !defined(_WIN32) /* * Simple mutex class. The implementation is system-dependent. * * The mutex must be unlocked by the thread that locked it. They are not * recursive, i.e. the same thread can't lock it multiple times. */ class RWLock { public: enum { PRIVATE = 0, SHARED = 1 }; RWLock(); RWLock(const char* name); RWLock(int type, const char* name = NULL); ~RWLock(); status_t readLock(); status_t tryReadLock(); status_t writeLock(); status_t tryWriteLock(); void unlock(); class AutoRLock { public: inline AutoRLock(RWLock& rwlock) : mLock(rwlock) { mLock.readLock(); } inline ~AutoRLock() { mLock.unlock(); } private: RWLock& mLock; }; class AutoWLock { public: inline AutoWLock(RWLock& rwlock) : mLock(rwlock) { mLock.writeLock(); } inline ~AutoWLock() { mLock.unlock(); } private: RWLock& mLock; }; private: // A RWLock cannot be copied RWLock(const RWLock&); RWLock& operator = (const RWLock&); pthread_rwlock_t mRWLock; }; inline RWLock::RWLock() { pthread_rwlock_init(&mRWLock, NULL); } inline RWLock::RWLock(__attribute__((unused)) const char* name) { pthread_rwlock_init(&mRWLock, NULL); } inline RWLock::RWLock(int type, __attribute__((unused)) const char* name) { if (type == SHARED) { pthread_rwlockattr_t attr; pthread_rwlockattr_init(&attr); pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); pthread_rwlock_init(&mRWLock, &attr); pthread_rwlockattr_destroy(&attr); } else { pthread_rwlock_init(&mRWLock, NULL); } } inline RWLock::~RWLock() { pthread_rwlock_destroy(&mRWLock); } inline status_t RWLock::readLock() { return -pthread_rwlock_rdlock(&mRWLock); } inline status_t RWLock::tryReadLock() { return -pthread_rwlock_tryrdlock(&mRWLock); } inline status_t RWLock::writeLock() { return -pthread_rwlock_wrlock(&mRWLock); } inline status_t RWLock::tryWriteLock() { return -pthread_rwlock_trywrlock(&mRWLock); } inline void RWLock::unlock() { pthread_rwlock_unlock(&mRWLock); } #endif // !defined(_WIN32) // --------------------------------------------------------------------------- }; // namespace android // --------------------------------------------------------------------------- #endif // _LIBS_UTILS_RWLOCK_H ================================================ FILE: phonelibs/android_system_core/include/utils/RefBase.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_REF_BASE_H #define ANDROID_REF_BASE_H #include #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { class TextOutput; TextOutput& printWeakPointer(TextOutput& to, const void* val); // --------------------------------------------------------------------------- #define COMPARE_WEAK(_op_) \ inline bool operator _op_ (const sp& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ inline bool operator _op_ (const T* o) const { \ return m_ptr _op_ o; \ } \ template \ inline bool operator _op_ (const sp& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template \ inline bool operator _op_ (const U* o) const { \ return m_ptr _op_ o; \ } // --------------------------------------------------------------------------- class ReferenceRenamer { protected: // destructor is purposedly not virtual so we avoid code overhead from // subclasses; we have to make it protected to guarantee that it // cannot be called from this base class (and to make strict compilers // happy). ~ReferenceRenamer() { } public: virtual void operator()(size_t i) const = 0; }; // --------------------------------------------------------------------------- class RefBase { public: void incStrong(const void* id) const; void decStrong(const void* id) const; void forceIncStrong(const void* id) const; //! DEBUGGING ONLY: Get current strong ref count. int32_t getStrongCount() const; class weakref_type { public: RefBase* refBase() const; void incWeak(const void* id); void decWeak(const void* id); // acquires a strong reference if there is already one. bool attemptIncStrong(const void* id); // acquires a weak reference if there is already one. // This is not always safe. see ProcessState.cpp and BpBinder.cpp // for proper use. bool attemptIncWeak(const void* id); //! DEBUGGING ONLY: Get current weak ref count. int32_t getWeakCount() const; //! DEBUGGING ONLY: Print references held on object. void printRefs() const; //! DEBUGGING ONLY: Enable tracking for this object. // enable -- enable/disable tracking // retain -- when tracking is enable, if true, then we save a stack trace // for each reference and dereference; when retain == false, we // match up references and dereferences and keep only the // outstanding ones. void trackMe(bool enable, bool retain); }; weakref_type* createWeak(const void* id) const; weakref_type* getWeakRefs() const; //! DEBUGGING ONLY: Print references held on object. inline void printRefs() const { getWeakRefs()->printRefs(); } //! DEBUGGING ONLY: Enable tracking of object. inline void trackMe(bool enable, bool retain) { getWeakRefs()->trackMe(enable, retain); } typedef RefBase basetype; protected: RefBase(); virtual ~RefBase(); //! Flags for extendObjectLifetime() enum { OBJECT_LIFETIME_STRONG = 0x0000, OBJECT_LIFETIME_WEAK = 0x0001, OBJECT_LIFETIME_MASK = 0x0001 }; void extendObjectLifetime(int32_t mode); //! Flags for onIncStrongAttempted() enum { FIRST_INC_STRONG = 0x0001 }; virtual void onFirstRef(); virtual void onLastStrongRef(const void* id); virtual bool onIncStrongAttempted(uint32_t flags, const void* id); virtual void onLastWeakRef(const void* id); private: friend class weakref_type; class weakref_impl; RefBase(const RefBase& o); RefBase& operator=(const RefBase& o); private: friend class ReferenceMover; static void renameRefs(size_t n, const ReferenceRenamer& renamer); static void renameRefId(weakref_type* ref, const void* old_id, const void* new_id); static void renameRefId(RefBase* ref, const void* old_id, const void* new_id); weakref_impl* const mRefs; }; // --------------------------------------------------------------------------- template class LightRefBase { public: inline LightRefBase() : mCount(0) { } inline void incStrong(__attribute__((unused)) const void* id) const { android_atomic_inc(&mCount); } inline void decStrong(__attribute__((unused)) const void* id) const { if (android_atomic_dec(&mCount) == 1) { delete static_cast(this); } } //! DEBUGGING ONLY: Get current strong ref count. inline int32_t getStrongCount() const { return mCount; } typedef LightRefBase basetype; protected: inline ~LightRefBase() { } private: friend class ReferenceMover; inline static void renameRefs(size_t n, const ReferenceRenamer& renamer) { } inline static void renameRefId(T* ref, const void* old_id, const void* new_id) { } private: mutable volatile int32_t mCount; }; // This is a wrapper around LightRefBase that simply enforces a virtual // destructor to eliminate the template requirement of LightRefBase class VirtualLightRefBase : public LightRefBase { public: virtual ~VirtualLightRefBase() {} }; // --------------------------------------------------------------------------- template class wp { public: typedef typename RefBase::weakref_type weakref_type; inline wp() : m_ptr(0) { } wp(T* other); wp(const wp& other); wp(const sp& other); template wp(U* other); template wp(const sp& other); template wp(const wp& other); ~wp(); // Assignment wp& operator = (T* other); wp& operator = (const wp& other); wp& operator = (const sp& other); template wp& operator = (U* other); template wp& operator = (const wp& other); template wp& operator = (const sp& other); void set_object_and_refs(T* other, weakref_type* refs); // promotion to sp sp promote() const; // Reset void clear(); // Accessors inline weakref_type* get_refs() const { return m_refs; } inline T* unsafe_get() const { return m_ptr; } // Operators COMPARE_WEAK(==) COMPARE_WEAK(!=) COMPARE_WEAK(>) COMPARE_WEAK(<) COMPARE_WEAK(<=) COMPARE_WEAK(>=) inline bool operator == (const wp& o) const { return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); } template inline bool operator == (const wp& o) const { return m_ptr == o.m_ptr; } inline bool operator > (const wp& o) const { return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); } template inline bool operator > (const wp& o) const { return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); } inline bool operator < (const wp& o) const { return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); } template inline bool operator < (const wp& o) const { return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); } inline bool operator != (const wp& o) const { return m_refs != o.m_refs; } template inline bool operator != (const wp& o) const { return !operator == (o); } inline bool operator <= (const wp& o) const { return !operator > (o); } template inline bool operator <= (const wp& o) const { return !operator > (o); } inline bool operator >= (const wp& o) const { return !operator < (o); } template inline bool operator >= (const wp& o) const { return !operator < (o); } private: template friend class sp; template friend class wp; T* m_ptr; weakref_type* m_refs; }; template TextOutput& operator<<(TextOutput& to, const wp& val); #undef COMPARE_WEAK // --------------------------------------------------------------------------- // No user serviceable parts below here. template wp::wp(T* other) : m_ptr(other) { if (other) m_refs = other->createWeak(this); } template wp::wp(const wp& other) : m_ptr(other.m_ptr), m_refs(other.m_refs) { if (m_ptr) m_refs->incWeak(this); } template wp::wp(const sp& other) : m_ptr(other.m_ptr) { if (m_ptr) { m_refs = m_ptr->createWeak(this); } } template template wp::wp(U* other) : m_ptr(other) { if (other) m_refs = other->createWeak(this); } template template wp::wp(const wp& other) : m_ptr(other.m_ptr) { if (m_ptr) { m_refs = other.m_refs; m_refs->incWeak(this); } } template template wp::wp(const sp& other) : m_ptr(other.m_ptr) { if (m_ptr) { m_refs = m_ptr->createWeak(this); } } template wp::~wp() { if (m_ptr) m_refs->decWeak(this); } template wp& wp::operator = (T* other) { weakref_type* newRefs = other ? other->createWeak(this) : 0; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } template wp& wp::operator = (const wp& other) { weakref_type* otherRefs(other.m_refs); T* otherPtr(other.m_ptr); if (otherPtr) otherRefs->incWeak(this); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; m_refs = otherRefs; return *this; } template wp& wp::operator = (const sp& other) { weakref_type* newRefs = other != NULL ? other->createWeak(this) : 0; T* otherPtr(other.m_ptr); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; m_refs = newRefs; return *this; } template template wp& wp::operator = (U* other) { weakref_type* newRefs = other ? other->createWeak(this) : 0; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } template template wp& wp::operator = (const wp& other) { weakref_type* otherRefs(other.m_refs); U* otherPtr(other.m_ptr); if (otherPtr) otherRefs->incWeak(this); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; m_refs = otherRefs; return *this; } template template wp& wp::operator = (const sp& other) { weakref_type* newRefs = other != NULL ? other->createWeak(this) : 0; U* otherPtr(other.m_ptr); if (m_ptr) m_refs->decWeak(this); m_ptr = otherPtr; m_refs = newRefs; return *this; } template void wp::set_object_and_refs(T* other, weakref_type* refs) { if (other) refs->incWeak(this); if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = refs; } template sp wp::promote() const { sp result; if (m_ptr && m_refs->attemptIncStrong(&result)) { result.set_pointer(m_ptr); } return result; } template void wp::clear() { if (m_ptr) { m_refs->decWeak(this); m_ptr = 0; } } template inline TextOutput& operator<<(TextOutput& to, const wp& val) { return printWeakPointer(to, val.unsafe_get()); } // --------------------------------------------------------------------------- // this class just serves as a namespace so TYPE::moveReferences can stay // private. class ReferenceMover { public: // it would be nice if we could make sure no extra code is generated // for sp or wp when TYPE is a descendant of RefBase: // Using a sp override doesn't work; it's a bit like we wanted // a template template... template static inline void move_references(sp* d, sp const* s, size_t n) { class Renamer : public ReferenceRenamer { sp* d; sp const* s; virtual void operator()(size_t i) const { // The id are known to be the sp<>'s this pointer TYPE::renameRefId(d[i].get(), &s[i], &d[i]); } public: Renamer(sp* d, sp const* s) : d(d), s(s) { } virtual ~Renamer() { } }; memmove(d, s, n*sizeof(sp)); TYPE::renameRefs(n, Renamer(d, s)); } template static inline void move_references(wp* d, wp const* s, size_t n) { class Renamer : public ReferenceRenamer { wp* d; wp const* s; virtual void operator()(size_t i) const { // The id are known to be the wp<>'s this pointer TYPE::renameRefId(d[i].get_refs(), &s[i], &d[i]); } public: Renamer(wp* d, wp const* s) : d(d), s(s) { } virtual ~Renamer() { } }; memmove(d, s, n*sizeof(wp)); TYPE::renameRefs(n, Renamer(d, s)); } }; // specialization for moving sp<> and wp<> types. // these are used by the [Sorted|Keyed]Vector<> implementations // sp<> and wp<> need to be handled specially, because they do not // have trivial copy operation in the general case (see RefBase.cpp // when DEBUG ops are enabled), but can be implemented very // efficiently in most cases. template inline void move_forward_type(sp* d, sp const* s, size_t n) { ReferenceMover::move_references(d, s, n); } template inline void move_backward_type(sp* d, sp const* s, size_t n) { ReferenceMover::move_references(d, s, n); } template inline void move_forward_type(wp* d, wp const* s, size_t n) { ReferenceMover::move_references(d, s, n); } template inline void move_backward_type(wp* d, wp const* s, size_t n) { ReferenceMover::move_references(d, s, n); } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_REF_BASE_H ================================================ FILE: phonelibs/android_system_core/include/utils/SharedBuffer.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_SHARED_BUFFER_H #define ANDROID_SHARED_BUFFER_H #include #include // --------------------------------------------------------------------------- namespace android { class SharedBuffer { public: /* flags to use with release() */ enum { eKeepStorage = 0x00000001 }; /*! allocate a buffer of size 'size' and acquire() it. * call release() to free it. */ static SharedBuffer* alloc(size_t size); /*! free the memory associated with the SharedBuffer. * Fails if there are any users associated with this SharedBuffer. * In other words, the buffer must have been release by all its * users. */ static ssize_t dealloc(const SharedBuffer* released); //! access the data for read inline const void* data() const; //! access the data for read/write inline void* data(); //! get size of the buffer inline size_t size() const; //! get back a SharedBuffer object from its data static inline SharedBuffer* bufferFromData(void* data); //! get back a SharedBuffer object from its data static inline const SharedBuffer* bufferFromData(const void* data); //! get the size of a SharedBuffer object from its data static inline size_t sizeFromData(const void* data); //! edit the buffer (get a writtable, or non-const, version of it) SharedBuffer* edit() const; //! edit the buffer, resizing if needed SharedBuffer* editResize(size_t size) const; //! like edit() but fails if a copy is required SharedBuffer* attemptEdit() const; //! resize and edit the buffer, loose it's content. SharedBuffer* reset(size_t size) const; //! acquire/release a reference on this buffer void acquire() const; /*! release a reference on this buffer, with the option of not * freeing the memory associated with it if it was the last reference * returns the previous reference count */ int32_t release(uint32_t flags = 0) const; //! returns wether or not we're the only owner inline bool onlyOwner() const; private: inline SharedBuffer() { } inline ~SharedBuffer() { } SharedBuffer(const SharedBuffer&); SharedBuffer& operator = (const SharedBuffer&); // 16 bytes. must be sized to preserve correct alignment. mutable int32_t mRefs; size_t mSize; uint32_t mReserved[2]; }; // --------------------------------------------------------------------------- const void* SharedBuffer::data() const { return this + 1; } void* SharedBuffer::data() { return this + 1; } size_t SharedBuffer::size() const { return mSize; } SharedBuffer* SharedBuffer::bufferFromData(void* data) { return data ? static_cast(data)-1 : 0; } const SharedBuffer* SharedBuffer::bufferFromData(const void* data) { return data ? static_cast(data)-1 : 0; } size_t SharedBuffer::sizeFromData(const void* data) { return data ? bufferFromData(data)->mSize : 0; } bool SharedBuffer::onlyOwner() const { return (mRefs == 1); } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_VECTOR_H ================================================ FILE: phonelibs/android_system_core/include/utils/Singleton.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UTILS_SINGLETON_H #define ANDROID_UTILS_SINGLETON_H #include #include #include #include namespace android { // --------------------------------------------------------------------------- template class ANDROID_API Singleton { public: static TYPE& getInstance() { Mutex::Autolock _l(sLock); TYPE* instance = sInstance; if (instance == 0) { instance = new TYPE(); sInstance = instance; } return *instance; } static bool hasInstance() { Mutex::Autolock _l(sLock); return sInstance != 0; } protected: ~Singleton() { }; Singleton() { }; private: Singleton(const Singleton&); Singleton& operator = (const Singleton&); static Mutex sLock; static TYPE* sInstance; }; /* * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file * (eg: .cpp) to create the static instance of Singleton<>'s attributes, * and avoid to have a copy of them in each compilation units Singleton * is used. * NOTE: we use a version of Mutex ctor that takes a parameter, because * for some unknown reason using the default ctor doesn't emit the variable! */ #define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ template<> ::android::Mutex \ (::android::Singleton< TYPE >::sLock)(::android::Mutex::PRIVATE); \ template<> TYPE* ::android::Singleton< TYPE >::sInstance(0); \ template class ::android::Singleton< TYPE >; // --------------------------------------------------------------------------- }; // namespace android #endif // ANDROID_UTILS_SINGLETON_H ================================================ FILE: phonelibs/android_system_core/include/utils/SortedVector.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_SORTED_VECTOR_H #define ANDROID_SORTED_VECTOR_H #include #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { template class SortedVector : private SortedVectorImpl { friend class Vector; public: typedef TYPE value_type; /*! * Constructors and destructors */ SortedVector(); SortedVector(const SortedVector& rhs); virtual ~SortedVector(); /*! copy operator */ const SortedVector& operator = (const SortedVector& rhs) const; SortedVector& operator = (const SortedVector& rhs); /* * empty the vector */ inline void clear() { VectorImpl::clear(); } /*! * vector stats */ //! returns number of items in the vector inline size_t size() const { return VectorImpl::size(); } //! returns whether or not the vector is empty inline bool isEmpty() const { return VectorImpl::isEmpty(); } //! returns how many items can be stored without reallocating the backing store inline size_t capacity() const { return VectorImpl::capacity(); } //! sets the capacity. capacity can never be reduced less than size() inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } /*! * C-style array access */ //! read-only C-style access inline const TYPE* array() const; //! read-write C-style access. BE VERY CAREFUL when modifying the array //! you must keep it sorted! You usually don't use this function. TYPE* editArray(); //! finds the index of an item ssize_t indexOf(const TYPE& item) const; //! finds where this item should be inserted size_t orderOf(const TYPE& item) const; /*! * accessors */ //! read-only access to an item at a given index inline const TYPE& operator [] (size_t index) const; //! alternate name for operator [] inline const TYPE& itemAt(size_t index) const; //! stack-usage of the vector. returns the top of the stack (last element) const TYPE& top() const; /*! * modifying the array */ //! add an item in the right place (and replace the one that is there) ssize_t add(const TYPE& item); //! editItemAt() MUST NOT change the order of this item TYPE& editItemAt(size_t index) { return *( static_cast(VectorImpl::editItemLocation(index)) ); } //! merges a vector into this one ssize_t merge(const Vector& vector); ssize_t merge(const SortedVector& vector); //! removes an item ssize_t remove(const TYPE&); //! remove several items inline ssize_t removeItemsAt(size_t index, size_t count = 1); //! remove one item inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } protected: virtual void do_construct(void* storage, size_t num) const; virtual void do_destroy(void* storage, size_t num) const; virtual void do_copy(void* dest, const void* from, size_t num) const; virtual void do_splat(void* dest, const void* item, size_t num) const; virtual void do_move_forward(void* dest, const void* from, size_t num) const; virtual void do_move_backward(void* dest, const void* from, size_t num) const; virtual int do_compare(const void* lhs, const void* rhs) const; }; // SortedVector can be trivially moved using memcpy() because moving does not // require any change to the underlying SharedBuffer contents or reference count. template struct trait_trivial_move > { enum { value = true }; }; // --------------------------------------------------------------------------- // No user serviceable parts from here... // --------------------------------------------------------------------------- template inline SortedVector::SortedVector() : SortedVectorImpl(sizeof(TYPE), ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) ) { } template inline SortedVector::SortedVector(const SortedVector& rhs) : SortedVectorImpl(rhs) { } template inline SortedVector::~SortedVector() { finish_vector(); } template inline SortedVector& SortedVector::operator = (const SortedVector& rhs) { SortedVectorImpl::operator = (rhs); return *this; } template inline const SortedVector& SortedVector::operator = (const SortedVector& rhs) const { SortedVectorImpl::operator = (rhs); return *this; } template inline const TYPE* SortedVector::array() const { return static_cast(arrayImpl()); } template inline TYPE* SortedVector::editArray() { return static_cast(editArrayImpl()); } template inline const TYPE& SortedVector::operator[](size_t index) const { LOG_FATAL_IF(index>=size(), "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, int(index), int(size())); return *(array() + index); } template inline const TYPE& SortedVector::itemAt(size_t index) const { return operator[](index); } template inline const TYPE& SortedVector::top() const { return *(array() + size() - 1); } template inline ssize_t SortedVector::add(const TYPE& item) { return SortedVectorImpl::add(&item); } template inline ssize_t SortedVector::indexOf(const TYPE& item) const { return SortedVectorImpl::indexOf(&item); } template inline size_t SortedVector::orderOf(const TYPE& item) const { return SortedVectorImpl::orderOf(&item); } template inline ssize_t SortedVector::merge(const Vector& vector) { return SortedVectorImpl::merge(reinterpret_cast(vector)); } template inline ssize_t SortedVector::merge(const SortedVector& vector) { return SortedVectorImpl::merge(reinterpret_cast(vector)); } template inline ssize_t SortedVector::remove(const TYPE& item) { return SortedVectorImpl::remove(&item); } template inline ssize_t SortedVector::removeItemsAt(size_t index, size_t count) { return VectorImpl::removeItemsAt(index, count); } // --------------------------------------------------------------------------- template void SortedVector::do_construct(void* storage, size_t num) const { construct_type( reinterpret_cast(storage), num ); } template void SortedVector::do_destroy(void* storage, size_t num) const { destroy_type( reinterpret_cast(storage), num ); } template void SortedVector::do_copy(void* dest, const void* from, size_t num) const { copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); } template void SortedVector::do_splat(void* dest, const void* item, size_t num) const { splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); } template void SortedVector::do_move_forward(void* dest, const void* from, size_t num) const { move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); } template void SortedVector::do_move_backward(void* dest, const void* from, size_t num) const { move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); } template int SortedVector::do_compare(const void* lhs, const void* rhs) const { return compare_type( *reinterpret_cast(lhs), *reinterpret_cast(rhs) ); } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_SORTED_VECTOR_H ================================================ FILE: phonelibs/android_system_core/include/utils/StopWatch.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_STOPWATCH_H #define ANDROID_STOPWATCH_H #include #include #include // --------------------------------------------------------------------------- namespace android { class StopWatch { public: StopWatch( const char *name, int clock = SYSTEM_TIME_MONOTONIC, uint32_t flags = 0); ~StopWatch(); const char* name() const; nsecs_t lap(); nsecs_t elapsedTime() const; void reset(); private: const char* mName; int mClock; uint32_t mFlags; struct lap_t { nsecs_t soFar; nsecs_t thisLap; }; nsecs_t mStartTime; lap_t mLaps[8]; int mNumLaps; }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_STOPWATCH_H ================================================ FILE: phonelibs/android_system_core/include/utils/String16.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_STRING16_H #define ANDROID_STRING16_H #include #include #include #include // --------------------------------------------------------------------------- extern "C" { } // --------------------------------------------------------------------------- namespace android { // --------------------------------------------------------------------------- class String8; class TextOutput; //! This is a string holding UTF-16 characters. class String16 { public: /* use String16(StaticLinkage) if you're statically linking against * libutils and declaring an empty static String16, e.g.: * * static String16 sAStaticEmptyString(String16::kEmptyString); * static String16 sAnotherStaticEmptyString(sAStaticEmptyString); */ enum StaticLinkage { kEmptyString }; String16(); explicit String16(StaticLinkage); String16(const String16& o); String16(const String16& o, size_t len, size_t begin=0); explicit String16(const char16_t* o); explicit String16(const char16_t* o, size_t len); explicit String16(const String8& o); explicit String16(const char* o); explicit String16(const char* o, size_t len); ~String16(); inline const char16_t* string() const; inline size_t size() const; inline const SharedBuffer* sharedBuffer() const; void setTo(const String16& other); status_t setTo(const char16_t* other); status_t setTo(const char16_t* other, size_t len); status_t setTo(const String16& other, size_t len, size_t begin=0); status_t append(const String16& other); status_t append(const char16_t* other, size_t len); inline String16& operator=(const String16& other); inline String16& operator+=(const String16& other); inline String16 operator+(const String16& other) const; status_t insert(size_t pos, const char16_t* chrs); status_t insert(size_t pos, const char16_t* chrs, size_t len); ssize_t findFirst(char16_t c) const; ssize_t findLast(char16_t c) const; bool startsWith(const String16& prefix) const; bool startsWith(const char16_t* prefix) const; status_t makeLower(); status_t replaceAll(char16_t replaceThis, char16_t withThis); status_t remove(size_t len, size_t begin=0); inline int compare(const String16& other) const; inline bool operator<(const String16& other) const; inline bool operator<=(const String16& other) const; inline bool operator==(const String16& other) const; inline bool operator!=(const String16& other) const; inline bool operator>=(const String16& other) const; inline bool operator>(const String16& other) const; inline bool operator<(const char16_t* other) const; inline bool operator<=(const char16_t* other) const; inline bool operator==(const char16_t* other) const; inline bool operator!=(const char16_t* other) const; inline bool operator>=(const char16_t* other) const; inline bool operator>(const char16_t* other) const; inline operator const char16_t*() const; private: const char16_t* mString; }; // String16 can be trivially moved using memcpy() because moving does not // require any change to the underlying SharedBuffer contents or reference count. ANDROID_TRIVIAL_MOVE_TRAIT(String16) // --------------------------------------------------------------------------- // No user servicable parts below. inline int compare_type(const String16& lhs, const String16& rhs) { return lhs.compare(rhs); } inline int strictly_order_type(const String16& lhs, const String16& rhs) { return compare_type(lhs, rhs) < 0; } inline const char16_t* String16::string() const { return mString; } inline size_t String16::size() const { return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; } inline const SharedBuffer* String16::sharedBuffer() const { return SharedBuffer::bufferFromData(mString); } inline String16& String16::operator=(const String16& other) { setTo(other); return *this; } inline String16& String16::operator+=(const String16& other) { append(other); return *this; } inline String16 String16::operator+(const String16& other) const { String16 tmp(*this); tmp += other; return tmp; } inline int String16::compare(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()); } inline bool String16::operator<(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()) < 0; } inline bool String16::operator<=(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()) <= 0; } inline bool String16::operator==(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()) == 0; } inline bool String16::operator!=(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()) != 0; } inline bool String16::operator>=(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()) >= 0; } inline bool String16::operator>(const String16& other) const { return strzcmp16(mString, size(), other.mString, other.size()) > 0; } inline bool String16::operator<(const char16_t* other) const { return strcmp16(mString, other) < 0; } inline bool String16::operator<=(const char16_t* other) const { return strcmp16(mString, other) <= 0; } inline bool String16::operator==(const char16_t* other) const { return strcmp16(mString, other) == 0; } inline bool String16::operator!=(const char16_t* other) const { return strcmp16(mString, other) != 0; } inline bool String16::operator>=(const char16_t* other) const { return strcmp16(mString, other) >= 0; } inline bool String16::operator>(const char16_t* other) const { return strcmp16(mString, other) > 0; } inline String16::operator const char16_t*() const { return mString; } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_STRING16_H ================================================ FILE: phonelibs/android_system_core/include/utils/String8.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_STRING8_H #define ANDROID_STRING8_H #include #include #include #include #include // for strcmp #include // --------------------------------------------------------------------------- namespace android { class String16; class TextOutput; //! This is a string holding UTF-8 characters. Does not allow the value more // than 0x10FFFF, which is not valid unicode codepoint. class String8 { public: /* use String8(StaticLinkage) if you're statically linking against * libutils and declaring an empty static String8, e.g.: * * static String8 sAStaticEmptyString(String8::kEmptyString); * static String8 sAnotherStaticEmptyString(sAStaticEmptyString); */ enum StaticLinkage { kEmptyString }; String8(); explicit String8(StaticLinkage); String8(const String8& o); explicit String8(const char* o); explicit String8(const char* o, size_t numChars); explicit String8(const String16& o); explicit String8(const char16_t* o); explicit String8(const char16_t* o, size_t numChars); explicit String8(const char32_t* o); explicit String8(const char32_t* o, size_t numChars); ~String8(); static inline const String8 empty(); static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2))); static String8 formatV(const char* fmt, va_list args); inline const char* string() const; inline size_t size() const; inline size_t length() const; inline size_t bytes() const; inline bool isEmpty() const; inline const SharedBuffer* sharedBuffer() const; void clear(); void setTo(const String8& other); status_t setTo(const char* other); status_t setTo(const char* other, size_t numChars); status_t setTo(const char16_t* other, size_t numChars); status_t setTo(const char32_t* other, size_t length); status_t append(const String8& other); status_t append(const char* other); status_t append(const char* other, size_t numChars); status_t appendFormat(const char* fmt, ...) __attribute__((format (printf, 2, 3))); status_t appendFormatV(const char* fmt, va_list args); // Note that this function takes O(N) time to calculate the value. // No cache value is stored. size_t getUtf32Length() const; int32_t getUtf32At(size_t index, size_t *next_index) const; void getUtf32(char32_t* dst) const; inline String8& operator=(const String8& other); inline String8& operator=(const char* other); inline String8& operator+=(const String8& other); inline String8 operator+(const String8& other) const; inline String8& operator+=(const char* other); inline String8 operator+(const char* other) const; inline int compare(const String8& other) const; inline bool operator<(const String8& other) const; inline bool operator<=(const String8& other) const; inline bool operator==(const String8& other) const; inline bool operator!=(const String8& other) const; inline bool operator>=(const String8& other) const; inline bool operator>(const String8& other) const; inline bool operator<(const char* other) const; inline bool operator<=(const char* other) const; inline bool operator==(const char* other) const; inline bool operator!=(const char* other) const; inline bool operator>=(const char* other) const; inline bool operator>(const char* other) const; inline operator const char*() const; char* lockBuffer(size_t size); void unlockBuffer(); status_t unlockBuffer(size_t size); // return the index of the first byte of other in this at or after // start, or -1 if not found ssize_t find(const char* other, size_t start = 0) const; // return true if this string contains the specified substring inline bool contains(const char* other) const; // removes all occurrence of the specified substring // returns true if any were found and removed bool removeAll(const char* other); void toLower(); void toLower(size_t start, size_t numChars); void toUpper(); void toUpper(size_t start, size_t numChars); /* * These methods operate on the string as if it were a path name. */ /* * Set the filename field to a specific value. * * Normalizes the filename, removing a trailing '/' if present. */ void setPathName(const char* name); void setPathName(const char* name, size_t numChars); /* * Get just the filename component. * * "/tmp/foo/bar.c" --> "bar.c" */ String8 getPathLeaf(void) const; /* * Remove the last (file name) component, leaving just the directory * name. * * "/tmp/foo/bar.c" --> "/tmp/foo" * "/tmp" --> "" // ????? shouldn't this be "/" ???? XXX * "bar.c" --> "" */ String8 getPathDir(void) const; /* * Retrieve the front (root dir) component. Optionally also return the * remaining components. * * "/tmp/foo/bar.c" --> "tmp" (remain = "foo/bar.c") * "/tmp" --> "tmp" (remain = "") * "bar.c" --> "bar.c" (remain = "") */ String8 walkPath(String8* outRemains = NULL) const; /* * Return the filename extension. This is the last '.' and any number * of characters that follow it. The '.' is included in case we * decide to expand our definition of what constitutes an extension. * * "/tmp/foo/bar.c" --> ".c" * "/tmp" --> "" * "/tmp/foo.bar/baz" --> "" * "foo.jpeg" --> ".jpeg" * "foo." --> "" */ String8 getPathExtension(void) const; /* * Return the path without the extension. Rules for what constitutes * an extension are described in the comment for getPathExtension(). * * "/tmp/foo/bar.c" --> "/tmp/foo/bar" */ String8 getBasePath(void) const; /* * Add a component to the pathname. We guarantee that there is * exactly one path separator between the old path and the new. * If there is no existing name, we just copy the new name in. * * If leaf is a fully qualified path (i.e. starts with '/', it * replaces whatever was there before. */ String8& appendPath(const char* leaf); String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); } /* * Like appendPath(), but does not affect this string. Returns a new one instead. */ String8 appendPathCopy(const char* leaf) const { String8 p(*this); p.appendPath(leaf); return p; } String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); } /* * Converts all separators in this string to /, the default path separator. * * If the default OS separator is backslash, this converts all * backslashes to slashes, in-place. Otherwise it does nothing. * Returns self. */ String8& convertToResPath(); private: status_t real_append(const char* other, size_t numChars); char* find_extension(void) const; const char* mString; }; // String8 can be trivially moved using memcpy() because moving does not // require any change to the underlying SharedBuffer contents or reference count. ANDROID_TRIVIAL_MOVE_TRAIT(String8) // --------------------------------------------------------------------------- // No user servicable parts below. inline int compare_type(const String8& lhs, const String8& rhs) { return lhs.compare(rhs); } inline int strictly_order_type(const String8& lhs, const String8& rhs) { return compare_type(lhs, rhs) < 0; } inline const String8 String8::empty() { return String8(); } inline const char* String8::string() const { return mString; } inline size_t String8::length() const { return SharedBuffer::sizeFromData(mString)-1; } inline size_t String8::size() const { return length(); } inline bool String8::isEmpty() const { return length() == 0; } inline size_t String8::bytes() const { return SharedBuffer::sizeFromData(mString)-1; } inline const SharedBuffer* String8::sharedBuffer() const { return SharedBuffer::bufferFromData(mString); } inline bool String8::contains(const char* other) const { return find(other) >= 0; } inline String8& String8::operator=(const String8& other) { setTo(other); return *this; } inline String8& String8::operator=(const char* other) { setTo(other); return *this; } inline String8& String8::operator+=(const String8& other) { append(other); return *this; } inline String8 String8::operator+(const String8& other) const { String8 tmp(*this); tmp += other; return tmp; } inline String8& String8::operator+=(const char* other) { append(other); return *this; } inline String8 String8::operator+(const char* other) const { String8 tmp(*this); tmp += other; return tmp; } inline int String8::compare(const String8& other) const { return strcmp(mString, other.mString); } inline bool String8::operator<(const String8& other) const { return strcmp(mString, other.mString) < 0; } inline bool String8::operator<=(const String8& other) const { return strcmp(mString, other.mString) <= 0; } inline bool String8::operator==(const String8& other) const { return strcmp(mString, other.mString) == 0; } inline bool String8::operator!=(const String8& other) const { return strcmp(mString, other.mString) != 0; } inline bool String8::operator>=(const String8& other) const { return strcmp(mString, other.mString) >= 0; } inline bool String8::operator>(const String8& other) const { return strcmp(mString, other.mString) > 0; } inline bool String8::operator<(const char* other) const { return strcmp(mString, other) < 0; } inline bool String8::operator<=(const char* other) const { return strcmp(mString, other) <= 0; } inline bool String8::operator==(const char* other) const { return strcmp(mString, other) == 0; } inline bool String8::operator!=(const char* other) const { return strcmp(mString, other) != 0; } inline bool String8::operator>=(const char* other) const { return strcmp(mString, other) >= 0; } inline bool String8::operator>(const char* other) const { return strcmp(mString, other) > 0; } inline String8::operator const char*() const { return mString; } } // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_STRING8_H ================================================ FILE: phonelibs/android_system_core/include/utils/StrongPointer.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_STRONG_POINTER_H #define ANDROID_STRONG_POINTER_H #include #include #include #include // --------------------------------------------------------------------------- namespace android { template class wp; // --------------------------------------------------------------------------- #define COMPARE(_op_) \ inline bool operator _op_ (const sp& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ inline bool operator _op_ (const T* o) const { \ return m_ptr _op_ o; \ } \ template \ inline bool operator _op_ (const sp& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template \ inline bool operator _op_ (const U* o) const { \ return m_ptr _op_ o; \ } \ inline bool operator _op_ (const wp& o) const { \ return m_ptr _op_ o.m_ptr; \ } \ template \ inline bool operator _op_ (const wp& o) const { \ return m_ptr _op_ o.m_ptr; \ } // --------------------------------------------------------------------------- template class sp { public: inline sp() : m_ptr(0) { } sp(T* other); sp(const sp& other); template sp(U* other); template sp(const sp& other); ~sp(); // Assignment sp& operator = (T* other); sp& operator = (const sp& other); template sp& operator = (const sp& other); template sp& operator = (U* other); //! Special optimization for use by ProcessState (and nobody else). void force_set(T* other); // Reset void clear(); // Accessors inline T& operator* () const { return *m_ptr; } inline T* operator-> () const { return m_ptr; } inline T* get() const { return m_ptr; } // Operators COMPARE(==) COMPARE(!=) COMPARE(>) COMPARE(<) COMPARE(<=) COMPARE(>=) private: template friend class sp; template friend class wp; void set_pointer(T* ptr); T* m_ptr; }; #undef COMPARE // --------------------------------------------------------------------------- // No user serviceable parts below here. template sp::sp(T* other) : m_ptr(other) { if (other) other->incStrong(this); } template sp::sp(const sp& other) : m_ptr(other.m_ptr) { if (m_ptr) m_ptr->incStrong(this); } template template sp::sp(U* other) : m_ptr(other) { if (other) ((T*) other)->incStrong(this); } template template sp::sp(const sp& other) : m_ptr(other.m_ptr) { if (m_ptr) m_ptr->incStrong(this); } template sp::~sp() { if (m_ptr) m_ptr->decStrong(this); } template sp& sp::operator =(const sp& other) { T* otherPtr(other.m_ptr); if (otherPtr) otherPtr->incStrong(this); if (m_ptr) m_ptr->decStrong(this); m_ptr = otherPtr; return *this; } template sp& sp::operator =(T* other) { if (other) other->incStrong(this); if (m_ptr) m_ptr->decStrong(this); m_ptr = other; return *this; } template template sp& sp::operator =(const sp& other) { T* otherPtr(other.m_ptr); if (otherPtr) otherPtr->incStrong(this); if (m_ptr) m_ptr->decStrong(this); m_ptr = otherPtr; return *this; } template template sp& sp::operator =(U* other) { if (other) ((T*) other)->incStrong(this); if (m_ptr) m_ptr->decStrong(this); m_ptr = other; return *this; } template void sp::force_set(T* other) { other->forceIncStrong(this); m_ptr = other; } template void sp::clear() { if (m_ptr) { m_ptr->decStrong(this); m_ptr = 0; } } template void sp::set_pointer(T* ptr) { m_ptr = ptr; } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_STRONG_POINTER_H ================================================ FILE: phonelibs/android_system_core/include/utils/SystemClock.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UTILS_SYSTEMCLOCK_H #define ANDROID_UTILS_SYSTEMCLOCK_H #include #include namespace android { int64_t uptimeMillis(); int64_t elapsedRealtime(); int64_t elapsedRealtimeNano(); }; // namespace android #endif // ANDROID_UTILS_SYSTEMCLOCK_H ================================================ FILE: phonelibs/android_system_core/include/utils/Thread.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_THREAD_H #define _LIBS_UTILS_THREAD_H #include #include #include #if !defined(_WIN32) # include #endif #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { // --------------------------------------------------------------------------- class Thread : virtual public RefBase { public: // Create a Thread object, but doesn't create or start the associated // thread. See the run() method. Thread(bool canCallJava = true); virtual ~Thread(); // Start the thread in threadLoop() which needs to be implemented. virtual status_t run( const char* name = 0, int32_t priority = PRIORITY_DEFAULT, size_t stack = 0); // Ask this object's thread to exit. This function is asynchronous, when the // function returns the thread might still be running. Of course, this // function can be called from a different thread. virtual void requestExit(); // Good place to do one-time initializations virtual status_t readyToRun(); // Call requestExit() and wait until this object's thread exits. // BE VERY CAREFUL of deadlocks. In particular, it would be silly to call // this function from this object's thread. Will return WOULD_BLOCK in // that case. status_t requestExitAndWait(); // Wait until this object's thread exits. Returns immediately if not yet running. // Do not call from this object's thread; will return WOULD_BLOCK in that case. status_t join(); // Indicates whether this thread is running or not. bool isRunning() const; #ifdef HAVE_ANDROID_OS // Return the thread's kernel ID, same as the thread itself calling gettid(), // or -1 if the thread is not running. pid_t getTid() const; #endif protected: // exitPending() returns true if requestExit() has been called. bool exitPending() const; private: // Derived class must implement threadLoop(). The thread starts its life // here. There are two ways of using the Thread object: // 1) loop: if threadLoop() returns true, it will be called again if // requestExit() wasn't called. // 2) once: if threadLoop() returns false, the thread will exit upon return. virtual bool threadLoop() = 0; private: Thread& operator=(const Thread&); static int _threadLoop(void* user); const bool mCanCallJava; // always hold mLock when reading or writing thread_id_t mThread; mutable Mutex mLock; Condition mThreadExitedCondition; status_t mStatus; // note that all accesses of mExitPending and mRunning need to hold mLock volatile bool mExitPending; volatile bool mRunning; sp mHoldSelf; #ifdef HAVE_ANDROID_OS // legacy for debugging, not used by getTid() as it is set by the child thread // and so is not initialized until the child reaches that point pid_t mTid; #endif }; }; // namespace android // --------------------------------------------------------------------------- #endif // _LIBS_UTILS_THREAD_H // --------------------------------------------------------------------------- ================================================ FILE: phonelibs/android_system_core/include/utils/ThreadDefs.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_THREAD_DEFS_H #define _LIBS_UTILS_THREAD_DEFS_H #include #include #include #include // --------------------------------------------------------------------------- // C API #ifdef __cplusplus extern "C" { #endif typedef void* android_thread_id_t; typedef int (*android_thread_func_t)(void*); #ifdef __cplusplus } // extern "C" #endif // --------------------------------------------------------------------------- // C++ API #ifdef __cplusplus namespace android { // --------------------------------------------------------------------------- typedef android_thread_id_t thread_id_t; typedef android_thread_func_t thread_func_t; enum { PRIORITY_LOWEST = ANDROID_PRIORITY_LOWEST, PRIORITY_BACKGROUND = ANDROID_PRIORITY_BACKGROUND, PRIORITY_NORMAL = ANDROID_PRIORITY_NORMAL, PRIORITY_FOREGROUND = ANDROID_PRIORITY_FOREGROUND, PRIORITY_DISPLAY = ANDROID_PRIORITY_DISPLAY, PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_URGENT_DISPLAY, PRIORITY_AUDIO = ANDROID_PRIORITY_AUDIO, PRIORITY_URGENT_AUDIO = ANDROID_PRIORITY_URGENT_AUDIO, PRIORITY_HIGHEST = ANDROID_PRIORITY_HIGHEST, PRIORITY_DEFAULT = ANDROID_PRIORITY_DEFAULT, PRIORITY_MORE_FAVORABLE = ANDROID_PRIORITY_MORE_FAVORABLE, PRIORITY_LESS_FAVORABLE = ANDROID_PRIORITY_LESS_FAVORABLE, }; // --------------------------------------------------------------------------- }; // namespace android #endif // __cplusplus // --------------------------------------------------------------------------- #endif // _LIBS_UTILS_THREAD_DEFS_H ================================================ FILE: phonelibs/android_system_core/include/utils/Timers.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Timer functions. // #ifndef _LIBS_UTILS_TIMERS_H #define _LIBS_UTILS_TIMERS_H #include #include #include #include // ------------------------------------------------------------------ // C API #ifdef __cplusplus extern "C" { #endif typedef int64_t nsecs_t; // nano-seconds static CONSTEXPR inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) { return secs*1000000000; } static CONSTEXPR inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs) { return secs*1000000; } static CONSTEXPR inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs) { return secs*1000; } static CONSTEXPR inline nsecs_t nanoseconds_to_seconds(nsecs_t secs) { return secs/1000000000; } static CONSTEXPR inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs) { return secs/1000000; } static CONSTEXPR inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs) { return secs/1000; } static CONSTEXPR inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);} static CONSTEXPR inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);} static CONSTEXPR inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);} static CONSTEXPR inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);} static CONSTEXPR inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);} static CONSTEXPR inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);} static CONSTEXPR inline nsecs_t seconds(nsecs_t v) { return s2ns(v); } static CONSTEXPR inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); } static CONSTEXPR inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); } enum { SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock SYSTEM_TIME_MONOTONIC = 1, // monotonic time since unspecified starting point SYSTEM_TIME_PROCESS = 2, // high-resolution per-process clock SYSTEM_TIME_THREAD = 3, // high-resolution per-thread clock SYSTEM_TIME_BOOTTIME = 4 // same as SYSTEM_TIME_MONOTONIC, but including CPU suspend time }; // return the system-time according to the specified clock #ifdef __cplusplus nsecs_t systemTime(int clock = SYSTEM_TIME_MONOTONIC); #else nsecs_t systemTime(int clock); #endif // def __cplusplus /** * Returns the number of milliseconds to wait between the reference time and the timeout time. * If the timeout is in the past relative to the reference time, returns 0. * If the timeout is more than INT_MAX milliseconds in the future relative to the reference time, * such as when timeoutTime == LLONG_MAX, returns -1 to indicate an infinite timeout delay. * Otherwise, returns the difference between the reference time and timeout time * rounded up to the next millisecond. */ int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime); #ifdef __cplusplus } // extern "C" #endif #endif // _LIBS_UTILS_TIMERS_H ================================================ FILE: phonelibs/android_system_core/include/utils/Tokenizer.h ================================================ /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _UTILS_TOKENIZER_H #define _UTILS_TOKENIZER_H #include #include #include #include namespace android { /** * A simple tokenizer for loading and parsing ASCII text files line by line. */ class Tokenizer { Tokenizer(const String8& filename, FileMap* fileMap, char* buffer, bool ownBuffer, size_t length); public: ~Tokenizer(); /** * Opens a file and maps it into memory. * * Returns NO_ERROR and a tokenizer for the file, if successful. * Otherwise returns an error and sets outTokenizer to NULL. */ static status_t open(const String8& filename, Tokenizer** outTokenizer); /** * Prepares to tokenize the contents of a string. * * Returns NO_ERROR and a tokenizer for the string, if successful. * Otherwise returns an error and sets outTokenizer to NULL. */ static status_t fromContents(const String8& filename, const char* contents, Tokenizer** outTokenizer); /** * Returns true if at the end of the file. */ inline bool isEof() const { return mCurrent == getEnd(); } /** * Returns true if at the end of the line or end of the file. */ inline bool isEol() const { return isEof() || *mCurrent == '\n'; } /** * Gets the name of the file. */ inline String8 getFilename() const { return mFilename; } /** * Gets a 1-based line number index for the current position. */ inline int32_t getLineNumber() const { return mLineNumber; } /** * Formats a location string consisting of the filename and current line number. * Returns a string like "MyFile.txt:33". */ String8 getLocation() const; /** * Gets the character at the current position. * Returns null at end of file. */ inline char peekChar() const { return isEof() ? '\0' : *mCurrent; } /** * Gets the remainder of the current line as a string, excluding the newline character. */ String8 peekRemainderOfLine() const; /** * Gets the character at the current position and advances past it. * Returns null at end of file. */ inline char nextChar() { return isEof() ? '\0' : *(mCurrent++); } /** * Gets the next token on this line stopping at the specified delimiters * or the end of the line whichever comes first and advances past it. * Also stops at embedded nulls. * Returns the token or an empty string if the current character is a delimiter * or is at the end of the line. */ String8 nextToken(const char* delimiters); /** * Advances to the next line. * Does nothing if already at the end of the file. */ void nextLine(); /** * Skips over the specified delimiters in the line. * Also skips embedded nulls. */ void skipDelimiters(const char* delimiters); private: Tokenizer(const Tokenizer& other); // not copyable String8 mFilename; FileMap* mFileMap; char* mBuffer; bool mOwnBuffer; size_t mLength; const char* mCurrent; int32_t mLineNumber; inline const char* getEnd() const { return mBuffer + mLength; } }; } // namespace android #endif // _UTILS_TOKENIZER_H ================================================ FILE: phonelibs/android_system_core/include/utils/Trace.h ================================================ /* * Copyright (C) 2012 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_TRACE_H #define ANDROID_TRACE_H #ifdef HAVE_ANDROID_OS #include #include #include #include #include #include #include #include #include #include // See for more ATRACE_* macros. // ATRACE_NAME traces the beginning and end of the current scope. To trace // the correct start and end times this macro should be declared first in the // scope body. #define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) // ATRACE_CALL is an ATRACE_NAME that uses the current function name. #define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) namespace android { class ScopedTrace { public: inline ScopedTrace(uint64_t tag, const char* name) : mTag(tag) { atrace_begin(mTag,name); } inline ~ScopedTrace() { atrace_end(mTag); } private: uint64_t mTag; }; }; // namespace android #else // HAVE_ANDROID_OS #define ATRACE_NAME(...) #define ATRACE_CALL() #endif // HAVE_ANDROID_OS #endif // ANDROID_TRACE_H ================================================ FILE: phonelibs/android_system_core/include/utils/TypeHelpers.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_TYPE_HELPERS_H #define ANDROID_TYPE_HELPERS_H #include #include #include #include // --------------------------------------------------------------------------- namespace android { /* * Types traits */ template struct trait_trivial_ctor { enum { value = false }; }; template struct trait_trivial_dtor { enum { value = false }; }; template struct trait_trivial_copy { enum { value = false }; }; template struct trait_trivial_move { enum { value = false }; }; template struct trait_pointer { enum { value = false }; }; template struct trait_pointer { enum { value = true }; }; template struct traits { enum { // whether this type is a pointer is_pointer = trait_pointer::value, // whether this type's constructor is a no-op has_trivial_ctor = is_pointer || trait_trivial_ctor::value, // whether this type's destructor is a no-op has_trivial_dtor = is_pointer || trait_trivial_dtor::value, // whether this type type can be copy-constructed with memcpy has_trivial_copy = is_pointer || trait_trivial_copy::value, // whether this type can be moved with memmove has_trivial_move = is_pointer || trait_trivial_move::value }; }; template struct aggregate_traits { enum { is_pointer = false, has_trivial_ctor = traits::has_trivial_ctor && traits::has_trivial_ctor, has_trivial_dtor = traits::has_trivial_dtor && traits::has_trivial_dtor, has_trivial_copy = traits::has_trivial_copy && traits::has_trivial_copy, has_trivial_move = traits::has_trivial_move && traits::has_trivial_move }; }; #define ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ template<> struct trait_trivial_ctor< T > { enum { value = true }; }; #define ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ template<> struct trait_trivial_dtor< T > { enum { value = true }; }; #define ANDROID_TRIVIAL_COPY_TRAIT( T ) \ template<> struct trait_trivial_copy< T > { enum { value = true }; }; #define ANDROID_TRIVIAL_MOVE_TRAIT( T ) \ template<> struct trait_trivial_move< T > { enum { value = true }; }; #define ANDROID_BASIC_TYPES_TRAITS( T ) \ ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ ANDROID_TRIVIAL_COPY_TRAIT( T ) \ ANDROID_TRIVIAL_MOVE_TRAIT( T ) // --------------------------------------------------------------------------- /* * basic types traits */ ANDROID_BASIC_TYPES_TRAITS( void ) ANDROID_BASIC_TYPES_TRAITS( bool ) ANDROID_BASIC_TYPES_TRAITS( char ) ANDROID_BASIC_TYPES_TRAITS( unsigned char ) ANDROID_BASIC_TYPES_TRAITS( short ) ANDROID_BASIC_TYPES_TRAITS( unsigned short ) ANDROID_BASIC_TYPES_TRAITS( int ) ANDROID_BASIC_TYPES_TRAITS( unsigned int ) ANDROID_BASIC_TYPES_TRAITS( long ) ANDROID_BASIC_TYPES_TRAITS( unsigned long ) ANDROID_BASIC_TYPES_TRAITS( long long ) ANDROID_BASIC_TYPES_TRAITS( unsigned long long ) ANDROID_BASIC_TYPES_TRAITS( float ) ANDROID_BASIC_TYPES_TRAITS( double ) // --------------------------------------------------------------------------- /* * compare and order types */ template inline int strictly_order_type(const TYPE& lhs, const TYPE& rhs) { return (lhs < rhs) ? 1 : 0; } template inline int compare_type(const TYPE& lhs, const TYPE& rhs) { return strictly_order_type(rhs, lhs) - strictly_order_type(lhs, rhs); } /* * create, destroy, copy and move types... */ template inline void construct_type(TYPE* p, size_t n) { if (!traits::has_trivial_ctor) { while (n--) { new(p++) TYPE; } } } template inline void destroy_type(TYPE* p, size_t n) { if (!traits::has_trivial_dtor) { while (n--) { p->~TYPE(); p++; } } } template inline void copy_type(TYPE* d, const TYPE* s, size_t n) { if (!traits::has_trivial_copy) { while (n--) { new(d) TYPE(*s); d++, s++; } } else { memcpy(d,s,n*sizeof(TYPE)); } } template inline void splat_type(TYPE* where, const TYPE* what, size_t n) { if (!traits::has_trivial_copy) { while (n--) { new(where) TYPE(*what); where++; } } else { while (n--) { *where++ = *what; } } } template inline void move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) { if ((traits::has_trivial_dtor && traits::has_trivial_copy) || traits::has_trivial_move) { memmove(d,s,n*sizeof(TYPE)); } else { d += n; s += n; while (n--) { --d, --s; if (!traits::has_trivial_copy) { new(d) TYPE(*s); } else { *d = *s; } if (!traits::has_trivial_dtor) { s->~TYPE(); } } } } template inline void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) { if ((traits::has_trivial_dtor && traits::has_trivial_copy) || traits::has_trivial_move) { memmove(d,s,n*sizeof(TYPE)); } else { while (n--) { if (!traits::has_trivial_copy) { new(d) TYPE(*s); } else { *d = *s; } if (!traits::has_trivial_dtor) { s->~TYPE(); } d++, s++; } } } // --------------------------------------------------------------------------- /* * a key/value pair */ template struct key_value_pair_t { typedef KEY key_t; typedef VALUE value_t; KEY key; VALUE value; key_value_pair_t() { } key_value_pair_t(const key_value_pair_t& o) : key(o.key), value(o.value) { } key_value_pair_t(const KEY& k, const VALUE& v) : key(k), value(v) { } key_value_pair_t(const KEY& k) : key(k) { } inline bool operator < (const key_value_pair_t& o) const { return strictly_order_type(key, o.key); } inline const KEY& getKey() const { return key; } inline const VALUE& getValue() const { return value; } }; template struct trait_trivial_ctor< key_value_pair_t > { enum { value = aggregate_traits::has_trivial_ctor }; }; template struct trait_trivial_dtor< key_value_pair_t > { enum { value = aggregate_traits::has_trivial_dtor }; }; template struct trait_trivial_copy< key_value_pair_t > { enum { value = aggregate_traits::has_trivial_copy }; }; template struct trait_trivial_move< key_value_pair_t > { enum { value = aggregate_traits::has_trivial_move }; }; // --------------------------------------------------------------------------- /* * Hash codes. */ typedef uint32_t hash_t; template hash_t hash_type(const TKey& key); /* Built-in hash code specializations. * Assumes pointers are 32bit. */ #define ANDROID_INT32_HASH(T) \ template <> inline hash_t hash_type(const T& value) { return hash_t(value); } #define ANDROID_INT64_HASH(T) \ template <> inline hash_t hash_type(const T& value) { \ return hash_t((value >> 32) ^ value); } #define ANDROID_REINTERPRET_HASH(T, R) \ template <> inline hash_t hash_type(const T& value) { \ return hash_type(*reinterpret_cast(&value)); } ANDROID_INT32_HASH(bool) ANDROID_INT32_HASH(int8_t) ANDROID_INT32_HASH(uint8_t) ANDROID_INT32_HASH(int16_t) ANDROID_INT32_HASH(uint16_t) ANDROID_INT32_HASH(int32_t) ANDROID_INT32_HASH(uint32_t) ANDROID_INT64_HASH(int64_t) ANDROID_INT64_HASH(uint64_t) ANDROID_REINTERPRET_HASH(float, uint32_t) ANDROID_REINTERPRET_HASH(double, uint64_t) template inline hash_t hash_type(T* const & value) { return hash_type(uintptr_t(value)); } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_TYPE_HELPERS_H ================================================ FILE: phonelibs/android_system_core/include/utils/Unicode.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_UNICODE_H #define ANDROID_UNICODE_H #include #include extern "C" { // Standard string functions on char16_t strings. int strcmp16(const char16_t *, const char16_t *); int strncmp16(const char16_t *s1, const char16_t *s2, size_t n); size_t strlen16(const char16_t *); size_t strnlen16(const char16_t *, size_t); char16_t *strcpy16(char16_t *, const char16_t *); char16_t *strncpy16(char16_t *, const char16_t *, size_t); // Version of comparison that supports embedded nulls. // This is different than strncmp() because we don't stop // at a nul character and consider the strings to be different // if the lengths are different (thus we need to supply the // lengths of both strings). This can also be used when // your string is not nul-terminated as it will have the // equivalent result as strcmp16 (unlike strncmp16). int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2); // Version of strzcmp16 for comparing strings in different endianness. int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2); // Standard string functions on char32_t strings. size_t strlen32(const char32_t *); size_t strnlen32(const char32_t *, size_t); /** * Measure the length of a UTF-32 string in UTF-8. If the string is invalid * such as containing a surrogate character, -1 will be returned. */ ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len); /** * Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not * large enough to store the string, the part of the "src" string is stored * into "dst" as much as possible. See the examples for more detail. * Returns the size actually used for storing the string. * dst" is not null-terminated when dst_len is fully used (like strncpy). * * Example 1 * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) * "src_len" == 2 * "dst_len" >= 7 * -> * Returned value == 6 * "dst" becomes \xE3\x81\x82\xE3\x81\x84\0 * (note that "dst" is null-terminated) * * Example 2 * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) * "src_len" == 2 * "dst_len" == 5 * -> * Returned value == 3 * "dst" becomes \xE3\x81\x82\0 * (note that "dst" is null-terminated, but \u3044 is not stored in "dst" * since "dst" does not have enough size to store the character) * * Example 3 * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) * "src_len" == 2 * "dst_len" == 6 * -> * Returned value == 6 * "dst" becomes \xE3\x81\x82\xE3\x81\x84 * (note that "dst" is NOT null-terminated, like strncpy) */ void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst, size_t dst_len); /** * Returns the unicode value at "index". * Returns -1 when the index is invalid (equals to or more than "src_len"). * If returned value is positive, it is able to be converted to char32_t, which * is unsigned. Then, if "next_index" is not NULL, the next index to be used is * stored in "next_index". "next_index" can be NULL. */ int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index); /** * Returns the UTF-8 length of UTF-16 string "src". */ ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len); /** * Converts a UTF-16 string to UTF-8. The destination buffer must be large * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added * NULL terminator. */ void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst, size_t dst_len); /** * Returns the length of "src" when "src" is valid UTF-8 string. * Returns 0 if src is NULL or 0-length string. Returns -1 when the source * is an invalid string. * * This function should be used to determine whether "src" is valid UTF-8 * characters with valid unicode codepoints. "src" must be null-terminated. * * If you are going to use other utf8_to_... functions defined in this header * with string which may not be valid UTF-8 with valid codepoint (form 0 to * 0x10FFFF), you should use this function before calling others, since the * other functions do not check whether the string is valid UTF-8 or not. * * If you do not care whether "src" is valid UTF-8 or not, you should use * strlen() as usual, which should be much faster. */ ssize_t utf8_length(const char *src); /** * Measure the length of a UTF-32 string. */ size_t utf8_to_utf32_length(const char *src, size_t src_len); /** * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large * enough to store the entire converted string as measured by * utf8_to_utf32_length plus space for a NULL terminator. */ void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst); /** * Returns the UTF-16 length of UTF-8 string "src". */ ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen); /** * Convert UTF-8 to UTF-16 including surrogate pairs. * Returns a pointer to the end of the string (where a null terminator might go * if you wanted to add one). */ char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst); /** * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer * must be large enough to hold the result as measured by utf8_to_utf16_length * plus an added NULL terminator. */ void utf8_to_utf16(const uint8_t* src, size_t srcLen, char16_t* dst); /** * Like utf8_to_utf16_no_null_terminator, but you can supply a maximum length of the * decoded string. The decoded string will fill up to that length; if it is longer * the returned pointer will be to the character after dstLen. */ char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen); } #endif ================================================ FILE: phonelibs/android_system_core/include/utils/Vector.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_VECTOR_H #define ANDROID_VECTOR_H #include #include #include #include #include #include // --------------------------------------------------------------------------- namespace android { template class SortedVector; /*! * The main templated vector class ensuring type safety * while making use of VectorImpl. * This is the class users want to use. */ template class Vector : private VectorImpl { public: typedef TYPE value_type; /*! * Constructors and destructors */ Vector(); Vector(const Vector& rhs); explicit Vector(const SortedVector& rhs); virtual ~Vector(); /*! copy operator */ const Vector& operator = (const Vector& rhs) const; Vector& operator = (const Vector& rhs); const Vector& operator = (const SortedVector& rhs) const; Vector& operator = (const SortedVector& rhs); /* * empty the vector */ inline void clear() { VectorImpl::clear(); } /*! * vector stats */ //! returns number of items in the vector inline size_t size() const { return VectorImpl::size(); } //! returns whether or not the vector is empty inline bool isEmpty() const { return VectorImpl::isEmpty(); } //! returns how many items can be stored without reallocating the backing store inline size_t capacity() const { return VectorImpl::capacity(); } //! sets the capacity. capacity can never be reduced less than size() inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } /*! * set the size of the vector. items are appended with the default * constructor, or removed from the end as needed. */ inline ssize_t resize(size_t size) { return VectorImpl::resize(size); } /*! * C-style array access */ //! read-only C-style access inline const TYPE* array() const; //! read-write C-style access TYPE* editArray(); /*! * accessors */ //! read-only access to an item at a given index inline const TYPE& operator [] (size_t index) const; //! alternate name for operator [] inline const TYPE& itemAt(size_t index) const; //! stack-usage of the vector. returns the top of the stack (last element) const TYPE& top() const; /*! * modifying the array */ //! copy-on write support, grants write access to an item TYPE& editItemAt(size_t index); //! grants right access to the top of the stack (last element) TYPE& editTop(); /*! * append/insert another vector */ //! insert another vector at a given index ssize_t insertVectorAt(const Vector& vector, size_t index); //! append another vector at the end of this one ssize_t appendVector(const Vector& vector); //! insert an array at a given index ssize_t insertArrayAt(const TYPE* array, size_t index, size_t length); //! append an array at the end of this vector ssize_t appendArray(const TYPE* array, size_t length); /*! * add/insert/replace items */ //! insert one or several items initialized with their default constructor inline ssize_t insertAt(size_t index, size_t numItems = 1); //! insert one or several items initialized from a prototype item ssize_t insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1); //! pop the top of the stack (removes the last element). No-op if the stack's empty inline void pop(); //! pushes an item initialized with its default constructor inline void push(); //! pushes an item on the top of the stack void push(const TYPE& item); //! same as push() but returns the index the item was added at (or an error) inline ssize_t add(); //! same as push() but returns the index the item was added at (or an error) ssize_t add(const TYPE& item); //! replace an item with a new one initialized with its default constructor inline ssize_t replaceAt(size_t index); //! replace an item with a new one ssize_t replaceAt(const TYPE& item, size_t index); /*! * remove items */ //! remove several items inline ssize_t removeItemsAt(size_t index, size_t count = 1); //! remove one item inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } /*! * sort (stable) the array */ typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs); typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state); inline status_t sort(compar_t cmp); inline status_t sort(compar_r_t cmp, void* state); // for debugging only inline size_t getItemSize() const { return itemSize(); } /* * these inlines add some level of compatibility with STL. eventually * we should probably turn things around. */ typedef TYPE* iterator; typedef TYPE const* const_iterator; inline iterator begin() { return editArray(); } inline iterator end() { return editArray() + size(); } inline const_iterator begin() const { return array(); } inline const_iterator end() const { return array() + size(); } inline void reserve(size_t n) { setCapacity(n); } inline bool empty() const{ return isEmpty(); } inline void push_back(const TYPE& item) { insertAt(item, size(), 1); } inline void push_front(const TYPE& item) { insertAt(item, 0, 1); } inline iterator erase(iterator pos) { ssize_t index = removeItemsAt(pos-array()); return begin() + index; } protected: virtual void do_construct(void* storage, size_t num) const; virtual void do_destroy(void* storage, size_t num) const; virtual void do_copy(void* dest, const void* from, size_t num) const; virtual void do_splat(void* dest, const void* item, size_t num) const; virtual void do_move_forward(void* dest, const void* from, size_t num) const; virtual void do_move_backward(void* dest, const void* from, size_t num) const; }; // Vector can be trivially moved using memcpy() because moving does not // require any change to the underlying SharedBuffer contents or reference count. template struct trait_trivial_move > { enum { value = true }; }; // --------------------------------------------------------------------------- // No user serviceable parts from here... // --------------------------------------------------------------------------- template inline Vector::Vector() : VectorImpl(sizeof(TYPE), ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) ) { } template inline Vector::Vector(const Vector& rhs) : VectorImpl(rhs) { } template inline Vector::Vector(const SortedVector& rhs) : VectorImpl(static_cast(rhs)) { } template inline Vector::~Vector() { finish_vector(); } template inline Vector& Vector::operator = (const Vector& rhs) { VectorImpl::operator = (rhs); return *this; } template inline const Vector& Vector::operator = (const Vector& rhs) const { VectorImpl::operator = (static_cast(rhs)); return *this; } template inline Vector& Vector::operator = (const SortedVector& rhs) { VectorImpl::operator = (static_cast(rhs)); return *this; } template inline const Vector& Vector::operator = (const SortedVector& rhs) const { VectorImpl::operator = (rhs); return *this; } template inline const TYPE* Vector::array() const { return static_cast(arrayImpl()); } template inline TYPE* Vector::editArray() { return static_cast(editArrayImpl()); } template inline const TYPE& Vector::operator[](size_t index) const { LOG_FATAL_IF(index>=size(), "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, int(index), int(size())); return *(array() + index); } template inline const TYPE& Vector::itemAt(size_t index) const { return operator[](index); } template inline const TYPE& Vector::top() const { return *(array() + size() - 1); } template inline TYPE& Vector::editItemAt(size_t index) { return *( static_cast(editItemLocation(index)) ); } template inline TYPE& Vector::editTop() { return *( static_cast(editItemLocation(size()-1)) ); } template inline ssize_t Vector::insertVectorAt(const Vector& vector, size_t index) { return VectorImpl::insertVectorAt(reinterpret_cast(vector), index); } template inline ssize_t Vector::appendVector(const Vector& vector) { return VectorImpl::appendVector(reinterpret_cast(vector)); } template inline ssize_t Vector::insertArrayAt(const TYPE* array, size_t index, size_t length) { return VectorImpl::insertArrayAt(array, index, length); } template inline ssize_t Vector::appendArray(const TYPE* array, size_t length) { return VectorImpl::appendArray(array, length); } template inline ssize_t Vector::insertAt(const TYPE& item, size_t index, size_t numItems) { return VectorImpl::insertAt(&item, index, numItems); } template inline void Vector::push(const TYPE& item) { return VectorImpl::push(&item); } template inline ssize_t Vector::add(const TYPE& item) { return VectorImpl::add(&item); } template inline ssize_t Vector::replaceAt(const TYPE& item, size_t index) { return VectorImpl::replaceAt(&item, index); } template inline ssize_t Vector::insertAt(size_t index, size_t numItems) { return VectorImpl::insertAt(index, numItems); } template inline void Vector::pop() { VectorImpl::pop(); } template inline void Vector::push() { VectorImpl::push(); } template inline ssize_t Vector::add() { return VectorImpl::add(); } template inline ssize_t Vector::replaceAt(size_t index) { return VectorImpl::replaceAt(index); } template inline ssize_t Vector::removeItemsAt(size_t index, size_t count) { return VectorImpl::removeItemsAt(index, count); } template inline status_t Vector::sort(Vector::compar_t cmp) { return VectorImpl::sort((VectorImpl::compar_t)cmp); } template inline status_t Vector::sort(Vector::compar_r_t cmp, void* state) { return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state); } // --------------------------------------------------------------------------- template void Vector::do_construct(void* storage, size_t num) const { construct_type( reinterpret_cast(storage), num ); } template void Vector::do_destroy(void* storage, size_t num) const { destroy_type( reinterpret_cast(storage), num ); } template void Vector::do_copy(void* dest, const void* from, size_t num) const { copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); } template void Vector::do_splat(void* dest, const void* item, size_t num) const { splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); } template void Vector::do_move_forward(void* dest, const void* from, size_t num) const { move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); } template void Vector::do_move_backward(void* dest, const void* from, size_t num) const { move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); } }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_VECTOR_H ================================================ FILE: phonelibs/android_system_core/include/utils/VectorImpl.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_VECTOR_IMPL_H #define ANDROID_VECTOR_IMPL_H #include #include #include #include // --------------------------------------------------------------------------- // No user serviceable parts in here... // --------------------------------------------------------------------------- namespace android { /*! * Implementation of the guts of the vector<> class * this ensures backward binary compatibility and * reduces code size. * For performance reasons, we expose mStorage and mCount * so these fields are set in stone. * */ class VectorImpl { public: enum { // flags passed to the ctor HAS_TRIVIAL_CTOR = 0x00000001, HAS_TRIVIAL_DTOR = 0x00000002, HAS_TRIVIAL_COPY = 0x00000004, }; VectorImpl(size_t itemSize, uint32_t flags); VectorImpl(const VectorImpl& rhs); virtual ~VectorImpl(); /*! must be called from subclasses destructor */ void finish_vector(); VectorImpl& operator = (const VectorImpl& rhs); /*! C-style array access */ inline const void* arrayImpl() const { return mStorage; } void* editArrayImpl(); /*! vector stats */ inline size_t size() const { return mCount; } inline bool isEmpty() const { return mCount == 0; } size_t capacity() const; ssize_t setCapacity(size_t size); ssize_t resize(size_t size); /*! append/insert another vector or array */ ssize_t insertVectorAt(const VectorImpl& vector, size_t index); ssize_t appendVector(const VectorImpl& vector); ssize_t insertArrayAt(const void* array, size_t index, size_t length); ssize_t appendArray(const void* array, size_t length); /*! add/insert/replace items */ ssize_t insertAt(size_t where, size_t numItems = 1); ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); void pop(); void push(); void push(const void* item); ssize_t add(); ssize_t add(const void* item); ssize_t replaceAt(size_t index); ssize_t replaceAt(const void* item, size_t index); /*! remove items */ ssize_t removeItemsAt(size_t index, size_t count = 1); void clear(); const void* itemLocation(size_t index) const; void* editItemLocation(size_t index); typedef int (*compar_t)(const void* lhs, const void* rhs); typedef int (*compar_r_t)(const void* lhs, const void* rhs, void* state); status_t sort(compar_t cmp); status_t sort(compar_r_t cmp, void* state); protected: size_t itemSize() const; void release_storage(); virtual void do_construct(void* storage, size_t num) const = 0; virtual void do_destroy(void* storage, size_t num) const = 0; virtual void do_copy(void* dest, const void* from, size_t num) const = 0; virtual void do_splat(void* dest, const void* item, size_t num) const = 0; virtual void do_move_forward(void* dest, const void* from, size_t num) const = 0; virtual void do_move_backward(void* dest, const void* from, size_t num) const = 0; private: void* _grow(size_t where, size_t amount); void _shrink(size_t where, size_t amount); inline void _do_construct(void* storage, size_t num) const; inline void _do_destroy(void* storage, size_t num) const; inline void _do_copy(void* dest, const void* from, size_t num) const; inline void _do_splat(void* dest, const void* item, size_t num) const; inline void _do_move_forward(void* dest, const void* from, size_t num) const; inline void _do_move_backward(void* dest, const void* from, size_t num) const; // These 2 fields are exposed in the inlines below, // so they're set in stone. void * mStorage; // base address of the vector size_t mCount; // number of items const uint32_t mFlags; const size_t mItemSize; }; class SortedVectorImpl : public VectorImpl { public: SortedVectorImpl(size_t itemSize, uint32_t flags); SortedVectorImpl(const VectorImpl& rhs); virtual ~SortedVectorImpl(); SortedVectorImpl& operator = (const SortedVectorImpl& rhs); //! finds the index of an item ssize_t indexOf(const void* item) const; //! finds where this item should be inserted size_t orderOf(const void* item) const; //! add an item in the right place (or replaces it if there is one) ssize_t add(const void* item); //! merges a vector into this one ssize_t merge(const VectorImpl& vector); ssize_t merge(const SortedVectorImpl& vector); //! removes an item ssize_t remove(const void* item); protected: virtual int do_compare(const void* lhs, const void* rhs) const = 0; private: ssize_t _indexOrderOf(const void* item, size_t* order = 0) const; // these are made private, because they can't be used on a SortedVector // (they don't have an implementation either) ssize_t add(); void pop(); void push(); void push(const void* item); ssize_t insertVectorAt(const VectorImpl& vector, size_t index); ssize_t appendVector(const VectorImpl& vector); ssize_t insertArrayAt(const void* array, size_t index, size_t length); ssize_t appendArray(const void* array, size_t length); ssize_t insertAt(size_t where, size_t numItems = 1); ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); ssize_t replaceAt(size_t index); ssize_t replaceAt(const void* item, size_t index); }; }; // namespace android // --------------------------------------------------------------------------- #endif // ANDROID_VECTOR_IMPL_H ================================================ FILE: phonelibs/android_system_core/include/utils/ashmem.h ================================================ /* utils/ashmem.h ** ** Copyright 2008 The Android Open Source Project ** ** This file is dual licensed. It may be redistributed and/or modified ** under the terms of the Apache 2.0 License OR version 2 of the GNU ** General Public License. */ #ifndef _UTILS_ASHMEM_H #define _UTILS_ASHMEM_H #include #include #define ASHMEM_NAME_LEN 256 #define ASHMEM_NAME_DEF "dev/ashmem" /* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ #define ASHMEM_NOT_REAPED 0 #define ASHMEM_WAS_REAPED 1 /* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ #define ASHMEM_NOW_UNPINNED 0 #define ASHMEM_NOW_PINNED 1 #define __ASHMEMIOC 0x77 #define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) #define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN]) #define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) #define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) #define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long) #define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6) #define ASHMEM_PIN _IO(__ASHMEMIOC, 7) #define ASHMEM_UNPIN _IO(__ASHMEMIOC, 8) #define ASHMEM_ISPINNED _IO(__ASHMEMIOC, 9) #define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10) #endif /* _UTILS_ASHMEM_H */ ================================================ FILE: phonelibs/android_system_core/include/utils/misc.h ================================================ /* * Copyright (C) 2005 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Handy utility functions and portability code. // #ifndef _LIBS_UTILS_MISC_H #define _LIBS_UTILS_MISC_H #include /* get #of elements in a static array */ #ifndef NELEM # define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) #endif namespace android { typedef void (*sysprop_change_callback)(void); void add_sysprop_change_callback(sysprop_change_callback cb, int priority); void report_sysprop_change(); }; // namespace android #endif // _LIBS_UTILS_MISC_H ================================================ FILE: phonelibs/android_system_core/include/utils/threads.h ================================================ /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _LIBS_UTILS_THREADS_H #define _LIBS_UTILS_THREADS_H /* * Please, DO NOT USE! * * This file is here only for legacy reasons. Instead, include directly * the headers you need below. * */ #include #ifdef __cplusplus #include #include #include #include #include #endif #endif // _LIBS_UTILS_THREADS_H ================================================ FILE: phonelibs/bzip2/LICENSE ================================================ -------------------------------------------------------------------------- This program, "bzip2", the associated library "libbzip2", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010 -------------------------------------------------------------------------- ================================================ FILE: phonelibs/bzip2/build.txt ================================================ git clone https://github.com/enthought/bzip2-1.0.6.git cd bzip2-1.0.6 git reset --hard 288acf97a15d558f96c24c89f578b724d6e06b0c make libbz2.a cp libbz2.a ../ ================================================ FILE: phonelibs/bzip2/bzlib.h ================================================ /*-------------------------------------------------------------*/ /*--- Public header file for the library. ---*/ /*--- bzlib.h ---*/ /*-------------------------------------------------------------*/ /* ------------------------------------------------------------------ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. bzip2/libbzip2 version 1.0.6 of 6 September 2010 Copyright (C) 1996-2010 Julian Seward Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. This program is released under the terms of the license contained in the file LICENSE. ------------------------------------------------------------------ */ #ifndef _BZLIB_H #define _BZLIB_H #ifdef __cplusplus extern "C" { #endif #define BZ_RUN 0 #define BZ_FLUSH 1 #define BZ_FINISH 2 #define BZ_OK 0 #define BZ_RUN_OK 1 #define BZ_FLUSH_OK 2 #define BZ_FINISH_OK 3 #define BZ_STREAM_END 4 #define BZ_SEQUENCE_ERROR (-1) #define BZ_PARAM_ERROR (-2) #define BZ_MEM_ERROR (-3) #define BZ_DATA_ERROR (-4) #define BZ_DATA_ERROR_MAGIC (-5) #define BZ_IO_ERROR (-6) #define BZ_UNEXPECTED_EOF (-7) #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) typedef struct { char *next_in; unsigned int avail_in; unsigned int total_in_lo32; unsigned int total_in_hi32; char *next_out; unsigned int avail_out; unsigned int total_out_lo32; unsigned int total_out_hi32; void *state; void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; } bz_stream; #ifndef BZ_IMPORT #define BZ_EXPORT #endif #ifndef BZ_NO_STDIO /* Need a definitition for FILE */ #include #endif #ifdef _WIN32 # include # ifdef small /* windows.h define small to char */ # undef small # endif # ifdef BZ_EXPORT # define BZ_API(func) WINAPI func # define BZ_EXTERN extern # else /* import windows dll dynamically */ # define BZ_API(func) (WINAPI * func) # define BZ_EXTERN # endif #else # define BZ_API(func) func # define BZ_EXTERN extern #endif /*-- Core (low-level) library functions --*/ BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN int BZ_API(BZ2_bzCompress) ( bz_stream* strm, int action ); BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( bz_stream* strm ); BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( bz_stream *strm, int verbosity, int small ); BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( bz_stream* strm ); BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ); /*-- High(er) level library functions --*/ #ifndef BZ_NO_STDIO #define BZ_MAX_UNUSED 5000 typedef void BZFILE; BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( int* bzerror, FILE* f, int verbosity, int small, void* unused, int nUnused ); BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( int* bzerror, BZFILE* b ); BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( int* bzerror, BZFILE* b, void** unused, int* nUnused ); BZ_EXTERN int BZ_API(BZ2_bzRead) ( int* bzerror, BZFILE* b, void* buf, int len ); BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( int* bzerror, FILE* f, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN void BZ_API(BZ2_bzWrite) ( int* bzerror, BZFILE* b, void* buf, int len ); BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( int* bzerror, BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ); BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( int* bzerror, BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); #endif /*-- Utility functions --*/ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( char* dest, unsigned int* destLen, char* source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( char* dest, unsigned int* destLen, char* source, unsigned int sourceLen, int small, int verbosity ); /*-- Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) to support better zlib compatibility. This code is not _officially_ part of libbzip2 (yet); I haven't tested it, documented it, or considered the threading-safeness of it. If this code breaks, please contact both Yoshioka and me. --*/ BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( void ); #ifndef BZ_NO_STDIO BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( const char *path, const char *mode ); BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); BZ_EXTERN int BZ_API(BZ2_bzread) ( BZFILE* b, void* buf, int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( BZFILE* b, void* buf, int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( BZFILE* b ); BZ_EXTERN void BZ_API(BZ2_bzclose) ( BZFILE* b ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( BZFILE *b, int *errnum ); #endif #ifdef __cplusplus } #endif #endif /*-------------------------------------------------------------*/ /*--- end bzlib.h ---*/ /*-------------------------------------------------------------*/ ================================================ FILE: phonelibs/json11/json11.cpp ================================================ /* Copyright (c) 2013 Dropbox, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "json11.hpp" #include #include #include #include #include namespace json11 { static const int max_depth = 200; using std::string; using std::vector; using std::map; using std::make_shared; using std::initializer_list; using std::move; /* Helper for representing null - just a do-nothing struct, plus comparison * operators so the helpers in JsonValue work. We can't use nullptr_t because * it may not be orderable. */ struct NullStruct { bool operator==(NullStruct) const { return true; } bool operator<(NullStruct) const { return false; } }; /* * * * * * * * * * * * * * * * * * * * * Serialization */ static void dump(NullStruct, string &out) { out += "null"; } static void dump(double value, string &out) { if (std::isfinite(value)) { char buf[32]; snprintf(buf, sizeof buf, "%.17g", value); out += buf; } else { out += "null"; } } static void dump(int value, string &out) { char buf[32]; snprintf(buf, sizeof buf, "%d", value); out += buf; } static void dump(bool value, string &out) { out += value ? "true" : "false"; } static void dump(const string &value, string &out) { out += '"'; for (size_t i = 0; i < value.length(); i++) { const char ch = value[i]; if (ch == '\\') { out += "\\\\"; } else if (ch == '"') { out += "\\\""; } else if (ch == '\b') { out += "\\b"; } else if (ch == '\f') { out += "\\f"; } else if (ch == '\n') { out += "\\n"; } else if (ch == '\r') { out += "\\r"; } else if (ch == '\t') { out += "\\t"; } else if (static_cast(ch) <= 0x1f) { char buf[8]; snprintf(buf, sizeof buf, "\\u%04x", ch); out += buf; } else if (static_cast(ch) == 0xe2 && static_cast(value[i+1]) == 0x80 && static_cast(value[i+2]) == 0xa8) { out += "\\u2028"; i += 2; } else if (static_cast(ch) == 0xe2 && static_cast(value[i+1]) == 0x80 && static_cast(value[i+2]) == 0xa9) { out += "\\u2029"; i += 2; } else { out += ch; } } out += '"'; } static void dump(const Json::array &values, string &out) { bool first = true; out += "["; for (const auto &value : values) { if (!first) out += ", "; value.dump(out); first = false; } out += "]"; } static void dump(const Json::object &values, string &out) { bool first = true; out += "{"; for (const auto &kv : values) { if (!first) out += ", "; dump(kv.first, out); out += ": "; kv.second.dump(out); first = false; } out += "}"; } void Json::dump(string &out) const { m_ptr->dump(out); } /* * * * * * * * * * * * * * * * * * * * * Value wrappers */ template class Value : public JsonValue { protected: // Constructors explicit Value(const T &value) : m_value(value) {} explicit Value(T &&value) : m_value(move(value)) {} // Get type tag Json::Type type() const override { return tag; } // Comparisons bool equals(const JsonValue * other) const override { return m_value == static_cast *>(other)->m_value; } bool less(const JsonValue * other) const override { return m_value < static_cast *>(other)->m_value; } const T m_value; void dump(string &out) const override { json11::dump(m_value, out); } }; class JsonDouble final : public Value { double number_value() const override { return m_value; } int int_value() const override { return static_cast(m_value); } bool equals(const JsonValue * other) const override { return m_value == other->number_value(); } bool less(const JsonValue * other) const override { return m_value < other->number_value(); } public: explicit JsonDouble(double value) : Value(value) {} }; class JsonInt final : public Value { double number_value() const override { return m_value; } int int_value() const override { return m_value; } bool equals(const JsonValue * other) const override { return m_value == other->number_value(); } bool less(const JsonValue * other) const override { return m_value < other->number_value(); } public: explicit JsonInt(int value) : Value(value) {} }; class JsonBoolean final : public Value { bool bool_value() const override { return m_value; } public: explicit JsonBoolean(bool value) : Value(value) {} }; class JsonString final : public Value { const string &string_value() const override { return m_value; } public: explicit JsonString(const string &value) : Value(value) {} explicit JsonString(string &&value) : Value(move(value)) {} }; class JsonArray final : public Value { const Json::array &array_items() const override { return m_value; } const Json & operator[](size_t i) const override; public: explicit JsonArray(const Json::array &value) : Value(value) {} explicit JsonArray(Json::array &&value) : Value(move(value)) {} }; class JsonObject final : public Value { const Json::object &object_items() const override { return m_value; } const Json & operator[](const string &key) const override; public: explicit JsonObject(const Json::object &value) : Value(value) {} explicit JsonObject(Json::object &&value) : Value(move(value)) {} }; class JsonNull final : public Value { public: JsonNull() : Value({}) {} }; /* * * * * * * * * * * * * * * * * * * * * Static globals - static-init-safe */ struct Statics { const std::shared_ptr null = make_shared(); const std::shared_ptr t = make_shared(true); const std::shared_ptr f = make_shared(false); const string empty_string; const vector empty_vector; const map empty_map; Statics() {} }; static const Statics & statics() { static const Statics s {}; return s; } static const Json & static_null() { // This has to be separate, not in Statics, because Json() accesses statics().null. static const Json json_null; return json_null; } /* * * * * * * * * * * * * * * * * * * * * Constructors */ Json::Json() noexcept : m_ptr(statics().null) {} Json::Json(std::nullptr_t) noexcept : m_ptr(statics().null) {} Json::Json(double value) : m_ptr(make_shared(value)) {} Json::Json(int value) : m_ptr(make_shared(value)) {} Json::Json(bool value) : m_ptr(value ? statics().t : statics().f) {} Json::Json(const string &value) : m_ptr(make_shared(value)) {} Json::Json(string &&value) : m_ptr(make_shared(move(value))) {} Json::Json(const char * value) : m_ptr(make_shared(value)) {} Json::Json(const Json::array &values) : m_ptr(make_shared(values)) {} Json::Json(Json::array &&values) : m_ptr(make_shared(move(values))) {} Json::Json(const Json::object &values) : m_ptr(make_shared(values)) {} Json::Json(Json::object &&values) : m_ptr(make_shared(move(values))) {} /* * * * * * * * * * * * * * * * * * * * * Accessors */ Json::Type Json::type() const { return m_ptr->type(); } double Json::number_value() const { return m_ptr->number_value(); } int Json::int_value() const { return m_ptr->int_value(); } bool Json::bool_value() const { return m_ptr->bool_value(); } const string & Json::string_value() const { return m_ptr->string_value(); } const vector & Json::array_items() const { return m_ptr->array_items(); } const map & Json::object_items() const { return m_ptr->object_items(); } const Json & Json::operator[] (size_t i) const { return (*m_ptr)[i]; } const Json & Json::operator[] (const string &key) const { return (*m_ptr)[key]; } double JsonValue::number_value() const { return 0; } int JsonValue::int_value() const { return 0; } bool JsonValue::bool_value() const { return false; } const string & JsonValue::string_value() const { return statics().empty_string; } const vector & JsonValue::array_items() const { return statics().empty_vector; } const map & JsonValue::object_items() const { return statics().empty_map; } const Json & JsonValue::operator[] (size_t) const { return static_null(); } const Json & JsonValue::operator[] (const string &) const { return static_null(); } const Json & JsonObject::operator[] (const string &key) const { auto iter = m_value.find(key); return (iter == m_value.end()) ? static_null() : iter->second; } const Json & JsonArray::operator[] (size_t i) const { if (i >= m_value.size()) return static_null(); else return m_value[i]; } /* * * * * * * * * * * * * * * * * * * * * Comparison */ bool Json::operator== (const Json &other) const { if (m_ptr->type() != other.m_ptr->type()) return false; return m_ptr->equals(other.m_ptr.get()); } bool Json::operator< (const Json &other) const { if (m_ptr->type() != other.m_ptr->type()) return m_ptr->type() < other.m_ptr->type(); return m_ptr->less(other.m_ptr.get()); } /* * * * * * * * * * * * * * * * * * * * * Parsing */ /* esc(c) * * Format char c suitable for printing in an error message. */ static inline string esc(char c) { char buf[12]; if (static_cast(c) >= 0x20 && static_cast(c) <= 0x7f) { snprintf(buf, sizeof buf, "'%c' (%d)", c, c); } else { snprintf(buf, sizeof buf, "(%d)", c); } return string(buf); } static inline bool in_range(long x, long lower, long upper) { return (x >= lower && x <= upper); } namespace { /* JsonParser * * Object that tracks all state of an in-progress parse. */ struct JsonParser final { /* State */ const string &str; size_t i; string &err; bool failed; const JsonParse strategy; /* fail(msg, err_ret = Json()) * * Mark this parse as failed. */ Json fail(string &&msg) { return fail(move(msg), Json()); } template T fail(string &&msg, const T err_ret) { if (!failed) err = std::move(msg); failed = true; return err_ret; } /* consume_whitespace() * * Advance until the current character is non-whitespace. */ void consume_whitespace() { while (str[i] == ' ' || str[i] == '\r' || str[i] == '\n' || str[i] == '\t') i++; } /* consume_comment() * * Advance comments (c-style inline and multiline). */ bool consume_comment() { bool comment_found = false; if (str[i] == '/') { i++; if (i == str.size()) return fail("unexpected end of input after start of comment", false); if (str[i] == '/') { // inline comment i++; // advance until next line, or end of input while (i < str.size() && str[i] != '\n') { i++; } comment_found = true; } else if (str[i] == '*') { // multiline comment i++; if (i > str.size()-2) return fail("unexpected end of input inside multi-line comment", false); // advance until closing tokens while (!(str[i] == '*' && str[i+1] == '/')) { i++; if (i > str.size()-2) return fail( "unexpected end of input inside multi-line comment", false); } i += 2; comment_found = true; } else return fail("malformed comment", false); } return comment_found; } /* consume_garbage() * * Advance until the current character is non-whitespace and non-comment. */ void consume_garbage() { consume_whitespace(); if(strategy == JsonParse::COMMENTS) { bool comment_found = false; do { comment_found = consume_comment(); if (failed) return; consume_whitespace(); } while(comment_found); } } /* get_next_token() * * Return the next non-whitespace character. If the end of the input is reached, * flag an error and return 0. */ char get_next_token() { consume_garbage(); if (failed) return (char)0; if (i == str.size()) return fail("unexpected end of input", (char)0); return str[i++]; } /* encode_utf8(pt, out) * * Encode pt as UTF-8 and add it to out. */ void encode_utf8(long pt, string & out) { if (pt < 0) return; if (pt < 0x80) { out += static_cast(pt); } else if (pt < 0x800) { out += static_cast((pt >> 6) | 0xC0); out += static_cast((pt & 0x3F) | 0x80); } else if (pt < 0x10000) { out += static_cast((pt >> 12) | 0xE0); out += static_cast(((pt >> 6) & 0x3F) | 0x80); out += static_cast((pt & 0x3F) | 0x80); } else { out += static_cast((pt >> 18) | 0xF0); out += static_cast(((pt >> 12) & 0x3F) | 0x80); out += static_cast(((pt >> 6) & 0x3F) | 0x80); out += static_cast((pt & 0x3F) | 0x80); } } /* parse_string() * * Parse a string, starting at the current position. */ string parse_string() { string out; long last_escaped_codepoint = -1; while (true) { if (i == str.size()) return fail("unexpected end of input in string", ""); char ch = str[i++]; if (ch == '"') { encode_utf8(last_escaped_codepoint, out); return out; } if (in_range(ch, 0, 0x1f)) return fail("unescaped " + esc(ch) + " in string", ""); // The usual case: non-escaped characters if (ch != '\\') { encode_utf8(last_escaped_codepoint, out); last_escaped_codepoint = -1; out += ch; continue; } // Handle escapes if (i == str.size()) return fail("unexpected end of input in string", ""); ch = str[i++]; if (ch == 'u') { // Extract 4-byte escape sequence string esc = str.substr(i, 4); // Explicitly check length of the substring. The following loop // relies on std::string returning the terminating NUL when // accessing str[length]. Checking here reduces brittleness. if (esc.length() < 4) { return fail("bad \\u escape: " + esc, ""); } for (size_t j = 0; j < 4; j++) { if (!in_range(esc[j], 'a', 'f') && !in_range(esc[j], 'A', 'F') && !in_range(esc[j], '0', '9')) return fail("bad \\u escape: " + esc, ""); } long codepoint = strtol(esc.data(), nullptr, 16); // JSON specifies that characters outside the BMP shall be encoded as a pair // of 4-hex-digit \u escapes encoding their surrogate pair components. Check // whether we're in the middle of such a beast: the previous codepoint was an // escaped lead (high) surrogate, and this is a trail (low) surrogate. if (in_range(last_escaped_codepoint, 0xD800, 0xDBFF) && in_range(codepoint, 0xDC00, 0xDFFF)) { // Reassemble the two surrogate pairs into one astral-plane character, per // the UTF-16 algorithm. encode_utf8((((last_escaped_codepoint - 0xD800) << 10) | (codepoint - 0xDC00)) + 0x10000, out); last_escaped_codepoint = -1; } else { encode_utf8(last_escaped_codepoint, out); last_escaped_codepoint = codepoint; } i += 4; continue; } encode_utf8(last_escaped_codepoint, out); last_escaped_codepoint = -1; if (ch == 'b') { out += '\b'; } else if (ch == 'f') { out += '\f'; } else if (ch == 'n') { out += '\n'; } else if (ch == 'r') { out += '\r'; } else if (ch == 't') { out += '\t'; } else if (ch == '"' || ch == '\\' || ch == '/') { out += ch; } else { return fail("invalid escape character " + esc(ch), ""); } } } /* parse_number() * * Parse a double. */ Json parse_number() { size_t start_pos = i; if (str[i] == '-') i++; // Integer part if (str[i] == '0') { i++; if (in_range(str[i], '0', '9')) return fail("leading 0s not permitted in numbers"); } else if (in_range(str[i], '1', '9')) { i++; while (in_range(str[i], '0', '9')) i++; } else { return fail("invalid " + esc(str[i]) + " in number"); } if (str[i] != '.' && str[i] != 'e' && str[i] != 'E' && (i - start_pos) <= static_cast(std::numeric_limits::digits10)) { return std::atoi(str.c_str() + start_pos); } // Decimal part if (str[i] == '.') { i++; if (!in_range(str[i], '0', '9')) return fail("at least one digit required in fractional part"); while (in_range(str[i], '0', '9')) i++; } // Exponent part if (str[i] == 'e' || str[i] == 'E') { i++; if (str[i] == '+' || str[i] == '-') i++; if (!in_range(str[i], '0', '9')) return fail("at least one digit required in exponent"); while (in_range(str[i], '0', '9')) i++; } return std::strtod(str.c_str() + start_pos, nullptr); } /* expect(str, res) * * Expect that 'str' starts at the character that was just read. If it does, advance * the input and return res. If not, flag an error. */ Json expect(const string &expected, Json res) { assert(i != 0); i--; if (str.compare(i, expected.length(), expected) == 0) { i += expected.length(); return res; } else { return fail("parse error: expected " + expected + ", got " + str.substr(i, expected.length())); } } /* parse_json() * * Parse a JSON object. */ Json parse_json(int depth) { if (depth > max_depth) { return fail("exceeded maximum nesting depth"); } char ch = get_next_token(); if (failed) return Json(); if (ch == '-' || (ch >= '0' && ch <= '9')) { i--; return parse_number(); } if (ch == 't') return expect("true", true); if (ch == 'f') return expect("false", false); if (ch == 'n') return expect("null", Json()); if (ch == '"') return parse_string(); if (ch == '{') { map data; ch = get_next_token(); if (ch == '}') return data; while (1) { if (ch != '"') return fail("expected '\"' in object, got " + esc(ch)); string key = parse_string(); if (failed) return Json(); ch = get_next_token(); if (ch != ':') return fail("expected ':' in object, got " + esc(ch)); data[std::move(key)] = parse_json(depth + 1); if (failed) return Json(); ch = get_next_token(); if (ch == '}') break; if (ch != ',') return fail("expected ',' in object, got " + esc(ch)); ch = get_next_token(); } return data; } if (ch == '[') { vector data; ch = get_next_token(); if (ch == ']') return data; while (1) { i--; data.push_back(parse_json(depth + 1)); if (failed) return Json(); ch = get_next_token(); if (ch == ']') break; if (ch != ',') return fail("expected ',' in list, got " + esc(ch)); ch = get_next_token(); (void)ch; } return data; } return fail("expected value, got " + esc(ch)); } }; }//namespace { Json Json::parse(const string &in, string &err, JsonParse strategy) { JsonParser parser { in, 0, err, false, strategy }; Json result = parser.parse_json(0); // Check for any trailing garbage parser.consume_garbage(); if (parser.failed) return Json(); if (parser.i != in.size()) return parser.fail("unexpected trailing " + esc(in[parser.i])); return result; } // Documented in json11.hpp vector Json::parse_multi(const string &in, std::string::size_type &parser_stop_pos, string &err, JsonParse strategy) { JsonParser parser { in, 0, err, false, strategy }; parser_stop_pos = 0; vector json_vec; while (parser.i != in.size() && !parser.failed) { json_vec.push_back(parser.parse_json(0)); if (parser.failed) break; // Check for another object parser.consume_garbage(); if (parser.failed) break; parser_stop_pos = parser.i; } return json_vec; } /* * * * * * * * * * * * * * * * * * * * * Shape-checking */ bool Json::has_shape(const shape & types, string & err) const { if (!is_object()) { err = "expected JSON object, got " + dump(); return false; } for (auto & item : types) { if ((*this)[item.first].type() != item.second) { err = "bad type for " + item.first + " in " + dump(); return false; } } return true; } } // namespace json11 ================================================ FILE: phonelibs/json11/json11.hpp ================================================ /* json11 * * json11 is a tiny JSON library for C++11, providing JSON parsing and serialization. * * The core object provided by the library is json11::Json. A Json object represents any JSON * value: null, bool, number (int or double), string (std::string), array (std::vector), or * object (std::map). * * Json objects act like values: they can be assigned, copied, moved, compared for equality or * order, etc. There are also helper methods Json::dump, to serialize a Json to a string, and * Json::parse (static) to parse a std::string as a Json object. * * Internally, the various types of Json object are represented by the JsonValue class * hierarchy. * * A note on numbers - JSON specifies the syntax of number formatting but not its semantics, * so some JSON implementations distinguish between integers and floating-point numbers, while * some don't. In json11, we choose the latter. Because some JSON implementations (namely * Javascript itself) treat all numbers as the same type, distinguishing the two leads * to JSON that will be *silently* changed by a round-trip through those implementations. * Dangerous! To avoid that risk, json11 stores all numbers as double internally, but also * provides integer helpers. * * Fortunately, double-precision IEEE754 ('double') can precisely store any integer in the * range +/-2^53, which includes every 'int' on most systems. (Timestamps often use int64 * or long long to avoid the Y2038K problem; a double storing microseconds since some epoch * will be exact for +/- 275 years.) */ /* Copyright (c) 2013 Dropbox, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #pragma once #include #include #include #include #include #ifdef _MSC_VER #if _MSC_VER <= 1800 // VS 2013 #ifndef noexcept #define noexcept throw() #endif #ifndef snprintf #define snprintf _snprintf_s #endif #endif #endif namespace json11 { enum JsonParse { STANDARD, COMMENTS }; class JsonValue; class Json final { public: // Types enum Type { NUL, NUMBER, BOOL, STRING, ARRAY, OBJECT }; // Array and object typedefs typedef std::vector array; typedef std::map object; // Constructors for the various types of JSON value. Json() noexcept; // NUL Json(std::nullptr_t) noexcept; // NUL Json(double value); // NUMBER Json(int value); // NUMBER Json(bool value); // BOOL Json(const std::string &value); // STRING Json(std::string &&value); // STRING Json(const char * value); // STRING Json(const array &values); // ARRAY Json(array &&values); // ARRAY Json(const object &values); // OBJECT Json(object &&values); // OBJECT // Implicit constructor: anything with a to_json() function. template Json(const T & t) : Json(t.to_json()) {} // Implicit constructor: map-like objects (std::map, std::unordered_map, etc) template ::value && std::is_constructible::value, int>::type = 0> Json(const M & m) : Json(object(m.begin(), m.end())) {} // Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc) template ::value, int>::type = 0> Json(const V & v) : Json(array(v.begin(), v.end())) {} // This prevents Json(some_pointer) from accidentally producing a bool. Use // Json(bool(some_pointer)) if that behavior is desired. Json(void *) = delete; // Accessors Type type() const; bool is_null() const { return type() == NUL; } bool is_number() const { return type() == NUMBER; } bool is_bool() const { return type() == BOOL; } bool is_string() const { return type() == STRING; } bool is_array() const { return type() == ARRAY; } bool is_object() const { return type() == OBJECT; } // Return the enclosed value if this is a number, 0 otherwise. Note that json11 does not // distinguish between integer and non-integer numbers - number_value() and int_value() // can both be applied to a NUMBER-typed object. double number_value() const; int int_value() const; // Return the enclosed value if this is a boolean, false otherwise. bool bool_value() const; // Return the enclosed string if this is a string, "" otherwise. const std::string &string_value() const; // Return the enclosed std::vector if this is an array, or an empty vector otherwise. const array &array_items() const; // Return the enclosed std::map if this is an object, or an empty map otherwise. const object &object_items() const; // Return a reference to arr[i] if this is an array, Json() otherwise. const Json & operator[](size_t i) const; // Return a reference to obj[key] if this is an object, Json() otherwise. const Json & operator[](const std::string &key) const; // Serialize. void dump(std::string &out) const; std::string dump() const { std::string out; dump(out); return out; } // Parse. If parse fails, return Json() and assign an error message to err. static Json parse(const std::string & in, std::string & err, JsonParse strategy = JsonParse::STANDARD); static Json parse(const char * in, std::string & err, JsonParse strategy = JsonParse::STANDARD) { if (in) { return parse(std::string(in), err, strategy); } else { err = "null input"; return nullptr; } } // Parse multiple objects, concatenated or separated by whitespace static std::vector parse_multi( const std::string & in, std::string::size_type & parser_stop_pos, std::string & err, JsonParse strategy = JsonParse::STANDARD); static inline std::vector parse_multi( const std::string & in, std::string & err, JsonParse strategy = JsonParse::STANDARD) { std::string::size_type parser_stop_pos; return parse_multi(in, parser_stop_pos, err, strategy); } bool operator== (const Json &rhs) const; bool operator< (const Json &rhs) const; bool operator!= (const Json &rhs) const { return !(*this == rhs); } bool operator<= (const Json &rhs) const { return !(rhs < *this); } bool operator> (const Json &rhs) const { return (rhs < *this); } bool operator>= (const Json &rhs) const { return !(*this < rhs); } /* has_shape(types, err) * * Return true if this is a JSON object and, for each item in types, has a field of * the given type. If not, return false and set err to a descriptive message. */ typedef std::initializer_list> shape; bool has_shape(const shape & types, std::string & err) const; private: std::shared_ptr m_ptr; }; // Internal class hierarchy - JsonValue objects are not exposed to users of this API. class JsonValue { protected: friend class Json; friend class JsonInt; friend class JsonDouble; virtual Json::Type type() const = 0; virtual bool equals(const JsonValue * other) const = 0; virtual bool less(const JsonValue * other) const = 0; virtual void dump(std::string &out) const = 0; virtual double number_value() const; virtual int int_value() const; virtual bool bool_value() const; virtual const std::string &string_value() const; virtual const Json::array &array_items() const; virtual const Json &operator[](size_t i) const; virtual const Json::object &object_items() const; virtual const Json &operator[](const std::string &key) const; virtual ~JsonValue() {} }; } // namespace json11 ================================================ FILE: phonelibs/kaitai/custom_decoder.h ================================================ #ifndef KAITAI_CUSTOM_DECODER_H #define KAITAI_CUSTOM_DECODER_H #include namespace kaitai { class custom_decoder { public: virtual ~custom_decoder() {}; virtual std::string decode(std::string src) = 0; }; } #endif ================================================ FILE: phonelibs/kaitai/exceptions.h ================================================ #ifndef KAITAI_EXCEPTIONS_H #define KAITAI_EXCEPTIONS_H #include #include #include // We need to use "noexcept" in virtual destructor of our exceptions // subclasses. Different compilers have different ideas on how to // achieve that: C++98 compilers prefer `throw()`, C++11 and later // use `noexcept`. We define KS_NOEXCEPT macro for that. #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) #define KS_NOEXCEPT noexcept #else #define KS_NOEXCEPT throw() #endif namespace kaitai { /** * Common ancestor for all error originating from Kaitai Struct usage. * Stores KSY source path, pointing to an element supposedly guilty of * an error. */ class kstruct_error: public std::runtime_error { public: kstruct_error(const std::string what, const std::string src_path): std::runtime_error(src_path + ": " + what), m_src_path(src_path) { } virtual ~kstruct_error() KS_NOEXCEPT {}; protected: const std::string m_src_path; }; /** * Error that occurs when default endianness should be decided with * a switch, but nothing matches (although using endianness expression * implies that there should be some positive result). */ class undecided_endianness_error: public kstruct_error { public: undecided_endianness_error(const std::string src_path): kstruct_error("unable to decide on endianness for a type", src_path) { } virtual ~undecided_endianness_error() KS_NOEXCEPT {}; }; /** * Common ancestor for all validation failures. Stores pointer to * KaitaiStream IO object which was involved in an error. */ class validation_failed_error: public kstruct_error { public: validation_failed_error(const std::string what, kstream* io, const std::string src_path): kstruct_error("at pos " + kstream::to_string(static_cast(io->pos())) + ": validation failed: " + what, src_path), m_io(io) { } // "at pos #{io.pos}: validation failed: #{msg}" virtual ~validation_failed_error() KS_NOEXCEPT {}; protected: kstream* m_io; }; /** * Signals validation failure: we required "actual" value to be equal to * "expected", but it turned out that it's not. */ template class validation_not_equal_error: public validation_failed_error { public: validation_not_equal_error(const T& expected, const T& actual, kstream* io, const std::string src_path): validation_failed_error("not equal", io, src_path), m_expected(expected), m_actual(actual) { } // "not equal, expected #{expected.inspect}, but got #{actual.inspect}" virtual ~validation_not_equal_error() KS_NOEXCEPT {}; protected: const T& m_expected; const T& m_actual; }; /** * Signals validation failure: we required "actual" value to be greater * than or equal to "min", but it turned out that it's not. */ template class validation_less_than_error: public validation_failed_error { public: validation_less_than_error(const T& min, const T& actual, kstream* io, const std::string src_path): validation_failed_error("not in range", io, src_path), m_min(min), m_actual(actual) { } // "not in range, min #{min.inspect}, but got #{actual.inspect}" virtual ~validation_less_than_error() KS_NOEXCEPT {}; protected: const T& m_min; const T& m_actual; }; /** * Signals validation failure: we required "actual" value to be less * than or equal to "max", but it turned out that it's not. */ template class validation_greater_than_error: public validation_failed_error { public: validation_greater_than_error(const T& max, const T& actual, kstream* io, const std::string src_path): validation_failed_error("not in range", io, src_path), m_max(max), m_actual(actual) { } // "not in range, max #{max.inspect}, but got #{actual.inspect}" virtual ~validation_greater_than_error() KS_NOEXCEPT {}; protected: const T& m_max; const T& m_actual; }; /** * Signals validation failure: we required "actual" value to be from * the list, but it turned out that it's not. */ template class validation_not_any_of_error: public validation_failed_error { public: validation_not_any_of_error(const T& actual, kstream* io, const std::string src_path): validation_failed_error("not any of the list", io, src_path), m_actual(actual) { } // "not any of the list, got #{actual.inspect}" virtual ~validation_not_any_of_error() KS_NOEXCEPT {}; protected: const T& m_actual; }; /** * Signals validation failure: we required "actual" value to match * the expression, but it turned out that it doesn't. */ template class validation_expr_error: public validation_failed_error { public: validation_expr_error(const T& actual, kstream* io, const std::string src_path): validation_failed_error("not matching the expression", io, src_path), m_actual(actual) { } // "not matching the expression, got #{actual.inspect}" virtual ~validation_expr_error() KS_NOEXCEPT {}; protected: const T& m_actual; }; } #endif ================================================ FILE: phonelibs/kaitai/kaitaistream.cpp ================================================ #include #if defined(__APPLE__) #include #include #define bswap_16(x) OSSwapInt16(x) #define bswap_32(x) OSSwapInt32(x) #define bswap_64(x) OSSwapInt64(x) #define __BYTE_ORDER BYTE_ORDER #define __BIG_ENDIAN BIG_ENDIAN #define __LITTLE_ENDIAN LITTLE_ENDIAN #elif defined(_MSC_VER) // !__APPLE__ #include #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 #define __BYTE_ORDER __LITTLE_ENDIAN #define bswap_16(x) _byteswap_ushort(x) #define bswap_32(x) _byteswap_ulong(x) #define bswap_64(x) _byteswap_uint64(x) #else // !__APPLE__ or !_MSC_VER #include #include #endif #include #include #include kaitai::kstream::kstream(std::istream* io) { m_io = io; init(); } kaitai::kstream::kstream(std::string& data): m_io_str(data) { m_io = &m_io_str; init(); } void kaitai::kstream::init() { exceptions_enable(); align_to_byte(); } void kaitai::kstream::close() { // m_io->close(); } void kaitai::kstream::exceptions_enable() const { m_io->exceptions( std::istream::eofbit | std::istream::failbit | std::istream::badbit ); } // ======================================================================== // Stream positioning // ======================================================================== bool kaitai::kstream::is_eof() const { if (m_bits_left > 0) { return false; } char t; m_io->exceptions( std::istream::badbit ); m_io->get(t); if (m_io->eof()) { m_io->clear(); exceptions_enable(); return true; } else { m_io->unget(); exceptions_enable(); return false; } } void kaitai::kstream::seek(uint64_t pos) { m_io->seekg(pos); } uint64_t kaitai::kstream::pos() { return m_io->tellg(); } uint64_t kaitai::kstream::size() { std::iostream::pos_type cur_pos = m_io->tellg(); m_io->seekg(0, std::ios::end); std::iostream::pos_type len = m_io->tellg(); m_io->seekg(cur_pos); return len; } // ======================================================================== // Integer numbers // ======================================================================== // ------------------------------------------------------------------------ // Signed // ------------------------------------------------------------------------ int8_t kaitai::kstream::read_s1() { char t; m_io->get(t); return t; } // ........................................................................ // Big-endian // ........................................................................ int16_t kaitai::kstream::read_s2be() { int16_t t; m_io->read(reinterpret_cast(&t), 2); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_16(t); #endif return t; } int32_t kaitai::kstream::read_s4be() { int32_t t; m_io->read(reinterpret_cast(&t), 4); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_32(t); #endif return t; } int64_t kaitai::kstream::read_s8be() { int64_t t; m_io->read(reinterpret_cast(&t), 8); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_64(t); #endif return t; } // ........................................................................ // Little-endian // ........................................................................ int16_t kaitai::kstream::read_s2le() { int16_t t; m_io->read(reinterpret_cast(&t), 2); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_16(t); #endif return t; } int32_t kaitai::kstream::read_s4le() { int32_t t; m_io->read(reinterpret_cast(&t), 4); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_32(t); #endif return t; } int64_t kaitai::kstream::read_s8le() { int64_t t; m_io->read(reinterpret_cast(&t), 8); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_64(t); #endif return t; } // ------------------------------------------------------------------------ // Unsigned // ------------------------------------------------------------------------ uint8_t kaitai::kstream::read_u1() { char t; m_io->get(t); return t; } // ........................................................................ // Big-endian // ........................................................................ uint16_t kaitai::kstream::read_u2be() { uint16_t t; m_io->read(reinterpret_cast(&t), 2); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_16(t); #endif return t; } uint32_t kaitai::kstream::read_u4be() { uint32_t t; m_io->read(reinterpret_cast(&t), 4); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_32(t); #endif return t; } uint64_t kaitai::kstream::read_u8be() { uint64_t t; m_io->read(reinterpret_cast(&t), 8); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_64(t); #endif return t; } // ........................................................................ // Little-endian // ........................................................................ uint16_t kaitai::kstream::read_u2le() { uint16_t t; m_io->read(reinterpret_cast(&t), 2); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_16(t); #endif return t; } uint32_t kaitai::kstream::read_u4le() { uint32_t t; m_io->read(reinterpret_cast(&t), 4); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_32(t); #endif return t; } uint64_t kaitai::kstream::read_u8le() { uint64_t t; m_io->read(reinterpret_cast(&t), 8); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_64(t); #endif return t; } // ======================================================================== // Floating point numbers // ======================================================================== // ........................................................................ // Big-endian // ........................................................................ float kaitai::kstream::read_f4be() { uint32_t t; m_io->read(reinterpret_cast(&t), 4); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_32(t); #endif return reinterpret_cast(t); } double kaitai::kstream::read_f8be() { uint64_t t; m_io->read(reinterpret_cast(&t), 8); #if __BYTE_ORDER == __LITTLE_ENDIAN t = bswap_64(t); #endif return reinterpret_cast(t); } // ........................................................................ // Little-endian // ........................................................................ float kaitai::kstream::read_f4le() { uint32_t t; m_io->read(reinterpret_cast(&t), 4); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_32(t); #endif return reinterpret_cast(t); } double kaitai::kstream::read_f8le() { uint64_t t; m_io->read(reinterpret_cast(&t), 8); #if __BYTE_ORDER == __BIG_ENDIAN t = bswap_64(t); #endif return reinterpret_cast(t); } // ======================================================================== // Unaligned bit values // ======================================================================== void kaitai::kstream::align_to_byte() { m_bits_left = 0; m_bits = 0; } uint64_t kaitai::kstream::read_bits_int_be(int n) { int bits_needed = n - m_bits_left; if (bits_needed > 0) { // 1 bit => 1 byte // 8 bits => 1 byte // 9 bits => 2 bytes int bytes_needed = ((bits_needed - 1) / 8) + 1; if (bytes_needed > 8) throw std::runtime_error("read_bits_int: more than 8 bytes requested"); char buf[8]; m_io->read(buf, bytes_needed); for (int i = 0; i < bytes_needed; i++) { uint8_t b = buf[i]; m_bits <<= 8; m_bits |= b; m_bits_left += 8; } } // raw mask with required number of 1s, starting from lowest bit uint64_t mask = get_mask_ones(n); // shift mask to align with highest bits available in @bits int shift_bits = m_bits_left - n; mask <<= shift_bits; // derive reading result uint64_t res = (m_bits & mask) >> shift_bits; // clear top bits that we've just read => AND with 1s m_bits_left -= n; mask = get_mask_ones(m_bits_left); m_bits &= mask; return res; } // Deprecated, use read_bits_int_be() instead. uint64_t kaitai::kstream::read_bits_int(int n) { return read_bits_int_be(n); } uint64_t kaitai::kstream::read_bits_int_le(int n) { int bits_needed = n - m_bits_left; if (bits_needed > 0) { // 1 bit => 1 byte // 8 bits => 1 byte // 9 bits => 2 bytes int bytes_needed = ((bits_needed - 1) / 8) + 1; if (bytes_needed > 8) throw std::runtime_error("read_bits_int_le: more than 8 bytes requested"); char buf[8]; m_io->read(buf, bytes_needed); for (int i = 0; i < bytes_needed; i++) { uint8_t b = buf[i]; m_bits |= (static_cast(b) << m_bits_left); m_bits_left += 8; } } // raw mask with required number of 1s, starting from lowest bit uint64_t mask = get_mask_ones(n); // derive reading result uint64_t res = m_bits & mask; // remove bottom bits that we've just read by shifting m_bits >>= n; m_bits_left -= n; return res; } uint64_t kaitai::kstream::get_mask_ones(int n) { if (n == 64) { return 0xFFFFFFFFFFFFFFFF; } else { return ((uint64_t) 1 << n) - 1; } } // ======================================================================== // Byte arrays // ======================================================================== std::string kaitai::kstream::read_bytes(std::streamsize len) { std::vector result(len); // NOTE: streamsize type is signed, negative values are only *supposed* to not be used. // http://en.cppreference.com/w/cpp/io/streamsize if (len < 0) { throw std::runtime_error("read_bytes: requested a negative amount"); } if (len > 0) { m_io->read(&result[0], len); } return std::string(result.begin(), result.end()); } std::string kaitai::kstream::read_bytes_full() { std::iostream::pos_type p1 = m_io->tellg(); m_io->seekg(0, std::ios::end); std::iostream::pos_type p2 = m_io->tellg(); size_t len = p2 - p1; // Note: this requires a std::string to be backed with a // contiguous buffer. Officially, it's a only requirement since // C++11 (C++98 and C++03 didn't have this requirement), but all // major implementations had contiguous buffers anyway. std::string result(len, ' '); m_io->seekg(p1); m_io->read(&result[0], len); return result; } std::string kaitai::kstream::read_bytes_term(char term, bool include, bool consume, bool eos_error) { std::string result; std::getline(*m_io, result, term); if (m_io->eof()) { // encountered EOF if (eos_error) { throw std::runtime_error("read_bytes_term: encountered EOF"); } } else { // encountered terminator if (include) result.push_back(term); if (!consume) m_io->unget(); } return result; } std::string kaitai::kstream::ensure_fixed_contents(std::string expected) { std::string actual = read_bytes(expected.length()); if (actual != expected) { // NOTE: I think printing it outright is not best idea, it could contain non-ascii charactes like backspace and beeps and whatnot. It would be better to print hexlified version, and also to redirect it to stderr. throw std::runtime_error("ensure_fixed_contents: actual data does not match expected data"); } return actual; } std::string kaitai::kstream::bytes_strip_right(std::string src, char pad_byte) { std::size_t new_len = src.length(); while (new_len > 0 && src[new_len - 1] == pad_byte) new_len--; return src.substr(0, new_len); } std::string kaitai::kstream::bytes_terminate(std::string src, char term, bool include) { std::size_t new_len = 0; std::size_t max_len = src.length(); while (new_len < max_len && src[new_len] != term) new_len++; if (include && new_len < max_len) new_len++; return src.substr(0, new_len); } // ======================================================================== // Byte array processing // ======================================================================== std::string kaitai::kstream::process_xor_one(std::string data, uint8_t key) { size_t len = data.length(); std::string result(len, ' '); for (size_t i = 0; i < len; i++) result[i] = data[i] ^ key; return result; } std::string kaitai::kstream::process_xor_many(std::string data, std::string key) { size_t len = data.length(); size_t kl = key.length(); std::string result(len, ' '); size_t ki = 0; for (size_t i = 0; i < len; i++) { result[i] = data[i] ^ key[ki]; ki++; if (ki >= kl) ki = 0; } return result; } std::string kaitai::kstream::process_rotate_left(std::string data, int amount) { size_t len = data.length(); std::string result(len, ' '); for (size_t i = 0; i < len; i++) { uint8_t bits = data[i]; result[i] = (bits << amount) | (bits >> (8 - amount)); } return result; } #ifdef KS_ZLIB #include std::string kaitai::kstream::process_zlib(std::string data) { int ret; unsigned char *src_ptr = reinterpret_cast(&data[0]); std::stringstream dst_strm; z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; ret = inflateInit(&strm); if (ret != Z_OK) throw std::runtime_error("process_zlib: inflateInit error"); strm.next_in = src_ptr; strm.avail_in = data.length(); unsigned char outbuffer[ZLIB_BUF_SIZE]; std::string outstring; // get the decompressed bytes blockwise using repeated calls to inflate do { strm.next_out = reinterpret_cast(outbuffer); strm.avail_out = sizeof(outbuffer); ret = inflate(&strm, 0); if (outstring.size() < strm.total_out) outstring.append(reinterpret_cast(outbuffer), strm.total_out - outstring.size()); } while (ret == Z_OK); if (ret != Z_STREAM_END) { // an error occurred that was not EOF std::ostringstream exc_msg; exc_msg << "process_zlib: error #" << ret << "): " << strm.msg; throw std::runtime_error(exc_msg.str()); } if (inflateEnd(&strm) != Z_OK) throw std::runtime_error("process_zlib: inflateEnd error"); return outstring; } #endif // ======================================================================== // Misc utility methods // ======================================================================== int kaitai::kstream::mod(int a, int b) { if (b <= 0) throw std::invalid_argument("mod: divisor b <= 0"); int r = a % b; if (r < 0) r += b; return r; } #include std::string kaitai::kstream::to_string(int val) { // if int is 32 bits, "-2147483648" is the longest string representation // => 11 chars + zero => 12 chars // if int is 64 bits, "-9223372036854775808" is the longest // => 20 chars + zero => 21 chars char buf[25]; int got_len = snprintf(buf, sizeof(buf), "%d", val); // should never happen, but check nonetheless if (got_len > sizeof(buf)) throw std::invalid_argument("to_string: integer is longer than string buffer"); return std::string(buf); } #include std::string kaitai::kstream::reverse(std::string val) { std::reverse(val.begin(), val.end()); return val; } uint8_t kaitai::kstream::byte_array_min(const std::string val) { uint8_t min = 0xff; // UINT8_MAX std::string::const_iterator end = val.end(); for (std::string::const_iterator it = val.begin(); it != end; ++it) { uint8_t cur = static_cast(*it); if (cur < min) { min = cur; } } return min; } uint8_t kaitai::kstream::byte_array_max(const std::string val) { uint8_t max = 0; // UINT8_MIN std::string::const_iterator end = val.end(); for (std::string::const_iterator it = val.begin(); it != end; ++it) { uint8_t cur = static_cast(*it); if (cur > max) { max = cur; } } return max; } // ======================================================================== // Other internal methods // ======================================================================== #ifndef KS_STR_DEFAULT_ENCODING #define KS_STR_DEFAULT_ENCODING "UTF-8" #endif #ifdef KS_STR_ENCODING_ICONV #include #include #include std::string kaitai::kstream::bytes_to_str(std::string src, std::string src_enc) { iconv_t cd = iconv_open(KS_STR_DEFAULT_ENCODING, src_enc.c_str()); if (cd == (iconv_t) -1) { if (errno == EINVAL) { throw std::runtime_error("bytes_to_str: invalid encoding pair conversion requested"); } else { throw std::runtime_error("bytes_to_str: error opening iconv"); } } size_t src_len = src.length(); size_t src_left = src_len; // Start with a buffer length of double the source length. size_t dst_len = src_len * 2; std::string dst(dst_len, ' '); size_t dst_left = dst_len; char *src_ptr = &src[0]; char *dst_ptr = &dst[0]; while (true) { size_t res = iconv(cd, &src_ptr, &src_left, &dst_ptr, &dst_left); if (res == (size_t) -1) { if (errno == E2BIG) { // dst buffer is not enough to accomodate whole string // enlarge the buffer and try again size_t dst_used = dst_len - dst_left; dst_left += dst_len; dst_len += dst_len; dst.resize(dst_len); // dst.resize might have allocated destination buffer in another area // of memory, thus our previous pointer "dst" will be invalid; re-point // it using "dst_used". dst_ptr = &dst[dst_used]; } else { throw std::runtime_error("bytes_to_str: iconv error"); } } else { // conversion successful dst.resize(dst_len - dst_left); break; } } if (iconv_close(cd) != 0) { throw std::runtime_error("bytes_to_str: iconv close error"); } return dst; } #elif defined(KS_STR_ENCODING_NONE) std::string kaitai::kstream::bytes_to_str(std::string src, std::string src_enc) { return src; } #else #error Need to decide how to handle strings: please define one of: KS_STR_ENCODING_ICONV, KS_STR_ENCODING_NONE #endif ================================================ FILE: phonelibs/kaitai/kaitaistream.h ================================================ #ifndef KAITAI_STREAM_H #define KAITAI_STREAM_H // Kaitai Struct runtime API version: x.y.z = 'xxxyyyzzz' decimal #define KAITAI_STRUCT_VERSION 9000L #include #include #include #include namespace kaitai { /** * Kaitai Stream class (kaitai::kstream) is an implementation of * Kaitai Struct stream API * for C++/STL. It's implemented as a wrapper over generic STL std::istream. * * It provides a wide variety of simple methods to read (parse) binary * representations of primitive types, such as integer and floating * point numbers, byte arrays and strings, and also provides stream * positioning / navigation methods with unified cross-language and * cross-toolkit semantics. * * Typically, end users won't access Kaitai Stream class manually, but would * describe a binary structure format using .ksy language and then would use * Kaitai Struct compiler to generate source code in desired target language. * That code, in turn, would use this class and API to do the actual parsing * job. */ class kstream { public: /** * Constructs new Kaitai Stream object, wrapping a given std::istream. * \param io istream object to use for this Kaitai Stream */ kstream(std::istream* io); /** * Constructs new Kaitai Stream object, wrapping a given in-memory data * buffer. * \param data data buffer to use for this Kaitai Stream */ kstream(std::string& data); void close(); /** @name Stream positioning */ //@{ /** * Check if stream pointer is at the end of stream. Note that the semantics * are different from traditional STL semantics: one does *not* need to do a * read (which will fail) after the actual end of the stream to trigger EOF * flag, which can be accessed after that read. It is sufficient to just be * at the end of the stream for this method to return true. * \return "true" if we are located at the end of the stream. */ bool is_eof() const; /** * Set stream pointer to designated position. * \param pos new position (offset in bytes from the beginning of the stream) */ void seek(uint64_t pos); /** * Get current position of a stream pointer. * \return pointer position, number of bytes from the beginning of the stream */ uint64_t pos(); /** * Get total size of the stream in bytes. * \return size of the stream in bytes */ uint64_t size(); //@} /** @name Integer numbers */ //@{ // ------------------------------------------------------------------------ // Signed // ------------------------------------------------------------------------ int8_t read_s1(); // ........................................................................ // Big-endian // ........................................................................ int16_t read_s2be(); int32_t read_s4be(); int64_t read_s8be(); // ........................................................................ // Little-endian // ........................................................................ int16_t read_s2le(); int32_t read_s4le(); int64_t read_s8le(); // ------------------------------------------------------------------------ // Unsigned // ------------------------------------------------------------------------ uint8_t read_u1(); // ........................................................................ // Big-endian // ........................................................................ uint16_t read_u2be(); uint32_t read_u4be(); uint64_t read_u8be(); // ........................................................................ // Little-endian // ........................................................................ uint16_t read_u2le(); uint32_t read_u4le(); uint64_t read_u8le(); //@} /** @name Floating point numbers */ //@{ // ........................................................................ // Big-endian // ........................................................................ float read_f4be(); double read_f8be(); // ........................................................................ // Little-endian // ........................................................................ float read_f4le(); double read_f8le(); //@} /** @name Unaligned bit values */ //@{ void align_to_byte(); uint64_t read_bits_int_be(int n); uint64_t read_bits_int(int n); uint64_t read_bits_int_le(int n); //@} /** @name Byte arrays */ //@{ std::string read_bytes(std::streamsize len); std::string read_bytes_full(); std::string read_bytes_term(char term, bool include, bool consume, bool eos_error); std::string ensure_fixed_contents(std::string expected); static std::string bytes_strip_right(std::string src, char pad_byte); static std::string bytes_terminate(std::string src, char term, bool include); static std::string bytes_to_str(std::string src, std::string src_enc); //@} /** @name Byte array processing */ //@{ /** * Performs a XOR processing with given data, XORing every byte of input with a single * given value. * @param data data to process * @param key value to XOR with * @return processed data */ static std::string process_xor_one(std::string data, uint8_t key); /** * Performs a XOR processing with given data, XORing every byte of input with a key * array, repeating key array many times, if necessary (i.e. if data array is longer * than key array). * @param data data to process * @param key array of bytes to XOR with * @return processed data */ static std::string process_xor_many(std::string data, std::string key); /** * Performs a circular left rotation shift for a given buffer by a given amount of bits, * using groups of 1 bytes each time. Right circular rotation should be performed * using this procedure with corrected amount. * @param data source data to process * @param amount number of bits to shift by * @return copy of source array with requested shift applied */ static std::string process_rotate_left(std::string data, int amount); #ifdef KS_ZLIB /** * Performs an unpacking ("inflation") of zlib-compressed data with usual zlib headers. * @param data data to unpack * @return unpacked data * @throws IOException */ static std::string process_zlib(std::string data); #endif //@} /** * Performs modulo operation between two integers: dividend `a` * and divisor `b`. Divisor `b` is expected to be positive. The * result is always 0 <= x <= b - 1. */ static int mod(int a, int b); /** * Converts given integer `val` to a decimal string representation. * Should be used in place of std::to_string() (which is available only * since C++11) in older C++ implementations. */ static std::string to_string(int val); /** * Reverses given string `val`, so that the first character becomes the * last and the last one becomes the first. This should be used to avoid * the need of local variables at the caller. */ static std::string reverse(std::string val); /** * Finds the minimal byte in a byte array, treating bytes as * unsigned values. * @param val byte array to scan * @return minimal byte in byte array as integer */ static uint8_t byte_array_min(const std::string val); /** * Finds the maximal byte in a byte array, treating bytes as * unsigned values. * @param val byte array to scan * @return maximal byte in byte array as integer */ static uint8_t byte_array_max(const std::string val); private: std::istream* m_io; std::istringstream m_io_str; int m_bits_left; uint64_t m_bits; void init(); void exceptions_enable() const; static uint64_t get_mask_ones(int n); static const int ZLIB_BUF_SIZE = 128 * 1024; }; } #endif ================================================ FILE: phonelibs/kaitai/kaitaistruct.h ================================================ #ifndef KAITAI_STRUCT_H #define KAITAI_STRUCT_H #include namespace kaitai { class kstruct { public: kstruct(kstream *_io) { m__io = _io; } virtual ~kstruct() {} protected: kstream *m__io; public: kstream *_io() { return m__io; } }; } #endif ================================================ FILE: phonelibs/libgralloc/include/gralloc_priv.h ================================================ /* * Copyright (C) 2008 The Android Open Source Project * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef GRALLOC_PRIV_H_ #define GRALLOC_PRIV_H_ #include #include #include #include #include #include #include #include #include #define ROUND_UP_PAGESIZE(x) ( (((unsigned long)(x)) + PAGE_SIZE-1) & \ (~(PAGE_SIZE-1)) ) /* Gralloc usage bits indicating the type of allocation that should be used */ /* SYSTEM heap comes from kernel vmalloc (ION_SYSTEM_HEAP_ID) * is cached by default and * is not secured */ /* GRALLOC_USAGE_PRIVATE_0 is unused */ /* Non linear, Universal Bandwidth Compression */ #define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_1 /* IOMMU heap comes from manually allocated pages, can be cached/uncached, * is not secured */ #define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP GRALLOC_USAGE_PRIVATE_2 /* MM heap is a carveout heap for video, can be secured */ #define GRALLOC_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_3 /* ADSP heap is a carveout heap, is not secured */ #define GRALLOC_USAGE_PRIVATE_ADSP_HEAP 0x01000000 /* Set this for allocating uncached memory (using O_DSYNC), * cannot be used with noncontiguous heaps */ #define GRALLOC_USAGE_PRIVATE_UNCACHED 0x02000000 /* Buffer content should be displayed on an primary display only */ #define GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY 0x04000000 /* Buffer content should be displayed on an external display only */ #define GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY 0x08000000 /* This flag is set for WFD usecase */ #define GRALLOC_USAGE_PRIVATE_WFD 0x00200000 /* CAMERA heap is a carveout heap for camera, is not secured */ #define GRALLOC_USAGE_PRIVATE_CAMERA_HEAP 0x00400000 /* This flag is used for SECURE display usecase */ #define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY 0x00800000 /* define Gralloc perform */ #define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 // This will be used by the graphics drivers to know if certain features // are defined in this display HAL. // Ex: Newer GFX libraries + Older Display HAL #define GRALLOC_MODULE_PERFORM_GET_STRIDE 2 #define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3 #define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4 #define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5 #define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 #define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 #define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 #define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 #define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10 #define GRALLOC_MODULE_PERFORM_GET_IGC 11 #define GRALLOC_MODULE_PERFORM_SET_IGC 12 #define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13 /* OEM specific HAL formats */ #define HAL_PIXEL_FORMAT_RGBA_5551 6 #define HAL_PIXEL_FORMAT_RGBA_4444 7 #define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04 #define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03 #define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109 #define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01 #define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B #define HAL_PIXEL_FORMAT_R_8 0x10D #define HAL_PIXEL_FORMAT_RG_88 0x10E #define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F #define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110 #define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111 #define HAL_PIXEL_FORMAT_BGRX_8888 0x112 #define HAL_PIXEL_FORMAT_NV21_ZSL 0x113 #define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114 #define HAL_PIXEL_FORMAT_BGR_565 0x115 #define HAL_PIXEL_FORMAT_INTERLACE 0x180 //v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component #define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559 //v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed //format reduces the memory access bandwidth #define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259 // UBWC aligned Venus format #define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06 //Khronos ASTC formats #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC #define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD /* possible values for inverse gamma correction */ #define HAL_IGC_NOT_SPECIFIED 0 #define HAL_IGC_s_RGB 1 /* possible formats for 3D content*/ enum { HAL_NO_3D = 0x0, HAL_3D_SIDE_BY_SIDE_L_R = 0x1, HAL_3D_SIDE_BY_SIDE_R_L = 0x2, HAL_3D_TOP_BOTTOM = 0x4, HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, //unused legacy format }; enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO }; #ifdef __cplusplus struct private_handle_t : public native_handle { #else struct private_handle_t { native_handle_t nativeHandle; #endif enum { PRIV_FLAGS_FRAMEBUFFER = 0x00000001, PRIV_FLAGS_USES_ION = 0x00000008, PRIV_FLAGS_USES_ASHMEM = 0x00000010, PRIV_FLAGS_NEEDS_FLUSH = 0x00000020, PRIV_FLAGS_INTERNAL_ONLY = 0x00000040, PRIV_FLAGS_NON_CPU_WRITER = 0x00000080, PRIV_FLAGS_NONCONTIGUOUS_MEM = 0x00000100, PRIV_FLAGS_CACHED = 0x00000200, PRIV_FLAGS_SECURE_BUFFER = 0x00000400, // Display on external only PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000, // Set by HWC for protected non secure buffers PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000, PRIV_FLAGS_VIDEO_ENCODER = 0x00010000, PRIV_FLAGS_CAMERA_WRITE = 0x00020000, PRIV_FLAGS_CAMERA_READ = 0x00040000, PRIV_FLAGS_HW_COMPOSER = 0x00080000, PRIV_FLAGS_HW_TEXTURE = 0x00100000, PRIV_FLAGS_ITU_R_601 = 0x00200000, //Unused from display PRIV_FLAGS_ITU_R_601_FR = 0x00400000, //Unused from display PRIV_FLAGS_ITU_R_709 = 0x00800000, //Unused from display PRIV_FLAGS_SECURE_DISPLAY = 0x01000000, // Buffer is rendered in Tile Format PRIV_FLAGS_TILE_RENDERED = 0x02000000, // Buffer rendered using CPU/SW renderer PRIV_FLAGS_CPU_RENDERED = 0x04000000, // Buffer is allocated with UBWC alignment PRIV_FLAGS_UBWC_ALIGNED = 0x08000000, // Buffer allocated will be consumed by SF/HWC PRIV_FLAGS_DISP_CONSUMER = 0x10000000 }; // file-descriptors int fd; int fd_metadata; // fd for the meta-data // ints int magic; int flags; unsigned int size; unsigned int offset; int bufferType; uint64_t base __attribute__((aligned(8))); unsigned int offset_metadata; // The gpu address mapped into the mmu. uint64_t gpuaddr __attribute__((aligned(8))); int format; int width; // specifies aligned width int height; // specifies aligned height int real_width; int real_height; uint64_t base_metadata __attribute__((aligned(8))); #ifdef __cplusplus static const int sNumFds = 2; static inline int sNumInts() { return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / sizeof(int)) - sNumFds; } static const int sMagic = 'gmsm'; private_handle_t(int fd, unsigned int size, int flags, int bufferType, int format, int aligned_width, int aligned_height, int width, int height, int eFd = -1, unsigned int eOffset = 0, uint64_t eBase = 0) : fd(fd), fd_metadata(eFd), magic(sMagic), flags(flags), size(size), offset(0), bufferType(bufferType), base(0), offset_metadata(eOffset), gpuaddr(0), format(format), width(aligned_width), height(aligned_height), real_width(width), real_height(height), base_metadata(eBase) { version = (int) sizeof(native_handle); numInts = sNumInts(); numFds = sNumFds; } ~private_handle_t() { magic = 0; } static int validate(const native_handle* h) { const private_handle_t* hnd = (const private_handle_t*)h; if (!h || h->version != sizeof(native_handle) || h->numInts != sNumInts() || h->numFds != sNumFds || hnd->magic != sMagic) { ALOGD("Invalid gralloc handle (at %p): " "ver(%d/%zu) ints(%d/%d) fds(%d/%d)" "magic(%c%c%c%c/%c%c%c%c)", h, h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, sNumInts(), h ? h->numFds : -1, sNumFds, hnd ? (((hnd->magic >> 24) & 0xFF)? ((hnd->magic >> 24) & 0xFF) : '-') : '?', hnd ? (((hnd->magic >> 16) & 0xFF)? ((hnd->magic >> 16) & 0xFF) : '-') : '?', hnd ? (((hnd->magic >> 8) & 0xFF)? ((hnd->magic >> 8) & 0xFF) : '-') : '?', hnd ? (((hnd->magic >> 0) & 0xFF)? ((hnd->magic >> 0) & 0xFF) : '-') : '?', (sMagic >> 24) & 0xFF, (sMagic >> 16) & 0xFF, (sMagic >> 8) & 0xFF, (sMagic >> 0) & 0xFF); return -EINVAL; } return 0; } static private_handle_t* dynamicCast(const native_handle* in) { if (validate(in) == 0) { return (private_handle_t*) in; } return NULL; } #endif }; #endif /* GRALLOC_PRIV_H_ */ ================================================ FILE: phonelibs/libyuv/include/libyuv/basic_types.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ #define INCLUDE_LIBYUV_BASIC_TYPES_H_ #include // for NULL, size_t #if defined(_MSC_VER) && (_MSC_VER < 1600) #include // for uintptr_t on x86 #else #include // for uintptr_t #endif #ifndef GG_LONGLONG #ifndef INT_TYPES_DEFINED #define INT_TYPES_DEFINED #ifdef COMPILER_MSVC typedef unsigned __int64 uint64; typedef __int64 int64; #ifndef INT64_C #define INT64_C(x) x ## I64 #endif #ifndef UINT64_C #define UINT64_C(x) x ## UI64 #endif #define INT64_F "I64" #else // COMPILER_MSVC #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) typedef unsigned long uint64; // NOLINT typedef long int64; // NOLINT #ifndef INT64_C #define INT64_C(x) x ## L #endif #ifndef UINT64_C #define UINT64_C(x) x ## UL #endif #define INT64_F "l" #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) typedef unsigned long long uint64; // NOLINT typedef long long int64; // NOLINT #ifndef INT64_C #define INT64_C(x) x ## LL #endif #ifndef UINT64_C #define UINT64_C(x) x ## ULL #endif #define INT64_F "ll" #endif // __LP64__ #endif // COMPILER_MSVC typedef unsigned int uint32; typedef int int32; typedef unsigned short uint16; // NOLINT typedef short int16; // NOLINT typedef unsigned char uint8; typedef signed char int8; #endif // INT_TYPES_DEFINED #endif // GG_LONGLONG // Detect compiler is for x86 or x64. #if defined(__x86_64__) || defined(_M_X64) || \ defined(__i386__) || defined(_M_IX86) #define CPU_X86 1 #endif // Detect compiler is for ARM. #if defined(__arm__) || defined(_M_ARM) #define CPU_ARM 1 #endif #ifndef ALIGNP #ifdef __cplusplus #define ALIGNP(p, t) \ (reinterpret_cast(((reinterpret_cast(p) + \ ((t) - 1)) & ~((t) - 1)))) #else #define ALIGNP(p, t) \ ((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ #endif #endif #if !defined(LIBYUV_API) #if defined(_WIN32) || defined(__CYGWIN__) #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) #define LIBYUV_API __declspec(dllexport) #elif defined(LIBYUV_USING_SHARED_LIBRARY) #define LIBYUV_API __declspec(dllimport) #else #define LIBYUV_API #endif // LIBYUV_BUILDING_SHARED_LIBRARY #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ defined(LIBYUV_USING_SHARED_LIBRARY)) #define LIBYUV_API __attribute__ ((visibility ("default"))) #else #define LIBYUV_API #endif // __GNUC__ #endif // LIBYUV_API #define LIBYUV_BOOL int #define LIBYUV_FALSE 0 #define LIBYUV_TRUE 1 // Visual C x86 or GCC little endian. #if defined(__x86_64__) || defined(_M_X64) || \ defined(__i386__) || defined(_M_IX86) || \ defined(__arm__) || defined(_M_ARM) || \ (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define LIBYUV_LITTLE_ENDIAN #endif #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/compare.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_COMPARE_H_ #define INCLUDE_LIBYUV_COMPARE_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Compute a hash for specified memory. Seed of 5381 recommended. LIBYUV_API uint32 HashDjb2(const uint8* src, uint64 count, uint32 seed); // Scan an opaque argb image and return fourcc based on alpha offset. // Returns FOURCC_ARGB, FOURCC_BGRA, or 0 if unknown. LIBYUV_API uint32 ARGBDetect(const uint8* argb, int stride_argb, int width, int height); // Sum Square Error - used to compute Mean Square Error or PSNR. LIBYUV_API uint64 ComputeSumSquareError(const uint8* src_a, const uint8* src_b, int count); LIBYUV_API uint64 ComputeSumSquareErrorPlane(const uint8* src_a, int stride_a, const uint8* src_b, int stride_b, int width, int height); static const int kMaxPsnr = 128; LIBYUV_API double SumSquareErrorToPsnr(uint64 sse, uint64 count); LIBYUV_API double CalcFramePsnr(const uint8* src_a, int stride_a, const uint8* src_b, int stride_b, int width, int height); LIBYUV_API double I420Psnr(const uint8* src_y_a, int stride_y_a, const uint8* src_u_a, int stride_u_a, const uint8* src_v_a, int stride_v_a, const uint8* src_y_b, int stride_y_b, const uint8* src_u_b, int stride_u_b, const uint8* src_v_b, int stride_v_b, int width, int height); LIBYUV_API double CalcFrameSsim(const uint8* src_a, int stride_a, const uint8* src_b, int stride_b, int width, int height); LIBYUV_API double I420Ssim(const uint8* src_y_a, int stride_y_a, const uint8* src_u_a, int stride_u_a, const uint8* src_v_a, int stride_v_a, const uint8* src_y_b, int stride_y_b, const uint8* src_u_b, int stride_u_b, const uint8* src_v_b, int stride_v_b, int width, int height); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_COMPARE_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/compare_row.h ================================================ /* * Copyright 2013 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_COMPARE_ROW_H_ #define INCLUDE_LIBYUV_COMPARE_ROW_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif #if defined(__pnacl__) || defined(__CLR_VER) || \ (defined(__i386__) && !defined(__SSE2__)) #define LIBYUV_DISABLE_X86 #endif // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 #if defined(__has_feature) #if __has_feature(memory_sanitizer) #define LIBYUV_DISABLE_X86 #endif #endif // Visual C 2012 required for AVX2. #if defined(_M_IX86) && !defined(__clang__) && \ defined(_MSC_VER) && _MSC_VER >= 1700 #define VISUALC_HAS_AVX2 1 #endif // VisualStudio >= 2012 // clang >= 3.4.0 required for AVX2. #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) #define CLANG_HAS_AVX2 1 #endif // clang >= 3.4 #endif // __clang__ #if !defined(LIBYUV_DISABLE_X86) && \ defined(_M_IX86) && (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) #define HAS_HASHDJB2_AVX2 #endif // The following are available for Visual C and GCC: #if !defined(LIBYUV_DISABLE_X86) && \ (defined(__x86_64__) || (defined(__i386__) || defined(_M_IX86))) #define HAS_HASHDJB2_SSE41 #define HAS_SUMSQUAREERROR_SSE2 #endif // The following are available for Visual C and clangcl 32 bit: #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \ (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) #define HAS_HASHDJB2_AVX2 #define HAS_SUMSQUAREERROR_AVX2 #endif // The following are available for Neon: #if !defined(LIBYUV_DISABLE_NEON) && \ (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) #define HAS_SUMSQUAREERROR_NEON #endif uint32 SumSquareError_C(const uint8* src_a, const uint8* src_b, int count); uint32 SumSquareError_SSE2(const uint8* src_a, const uint8* src_b, int count); uint32 SumSquareError_AVX2(const uint8* src_a, const uint8* src_b, int count); uint32 SumSquareError_NEON(const uint8* src_a, const uint8* src_b, int count); uint32 HashDjb2_C(const uint8* src, int count, uint32 seed); uint32 HashDjb2_SSE41(const uint8* src, int count, uint32 seed); uint32 HashDjb2_AVX2(const uint8* src, int count, uint32 seed); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_COMPARE_ROW_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/convert.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_CONVERT_H_ #define INCLUDE_LIBYUV_CONVERT_H_ #include "libyuv/basic_types.h" #include "libyuv/rotate.h" // For enum RotationMode. // TODO(fbarchard): fix WebRTC source to include following libyuv headers: #include "libyuv/convert_argb.h" // For WebRTC I420ToARGB. b/620 #include "libyuv/convert_from.h" // For WebRTC ConvertFromI420. b/620 #include "libyuv/planar_functions.h" // For WebRTC I420Rect, CopyPlane. b/618 #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Convert I444 to I420. LIBYUV_API int I444ToI420(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert I422 to I420. LIBYUV_API int I422ToI420(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert I411 to I420. LIBYUV_API int I411ToI420(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Copy I420 to I420. #define I420ToI420 I420Copy LIBYUV_API int I420Copy(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert I400 (grey) to I420. LIBYUV_API int I400ToI420(const uint8* src_y, int src_stride_y, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); #define J400ToJ420 I400ToI420 // Convert NV12 to I420. LIBYUV_API int NV12ToI420(const uint8* src_y, int src_stride_y, const uint8* src_uv, int src_stride_uv, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert NV21 to I420. LIBYUV_API int NV21ToI420(const uint8* src_y, int src_stride_y, const uint8* src_vu, int src_stride_vu, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert YUY2 to I420. LIBYUV_API int YUY2ToI420(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert UYVY to I420. LIBYUV_API int UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert M420 to I420. LIBYUV_API int M420ToI420(const uint8* src_m420, int src_stride_m420, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert Android420 to I420. LIBYUV_API int Android420ToI420(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, int pixel_stride_uv, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // ARGB little endian (bgra in memory) to I420. LIBYUV_API int ARGBToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // BGRA little endian (argb in memory) to I420. LIBYUV_API int BGRAToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // ABGR little endian (rgba in memory) to I420. LIBYUV_API int ABGRToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // RGBA little endian (abgr in memory) to I420. LIBYUV_API int RGBAToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // RGB little endian (bgr in memory) to I420. LIBYUV_API int RGB24ToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // RGB big endian (rgb in memory) to I420. LIBYUV_API int RAWToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // RGB16 (RGBP fourcc) little endian to I420. LIBYUV_API int RGB565ToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // RGB15 (RGBO fourcc) little endian to I420. LIBYUV_API int ARGB1555ToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // RGB12 (R444 fourcc) little endian to I420. LIBYUV_API int ARGB4444ToI420(const uint8* src_frame, int src_stride_frame, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); #ifdef HAVE_JPEG // src_width/height provided by capture. // dst_width/height for clipping determine final size. LIBYUV_API int MJPGToI420(const uint8* sample, size_t sample_size, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int src_width, int src_height, int dst_width, int dst_height); // Query size of MJPG in pixels. LIBYUV_API int MJPGSize(const uint8* sample, size_t sample_size, int* width, int* height); #endif // Convert camera sample to I420 with cropping, rotation and vertical flip. // "src_size" is needed to parse MJPG. // "dst_stride_y" number of bytes in a row of the dst_y plane. // Normally this would be the same as dst_width, with recommended alignment // to 16 bytes for better efficiency. // If rotation of 90 or 270 is used, stride is affected. The caller should // allocate the I420 buffer according to rotation. // "dst_stride_u" number of bytes in a row of the dst_u plane. // Normally this would be the same as (dst_width + 1) / 2, with // recommended alignment to 16 bytes for better efficiency. // If rotation of 90 or 270 is used, stride is affected. // "crop_x" and "crop_y" are starting position for cropping. // To center, crop_x = (src_width - dst_width) / 2 // crop_y = (src_height - dst_height) / 2 // "src_width" / "src_height" is size of src_frame in pixels. // "src_height" can be negative indicating a vertically flipped image source. // "crop_width" / "crop_height" is the size to crop the src to. // Must be less than or equal to src_width/src_height // Cropping parameters are pre-rotation. // "rotation" can be 0, 90, 180 or 270. // "format" is a fourcc. ie 'I420', 'YUY2' // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. LIBYUV_API int ConvertToI420(const uint8* src_frame, size_t src_size, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int crop_x, int crop_y, int src_width, int src_height, int crop_width, int crop_height, enum RotationMode rotation, uint32 format); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_CONVERT_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/convert_argb.h ================================================ /* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_CONVERT_ARGB_H_ #define INCLUDE_LIBYUV_CONVERT_ARGB_H_ #include "libyuv/basic_types.h" #include "libyuv/rotate.h" // For enum RotationMode. // TODO(fbarchard): This set of functions should exactly match convert.h // TODO(fbarchard): Add tests. Create random content of right size and convert // with C vs Opt and or to I420 and compare. // TODO(fbarchard): Some of these functions lack parameter setting. #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Alias. #define ARGBToARGB ARGBCopy // Copy ARGB to ARGB. LIBYUV_API int ARGBCopy(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert I420 to ARGB. LIBYUV_API int I420ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Duplicate prototype for function in convert_from.h for remoting. LIBYUV_API int I420ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert I422 to ARGB. LIBYUV_API int I422ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert I444 to ARGB. LIBYUV_API int I444ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert J444 to ARGB. LIBYUV_API int J444ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert I444 to ABGR. LIBYUV_API int I444ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // Convert I411 to ARGB. LIBYUV_API int I411ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert I420 with Alpha to preattenuated ARGB. LIBYUV_API int I420AlphaToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, const uint8* src_a, int src_stride_a, uint8* dst_argb, int dst_stride_argb, int width, int height, int attenuate); // Convert I420 with Alpha to preattenuated ABGR. LIBYUV_API int I420AlphaToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, const uint8* src_a, int src_stride_a, uint8* dst_abgr, int dst_stride_abgr, int width, int height, int attenuate); // Convert I400 (grey) to ARGB. Reverse of ARGBToI400. LIBYUV_API int I400ToARGB(const uint8* src_y, int src_stride_y, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert J400 (jpeg grey) to ARGB. LIBYUV_API int J400ToARGB(const uint8* src_y, int src_stride_y, uint8* dst_argb, int dst_stride_argb, int width, int height); // Alias. #define YToARGB I400ToARGB // Convert NV12 to ARGB. LIBYUV_API int NV12ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_uv, int src_stride_uv, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert NV21 to ARGB. LIBYUV_API int NV21ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_vu, int src_stride_vu, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert M420 to ARGB. LIBYUV_API int M420ToARGB(const uint8* src_m420, int src_stride_m420, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert YUY2 to ARGB. LIBYUV_API int YUY2ToARGB(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert UYVY to ARGB. LIBYUV_API int UYVYToARGB(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert J420 to ARGB. LIBYUV_API int J420ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert J422 to ARGB. LIBYUV_API int J422ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert J420 to ABGR. LIBYUV_API int J420ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // Convert J422 to ABGR. LIBYUV_API int J422ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // Convert H420 to ARGB. LIBYUV_API int H420ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert H422 to ARGB. LIBYUV_API int H422ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert H420 to ABGR. LIBYUV_API int H420ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // Convert H422 to ABGR. LIBYUV_API int H422ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // BGRA little endian (argb in memory) to ARGB. LIBYUV_API int BGRAToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // ABGR little endian (rgba in memory) to ARGB. LIBYUV_API int ABGRToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // RGBA little endian (abgr in memory) to ARGB. LIBYUV_API int RGBAToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // Deprecated function name. #define BG24ToARGB RGB24ToARGB // RGB little endian (bgr in memory) to ARGB. LIBYUV_API int RGB24ToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // RGB big endian (rgb in memory) to ARGB. LIBYUV_API int RAWToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // RGB16 (RGBP fourcc) little endian to ARGB. LIBYUV_API int RGB565ToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // RGB15 (RGBO fourcc) little endian to ARGB. LIBYUV_API int ARGB1555ToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); // RGB12 (R444 fourcc) little endian to ARGB. LIBYUV_API int ARGB4444ToARGB(const uint8* src_frame, int src_stride_frame, uint8* dst_argb, int dst_stride_argb, int width, int height); #ifdef HAVE_JPEG // src_width/height provided by capture // dst_width/height for clipping determine final size. LIBYUV_API int MJPGToARGB(const uint8* sample, size_t sample_size, uint8* dst_argb, int dst_stride_argb, int src_width, int src_height, int dst_width, int dst_height); #endif // Convert camera sample to ARGB with cropping, rotation and vertical flip. // "src_size" is needed to parse MJPG. // "dst_stride_argb" number of bytes in a row of the dst_argb plane. // Normally this would be the same as dst_width, with recommended alignment // to 16 bytes for better efficiency. // If rotation of 90 or 270 is used, stride is affected. The caller should // allocate the I420 buffer according to rotation. // "dst_stride_u" number of bytes in a row of the dst_u plane. // Normally this would be the same as (dst_width + 1) / 2, with // recommended alignment to 16 bytes for better efficiency. // If rotation of 90 or 270 is used, stride is affected. // "crop_x" and "crop_y" are starting position for cropping. // To center, crop_x = (src_width - dst_width) / 2 // crop_y = (src_height - dst_height) / 2 // "src_width" / "src_height" is size of src_frame in pixels. // "src_height" can be negative indicating a vertically flipped image source. // "crop_width" / "crop_height" is the size to crop the src to. // Must be less than or equal to src_width/src_height // Cropping parameters are pre-rotation. // "rotation" can be 0, 90, 180 or 270. // "format" is a fourcc. ie 'I420', 'YUY2' // Returns 0 for successful; -1 for invalid parameter. Non-zero for failure. LIBYUV_API int ConvertToARGB(const uint8* src_frame, size_t src_size, uint8* dst_argb, int dst_stride_argb, int crop_x, int crop_y, int src_width, int src_height, int crop_width, int crop_height, enum RotationMode rotation, uint32 format); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_CONVERT_ARGB_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/convert_from.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_ #define INCLUDE_LIBYUV_CONVERT_FROM_H_ #include "libyuv/basic_types.h" #include "libyuv/rotate.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // See Also convert.h for conversions from formats to I420. // I420Copy in convert to I420ToI420. LIBYUV_API int I420ToI422(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); LIBYUV_API int I420ToI444(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); LIBYUV_API int I420ToI411(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21. LIBYUV_API int I400Copy(const uint8* src_y, int src_stride_y, uint8* dst_y, int dst_stride_y, int width, int height); LIBYUV_API int I420ToNV12(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_uv, int dst_stride_uv, int width, int height); LIBYUV_API int I420ToNV21(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_vu, int dst_stride_vu, int width, int height); LIBYUV_API int I420ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); LIBYUV_API int I420ToUYVY(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); LIBYUV_API int I420ToARGB(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); LIBYUV_API int I420ToBGRA(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); LIBYUV_API int I420ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_argb, int dst_stride_argb, int width, int height); LIBYUV_API int I420ToRGBA(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_rgba, int dst_stride_rgba, int width, int height); LIBYUV_API int I420ToRGB24(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); LIBYUV_API int I420ToRAW(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); LIBYUV_API int I420ToRGB565(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); // Convert I420 To RGB565 with 4x4 dither matrix (16 bytes). // Values in dither matrix from 0 to 7 recommended. // The order of the dither matrix is first byte is upper left. LIBYUV_API int I420ToRGB565Dither(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, const uint8* dither4x4, int width, int height); LIBYUV_API int I420ToARGB1555(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); LIBYUV_API int I420ToARGB4444(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); // Convert I420 to specified format. // "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the // buffer has contiguous rows. Can be negative. A multiple of 16 is optimal. LIBYUV_API int ConvertFromI420(const uint8* y, int y_stride, const uint8* u, int u_stride, const uint8* v, int v_stride, uint8* dst_sample, int dst_sample_stride, int width, int height, uint32 format); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_CONVERT_FROM_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/convert_from_argb.h ================================================ /* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ #define INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Copy ARGB to ARGB. #define ARGBToARGB ARGBCopy LIBYUV_API int ARGBCopy(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert ARGB To BGRA. LIBYUV_API int ARGBToBGRA(const uint8* src_argb, int src_stride_argb, uint8* dst_bgra, int dst_stride_bgra, int width, int height); // Convert ARGB To ABGR. LIBYUV_API int ARGBToABGR(const uint8* src_argb, int src_stride_argb, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // Convert ARGB To RGBA. LIBYUV_API int ARGBToRGBA(const uint8* src_argb, int src_stride_argb, uint8* dst_rgba, int dst_stride_rgba, int width, int height); // Convert ARGB To RGB24. LIBYUV_API int ARGBToRGB24(const uint8* src_argb, int src_stride_argb, uint8* dst_rgb24, int dst_stride_rgb24, int width, int height); // Convert ARGB To RAW. LIBYUV_API int ARGBToRAW(const uint8* src_argb, int src_stride_argb, uint8* dst_rgb, int dst_stride_rgb, int width, int height); // Convert ARGB To RGB565. LIBYUV_API int ARGBToRGB565(const uint8* src_argb, int src_stride_argb, uint8* dst_rgb565, int dst_stride_rgb565, int width, int height); // Convert ARGB To RGB565 with 4x4 dither matrix (16 bytes). // Values in dither matrix from 0 to 7 recommended. // The order of the dither matrix is first byte is upper left. // TODO(fbarchard): Consider pointer to 2d array for dither4x4. // const uint8(*dither)[4][4]; LIBYUV_API int ARGBToRGB565Dither(const uint8* src_argb, int src_stride_argb, uint8* dst_rgb565, int dst_stride_rgb565, const uint8* dither4x4, int width, int height); // Convert ARGB To ARGB1555. LIBYUV_API int ARGBToARGB1555(const uint8* src_argb, int src_stride_argb, uint8* dst_argb1555, int dst_stride_argb1555, int width, int height); // Convert ARGB To ARGB4444. LIBYUV_API int ARGBToARGB4444(const uint8* src_argb, int src_stride_argb, uint8* dst_argb4444, int dst_stride_argb4444, int width, int height); // Convert ARGB To I444. LIBYUV_API int ARGBToI444(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert ARGB To I422. LIBYUV_API int ARGBToI422(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert ARGB To I420. (also in convert.h) LIBYUV_API int ARGBToI420(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert ARGB to J420. (JPeg full range I420). LIBYUV_API int ARGBToJ420(const uint8* src_argb, int src_stride_argb, uint8* dst_yj, int dst_stride_yj, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert ARGB to J422. LIBYUV_API int ARGBToJ422(const uint8* src_argb, int src_stride_argb, uint8* dst_yj, int dst_stride_yj, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert ARGB To I411. LIBYUV_API int ARGBToI411(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert ARGB to J400. (JPeg full range). LIBYUV_API int ARGBToJ400(const uint8* src_argb, int src_stride_argb, uint8* dst_yj, int dst_stride_yj, int width, int height); // Convert ARGB to I400. LIBYUV_API int ARGBToI400(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, int width, int height); // Convert ARGB to G. (Reverse of J400toARGB, which replicates G back to ARGB) LIBYUV_API int ARGBToG(const uint8* src_argb, int src_stride_argb, uint8* dst_g, int dst_stride_g, int width, int height); // Convert ARGB To NV12. LIBYUV_API int ARGBToNV12(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_uv, int dst_stride_uv, int width, int height); // Convert ARGB To NV21. LIBYUV_API int ARGBToNV21(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_vu, int dst_stride_vu, int width, int height); // Convert ARGB To NV21. LIBYUV_API int ARGBToNV21(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, uint8* dst_vu, int dst_stride_vu, int width, int height); // Convert ARGB To YUY2. LIBYUV_API int ARGBToYUY2(const uint8* src_argb, int src_stride_argb, uint8* dst_yuy2, int dst_stride_yuy2, int width, int height); // Convert ARGB To UYVY. LIBYUV_API int ARGBToUYVY(const uint8* src_argb, int src_stride_argb, uint8* dst_uyvy, int dst_stride_uyvy, int width, int height); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_CONVERT_FROM_ARGB_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/cpu_id.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_CPU_ID_H_ #define INCLUDE_LIBYUV_CPU_ID_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Internal flag to indicate cpuid requires initialization. static const int kCpuInitialized = 0x1; // These flags are only valid on ARM processors. static const int kCpuHasARM = 0x2; static const int kCpuHasNEON = 0x4; // 0x8 reserved for future ARM flag. // These flags are only valid on x86 processors. static const int kCpuHasX86 = 0x10; static const int kCpuHasSSE2 = 0x20; static const int kCpuHasSSSE3 = 0x40; static const int kCpuHasSSE41 = 0x80; static const int kCpuHasSSE42 = 0x100; static const int kCpuHasAVX = 0x200; static const int kCpuHasAVX2 = 0x400; static const int kCpuHasERMS = 0x800; static const int kCpuHasFMA3 = 0x1000; static const int kCpuHasAVX3 = 0x2000; // 0x2000, 0x4000, 0x8000 reserved for future X86 flags. // These flags are only valid on MIPS processors. static const int kCpuHasMIPS = 0x10000; static const int kCpuHasDSPR2 = 0x20000; static const int kCpuHasMSA = 0x40000; // Internal function used to auto-init. LIBYUV_API int InitCpuFlags(void); // Internal function for parsing /proc/cpuinfo. LIBYUV_API int ArmCpuCaps(const char* cpuinfo_name); // Detect CPU has SSE2 etc. // Test_flag parameter should be one of kCpuHas constants above. // returns non-zero if instruction set is detected static __inline int TestCpuFlag(int test_flag) { LIBYUV_API extern int cpu_info_; return (!cpu_info_ ? InitCpuFlags() : cpu_info_) & test_flag; } // For testing, allow CPU flags to be disabled. // ie MaskCpuFlags(~kCpuHasSSSE3) to disable SSSE3. // MaskCpuFlags(-1) to enable all cpu specific optimizations. // MaskCpuFlags(1) to disable all cpu specific optimizations. LIBYUV_API void MaskCpuFlags(int enable_flags); // Low level cpuid for X86. Returns zeros on other CPUs. // eax is the info type that you want. // ecx is typically the cpu number, and should normally be zero. LIBYUV_API void CpuId(uint32 eax, uint32 ecx, uint32* cpu_info); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_CPU_ID_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/macros_msa.h ================================================ /* * Copyright 2016 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_MACROS_MSA_H_ #define INCLUDE_LIBYUV_MACROS_MSA_H_ #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) #include #include #define LD_B(RTYPE, psrc) *((RTYPE*)(psrc)) /* NOLINT */ #define LD_UB(...) LD_B(v16u8, __VA_ARGS__) #define ST_B(RTYPE, in, pdst) *((RTYPE*)(pdst)) = (in) /* NOLINT */ #define ST_UB(...) ST_B(v16u8, __VA_ARGS__) /* Description : Load two vectors with 16 'byte' sized elements Arguments : Inputs - psrc, stride Outputs - out0, out1 Return Type - as per RTYPE Details : Load 16 byte elements in 'out0' from (psrc) Load 16 byte elements in 'out1' from (psrc + stride) */ #define LD_B2(RTYPE, psrc, stride, out0, out1) { \ out0 = LD_B(RTYPE, (psrc)); \ out1 = LD_B(RTYPE, (psrc) + stride); \ } #define LD_UB2(...) LD_B2(v16u8, __VA_ARGS__) #define LD_B4(RTYPE, psrc, stride, out0, out1, out2, out3) { \ LD_B2(RTYPE, (psrc), stride, out0, out1); \ LD_B2(RTYPE, (psrc) + 2 * stride , stride, out2, out3); \ } #define LD_UB4(...) LD_B4(v16u8, __VA_ARGS__) /* Description : Store two vectors with stride each having 16 'byte' sized elements Arguments : Inputs - in0, in1, pdst, stride Details : Store 16 byte elements from 'in0' to (pdst) Store 16 byte elements from 'in1' to (pdst + stride) */ #define ST_B2(RTYPE, in0, in1, pdst, stride) { \ ST_B(RTYPE, in0, (pdst)); \ ST_B(RTYPE, in1, (pdst) + stride); \ } #define ST_UB2(...) ST_B2(v16u8, __VA_ARGS__) # #define ST_B4(RTYPE, in0, in1, in2, in3, pdst, stride) { \ ST_B2(RTYPE, in0, in1, (pdst), stride); \ ST_B2(RTYPE, in2, in3, (pdst) + 2 * stride, stride); \ } #define ST_UB4(...) ST_B4(v16u8, __VA_ARGS__) # /* Description : Shuffle byte vector elements as per mask vector Arguments : Inputs - in0, in1, in2, in3, mask0, mask1 Outputs - out0, out1 Return Type - as per RTYPE Details : Byte elements from 'in0' & 'in1' are copied selectively to 'out0' as per control vector 'mask0' */ #define VSHF_B2(RTYPE, in0, in1, in2, in3, mask0, mask1, out0, out1) { \ out0 = (RTYPE) __msa_vshf_b((v16i8) mask0, (v16i8) in1, (v16i8) in0); \ out1 = (RTYPE) __msa_vshf_b((v16i8) mask1, (v16i8) in3, (v16i8) in2); \ } #define VSHF_B2_UB(...) VSHF_B2(v16u8, __VA_ARGS__) #endif /* !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) */ #endif // INCLUDE_LIBYUV_MACROS_MSA_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/mjpeg_decoder.h ================================================ /* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_MJPEG_DECODER_H_ #define INCLUDE_LIBYUV_MJPEG_DECODER_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus // NOTE: For a simplified public API use convert.h MJPGToI420(). struct jpeg_common_struct; struct jpeg_decompress_struct; struct jpeg_source_mgr; namespace libyuv { #ifdef __cplusplus extern "C" { #endif LIBYUV_BOOL ValidateJpeg(const uint8* sample, size_t sample_size); #ifdef __cplusplus } // extern "C" #endif static const uint32 kUnknownDataSize = 0xFFFFFFFF; enum JpegSubsamplingType { kJpegYuv420, kJpegYuv422, kJpegYuv411, kJpegYuv444, kJpegYuv400, kJpegUnknown }; struct Buffer { const uint8* data; int len; }; struct BufferVector { Buffer* buffers; int len; int pos; }; struct SetJmpErrorMgr; // MJPEG ("Motion JPEG") is a pseudo-standard video codec where the frames are // simply independent JPEG images with a fixed huffman table (which is omitted). // It is rarely used in video transmission, but is common as a camera capture // format, especially in Logitech devices. This class implements a decoder for // MJPEG frames. // // See http://tools.ietf.org/html/rfc2435 class LIBYUV_API MJpegDecoder { public: typedef void (*CallbackFunction)(void* opaque, const uint8* const* data, const int* strides, int rows); static const int kColorSpaceUnknown; static const int kColorSpaceGrayscale; static const int kColorSpaceRgb; static const int kColorSpaceYCbCr; static const int kColorSpaceCMYK; static const int kColorSpaceYCCK; MJpegDecoder(); ~MJpegDecoder(); // Loads a new frame, reads its headers, and determines the uncompressed // image format. // Returns LIBYUV_TRUE if image looks valid and format is supported. // If return value is LIBYUV_TRUE, then the values for all the following // getters are populated. // src_len is the size of the compressed mjpeg frame in bytes. LIBYUV_BOOL LoadFrame(const uint8* src, size_t src_len); // Returns width of the last loaded frame in pixels. int GetWidth(); // Returns height of the last loaded frame in pixels. int GetHeight(); // Returns format of the last loaded frame. The return value is one of the // kColorSpace* constants. int GetColorSpace(); // Number of color components in the color space. int GetNumComponents(); // Sample factors of the n-th component. int GetHorizSampFactor(int component); int GetVertSampFactor(int component); int GetHorizSubSampFactor(int component); int GetVertSubSampFactor(int component); // Public for testability. int GetImageScanlinesPerImcuRow(); // Public for testability. int GetComponentScanlinesPerImcuRow(int component); // Width of a component in bytes. int GetComponentWidth(int component); // Height of a component. int GetComponentHeight(int component); // Width of a component in bytes with padding for DCTSIZE. Public for testing. int GetComponentStride(int component); // Size of a component in bytes. int GetComponentSize(int component); // Call this after LoadFrame() if you decide you don't want to decode it // after all. LIBYUV_BOOL UnloadFrame(); // Decodes the entire image into a one-buffer-per-color-component format. // dst_width must match exactly. dst_height must be <= to image height; if // less, the image is cropped. "planes" must have size equal to at least // GetNumComponents() and they must point to non-overlapping buffers of size // at least GetComponentSize(i). The pointers in planes are incremented // to point to after the end of the written data. // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. LIBYUV_BOOL DecodeToBuffers(uint8** planes, int dst_width, int dst_height); // Decodes the entire image and passes the data via repeated calls to a // callback function. Each call will get the data for a whole number of // image scanlines. // TODO(fbarchard): Add dst_x, dst_y to allow specific rect to be decoded. LIBYUV_BOOL DecodeToCallback(CallbackFunction fn, void* opaque, int dst_width, int dst_height); // The helper function which recognizes the jpeg sub-sampling type. static JpegSubsamplingType JpegSubsamplingTypeHelper( int* subsample_x, int* subsample_y, int number_of_components); private: void AllocOutputBuffers(int num_outbufs); void DestroyOutputBuffers(); LIBYUV_BOOL StartDecode(); LIBYUV_BOOL FinishDecode(); void SetScanlinePointers(uint8** data); LIBYUV_BOOL DecodeImcuRow(); int GetComponentScanlinePadding(int component); // A buffer holding the input data for a frame. Buffer buf_; BufferVector buf_vec_; jpeg_decompress_struct* decompress_struct_; jpeg_source_mgr* source_mgr_; SetJmpErrorMgr* error_mgr_; // LIBYUV_TRUE iff at least one component has scanline padding. (i.e., // GetComponentScanlinePadding() != 0.) LIBYUV_BOOL has_scanline_padding_; // Temporaries used to point to scanline outputs. int num_outbufs_; // Outermost size of all arrays below. uint8*** scanlines_; int* scanlines_sizes_; // Temporary buffer used for decoding when we can't decode directly to the // output buffers. Large enough for just one iMCU row. uint8** databuf_; int* databuf_strides_; }; } // namespace libyuv #endif // __cplusplus #endif // INCLUDE_LIBYUV_MJPEG_DECODER_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/planar_functions.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ #define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ #include "libyuv/basic_types.h" // TODO(fbarchard): Remove the following headers includes. #include "libyuv/convert.h" #include "libyuv/convert_argb.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Copy a plane of data. LIBYUV_API void CopyPlane(const uint8* src_y, int src_stride_y, uint8* dst_y, int dst_stride_y, int width, int height); LIBYUV_API void CopyPlane_16(const uint16* src_y, int src_stride_y, uint16* dst_y, int dst_stride_y, int width, int height); // Set a plane of data to a 32 bit value. LIBYUV_API void SetPlane(uint8* dst_y, int dst_stride_y, int width, int height, uint32 value); // Split interleaved UV plane into separate U and V planes. LIBYUV_API void SplitUVPlane(const uint8* src_uv, int src_stride_uv, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Merge separate U and V planes into one interleaved UV plane. LIBYUV_API void MergeUVPlane(const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_uv, int dst_stride_uv, int width, int height); // Copy I400. Supports inverting. LIBYUV_API int I400ToI400(const uint8* src_y, int src_stride_y, uint8* dst_y, int dst_stride_y, int width, int height); #define J400ToJ400 I400ToI400 // Copy I422 to I422. #define I422ToI422 I422Copy LIBYUV_API int I422Copy(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Copy I444 to I444. #define I444ToI444 I444Copy LIBYUV_API int I444Copy(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert YUY2 to I422. LIBYUV_API int YUY2ToI422(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Convert UYVY to I422. LIBYUV_API int UYVYToI422(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); LIBYUV_API int YUY2ToNV12(const uint8* src_yuy2, int src_stride_yuy2, uint8* dst_y, int dst_stride_y, uint8* dst_uv, int dst_stride_uv, int width, int height); LIBYUV_API int UYVYToNV12(const uint8* src_uyvy, int src_stride_uyvy, uint8* dst_y, int dst_stride_y, uint8* dst_uv, int dst_stride_uv, int width, int height); // Convert I420 to I400. (calls CopyPlane ignoring u/v). LIBYUV_API int I420ToI400(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, int width, int height); // Alias #define J420ToJ400 I420ToI400 #define I420ToI420Mirror I420Mirror // I420 mirror. LIBYUV_API int I420Mirror(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Alias #define I400ToI400Mirror I400Mirror // I400 mirror. A single plane is mirrored horizontally. // Pass negative height to achieve 180 degree rotation. LIBYUV_API int I400Mirror(const uint8* src_y, int src_stride_y, uint8* dst_y, int dst_stride_y, int width, int height); // Alias #define ARGBToARGBMirror ARGBMirror // ARGB mirror. LIBYUV_API int ARGBMirror(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert NV12 to RGB565. LIBYUV_API int NV12ToRGB565(const uint8* src_y, int src_stride_y, const uint8* src_uv, int src_stride_uv, uint8* dst_rgb565, int dst_stride_rgb565, int width, int height); // I422ToARGB is in convert_argb.h // Convert I422 to BGRA. LIBYUV_API int I422ToBGRA(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_bgra, int dst_stride_bgra, int width, int height); // Convert I422 to ABGR. LIBYUV_API int I422ToABGR(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_abgr, int dst_stride_abgr, int width, int height); // Convert I422 to RGBA. LIBYUV_API int I422ToRGBA(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_rgba, int dst_stride_rgba, int width, int height); // Alias #define RGB24ToRAW RAWToRGB24 LIBYUV_API int RAWToRGB24(const uint8* src_raw, int src_stride_raw, uint8* dst_rgb24, int dst_stride_rgb24, int width, int height); // Draw a rectangle into I420. LIBYUV_API int I420Rect(uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int x, int y, int width, int height, int value_y, int value_u, int value_v); // Draw a rectangle into ARGB. LIBYUV_API int ARGBRect(uint8* dst_argb, int dst_stride_argb, int x, int y, int width, int height, uint32 value); // Convert ARGB to gray scale ARGB. LIBYUV_API int ARGBGrayTo(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Make a rectangle of ARGB gray scale. LIBYUV_API int ARGBGray(uint8* dst_argb, int dst_stride_argb, int x, int y, int width, int height); // Make a rectangle of ARGB Sepia tone. LIBYUV_API int ARGBSepia(uint8* dst_argb, int dst_stride_argb, int x, int y, int width, int height); // Apply a matrix rotation to each ARGB pixel. // matrix_argb is 4 signed ARGB values. -128 to 127 representing -2 to 2. // The first 4 coefficients apply to B, G, R, A and produce B of the output. // The next 4 coefficients apply to B, G, R, A and produce G of the output. // The next 4 coefficients apply to B, G, R, A and produce R of the output. // The last 4 coefficients apply to B, G, R, A and produce A of the output. LIBYUV_API int ARGBColorMatrix(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, const int8* matrix_argb, int width, int height); // Deprecated. Use ARGBColorMatrix instead. // Apply a matrix rotation to each ARGB pixel. // matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1. // The first 4 coefficients apply to B, G, R, A and produce B of the output. // The next 4 coefficients apply to B, G, R, A and produce G of the output. // The last 4 coefficients apply to B, G, R, A and produce R of the output. LIBYUV_API int RGBColorMatrix(uint8* dst_argb, int dst_stride_argb, const int8* matrix_rgb, int x, int y, int width, int height); // Apply a color table each ARGB pixel. // Table contains 256 ARGB values. LIBYUV_API int ARGBColorTable(uint8* dst_argb, int dst_stride_argb, const uint8* table_argb, int x, int y, int width, int height); // Apply a color table each ARGB pixel but preserve destination alpha. // Table contains 256 ARGB values. LIBYUV_API int RGBColorTable(uint8* dst_argb, int dst_stride_argb, const uint8* table_argb, int x, int y, int width, int height); // Apply a luma/color table each ARGB pixel but preserve destination alpha. // Table contains 32768 values indexed by [Y][C] where 7 it 7 bit luma from // RGB (YJ style) and C is an 8 bit color component (R, G or B). LIBYUV_API int ARGBLumaColorTable(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, const uint8* luma_rgb_table, int width, int height); // Apply a 3 term polynomial to ARGB values. // poly points to a 4x4 matrix. The first row is constants. The 2nd row is // coefficients for b, g, r and a. The 3rd row is coefficients for b squared, // g squared, r squared and a squared. The 4rd row is coefficients for b to // the 3, g to the 3, r to the 3 and a to the 3. The values are summed and // result clamped to 0 to 255. // A polynomial approximation can be dirived using software such as 'R'. LIBYUV_API int ARGBPolynomial(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, const float* poly, int width, int height); // Convert plane of 16 bit shorts to half floats. // Source values are multiplied by scale before storing as half float. LIBYUV_API int HalfFloatPlane(const uint16* src_y, int src_stride_y, uint16* dst_y, int dst_stride_y, float scale, int width, int height); // Quantize a rectangle of ARGB. Alpha unaffected. // scale is a 16 bit fractional fixed point scaler between 0 and 65535. // interval_size should be a value between 1 and 255. // interval_offset should be a value between 0 and 255. LIBYUV_API int ARGBQuantize(uint8* dst_argb, int dst_stride_argb, int scale, int interval_size, int interval_offset, int x, int y, int width, int height); // Copy ARGB to ARGB. LIBYUV_API int ARGBCopy(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Copy Alpha channel of ARGB to alpha of ARGB. LIBYUV_API int ARGBCopyAlpha(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Extract the alpha channel from ARGB. LIBYUV_API int ARGBExtractAlpha(const uint8* src_argb, int src_stride_argb, uint8* dst_a, int dst_stride_a, int width, int height); // Copy Y channel to Alpha of ARGB. LIBYUV_API int ARGBCopyYToAlpha(const uint8* src_y, int src_stride_y, uint8* dst_argb, int dst_stride_argb, int width, int height); typedef void (*ARGBBlendRow)(const uint8* src_argb0, const uint8* src_argb1, uint8* dst_argb, int width); // Get function to Alpha Blend ARGB pixels and store to destination. LIBYUV_API ARGBBlendRow GetARGBBlend(); // Alpha Blend ARGB images and store to destination. // Source is pre-multiplied by alpha using ARGBAttenuate. // Alpha of destination is set to 255. LIBYUV_API int ARGBBlend(const uint8* src_argb0, int src_stride_argb0, const uint8* src_argb1, int src_stride_argb1, uint8* dst_argb, int dst_stride_argb, int width, int height); // Alpha Blend plane and store to destination. // Source is not pre-multiplied by alpha. LIBYUV_API int BlendPlane(const uint8* src_y0, int src_stride_y0, const uint8* src_y1, int src_stride_y1, const uint8* alpha, int alpha_stride, uint8* dst_y, int dst_stride_y, int width, int height); // Alpha Blend YUV images and store to destination. // Source is not pre-multiplied by alpha. // Alpha is full width x height and subsampled to half size to apply to UV. LIBYUV_API int I420Blend(const uint8* src_y0, int src_stride_y0, const uint8* src_u0, int src_stride_u0, const uint8* src_v0, int src_stride_v0, const uint8* src_y1, int src_stride_y1, const uint8* src_u1, int src_stride_u1, const uint8* src_v1, int src_stride_v1, const uint8* alpha, int alpha_stride, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height); // Multiply ARGB image by ARGB image. Shifted down by 8. Saturates to 255. LIBYUV_API int ARGBMultiply(const uint8* src_argb0, int src_stride_argb0, const uint8* src_argb1, int src_stride_argb1, uint8* dst_argb, int dst_stride_argb, int width, int height); // Add ARGB image with ARGB image. Saturates to 255. LIBYUV_API int ARGBAdd(const uint8* src_argb0, int src_stride_argb0, const uint8* src_argb1, int src_stride_argb1, uint8* dst_argb, int dst_stride_argb, int width, int height); // Subtract ARGB image (argb1) from ARGB image (argb0). Saturates to 0. LIBYUV_API int ARGBSubtract(const uint8* src_argb0, int src_stride_argb0, const uint8* src_argb1, int src_stride_argb1, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert I422 to YUY2. LIBYUV_API int I422ToYUY2(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); // Convert I422 to UYVY. LIBYUV_API int I422ToUYVY(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_frame, int dst_stride_frame, int width, int height); // Convert unattentuated ARGB to preattenuated ARGB. LIBYUV_API int ARGBAttenuate(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Convert preattentuated ARGB to unattenuated ARGB. LIBYUV_API int ARGBUnattenuate(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Internal function - do not call directly. // Computes table of cumulative sum for image where the value is the sum // of all values above and to the left of the entry. Used by ARGBBlur. LIBYUV_API int ARGBComputeCumulativeSum(const uint8* src_argb, int src_stride_argb, int32* dst_cumsum, int dst_stride32_cumsum, int width, int height); // Blur ARGB image. // dst_cumsum table of width * (height + 1) * 16 bytes aligned to // 16 byte boundary. // dst_stride32_cumsum is number of ints in a row (width * 4). // radius is number of pixels around the center. e.g. 1 = 3x3. 2=5x5. // Blur is optimized for radius of 5 (11x11) or less. LIBYUV_API int ARGBBlur(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int32* dst_cumsum, int dst_stride32_cumsum, int width, int height, int radius); // Multiply ARGB image by ARGB value. LIBYUV_API int ARGBShade(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height, uint32 value); // Interpolate between two images using specified amount of interpolation // (0 to 255) and store to destination. // 'interpolation' is specified as 8 bit fraction where 0 means 100% src0 // and 255 means 1% src0 and 99% src1. LIBYUV_API int InterpolatePlane(const uint8* src0, int src_stride0, const uint8* src1, int src_stride1, uint8* dst, int dst_stride, int width, int height, int interpolation); // Interpolate between two ARGB images using specified amount of interpolation // Internally calls InterpolatePlane with width * 4 (bpp). LIBYUV_API int ARGBInterpolate(const uint8* src_argb0, int src_stride_argb0, const uint8* src_argb1, int src_stride_argb1, uint8* dst_argb, int dst_stride_argb, int width, int height, int interpolation); // Interpolate between two YUV images using specified amount of interpolation // Internally calls InterpolatePlane on each plane where the U and V planes // are half width and half height. LIBYUV_API int I420Interpolate(const uint8* src0_y, int src0_stride_y, const uint8* src0_u, int src0_stride_u, const uint8* src0_v, int src0_stride_v, const uint8* src1_y, int src1_stride_y, const uint8* src1_u, int src1_stride_u, const uint8* src1_v, int src1_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int width, int height, int interpolation); #if defined(__pnacl__) || defined(__CLR_VER) || \ (defined(__i386__) && !defined(__SSE2__)) #define LIBYUV_DISABLE_X86 #endif // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 #if defined(__has_feature) #if __has_feature(memory_sanitizer) #define LIBYUV_DISABLE_X86 #endif #endif // The following are available on all x86 platforms: #if !defined(LIBYUV_DISABLE_X86) && \ (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) #define HAS_ARGBAFFINEROW_SSE2 #endif // Row function for copying pixels from a source with a slope to a row // of destination. Useful for scaling, rotation, mirror, texture mapping. LIBYUV_API void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride, uint8* dst_argb, const float* uv_dudv, int width); LIBYUV_API void ARGBAffineRow_SSE2(const uint8* src_argb, int src_argb_stride, uint8* dst_argb, const float* uv_dudv, int width); // Shuffle ARGB channel order. e.g. BGRA to ARGB. // shuffler is 16 bytes and must be aligned. LIBYUV_API int ARGBShuffle(const uint8* src_bgra, int src_stride_bgra, uint8* dst_argb, int dst_stride_argb, const uint8* shuffler, int width, int height); // Sobel ARGB effect with planar output. LIBYUV_API int ARGBSobelToPlane(const uint8* src_argb, int src_stride_argb, uint8* dst_y, int dst_stride_y, int width, int height); // Sobel ARGB effect. LIBYUV_API int ARGBSobel(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); // Sobel ARGB effect w/ Sobel X, Sobel, Sobel Y in ARGB. LIBYUV_API int ARGBSobelXY(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/rotate.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_ROTATE_H_ #define INCLUDE_LIBYUV_ROTATE_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Supported rotation. typedef enum RotationMode { kRotate0 = 0, // No rotation. kRotate90 = 90, // Rotate 90 degrees clockwise. kRotate180 = 180, // Rotate 180 degrees. kRotate270 = 270, // Rotate 270 degrees clockwise. // Deprecated. kRotateNone = 0, kRotateClockwise = 90, kRotateCounterClockwise = 270, } RotationModeEnum; // Rotate I420 frame. LIBYUV_API int I420Rotate(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int src_width, int src_height, enum RotationMode mode); // Rotate NV12 input and store in I420. LIBYUV_API int NV12ToI420Rotate(const uint8* src_y, int src_stride_y, const uint8* src_uv, int src_stride_uv, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int src_width, int src_height, enum RotationMode mode); // Rotate a plane by 0, 90, 180, or 270. LIBYUV_API int RotatePlane(const uint8* src, int src_stride, uint8* dst, int dst_stride, int src_width, int src_height, enum RotationMode mode); // Rotate planes by 90, 180, 270. Deprecated. LIBYUV_API void RotatePlane90(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height); LIBYUV_API void RotatePlane180(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height); LIBYUV_API void RotatePlane270(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height); LIBYUV_API void RotateUV90(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width, int height); // Rotations for when U and V are interleaved. // These functions take one input pointer and // split the data into two buffers while // rotating them. Deprecated. LIBYUV_API void RotateUV180(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width, int height); LIBYUV_API void RotateUV270(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width, int height); // The 90 and 270 functions are based on transposes. // Doing a transpose with reversing the read/write // order will result in a rotation by +- 90 degrees. // Deprecated. LIBYUV_API void TransposePlane(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height); LIBYUV_API void TransposeUV(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width, int height); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_ROTATE_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/rotate_argb.h ================================================ /* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_ROTATE_ARGB_H_ #define INCLUDE_LIBYUV_ROTATE_ARGB_H_ #include "libyuv/basic_types.h" #include "libyuv/rotate.h" // For RotationMode. #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Rotate ARGB frame LIBYUV_API int ARGBRotate(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int src_width, int src_height, enum RotationMode mode); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_ROTATE_ARGB_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/rotate_row.h ================================================ /* * Copyright 2013 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_ROTATE_ROW_H_ #define INCLUDE_LIBYUV_ROTATE_ROW_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif #if defined(__pnacl__) || defined(__CLR_VER) || \ (defined(__i386__) && !defined(__SSE2__)) #define LIBYUV_DISABLE_X86 #endif // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 #if defined(__has_feature) #if __has_feature(memory_sanitizer) #define LIBYUV_DISABLE_X86 #endif #endif // The following are available for Visual C and clangcl 32 bit: #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) #define HAS_TRANSPOSEWX8_SSSE3 #define HAS_TRANSPOSEUVWX8_SSE2 #endif // The following are available for GCC 32 or 64 bit but not NaCL for 64 bit: #if !defined(LIBYUV_DISABLE_X86) && \ (defined(__i386__) || (defined(__x86_64__) && !defined(__native_client__))) #define HAS_TRANSPOSEWX8_SSSE3 #endif // The following are available for 64 bit GCC but not NaCL: #if !defined(LIBYUV_DISABLE_X86) && !defined(__native_client__) && \ defined(__x86_64__) #define HAS_TRANSPOSEWX8_FAST_SSSE3 #define HAS_TRANSPOSEUVWX8_SSE2 #endif #if !defined(LIBYUV_DISABLE_NEON) && !defined(__native_client__) && \ (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) #define HAS_TRANSPOSEWX8_NEON #define HAS_TRANSPOSEUVWX8_NEON #endif #if !defined(LIBYUV_DISABLE_MIPS) && !defined(__native_client__) && \ defined(__mips__) && \ defined(__mips_dsp) && (__mips_dsp_rev >= 2) #define HAS_TRANSPOSEWX8_DSPR2 #define HAS_TRANSPOSEUVWX8_DSPR2 #endif // defined(__mips__) void TransposeWxH_C(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width, int height); void TransposeWx8_C(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_NEON(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_SSSE3(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_Fast_SSSE3(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_DSPR2(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_Fast_DSPR2(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_Any_NEON(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_Any_SSSE3(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_Fast_Any_SSSE3(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeWx8_Any_DSPR2(const uint8* src, int src_stride, uint8* dst, int dst_stride, int width); void TransposeUVWxH_C(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width, int height); void TransposeUVWx8_C(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); void TransposeUVWx8_SSE2(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); void TransposeUVWx8_NEON(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); void TransposeUVWx8_DSPR2(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); void TransposeUVWx8_Any_SSE2(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); void TransposeUVWx8_Any_NEON(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); void TransposeUVWx8_Any_DSPR2(const uint8* src, int src_stride, uint8* dst_a, int dst_stride_a, uint8* dst_b, int dst_stride_b, int width); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_ROTATE_ROW_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/row.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_ROW_H_ #define INCLUDE_LIBYUV_ROW_H_ #include // For malloc. #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif #define IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) #define align_buffer_64(var, size) \ uint8* var##_mem = (uint8*)(malloc((size) + 63)); /* NOLINT */ \ uint8* var = (uint8*)(((intptr_t)(var##_mem) + 63) & ~63) /* NOLINT */ #define free_aligned_buffer_64(var) \ free(var##_mem); \ var = 0 #if defined(__pnacl__) || defined(__CLR_VER) || \ (defined(__i386__) && !defined(__SSE2__)) #define LIBYUV_DISABLE_X86 #endif // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 #if defined(__has_feature) #if __has_feature(memory_sanitizer) #define LIBYUV_DISABLE_X86 #endif #endif // True if compiling for SSSE3 as a requirement. #if defined(__SSSE3__) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 3)) #define LIBYUV_SSSE3_ONLY #endif #if defined(__native_client__) #define LIBYUV_DISABLE_NEON #endif // clang >= 3.5.0 required for Arm64. #if defined(__clang__) && defined(__aarch64__) && !defined(LIBYUV_DISABLE_NEON) #if (__clang_major__ < 3) || (__clang_major__ == 3 && (__clang_minor__ < 5)) #define LIBYUV_DISABLE_NEON #endif // clang >= 3.5 #endif // __clang__ // GCC >= 4.7.0 required for AVX2. #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) #if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7)) #define GCC_HAS_AVX2 1 #endif // GNUC >= 4.7 #endif // __GNUC__ // clang >= 3.4.0 required for AVX2. #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) #define CLANG_HAS_AVX2 1 #endif // clang >= 3.4 #endif // __clang__ // Visual C 2012 required for AVX2. #if defined(_M_IX86) && !defined(__clang__) && \ defined(_MSC_VER) && _MSC_VER >= 1700 #define VISUALC_HAS_AVX2 1 #endif // VisualStudio >= 2012 // The following are available on all x86 platforms: #if !defined(LIBYUV_DISABLE_X86) && \ (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) // Conversions: #define HAS_ABGRTOUVROW_SSSE3 #define HAS_ABGRTOYROW_SSSE3 #define HAS_ARGB1555TOARGBROW_SSE2 #define HAS_ARGB4444TOARGBROW_SSE2 #define HAS_ARGBSETROW_X86 #define HAS_ARGBSHUFFLEROW_SSE2 #define HAS_ARGBSHUFFLEROW_SSSE3 #define HAS_ARGBTOARGB1555ROW_SSE2 #define HAS_ARGBTOARGB4444ROW_SSE2 #define HAS_ARGBTORAWROW_SSSE3 #define HAS_ARGBTORGB24ROW_SSSE3 #define HAS_ARGBTORGB565DITHERROW_SSE2 #define HAS_ARGBTORGB565ROW_SSE2 #define HAS_ARGBTOUV444ROW_SSSE3 #define HAS_ARGBTOUVJROW_SSSE3 #define HAS_ARGBTOUVROW_SSSE3 #define HAS_ARGBTOYJROW_SSSE3 #define HAS_ARGBTOYROW_SSSE3 #define HAS_ARGBEXTRACTALPHAROW_SSE2 #define HAS_BGRATOUVROW_SSSE3 #define HAS_BGRATOYROW_SSSE3 #define HAS_COPYROW_ERMS #define HAS_COPYROW_SSE2 #define HAS_H422TOARGBROW_SSSE3 #define HAS_I400TOARGBROW_SSE2 #define HAS_I422TOARGB1555ROW_SSSE3 #define HAS_I422TOARGB4444ROW_SSSE3 #define HAS_I422TOARGBROW_SSSE3 #define HAS_I422TORGB24ROW_SSSE3 #define HAS_I422TORGB565ROW_SSSE3 #define HAS_I422TORGBAROW_SSSE3 #define HAS_I422TOUYVYROW_SSE2 #define HAS_I422TOYUY2ROW_SSE2 #define HAS_I444TOARGBROW_SSSE3 #define HAS_J400TOARGBROW_SSE2 #define HAS_J422TOARGBROW_SSSE3 #define HAS_MERGEUVROW_SSE2 #define HAS_MIRRORROW_SSSE3 #define HAS_MIRRORUVROW_SSSE3 #define HAS_NV12TOARGBROW_SSSE3 #define HAS_NV12TORGB565ROW_SSSE3 #define HAS_NV21TOARGBROW_SSSE3 #define HAS_RAWTOARGBROW_SSSE3 #define HAS_RAWTORGB24ROW_SSSE3 #define HAS_RAWTOYROW_SSSE3 #define HAS_RGB24TOARGBROW_SSSE3 #define HAS_RGB24TOYROW_SSSE3 #define HAS_RGB565TOARGBROW_SSE2 #define HAS_RGBATOUVROW_SSSE3 #define HAS_RGBATOYROW_SSSE3 #define HAS_SETROW_ERMS #define HAS_SETROW_X86 #define HAS_SPLITUVROW_SSE2 #define HAS_UYVYTOARGBROW_SSSE3 #define HAS_UYVYTOUV422ROW_SSE2 #define HAS_UYVYTOUVROW_SSE2 #define HAS_UYVYTOYROW_SSE2 #define HAS_YUY2TOARGBROW_SSSE3 #define HAS_YUY2TOUV422ROW_SSE2 #define HAS_YUY2TOUVROW_SSE2 #define HAS_YUY2TOYROW_SSE2 // Effects: #define HAS_ARGBADDROW_SSE2 #define HAS_ARGBAFFINEROW_SSE2 #define HAS_ARGBATTENUATEROW_SSSE3 #define HAS_ARGBBLENDROW_SSSE3 #define HAS_ARGBCOLORMATRIXROW_SSSE3 #define HAS_ARGBCOLORTABLEROW_X86 #define HAS_ARGBCOPYALPHAROW_SSE2 #define HAS_ARGBCOPYYTOALPHAROW_SSE2 #define HAS_ARGBGRAYROW_SSSE3 #define HAS_ARGBLUMACOLORTABLEROW_SSSE3 #define HAS_ARGBMIRRORROW_SSE2 #define HAS_ARGBMULTIPLYROW_SSE2 #define HAS_ARGBPOLYNOMIALROW_SSE2 #define HAS_ARGBQUANTIZEROW_SSE2 #define HAS_ARGBSEPIAROW_SSSE3 #define HAS_ARGBSHADEROW_SSE2 #define HAS_ARGBSUBTRACTROW_SSE2 #define HAS_ARGBUNATTENUATEROW_SSE2 #define HAS_BLENDPLANEROW_SSSE3 #define HAS_COMPUTECUMULATIVESUMROW_SSE2 #define HAS_CUMULATIVESUMTOAVERAGEROW_SSE2 #define HAS_INTERPOLATEROW_SSSE3 #define HAS_RGBCOLORTABLEROW_X86 #define HAS_SOBELROW_SSE2 #define HAS_SOBELTOPLANEROW_SSE2 #define HAS_SOBELXROW_SSE2 #define HAS_SOBELXYROW_SSE2 #define HAS_SOBELYROW_SSE2 // The following functions fail on gcc/clang 32 bit with fpic and framepointer. // caveat: clangcl uses row_win.cc which works. #if defined(NDEBUG) || !(defined(_DEBUG) && defined(__i386__)) || \ !defined(__i386__) || defined(_MSC_VER) // TODO(fbarchard): fix build error on x86 debug // https://code.google.com/p/libyuv/issues/detail?id=524 #define HAS_I411TOARGBROW_SSSE3 // TODO(fbarchard): fix build error on android_full_debug=1 // https://code.google.com/p/libyuv/issues/detail?id=517 #define HAS_I422ALPHATOARGBROW_SSSE3 #endif #endif // The following are available on all x86 platforms, but // require VS2012, clang 3.4 or gcc 4.7. // The code supports NaCL but requires a new compiler and validator. #if !defined(LIBYUV_DISABLE_X86) && (defined(VISUALC_HAS_AVX2) || \ defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2)) #define HAS_ARGBCOPYALPHAROW_AVX2 #define HAS_ARGBCOPYYTOALPHAROW_AVX2 #define HAS_ARGBMIRRORROW_AVX2 #define HAS_ARGBPOLYNOMIALROW_AVX2 #define HAS_ARGBSHUFFLEROW_AVX2 #define HAS_ARGBTORGB565DITHERROW_AVX2 #define HAS_ARGBTOUVJROW_AVX2 #define HAS_ARGBTOUVROW_AVX2 #define HAS_ARGBTOYJROW_AVX2 #define HAS_ARGBTOYROW_AVX2 #define HAS_COPYROW_AVX #define HAS_H422TOARGBROW_AVX2 #define HAS_I400TOARGBROW_AVX2 #if !(defined(_DEBUG) && defined(__i386__)) // TODO(fbarchard): fix build error on android_full_debug=1 // https://code.google.com/p/libyuv/issues/detail?id=517 #define HAS_I422ALPHATOARGBROW_AVX2 #endif #define HAS_I411TOARGBROW_AVX2 #define HAS_I422TOARGB1555ROW_AVX2 #define HAS_I422TOARGB4444ROW_AVX2 #define HAS_I422TOARGBROW_AVX2 #define HAS_I422TORGB24ROW_AVX2 #define HAS_I422TORGB565ROW_AVX2 #define HAS_I422TORGBAROW_AVX2 #define HAS_I444TOARGBROW_AVX2 #define HAS_INTERPOLATEROW_AVX2 #define HAS_J422TOARGBROW_AVX2 #define HAS_MERGEUVROW_AVX2 #define HAS_MIRRORROW_AVX2 #define HAS_NV12TOARGBROW_AVX2 #define HAS_NV12TORGB565ROW_AVX2 #define HAS_NV21TOARGBROW_AVX2 #define HAS_SPLITUVROW_AVX2 #define HAS_UYVYTOARGBROW_AVX2 #define HAS_UYVYTOUV422ROW_AVX2 #define HAS_UYVYTOUVROW_AVX2 #define HAS_UYVYTOYROW_AVX2 #define HAS_YUY2TOARGBROW_AVX2 #define HAS_YUY2TOUV422ROW_AVX2 #define HAS_YUY2TOUVROW_AVX2 #define HAS_YUY2TOYROW_AVX2 #define HAS_HALFFLOATROW_AVX2 // Effects: #define HAS_ARGBADDROW_AVX2 #define HAS_ARGBATTENUATEROW_AVX2 #define HAS_ARGBMULTIPLYROW_AVX2 #define HAS_ARGBSUBTRACTROW_AVX2 #define HAS_ARGBUNATTENUATEROW_AVX2 #define HAS_BLENDPLANEROW_AVX2 #endif // The following are available for AVX2 Visual C and clangcl 32 bit: // TODO(fbarchard): Port to gcc. #if !defined(LIBYUV_DISABLE_X86) && defined(_M_IX86) && \ (defined(VISUALC_HAS_AVX2) || defined(CLANG_HAS_AVX2)) #define HAS_ARGB1555TOARGBROW_AVX2 #define HAS_ARGB4444TOARGBROW_AVX2 #define HAS_ARGBTOARGB1555ROW_AVX2 #define HAS_ARGBTOARGB4444ROW_AVX2 #define HAS_ARGBTORGB565ROW_AVX2 #define HAS_J400TOARGBROW_AVX2 #define HAS_RGB565TOARGBROW_AVX2 #endif // The following are also available on x64 Visual C. #if !defined(LIBYUV_DISABLE_X86) && defined(_MSC_VER) && defined(_M_X64) && \ (!defined(__clang__) || defined(__SSSE3__)) #define HAS_I422ALPHATOARGBROW_SSSE3 #define HAS_I422TOARGBROW_SSSE3 #endif // The following are available on gcc x86 platforms: // TODO(fbarchard): Port to Visual C. #if !defined(LIBYUV_DISABLE_X86) && \ (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER))) #define HAS_HALFFLOATROW_SSE2 #endif // The following are available on Neon platforms: #if !defined(LIBYUV_DISABLE_NEON) && \ (defined(__aarch64__) || defined(__ARM_NEON__) || defined(LIBYUV_NEON)) #define HAS_ABGRTOUVROW_NEON #define HAS_ABGRTOYROW_NEON #define HAS_ARGB1555TOARGBROW_NEON #define HAS_ARGB1555TOUVROW_NEON #define HAS_ARGB1555TOYROW_NEON #define HAS_ARGB4444TOARGBROW_NEON #define HAS_ARGB4444TOUVROW_NEON #define HAS_ARGB4444TOYROW_NEON #define HAS_ARGBSETROW_NEON #define HAS_ARGBTOARGB1555ROW_NEON #define HAS_ARGBTOARGB4444ROW_NEON #define HAS_ARGBTORAWROW_NEON #define HAS_ARGBTORGB24ROW_NEON #define HAS_ARGBTORGB565DITHERROW_NEON #define HAS_ARGBTORGB565ROW_NEON #define HAS_ARGBTOUV411ROW_NEON #define HAS_ARGBTOUV444ROW_NEON #define HAS_ARGBTOUVJROW_NEON #define HAS_ARGBTOUVROW_NEON #define HAS_ARGBTOYJROW_NEON #define HAS_ARGBTOYROW_NEON #define HAS_ARGBEXTRACTALPHAROW_NEON #define HAS_BGRATOUVROW_NEON #define HAS_BGRATOYROW_NEON #define HAS_COPYROW_NEON #define HAS_I400TOARGBROW_NEON #define HAS_I411TOARGBROW_NEON #define HAS_I422ALPHATOARGBROW_NEON #define HAS_I422TOARGB1555ROW_NEON #define HAS_I422TOARGB4444ROW_NEON #define HAS_I422TOARGBROW_NEON #define HAS_I422TORGB24ROW_NEON #define HAS_I422TORGB565ROW_NEON #define HAS_I422TORGBAROW_NEON #define HAS_I422TOUYVYROW_NEON #define HAS_I422TOYUY2ROW_NEON #define HAS_I444TOARGBROW_NEON #define HAS_J400TOARGBROW_NEON #define HAS_MERGEUVROW_NEON #define HAS_MIRRORROW_NEON #define HAS_MIRRORUVROW_NEON #define HAS_NV12TOARGBROW_NEON #define HAS_NV12TORGB565ROW_NEON #define HAS_NV21TOARGBROW_NEON #define HAS_RAWTOARGBROW_NEON #define HAS_RAWTORGB24ROW_NEON #define HAS_RAWTOUVROW_NEON #define HAS_RAWTOYROW_NEON #define HAS_RGB24TOARGBROW_NEON #define HAS_RGB24TOUVROW_NEON #define HAS_RGB24TOYROW_NEON #define HAS_RGB565TOARGBROW_NEON #define HAS_RGB565TOUVROW_NEON #define HAS_RGB565TOYROW_NEON #define HAS_RGBATOUVROW_NEON #define HAS_RGBATOYROW_NEON #define HAS_SETROW_NEON #define HAS_SPLITUVROW_NEON #define HAS_UYVYTOARGBROW_NEON #define HAS_UYVYTOUV422ROW_NEON #define HAS_UYVYTOUVROW_NEON #define HAS_UYVYTOYROW_NEON #define HAS_YUY2TOARGBROW_NEON #define HAS_YUY2TOUV422ROW_NEON #define HAS_YUY2TOUVROW_NEON #define HAS_YUY2TOYROW_NEON // Effects: #define HAS_ARGBADDROW_NEON #define HAS_ARGBATTENUATEROW_NEON #define HAS_ARGBBLENDROW_NEON #define HAS_ARGBCOLORMATRIXROW_NEON #define HAS_ARGBGRAYROW_NEON #define HAS_ARGBMIRRORROW_NEON #define HAS_ARGBMULTIPLYROW_NEON #define HAS_ARGBQUANTIZEROW_NEON #define HAS_ARGBSEPIAROW_NEON #define HAS_ARGBSHADEROW_NEON #define HAS_ARGBSHUFFLEROW_NEON #define HAS_ARGBSUBTRACTROW_NEON #define HAS_INTERPOLATEROW_NEON #define HAS_SOBELROW_NEON #define HAS_SOBELTOPLANEROW_NEON #define HAS_SOBELXROW_NEON #define HAS_SOBELXYROW_NEON #define HAS_SOBELYROW_NEON #endif // The following are available on Mips platforms: #if !defined(LIBYUV_DISABLE_MIPS) && defined(__mips__) && \ (_MIPS_SIM == _MIPS_SIM_ABI32) && (__mips_isa_rev < 6) #define HAS_COPYROW_MIPS #if defined(__mips_dsp) && (__mips_dsp_rev >= 2) #define HAS_I422TOARGBROW_DSPR2 #define HAS_INTERPOLATEROW_DSPR2 #define HAS_MIRRORROW_DSPR2 #define HAS_MIRRORUVROW_DSPR2 #define HAS_SPLITUVROW_DSPR2 #endif #endif #if !defined(LIBYUV_DISABLE_MSA) && defined(__mips_msa) #define HAS_MIRRORROW_MSA #define HAS_ARGBMIRRORROW_MSA #endif #if defined(_MSC_VER) && !defined(__CLR_VER) && !defined(__clang__) #if defined(VISUALC_HAS_AVX2) #define SIMD_ALIGNED(var) __declspec(align(32)) var #else #define SIMD_ALIGNED(var) __declspec(align(16)) var #endif typedef __declspec(align(16)) int16 vec16[8]; typedef __declspec(align(16)) int32 vec32[4]; typedef __declspec(align(16)) int8 vec8[16]; typedef __declspec(align(16)) uint16 uvec16[8]; typedef __declspec(align(16)) uint32 uvec32[4]; typedef __declspec(align(16)) uint8 uvec8[16]; typedef __declspec(align(32)) int16 lvec16[16]; typedef __declspec(align(32)) int32 lvec32[8]; typedef __declspec(align(32)) int8 lvec8[32]; typedef __declspec(align(32)) uint16 ulvec16[16]; typedef __declspec(align(32)) uint32 ulvec32[8]; typedef __declspec(align(32)) uint8 ulvec8[32]; #elif !defined(__pnacl__) && (defined(__GNUC__) || defined(__clang__)) // Caveat GCC 4.2 to 4.7 have a known issue using vectors with const. #if defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2) #define SIMD_ALIGNED(var) var __attribute__((aligned(32))) #else #define SIMD_ALIGNED(var) var __attribute__((aligned(16))) #endif typedef int16 __attribute__((vector_size(16))) vec16; typedef int32 __attribute__((vector_size(16))) vec32; typedef int8 __attribute__((vector_size(16))) vec8; typedef uint16 __attribute__((vector_size(16))) uvec16; typedef uint32 __attribute__((vector_size(16))) uvec32; typedef uint8 __attribute__((vector_size(16))) uvec8; typedef int16 __attribute__((vector_size(32))) lvec16; typedef int32 __attribute__((vector_size(32))) lvec32; typedef int8 __attribute__((vector_size(32))) lvec8; typedef uint16 __attribute__((vector_size(32))) ulvec16; typedef uint32 __attribute__((vector_size(32))) ulvec32; typedef uint8 __attribute__((vector_size(32))) ulvec8; #else #define SIMD_ALIGNED(var) var typedef int16 vec16[8]; typedef int32 vec32[4]; typedef int8 vec8[16]; typedef uint16 uvec16[8]; typedef uint32 uvec32[4]; typedef uint8 uvec8[16]; typedef int16 lvec16[16]; typedef int32 lvec32[8]; typedef int8 lvec8[32]; typedef uint16 ulvec16[16]; typedef uint32 ulvec32[8]; typedef uint8 ulvec8[32]; #endif #if defined(__aarch64__) // This struct is for Arm64 color conversion. struct YuvConstants { uvec16 kUVToRB; uvec16 kUVToRB2; uvec16 kUVToG; uvec16 kUVToG2; vec16 kUVBiasBGR; vec32 kYToRgb; }; #elif defined(__arm__) // This struct is for ArmV7 color conversion. struct YuvConstants { uvec8 kUVToRB; uvec8 kUVToG; vec16 kUVBiasBGR; vec32 kYToRgb; }; #else // This struct is for Intel color conversion. struct YuvConstants { int8 kUVToB[32]; int8 kUVToG[32]; int8 kUVToR[32]; int16 kUVBiasB[16]; int16 kUVBiasG[16]; int16 kUVBiasR[16]; int16 kYToRgb[16]; }; // Offsets into YuvConstants structure #define KUVTOB 0 #define KUVTOG 32 #define KUVTOR 64 #define KUVBIASB 96 #define KUVBIASG 128 #define KUVBIASR 160 #define KYTORGB 192 #endif // Conversion matrix for YUV to RGB extern const struct YuvConstants SIMD_ALIGNED(kYuvI601Constants); // BT.601 extern const struct YuvConstants SIMD_ALIGNED(kYuvJPEGConstants); // JPeg extern const struct YuvConstants SIMD_ALIGNED(kYuvH709Constants); // BT.709 // Conversion matrix for YVU to BGR extern const struct YuvConstants SIMD_ALIGNED(kYvuI601Constants); // BT.601 extern const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants); // JPeg extern const struct YuvConstants SIMD_ALIGNED(kYvuH709Constants); // BT.709 #if defined(__APPLE__) || defined(__x86_64__) || defined(__llvm__) #define OMITFP #else #define OMITFP __attribute__((optimize("omit-frame-pointer"))) #endif // NaCL macros for GCC x86 and x64. #if defined(__native_client__) #define LABELALIGN ".p2align 5\n" #else #define LABELALIGN #endif #if defined(__native_client__) && defined(__x86_64__) // r14 is used for MEMOP macros. #define NACL_R14 "r14", #define BUNDLELOCK ".bundle_lock\n" #define BUNDLEUNLOCK ".bundle_unlock\n" #define MEMACCESS(base) "%%nacl:(%%r15,%q" #base ")" #define MEMACCESS2(offset, base) "%%nacl:" #offset "(%%r15,%q" #base ")" #define MEMLEA(offset, base) #offset "(%q" #base ")" #define MEMLEA3(offset, index, scale) \ #offset "(,%q" #index "," #scale ")" #define MEMLEA4(offset, base, index, scale) \ #offset "(%q" #base ",%q" #index "," #scale ")" #define MEMMOVESTRING(s, d) "%%nacl:(%q" #s "),%%nacl:(%q" #d "), %%r15" #define MEMSTORESTRING(reg, d) "%%" #reg ",%%nacl:(%q" #d "), %%r15" #define MEMOPREG(opcode, offset, base, index, scale, reg) \ BUNDLELOCK \ "lea " #offset "(%q" #base ",%q" #index "," #scale "),%%r14d\n" \ #opcode " (%%r15,%%r14),%%" #reg "\n" \ BUNDLEUNLOCK #define MEMOPMEM(opcode, reg, offset, base, index, scale) \ BUNDLELOCK \ "lea " #offset "(%q" #base ",%q" #index "," #scale "),%%r14d\n" \ #opcode " %%" #reg ",(%%r15,%%r14)\n" \ BUNDLEUNLOCK #define MEMOPARG(opcode, offset, base, index, scale, arg) \ BUNDLELOCK \ "lea " #offset "(%q" #base ",%q" #index "," #scale "),%%r14d\n" \ #opcode " (%%r15,%%r14),%" #arg "\n" \ BUNDLEUNLOCK #define VMEMOPREG(opcode, offset, base, index, scale, reg1, reg2) \ BUNDLELOCK \ "lea " #offset "(%q" #base ",%q" #index "," #scale "),%%r14d\n" \ #opcode " (%%r15,%%r14),%%" #reg1 ",%%" #reg2 "\n" \ BUNDLEUNLOCK #define VEXTOPMEM(op, sel, reg, offset, base, index, scale) \ BUNDLELOCK \ "lea " #offset "(%q" #base ",%q" #index "," #scale "),%%r14d\n" \ #op " $" #sel ",%%" #reg ",(%%r15,%%r14)\n" \ BUNDLEUNLOCK #else // defined(__native_client__) && defined(__x86_64__) #define NACL_R14 #define BUNDLEALIGN #define MEMACCESS(base) "(%" #base ")" #define MEMACCESS2(offset, base) #offset "(%" #base ")" #define MEMLEA(offset, base) #offset "(%" #base ")" #define MEMLEA3(offset, index, scale) \ #offset "(,%" #index "," #scale ")" #define MEMLEA4(offset, base, index, scale) \ #offset "(%" #base ",%" #index "," #scale ")" #define MEMMOVESTRING(s, d) #define MEMSTORESTRING(reg, d) #define MEMOPREG(opcode, offset, base, index, scale, reg) \ #opcode " " #offset "(%" #base ",%" #index "," #scale "),%%" #reg "\n" #define MEMOPMEM(opcode, reg, offset, base, index, scale) \ #opcode " %%" #reg ","#offset "(%" #base ",%" #index "," #scale ")\n" #define MEMOPARG(opcode, offset, base, index, scale, arg) \ #opcode " " #offset "(%" #base ",%" #index "," #scale "),%" #arg "\n" #define VMEMOPREG(opcode, offset, base, index, scale, reg1, reg2) \ #opcode " " #offset "(%" #base ",%" #index "," #scale "),%%" #reg1 ",%%" \ #reg2 "\n" #define VEXTOPMEM(op, sel, reg, offset, base, index, scale) \ #op " $" #sel ",%%" #reg ","#offset "(%" #base ",%" #index "," #scale ")\n" #endif // defined(__native_client__) && defined(__x86_64__) #if defined(__arm__) || defined(__aarch64__) #undef MEMACCESS #if defined(__native_client__) #define MEMACCESS(base) ".p2align 3\nbic %" #base ", #0xc0000000\n" #else #define MEMACCESS(base) #endif #endif void I444ToARGBRow_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_NEON(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, const uint8* a_buf, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgb24, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgb565, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb1555, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb4444, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_NEON(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_NEON(const uint8* src_y, const uint8* src_uv, uint8* dst_rgb565, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_NEON(const uint8* src_y, const uint8* src_vu, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_NEON(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_NEON(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void ARGBToYRow_AVX2(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYRow_Any_AVX2(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYRow_SSSE3(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_AVX2(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_Any_AVX2(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_SSSE3(const uint8* src_argb, uint8* dst_y, int width); void BGRAToYRow_SSSE3(const uint8* src_bgra, uint8* dst_y, int width); void ABGRToYRow_SSSE3(const uint8* src_abgr, uint8* dst_y, int width); void RGBAToYRow_SSSE3(const uint8* src_rgba, uint8* dst_y, int width); void RGB24ToYRow_SSSE3(const uint8* src_rgb24, uint8* dst_y, int width); void RAWToYRow_SSSE3(const uint8* src_raw, uint8* dst_y, int width); void ARGBToYRow_NEON(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_NEON(const uint8* src_argb, uint8* dst_y, int width); void ARGBToUV444Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV411Row_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVRow_NEON(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_NEON(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void BGRAToUVRow_NEON(const uint8* src_bgra, int src_stride_bgra, uint8* dst_u, uint8* dst_v, int width); void ABGRToUVRow_NEON(const uint8* src_abgr, int src_stride_abgr, uint8* dst_u, uint8* dst_v, int width); void RGBAToUVRow_NEON(const uint8* src_rgba, int src_stride_rgba, uint8* dst_u, uint8* dst_v, int width); void RGB24ToUVRow_NEON(const uint8* src_rgb24, int src_stride_rgb24, uint8* dst_u, uint8* dst_v, int width); void RAWToUVRow_NEON(const uint8* src_raw, int src_stride_raw, uint8* dst_u, uint8* dst_v, int width); void RGB565ToUVRow_NEON(const uint8* src_rgb565, int src_stride_rgb565, uint8* dst_u, uint8* dst_v, int width); void ARGB1555ToUVRow_NEON(const uint8* src_argb1555, int src_stride_argb1555, uint8* dst_u, uint8* dst_v, int width); void ARGB4444ToUVRow_NEON(const uint8* src_argb4444, int src_stride_argb4444, uint8* dst_u, uint8* dst_v, int width); void BGRAToYRow_NEON(const uint8* src_bgra, uint8* dst_y, int width); void ABGRToYRow_NEON(const uint8* src_abgr, uint8* dst_y, int width); void RGBAToYRow_NEON(const uint8* src_rgba, uint8* dst_y, int width); void RGB24ToYRow_NEON(const uint8* src_rgb24, uint8* dst_y, int width); void RAWToYRow_NEON(const uint8* src_raw, uint8* dst_y, int width); void RGB565ToYRow_NEON(const uint8* src_rgb565, uint8* dst_y, int width); void ARGB1555ToYRow_NEON(const uint8* src_argb1555, uint8* dst_y, int width); void ARGB4444ToYRow_NEON(const uint8* src_argb4444, uint8* dst_y, int width); void ARGBToYRow_C(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_C(const uint8* src_argb, uint8* dst_y, int width); void BGRAToYRow_C(const uint8* src_bgra, uint8* dst_y, int width); void ABGRToYRow_C(const uint8* src_abgr, uint8* dst_y, int width); void RGBAToYRow_C(const uint8* src_rgba, uint8* dst_y, int width); void RGB24ToYRow_C(const uint8* src_rgb24, uint8* dst_y, int width); void RAWToYRow_C(const uint8* src_raw, uint8* dst_y, int width); void RGB565ToYRow_C(const uint8* src_rgb565, uint8* dst_y, int width); void ARGB1555ToYRow_C(const uint8* src_argb1555, uint8* dst_y, int width); void ARGB4444ToYRow_C(const uint8* src_argb4444, uint8* dst_y, int width); void ARGBToYRow_Any_SSSE3(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_Any_SSSE3(const uint8* src_argb, uint8* dst_y, int width); void BGRAToYRow_Any_SSSE3(const uint8* src_bgra, uint8* dst_y, int width); void ABGRToYRow_Any_SSSE3(const uint8* src_abgr, uint8* dst_y, int width); void RGBAToYRow_Any_SSSE3(const uint8* src_rgba, uint8* dst_y, int width); void RGB24ToYRow_Any_SSSE3(const uint8* src_rgb24, uint8* dst_y, int width); void RAWToYRow_Any_SSSE3(const uint8* src_raw, uint8* dst_y, int width); void ARGBToYRow_Any_NEON(const uint8* src_argb, uint8* dst_y, int width); void ARGBToYJRow_Any_NEON(const uint8* src_argb, uint8* dst_y, int width); void BGRAToYRow_Any_NEON(const uint8* src_bgra, uint8* dst_y, int width); void ABGRToYRow_Any_NEON(const uint8* src_abgr, uint8* dst_y, int width); void RGBAToYRow_Any_NEON(const uint8* src_rgba, uint8* dst_y, int width); void RGB24ToYRow_Any_NEON(const uint8* src_rgb24, uint8* dst_y, int width); void RAWToYRow_Any_NEON(const uint8* src_raw, uint8* dst_y, int width); void RGB565ToYRow_Any_NEON(const uint8* src_rgb565, uint8* dst_y, int width); void ARGB1555ToYRow_Any_NEON(const uint8* src_argb1555, uint8* dst_y, int width); void ARGB4444ToYRow_Any_NEON(const uint8* src_argb4444, uint8* dst_y, int width); void ARGBToUVRow_AVX2(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_AVX2(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVRow_SSSE3(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_SSSE3(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void BGRAToUVRow_SSSE3(const uint8* src_bgra, int src_stride_bgra, uint8* dst_u, uint8* dst_v, int width); void ABGRToUVRow_SSSE3(const uint8* src_abgr, int src_stride_abgr, uint8* dst_u, uint8* dst_v, int width); void RGBAToUVRow_SSSE3(const uint8* src_rgba, int src_stride_rgba, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVRow_Any_AVX2(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_Any_AVX2(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVRow_Any_SSSE3(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_Any_SSSE3(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void BGRAToUVRow_Any_SSSE3(const uint8* src_bgra, int src_stride_bgra, uint8* dst_u, uint8* dst_v, int width); void ABGRToUVRow_Any_SSSE3(const uint8* src_abgr, int src_stride_abgr, uint8* dst_u, uint8* dst_v, int width); void RGBAToUVRow_Any_SSSE3(const uint8* src_rgba, int src_stride_rgba, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV444Row_Any_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV411Row_Any_NEON(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVRow_Any_NEON(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_Any_NEON(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void BGRAToUVRow_Any_NEON(const uint8* src_bgra, int src_stride_bgra, uint8* dst_u, uint8* dst_v, int width); void ABGRToUVRow_Any_NEON(const uint8* src_abgr, int src_stride_abgr, uint8* dst_u, uint8* dst_v, int width); void RGBAToUVRow_Any_NEON(const uint8* src_rgba, int src_stride_rgba, uint8* dst_u, uint8* dst_v, int width); void RGB24ToUVRow_Any_NEON(const uint8* src_rgb24, int src_stride_rgb24, uint8* dst_u, uint8* dst_v, int width); void RAWToUVRow_Any_NEON(const uint8* src_raw, int src_stride_raw, uint8* dst_u, uint8* dst_v, int width); void RGB565ToUVRow_Any_NEON(const uint8* src_rgb565, int src_stride_rgb565, uint8* dst_u, uint8* dst_v, int width); void ARGB1555ToUVRow_Any_NEON(const uint8* src_argb1555, int src_stride_argb1555, uint8* dst_u, uint8* dst_v, int width); void ARGB4444ToUVRow_Any_NEON(const uint8* src_argb4444, int src_stride_argb4444, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVRow_C(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUVJRow_C(const uint8* src_argb, int src_stride_argb, uint8* dst_u, uint8* dst_v, int width); void BGRAToUVRow_C(const uint8* src_bgra, int src_stride_bgra, uint8* dst_u, uint8* dst_v, int width); void ABGRToUVRow_C(const uint8* src_abgr, int src_stride_abgr, uint8* dst_u, uint8* dst_v, int width); void RGBAToUVRow_C(const uint8* src_rgba, int src_stride_rgba, uint8* dst_u, uint8* dst_v, int width); void RGB24ToUVRow_C(const uint8* src_rgb24, int src_stride_rgb24, uint8* dst_u, uint8* dst_v, int width); void RAWToUVRow_C(const uint8* src_raw, int src_stride_raw, uint8* dst_u, uint8* dst_v, int width); void RGB565ToUVRow_C(const uint8* src_rgb565, int src_stride_rgb565, uint8* dst_u, uint8* dst_v, int width); void ARGB1555ToUVRow_C(const uint8* src_argb1555, int src_stride_argb1555, uint8* dst_u, uint8* dst_v, int width); void ARGB4444ToUVRow_C(const uint8* src_argb4444, int src_stride_argb4444, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV444Row_SSSE3(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV444Row_Any_SSSE3(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV444Row_C(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void ARGBToUV411Row_C(const uint8* src_argb, uint8* dst_u, uint8* dst_v, int width); void MirrorRow_AVX2(const uint8* src, uint8* dst, int width); void MirrorRow_SSSE3(const uint8* src, uint8* dst, int width); void MirrorRow_NEON(const uint8* src, uint8* dst, int width); void MirrorRow_DSPR2(const uint8* src, uint8* dst, int width); void MirrorRow_MSA(const uint8* src, uint8* dst, int width); void MirrorRow_C(const uint8* src, uint8* dst, int width); void MirrorRow_Any_AVX2(const uint8* src, uint8* dst, int width); void MirrorRow_Any_SSSE3(const uint8* src, uint8* dst, int width); void MirrorRow_Any_SSE2(const uint8* src, uint8* dst, int width); void MirrorRow_Any_NEON(const uint8* src, uint8* dst, int width); void MirrorRow_Any_MSA(const uint8* src, uint8* dst, int width); void MirrorUVRow_SSSE3(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void MirrorUVRow_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void MirrorUVRow_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void MirrorUVRow_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void ARGBMirrorRow_AVX2(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_SSE2(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_NEON(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_MSA(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_C(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_Any_AVX2(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_Any_SSE2(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_Any_NEON(const uint8* src, uint8* dst, int width); void ARGBMirrorRow_Any_MSA(const uint8* src, uint8* dst, int width); void SplitUVRow_C(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_SSE2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_AVX2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_Any_SSE2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_Any_AVX2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_Any_NEON(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void SplitUVRow_Any_DSPR2(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int width); void MergeUVRow_C(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void MergeUVRow_SSE2(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void MergeUVRow_AVX2(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void MergeUVRow_NEON(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void MergeUVRow_Any_SSE2(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void MergeUVRow_Any_AVX2(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void MergeUVRow_Any_NEON(const uint8* src_u, const uint8* src_v, uint8* dst_uv, int width); void CopyRow_SSE2(const uint8* src, uint8* dst, int count); void CopyRow_AVX(const uint8* src, uint8* dst, int count); void CopyRow_ERMS(const uint8* src, uint8* dst, int count); void CopyRow_NEON(const uint8* src, uint8* dst, int count); void CopyRow_MIPS(const uint8* src, uint8* dst, int count); void CopyRow_C(const uint8* src, uint8* dst, int count); void CopyRow_Any_SSE2(const uint8* src, uint8* dst, int count); void CopyRow_Any_AVX(const uint8* src, uint8* dst, int count); void CopyRow_Any_NEON(const uint8* src, uint8* dst, int count); void CopyRow_16_C(const uint16* src, uint16* dst, int count); void ARGBCopyAlphaRow_C(const uint8* src_argb, uint8* dst_argb, int width); void ARGBCopyAlphaRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBCopyAlphaRow_AVX2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBCopyAlphaRow_Any_SSE2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBCopyAlphaRow_Any_AVX2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBExtractAlphaRow_C(const uint8* src_argb, uint8* dst_a, int width); void ARGBExtractAlphaRow_SSE2(const uint8* src_argb, uint8* dst_a, int width); void ARGBExtractAlphaRow_NEON(const uint8* src_argb, uint8* dst_a, int width); void ARGBExtractAlphaRow_Any_SSE2(const uint8* src_argb, uint8* dst_a, int width); void ARGBExtractAlphaRow_Any_NEON(const uint8* src_argb, uint8* dst_a, int width); void ARGBCopyYToAlphaRow_C(const uint8* src_y, uint8* dst_argb, int width); void ARGBCopyYToAlphaRow_SSE2(const uint8* src_y, uint8* dst_argb, int width); void ARGBCopyYToAlphaRow_AVX2(const uint8* src_y, uint8* dst_argb, int width); void ARGBCopyYToAlphaRow_Any_SSE2(const uint8* src_y, uint8* dst_argb, int width); void ARGBCopyYToAlphaRow_Any_AVX2(const uint8* src_y, uint8* dst_argb, int width); void SetRow_C(uint8* dst, uint8 v8, int count); void SetRow_X86(uint8* dst, uint8 v8, int count); void SetRow_ERMS(uint8* dst, uint8 v8, int count); void SetRow_NEON(uint8* dst, uint8 v8, int count); void SetRow_Any_X86(uint8* dst, uint8 v8, int count); void SetRow_Any_NEON(uint8* dst, uint8 v8, int count); void ARGBSetRow_C(uint8* dst_argb, uint32 v32, int count); void ARGBSetRow_X86(uint8* dst_argb, uint32 v32, int count); void ARGBSetRow_NEON(uint8* dst_argb, uint32 v32, int count); void ARGBSetRow_Any_NEON(uint8* dst_argb, uint32 v32, int count); // ARGBShufflers for BGRAToARGB etc. void ARGBShuffleRow_C(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_SSE2(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_SSSE3(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_AVX2(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_NEON(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_Any_SSE2(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_Any_SSSE3(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_Any_AVX2(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void ARGBShuffleRow_Any_NEON(const uint8* src_argb, uint8* dst_argb, const uint8* shuffler, int width); void RGB24ToARGBRow_SSSE3(const uint8* src_rgb24, uint8* dst_argb, int width); void RAWToARGBRow_SSSE3(const uint8* src_raw, uint8* dst_argb, int width); void RAWToRGB24Row_SSSE3(const uint8* src_raw, uint8* dst_rgb24, int width); void RGB565ToARGBRow_SSE2(const uint8* src_rgb565, uint8* dst_argb, int width); void ARGB1555ToARGBRow_SSE2(const uint8* src_argb1555, uint8* dst_argb, int width); void ARGB4444ToARGBRow_SSE2(const uint8* src_argb4444, uint8* dst_argb, int width); void RGB565ToARGBRow_AVX2(const uint8* src_rgb565, uint8* dst_argb, int width); void ARGB1555ToARGBRow_AVX2(const uint8* src_argb1555, uint8* dst_argb, int width); void ARGB4444ToARGBRow_AVX2(const uint8* src_argb4444, uint8* dst_argb, int width); void RGB24ToARGBRow_NEON(const uint8* src_rgb24, uint8* dst_argb, int width); void RAWToARGBRow_NEON(const uint8* src_raw, uint8* dst_argb, int width); void RAWToRGB24Row_NEON(const uint8* src_raw, uint8* dst_rgb24, int width); void RGB565ToARGBRow_NEON(const uint8* src_rgb565, uint8* dst_argb, int width); void ARGB1555ToARGBRow_NEON(const uint8* src_argb1555, uint8* dst_argb, int width); void ARGB4444ToARGBRow_NEON(const uint8* src_argb4444, uint8* dst_argb, int width); void RGB24ToARGBRow_C(const uint8* src_rgb24, uint8* dst_argb, int width); void RAWToARGBRow_C(const uint8* src_raw, uint8* dst_argb, int width); void RAWToRGB24Row_C(const uint8* src_raw, uint8* dst_rgb24, int width); void RGB565ToARGBRow_C(const uint8* src_rgb, uint8* dst_argb, int width); void ARGB1555ToARGBRow_C(const uint8* src_argb, uint8* dst_argb, int width); void ARGB4444ToARGBRow_C(const uint8* src_argb, uint8* dst_argb, int width); void RGB24ToARGBRow_Any_SSSE3(const uint8* src_rgb24, uint8* dst_argb, int width); void RAWToARGBRow_Any_SSSE3(const uint8* src_raw, uint8* dst_argb, int width); void RAWToRGB24Row_Any_SSSE3(const uint8* src_raw, uint8* dst_rgb24, int width); void RGB565ToARGBRow_Any_SSE2(const uint8* src_rgb565, uint8* dst_argb, int width); void ARGB1555ToARGBRow_Any_SSE2(const uint8* src_argb1555, uint8* dst_argb, int width); void ARGB4444ToARGBRow_Any_SSE2(const uint8* src_argb4444, uint8* dst_argb, int width); void RGB565ToARGBRow_Any_AVX2(const uint8* src_rgb565, uint8* dst_argb, int width); void ARGB1555ToARGBRow_Any_AVX2(const uint8* src_argb1555, uint8* dst_argb, int width); void ARGB4444ToARGBRow_Any_AVX2(const uint8* src_argb4444, uint8* dst_argb, int width); void RGB24ToARGBRow_Any_NEON(const uint8* src_rgb24, uint8* dst_argb, int width); void RAWToARGBRow_Any_NEON(const uint8* src_raw, uint8* dst_argb, int width); void RAWToRGB24Row_Any_NEON(const uint8* src_raw, uint8* dst_rgb24, int width); void RGB565ToARGBRow_Any_NEON(const uint8* src_rgb565, uint8* dst_argb, int width); void ARGB1555ToARGBRow_Any_NEON(const uint8* src_argb1555, uint8* dst_argb, int width); void ARGB4444ToARGBRow_Any_NEON(const uint8* src_argb4444, uint8* dst_argb, int width); void ARGBToRGB24Row_SSSE3(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRAWRow_SSSE3(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565Row_SSE2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_SSE2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_SSE2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565DitherRow_C(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void ARGBToRGB565DitherRow_SSE2(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void ARGBToRGB565DitherRow_AVX2(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void ARGBToRGB565Row_AVX2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_AVX2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_AVX2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB24Row_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRAWRow_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565Row_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565DitherRow_NEON(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void ARGBToRGBARow_C(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB24Row_C(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRAWRow_C(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565Row_C(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_C(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_C(const uint8* src_argb, uint8* dst_rgb, int width); void J400ToARGBRow_SSE2(const uint8* src_y, uint8* dst_argb, int width); void J400ToARGBRow_AVX2(const uint8* src_y, uint8* dst_argb, int width); void J400ToARGBRow_NEON(const uint8* src_y, uint8* dst_argb, int width); void J400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width); void J400ToARGBRow_Any_SSE2(const uint8* src_y, uint8* dst_argb, int width); void J400ToARGBRow_Any_AVX2(const uint8* src_y, uint8* dst_argb, int width); void J400ToARGBRow_Any_NEON(const uint8* src_y, uint8* dst_argb, int width); void I444ToARGBRow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_C(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, const uint8* a_buf, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_C(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_C(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_C(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_C(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_C(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgb24, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb4444, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb4444, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgb565, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I444ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I444ToARGBRow_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I444ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I444ToARGBRow_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_SSSE3(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, const uint8* a_buf, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_AVX2(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, const uint8* a_buf, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_AVX2(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_AVX2(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_AVX2(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_SSSE3(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_SSSE3(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_AVX2(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_AVX2(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgb24, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgb24, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I444ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I444ToARGBRow_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_Any_SSSE3(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, const uint8* a_buf, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_Any_AVX2(const uint8* y_buf, const uint8* u_buf, const uint8* v_buf, const uint8* a_buf, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_Any_AVX2(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_Any_SSSE3(const uint8* src_y, const uint8* src_vu, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_Any_AVX2(const uint8* src_y, const uint8* src_vu, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_Any_SSSE3(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_Any_AVX2(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_Any_SSSE3(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_Any_SSSE3(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_Any_AVX2(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_Any_AVX2(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_rgba, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_Any_SSSE3(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_Any_AVX2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width); void I400ToARGBRow_SSE2(const uint8* src_y, uint8* dst_argb, int width); void I400ToARGBRow_AVX2(const uint8* src_y, uint8* dst_argb, int width); void I400ToARGBRow_NEON(const uint8* src_y, uint8* dst_argb, int width); void I400ToARGBRow_Any_SSE2(const uint8* src_y, uint8* dst_argb, int width); void I400ToARGBRow_Any_AVX2(const uint8* src_y, uint8* dst_argb, int width); void I400ToARGBRow_Any_NEON(const uint8* src_y, uint8* dst_argb, int width); // ARGB preattenuated alpha blend. void ARGBBlendRow_SSSE3(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBBlendRow_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBBlendRow_C(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); // Unattenuated planar alpha blend. void BlendPlaneRow_SSSE3(const uint8* src0, const uint8* src1, const uint8* alpha, uint8* dst, int width); void BlendPlaneRow_Any_SSSE3(const uint8* src0, const uint8* src1, const uint8* alpha, uint8* dst, int width); void BlendPlaneRow_AVX2(const uint8* src0, const uint8* src1, const uint8* alpha, uint8* dst, int width); void BlendPlaneRow_Any_AVX2(const uint8* src0, const uint8* src1, const uint8* alpha, uint8* dst, int width); void BlendPlaneRow_C(const uint8* src0, const uint8* src1, const uint8* alpha, uint8* dst, int width); // ARGB multiply images. Same API as Blend, but these require // pointer and width alignment for SSE2. void ARGBMultiplyRow_C(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBMultiplyRow_SSE2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBMultiplyRow_Any_SSE2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBMultiplyRow_AVX2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBMultiplyRow_Any_AVX2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBMultiplyRow_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBMultiplyRow_Any_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); // ARGB add images. void ARGBAddRow_C(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBAddRow_SSE2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBAddRow_Any_SSE2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBAddRow_AVX2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBAddRow_Any_AVX2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBAddRow_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBAddRow_Any_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); // ARGB subtract images. Same API as Blend, but these require // pointer and width alignment for SSE2. void ARGBSubtractRow_C(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBSubtractRow_SSE2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBSubtractRow_Any_SSE2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBSubtractRow_AVX2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBSubtractRow_Any_AVX2(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBSubtractRow_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBSubtractRow_Any_NEON(const uint8* src_argb, const uint8* src_argb1, uint8* dst_argb, int width); void ARGBToRGB24Row_Any_SSSE3(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRAWRow_Any_SSSE3(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565Row_Any_SSE2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_Any_SSE2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_Any_SSE2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565DitherRow_Any_SSE2(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void ARGBToRGB565DitherRow_Any_AVX2(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void ARGBToRGB565Row_Any_AVX2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_Any_AVX2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_Any_AVX2(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB24Row_Any_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRAWRow_Any_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565Row_Any_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB1555Row_Any_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToARGB4444Row_Any_NEON(const uint8* src_argb, uint8* dst_rgb, int width); void ARGBToRGB565DitherRow_Any_NEON(const uint8* src_argb, uint8* dst_rgb, const uint32 dither4, int width); void I444ToARGBRow_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422AlphaToARGBRow_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, const uint8* src_a, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I411ToARGBRow_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGBARow_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGB24Row_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGB4444Row_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGB1555Row_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToRGB565Row_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToARGBRow_Any_NEON(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV21ToARGBRow_Any_NEON(const uint8* src_y, const uint8* src_vu, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void NV12ToRGB565Row_Any_NEON(const uint8* src_y, const uint8* src_uv, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToARGBRow_Any_NEON(const uint8* src_yuy2, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void UYVYToARGBRow_Any_NEON(const uint8* src_uyvy, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_DSPR2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void I422ToARGBRow_DSPR2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_argb, const struct YuvConstants* yuvconstants, int width); void YUY2ToYRow_AVX2(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_AVX2(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_AVX2(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToYRow_SSE2(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_SSE2(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_SSE2(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToYRow_NEON(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_NEON(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_NEON(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToYRow_C(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_C(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_C(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToYRow_Any_AVX2(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_Any_AVX2(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_Any_AVX2(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToYRow_Any_SSE2(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_Any_SSE2(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_Any_SSE2(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToYRow_Any_NEON(const uint8* src_yuy2, uint8* dst_y, int width); void YUY2ToUVRow_Any_NEON(const uint8* src_yuy2, int stride_yuy2, uint8* dst_u, uint8* dst_v, int width); void YUY2ToUV422Row_Any_NEON(const uint8* src_yuy2, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_AVX2(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_AVX2(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_AVX2(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_SSE2(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_SSE2(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_SSE2(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_AVX2(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_AVX2(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_AVX2(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_NEON(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_NEON(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_NEON(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_C(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_C(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_C(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_Any_AVX2(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_Any_AVX2(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_Any_AVX2(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_Any_SSE2(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_Any_SSE2(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_Any_SSE2(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToYRow_Any_NEON(const uint8* src_uyvy, uint8* dst_y, int width); void UYVYToUVRow_Any_NEON(const uint8* src_uyvy, int stride_uyvy, uint8* dst_u, uint8* dst_v, int width); void UYVYToUV422Row_Any_NEON(const uint8* src_uyvy, uint8* dst_u, uint8* dst_v, int width); void I422ToYUY2Row_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_yuy2, int width); void I422ToUYVYRow_C(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_uyvy, int width); void I422ToYUY2Row_SSE2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_yuy2, int width); void I422ToUYVYRow_SSE2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_uyvy, int width); void I422ToYUY2Row_Any_SSE2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_yuy2, int width); void I422ToUYVYRow_Any_SSE2(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_uyvy, int width); void I422ToYUY2Row_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_yuy2, int width); void I422ToUYVYRow_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_uyvy, int width); void I422ToYUY2Row_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_yuy2, int width); void I422ToUYVYRow_Any_NEON(const uint8* src_y, const uint8* src_u, const uint8* src_v, uint8* dst_uyvy, int width); // Effects related row functions. void ARGBAttenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_SSSE3(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_AVX2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_NEON(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_Any_SSE2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_Any_SSSE3(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_Any_AVX2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBAttenuateRow_Any_NEON(const uint8* src_argb, uint8* dst_argb, int width); // Inverse table for unattenuate, shared by C and SSE2. extern const uint32 fixed_invtbl8[256]; void ARGBUnattenuateRow_C(const uint8* src_argb, uint8* dst_argb, int width); void ARGBUnattenuateRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBUnattenuateRow_AVX2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBUnattenuateRow_Any_SSE2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBUnattenuateRow_Any_AVX2(const uint8* src_argb, uint8* dst_argb, int width); void ARGBGrayRow_C(const uint8* src_argb, uint8* dst_argb, int width); void ARGBGrayRow_SSSE3(const uint8* src_argb, uint8* dst_argb, int width); void ARGBGrayRow_NEON(const uint8* src_argb, uint8* dst_argb, int width); void ARGBSepiaRow_C(uint8* dst_argb, int width); void ARGBSepiaRow_SSSE3(uint8* dst_argb, int width); void ARGBSepiaRow_NEON(uint8* dst_argb, int width); void ARGBColorMatrixRow_C(const uint8* src_argb, uint8* dst_argb, const int8* matrix_argb, int width); void ARGBColorMatrixRow_SSSE3(const uint8* src_argb, uint8* dst_argb, const int8* matrix_argb, int width); void ARGBColorMatrixRow_NEON(const uint8* src_argb, uint8* dst_argb, const int8* matrix_argb, int width); void ARGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width); void ARGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb, int width); void RGBColorTableRow_C(uint8* dst_argb, const uint8* table_argb, int width); void RGBColorTableRow_X86(uint8* dst_argb, const uint8* table_argb, int width); void ARGBQuantizeRow_C(uint8* dst_argb, int scale, int interval_size, int interval_offset, int width); void ARGBQuantizeRow_SSE2(uint8* dst_argb, int scale, int interval_size, int interval_offset, int width); void ARGBQuantizeRow_NEON(uint8* dst_argb, int scale, int interval_size, int interval_offset, int width); void ARGBShadeRow_C(const uint8* src_argb, uint8* dst_argb, int width, uint32 value); void ARGBShadeRow_SSE2(const uint8* src_argb, uint8* dst_argb, int width, uint32 value); void ARGBShadeRow_NEON(const uint8* src_argb, uint8* dst_argb, int width, uint32 value); // Used for blur. void CumulativeSumToAverageRow_SSE2(const int32* topleft, const int32* botleft, int width, int area, uint8* dst, int count); void ComputeCumulativeSumRow_SSE2(const uint8* row, int32* cumsum, const int32* previous_cumsum, int width); void CumulativeSumToAverageRow_C(const int32* topleft, const int32* botleft, int width, int area, uint8* dst, int count); void ComputeCumulativeSumRow_C(const uint8* row, int32* cumsum, const int32* previous_cumsum, int width); LIBYUV_API void ARGBAffineRow_C(const uint8* src_argb, int src_argb_stride, uint8* dst_argb, const float* uv_dudv, int width); LIBYUV_API void ARGBAffineRow_SSE2(const uint8* src_argb, int src_argb_stride, uint8* dst_argb, const float* uv_dudv, int width); // Used for I420Scale, ARGBScale, and ARGBInterpolate. void InterpolateRow_C(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_SSSE3(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_AVX2(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_NEON(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_DSPR2(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_Any_NEON(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_Any_SSSE3(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_Any_AVX2(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_Any_DSPR2(uint8* dst_ptr, const uint8* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); void InterpolateRow_16_C(uint16* dst_ptr, const uint16* src_ptr, ptrdiff_t src_stride_ptr, int width, int source_y_fraction); // Sobel images. void SobelXRow_C(const uint8* src_y0, const uint8* src_y1, const uint8* src_y2, uint8* dst_sobelx, int width); void SobelXRow_SSE2(const uint8* src_y0, const uint8* src_y1, const uint8* src_y2, uint8* dst_sobelx, int width); void SobelXRow_NEON(const uint8* src_y0, const uint8* src_y1, const uint8* src_y2, uint8* dst_sobelx, int width); void SobelYRow_C(const uint8* src_y0, const uint8* src_y1, uint8* dst_sobely, int width); void SobelYRow_SSE2(const uint8* src_y0, const uint8* src_y1, uint8* dst_sobely, int width); void SobelYRow_NEON(const uint8* src_y0, const uint8* src_y1, uint8* dst_sobely, int width); void SobelRow_C(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelRow_SSE2(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelRow_NEON(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelToPlaneRow_C(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_y, int width); void SobelToPlaneRow_SSE2(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_y, int width); void SobelToPlaneRow_NEON(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_y, int width); void SobelXYRow_C(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelXYRow_SSE2(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelXYRow_NEON(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelRow_Any_SSE2(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelRow_Any_NEON(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelToPlaneRow_Any_SSE2(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_y, int width); void SobelToPlaneRow_Any_NEON(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_y, int width); void SobelXYRow_Any_SSE2(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void SobelXYRow_Any_NEON(const uint8* src_sobelx, const uint8* src_sobely, uint8* dst_argb, int width); void ARGBPolynomialRow_C(const uint8* src_argb, uint8* dst_argb, const float* poly, int width); void ARGBPolynomialRow_SSE2(const uint8* src_argb, uint8* dst_argb, const float* poly, int width); void ARGBPolynomialRow_AVX2(const uint8* src_argb, uint8* dst_argb, const float* poly, int width); // Scale and convert to half float. void HalfFloatRow_C(const uint16* src, uint16* dst, float scale, int width); void HalfFloatRow_AVX2(const uint16* src, uint16* dst, float scale, int width); void HalfFloatRow_Any_AVX2(const uint16* src, uint16* dst, float scale, int width); void HalfFloatRow_SSE2(const uint16* src, uint16* dst, float scale, int width); void HalfFloatRow_Any_SSE2(const uint16* src, uint16* dst, float scale, int width); void ARGBLumaColorTableRow_C(const uint8* src_argb, uint8* dst_argb, int width, const uint8* luma, uint32 lumacoeff); void ARGBLumaColorTableRow_SSSE3(const uint8* src_argb, uint8* dst_argb, int width, const uint8* luma, uint32 lumacoeff); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_ROW_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/scale.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_SCALE_H_ #define INCLUDE_LIBYUV_SCALE_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif // Supported filtering. typedef enum FilterMode { kFilterNone = 0, // Point sample; Fastest. kFilterLinear = 1, // Filter horizontally only. kFilterBilinear = 2, // Faster than box, but lower quality scaling down. kFilterBox = 3 // Highest quality. } FilterModeEnum; // Scale a YUV plane. LIBYUV_API void ScalePlane(const uint8* src, int src_stride, int src_width, int src_height, uint8* dst, int dst_stride, int dst_width, int dst_height, enum FilterMode filtering); LIBYUV_API void ScalePlane_16(const uint16* src, int src_stride, int src_width, int src_height, uint16* dst, int dst_stride, int dst_width, int dst_height, enum FilterMode filtering); // Scales a YUV 4:2:0 image from the src width and height to the // dst width and height. // If filtering is kFilterNone, a simple nearest-neighbor algorithm is // used. This produces basic (blocky) quality at the fastest speed. // If filtering is kFilterBilinear, interpolation is used to produce a better // quality image, at the expense of speed. // If filtering is kFilterBox, averaging is used to produce ever better // quality image, at further expense of speed. // Returns 0 if successful. LIBYUV_API int I420Scale(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, int src_width, int src_height, uint8* dst_y, int dst_stride_y, uint8* dst_u, int dst_stride_u, uint8* dst_v, int dst_stride_v, int dst_width, int dst_height, enum FilterMode filtering); LIBYUV_API int I420Scale_16(const uint16* src_y, int src_stride_y, const uint16* src_u, int src_stride_u, const uint16* src_v, int src_stride_v, int src_width, int src_height, uint16* dst_y, int dst_stride_y, uint16* dst_u, int dst_stride_u, uint16* dst_v, int dst_stride_v, int dst_width, int dst_height, enum FilterMode filtering); #ifdef __cplusplus // Legacy API. Deprecated. LIBYUV_API int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, int src_stride_y, int src_stride_u, int src_stride_v, int src_width, int src_height, uint8* dst_y, uint8* dst_u, uint8* dst_v, int dst_stride_y, int dst_stride_u, int dst_stride_v, int dst_width, int dst_height, LIBYUV_BOOL interpolate); // Legacy API. Deprecated. LIBYUV_API int ScaleOffset(const uint8* src_i420, int src_width, int src_height, uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, LIBYUV_BOOL interpolate); // For testing, allow disabling of specialized scalers. LIBYUV_API void SetUseReferenceImpl(LIBYUV_BOOL use); #endif // __cplusplus #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_SCALE_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/scale_argb.h ================================================ /* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_SCALE_ARGB_H_ #define INCLUDE_LIBYUV_SCALE_ARGB_H_ #include "libyuv/basic_types.h" #include "libyuv/scale.h" // For FilterMode #ifdef __cplusplus namespace libyuv { extern "C" { #endif LIBYUV_API int ARGBScale(const uint8* src_argb, int src_stride_argb, int src_width, int src_height, uint8* dst_argb, int dst_stride_argb, int dst_width, int dst_height, enum FilterMode filtering); // Clipped scale takes destination rectangle coordinates for clip values. LIBYUV_API int ARGBScaleClip(const uint8* src_argb, int src_stride_argb, int src_width, int src_height, uint8* dst_argb, int dst_stride_argb, int dst_width, int dst_height, int clip_x, int clip_y, int clip_width, int clip_height, enum FilterMode filtering); // Scale with YUV conversion to ARGB and clipping. LIBYUV_API int YUVToARGBScaleClip(const uint8* src_y, int src_stride_y, const uint8* src_u, int src_stride_u, const uint8* src_v, int src_stride_v, uint32 src_fourcc, int src_width, int src_height, uint8* dst_argb, int dst_stride_argb, uint32 dst_fourcc, int dst_width, int dst_height, int clip_x, int clip_y, int clip_width, int clip_height, enum FilterMode filtering); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_SCALE_ARGB_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/scale_row.h ================================================ /* * Copyright 2013 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_SCALE_ROW_H_ #define INCLUDE_LIBYUV_SCALE_ROW_H_ #include "libyuv/basic_types.h" #include "libyuv/scale.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif #if defined(__pnacl__) || defined(__CLR_VER) || \ (defined(__i386__) && !defined(__SSE2__)) #define LIBYUV_DISABLE_X86 #endif // MemorySanitizer does not support assembly code yet. http://crbug.com/344505 #if defined(__has_feature) #if __has_feature(memory_sanitizer) #define LIBYUV_DISABLE_X86 #endif #endif // GCC >= 4.7.0 required for AVX2. #if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) #if (__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7)) #define GCC_HAS_AVX2 1 #endif // GNUC >= 4.7 #endif // __GNUC__ // clang >= 3.4.0 required for AVX2. #if defined(__clang__) && (defined(__x86_64__) || defined(__i386__)) #if (__clang_major__ > 3) || (__clang_major__ == 3 && (__clang_minor__ >= 4)) #define CLANG_HAS_AVX2 1 #endif // clang >= 3.4 #endif // __clang__ // Visual C 2012 required for AVX2. #if defined(_M_IX86) && !defined(__clang__) && \ defined(_MSC_VER) && _MSC_VER >= 1700 #define VISUALC_HAS_AVX2 1 #endif // VisualStudio >= 2012 // The following are available on all x86 platforms: #if !defined(LIBYUV_DISABLE_X86) && \ (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__)) #define HAS_FIXEDDIV1_X86 #define HAS_FIXEDDIV_X86 #define HAS_SCALEARGBCOLS_SSE2 #define HAS_SCALEARGBCOLSUP2_SSE2 #define HAS_SCALEARGBFILTERCOLS_SSSE3 #define HAS_SCALEARGBROWDOWN2_SSE2 #define HAS_SCALEARGBROWDOWNEVEN_SSE2 #define HAS_SCALECOLSUP2_SSE2 #define HAS_SCALEFILTERCOLS_SSSE3 #define HAS_SCALEROWDOWN2_SSSE3 #define HAS_SCALEROWDOWN34_SSSE3 #define HAS_SCALEROWDOWN38_SSSE3 #define HAS_SCALEROWDOWN4_SSSE3 #define HAS_SCALEADDROW_SSE2 #endif // The following are available on all x86 platforms, but // require VS2012, clang 3.4 or gcc 4.7. // The code supports NaCL but requires a new compiler and validator. #if !defined(LIBYUV_DISABLE_X86) && (defined(VISUALC_HAS_AVX2) || \ defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2)) #define HAS_SCALEADDROW_AVX2 #define HAS_SCALEROWDOWN2_AVX2 #define HAS_SCALEROWDOWN4_AVX2 #endif // The following are available on Neon platforms: #if !defined(LIBYUV_DISABLE_NEON) && !defined(__native_client__) && \ (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__)) #define HAS_SCALEARGBCOLS_NEON #define HAS_SCALEARGBROWDOWN2_NEON #define HAS_SCALEARGBROWDOWNEVEN_NEON #define HAS_SCALEFILTERCOLS_NEON #define HAS_SCALEROWDOWN2_NEON #define HAS_SCALEROWDOWN34_NEON #define HAS_SCALEROWDOWN38_NEON #define HAS_SCALEROWDOWN4_NEON #define HAS_SCALEARGBFILTERCOLS_NEON #endif // The following are available on Mips platforms: #if !defined(LIBYUV_DISABLE_MIPS) && !defined(__native_client__) && \ defined(__mips__) && defined(__mips_dsp) && (__mips_dsp_rev >= 2) #define HAS_SCALEROWDOWN2_DSPR2 #define HAS_SCALEROWDOWN4_DSPR2 #define HAS_SCALEROWDOWN34_DSPR2 #define HAS_SCALEROWDOWN38_DSPR2 #endif // Scale ARGB vertically with bilinear interpolation. void ScalePlaneVertical(int src_height, int dst_width, int dst_height, int src_stride, int dst_stride, const uint8* src_argb, uint8* dst_argb, int x, int y, int dy, int bpp, enum FilterMode filtering); void ScalePlaneVertical_16(int src_height, int dst_width, int dst_height, int src_stride, int dst_stride, const uint16* src_argb, uint16* dst_argb, int x, int y, int dy, int wpp, enum FilterMode filtering); // Simplify the filtering based on scale factors. enum FilterMode ScaleFilterReduce(int src_width, int src_height, int dst_width, int dst_height, enum FilterMode filtering); // Divide num by div and return as 16.16 fixed point result. int FixedDiv_C(int num, int div); int FixedDiv_X86(int num, int div); // Divide num - 1 by div - 1 and return as 16.16 fixed point result. int FixedDiv1_C(int num, int div); int FixedDiv1_X86(int num, int div); #ifdef HAS_FIXEDDIV_X86 #define FixedDiv FixedDiv_X86 #define FixedDiv1 FixedDiv1_X86 #else #define FixedDiv FixedDiv_C #define FixedDiv1 FixedDiv1_C #endif // Compute slope values for stepping. void ScaleSlope(int src_width, int src_height, int dst_width, int dst_height, enum FilterMode filtering, int* x, int* y, int* dx, int* dy); void ScaleRowDown2_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown2Linear_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Linear_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown2Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Box_Odd_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown4_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown4_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown4Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown4Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown34_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown34_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown34_0_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* d, int dst_width); void ScaleRowDown34_0_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* d, int dst_width); void ScaleRowDown34_1_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* d, int dst_width); void ScaleRowDown34_1_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* d, int dst_width); void ScaleCols_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); void ScaleCols_16_C(uint16* dst_ptr, const uint16* src_ptr, int dst_width, int x, int dx); void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int, int); void ScaleColsUp2_16_C(uint16* dst_ptr, const uint16* src_ptr, int dst_width, int, int); void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); void ScaleFilterCols_16_C(uint16* dst_ptr, const uint16* src_ptr, int dst_width, int x, int dx); void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); void ScaleFilterCols64_16_C(uint16* dst_ptr, const uint16* src_ptr, int dst_width, int x, int dx); void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown38_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst, int dst_width); void ScaleRowDown38_3_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_3_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst_ptr, int dst_width); void ScaleRowDown38_2_Box_C(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_2_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride, uint16* dst_ptr, int dst_width); void ScaleAddRow_C(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleAddRow_16_C(const uint16* src_ptr, uint32* dst_ptr, int src_width); void ScaleARGBRowDown2_C(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Linear_C(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEvenBox_C(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int, int); void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); // Specialized scalers for x86. void ScaleRowDown2_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Linear_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Box_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Linear_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Box_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4Box_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4Box_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_1_Box_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_0_Box_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_3_Box_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_2_Box_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Linear_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Box_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Box_Odd_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2_Any_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Linear_Any_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Box_Any_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2Box_Odd_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4Box_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4_Any_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4Box_Any_AVX2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_1_Box_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_0_Box_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_3_Box_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_2_Box_Any_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleAddRow_SSE2(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleAddRow_AVX2(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleAddRow_Any_SSE2(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleAddRow_Any_AVX2(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); void ScaleColsUp2_SSE2(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); // ARGB Column functions void ScaleARGBCols_SSE2(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBFilterCols_SSSE3(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBColsUp2_SSE2(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBFilterCols_NEON(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBCols_NEON(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBFilterCols_Any_NEON(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); void ScaleARGBCols_Any_NEON(uint8* dst_argb, const uint8* src_argb, int dst_width, int x, int dx); // ARGB Row functions void ScaleARGBRowDown2_SSE2(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Linear_SSE2(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleARGBRowDown2Linear_NEON(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleARGBRowDown2_Any_SSE2(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Linear_Any_SSE2(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Box_Any_SSE2(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleARGBRowDown2Linear_Any_NEON(const uint8* src_argb, ptrdiff_t src_stride, uint8* dst_argb, int dst_width); void ScaleARGBRowDown2Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEvenBox_SSE2(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEven_NEON(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEvenBox_NEON(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEven_Any_SSE2(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEvenBox_Any_SSE2(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEven_Any_NEON(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); void ScaleARGBRowDownEvenBox_Any_NEON(const uint8* src_argb, ptrdiff_t src_stride, int src_stepx, uint8* dst_argb, int dst_width); // ScaleRowDown2Box also used by planar functions // NEON downscalers with interpolation. // Note - not static due to reuse in convert for 444 to 420. void ScaleRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Linear_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown4_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // Down scale from 4 to 3 pixels. Use the neon multilane read/write // to load up the every 4th pixel into a 4 different registers. // Point samples 32 pixels to 24 pixels. void ScaleRowDown34_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_0_Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_1_Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // 32 -> 12 void ScaleRowDown38_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // 32x3 -> 12x1 void ScaleRowDown38_3_Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // 32x2 -> 12x1 void ScaleRowDown38_2_Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown2_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Linear_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Box_Odd_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown4_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown4Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_0_Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown34_1_Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // 32 -> 12 void ScaleRowDown38_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // 32x3 -> 12x1 void ScaleRowDown38_3_Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); // 32x2 -> 12x1 void ScaleRowDown38_2_Box_Any_NEON(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleAddRow_NEON(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleAddRow_Any_NEON(const uint8* src_ptr, uint16* dst_ptr, int src_width); void ScaleFilterCols_NEON(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); void ScaleFilterCols_Any_NEON(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); void ScaleRowDown2_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown2Box_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown4_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown4Box_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown34_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown34_0_Box_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* d, int dst_width); void ScaleRowDown34_1_Box_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* d, int dst_width); void ScaleRowDown38_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst, int dst_width); void ScaleRowDown38_2_Box_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); void ScaleRowDown38_3_Box_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride, uint8* dst_ptr, int dst_width); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_SCALE_ROW_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/version.h ================================================ /* * Copyright 2012 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ #define LIBYUV_VERSION 1622 #endif // INCLUDE_LIBYUV_VERSION_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv/video_common.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ // Common definitions for video, including fourcc and VideoFormat. #ifndef INCLUDE_LIBYUV_VIDEO_COMMON_H_ #define INCLUDE_LIBYUV_VIDEO_COMMON_H_ #include "libyuv/basic_types.h" #ifdef __cplusplus namespace libyuv { extern "C" { #endif ////////////////////////////////////////////////////////////////////////////// // Definition of FourCC codes ////////////////////////////////////////////////////////////////////////////// // Convert four characters to a FourCC code. // Needs to be a macro otherwise the OS X compiler complains when the kFormat* // constants are used in a switch. #ifdef __cplusplus #define FOURCC(a, b, c, d) ( \ (static_cast(a)) | (static_cast(b) << 8) | \ (static_cast(c) << 16) | (static_cast(d) << 24)) #else #define FOURCC(a, b, c, d) ( \ ((uint32)(a)) | ((uint32)(b) << 8) | /* NOLINT */ \ ((uint32)(c) << 16) | ((uint32)(d) << 24)) /* NOLINT */ #endif // Some pages discussing FourCC codes: // http://www.fourcc.org/yuv.php // http://v4l2spec.bytesex.org/spec/book1.htm // http://developer.apple.com/quicktime/icefloe/dispatch020.html // http://msdn.microsoft.com/library/windows/desktop/dd206750.aspx#nv12 // http://people.xiph.org/~xiphmont/containers/nut/nut4cc.txt // FourCC codes grouped according to implementation efficiency. // Primary formats should convert in 1 efficient step. // Secondary formats are converted in 2 steps. // Auxilliary formats call primary converters. enum FourCC { // 9 Primary YUV formats: 5 planar, 2 biplanar, 2 packed. FOURCC_I420 = FOURCC('I', '4', '2', '0'), FOURCC_I422 = FOURCC('I', '4', '2', '2'), FOURCC_I444 = FOURCC('I', '4', '4', '4'), FOURCC_I411 = FOURCC('I', '4', '1', '1'), FOURCC_I400 = FOURCC('I', '4', '0', '0'), FOURCC_NV21 = FOURCC('N', 'V', '2', '1'), FOURCC_NV12 = FOURCC('N', 'V', '1', '2'), FOURCC_YUY2 = FOURCC('Y', 'U', 'Y', '2'), FOURCC_UYVY = FOURCC('U', 'Y', 'V', 'Y'), // 2 Secondary YUV formats: row biplanar. FOURCC_M420 = FOURCC('M', '4', '2', '0'), FOURCC_Q420 = FOURCC('Q', '4', '2', '0'), // deprecated. // 9 Primary RGB formats: 4 32 bpp, 2 24 bpp, 3 16 bpp. FOURCC_ARGB = FOURCC('A', 'R', 'G', 'B'), FOURCC_BGRA = FOURCC('B', 'G', 'R', 'A'), FOURCC_ABGR = FOURCC('A', 'B', 'G', 'R'), FOURCC_24BG = FOURCC('2', '4', 'B', 'G'), FOURCC_RAW = FOURCC('r', 'a', 'w', ' '), FOURCC_RGBA = FOURCC('R', 'G', 'B', 'A'), FOURCC_RGBP = FOURCC('R', 'G', 'B', 'P'), // rgb565 LE. FOURCC_RGBO = FOURCC('R', 'G', 'B', 'O'), // argb1555 LE. FOURCC_R444 = FOURCC('R', '4', '4', '4'), // argb4444 LE. // 4 Secondary RGB formats: 4 Bayer Patterns. deprecated. FOURCC_RGGB = FOURCC('R', 'G', 'G', 'B'), FOURCC_BGGR = FOURCC('B', 'G', 'G', 'R'), FOURCC_GRBG = FOURCC('G', 'R', 'B', 'G'), FOURCC_GBRG = FOURCC('G', 'B', 'R', 'G'), // 1 Primary Compressed YUV format. FOURCC_MJPG = FOURCC('M', 'J', 'P', 'G'), // 5 Auxiliary YUV variations: 3 with U and V planes are swapped, 1 Alias. FOURCC_YV12 = FOURCC('Y', 'V', '1', '2'), FOURCC_YV16 = FOURCC('Y', 'V', '1', '6'), FOURCC_YV24 = FOURCC('Y', 'V', '2', '4'), FOURCC_YU12 = FOURCC('Y', 'U', '1', '2'), // Linux version of I420. FOURCC_J420 = FOURCC('J', '4', '2', '0'), FOURCC_J400 = FOURCC('J', '4', '0', '0'), // unofficial fourcc FOURCC_H420 = FOURCC('H', '4', '2', '0'), // unofficial fourcc // 14 Auxiliary aliases. CanonicalFourCC() maps these to canonical fourcc. FOURCC_IYUV = FOURCC('I', 'Y', 'U', 'V'), // Alias for I420. FOURCC_YU16 = FOURCC('Y', 'U', '1', '6'), // Alias for I422. FOURCC_YU24 = FOURCC('Y', 'U', '2', '4'), // Alias for I444. FOURCC_YUYV = FOURCC('Y', 'U', 'Y', 'V'), // Alias for YUY2. FOURCC_YUVS = FOURCC('y', 'u', 'v', 's'), // Alias for YUY2 on Mac. FOURCC_HDYC = FOURCC('H', 'D', 'Y', 'C'), // Alias for UYVY. FOURCC_2VUY = FOURCC('2', 'v', 'u', 'y'), // Alias for UYVY on Mac. FOURCC_JPEG = FOURCC('J', 'P', 'E', 'G'), // Alias for MJPG. FOURCC_DMB1 = FOURCC('d', 'm', 'b', '1'), // Alias for MJPG on Mac. FOURCC_BA81 = FOURCC('B', 'A', '8', '1'), // Alias for BGGR. FOURCC_RGB3 = FOURCC('R', 'G', 'B', '3'), // Alias for RAW. FOURCC_BGR3 = FOURCC('B', 'G', 'R', '3'), // Alias for 24BG. FOURCC_CM32 = FOURCC(0, 0, 0, 32), // Alias for BGRA kCMPixelFormat_32ARGB FOURCC_CM24 = FOURCC(0, 0, 0, 24), // Alias for RAW kCMPixelFormat_24RGB FOURCC_L555 = FOURCC('L', '5', '5', '5'), // Alias for RGBO. FOURCC_L565 = FOURCC('L', '5', '6', '5'), // Alias for RGBP. FOURCC_5551 = FOURCC('5', '5', '5', '1'), // Alias for RGBO. // 1 Auxiliary compressed YUV format set aside for capturer. FOURCC_H264 = FOURCC('H', '2', '6', '4'), // Match any fourcc. FOURCC_ANY = -1, }; enum FourCCBpp { // Canonical fourcc codes used in our code. FOURCC_BPP_I420 = 12, FOURCC_BPP_I422 = 16, FOURCC_BPP_I444 = 24, FOURCC_BPP_I411 = 12, FOURCC_BPP_I400 = 8, FOURCC_BPP_NV21 = 12, FOURCC_BPP_NV12 = 12, FOURCC_BPP_YUY2 = 16, FOURCC_BPP_UYVY = 16, FOURCC_BPP_M420 = 12, FOURCC_BPP_Q420 = 12, FOURCC_BPP_ARGB = 32, FOURCC_BPP_BGRA = 32, FOURCC_BPP_ABGR = 32, FOURCC_BPP_RGBA = 32, FOURCC_BPP_24BG = 24, FOURCC_BPP_RAW = 24, FOURCC_BPP_RGBP = 16, FOURCC_BPP_RGBO = 16, FOURCC_BPP_R444 = 16, FOURCC_BPP_RGGB = 8, FOURCC_BPP_BGGR = 8, FOURCC_BPP_GRBG = 8, FOURCC_BPP_GBRG = 8, FOURCC_BPP_YV12 = 12, FOURCC_BPP_YV16 = 16, FOURCC_BPP_YV24 = 24, FOURCC_BPP_YU12 = 12, FOURCC_BPP_J420 = 12, FOURCC_BPP_J400 = 8, FOURCC_BPP_H420 = 12, FOURCC_BPP_MJPG = 0, // 0 means unknown. FOURCC_BPP_H264 = 0, FOURCC_BPP_IYUV = 12, FOURCC_BPP_YU16 = 16, FOURCC_BPP_YU24 = 24, FOURCC_BPP_YUYV = 16, FOURCC_BPP_YUVS = 16, FOURCC_BPP_HDYC = 16, FOURCC_BPP_2VUY = 16, FOURCC_BPP_JPEG = 1, FOURCC_BPP_DMB1 = 1, FOURCC_BPP_BA81 = 8, FOURCC_BPP_RGB3 = 24, FOURCC_BPP_BGR3 = 24, FOURCC_BPP_CM32 = 32, FOURCC_BPP_CM24 = 24, // Match any fourcc. FOURCC_BPP_ANY = 0, // 0 means unknown. }; // Converts fourcc aliases into canonical ones. LIBYUV_API uint32 CanonicalFourCC(uint32 fourcc); #ifdef __cplusplus } // extern "C" } // namespace libyuv #endif #endif // INCLUDE_LIBYUV_VIDEO_COMMON_H_ ================================================ FILE: phonelibs/libyuv/include/libyuv.h ================================================ /* * Copyright 2011 The LibYuv Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef INCLUDE_LIBYUV_H_ #define INCLUDE_LIBYUV_H_ #include "libyuv/basic_types.h" #include "libyuv/compare.h" #include "libyuv/convert.h" #include "libyuv/convert_argb.h" #include "libyuv/convert_from.h" #include "libyuv/convert_from_argb.h" #include "libyuv/cpu_id.h" #include "libyuv/mjpeg_decoder.h" #include "libyuv/planar_functions.h" #include "libyuv/rotate.h" #include "libyuv/rotate_argb.h" #include "libyuv/row.h" #include "libyuv/scale.h" #include "libyuv/scale_argb.h" #include "libyuv/scale_row.h" #include "libyuv/version.h" #include "libyuv/video_common.h" #endif // INCLUDE_LIBYUV_H_ ================================================ FILE: phonelibs/linux/include/linux/ion.h ================================================ /**************************************************************************** **************************************************************************** *** *** This header was automatically generated from a Linux kernel header *** of the same name, to make information necessary for userspace to *** call into the kernel available to libc. It contains only constants, *** structures, and macros generated from the original header, and thus, *** contains no copyrightable information. *** *** To edit the content of this header, modify the corresponding *** source file (e.g. under external/kernel-headers/original/) then *** run bionic/libc/kernel/tools/update_all.py *** *** Any manual change here will be lost the next time this script will *** be run. You've been warned! *** **************************************************************************** ****************************************************************************/ #ifndef _UAPI_LINUX_ION_H #define _UAPI_LINUX_ION_H #include #include typedef int ion_user_handle_t; enum ion_heap_type { ION_HEAP_TYPE_SYSTEM, ION_HEAP_TYPE_SYSTEM_CONTIG, ION_HEAP_TYPE_CARVEOUT, ION_HEAP_TYPE_CHUNK, ION_HEAP_TYPE_DMA, ION_HEAP_TYPE_CUSTOM, }; #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) #define ION_FLAG_CACHED 1 #define ION_FLAG_CACHED_NEEDS_SYNC 2 struct ion_allocation_data { size_t len; size_t align; unsigned int heap_id_mask; unsigned int flags; ion_user_handle_t handle; }; struct ion_fd_data { ion_user_handle_t handle; int fd; }; struct ion_handle_data { ion_user_handle_t handle; }; struct ion_custom_data { unsigned int cmd; unsigned long arg; }; #define MAX_HEAP_NAME 32 struct ion_heap_data { char name[MAX_HEAP_NAME]; __u32 type; __u32 heap_id; __u32 reserved0; __u32 reserved1; __u32 reserved2; }; struct ion_heap_query { __u32 cnt; __u32 reserved0; __u64 heaps; __u32 reserved1; __u32 reserved2; }; #define ION_IOC_MAGIC 'I' #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, struct ion_allocation_data) #define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data) #define ION_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion_fd_data) #define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data) #define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data) #define ION_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion_fd_data) #define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data) #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, struct ion_heap_query) #endif ================================================ FILE: phonelibs/linux/include/msm_ion.h ================================================ #ifndef _UAPI_MSM_ION_H #define _UAPI_MSM_ION_H #include enum msm_ion_heap_types { ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1, ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START, ION_HEAP_TYPE_SYSTEM_SECURE, ION_HEAP_TYPE_HYP_CMA, /* * if you add a heap type here you should also add it to * heap_types_info[] in msm_ion.c */ }; /** * These are the only ids that should be used for Ion heap ids. * The ids listed are the order in which allocation will be attempted * if specified. Don't swap the order of heap ids unless you know what * you are doing! * Id's are spaced by purpose to allow new Id's to be inserted in-between (for * possible fallbacks) */ enum ion_heap_ids { INVALID_HEAP_ID = -1, ION_CP_MM_HEAP_ID = 8, ION_SECURE_HEAP_ID = 9, ION_SECURE_DISPLAY_HEAP_ID = 10, ION_CP_MFC_HEAP_ID = 12, ION_CP_WB_HEAP_ID = 16, /* 8660 only */ ION_CAMERA_HEAP_ID = 20, /* 8660 only */ ION_SYSTEM_CONTIG_HEAP_ID = 21, ION_ADSP_HEAP_ID = 22, ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ ION_SF_HEAP_ID = 24, ION_SYSTEM_HEAP_ID = 25, ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ ION_QSECOM_HEAP_ID = 27, ION_AUDIO_HEAP_ID = 28, ION_MM_FIRMWARE_HEAP_ID = 29, ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ }; /* * The IOMMU heap is deprecated! Here are some aliases for backwards * compatibility: */ #define ION_IOMMU_HEAP_ID ION_SYSTEM_HEAP_ID #define ION_HEAP_TYPE_IOMMU ION_HEAP_TYPE_SYSTEM enum ion_fixed_position { NOT_FIXED, FIXED_LOW, FIXED_MIDDLE, FIXED_HIGH, }; enum cp_mem_usage { VIDEO_BITSTREAM = 0x1, VIDEO_PIXEL = 0x2, VIDEO_NONPIXEL = 0x3, DISPLAY_SECURE_CP_USAGE = 0x4, CAMERA_SECURE_CP_USAGE = 0x5, MAX_USAGE = 0x6, UNKNOWN = 0x7FFFFFFF, }; /** * Flags to be used when allocating from the secure heap for * content protection */ #define ION_FLAG_CP_TOUCH (1 << 17) #define ION_FLAG_CP_BITSTREAM (1 << 18) #define ION_FLAG_CP_PIXEL (1 << 19) #define ION_FLAG_CP_NON_PIXEL (1 << 20) #define ION_FLAG_CP_CAMERA (1 << 21) #define ION_FLAG_CP_HLOS (1 << 22) #define ION_FLAG_CP_HLOS_FREE (1 << 23) #define ION_FLAG_CP_SEC_DISPLAY (1 << 25) #define ION_FLAG_CP_APP (1 << 26) /** * Flag to allow non continguous allocation of memory from secure * heap */ #define ION_FLAG_ALLOW_NON_CONTIG (1 << 24) /** * Flag to use when allocating to indicate that a heap is secure. */ #define ION_FLAG_SECURE (1 << ION_HEAP_ID_RESERVED) /** * Flag for clients to force contiguous memort allocation * * Use of this flag is carefully monitored! */ #define ION_FLAG_FORCE_CONTIGUOUS (1 << 30) /* * Used in conjunction with heap which pool memory to force an allocation * to come from the page allocator directly instead of from the pool allocation */ #define ION_FLAG_POOL_FORCE_ALLOC (1 << 16) #define ION_FLAG_POOL_PREFETCH (1 << 27) /** * Deprecated! Please use the corresponding ION_FLAG_* */ #define ION_SECURE ION_FLAG_SECURE #define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS /** * Macro should be used with ion_heap_ids defined above. */ #define ION_HEAP(bit) (1 << (bit)) #define ION_ADSP_HEAP_NAME "adsp" #define ION_SYSTEM_HEAP_NAME "system" #define ION_VMALLOC_HEAP_NAME ION_SYSTEM_HEAP_NAME #define ION_KMALLOC_HEAP_NAME "kmalloc" #define ION_AUDIO_HEAP_NAME "audio" #define ION_SF_HEAP_NAME "sf" #define ION_MM_HEAP_NAME "mm" #define ION_CAMERA_HEAP_NAME "camera_preview" #define ION_IOMMU_HEAP_NAME "iommu" #define ION_MFC_HEAP_NAME "mfc" #define ION_WB_HEAP_NAME "wb" #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" #define ION_PIL1_HEAP_NAME "pil_1" #define ION_PIL2_HEAP_NAME "pil_2" #define ION_QSECOM_HEAP_NAME "qsecom" #define ION_SECURE_HEAP_NAME "secure_heap" #define ION_SECURE_DISPLAY_HEAP_NAME "secure_display" #define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED) #define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED) #define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) /* struct ion_flush_data - data passed to ion for flushing caches * * @handle: handle with data to flush * @fd: fd to flush * @vaddr: userspace virtual address mapped with mmap * @offset: offset into the handle to flush * @length: length of handle to flush * * Performs cache operations on the handle. If p is the start address * of the handle, p + offset through p + offset + length will have * the cache operations performed */ struct ion_flush_data { ion_user_handle_t handle; int fd; void *vaddr; unsigned int offset; unsigned int length; }; struct ion_prefetch_regions { unsigned int vmid; size_t *sizes; unsigned int nr_sizes; }; struct ion_prefetch_data { int heap_id; unsigned long len; /* Is unsigned long bad? 32bit compiler vs 64 bit compiler*/ struct ion_prefetch_regions *regions; unsigned int nr_regions; }; #define ION_IOC_MSM_MAGIC 'M' /** * DOC: ION_IOC_CLEAN_CACHES - clean the caches * * Clean the caches of the handle specified. */ #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ struct ion_flush_data) /** * DOC: ION_IOC_INV_CACHES - invalidate the caches * * Invalidate the caches of the handle specified. */ #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ struct ion_flush_data) /** * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches * * Clean and invalidate the caches of the handle specified. */ #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ struct ion_flush_data) #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ struct ion_prefetch_data) #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ struct ion_prefetch_data) #endif ================================================ FILE: phonelibs/mapbox-gl-native-qt/include/QMapbox ================================================ #include "qmapbox.hpp" ================================================ FILE: phonelibs/mapbox-gl-native-qt/include/QMapboxGL ================================================ #include "qmapboxgl.hpp" ================================================ FILE: phonelibs/mapbox-gl-native-qt/include/qmapbox.hpp ================================================ #ifndef QMAPBOX_H #define QMAPBOX_H #include #include #include #include #include // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style #if !defined(QT_MAPBOXGL_STATIC) # if defined(QT_BUILD_MAPBOXGL_LIB) # define Q_MAPBOXGL_EXPORT Q_DECL_EXPORT # else # define Q_MAPBOXGL_EXPORT Q_DECL_IMPORT # endif #else # define Q_MAPBOXGL_EXPORT #endif namespace QMapbox { typedef QPair Coordinate; typedef QPair CoordinateZoom; typedef QPair ProjectedMeters; typedef QVector Coordinates; typedef QVector CoordinatesCollection; typedef QVector CoordinatesCollections; struct Q_MAPBOXGL_EXPORT Feature { enum Type { PointType = 1, LineStringType, PolygonType }; /*! Class constructor. */ Feature(Type type_ = PointType, const CoordinatesCollections& geometry_ = CoordinatesCollections(), const QVariantMap& properties_ = QVariantMap(), const QVariant& id_ = QVariant()) : type(type_), geometry(geometry_), properties(properties_), id(id_) {} Type type; CoordinatesCollections geometry; QVariantMap properties; QVariant id; }; struct Q_MAPBOXGL_EXPORT ShapeAnnotationGeometry { enum Type { LineStringType = 1, PolygonType, MultiLineStringType, MultiPolygonType }; /*! Class constructor. */ ShapeAnnotationGeometry(Type type_ = LineStringType, const CoordinatesCollections& geometry_ = CoordinatesCollections()) : type(type_), geometry(geometry_) {} Type type; CoordinatesCollections geometry; }; struct Q_MAPBOXGL_EXPORT SymbolAnnotation { Coordinate geometry; QString icon; }; struct Q_MAPBOXGL_EXPORT LineAnnotation { /*! Class constructor. */ LineAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, float width_ = 1.0f, const QColor& color_ = Qt::black) : geometry(geometry_), opacity(opacity_), width(width_), color(color_) {} ShapeAnnotationGeometry geometry; float opacity; float width; QColor color; }; struct Q_MAPBOXGL_EXPORT FillAnnotation { /*! Class constructor. */ FillAnnotation(const ShapeAnnotationGeometry& geometry_ = ShapeAnnotationGeometry(), float opacity_ = 1.0f, const QColor& color_ = Qt::black, const QVariant& outlineColor_ = QVariant()) : geometry(geometry_), opacity(opacity_), color(color_), outlineColor(outlineColor_) {} ShapeAnnotationGeometry geometry; float opacity; QColor color; QVariant outlineColor; }; typedef QVariant Annotation; typedef quint32 AnnotationID; typedef QVector AnnotationIDs; enum NetworkMode { Online, // Default Offline, }; Q_MAPBOXGL_EXPORT QVector >& defaultStyles(); Q_MAPBOXGL_EXPORT NetworkMode networkMode(); Q_MAPBOXGL_EXPORT void setNetworkMode(NetworkMode); // This struct is a 1:1 copy of mbgl::CustomLayerRenderParameters. struct Q_MAPBOXGL_EXPORT CustomLayerRenderParameters { double width; double height; double latitude; double longitude; double zoom; double bearing; double pitch; double fieldOfView; }; class Q_MAPBOXGL_EXPORT CustomLayerHostInterface { public: virtual ~CustomLayerHostInterface() = default; virtual void initialize() = 0; virtual void render(const CustomLayerRenderParameters&) = 0; virtual void deinitialize() = 0; }; Q_MAPBOXGL_EXPORT double metersPerPixelAtLatitude(double latitude, double zoom); Q_MAPBOXGL_EXPORT ProjectedMeters projectedMetersForCoordinate(const Coordinate &); Q_MAPBOXGL_EXPORT Coordinate coordinateForProjectedMeters(const ProjectedMeters &); } // namespace QMapbox Q_DECLARE_METATYPE(QMapbox::Coordinate); Q_DECLARE_METATYPE(QMapbox::Coordinates); Q_DECLARE_METATYPE(QMapbox::CoordinatesCollection); Q_DECLARE_METATYPE(QMapbox::CoordinatesCollections); Q_DECLARE_METATYPE(QMapbox::Feature); Q_DECLARE_METATYPE(QMapbox::SymbolAnnotation); Q_DECLARE_METATYPE(QMapbox::ShapeAnnotationGeometry); Q_DECLARE_METATYPE(QMapbox::LineAnnotation); Q_DECLARE_METATYPE(QMapbox::FillAnnotation); #endif // QMAPBOX_H ================================================ FILE: phonelibs/mapbox-gl-native-qt/include/qmapboxgl.hpp ================================================ #ifndef QMAPBOXGL_H #define QMAPBOXGL_H #include #include #include #include #include #include #include #include #include class QMapboxGLPrivate; // This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style class Q_MAPBOXGL_EXPORT QMapboxGLSettings { public: QMapboxGLSettings(); enum GLContextMode { UniqueGLContext = 0, SharedGLContext }; enum MapMode { Continuous = 0, Static }; enum ConstrainMode { NoConstrain = 0, ConstrainHeightOnly, ConstrainWidthAndHeight }; enum ViewportMode { DefaultViewport = 0, FlippedYViewport }; GLContextMode contextMode() const; void setContextMode(GLContextMode); MapMode mapMode() const; void setMapMode(MapMode); ConstrainMode constrainMode() const; void setConstrainMode(ConstrainMode); ViewportMode viewportMode() const; void setViewportMode(ViewportMode); unsigned cacheDatabaseMaximumSize() const; void setCacheDatabaseMaximumSize(unsigned); QString cacheDatabasePath() const; void setCacheDatabasePath(const QString &); QString assetPath() const; void setAssetPath(const QString &); QString accessToken() const; void setAccessToken(const QString &); QString apiBaseUrl() const; void setApiBaseUrl(const QString &); QString localFontFamily() const; void setLocalFontFamily(const QString &); std::function resourceTransform() const; void setResourceTransform(const std::function &); private: GLContextMode m_contextMode; MapMode m_mapMode; ConstrainMode m_constrainMode; ViewportMode m_viewportMode; unsigned m_cacheMaximumSize; QString m_cacheDatabasePath; QString m_assetPath; QString m_accessToken; QString m_apiBaseUrl; QString m_localFontFamily; std::function m_resourceTransform; }; struct Q_MAPBOXGL_EXPORT QMapboxGLCameraOptions { QVariant center; // Coordinate QVariant anchor; // QPointF QVariant zoom; // double QVariant bearing; // double QVariant pitch; // double }; class Q_MAPBOXGL_EXPORT QMapboxGL : public QObject { Q_OBJECT Q_PROPERTY(double latitude READ latitude WRITE setLatitude) Q_PROPERTY(double longitude READ longitude WRITE setLongitude) Q_PROPERTY(double zoom READ zoom WRITE setZoom) Q_PROPERTY(double bearing READ bearing WRITE setBearing) Q_PROPERTY(double pitch READ pitch WRITE setPitch) Q_PROPERTY(QString styleJson READ styleJson WRITE setStyleJson) Q_PROPERTY(QString styleUrl READ styleUrl WRITE setStyleUrl) Q_PROPERTY(double scale READ scale WRITE setScale) Q_PROPERTY(QMapbox::Coordinate coordinate READ coordinate WRITE setCoordinate) Q_PROPERTY(QMargins margins READ margins WRITE setMargins) public: enum MapChange { MapChangeRegionWillChange = 0, MapChangeRegionWillChangeAnimated, MapChangeRegionIsChanging, MapChangeRegionDidChange, MapChangeRegionDidChangeAnimated, MapChangeWillStartLoadingMap, MapChangeDidFinishLoadingMap, MapChangeDidFailLoadingMap, MapChangeWillStartRenderingFrame, MapChangeDidFinishRenderingFrame, MapChangeDidFinishRenderingFrameFullyRendered, MapChangeWillStartRenderingMap, MapChangeDidFinishRenderingMap, MapChangeDidFinishRenderingMapFullyRendered, MapChangeDidFinishLoadingStyle, MapChangeSourceDidChange }; enum MapLoadingFailure { StyleParseFailure, StyleLoadFailure, NotFoundFailure, UnknownFailure }; // Determines the orientation of the map. enum NorthOrientation { NorthUpwards, // Default NorthRightwards, NorthDownwards, NorthLeftwards, }; QMapboxGL(QObject* parent = 0, const QMapboxGLSettings& = QMapboxGLSettings(), const QSize& size = QSize(), qreal pixelRatio = 1); virtual ~QMapboxGL(); QString styleJson() const; QString styleUrl() const; void setStyleJson(const QString &); void setStyleUrl(const QString &); double latitude() const; void setLatitude(double latitude); double longitude() const; void setLongitude(double longitude); double scale() const; void setScale(double scale, const QPointF ¢er = QPointF()); double zoom() const; void setZoom(double zoom); double minimumZoom() const; double maximumZoom() const; double bearing() const; void setBearing(double degrees); void setBearing(double degrees, const QPointF ¢er); double pitch() const; void setPitch(double pitch); void pitchBy(double pitch); NorthOrientation northOrientation() const; void setNorthOrientation(NorthOrientation); QMapbox::Coordinate coordinate() const; void setCoordinate(const QMapbox::Coordinate &); void setCoordinateZoom(const QMapbox::Coordinate &, double zoom); void jumpTo(const QMapboxGLCameraOptions&); void setGestureInProgress(bool inProgress); void setTransitionOptions(qint64 duration, qint64 delay = 0); void addAnnotationIcon(const QString &name, const QImage &sprite); QMapbox::AnnotationID addAnnotation(const QMapbox::Annotation &); void updateAnnotation(QMapbox::AnnotationID, const QMapbox::Annotation &); void removeAnnotation(QMapbox::AnnotationID); bool setLayoutProperty(const QString &layer, const QString &property, const QVariant &value); bool setPaintProperty(const QString &layer, const QString &property, const QVariant &value); bool isFullyLoaded() const; void moveBy(const QPointF &offset); void scaleBy(double scale, const QPointF ¢er = QPointF()); void rotateBy(const QPointF &first, const QPointF &second); void resize(const QSize &size); double metersPerPixelAtLatitude(double latitude, double zoom) const; QMapbox::ProjectedMeters projectedMetersForCoordinate(const QMapbox::Coordinate &) const; QMapbox::Coordinate coordinateForProjectedMeters(const QMapbox::ProjectedMeters &) const; QPointF pixelForCoordinate(const QMapbox::Coordinate &) const; QMapbox::Coordinate coordinateForPixel(const QPointF &) const; QMapbox::CoordinateZoom coordinateZoomForBounds(const QMapbox::Coordinate &sw, QMapbox::Coordinate &ne) const; QMapbox::CoordinateZoom coordinateZoomForBounds(const QMapbox::Coordinate &sw, QMapbox::Coordinate &ne, double bearing, double pitch); void setMargins(const QMargins &margins); QMargins margins() const; void addSource(const QString &sourceID, const QVariantMap& params); bool sourceExists(const QString &sourceID); void updateSource(const QString &sourceID, const QVariantMap& params); void removeSource(const QString &sourceID); void addImage(const QString &name, const QImage &sprite); void removeImage(const QString &name); void addCustomLayer(const QString &id, QScopedPointer& host, const QString& before = QString()); void addLayer(const QVariantMap ¶ms, const QString& before = QString()); bool layerExists(const QString &id); void removeLayer(const QString &id); QVector layerIds() const; void setFilter(const QString &layer, const QVariant &filter); QVariant getFilter(const QString &layer) const; // When rendering on a different thread, // should be called on the render thread. void createRenderer(); void destroyRenderer(); void setFramebufferObject(quint32 fbo, const QSize &size); public slots: void render(); void connectionEstablished(); // Commit changes, load all the resources // and renders the map when completed. void startStaticRender(); signals: void needsRendering(); void mapChanged(QMapboxGL::MapChange); void mapLoadingFailed(QMapboxGL::MapLoadingFailure, const QString &reason); void copyrightsChanged(const QString ©rightsHtml); void staticRenderFinished(const QString &error); private: Q_DISABLE_COPY(QMapboxGL) QMapboxGLPrivate *d_ptr; }; Q_DECLARE_METATYPE(QMapboxGL::MapChange); Q_DECLARE_METATYPE(QMapboxGL::MapLoadingFailure); #endif // QMAPBOXGL_H ================================================ FILE: phonelibs/nanovg/fontstash.h ================================================ // // Copyright (c) 2009-2013 Mikko Mononen memon@inside.org // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // #ifndef FONS_H #define FONS_H #define FONS_INVALID -1 enum FONSflags { FONS_ZERO_TOPLEFT = 1, FONS_ZERO_BOTTOMLEFT = 2, }; enum FONSalign { // Horizontal align FONS_ALIGN_LEFT = 1<<0, // Default FONS_ALIGN_CENTER = 1<<1, FONS_ALIGN_RIGHT = 1<<2, // Vertical align FONS_ALIGN_TOP = 1<<3, FONS_ALIGN_MIDDLE = 1<<4, FONS_ALIGN_BOTTOM = 1<<5, FONS_ALIGN_BASELINE = 1<<6, // Default }; enum FONSerrorCode { // Font atlas is full. FONS_ATLAS_FULL = 1, // Scratch memory used to render glyphs is full, requested size reported in 'val', you may need to bump up FONS_SCRATCH_BUF_SIZE. FONS_SCRATCH_FULL = 2, // Calls to fonsPushState has created too large stack, if you need deep state stack bump up FONS_MAX_STATES. FONS_STATES_OVERFLOW = 3, // Trying to pop too many states fonsPopState(). FONS_STATES_UNDERFLOW = 4, }; struct FONSparams { int width, height; unsigned char flags; void* userPtr; int (*renderCreate)(void* uptr, int width, int height); int (*renderResize)(void* uptr, int width, int height); void (*renderUpdate)(void* uptr, int* rect, const unsigned char* data); void (*renderDraw)(void* uptr, const float* verts, const float* tcoords, const unsigned int* colors, int nverts); void (*renderDelete)(void* uptr); }; typedef struct FONSparams FONSparams; struct FONSquad { float x0,y0,s0,t0; float x1,y1,s1,t1; }; typedef struct FONSquad FONSquad; struct FONStextIter { float x, y, nextx, nexty, scale, spacing; unsigned int codepoint; short isize, iblur; struct FONSfont* font; int prevGlyphIndex; const char* str; const char* next; const char* end; unsigned int utf8state; }; typedef struct FONStextIter FONStextIter; typedef struct FONScontext FONScontext; // Constructor and destructor. FONScontext* fonsCreateInternal(FONSparams* params); void fonsDeleteInternal(FONScontext* s); void fonsSetErrorCallback(FONScontext* s, void (*callback)(void* uptr, int error, int val), void* uptr); // Returns current atlas size. void fonsGetAtlasSize(FONScontext* s, int* width, int* height); // Expands the atlas size. int fonsExpandAtlas(FONScontext* s, int width, int height); // Resets the whole stash. int fonsResetAtlas(FONScontext* stash, int width, int height); // Add fonts int fonsAddFont(FONScontext* s, const char* name, const char* path); int fonsAddFontMem(FONScontext* s, const char* name, unsigned char* data, int ndata, int freeData); int fonsGetFontByName(FONScontext* s, const char* name); // State handling void fonsPushState(FONScontext* s); void fonsPopState(FONScontext* s); void fonsClearState(FONScontext* s); // State setting void fonsSetSize(FONScontext* s, float size); void fonsSetColor(FONScontext* s, unsigned int color); void fonsSetSpacing(FONScontext* s, float spacing); void fonsSetBlur(FONScontext* s, float blur); void fonsSetAlign(FONScontext* s, int align); void fonsSetFont(FONScontext* s, int font); // Draw text float fonsDrawText(FONScontext* s, float x, float y, const char* string, const char* end); // Measure text float fonsTextBounds(FONScontext* s, float x, float y, const char* string, const char* end, float* bounds); void fonsLineBounds(FONScontext* s, float y, float* miny, float* maxy); void fonsVertMetrics(FONScontext* s, float* ascender, float* descender, float* lineh); // Text iterator int fonsTextIterInit(FONScontext* stash, FONStextIter* iter, float x, float y, const char* str, const char* end); int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, struct FONSquad* quad); // Pull texture changes const unsigned char* fonsGetTextureData(FONScontext* stash, int* width, int* height); int fonsValidateTexture(FONScontext* s, int* dirty); // Draws the stash texture for debugging void fonsDrawDebug(FONScontext* s, float x, float y); #endif // FONTSTASH_H #ifdef FONTSTASH_IMPLEMENTATION #define FONS_NOTUSED(v) (void)sizeof(v) #ifdef FONS_USE_FREETYPE #include #include FT_FREETYPE_H #include FT_ADVANCES_H #include struct FONSttFontImpl { FT_Face font; }; typedef struct FONSttFontImpl FONSttFontImpl; static FT_Library ftLibrary; int fons__tt_init(FONScontext *context) { FT_Error ftError; FONS_NOTUSED(context); ftError = FT_Init_FreeType(&ftLibrary); return ftError == 0; } int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize) { FT_Error ftError; FONS_NOTUSED(context); //font->font.userdata = stash; ftError = FT_New_Memory_Face(ftLibrary, (const FT_Byte*)data, dataSize, 0, &font->font); return ftError == 0; } void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, int *lineGap) { *ascent = font->font->ascender; *descent = font->font->descender; *lineGap = font->font->height - (*ascent - *descent); } float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size) { return size / (font->font->ascender - font->font->descender); } int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint) { return FT_Get_Char_Index(font->font, codepoint); } int fons__tt_buildGlyphBitmap(FONSttFontImpl *font, int glyph, float size, float scale, int *advance, int *lsb, int *x0, int *y0, int *x1, int *y1) { FT_Error ftError; FT_GlyphSlot ftGlyph; FT_Fixed advFixed; FONS_NOTUSED(scale); ftError = FT_Set_Pixel_Sizes(font->font, 0, (FT_UInt)(size * (float)font->font->units_per_EM / (float)(font->font->ascender - font->font->descender))); if (ftError) return 0; ftError = FT_Load_Glyph(font->font, glyph, FT_LOAD_RENDER); if (ftError) return 0; ftError = FT_Get_Advance(font->font, glyph, FT_LOAD_NO_SCALE, &advFixed); if (ftError) return 0; ftGlyph = font->font->glyph; *advance = (int)advFixed; *lsb = (int)ftGlyph->metrics.horiBearingX; *x0 = ftGlyph->bitmap_left; *x1 = *x0 + ftGlyph->bitmap.width; *y0 = -ftGlyph->bitmap_top; *y1 = *y0 + ftGlyph->bitmap.rows; return 1; } void fons__tt_renderGlyphBitmap(FONSttFontImpl *font, unsigned char *output, int outWidth, int outHeight, int outStride, float scaleX, float scaleY, int glyph) { FT_GlyphSlot ftGlyph = font->font->glyph; int ftGlyphOffset = 0; int x, y; FONS_NOTUSED(outWidth); FONS_NOTUSED(outHeight); FONS_NOTUSED(scaleX); FONS_NOTUSED(scaleY); FONS_NOTUSED(glyph); // glyph has already been loaded by fons__tt_buildGlyphBitmap for ( y = 0; y < ftGlyph->bitmap.rows; y++ ) { for ( x = 0; x < ftGlyph->bitmap.width; x++ ) { output[(y * outStride) + x] = ftGlyph->bitmap.buffer[ftGlyphOffset++]; } } } int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2) { FT_Vector ftKerning; FT_Get_Kerning(font->font, glyph1, glyph2, FT_KERNING_DEFAULT, &ftKerning); return (int)((ftKerning.x + 32) >> 6); // Round up and convert to integer } #else #define STB_TRUETYPE_IMPLEMENTATION static void* fons__tmpalloc(size_t size, void* up); static void fons__tmpfree(void* ptr, void* up); #define STBTT_malloc(x,u) fons__tmpalloc(x,u) #define STBTT_free(x,u) fons__tmpfree(x,u) #include "stb_truetype.h" struct FONSttFontImpl { stbtt_fontinfo font; }; typedef struct FONSttFontImpl FONSttFontImpl; int fons__tt_init(FONScontext *context) { FONS_NOTUSED(context); return 1; } int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize) { int stbError; FONS_NOTUSED(dataSize); font->font.userdata = context; stbError = stbtt_InitFont(&font->font, data, 0); return stbError; } void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, int *lineGap) { stbtt_GetFontVMetrics(&font->font, ascent, descent, lineGap); } float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size) { return stbtt_ScaleForPixelHeight(&font->font, size); } int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint) { return stbtt_FindGlyphIndex(&font->font, codepoint); } int fons__tt_buildGlyphBitmap(FONSttFontImpl *font, int glyph, float size, float scale, int *advance, int *lsb, int *x0, int *y0, int *x1, int *y1) { FONS_NOTUSED(size); stbtt_GetGlyphHMetrics(&font->font, glyph, advance, lsb); stbtt_GetGlyphBitmapBox(&font->font, glyph, scale, scale, x0, y0, x1, y1); return 1; } void fons__tt_renderGlyphBitmap(FONSttFontImpl *font, unsigned char *output, int outWidth, int outHeight, int outStride, float scaleX, float scaleY, int glyph) { stbtt_MakeGlyphBitmap(&font->font, output, outWidth, outHeight, outStride, scaleX, scaleY, glyph); } int fons__tt_getGlyphKernAdvance(FONSttFontImpl *font, int glyph1, int glyph2) { return stbtt_GetGlyphKernAdvance(&font->font, glyph1, glyph2); } #endif #ifndef FONS_SCRATCH_BUF_SIZE # define FONS_SCRATCH_BUF_SIZE 64000 #endif #ifndef FONS_HASH_LUT_SIZE # define FONS_HASH_LUT_SIZE 256 #endif #ifndef FONS_INIT_FONTS # define FONS_INIT_FONTS 4 #endif #ifndef FONS_INIT_GLYPHS # define FONS_INIT_GLYPHS 256 #endif #ifndef FONS_INIT_ATLAS_NODES # define FONS_INIT_ATLAS_NODES 256 #endif #ifndef FONS_VERTEX_COUNT # define FONS_VERTEX_COUNT 1024 #endif #ifndef FONS_MAX_STATES # define FONS_MAX_STATES 20 #endif #ifndef FONS_MAX_FALLBACKS # define FONS_MAX_FALLBACKS 20 #endif static unsigned int fons__hashint(unsigned int a) { a += ~(a<<15); a ^= (a>>10); a += (a<<3); a ^= (a>>6); a += ~(a<<11); a ^= (a>>16); return a; } static int fons__mini(int a, int b) { return a < b ? a : b; } static int fons__maxi(int a, int b) { return a > b ? a : b; } struct FONSglyph { unsigned int codepoint; int index; int next; short size, blur; short x0,y0,x1,y1; short xadv,xoff,yoff; }; typedef struct FONSglyph FONSglyph; struct FONSfont { FONSttFontImpl font; char name[64]; unsigned char* data; int dataSize; unsigned char freeData; float ascender; float descender; float lineh; FONSglyph* glyphs; int cglyphs; int nglyphs; int lut[FONS_HASH_LUT_SIZE]; int fallbacks[FONS_MAX_FALLBACKS]; int nfallbacks; }; typedef struct FONSfont FONSfont; struct FONSstate { int font; int align; float size; unsigned int color; float blur; float spacing; }; typedef struct FONSstate FONSstate; struct FONSatlasNode { short x, y, width; }; typedef struct FONSatlasNode FONSatlasNode; struct FONSatlas { int width, height; FONSatlasNode* nodes; int nnodes; int cnodes; }; typedef struct FONSatlas FONSatlas; struct FONScontext { FONSparams params; float itw,ith; unsigned char* texData; int dirtyRect[4]; FONSfont** fonts; FONSatlas* atlas; int cfonts; int nfonts; float verts[FONS_VERTEX_COUNT*2]; float tcoords[FONS_VERTEX_COUNT*2]; unsigned int colors[FONS_VERTEX_COUNT]; int nverts; unsigned char* scratch; int nscratch; FONSstate states[FONS_MAX_STATES]; int nstates; void (*handleError)(void* uptr, int error, int val); void* errorUptr; }; #ifdef STB_TRUETYPE_IMPLEMENTATION static void* fons__tmpalloc(size_t size, void* up) { unsigned char* ptr; FONScontext* stash = (FONScontext*)up; // 16-byte align the returned pointer size = (size + 0xf) & ~0xf; if (stash->nscratch+(int)size > FONS_SCRATCH_BUF_SIZE) { if (stash->handleError) stash->handleError(stash->errorUptr, FONS_SCRATCH_FULL, stash->nscratch+(int)size); return NULL; } ptr = stash->scratch + stash->nscratch; stash->nscratch += (int)size; return ptr; } static void fons__tmpfree(void* ptr, void* up) { (void)ptr; (void)up; // empty } #endif // STB_TRUETYPE_IMPLEMENTATION // Copyright (c) 2008-2010 Bjoern Hoehrmann // See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details. #define FONS_UTF8_ACCEPT 0 #define FONS_UTF8_REJECT 12 static unsigned int fons__decutf8(unsigned int* state, unsigned int* codep, unsigned int byte) { static const unsigned char utf8d[] = { // The first part of the table maps bytes to character classes that // to reduce the size of the transition table and create bitmasks. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, // The second part is a transition table that maps a combination // of a state of the automaton and a character class to a state. 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12, 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12, 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12, 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,12,12,12,12,12, }; unsigned int type = utf8d[byte]; *codep = (*state != FONS_UTF8_ACCEPT) ? (byte & 0x3fu) | (*codep << 6) : (0xff >> type) & (byte); *state = utf8d[256 + *state + type]; return *state; } // Atlas based on Skyline Bin Packer by Jukka Jylänki static void fons__deleteAtlas(FONSatlas* atlas) { if (atlas == NULL) return; if (atlas->nodes != NULL) free(atlas->nodes); free(atlas); } static FONSatlas* fons__allocAtlas(int w, int h, int nnodes) { FONSatlas* atlas = NULL; // Allocate memory for the font stash. atlas = (FONSatlas*)malloc(sizeof(FONSatlas)); if (atlas == NULL) goto error; memset(atlas, 0, sizeof(FONSatlas)); atlas->width = w; atlas->height = h; // Allocate space for skyline nodes atlas->nodes = (FONSatlasNode*)malloc(sizeof(FONSatlasNode) * nnodes); if (atlas->nodes == NULL) goto error; memset(atlas->nodes, 0, sizeof(FONSatlasNode) * nnodes); atlas->nnodes = 0; atlas->cnodes = nnodes; // Init root node. atlas->nodes[0].x = 0; atlas->nodes[0].y = 0; atlas->nodes[0].width = (short)w; atlas->nnodes++; return atlas; error: if (atlas) fons__deleteAtlas(atlas); return NULL; } static int fons__atlasInsertNode(FONSatlas* atlas, int idx, int x, int y, int w) { int i; // Insert node if (atlas->nnodes+1 > atlas->cnodes) { atlas->cnodes = atlas->cnodes == 0 ? 8 : atlas->cnodes * 2; atlas->nodes = (FONSatlasNode*)realloc(atlas->nodes, sizeof(FONSatlasNode) * atlas->cnodes); if (atlas->nodes == NULL) return 0; } for (i = atlas->nnodes; i > idx; i--) atlas->nodes[i] = atlas->nodes[i-1]; atlas->nodes[idx].x = (short)x; atlas->nodes[idx].y = (short)y; atlas->nodes[idx].width = (short)w; atlas->nnodes++; return 1; } static void fons__atlasRemoveNode(FONSatlas* atlas, int idx) { int i; if (atlas->nnodes == 0) return; for (i = idx; i < atlas->nnodes-1; i++) atlas->nodes[i] = atlas->nodes[i+1]; atlas->nnodes--; } static void fons__atlasExpand(FONSatlas* atlas, int w, int h) { // Insert node for empty space if (w > atlas->width) fons__atlasInsertNode(atlas, atlas->nnodes, atlas->width, 0, w - atlas->width); atlas->width = w; atlas->height = h; } static void fons__atlasReset(FONSatlas* atlas, int w, int h) { atlas->width = w; atlas->height = h; atlas->nnodes = 0; // Init root node. atlas->nodes[0].x = 0; atlas->nodes[0].y = 0; atlas->nodes[0].width = (short)w; atlas->nnodes++; } static int fons__atlasAddSkylineLevel(FONSatlas* atlas, int idx, int x, int y, int w, int h) { int i; // Insert new node if (fons__atlasInsertNode(atlas, idx, x, y+h, w) == 0) return 0; // Delete skyline segments that fall under the shadow of the new segment. for (i = idx+1; i < atlas->nnodes; i++) { if (atlas->nodes[i].x < atlas->nodes[i-1].x + atlas->nodes[i-1].width) { int shrink = atlas->nodes[i-1].x + atlas->nodes[i-1].width - atlas->nodes[i].x; atlas->nodes[i].x += (short)shrink; atlas->nodes[i].width -= (short)shrink; if (atlas->nodes[i].width <= 0) { fons__atlasRemoveNode(atlas, i); i--; } else { break; } } else { break; } } // Merge same height skyline segments that are next to each other. for (i = 0; i < atlas->nnodes-1; i++) { if (atlas->nodes[i].y == atlas->nodes[i+1].y) { atlas->nodes[i].width += atlas->nodes[i+1].width; fons__atlasRemoveNode(atlas, i+1); i--; } } return 1; } static int fons__atlasRectFits(FONSatlas* atlas, int i, int w, int h) { // Checks if there is enough space at the location of skyline span 'i', // and return the max height of all skyline spans under that at that location, // (think tetris block being dropped at that position). Or -1 if no space found. int x = atlas->nodes[i].x; int y = atlas->nodes[i].y; int spaceLeft; if (x + w > atlas->width) return -1; spaceLeft = w; while (spaceLeft > 0) { if (i == atlas->nnodes) return -1; y = fons__maxi(y, atlas->nodes[i].y); if (y + h > atlas->height) return -1; spaceLeft -= atlas->nodes[i].width; ++i; } return y; } static int fons__atlasAddRect(FONSatlas* atlas, int rw, int rh, int* rx, int* ry) { int besth = atlas->height, bestw = atlas->width, besti = -1; int bestx = -1, besty = -1, i; // Bottom left fit heuristic. for (i = 0; i < atlas->nnodes; i++) { int y = fons__atlasRectFits(atlas, i, rw, rh); if (y != -1) { if (y + rh < besth || (y + rh == besth && atlas->nodes[i].width < bestw)) { besti = i; bestw = atlas->nodes[i].width; besth = y + rh; bestx = atlas->nodes[i].x; besty = y; } } } if (besti == -1) return 0; // Perform the actual packing. if (fons__atlasAddSkylineLevel(atlas, besti, bestx, besty, rw, rh) == 0) return 0; *rx = bestx; *ry = besty; return 1; } static void fons__addWhiteRect(FONScontext* stash, int w, int h) { int x, y, gx, gy; unsigned char* dst; if (fons__atlasAddRect(stash->atlas, w, h, &gx, &gy) == 0) return; // Rasterize dst = &stash->texData[gx + gy * stash->params.width]; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) dst[x] = 0xff; dst += stash->params.width; } stash->dirtyRect[0] = fons__mini(stash->dirtyRect[0], gx); stash->dirtyRect[1] = fons__mini(stash->dirtyRect[1], gy); stash->dirtyRect[2] = fons__maxi(stash->dirtyRect[2], gx+w); stash->dirtyRect[3] = fons__maxi(stash->dirtyRect[3], gy+h); } FONScontext* fonsCreateInternal(FONSparams* params) { FONScontext* stash = NULL; // Allocate memory for the font stash. stash = (FONScontext*)malloc(sizeof(FONScontext)); if (stash == NULL) goto error; memset(stash, 0, sizeof(FONScontext)); stash->params = *params; // Allocate scratch buffer. stash->scratch = (unsigned char*)malloc(FONS_SCRATCH_BUF_SIZE); if (stash->scratch == NULL) goto error; // Initialize implementation library if (!fons__tt_init(stash)) goto error; if (stash->params.renderCreate != NULL) { if (stash->params.renderCreate(stash->params.userPtr, stash->params.width, stash->params.height) == 0) goto error; } stash->atlas = fons__allocAtlas(stash->params.width, stash->params.height, FONS_INIT_ATLAS_NODES); if (stash->atlas == NULL) goto error; // Allocate space for fonts. stash->fonts = (FONSfont**)malloc(sizeof(FONSfont*) * FONS_INIT_FONTS); if (stash->fonts == NULL) goto error; memset(stash->fonts, 0, sizeof(FONSfont*) * FONS_INIT_FONTS); stash->cfonts = FONS_INIT_FONTS; stash->nfonts = 0; // Create texture for the cache. stash->itw = 1.0f/stash->params.width; stash->ith = 1.0f/stash->params.height; stash->texData = (unsigned char*)malloc(stash->params.width * stash->params.height); if (stash->texData == NULL) goto error; memset(stash->texData, 0, stash->params.width * stash->params.height); stash->dirtyRect[0] = stash->params.width; stash->dirtyRect[1] = stash->params.height; stash->dirtyRect[2] = 0; stash->dirtyRect[3] = 0; // Add white rect at 0,0 for debug drawing. fons__addWhiteRect(stash, 2,2); fonsPushState(stash); fonsClearState(stash); return stash; error: fonsDeleteInternal(stash); return NULL; } static FONSstate* fons__getState(FONScontext* stash) { return &stash->states[stash->nstates-1]; } int fonsAddFallbackFont(FONScontext* stash, int base, int fallback) { FONSfont* baseFont = stash->fonts[base]; if (baseFont->nfallbacks < FONS_MAX_FALLBACKS) { baseFont->fallbacks[baseFont->nfallbacks++] = fallback; return 1; } return 0; } void fonsSetSize(FONScontext* stash, float size) { fons__getState(stash)->size = size; } void fonsSetColor(FONScontext* stash, unsigned int color) { fons__getState(stash)->color = color; } void fonsSetSpacing(FONScontext* stash, float spacing) { fons__getState(stash)->spacing = spacing; } void fonsSetBlur(FONScontext* stash, float blur) { fons__getState(stash)->blur = blur; } void fonsSetAlign(FONScontext* stash, int align) { fons__getState(stash)->align = align; } void fonsSetFont(FONScontext* stash, int font) { fons__getState(stash)->font = font; } void fonsPushState(FONScontext* stash) { if (stash->nstates >= FONS_MAX_STATES) { if (stash->handleError) stash->handleError(stash->errorUptr, FONS_STATES_OVERFLOW, 0); return; } if (stash->nstates > 0) memcpy(&stash->states[stash->nstates], &stash->states[stash->nstates-1], sizeof(FONSstate)); stash->nstates++; } void fonsPopState(FONScontext* stash) { if (stash->nstates <= 1) { if (stash->handleError) stash->handleError(stash->errorUptr, FONS_STATES_UNDERFLOW, 0); return; } stash->nstates--; } void fonsClearState(FONScontext* stash) { FONSstate* state = fons__getState(stash); state->size = 12.0f; state->color = 0xffffffff; state->font = 0; state->blur = 0; state->spacing = 0; state->align = FONS_ALIGN_LEFT | FONS_ALIGN_BASELINE; } static void fons__freeFont(FONSfont* font) { if (font == NULL) return; if (font->glyphs) free(font->glyphs); if (font->freeData && font->data) free(font->data); free(font); } static int fons__allocFont(FONScontext* stash) { FONSfont* font = NULL; if (stash->nfonts+1 > stash->cfonts) { stash->cfonts = stash->cfonts == 0 ? 8 : stash->cfonts * 2; stash->fonts = (FONSfont**)realloc(stash->fonts, sizeof(FONSfont*) * stash->cfonts); if (stash->fonts == NULL) return -1; } font = (FONSfont*)malloc(sizeof(FONSfont)); if (font == NULL) goto error; memset(font, 0, sizeof(FONSfont)); font->glyphs = (FONSglyph*)malloc(sizeof(FONSglyph) * FONS_INIT_GLYPHS); if (font->glyphs == NULL) goto error; font->cglyphs = FONS_INIT_GLYPHS; font->nglyphs = 0; stash->fonts[stash->nfonts++] = font; return stash->nfonts-1; error: fons__freeFont(font); return FONS_INVALID; } int fonsAddFont(FONScontext* stash, const char* name, const char* path) { FILE* fp = 0; int dataSize = 0; unsigned char* data = NULL; // Read in the font data. fp = fopen(path, "rb"); if (fp == NULL) goto error; fseek(fp,0,SEEK_END); dataSize = (int)ftell(fp); fseek(fp,0,SEEK_SET); data = (unsigned char*)malloc(dataSize); if (data == NULL) goto error; fread(data, 1, dataSize, fp); fclose(fp); fp = 0; return fonsAddFontMem(stash, name, data, dataSize, 1); error: if (data) free(data); if (fp) fclose(fp); return FONS_INVALID; } int fonsAddFontMem(FONScontext* stash, const char* name, unsigned char* data, int dataSize, int freeData) { int i, ascent, descent, fh, lineGap; FONSfont* font; int idx = fons__allocFont(stash); if (idx == FONS_INVALID) return FONS_INVALID; font = stash->fonts[idx]; strncpy(font->name, name, sizeof(font->name)); font->name[sizeof(font->name)-1] = '\0'; // Init hash lookup. for (i = 0; i < FONS_HASH_LUT_SIZE; ++i) font->lut[i] = -1; // Read in the font data. font->dataSize = dataSize; font->data = data; font->freeData = (unsigned char)freeData; // Init font stash->nscratch = 0; if (!fons__tt_loadFont(stash, &font->font, data, dataSize)) goto error; // Store normalized line height. The real line height is got // by multiplying the lineh by font size. fons__tt_getFontVMetrics( &font->font, &ascent, &descent, &lineGap); fh = ascent - descent; font->ascender = (float)ascent / (float)fh; font->descender = (float)descent / (float)fh; font->lineh = (float)(fh + lineGap) / (float)fh; return idx; error: fons__freeFont(font); stash->nfonts--; return FONS_INVALID; } int fonsGetFontByName(FONScontext* s, const char* name) { int i; for (i = 0; i < s->nfonts; i++) { if (strcmp(s->fonts[i]->name, name) == 0) return i; } return FONS_INVALID; } static FONSglyph* fons__allocGlyph(FONSfont* font) { if (font->nglyphs+1 > font->cglyphs) { font->cglyphs = font->cglyphs == 0 ? 8 : font->cglyphs * 2; font->glyphs = (FONSglyph*)realloc(font->glyphs, sizeof(FONSglyph) * font->cglyphs); if (font->glyphs == NULL) return NULL; } font->nglyphs++; return &font->glyphs[font->nglyphs-1]; } // Based on Exponential blur, Jani Huhtanen, 2006 #define APREC 16 #define ZPREC 7 static void fons__blurCols(unsigned char* dst, int w, int h, int dstStride, int alpha) { int x, y; for (y = 0; y < h; y++) { int z = 0; // force zero border for (x = 1; x < w; x++) { z += (alpha * (((int)(dst[x]) << ZPREC) - z)) >> APREC; dst[x] = (unsigned char)(z >> ZPREC); } dst[w-1] = 0; // force zero border z = 0; for (x = w-2; x >= 0; x--) { z += (alpha * (((int)(dst[x]) << ZPREC) - z)) >> APREC; dst[x] = (unsigned char)(z >> ZPREC); } dst[0] = 0; // force zero border dst += dstStride; } } static void fons__blurRows(unsigned char* dst, int w, int h, int dstStride, int alpha) { int x, y; for (x = 0; x < w; x++) { int z = 0; // force zero border for (y = dstStride; y < h*dstStride; y += dstStride) { z += (alpha * (((int)(dst[y]) << ZPREC) - z)) >> APREC; dst[y] = (unsigned char)(z >> ZPREC); } dst[(h-1)*dstStride] = 0; // force zero border z = 0; for (y = (h-2)*dstStride; y >= 0; y -= dstStride) { z += (alpha * (((int)(dst[y]) << ZPREC) - z)) >> APREC; dst[y] = (unsigned char)(z >> ZPREC); } dst[0] = 0; // force zero border dst++; } } static void fons__blur(FONScontext* stash, unsigned char* dst, int w, int h, int dstStride, int blur) { int alpha; float sigma; (void)stash; if (blur < 1) return; // Calculate the alpha such that 90% of the kernel is within the radius. (Kernel extends to infinity) sigma = (float)blur * 0.57735f; // 1 / sqrt(3) alpha = (int)((1< 20) iblur = 20; pad = iblur+2; // Reset allocator. stash->nscratch = 0; // Find code point and size. h = fons__hashint(codepoint) & (FONS_HASH_LUT_SIZE-1); i = font->lut[h]; while (i != -1) { if (font->glyphs[i].codepoint == codepoint && font->glyphs[i].size == isize && font->glyphs[i].blur == iblur) return &font->glyphs[i]; i = font->glyphs[i].next; } // Could not find glyph, create it. scale = fons__tt_getPixelHeightScale(&font->font, size); g = fons__tt_getGlyphIndex(&font->font, codepoint); // Try to find the glyph in fallback fonts. if (g == 0) { for (i = 0; i < font->nfallbacks; ++i) { FONSglyph* fallbackGlyph = fons__getGlyph(stash, stash->fonts[font->fallbacks[i]], codepoint, isize, iblur); if (fallbackGlyph != NULL && fallbackGlyph->index != 0) { return fallbackGlyph; } } } fons__tt_buildGlyphBitmap(&font->font, g, size, scale, &advance, &lsb, &x0, &y0, &x1, &y1); gw = x1-x0 + pad*2; gh = y1-y0 + pad*2; // Find free spot for the rect in the atlas added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy); if (added == 0 && stash->handleError != NULL) { // Atlas is full, let the user to resize the atlas (or not), and try again. stash->handleError(stash->errorUptr, FONS_ATLAS_FULL, 0); added = fons__atlasAddRect(stash->atlas, gw, gh, &gx, &gy); } if (added == 0) return NULL; // Init glyph. glyph = fons__allocGlyph(font); glyph->codepoint = codepoint; glyph->size = isize; glyph->blur = iblur; glyph->index = g; glyph->x0 = (short)gx; glyph->y0 = (short)gy; glyph->x1 = (short)(glyph->x0+gw); glyph->y1 = (short)(glyph->y0+gh); glyph->xadv = (short)(scale * advance * 10.0f); glyph->xoff = (short)(x0 - pad); glyph->yoff = (short)(y0 - pad); glyph->next = 0; // Insert char to hash lookup. glyph->next = font->lut[h]; font->lut[h] = font->nglyphs-1; // Rasterize dst = &stash->texData[(glyph->x0+pad) + (glyph->y0+pad) * stash->params.width]; fons__tt_renderGlyphBitmap(&font->font, dst, gw-pad*2,gh-pad*2, stash->params.width, scale,scale, g); // Make sure there is one pixel empty border. dst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width]; for (y = 0; y < gh; y++) { dst[y*stash->params.width] = 0; dst[gw-1 + y*stash->params.width] = 0; } for (x = 0; x < gw; x++) { dst[x] = 0; dst[x + (gh-1)*stash->params.width] = 0; } // Debug code to color the glyph background /* unsigned char* fdst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width]; for (y = 0; y < gh; y++) { for (x = 0; x < gw; x++) { int a = (int)fdst[x+y*stash->params.width] + 20; if (a > 255) a = 255; fdst[x+y*stash->params.width] = a; } }*/ // Blur if (iblur > 0) { stash->nscratch = 0; bdst = &stash->texData[glyph->x0 + glyph->y0 * stash->params.width]; fons__blur(stash, bdst, gw,gh, stash->params.width, iblur); } stash->dirtyRect[0] = fons__mini(stash->dirtyRect[0], glyph->x0); stash->dirtyRect[1] = fons__mini(stash->dirtyRect[1], glyph->y0); stash->dirtyRect[2] = fons__maxi(stash->dirtyRect[2], glyph->x1); stash->dirtyRect[3] = fons__maxi(stash->dirtyRect[3], glyph->y1); return glyph; } static void fons__getQuad(FONScontext* stash, FONSfont* font, int prevGlyphIndex, FONSglyph* glyph, float scale, float spacing, float* x, float* y, FONSquad* q) { float rx,ry,xoff,yoff,x0,y0,x1,y1; if (prevGlyphIndex != -1) { float adv = fons__tt_getGlyphKernAdvance(&font->font, prevGlyphIndex, glyph->index) * scale; *x += (int)(adv + spacing + 0.5f); } // Each glyph has 2px border to allow good interpolation, // one pixel to prevent leaking, and one to allow good interpolation for rendering. // Inset the texture region by one pixel for correct interpolation. xoff = (short)(glyph->xoff+1); yoff = (short)(glyph->yoff+1); x0 = (float)(glyph->x0+1); y0 = (float)(glyph->y0+1); x1 = (float)(glyph->x1-1); y1 = (float)(glyph->y1-1); if (stash->params.flags & FONS_ZERO_TOPLEFT) { rx = (float)(int)(*x + xoff); ry = (float)(int)(*y + yoff); q->x0 = rx; q->y0 = ry; q->x1 = rx + x1 - x0; q->y1 = ry + y1 - y0; q->s0 = x0 * stash->itw; q->t0 = y0 * stash->ith; q->s1 = x1 * stash->itw; q->t1 = y1 * stash->ith; } else { rx = (float)(int)(*x + xoff); ry = (float)(int)(*y - yoff); q->x0 = rx; q->y0 = ry; q->x1 = rx + x1 - x0; q->y1 = ry - y1 + y0; q->s0 = x0 * stash->itw; q->t0 = y0 * stash->ith; q->s1 = x1 * stash->itw; q->t1 = y1 * stash->ith; } *x += (int)(glyph->xadv / 10.0f + 0.5f); } static void fons__flush(FONScontext* stash) { // Flush texture if (stash->dirtyRect[0] < stash->dirtyRect[2] && stash->dirtyRect[1] < stash->dirtyRect[3]) { if (stash->params.renderUpdate != NULL) stash->params.renderUpdate(stash->params.userPtr, stash->dirtyRect, stash->texData); // Reset dirty rect stash->dirtyRect[0] = stash->params.width; stash->dirtyRect[1] = stash->params.height; stash->dirtyRect[2] = 0; stash->dirtyRect[3] = 0; } // Flush triangles if (stash->nverts > 0) { if (stash->params.renderDraw != NULL) stash->params.renderDraw(stash->params.userPtr, stash->verts, stash->tcoords, stash->colors, stash->nverts); stash->nverts = 0; } } static __inline void fons__vertex(FONScontext* stash, float x, float y, float s, float t, unsigned int c) { stash->verts[stash->nverts*2+0] = x; stash->verts[stash->nverts*2+1] = y; stash->tcoords[stash->nverts*2+0] = s; stash->tcoords[stash->nverts*2+1] = t; stash->colors[stash->nverts] = c; stash->nverts++; } static float fons__getVertAlign(FONScontext* stash, FONSfont* font, int align, short isize) { if (stash->params.flags & FONS_ZERO_TOPLEFT) { if (align & FONS_ALIGN_TOP) { return font->ascender * (float)isize/10.0f; } else if (align & FONS_ALIGN_MIDDLE) { return (font->ascender + font->descender) / 2.0f * (float)isize/10.0f; } else if (align & FONS_ALIGN_BASELINE) { return 0.0f; } else if (align & FONS_ALIGN_BOTTOM) { return font->descender * (float)isize/10.0f; } } else { if (align & FONS_ALIGN_TOP) { return -font->ascender * (float)isize/10.0f; } else if (align & FONS_ALIGN_MIDDLE) { return -(font->ascender + font->descender) / 2.0f * (float)isize/10.0f; } else if (align & FONS_ALIGN_BASELINE) { return 0.0f; } else if (align & FONS_ALIGN_BOTTOM) { return -font->descender * (float)isize/10.0f; } } return 0.0; } float fonsDrawText(FONScontext* stash, float x, float y, const char* str, const char* end) { FONSstate* state = fons__getState(stash); unsigned int codepoint; unsigned int utf8state = 0; FONSglyph* glyph = NULL; FONSquad q; int prevGlyphIndex = -1; short isize = (short)(state->size*10.0f); short iblur = (short)state->blur; float scale; FONSfont* font; float width; if (stash == NULL) return x; if (state->font < 0 || state->font >= stash->nfonts) return x; font = stash->fonts[state->font]; if (font->data == NULL) return x; scale = fons__tt_getPixelHeightScale(&font->font, (float)isize/10.0f); if (end == NULL) end = str + strlen(str); // Align horizontally if (state->align & FONS_ALIGN_LEFT) { // empty } else if (state->align & FONS_ALIGN_RIGHT) { width = fonsTextBounds(stash, x,y, str, end, NULL); x -= width; } else if (state->align & FONS_ALIGN_CENTER) { width = fonsTextBounds(stash, x,y, str, end, NULL); x -= width * 0.5f; } // Align vertically. y += fons__getVertAlign(stash, font, state->align, isize); for (; str != end; ++str) { if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str)) continue; glyph = fons__getGlyph(stash, font, codepoint, isize, iblur); if (glyph != NULL) { fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q); if (stash->nverts+6 > FONS_VERTEX_COUNT) fons__flush(stash); fons__vertex(stash, q.x0, q.y0, q.s0, q.t0, state->color); fons__vertex(stash, q.x1, q.y1, q.s1, q.t1, state->color); fons__vertex(stash, q.x1, q.y0, q.s1, q.t0, state->color); fons__vertex(stash, q.x0, q.y0, q.s0, q.t0, state->color); fons__vertex(stash, q.x0, q.y1, q.s0, q.t1, state->color); fons__vertex(stash, q.x1, q.y1, q.s1, q.t1, state->color); } prevGlyphIndex = glyph != NULL ? glyph->index : -1; } fons__flush(stash); return x; } int fonsTextIterInit(FONScontext* stash, FONStextIter* iter, float x, float y, const char* str, const char* end) { FONSstate* state = fons__getState(stash); float width; memset(iter, 0, sizeof(*iter)); if (stash == NULL) return 0; if (state->font < 0 || state->font >= stash->nfonts) return 0; iter->font = stash->fonts[state->font]; if (iter->font->data == NULL) return 0; iter->isize = (short)(state->size*10.0f); iter->iblur = (short)state->blur; iter->scale = fons__tt_getPixelHeightScale(&iter->font->font, (float)iter->isize/10.0f); // Align horizontally if (state->align & FONS_ALIGN_LEFT) { // empty } else if (state->align & FONS_ALIGN_RIGHT) { width = fonsTextBounds(stash, x,y, str, end, NULL); x -= width; } else if (state->align & FONS_ALIGN_CENTER) { width = fonsTextBounds(stash, x,y, str, end, NULL); x -= width * 0.5f; } // Align vertically. y += fons__getVertAlign(stash, iter->font, state->align, iter->isize); if (end == NULL) end = str + strlen(str); iter->x = iter->nextx = x; iter->y = iter->nexty = y; iter->spacing = state->spacing; iter->str = str; iter->next = str; iter->end = end; iter->codepoint = 0; iter->prevGlyphIndex = -1; return 1; } int fonsTextIterNext(FONScontext* stash, FONStextIter* iter, FONSquad* quad) { FONSglyph* glyph = NULL; const char* str = iter->next; iter->str = iter->next; if (str == iter->end) return 0; for (; str != iter->end; str++) { if (fons__decutf8(&iter->utf8state, &iter->codepoint, *(const unsigned char*)str)) continue; str++; // Get glyph and quad iter->x = iter->nextx; iter->y = iter->nexty; glyph = fons__getGlyph(stash, iter->font, iter->codepoint, iter->isize, iter->iblur); if (glyph != NULL) fons__getQuad(stash, iter->font, iter->prevGlyphIndex, glyph, iter->scale, iter->spacing, &iter->nextx, &iter->nexty, quad); iter->prevGlyphIndex = glyph != NULL ? glyph->index : -1; break; } iter->next = str; return 1; } void fonsDrawDebug(FONScontext* stash, float x, float y) { int i; int w = stash->params.width; int h = stash->params.height; float u = w == 0 ? 0 : (1.0f / w); float v = h == 0 ? 0 : (1.0f / h); if (stash->nverts+6+6 > FONS_VERTEX_COUNT) fons__flush(stash); // Draw background fons__vertex(stash, x+0, y+0, u, v, 0x0fffffff); fons__vertex(stash, x+w, y+h, u, v, 0x0fffffff); fons__vertex(stash, x+w, y+0, u, v, 0x0fffffff); fons__vertex(stash, x+0, y+0, u, v, 0x0fffffff); fons__vertex(stash, x+0, y+h, u, v, 0x0fffffff); fons__vertex(stash, x+w, y+h, u, v, 0x0fffffff); // Draw texture fons__vertex(stash, x+0, y+0, 0, 0, 0xffffffff); fons__vertex(stash, x+w, y+h, 1, 1, 0xffffffff); fons__vertex(stash, x+w, y+0, 1, 0, 0xffffffff); fons__vertex(stash, x+0, y+0, 0, 0, 0xffffffff); fons__vertex(stash, x+0, y+h, 0, 1, 0xffffffff); fons__vertex(stash, x+w, y+h, 1, 1, 0xffffffff); // Drawbug draw atlas for (i = 0; i < stash->atlas->nnodes; i++) { FONSatlasNode* n = &stash->atlas->nodes[i]; if (stash->nverts+6 > FONS_VERTEX_COUNT) fons__flush(stash); fons__vertex(stash, x+n->x+0, y+n->y+0, u, v, 0xc00000ff); fons__vertex(stash, x+n->x+n->width, y+n->y+1, u, v, 0xc00000ff); fons__vertex(stash, x+n->x+n->width, y+n->y+0, u, v, 0xc00000ff); fons__vertex(stash, x+n->x+0, y+n->y+0, u, v, 0xc00000ff); fons__vertex(stash, x+n->x+0, y+n->y+1, u, v, 0xc00000ff); fons__vertex(stash, x+n->x+n->width, y+n->y+1, u, v, 0xc00000ff); } fons__flush(stash); } float fonsTextBounds(FONScontext* stash, float x, float y, const char* str, const char* end, float* bounds) { FONSstate* state = fons__getState(stash); unsigned int codepoint; unsigned int utf8state = 0; FONSquad q; FONSglyph* glyph = NULL; int prevGlyphIndex = -1; short isize = (short)(state->size*10.0f); short iblur = (short)state->blur; float scale; FONSfont* font; float startx, advance; float minx, miny, maxx, maxy; if (stash == NULL) return 0; if (state->font < 0 || state->font >= stash->nfonts) return 0; font = stash->fonts[state->font]; if (font->data == NULL) return 0; scale = fons__tt_getPixelHeightScale(&font->font, (float)isize/10.0f); // Align vertically. y += fons__getVertAlign(stash, font, state->align, isize); minx = maxx = x; miny = maxy = y; startx = x; if (end == NULL) end = str + strlen(str); for (; str != end; ++str) { if (fons__decutf8(&utf8state, &codepoint, *(const unsigned char*)str)) continue; glyph = fons__getGlyph(stash, font, codepoint, isize, iblur); if (glyph != NULL) { fons__getQuad(stash, font, prevGlyphIndex, glyph, scale, state->spacing, &x, &y, &q); if (q.x0 < minx) minx = q.x0; if (q.x1 > maxx) maxx = q.x1; if (stash->params.flags & FONS_ZERO_TOPLEFT) { if (q.y0 < miny) miny = q.y0; if (q.y1 > maxy) maxy = q.y1; } else { if (q.y1 < miny) miny = q.y1; if (q.y0 > maxy) maxy = q.y0; } } prevGlyphIndex = glyph != NULL ? glyph->index : -1; } advance = x - startx; // Align horizontally if (state->align & FONS_ALIGN_LEFT) { // empty } else if (state->align & FONS_ALIGN_RIGHT) { minx -= advance; maxx -= advance; } else if (state->align & FONS_ALIGN_CENTER) { minx -= advance * 0.5f; maxx -= advance * 0.5f; } if (bounds) { bounds[0] = minx; bounds[1] = miny; bounds[2] = maxx; bounds[3] = maxy; } return advance; } void fonsVertMetrics(FONScontext* stash, float* ascender, float* descender, float* lineh) { FONSfont* font; FONSstate* state = fons__getState(stash); short isize; if (stash == NULL) return; if (state->font < 0 || state->font >= stash->nfonts) return; font = stash->fonts[state->font]; isize = (short)(state->size*10.0f); if (font->data == NULL) return; if (ascender) *ascender = font->ascender*isize/10.0f; if (descender) *descender = font->descender*isize/10.0f; if (lineh) *lineh = font->lineh*isize/10.0f; } void fonsLineBounds(FONScontext* stash, float y, float* miny, float* maxy) { FONSfont* font; FONSstate* state = fons__getState(stash); short isize; if (stash == NULL) return; if (state->font < 0 || state->font >= stash->nfonts) return; font = stash->fonts[state->font]; isize = (short)(state->size*10.0f); if (font->data == NULL) return; y += fons__getVertAlign(stash, font, state->align, isize); if (stash->params.flags & FONS_ZERO_TOPLEFT) { *miny = y - font->ascender * (float)isize/10.0f; *maxy = *miny + font->lineh*isize/10.0f; } else { *maxy = y + font->descender * (float)isize/10.0f; *miny = *maxy - font->lineh*isize/10.0f; } } const unsigned char* fonsGetTextureData(FONScontext* stash, int* width, int* height) { if (width != NULL) *width = stash->params.width; if (height != NULL) *height = stash->params.height; return stash->texData; } int fonsValidateTexture(FONScontext* stash, int* dirty) { if (stash->dirtyRect[0] < stash->dirtyRect[2] && stash->dirtyRect[1] < stash->dirtyRect[3]) { dirty[0] = stash->dirtyRect[0]; dirty[1] = stash->dirtyRect[1]; dirty[2] = stash->dirtyRect[2]; dirty[3] = stash->dirtyRect[3]; // Reset dirty rect stash->dirtyRect[0] = stash->params.width; stash->dirtyRect[1] = stash->params.height; stash->dirtyRect[2] = 0; stash->dirtyRect[3] = 0; return 1; } return 0; } void fonsDeleteInternal(FONScontext* stash) { int i; if (stash == NULL) return; if (stash->params.renderDelete) stash->params.renderDelete(stash->params.userPtr); for (i = 0; i < stash->nfonts; ++i) fons__freeFont(stash->fonts[i]); if (stash->atlas) fons__deleteAtlas(stash->atlas); if (stash->fonts) free(stash->fonts); if (stash->texData) free(stash->texData); if (stash->scratch) free(stash->scratch); free(stash); } void fonsSetErrorCallback(FONScontext* stash, void (*callback)(void* uptr, int error, int val), void* uptr) { if (stash == NULL) return; stash->handleError = callback; stash->errorUptr = uptr; } void fonsGetAtlasSize(FONScontext* stash, int* width, int* height) { if (stash == NULL) return; *width = stash->params.width; *height = stash->params.height; } int fonsExpandAtlas(FONScontext* stash, int width, int height) { int i, maxy = 0; unsigned char* data = NULL; if (stash == NULL) return 0; width = fons__maxi(width, stash->params.width); height = fons__maxi(height, stash->params.height); if (width == stash->params.width && height == stash->params.height) return 1; // Flush pending glyphs. fons__flush(stash); // Create new texture if (stash->params.renderResize != NULL) { if (stash->params.renderResize(stash->params.userPtr, width, height) == 0) return 0; } // Copy old texture data over. data = (unsigned char*)malloc(width * height); if (data == NULL) return 0; for (i = 0; i < stash->params.height; i++) { unsigned char* dst = &data[i*width]; unsigned char* src = &stash->texData[i*stash->params.width]; memcpy(dst, src, stash->params.width); if (width > stash->params.width) memset(dst+stash->params.width, 0, width - stash->params.width); } if (height > stash->params.height) memset(&data[stash->params.height * width], 0, (height - stash->params.height) * width); free(stash->texData); stash->texData = data; // Increase atlas size fons__atlasExpand(stash->atlas, width, height); // Add existing data as dirty. for (i = 0; i < stash->atlas->nnodes; i++) maxy = fons__maxi(maxy, stash->atlas->nodes[i].y); stash->dirtyRect[0] = 0; stash->dirtyRect[1] = 0; stash->dirtyRect[2] = stash->params.width; stash->dirtyRect[3] = maxy; stash->params.width = width; stash->params.height = height; stash->itw = 1.0f/stash->params.width; stash->ith = 1.0f/stash->params.height; return 1; } int fonsResetAtlas(FONScontext* stash, int width, int height) { int i, j; if (stash == NULL) return 0; // Flush pending glyphs. fons__flush(stash); // Create new texture if (stash->params.renderResize != NULL) { if (stash->params.renderResize(stash->params.userPtr, width, height) == 0) return 0; } // Reset atlas fons__atlasReset(stash->atlas, width, height); // Clear texture data. stash->texData = (unsigned char*)realloc(stash->texData, width * height); if (stash->texData == NULL) return 0; memset(stash->texData, 0, width * height); // Reset dirty rect stash->dirtyRect[0] = width; stash->dirtyRect[1] = height; stash->dirtyRect[2] = 0; stash->dirtyRect[3] = 0; // Reset cached glyphs for (i = 0; i < stash->nfonts; i++) { FONSfont* font = stash->fonts[i]; font->nglyphs = 0; for (j = 0; j < FONS_HASH_LUT_SIZE; j++) font->lut[j] = -1; } stash->params.width = width; stash->params.height = height; stash->itw = 1.0f/stash->params.width; stash->ith = 1.0f/stash->params.height; // Add white rect at 0,0 for debug drawing. fons__addWhiteRect(stash, 2,2); return 1; } #endif ================================================ FILE: phonelibs/nanovg/nanovg.c ================================================ // // Copyright (c) 2013 Mikko Mononen memon@inside.org // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // #include #include #include #include #include "nanovg.h" #define FONTSTASH_IMPLEMENTATION #include "fontstash.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #ifdef _MSC_VER #pragma warning(disable: 4100) // unreferenced formal parameter #pragma warning(disable: 4127) // conditional expression is constant #pragma warning(disable: 4204) // nonstandard extension used : non-constant aggregate initializer #pragma warning(disable: 4706) // assignment within conditional expression #endif #define NVG_INIT_FONTIMAGE_SIZE 512 #define NVG_MAX_FONTIMAGE_SIZE 2048 #define NVG_MAX_FONTIMAGES 4 #define NVG_INIT_COMMANDS_SIZE 256 #define NVG_INIT_POINTS_SIZE 128 #define NVG_INIT_PATHS_SIZE 16 #define NVG_INIT_VERTS_SIZE 256 #define NVG_MAX_STATES 32 #define NVG_KAPPA90 0.5522847493f // Length proportional to radius of a cubic bezier handle for 90deg arcs. #define NVG_COUNTOF(arr) (sizeof(arr) / sizeof(0[arr])) enum NVGcommands { NVG_MOVETO = 0, NVG_LINETO = 1, NVG_BEZIERTO = 2, NVG_CLOSE = 3, NVG_WINDING = 4, }; enum NVGpointFlags { NVG_PT_CORNER = 0x01, NVG_PT_LEFT = 0x02, NVG_PT_BEVEL = 0x04, NVG_PR_INNERBEVEL = 0x08, }; struct NVGstate { NVGcompositeOperationState compositeOperation; NVGpaint fill; NVGpaint stroke; float strokeWidth; float miterLimit; int lineJoin; int lineCap; float alpha; float xform[6]; NVGscissor scissor; float fontSize; float letterSpacing; float lineHeight; float fontBlur; int textAlign; int fontId; }; typedef struct NVGstate NVGstate; struct NVGpoint { float x,y; float dx, dy; float len; float dmx, dmy; unsigned char flags; }; typedef struct NVGpoint NVGpoint; struct NVGpathCache { NVGpoint* points; int npoints; int cpoints; NVGpath* paths; int npaths; int cpaths; NVGvertex* verts; int nverts; int cverts; float bounds[4]; }; typedef struct NVGpathCache NVGpathCache; struct NVGcontext { NVGparams params; float* commands; int ccommands; int ncommands; float commandx, commandy; NVGstate states[NVG_MAX_STATES]; int nstates; NVGpathCache* cache; float tessTol; float distTol; float fringeWidth; float devicePxRatio; struct FONScontext* fs; int fontImages[NVG_MAX_FONTIMAGES]; int fontImageIdx; int drawCallCount; int fillTriCount; int strokeTriCount; int textTriCount; }; static float nvg__sqrtf(float a) { return sqrtf(a); } static float nvg__modf(float a, float b) { return fmodf(a, b); } static float nvg__sinf(float a) { return sinf(a); } static float nvg__cosf(float a) { return cosf(a); } static float nvg__tanf(float a) { return tanf(a); } static float nvg__atan2f(float a,float b) { return atan2f(a, b); } static float nvg__acosf(float a) { return acosf(a); } static int nvg__mini(int a, int b) { return a < b ? a : b; } static int nvg__maxi(int a, int b) { return a > b ? a : b; } static int nvg__clampi(int a, int mn, int mx) { return a < mn ? mn : (a > mx ? mx : a); } static float nvg__minf(float a, float b) { return a < b ? a : b; } static float nvg__maxf(float a, float b) { return a > b ? a : b; } static float nvg__absf(float a) { return a >= 0.0f ? a : -a; } static float nvg__signf(float a) { return a >= 0.0f ? 1.0f : -1.0f; } static float nvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); } static float nvg__cross(float dx0, float dy0, float dx1, float dy1) { return dx1*dy0 - dx0*dy1; } static float nvg__normalize(float *x, float* y) { float d = nvg__sqrtf((*x)*(*x) + (*y)*(*y)); if (d > 1e-6f) { float id = 1.0f / d; *x *= id; *y *= id; } return d; } static void nvg__deletePathCache(NVGpathCache* c) { if (c == NULL) return; if (c->points != NULL) free(c->points); if (c->paths != NULL) free(c->paths); if (c->verts != NULL) free(c->verts); free(c); } static NVGpathCache* nvg__allocPathCache(void) { NVGpathCache* c = (NVGpathCache*)malloc(sizeof(NVGpathCache)); if (c == NULL) goto error; memset(c, 0, sizeof(NVGpathCache)); c->points = (NVGpoint*)malloc(sizeof(NVGpoint)*NVG_INIT_POINTS_SIZE); if (!c->points) goto error; c->npoints = 0; c->cpoints = NVG_INIT_POINTS_SIZE; c->paths = (NVGpath*)malloc(sizeof(NVGpath)*NVG_INIT_PATHS_SIZE); if (!c->paths) goto error; c->npaths = 0; c->cpaths = NVG_INIT_PATHS_SIZE; c->verts = (NVGvertex*)malloc(sizeof(NVGvertex)*NVG_INIT_VERTS_SIZE); if (!c->verts) goto error; c->nverts = 0; c->cverts = NVG_INIT_VERTS_SIZE; return c; error: nvg__deletePathCache(c); return NULL; } static void nvg__setDevicePixelRatio(NVGcontext* ctx, float ratio) { ctx->tessTol = 0.25f / ratio; ctx->distTol = 0.01f / ratio; ctx->fringeWidth = 1.0f / ratio; ctx->devicePxRatio = ratio; } static NVGcompositeOperationState nvg__compositeOperationState(int op) { int sfactor, dfactor; if (op == NVG_SOURCE_OVER) { sfactor = NVG_ONE; dfactor = NVG_ONE_MINUS_SRC_ALPHA; } else if (op == NVG_SOURCE_IN) { sfactor = NVG_DST_ALPHA; dfactor = NVG_ZERO; } else if (op == NVG_SOURCE_OUT) { sfactor = NVG_ONE_MINUS_DST_ALPHA; dfactor = NVG_ZERO; } else if (op == NVG_ATOP) { sfactor = NVG_DST_ALPHA; dfactor = NVG_ONE_MINUS_SRC_ALPHA; } else if (op == NVG_DESTINATION_OVER) { sfactor = NVG_ONE_MINUS_DST_ALPHA; dfactor = NVG_ONE; } else if (op == NVG_DESTINATION_IN) { sfactor = NVG_ZERO; dfactor = NVG_SRC_ALPHA; } else if (op == NVG_DESTINATION_OUT) { sfactor = NVG_ZERO; dfactor = NVG_ONE_MINUS_SRC_ALPHA; } else if (op == NVG_DESTINATION_ATOP) { sfactor = NVG_ONE_MINUS_DST_ALPHA; dfactor = NVG_SRC_ALPHA; } else if (op == NVG_LIGHTER) { sfactor = NVG_ONE; dfactor = NVG_ONE; } else if (op == NVG_COPY) { sfactor = NVG_ONE; dfactor = NVG_ZERO; } else if (op == NVG_XOR) { sfactor = NVG_ONE_MINUS_DST_ALPHA; dfactor = NVG_ONE_MINUS_SRC_ALPHA; } NVGcompositeOperationState state; state.srcRGB = sfactor; state.dstRGB = dfactor; state.srcAlpha = sfactor; state.dstAlpha = dfactor; return state; } static NVGstate* nvg__getState(NVGcontext* ctx) { return &ctx->states[ctx->nstates-1]; } NVGcontext* nvgCreateInternal(NVGparams* params) { FONSparams fontParams; NVGcontext* ctx = (NVGcontext*)malloc(sizeof(NVGcontext)); int i; if (ctx == NULL) goto error; memset(ctx, 0, sizeof(NVGcontext)); ctx->params = *params; for (i = 0; i < NVG_MAX_FONTIMAGES; i++) ctx->fontImages[i] = 0; ctx->commands = (float*)malloc(sizeof(float)*NVG_INIT_COMMANDS_SIZE); if (!ctx->commands) goto error; ctx->ncommands = 0; ctx->ccommands = NVG_INIT_COMMANDS_SIZE; ctx->cache = nvg__allocPathCache(); if (ctx->cache == NULL) goto error; nvgSave(ctx); nvgReset(ctx); nvg__setDevicePixelRatio(ctx, 1.0f); if (ctx->params.renderCreate(ctx->params.userPtr) == 0) goto error; // Init font rendering memset(&fontParams, 0, sizeof(fontParams)); fontParams.width = NVG_INIT_FONTIMAGE_SIZE; fontParams.height = NVG_INIT_FONTIMAGE_SIZE; fontParams.flags = FONS_ZERO_TOPLEFT; fontParams.renderCreate = NULL; fontParams.renderUpdate = NULL; fontParams.renderDraw = NULL; fontParams.renderDelete = NULL; fontParams.userPtr = NULL; ctx->fs = fonsCreateInternal(&fontParams); if (ctx->fs == NULL) goto error; // Create font texture ctx->fontImages[0] = ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_ALPHA, fontParams.width, fontParams.height, 0, NULL); if (ctx->fontImages[0] == 0) goto error; ctx->fontImageIdx = 0; return ctx; error: nvgDeleteInternal(ctx); return 0; } NVGparams* nvgInternalParams(NVGcontext* ctx) { return &ctx->params; } void nvgDeleteInternal(NVGcontext* ctx) { int i; if (ctx == NULL) return; if (ctx->commands != NULL) free(ctx->commands); if (ctx->cache != NULL) nvg__deletePathCache(ctx->cache); if (ctx->fs) fonsDeleteInternal(ctx->fs); for (i = 0; i < NVG_MAX_FONTIMAGES; i++) { if (ctx->fontImages[i] != 0) { nvgDeleteImage(ctx, ctx->fontImages[i]); ctx->fontImages[i] = 0; } } if (ctx->params.renderDelete != NULL) ctx->params.renderDelete(ctx->params.userPtr); free(ctx); } void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio) { /* printf("Tris: draws:%d fill:%d stroke:%d text:%d TOT:%d\n", ctx->drawCallCount, ctx->fillTriCount, ctx->strokeTriCount, ctx->textTriCount, ctx->fillTriCount+ctx->strokeTriCount+ctx->textTriCount);*/ ctx->nstates = 0; nvgSave(ctx); nvgReset(ctx); nvg__setDevicePixelRatio(ctx, devicePixelRatio); ctx->params.renderViewport(ctx->params.userPtr, windowWidth, windowHeight, devicePixelRatio); ctx->drawCallCount = 0; ctx->fillTriCount = 0; ctx->strokeTriCount = 0; ctx->textTriCount = 0; } void nvgCancelFrame(NVGcontext* ctx) { ctx->params.renderCancel(ctx->params.userPtr); } void nvgEndFrame(NVGcontext* ctx) { NVGstate* state = nvg__getState(ctx); ctx->params.renderFlush(ctx->params.userPtr, state->compositeOperation); if (ctx->fontImageIdx != 0) { int fontImage = ctx->fontImages[ctx->fontImageIdx]; int i, j, iw, ih; // delete images that smaller than current one if (fontImage == 0) return; nvgImageSize(ctx, fontImage, &iw, &ih); for (i = j = 0; i < ctx->fontImageIdx; i++) { if (ctx->fontImages[i] != 0) { int nw, nh; nvgImageSize(ctx, ctx->fontImages[i], &nw, &nh); if (nw < iw || nh < ih) nvgDeleteImage(ctx, ctx->fontImages[i]); else ctx->fontImages[j++] = ctx->fontImages[i]; } } // make current font image to first ctx->fontImages[j++] = ctx->fontImages[0]; ctx->fontImages[0] = fontImage; ctx->fontImageIdx = 0; // clear all images after j for (i = j; i < NVG_MAX_FONTIMAGES; i++) ctx->fontImages[i] = 0; } } NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b) { return nvgRGBA(r,g,b,255); } NVGcolor nvgRGBf(float r, float g, float b) { return nvgRGBAf(r,g,b,1.0f); } NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { NVGcolor color; // Use longer initialization to suppress warning. color.r = r / 255.0f; color.g = g / 255.0f; color.b = b / 255.0f; color.a = a / 255.0f; return color; } NVGcolor nvgRGBAf(float r, float g, float b, float a) { NVGcolor color; // Use longer initialization to suppress warning. color.r = r; color.g = g; color.b = b; color.a = a; return color; } NVGcolor nvgTransRGBA(NVGcolor c, unsigned char a) { c.a = a / 255.0f; return c; } NVGcolor nvgTransRGBAf(NVGcolor c, float a) { c.a = a; return c; } NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u) { int i; float oneminu; NVGcolor cint = {0}; u = nvg__clampf(u, 0.0f, 1.0f); oneminu = 1.0f - u; for( i = 0; i <4; i++ ) { cint.rgba[i] = c0.rgba[i] * oneminu + c1.rgba[i] * u; } return cint; } NVGcolor nvgHSL(float h, float s, float l) { return nvgHSLA(h,s,l,255); } static float nvg__hue(float h, float m1, float m2) { if (h < 0) h += 1; if (h > 1) h -= 1; if (h < 1.0f/6.0f) return m1 + (m2 - m1) * h * 6.0f; else if (h < 3.0f/6.0f) return m2; else if (h < 4.0f/6.0f) return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f; return m1; } NVGcolor nvgHSLA(float h, float s, float l, unsigned char a) { float m1, m2; NVGcolor col; h = nvg__modf(h, 1.0f); if (h < 0.0f) h += 1.0f; s = nvg__clampf(s, 0.0f, 1.0f); l = nvg__clampf(l, 0.0f, 1.0f); m2 = l <= 0.5f ? (l * (1 + s)) : (l + s - l * s); m1 = 2 * l - m2; col.r = nvg__clampf(nvg__hue(h + 1.0f/3.0f, m1, m2), 0.0f, 1.0f); col.g = nvg__clampf(nvg__hue(h, m1, m2), 0.0f, 1.0f); col.b = nvg__clampf(nvg__hue(h - 1.0f/3.0f, m1, m2), 0.0f, 1.0f); col.a = a/255.0f; return col; } void nvgTransformIdentity(float* t) { t[0] = 1.0f; t[1] = 0.0f; t[2] = 0.0f; t[3] = 1.0f; t[4] = 0.0f; t[5] = 0.0f; } void nvgTransformTranslate(float* t, float tx, float ty) { t[0] = 1.0f; t[1] = 0.0f; t[2] = 0.0f; t[3] = 1.0f; t[4] = tx; t[5] = ty; } void nvgTransformScale(float* t, float sx, float sy) { t[0] = sx; t[1] = 0.0f; t[2] = 0.0f; t[3] = sy; t[4] = 0.0f; t[5] = 0.0f; } void nvgTransformRotate(float* t, float a) { float cs = nvg__cosf(a), sn = nvg__sinf(a); t[0] = cs; t[1] = sn; t[2] = -sn; t[3] = cs; t[4] = 0.0f; t[5] = 0.0f; } void nvgTransformSkewX(float* t, float a) { t[0] = 1.0f; t[1] = 0.0f; t[2] = nvg__tanf(a); t[3] = 1.0f; t[4] = 0.0f; t[5] = 0.0f; } void nvgTransformSkewY(float* t, float a) { t[0] = 1.0f; t[1] = nvg__tanf(a); t[2] = 0.0f; t[3] = 1.0f; t[4] = 0.0f; t[5] = 0.0f; } void nvgTransformMultiply(float* t, const float* s) { float t0 = t[0] * s[0] + t[1] * s[2]; float t2 = t[2] * s[0] + t[3] * s[2]; float t4 = t[4] * s[0] + t[5] * s[2] + s[4]; t[1] = t[0] * s[1] + t[1] * s[3]; t[3] = t[2] * s[1] + t[3] * s[3]; t[5] = t[4] * s[1] + t[5] * s[3] + s[5]; t[0] = t0; t[2] = t2; t[4] = t4; } void nvgTransformPremultiply(float* t, const float* s) { float s2[6]; memcpy(s2, s, sizeof(float)*6); nvgTransformMultiply(s2, t); memcpy(t, s2, sizeof(float)*6); } int nvgTransformInverse(float* inv, const float* t) { double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1]; if (det > -1e-6 && det < 1e-6) { nvgTransformIdentity(inv); return 0; } invdet = 1.0 / det; inv[0] = (float)(t[3] * invdet); inv[2] = (float)(-t[2] * invdet); inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet); inv[1] = (float)(-t[1] * invdet); inv[3] = (float)(t[0] * invdet); inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet); return 1; } void nvgTransformPoint(float* dx, float* dy, const float* t, float sx, float sy) { *dx = sx*t[0] + sy*t[2] + t[4]; *dy = sx*t[1] + sy*t[3] + t[5]; } float nvgDegToRad(float deg) { return deg / 180.0f * NVG_PI; } float nvgRadToDeg(float rad) { return rad / NVG_PI * 180.0f; } static void nvg__setPaintColor(NVGpaint* p, NVGcolor color) { memset(p, 0, sizeof(*p)); nvgTransformIdentity(p->xform); p->radius = 0.0f; p->feather = 1.0f; p->innerColor = color; p->outerColor = color; } // State handling void nvgSave(NVGcontext* ctx) { if (ctx->nstates >= NVG_MAX_STATES) return; if (ctx->nstates > 0) memcpy(&ctx->states[ctx->nstates], &ctx->states[ctx->nstates-1], sizeof(NVGstate)); ctx->nstates++; } void nvgRestore(NVGcontext* ctx) { if (ctx->nstates <= 1) return; ctx->nstates--; } void nvgReset(NVGcontext* ctx) { NVGstate* state = nvg__getState(ctx); memset(state, 0, sizeof(*state)); nvg__setPaintColor(&state->fill, nvgRGBA(255,255,255,255)); nvg__setPaintColor(&state->stroke, nvgRGBA(0,0,0,255)); state->compositeOperation = nvg__compositeOperationState(NVG_SOURCE_OVER); state->strokeWidth = 1.0f; state->miterLimit = 10.0f; state->lineCap = NVG_BUTT; state->lineJoin = NVG_MITER; state->alpha = 1.0f; nvgTransformIdentity(state->xform); state->scissor.extent[0] = -1.0f; state->scissor.extent[1] = -1.0f; state->fontSize = 16.0f; state->letterSpacing = 0.0f; state->lineHeight = 1.0f; state->fontBlur = 0.0f; state->textAlign = NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE; state->fontId = 0; } // State setting void nvgStrokeWidth(NVGcontext* ctx, float width) { NVGstate* state = nvg__getState(ctx); state->strokeWidth = width; } void nvgMiterLimit(NVGcontext* ctx, float limit) { NVGstate* state = nvg__getState(ctx); state->miterLimit = limit; } void nvgLineCap(NVGcontext* ctx, int cap) { NVGstate* state = nvg__getState(ctx); state->lineCap = cap; } void nvgLineJoin(NVGcontext* ctx, int join) { NVGstate* state = nvg__getState(ctx); state->lineJoin = join; } void nvgGlobalAlpha(NVGcontext* ctx, float alpha) { NVGstate* state = nvg__getState(ctx); state->alpha = alpha; } void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f) { NVGstate* state = nvg__getState(ctx); float t[6] = { a, b, c, d, e, f }; nvgTransformPremultiply(state->xform, t); } void nvgResetTransform(NVGcontext* ctx) { NVGstate* state = nvg__getState(ctx); nvgTransformIdentity(state->xform); } void nvgTranslate(NVGcontext* ctx, float x, float y) { NVGstate* state = nvg__getState(ctx); float t[6]; nvgTransformTranslate(t, x,y); nvgTransformPremultiply(state->xform, t); } void nvgRotate(NVGcontext* ctx, float angle) { NVGstate* state = nvg__getState(ctx); float t[6]; nvgTransformRotate(t, angle); nvgTransformPremultiply(state->xform, t); } void nvgSkewX(NVGcontext* ctx, float angle) { NVGstate* state = nvg__getState(ctx); float t[6]; nvgTransformSkewX(t, angle); nvgTransformPremultiply(state->xform, t); } void nvgSkewY(NVGcontext* ctx, float angle) { NVGstate* state = nvg__getState(ctx); float t[6]; nvgTransformSkewY(t, angle); nvgTransformPremultiply(state->xform, t); } void nvgScale(NVGcontext* ctx, float x, float y) { NVGstate* state = nvg__getState(ctx); float t[6]; nvgTransformScale(t, x,y); nvgTransformPremultiply(state->xform, t); } void nvgCurrentTransform(NVGcontext* ctx, float* xform) { NVGstate* state = nvg__getState(ctx); if (xform == NULL) return; memcpy(xform, state->xform, sizeof(float)*6); } void nvgStrokeColor(NVGcontext* ctx, NVGcolor color) { NVGstate* state = nvg__getState(ctx); nvg__setPaintColor(&state->stroke, color); } void nvgStrokePaint(NVGcontext* ctx, NVGpaint paint) { NVGstate* state = nvg__getState(ctx); state->stroke = paint; nvgTransformMultiply(state->stroke.xform, state->xform); } void nvgFillColor(NVGcontext* ctx, NVGcolor color) { NVGstate* state = nvg__getState(ctx); nvg__setPaintColor(&state->fill, color); } void nvgFillPaint(NVGcontext* ctx, NVGpaint paint) { NVGstate* state = nvg__getState(ctx); state->fill = paint; nvgTransformMultiply(state->fill.xform, state->xform); } int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags) { int w, h, n, image; unsigned char* img; stbi_set_unpremultiply_on_load(1); stbi_convert_iphone_png_to_rgb(1); img = stbi_load(filename, &w, &h, &n, 4); if (img == NULL) { // printf("Failed to load %s - %s\n", filename, stbi_failure_reason()); return 0; } image = nvgCreateImageRGBA(ctx, w, h, imageFlags, img); stbi_image_free(img); return image; } int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata) { int w, h, n, image; unsigned char* img = stbi_load_from_memory(data, ndata, &w, &h, &n, 4); if (img == NULL) { // printf("Failed to load %s - %s\n", filename, stbi_failure_reason()); return 0; } image = nvgCreateImageRGBA(ctx, w, h, imageFlags, img); stbi_image_free(img); return image; } int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data) { return ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_RGBA, w, h, imageFlags, data); } void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data) { int w, h; ctx->params.renderGetTextureSize(ctx->params.userPtr, image, &w, &h); ctx->params.renderUpdateTexture(ctx->params.userPtr, image, 0,0, w,h, data); } void nvgImageSize(NVGcontext* ctx, int image, int* w, int* h) { ctx->params.renderGetTextureSize(ctx->params.userPtr, image, w, h); } void nvgDeleteImage(NVGcontext* ctx, int image) { ctx->params.renderDeleteTexture(ctx->params.userPtr, image); } NVGpaint nvgLinearGradient(NVGcontext* ctx, float sx, float sy, float ex, float ey, NVGcolor icol, NVGcolor ocol) { NVGpaint p; float dx, dy, d; const float large = 1e5; NVG_NOTUSED(ctx); memset(&p, 0, sizeof(p)); // Calculate transform aligned to the line dx = ex - sx; dy = ey - sy; d = sqrtf(dx*dx + dy*dy); if (d > 0.0001f) { dx /= d; dy /= d; } else { dx = 0; dy = 1; } p.xform[0] = dy; p.xform[1] = -dx; p.xform[2] = dx; p.xform[3] = dy; p.xform[4] = sx - dx*large; p.xform[5] = sy - dy*large; p.extent[0] = large; p.extent[1] = large + d*0.5f; p.radius = 0.0f; p.feather = nvg__maxf(1.0f, d); p.innerColor = icol; p.outerColor = ocol; return p; } NVGpaint nvgRadialGradient(NVGcontext* ctx, float cx, float cy, float inr, float outr, NVGcolor icol, NVGcolor ocol) { NVGpaint p; float r = (inr+outr)*0.5f; float f = (outr-inr); NVG_NOTUSED(ctx); memset(&p, 0, sizeof(p)); nvgTransformIdentity(p.xform); p.xform[4] = cx; p.xform[5] = cy; p.extent[0] = r; p.extent[1] = r; p.radius = r; p.feather = nvg__maxf(1.0f, f); p.innerColor = icol; p.outerColor = ocol; return p; } NVGpaint nvgBoxGradient(NVGcontext* ctx, float x, float y, float w, float h, float r, float f, NVGcolor icol, NVGcolor ocol) { NVGpaint p; NVG_NOTUSED(ctx); memset(&p, 0, sizeof(p)); nvgTransformIdentity(p.xform); p.xform[4] = x+w*0.5f; p.xform[5] = y+h*0.5f; p.extent[0] = w*0.5f; p.extent[1] = h*0.5f; p.radius = r; p.feather = nvg__maxf(1.0f, f); p.innerColor = icol; p.outerColor = ocol; return p; } NVGpaint nvgImagePattern(NVGcontext* ctx, float cx, float cy, float w, float h, float angle, int image, float alpha) { NVGpaint p; NVG_NOTUSED(ctx); memset(&p, 0, sizeof(p)); nvgTransformRotate(p.xform, angle); p.xform[4] = cx; p.xform[5] = cy; p.extent[0] = w; p.extent[1] = h; p.image = image; p.innerColor = p.outerColor = nvgRGBAf(1,1,1,alpha); return p; } // Scissoring void nvgScissor(NVGcontext* ctx, float x, float y, float w, float h) { NVGstate* state = nvg__getState(ctx); w = nvg__maxf(0.0f, w); h = nvg__maxf(0.0f, h); nvgTransformIdentity(state->scissor.xform); state->scissor.xform[4] = x+w*0.5f; state->scissor.xform[5] = y+h*0.5f; nvgTransformMultiply(state->scissor.xform, state->xform); state->scissor.extent[0] = w*0.5f; state->scissor.extent[1] = h*0.5f; } static void nvg__isectRects(float* dst, float ax, float ay, float aw, float ah, float bx, float by, float bw, float bh) { float minx = nvg__maxf(ax, bx); float miny = nvg__maxf(ay, by); float maxx = nvg__minf(ax+aw, bx+bw); float maxy = nvg__minf(ay+ah, by+bh); dst[0] = minx; dst[1] = miny; dst[2] = nvg__maxf(0.0f, maxx - minx); dst[3] = nvg__maxf(0.0f, maxy - miny); } void nvgIntersectScissor(NVGcontext* ctx, float x, float y, float w, float h) { NVGstate* state = nvg__getState(ctx); float pxform[6], invxorm[6]; float rect[4]; float ex, ey, tex, tey; // If no previous scissor has been set, set the scissor as current scissor. if (state->scissor.extent[0] < 0) { nvgScissor(ctx, x, y, w, h); return; } // Transform the current scissor rect into current transform space. // If there is difference in rotation, this will be approximation. memcpy(pxform, state->scissor.xform, sizeof(float)*6); ex = state->scissor.extent[0]; ey = state->scissor.extent[1]; nvgTransformInverse(invxorm, state->xform); nvgTransformMultiply(pxform, invxorm); tex = ex*nvg__absf(pxform[0]) + ey*nvg__absf(pxform[2]); tey = ex*nvg__absf(pxform[1]) + ey*nvg__absf(pxform[3]); // Intersect rects. nvg__isectRects(rect, pxform[4]-tex,pxform[5]-tey,tex*2,tey*2, x,y,w,h); nvgScissor(ctx, rect[0], rect[1], rect[2], rect[3]); } void nvgResetScissor(NVGcontext* ctx) { NVGstate* state = nvg__getState(ctx); memset(state->scissor.xform, 0, sizeof(state->scissor.xform)); state->scissor.extent[0] = -1.0f; state->scissor.extent[1] = -1.0f; } // Global composite operation. void nvgGlobalCompositeOperation(NVGcontext* ctx, int op) { NVGstate* state = nvg__getState(ctx); state->compositeOperation = nvg__compositeOperationState(op); } void nvgGlobalCompositeBlendFunc(NVGcontext* ctx, int sfactor, int dfactor) { nvgGlobalCompositeBlendFuncSeparate(ctx, sfactor, dfactor, sfactor, dfactor); } void nvgGlobalCompositeBlendFuncSeparate(NVGcontext* ctx, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) { NVGcompositeOperationState op; op.srcRGB = srcRGB; op.dstRGB = dstRGB; op.srcAlpha = srcAlpha; op.dstAlpha = dstAlpha; NVGstate* state = nvg__getState(ctx); state->compositeOperation = op; } static int nvg__ptEquals(float x1, float y1, float x2, float y2, float tol) { float dx = x2 - x1; float dy = y2 - y1; return dx*dx + dy*dy < tol*tol; } static float nvg__distPtSeg(float x, float y, float px, float py, float qx, float qy) { float pqx, pqy, dx, dy, d, t; pqx = qx-px; pqy = qy-py; dx = x-px; dy = y-py; d = pqx*pqx + pqy*pqy; t = pqx*dx + pqy*dy; if (d > 0) t /= d; if (t < 0) t = 0; else if (t > 1) t = 1; dx = px + t*pqx - x; dy = py + t*pqy - y; return dx*dx + dy*dy; } static void nvg__appendCommands(NVGcontext* ctx, float* vals, int nvals) { NVGstate* state = nvg__getState(ctx); int i; if (ctx->ncommands+nvals > ctx->ccommands) { float* commands; int ccommands = ctx->ncommands+nvals + ctx->ccommands/2; commands = (float*)realloc(ctx->commands, sizeof(float)*ccommands); if (commands == NULL) return; ctx->commands = commands; ctx->ccommands = ccommands; } if ((int)vals[0] != NVG_CLOSE && (int)vals[0] != NVG_WINDING) { ctx->commandx = vals[nvals-2]; ctx->commandy = vals[nvals-1]; } // transform commands i = 0; while (i < nvals) { int cmd = (int)vals[i]; switch (cmd) { case NVG_MOVETO: nvgTransformPoint(&vals[i+1],&vals[i+2], state->xform, vals[i+1],vals[i+2]); i += 3; break; case NVG_LINETO: nvgTransformPoint(&vals[i+1],&vals[i+2], state->xform, vals[i+1],vals[i+2]); i += 3; break; case NVG_BEZIERTO: nvgTransformPoint(&vals[i+1],&vals[i+2], state->xform, vals[i+1],vals[i+2]); nvgTransformPoint(&vals[i+3],&vals[i+4], state->xform, vals[i+3],vals[i+4]); nvgTransformPoint(&vals[i+5],&vals[i+6], state->xform, vals[i+5],vals[i+6]); i += 7; break; case NVG_CLOSE: i++; break; case NVG_WINDING: i += 2; break; default: i++; } } memcpy(&ctx->commands[ctx->ncommands], vals, nvals*sizeof(float)); ctx->ncommands += nvals; } static void nvg__clearPathCache(NVGcontext* ctx) { ctx->cache->npoints = 0; ctx->cache->npaths = 0; } static NVGpath* nvg__lastPath(NVGcontext* ctx) { if (ctx->cache->npaths > 0) return &ctx->cache->paths[ctx->cache->npaths-1]; return NULL; } static void nvg__addPath(NVGcontext* ctx) { NVGpath* path; if (ctx->cache->npaths+1 > ctx->cache->cpaths) { NVGpath* paths; int cpaths = ctx->cache->npaths+1 + ctx->cache->cpaths/2; paths = (NVGpath*)realloc(ctx->cache->paths, sizeof(NVGpath)*cpaths); if (paths == NULL) return; ctx->cache->paths = paths; ctx->cache->cpaths = cpaths; } path = &ctx->cache->paths[ctx->cache->npaths]; memset(path, 0, sizeof(*path)); path->first = ctx->cache->npoints; path->winding = NVG_CCW; ctx->cache->npaths++; } static NVGpoint* nvg__lastPoint(NVGcontext* ctx) { if (ctx->cache->npoints > 0) return &ctx->cache->points[ctx->cache->npoints-1]; return NULL; } static void nvg__addPoint(NVGcontext* ctx, float x, float y, int flags) { NVGpath* path = nvg__lastPath(ctx); NVGpoint* pt; if (path == NULL) return; if (path->count > 0 && ctx->cache->npoints > 0) { pt = nvg__lastPoint(ctx); if (nvg__ptEquals(pt->x,pt->y, x,y, ctx->distTol)) { pt->flags |= flags; return; } } if (ctx->cache->npoints+1 > ctx->cache->cpoints) { NVGpoint* points; int cpoints = ctx->cache->npoints+1 + ctx->cache->cpoints/2; points = (NVGpoint*)realloc(ctx->cache->points, sizeof(NVGpoint)*cpoints); if (points == NULL) return; ctx->cache->points = points; ctx->cache->cpoints = cpoints; } pt = &ctx->cache->points[ctx->cache->npoints]; memset(pt, 0, sizeof(*pt)); pt->x = x; pt->y = y; pt->flags = (unsigned char)flags; ctx->cache->npoints++; path->count++; } static void nvg__closePath(NVGcontext* ctx) { NVGpath* path = nvg__lastPath(ctx); if (path == NULL) return; path->closed = 1; } static void nvg__pathWinding(NVGcontext* ctx, int winding) { NVGpath* path = nvg__lastPath(ctx); if (path == NULL) return; path->winding = winding; } static float nvg__getAverageScale(float *t) { float sx = sqrtf(t[0]*t[0] + t[2]*t[2]); float sy = sqrtf(t[1]*t[1] + t[3]*t[3]); return (sx + sy) * 0.5f; } static NVGvertex* nvg__allocTempVerts(NVGcontext* ctx, int nverts) { if (nverts > ctx->cache->cverts) { NVGvertex* verts; int cverts = (nverts + 0xff) & ~0xff; // Round up to prevent allocations when things change just slightly. verts = (NVGvertex*)realloc(ctx->cache->verts, sizeof(NVGvertex)*cverts); if (verts == NULL) return NULL; ctx->cache->verts = verts; ctx->cache->cverts = cverts; } return ctx->cache->verts; } static float nvg__triarea2(float ax, float ay, float bx, float by, float cx, float cy) { float abx = bx - ax; float aby = by - ay; float acx = cx - ax; float acy = cy - ay; return acx*aby - abx*acy; } static float nvg__polyArea(NVGpoint* pts, int npts) { int i; float area = 0; for (i = 2; i < npts; i++) { NVGpoint* a = &pts[0]; NVGpoint* b = &pts[i-1]; NVGpoint* c = &pts[i]; area += nvg__triarea2(a->x,a->y, b->x,b->y, c->x,c->y); } return area * 0.5f; } static void nvg__polyReverse(NVGpoint* pts, int npts) { NVGpoint tmp; int i = 0, j = npts-1; while (i < j) { tmp = pts[i]; pts[i] = pts[j]; pts[j] = tmp; i++; j--; } } static void nvg__vset(NVGvertex* vtx, float x, float y, float u, float v) { vtx->x = x; vtx->y = y; vtx->u = u; vtx->v = v; } static void nvg__tesselateBezier(NVGcontext* ctx, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, int level, int type) { float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234; float dx,dy,d2,d3; if (level > 10) return; x12 = (x1+x2)*0.5f; y12 = (y1+y2)*0.5f; x23 = (x2+x3)*0.5f; y23 = (y2+y3)*0.5f; x34 = (x3+x4)*0.5f; y34 = (y3+y4)*0.5f; x123 = (x12+x23)*0.5f; y123 = (y12+y23)*0.5f; dx = x4 - x1; dy = y4 - y1; d2 = nvg__absf(((x2 - x4) * dy - (y2 - y4) * dx)); d3 = nvg__absf(((x3 - x4) * dy - (y3 - y4) * dx)); if ((d2 + d3)*(d2 + d3) < ctx->tessTol * (dx*dx + dy*dy)) { nvg__addPoint(ctx, x4, y4, type); return; } /* if (nvg__absf(x1+x3-x2-x2) + nvg__absf(y1+y3-y2-y2) + nvg__absf(x2+x4-x3-x3) + nvg__absf(y2+y4-y3-y3) < ctx->tessTol) { nvg__addPoint(ctx, x4, y4, type); return; }*/ x234 = (x23+x34)*0.5f; y234 = (y23+y34)*0.5f; x1234 = (x123+x234)*0.5f; y1234 = (y123+y234)*0.5f; nvg__tesselateBezier(ctx, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0); nvg__tesselateBezier(ctx, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type); } static void nvg__flattenPaths(NVGcontext* ctx) { NVGpathCache* cache = ctx->cache; // NVGstate* state = nvg__getState(ctx); NVGpoint* last; NVGpoint* p0; NVGpoint* p1; NVGpoint* pts; NVGpath* path; int i, j; float* cp1; float* cp2; float* p; float area; if (cache->npaths > 0) return; // Flatten i = 0; while (i < ctx->ncommands) { int cmd = (int)ctx->commands[i]; switch (cmd) { case NVG_MOVETO: nvg__addPath(ctx); p = &ctx->commands[i+1]; nvg__addPoint(ctx, p[0], p[1], NVG_PT_CORNER); i += 3; break; case NVG_LINETO: p = &ctx->commands[i+1]; nvg__addPoint(ctx, p[0], p[1], NVG_PT_CORNER); i += 3; break; case NVG_BEZIERTO: last = nvg__lastPoint(ctx); if (last != NULL) { cp1 = &ctx->commands[i+1]; cp2 = &ctx->commands[i+3]; p = &ctx->commands[i+5]; nvg__tesselateBezier(ctx, last->x,last->y, cp1[0],cp1[1], cp2[0],cp2[1], p[0],p[1], 0, NVG_PT_CORNER); } i += 7; break; case NVG_CLOSE: nvg__closePath(ctx); i++; break; case NVG_WINDING: nvg__pathWinding(ctx, (int)ctx->commands[i+1]); i += 2; break; default: i++; } } cache->bounds[0] = cache->bounds[1] = 1e6f; cache->bounds[2] = cache->bounds[3] = -1e6f; // Calculate the direction and length of line segments. for (j = 0; j < cache->npaths; j++) { path = &cache->paths[j]; pts = &cache->points[path->first]; // If the first and last points are the same, remove the last, mark as closed path. p0 = &pts[path->count-1]; p1 = &pts[0]; if (nvg__ptEquals(p0->x,p0->y, p1->x,p1->y, ctx->distTol)) { path->count--; p0 = &pts[path->count-1]; path->closed = 1; } // Enforce winding. if (path->count > 2) { area = nvg__polyArea(pts, path->count); if (path->winding == NVG_CCW && area < 0.0f) nvg__polyReverse(pts, path->count); if (path->winding == NVG_CW && area > 0.0f) nvg__polyReverse(pts, path->count); } for(i = 0; i < path->count; i++) { // Calculate segment direction and length p0->dx = p1->x - p0->x; p0->dy = p1->y - p0->y; p0->len = nvg__normalize(&p0->dx, &p0->dy); // Update bounds cache->bounds[0] = nvg__minf(cache->bounds[0], p0->x); cache->bounds[1] = nvg__minf(cache->bounds[1], p0->y); cache->bounds[2] = nvg__maxf(cache->bounds[2], p0->x); cache->bounds[3] = nvg__maxf(cache->bounds[3], p0->y); // Advance p0 = p1++; } } } static int nvg__curveDivs(float r, float arc, float tol) { float da = acosf(r / (r + tol)) * 2.0f; return nvg__maxi(2, (int)ceilf(arc / da)); } static void nvg__chooseBevel(int bevel, NVGpoint* p0, NVGpoint* p1, float w, float* x0, float* y0, float* x1, float* y1) { if (bevel) { *x0 = p1->x + p0->dy * w; *y0 = p1->y - p0->dx * w; *x1 = p1->x + p1->dy * w; *y1 = p1->y - p1->dx * w; } else { *x0 = p1->x + p1->dmx * w; *y0 = p1->y + p1->dmy * w; *x1 = p1->x + p1->dmx * w; *y1 = p1->y + p1->dmy * w; } } static NVGvertex* nvg__roundJoin(NVGvertex* dst, NVGpoint* p0, NVGpoint* p1, float lw, float rw, float lu, float ru, int ncap, float fringe) { int i, n; float dlx0 = p0->dy; float dly0 = -p0->dx; float dlx1 = p1->dy; float dly1 = -p1->dx; NVG_NOTUSED(fringe); if (p1->flags & NVG_PT_LEFT) { float lx0,ly0,lx1,ly1,a0,a1; nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, lw, &lx0,&ly0, &lx1,&ly1); a0 = atan2f(-dly0, -dlx0); a1 = atan2f(-dly1, -dlx1); if (a1 > a0) a1 -= NVG_PI*2; nvg__vset(dst, lx0, ly0, lu,1); dst++; nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; n = nvg__clampi((int)ceilf(((a0 - a1) / NVG_PI) * ncap), 2, ncap); for (i = 0; i < n; i++) { float u = i/(float)(n-1); float a = a0 + u*(a1-a0); float rx = p1->x + cosf(a) * rw; float ry = p1->y + sinf(a) * rw; nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; nvg__vset(dst, rx, ry, ru,1); dst++; } nvg__vset(dst, lx1, ly1, lu,1); dst++; nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; } else { float rx0,ry0,rx1,ry1,a0,a1; nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, -rw, &rx0,&ry0, &rx1,&ry1); a0 = atan2f(dly0, dlx0); a1 = atan2f(dly1, dlx1); if (a1 < a0) a1 += NVG_PI*2; nvg__vset(dst, p1->x + dlx0*rw, p1->y + dly0*rw, lu,1); dst++; nvg__vset(dst, rx0, ry0, ru,1); dst++; n = nvg__clampi((int)ceilf(((a1 - a0) / NVG_PI) * ncap), 2, ncap); for (i = 0; i < n; i++) { float u = i/(float)(n-1); float a = a0 + u*(a1-a0); float lx = p1->x + cosf(a) * lw; float ly = p1->y + sinf(a) * lw; nvg__vset(dst, lx, ly, lu,1); dst++; nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; } nvg__vset(dst, p1->x + dlx1*rw, p1->y + dly1*rw, lu,1); dst++; nvg__vset(dst, rx1, ry1, ru,1); dst++; } return dst; } static NVGvertex* nvg__bevelJoin(NVGvertex* dst, NVGpoint* p0, NVGpoint* p1, float lw, float rw, float lu, float ru, float fringe) { float rx0,ry0,rx1,ry1; float lx0,ly0,lx1,ly1; float dlx0 = p0->dy; float dly0 = -p0->dx; float dlx1 = p1->dy; float dly1 = -p1->dx; NVG_NOTUSED(fringe); if (p1->flags & NVG_PT_LEFT) { nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, lw, &lx0,&ly0, &lx1,&ly1); nvg__vset(dst, lx0, ly0, lu,1); dst++; nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; if (p1->flags & NVG_PT_BEVEL) { nvg__vset(dst, lx0, ly0, lu,1); dst++; nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; nvg__vset(dst, lx1, ly1, lu,1); dst++; nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; } else { rx0 = p1->x - p1->dmx * rw; ry0 = p1->y - p1->dmy * rw; nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; nvg__vset(dst, p1->x - dlx0*rw, p1->y - dly0*rw, ru,1); dst++; nvg__vset(dst, rx0, ry0, ru,1); dst++; nvg__vset(dst, rx0, ry0, ru,1); dst++; nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; } nvg__vset(dst, lx1, ly1, lu,1); dst++; nvg__vset(dst, p1->x - dlx1*rw, p1->y - dly1*rw, ru,1); dst++; } else { nvg__chooseBevel(p1->flags & NVG_PR_INNERBEVEL, p0, p1, -rw, &rx0,&ry0, &rx1,&ry1); nvg__vset(dst, p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); dst++; nvg__vset(dst, rx0, ry0, ru,1); dst++; if (p1->flags & NVG_PT_BEVEL) { nvg__vset(dst, p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); dst++; nvg__vset(dst, rx0, ry0, ru,1); dst++; nvg__vset(dst, p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); dst++; nvg__vset(dst, rx1, ry1, ru,1); dst++; } else { lx0 = p1->x + p1->dmx * lw; ly0 = p1->y + p1->dmy * lw; nvg__vset(dst, p1->x + dlx0*lw, p1->y + dly0*lw, lu,1); dst++; nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; nvg__vset(dst, lx0, ly0, lu,1); dst++; nvg__vset(dst, lx0, ly0, lu,1); dst++; nvg__vset(dst, p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); dst++; nvg__vset(dst, p1->x, p1->y, 0.5f,1); dst++; } nvg__vset(dst, p1->x + dlx1*lw, p1->y + dly1*lw, lu,1); dst++; nvg__vset(dst, rx1, ry1, ru,1); dst++; } return dst; } static NVGvertex* nvg__buttCapStart(NVGvertex* dst, NVGpoint* p, float dx, float dy, float w, float d, float aa) { float px = p->x - dx*d; float py = p->y - dy*d; float dlx = dy; float dly = -dx; nvg__vset(dst, px + dlx*w - dx*aa, py + dly*w - dy*aa, 0,0); dst++; nvg__vset(dst, px - dlx*w - dx*aa, py - dly*w - dy*aa, 1,0); dst++; nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; return dst; } static NVGvertex* nvg__buttCapEnd(NVGvertex* dst, NVGpoint* p, float dx, float dy, float w, float d, float aa) { float px = p->x + dx*d; float py = p->y + dy*d; float dlx = dy; float dly = -dx; nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; nvg__vset(dst, px + dlx*w + dx*aa, py + dly*w + dy*aa, 0,0); dst++; nvg__vset(dst, px - dlx*w + dx*aa, py - dly*w + dy*aa, 1,0); dst++; return dst; } static NVGvertex* nvg__roundCapStart(NVGvertex* dst, NVGpoint* p, float dx, float dy, float w, int ncap, float aa) { int i; float px = p->x; float py = p->y; float dlx = dy; float dly = -dx; NVG_NOTUSED(aa); for (i = 0; i < ncap; i++) { float a = i/(float)(ncap-1)*NVG_PI; float ax = cosf(a) * w, ay = sinf(a) * w; nvg__vset(dst, px - dlx*ax - dx*ay, py - dly*ax - dy*ay, 0,1); dst++; nvg__vset(dst, px, py, 0.5f,1); dst++; } nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; return dst; } static NVGvertex* nvg__roundCapEnd(NVGvertex* dst, NVGpoint* p, float dx, float dy, float w, int ncap, float aa) { int i; float px = p->x; float py = p->y; float dlx = dy; float dly = -dx; NVG_NOTUSED(aa); nvg__vset(dst, px + dlx*w, py + dly*w, 0,1); dst++; nvg__vset(dst, px - dlx*w, py - dly*w, 1,1); dst++; for (i = 0; i < ncap; i++) { float a = i/(float)(ncap-1)*NVG_PI; float ax = cosf(a) * w, ay = sinf(a) * w; nvg__vset(dst, px, py, 0.5f,1); dst++; nvg__vset(dst, px - dlx*ax + dx*ay, py - dly*ax + dy*ay, 0,1); dst++; } return dst; } static void nvg__calculateJoins(NVGcontext* ctx, float w, int lineJoin, float miterLimit) { NVGpathCache* cache = ctx->cache; int i, j; float iw = 0.0f; if (w > 0.0f) iw = 1.0f / w; // Calculate which joins needs extra vertices to append, and gather vertex count. for (i = 0; i < cache->npaths; i++) { NVGpath* path = &cache->paths[i]; NVGpoint* pts = &cache->points[path->first]; NVGpoint* p0 = &pts[path->count-1]; NVGpoint* p1 = &pts[0]; int nleft = 0; path->nbevel = 0; for (j = 0; j < path->count; j++) { float dlx0, dly0, dlx1, dly1, dmr2, cross, limit; dlx0 = p0->dy; dly0 = -p0->dx; dlx1 = p1->dy; dly1 = -p1->dx; // Calculate extrusions p1->dmx = (dlx0 + dlx1) * 0.5f; p1->dmy = (dly0 + dly1) * 0.5f; dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy; if (dmr2 > 0.000001f) { float scale = 1.0f / dmr2; if (scale > 600.0f) { scale = 600.0f; } p1->dmx *= scale; p1->dmy *= scale; } // Clear flags, but keep the corner. p1->flags = (p1->flags & NVG_PT_CORNER) ? NVG_PT_CORNER : 0; // Keep track of left turns. cross = p1->dx * p0->dy - p0->dx * p1->dy; if (cross > 0.0f) { nleft++; p1->flags |= NVG_PT_LEFT; } // Calculate if we should use bevel or miter for inner join. limit = nvg__maxf(1.01f, nvg__minf(p0->len, p1->len) * iw); if ((dmr2 * limit*limit) < 1.0f) p1->flags |= NVG_PR_INNERBEVEL; // Check to see if the corner needs to be beveled. if (p1->flags & NVG_PT_CORNER) { if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NVG_BEVEL || lineJoin == NVG_ROUND) { p1->flags |= NVG_PT_BEVEL; } } if ((p1->flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) path->nbevel++; p0 = p1++; } path->convex = (nleft == path->count) ? 1 : 0; } } static int nvg__expandStroke(NVGcontext* ctx, float w, int lineCap, int lineJoin, float miterLimit) { NVGpathCache* cache = ctx->cache; NVGvertex* verts; NVGvertex* dst; int cverts, i, j; float aa = ctx->fringeWidth; int ncap = nvg__curveDivs(w, NVG_PI, ctx->tessTol); // Calculate divisions per half circle. nvg__calculateJoins(ctx, w, lineJoin, miterLimit); // Calculate max vertex usage. cverts = 0; for (i = 0; i < cache->npaths; i++) { NVGpath* path = &cache->paths[i]; int loop = (path->closed == 0) ? 0 : 1; if (lineJoin == NVG_ROUND) cverts += (path->count + path->nbevel*(ncap+2) + 1) * 2; // plus one for loop else cverts += (path->count + path->nbevel*5 + 1) * 2; // plus one for loop if (loop == 0) { // space for caps if (lineCap == NVG_ROUND) { cverts += (ncap*2 + 2)*2; } else { cverts += (3+3)*2; } } } verts = nvg__allocTempVerts(ctx, cverts); if (verts == NULL) return 0; for (i = 0; i < cache->npaths; i++) { NVGpath* path = &cache->paths[i]; NVGpoint* pts = &cache->points[path->first]; NVGpoint* p0; NVGpoint* p1; int s, e, loop; float dx, dy; path->fill = 0; path->nfill = 0; // Calculate fringe or stroke loop = (path->closed == 0) ? 0 : 1; dst = verts; path->stroke = dst; if (loop) { // Looping p0 = &pts[path->count-1]; p1 = &pts[0]; s = 0; e = path->count; } else { // Add cap p0 = &pts[0]; p1 = &pts[1]; s = 1; e = path->count-1; } if (loop == 0) { // Add cap dx = p1->x - p0->x; dy = p1->y - p0->y; nvg__normalize(&dx, &dy); if (lineCap == NVG_BUTT) dst = nvg__buttCapStart(dst, p0, dx, dy, w, -aa*0.5f, aa); else if (lineCap == NVG_BUTT || lineCap == NVG_SQUARE) dst = nvg__buttCapStart(dst, p0, dx, dy, w, w-aa, aa); else if (lineCap == NVG_ROUND) dst = nvg__roundCapStart(dst, p0, dx, dy, w, ncap, aa); } for (j = s; j < e; ++j) { if ((p1->flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) { if (lineJoin == NVG_ROUND) { dst = nvg__roundJoin(dst, p0, p1, w, w, 0, 1, ncap, aa); } else { dst = nvg__bevelJoin(dst, p0, p1, w, w, 0, 1, aa); } } else { nvg__vset(dst, p1->x + (p1->dmx * w), p1->y + (p1->dmy * w), 0,1); dst++; nvg__vset(dst, p1->x - (p1->dmx * w), p1->y - (p1->dmy * w), 1,1); dst++; } p0 = p1++; } if (loop) { // Loop it nvg__vset(dst, verts[0].x, verts[0].y, 0,1); dst++; nvg__vset(dst, verts[1].x, verts[1].y, 1,1); dst++; } else { // Add cap dx = p1->x - p0->x; dy = p1->y - p0->y; nvg__normalize(&dx, &dy); if (lineCap == NVG_BUTT) dst = nvg__buttCapEnd(dst, p1, dx, dy, w, -aa*0.5f, aa); else if (lineCap == NVG_BUTT || lineCap == NVG_SQUARE) dst = nvg__buttCapEnd(dst, p1, dx, dy, w, w-aa, aa); else if (lineCap == NVG_ROUND) dst = nvg__roundCapEnd(dst, p1, dx, dy, w, ncap, aa); } path->nstroke = (int)(dst - verts); verts = dst; } return 1; } static int nvg__expandFill(NVGcontext* ctx, float w, int lineJoin, float miterLimit) { NVGpathCache* cache = ctx->cache; NVGvertex* verts; NVGvertex* dst; int cverts, convex, i, j; float aa = ctx->fringeWidth; int fringe = w > 0.0f; nvg__calculateJoins(ctx, w, lineJoin, miterLimit); // Calculate max vertex usage. cverts = 0; for (i = 0; i < cache->npaths; i++) { NVGpath* path = &cache->paths[i]; cverts += path->count + path->nbevel + 1; if (fringe) cverts += (path->count + path->nbevel*5 + 1) * 2; // plus one for loop } verts = nvg__allocTempVerts(ctx, cverts); if (verts == NULL) return 0; convex = cache->npaths == 1 && cache->paths[0].convex; for (i = 0; i < cache->npaths; i++) { NVGpath* path = &cache->paths[i]; NVGpoint* pts = &cache->points[path->first]; NVGpoint* p0; NVGpoint* p1; float rw, lw, woff; float ru, lu; // Calculate shape vertices. woff = 0.5f*aa; dst = verts; path->fill = dst; if (fringe) { // Looping p0 = &pts[path->count-1]; p1 = &pts[0]; for (j = 0; j < path->count; ++j) { if (p1->flags & NVG_PT_BEVEL) { float dlx0 = p0->dy; float dly0 = -p0->dx; float dlx1 = p1->dy; float dly1 = -p1->dx; if (p1->flags & NVG_PT_LEFT) { float lx = p1->x + p1->dmx * woff; float ly = p1->y + p1->dmy * woff; nvg__vset(dst, lx, ly, 0.5f,1); dst++; } else { float lx0 = p1->x + dlx0 * woff; float ly0 = p1->y + dly0 * woff; float lx1 = p1->x + dlx1 * woff; float ly1 = p1->y + dly1 * woff; nvg__vset(dst, lx0, ly0, 0.5f,1); dst++; nvg__vset(dst, lx1, ly1, 0.5f,1); dst++; } } else { nvg__vset(dst, p1->x + (p1->dmx * woff), p1->y + (p1->dmy * woff), 0.5f,1); dst++; } p0 = p1++; } } else { for (j = 0; j < path->count; ++j) { nvg__vset(dst, pts[j].x, pts[j].y, 0.5f,1); dst++; } } path->nfill = (int)(dst - verts); verts = dst; // Calculate fringe if (fringe) { lw = w + woff; rw = w - woff; lu = 0; ru = 1; dst = verts; path->stroke = dst; // Create only half a fringe for convex shapes so that // the shape can be rendered without stenciling. if (convex) { lw = woff; // This should generate the same vertex as fill inset above. lu = 0.5f; // Set outline fade at middle. } // Looping p0 = &pts[path->count-1]; p1 = &pts[0]; for (j = 0; j < path->count; ++j) { if ((p1->flags & (NVG_PT_BEVEL | NVG_PR_INNERBEVEL)) != 0) { dst = nvg__bevelJoin(dst, p0, p1, lw, rw, lu, ru, ctx->fringeWidth); } else { nvg__vset(dst, p1->x + (p1->dmx * lw), p1->y + (p1->dmy * lw), lu,1); dst++; nvg__vset(dst, p1->x - (p1->dmx * rw), p1->y - (p1->dmy * rw), ru,1); dst++; } p0 = p1++; } // Loop it nvg__vset(dst, verts[0].x, verts[0].y, lu,1); dst++; nvg__vset(dst, verts[1].x, verts[1].y, ru,1); dst++; path->nstroke = (int)(dst - verts); verts = dst; } else { path->stroke = NULL; path->nstroke = 0; } } return 1; } // Draw void nvgBeginPath(NVGcontext* ctx) { ctx->ncommands = 0; nvg__clearPathCache(ctx); } void nvgMoveTo(NVGcontext* ctx, float x, float y) { float vals[] = { NVG_MOVETO, x, y }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgLineTo(NVGcontext* ctx, float x, float y) { float vals[] = { NVG_LINETO, x, y }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgBezierTo(NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y) { float vals[] = { NVG_BEZIERTO, c1x, c1y, c2x, c2y, x, y }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgQuadTo(NVGcontext* ctx, float cx, float cy, float x, float y) { float x0 = ctx->commandx; float y0 = ctx->commandy; float vals[] = { NVG_BEZIERTO, x0 + 2.0f/3.0f*(cx - x0), y0 + 2.0f/3.0f*(cy - y0), x + 2.0f/3.0f*(cx - x), y + 2.0f/3.0f*(cy - y), x, y }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgArcTo(NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius) { float x0 = ctx->commandx; float y0 = ctx->commandy; float dx0,dy0, dx1,dy1, a, d, cx,cy, a0,a1; int dir; if (ctx->ncommands == 0) { return; } // Handle degenerate cases. if (nvg__ptEquals(x0,y0, x1,y1, ctx->distTol) || nvg__ptEquals(x1,y1, x2,y2, ctx->distTol) || nvg__distPtSeg(x1,y1, x0,y0, x2,y2) < ctx->distTol*ctx->distTol || radius < ctx->distTol) { nvgLineTo(ctx, x1,y1); return; } // Calculate tangential circle to lines (x0,y0)-(x1,y1) and (x1,y1)-(x2,y2). dx0 = x0-x1; dy0 = y0-y1; dx1 = x2-x1; dy1 = y2-y1; nvg__normalize(&dx0,&dy0); nvg__normalize(&dx1,&dy1); a = nvg__acosf(dx0*dx1 + dy0*dy1); d = radius / nvg__tanf(a/2.0f); // printf("a=%f° d=%f\n", a/NVG_PI*180.0f, d); if (d > 10000.0f) { nvgLineTo(ctx, x1,y1); return; } if (nvg__cross(dx0,dy0, dx1,dy1) > 0.0f) { cx = x1 + dx0*d + dy0*radius; cy = y1 + dy0*d + -dx0*radius; a0 = nvg__atan2f(dx0, -dy0); a1 = nvg__atan2f(-dx1, dy1); dir = NVG_CW; // printf("CW c=(%f, %f) a0=%f° a1=%f°\n", cx, cy, a0/NVG_PI*180.0f, a1/NVG_PI*180.0f); } else { cx = x1 + dx0*d + -dy0*radius; cy = y1 + dy0*d + dx0*radius; a0 = nvg__atan2f(-dx0, dy0); a1 = nvg__atan2f(dx1, -dy1); dir = NVG_CCW; // printf("CCW c=(%f, %f) a0=%f° a1=%f°\n", cx, cy, a0/NVG_PI*180.0f, a1/NVG_PI*180.0f); } nvgArc(ctx, cx, cy, radius, a0, a1, dir); } void nvgClosePath(NVGcontext* ctx) { float vals[] = { NVG_CLOSE }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgPathWinding(NVGcontext* ctx, int dir) { float vals[] = { NVG_WINDING, (float)dir }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgArc(NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, int dir) { float a = 0, da = 0, hda = 0, kappa = 0; float dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0; float px = 0, py = 0, ptanx = 0, ptany = 0; float vals[3 + 5*7 + 100]; int i, ndivs, nvals; int move = ctx->ncommands > 0 ? NVG_LINETO : NVG_MOVETO; // Clamp angles da = a1 - a0; if (dir == NVG_CW) { if (nvg__absf(da) >= NVG_PI*2) { da = NVG_PI*2; } else { while (da < 0.0f) da += NVG_PI*2; } } else { if (nvg__absf(da) >= NVG_PI*2) { da = -NVG_PI*2; } else { while (da > 0.0f) da -= NVG_PI*2; } } // Split arc into max 90 degree segments. ndivs = nvg__maxi(1, nvg__mini((int)(nvg__absf(da) / (NVG_PI*0.5f) + 0.5f), 5)); hda = (da / (float)ndivs) / 2.0f; kappa = nvg__absf(4.0f / 3.0f * (1.0f - nvg__cosf(hda)) / nvg__sinf(hda)); if (dir == NVG_CCW) kappa = -kappa; nvals = 0; for (i = 0; i <= ndivs; i++) { a = a0 + da * (i/(float)ndivs); dx = nvg__cosf(a); dy = nvg__sinf(a); x = cx + dx*r; y = cy + dy*r; tanx = -dy*r*kappa; tany = dx*r*kappa; if (i == 0) { vals[nvals++] = (float)move; vals[nvals++] = x; vals[nvals++] = y; } else { vals[nvals++] = NVG_BEZIERTO; vals[nvals++] = px+ptanx; vals[nvals++] = py+ptany; vals[nvals++] = x-tanx; vals[nvals++] = y-tany; vals[nvals++] = x; vals[nvals++] = y; } px = x; py = y; ptanx = tanx; ptany = tany; } nvg__appendCommands(ctx, vals, nvals); } void nvgRect(NVGcontext* ctx, float x, float y, float w, float h) { float vals[] = { NVG_MOVETO, x,y, NVG_LINETO, x,y+h, NVG_LINETO, x+w,y+h, NVG_LINETO, x+w,y, NVG_CLOSE }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgRoundedRect(NVGcontext* ctx, float x, float y, float w, float h, float r) { nvgRoundedRectVarying(ctx, x, y, w, h, r, r, r, r); } void nvgRoundedRectVarying(NVGcontext* ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft) { if(radTopLeft < 0.1f && radTopRight < 0.1f && radBottomRight < 0.1f && radBottomLeft < 0.1f) { nvgRect(ctx, x, y, w, h); return; } else { float halfw = nvg__absf(w)*0.5f; float halfh = nvg__absf(h)*0.5f; float rxBL = nvg__minf(radBottomLeft, halfw) * nvg__signf(w), ryBL = nvg__minf(radBottomLeft, halfh) * nvg__signf(h); float rxBR = nvg__minf(radBottomRight, halfw) * nvg__signf(w), ryBR = nvg__minf(radBottomRight, halfh) * nvg__signf(h); float rxTR = nvg__minf(radTopRight, halfw) * nvg__signf(w), ryTR = nvg__minf(radTopRight, halfh) * nvg__signf(h); float rxTL = nvg__minf(radTopLeft, halfw) * nvg__signf(w), ryTL = nvg__minf(radTopLeft, halfh) * nvg__signf(h); float vals[] = { NVG_MOVETO, x, y + ryTL, NVG_LINETO, x, y + h - ryBL, NVG_BEZIERTO, x, y + h - ryBL*(1 - NVG_KAPPA90), x + rxBL*(1 - NVG_KAPPA90), y + h, x + rxBL, y + h, NVG_LINETO, x + w - rxBR, y + h, NVG_BEZIERTO, x + w - rxBR*(1 - NVG_KAPPA90), y + h, x + w, y + h - ryBR*(1 - NVG_KAPPA90), x + w, y + h - ryBR, NVG_LINETO, x + w, y + ryTR, NVG_BEZIERTO, x + w, y + ryTR*(1 - NVG_KAPPA90), x + w - rxTR*(1 - NVG_KAPPA90), y, x + w - rxTR, y, NVG_LINETO, x + rxTL, y, NVG_BEZIERTO, x + rxTL*(1 - NVG_KAPPA90), y, x, y + ryTL*(1 - NVG_KAPPA90), x, y + ryTL, NVG_CLOSE }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } } void nvgEllipse(NVGcontext* ctx, float cx, float cy, float rx, float ry) { float vals[] = { NVG_MOVETO, cx-rx, cy, NVG_BEZIERTO, cx-rx, cy+ry*NVG_KAPPA90, cx-rx*NVG_KAPPA90, cy+ry, cx, cy+ry, NVG_BEZIERTO, cx+rx*NVG_KAPPA90, cy+ry, cx+rx, cy+ry*NVG_KAPPA90, cx+rx, cy, NVG_BEZIERTO, cx+rx, cy-ry*NVG_KAPPA90, cx+rx*NVG_KAPPA90, cy-ry, cx, cy-ry, NVG_BEZIERTO, cx-rx*NVG_KAPPA90, cy-ry, cx-rx, cy-ry*NVG_KAPPA90, cx-rx, cy, NVG_CLOSE }; nvg__appendCommands(ctx, vals, NVG_COUNTOF(vals)); } void nvgCircle(NVGcontext* ctx, float cx, float cy, float r) { nvgEllipse(ctx, cx,cy, r,r); } void nvgDebugDumpPathCache(NVGcontext* ctx) { const NVGpath* path; int i, j; printf("Dumping %d cached paths\n", ctx->cache->npaths); for (i = 0; i < ctx->cache->npaths; i++) { path = &ctx->cache->paths[i]; printf(" - Path %d\n", i); if (path->nfill) { printf(" - fill: %d\n", path->nfill); for (j = 0; j < path->nfill; j++) printf("%f\t%f\n", path->fill[j].x, path->fill[j].y); } if (path->nstroke) { printf(" - stroke: %d\n", path->nstroke); for (j = 0; j < path->nstroke; j++) printf("%f\t%f\n", path->stroke[j].x, path->stroke[j].y); } } } void nvgFill(NVGcontext* ctx) { NVGstate* state = nvg__getState(ctx); const NVGpath* path; NVGpaint fillPaint = state->fill; int i; nvg__flattenPaths(ctx); if (ctx->params.edgeAntiAlias) nvg__expandFill(ctx, ctx->fringeWidth, NVG_MITER, 2.4f); else nvg__expandFill(ctx, 0.0f, NVG_MITER, 2.4f); // Apply global alpha fillPaint.innerColor.a *= state->alpha; fillPaint.outerColor.a *= state->alpha; ctx->params.renderFill(ctx->params.userPtr, &fillPaint, &state->scissor, ctx->fringeWidth, ctx->cache->bounds, ctx->cache->paths, ctx->cache->npaths); // Count triangles for (i = 0; i < ctx->cache->npaths; i++) { path = &ctx->cache->paths[i]; ctx->fillTriCount += path->nfill-2; ctx->fillTriCount += path->nstroke-2; ctx->drawCallCount += 2; } } void nvgStroke(NVGcontext* ctx) { NVGstate* state = nvg__getState(ctx); float scale = nvg__getAverageScale(state->xform); float strokeWidth = nvg__clampf(state->strokeWidth * scale, 0.0f, 200.0f); NVGpaint strokePaint = state->stroke; const NVGpath* path; int i; if (strokeWidth < ctx->fringeWidth) { // If the stroke width is less than pixel size, use alpha to emulate coverage. // Since coverage is area, scale by alpha*alpha. float alpha = nvg__clampf(strokeWidth / ctx->fringeWidth, 0.0f, 1.0f); strokePaint.innerColor.a *= alpha*alpha; strokePaint.outerColor.a *= alpha*alpha; strokeWidth = ctx->fringeWidth; } // Apply global alpha strokePaint.innerColor.a *= state->alpha; strokePaint.outerColor.a *= state->alpha; nvg__flattenPaths(ctx); if (ctx->params.edgeAntiAlias) nvg__expandStroke(ctx, strokeWidth*0.5f + ctx->fringeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit); else nvg__expandStroke(ctx, strokeWidth*0.5f, state->lineCap, state->lineJoin, state->miterLimit); ctx->params.renderStroke(ctx->params.userPtr, &strokePaint, &state->scissor, ctx->fringeWidth, strokeWidth, ctx->cache->paths, ctx->cache->npaths); // Count triangles for (i = 0; i < ctx->cache->npaths; i++) { path = &ctx->cache->paths[i]; ctx->strokeTriCount += path->nstroke-2; ctx->drawCallCount++; } } // Add fonts int nvgCreateFont(NVGcontext* ctx, const char* name, const char* path) { return fonsAddFont(ctx->fs, name, path); } int nvgCreateFontMem(NVGcontext* ctx, const char* name, unsigned char* data, int ndata, int freeData) { return fonsAddFontMem(ctx->fs, name, data, ndata, freeData); } int nvgFindFont(NVGcontext* ctx, const char* name) { if (name == NULL) return -1; return fonsGetFontByName(ctx->fs, name); } int nvgAddFallbackFontId(NVGcontext* ctx, int baseFont, int fallbackFont) { if(baseFont == -1 || fallbackFont == -1) return 0; return fonsAddFallbackFont(ctx->fs, baseFont, fallbackFont); } int nvgAddFallbackFont(NVGcontext* ctx, const char* baseFont, const char* fallbackFont) { return nvgAddFallbackFontId(ctx, nvgFindFont(ctx, baseFont), nvgFindFont(ctx, fallbackFont)); } // State setting void nvgFontSize(NVGcontext* ctx, float size) { NVGstate* state = nvg__getState(ctx); state->fontSize = size; } void nvgFontBlur(NVGcontext* ctx, float blur) { NVGstate* state = nvg__getState(ctx); state->fontBlur = blur; } void nvgTextLetterSpacing(NVGcontext* ctx, float spacing) { NVGstate* state = nvg__getState(ctx); state->letterSpacing = spacing; } void nvgTextLineHeight(NVGcontext* ctx, float lineHeight) { NVGstate* state = nvg__getState(ctx); state->lineHeight = lineHeight; } void nvgTextAlign(NVGcontext* ctx, int align) { NVGstate* state = nvg__getState(ctx); state->textAlign = align; } void nvgFontFaceId(NVGcontext* ctx, int font) { NVGstate* state = nvg__getState(ctx); state->fontId = font; } void nvgFontFace(NVGcontext* ctx, const char* font) { NVGstate* state = nvg__getState(ctx); state->fontId = fonsGetFontByName(ctx->fs, font); } static float nvg__quantize(float a, float d) { return ((int)(a / d + 0.5f)) * d; } static float nvg__getFontScale(NVGstate* state) { return nvg__minf(nvg__quantize(nvg__getAverageScale(state->xform), 0.01f), 4.0f); } static void nvg__flushTextTexture(NVGcontext* ctx) { int dirty[4]; if (fonsValidateTexture(ctx->fs, dirty)) { int fontImage = ctx->fontImages[ctx->fontImageIdx]; // Update texture if (fontImage != 0) { int iw, ih; const unsigned char* data = fonsGetTextureData(ctx->fs, &iw, &ih); int x = dirty[0]; int y = dirty[1]; int w = dirty[2] - dirty[0]; int h = dirty[3] - dirty[1]; ctx->params.renderUpdateTexture(ctx->params.userPtr, fontImage, x,y, w,h, data); } } } static int nvg__allocTextAtlas(NVGcontext* ctx) { int iw, ih; nvg__flushTextTexture(ctx); if (ctx->fontImageIdx >= NVG_MAX_FONTIMAGES-1) return 0; // if next fontImage already have a texture if (ctx->fontImages[ctx->fontImageIdx+1] != 0) nvgImageSize(ctx, ctx->fontImages[ctx->fontImageIdx+1], &iw, &ih); else { // calculate the new font image size and create it. nvgImageSize(ctx, ctx->fontImages[ctx->fontImageIdx], &iw, &ih); if (iw > ih) ih *= 2; else iw *= 2; if (iw > NVG_MAX_FONTIMAGE_SIZE || ih > NVG_MAX_FONTIMAGE_SIZE) iw = ih = NVG_MAX_FONTIMAGE_SIZE; ctx->fontImages[ctx->fontImageIdx+1] = ctx->params.renderCreateTexture(ctx->params.userPtr, NVG_TEXTURE_ALPHA, iw, ih, 0, NULL); } ++ctx->fontImageIdx; fonsResetAtlas(ctx->fs, iw, ih); return 1; } static void nvg__renderText(NVGcontext* ctx, NVGvertex* verts, int nverts) { NVGstate* state = nvg__getState(ctx); NVGpaint paint = state->fill; // Render triangles. paint.image = ctx->fontImages[ctx->fontImageIdx]; // Apply global alpha paint.innerColor.a *= state->alpha; paint.outerColor.a *= state->alpha; ctx->params.renderTriangles(ctx->params.userPtr, &paint, &state->scissor, verts, nverts); ctx->drawCallCount++; ctx->textTriCount += nverts/3; } float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char* end) { NVGstate* state = nvg__getState(ctx); FONStextIter iter, prevIter; FONSquad q; NVGvertex* verts; float scale = nvg__getFontScale(state) * ctx->devicePxRatio; float invscale = 1.0f / scale; int cverts = 0; int nverts = 0; if (end == NULL) end = string + strlen(string); if (state->fontId == FONS_INVALID) return x; fonsSetSize(ctx->fs, state->fontSize*scale); fonsSetSpacing(ctx->fs, state->letterSpacing*scale); fonsSetBlur(ctx->fs, state->fontBlur*scale); fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); cverts = nvg__maxi(2, (int)(end - string)) * 6; // conservative estimate. verts = nvg__allocTempVerts(ctx, cverts); if (verts == NULL) return x; fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end); prevIter = iter; while (fonsTextIterNext(ctx->fs, &iter, &q)) { float c[4*2]; if (iter.prevGlyphIndex == -1) { // can not retrieve glyph? if (!nvg__allocTextAtlas(ctx)) break; // no memory :( if (nverts != 0) { nvg__renderText(ctx, verts, nverts); nverts = 0; } iter = prevIter; fonsTextIterNext(ctx->fs, &iter, &q); // try again if (iter.prevGlyphIndex == -1) // still can not find glyph? break; } prevIter = iter; // Transform corners. nvgTransformPoint(&c[0],&c[1], state->xform, q.x0*invscale, q.y0*invscale); nvgTransformPoint(&c[2],&c[3], state->xform, q.x1*invscale, q.y0*invscale); nvgTransformPoint(&c[4],&c[5], state->xform, q.x1*invscale, q.y1*invscale); nvgTransformPoint(&c[6],&c[7], state->xform, q.x0*invscale, q.y1*invscale); // Create triangles if (nverts+6 <= cverts) { nvg__vset(&verts[nverts], c[0], c[1], q.s0, q.t0); nverts++; nvg__vset(&verts[nverts], c[4], c[5], q.s1, q.t1); nverts++; nvg__vset(&verts[nverts], c[2], c[3], q.s1, q.t0); nverts++; nvg__vset(&verts[nverts], c[0], c[1], q.s0, q.t0); nverts++; nvg__vset(&verts[nverts], c[6], c[7], q.s0, q.t1); nverts++; nvg__vset(&verts[nverts], c[4], c[5], q.s1, q.t1); nverts++; } } // TODO: add back-end bit to do this just once per frame. nvg__flushTextTexture(ctx); nvg__renderText(ctx, verts, nverts); return iter.x; } void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end) { NVGstate* state = nvg__getState(ctx); NVGtextRow rows[2]; int nrows = 0, i; int oldAlign = state->textAlign; int haling = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT); int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE); float lineh = 0; if (state->fontId == FONS_INVALID) return; nvgTextMetrics(ctx, NULL, NULL, &lineh); state->textAlign = NVG_ALIGN_LEFT | valign; while ((nrows = nvgTextBreakLines(ctx, string, end, breakRowWidth, rows, 2))) { for (i = 0; i < nrows; i++) { NVGtextRow* row = &rows[i]; if (haling & NVG_ALIGN_LEFT) nvgText(ctx, x, y, row->start, row->end); else if (haling & NVG_ALIGN_CENTER) nvgText(ctx, x + breakRowWidth*0.5f - row->width*0.5f, y, row->start, row->end); else if (haling & NVG_ALIGN_RIGHT) nvgText(ctx, x + breakRowWidth - row->width, y, row->start, row->end); y += lineh * state->lineHeight; } string = rows[nrows-1].next; } state->textAlign = oldAlign; } int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string, const char* end, NVGglyphPosition* positions, int maxPositions) { NVGstate* state = nvg__getState(ctx); float scale = nvg__getFontScale(state) * ctx->devicePxRatio; float invscale = 1.0f / scale; FONStextIter iter, prevIter; FONSquad q; int npos = 0; if (state->fontId == FONS_INVALID) return 0; if (end == NULL) end = string + strlen(string); if (string == end) return 0; fonsSetSize(ctx->fs, state->fontSize*scale); fonsSetSpacing(ctx->fs, state->letterSpacing*scale); fonsSetBlur(ctx->fs, state->fontBlur*scale); fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end); prevIter = iter; while (fonsTextIterNext(ctx->fs, &iter, &q)) { if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph? iter = prevIter; fonsTextIterNext(ctx->fs, &iter, &q); // try again } prevIter = iter; positions[npos].str = iter.str; positions[npos].x = iter.x * invscale; positions[npos].minx = nvg__minf(iter.x, q.x0) * invscale; positions[npos].maxx = nvg__maxf(iter.nextx, q.x1) * invscale; npos++; if (npos >= maxPositions) break; } return npos; } enum NVGcodepointType { NVG_SPACE, NVG_NEWLINE, NVG_CHAR, }; int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, float breakRowWidth, NVGtextRow* rows, int maxRows) { NVGstate* state = nvg__getState(ctx); float scale = nvg__getFontScale(state) * ctx->devicePxRatio; float invscale = 1.0f / scale; FONStextIter iter, prevIter; FONSquad q; int nrows = 0; float rowStartX = 0; float rowWidth = 0; float rowMinX = 0; float rowMaxX = 0; const char* rowStart = NULL; const char* rowEnd = NULL; const char* wordStart = NULL; float wordStartX = 0; float wordMinX = 0; const char* breakEnd = NULL; float breakWidth = 0; float breakMaxX = 0; int type = NVG_SPACE, ptype = NVG_SPACE; unsigned int pcodepoint = 0; if (maxRows == 0) return 0; if (state->fontId == FONS_INVALID) return 0; if (end == NULL) end = string + strlen(string); if (string == end) return 0; fonsSetSize(ctx->fs, state->fontSize*scale); fonsSetSpacing(ctx->fs, state->letterSpacing*scale); fonsSetBlur(ctx->fs, state->fontBlur*scale); fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); breakRowWidth *= scale; fonsTextIterInit(ctx->fs, &iter, 0, 0, string, end); prevIter = iter; while (fonsTextIterNext(ctx->fs, &iter, &q)) { if (iter.prevGlyphIndex < 0 && nvg__allocTextAtlas(ctx)) { // can not retrieve glyph? iter = prevIter; fonsTextIterNext(ctx->fs, &iter, &q); // try again } prevIter = iter; switch (iter.codepoint) { case 9: // \t case 11: // \v case 12: // \f case 32: // space case 0x00a0: // NBSP type = NVG_SPACE; break; case 10: // \n type = pcodepoint == 13 ? NVG_SPACE : NVG_NEWLINE; break; case 13: // \r type = pcodepoint == 10 ? NVG_SPACE : NVG_NEWLINE; break; case 0x0085: // NEL type = NVG_NEWLINE; break; default: type = NVG_CHAR; break; } if (type == NVG_NEWLINE) { // Always handle new lines. rows[nrows].start = rowStart != NULL ? rowStart : iter.str; rows[nrows].end = rowEnd != NULL ? rowEnd : iter.str; rows[nrows].width = rowWidth * invscale; rows[nrows].minx = rowMinX * invscale; rows[nrows].maxx = rowMaxX * invscale; rows[nrows].next = iter.next; nrows++; if (nrows >= maxRows) return nrows; // Set null break point breakEnd = rowStart; breakWidth = 0.0; breakMaxX = 0.0; // Indicate to skip the white space at the beginning of the row. rowStart = NULL; rowEnd = NULL; rowWidth = 0; rowMinX = rowMaxX = 0; } else { if (rowStart == NULL) { // Skip white space until the beginning of the line if (type == NVG_CHAR) { // The current char is the row so far rowStartX = iter.x; rowStart = iter.str; rowEnd = iter.next; rowWidth = iter.nextx - rowStartX; // q.x1 - rowStartX; rowMinX = q.x0 - rowStartX; rowMaxX = q.x1 - rowStartX; wordStart = iter.str; wordStartX = iter.x; wordMinX = q.x0 - rowStartX; // Set null break point breakEnd = rowStart; breakWidth = 0.0; breakMaxX = 0.0; } } else { float nextWidth = iter.nextx - rowStartX; // track last non-white space character if (type == NVG_CHAR) { rowEnd = iter.next; rowWidth = iter.nextx - rowStartX; rowMaxX = q.x1 - rowStartX; } // track last end of a word if (ptype == NVG_CHAR && type == NVG_SPACE) { breakEnd = iter.str; breakWidth = rowWidth; breakMaxX = rowMaxX; } // track last beginning of a word if (ptype == NVG_SPACE && type == NVG_CHAR) { wordStart = iter.str; wordStartX = iter.x; wordMinX = q.x0 - rowStartX; } // Break to new line when a character is beyond break width. if (type == NVG_CHAR && nextWidth > breakRowWidth) { // The run length is too long, need to break to new line. if (breakEnd == rowStart) { // The current word is longer than the row length, just break it from here. rows[nrows].start = rowStart; rows[nrows].end = iter.str; rows[nrows].width = rowWidth * invscale; rows[nrows].minx = rowMinX * invscale; rows[nrows].maxx = rowMaxX * invscale; rows[nrows].next = iter.str; nrows++; if (nrows >= maxRows) return nrows; rowStartX = iter.x; rowStart = iter.str; rowEnd = iter.next; rowWidth = iter.nextx - rowStartX; rowMinX = q.x0 - rowStartX; rowMaxX = q.x1 - rowStartX; wordStart = iter.str; wordStartX = iter.x; wordMinX = q.x0 - rowStartX; } else { // Break the line from the end of the last word, and start new line from the beginning of the new. rows[nrows].start = rowStart; rows[nrows].end = breakEnd; rows[nrows].width = breakWidth * invscale; rows[nrows].minx = rowMinX * invscale; rows[nrows].maxx = breakMaxX * invscale; rows[nrows].next = wordStart; nrows++; if (nrows >= maxRows) return nrows; rowStartX = wordStartX; rowStart = wordStart; rowEnd = iter.next; rowWidth = iter.nextx - rowStartX; rowMinX = wordMinX; rowMaxX = q.x1 - rowStartX; // No change to the word start } // Set null break point breakEnd = rowStart; breakWidth = 0.0; breakMaxX = 0.0; } } } pcodepoint = iter.codepoint; ptype = type; } // Break the line from the end of the last word, and start new line from the beginning of the new. if (rowStart != NULL) { rows[nrows].start = rowStart; rows[nrows].end = rowEnd; rows[nrows].width = rowWidth * invscale; rows[nrows].minx = rowMinX * invscale; rows[nrows].maxx = rowMaxX * invscale; rows[nrows].next = end; nrows++; } return nrows; } float nvgTextBounds(NVGcontext* ctx, float x, float y, const char* string, const char* end, float* bounds) { NVGstate* state = nvg__getState(ctx); float scale = nvg__getFontScale(state) * ctx->devicePxRatio; float invscale = 1.0f / scale; float width; if (state->fontId == FONS_INVALID) return 0; fonsSetSize(ctx->fs, state->fontSize*scale); fonsSetSpacing(ctx->fs, state->letterSpacing*scale); fonsSetBlur(ctx->fs, state->fontBlur*scale); fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); width = fonsTextBounds(ctx->fs, x*scale, y*scale, string, end, bounds); if (bounds != NULL) { // Use line bounds for height. fonsLineBounds(ctx->fs, y*scale, &bounds[1], &bounds[3]); bounds[0] *= invscale; bounds[1] *= invscale; bounds[2] *= invscale; bounds[3] *= invscale; } return width * invscale; } void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end, float* bounds) { NVGstate* state = nvg__getState(ctx); NVGtextRow rows[2]; float scale = nvg__getFontScale(state) * ctx->devicePxRatio; float invscale = 1.0f / scale; int nrows = 0, i; int oldAlign = state->textAlign; int haling = state->textAlign & (NVG_ALIGN_LEFT | NVG_ALIGN_CENTER | NVG_ALIGN_RIGHT); int valign = state->textAlign & (NVG_ALIGN_TOP | NVG_ALIGN_MIDDLE | NVG_ALIGN_BOTTOM | NVG_ALIGN_BASELINE); float lineh = 0, rminy = 0, rmaxy = 0; float minx, miny, maxx, maxy; if (state->fontId == FONS_INVALID) { if (bounds != NULL) bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0f; return; } nvgTextMetrics(ctx, NULL, NULL, &lineh); state->textAlign = NVG_ALIGN_LEFT | valign; minx = maxx = x; miny = maxy = y; fonsSetSize(ctx->fs, state->fontSize*scale); fonsSetSpacing(ctx->fs, state->letterSpacing*scale); fonsSetBlur(ctx->fs, state->fontBlur*scale); fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); fonsLineBounds(ctx->fs, 0, &rminy, &rmaxy); rminy *= invscale; rmaxy *= invscale; while ((nrows = nvgTextBreakLines(ctx, string, end, breakRowWidth, rows, 2))) { for (i = 0; i < nrows; i++) { NVGtextRow* row = &rows[i]; float rminx, rmaxx, dx = 0; // Horizontal bounds if (haling & NVG_ALIGN_LEFT) dx = 0; else if (haling & NVG_ALIGN_CENTER) dx = breakRowWidth*0.5f - row->width*0.5f; else if (haling & NVG_ALIGN_RIGHT) dx = breakRowWidth - row->width; rminx = x + row->minx + dx; rmaxx = x + row->maxx + dx; minx = nvg__minf(minx, rminx); maxx = nvg__maxf(maxx, rmaxx); // Vertical bounds. miny = nvg__minf(miny, y + rminy); maxy = nvg__maxf(maxy, y + rmaxy); y += lineh * state->lineHeight; } string = rows[nrows-1].next; } state->textAlign = oldAlign; if (bounds != NULL) { bounds[0] = minx; bounds[1] = miny; bounds[2] = maxx; bounds[3] = maxy; } } void nvgTextMetrics(NVGcontext* ctx, float* ascender, float* descender, float* lineh) { NVGstate* state = nvg__getState(ctx); float scale = nvg__getFontScale(state) * ctx->devicePxRatio; float invscale = 1.0f / scale; if (state->fontId == FONS_INVALID) return; fonsSetSize(ctx->fs, state->fontSize*scale); fonsSetSpacing(ctx->fs, state->letterSpacing*scale); fonsSetBlur(ctx->fs, state->fontBlur*scale); fonsSetAlign(ctx->fs, state->textAlign); fonsSetFont(ctx->fs, state->fontId); fonsVertMetrics(ctx->fs, ascender, descender, lineh); if (ascender != NULL) *ascender *= invscale; if (descender != NULL) *descender *= invscale; if (lineh != NULL) *lineh *= invscale; } // vim: ft=c nu noet ts=4 ================================================ FILE: phonelibs/nanovg/nanovg.h ================================================ // // Copyright (c) 2013 Mikko Mononen memon@inside.org // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // #ifndef NANOVG_H #define NANOVG_H #ifdef __cplusplus extern "C" { #endif #define NVG_PI 3.14159265358979323846264338327f #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union #endif typedef struct NVGcontext NVGcontext; struct NVGcolor { union { float rgba[4]; struct { float r,g,b,a; }; }; }; typedef struct NVGcolor NVGcolor; struct NVGpaint { float xform[6]; float extent[2]; float radius; float feather; NVGcolor innerColor; NVGcolor outerColor; int image; }; typedef struct NVGpaint NVGpaint; enum NVGwinding { NVG_CCW = 1, // Winding for solid shapes NVG_CW = 2, // Winding for holes }; enum NVGsolidity { NVG_SOLID = 1, // CCW NVG_HOLE = 2, // CW }; enum NVGlineCap { NVG_BUTT, NVG_ROUND, NVG_SQUARE, NVG_BEVEL, NVG_MITER, }; enum NVGalign { // Horizontal align NVG_ALIGN_LEFT = 1<<0, // Default, align text horizontally to left. NVG_ALIGN_CENTER = 1<<1, // Align text horizontally to center. NVG_ALIGN_RIGHT = 1<<2, // Align text horizontally to right. // Vertical align NVG_ALIGN_TOP = 1<<3, // Align text vertically to top. NVG_ALIGN_MIDDLE = 1<<4, // Align text vertically to middle. NVG_ALIGN_BOTTOM = 1<<5, // Align text vertically to bottom. NVG_ALIGN_BASELINE = 1<<6, // Default, align text vertically to baseline. }; enum NVGblendFactor { NVG_ZERO = 1<<0, NVG_ONE = 1<<1, NVG_SRC_COLOR = 1<<2, NVG_ONE_MINUS_SRC_COLOR = 1<<3, NVG_DST_COLOR = 1<<4, NVG_ONE_MINUS_DST_COLOR = 1<<5, NVG_SRC_ALPHA = 1<<6, NVG_ONE_MINUS_SRC_ALPHA = 1<<7, NVG_DST_ALPHA = 1<<8, NVG_ONE_MINUS_DST_ALPHA = 1<<9, NVG_SRC_ALPHA_SATURATE = 1<<10, }; enum NVGcompositeOperation { NVG_SOURCE_OVER, NVG_SOURCE_IN, NVG_SOURCE_OUT, NVG_ATOP, NVG_DESTINATION_OVER, NVG_DESTINATION_IN, NVG_DESTINATION_OUT, NVG_DESTINATION_ATOP, NVG_LIGHTER, NVG_COPY, NVG_XOR, }; struct NVGcompositeOperationState { int srcRGB; int dstRGB; int srcAlpha; int dstAlpha; }; typedef struct NVGcompositeOperationState NVGcompositeOperationState; struct NVGglyphPosition { const char* str; // Position of the glyph in the input string. float x; // The x-coordinate of the logical glyph position. float minx, maxx; // The bounds of the glyph shape. }; typedef struct NVGglyphPosition NVGglyphPosition; struct NVGtextRow { const char* start; // Pointer to the input text where the row starts. const char* end; // Pointer to the input text where the row ends (one past the last character). const char* next; // Pointer to the beginning of the next row. float width; // Logical width of the row. float minx, maxx; // Actual bounds of the row. Logical with and bounds can differ because of kerning and some parts over extending. }; typedef struct NVGtextRow NVGtextRow; enum NVGimageFlags { NVG_IMAGE_GENERATE_MIPMAPS = 1<<0, // Generate mipmaps during creation of the image. NVG_IMAGE_REPEATX = 1<<1, // Repeat image in X direction. NVG_IMAGE_REPEATY = 1<<2, // Repeat image in Y direction. NVG_IMAGE_FLIPY = 1<<3, // Flips (inverses) image in Y direction when rendered. NVG_IMAGE_PREMULTIPLIED = 1<<4, // Image data has premultiplied alpha. }; // Begin drawing a new frame // Calls to nanovg drawing API should be wrapped in nvgBeginFrame() & nvgEndFrame() // nvgBeginFrame() defines the size of the window to render to in relation currently // set viewport (i.e. glViewport on GL backends). Device pixel ration allows to // control the rendering on Hi-DPI devices. // For example, GLFW returns two dimension for an opened window: window size and // frame buffer size. In that case you would set windowWidth/Height to the window size // devicePixelRatio to: frameBufferWidth / windowWidth. void nvgBeginFrame(NVGcontext* ctx, int windowWidth, int windowHeight, float devicePixelRatio); // Cancels drawing the current frame. void nvgCancelFrame(NVGcontext* ctx); // Ends drawing flushing remaining render state. void nvgEndFrame(NVGcontext* ctx); // // Composite operation // // The composite operations in NanoVG are modeled after HTML Canvas API, and // the blend func is based on OpenGL (see corresponding manuals for more info). // The colors in the blending state have premultiplied alpha. // Sets the composite operation. The op parameter should be one of NVGcompositeOperation. void nvgGlobalCompositeOperation(NVGcontext* ctx, int op); // Sets the composite operation with custom pixel arithmetic. The parameters should be one of NVGblendFactor. void nvgGlobalCompositeBlendFunc(NVGcontext* ctx, int sfactor, int dfactor); // Sets the composite operation with custom pixel arithmetic for RGB and alpha components separately. The parameters should be one of NVGblendFactor. void nvgGlobalCompositeBlendFuncSeparate(NVGcontext* ctx, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha); // // Color utils // // Colors in NanoVG are stored as unsigned ints in ABGR format. // Returns a color value from red, green, blue values. Alpha will be set to 255 (1.0f). NVGcolor nvgRGB(unsigned char r, unsigned char g, unsigned char b); // Returns a color value from red, green, blue values. Alpha will be set to 1.0f. NVGcolor nvgRGBf(float r, float g, float b); // Returns a color value from red, green, blue and alpha values. NVGcolor nvgRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); // Returns a color value from red, green, blue and alpha values. NVGcolor nvgRGBAf(float r, float g, float b, float a); // Linearly interpolates from color c0 to c1, and returns resulting color value. NVGcolor nvgLerpRGBA(NVGcolor c0, NVGcolor c1, float u); // Sets transparency of a color value. NVGcolor nvgTransRGBA(NVGcolor c0, unsigned char a); // Sets transparency of a color value. NVGcolor nvgTransRGBAf(NVGcolor c0, float a); // Returns color value specified by hue, saturation and lightness. // HSL values are all in range [0..1], alpha will be set to 255. NVGcolor nvgHSL(float h, float s, float l); // Returns color value specified by hue, saturation and lightness and alpha. // HSL values are all in range [0..1], alpha in range [0..255] NVGcolor nvgHSLA(float h, float s, float l, unsigned char a); // // State Handling // // NanoVG contains state which represents how paths will be rendered. // The state contains transform, fill and stroke styles, text and font styles, // and scissor clipping. // Pushes and saves the current render state into a state stack. // A matching nvgRestore() must be used to restore the state. void nvgSave(NVGcontext* ctx); // Pops and restores current render state. void nvgRestore(NVGcontext* ctx); // Resets current render state to default values. Does not affect the render state stack. void nvgReset(NVGcontext* ctx); // // Render styles // // Fill and stroke render style can be either a solid color or a paint which is a gradient or a pattern. // Solid color is simply defined as a color value, different kinds of paints can be created // using nvgLinearGradient(), nvgBoxGradient(), nvgRadialGradient() and nvgImagePattern(). // // Current render style can be saved and restored using nvgSave() and nvgRestore(). // Sets current stroke style to a solid color. void nvgStrokeColor(NVGcontext* ctx, NVGcolor color); // Sets current stroke style to a paint, which can be a one of the gradients or a pattern. void nvgStrokePaint(NVGcontext* ctx, NVGpaint paint); // Sets current fill style to a solid color. void nvgFillColor(NVGcontext* ctx, NVGcolor color); // Sets current fill style to a paint, which can be a one of the gradients or a pattern. void nvgFillPaint(NVGcontext* ctx, NVGpaint paint); // Sets the miter limit of the stroke style. // Miter limit controls when a sharp corner is beveled. void nvgMiterLimit(NVGcontext* ctx, float limit); // Sets the stroke width of the stroke style. void nvgStrokeWidth(NVGcontext* ctx, float size); // Sets how the end of the line (cap) is drawn, // Can be one of: NVG_BUTT (default), NVG_ROUND, NVG_SQUARE. void nvgLineCap(NVGcontext* ctx, int cap); // Sets how sharp path corners are drawn. // Can be one of NVG_MITER (default), NVG_ROUND, NVG_BEVEL. void nvgLineJoin(NVGcontext* ctx, int join); // Sets the transparency applied to all rendered shapes. // Already transparent paths will get proportionally more transparent as well. void nvgGlobalAlpha(NVGcontext* ctx, float alpha); // // Transforms // // The paths, gradients, patterns and scissor region are transformed by an transformation // matrix at the time when they are passed to the API. // The current transformation matrix is a affine matrix: // [sx kx tx] // [ky sy ty] // [ 0 0 1] // Where: sx,sy define scaling, kx,ky skewing, and tx,ty translation. // The last row is assumed to be 0,0,1 and is not stored. // // Apart from nvgResetTransform(), each transformation function first creates // specific transformation matrix and pre-multiplies the current transformation by it. // // Current coordinate system (transformation) can be saved and restored using nvgSave() and nvgRestore(). // Resets current transform to a identity matrix. void nvgResetTransform(NVGcontext* ctx); // Premultiplies current coordinate system by specified matrix. // The parameters are interpreted as matrix as follows: // [a c e] // [b d f] // [0 0 1] void nvgTransform(NVGcontext* ctx, float a, float b, float c, float d, float e, float f); // Translates current coordinate system. void nvgTranslate(NVGcontext* ctx, float x, float y); // Rotates current coordinate system. Angle is specified in radians. void nvgRotate(NVGcontext* ctx, float angle); // Skews the current coordinate system along X axis. Angle is specified in radians. void nvgSkewX(NVGcontext* ctx, float angle); // Skews the current coordinate system along Y axis. Angle is specified in radians. void nvgSkewY(NVGcontext* ctx, float angle); // Scales the current coordinate system. void nvgScale(NVGcontext* ctx, float x, float y); // Stores the top part (a-f) of the current transformation matrix in to the specified buffer. // [a c e] // [b d f] // [0 0 1] // There should be space for 6 floats in the return buffer for the values a-f. void nvgCurrentTransform(NVGcontext* ctx, float* xform); // The following functions can be used to make calculations on 2x3 transformation matrices. // A 2x3 matrix is represented as float[6]. // Sets the transform to identity matrix. void nvgTransformIdentity(float* dst); // Sets the transform to translation matrix matrix. void nvgTransformTranslate(float* dst, float tx, float ty); // Sets the transform to scale matrix. void nvgTransformScale(float* dst, float sx, float sy); // Sets the transform to rotate matrix. Angle is specified in radians. void nvgTransformRotate(float* dst, float a); // Sets the transform to skew-x matrix. Angle is specified in radians. void nvgTransformSkewX(float* dst, float a); // Sets the transform to skew-y matrix. Angle is specified in radians. void nvgTransformSkewY(float* dst, float a); // Sets the transform to the result of multiplication of two transforms, of A = A*B. void nvgTransformMultiply(float* dst, const float* src); // Sets the transform to the result of multiplication of two transforms, of A = B*A. void nvgTransformPremultiply(float* dst, const float* src); // Sets the destination to inverse of specified transform. // Returns 1 if the inverse could be calculated, else 0. int nvgTransformInverse(float* dst, const float* src); // Transform a point by given transform. void nvgTransformPoint(float* dstx, float* dsty, const float* xform, float srcx, float srcy); // Converts degrees to radians and vice versa. float nvgDegToRad(float deg); float nvgRadToDeg(float rad); // // Images // // NanoVG allows you to load jpg, png, psd, tga, pic and gif files to be used for rendering. // In addition you can upload your own image. The image loading is provided by stb_image. // The parameter imageFlags is combination of flags defined in NVGimageFlags. // Creates image by loading it from the disk from specified file name. // Returns handle to the image. int nvgCreateImage(NVGcontext* ctx, const char* filename, int imageFlags); // Creates image by loading it from the specified chunk of memory. // Returns handle to the image. int nvgCreateImageMem(NVGcontext* ctx, int imageFlags, unsigned char* data, int ndata); // Creates image from specified image data. // Returns handle to the image. int nvgCreateImageRGBA(NVGcontext* ctx, int w, int h, int imageFlags, const unsigned char* data); // Updates image data specified by image handle. void nvgUpdateImage(NVGcontext* ctx, int image, const unsigned char* data); // Returns the dimensions of a created image. void nvgImageSize(NVGcontext* ctx, int image, int* w, int* h); // Deletes created image. void nvgDeleteImage(NVGcontext* ctx, int image); // // Paints // // NanoVG supports four types of paints: linear gradient, box gradient, radial gradient and image pattern. // These can be used as paints for strokes and fills. // Creates and returns a linear gradient. Parameters (sx,sy)-(ex,ey) specify the start and end coordinates // of the linear gradient, icol specifies the start color and ocol the end color. // The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). NVGpaint nvgLinearGradient(NVGcontext* ctx, float sx, float sy, float ex, float ey, NVGcolor icol, NVGcolor ocol); // Creates and returns a box gradient. Box gradient is a feathered rounded rectangle, it is useful for rendering // drop shadows or highlights for boxes. Parameters (x,y) define the top-left corner of the rectangle, // (w,h) define the size of the rectangle, r defines the corner radius, and f feather. Feather defines how blurry // the border of the rectangle is. Parameter icol specifies the inner color and ocol the outer color of the gradient. // The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). NVGpaint nvgBoxGradient(NVGcontext* ctx, float x, float y, float w, float h, float r, float f, NVGcolor icol, NVGcolor ocol); // Creates and returns a radial gradient. Parameters (cx,cy) specify the center, inr and outr specify // the inner and outer radius of the gradient, icol specifies the start color and ocol the end color. // The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). NVGpaint nvgRadialGradient(NVGcontext* ctx, float cx, float cy, float inr, float outr, NVGcolor icol, NVGcolor ocol); // Creates and returns an image patter. Parameters (ox,oy) specify the left-top location of the image pattern, // (ex,ey) the size of one image, angle rotation around the top-left corner, image is handle to the image to render. // The gradient is transformed by the current transform when it is passed to nvgFillPaint() or nvgStrokePaint(). NVGpaint nvgImagePattern(NVGcontext* ctx, float ox, float oy, float ex, float ey, float angle, int image, float alpha); // // Scissoring // // Scissoring allows you to clip the rendering into a rectangle. This is useful for various // user interface cases like rendering a text edit or a timeline. // Sets the current scissor rectangle. // The scissor rectangle is transformed by the current transform. void nvgScissor(NVGcontext* ctx, float x, float y, float w, float h); // Intersects current scissor rectangle with the specified rectangle. // The scissor rectangle is transformed by the current transform. // Note: in case the rotation of previous scissor rect differs from // the current one, the intersection will be done between the specified // rectangle and the previous scissor rectangle transformed in the current // transform space. The resulting shape is always rectangle. void nvgIntersectScissor(NVGcontext* ctx, float x, float y, float w, float h); // Reset and disables scissoring. void nvgResetScissor(NVGcontext* ctx); // // Paths // // Drawing a new shape starts with nvgBeginPath(), it clears all the currently defined paths. // Then you define one or more paths and sub-paths which describe the shape. The are functions // to draw common shapes like rectangles and circles, and lower level step-by-step functions, // which allow to define a path curve by curve. // // NanoVG uses even-odd fill rule to draw the shapes. Solid shapes should have counter clockwise // winding and holes should have counter clockwise order. To specify winding of a path you can // call nvgPathWinding(). This is useful especially for the common shapes, which are drawn CCW. // // Finally you can fill the path using current fill style by calling nvgFill(), and stroke it // with current stroke style by calling nvgStroke(). // // The curve segments and sub-paths are transformed by the current transform. // Clears the current path and sub-paths. void nvgBeginPath(NVGcontext* ctx); // Starts new sub-path with specified point as first point. void nvgMoveTo(NVGcontext* ctx, float x, float y); // Adds line segment from the last point in the path to the specified point. void nvgLineTo(NVGcontext* ctx, float x, float y); // Adds cubic bezier segment from last point in the path via two control points to the specified point. void nvgBezierTo(NVGcontext* ctx, float c1x, float c1y, float c2x, float c2y, float x, float y); // Adds quadratic bezier segment from last point in the path via a control point to the specified point. void nvgQuadTo(NVGcontext* ctx, float cx, float cy, float x, float y); // Adds an arc segment at the corner defined by the last path point, and two specified points. void nvgArcTo(NVGcontext* ctx, float x1, float y1, float x2, float y2, float radius); // Closes current sub-path with a line segment. void nvgClosePath(NVGcontext* ctx); // Sets the current sub-path winding, see NVGwinding and NVGsolidity. void nvgPathWinding(NVGcontext* ctx, int dir); // Creates new circle arc shaped sub-path. The arc center is at cx,cy, the arc radius is r, // and the arc is drawn from angle a0 to a1, and swept in direction dir (NVG_CCW, or NVG_CW). // Angles are specified in radians. void nvgArc(NVGcontext* ctx, float cx, float cy, float r, float a0, float a1, int dir); // Creates new rectangle shaped sub-path. void nvgRect(NVGcontext* ctx, float x, float y, float w, float h); // Creates new rounded rectangle shaped sub-path. void nvgRoundedRect(NVGcontext* ctx, float x, float y, float w, float h, float r); // Creates new rounded rectangle shaped sub-path with varying radii for each corner. void nvgRoundedRectVarying(NVGcontext* ctx, float x, float y, float w, float h, float radTopLeft, float radTopRight, float radBottomRight, float radBottomLeft); // Creates new ellipse shaped sub-path. void nvgEllipse(NVGcontext* ctx, float cx, float cy, float rx, float ry); // Creates new circle shaped sub-path. void nvgCircle(NVGcontext* ctx, float cx, float cy, float r); // Fills the current path with current fill style. void nvgFill(NVGcontext* ctx); // Fills the current path with current stroke style. void nvgStroke(NVGcontext* ctx); // // Text // // NanoVG allows you to load .ttf files and use the font to render text. // // The appearance of the text can be defined by setting the current text style // and by specifying the fill color. Common text and font settings such as // font size, letter spacing and text align are supported. Font blur allows you // to create simple text effects such as drop shadows. // // At render time the font face can be set based on the font handles or name. // // Font measure functions return values in local space, the calculations are // carried in the same resolution as the final rendering. This is done because // the text glyph positions are snapped to the nearest pixels sharp rendering. // // The local space means that values are not rotated or scale as per the current // transformation. For example if you set font size to 12, which would mean that // line height is 16, then regardless of the current scaling and rotation, the // returned line height is always 16. Some measures may vary because of the scaling // since aforementioned pixel snapping. // // While this may sound a little odd, the setup allows you to always render the // same way regardless of scaling. I.e. following works regardless of scaling: // // const char* txt = "Text me up."; // nvgTextBounds(vg, x,y, txt, NULL, bounds); // nvgBeginPath(vg); // nvgRoundedRect(vg, bounds[0],bounds[1], bounds[2]-bounds[0], bounds[3]-bounds[1]); // nvgFill(vg); // // Note: currently only solid color fill is supported for text. // Creates font by loading it from the disk from specified file name. // Returns handle to the font. int nvgCreateFont(NVGcontext* ctx, const char* name, const char* filename); // Creates font by loading it from the specified memory chunk. // Returns handle to the font. int nvgCreateFontMem(NVGcontext* ctx, const char* name, unsigned char* data, int ndata, int freeData); // Finds a loaded font of specified name, and returns handle to it, or -1 if the font is not found. int nvgFindFont(NVGcontext* ctx, const char* name); // Adds a fallback font by handle. int nvgAddFallbackFontId(NVGcontext* ctx, int baseFont, int fallbackFont); // Adds a fallback font by name. int nvgAddFallbackFont(NVGcontext* ctx, const char* baseFont, const char* fallbackFont); // Sets the font size of current text style. void nvgFontSize(NVGcontext* ctx, float size); // Sets the blur of current text style. void nvgFontBlur(NVGcontext* ctx, float blur); // Sets the letter spacing of current text style. void nvgTextLetterSpacing(NVGcontext* ctx, float spacing); // Sets the proportional line height of current text style. The line height is specified as multiple of font size. void nvgTextLineHeight(NVGcontext* ctx, float lineHeight); // Sets the text align of current text style, see NVGalign for options. void nvgTextAlign(NVGcontext* ctx, int align); // Sets the font face based on specified id of current text style. void nvgFontFaceId(NVGcontext* ctx, int font); // Sets the font face based on specified name of current text style. void nvgFontFace(NVGcontext* ctx, const char* font); // Draws text string at specified location. If end is specified only the sub-string up to the end is drawn. float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char* end); // Draws multi-line text string at specified location wrapped at the specified width. If end is specified only the sub-string up to the end is drawn. // White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. // Words longer than the max width are slit at nearest character (i.e. no hyphenation). void nvgTextBox(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end); // Measures the specified text string. Parameter bounds should be a pointer to float[4], // if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] // Returns the horizontal advance of the measured text (i.e. where the next character should drawn). // Measured values are returned in local coordinate space. float nvgTextBounds(NVGcontext* ctx, float x, float y, const char* string, const char* end, float* bounds); // Measures the specified multi-text string. Parameter bounds should be a pointer to float[4], // if the bounding box of the text should be returned. The bounds value are [xmin,ymin, xmax,ymax] // Measured values are returned in local coordinate space. void nvgTextBoxBounds(NVGcontext* ctx, float x, float y, float breakRowWidth, const char* string, const char* end, float* bounds); // Calculates the glyph x positions of the specified text. If end is specified only the sub-string will be used. // Measured values are returned in local coordinate space. int nvgTextGlyphPositions(NVGcontext* ctx, float x, float y, const char* string, const char* end, NVGglyphPosition* positions, int maxPositions); // Returns the vertical metrics based on the current text style. // Measured values are returned in local coordinate space. void nvgTextMetrics(NVGcontext* ctx, float* ascender, float* descender, float* lineh); // Breaks the specified text into lines. If end is specified only the sub-string will be used. // White space is stripped at the beginning of the rows, the text is split at word boundaries or when new-line characters are encountered. // Words longer than the max width are slit at nearest character (i.e. no hyphenation). int nvgTextBreakLines(NVGcontext* ctx, const char* string, const char* end, float breakRowWidth, NVGtextRow* rows, int maxRows); // // Internal Render API // enum NVGtexture { NVG_TEXTURE_ALPHA = 0x01, NVG_TEXTURE_RGBA = 0x02, }; struct NVGscissor { float xform[6]; float extent[2]; }; typedef struct NVGscissor NVGscissor; struct NVGvertex { float x,y,u,v; }; typedef struct NVGvertex NVGvertex; struct NVGpath { int first; int count; unsigned char closed; int nbevel; NVGvertex* fill; int nfill; NVGvertex* stroke; int nstroke; int winding; int convex; }; typedef struct NVGpath NVGpath; struct NVGparams { void* userPtr; int edgeAntiAlias; int (*renderCreate)(void* uptr); int (*renderCreateTexture)(void* uptr, int type, int w, int h, int imageFlags, const unsigned char* data); int (*renderDeleteTexture)(void* uptr, int image); int (*renderUpdateTexture)(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data); int (*renderGetTextureSize)(void* uptr, int image, int* w, int* h); void (*renderViewport)(void* uptr, int width, int height, float devicePixelRatio); void (*renderCancel)(void* uptr); void (*renderFlush)(void* uptr, NVGcompositeOperationState compositeOperation); void (*renderFill)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths); void (*renderStroke)(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, float strokeWidth, const NVGpath* paths, int npaths); void (*renderTriangles)(void* uptr, NVGpaint* paint, NVGscissor* scissor, const NVGvertex* verts, int nverts); void (*renderDelete)(void* uptr); }; typedef struct NVGparams NVGparams; // Constructor and destructor, called by the render back-end. NVGcontext* nvgCreateInternal(NVGparams* params); void nvgDeleteInternal(NVGcontext* ctx); NVGparams* nvgInternalParams(NVGcontext* ctx); // Debug function to dump cached path data. void nvgDebugDumpPathCache(NVGcontext* ctx); #ifdef _MSC_VER #pragma warning(pop) #endif #define NVG_NOTUSED(v) for (;;) { (void)(1 ? (void)0 : ( (void)(v) ) ); break; } #ifdef __cplusplus } #endif #endif // NANOVG_H ================================================ FILE: phonelibs/nanovg/nanovg_gl.h ================================================ // // Copyright (c) 2009-2013 Mikko Mononen memon@inside.org // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // #ifndef NANOVG_GL_H #define NANOVG_GL_H #ifdef __cplusplus extern "C" { #endif // Create flags enum NVGcreateFlags { // Flag indicating if geometry based anti-aliasing is used (may not be needed when using MSAA). NVG_ANTIALIAS = 1<<0, // Flag indicating if strokes should be drawn using stencil buffer. The rendering will be a little // slower, but path overlaps (i.e. self-intersecting or sharp turns) will be drawn just once. NVG_STENCIL_STROKES = 1<<1, // Flag indicating that additional debug checks are done. NVG_DEBUG = 1<<2, }; #if defined NANOVG_GL2_IMPLEMENTATION # define NANOVG_GL2 1 # define NANOVG_GL_IMPLEMENTATION 1 #elif defined NANOVG_GL3_IMPLEMENTATION # define NANOVG_GL3 1 # define NANOVG_GL_IMPLEMENTATION 1 # define NANOVG_GL_USE_UNIFORMBUFFER 1 #elif defined NANOVG_GLES2_IMPLEMENTATION # define NANOVG_GLES2 1 # define NANOVG_GL_IMPLEMENTATION 1 #elif defined NANOVG_GLES3_IMPLEMENTATION # define NANOVG_GLES3 1 # define NANOVG_GL_IMPLEMENTATION 1 #endif #define NANOVG_GL_USE_STATE_FILTER (1) // Creates NanoVG contexts for different OpenGL (ES) versions. // Flags should be combination of the create flags above. #if defined NANOVG_GL2 NVGcontext* nvgCreateGL2(int flags); void nvgDeleteGL2(NVGcontext* ctx); int nvglCreateImageFromHandleGL2(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); GLuint nvglImageHandleGL2(NVGcontext* ctx, int image); #endif #if defined NANOVG_GL3 NVGcontext* nvgCreateGL3(int flags); void nvgDeleteGL3(NVGcontext* ctx); int nvglCreateImageFromHandleGL3(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); GLuint nvglImageHandleGL3(NVGcontext* ctx, int image); #endif #if defined NANOVG_GLES2 NVGcontext* nvgCreateGLES2(int flags); void nvgDeleteGLES2(NVGcontext* ctx); int nvglCreateImageFromHandleGLES2(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); GLuint nvglImageHandleGLES2(NVGcontext* ctx, int image); #endif #if defined NANOVG_GLES3 NVGcontext* nvgCreateGLES3(int flags); void nvgDeleteGLES3(NVGcontext* ctx); int nvglCreateImageFromHandleGLES3(NVGcontext* ctx, GLuint textureId, int w, int h, int flags); GLuint nvglImageHandleGLES3(NVGcontext* ctx, int image); #endif // These are additional flags on top of NVGimageFlags. enum NVGimageFlagsGL { NVG_IMAGE_NODELETE = 1<<16, // Do not delete GL texture handle. }; #ifdef __cplusplus } #endif #endif /* NANOVG_GL_H */ #ifdef NANOVG_GL_IMPLEMENTATION #include #include #include #include #include "nanovg.h" enum GLNVGuniformLoc { GLNVG_LOC_VIEWSIZE, GLNVG_LOC_TEX, GLNVG_LOC_FRAG, GLNVG_MAX_LOCS }; enum GLNVGshaderType { NSVG_SHADER_FILLGRAD, NSVG_SHADER_FILLIMG, NSVG_SHADER_SIMPLE, NSVG_SHADER_IMG }; #if NANOVG_GL_USE_UNIFORMBUFFER enum GLNVGuniformBindings { GLNVG_FRAG_BINDING = 0, }; #endif struct GLNVGshader { GLuint prog; GLuint frag; GLuint vert; GLint loc[GLNVG_MAX_LOCS]; }; typedef struct GLNVGshader GLNVGshader; struct GLNVGtexture { int id; GLuint tex; int width, height; int type; int flags; }; typedef struct GLNVGtexture GLNVGtexture; enum GLNVGcallType { GLNVG_NONE = 0, GLNVG_FILL, GLNVG_CONVEXFILL, GLNVG_STROKE, GLNVG_TRIANGLES, }; struct GLNVGcall { int type; int image; int pathOffset; int pathCount; int triangleOffset; int triangleCount; int uniformOffset; }; typedef struct GLNVGcall GLNVGcall; struct GLNVGpath { int fillOffset; int fillCount; int strokeOffset; int strokeCount; }; typedef struct GLNVGpath GLNVGpath; struct GLNVGfragUniforms { #if NANOVG_GL_USE_UNIFORMBUFFER float scissorMat[12]; // matrices are actually 3 vec4s float paintMat[12]; struct NVGcolor innerCol; struct NVGcolor outerCol; float scissorExt[2]; float scissorScale[2]; float extent[2]; float radius; float feather; float strokeMult; float strokeThr; int texType; int type; #else // note: after modifying layout or size of uniform array, // don't forget to also update the fragment shader source! #define NANOVG_GL_UNIFORMARRAY_SIZE 11 union { struct { float scissorMat[12]; // matrices are actually 3 vec4s float paintMat[12]; struct NVGcolor innerCol; struct NVGcolor outerCol; float scissorExt[2]; float scissorScale[2]; float extent[2]; float radius; float feather; float strokeMult; float strokeThr; float texType; float type; }; float uniformArray[NANOVG_GL_UNIFORMARRAY_SIZE][4]; }; #endif }; typedef struct GLNVGfragUniforms GLNVGfragUniforms; struct GLNVGcontext { GLNVGshader shader; GLNVGtexture* textures; float view[2]; int ntextures; int ctextures; int textureId; GLuint vertBuf; #if defined NANOVG_GL3 GLuint vertArr; #endif #if NANOVG_GL_USE_UNIFORMBUFFER GLuint fragBuf; #endif int fragSize; int flags; // Per frame buffers GLNVGcall* calls; int ccalls; int ncalls; GLNVGpath* paths; int cpaths; int npaths; struct NVGvertex* verts; int cverts; int nverts; unsigned char* uniforms; int cuniforms; int nuniforms; // cached state #if NANOVG_GL_USE_STATE_FILTER GLuint boundTexture; GLuint stencilMask; GLenum stencilFunc; GLint stencilFuncRef; GLuint stencilFuncMask; #endif }; typedef struct GLNVGcontext GLNVGcontext; static int glnvg__maxi(int a, int b) { return a > b ? a : b; } #ifdef NANOVG_GLES2 static unsigned int glnvg__nearestPow2(unsigned int num) { unsigned n = num > 0 ? num - 1 : 0; n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; n++; return n; } #endif static void glnvg__bindTexture(GLNVGcontext* gl, GLuint tex) { #if NANOVG_GL_USE_STATE_FILTER if (gl->boundTexture != tex) { gl->boundTexture = tex; glBindTexture(GL_TEXTURE_2D, tex); } #else glBindTexture(GL_TEXTURE_2D, tex); #endif } static void glnvg__stencilMask(GLNVGcontext* gl, GLuint mask) { #if NANOVG_GL_USE_STATE_FILTER if (gl->stencilMask != mask) { gl->stencilMask = mask; glStencilMask(mask); } #else glStencilMask(mask); #endif } static void glnvg__stencilFunc(GLNVGcontext* gl, GLenum func, GLint ref, GLuint mask) { #if NANOVG_GL_USE_STATE_FILTER if ((gl->stencilFunc != func) || (gl->stencilFuncRef != ref) || (gl->stencilFuncMask != mask)) { gl->stencilFunc = func; gl->stencilFuncRef = ref; gl->stencilFuncMask = mask; glStencilFunc(func, ref, mask); } #else glStencilFunc(func, ref, mask); #endif } static GLNVGtexture* glnvg__allocTexture(GLNVGcontext* gl) { GLNVGtexture* tex = NULL; int i; for (i = 0; i < gl->ntextures; i++) { if (gl->textures[i].id == 0) { tex = &gl->textures[i]; break; } } if (tex == NULL) { if (gl->ntextures+1 > gl->ctextures) { GLNVGtexture* textures; int ctextures = glnvg__maxi(gl->ntextures+1, 4) + gl->ctextures/2; // 1.5x Overallocate textures = (GLNVGtexture*)realloc(gl->textures, sizeof(GLNVGtexture)*ctextures); if (textures == NULL) return NULL; gl->textures = textures; gl->ctextures = ctextures; } tex = &gl->textures[gl->ntextures++]; } memset(tex, 0, sizeof(*tex)); tex->id = ++gl->textureId; return tex; } static GLNVGtexture* glnvg__findTexture(GLNVGcontext* gl, int id) { int i; for (i = 0; i < gl->ntextures; i++) if (gl->textures[i].id == id) return &gl->textures[i]; return NULL; } static int glnvg__deleteTexture(GLNVGcontext* gl, int id) { int i; for (i = 0; i < gl->ntextures; i++) { if (gl->textures[i].id == id) { if (gl->textures[i].tex != 0 && (gl->textures[i].flags & NVG_IMAGE_NODELETE) == 0) glDeleteTextures(1, &gl->textures[i].tex); memset(&gl->textures[i], 0, sizeof(gl->textures[i])); return 1; } } return 0; } static void glnvg__dumpShaderError(GLuint shader, const char* name, const char* type) { GLchar str[512+1]; GLsizei len = 0; glGetShaderInfoLog(shader, 512, &len, str); if (len > 512) len = 512; str[len] = '\0'; printf("Shader %s/%s error:\n%s\n", name, type, str); } static void glnvg__dumpProgramError(GLuint prog, const char* name) { GLchar str[512+1]; GLsizei len = 0; glGetProgramInfoLog(prog, 512, &len, str); if (len > 512) len = 512; str[len] = '\0'; printf("Program %s error:\n%s\n", name, str); } static void glnvg__checkError(GLNVGcontext* gl, const char* str) { GLenum err; if ((gl->flags & NVG_DEBUG) == 0) return; err = glGetError(); if (err != GL_NO_ERROR) { printf("Error %08x after %s\n", err, str); return; } } static int glnvg__createShader(GLNVGshader* shader, const char* name, const char* header, const char* opts, const char* vshader, const char* fshader) { GLint status; GLuint prog, vert, frag; const char* str[3]; str[0] = header; str[1] = opts != NULL ? opts : ""; memset(shader, 0, sizeof(*shader)); prog = glCreateProgram(); vert = glCreateShader(GL_VERTEX_SHADER); frag = glCreateShader(GL_FRAGMENT_SHADER); str[2] = vshader; glShaderSource(vert, 3, str, 0); str[2] = fshader; glShaderSource(frag, 3, str, 0); glCompileShader(vert); glGetShaderiv(vert, GL_COMPILE_STATUS, &status); if (status != GL_TRUE) { glnvg__dumpShaderError(vert, name, "vert"); return 0; } glCompileShader(frag); glGetShaderiv(frag, GL_COMPILE_STATUS, &status); if (status != GL_TRUE) { glnvg__dumpShaderError(frag, name, "frag"); return 0; } glAttachShader(prog, vert); glAttachShader(prog, frag); glBindAttribLocation(prog, 0, "vertex"); glBindAttribLocation(prog, 1, "tcoord"); glLinkProgram(prog); glGetProgramiv(prog, GL_LINK_STATUS, &status); if (status != GL_TRUE) { glnvg__dumpProgramError(prog, name); return 0; } shader->prog = prog; shader->vert = vert; shader->frag = frag; return 1; } static void glnvg__deleteShader(GLNVGshader* shader) { if (shader->prog != 0) glDeleteProgram(shader->prog); if (shader->vert != 0) glDeleteShader(shader->vert); if (shader->frag != 0) glDeleteShader(shader->frag); } static void glnvg__getUniforms(GLNVGshader* shader) { shader->loc[GLNVG_LOC_VIEWSIZE] = glGetUniformLocation(shader->prog, "viewSize"); shader->loc[GLNVG_LOC_TEX] = glGetUniformLocation(shader->prog, "tex"); #if NANOVG_GL_USE_UNIFORMBUFFER shader->loc[GLNVG_LOC_FRAG] = glGetUniformBlockIndex(shader->prog, "frag"); #else shader->loc[GLNVG_LOC_FRAG] = glGetUniformLocation(shader->prog, "frag"); #endif } static int glnvg__renderCreate(void* uptr) { GLNVGcontext* gl = (GLNVGcontext*)uptr; int align = 4; // TODO: mediump float may not be enough for GLES2 in iOS. // see the following discussion: https://github.com/memononen/nanovg/issues/46 static const char* shaderHeader = #if defined NANOVG_GL2 "#define NANOVG_GL2 1\n" #elif defined NANOVG_GL3 "#version 150 core\n" "#define NANOVG_GL3 1\n" #elif defined NANOVG_GLES2 "#version 100\n" "#define NANOVG_GL2 1\n" #elif defined NANOVG_GLES3 "#version 300 es\n" "#define NANOVG_GL3 1\n" #endif #if NANOVG_GL_USE_UNIFORMBUFFER "#define USE_UNIFORMBUFFER 1\n" #else "#define UNIFORMARRAY_SIZE 11\n" #endif "\n"; static const char* fillVertShader = "#ifdef NANOVG_GL3\n" " uniform vec2 viewSize;\n" " in vec2 vertex;\n" " in vec2 tcoord;\n" " out vec2 ftcoord;\n" " out vec2 fpos;\n" "#else\n" " uniform vec2 viewSize;\n" " attribute vec2 vertex;\n" " attribute vec2 tcoord;\n" " varying vec2 ftcoord;\n" " varying vec2 fpos;\n" "#endif\n" "void main(void) {\n" " ftcoord = tcoord;\n" " fpos = vertex;\n" " gl_Position = vec4(2.0*vertex.x/viewSize.x - 1.0, 1.0 - 2.0*vertex.y/viewSize.y, 0, 1);\n" "}\n"; static const char* fillFragShader = "#ifdef GL_ES\n" "#if defined(GL_FRAGMENT_PRECISION_HIGH) || defined(NANOVG_GL3)\n" " precision highp float;\n" "#else\n" " precision mediump float;\n" "#endif\n" "#endif\n" "#ifdef NANOVG_GL3\n" "#ifdef USE_UNIFORMBUFFER\n" " layout(std140) uniform frag {\n" " mat3 scissorMat;\n" " mat3 paintMat;\n" " vec4 innerCol;\n" " vec4 outerCol;\n" " vec2 scissorExt;\n" " vec2 scissorScale;\n" " vec2 extent;\n" " float radius;\n" " float feather;\n" " float strokeMult;\n" " float strokeThr;\n" " int texType;\n" " int type;\n" " };\n" "#else\n" // NANOVG_GL3 && !USE_UNIFORMBUFFER " uniform vec4 frag[UNIFORMARRAY_SIZE];\n" "#endif\n" " uniform sampler2D tex;\n" " in vec2 ftcoord;\n" " in vec2 fpos;\n" " out vec4 outColor;\n" "#else\n" // !NANOVG_GL3 " uniform vec4 frag[UNIFORMARRAY_SIZE];\n" " uniform sampler2D tex;\n" " varying vec2 ftcoord;\n" " varying vec2 fpos;\n" "#endif\n" "#ifndef USE_UNIFORMBUFFER\n" " #define scissorMat mat3(frag[0].xyz, frag[1].xyz, frag[2].xyz)\n" " #define paintMat mat3(frag[3].xyz, frag[4].xyz, frag[5].xyz)\n" " #define innerCol frag[6]\n" " #define outerCol frag[7]\n" " #define scissorExt frag[8].xy\n" " #define scissorScale frag[8].zw\n" " #define extent frag[9].xy\n" " #define radius frag[9].z\n" " #define feather frag[9].w\n" " #define strokeMult frag[10].x\n" " #define strokeThr frag[10].y\n" " #define texType int(frag[10].z)\n" " #define type int(frag[10].w)\n" "#endif\n" "\n" "float sdroundrect(vec2 pt, vec2 ext, float rad) {\n" " vec2 ext2 = ext - vec2(rad,rad);\n" " vec2 d = abs(pt) - ext2;\n" " return min(max(d.x,d.y),0.0) + length(max(d,0.0)) - rad;\n" "}\n" "\n" "// Scissoring\n" "float scissorMask(vec2 p) {\n" " vec2 sc = (abs((scissorMat * vec3(p,1.0)).xy) - scissorExt);\n" " sc = vec2(0.5,0.5) - sc * scissorScale;\n" " return clamp(sc.x,0.0,1.0) * clamp(sc.y,0.0,1.0);\n" "}\n" "#ifdef EDGE_AA\n" "// Stroke - from [0..1] to clipped pyramid, where the slope is 1px.\n" "float strokeMask() {\n" " return min(1.0, (1.0-abs(ftcoord.x*2.0-1.0))*strokeMult) * min(1.0, ftcoord.y);\n" "}\n" "#endif\n" "\n" "void main(void) {\n" " vec4 result;\n" " float scissor = scissorMask(fpos);\n" "#ifdef EDGE_AA\n" " float strokeAlpha = strokeMask();\n" "#else\n" " float strokeAlpha = 1.0;\n" "#endif\n" " if (type == 0) { // Gradient\n" " // Calculate gradient color using box gradient\n" " vec2 pt = (paintMat * vec3(fpos,1.0)).xy;\n" " float d = clamp((sdroundrect(pt, extent, radius) + feather*0.5) / feather, 0.0, 1.0);\n" " vec4 color = mix(innerCol,outerCol,d);\n" " // Combine alpha\n" " color *= strokeAlpha * scissor;\n" " result = color;\n" " } else if (type == 1) { // Image\n" " // Calculate color fron texture\n" " vec2 pt = (paintMat * vec3(fpos,1.0)).xy / extent;\n" "#ifdef NANOVG_GL3\n" " vec4 color = texture(tex, pt);\n" "#else\n" " vec4 color = texture2D(tex, pt);\n" "#endif\n" " if (texType == 1) color = vec4(color.xyz*color.w,color.w);" " if (texType == 2) color = vec4(color.x);" " // Apply color tint and alpha.\n" " color *= innerCol;\n" " // Combine alpha\n" " color *= strokeAlpha * scissor;\n" " result = color;\n" " } else if (type == 2) { // Stencil fill\n" " result = vec4(1,1,1,1);\n" " } else if (type == 3) { // Textured tris\n" "#ifdef NANOVG_GL3\n" " vec4 color = texture(tex, ftcoord);\n" "#else\n" " vec4 color = texture2D(tex, ftcoord);\n" "#endif\n" " if (texType == 1) color = vec4(color.xyz*color.w,color.w);" " if (texType == 2) color = vec4(color.x);" " color *= scissor;\n" " result = color * innerCol;\n" " }\n" "#ifdef EDGE_AA\n" " if (strokeAlpha < strokeThr) discard;\n" "#endif\n" "#ifdef NANOVG_GL3\n" " outColor = result;\n" "#else\n" " gl_FragColor = result;\n" "#endif\n" "}\n"; glnvg__checkError(gl, "init"); if (gl->flags & NVG_ANTIALIAS) { if (glnvg__createShader(&gl->shader, "shader", shaderHeader, "#define EDGE_AA 1\n", fillVertShader, fillFragShader) == 0) return 0; } else { if (glnvg__createShader(&gl->shader, "shader", shaderHeader, NULL, fillVertShader, fillFragShader) == 0) return 0; } glnvg__checkError(gl, "uniform locations"); glnvg__getUniforms(&gl->shader); // Create dynamic vertex array #if defined NANOVG_GL3 glGenVertexArrays(1, &gl->vertArr); #endif glGenBuffers(1, &gl->vertBuf); #if NANOVG_GL_USE_UNIFORMBUFFER // Create UBOs glUniformBlockBinding(gl->shader.prog, gl->shader.loc[GLNVG_LOC_FRAG], GLNVG_FRAG_BINDING); glGenBuffers(1, &gl->fragBuf); glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &align); #endif gl->fragSize = sizeof(GLNVGfragUniforms) + align - sizeof(GLNVGfragUniforms) % align; glnvg__checkError(gl, "create done"); glFinish(); return 1; } static int glnvg__renderCreateTexture(void* uptr, int type, int w, int h, int imageFlags, const unsigned char* data) { GLNVGcontext* gl = (GLNVGcontext*)uptr; GLNVGtexture* tex = glnvg__allocTexture(gl); if (tex == NULL) return 0; #ifdef NANOVG_GLES2 // Check for non-power of 2. if (glnvg__nearestPow2(w) != (unsigned int)w || glnvg__nearestPow2(h) != (unsigned int)h) { // No repeat if ((imageFlags & NVG_IMAGE_REPEATX) != 0 || (imageFlags & NVG_IMAGE_REPEATY) != 0) { printf("Repeat X/Y is not supported for non power-of-two textures (%d x %d)\n", w, h); imageFlags &= ~(NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); } // No mips. if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { printf("Mip-maps is not support for non power-of-two textures (%d x %d)\n", w, h); imageFlags &= ~NVG_IMAGE_GENERATE_MIPMAPS; } } #endif glGenTextures(1, &tex->tex); tex->width = w; tex->height = h; tex->type = type; tex->flags = imageFlags; glnvg__bindTexture(gl, tex->tex); glPixelStorei(GL_UNPACK_ALIGNMENT,1); #ifndef NANOVG_GLES2 glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->width); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); #endif #if defined (NANOVG_GL2) // GL 1.4 and later has support for generating mipmaps using a tex parameter. if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); } #endif if (type == NVG_TEXTURE_RGBA) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); else #if defined(NANOVG_GLES2) glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, w, h, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); #elif defined(NANOVG_GLES3) glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data); #else glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data); #endif if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } else { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (imageFlags & NVG_IMAGE_REPEATX) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); if (imageFlags & NVG_IMAGE_REPEATY) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); #ifndef NANOVG_GLES2 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); #endif // The new way to build mipmaps on GLES and GL3 #if !defined(NANOVG_GL2) if (imageFlags & NVG_IMAGE_GENERATE_MIPMAPS) { glGenerateMipmap(GL_TEXTURE_2D); } #endif glnvg__checkError(gl, "create tex"); glnvg__bindTexture(gl, 0); return tex->id; } static int glnvg__renderDeleteTexture(void* uptr, int image) { GLNVGcontext* gl = (GLNVGcontext*)uptr; return glnvg__deleteTexture(gl, image); } static int glnvg__renderUpdateTexture(void* uptr, int image, int x, int y, int w, int h, const unsigned char* data) { GLNVGcontext* gl = (GLNVGcontext*)uptr; GLNVGtexture* tex = glnvg__findTexture(gl, image); if (tex == NULL) return 0; glnvg__bindTexture(gl, tex->tex); glPixelStorei(GL_UNPACK_ALIGNMENT,1); #ifndef NANOVG_GLES2 glPixelStorei(GL_UNPACK_ROW_LENGTH, tex->width); glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); #else // No support for all of skip, need to update a whole row at a time. if (tex->type == NVG_TEXTURE_RGBA) data += y*tex->width*4; else data += y*tex->width; x = 0; w = tex->width; #endif if (tex->type == NVG_TEXTURE_RGBA) glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RGBA, GL_UNSIGNED_BYTE, data); else #ifdef NANOVG_GLES2 glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); #else glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RED, GL_UNSIGNED_BYTE, data); #endif glPixelStorei(GL_UNPACK_ALIGNMENT, 4); #ifndef NANOVG_GLES2 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); #endif glnvg__bindTexture(gl, 0); return 1; } static int glnvg__renderGetTextureSize(void* uptr, int image, int* w, int* h) { GLNVGcontext* gl = (GLNVGcontext*)uptr; GLNVGtexture* tex = glnvg__findTexture(gl, image); if (tex == NULL) return 0; *w = tex->width; *h = tex->height; return 1; } static void glnvg__xformToMat3x4(float* m3, float* t) { m3[0] = t[0]; m3[1] = t[1]; m3[2] = 0.0f; m3[3] = 0.0f; m3[4] = t[2]; m3[5] = t[3]; m3[6] = 0.0f; m3[7] = 0.0f; m3[8] = t[4]; m3[9] = t[5]; m3[10] = 1.0f; m3[11] = 0.0f; } static NVGcolor glnvg__premulColor(NVGcolor c) { c.r *= c.a; c.g *= c.a; c.b *= c.a; return c; } static int glnvg__convertPaint(GLNVGcontext* gl, GLNVGfragUniforms* frag, NVGpaint* paint, NVGscissor* scissor, float width, float fringe, float strokeThr) { GLNVGtexture* tex = NULL; float invxform[6]; memset(frag, 0, sizeof(*frag)); frag->innerCol = glnvg__premulColor(paint->innerColor); frag->outerCol = glnvg__premulColor(paint->outerColor); if (scissor->extent[0] < -0.5f || scissor->extent[1] < -0.5f) { memset(frag->scissorMat, 0, sizeof(frag->scissorMat)); frag->scissorExt[0] = 1.0f; frag->scissorExt[1] = 1.0f; frag->scissorScale[0] = 1.0f; frag->scissorScale[1] = 1.0f; } else { nvgTransformInverse(invxform, scissor->xform); glnvg__xformToMat3x4(frag->scissorMat, invxform); frag->scissorExt[0] = scissor->extent[0]; frag->scissorExt[1] = scissor->extent[1]; frag->scissorScale[0] = sqrtf(scissor->xform[0]*scissor->xform[0] + scissor->xform[2]*scissor->xform[2]) / fringe; frag->scissorScale[1] = sqrtf(scissor->xform[1]*scissor->xform[1] + scissor->xform[3]*scissor->xform[3]) / fringe; } memcpy(frag->extent, paint->extent, sizeof(frag->extent)); frag->strokeMult = (width*0.5f + fringe*0.5f) / fringe; frag->strokeThr = strokeThr; if (paint->image != 0) { tex = glnvg__findTexture(gl, paint->image); if (tex == NULL) return 0; if ((tex->flags & NVG_IMAGE_FLIPY) != 0) { float m1[6], m2[6]; nvgTransformTranslate(m1, 0.0f, frag->extent[1] * 0.5f); nvgTransformMultiply(m1, paint->xform); nvgTransformScale(m2, 1.0f, -1.0f); nvgTransformMultiply(m2, m1); nvgTransformTranslate(m1, 0.0f, -frag->extent[1] * 0.5f); nvgTransformMultiply(m1, m2); nvgTransformInverse(invxform, m1); } else { nvgTransformInverse(invxform, paint->xform); } frag->type = NSVG_SHADER_FILLIMG; if (tex->type == NVG_TEXTURE_RGBA) frag->texType = (tex->flags & NVG_IMAGE_PREMULTIPLIED) ? 0 : 1; else frag->texType = 2; // printf("frag->texType = %d\n", frag->texType); } else { frag->type = NSVG_SHADER_FILLGRAD; frag->radius = paint->radius; frag->feather = paint->feather; nvgTransformInverse(invxform, paint->xform); } glnvg__xformToMat3x4(frag->paintMat, invxform); return 1; } static GLNVGfragUniforms* nvg__fragUniformPtr(GLNVGcontext* gl, int i); static void glnvg__setUniforms(GLNVGcontext* gl, int uniformOffset, int image) { #if NANOVG_GL_USE_UNIFORMBUFFER glBindBufferRange(GL_UNIFORM_BUFFER, GLNVG_FRAG_BINDING, gl->fragBuf, uniformOffset, sizeof(GLNVGfragUniforms)); #else GLNVGfragUniforms* frag = nvg__fragUniformPtr(gl, uniformOffset); glUniform4fv(gl->shader.loc[GLNVG_LOC_FRAG], NANOVG_GL_UNIFORMARRAY_SIZE, &(frag->uniformArray[0][0])); #endif if (image != 0) { GLNVGtexture* tex = glnvg__findTexture(gl, image); glnvg__bindTexture(gl, tex != NULL ? tex->tex : 0); glnvg__checkError(gl, "tex paint tex"); } else { glnvg__bindTexture(gl, 0); } } static void glnvg__renderViewport(void* uptr, int width, int height, float devicePixelRatio) { GLNVGcontext* gl = (GLNVGcontext*)uptr; gl->view[0] = (float)width; gl->view[1] = (float)height; } static void glnvg__fill(GLNVGcontext* gl, GLNVGcall* call) { GLNVGpath* paths = &gl->paths[call->pathOffset]; int i, npaths = call->pathCount; // Draw shapes glEnable(GL_STENCIL_TEST); glnvg__stencilMask(gl, 0xff); glnvg__stencilFunc(gl, GL_ALWAYS, 0, 0xff); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // set bindpoint for solid loc glnvg__setUniforms(gl, call->uniformOffset, 0); glnvg__checkError(gl, "fill simple"); glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR_WRAP); glStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR_WRAP); glDisable(GL_CULL_FACE); for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_FAN, paths[i].fillOffset, paths[i].fillCount); glEnable(GL_CULL_FACE); // Draw anti-aliased pixels glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glnvg__setUniforms(gl, call->uniformOffset + gl->fragSize, call->image); glnvg__checkError(gl, "fill fill"); if (gl->flags & NVG_ANTIALIAS) { glnvg__stencilFunc(gl, GL_EQUAL, 0x00, 0xff); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // Draw fringes for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); } // Draw fill glnvg__stencilFunc(gl, GL_NOTEQUAL, 0x0, 0xff); glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); glDrawArrays(GL_TRIANGLES, call->triangleOffset, call->triangleCount); glDisable(GL_STENCIL_TEST); } static void glnvg__convexFill(GLNVGcontext* gl, GLNVGcall* call) { GLNVGpath* paths = &gl->paths[call->pathOffset]; int i, npaths = call->pathCount; glnvg__setUniforms(gl, call->uniformOffset, call->image); glnvg__checkError(gl, "convex fill"); for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_FAN, paths[i].fillOffset, paths[i].fillCount); if (gl->flags & NVG_ANTIALIAS) { // Draw fringes for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); } } static void glnvg__stroke(GLNVGcontext* gl, GLNVGcall* call) { GLNVGpath* paths = &gl->paths[call->pathOffset]; int npaths = call->pathCount, i; if (gl->flags & NVG_STENCIL_STROKES) { glEnable(GL_STENCIL_TEST); glnvg__stencilMask(gl, 0xff); // Fill the stroke base without overlap glnvg__stencilFunc(gl, GL_EQUAL, 0x0, 0xff); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); glnvg__setUniforms(gl, call->uniformOffset + gl->fragSize, call->image); glnvg__checkError(gl, "stroke fill 0"); for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); // Draw anti-aliased pixels. glnvg__setUniforms(gl, call->uniformOffset, call->image); glnvg__stencilFunc(gl, GL_EQUAL, 0x00, 0xff); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); // Clear stencil buffer. glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glnvg__stencilFunc(gl, GL_ALWAYS, 0x0, 0xff); glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); glnvg__checkError(gl, "stroke fill 1"); for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDisable(GL_STENCIL_TEST); // glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset + gl->fragSize), paint, scissor, strokeWidth, fringe, 1.0f - 0.5f/255.0f); } else { glnvg__setUniforms(gl, call->uniformOffset, call->image); glnvg__checkError(gl, "stroke fill"); // Draw Strokes for (i = 0; i < npaths; i++) glDrawArrays(GL_TRIANGLE_STRIP, paths[i].strokeOffset, paths[i].strokeCount); } } static void glnvg__triangles(GLNVGcontext* gl, GLNVGcall* call) { glnvg__setUniforms(gl, call->uniformOffset, call->image); glnvg__checkError(gl, "triangles fill"); glDrawArrays(GL_TRIANGLES, call->triangleOffset, call->triangleCount); } static void glnvg__renderCancel(void* uptr) { GLNVGcontext* gl = (GLNVGcontext*)uptr; gl->nverts = 0; gl->npaths = 0; gl->ncalls = 0; gl->nuniforms = 0; } static GLenum glnvg_convertBlendFuncFactor(int factor) { if (factor == NVG_ZERO) return GL_ZERO; if (factor == NVG_ONE) return GL_ONE; if (factor == NVG_SRC_COLOR) return GL_SRC_COLOR; if (factor == NVG_ONE_MINUS_SRC_COLOR) return GL_ONE_MINUS_SRC_COLOR; if (factor == NVG_DST_COLOR) return GL_DST_COLOR; if (factor == NVG_ONE_MINUS_DST_COLOR) return GL_ONE_MINUS_DST_COLOR; if (factor == NVG_SRC_ALPHA) return GL_SRC_ALPHA; if (factor == NVG_ONE_MINUS_SRC_ALPHA) return GL_ONE_MINUS_SRC_ALPHA; if (factor == NVG_DST_ALPHA) return GL_DST_ALPHA; if (factor == NVG_ONE_MINUS_DST_ALPHA) return GL_ONE_MINUS_DST_ALPHA; if (factor == NVG_SRC_ALPHA_SATURATE) return GL_SRC_ALPHA_SATURATE; return GL_INVALID_ENUM; } static void glnvg__blendCompositeOperation(NVGcompositeOperationState op) { GLenum srcRGB = glnvg_convertBlendFuncFactor(op.srcRGB); GLenum dstRGB = glnvg_convertBlendFuncFactor(op.dstRGB); GLenum srcAlpha = glnvg_convertBlendFuncFactor(op.srcAlpha); GLenum dstAlpha = glnvg_convertBlendFuncFactor(op.dstAlpha); if (srcRGB == GL_INVALID_ENUM || dstRGB == GL_INVALID_ENUM || srcAlpha == GL_INVALID_ENUM || dstAlpha == GL_INVALID_ENUM) glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); else glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); } static void glnvg__renderFlush(void* uptr, NVGcompositeOperationState compositeOperation) { GLNVGcontext* gl = (GLNVGcontext*)uptr; int i; if (gl->ncalls > 0) { // Setup require GL state. glUseProgram(gl->shader.prog); glnvg__blendCompositeOperation(compositeOperation); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CCW); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilMask(0xffffffff); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_ALWAYS, 0, 0xffffffff); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); #if NANOVG_GL_USE_STATE_FILTER gl->boundTexture = 0; gl->stencilMask = 0xffffffff; gl->stencilFunc = GL_ALWAYS; gl->stencilFuncRef = 0; gl->stencilFuncMask = 0xffffffff; #endif #if NANOVG_GL_USE_UNIFORMBUFFER // Upload ubo for frag shaders glBindBuffer(GL_UNIFORM_BUFFER, gl->fragBuf); glBufferData(GL_UNIFORM_BUFFER, gl->nuniforms * gl->fragSize, gl->uniforms, GL_STREAM_DRAW); #endif // Upload vertex data #if defined NANOVG_GL3 glBindVertexArray(gl->vertArr); #endif glBindBuffer(GL_ARRAY_BUFFER, gl->vertBuf); glBufferData(GL_ARRAY_BUFFER, gl->nverts * sizeof(NVGvertex), gl->verts, GL_STREAM_DRAW); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(NVGvertex), (const GLvoid*)(size_t)0); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(NVGvertex), (const GLvoid*)(0 + 2*sizeof(float))); // Set view and texture just once per frame. glUniform1i(gl->shader.loc[GLNVG_LOC_TEX], 0); glUniform2fv(gl->shader.loc[GLNVG_LOC_VIEWSIZE], 1, gl->view); #if NANOVG_GL_USE_UNIFORMBUFFER glBindBuffer(GL_UNIFORM_BUFFER, gl->fragBuf); #endif for (i = 0; i < gl->ncalls; i++) { GLNVGcall* call = &gl->calls[i]; if (call->type == GLNVG_FILL) glnvg__fill(gl, call); else if (call->type == GLNVG_CONVEXFILL) glnvg__convexFill(gl, call); else if (call->type == GLNVG_STROKE) glnvg__stroke(gl, call); else if (call->type == GLNVG_TRIANGLES) glnvg__triangles(gl, call); } glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); #if defined NANOVG_GL3 glBindVertexArray(0); #endif glDisable(GL_CULL_FACE); glBindBuffer(GL_ARRAY_BUFFER, 0); glUseProgram(0); glnvg__bindTexture(gl, 0); } // Reset calls gl->nverts = 0; gl->npaths = 0; gl->ncalls = 0; gl->nuniforms = 0; } static int glnvg__maxVertCount(const NVGpath* paths, int npaths) { int i, count = 0; for (i = 0; i < npaths; i++) { count += paths[i].nfill; count += paths[i].nstroke; } return count; } static GLNVGcall* glnvg__allocCall(GLNVGcontext* gl) { GLNVGcall* ret = NULL; if (gl->ncalls+1 > gl->ccalls) { GLNVGcall* calls; int ccalls = glnvg__maxi(gl->ncalls+1, 128) + gl->ccalls/2; // 1.5x Overallocate calls = (GLNVGcall*)realloc(gl->calls, sizeof(GLNVGcall) * ccalls); if (calls == NULL) return NULL; gl->calls = calls; gl->ccalls = ccalls; } ret = &gl->calls[gl->ncalls++]; memset(ret, 0, sizeof(GLNVGcall)); return ret; } static int glnvg__allocPaths(GLNVGcontext* gl, int n) { int ret = 0; if (gl->npaths+n > gl->cpaths) { GLNVGpath* paths; int cpaths = glnvg__maxi(gl->npaths + n, 128) + gl->cpaths/2; // 1.5x Overallocate paths = (GLNVGpath*)realloc(gl->paths, sizeof(GLNVGpath) * cpaths); if (paths == NULL) return -1; gl->paths = paths; gl->cpaths = cpaths; } ret = gl->npaths; gl->npaths += n; return ret; } static int glnvg__allocVerts(GLNVGcontext* gl, int n) { int ret = 0; if (gl->nverts+n > gl->cverts) { NVGvertex* verts; int cverts = glnvg__maxi(gl->nverts + n, 4096) + gl->cverts/2; // 1.5x Overallocate verts = (NVGvertex*)realloc(gl->verts, sizeof(NVGvertex) * cverts); if (verts == NULL) return -1; gl->verts = verts; gl->cverts = cverts; } ret = gl->nverts; gl->nverts += n; return ret; } static int glnvg__allocFragUniforms(GLNVGcontext* gl, int n) { int ret = 0, structSize = gl->fragSize; if (gl->nuniforms+n > gl->cuniforms) { unsigned char* uniforms; int cuniforms = glnvg__maxi(gl->nuniforms+n, 128) + gl->cuniforms/2; // 1.5x Overallocate uniforms = (unsigned char*)realloc(gl->uniforms, structSize * cuniforms); if (uniforms == NULL) return -1; gl->uniforms = uniforms; gl->cuniforms = cuniforms; } ret = gl->nuniforms * structSize; gl->nuniforms += n; return ret; } static GLNVGfragUniforms* nvg__fragUniformPtr(GLNVGcontext* gl, int i) { return (GLNVGfragUniforms*)&gl->uniforms[i]; } static void glnvg__vset(NVGvertex* vtx, float x, float y, float u, float v) { vtx->x = x; vtx->y = y; vtx->u = u; vtx->v = v; } static void glnvg__renderFill(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, const float* bounds, const NVGpath* paths, int npaths) { GLNVGcontext* gl = (GLNVGcontext*)uptr; GLNVGcall* call = glnvg__allocCall(gl); NVGvertex* quad; GLNVGfragUniforms* frag; int i, maxverts, offset; if (call == NULL) return; call->type = GLNVG_FILL; call->pathOffset = glnvg__allocPaths(gl, npaths); if (call->pathOffset == -1) goto error; call->pathCount = npaths; call->image = paint->image; if (npaths == 1 && paths[0].convex) call->type = GLNVG_CONVEXFILL; // Allocate vertices for all the paths. maxverts = glnvg__maxVertCount(paths, npaths) + 6; offset = glnvg__allocVerts(gl, maxverts); if (offset == -1) goto error; for (i = 0; i < npaths; i++) { GLNVGpath* copy = &gl->paths[call->pathOffset + i]; const NVGpath* path = &paths[i]; memset(copy, 0, sizeof(GLNVGpath)); if (path->nfill > 0) { copy->fillOffset = offset; copy->fillCount = path->nfill; memcpy(&gl->verts[offset], path->fill, sizeof(NVGvertex) * path->nfill); offset += path->nfill; } if (path->nstroke > 0) { copy->strokeOffset = offset; copy->strokeCount = path->nstroke; memcpy(&gl->verts[offset], path->stroke, sizeof(NVGvertex) * path->nstroke); offset += path->nstroke; } } // Quad call->triangleOffset = offset; call->triangleCount = 6; quad = &gl->verts[call->triangleOffset]; glnvg__vset(&quad[0], bounds[0], bounds[3], 0.5f, 1.0f); glnvg__vset(&quad[1], bounds[2], bounds[3], 0.5f, 1.0f); glnvg__vset(&quad[2], bounds[2], bounds[1], 0.5f, 1.0f); glnvg__vset(&quad[3], bounds[0], bounds[3], 0.5f, 1.0f); glnvg__vset(&quad[4], bounds[2], bounds[1], 0.5f, 1.0f); glnvg__vset(&quad[5], bounds[0], bounds[1], 0.5f, 1.0f); // Setup uniforms for draw calls if (call->type == GLNVG_FILL) { call->uniformOffset = glnvg__allocFragUniforms(gl, 2); if (call->uniformOffset == -1) goto error; // Simple shader for stencil frag = nvg__fragUniformPtr(gl, call->uniformOffset); memset(frag, 0, sizeof(*frag)); frag->strokeThr = -1.0f; frag->type = NSVG_SHADER_SIMPLE; // Fill shader glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset + gl->fragSize), paint, scissor, fringe, fringe, -1.0f); } else { call->uniformOffset = glnvg__allocFragUniforms(gl, 1); if (call->uniformOffset == -1) goto error; // Fill shader glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset), paint, scissor, fringe, fringe, -1.0f); } return; error: // We get here if call alloc was ok, but something else is not. // Roll back the last call to prevent drawing it. if (gl->ncalls > 0) gl->ncalls--; } static void glnvg__renderStroke(void* uptr, NVGpaint* paint, NVGscissor* scissor, float fringe, float strokeWidth, const NVGpath* paths, int npaths) { GLNVGcontext* gl = (GLNVGcontext*)uptr; GLNVGcall* call = glnvg__allocCall(gl); int i, maxverts, offset; if (call == NULL) return; call->type = GLNVG_STROKE; call->pathOffset = glnvg__allocPaths(gl, npaths); if (call->pathOffset == -1) goto error; call->pathCount = npaths; call->image = paint->image; // Allocate vertices for all the paths. maxverts = glnvg__maxVertCount(paths, npaths); offset = glnvg__allocVerts(gl, maxverts); if (offset == -1) goto error; for (i = 0; i < npaths; i++) { GLNVGpath* copy = &gl->paths[call->pathOffset + i]; const NVGpath* path = &paths[i]; memset(copy, 0, sizeof(GLNVGpath)); if (path->nstroke) { copy->strokeOffset = offset; copy->strokeCount = path->nstroke; memcpy(&gl->verts[offset], path->stroke, sizeof(NVGvertex) * path->nstroke); offset += path->nstroke; } } if (gl->flags & NVG_STENCIL_STROKES) { // Fill shader call->uniformOffset = glnvg__allocFragUniforms(gl, 2); if (call->uniformOffset == -1) goto error; glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset), paint, scissor, strokeWidth, fringe, -1.0f); glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset + gl->fragSize), paint, scissor, strokeWidth, fringe, 1.0f - 0.5f/255.0f); } else { // Fill shader call->uniformOffset = glnvg__allocFragUniforms(gl, 1); if (call->uniformOffset == -1) goto error; glnvg__convertPaint(gl, nvg__fragUniformPtr(gl, call->uniformOffset), paint, scissor, strokeWidth, fringe, -1.0f); } return; error: // We get here if call alloc was ok, but something else is not. // Roll back the last call to prevent drawing it. if (gl->ncalls > 0) gl->ncalls--; } static void glnvg__renderTriangles(void* uptr, NVGpaint* paint, NVGscissor* scissor, const NVGvertex* verts, int nverts) { GLNVGcontext* gl = (GLNVGcontext*)uptr; GLNVGcall* call = glnvg__allocCall(gl); GLNVGfragUniforms* frag; if (call == NULL) return; call->type = GLNVG_TRIANGLES; call->image = paint->image; // Allocate vertices for all the paths. call->triangleOffset = glnvg__allocVerts(gl, nverts); if (call->triangleOffset == -1) goto error; call->triangleCount = nverts; memcpy(&gl->verts[call->triangleOffset], verts, sizeof(NVGvertex) * nverts); // Fill shader call->uniformOffset = glnvg__allocFragUniforms(gl, 1); if (call->uniformOffset == -1) goto error; frag = nvg__fragUniformPtr(gl, call->uniformOffset); glnvg__convertPaint(gl, frag, paint, scissor, 1.0f, 1.0f, -1.0f); frag->type = NSVG_SHADER_IMG; return; error: // We get here if call alloc was ok, but something else is not. // Roll back the last call to prevent drawing it. if (gl->ncalls > 0) gl->ncalls--; } static void glnvg__renderDelete(void* uptr) { GLNVGcontext* gl = (GLNVGcontext*)uptr; int i; if (gl == NULL) return; glnvg__deleteShader(&gl->shader); #if NANOVG_GL3 #if NANOVG_GL_USE_UNIFORMBUFFER if (gl->fragBuf != 0) glDeleteBuffers(1, &gl->fragBuf); #endif if (gl->vertArr != 0) glDeleteVertexArrays(1, &gl->vertArr); #endif if (gl->vertBuf != 0) glDeleteBuffers(1, &gl->vertBuf); for (i = 0; i < gl->ntextures; i++) { if (gl->textures[i].tex != 0 && (gl->textures[i].flags & NVG_IMAGE_NODELETE) == 0) glDeleteTextures(1, &gl->textures[i].tex); } free(gl->textures); free(gl->paths); free(gl->verts); free(gl->uniforms); free(gl->calls); free(gl); } #if defined NANOVG_GL2 NVGcontext* nvgCreateGL2(int flags) #elif defined NANOVG_GL3 NVGcontext* nvgCreateGL3(int flags) #elif defined NANOVG_GLES2 NVGcontext* nvgCreateGLES2(int flags) #elif defined NANOVG_GLES3 NVGcontext* nvgCreateGLES3(int flags) #endif { NVGparams params; NVGcontext* ctx = NULL; GLNVGcontext* gl = (GLNVGcontext*)malloc(sizeof(GLNVGcontext)); if (gl == NULL) goto error; memset(gl, 0, sizeof(GLNVGcontext)); memset(¶ms, 0, sizeof(params)); params.renderCreate = glnvg__renderCreate; params.renderCreateTexture = glnvg__renderCreateTexture; params.renderDeleteTexture = glnvg__renderDeleteTexture; params.renderUpdateTexture = glnvg__renderUpdateTexture; params.renderGetTextureSize = glnvg__renderGetTextureSize; params.renderViewport = glnvg__renderViewport; params.renderCancel = glnvg__renderCancel; params.renderFlush = glnvg__renderFlush; params.renderFill = glnvg__renderFill; params.renderStroke = glnvg__renderStroke; params.renderTriangles = glnvg__renderTriangles; params.renderDelete = glnvg__renderDelete; params.userPtr = gl; params.edgeAntiAlias = flags & NVG_ANTIALIAS ? 1 : 0; gl->flags = flags; ctx = nvgCreateInternal(¶ms); if (ctx == NULL) goto error; return ctx; error: // 'gl' is freed by nvgDeleteInternal. if (ctx != NULL) nvgDeleteInternal(ctx); return NULL; } #if defined NANOVG_GL2 void nvgDeleteGL2(NVGcontext* ctx) #elif defined NANOVG_GL3 void nvgDeleteGL3(NVGcontext* ctx) #elif defined NANOVG_GLES2 void nvgDeleteGLES2(NVGcontext* ctx) #elif defined NANOVG_GLES3 void nvgDeleteGLES3(NVGcontext* ctx) #endif { nvgDeleteInternal(ctx); } #if defined NANOVG_GL2 int nvglCreateImageFromHandleGL2(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) #elif defined NANOVG_GL3 int nvglCreateImageFromHandleGL3(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) #elif defined NANOVG_GLES2 int nvglCreateImageFromHandleGLES2(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) #elif defined NANOVG_GLES3 int nvglCreateImageFromHandleGLES3(NVGcontext* ctx, GLuint textureId, int w, int h, int imageFlags) #endif { GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(ctx)->userPtr; GLNVGtexture* tex = glnvg__allocTexture(gl); if (tex == NULL) return 0; tex->type = NVG_TEXTURE_RGBA; tex->tex = textureId; tex->flags = imageFlags; tex->width = w; tex->height = h; return tex->id; } #if defined NANOVG_GL2 GLuint nvglImageHandleGL2(NVGcontext* ctx, int image) #elif defined NANOVG_GL3 GLuint nvglImageHandleGL3(NVGcontext* ctx, int image) #elif defined NANOVG_GLES2 GLuint nvglImageHandleGLES2(NVGcontext* ctx, int image) #elif defined NANOVG_GLES3 GLuint nvglImageHandleGLES3(NVGcontext* ctx, int image) #endif { GLNVGcontext* gl = (GLNVGcontext*)nvgInternalParams(ctx)->userPtr; GLNVGtexture* tex = glnvg__findTexture(gl, image); return tex->tex; } #endif /* NANOVG_GL_IMPLEMENTATION */ ================================================ FILE: phonelibs/nanovg/nanovg_gl_utils.h ================================================ // // Copyright (c) 2009-2013 Mikko Mononen memon@inside.org // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. // #ifndef NANOVG_GL_UTILS_H #define NANOVG_GL_UTILS_H struct NVGLUframebuffer { NVGcontext* ctx; GLuint fbo; GLuint rbo; GLuint texture; int image; }; typedef struct NVGLUframebuffer NVGLUframebuffer; // Helper function to create GL frame buffer to render to. void nvgluBindFramebuffer(NVGLUframebuffer* fb); NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags); void nvgluDeleteFramebuffer(NVGLUframebuffer* fb); #endif // NANOVG_GL_UTILS_H #ifdef NANOVG_GL_IMPLEMENTATION #if defined(NANOVG_GL3) || defined(NANOVG_GLES2) || defined(NANOVG_GLES3) // FBO is core in OpenGL 3>. # define NANOVG_FBO_VALID 1 #elif defined(NANOVG_GL2) // On OS X including glext defines FBO on GL2 too. # ifdef __APPLE__ # include # define NANOVG_FBO_VALID 1 # endif #endif static GLint defaultFBO = -1; NVGLUframebuffer* nvgluCreateFramebuffer(NVGcontext* ctx, int w, int h, int imageFlags) { #ifdef NANOVG_FBO_VALID GLint defaultFBO; GLint defaultRBO; NVGLUframebuffer* fb = NULL; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); glGetIntegerv(GL_RENDERBUFFER_BINDING, &defaultRBO); fb = (NVGLUframebuffer*)malloc(sizeof(NVGLUframebuffer)); if (fb == NULL) goto error; memset(fb, 0, sizeof(NVGLUframebuffer)); fb->image = nvgCreateImageRGBA(ctx, w, h, imageFlags | NVG_IMAGE_FLIPY | NVG_IMAGE_PREMULTIPLIED, NULL); #if defined NANOVG_GL2 fb->texture = nvglImageHandleGL2(ctx, fb->image); #elif defined NANOVG_GL3 fb->texture = nvglImageHandleGL3(ctx, fb->image); #elif defined NANOVG_GLES2 fb->texture = nvglImageHandleGLES2(ctx, fb->image); #elif defined NANOVG_GLES3 fb->texture = nvglImageHandleGLES3(ctx, fb->image); #endif fb->ctx = ctx; // frame buffer object glGenFramebuffers(1, &fb->fbo); glBindFramebuffer(GL_FRAMEBUFFER, fb->fbo); // render buffer object glGenRenderbuffers(1, &fb->rbo); glBindRenderbuffer(GL_RENDERBUFFER, fb->rbo); glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, w, h); // combine all glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb->texture, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fb->rbo); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) goto error; glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO); return fb; error: glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); glBindRenderbuffer(GL_RENDERBUFFER, defaultRBO); nvgluDeleteFramebuffer(fb); return NULL; #else NVG_NOTUSED(ctx); NVG_NOTUSED(w); NVG_NOTUSED(h); NVG_NOTUSED(imageFlags); return NULL; #endif } void nvgluBindFramebuffer(NVGLUframebuffer* fb) { #ifdef NANOVG_FBO_VALID if (defaultFBO == -1) glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); glBindFramebuffer(GL_FRAMEBUFFER, fb != NULL ? fb->fbo : defaultFBO); #else NVG_NOTUSED(fb); #endif } void nvgluDeleteFramebuffer(NVGLUframebuffer* fb) { #ifdef NANOVG_FBO_VALID if (fb == NULL) return; if (fb->fbo != 0) glDeleteFramebuffers(1, &fb->fbo); if (fb->rbo != 0) glDeleteRenderbuffers(1, &fb->rbo); if (fb->image >= 0) nvgDeleteImage(fb->ctx, fb->image); fb->ctx = NULL; fb->fbo = 0; fb->rbo = 0; fb->texture = 0; fb->image = -1; free(fb); #else NVG_NOTUSED(fb); #endif } #endif // NANOVG_GL_IMPLEMENTATION ================================================ FILE: phonelibs/nanovg/stb_image.h ================================================ /* stb_image - v2.10 - public domain image loader - http://nothings.org/stb_image.h no warranty implied; use at your own risk Do this: #define STB_IMAGE_IMPLEMENTATION before you include this file in *one* C or C++ file to create the implementation. // i.e. it should look like this: #include ... #include ... #include ... #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free QUICK NOTES: Primarily of interest to game developers and other people who can avoid problematic images and only need the trivial interface JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) PNG 1/2/4/8-bit-per-channel (16 bpc not supported) TGA (not sure what subset, if a subset) BMP non-1bpp, non-RLE PSD (composited view only, no extra channels, 8/16 bit-per-channel) GIF (*comp always reports as 4-channel) HDR (radiance rgbE format) PIC (Softimage PIC) PNM (PPM and PGM binary only) Animated GIF still needs a proper API, but here's one way to do it: http://gist.github.com/urraka/685d9a6340b26b830d49 - decode from memory or through FILE (define STBI_NO_STDIO to remove code) - decode from arbitrary I/O callbacks - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) Full documentation under "DOCUMENTATION" below. Revision 2.00 release notes: - Progressive JPEG is now supported. - PPM and PGM binary formats are now supported, thanks to Ken Miller. - x86 platforms now make use of SSE2 SIMD instructions for JPEG decoding, and ARM platforms can use NEON SIMD if requested. This work was done by Fabian "ryg" Giesen. SSE2 is used by default, but NEON must be enabled explicitly; see docs. With other JPEG optimizations included in this version, we see 2x speedup on a JPEG on an x86 machine, and a 1.5x speedup on a JPEG on an ARM machine, relative to previous versions of this library. The same results will not obtain for all JPGs and for all x86/ARM machines. (Note that progressive JPEGs are significantly slower to decode than regular JPEGs.) This doesn't mean that this is the fastest JPEG decoder in the land; rather, it brings it closer to parity with standard libraries. If you want the fastest decode, look elsewhere. (See "Philosophy" section of docs below.) See final bullet items below for more info on SIMD. - Added STBI_MALLOC, STBI_REALLOC, and STBI_FREE macros for replacing the memory allocator. Unlike other STBI libraries, these macros don't support a context parameter, so if you need to pass a context in to the allocator, you'll have to store it in a global or a thread-local variable. - Split existing STBI_NO_HDR flag into two flags, STBI_NO_HDR and STBI_NO_LINEAR. STBI_NO_HDR: suppress implementation of .hdr reader format STBI_NO_LINEAR: suppress high-dynamic-range light-linear float API - You can suppress implementation of any of the decoders to reduce your code footprint by #defining one or more of the following symbols before creating the implementation. STBI_NO_JPEG STBI_NO_PNG STBI_NO_BMP STBI_NO_PSD STBI_NO_TGA STBI_NO_GIF STBI_NO_HDR STBI_NO_PIC STBI_NO_PNM (.ppm and .pgm) - You can request *only* certain decoders and suppress all other ones (this will be more forward-compatible, as addition of new decoders doesn't require you to disable them explicitly): STBI_ONLY_JPEG STBI_ONLY_PNG STBI_ONLY_BMP STBI_ONLY_PSD STBI_ONLY_TGA STBI_ONLY_GIF STBI_ONLY_HDR STBI_ONLY_PIC STBI_ONLY_PNM (.ppm and .pgm) Note that you can define multiples of these, and you will get all of them ("only x" and "only y" is interpreted to mean "only x&y"). - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB - Compilation of all SIMD code can be suppressed with #define STBI_NO_SIMD It should not be necessary to disable SIMD unless you have issues compiling (e.g. using an x86 compiler which doesn't support SSE intrinsics or that doesn't support the method used to detect SSE2 support at run-time), and even those can be reported as bugs so I can refine the built-in compile-time checking to be smarter. - The old STBI_SIMD system which allowed installing a user-defined IDCT etc. has been removed. If you need this, don't upgrade. My assumption is that almost nobody was doing this, and those who were will find the built-in SIMD more satisfactory anyway. - RGB values computed for JPEG images are slightly different from previous versions of stb_image. (This is due to using less integer precision in SIMD.) The C code has been adjusted so that the same RGB values will be computed regardless of whether SIMD support is available, so your app should always produce consistent results. But these results are slightly different from previous versions. (Specifically, about 3% of available YCbCr values will compute different RGB results from pre-1.49 versions by +-1; most of the deviating values are one smaller in the G channel.) - If you must produce consistent results with previous versions of stb_image, #define STBI_JPEG_OLD and you will get the same results you used to; however, you will not get the SIMD speedups for the YCbCr-to-RGB conversion step (although you should still see significant JPEG speedup from the other changes). Please note that STBI_JPEG_OLD is a temporary feature; it will be removed in future versions of the library. It is only intended for near-term back-compatibility use. Latest revision history: 2.10 (2016-01-22) avoid warning introduced in 2.09 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) partial animated GIF support limited 16-bit PSD support minor bugs, code cleanup, and compiler warnings 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) additional corruption checking stbi_set_flip_vertically_on_load fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPEG, including x86 SSE2 & ARM NEON SIMD progressive JPEG PGM/PPM support STBI_MALLOC,STBI_REALLOC,STBI_FREE STBI_NO_*, STBI_ONLY_* GIF bugfix 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support (both grayscale and paletted) optimize PNG fix bug in interlaced PNG with user-specified channel count See end of file for full revision history. ============================ Contributors ========================= Image formats Extensions, features Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) urraka@github (animated gif) Junggon Kim (PNM comments) Daniel Gibson (16-bit TGA) Optimizations & bugfixes Fabian "ryg" Giesen Arseny Kapoulkine Bug & warning fixes Marc LeBlanc David Woo Guillaume George Martins Mozeiko Christpher Lloyd Martin Golini Jerry Jansson Joseph Thomson Dave Moore Roy Eltham Hayaki Saito Phil Jordan Won Chun Luke Graham Johan Duparc Nathan Reed the Horde3D community Thomas Ruf Ronny Chevalier Nick Verigakis Janez Zemva John Bartholomew Michal Cichon svdijk@github Jonathan Blow Ken Hamada Tero Hanninen Baldur Karlsson Laurent Gomila Cort Stratton Sergio Gonzalez romigrou@github Aruelien Pocheville Thibault Reuille Cass Everitt Ryamond Barbiero Paul Du Bois Engin Manap Blazej Dariusz Roszkowski Michaelangel007@github LICENSE This software is in the public domain. Where that dedication is not recognized, you are granted a perpetual, irrevocable license to copy, distribute, and modify this file as you see fit. */ #ifndef STBI_INCLUDE_STB_IMAGE_H #define STBI_INCLUDE_STB_IMAGE_H // DOCUMENTATION // // Limitations: // - no 16-bit-per-channel PNG // - no 12-bit-per-channel JPEG // - no JPEGs with arithmetic coding // - no 1-bit BMP // - GIF always returns *comp=4 // // Basic usage (see HDR discussion below for HDR usage): // int x,y,n; // unsigned char *data = stbi_load(filename, &x, &y, &n, 0); // // ... process data if not NULL ... // // ... x = width, y = height, n = # 8-bit components per pixel ... // // ... replace '0' with '1'..'4' to force that many components per pixel // // ... but 'n' will always be the number that it would have been if you said 0 // stbi_image_free(data) // // Standard parameters: // int *x -- outputs image width in pixels // int *y -- outputs image height in pixels // int *comp -- outputs # of image components in image file // int req_comp -- if non-zero, # of image components requested in result // // The return value from an image loader is an 'unsigned char *' which points // to the pixel data, or NULL on an allocation failure or if the image is // corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, // with each pixel consisting of N interleaved 8-bit components; the first // pixel pointed to is top-left-most in the image. There is no padding between // image scanlines or between pixels, regardless of format. The number of // components N is 'req_comp' if req_comp is non-zero, or *comp otherwise. // If req_comp is non-zero, *comp has the number of components that _would_ // have been output otherwise. E.g. if you set req_comp to 4, you will always // get RGBA output, but you can check *comp to see if it's trivially opaque // because e.g. there were only 3 channels in the source image. // // An output image with N components has the following components interleaved // in this order in each pixel: // // N=#comp components // 1 grey // 2 grey, alpha // 3 red, green, blue // 4 red, green, blue, alpha // // If image loading fails for any reason, the return value will be NULL, // and *x, *y, *comp will be unchanged. The function stbi_failure_reason() // can be queried for an extremely brief, end-user unfriendly explanation // of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid // compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly // more user-friendly ones. // // Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. // // =========================================================================== // // Philosophy // // stb libraries are designed with the following priorities: // // 1. easy to use // 2. easy to maintain // 3. good performance // // Sometimes I let "good performance" creep up in priority over "easy to maintain", // and for best performance I may provide less-easy-to-use APIs that give higher // performance, in addition to the easy to use ones. Nevertheless, it's important // to keep in mind that from the standpoint of you, a client of this library, // all you care about is #1 and #3, and stb libraries do not emphasize #3 above all. // // Some secondary priorities arise directly from the first two, some of which // make more explicit reasons why performance can't be emphasized. // // - Portable ("ease of use") // - Small footprint ("easy to maintain") // - No dependencies ("ease of use") // // =========================================================================== // // I/O callbacks // // I/O callbacks allow you to read from arbitrary sources, like packaged // files or some other source. Data read from callbacks are processed // through a small internal buffer (currently 128 bytes) to try to reduce // overhead. // // The three functions you must define are "read" (reads some bytes of data), // "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). // // =========================================================================== // // SIMD support // // The JPEG decoder will try to automatically use SIMD kernels on x86 when // supported by the compiler. For ARM Neon support, you must explicitly // request it. // // (The old do-it-yourself SIMD API is no longer supported in the current // code.) // // On x86, SSE2 will automatically be used when available based on a run-time // test; if not, the generic C versions are used as a fall-back. On ARM targets, // the typical path is to have separate builds for NEON and non-NEON devices // (at least this is true for iOS and Android). Therefore, the NEON support is // toggled by a build flag: define STBI_NEON to get NEON loops. // // The output of the JPEG decoder is slightly different from versions where // SIMD support was introduced (that is, for versions before 1.49). The // difference is only +-1 in the 8-bit RGB channels, and only on a small // fraction of pixels. You can force the pre-1.49 behavior by defining // STBI_JPEG_OLD, but this will disable some of the SIMD decoding path // and hence cost some performance. // // If for some reason you do not want to use any of SIMD code, or if // you have issues compiling it, you can disable it entirely by // defining STBI_NO_SIMD. // // =========================================================================== // // HDR image support (disable by defining STBI_NO_HDR) // // stb_image now supports loading HDR images in general, and currently // the Radiance .HDR file format, although the support is provided // generically. You can still load any file through the existing interface; // if you attempt to load an HDR file, it will be automatically remapped to // LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; // both of these constants can be reconfigured through this interface: // // stbi_hdr_to_ldr_gamma(2.2f); // stbi_hdr_to_ldr_scale(1.0f); // // (note, do not use _inverse_ constants; stbi_image will invert them // appropriately). // // Additionally, there is a new, parallel interface for loading files as // (linear) floats to preserve the full dynamic range: // // float *data = stbi_loadf(filename, &x, &y, &n, 0); // // If you load LDR images through this interface, those images will // be promoted to floating point values, run through the inverse of // constants corresponding to the above: // // stbi_ldr_to_hdr_scale(1.0f); // stbi_ldr_to_hdr_gamma(2.2f); // // Finally, given a filename (or an open file or memory block--see header // file for details) containing image data, you can query for the "most // appropriate" interface to use (that is, whether the image is HDR or // not), using: // // stbi_is_hdr(char *filename); // // =========================================================================== // // iPhone PNG support: // // By default we convert iphone-formatted PNGs back to RGB, even though // they are internally encoded differently. You can disable this conversion // by by calling stbi_convert_iphone_png_to_rgb(0), in which case // you will always just get the native iphone "format" through (which // is BGR stored in RGB). // // Call stbi_set_unpremultiply_on_load(1) as well to force a divide per // pixel to remove any premultiplied alpha *only* if the image file explicitly // says there's premultiplied data (currently only happens in iPhone images, // and only if iPhone convert-to-rgb processing is on). // #ifndef STBI_NO_STDIO #include #endif // STBI_NO_STDIO #define STBI_VERSION 1 enum { STBI_default = 0, // only used for req_comp STBI_grey = 1, STBI_grey_alpha = 2, STBI_rgb = 3, STBI_rgb_alpha = 4 }; typedef unsigned char stbi_uc; #ifdef __cplusplus extern "C" { #endif #ifdef STB_IMAGE_STATIC #define STBIDEF static #else #define STBIDEF extern #endif ////////////////////////////////////////////////////////////////////////////// // // PRIMARY API - works on images of any type // // // load image by filename, open file, or memory buffer // typedef struct { int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative int (*eof) (void *user); // returns nonzero if we are at end of file/data } stbi_io_callbacks; STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *comp, int req_comp); STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *comp, int req_comp); STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *comp, int req_comp); #ifndef STBI_NO_STDIO STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); // for stbi_load_from_file, file pointer is left pointing immediately after image #endif #ifndef STBI_NO_LINEAR STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *comp, int req_comp); STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp); STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp); #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *comp, int req_comp); #endif #endif #ifndef STBI_NO_HDR STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); STBIDEF void stbi_hdr_to_ldr_scale(float scale); #endif // STBI_NO_HDR #ifndef STBI_NO_LINEAR STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); STBIDEF void stbi_ldr_to_hdr_scale(float scale); #endif // STBI_NO_LINEAR // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename); STBIDEF int stbi_is_hdr_from_file(FILE *f); #endif // STBI_NO_STDIO // get a VERY brief reason for failure // NOT THREADSAFE STBIDEF const char *stbi_failure_reason (void); // free the loaded image -- this is just free() STBIDEF void stbi_image_free (void *retval_from_stbi_load); // get image dimensions & components without fully decoding STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); #ifndef STBI_NO_STDIO STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); #endif // for image formats that explicitly notate that they have premultiplied alpha, // we just return the colors as stored in the file. set this flag to force // unpremultiplication. results are undefined if the unpremultiply overflow. STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); // indicate whether we should process iphone images back to canonical format, // or just pass them through "as-is" STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); // flip the image vertically, so the first pixel in the output array is the bottom left STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); // ZLIB client - used by PNG, available for other purposes STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); #ifdef __cplusplus } #endif // // //// end header file ///////////////////////////////////////////////////// #endif // STBI_INCLUDE_STB_IMAGE_H #ifdef STB_IMAGE_IMPLEMENTATION #if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ || defined(STBI_ONLY_ZLIB) #ifndef STBI_ONLY_JPEG #define STBI_NO_JPEG #endif #ifndef STBI_ONLY_PNG #define STBI_NO_PNG #endif #ifndef STBI_ONLY_BMP #define STBI_NO_BMP #endif #ifndef STBI_ONLY_PSD #define STBI_NO_PSD #endif #ifndef STBI_ONLY_TGA #define STBI_NO_TGA #endif #ifndef STBI_ONLY_GIF #define STBI_NO_GIF #endif #ifndef STBI_ONLY_HDR #define STBI_NO_HDR #endif #ifndef STBI_ONLY_PIC #define STBI_NO_PIC #endif #ifndef STBI_ONLY_PNM #define STBI_NO_PNM #endif #endif #if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) #define STBI_NO_ZLIB #endif #include #include // ptrdiff_t on osx #include #include #if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) #include // ldexp #endif #ifndef STBI_NO_STDIO #include #endif #ifndef STBI_ASSERT #include #define STBI_ASSERT(x) assert(x) #endif #ifndef _MSC_VER #ifdef __cplusplus #define stbi_inline inline #else #define stbi_inline #endif #else #define stbi_inline __forceinline #endif #ifdef _MSC_VER typedef unsigned short stbi__uint16; typedef signed short stbi__int16; typedef unsigned int stbi__uint32; typedef signed int stbi__int32; #else #include typedef uint16_t stbi__uint16; typedef int16_t stbi__int16; typedef uint32_t stbi__uint32; typedef int32_t stbi__int32; #endif // should produce compiler error if size is wrong typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; #ifdef _MSC_VER #define STBI_NOTUSED(v) (void)(v) #else #define STBI_NOTUSED(v) (void)sizeof(v) #endif #ifdef _MSC_VER #define STBI_HAS_LROTL #endif #ifdef STBI_HAS_LROTL #define stbi_lrot(x,y) _lrotl(x,y) #else #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif #if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) // ok #elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) // ok #else #error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." #endif #ifndef STBI_MALLOC #define STBI_MALLOC(sz) malloc(sz) #define STBI_REALLOC(p,newsz) realloc(p,newsz) #define STBI_FREE(p) free(p) #endif #ifndef STBI_REALLOC_SIZED #define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) #endif // x86/x64 detection #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) #define STBI__X86_TARGET #endif #if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) // NOTE: not clear do we actually need this for the 64-bit path? // gcc doesn't support sse2 intrinsics unless you compile with -msse2, // (but compiling with -msse2 allows the compiler to use SSE2 everywhere; // this is just broken and gcc are jerks for not fixing it properly // http://www.virtualdub.org/blog/pivot/entry.php?id=363 ) #define STBI_NO_SIMD #endif #if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) // Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET // // 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the // Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. // As a result, enabling SSE2 on 32-bit MinGW is dangerous when not // simultaneously enabling "-mstackrealign". // // See https://github.com/nothings/stb/issues/81 for more information. // // So default to no SSE2 on 32-bit MinGW. If you've read this far and added // -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. #define STBI_NO_SIMD #endif #if !defined(STBI_NO_SIMD) && defined(STBI__X86_TARGET) #define STBI_SSE2 #include #ifdef _MSC_VER #if _MSC_VER >= 1400 // not VC6 #include // __cpuid static int stbi__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else static int stbi__cpuid3(void) { int res; __asm { mov eax,1 cpuid mov res,edx } return res; } #endif #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name static int stbi__sse2_available() { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; } #else // assume GCC-style if not VC++ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) static int stbi__sse2_available() { #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later // GCC 4.8+ has a nice way to do this return __builtin_cpu_supports("sse2"); #else // portable way to do this, preferably without using GCC inline ASM? // just bail for now. return 0; #endif } #endif #endif // ARM NEON #if defined(STBI_NO_SIMD) && defined(STBI_NEON) #undef STBI_NEON #endif #ifdef STBI_NEON #include // assume GCC or Clang on ARM targets #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif #ifndef STBI_SIMD_ALIGN #define STBI_SIMD_ALIGN(type, name) type name #endif /////////////////////////////////////////////// // // stbi__context struct and start_xxx functions // stbi__context structure is our basic context used by all images, so it // contains all the IO context, plus some basic image information typedef struct { stbi__uint32 img_x, img_y; int img_n, img_out_n; stbi_io_callbacks io; void *io_user_data; int read_from_callbacks; int buflen; stbi_uc buffer_start[128]; stbi_uc *img_buffer, *img_buffer_end; stbi_uc *img_buffer_original, *img_buffer_original_end; } stbi__context; static void stbi__refill_buffer(stbi__context *s); // initialize a memory-decode context static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; } // initialize a callback-based context static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) { s->io = *c; s->io_user_data = user; s->buflen = sizeof(s->buffer_start); s->read_from_callbacks = 1; s->img_buffer_original = s->buffer_start; stbi__refill_buffer(s); s->img_buffer_original_end = s->img_buffer_end; } #ifndef STBI_NO_STDIO static int stbi__stdio_read(void *user, char *data, int size) { return (int) fread(data,1,size,(FILE*) user); } static void stbi__stdio_skip(void *user, int n) { fseek((FILE*) user, n, SEEK_CUR); } static int stbi__stdio_eof(void *user) { return feof((FILE*) user); } static stbi_io_callbacks stbi__stdio_callbacks = { stbi__stdio_read, stbi__stdio_skip, stbi__stdio_eof, }; static void stbi__start_file(stbi__context *s, FILE *f) { stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); } //static void stop_file(stbi__context *s) { } #endif // !STBI_NO_STDIO static void stbi__rewind(stbi__context *s) { // conceptually rewind SHOULD rewind to the beginning of the stream, // but we just rewind to the beginning of the initial buffer, because // we only use it after doing 'test', which only ever looks at at most 92 bytes s->img_buffer = s->img_buffer_original; s->img_buffer_end = s->img_buffer_original_end; } #ifndef STBI_NO_JPEG static int stbi__jpeg_test(stbi__context *s); static stbi_uc *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNG static int stbi__png_test(stbi__context *s); static stbi_uc *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_BMP static int stbi__bmp_test(stbi__context *s); static stbi_uc *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_TGA static int stbi__tga_test(stbi__context *s); static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s); static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_HDR static int stbi__hdr_test(stbi__context *s); static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PIC static int stbi__pic_test(stbi__context *s); static stbi_uc *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_GIF static int stbi__gif_test(stbi__context *s); static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); #endif #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s); static stbi_uc *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); #endif // this is not threadsafe static const char *stbi__g_failure_reason; STBIDEF const char *stbi_failure_reason(void) { return stbi__g_failure_reason; } static int stbi__err(const char *str) { stbi__g_failure_reason = str; return 0; } static void *stbi__malloc(size_t size) { return STBI_MALLOC(size); } // stbi__err - error // stbi__errpf - error returning pointer to float // stbi__errpuc - error returning pointer to unsigned char #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) #define stbi__err(x,y) stbi__err(y) #else #define stbi__err(x,y) stbi__err(x) #endif #define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) STBIDEF void stbi_image_free(void *retval_from_stbi_load) { STBI_FREE(retval_from_stbi_load); } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); #endif #ifndef STBI_NO_HDR static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); #endif static int stbi__vertically_flip_on_load = 0; STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) { stbi__vertically_flip_on_load = flag_true_if_should_flip; } static unsigned char *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_PNG if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_BMP if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_GIF if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_PSD if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_PIC if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_PNM if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp); #endif #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr = stbi__hdr_load(s, x,y,comp,req_comp); return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); } #endif #ifndef STBI_NO_TGA // test tga last because it's a crappy test! if (stbi__tga_test(s)) return stbi__tga_load(s,x,y,comp,req_comp); #endif return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); if (stbi__vertically_flip_on_load && result != NULL) { int w = *x, h = *y; int depth = req_comp ? req_comp : *comp; int row,col,z; stbi_uc temp; // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once for (row = 0; row < (h>>1); row++) { for (col = 0; col < w; col++) { for (z = 0; z < depth; z++) { temp = result[(row * w + col) * depth + z]; result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; result[((h - row - 1) * w + col) * depth + z] = temp; } } } } return result; } #ifndef STBI_NO_HDR static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) { if (stbi__vertically_flip_on_load && result != NULL) { int w = *x, h = *y; int depth = req_comp ? req_comp : *comp; int row,col,z; float temp; // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once for (row = 0; row < (h>>1); row++) { for (col = 0; col < w; col++) { for (z = 0; z < depth; z++) { temp = result[(row * w + col) * depth + z]; result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; result[((h - row - 1) * w + col) * depth + z] = temp; } } } } } #endif #ifndef STBI_NO_STDIO static FILE *stbi__fopen(char const *filename, char const *mode) { FILE *f; #if defined(_MSC_VER) && _MSC_VER >= 1400 if (0 != fopen_s(&f, filename, mode)) f=0; #else f = fopen(filename, mode); #endif return f; } STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) { FILE *f = stbi__fopen(filename, "rb"); unsigned char *result; if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); result = stbi_load_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { unsigned char *result; stbi__context s; stbi__start_file(&s,f); result = stbi__load_flip(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); } return result; } #endif //!STBI_NO_STDIO STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__load_flip(&s,x,y,comp,req_comp); } STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__load_flip(&s,x,y,comp,req_comp); } #ifndef STBI_NO_LINEAR static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *data; #ifndef STBI_NO_HDR if (stbi__hdr_test(s)) { float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp); if (hdr_data) stbi__float_postprocess(hdr_data,x,y,comp,req_comp); return hdr_data; } #endif data = stbi__load_flip(s, x, y, comp, req_comp); if (data) return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); } STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__loadf_main(&s,x,y,comp,req_comp); } STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__loadf_main(&s,x,y,comp,req_comp); } #ifndef STBI_NO_STDIO STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) { float *result; FILE *f = stbi__fopen(filename, "rb"); if (!f) return stbi__errpf("can't fopen", "Unable to open file"); result = stbi_loadf_from_file(f,x,y,comp,req_comp); fclose(f); return result; } STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_file(&s,f); return stbi__loadf_main(&s,x,y,comp,req_comp); } #endif // !STBI_NO_STDIO #endif // !STBI_NO_LINEAR // these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is // defined, for API simplicity; if STBI_NO_LINEAR is defined, it always // reports false! STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__hdr_test(&s); #else STBI_NOTUSED(buffer); STBI_NOTUSED(len); return 0; #endif } #ifndef STBI_NO_STDIO STBIDEF int stbi_is_hdr (char const *filename) { FILE *f = stbi__fopen(filename, "rb"); int result=0; if (f) { result = stbi_is_hdr_from_file(f); fclose(f); } return result; } STBIDEF int stbi_is_hdr_from_file(FILE *f) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_file(&s,f); return stbi__hdr_test(&s); #else STBI_NOTUSED(f); return 0; #endif } #endif // !STBI_NO_STDIO STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) { #ifndef STBI_NO_HDR stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); return stbi__hdr_test(&s); #else STBI_NOTUSED(clbk); STBI_NOTUSED(user); return 0; #endif } #ifndef STBI_NO_LINEAR static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } #endif static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } ////////////////////////////////////////////////////////////////////////////// // // Common code used by all image loaders // enum { STBI__SCAN_load=0, STBI__SCAN_type, STBI__SCAN_header }; static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); if (n == 0) { // at end of file, treat same as if from memory, but need to handle case // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; } else { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } } stbi_inline static stbi_uc stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { stbi__refill_buffer(s); return *s->img_buffer++; } return 0; } stbi_inline static int stbi__at_eof(stbi__context *s) { if (s->io.read) { if (!(s->io.eof)(s->io_user_data)) return 0; // if feof() is true, check if buffer = end // special case: we've only got the special 0 character at the end if (s->read_from_callbacks == 0) return 1; } return s->img_buffer >= s->img_buffer_end; } static void stbi__skip(stbi__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; return; } if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { s->img_buffer = s->img_buffer_end; (s->io.skip)(s->io_user_data, n - blen); return; } } s->img_buffer += n; } static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) { if (s->io.read) { int blen = (int) (s->img_buffer_end - s->img_buffer); if (blen < n) { int res, count; memcpy(buffer, s->img_buffer, blen); count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); res = (count == (n-blen)); s->img_buffer = s->img_buffer_end; return res; } } if (s->img_buffer+n <= s->img_buffer_end) { memcpy(buffer, s->img_buffer, n); s->img_buffer += n; return 1; } else return 0; } static int stbi__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } static stbi__uint32 stbi__get32be(stbi__context *s) { stbi__uint32 z = stbi__get16be(s); return (z << 16) + stbi__get16be(s); } #if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) // nothing #else static int stbi__get16le(stbi__context *s) { int z = stbi__get8(s); return z + (stbi__get8(s) << 8); } #endif #ifndef STBI_NO_BMP static stbi__uint32 stbi__get32le(stbi__context *s) { stbi__uint32 z = stbi__get16le(s); return z + (stbi__get16le(s) << 16); } #endif #define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings ////////////////////////////////////////////////////////////////////////////// // // generic converter from built-in img_n to req_comp // individual types do this automatically as much as possible (e.g. jpeg // does all cases internally since it needs to colorspace convert anyway, // and it never has alpha, so very few cases ). png can automatically // interleave an alpha=255 channel, but falls back to this for other cases // // assume data buffer is malloced, so malloc a new one and free that one // only failure mode is malloc failing static stbi_uc stbi__compute_y(int r, int g, int b) { return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); } static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) { int i,j; unsigned char *good; if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); good = (unsigned char *) stbi__malloc(req_comp * x * y); if (good == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } for (j=0; j < (int) y; ++j) { unsigned char *src = data + j * x * img_n ; unsigned char *dest = good + j * x * req_comp; #define COMBO(a,b) ((a)*8+(b)) #define CASE(a,b) case COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) // convert source image with img_n components to one with req_comp components; // avoid switch per pixel, so use switch per scanline and massive macros switch (COMBO(img_n, req_comp)) { CASE(1,2) dest[0]=src[0], dest[1]=255; break; CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break; CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break; CASE(2,1) dest[0]=src[0]; break; CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break; CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break; CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break; CASE(3,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; CASE(3,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255; break; CASE(4,1) dest[0]=stbi__compute_y(src[0],src[1],src[2]); break; CASE(4,2) dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break; CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break; default: STBI_ASSERT(0); } #undef CASE } STBI_FREE(data); return good; } #ifndef STBI_NO_LINEAR static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) { int i,k,n; float *output = (float *) stbi__malloc(x * y * comp * sizeof(float)); if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); } if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f; } STBI_FREE(data); return output; } #endif #ifndef STBI_NO_HDR #define stbi__float2int(x) ((int) (x)) static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) { int i,k,n; stbi_uc *output = (stbi_uc *) stbi__malloc(x * y * comp); if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } // compute number of non-alpha components if (comp & 1) n = comp; else n = comp-1; for (i=0; i < x*y; ++i) { for (k=0; k < n; ++k) { float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } if (k < comp) { float z = data[i*comp+k] * 255 + 0.5f; if (z < 0) z = 0; if (z > 255) z = 255; output[i*comp + k] = (stbi_uc) stbi__float2int(z); } } STBI_FREE(data); return output; } #endif ////////////////////////////////////////////////////////////////////////////// // // "baseline" JPEG/JFIF decoder // // simple implementation // - doesn't support delayed output of y-dimension // - simple interface (only one output format: 8-bit interleaved RGB) // - doesn't try to recover corrupt jpegs // - doesn't allow partial loading, loading multiple at once // - still fast on x86 (copying globals into locals doesn't help x86) // - allocates lots of intermediate memory (full size of all components) // - non-interleaved case requires this anyway // - allows good upsampling (see next) // high-quality // - upsampled channels are bilinearly interpolated, even across blocks // - quality integer IDCT derived from IJG's 'slow' // performance // - fast huffman; reasonable integer IDCT // - some SIMD kernels for common paths on targets with SSE2/NEON // - uses a lot of intermediate memory, could cache poorly #ifndef STBI_NO_JPEG // huffman decoding acceleration #define FAST_BITS 9 // larger handles more cases; smaller stomps less cache typedef struct { stbi_uc fast[1 << FAST_BITS]; // weirdly, repacking this into AoS is a 10% speed loss, instead of a win stbi__uint16 code[256]; stbi_uc values[256]; stbi_uc size[257]; unsigned int maxcode[18]; int delta[17]; // old 'firstsymbol' - old 'firstcode' } stbi__huffman; typedef struct { stbi__context *s; stbi__huffman huff_dc[4]; stbi__huffman huff_ac[4]; stbi_uc dequant[4][64]; stbi__int16 fast_ac[4][1 << FAST_BITS]; // sizes for components, interleaved MCUs int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; // definition of jpeg image component struct { int id; int h,v; int tq; int hd,ha; int dc_pred; int x,y,w2,h2; stbi_uc *data; void *raw_data, *raw_coeff; stbi_uc *linebuf; short *coeff; // progressive only int coeff_w, coeff_h; // number of 8x8 coefficient blocks } img_comp[4]; stbi__uint32 code_buffer; // jpeg entropy-coded buffer int code_bits; // number of valid bits unsigned char marker; // marker seen while filling entropy buffer int nomore; // flag if we saw a marker so must stop int progressive; int spec_start; int spec_end; int succ_high; int succ_low; int eob_run; int scan_n, order[4]; int restart_interval, todo; // kernels void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); } stbi__jpeg; static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0,code; // build size list for each symbol (from JPEG spec) for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (stbi_uc) (i+1); h->size[k] = 0; // compute actual symbols (from jpeg spec) code = 0; k = 0; for(j=1; j <= 16; ++j) { // compute delta to add to code to compute symbol id h->delta[j] = k - code; if (h->size[k] == j) { while (h->size[k] == j) h->code[k++] = (stbi__uint16) (code++); if (code-1 >= (1 << j)) return stbi__err("bad code lengths","Corrupt JPEG"); } // compute largest code + 1 for this size, preshifted as needed later h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; // build non-spec acceleration table; 255 is flag for not-accelerated memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; if (s <= FAST_BITS) { int c = h->code[i] << (FAST_BITS-s); int m = 1 << (FAST_BITS-s); for (j=0; j < m; ++j) { h->fast[c+j] = (stbi_uc) i; } } } return 1; } // build a table that decodes both magnitude and value of small ACs in // one go. static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) { int i; for (i=0; i < (1 << FAST_BITS); ++i) { stbi_uc fast = h->fast[i]; fast_ac[i] = 0; if (fast < 255) { int rs = h->values[fast]; int run = (rs >> 4) & 15; int magbits = rs & 15; int len = h->size[fast]; if (magbits && len + magbits <= FAST_BITS) { // magnitude code followed by receive_extend code int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (-1 << magbits) + 1; // if the result is small enough, we can fit it in fast_ac table if (k >= -128 && k <= 127) fast_ac[i] = (stbi__int16) ((k << 8) + (run << 4) + (len + magbits)); } } } } static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { do { int b = j->nomore ? 0 : stbi__get8(j->s); if (b == 0xff) { int c = stbi__get8(j->s); if (c != 0) { j->marker = (unsigned char) c; j->nomore = 1; return; } } j->code_buffer |= b << (24 - j->code_bits); j->code_bits += 8; } while (j->code_bits <= 24); } // (1 << n) - 1 static stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; // decode a jpeg huffman value from the bitstream stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); // look at the top FAST_BITS and determine what symbol ID it is, // if the code is <= FAST_BITS c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; if (k < 255) { int s = h->size[k]; if (s > j->code_bits) return -1; j->code_buffer <<= s; j->code_bits -= s; return h->values[k]; } // naive test is to shift the code_buffer down so k bits are // valid, then test against maxcode. To speed this up, we've // preshifted maxcode left so that it has (16-k) 0s at the // end; in other words, regardless of the number of bits, it // wants to be compared against something shifted to have 16; // that way we don't need to shift inside the loop. temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; if (k == 17) { // error! code not found j->code_bits -= 16; return -1; } if (k > j->code_bits) return -1; // convert the huffman code to the symbol id c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); // convert the id to a symbol j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } // bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB k = stbi_lrot(j->code_buffer, n); STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k + (stbi__jbias[n] & ~sgn); } // get some unsigned bits stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; if (j->code_bits < n) stbi__grow_buffer_unsafe(j); k = stbi_lrot(j->code_buffer, n); j->code_buffer = k & ~stbi__bmask[n]; k &= stbi__bmask[n]; j->code_bits -= n; return k; } stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) { unsigned int k; if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; return k & 0x80000000; } // given a value that's at position X in the zigzag stream, // where does it appear in the 8x8 matrix coded as row-major? static stbi_uc stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, // let corrupt input sample past end 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; // decode one 64-entry block-- static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi_uc *dequant) { int diff,dc,k; int t; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); t = stbi__jpeg_huff_decode(j, hdc); if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); // 0 all the ac values now so we can do it 32-bits at a time memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); // decode AC components, see JPEG spec k = 1; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (rs != 0xf0) break; // end block k += 16; } else { k += r; // decode into unzigzag'd location zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) { int diff,dc; int t; if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); if (j->succ_high == 0) { // first scan for DC coefficient, must be first memset(data,0,64*sizeof(data[0])); // 0 all the ac values now t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc << j->succ_low); } else { // refinement scan for DC coefficient if (stbi__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } // @OPTIMIZE: store non-zigzagged during the decode passes, // and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) { int k; if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; if (j->eob_run) { --j->eob_run; return 1; } k = j->spec_start; do { unsigned int zig; int c,r,s; if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { // fast-AC path k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) << shift); } else { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) j->eob_run += stbi__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) << shift); } } } while (k <= j->spec_end); } else { // refinement scan for these AC coefficients short bit = (short) (1 << j->succ_low); if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { short *p = &data[stbi__jpeg_dezigzag[k]]; if (*p != 0) if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } } else { k = j->spec_start; do { int r,s; int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) j->eob_run += stbi__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do // a run of 15 0s and then write s (which is 0), // so we don't have to do anything special here } } else { if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); // sign bit if (stbi__jpeg_get_bit(j)) s = bit; else s = -bit; } // advance by r while (k <= j->spec_end) { short *p = &data[stbi__jpeg_dezigzag[k++]]; if (*p != 0) { if (stbi__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; else *p -= bit; } } else { if (r == 0) { *p = (short) s; break; } --r; } } } while (k <= j->spec_end); } } return 1; } // take a -128..127 value and stbi__clamp it and convert to 0..255 stbi_inline static stbi_uc stbi__clamp(int x) { // trick to use a single test to catch both cases if ((unsigned int) x > 255) { if (x < 0) return 0; if (x > 255) return 255; } return (stbi_uc) x; } #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) << 12) // derived from jidctint -- DCT_ISLOW #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ p1 = (p2+p3) * stbi__f2f(0.5411961f); \ t2 = p1 + p3*stbi__f2f(-1.847759065f); \ t3 = p1 + p2*stbi__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ t0 = stbi__fsh(p2+p3); \ t1 = stbi__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ x2 = t1-t2; \ t0 = s7; \ t1 = s5; \ t2 = s3; \ t3 = s1; \ p3 = t0+t2; \ p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ t0 = t0*stbi__f2f( 0.298631336f); \ t1 = t1*stbi__f2f( 2.053119869f); \ t2 = t2*stbi__f2f( 3.072711026f); \ t3 = t3*stbi__f2f( 1.501321110f); \ p1 = p5 + p1*stbi__f2f(-0.899976223f); \ p2 = p5 + p2*stbi__f2f(-2.562915447f); \ p3 = p3*stbi__f2f(-1.961570560f); \ p4 = p4*stbi__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) { int i,val[64],*v=val; stbi_uc *o; short *d = data; // columns for (i=0; i < 8; ++i,++d, ++v) { // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { // no shortcut 0 seconds // (1|2|3|4|5|6|7)==0 0 seconds // all separate -0.047 seconds // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds int dcterm = d[0] << 2; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) // constants scaled things up by 1<<12; let's bring them back // down, but keep 2 extra bits of precision x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; v[ 8] = (x1+t2) >> 10; v[48] = (x1-t2) >> 10; v[16] = (x2+t1) >> 10; v[40] = (x2-t1) >> 10; v[24] = (x3+t0) >> 10; v[32] = (x3-t0) >> 10; } } for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { // no fast case since the first 1D IDCT spread components out STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) // constants scaled things up by 1<<12, plus we had 1<<2 from first // loop, plus horizontal and vertical each scale by sqrt(8) so together // we've got an extra 1<<3, so 1<<17 total we need to remove. // so we want to round that, which means adding 0.5 * 1<<17, // aka 65536. Also, we'll end up with -128 to 127 that we want // to encode as 0..255 by adding 128, so we'll add that before the shift x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower o[0] = stbi__clamp((x0+t3) >> 17); o[7] = stbi__clamp((x0-t3) >> 17); o[1] = stbi__clamp((x1+t2) >> 17); o[6] = stbi__clamp((x1-t2) >> 17); o[2] = stbi__clamp((x2+t1) >> 17); o[5] = stbi__clamp((x2-t1) >> 17); o[3] = stbi__clamp((x3+t0) >> 17); o[4] = stbi__clamp((x3-t0) >> 17); } } #ifdef STBI_SSE2 // sse2 integer IDCT. not the fastest possible implementation but it // produces bit-identical results to the generic C version so it's // fully "transparent". static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { // This is constructed to match our regular (generic) integer IDCT exactly. __m128i row0, row1, row2, row3, row4, row5, row6, row7; __m128i tmp; // dot product constant: even elems=x, odd elems=y #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) // out(1) = c1[even]*x + c1[odd]*y #define dct_rot(out0,out1, x,y,c0,c1) \ __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) // out = in << 12 (in 16-bit, out 32-bit) #define dct_widen(out, in) \ __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) // wide add #define dct_wadd(out, a, b) \ __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_add_epi32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) // butterfly a/b, add bias, then shift by "s" and pack #define dct_bfly32o(out0, out1, a,b,bias,s) \ { \ __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ dct_wadd(sum, abiased, b); \ dct_wsub(dif, abiased, b); \ out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ } // 8-bit interleave step (for transposes) #define dct_interleave8(a, b) \ tmp = a; \ a = _mm_unpacklo_epi8(a, b); \ b = _mm_unpackhi_epi8(tmp, b) // 16-bit interleave step (for transposes) #define dct_interleave16(a, b) \ tmp = a; \ a = _mm_unpacklo_epi16(a, b); \ b = _mm_unpackhi_epi16(tmp, b) #define dct_pass(bias,shift) \ { \ /* even part */ \ dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ __m128i sum04 = _mm_add_epi16(row0, row4); \ __m128i dif04 = _mm_sub_epi16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ __m128i sum17 = _mm_add_epi16(row1, row7); \ __m128i sum35 = _mm_add_epi16(row3, row5); \ dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ dct_wadd(x4, y0o, y4o); \ dct_wadd(x5, y1o, y5o); \ dct_wadd(x6, y2o, y5o); \ dct_wadd(x7, y3o, y4o); \ dct_bfly32o(row0,row7, x0,x7,bias,shift); \ dct_bfly32o(row1,row6, x1,x6,bias,shift); \ dct_bfly32o(row2,row5, x2,x5,bias,shift); \ dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); // rounding biases in column/row passes, see stbi__idct_block for explanation. __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); // load row0 = _mm_load_si128((const __m128i *) (data + 0*8)); row1 = _mm_load_si128((const __m128i *) (data + 1*8)); row2 = _mm_load_si128((const __m128i *) (data + 2*8)); row3 = _mm_load_si128((const __m128i *) (data + 3*8)); row4 = _mm_load_si128((const __m128i *) (data + 4*8)); row5 = _mm_load_si128((const __m128i *) (data + 5*8)); row6 = _mm_load_si128((const __m128i *) (data + 6*8)); row7 = _mm_load_si128((const __m128i *) (data + 7*8)); // column pass dct_pass(bias_0, 10); { // 16bit 8x8 transpose pass 1 dct_interleave16(row0, row4); dct_interleave16(row1, row5); dct_interleave16(row2, row6); dct_interleave16(row3, row7); // transpose pass 2 dct_interleave16(row0, row2); dct_interleave16(row1, row3); dct_interleave16(row4, row6); dct_interleave16(row5, row7); // transpose pass 3 dct_interleave16(row0, row1); dct_interleave16(row2, row3); dct_interleave16(row4, row5); dct_interleave16(row6, row7); } // row pass dct_pass(bias_1, 17); { // pack __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 __m128i p1 = _mm_packus_epi16(row2, row3); __m128i p2 = _mm_packus_epi16(row4, row5); __m128i p3 = _mm_packus_epi16(row6, row7); // 8bit 8x8 transpose pass 1 dct_interleave8(p0, p2); // a0e0a1e1... dct_interleave8(p1, p3); // c0g0c1g1... // transpose pass 2 dct_interleave8(p0, p1); // a0c0e0g0... dct_interleave8(p2, p3); // b0d0f0h0... // transpose pass 3 dct_interleave8(p0, p2); // a0b0c0d0... dct_interleave8(p1, p3); // a4b4c4d4... // store _mm_storel_epi64((__m128i *) out, p0); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p2); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p1); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; _mm_storel_epi64((__m128i *) out, p3); out += out_stride; _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); } #undef dct_const #undef dct_rot #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_interleave8 #undef dct_interleave16 #undef dct_pass } #endif // STBI_SSE2 #ifdef STBI_NEON // NEON integer IDCT. should produce bit-identical // results to the generic C version. static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) #define dct_long_mac(out, acc, inq, coeff) \ int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) #define dct_widen(out, inq) \ int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) // wide add #define dct_wadd(out, a, b) \ int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ int32x4_t out##_h = vaddq_s32(a##_h, b##_h) // wide sub #define dct_wsub(out, a, b) \ int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ int32x4_t out##_h = vsubq_s32(a##_h, b##_h) // butterfly a/b, then shift using "shiftop" by "s" and pack #define dct_bfly32o(out0,out1, a,b,shiftop,s) \ { \ dct_wadd(sum, a, b); \ dct_wsub(dif, a, b); \ out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ } #define dct_pass(shiftop, shift) \ { \ /* even part */ \ int16x8_t sum26 = vaddq_s16(row2, row6); \ dct_long_mul(p1e, sum26, rot0_0); \ dct_long_mac(t2e, p1e, row6, rot0_1); \ dct_long_mac(t3e, p1e, row2, rot0_2); \ int16x8_t sum04 = vaddq_s16(row0, row4); \ int16x8_t dif04 = vsubq_s16(row0, row4); \ dct_widen(t0e, sum04); \ dct_widen(t1e, dif04); \ dct_wadd(x0, t0e, t3e); \ dct_wsub(x3, t0e, t3e); \ dct_wadd(x1, t1e, t2e); \ dct_wsub(x2, t1e, t2e); \ /* odd part */ \ int16x8_t sum15 = vaddq_s16(row1, row5); \ int16x8_t sum17 = vaddq_s16(row1, row7); \ int16x8_t sum35 = vaddq_s16(row3, row5); \ int16x8_t sum37 = vaddq_s16(row3, row7); \ int16x8_t sumodd = vaddq_s16(sum17, sum35); \ dct_long_mul(p5o, sumodd, rot1_0); \ dct_long_mac(p1o, p5o, sum17, rot1_1); \ dct_long_mac(p2o, p5o, sum35, rot1_2); \ dct_long_mul(p3o, sum37, rot2_0); \ dct_long_mul(p4o, sum15, rot2_1); \ dct_wadd(sump13o, p1o, p3o); \ dct_wadd(sump24o, p2o, p4o); \ dct_wadd(sump23o, p2o, p3o); \ dct_wadd(sump14o, p1o, p4o); \ dct_long_mac(x4, sump13o, row7, rot3_0); \ dct_long_mac(x5, sump24o, row5, rot3_1); \ dct_long_mac(x6, sump23o, row3, rot3_2); \ dct_long_mac(x7, sump14o, row1, rot3_3); \ dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ } // load row0 = vld1q_s16(data + 0*8); row1 = vld1q_s16(data + 1*8); row2 = vld1q_s16(data + 2*8); row3 = vld1q_s16(data + 3*8); row4 = vld1q_s16(data + 4*8); row5 = vld1q_s16(data + 5*8); row6 = vld1q_s16(data + 6*8); row7 = vld1q_s16(data + 7*8); // add DC bias row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); // column pass dct_pass(vrshrn_n_s32, 10); // 16bit 8x8 transpose { // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. // whether compilers actually get this is another story, sadly. #define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } #define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } // pass 1 dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 dct_trn16(row2, row3); dct_trn16(row4, row5); dct_trn16(row6, row7); // pass 2 dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 dct_trn32(row1, row3); dct_trn32(row4, row6); dct_trn32(row5, row7); // pass 3 dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 dct_trn64(row1, row5); dct_trn64(row2, row6); dct_trn64(row3, row7); #undef dct_trn16 #undef dct_trn32 #undef dct_trn64 } // row pass // vrshrn_n_s32 only supports shifts up to 16, we need // 17. so do a non-rounding shift of 16 first then follow // up with a rounding shift by 1. dct_pass(vshrn_n_s32, 16); { // pack and round uint8x8_t p0 = vqrshrun_n_s16(row0, 1); uint8x8_t p1 = vqrshrun_n_s16(row1, 1); uint8x8_t p2 = vqrshrun_n_s16(row2, 1); uint8x8_t p3 = vqrshrun_n_s16(row3, 1); uint8x8_t p4 = vqrshrun_n_s16(row4, 1); uint8x8_t p5 = vqrshrun_n_s16(row5, 1); uint8x8_t p6 = vqrshrun_n_s16(row6, 1); uint8x8_t p7 = vqrshrun_n_s16(row7, 1); // again, these can translate into one instruction, but often don't. #define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } #define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } #define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } // sadly can't use interleaved stores here since we only write // 8 bytes to each scan line! // 8x8 8-bit transpose pass 1 dct_trn8_8(p0, p1); dct_trn8_8(p2, p3); dct_trn8_8(p4, p5); dct_trn8_8(p6, p7); // pass 2 dct_trn8_16(p0, p2); dct_trn8_16(p1, p3); dct_trn8_16(p4, p6); dct_trn8_16(p5, p7); // pass 3 dct_trn8_32(p0, p4); dct_trn8_32(p1, p5); dct_trn8_32(p2, p6); dct_trn8_32(p3, p7); // store vst1_u8(out, p0); out += out_stride; vst1_u8(out, p1); out += out_stride; vst1_u8(out, p2); out += out_stride; vst1_u8(out, p3); out += out_stride; vst1_u8(out, p4); out += out_stride; vst1_u8(out, p5); out += out_stride; vst1_u8(out, p6); out += out_stride; vst1_u8(out, p7); #undef dct_trn8_8 #undef dct_trn8_16 #undef dct_trn8_32 } #undef dct_long_mul #undef dct_long_mac #undef dct_widen #undef dct_wadd #undef dct_wsub #undef dct_bfly32o #undef dct_pass } #endif // STBI_NEON #define STBI__MARKER_none 0xff // if there's a pending marker from the entropy stream, return that // otherwise, fetch from the stream and get a marker. if there's no // marker, return 0xff, which is never a valid marker value static stbi_uc stbi__get_marker(stbi__jpeg *j) { stbi_uc x; if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } x = stbi__get8(j->s); if (x != 0xff) return STBI__MARKER_none; while (x == 0xff) x = stbi__get8(j->s); return x; } // in each scan, we'll have scan_n components, and the order // of the components is specified by order[] #define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) // after a restart interval, stbi__jpeg_reset the entropy decoder and // the dc prediction static void stbi__jpeg_reset(stbi__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, // since we don't even allow 1<<30 pixels } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) { stbi__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; STBI_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } else { if (z->scan_n == 1) { int i,j; int n = z->order[0]; // non-interleaved data, we just need to process one block at a time, // in trivial scanline order // number of blocks to do just depends on how many actual "pixels" this // component has, independent of interleaved MCU blocking and such int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } else { // interleaved int i,j,k,x,y; for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order for (k=0; k < z->scan_n; ++k) { int n = z->order[k]; // scan out an mcu's worth of this component; that's just determined // by the basic H and V specified for the component for (y=0; y < z->img_comp[n].v; ++y) { for (x=0; x < z->img_comp[n].h; ++x) { int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } } // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); if (!STBI__RESTART(z->marker)) return 1; stbi__jpeg_reset(z); } } } return 1; } } } static void stbi__jpeg_dequantize(short *data, stbi_uc *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } static void stbi__jpeg_finish(stbi__jpeg *z) { if (z->progressive) { // dequantize and idct the data int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } } } } static int stbi__process_marker(stbi__jpeg *z, int m) { int L; switch (m) { case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); case 0xDD: // DRI - specify restart interval if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; case 0xDB: // DQT - define quantization table L = stbi__get16be(z->s)-2; while (L > 0) { int q = stbi__get8(z->s); int p = q >> 4; int t = q & 15,i; if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG"); if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s); L -= 65; } return L==0; case 0xC4: // DHT - define huffman table L = stbi__get16be(z->s)-2; while (L > 0) { stbi_uc *v; int sizes[16],i,n=0; int q = stbi__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { sizes[i] = stbi__get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) v[i] = stbi__get8(z->s); if (tc != 0) stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; } // check for comment block or APP blocks if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { stbi__skip(z->s, stbi__get16be(z->s)-2); return 1; } return 0; } // after we see SOS static int stbi__process_scan_header(stbi__jpeg *z) { int i; int Ls = stbi__get16be(z->s); z->scan_n = stbi__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { int id = stbi__get8(z->s), which; int q = stbi__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) break; if (which == z->s->img_n) return 0; // no match z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; z->spec_start = stbi__get8(z->s); z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 aa = stbi__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) return stbi__err("bad SOS", "Corrupt JPEG"); } else { if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } return 1; } static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires c = stbi__get8(s); if (c != 3 && c != 1) return stbi__err("bad component count","Corrupt JPEG"); // JFIF requires s->img_n = c; for (i=0; i < c; ++i) { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); for (i=0; i < s->img_n; ++i) { z->img_comp[i].id = stbi__get8(s); if (z->img_comp[i].id != i+1) // JFIF requires if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! return stbi__err("bad component ID","Corrupt JPEG"); q = stbi__get8(s); z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); } if (scan != STBI__SCAN_load) return 1; if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; } // compute interleaved mcu info z->img_h_max = h_max; z->img_v_max = v_max; z->img_mcu_w = h_max * 8; z->img_mcu_h = v_max * 8; z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; for (i=0; i < s->img_n; ++i) { // number of effective pixels (e.g. for non-interleaved MCU) z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; // to simplify generation, we'll allocate enough memory to decode // the bogus oversized data from using interleaved MCUs and their // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't // discard the extra data until colorspace conversion z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; z->img_comp[i].raw_data = stbi__malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); if (z->img_comp[i].raw_data == NULL) { for(--i; i >= 0; --i) { STBI_FREE(z->img_comp[i].raw_data); z->img_comp[i].raw_data = NULL; } return stbi__err("outofmem", "Out of memory"); } // align blocks for idct using mmx/sse z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); z->img_comp[i].linebuf = NULL; if (z->progressive) { z->img_comp[i].coeff_w = (z->img_comp[i].w2 + 7) >> 3; z->img_comp[i].coeff_h = (z->img_comp[i].h2 + 7) >> 3; z->img_comp[i].raw_coeff = STBI_MALLOC(z->img_comp[i].coeff_w * z->img_comp[i].coeff_h * 64 * sizeof(short) + 15); z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); } else { z->img_comp[i].coeff = 0; z->img_comp[i].raw_coeff = 0; } } return 1; } // use comparisons since in some cases we handle more than one case (e.g. SOF) #define stbi__DNL(x) ((x) == 0xdc) #define stbi__SOI(x) ((x) == 0xd8) #define stbi__EOI(x) ((x) == 0xd9) #define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) #define stbi__SOS(x) ((x) == 0xda) #define stbi__SOF_progressive(x) ((x) == 0xc2) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; z->marker = STBI__MARKER_none; // initialize cached marker to empty m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; m = stbi__get_marker(z); while (!stbi__SOF(m)) { if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { // some files have extra padding after their blocks, so ok, we'll scan if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } } z->progressive = stbi__SOF_progressive(m); if (!stbi__process_frame_header(z, scan)) return 0; return 1; } // decode image to YCbCr format static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; for (m = 0; m < 4; m++) { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); while (!stbi__EOI(m)) { if (stbi__SOS(m)) { if (!stbi__process_scan_header(j)) return 0; if (!stbi__parse_entropy_coded_data(j)) return 0; if (j->marker == STBI__MARKER_none ) { // handle 0s at the end of image data from IP Kamera 9060 while (!stbi__at_eof(j->s)) { int x = stbi__get8(j->s); if (x == 255) { j->marker = stbi__get8(j->s); break; } else if (x != 0) { return stbi__err("junk before marker", "Corrupt JPEG"); } } // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 } } else { if (!stbi__process_marker(j, m)) return 0; } m = stbi__get_marker(j); } if (j->progressive) stbi__jpeg_finish(j); return 1; } // static jfif-centered resampling (across block boundaries) typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, int w, int hs); #define stbi__div4(x) ((stbi_uc) ((x) >> 2)) static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { STBI_NOTUSED(out); STBI_NOTUSED(in_far); STBI_NOTUSED(w); STBI_NOTUSED(hs); return in_near; } static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples vertically for every one in input int i; STBI_NOTUSED(hs); for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; } static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate two samples horizontally for every one in input int i; stbi_uc *input = in_near; if (w == 1) { // if only one sample, can't do any interpolation out[0] = out[1] = input[0]; return out; } out[0] = input[0]; out[1] = stbi__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; out[i*2+0] = stbi__div4(n+input[i-1]); out[i*2+1] = stbi__div4(n+input[i+1]); } out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; STBI_NOTUSED(in_far); STBI_NOTUSED(hs); return out; } #define stbi__div16(x) ((stbi_uc) ((x) >> 4)) static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; out[0] = stbi__div4(t1+2); for (i=1; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #if defined(STBI_SSE2) || defined(STBI_NEON) static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // need to generate 2x2 samples for every one in input int i=0,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); return out; } t1 = 3*in_near[0] + in_far[0]; // process groups of 8 pixels for as long as we can. // note we can't handle the last pixel in a row in this loop // because we need to handle the filter boundary conditions. for (; i < ((w-1) & ~7); i += 8) { #if defined(STBI_SSE2) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) __m128i zero = _mm_setzero_si128(); __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); __m128i farw = _mm_unpacklo_epi8(farb, zero); __m128i nearw = _mm_unpacklo_epi8(nearb, zero); __m128i diff = _mm_sub_epi16(farw, nearw); __m128i nears = _mm_slli_epi16(nearw, 2); __m128i curr = _mm_add_epi16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. __m128i prv0 = _mm_slli_si128(curr, 2); __m128i nxt0 = _mm_srli_si128(curr, 2); __m128i prev = _mm_insert_epi16(prv0, t1, 0); __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. __m128i bias = _mm_set1_epi16(8); __m128i curs = _mm_slli_epi16(curr, 2); __m128i prvd = _mm_sub_epi16(prev, curr); __m128i nxtd = _mm_sub_epi16(next, curr); __m128i curb = _mm_add_epi16(curs, bias); __m128i even = _mm_add_epi16(prvd, curb); __m128i odd = _mm_add_epi16(nxtd, curb); // interleave even and odd pixels, then undo scaling. __m128i int0 = _mm_unpacklo_epi16(even, odd); __m128i int1 = _mm_unpackhi_epi16(even, odd); __m128i de0 = _mm_srli_epi16(int0, 4); __m128i de1 = _mm_srli_epi16(int1, 4); // pack and write output __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) // load and perform the vertical filtering pass // this uses 3*x + y = 4*x + (y - x) uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); int16x8_t curr = vaddq_s16(nears, diff); // current row // horizontal filter works the same based on shifted vers of current // row. "prev" is current row shifted right by 1 pixel; we need to // insert the previous pixel value (from t1). // "next" is current row shifted left by 1 pixel, with first pixel // of next block of 8 pixels added in. int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); // horizontal filter, polyphase implementation since it's convenient: // even pixels = 3*cur + prev = cur*4 + (prev - cur) // odd pixels = 3*cur + next = cur*4 + (next - cur) // note the shared term. int16x8_t curs = vshlq_n_s16(curr, 2); int16x8_t prvd = vsubq_s16(prev, curr); int16x8_t nxtd = vsubq_s16(next, curr); int16x8_t even = vaddq_s16(curs, prvd); int16x8_t odd = vaddq_s16(curs, nxtd); // undo scaling and round, then store with even/odd phases interleaved uint8x8x2_t o; o.val[0] = vqrshrun_n_s16(even, 4); o.val[1] = vqrshrun_n_s16(odd, 4); vst2_u8(out + i*2, o); #endif // "previous" value for next iter t1 = 3*in_near[i+7] + in_far[i+7]; } t0 = t1; t1 = 3*in_near[i] + in_far[i]; out[i*2] = stbi__div16(3*t1 + t0 + 8); for (++i; i < w; ++i) { t0 = t1; t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } out[w*2-1] = stbi__div4(t1+2); STBI_NOTUSED(hs); return out; } #endif static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) { // resample with nearest-neighbor int i,j; STBI_NOTUSED(in_far); for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } #ifdef STBI_JPEG_OLD // this is the same YCbCr-to-RGB calculation that stb_image has used // historically before the algorithm changes in 1.49 #define float2fixed(x) ((int) ((x) * 65536 + 0.5)) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 16) + 32768; // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr*float2fixed(1.40200f); g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); b = y_fixed + cb*float2fixed(1.77200f); r >>= 16; g >>= 16; b >>= 16; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #else // this is a reduced-precision calculation of YCbCr-to-RGB introduced // to make sure the code produces the same results in both SIMD and scalar #define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* float2fixed(1.40200f); g = y_fixed + (cr*-float2fixed(0.71414f)) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif #if defined(STBI_SSE2) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) { int i = 0; #ifdef STBI_SSE2 // step == 3 is pretty ugly on the final interleave, and i'm not convinced // it's useful in practice (you wouldn't use it for textures, for example). // so just accelerate step == 4 case. if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. __m128i signflip = _mm_set1_epi8(-0x80); __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); __m128i xw = _mm_set1_epi16(255); // alpha channel for (; i+7 < count; i += 8) { // load __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 // unpack to short (and left-shift cr, cb by 8) __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); // color transform __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); __m128i rws = _mm_add_epi16(cr0, yws); __m128i gwt = _mm_add_epi16(cb0, yws); __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); // descale __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); // back to byte, set up for transpose __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); // transpose to interleave channels __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); // store _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; } } #endif #ifdef STBI_NEON // in this version, step=3 support would be easy to add. but is there demand? if (step == 4) { // this is a fairly straightforward implementation and not super-optimized. uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); for (; i+7 < count; i += 8) { // load uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); // expand to s16 int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); // color transform int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); int16x8_t rws = vaddq_s16(yws, cr0); int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); // undo scaling, round, convert to byte uint8x8x4_t o; o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); // store, interleaving r/g/b/a vst4_u8(out, o); out += 8*4; } } #endif for (; i < count; ++i) { int y_fixed = (y[i] << 20) + (1<<19); // rounding int r,g,b; int cr = pcr[i] - 128; int cb = pcb[i] - 128; r = y_fixed + cr* float2fixed(1.40200f); g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); b = y_fixed + cb* float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } out[0] = (stbi_uc)r; out[1] = (stbi_uc)g; out[2] = (stbi_uc)b; out[3] = 255; out += step; } } #endif // set up the kernels static void stbi__setup_jpeg(stbi__jpeg *j) { j->idct_block_kernel = stbi__idct_block; j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; #ifdef STBI_SSE2 if (stbi__sse2_available()) { j->idct_block_kernel = stbi__idct_simd; #ifndef STBI_JPEG_OLD j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; #endif j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; #ifndef STBI_JPEG_OLD j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; #endif j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } // clean up the temporary component buffers static void stbi__cleanup_jpeg(stbi__jpeg *j) { int i; for (i=0; i < j->s->img_n; ++i) { if (j->img_comp[i].raw_data) { STBI_FREE(j->img_comp[i].raw_data); j->img_comp[i].raw_data = NULL; j->img_comp[i].data = NULL; } if (j->img_comp[i].raw_coeff) { STBI_FREE(j->img_comp[i].raw_coeff); j->img_comp[i].raw_coeff = 0; j->img_comp[i].coeff = 0; } if (j->img_comp[i].linebuf) { STBI_FREE(j->img_comp[i].linebuf); j->img_comp[i].linebuf = NULL; } } } typedef struct { resample_row_func resample; stbi_uc *line0,*line1; int hs,vs; // expansion factor in each axis int w_lores; // horizontal pixels pre-expansion int ystep; // how far through vertical expansion we are int ypos; // which pre-expansion row we're on } stbi__resample; static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n; z->s->img_n = 0; // make stbi__cleanup_jpeg safe // validate req_comp if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); // load a jpeg image from whichever source, but leave in YCbCr format if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n; if (z->s->img_n == 3 && n < 3) decode_n = 1; else decode_n = z->s->img_n; // resample and color-convert { int k; unsigned int i,j; stbi_uc *output; stbi_uc *coutput[4]; stbi__resample res_comp[4]; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; // allocate line buffer big enough for upsampling off the edges // with upsample factor of 4 z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; r->ystep = r->vs >> 1; r->w_lores = (z->s->img_x + r->hs-1) / r->hs; r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; else r->resample = stbi__resample_row_generic; } // can't error after this so, this is safe output = (stbi_uc *) stbi__malloc(n * z->s->img_x * z->s->img_y + 1); if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } // now go ahead and resample for (j=0; j < z->s->img_y; ++j) { stbi_uc *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { stbi__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, y_bot ? r->line0 : r->line1, r->w_lores, r->hs); if (++r->ystep >= r->vs) { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } if (n >= 3) { stbi_uc *y = coutput[0]; if (z->s->img_n == 3) { z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); } else for (i=0; i < z->s->img_x; ++i) { out[0] = out[1] = out[2] = y[i]; out[3] = 255; // not used if n==3 out += n; } } else { stbi_uc *y = coutput[0]; if (n == 1) for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; else for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; } } stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; if (comp) *comp = z->s->img_n; // report original components, not output return output; } } static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__jpeg j; j.s = s; stbi__setup_jpeg(&j); return load_jpeg_image(&j, x,y,comp,req_comp); } static int stbi__jpeg_test(stbi__context *s) { int r; stbi__jpeg j; j.s = s; stbi__setup_jpeg(&j); r = stbi__decode_jpeg_header(&j, STBI__SCAN_type); stbi__rewind(s); return r; } static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) { if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { stbi__rewind( j->s ); return 0; } if (x) *x = j->s->img_x; if (y) *y = j->s->img_y; if (comp) *comp = j->s->img_n; return 1; } static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) { stbi__jpeg j; j.s = s; return stbi__jpeg_info_raw(&j, x, y, comp); } #endif // public domain zlib decode v0.2 Sean Barrett 2006-11-18 // simple implementation // - all input must be provided in an upfront buffer // - all output is written to a single output buffer (can malloc/realloc) // performance // - fast huffman #ifndef STBI_NO_ZLIB // fast-way is faster to check than jpeg huffman, but slow way is slower #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables #define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) // zlib-style huffman encoding // (jpegs packs from left, zlib from right, so can't share code) typedef struct { stbi__uint16 fast[1 << STBI__ZFAST_BITS]; stbi__uint16 firstcode[16]; int maxcode[17]; stbi__uint16 firstsymbol[16]; stbi_uc size[288]; stbi__uint16 value[288]; } stbi__zhuffman; stbi_inline static int stbi__bitreverse16(int n) { n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); return n; } stbi_inline static int stbi__bit_reverse(int v, int bits) { STBI_ASSERT(bits <= 16); // to bit reverse n bits, reverse 16 and shift // e.g. 11 bits, bit reverse and shift away 5 return stbi__bitreverse16(v) >> (16-bits); } static int stbi__zbuild_huffman(stbi__zhuffman *z, stbi_uc *sizelist, int num) { int i,k=0; int code, next_code[16], sizes[17]; // DEFLATE spec for generating codes memset(sizes, 0, sizeof(sizes)); memset(z->fast, 0, sizeof(z->fast)); for (i=0; i < num; ++i) ++sizes[sizelist[i]]; sizes[0] = 0; for (i=1; i < 16; ++i) if (sizes[i] > (1 << i)) return stbi__err("bad sizes", "Corrupt PNG"); code = 0; for (i=1; i < 16; ++i) { next_code[i] = code; z->firstcode[i] = (stbi__uint16) code; z->firstsymbol[i] = (stbi__uint16) k; code = (code + sizes[i]); if (sizes[i]) if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); z->maxcode[i] = code << (16-i); // preshift for inner loop code <<= 1; k += sizes[i]; } z->maxcode[16] = 0x10000; // sentinel for (i=0; i < num; ++i) { int s = sizelist[i]; if (s) { int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); z->size [c] = (stbi_uc ) s; z->value[c] = (stbi__uint16) i; if (s <= STBI__ZFAST_BITS) { int j = stbi__bit_reverse(next_code[s],s); while (j < (1 << STBI__ZFAST_BITS)) { z->fast[j] = fastv; j += (1 << s); } } ++next_code[s]; } } return 1; } // zlib-from-memory implementation for PNG reading // because PNG allows splitting the zlib stream arbitrarily, // and it's annoying structurally to have PNG call ZLIB call PNG, // we require PNG read all the IDATs and combine them into a single // memory buffer typedef struct { stbi_uc *zbuffer, *zbuffer_end; int num_bits; stbi__uint32 code_buffer; char *zout; char *zout_start; char *zout_end; int z_expandable; stbi__zhuffman z_length, z_distance; } stbi__zbuf; stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) { if (z->zbuffer >= z->zbuffer_end) return 0; return *z->zbuffer++; } static void stbi__fill_bits(stbi__zbuf *z) { do { STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; z->num_bits += 8; } while (z->num_bits <= 24); } stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) { unsigned int k; if (z->num_bits < n) stbi__fill_bits(z); k = z->code_buffer & ((1 << n) - 1); z->code_buffer >>= n; z->num_bits -= n; return k; } static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) { int b,s,k; // not resolved by fast table, so compute it the slow way // use jpeg approach, which requires MSbits at top k = stbi__bit_reverse(a->code_buffer, 16); for (s=STBI__ZFAST_BITS+1; ; ++s) if (k < z->maxcode[s]) break; if (s == 16) return -1; // invalid code! // code size is s, so: b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; STBI_ASSERT(z->size[b] == s); a->code_buffer >>= s; a->num_bits -= s; return z->value[b]; } stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) { int b,s; if (a->num_bits < 16) stbi__fill_bits(a); b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; if (b) { s = b >> 9; a->code_buffer >>= s; a->num_bits -= s; return b & 511; } return stbi__zhuffman_decode_slowpath(a, z); } static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes { char *q; int cur, limit, old_limit; z->zout = zout; if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); cur = (int) (z->zout - z->zout_start); limit = old_limit = (int) (z->zout_end - z->zout_start); while (cur + n > limit) limit *= 2; q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); STBI_NOTUSED(old_limit); if (q == NULL) return stbi__err("outofmem", "Out of memory"); z->zout_start = q; z->zout = q + cur; z->zout_end = q + limit; return 1; } static int stbi__zlength_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 }; static int stbi__zlength_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; static int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; static int stbi__zdist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; static int stbi__parse_huffman_block(stbi__zbuf *a) { char *zout = a->zout; for(;;) { int z = stbi__zhuffman_decode(a, &a->z_length); if (z < 256) { if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes if (zout >= a->zout_end) { if (!stbi__zexpand(a, zout, 1)) return 0; zout = a->zout; } *zout++ = (char) z; } else { stbi_uc *p; int len,dist; if (z == 256) { a->zout = zout; return 1; } z -= 257; len = stbi__zlength_base[z]; if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); z = stbi__zhuffman_decode(a, &a->z_distance); if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); dist = stbi__zdist_base[z]; if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); if (zout + len > a->zout_end) { if (!stbi__zexpand(a, zout, len)) return 0; zout = a->zout; } p = (stbi_uc *) (zout - dist); if (dist == 1) { // run of one byte; common in images. stbi_uc v = *p; if (len) { do *zout++ = v; while (--len); } } else { if (len) { do *zout++ = *p++; while (--len); } } } } } static int stbi__compute_huffman_codes(stbi__zbuf *a) { static stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; stbi__zhuffman z_codelength; stbi_uc lencodes[286+32+137];//padding for maximum single op stbi_uc codelength_sizes[19]; int i,n; int hlit = stbi__zreceive(a,5) + 257; int hdist = stbi__zreceive(a,5) + 1; int hclen = stbi__zreceive(a,4) + 4; memset(codelength_sizes, 0, sizeof(codelength_sizes)); for (i=0; i < hclen; ++i) { int s = stbi__zreceive(a,3); codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; } if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; n = 0; while (n < hlit + hdist) { int c = stbi__zhuffman_decode(a, &z_codelength); if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); if (c < 16) lencodes[n++] = (stbi_uc) c; else if (c == 16) { c = stbi__zreceive(a,2)+3; memset(lencodes+n, lencodes[n-1], c); n += c; } else if (c == 17) { c = stbi__zreceive(a,3)+3; memset(lencodes+n, 0, c); n += c; } else { STBI_ASSERT(c == 18); c = stbi__zreceive(a,7)+11; memset(lencodes+n, 0, c); n += c; } } if (n != hlit+hdist) return stbi__err("bad codelengths","Corrupt PNG"); if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; return 1; } static int stbi__parse_uncomperssed_block(stbi__zbuf *a) { stbi_uc header[4]; int len,nlen,k; if (a->num_bits & 7) stbi__zreceive(a, a->num_bits & 7); // discard // drain the bit-packed data into header k = 0; while (a->num_bits > 0) { header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check a->code_buffer >>= 8; a->num_bits -= 8; } STBI_ASSERT(a->num_bits == 0); // now fill header the normal way while (k < 4) header[k++] = stbi__zget8(a); len = header[1] * 256 + header[0]; nlen = header[3] * 256 + header[2]; if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); if (a->zout + len > a->zout_end) if (!stbi__zexpand(a, a->zout, len)) return 0; memcpy(a->zout, a->zbuffer, len); a->zbuffer += len; a->zout += len; return 1; } static int stbi__parse_zlib_header(stbi__zbuf *a) { int cmf = stbi__zget8(a); int cm = cmf & 15; /* int cinfo = cmf >> 4; */ int flg = stbi__zget8(a); if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png // window = 1 << (8 + cinfo)... but who cares, we fully buffer output return 1; } // @TODO: should statically initialize these for optimal thread safety static stbi_uc stbi__zdefault_length[288], stbi__zdefault_distance[32]; static void stbi__init_zdefaults(void) { int i; // use <= to match clearly with spec for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; } static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) { int final, type; if (parse_header) if (!stbi__parse_zlib_header(a)) return 0; a->num_bits = 0; a->code_buffer = 0; do { final = stbi__zreceive(a,1); type = stbi__zreceive(a,2); if (type == 0) { if (!stbi__parse_uncomperssed_block(a)) return 0; } else if (type == 3) { return 0; } else { if (type == 1) { // use fixed code lengths if (!stbi__zdefault_distance[31]) stbi__init_zdefaults(); if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , 288)) return 0; if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; } else { if (!stbi__compute_huffman_codes(a)) return 0; } if (!stbi__parse_huffman_block(a)) return 0; } } while (!final); return 1; } static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) { a->zout_start = obuf; a->zout = obuf; a->zout_end = obuf + olen; a->z_expandable = exp; return stbi__parse_zlib(a, parse_header); } STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) { return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); } STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) { stbi__zbuf a; char *p = (char *) stbi__malloc(initial_size); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer + len; if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) return (int) (a.zout - a.zout_start); else return -1; } STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) { stbi__zbuf a; char *p = (char *) stbi__malloc(16384); if (p == NULL) return NULL; a.zbuffer = (stbi_uc *) buffer; a.zbuffer_end = (stbi_uc *) buffer+len; if (stbi__do_zlib(&a, p, 16384, 1, 0)) { if (outlen) *outlen = (int) (a.zout - a.zout_start); return a.zout_start; } else { STBI_FREE(a.zout_start); return NULL; } } STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) { stbi__zbuf a; a.zbuffer = (stbi_uc *) ibuffer; a.zbuffer_end = (stbi_uc *) ibuffer + ilen; if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) return (int) (a.zout - a.zout_start); else return -1; } #endif // public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 // simple implementation // - only 8-bit samples // - no CRC checking // - allocates lots of intermediate memory // - avoids problem of streaming data between subsystems // - avoids explicit window management // performance // - uses stb_zlib, a PD zlib implementation with fast huffman decoding #ifndef STBI_NO_PNG typedef struct { stbi__uint32 length; stbi__uint32 type; } stbi__pngchunk; static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) { stbi__pngchunk c; c.length = stbi__get32be(s); c.type = stbi__get32be(s); return c; } static int stbi__check_png_header(stbi__context *s) { static stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; int i; for (i=0; i < 8; ++i) if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); return 1; } typedef struct { stbi__context *s; stbi_uc *idata, *expanded, *out; } stbi__png; enum { STBI__F_none=0, STBI__F_sub=1, STBI__F_up=2, STBI__F_avg=3, STBI__F_paeth=4, // synthetic filters used for first scanline to avoid needing a dummy row of 0s STBI__F_avg_first, STBI__F_paeth_first }; static stbi_uc first_row_filter[5] = { STBI__F_none, STBI__F_sub, STBI__F_none, STBI__F_avg_first, STBI__F_paeth_first }; static int stbi__paeth(int a, int b, int c) { int p = a + b - c; int pa = abs(p-a); int pb = abs(p-b); int pc = abs(p-c); if (pa <= pb && pa <= pc) return a; if (pb <= pc) return b; return c; } static stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; // create the png data from post-deflated data static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) { stbi__context *s = a->s; stbi__uint32 i,j,stride = x*out_n; stbi__uint32 img_len, img_width_bytes; int k; int img_n = s->img_n; // copy it into a local for later STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); a->out = (stbi_uc *) stbi__malloc(x * y * out_n); // extra bytes to write off the end into if (!a->out) return stbi__err("outofmem", "Out of memory"); img_width_bytes = (((img_n * x * depth) + 7) >> 3); img_len = (img_width_bytes + 1) * y; if (s->img_x == x && s->img_y == y) { if (raw_len != img_len) return stbi__err("not enough pixels","Corrupt PNG"); } else { // interlaced: if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); } for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *prior = cur - stride; int filter = *raw++; int filter_bytes = img_n; int width = x; if (filter > 4) return stbi__err("invalid filter","Corrupt PNG"); if (depth < 8) { STBI_ASSERT(img_width_bytes <= x); cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place filter_bytes = 1; width = img_width_bytes; } // if first row, use special filter that doesn't sample previous row if (j == 0) filter = first_row_filter[filter]; // handle first byte explicitly for (k=0; k < filter_bytes; ++k) { switch (filter) { case STBI__F_none : cur[k] = raw[k]; break; case STBI__F_sub : cur[k] = raw[k]; break; case STBI__F_up : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; case STBI__F_avg : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break; case STBI__F_paeth : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break; case STBI__F_avg_first : cur[k] = raw[k]; break; case STBI__F_paeth_first: cur[k] = raw[k]; break; } } if (depth == 8) { if (img_n != out_n) cur[img_n] = 255; // first pixel raw += img_n; cur += out_n; prior += out_n; } else { raw += 1; cur += 1; prior += 1; } // this is a little gross, so that we don't switch per-pixel or per-component if (depth < 8 || img_n == out_n) { int nk = (width - 1)*img_n; #define CASE(f) \ case f: \ for (k=0; k < nk; ++k) switch (filter) { // "none" filter turns into a memcpy here; make that explicit. case STBI__F_none: memcpy(cur, raw, nk); break; CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); break; CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); break; CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); break; CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); break; CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); break; } #undef CASE raw += nk; } else { STBI_ASSERT(img_n+1 == out_n); #define CASE(f) \ case f: \ for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \ for (k=0; k < img_n; ++k) switch (filter) { CASE(STBI__F_none) cur[k] = raw[k]; break; CASE(STBI__F_sub) cur[k] = STBI__BYTECAST(raw[k] + cur[k-out_n]); break; CASE(STBI__F_up) cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; CASE(STBI__F_avg) cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-out_n])>>1)); break; CASE(STBI__F_paeth) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],prior[k],prior[k-out_n])); break; CASE(STBI__F_avg_first) cur[k] = STBI__BYTECAST(raw[k] + (cur[k-out_n] >> 1)); break; CASE(STBI__F_paeth_first) cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-out_n],0,0)); break; } #undef CASE } } // we make a separate pass to expand bits to pixels; for performance, // this could run two scanlines behind the above code, so it won't // intefere with filtering but will still be in the cache. if (depth < 8) { for (j=0; j < y; ++j) { stbi_uc *cur = a->out + stride*j; stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range // note that the final byte might overshoot and write more data than desired. // we can allocate enough data that this never writes out of memory, but it // could also overwrite the next scanline. can it overwrite non-empty data // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. // so we need to explicitly clamp the final ones if (depth == 4) { for (k=x*img_n; k >= 2; k-=2, ++in) { *cur++ = scale * ((*in >> 4) ); *cur++ = scale * ((*in ) & 0x0f); } if (k > 0) *cur++ = scale * ((*in >> 4) ); } else if (depth == 2) { for (k=x*img_n; k >= 4; k-=4, ++in) { *cur++ = scale * ((*in >> 6) ); *cur++ = scale * ((*in >> 4) & 0x03); *cur++ = scale * ((*in >> 2) & 0x03); *cur++ = scale * ((*in ) & 0x03); } if (k > 0) *cur++ = scale * ((*in >> 6) ); if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); } else if (depth == 1) { for (k=x*img_n; k >= 8; k-=8, ++in) { *cur++ = scale * ((*in >> 7) ); *cur++ = scale * ((*in >> 6) & 0x01); *cur++ = scale * ((*in >> 5) & 0x01); *cur++ = scale * ((*in >> 4) & 0x01); *cur++ = scale * ((*in >> 3) & 0x01); *cur++ = scale * ((*in >> 2) & 0x01); *cur++ = scale * ((*in >> 1) & 0x01); *cur++ = scale * ((*in ) & 0x01); } if (k > 0) *cur++ = scale * ((*in >> 7) ); if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); } if (img_n != out_n) { int q; // insert alpha = 255 cur = a->out + stride*j; if (img_n == 1) { for (q=x-1; q >= 0; --q) { cur[q*2+1] = 255; cur[q*2+0] = cur[q]; } } else { STBI_ASSERT(img_n == 3); for (q=x-1; q >= 0; --q) { cur[q*4+3] = 255; cur[q*4+2] = cur[q*3+2]; cur[q*4+1] = cur[q*3+1]; cur[q*4+0] = cur[q*3+0]; } } } } } return 1; } static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) { stbi_uc *final; int p; if (!interlaced) return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); // de-interlacing final = (stbi_uc *) stbi__malloc(a->s->img_x * a->s->img_y * out_n); for (p=0; p < 7; ++p) { int xorig[] = { 0,4,0,2,0,1,0 }; int yorig[] = { 0,0,4,0,2,0,1 }; int xspc[] = { 8,8,4,4,2,2,1 }; int yspc[] = { 8,8,8,4,4,2,2 }; int i,j,x,y; // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; if (x && y) { stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { STBI_FREE(final); return 0; } for (j=0; j < y; ++j) { for (i=0; i < x; ++i) { int out_y = j*yspc[p]+yorig[p]; int out_x = i*xspc[p]+xorig[p]; memcpy(final + out_y*a->s->img_x*out_n + out_x*out_n, a->out + (j*x+i)*out_n, out_n); } } STBI_FREE(a->out); image_data += img_len; image_data_len -= img_len; } } a->out = final; return 1; } static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; // compute color-based transparency, assuming we've // already got 255 as the alpha value in the output STBI_ASSERT(out_n == 2 || out_n == 4); if (out_n == 2) { for (i=0; i < pixel_count; ++i) { p[1] = (p[0] == tc[0] ? 0 : 255); p += 2; } } else { for (i=0; i < pixel_count; ++i) { if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) p[3] = 0; p += 4; } } return 1; } static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) { stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; stbi_uc *p, *temp_out, *orig = a->out; p = (stbi_uc *) stbi__malloc(pixel_count * pal_img_n); if (p == NULL) return stbi__err("outofmem", "Out of memory"); // between here and free(out) below, exitting would leak temp_out = p; if (pal_img_n == 3) { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p += 3; } } else { for (i=0; i < pixel_count; ++i) { int n = orig[i]*4; p[0] = palette[n ]; p[1] = palette[n+1]; p[2] = palette[n+2]; p[3] = palette[n+3]; p += 4; } } STBI_FREE(a->out); a->out = temp_out; STBI_NOTUSED(len); return 1; } static int stbi__unpremultiply_on_load = 0; static int stbi__de_iphone_flag = 0; STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) { stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; } STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) { stbi__de_iphone_flag = flag_true_if_should_convert; } static void stbi__de_iphone(stbi__png *z) { stbi__context *s = z->s; stbi__uint32 i, pixel_count = s->img_x * s->img_y; stbi_uc *p = z->out; if (s->img_out_n == 3) { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 3; } } else { STBI_ASSERT(s->img_out_n == 4); if (stbi__unpremultiply_on_load) { // convert bgr to rgb and unpremultiply for (i=0; i < pixel_count; ++i) { stbi_uc a = p[3]; stbi_uc t = p[0]; if (a) { p[0] = p[2] * 255 / a; p[1] = p[1] * 255 / a; p[2] = t * 255 / a; } else { p[0] = p[2]; p[2] = t; } p += 4; } } else { // convert bgr to rgb for (i=0; i < pixel_count; ++i) { stbi_uc t = p[0]; p[0] = p[2]; p[2] = t; p += 4; } } } } #define STBI__PNG_TYPE(a,b,c,d) (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) { stbi_uc palette[1024], pal_img_n=0; stbi_uc has_trans=0, tc[3]; stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; int first=1,k,interlace=0, color=0, depth=0, is_iphone=0; stbi__context *s = z->s; z->expanded = NULL; z->idata = NULL; z->out = NULL; if (!stbi__check_png_header(s)) return 0; if (scan == STBI__SCAN_type) return 1; for (;;) { stbi__pngchunk c = stbi__get_chunk_header(s); switch (c.type) { case STBI__PNG_TYPE('C','g','B','I'): is_iphone = 1; stbi__skip(s, c.length); break; case STBI__PNG_TYPE('I','H','D','R'): { int comp,filter; if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); first = 0; if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large","Very large image (corrupt?)"); depth = stbi__get8(s); if (depth != 1 && depth != 2 && depth != 4 && depth != 8) return stbi__err("1/2/4/8-bit only","PNG not supported: 1/2/4/8-bit only"); color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); if (!pal_img_n) { s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); if (scan == STBI__SCAN_header) return 1; } else { // if paletted, then pal_n is our final components, and // img_n is # components to decompress/filter. s->img_n = 1; if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); // if SCAN_header, have to scan to see if we have a tRNS } break; } case STBI__PNG_TYPE('P','L','T','E'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); pal_len = c.length / 3; if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); for (i=0; i < pal_len; ++i) { palette[i*4+0] = stbi__get8(s); palette[i*4+1] = stbi__get8(s); palette[i*4+2] = stbi__get8(s); palette[i*4+3] = 255; } break; } case STBI__PNG_TYPE('t','R','N','S'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); if (pal_img_n) { if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); pal_img_n = 4; for (i=0; i < c.length; ++i) palette[i*4+3] = stbi__get8(s); } else { if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); has_trans = 1; for (k=0; k < s->img_n; ++k) tc[k] = (stbi_uc) (stbi__get16be(s) & 255) * stbi__depth_scale_table[depth]; // non 8-bit images will be larger } break; } case STBI__PNG_TYPE('I','D','A','T'): { if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } if ((int)(ioff + c.length) < (int)ioff) return 0; if (ioff + c.length > idata_limit) { stbi__uint32 idata_limit_old = idata_limit; stbi_uc *p; if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; while (ioff + c.length > idata_limit) idata_limit *= 2; STBI_NOTUSED(idata_limit_old); p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); z->idata = p; } if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); ioff += c.length; break; } case STBI__PNG_TYPE('I','E','N','D'): { stbi__uint32 raw_len, bpl; if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if (scan != STBI__SCAN_load) return 1; if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); // initial guess for decoded data size to avoid unnecessary reallocs bpl = (s->img_x * depth + 7) / 8; // bytes per line, per component raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); if (z->expanded == NULL) return 0; // zlib should set error STBI_FREE(z->idata); z->idata = NULL; if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) s->img_out_n = s->img_n+1; else s->img_out_n = s->img_n; if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, depth, color, interlace)) return 0; if (has_trans) if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) stbi__de_iphone(z); if (pal_img_n) { // pal_img_n == 3 or 4 s->img_n = pal_img_n; // record the actual colors we had s->img_out_n = pal_img_n; if (req_comp >= 3) s->img_out_n = req_comp; if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) return 0; } STBI_FREE(z->expanded); z->expanded = NULL; return 1; } default: // if critical, fail if (first) return stbi__err("first not IHDR", "Corrupt PNG"); if ((c.type & (1 << 29)) == 0) { #ifndef STBI_NO_FAILURE_STRINGS // not threadsafe static char invalid_chunk[] = "XXXX PNG chunk not known"; invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); #endif return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); } stbi__skip(s, c.length); break; } // end of PNG chunk, read and skip CRC stbi__get32be(s); } } static unsigned char *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp) { unsigned char *result=NULL; if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { result = p->out; p->out = NULL; if (req_comp && req_comp != p->s->img_out_n) { result = stbi__convert_format(result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); p->s->img_out_n = req_comp; if (result == NULL) return result; } *x = p->s->img_x; *y = p->s->img_y; if (n) *n = p->s->img_out_n; } STBI_FREE(p->out); p->out = NULL; STBI_FREE(p->expanded); p->expanded = NULL; STBI_FREE(p->idata); p->idata = NULL; return result; } static unsigned char *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi__png p; p.s = s; return stbi__do_png(&p, x,y,comp,req_comp); } static int stbi__png_test(stbi__context *s) { int r; r = stbi__check_png_header(s); stbi__rewind(s); return r; } static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) { if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { stbi__rewind( p->s ); return 0; } if (x) *x = p->s->img_x; if (y) *y = p->s->img_y; if (comp) *comp = p->s->img_n; return 1; } static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) { stbi__png p; p.s = s; return stbi__png_info_raw(&p, x, y, comp); } #endif // Microsoft/Windows BMP image #ifndef STBI_NO_BMP static int stbi__bmp_test_raw(stbi__context *s) { int r; int sz; if (stbi__get8(s) != 'B') return 0; if (stbi__get8(s) != 'M') return 0; stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved stbi__get32le(s); // discard data offset sz = stbi__get32le(s); r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); return r; } static int stbi__bmp_test(stbi__context *s) { int r = stbi__bmp_test_raw(s); stbi__rewind(s); return r; } // returns 0..31 for the highest set bit static int stbi__high_bit(unsigned int z) { int n=0; if (z == 0) return -1; if (z >= 0x10000) n += 16, z >>= 16; if (z >= 0x00100) n += 8, z >>= 8; if (z >= 0x00010) n += 4, z >>= 4; if (z >= 0x00004) n += 2, z >>= 2; if (z >= 0x00002) n += 1, z >>= 1; return n; } static int stbi__bitcount(unsigned int a) { a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits a = (a + (a >> 8)); // max 16 per 8 bits a = (a + (a >> 16)); // max 32 per 8 bits return a & 0xff; } static int stbi__shiftsigned(int v, int shift, int bits) { int result; int z=0; if (shift < 0) v <<= -shift; else v >>= shift; result = v; z = bits; while (z < 8) { result += v >> z; z += bits; } return result; } typedef struct { int bpp, offset, hsz; unsigned int mr,mg,mb,ma, all_a; } stbi__bmp_data; static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) { int hsz; if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); stbi__get32le(s); // discard filesize stbi__get16le(s); // discard reserved stbi__get16le(s); // discard reserved info->offset = stbi__get32le(s); info->hsz = hsz = stbi__get32le(s); if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); if (hsz == 12) { s->img_x = stbi__get16le(s); s->img_y = stbi__get16le(s); } else { s->img_x = stbi__get32le(s); s->img_y = stbi__get32le(s); } if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); info->bpp = stbi__get16le(s); if (info->bpp == 1) return stbi__errpuc("monochrome", "BMP type not supported: 1-bit"); if (hsz != 12) { int compress = stbi__get32le(s); if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); stbi__get32le(s); // discard sizeof stbi__get32le(s); // discard hres stbi__get32le(s); // discard vres stbi__get32le(s); // discard colorsused stbi__get32le(s); // discard max important if (hsz == 40 || hsz == 56) { if (hsz == 56) { stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); stbi__get32le(s); } if (info->bpp == 16 || info->bpp == 32) { info->mr = info->mg = info->mb = 0; if (compress == 0) { if (info->bpp == 32) { info->mr = 0xffu << 16; info->mg = 0xffu << 8; info->mb = 0xffu << 0; info->ma = 0xffu << 24; info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 } else { info->mr = 31u << 10; info->mg = 31u << 5; info->mb = 31u << 0; } } else if (compress == 3) { info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); // not documented, but generated by photoshop and handled by mspaint if (info->mr == info->mg && info->mg == info->mb) { // ?!?!? return stbi__errpuc("bad BMP", "bad BMP"); } } else return stbi__errpuc("bad BMP", "bad BMP"); } } else { int i; if (hsz != 108 && hsz != 124) return stbi__errpuc("bad BMP", "bad BMP"); info->mr = stbi__get32le(s); info->mg = stbi__get32le(s); info->mb = stbi__get32le(s); info->ma = stbi__get32le(s); stbi__get32le(s); // discard color space for (i=0; i < 12; ++i) stbi__get32le(s); // discard color space parameters if (hsz == 124) { stbi__get32le(s); // discard rendering intent stbi__get32le(s); // discard offset of profile data stbi__get32le(s); // discard size of profile data stbi__get32le(s); // discard reserved } } } return (void *) 1; } static stbi_uc *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi_uc *out; unsigned int mr=0,mg=0,mb=0,ma=0, all_a; stbi_uc pal[256][4]; int psize=0,i,j,width; int flip_vertically, pad, target; stbi__bmp_data info; info.all_a = 255; if (stbi__bmp_parse_header(s, &info) == NULL) return NULL; // error code already set flip_vertically = ((int) s->img_y) > 0; s->img_y = abs((int) s->img_y); mr = info.mr; mg = info.mg; mb = info.mb; ma = info.ma; all_a = info.all_a; if (info.hsz == 12) { if (info.bpp < 24) psize = (info.offset - 14 - 24) / 3; } else { if (info.bpp < 16) psize = (info.offset - 14 - info.hsz) >> 2; } s->img_n = ma ? 4 : 3; if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 target = req_comp; else target = s->img_n; // if they want monochrome, we'll post-convert out = (stbi_uc *) stbi__malloc(target * s->img_x * s->img_y); if (!out) return stbi__errpuc("outofmem", "Out of memory"); if (info.bpp < 16) { int z=0; if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } for (i=0; i < psize; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); if (info.hsz != 12) stbi__get8(s); pal[i][3] = 255; } stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); if (info.bpp == 4) width = (s->img_x + 1) >> 1; else if (info.bpp == 8) width = s->img_x; else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } pad = (-width)&3; for (j=0; j < (int) s->img_y; ++j) { for (i=0; i < (int) s->img_x; i += 2) { int v=stbi__get8(s),v2=0; if (info.bpp == 4) { v2 = v & 15; v >>= 4; } out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; if (i+1 == (int) s->img_x) break; v = (info.bpp == 8) ? stbi__get8(s) : v2; out[z++] = pal[v][0]; out[z++] = pal[v][1]; out[z++] = pal[v][2]; if (target == 4) out[z++] = 255; } stbi__skip(s, pad); } } else { int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; int z = 0; int easy=0; stbi__skip(s, info.offset - 14 - info.hsz); if (info.bpp == 24) width = 3 * s->img_x; else if (info.bpp == 16) width = 2*s->img_x; else /* bpp = 32 and pad = 0 */ width=0; pad = (-width) & 3; if (info.bpp == 24) { easy = 1; } else if (info.bpp == 32) { if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) easy = 2; } if (!easy) { if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } // right shift amt to put high bit in position #7 rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); } for (j=0; j < (int) s->img_y; ++j) { if (easy) { for (i=0; i < (int) s->img_x; ++i) { unsigned char a; out[z+2] = stbi__get8(s); out[z+1] = stbi__get8(s); out[z+0] = stbi__get8(s); z += 3; a = (easy == 2 ? stbi__get8(s) : 255); all_a |= a; if (target == 4) out[z++] = a; } } else { int bpp = info.bpp; for (i=0; i < (int) s->img_x; ++i) { stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); int a; out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); all_a |= a; if (target == 4) out[z++] = STBI__BYTECAST(a); } } stbi__skip(s, pad); } } // if alpha channel is all 0s, replace with all 255s if (target == 4 && all_a == 0) for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) out[i] = 255; if (flip_vertically) { stbi_uc t; for (j=0; j < (int) s->img_y>>1; ++j) { stbi_uc *p1 = out + j *s->img_x*target; stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; for (i=0; i < (int) s->img_x*target; ++i) { t = p1[i], p1[i] = p2[i], p2[i] = t; } } } if (req_comp && req_comp != target) { out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } *x = s->img_x; *y = s->img_y; if (comp) *comp = s->img_n; return out; } #endif // Targa Truevision - TGA // by Jonathan Dummer #ifndef STBI_NO_TGA // returns STBI_rgb or whatever, 0 on error static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) { // only RGB or RGBA (incl. 16bit) or grey allowed if(is_rgb16) *is_rgb16 = 0; switch(bits_per_pixel) { case 8: return STBI_grey; case 16: if(is_grey) return STBI_grey_alpha; // else: fall-through case 15: if(is_rgb16) *is_rgb16 = 1; return STBI_rgb; case 24: // fall-through case 32: return bits_per_pixel/8; default: return 0; } } static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) { int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; int sz, tga_colormap_type; stbi__get8(s); // discard Offset tga_colormap_type = stbi__get8(s); // colormap type if( tga_colormap_type > 1 ) { stbi__rewind(s); return 0; // only RGB or indexed allowed } tga_image_type = stbi__get8(s); // image type if ( tga_colormap_type == 1 ) { // colormapped (paletted) image if (tga_image_type != 1 && tga_image_type != 9) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { stbi__rewind(s); return 0; } stbi__skip(s,4); // skip image x and y origin tga_colormap_bpp = sz; } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { stbi__rewind(s); return 0; // only RGB or grey allowed, +/- RLE } stbi__skip(s,9); // skip colormap specification and image x/y origin tga_colormap_bpp = 0; } tga_w = stbi__get16le(s); if( tga_w < 1 ) { stbi__rewind(s); return 0; // test width } tga_h = stbi__get16le(s); if( tga_h < 1 ) { stbi__rewind(s); return 0; // test height } tga_bits_per_pixel = stbi__get8(s); // bits per pixel stbi__get8(s); // ignore alpha bits if (tga_colormap_bpp != 0) { if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { // when using a colormap, tga_bits_per_pixel is the size of the indexes // I don't think anything but 8 or 16bit indexes makes sense stbi__rewind(s); return 0; } tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); } else { tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); } if(!tga_comp) { stbi__rewind(s); return 0; } if (x) *x = tga_w; if (y) *y = tga_h; if (comp) *comp = tga_comp; return 1; // seems to have passed everything } static int stbi__tga_test(stbi__context *s) { int res = 0; int sz, tga_color_type; stbi__get8(s); // discard Offset tga_color_type = stbi__get8(s); // color type if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed sz = stbi__get8(s); // image type if ( tga_color_type == 1 ) { // colormapped (paletted) image if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 stbi__skip(s,4); // skip index of first colormap entry and number of entries sz = stbi__get8(s); // check bits per palette color entry if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; stbi__skip(s,4); // skip image x and y origin } else { // "normal" image w/o colormap if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE stbi__skip(s,9); // skip colormap specification and image x/y origin } if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height sz = stbi__get8(s); // bits per pixel if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; res = 1; // if we got this far, everything's good and we can return 1 instead of 0 errorEnd: stbi__rewind(s); return res; } // read 16bit value and convert to 24bit RGB void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) { stbi__uint16 px = stbi__get16le(s); stbi__uint16 fiveBitMask = 31; // we have 3 channels with 5bits each int r = (px >> 10) & fiveBitMask; int g = (px >> 5) & fiveBitMask; int b = px & fiveBitMask; // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later out[0] = (r * 255)/31; out[1] = (g * 255)/31; out[2] = (b * 255)/31; // some people claim that the most significant bit might be used for alpha // (possibly if an alpha-bit is set in the "image descriptor byte") // but that only made 16bit test images completely translucent.. // so let's treat all 15 and 16bit TGAs as RGB with no alpha. } static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { // read in the TGA header stuff int tga_offset = stbi__get8(s); int tga_indexed = stbi__get8(s); int tga_image_type = stbi__get8(s); int tga_is_RLE = 0; int tga_palette_start = stbi__get16le(s); int tga_palette_len = stbi__get16le(s); int tga_palette_bits = stbi__get8(s); int tga_x_origin = stbi__get16le(s); int tga_y_origin = stbi__get16le(s); int tga_width = stbi__get16le(s); int tga_height = stbi__get16le(s); int tga_bits_per_pixel = stbi__get8(s); int tga_comp, tga_rgb16=0; int tga_inverted = stbi__get8(s); // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) // image data unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; unsigned char raw_data[4]; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; // do a tiny bit of precessing if ( tga_image_type >= 8 ) { tga_image_type -= 8; tga_is_RLE = 1; } tga_inverted = 1 - ((tga_inverted >> 5) & 1); // If I'm paletted, then I'll use the number of bits from the palette if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); // tga info *x = tga_width; *y = tga_height; if (comp) *comp = tga_comp; tga_data = (unsigned char*)stbi__malloc( (size_t)tga_width * tga_height * tga_comp ); if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); // skip to the data's starting position (offset usually = 0) stbi__skip(s, tga_offset ); if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { for (i=0; i < tga_height; ++i) { int row = tga_inverted ? tga_height -i - 1 : i; stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; stbi__getn(s, tga_row, tga_width * tga_comp); } } else { // do I need to load a palette? if ( tga_indexed) { // any data to skip? (offset usually = 0) stbi__skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)stbi__malloc( tga_palette_len * tga_comp ); if (!tga_palette) { STBI_FREE(tga_data); return stbi__errpuc("outofmem", "Out of memory"); } if (tga_rgb16) { stbi_uc *pal_entry = tga_palette; STBI_ASSERT(tga_comp == STBI_rgb); for (i=0; i < tga_palette_len; ++i) { stbi__tga_read_rgb16(s, pal_entry); pal_entry += tga_comp; } } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { STBI_FREE(tga_data); STBI_FREE(tga_palette); return stbi__errpuc("bad palette", "Corrupt TGA"); } } // load the data for (i=0; i < tga_width * tga_height; ++i) { // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? if ( tga_is_RLE ) { if ( RLE_count == 0 ) { // yep, get the next byte as a RLE command int RLE_cmd = stbi__get8(s); RLE_count = 1 + (RLE_cmd & 127); RLE_repeating = RLE_cmd >> 7; read_next_pixel = 1; } else if ( !RLE_repeating ) { read_next_pixel = 1; } } else { read_next_pixel = 1; } // OK, if I need to read a pixel, do it now if ( read_next_pixel ) { // load however much data we did have if ( tga_indexed ) { // read in index, then perform the lookup int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); if ( pal_idx >= tga_palette_len ) { // invalid index pal_idx = 0; } pal_idx *= tga_comp; for (j = 0; j < tga_comp; ++j) { raw_data[j] = tga_palette[pal_idx+j]; } } else if(tga_rgb16) { STBI_ASSERT(tga_comp == STBI_rgb); stbi__tga_read_rgb16(s, raw_data); } else { // read in the data raw for (j = 0; j < tga_comp; ++j) { raw_data[j] = stbi__get8(s); } } // clear the reading flag for the next pixel read_next_pixel = 0; } // end of reading a pixel // copy data for (j = 0; j < tga_comp; ++j) tga_data[i*tga_comp+j] = raw_data[j]; // in case we're in RLE mode, keep counting down --RLE_count; } // do I need to invert the image? if ( tga_inverted ) { for (j = 0; j*2 < tga_height; ++j) { int index1 = j * tga_width * tga_comp; int index2 = (tga_height - 1 - j) * tga_width * tga_comp; for (i = tga_width * tga_comp; i > 0; --i) { unsigned char temp = tga_data[index1]; tga_data[index1] = tga_data[index2]; tga_data[index2] = temp; ++index1; ++index2; } } } // clear my palette, if I had one if ( tga_palette != NULL ) { STBI_FREE( tga_palette ); } } // swap RGB - if the source data was RGB16, it already is in the right order if (tga_comp >= 3 && !tga_rgb16) { unsigned char* tga_pixel = tga_data; for (i=0; i < tga_width * tga_height; ++i) { unsigned char temp = tga_pixel[0]; tga_pixel[0] = tga_pixel[2]; tga_pixel[2] = temp; tga_pixel += tga_comp; } } // convert to target component count if (req_comp && req_comp != tga_comp) tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); // the things I do to get rid of an error message, and yet keep // Microsoft's C compilers happy... [8^( tga_palette_start = tga_palette_len = tga_palette_bits = tga_x_origin = tga_y_origin = 0; // OK, done return tga_data; } #endif // ************************************************************************************************* // Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB #ifndef STBI_NO_PSD static int stbi__psd_test(stbi__context *s) { int r = (stbi__get32be(s) == 0x38425053); stbi__rewind(s); return r; } static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { int pixelCount; int channelCount, compression; int channel, i, count, len; int bitdepth; int w,h; stbi_uc *out; // Check identifier if (stbi__get32be(s) != 0x38425053) // "8BPS" return stbi__errpuc("not PSD", "Corrupt PSD image"); // Check file type version. if (stbi__get16be(s) != 1) return stbi__errpuc("wrong version", "Unsupported version of PSD image"); // Skip 6 reserved bytes. stbi__skip(s, 6 ); // Read the number of channels (R, G, B, A, etc). channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); // Read the rows and columns of the image. h = stbi__get32be(s); w = stbi__get32be(s); // Make sure the depth is 8 bits. bitdepth = stbi__get16be(s); if (bitdepth != 8 && bitdepth != 16) return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); // Make sure the color mode is RGB. // Valid options are: // 0: Bitmap // 1: Grayscale // 2: Indexed color // 3: RGB color // 4: CMYK color // 7: Multichannel // 8: Duotone // 9: Lab color if (stbi__get16be(s) != 3) return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) stbi__skip(s,stbi__get32be(s) ); // Skip the image resources. (resolution, pen tool paths, etc) stbi__skip(s, stbi__get32be(s) ); // Skip the reserved data. stbi__skip(s, stbi__get32be(s) ); // Find out if the data is compressed. // Known values: // 0: no compression // 1: RLE compressed compression = stbi__get16be(s); if (compression > 1) return stbi__errpuc("bad compression", "PSD has an unknown compression format"); // Create the destination image. out = (stbi_uc *) stbi__malloc(4 * w*h); if (!out) return stbi__errpuc("outofmem", "Out of memory"); pixelCount = w*h; // Initialize the data to zero. //memset( out, 0, pixelCount * 4 ); // Finally, the image data. if (compression) { // RLE as used by .PSD and .TIFF // Loop until you get the number of unpacked bytes you are expecting: // Read the next source byte into n. // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. // Else if n is 128, noop. // Endloop // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, // which we're going to just skip. stbi__skip(s, h * channelCount * 2 ); // Read the RLE data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out+channel; if (channel >= channelCount) { // Fill this channel with default data. for (i = 0; i < pixelCount; i++, p += 4) *p = (channel == 3 ? 255 : 0); } else { // Read the RLE data. count = 0; while (count < pixelCount) { len = stbi__get8(s); if (len == 128) { // No-op. } else if (len < 128) { // Copy next len+1 bytes literally. len++; count += len; while (len) { *p = stbi__get8(s); p += 4; len--; } } else if (len > 128) { stbi_uc val; // Next -len+1 bytes in the dest are replicated from next source byte. // (Interpret len as a negative 8-bit int.) len ^= 0x0FF; len += 2; val = stbi__get8(s); count += len; while (len) { *p = val; p += 4; len--; } } } } } } else { // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) // where each channel consists of an 8-bit value for each pixel in the image. // Read the data by channel. for (channel = 0; channel < 4; channel++) { stbi_uc *p; p = out + channel; if (channel >= channelCount) { // Fill this channel with default data. stbi_uc val = channel == 3 ? 255 : 0; for (i = 0; i < pixelCount; i++, p += 4) *p = val; } else { // Read the data. if (bitdepth == 16) { for (i = 0; i < pixelCount; i++, p += 4) *p = (stbi_uc) (stbi__get16be(s) >> 8); } else { for (i = 0; i < pixelCount; i++, p += 4) *p = stbi__get8(s); } } } } if (req_comp && req_comp != 4) { out = stbi__convert_format(out, 4, req_comp, w, h); if (out == NULL) return out; // stbi__convert_format frees input on failure } if (comp) *comp = 4; *y = h; *x = w; return out; } #endif // ************************************************************************************************* // Softimage PIC loader // by Tom Seddon // // See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format // See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ #ifndef STBI_NO_PIC static int stbi__pic_is4(stbi__context *s,const char *str) { int i; for (i=0; i<4; ++i) if (stbi__get8(s) != (stbi_uc)str[i]) return 0; return 1; } static int stbi__pic_test_core(stbi__context *s) { int i; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) return 0; for(i=0;i<84;++i) stbi__get8(s); if (!stbi__pic_is4(s,"PICT")) return 0; return 1; } typedef struct { stbi_uc size,type,channel; } stbi__pic_packet; static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) { int mask=0x80, i; for (i=0; i<4; ++i, mask>>=1) { if (channel & mask) { if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); dest[i]=stbi__get8(s); } } return dest; } static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) { int mask=0x80,i; for (i=0;i<4; ++i, mask>>=1) if (channel&mask) dest[i]=src[i]; } static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) { int act_comp=0,num_packets=0,y,chained; stbi__pic_packet packets[10]; // this will (should...) cater for even some bizarre stuff like having data // for the same channel in multiple packets. do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return stbi__errpuc("bad format","too many packets"); packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? for(y=0; ytype) { default: return stbi__errpuc("bad format","packet has bad compression type"); case 0: {//uncompressed int x; for(x=0;xchannel,dest)) return 0; break; } case 1://Pure RLE { int left=width, i; while (left>0) { stbi_uc count,value[4]; count=stbi__get8(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); if (count > left) count = (stbi_uc) left; if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0; ichannel,dest,value); left -= count; } } break; case 2: {//Mixed RLE int left=width; while (left>0) { int count = stbi__get8(s), i; if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); if (count >= 128) { // Repeated stbi_uc value[4]; if (count==128) count = stbi__get16be(s); else count -= 127; if (count > left) return stbi__errpuc("bad file","scanline overrun"); if (!stbi__readval(s,packet->channel,value)) return 0; for(i=0;ichannel,dest,value); } else { // Raw ++count; if (count>left) return stbi__errpuc("bad file","scanline overrun"); for(i=0;ichannel,dest)) return 0; } left-=count; } break; } } } } return result; } static stbi_uc *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp) { stbi_uc *result; int i, x,y; for (i=0; i<92; ++i) stbi__get8(s); x = stbi__get16be(s); y = stbi__get16be(s); if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); if ((1 << 28) / x < y) return stbi__errpuc("too large", "Image too large to decode"); stbi__get32be(s); //skip `ratio' stbi__get16be(s); //skip `fields' stbi__get16be(s); //skip `pad' // intermediate buffer is RGBA result = (stbi_uc *) stbi__malloc(x*y*4); memset(result, 0xff, x*y*4); if (!stbi__pic_load_core(s,x,y,comp, result)) { STBI_FREE(result); result=0; } *px = x; *py = y; if (req_comp == 0) req_comp = *comp; result=stbi__convert_format(result,4,req_comp,x,y); return result; } static int stbi__pic_test(stbi__context *s) { int r = stbi__pic_test_core(s); stbi__rewind(s); return r; } #endif // ************************************************************************************************* // GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb #ifndef STBI_NO_GIF typedef struct { stbi__int16 prefix; stbi_uc first; stbi_uc suffix; } stbi__gif_lzw; typedef struct { int w,h; stbi_uc *out, *old_out; // output buffer (always 4 components) int flags, bgindex, ratio, transparent, eflags, delay; stbi_uc pal[256][4]; stbi_uc lpal[256][4]; stbi__gif_lzw codes[4096]; stbi_uc *color_table; int parse, step; int lflags; int start_x, start_y; int max_x, max_y; int cur_x, cur_y; int line_size; } stbi__gif; static int stbi__gif_test_raw(stbi__context *s) { int sz; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; sz = stbi__get8(s); if (sz != '9' && sz != '7') return 0; if (stbi__get8(s) != 'a') return 0; return 1; } static int stbi__gif_test(stbi__context *s) { int r = stbi__gif_test_raw(s); stbi__rewind(s); return r; } static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) { int i; for (i=0; i < num_entries; ++i) { pal[i][2] = stbi__get8(s); pal[i][1] = stbi__get8(s); pal[i][0] = stbi__get8(s); pal[i][3] = transp == i ? 0 : 255; } } static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) { stbi_uc version; if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return stbi__err("not GIF", "Corrupt GIF"); version = stbi__get8(s); if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); stbi__g_failure_reason = ""; g->w = stbi__get16le(s); g->h = stbi__get16le(s); g->flags = stbi__get8(s); g->bgindex = stbi__get8(s); g->ratio = stbi__get8(s); g->transparent = -1; if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments if (is_info) return 1; if (g->flags & 0x80) stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); return 1; } static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) { stbi__gif g; if (!stbi__gif_header(s, &g, comp, 1)) { stbi__rewind( s ); return 0; } if (x) *x = g.w; if (y) *y = g.h; return 1; } static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) { stbi_uc *p, *c; // recurse to decode the prefixes, since the linked-list is backwards, // and working backwards through an interleaved image would be nasty if (g->codes[code].prefix >= 0) stbi__out_gif_code(g, g->codes[code].prefix); if (g->cur_y >= g->max_y) return; p = &g->out[g->cur_x + g->cur_y]; c = &g->color_table[g->codes[code].suffix * 4]; if (c[3] >= 128) { p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = c[3]; } g->cur_x += 4; if (g->cur_x >= g->max_x) { g->cur_x = g->start_x; g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { g->step = (1 << g->parse) * g->line_size; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } } } static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) { stbi_uc lzw_cs; stbi__int32 len, init_code; stbi__uint32 first; stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; stbi__gif_lzw *p; lzw_cs = stbi__get8(s); if (lzw_cs > 12) return NULL; clear = 1 << lzw_cs; first = 1; codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; bits = 0; valid_bits = 0; for (init_code = 0; init_code < clear; init_code++) { g->codes[init_code].prefix = -1; g->codes[init_code].first = (stbi_uc) init_code; g->codes[init_code].suffix = (stbi_uc) init_code; } // support no starting clear code avail = clear+2; oldcode = -1; len = 0; for(;;) { if (valid_bits < codesize) { if (len == 0) { len = stbi__get8(s); // start new block if (len == 0) return g->out; } --len; bits |= (stbi__int32) stbi__get8(s) << valid_bits; valid_bits += 8; } else { stbi__int32 code = bits & codemask; bits >>= codesize; valid_bits -= codesize; // @OPTIMIZE: is there some way we can accelerate the non-clear path? if (code == clear) { // clear code codesize = lzw_cs + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; first = 0; } else if (code == clear + 1) { // end of stream code stbi__skip(s, len); while ((len = stbi__get8(s)) > 0) stbi__skip(s,len); return g->out; } else if (code <= avail) { if (first) return stbi__errpuc("no clear code", "Corrupt GIF"); if (oldcode >= 0) { p = &g->codes[avail++]; if (avail > 4096) return stbi__errpuc("too many codes", "Corrupt GIF"); p->prefix = (stbi__int16) oldcode; p->first = g->codes[oldcode].first; p->suffix = (code == avail) ? p->first : g->codes[code].first; } else if (code == avail) return stbi__errpuc("illegal code in raster", "Corrupt GIF"); stbi__out_gif_code(g, (stbi__uint16) code); if ((avail & codemask) == 0 && avail <= 0x0FFF) { codesize++; codemask = (1 << codesize) - 1; } oldcode = code; } else { return stbi__errpuc("illegal code in raster", "Corrupt GIF"); } } } } static void stbi__fill_gif_background(stbi__gif *g, int x0, int y0, int x1, int y1) { int x, y; stbi_uc *c = g->pal[g->bgindex]; for (y = y0; y < y1; y += 4 * g->w) { for (x = x0; x < x1; x += 4) { stbi_uc *p = &g->out[y + x]; p[0] = c[2]; p[1] = c[1]; p[2] = c[0]; p[3] = 0; } } } // this function is designed to support animated gifs, although stb_image doesn't support it static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp) { int i; stbi_uc *prev_out = 0; if (g->out == 0 && !stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header prev_out = g->out; g->out = (stbi_uc *) stbi__malloc(4 * g->w * g->h); if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory"); switch ((g->eflags & 0x1C) >> 2) { case 0: // unspecified (also always used on 1st frame) stbi__fill_gif_background(g, 0, 0, 4 * g->w, 4 * g->w * g->h); break; case 1: // do not dispose if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); g->old_out = prev_out; break; case 2: // dispose to background if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h); stbi__fill_gif_background(g, g->start_x, g->start_y, g->max_x, g->max_y); break; case 3: // dispose to previous if (g->old_out) { for (i = g->start_y; i < g->max_y; i += 4 * g->w) memcpy(&g->out[i + g->start_x], &g->old_out[i + g->start_x], g->max_x - g->start_x); } break; } for (;;) { switch (stbi__get8(s)) { case 0x2C: /* Image Descriptor */ { int prev_trans = -1; stbi__int32 x, y, w, h; stbi_uc *o; x = stbi__get16le(s); y = stbi__get16le(s); w = stbi__get16le(s); h = stbi__get16le(s); if (((x + w) > (g->w)) || ((y + h) > (g->h))) return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); g->line_size = g->w * 4; g->start_x = x * 4; g->start_y = y * g->line_size; g->max_x = g->start_x + w * 4; g->max_y = g->start_y + h * g->line_size; g->cur_x = g->start_x; g->cur_y = g->start_y; g->lflags = stbi__get8(s); if (g->lflags & 0x40) { g->step = 8 * g->line_size; // first interlaced spacing g->parse = 3; } else { g->step = g->line_size; g->parse = 0; } if (g->lflags & 0x80) { stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); g->color_table = (stbi_uc *) g->lpal; } else if (g->flags & 0x80) { if (g->transparent >= 0 && (g->eflags & 0x01)) { prev_trans = g->pal[g->transparent][3]; g->pal[g->transparent][3] = 0; } g->color_table = (stbi_uc *) g->pal; } else return stbi__errpuc("missing color table", "Corrupt GIF"); o = stbi__process_gif_raster(s, g); if (o == NULL) return NULL; if (prev_trans != -1) g->pal[g->transparent][3] = (stbi_uc) prev_trans; return o; } case 0x21: // Comment Extension. { int len; if (stbi__get8(s) == 0xF9) { // Graphic Control Extension. len = stbi__get8(s); if (len == 4) { g->eflags = stbi__get8(s); g->delay = stbi__get16le(s); g->transparent = stbi__get8(s); } else { stbi__skip(s, len); break; } } while ((len = stbi__get8(s)) != 0) stbi__skip(s, len); break; } case 0x3B: // gif stream termination code return (stbi_uc *) s; // using '1' causes warning on some compilers default: return stbi__errpuc("unknown code", "Corrupt GIF"); } } STBI_NOTUSED(req_comp); } static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi_uc *u = 0; stbi__gif g; memset(&g, 0, sizeof(g)); u = stbi__gif_load_next(s, &g, comp, req_comp); if (u == (stbi_uc *) s) u = 0; // end of animated gif marker if (u) { *x = g.w; *y = g.h; if (req_comp && req_comp != 4) u = stbi__convert_format(u, 4, req_comp, g.w, g.h); } else if (g.out) STBI_FREE(g.out); return u; } static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) { return stbi__gif_info_raw(s,x,y,comp); } #endif // ************************************************************************************************* // Radiance RGBE HDR loader // originally by Nicolas Schulz #ifndef STBI_NO_HDR static int stbi__hdr_test_core(stbi__context *s) { const char *signature = "#?RADIANCE\n"; int i; for (i=0; signature[i]; ++i) if (stbi__get8(s) != signature[i]) return 0; return 1; } static int stbi__hdr_test(stbi__context* s) { int r = stbi__hdr_test_core(s); stbi__rewind(s); return r; } #define STBI__HDR_BUFLEN 1024 static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) { int len=0; char c = '\0'; c = (char) stbi__get8(z); while (!stbi__at_eof(z) && c != '\n') { buffer[len++] = c; if (len == STBI__HDR_BUFLEN-1) { // flush to end of line while (!stbi__at_eof(z) && stbi__get8(z) != '\n') ; break; } c = (char) stbi__get8(z); } buffer[len] = 0; return buffer; } static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) { if ( input[3] != 0 ) { float f1; // Exponent f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); if (req_comp <= 2) output[0] = (input[0] + input[1] + input[2]) * f1 / 3; else { output[0] = input[0] * f1; output[1] = input[1] * f1; output[2] = input[2] * f1; } if (req_comp == 2) output[1] = 1; if (req_comp == 4) output[3] = 1; } else { switch (req_comp) { case 4: output[3] = 1; /* fallthrough */ case 3: output[0] = output[1] = output[2] = 0; break; case 2: output[1] = 1; /* fallthrough */ case 1: output[0] = 0; break; } } } static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; int width, height; stbi_uc *scanline; float *hdr_data; int len; unsigned char count, value; int i, j, k, c1,c2, z; // Check identifier if (strcmp(stbi__hdr_gettoken(s,buffer), "#?RADIANCE") != 0) return stbi__errpf("not HDR", "Corrupt HDR image"); // Parse header for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); // Parse width and height // can't use sscanf() if we're not using stdio! token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; height = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); token += 3; width = (int) strtol(token, NULL, 10); *x = width; *y = height; if (comp) *comp = 3; if (req_comp == 0) req_comp = 3; // Read data hdr_data = (float *) stbi__malloc(height * width * req_comp * sizeof(float)); // Load image data // image data is stored as some number of sca if ( width < 8 || width >= 32768) { // Read flat data for (j=0; j < height; ++j) { for (i=0; i < width; ++i) { stbi_uc rgbe[4]; main_decode_loop: stbi__getn(s, rgbe, 4); stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); } } } else { // Read RLE-encoded data scanline = NULL; for (j = 0; j < height; ++j) { c1 = stbi__get8(s); c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { // not run-length encoded, so we have to actually use THIS data as a decoded // pixel (note this can't be a valid pixel--one of RGB must be >= 128) stbi_uc rgbe[4]; rgbe[0] = (stbi_uc) c1; rgbe[1] = (stbi_uc) c2; rgbe[2] = (stbi_uc) len; rgbe[3] = (stbi_uc) stbi__get8(s); stbi__hdr_convert(hdr_data, rgbe, req_comp); i = 1; j = 0; STBI_FREE(scanline); goto main_decode_loop; // yes, this makes no sense } len <<= 8; len |= stbi__get8(s); if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } if (scanline == NULL) scanline = (stbi_uc *) stbi__malloc(width * 4); for (k = 0; k < 4; ++k) { i = 0; while (i < width) { count = stbi__get8(s); if (count > 128) { // Run value = stbi__get8(s); count -= 128; for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = value; } else { // Dump for (z = 0; z < count; ++z) scanline[i++ * 4 + k] = stbi__get8(s); } } } for (i=0; i < width; ++i) stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); } STBI_FREE(scanline); } return hdr_data; } static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) { char buffer[STBI__HDR_BUFLEN]; char *token; int valid = 0; if (stbi__hdr_test(s) == 0) { stbi__rewind( s ); return 0; } for(;;) { token = stbi__hdr_gettoken(s,buffer); if (token[0] == 0) break; if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; } if (!valid) { stbi__rewind( s ); return 0; } token = stbi__hdr_gettoken(s,buffer); if (strncmp(token, "-Y ", 3)) { stbi__rewind( s ); return 0; } token += 3; *y = (int) strtol(token, &token, 10); while (*token == ' ') ++token; if (strncmp(token, "+X ", 3)) { stbi__rewind( s ); return 0; } token += 3; *x = (int) strtol(token, NULL, 10); *comp = 3; return 1; } #endif // STBI_NO_HDR #ifndef STBI_NO_BMP static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) { void *p; stbi__bmp_data info; info.all_a = 255; p = stbi__bmp_parse_header(s, &info); stbi__rewind( s ); if (p == NULL) return 0; *x = s->img_x; *y = s->img_y; *comp = info.ma ? 4 : 3; return 1; } #endif #ifndef STBI_NO_PSD static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) { int channelCount; if (stbi__get32be(s) != 0x38425053) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 1) { stbi__rewind( s ); return 0; } stbi__skip(s, 6); channelCount = stbi__get16be(s); if (channelCount < 0 || channelCount > 16) { stbi__rewind( s ); return 0; } *y = stbi__get32be(s); *x = stbi__get32be(s); if (stbi__get16be(s) != 8) { stbi__rewind( s ); return 0; } if (stbi__get16be(s) != 3) { stbi__rewind( s ); return 0; } *comp = 4; return 1; } #endif #ifndef STBI_NO_PIC static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) { int act_comp=0,num_packets=0,chained; stbi__pic_packet packets[10]; if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { stbi__rewind(s); return 0; } stbi__skip(s, 88); *x = stbi__get16be(s); *y = stbi__get16be(s); if (stbi__at_eof(s)) { stbi__rewind( s); return 0; } if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { stbi__rewind( s ); return 0; } stbi__skip(s, 8); do { stbi__pic_packet *packet; if (num_packets==sizeof(packets)/sizeof(packets[0])) return 0; packet = &packets[num_packets++]; chained = stbi__get8(s); packet->size = stbi__get8(s); packet->type = stbi__get8(s); packet->channel = stbi__get8(s); act_comp |= packet->channel; if (stbi__at_eof(s)) { stbi__rewind( s ); return 0; } if (packet->size != 8) { stbi__rewind( s ); return 0; } } while (chained); *comp = (act_comp & 0x10 ? 4 : 3); return 1; } #endif // ************************************************************************************************* // Portable Gray Map and Portable Pixel Map loader // by Ken Miller // // PGM: http://netpbm.sourceforge.net/doc/pgm.html // PPM: http://netpbm.sourceforge.net/doc/ppm.html // // Known limitations: // Does not support comments in the header section // Does not support ASCII image data (formats P2 and P3) // Does not support 16-bit-per-channel #ifndef STBI_NO_PNM static int stbi__pnm_test(stbi__context *s) { char p, t; p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } return 1; } static stbi_uc *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) { stbi_uc *out; if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) return 0; *x = s->img_x; *y = s->img_y; *comp = s->img_n; out = (stbi_uc *) stbi__malloc(s->img_n * s->img_x * s->img_y); if (!out) return stbi__errpuc("outofmem", "Out of memory"); stbi__getn(s, out, s->img_n * s->img_x * s->img_y); if (req_comp && req_comp != s->img_n) { out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); if (out == NULL) return out; // stbi__convert_format frees input on failure } return out; } static int stbi__pnm_isspace(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; } static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) { for (;;) { while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) *c = (char) stbi__get8(s); if (stbi__at_eof(s) || *c != '#') break; while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) *c = (char) stbi__get8(s); } } static int stbi__pnm_isdigit(char c) { return c >= '0' && c <= '9'; } static int stbi__pnm_getinteger(stbi__context *s, char *c) { int value = 0; while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { value = value*10 + (*c - '0'); *c = (char) stbi__get8(s); } return value; } static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) { int maxv; char c, p, t; stbi__rewind( s ); // Get identifier p = (char) stbi__get8(s); t = (char) stbi__get8(s); if (p != 'P' || (t != '5' && t != '6')) { stbi__rewind( s ); return 0; } *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm c = (char) stbi__get8(s); stbi__pnm_skip_whitespace(s, &c); *x = stbi__pnm_getinteger(s, &c); // read width stbi__pnm_skip_whitespace(s, &c); *y = stbi__pnm_getinteger(s, &c); // read height stbi__pnm_skip_whitespace(s, &c); maxv = stbi__pnm_getinteger(s, &c); // read max value if (maxv > 255) return stbi__err("max value > 255", "PPM image not 8-bit"); else return 1; } #endif static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNG if (stbi__png_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_GIF if (stbi__gif_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_BMP if (stbi__bmp_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PSD if (stbi__psd_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PIC if (stbi__pic_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_PNM if (stbi__pnm_info(s, x, y, comp)) return 1; #endif #ifndef STBI_NO_HDR if (stbi__hdr_info(s, x, y, comp)) return 1; #endif // test tga last because it's a crappy test! #ifndef STBI_NO_TGA if (stbi__tga_info(s, x, y, comp)) return 1; #endif return stbi__err("unknown image type", "Image not of any known type, or corrupt"); } #ifndef STBI_NO_STDIO STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) { FILE *f = stbi__fopen(filename, "rb"); int result; if (!f) return stbi__err("can't fopen", "Unable to open file"); result = stbi_info_from_file(f, x, y, comp); fclose(f); return result; } STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) { int r; stbi__context s; long pos = ftell(f); stbi__start_file(&s, f); r = stbi__info_main(&s,x,y,comp); fseek(f,pos,SEEK_SET); return r; } #endif // !STBI_NO_STDIO STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) { stbi__context s; stbi__start_mem(&s,buffer,len); return stbi__info_main(&s,x,y,comp); } STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) { stbi__context s; stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); return stbi__info_main(&s,x,y,comp); } #endif // STB_IMAGE_IMPLEMENTATION /* revision history: 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED 2.09 (2016-01-16) allow comments in PNM files 16-bit-per-pixel TGA (not bit-per-component) info() for TGA could break due to .hdr handling info() for BMP to shares code instead of sloppy parse can use STBI_REALLOC_SIZED if allocator doesn't support realloc code cleanup 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA 2.07 (2015-09-13) fix compiler warnings partial animated GIF support limited 16-bpc PSD support #ifdef unused functions bug with < 92 byte PIC,PNM,HDR,TGA 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit 2.03 (2015-04-12) extra corruption checking (mmozeiko) stbi_set_flip_vertically_on_load (nguillemot) fix NEON support; fix mingw support 2.02 (2015-01-19) fix incorrect assert, fix warning 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) progressive JPEG (stb) PGM/PPM support (Ken Miller) STBI_MALLOC,STBI_REALLOC,STBI_FREE GIF bugfix -- seemingly never worked STBI_NO_*, STBI_ONLY_* 1.48 (2014-12-14) fix incorrectly-named assert() 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) optimize PNG (ryg) fix bug in interlaced PNG with user-specified channel count (stb) 1.46 (2014-08-26) fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG 1.45 (2014-08-16) fix MSVC-ARM internal compiler error by wrapping malloc 1.44 (2014-08-07) various warning fixes from Ronny Chevalier 1.43 (2014-07-15) fix MSVC-only compiler problem in code changed in 1.42 1.42 (2014-07-09) don't define _CRT_SECURE_NO_WARNINGS (affects user code) fixes to stbi__cleanup_jpeg path added STBI_ASSERT to avoid requiring assert.h 1.41 (2014-06-25) fix search&replace from 1.36 that messed up comments/error messages 1.40 (2014-06-22) fix gcc struct-initialization warning 1.39 (2014-06-15) fix to TGA optimization when req_comp != number of components in TGA; fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) add support for BMP version 5 (more ignored fields) 1.38 (2014-06-06) suppress MSVC warnings on integer casts truncating values fix accidental rename of 'skip' field of I/O 1.37 (2014-06-04) remove duplicate typedef 1.36 (2014-06-03) convert to header file single-file library if de-iphone isn't set, load iphone images color-swapped instead of returning NULL 1.35 (2014-05-27) various warnings fix broken STBI_SIMD path fix bug where stbi_load_from_file no longer left file pointer in correct place fix broken non-easy path for 32-bit BMP (possibly never used) TGA optimization by Arseny Kapoulkine 1.34 (unknown) use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case 1.33 (2011-07-14) make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements 1.32 (2011-07-13) support for "info" function for all supported filetypes (SpartanJ) 1.31 (2011-06-20) a few more leak fixes, bug in PNG handling (SpartanJ) 1.30 (2011-06-11) added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) removed deprecated format-specific test/load functions removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) fix inefficiency in decoding 32-bit BMP (David Woo) 1.29 (2010-08-16) various warning fixes from Aurelien Pocheville 1.28 (2010-08-01) fix bug in GIF palette transparency (SpartanJ) 1.27 (2010-08-01) cast-to-stbi_uc to fix warnings 1.26 (2010-07-24) fix bug in file buffering for PNG reported by SpartanJ 1.25 (2010-07-17) refix trans_data warning (Won Chun) 1.24 (2010-07-12) perf improvements reading from files on platforms with lock-heavy fgetc() minor perf improvements for jpeg deprecated type-specific functions so we'll get feedback if they're needed attempt to fix trans_data warning (Won Chun) 1.23 fixed bug in iPhone support 1.22 (2010-07-10) removed image *writing* support stbi_info support from Jetro Lauha GIF support from Jean-Marc Lienher iPhone PNG-extensions from James Brown warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) 1.21 fix use of 'stbi_uc' in header (reported by jon blow) 1.20 added support for Softimage PIC, by Tom Seddon 1.19 bug in interlaced PNG corruption check (found by ryg) 1.18 (2008-08-02) fix a threading bug (local mutable static) 1.17 support interlaced PNG 1.16 major bugfix - stbi__convert_format converted one too many pixels 1.15 initialize some fields for thread safety 1.14 fix threadsafe conversion bug header-file-only version (#define STBI_HEADER_FILE_ONLY before including) 1.13 threadsafe 1.12 const qualifiers in the API 1.11 Support installable IDCT, colorspace conversion routines 1.10 Fixes for 64-bit (don't use "unsigned long") optimized upsampling by Fabian "ryg" Giesen 1.09 Fix format-conversion for PSD code (bad global variables!) 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz 1.07 attempt to fix C++ warning/errors again 1.06 attempt to fix C++ warning/errors again 1.05 fix TGA loading to return correct *comp and use good luminance calc 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR 1.02 support for (subset of) HDR files, float interface for preferred access to them 1.01 fix bug: possible bug in handling right-side up bmps... not sure fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all 1.00 interface to zlib that skips zlib header 0.99 correct handling of alpha in palette 0.98 TGA loader by lonesock; dynamically add loaders (untested) 0.97 jpeg errors on too large a file; also catch another malloc failure 0.96 fix detection of invalid v value - particleman@mollyrocket forum 0.95 during header scan, seek to markers in case of padding 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same 0.93 handle jpegtran output; verbose errors 0.92 read 4,8,16,24,32-bit BMP files of several formats 0.91 output 24-bit Windows 3.0 BMP files 0.90 fix a few more warnings; bump version number to approach 1.0 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd 0.60 fix compiling as c++ 0.59 fix warnings: merge Dave Moore's -Wall fixes 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available 0.56 fix bug: zlib uncompressed mode len vs. nlen 0.55 fix bug: restart_interval not initialized to 0 0.54 allow NULL for 'int *comp' 0.53 fix bug in png 3->4; speedup png decoding 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments 0.51 obey req_comp requests, 1-component jpegs return as 1-component, on 'test' only check type, not whether we support this variant 0.50 (2006-11-19) first released version */ ================================================ FILE: phonelibs/nanovg/stb_truetype.h ================================================ // stb_truetype.h - v1.24 - public domain // authored from 2009-2020 by Sean Barrett / RAD Game Tools // // ======================================================================= // // NO SECURITY GUARANTEE -- DO NOT USE THIS ON UNTRUSTED FONT FILES // // This library does no range checking of the offsets found in the file, // meaning an attacker can use it to read arbitrary memory. // // ======================================================================= // // This library processes TrueType files: // parse files // extract glyph metrics // extract glyph shapes // render glyphs to one-channel bitmaps with antialiasing (box filter) // render glyphs to one-channel SDF bitmaps (signed-distance field/function) // // Todo: // non-MS cmaps // crashproof on bad data // hinting? (no longer patented) // cleartype-style AA? // optimize: use simple memory allocator for intermediates // optimize: build edge-list directly from curves // optimize: rasterize directly from curves? // // ADDITIONAL CONTRIBUTORS // // Mikko Mononen: compound shape support, more cmap formats // Tor Andersson: kerning, subpixel rendering // Dougall Johnson: OpenType / Type 2 font handling // Daniel Ribeiro Maciel: basic GPOS-based kerning // // Misc other: // Ryan Gordon // Simon Glass // github:IntellectualKitty // Imanol Celaya // Daniel Ribeiro Maciel // // Bug/warning reports/fixes: // "Zer" on mollyrocket Fabian "ryg" Giesen github:NiLuJe // Cass Everitt Martins Mozeiko github:aloucks // stoiko (Haemimont Games) Cap Petschulat github:oyvindjam // Brian Hook Omar Cornut github:vassvik // Walter van Niftrik Ryan Griege // David Gow Peter LaValle // David Given Sergey Popov // Ivan-Assen Ivanov Giumo X. Clanjor // Anthony Pesch Higor Euripedes // Johan Duparc Thomas Fields // Hou Qiming Derek Vinyard // Rob Loach Cort Stratton // Kenney Phillis Jr. Brian Costabile // Ken Voskuil (kaesve) // // VERSION HISTORY // // 1.24 (2020-02-05) fix warning // 1.23 (2020-02-02) query SVG data for glyphs; query whole kerning table (but only kern not GPOS) // 1.22 (2019-08-11) minimize missing-glyph duplication; fix kerning if both 'GPOS' and 'kern' are defined // 1.21 (2019-02-25) fix warning // 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics() // 1.19 (2018-02-11) GPOS kerning, STBTT_fmod // 1.18 (2018-01-29) add missing function // 1.17 (2017-07-23) make more arguments const; doc fix // 1.16 (2017-07-12) SDF support // 1.15 (2017-03-03) make more arguments const // 1.14 (2017-01-16) num-fonts-in-TTC function // 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts // 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; // variant PackFontRanges to pack and render in separate phases; // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer // // Full history can be found at the end of this file. // // LICENSE // // See end of file for license information. // // USAGE // // Include this file in whatever places need to refer to it. In ONE C/C++ // file, write: // #define STB_TRUETYPE_IMPLEMENTATION // before the #include of this file. This expands out the actual // implementation into that C/C++ file. // // To make the implementation private to the file that generates the implementation, // #define STBTT_STATIC // // Simple 3D API (don't ship this, but it's fine for tools and quick start) // stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture // stbtt_GetBakedQuad() -- compute quad to draw for a given char // // Improved 3D API (more shippable): // #include "stb_rect_pack.h" -- optional, but you really want it // stbtt_PackBegin() // stbtt_PackSetOversampling() -- for improved quality on small fonts // stbtt_PackFontRanges() -- pack and renders // stbtt_PackEnd() // stbtt_GetPackedQuad() // // "Load" a font file from a memory buffer (you have to keep the buffer loaded) // stbtt_InitFont() // stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections // stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections // // Render a unicode codepoint to a bitmap // stbtt_GetCodepointBitmap() -- allocates and returns a bitmap // stbtt_MakeCodepointBitmap() -- renders into bitmap you provide // stbtt_GetCodepointBitmapBox() -- how big the bitmap must be // // Character advance/positioning // stbtt_GetCodepointHMetrics() // stbtt_GetFontVMetrics() // stbtt_GetFontVMetricsOS2() // stbtt_GetCodepointKernAdvance() // // Starting with version 1.06, the rasterizer was replaced with a new, // faster and generally-more-precise rasterizer. The new rasterizer more // accurately measures pixel coverage for anti-aliasing, except in the case // where multiple shapes overlap, in which case it overestimates the AA pixel // coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If // this turns out to be a problem, you can re-enable the old rasterizer with // #define STBTT_RASTERIZER_VERSION 1 // which will incur about a 15% speed hit. // // ADDITIONAL DOCUMENTATION // // Immediately after this block comment are a series of sample programs. // // After the sample programs is the "header file" section. This section // includes documentation for each API function. // // Some important concepts to understand to use this library: // // Codepoint // Characters are defined by unicode codepoints, e.g. 65 is // uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is // the hiragana for "ma". // // Glyph // A visual character shape (every codepoint is rendered as // some glyph) // // Glyph index // A font-specific integer ID representing a glyph // // Baseline // Glyph shapes are defined relative to a baseline, which is the // bottom of uppercase characters. Characters extend both above // and below the baseline. // // Current Point // As you draw text to the screen, you keep track of a "current point" // which is the origin of each character. The current point's vertical // position is the baseline. Even "baked fonts" use this model. // // Vertical Font Metrics // The vertical qualities of the font, used to vertically position // and space the characters. See docs for stbtt_GetFontVMetrics. // // Font Size in Pixels or Points // The preferred interface for specifying font sizes in stb_truetype // is to specify how tall the font's vertical extent should be in pixels. // If that sounds good enough, skip the next paragraph. // // Most font APIs instead use "points", which are a common typographic // measurement for describing font size, defined as 72 points per inch. // stb_truetype provides a point API for compatibility. However, true // "per inch" conventions don't make much sense on computer displays // since different monitors have different number of pixels per // inch. For example, Windows traditionally uses a convention that // there are 96 pixels per inch, thus making 'inch' measurements have // nothing to do with inches, and thus effectively defining a point to // be 1.333 pixels. Additionally, the TrueType font data provides // an explicit scale factor to scale a given font's glyphs to points, // but the author has observed that this scale factor is often wrong // for non-commercial fonts, thus making fonts scaled in points // according to the TrueType spec incoherently sized in practice. // // DETAILED USAGE: // // Scale: // Select how high you want the font to be, in points or pixels. // Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute // a scale factor SF that will be used by all other functions. // // Baseline: // You need to select a y-coordinate that is the baseline of where // your text will appear. Call GetFontBoundingBox to get the baseline-relative // bounding box for all characters. SF*-y0 will be the distance in pixels // that the worst-case character could extend above the baseline, so if // you want the top edge of characters to appear at the top of the // screen where y=0, then you would set the baseline to SF*-y0. // // Current point: // Set the current point where the first character will appear. The // first character could extend left of the current point; this is font // dependent. You can either choose a current point that is the leftmost // point and hope, or add some padding, or check the bounding box or // left-side-bearing of the first character to be displayed and set // the current point based on that. // // Displaying a character: // Compute the bounding box of the character. It will contain signed values // relative to . I.e. if it returns x0,y0,x1,y1, // then the character should be displayed in the rectangle from // to = 32 && *text < 128) { stbtt_aligned_quad q; stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); } ++text; } glEnd(); } #endif // // ////////////////////////////////////////////////////////////////////////////// // // Complete program (this compiles): get a single bitmap, print as ASCII art // #if 0 #include #define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation #include "stb_truetype.h" char ttf_buffer[1<<25]; int main(int argc, char **argv) { stbtt_fontinfo font; unsigned char *bitmap; int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); for (j=0; j < h; ++j) { for (i=0; i < w; ++i) putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); putchar('\n'); } return 0; } #endif // // Output: // // .ii. // @@@@@@. // V@Mio@@o // :i. V@V // :oM@@M // :@@@MM@M // @@o o@M // :@@. M@M // @@@o@@@@ // :M@@V:@@. // ////////////////////////////////////////////////////////////////////////////// // // Complete program: print "Hello World!" banner, with bugs // #if 0 char buffer[24<<20]; unsigned char screen[20][79]; int main(int arg, char **argv) { stbtt_fontinfo font; int i,j,ascent,baseline,ch=0; float scale, xpos=2; // leave a little padding in case the character extends left char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); stbtt_InitFont(&font, buffer, 0); scale = stbtt_ScaleForPixelHeight(&font, 15); stbtt_GetFontVMetrics(&font, &ascent,0,0); baseline = (int) (ascent*scale); while (text[ch]) { int advance,lsb,x0,y0,x1,y1; float x_shift = xpos - (float) floor(xpos); stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong // because this API is really for baking character bitmaps into textures. if you want to render // a sequence of characters, you really need to render each bitmap to a temp buffer, then // "alpha blend" that into the working buffer xpos += (advance * scale); if (text[ch+1]) xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); ++ch; } for (j=0; j < 20; ++j) { for (i=0; i < 78; ++i) putchar(" .:ioVM@"[screen[j][i]>>5]); putchar('\n'); } return 0; } #endif ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// //// //// INTEGRATION WITH YOUR CODEBASE //// //// The following sections allow you to supply alternate definitions //// of C library functions used by stb_truetype, e.g. if you don't //// link with the C runtime library. #ifdef STB_TRUETYPE_IMPLEMENTATION // #define your own (u)stbtt_int8/16/32 before including to override this #ifndef stbtt_uint8 typedef unsigned char stbtt_uint8; typedef signed char stbtt_int8; typedef unsigned short stbtt_uint16; typedef signed short stbtt_int16; typedef unsigned int stbtt_uint32; typedef signed int stbtt_int32; #endif typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h #ifndef STBTT_ifloor #include #define STBTT_ifloor(x) ((int) floor(x)) #define STBTT_iceil(x) ((int) ceil(x)) #endif #ifndef STBTT_sqrt #include #define STBTT_sqrt(x) sqrt(x) #define STBTT_pow(x,y) pow(x,y) #endif #ifndef STBTT_fmod #include #define STBTT_fmod(x,y) fmod(x,y) #endif #ifndef STBTT_cos #include #define STBTT_cos(x) cos(x) #define STBTT_acos(x) acos(x) #endif #ifndef STBTT_fabs #include #define STBTT_fabs(x) fabs(x) #endif // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h #ifndef STBTT_malloc #include #define STBTT_malloc(x,u) ((void)(u),malloc(x)) #define STBTT_free(x,u) ((void)(u),free(x)) #endif #ifndef STBTT_assert #include #define STBTT_assert(x) assert(x) #endif #ifndef STBTT_strlen #include #define STBTT_strlen(x) strlen(x) #endif #ifndef STBTT_memcpy #include #define STBTT_memcpy memcpy #define STBTT_memset memset #endif #endif /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// //// INTERFACE //// //// #ifndef __STB_INCLUDE_STB_TRUETYPE_H__ #define __STB_INCLUDE_STB_TRUETYPE_H__ #ifdef STBTT_STATIC #define STBTT_DEF static #else #define STBTT_DEF extern #endif #ifdef __cplusplus extern "C" { #endif // private structure typedef struct { unsigned char *data; int cursor; int size; } stbtt__buf; ////////////////////////////////////////////////////////////////////////////// // // TEXTURE BAKING API // // If you use this API, you only have to call two functions ever. // typedef struct { unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap float xoff,yoff,xadvance; } stbtt_bakedchar; STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake stbtt_bakedchar *chardata); // you allocate this, it's num_chars long // if return is positive, the first unused row of the bitmap // if return is negative, returns the negative of the number of characters that fit // if return is 0, no characters fit and no rows were used // This uses a very crappy packing. typedef struct { float x0,y0,s0,t0; // top-left float x1,y1,s1,t1; // bottom-right } stbtt_aligned_quad; STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier // Call GetBakedQuad with char_index = 'character - first_char', and it // creates the quad you need to draw and advances the current position. // // The coordinate system used assumes y increases downwards. // // Characters will extend both above and below the current position; // see discussion of "BASELINE" above. // // It's inefficient; you might want to c&p it and optimize it. STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap); // Query the font vertical metrics without having to create a font first. ////////////////////////////////////////////////////////////////////////////// // // NEW TEXTURE BAKING API // // This provides options for packing multiple fonts into one atlas, not // perfectly but better than nothing. typedef struct { unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap float xoff,yoff,xadvance; float xoff2,yoff2; } stbtt_packedchar; typedef struct stbtt_pack_context stbtt_pack_context; typedef struct stbtt_fontinfo stbtt_fontinfo; #ifndef STB_RECT_PACK_VERSION typedef struct stbrp_rect stbrp_rect; #endif STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); // Initializes a packing context stored in the passed-in stbtt_pack_context. // Future calls using this context will pack characters into the bitmap passed // in here: a 1-channel bitmap that is width * height. stride_in_bytes is // the distance from one row to the next (or 0 to mean they are packed tightly // together). "padding" is the amount of padding to leave between each // character (normally you want '1' for bitmaps you'll use as textures with // bilinear filtering). // // Returns 0 on failure, 1 on success. STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); // Cleans up the packing context and frees all memory. #define STBTT_POINT_SIZE(x) (-(x)) STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); // Creates character bitmaps from the font_index'th font found in fontdata (use // font_index=0 if you don't know what that is). It creates num_chars_in_range // bitmaps for characters with unicode values starting at first_unicode_char_in_range // and increasing. Data for how to render them is stored in chardata_for_range; // pass these to stbtt_GetPackedQuad to get back renderable quads. // // font_size is the full height of the character from ascender to descender, // as computed by stbtt_ScaleForPixelHeight. To use a point size as computed // by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() // and pass that result as 'font_size': // ..., 20 , ... // font max minus min y is 20 pixels tall // ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall typedef struct { float font_size; int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints int num_chars; stbtt_packedchar *chardata_for_range; // output unsigned char h_oversample, v_oversample; // don't set these, they're used internally } stbtt_pack_range; STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); // Creates character bitmaps from multiple ranges of characters stored in // ranges. This will usually create a better-packed bitmap than multiple // calls to stbtt_PackFontRange. Note that you can call this multiple // times within a single PackBegin/PackEnd. STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); // Oversampling a font increases the quality by allowing higher-quality subpixel // positioning, and is especially valuable at smaller text sizes. // // This function sets the amount of oversampling for all following calls to // stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given // pack context. The default (no oversampling) is achieved by h_oversample=1 // and v_oversample=1. The total number of pixels required is // h_oversample*v_oversample larger than the default; for example, 2x2 // oversampling requires 4x the storage of 1x1. For best results, render // oversampled textures with bilinear filtering. Look at the readme in // stb/tests/oversample for information about oversampled fonts // // To use with PackFontRangesGather etc., you must set it before calls // call to PackFontRangesGatherRects. STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip); // If skip != 0, this tells stb_truetype to skip any codepoints for which // there is no corresponding glyph. If skip=0, which is the default, then // codepoints without a glyph recived the font's "missing character" glyph, // typically an empty box by convention. STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int align_to_integer); STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); // Calling these functions in sequence is roughly equivalent to calling // stbtt_PackFontRanges(). If you more control over the packing of multiple // fonts, or if you want to pack custom data into a font texture, take a look // at the source to of stbtt_PackFontRanges() and create a custom version // using these functions, e.g. call GatherRects multiple times, // building up a single array of rects, then call PackRects once, // then call RenderIntoRects repeatedly. This may result in a // better packing than calling PackFontRanges multiple times // (or it may not). // this is an opaque structure that you shouldn't mess with which holds // all the context needed from PackBegin to PackEnd. struct stbtt_pack_context { void *user_allocator_context; void *pack_info; int width; int height; int stride_in_bytes; int padding; int skip_missing; unsigned int h_oversample, v_oversample; unsigned char *pixels; void *nodes; }; ////////////////////////////////////////////////////////////////////////////// // // FONT LOADING // // STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); // This function will determine the number of fonts in a font file. TrueType // collection (.ttc) files may contain multiple fonts, while TrueType font // (.ttf) files only contain one font. The number of fonts can be used for // indexing with the previous function where the index is between zero and one // less than the total fonts. If an error occurs, -1 is returned. STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // Each .ttf/.ttc file may have more than one font. Each font has a sequential // index number starting from 0. Call this function to get the font offset for // a given index; it returns -1 if the index is out of range. A regular .ttf // file will only define one font and it always be at offset 0, so it will // return '0' for index 0, and -1 for all other indices. // The following structure is defined publicly so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. struct stbtt_fontinfo { void * userdata; unsigned char * data; // pointer to .ttf file int fontstart; // offset of start of font int numGlyphs; // number of glyphs, needed for range checking int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf int index_map; // a cmap mapping for our chosen character encoding int indexToLocFormat; // format needed to map from glyph index to glyph stbtt__buf cff; // cff font data stbtt__buf charstrings; // the charstring index stbtt__buf gsubrs; // global charstring subroutines index stbtt__buf subrs; // private charstring subroutines index stbtt__buf fontdicts; // array of font dicts stbtt__buf fdselect; // map from glyph to fontdict }; STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); // Given an offset into the file that defines a font, this function builds // the necessary cached info for the rest of the system. You must allocate // the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't // need to do anything special to free it, because the contents are pure // value data with no additional data structures. Returns 0 on failure. ////////////////////////////////////////////////////////////////////////////// // // CHARACTER TO GLYPH-INDEX CONVERSIOn STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); // If you're going to perform multiple operations on the same character // and you want a speed-up, call this function with the character you're // going to process, then use glyph-based functions instead of the // codepoint-based functions. // Returns 0 if the character codepoint is not defined in the font. ////////////////////////////////////////////////////////////////////////////// // // CHARACTER PROPERTIES // STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); // computes a scale factor to produce a font whose "height" is 'pixels' tall. // Height is measured as the distance from the highest ascender to the lowest // descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics // and computing: // scale = pixels / (ascent - descent) // so if you prefer to measure height by the ascent only, use a similar calculation. STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); // computes a scale factor to produce a font whose EM size is mapped to // 'pixels' tall. This is probably what traditional APIs compute, but // I'm not positive. STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); // ascent is the coordinate above the baseline the font extends; descent // is the coordinate below the baseline the font extends (i.e. it is typically negative) // lineGap is the spacing between one row's descent and the next row's ascent... // so you should advance the vertical position by "*ascent - *descent + *lineGap" // these are expressed in unscaled coordinates, so you must multiply by // the scale factor for a given size STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); // analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 // table (specific to MS/Windows TTF files). // // Returns 1 on success (table present), 0 on failure. STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); // the bounding box around all possible characters STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); // leftSideBearing is the offset from the current horizontal position to the left edge of the character // advanceWidth is the offset from the current horizontal position to the next horizontal position // these are expressed in unscaled coordinates STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); // an additional amount to add to the 'advance' value between ch1 and ch2 STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); // Gets the bounding box of the visible part of the glyph, in unscaled coordinates STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); // as above, but takes one or more glyph indices for greater efficiency typedef struct stbtt_kerningentry { int glyph1; // use stbtt_FindGlyphIndex int glyph2; int advance; } stbtt_kerningentry; STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info); STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length); // Retrieves a complete list of all of the kerning pairs provided by the font // stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write. // The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1) ////////////////////////////////////////////////////////////////////////////// // // GLYPH SHAPES (you probably don't need these, but they have to go before // the bitmaps for C declaration-order reasons) // #ifndef STBTT_vmove // you can predefine these to use different values (but why?) enum { STBTT_vmove=1, STBTT_vline, STBTT_vcurve, STBTT_vcubic }; #endif #ifndef stbtt_vertex // you can predefine this to use different values // (we share this with other code at RAD) #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file typedef struct { stbtt_vertex_type x,y,cx,cy,cx1,cy1; unsigned char type,padding; } stbtt_vertex; #endif STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); // returns non-zero if nothing is drawn for this glyph STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); // returns # of vertices and fills *vertices with the pointer to them // these are expressed in "unscaled" coordinates // // The shape is a series of contours. Each one starts with // a STBTT_moveto, then consists of a series of mixed // STBTT_lineto and STBTT_curveto segments. A lineto // draws a line from previous endpoint to its x,y; a curveto // draws a quadratic bezier from previous endpoint to // its x,y, using cx,cy as the bezier control point. STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); // frees the data allocated above STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg); STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg); // fills svg with the character's SVG data. // returns data size or 0 if SVG not found. ////////////////////////////////////////////////////////////////////////////// // // BITMAP RENDERING // STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); // frees the bitmap allocated below STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); // allocates a large-enough single-channel 8bpp bitmap and renders the // specified character/glyph at the specified scale into it, with // antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). // *width & *height are filled out with the width & height of the bitmap, // which is stored left-to-right, top-to-bottom. // // xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); // the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel // shift for the character STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); // the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap // in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap // is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the // width and height and positioning info for it first. STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel // shift for the character STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); // same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering // is performed (see stbtt_PackSetOversampling) STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); // get the bbox of the bitmap centered around the glyph origin; so the // bitmap width is ix1-ix0, height is iy1-iy0, and location to place // the bitmap top left is (leftSideBearing*scale,iy0). // (Note that the bitmap uses y-increases-down, but the shape uses // y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); // same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel // shift for the character // the following functions are equivalent to the above functions, but operate // on glyph indices instead of Unicode codepoints (for efficiency) STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); // @TODO: don't expose this structure typedef struct { int w,h,stride; unsigned char *pixels; } stbtt__bitmap; // rasterize a shape with quadratic beziers into a bitmap STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into float flatness_in_pixels, // allowable error of curve in pixels stbtt_vertex *vertices, // array of vertices defining shape int num_verts, // number of vertices in above array float scale_x, float scale_y, // scale applied to input vertices float shift_x, float shift_y, // translation applied to input vertices int x_off, int y_off, // another translation applied to input int invert, // if non-zero, vertically flip shape void *userdata); // context for to STBTT_MALLOC ////////////////////////////////////////////////////////////////////////////// // // Signed Distance Function (or Field) rendering STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); // frees the SDF bitmap allocated below STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); // These functions compute a discretized SDF field for a single character, suitable for storing // in a single-channel texture, sampling with bilinear filtering, and testing against // larger than some threshold to produce scalable fonts. // info -- the font // scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap // glyph/codepoint -- the character to generate the SDF for // padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), // which allows effects like bit outlines // onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) // pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) // if positive, > onedge_value is inside; if negative, < onedge_value is inside // width,height -- output height & width of the SDF bitmap (including padding) // xoff,yoff -- output origin of the character // return value -- a 2D array of bytes 0..255, width*height in size // // pixel_dist_scale & onedge_value are a scale & bias that allows you to make // optimal use of the limited 0..255 for your application, trading off precision // and special effects. SDF values outside the range 0..255 are clamped to 0..255. // // Example: // scale = stbtt_ScaleForPixelHeight(22) // padding = 5 // onedge_value = 180 // pixel_dist_scale = 180/5.0 = 36.0 // // This will create an SDF bitmap in which the character is about 22 pixels // high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled // shape, sample the SDF at each pixel and fill the pixel if the SDF value // is greater than or equal to 180/255. (You'll actually want to antialias, // which is beyond the scope of this example.) Additionally, you can compute // offset outlines (e.g. to stroke the character border inside & outside, // or only outside). For example, to fill outside the character up to 3 SDF // pixels, you would compare against (180-36.0*3)/255 = 72/255. The above // choice of variables maps a range from 5 pixels outside the shape to // 2 pixels inside the shape to 0..255; this is intended primarily for apply // outside effects only (the interior range is needed to allow proper // antialiasing of the font at *smaller* sizes) // // The function computes the SDF analytically at each SDF pixel, not by e.g. // building a higher-res bitmap and approximating it. In theory the quality // should be as high as possible for an SDF of this size & representation, but // unclear if this is true in practice (perhaps building a higher-res bitmap // and computing from that can allow drop-out prevention). // // The algorithm has not been optimized at all, so expect it to be slow // if computing lots of characters or very large sizes. ////////////////////////////////////////////////////////////////////////////// // // Finding the right font... // // You should really just solve this offline, keep your own tables // of what font is what, and don't try to get it out of the .ttf file. // That's because getting it out of the .ttf file is really hard, because // the names in the file can appear in many possible encodings, in many // possible languages, and e.g. if you need a case-insensitive comparison, // the details of that depend on the encoding & language in a complex way // (actually underspecified in truetype, but also gigantic). // // But you can use the provided functions in two possible ways: // stbtt_FindMatchingFont() will use *case-sensitive* comparisons on // unicode-encoded names to try to find the font you want; // you can run this before calling stbtt_InitFont() // // stbtt_GetFontNameString() lets you get any of the various strings // from the file yourself and do your own comparisons on them. // You have to have called stbtt_InitFont() first. STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); // returns the offset (not index) of the font that matches, or -1 if none // if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". // if you use any other flag, use a font name like "Arial"; this checks // the 'macStyle' header field; i don't know if fonts set this consistently #define STBTT_MACSTYLE_DONTCARE 0 #define STBTT_MACSTYLE_BOLD 1 #define STBTT_MACSTYLE_ITALIC 2 #define STBTT_MACSTYLE_UNDERSCORE 4 #define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); // returns 1/0 whether the first string interpreted as utf8 is identical to // the second string interpreted as big-endian utf16... useful for strings from next func STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); // returns the string (which may be big-endian double byte, e.g. for unicode) // and puts the length in bytes in *length. // // some of the values for the IDs are below; for more see the truetype spec: // http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html // http://www.microsoft.com/typography/otspec/name.htm enum { // platformID STBTT_PLATFORM_ID_UNICODE =0, STBTT_PLATFORM_ID_MAC =1, STBTT_PLATFORM_ID_ISO =2, STBTT_PLATFORM_ID_MICROSOFT =3 }; enum { // encodingID for STBTT_PLATFORM_ID_UNICODE STBTT_UNICODE_EID_UNICODE_1_0 =0, STBTT_UNICODE_EID_UNICODE_1_1 =1, STBTT_UNICODE_EID_ISO_10646 =2, STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 }; enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT STBTT_MS_EID_SYMBOL =0, STBTT_MS_EID_UNICODE_BMP =1, STBTT_MS_EID_SHIFTJIS =2, STBTT_MS_EID_UNICODE_FULL =10 }; enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 }; enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D }; enum { // languageID for STBTT_PLATFORM_ID_MAC STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 }; #ifdef __cplusplus } #endif #endif // __STB_INCLUDE_STB_TRUETYPE_H__ /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// //// //// IMPLEMENTATION //// //// #ifdef STB_TRUETYPE_IMPLEMENTATION #ifndef STBTT_MAX_OVERSAMPLE #define STBTT_MAX_OVERSAMPLE 8 #endif #if STBTT_MAX_OVERSAMPLE > 255 #error "STBTT_MAX_OVERSAMPLE cannot be > 255" #endif typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; #ifndef STBTT_RASTERIZER_VERSION #define STBTT_RASTERIZER_VERSION 2 #endif #ifdef _MSC_VER #define STBTT__NOTUSED(v) (void)(v) #else #define STBTT__NOTUSED(v) (void)sizeof(v) #endif ////////////////////////////////////////////////////////////////////////// // // stbtt__buf helpers to parse data from file // static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) { if (b->cursor >= b->size) return 0; return b->data[b->cursor++]; } static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) { if (b->cursor >= b->size) return 0; return b->data[b->cursor]; } static void stbtt__buf_seek(stbtt__buf *b, int o) { STBTT_assert(!(o > b->size || o < 0)); b->cursor = (o > b->size || o < 0) ? b->size : o; } static void stbtt__buf_skip(stbtt__buf *b, int o) { stbtt__buf_seek(b, b->cursor + o); } static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) { stbtt_uint32 v = 0; int i; STBTT_assert(n >= 1 && n <= 4); for (i = 0; i < n; i++) v = (v << 8) | stbtt__buf_get8(b); return v; } static stbtt__buf stbtt__new_buf(const void *p, size_t size) { stbtt__buf r; STBTT_assert(size < 0x40000000); r.data = (stbtt_uint8*) p; r.size = (int) size; r.cursor = 0; return r; } #define stbtt__buf_get16(b) stbtt__buf_get((b), 2) #define stbtt__buf_get32(b) stbtt__buf_get((b), 4) static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) { stbtt__buf r = stbtt__new_buf(NULL, 0); if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; r.data = b->data + o; r.size = s; return r; } static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) { int count, start, offsize; start = b->cursor; count = stbtt__buf_get16(b); if (count) { offsize = stbtt__buf_get8(b); STBTT_assert(offsize >= 1 && offsize <= 4); stbtt__buf_skip(b, offsize * count); stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); } return stbtt__buf_range(b, start, b->cursor - start); } static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) { int b0 = stbtt__buf_get8(b); if (b0 >= 32 && b0 <= 246) return b0 - 139; else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; else if (b0 == 28) return stbtt__buf_get16(b); else if (b0 == 29) return stbtt__buf_get32(b); STBTT_assert(0); return 0; } static void stbtt__cff_skip_operand(stbtt__buf *b) { int v, b0 = stbtt__buf_peek8(b); STBTT_assert(b0 >= 28); if (b0 == 30) { stbtt__buf_skip(b, 1); while (b->cursor < b->size) { v = stbtt__buf_get8(b); if ((v & 0xF) == 0xF || (v >> 4) == 0xF) break; } } else { stbtt__cff_int(b); } } static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) { stbtt__buf_seek(b, 0); while (b->cursor < b->size) { int start = b->cursor, end, op; while (stbtt__buf_peek8(b) >= 28) stbtt__cff_skip_operand(b); end = b->cursor; op = stbtt__buf_get8(b); if (op == 12) op = stbtt__buf_get8(b) | 0x100; if (op == key) return stbtt__buf_range(b, start, end-start); } return stbtt__buf_range(b, 0, 0); } static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) { int i; stbtt__buf operands = stbtt__dict_get(b, key); for (i = 0; i < outcount && operands.cursor < operands.size; i++) out[i] = stbtt__cff_int(&operands); } static int stbtt__cff_index_count(stbtt__buf *b) { stbtt__buf_seek(b, 0); return stbtt__buf_get16(b); } static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) { int count, offsize, start, end; stbtt__buf_seek(&b, 0); count = stbtt__buf_get16(&b); offsize = stbtt__buf_get8(&b); STBTT_assert(i >= 0 && i < count); STBTT_assert(offsize >= 1 && offsize <= 4); stbtt__buf_skip(&b, i*offsize); start = stbtt__buf_get(&b, offsize); end = stbtt__buf_get(&b, offsize); return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); } ////////////////////////////////////////////////////////////////////////// // // accessors to parse data from file // // on platforms that don't allow misaligned reads, if we want to allow // truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE #define ttBYTE(p) (* (stbtt_uint8 *) (p)) #define ttCHAR(p) (* (stbtt_int8 *) (p)) #define ttFixed(p) ttLONG(p) static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } #define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) #define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) static int stbtt__isfont(stbtt_uint8 *font) { // check the version number if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts return 0; } // @OPTIMIZE: binary search static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) { stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); stbtt_uint32 tabledir = fontstart + 12; stbtt_int32 i; for (i=0; i < num_tables; ++i) { stbtt_uint32 loc = tabledir + 16*i; if (stbtt_tag(data+loc+0, tag)) return ttULONG(data+loc+8); } return 0; } static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) return index == 0 ? 0 : -1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { // version 1? if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { stbtt_int32 n = ttLONG(font_collection+8); if (index >= n) return -1; return ttULONG(font_collection+12+index*4); } } return -1; } static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) { // if it's just a font, there's only one valid font if (stbtt__isfont(font_collection)) return 1; // check if it's a TTC if (stbtt_tag(font_collection, "ttcf")) { // version 1? if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { return ttLONG(font_collection+8); } } return 0; } static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) { stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; stbtt__buf pdict; stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); if (!subrsoff) return stbtt__new_buf(NULL, 0); stbtt__buf_seek(&cff, private_loc[1]+subrsoff); return stbtt__cff_get_index(&cff); } // since most people won't use this, find this table the first time it's needed static int stbtt__get_svg(stbtt_fontinfo *info) { stbtt_uint32 t; if (info->svg < 0) { t = stbtt__find_table(info->data, info->fontstart, "SVG "); if (t) { stbtt_uint32 offset = ttULONG(info->data + t + 2); info->svg = t + offset; } else { info->svg = 0; } } return info->svg; } static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) { stbtt_uint32 cmap, t; stbtt_int32 i,numTables; info->data = data; info->fontstart = fontstart; info->cff = stbtt__new_buf(NULL, 0); cmap = stbtt__find_table(data, fontstart, "cmap"); // required info->loca = stbtt__find_table(data, fontstart, "loca"); // required info->head = stbtt__find_table(data, fontstart, "head"); // required info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required info->kern = stbtt__find_table(data, fontstart, "kern"); // not required info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required if (!cmap || !info->head || !info->hhea || !info->hmtx) return 0; if (info->glyf) { // required for truetype if (!info->loca) return 0; } else { // initialization for CFF / Type2 fonts (OTF) stbtt__buf b, topdict, topdictidx; stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; stbtt_uint32 cff; cff = stbtt__find_table(data, fontstart, "CFF "); if (!cff) return 0; info->fontdicts = stbtt__new_buf(NULL, 0); info->fdselect = stbtt__new_buf(NULL, 0); // @TODO this should use size from table (not 512MB) info->cff = stbtt__new_buf(data+cff, 512*1024*1024); b = info->cff; // read the header stbtt__buf_skip(&b, 2); stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize // @TODO the name INDEX could list multiple fonts, // but we just use the first one. stbtt__cff_get_index(&b); // name INDEX topdictidx = stbtt__cff_get_index(&b); topdict = stbtt__cff_index_get(topdictidx, 0); stbtt__cff_get_index(&b); // string INDEX info->gsubrs = stbtt__cff_get_index(&b); stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); info->subrs = stbtt__get_subrs(b, topdict); // we only support Type 2 charstrings if (cstype != 2) return 0; if (charstrings == 0) return 0; if (fdarrayoff) { // looks like a CID font if (!fdselectoff) return 0; stbtt__buf_seek(&b, fdarrayoff); info->fontdicts = stbtt__cff_get_index(&b); info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); } stbtt__buf_seek(&b, charstrings); info->charstrings = stbtt__cff_get_index(&b); } t = stbtt__find_table(data, fontstart, "maxp"); if (t) info->numGlyphs = ttUSHORT(data+t+4); else info->numGlyphs = 0xffff; info->svg = -1; // find a cmap encoding table we understand *now* to avoid searching // later. (todo: could make this installable) // the same regardless of glyph. numTables = ttUSHORT(data + cmap + 2); info->index_map = 0; for (i=0; i < numTables; ++i) { stbtt_uint32 encoding_record = cmap + 4 + 8 * i; // find an encoding we understand: switch(ttUSHORT(data+encoding_record)) { case STBTT_PLATFORM_ID_MICROSOFT: switch (ttUSHORT(data+encoding_record+2)) { case STBTT_MS_EID_UNICODE_BMP: case STBTT_MS_EID_UNICODE_FULL: // MS/Unicode info->index_map = cmap + ttULONG(data+encoding_record+4); break; } break; case STBTT_PLATFORM_ID_UNICODE: // Mac/iOS has these // all the encodingIDs are unicode, so we don't bother to check it info->index_map = cmap + ttULONG(data+encoding_record+4); break; } } if (info->index_map == 0) return 0; info->indexToLocFormat = ttUSHORT(data+info->head + 50); return 1; } STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) { stbtt_uint8 *data = info->data; stbtt_uint32 index_map = info->index_map; stbtt_uint16 format = ttUSHORT(data + index_map + 0); if (format == 0) { // apple byte encoding stbtt_int32 bytes = ttUSHORT(data + index_map + 2); if (unicode_codepoint < bytes-6) return ttBYTE(data + index_map + 6 + unicode_codepoint); return 0; } else if (format == 6) { stbtt_uint32 first = ttUSHORT(data + index_map + 6); stbtt_uint32 count = ttUSHORT(data + index_map + 8); if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); return 0; } else if (format == 2) { STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean return 0; } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; // do a binary search of the segments stbtt_uint32 endCount = index_map + 14; stbtt_uint32 search = endCount; if (unicode_codepoint > 0xffff) return 0; // they lie from endCount .. endCount + segCount // but searchRange is the nearest power of two, so... if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) search += rangeShift*2; // now decrement to bias correctly to find smallest search -= 2; while (entrySelector) { stbtt_uint16 end; searchRange >>= 1; end = ttUSHORT(data + search + searchRange*2); if (unicode_codepoint > end) search += searchRange*2; --entrySelector; } search += 2; { stbtt_uint16 offset, start; stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); if (unicode_codepoint < start) return 0; offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); if (offset == 0) return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); } } else if (format == 12 || format == 13) { stbtt_uint32 ngroups = ttULONG(data+index_map+12); stbtt_int32 low,high; low = 0; high = (stbtt_int32)ngroups; // Binary search the right group. while (low < high) { stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); if ((stbtt_uint32) unicode_codepoint < start_char) high = mid; else if ((stbtt_uint32) unicode_codepoint > end_char) low = mid+1; else { stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); if (format == 12) return start_glyph + unicode_codepoint-start_char; else // format == 13 return start_glyph; } } return 0; // not found } // @TODO STBTT_assert(0); return 0; } STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) { return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); } static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) { v->type = type; v->x = (stbtt_int16) x; v->y = (stbtt_int16) y; v->cx = (stbtt_int16) cx; v->cy = (stbtt_int16) cy; } static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) { int g1,g2; STBTT_assert(!info->cff.size); if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format if (info->indexToLocFormat == 0) { g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; } else { g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); } return g1==g2 ? -1 : g1; // if length is 0, return -1 } static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { if (info->cff.size) { stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); } else { int g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 0; if (x0) *x0 = ttSHORT(info->data + g + 2); if (y0) *y0 = ttSHORT(info->data + g + 4); if (x1) *x1 = ttSHORT(info->data + g + 6); if (y1) *y1 = ttSHORT(info->data + g + 8); } return 1; } STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) { return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); } STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) { stbtt_int16 numberOfContours; int g; if (info->cff.size) return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 1; numberOfContours = ttSHORT(info->data + g); return numberOfContours == 0; } static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) { if (start_off) { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); } else { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); else stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); } return num_vertices; } static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { stbtt_int16 numberOfContours; stbtt_uint8 *endPtsOfContours; stbtt_uint8 *data = info->data; stbtt_vertex *vertices=0; int num_vertices=0; int g = stbtt__GetGlyfOffset(info, glyph_index); *pvertices = NULL; if (g < 0) return 0; numberOfContours = ttSHORT(data + g); if (numberOfContours > 0) { stbtt_uint8 flags=0,flagcount; stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; stbtt_uint8 *points; endPtsOfContours = (data + g + 10); ins = ttUSHORT(data + g + 10 + numberOfContours * 2); points = data + g + 10 + numberOfContours * 2 + 2 + ins; n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); m = n + 2*numberOfContours; // a loose bound on how many vertices we might need vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); if (vertices == 0) return 0; next_move = 0; flagcount=0; // in first pass, we load uninterpreted data into the allocated array // above, shifted to the end of the array so we won't overwrite it when // we create our final data starting from the front off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated // first load flags for (i=0; i < n; ++i) { if (flagcount == 0) { flags = *points++; if (flags & 8) flagcount = *points++; } else --flagcount; vertices[off+i].type = flags; } // now load x coordinates x=0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; if (flags & 2) { stbtt_int16 dx = *points++; x += (flags & 16) ? dx : -dx; // ??? } else { if (!(flags & 16)) { x = x + (stbtt_int16) (points[0]*256 + points[1]); points += 2; } } vertices[off+i].x = (stbtt_int16) x; } // now load y coordinates y=0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; if (flags & 4) { stbtt_int16 dy = *points++; y += (flags & 32) ? dy : -dy; // ??? } else { if (!(flags & 32)) { y = y + (stbtt_int16) (points[0]*256 + points[1]); points += 2; } } vertices[off+i].y = (stbtt_int16) y; } // now convert them to our format num_vertices=0; sx = sy = cx = cy = scx = scy = 0; for (i=0; i < n; ++i) { flags = vertices[off+i].type; x = (stbtt_int16) vertices[off+i].x; y = (stbtt_int16) vertices[off+i].y; if (next_move == i) { if (i != 0) num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); // now start the new one start_off = !(flags & 1); if (start_off) { // if we start off with an off-curve point, then when we need to find a point on the curve // where we can start, and we need to save some state for when we wraparound. scx = x; scy = y; if (!(vertices[off+i+1].type & 1)) { // next point is also a curve point, so interpolate an on-point curve sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; } else { // otherwise just use the next point as our start point sx = (stbtt_int32) vertices[off+i+1].x; sy = (stbtt_int32) vertices[off+i+1].y; ++i; // we're using point i+1 as the starting point, so skip it } } else { sx = x; sy = y; } stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); was_off = 0; next_move = 1 + ttUSHORT(endPtsOfContours+j*2); ++j; } else { if (!(flags & 1)) { // if it's a curve if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); cx = x; cy = y; was_off = 1; } else { if (was_off) stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); else stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); was_off = 0; } } } num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); } else if (numberOfContours < 0) { // Compound shapes. int more = 1; stbtt_uint8 *comp = data + g + 10; num_vertices = 0; vertices = 0; while (more) { stbtt_uint16 flags, gidx; int comp_num_verts = 0, i; stbtt_vertex *comp_verts = 0, *tmp = 0; float mtx[6] = {1,0,0,1,0,0}, m, n; flags = ttSHORT(comp); comp+=2; gidx = ttSHORT(comp); comp+=2; if (flags & 2) { // XY values if (flags & 1) { // shorts mtx[4] = ttSHORT(comp); comp+=2; mtx[5] = ttSHORT(comp); comp+=2; } else { mtx[4] = ttCHAR(comp); comp+=1; mtx[5] = ttCHAR(comp); comp+=1; } } else { // @TODO handle matching point STBTT_assert(0); } if (flags & (1<<3)) { // WE_HAVE_A_SCALE mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = mtx[2] = 0; } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = mtx[2] = 0; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } // Find transformation scales. m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); // Get indexed glyph. comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); if (comp_num_verts > 0) { // Transform vertices. for (i = 0; i < comp_num_verts; ++i) { stbtt_vertex* v = &comp_verts[i]; stbtt_vertex_type x,y; x=v->x; y=v->y; v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); x=v->cx; y=v->cy; v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); } // Append vertices. tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); if (!tmp) { if (vertices) STBTT_free(vertices, info->userdata); if (comp_verts) STBTT_free(comp_verts, info->userdata); return 0; } if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); if (vertices) STBTT_free(vertices, info->userdata); vertices = tmp; STBTT_free(comp_verts, info->userdata); num_vertices += comp_num_verts; } // More components ? more = flags & (1<<5); } } else { // numberOfCounters == 0, do nothing } *pvertices = vertices; return num_vertices; } typedef struct { int bounds; int started; float first_x, first_y; float x, y; stbtt_int32 min_x, max_x, min_y, max_y; stbtt_vertex *pvertices; int num_vertices; } stbtt__csctx; #define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) { if (x > c->max_x || !c->started) c->max_x = x; if (y > c->max_y || !c->started) c->max_y = y; if (x < c->min_x || !c->started) c->min_x = x; if (y < c->min_y || !c->started) c->min_y = y; c->started = 1; } static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) { if (c->bounds) { stbtt__track_vertex(c, x, y); if (type == STBTT_vcubic) { stbtt__track_vertex(c, cx, cy); stbtt__track_vertex(c, cx1, cy1); } } else { stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; } c->num_vertices++; } static void stbtt__csctx_close_shape(stbtt__csctx *ctx) { if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); } static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) { stbtt__csctx_close_shape(ctx); ctx->first_x = ctx->x = ctx->x + dx; ctx->first_y = ctx->y = ctx->y + dy; stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) { ctx->x += dx; ctx->y += dy; stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); } static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) { float cx1 = ctx->x + dx1; float cy1 = ctx->y + dy1; float cx2 = cx1 + dx2; float cy2 = cy1 + dy2; ctx->x = cx2 + dx3; ctx->y = cy2 + dy3; stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); } static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) { int count = stbtt__cff_index_count(&idx); int bias = 107; if (count >= 33900) bias = 32768; else if (count >= 1240) bias = 1131; n += bias; if (n < 0 || n >= count) return stbtt__new_buf(NULL, 0); return stbtt__cff_index_get(idx, n); } static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) { stbtt__buf fdselect = info->fdselect; int nranges, start, end, v, fmt, fdselector = -1, i; stbtt__buf_seek(&fdselect, 0); fmt = stbtt__buf_get8(&fdselect); if (fmt == 0) { // untested stbtt__buf_skip(&fdselect, glyph_index); fdselector = stbtt__buf_get8(&fdselect); } else if (fmt == 3) { nranges = stbtt__buf_get16(&fdselect); start = stbtt__buf_get16(&fdselect); for (i = 0; i < nranges; i++) { v = stbtt__buf_get8(&fdselect); end = stbtt__buf_get16(&fdselect); if (glyph_index >= start && glyph_index < end) { fdselector = v; break; } start = end; } } if (fdselector == -1) stbtt__new_buf(NULL, 0); return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); } static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) { int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; int has_subrs = 0, clear_stack; float s[48]; stbtt__buf subr_stack[10], subrs = info->subrs, b; float f; #define STBTT__CSERR(s) (0) // this currently ignores the initial width value, which isn't needed if we have hmtx b = stbtt__cff_index_get(info->charstrings, glyph_index); while (b.cursor < b.size) { i = 0; clear_stack = 1; b0 = stbtt__buf_get8(&b); switch (b0) { // @TODO implement hinting case 0x13: // hintmask case 0x14: // cntrmask if (in_header) maskbits += (sp / 2); // implicit "vstem" in_header = 0; stbtt__buf_skip(&b, (maskbits + 7) / 8); break; case 0x01: // hstem case 0x03: // vstem case 0x12: // hstemhm case 0x17: // vstemhm maskbits += (sp / 2); break; case 0x15: // rmoveto in_header = 0; if (sp < 2) return STBTT__CSERR("rmoveto stack"); stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); break; case 0x04: // vmoveto in_header = 0; if (sp < 1) return STBTT__CSERR("vmoveto stack"); stbtt__csctx_rmove_to(c, 0, s[sp-1]); break; case 0x16: // hmoveto in_header = 0; if (sp < 1) return STBTT__CSERR("hmoveto stack"); stbtt__csctx_rmove_to(c, s[sp-1], 0); break; case 0x05: // rlineto if (sp < 2) return STBTT__CSERR("rlineto stack"); for (; i + 1 < sp; i += 2) stbtt__csctx_rline_to(c, s[i], s[i+1]); break; // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical // starting from a different place. case 0x07: // vlineto if (sp < 1) return STBTT__CSERR("vlineto stack"); goto vlineto; case 0x06: // hlineto if (sp < 1) return STBTT__CSERR("hlineto stack"); for (;;) { if (i >= sp) break; stbtt__csctx_rline_to(c, s[i], 0); i++; vlineto: if (i >= sp) break; stbtt__csctx_rline_to(c, 0, s[i]); i++; } break; case 0x1F: // hvcurveto if (sp < 4) return STBTT__CSERR("hvcurveto stack"); goto hvcurveto; case 0x1E: // vhcurveto if (sp < 4) return STBTT__CSERR("vhcurveto stack"); for (;;) { if (i + 3 >= sp) break; stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); i += 4; hvcurveto: if (i + 3 >= sp) break; stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); i += 4; } break; case 0x08: // rrcurveto if (sp < 6) return STBTT__CSERR("rcurveline stack"); for (; i + 5 < sp; i += 6) stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); break; case 0x18: // rcurveline if (sp < 8) return STBTT__CSERR("rcurveline stack"); for (; i + 5 < sp - 2; i += 6) stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); stbtt__csctx_rline_to(c, s[i], s[i+1]); break; case 0x19: // rlinecurve if (sp < 8) return STBTT__CSERR("rlinecurve stack"); for (; i + 1 < sp - 6; i += 2) stbtt__csctx_rline_to(c, s[i], s[i+1]); if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); break; case 0x1A: // vvcurveto case 0x1B: // hhcurveto if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); f = 0.0; if (sp & 1) { f = s[i]; i++; } for (; i + 3 < sp; i += 4) { if (b0 == 0x1B) stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); else stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); f = 0.0; } break; case 0x0A: // callsubr if (!has_subrs) { if (info->fdselect.size) subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); has_subrs = 1; } // fallthrough case 0x1D: // callgsubr if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); v = (int) s[--sp]; if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); subr_stack[subr_stack_height++] = b; b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); if (b.size == 0) return STBTT__CSERR("subr not found"); b.cursor = 0; clear_stack = 0; break; case 0x0B: // return if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); b = subr_stack[--subr_stack_height]; clear_stack = 0; break; case 0x0E: // endchar stbtt__csctx_close_shape(c); return 1; case 0x0C: { // two-byte escape float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; float dx, dy; int b1 = stbtt__buf_get8(&b); switch (b1) { // @TODO These "flex" implementations ignore the flex-depth and resolution, // and always draw beziers. case 0x22: // hflex if (sp < 7) return STBTT__CSERR("hflex stack"); dx1 = s[0]; dx2 = s[1]; dy2 = s[2]; dx3 = s[3]; dx4 = s[4]; dx5 = s[5]; dx6 = s[6]; stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); break; case 0x23: // flex if (sp < 13) return STBTT__CSERR("flex stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dy3 = s[5]; dx4 = s[6]; dy4 = s[7]; dx5 = s[8]; dy5 = s[9]; dx6 = s[10]; dy6 = s[11]; //fd is s[12] stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); break; case 0x24: // hflex1 if (sp < 9) return STBTT__CSERR("hflex1 stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dx4 = s[5]; dx5 = s[6]; dy5 = s[7]; dx6 = s[8]; stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); break; case 0x25: // flex1 if (sp < 11) return STBTT__CSERR("flex1 stack"); dx1 = s[0]; dy1 = s[1]; dx2 = s[2]; dy2 = s[3]; dx3 = s[4]; dy3 = s[5]; dx4 = s[6]; dy4 = s[7]; dx5 = s[8]; dy5 = s[9]; dx6 = dy6 = s[10]; dx = dx1+dx2+dx3+dx4+dx5; dy = dy1+dy2+dy3+dy4+dy5; if (STBTT_fabs(dx) > STBTT_fabs(dy)) dy6 = -dy; else dx6 = -dx; stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); break; default: return STBTT__CSERR("unimplemented"); } } break; default: if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) return STBTT__CSERR("reserved operator"); // push immediate if (b0 == 255) { f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; } else { stbtt__buf_skip(&b, -1); f = (float)(stbtt_int16)stbtt__cff_int(&b); } if (sp >= 48) return STBTT__CSERR("push stack overflow"); s[sp++] = f; clear_stack = 0; break; } if (clear_stack) sp = 0; } return STBTT__CSERR("no endchar"); #undef STBTT__CSERR } static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { // runs the charstring twice, once to count and once to output (to avoid realloc) stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); output_ctx.pvertices = *pvertices; if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); return output_ctx.num_vertices; } } *pvertices = NULL; return 0; } static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { stbtt__csctx c = STBTT__CSCTX_INIT(1); int r = stbtt__run_charstring(info, glyph_index, &c); if (x0) *x0 = r ? c.min_x : 0; if (y0) *y0 = r ? c.min_y : 0; if (x1) *x1 = r ? c.max_x : 0; if (y1) *y1 = r ? c.max_y : 0; return r ? c.num_vertices : 0; } STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { if (!info->cff.size) return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); else return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); } STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) { stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); if (glyph_index < numOfLongHorMetrics) { if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); } else { if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); } } STBTT_DEF int stbtt_GetKerningTableLength(const stbtt_fontinfo *info) { stbtt_uint8 *data = info->data + info->kern; // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format return 0; return ttUSHORT(data+10); } STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length) { stbtt_uint8 *data = info->data + info->kern; int k, length; // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format return 0; length = ttUSHORT(data+10); if (table_length < length) length = table_length; for (k = 0; k < length; k++) { table[k].glyph1 = ttUSHORT(data+18+(k*6)); table[k].glyph2 = ttUSHORT(data+20+(k*6)); table[k].advance = ttSHORT(data+22+(k*6)); } return length; } static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint8 *data = info->data + info->kern; stbtt_uint32 needle, straw; int l, r, m; // we only look at the first table. it must be 'horizontal' and format 0. if (!info->kern) return 0; if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 return 0; if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format return 0; l = 0; r = ttUSHORT(data+10) - 1; needle = glyph1 << 16 | glyph2; while (l <= r) { m = (l + r) >> 1; straw = ttULONG(data+18+(m*6)); // note: unaligned read if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else return ttSHORT(data+22+(m*6)); } return 0; } static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) { stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); switch(coverageFormat) { case 1: { stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); // Binary search. stbtt_int32 l=0, r=glyphCount-1, m; int straw, needle=glyph; while (l <= r) { stbtt_uint8 *glyphArray = coverageTable + 4; stbtt_uint16 glyphID; m = (l + r) >> 1; glyphID = ttUSHORT(glyphArray + 2 * m); straw = glyphID; if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else { return m; } } } break; case 2: { stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); stbtt_uint8 *rangeArray = coverageTable + 4; // Binary search. stbtt_int32 l=0, r=rangeCount-1, m; int strawStart, strawEnd, needle=glyph; while (l <= r) { stbtt_uint8 *rangeRecord; m = (l + r) >> 1; rangeRecord = rangeArray + 6 * m; strawStart = ttUSHORT(rangeRecord); strawEnd = ttUSHORT(rangeRecord + 2); if (needle < strawStart) r = m - 1; else if (needle > strawEnd) l = m + 1; else { stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); return startCoverageIndex + glyph - strawStart; } } } break; default: { // There are no other cases. STBTT_assert(0); } break; } return -1; } static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) { stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); switch(classDefFormat) { case 1: { stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); stbtt_uint8 *classDef1ValueArray = classDefTable + 6; if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); classDefTable = classDef1ValueArray + 2 * glyphCount; } break; case 2: { stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); stbtt_uint8 *classRangeRecords = classDefTable + 4; // Binary search. stbtt_int32 l=0, r=classRangeCount-1, m; int strawStart, strawEnd, needle=glyph; while (l <= r) { stbtt_uint8 *classRangeRecord; m = (l + r) >> 1; classRangeRecord = classRangeRecords + 6 * m; strawStart = ttUSHORT(classRangeRecord); strawEnd = ttUSHORT(classRangeRecord + 2); if (needle < strawStart) r = m - 1; else if (needle > strawEnd) l = m + 1; else return (stbtt_int32)ttUSHORT(classRangeRecord + 4); } classDefTable = classRangeRecords + 6 * classRangeCount; } break; default: { // There are no other cases. STBTT_assert(0); } break; } return -1; } // Define to STBTT_assert(x) if you want to break on unimplemented formats. #define STBTT_GPOS_TODO_assert(x) static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) { stbtt_uint16 lookupListOffset; stbtt_uint8 *lookupList; stbtt_uint16 lookupCount; stbtt_uint8 *data; stbtt_int32 i; if (!info->gpos) return 0; data = info->data + info->gpos; if (ttUSHORT(data+0) != 1) return 0; // Major version 1 if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 lookupListOffset = ttUSHORT(data+8); lookupList = data + lookupListOffset; lookupCount = ttUSHORT(lookupList); for (i=0; i> 1; pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; secondGlyph = ttUSHORT(pairValue); straw = secondGlyph; if (needle < straw) r = m - 1; else if (needle > straw) l = m + 1; else { stbtt_int16 xAdvance = ttSHORT(pairValue + 2); return xAdvance; } } } break; case 2: { stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); stbtt_uint16 class1Count = ttUSHORT(table + 12); stbtt_uint16 class2Count = ttUSHORT(table + 14); STBTT_assert(glyph1class < class1Count); STBTT_assert(glyph2class < class2Count); // TODO: Support more formats. STBTT_GPOS_TODO_assert(valueFormat1 == 4); if (valueFormat1 != 4) return 0; STBTT_GPOS_TODO_assert(valueFormat2 == 0); if (valueFormat2 != 0) return 0; if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { stbtt_uint8 *class1Records = table + 16; stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); return xAdvance; } } break; default: { // There are no other cases. STBTT_assert(0); break; }; } } break; }; default: // TODO: Implement other stuff. break; } } return 0; } STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) { int xAdvance = 0; if (info->gpos) xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); else if (info->kern) xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); return xAdvance; } STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) { if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs return 0; return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); } STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) { stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); } STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) { if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); if (descent) *descent = ttSHORT(info->data+info->hhea + 6); if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); } STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) { int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); if (!tab) return 0; if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); return 1; } STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) { *x0 = ttSHORT(info->data + info->head + 36); *y0 = ttSHORT(info->data + info->head + 38); *x1 = ttSHORT(info->data + info->head + 40); *y1 = ttSHORT(info->data + info->head + 42); } STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) { int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); return (float) height / fheight; } STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) { int unitsPerEm = ttUSHORT(info->data + info->head + 18); return pixels / unitsPerEm; } STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) { STBTT_free(v, info->userdata); } STBTT_DEF stbtt_uint8 *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl) { int i; stbtt_uint8 *data = info->data; stbtt_uint8 *svg_doc_list = data + stbtt__get_svg((stbtt_fontinfo *) info); int numEntries = ttUSHORT(svg_doc_list); stbtt_uint8 *svg_docs = svg_doc_list + 2; for(i=0; i= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2))) return svg_doc; } return 0; } STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg) { stbtt_uint8 *data = info->data; stbtt_uint8 *svg_doc; if (info->svg == 0) return 0; svg_doc = stbtt_FindSVGDoc(info, gl); if (svg_doc != NULL) { *svg = (char *) data + info->svg + ttULONG(svg_doc + 4); return ttULONG(svg_doc + 8); } else { return 0; } } STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg) { return stbtt_GetGlyphSVG(info, stbtt_FindGlyphIndex(info, unicode_codepoint), svg); } ////////////////////////////////////////////////////////////////////////////// // // antialiasing software rasterizer // STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { // e.g. space character if (ix0) *ix0 = 0; if (iy0) *iy0 = 0; if (ix1) *ix1 = 0; if (iy1) *iy1 = 0; } else { // move to integral bboxes (treating pixels as little squares, what pixels get touched)? if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); } } STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); } STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); } STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) { stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); } ////////////////////////////////////////////////////////////////////////////// // // Rasterizer typedef struct stbtt__hheap_chunk { struct stbtt__hheap_chunk *next; } stbtt__hheap_chunk; typedef struct stbtt__hheap { struct stbtt__hheap_chunk *head; void *first_free; int num_remaining_in_head_chunk; } stbtt__hheap; static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) { if (hh->first_free) { void *p = hh->first_free; hh->first_free = * (void **) p; return p; } else { if (hh->num_remaining_in_head_chunk == 0) { int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); if (c == NULL) return NULL; c->next = hh->head; hh->head = c; hh->num_remaining_in_head_chunk = count; } --hh->num_remaining_in_head_chunk; return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; } } static void stbtt__hheap_free(stbtt__hheap *hh, void *p) { *(void **) p = hh->first_free; hh->first_free = p; } static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) { stbtt__hheap_chunk *c = hh->head; while (c) { stbtt__hheap_chunk *n = c->next; STBTT_free(c, userdata); c = n; } } typedef struct stbtt__edge { float x0,y0, x1,y1; int invert; } stbtt__edge; typedef struct stbtt__active_edge { struct stbtt__active_edge *next; #if STBTT_RASTERIZER_VERSION==1 int x,dx; float ey; int direction; #elif STBTT_RASTERIZER_VERSION==2 float fx,fdx,fdy; float direction; float sy; float ey; #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif } stbtt__active_edge; #if STBTT_RASTERIZER_VERSION == 1 #define STBTT_FIXSHIFT 10 #define STBTT_FIX (1 << STBTT_FIXSHIFT) #define STBTT_FIXMASK (STBTT_FIX-1) static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); if (!z) return z; // round dx down to avoid overshooting if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); else z->dx = STBTT_ifloor(STBTT_FIX * dxdy); z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount z->x -= off_x * STBTT_FIX; z->ey = e->y1; z->next = 0; z->direction = e->invert ? 1 : -1; return z; } #elif STBTT_RASTERIZER_VERSION == 2 static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) { stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); //STBTT_assert(e->y0 <= start_point); if (!z) return z; z->fdx = dxdy; z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; z->fx = e->x0 + dxdy * (start_point - e->y0); z->fx -= off_x; z->direction = e->invert ? 1.0f : -1.0f; z->sy = e->y0; z->ey = e->y1; z->next = 0; return z; } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif #if STBTT_RASTERIZER_VERSION == 1 // note: this routine clips fills that extend off the edges... ideally this // wouldn't happen, but it could happen if the truetype glyph bounding boxes // are wrong, or if the user supplies a too-small bitmap static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) { // non-zero winding fill int x0=0, w=0; while (e) { if (w == 0) { // if we're currently at zero, we need to record the edge start point x0 = e->x; w += e->direction; } else { int x1 = e->x; w += e->direction; // if we went to zero, we need to draw if (w == 0) { int i = x0 >> STBTT_FIXSHIFT; int j = x1 >> STBTT_FIXSHIFT; if (i < len && j >= 0) { if (i == j) { // x0,x1 are the same pixel, so compute combined coverage scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); } else { if (i >= 0) // add antialiasing for x0 scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); else i = -1; // clip if (j < len) // add antialiasing for x1 scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); else j = len; // clip for (++i; i < j; ++i) // fill pixels between x0 and x1 scanline[i] = scanline[i] + (stbtt_uint8) max_weight; } } } } e = e->next; } } static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; int y,j=0; int max_weight = (255 / vsubsample); // weight per vertical scanline int s; // vertical subsample index unsigned char scanline_data[512], *scanline; if (result->w > 512) scanline = (unsigned char *) STBTT_malloc(result->w, userdata); else scanline = scanline_data; y = off_y * vsubsample; e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; while (j < result->h) { STBTT_memset(scanline, 0, result->w); for (s=0; s < vsubsample; ++s) { // find center of pixel for this scanline float scan_y = y + 0.5f; stbtt__active_edge **step = &active; // update all active edges; // remove all active edges that terminate before the center of this scanline while (*step) { stbtt__active_edge * z = *step; if (z->ey <= scan_y) { *step = z->next; // delete from list STBTT_assert(z->direction); z->direction = 0; stbtt__hheap_free(&hh, z); } else { z->x += z->dx; // advance to position for current scanline step = &((*step)->next); // advance through list } } // resort the list if needed for(;;) { int changed=0; step = &active; while (*step && (*step)->next) { if ((*step)->x > (*step)->next->x) { stbtt__active_edge *t = *step; stbtt__active_edge *q = t->next; t->next = q->next; q->next = t; *step = q; changed = 1; } step = &(*step)->next; } if (!changed) break; } // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline while (e->y0 <= scan_y) { if (e->y1 > scan_y) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); if (z != NULL) { // find insertion point if (active == NULL) active = z; else if (z->x < active->x) { // insert at front z->next = active; active = z; } else { // find thing to insert AFTER stbtt__active_edge *p = active; while (p->next && p->next->x < z->x) p = p->next; // at this point, p->next->x is NOT < z->x z->next = p->next; p->next = z; } } } ++e; } // now process all active edges in XOR fashion if (active) stbtt__fill_active_edges(scanline, result->w, active, max_weight); ++y; } STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) STBTT_free(scanline, userdata); } #elif STBTT_RASTERIZER_VERSION == 2 // the edge passed in here does not cross the vertical line at x or the vertical line at x+1 // (i.e. it has already been clipped to those) static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) { if (y0 == y1) return; STBTT_assert(y0 < y1); STBTT_assert(e->sy <= e->ey); if (y0 > e->ey) return; if (y1 < e->sy) return; if (y0 < e->sy) { x0 += (x1-x0) * (e->sy - y0) / (y1-y0); y0 = e->sy; } if (y1 > e->ey) { x1 += (x1-x0) * (e->ey - y1) / (y1-y0); y1 = e->ey; } if (x0 == x) STBTT_assert(x1 <= x+1); else if (x0 == x+1) STBTT_assert(x1 >= x); else if (x0 <= x) STBTT_assert(x1 <= x); else if (x0 >= x+1) STBTT_assert(x1 >= x+1); else STBTT_assert(x1 >= x && x1 <= x+1); if (x0 <= x && x1 <= x) scanline[x] += e->direction * (y1-y0); else if (x0 >= x+1 && x1 >= x+1) ; else { STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position } } static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) { float y_bottom = y_top+1; while (e) { // brute force every pixel // compute intersection points with top & bottom STBTT_assert(e->ey >= y_top); if (e->fdx == 0) { float x0 = e->fx; if (x0 < len) { if (x0 >= 0) { stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); } else { stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); } } } else { float x0 = e->fx; float dx = e->fdx; float xb = x0 + dx; float x_top, x_bottom; float sy0,sy1; float dy = e->fdy; STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); // compute endpoints of line segment clipped to this scanline (if the // line segment starts on this scanline. x0 is the intersection of the // line with y_top, but that may be off the line segment. if (e->sy > y_top) { x_top = x0 + dx * (e->sy - y_top); sy0 = e->sy; } else { x_top = x0; sy0 = y_top; } if (e->ey < y_bottom) { x_bottom = x0 + dx * (e->ey - y_top); sy1 = e->ey; } else { x_bottom = xb; sy1 = y_bottom; } if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { // from here on, we don't have to range check x values if ((int) x_top == (int) x_bottom) { float height; // simple case, only spans one pixel int x = (int) x_top; height = sy1 - sy0; STBTT_assert(x >= 0 && x < len); scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; scanline_fill[x] += e->direction * height; // everything right of this pixel is filled } else { int x,x1,x2; float y_crossing, step, sign, area; // covers 2+ pixels if (x_top > x_bottom) { // flip scanline vertically; signed area is the same float t; sy0 = y_bottom - (sy0 - y_top); sy1 = y_bottom - (sy1 - y_top); t = sy0, sy0 = sy1, sy1 = t; t = x_bottom, x_bottom = x_top, x_top = t; dx = -dx; dy = -dy; t = x0, x0 = xb, xb = t; } x1 = (int) x_top; x2 = (int) x_bottom; // compute intersection with y axis at x1+1 y_crossing = (x1+1 - x0) * dy + y_top; sign = e->direction; // area of the rectangle covered from y0..y_crossing area = sign * (y_crossing-sy0); // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); step = sign * dy; for (x = x1+1; x < x2; ++x) { scanline[x] += area + step/2; area += step; } y_crossing += dy * (x2 - (x1+1)); STBTT_assert(STBTT_fabs(area) <= 1.01f); scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); scanline_fill[x2] += sign * (sy1-sy0); } } else { // if edge goes outside of box we're drawing, we require // clipping logic. since this does not match the intended use // of this library, we use a different, very slow brute // force implementation int x; for (x=0; x < len; ++x) { // cases: // // there can be up to two intersections with the pixel. any intersection // with left or right edges can be handled by splitting into two (or three) // regions. intersections with top & bottom do not necessitate case-wise logic. // // the old way of doing this found the intersections with the left & right edges, // then used some simple logic to produce up to three segments in sorted order // from top-to-bottom. however, this had a problem: if an x edge was epsilon // across the x border, then the corresponding y position might not be distinct // from the other y segment, and it might ignored as an empty segment. to avoid // that, we need to explicitly produce segments based on x positions. // rename variables to clearly-defined pairs float y0 = y_top; float x1 = (float) (x); float x2 = (float) (x+1); float x3 = xb; float y3 = y_bottom; // x = e->x + e->dx * (y-y_top) // (y-y_top) = (x - e->x) / e->dx // y = (x - e->x) / e->dx + y_top float y1 = (x - x0) / dx + y_top; float y2 = (x+1 - x0) / dx + y_top; if (x0 < x1 && x3 > x2) { // three segments descending down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else if (x3 < x1 && x0 > x2) { // three segments descending down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); } else { // one segment stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); } } } } e = e->next; } } // directly AA rasterize edges w/o supersampling static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) { stbtt__hheap hh = { 0, 0, 0 }; stbtt__active_edge *active = NULL; int y,j=0, i; float scanline_data[129], *scanline, *scanline2; STBTT__NOTUSED(vsubsample); if (result->w > 64) scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); else scanline = scanline_data; scanline2 = scanline + result->w; y = off_y; e[n].y0 = (float) (off_y + result->h) + 1; while (j < result->h) { // find center of pixel for this scanline float scan_y_top = y + 0.0f; float scan_y_bottom = y + 1.0f; stbtt__active_edge **step = &active; STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); // update all active edges; // remove all active edges that terminate before the top of this scanline while (*step) { stbtt__active_edge * z = *step; if (z->ey <= scan_y_top) { *step = z->next; // delete from list STBTT_assert(z->direction); z->direction = 0; stbtt__hheap_free(&hh, z); } else { step = &((*step)->next); // advance through list } } // insert all edges that start before the bottom of this scanline while (e->y0 <= scan_y_bottom) { if (e->y0 != e->y1) { stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); if (z != NULL) { if (j == 0 && off_y != 0) { if (z->ey < scan_y_top) { // this can happen due to subpixel positioning and some kind of fp rounding error i think z->ey = scan_y_top; } } STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds // insert at front z->next = active; active = z; } } ++e; } // now process all active edges if (active) stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); { float sum = 0; for (i=0; i < result->w; ++i) { float k; int m; sum += scanline2[i]; k = scanline[i] + sum; k = (float) STBTT_fabs(k)*255 + 0.5f; m = (int) k; if (m > 255) m = 255; result->pixels[j*result->stride + i] = (unsigned char) m; } } // advance all the edges step = &active; while (*step) { stbtt__active_edge *z = *step; z->fx += z->fdx; // advance to position for current scanline step = &((*step)->next); // advance through list } ++y; ++j; } stbtt__hheap_cleanup(&hh, userdata); if (scanline != scanline_data) STBTT_free(scanline, userdata); } #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif #define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) { int i,j; for (i=1; i < n; ++i) { stbtt__edge t = p[i], *a = &t; j = i; while (j > 0) { stbtt__edge *b = &p[j-1]; int c = STBTT__COMPARE(a,b); if (!c) break; p[j] = p[j-1]; --j; } if (i != j) p[j] = t; } } static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) { /* threshold for transitioning to insertion sort */ while (n > 12) { stbtt__edge t; int c01,c12,c,m,i,j; /* compute median of three */ m = n >> 1; c01 = STBTT__COMPARE(&p[0],&p[m]); c12 = STBTT__COMPARE(&p[m],&p[n-1]); /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ if (c01 != c12) { /* otherwise, we'll need to swap something else to middle */ int z; c = STBTT__COMPARE(&p[0],&p[n-1]); /* 0>mid && midn => n; 0 0 */ /* 0n: 0>n => 0; 0 n */ z = (c == c12) ? 0 : n-1; t = p[z]; p[z] = p[m]; p[m] = t; } /* now p[m] is the median-of-three */ /* swap it to the beginning so it won't move around */ t = p[0]; p[0] = p[m]; p[m] = t; /* partition loop */ i=1; j=n-1; for(;;) { /* handling of equality is crucial here */ /* for sentinels & efficiency with duplicates */ for (;;++i) { if (!STBTT__COMPARE(&p[i], &p[0])) break; } for (;;--j) { if (!STBTT__COMPARE(&p[0], &p[j])) break; } /* make sure we haven't crossed */ if (i >= j) break; t = p[i]; p[i] = p[j]; p[j] = t; ++i; --j; } /* recurse on smaller side, iterate on larger */ if (j < (n-i)) { stbtt__sort_edges_quicksort(p,j); p = p+i; n = n-i; } else { stbtt__sort_edges_quicksort(p+i, n-i); n = j; } } } static void stbtt__sort_edges(stbtt__edge *p, int n) { stbtt__sort_edges_quicksort(p, n); stbtt__sort_edges_ins_sort(p, n); } typedef struct { float x,y; } stbtt__point; static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) { float y_scale_inv = invert ? -scale_y : scale_y; stbtt__edge *e; int n,i,j,k,m; #if STBTT_RASTERIZER_VERSION == 1 int vsubsample = result->h < 8 ? 15 : 5; #elif STBTT_RASTERIZER_VERSION == 2 int vsubsample = 1; #else #error "Unrecognized value of STBTT_RASTERIZER_VERSION" #endif // vsubsample should divide 255 evenly; otherwise we won't reach full opacity // now we have to blow out the windings into explicit edge lists n = 0; for (i=0; i < windings; ++i) n += wcount[i]; e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel if (e == 0) return; n = 0; m=0; for (i=0; i < windings; ++i) { stbtt__point *p = pts + m; m += wcount[i]; j = wcount[i]-1; for (k=0; k < wcount[i]; j=k++) { int a=k,b=j; // skip the edge if horizontal if (p[j].y == p[k].y) continue; // add edge from j to k to the list e[n].invert = 0; if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { e[n].invert = 1; a=j,b=k; } e[n].x0 = p[a].x * scale_x + shift_x; e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; e[n].x1 = p[b].x * scale_x + shift_x; e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; ++n; } } // now sort the edges by their highest point (should snap to integer, and then by x) //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); stbtt__sort_edges(e, n); // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); STBTT_free(e, userdata); } static void stbtt__add_point(stbtt__point *points, int n, float x, float y) { if (!points) return; // during first pass, it's unallocated points[n].x = x; points[n].y = y; } // tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) { // midpoint float mx = (x0 + 2*x1 + x2)/4; float my = (y0 + 2*y1 + y2)/4; // versus directly drawn line float dx = (x0+x2)/2 - mx; float dy = (y0+y2)/2 - my; if (n > 16) // 65536 segments on one curve better be enough! return 1; if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); } else { stbtt__add_point(points, *num_points,x2,y2); *num_points = *num_points+1; } return 1; } static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) { // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough float dx0 = x1-x0; float dy0 = y1-y0; float dx1 = x2-x1; float dy1 = y2-y1; float dx2 = x3-x2; float dy2 = y3-y2; float dx = x3-x0; float dy = y3-y0; float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); float flatness_squared = longlen*longlen-shortlen*shortlen; if (n > 16) // 65536 segments on one curve better be enough! return; if (flatness_squared > objspace_flatness_squared) { float x01 = (x0+x1)/2; float y01 = (y0+y1)/2; float x12 = (x1+x2)/2; float y12 = (y1+y2)/2; float x23 = (x2+x3)/2; float y23 = (y2+y3)/2; float xa = (x01+x12)/2; float ya = (y01+y12)/2; float xb = (x12+x23)/2; float yb = (y12+y23)/2; float mx = (xa+xb)/2; float my = (ya+yb)/2; stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); } else { stbtt__add_point(points, *num_points,x3,y3); *num_points = *num_points+1; } } // returns number of contours static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) { stbtt__point *points=0; int num_points=0; float objspace_flatness_squared = objspace_flatness * objspace_flatness; int i,n=0,start=0, pass; // count how many "moves" there are to get the contour count for (i=0; i < num_verts; ++i) if (vertices[i].type == STBTT_vmove) ++n; *num_contours = n; if (n == 0) return 0; *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); if (*contour_lengths == 0) { *num_contours = 0; return 0; } // make two passes through the points so we don't need to realloc for (pass=0; pass < 2; ++pass) { float x=0,y=0; if (pass == 1) { points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); if (points == NULL) goto error; } num_points = 0; n= -1; for (i=0; i < num_verts; ++i) { switch (vertices[i].type) { case STBTT_vmove: // start the next contour if (n >= 0) (*contour_lengths)[n] = num_points - start; ++n; start = num_points; x = vertices[i].x, y = vertices[i].y; stbtt__add_point(points, num_points++, x,y); break; case STBTT_vline: x = vertices[i].x, y = vertices[i].y; stbtt__add_point(points, num_points++, x, y); break; case STBTT_vcurve: stbtt__tesselate_curve(points, &num_points, x,y, vertices[i].cx, vertices[i].cy, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; case STBTT_vcubic: stbtt__tesselate_cubic(points, &num_points, x,y, vertices[i].cx, vertices[i].cy, vertices[i].cx1, vertices[i].cy1, vertices[i].x, vertices[i].y, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; } } (*contour_lengths)[n] = num_points - start; } return points; error: STBTT_free(points, userdata); STBTT_free(*contour_lengths, userdata); *contour_lengths = 0; *num_contours = 0; return NULL; } STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) { float scale = scale_x > scale_y ? scale_y : scale_x; int winding_count = 0; int *winding_lengths = NULL; stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); if (windings) { stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); STBTT_free(winding_lengths, userdata); STBTT_free(windings, userdata); } } STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) { STBTT_free(bitmap, userdata); } STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; if (scale_y == 0) { if (scale_x == 0) { STBTT_free(vertices, info->userdata); return NULL; } scale_y = scale_x; } stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); // now we get the size gbm.w = (ix1 - ix0); gbm.h = (iy1 - iy0); gbm.pixels = NULL; // in case we error if (width ) *width = gbm.w; if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); if (gbm.pixels) { gbm.stride = gbm.w; stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); } } STBTT_free(vertices, info->userdata); return gbm.pixels; } STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); } STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) { int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; gbm.w = out_w; gbm.h = out_h; gbm.stride = out_stride; if (gbm.w && gbm.h) stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); STBTT_free(vertices, info->userdata); } STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); } STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); } STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) { stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); } STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); } STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); } STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) { stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); } ////////////////////////////////////////////////////////////////////////////// // // bitmap baking // // This is SUPER-CRAPPY packing to keep source code small static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake stbtt_bakedchar *chardata) { float scale; int x,y,bottom_y, i; stbtt_fontinfo f; f.userdata = NULL; if (!stbtt_InitFont(&f, data, offset)) return -1; STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels x=y=1; bottom_y = 1; scale = stbtt_ScaleForPixelHeight(&f, pixel_height); for (i=0; i < num_chars; ++i) { int advance, lsb, x0,y0,x1,y1,gw,gh; int g = stbtt_FindGlyphIndex(&f, first_char + i); stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); gw = x1-x0; gh = y1-y0; if (x + gw + 1 >= pw) y = bottom_y, x = 1; // advance to next row if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row return -i; STBTT_assert(x+gw < pw); STBTT_assert(y+gh < ph); stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); chardata[i].x0 = (stbtt_int16) x; chardata[i].y0 = (stbtt_int16) y; chardata[i].x1 = (stbtt_int16) (x + gw); chardata[i].y1 = (stbtt_int16) (y + gh); chardata[i].xadvance = scale * advance; chardata[i].xoff = (float) x0; chardata[i].yoff = (float) y0; x = x + gw + 1; if (y+gh+1 > bottom_y) bottom_y = y+gh+1; } return bottom_y; } STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) { float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_bakedchar *b = chardata + char_index; int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); q->x0 = round_x + d3d_bias; q->y0 = round_y + d3d_bias; q->x1 = round_x + b->x1 - b->x0 + d3d_bias; q->y1 = round_y + b->y1 - b->y0 + d3d_bias; q->s0 = b->x0 * ipw; q->t0 = b->y0 * iph; q->s1 = b->x1 * ipw; q->t1 = b->y1 * iph; *xpos += b->xadvance; } ////////////////////////////////////////////////////////////////////////////// // // rectangle packing replacement routines if you don't have stb_rect_pack.h // #ifndef STB_RECT_PACK_VERSION typedef int stbrp_coord; //////////////////////////////////////////////////////////////////////////////////// // // // // // COMPILER WARNING ?!?!? // // // // // // if you get a compile warning due to these symbols being defined more than // // once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // // // //////////////////////////////////////////////////////////////////////////////////// typedef struct { int width,height; int x,y,bottom_y; } stbrp_context; typedef struct { unsigned char x; } stbrp_node; struct stbrp_rect { stbrp_coord x,y; int id,w,h,was_packed; }; static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) { con->width = pw; con->height = ph; con->x = 0; con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) { int i; for (i=0; i < num_rects; ++i) { if (con->x + rects[i].w > con->width) { con->x = 0; con->y = con->bottom_y; } if (con->y + rects[i].h > con->height) break; rects[i].x = con->x; rects[i].y = con->y; rects[i].was_packed = 1; con->x += rects[i].w; if (con->y + rects[i].h > con->bottom_y) con->bottom_y = con->y + rects[i].h; } for ( ; i < num_rects; ++i) rects[i].was_packed = 0; } #endif ////////////////////////////////////////////////////////////////////////////// // // bitmap baking // // This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If // stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) { stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); int num_nodes = pw - padding; stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); if (context == NULL || nodes == NULL) { if (context != NULL) STBTT_free(context, alloc_context); if (nodes != NULL) STBTT_free(nodes , alloc_context); return 0; } spc->user_allocator_context = alloc_context; spc->width = pw; spc->height = ph; spc->pixels = pixels; spc->pack_info = context; spc->nodes = nodes; spc->padding = padding; spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; spc->h_oversample = 1; spc->v_oversample = 1; spc->skip_missing = 0; stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); if (pixels) STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels return 1; } STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) { STBTT_free(spc->nodes , spc->user_allocator_context); STBTT_free(spc->pack_info, spc->user_allocator_context); } STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) { STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); if (h_oversample <= STBTT_MAX_OVERSAMPLE) spc->h_oversample = h_oversample; if (v_oversample <= STBTT_MAX_OVERSAMPLE) spc->v_oversample = v_oversample; } STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) { spc->skip_missing = skip; } #define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; int safe_w = w - kernel_width; int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < h; ++j) { int i; unsigned int total; STBTT_memset(buffer, 0, kernel_width); total = 0; // make kernel_width a constant in common cases so compiler can optimize out the divide switch (kernel_width) { case 2: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 2); } break; case 3: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 3); } break; case 4: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 4); } break; case 5: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / 5); } break; default: for (i=0; i <= safe_w; ++i) { total += pixels[i] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; pixels[i] = (unsigned char) (total / kernel_width); } break; } for (; i < w; ++i) { STBTT_assert(pixels[i] == 0); total -= buffer[i & STBTT__OVER_MASK]; pixels[i] = (unsigned char) (total / kernel_width); } pixels += stride_in_bytes; } } static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) { unsigned char buffer[STBTT_MAX_OVERSAMPLE]; int safe_h = h - kernel_width; int j; STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze for (j=0; j < w; ++j) { int i; unsigned int total; STBTT_memset(buffer, 0, kernel_width); total = 0; // make kernel_width a constant in common cases so compiler can optimize out the divide switch (kernel_width) { case 2: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 2); } break; case 3: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 3); } break; case 4: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 4); } break; case 5: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / 5); } break; default: for (i=0; i <= safe_h; ++i) { total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); } break; } for (; i < h; ++i) { STBTT_assert(pixels[i*stride_in_bytes] == 0); total -= buffer[i & STBTT__OVER_MASK]; pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); } pixels += 1; } } static float stbtt__oversample_shift(int oversample) { if (!oversample) return 0.0f; // The prefilter is a box filter of width "oversample", // which shifts phase by (oversample - 1)/2 pixels in // oversampled space. We want to shift in the opposite // direction to counter this. return (float)-(oversample - 1) / (2.0f * (float)oversample); } // rects array must be big enough to accommodate all characters in the given ranges STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k; int missing_glyph_added = 0; k=0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); ranges[i].h_oversample = (unsigned char) spc->h_oversample; ranges[i].v_oversample = (unsigned char) spc->v_oversample; for (j=0; j < ranges[i].num_chars; ++j) { int x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) { rects[k].w = rects[k].h = 0; } else { stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, scale * spc->h_oversample, scale * spc->v_oversample, 0,0, &x0,&y0,&x1,&y1); rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); if (glyph == 0) missing_glyph_added = 1; } ++k; } } return k; } STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) { stbtt_MakeGlyphBitmapSubpixel(info, output, out_w - (prefilter_x - 1), out_h - (prefilter_y - 1), out_stride, scale_x, scale_y, shift_x, shift_y, glyph); if (prefilter_x > 1) stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); if (prefilter_y > 1) stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); *sub_x = stbtt__oversample_shift(prefilter_x); *sub_y = stbtt__oversample_shift(prefilter_y); } // rects array must be big enough to accommodate all characters in the given ranges STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k, missing_glyph = -1, return_value = 1; // save current values int old_h_over = spc->h_oversample; int old_v_over = spc->v_oversample; k = 0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); float recip_h,recip_v,sub_x,sub_y; spc->h_oversample = ranges[i].h_oversample; spc->v_oversample = ranges[i].v_oversample; recip_h = 1.0f / spc->h_oversample; recip_v = 1.0f / spc->v_oversample; sub_x = stbtt__oversample_shift(spc->h_oversample); sub_y = stbtt__oversample_shift(spc->v_oversample); for (j=0; j < ranges[i].num_chars; ++j) { stbrp_rect *r = &rects[k]; if (r->was_packed && r->w != 0 && r->h != 0) { stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; int advance, lsb, x0,y0,x1,y1; int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; int glyph = stbtt_FindGlyphIndex(info, codepoint); stbrp_coord pad = (stbrp_coord) spc->padding; // pad on left and top r->x += pad; r->y += pad; r->w -= pad; r->h -= pad; stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); stbtt_GetGlyphBitmapBox(info, glyph, scale * spc->h_oversample, scale * spc->v_oversample, &x0,&y0,&x1,&y1); stbtt_MakeGlyphBitmapSubpixel(info, spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w - spc->h_oversample+1, r->h - spc->v_oversample+1, spc->stride_in_bytes, scale * spc->h_oversample, scale * spc->v_oversample, 0,0, glyph); if (spc->h_oversample > 1) stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w, r->h, spc->stride_in_bytes, spc->h_oversample); if (spc->v_oversample > 1) stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, r->w, r->h, spc->stride_in_bytes, spc->v_oversample); bc->x0 = (stbtt_int16) r->x; bc->y0 = (stbtt_int16) r->y; bc->x1 = (stbtt_int16) (r->x + r->w); bc->y1 = (stbtt_int16) (r->y + r->h); bc->xadvance = scale * advance; bc->xoff = (float) x0 * recip_h + sub_x; bc->yoff = (float) y0 * recip_v + sub_y; bc->xoff2 = (x0 + r->w) * recip_h + sub_x; bc->yoff2 = (y0 + r->h) * recip_v + sub_y; if (glyph == 0) missing_glyph = j; } else if (spc->skip_missing) { return_value = 0; } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) { ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph]; } else { return_value = 0; // if any fail, report failure } ++k; } } // restore original values spc->h_oversample = old_h_over; spc->v_oversample = old_v_over; return return_value; } STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) { stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); } STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) { stbtt_fontinfo info; int i,j,n, return_value = 1; //stbrp_context *context = (stbrp_context *) spc->pack_info; stbrp_rect *rects; // flag all characters as NOT packed for (i=0; i < num_ranges; ++i) for (j=0; j < ranges[i].num_chars; ++j) ranges[i].chardata_for_range[j].x0 = ranges[i].chardata_for_range[j].y0 = ranges[i].chardata_for_range[j].x1 = ranges[i].chardata_for_range[j].y1 = 0; n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars; rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); if (rects == NULL) return 0; info.userdata = spc->user_allocator_context; stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); stbtt_PackFontRangesPackRects(spc, rects, n); return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); STBTT_free(rects, spc->user_allocator_context); return return_value; } STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; range.array_of_unicode_codepoints = NULL; range.num_chars = num_chars_in_range; range.chardata_for_range = chardata_for_range; range.font_size = font_size; return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); } STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap) { int i_ascent, i_descent, i_lineGap; float scale; stbtt_fontinfo info; stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index)); scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size); stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap); *ascent = (float) i_ascent * scale; *descent = (float) i_descent * scale; *lineGap = (float) i_lineGap * scale; } STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) { float ipw = 1.0f / pw, iph = 1.0f / ph; const stbtt_packedchar *b = chardata + char_index; if (align_to_integer) { float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); q->x0 = x; q->y0 = y; q->x1 = x + b->xoff2 - b->xoff; q->y1 = y + b->yoff2 - b->yoff; } else { q->x0 = *xpos + b->xoff; q->y0 = *ypos + b->yoff; q->x1 = *xpos + b->xoff2; q->y1 = *ypos + b->yoff2; } q->s0 = b->x0 * ipw; q->t0 = b->y0 * iph; q->s1 = b->x1 * ipw; q->t1 = b->y1 * iph; *xpos += b->xadvance; } ////////////////////////////////////////////////////////////////////////////// // // sdf computation // #define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) #define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) { float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; float roperp = orig[1]*ray[0] - orig[0]*ray[1]; float a = q0perp - 2*q1perp + q2perp; float b = q1perp - q0perp; float c = q0perp - roperp; float s0 = 0., s1 = 0.; int num_s = 0; if (a != 0.0) { float discr = b*b - a*c; if (discr > 0.0) { float rcpna = -1 / a; float d = (float) STBTT_sqrt(discr); s0 = (b+d) * rcpna; s1 = (b-d) * rcpna; if (s0 >= 0.0 && s0 <= 1.0) num_s = 1; if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { if (num_s == 0) s0 = s1; ++num_s; } } } else { // 2*b*s + c = 0 // s = -c / (2*b) s0 = c / (-2 * b); if (s0 >= 0.0 && s0 <= 1.0) num_s = 1; } if (num_s == 0) return 0; else { float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; float q0d = q0[0]*rayn_x + q0[1]*rayn_y; float q1d = q1[0]*rayn_x + q1[1]*rayn_y; float q2d = q2[0]*rayn_x + q2[1]*rayn_y; float rod = orig[0]*rayn_x + orig[1]*rayn_y; float q10d = q1d - q0d; float q20d = q2d - q0d; float q0rd = q0d - rod; hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; hits[0][1] = a*s0+b; if (num_s > 1) { hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; hits[1][1] = a*s1+b; return 2; } else { return 1; } } } static int equal(float *a, float *b) { return (a[0] == b[0] && a[1] == b[1]); } static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) { int i; float orig[2], ray[2] = { 1, 0 }; float y_frac; int winding = 0; orig[0] = x; orig[1] = y; // make sure y never passes through a vertex of the shape y_frac = (float) STBTT_fmod(y, 1.0f); if (y_frac < 0.01f) y += 0.01f; else if (y_frac > 0.99f) y -= 0.01f; orig[1] = y; // test a ray from (-infinity,y) to (x,y) for (i=0; i < nverts; ++i) { if (verts[i].type == STBTT_vline) { int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; if (x_inter < x) winding += (y0 < y1) ? 1 : -1; } } if (verts[i].type == STBTT_vcurve) { int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); int by = STBTT_max(y0,STBTT_max(y1,y2)); if (y > ay && y < by && x > ax) { float q0[2],q1[2],q2[2]; float hits[2][2]; q0[0] = (float)x0; q0[1] = (float)y0; q1[0] = (float)x1; q1[1] = (float)y1; q2[0] = (float)x2; q2[1] = (float)y2; if (equal(q0,q1) || equal(q1,q2)) { x0 = (int)verts[i-1].x; y0 = (int)verts[i-1].y; x1 = (int)verts[i ].x; y1 = (int)verts[i ].y; if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; if (x_inter < x) winding += (y0 < y1) ? 1 : -1; } } else { int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); if (num_hits >= 1) if (hits[0][0] < 0) winding += (hits[0][1] < 0 ? -1 : 1); if (num_hits >= 2) if (hits[1][0] < 0) winding += (hits[1][1] < 0 ? -1 : 1); } } } } return winding; } static float stbtt__cuberoot( float x ) { if (x<0) return -(float) STBTT_pow(-x,1.0f/3.0f); else return (float) STBTT_pow( x,1.0f/3.0f); } // x^3 + c*x^2 + b*x + a = 0 static int stbtt__solve_cubic(float a, float b, float c, float* r) { float s = -a / 3; float p = b - a*a / 3; float q = a * (2*a*a - 9*b) / 27 + c; float p3 = p*p*p; float d = q*q + 4*p3 / 27; if (d >= 0) { float z = (float) STBTT_sqrt(d); float u = (-q + z) / 2; float v = (-q - z) / 2; u = stbtt__cuberoot(u); v = stbtt__cuberoot(v); r[0] = s + u + v; return 1; } else { float u = (float) STBTT_sqrt(-p/3); float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative float m = (float) STBTT_cos(v); float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; r[0] = s + u * 2 * m; r[1] = s - u * (m + n); r[2] = s - u * (m - n); //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); return 3; } } STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { float scale_x = scale, scale_y = scale; int ix0,iy0,ix1,iy1; int w,h; unsigned char *data; if (scale == 0) return NULL; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); // if empty, return NULL if (ix0 == ix1 || iy0 == iy1) return NULL; ix0 -= padding; iy0 -= padding; ix1 += padding; iy1 += padding; w = (ix1 - ix0); h = (iy1 - iy0); if (width ) *width = w; if (height) *height = h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; // invert for y-downwards bitmaps scale_y = -scale_y; { int x,y,i,j; float *precompute; stbtt_vertex *verts; int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); data = (unsigned char *) STBTT_malloc(w * h, info->userdata); precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); for (i=0,j=num_verts-1; i < num_verts; j=i++) { if (verts[i].type == STBTT_vline) { float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; } else if (verts[i].type == STBTT_vcurve) { float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float len2 = bx*bx + by*by; if (len2 != 0.0f) precompute[i] = 1.0f / (bx*bx + by*by); else precompute[i] = 0.0f; } else precompute[i] = 0.0f; } for (y=iy0; y < iy1; ++y) { for (x=ix0; x < ix1; ++x) { float val; float min_dist = 999999.0f; float sx = (float) x + 0.5f; float sy = (float) y + 0.5f; float x_gspace = (sx / scale_x); float y_gspace = (sy / scale_y); int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path for (i=0; i < num_verts; ++i) { float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); if (dist2 < min_dist*min_dist) min_dist = (float) STBTT_sqrt(dist2); if (verts[i].type == STBTT_vline) { float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; // coarse culling against bbox //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; STBTT_assert(i != 0); if (dist < min_dist) { // check position along line // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) float dx = x1-x0, dy = y1-y0; float px = x0-sx, py = y0-sy; // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve float t = -(px*dx + py*dy) / (dx*dx + dy*dy); if (t >= 0.0f && t <= 1.0f) min_dist = dist; } } else if (verts[i].type == STBTT_vcurve) { float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); // coarse culling against bbox to avoid computing cubic unnecessarily if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { int num=0; float ax = x1-x0, ay = y1-y0; float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; float mx = x0 - sx, my = y0 - sy; float res[3],px,py,t,it; float a_inv = precompute[i]; if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula float a = 3*(ax*bx + ay*by); float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); float c = mx*ax+my*ay; if (a == 0.0) { // if a is 0, it's linear if (b != 0.0) { res[num++] = -c/b; } } else { float discriminant = b*b - 4*a*c; if (discriminant < 0) num = 0; else { float root = (float) STBTT_sqrt(discriminant); res[0] = (-b - root)/(2*a); res[1] = (-b + root)/(2*a); num = 2; // don't bother distinguishing 1-solution case, as code below will still work } } } else { float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; float d = (mx*ax+my*ay) * a_inv; num = stbtt__solve_cubic(b, c, d, res); } if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { t = res[0], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { t = res[1], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { t = res[2], it = 1.0f - t; px = it*it*x0 + 2*t*it*x1 + t*t*x2; py = it*it*y0 + 2*t*it*y1 + t*t*y2; dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); if (dist2 < min_dist * min_dist) min_dist = (float) STBTT_sqrt(dist2); } } } } if (winding == 0) min_dist = -min_dist; // if outside the shape, value is negative val = onedge_value + pixel_dist_scale * min_dist; if (val < 0) val = 0; else if (val > 255) val = 255; data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; } } STBTT_free(precompute, info->userdata); STBTT_free(verts, info->userdata); } return data; } STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); } STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) { STBTT_free(bitmap, userdata); } ////////////////////////////////////////////////////////////////////////////// // // font name matching -- recommended not to use this // // check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; // convert utf16 to utf8 and compare the results while converting while (len2) { stbtt_uint16 ch = s2[0]*256 + s2[1]; if (ch < 0x80) { if (i >= len1) return -1; if (s1[i++] != ch) return -1; } else if (ch < 0x800) { if (i+1 >= len1) return -1; if (s1[i++] != 0xc0 + (ch >> 6)) return -1; if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; } else if (ch >= 0xd800 && ch < 0xdc00) { stbtt_uint32 c; stbtt_uint16 ch2 = s2[2]*256 + s2[3]; if (i+3 >= len1) return -1; c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; if (s1[i++] != 0xf0 + (c >> 18)) return -1; if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; s2 += 2; // plus another 2 below len2 -= 2; } else if (ch >= 0xdc00 && ch < 0xe000) { return -1; } else { if (i+2 >= len1) return -1; if (s1[i++] != 0xe0 + (ch >> 12)) return -1; if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; } s2 += 2; len2 -= 2; } return i; } static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) { return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); } // returns results in whatever encoding you request... but note that 2-byte encodings // will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) { stbtt_int32 i,count,stringOffset; stbtt_uint8 *fc = font->data; stbtt_uint32 offset = font->fontstart; stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); if (!nm) return NULL; count = ttUSHORT(fc+nm+2); stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { stbtt_uint32 loc = nm + 6 + 12 * i; if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { *length = ttUSHORT(fc+loc+8); return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); } } return NULL; } static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) { stbtt_int32 i; stbtt_int32 count = ttUSHORT(fc+nm+2); stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); for (i=0; i < count; ++i) { stbtt_uint32 loc = nm + 6 + 12 * i; stbtt_int32 id = ttUSHORT(fc+loc+6); if (id == target_id) { // find the encoding stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); // is this a Unicode encoding? if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { stbtt_int32 slen = ttUSHORT(fc+loc+8); stbtt_int32 off = ttUSHORT(fc+loc+10); // check if there's a prefix match stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); if (matchlen >= 0) { // check for target_id+1 immediately following, with same encoding & language if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { slen = ttUSHORT(fc+loc+12+8); off = ttUSHORT(fc+loc+12+10); if (slen == 0) { if (matchlen == nlen) return 1; } else if (matchlen < nlen && name[matchlen] == ' ') { ++matchlen; if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) return 1; } } else { // if nothing immediately following if (matchlen == nlen) return 1; } } } // @TODO handle other encodings } } return 0; } static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) { stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); stbtt_uint32 nm,hd; if (!stbtt__isfont(fc+offset)) return 0; // check italics/bold/underline flags in macStyle... if (flags) { hd = stbtt__find_table(fc, offset, "head"); if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; } nm = stbtt__find_table(fc, offset, "name"); if (!nm) return 0; if (flags) { // if we checked the macStyle flags, then just check the family and ignore the subfamily if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } else { if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; } return 0; } static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) { stbtt_int32 i; for (i=0;;++i) { stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); if (off < 0) return off; if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) return off; } } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wcast-qual" #endif STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, float pixel_height, unsigned char *pixels, int pw, int ph, int first_char, int num_chars, stbtt_bakedchar *chardata) { return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); } STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) { return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); } STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) { return stbtt_GetNumberOfFonts_internal((unsigned char *) data); } STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) { return stbtt_InitFont_internal(info, (unsigned char *) data, offset); } STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) { return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); } STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) { return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); } #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif #endif // STB_TRUETYPE_IMPLEMENTATION // FULL VERSION HISTORY // // 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod // 1.18 (2018-01-29) add missing function // 1.17 (2017-07-23) make more arguments const; doc fix // 1.16 (2017-07-12) SDF support // 1.15 (2017-03-03) make more arguments const // 1.14 (2017-01-16) num-fonts-in-TTC function // 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts // 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) allow user-defined fabs() replacement // fix memory leak if fontsize=0.0 // fix warning from duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges // 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges // 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; // allow PackFontRanges to pack and render in separate phases; // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer // 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) // also more precise AA rasterizer, except if shapes overlap // remove need for STBTT_sort // 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC // 1.04 (2015-04-15) typo in example // 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes // 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ // 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match // non-oversampled; STBTT_POINT_SIZE for packed case only // 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling // 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) // 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID // 0.8b (2014-07-07) fix a warning // 0.8 (2014-05-25) fix a few more warnings // 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back // 0.6c (2012-07-24) improve documentation // 0.6b (2012-07-20) fix a few more warnings // 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, // stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty // 0.5 (2011-12-09) bugfixes: // subpixel glyph renderer computed wrong bounding box // first vertex of shape can be off-curve (FreeSans) // 0.4b (2011-12-03) fixed an error in the font baking example // 0.4 (2011-12-01) kerning, subpixel rendering (tor) // bugfixes for: // codepoint-to-glyph conversion using table fmt=12 // codepoint-to-glyph conversion using table fmt=4 // stbtt_GetBakedQuad with non-square texture (Zer) // updated Hello World! sample to use kerning and subpixel // fixed some warnings // 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) // userdata, malloc-from-userdata, non-zero fill (stb) // 0.2 (2009-03-11) Fix unsigned/signed char warnings // 0.1 (2009-03-09) First public release // /* ------------------------------------------------------------------------------ This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------ ALTERNATIVE A - MIT License Copyright (c) 2017 Sean Barrett Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ ALTERNATIVE B - Public Domain (www.unlicense.org) This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ ================================================ FILE: phonelibs/opencl/include/CL/cl.h ================================================ /******************************************************************************* * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ******************************************************************************/ #ifndef __OPENCL_CL_H #define __OPENCL_CL_H #ifdef __APPLE__ #include #else #include #endif #ifdef __cplusplus extern "C" { #endif /******************************************************************************/ typedef struct _cl_platform_id * cl_platform_id; typedef struct _cl_device_id * cl_device_id; typedef struct _cl_context * cl_context; typedef struct _cl_command_queue * cl_command_queue; typedef struct _cl_mem * cl_mem; typedef struct _cl_program * cl_program; typedef struct _cl_kernel * cl_kernel; typedef struct _cl_event * cl_event; typedef struct _cl_sampler * cl_sampler; typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ typedef cl_ulong cl_bitfield; typedef cl_bitfield cl_device_type; typedef cl_uint cl_platform_info; typedef cl_uint cl_device_info; typedef cl_bitfield cl_device_fp_config; typedef cl_uint cl_device_mem_cache_type; typedef cl_uint cl_device_local_mem_type; typedef cl_bitfield cl_device_exec_capabilities; typedef cl_bitfield cl_device_svm_capabilities; typedef cl_bitfield cl_command_queue_properties; typedef intptr_t cl_device_partition_property; typedef cl_bitfield cl_device_affinity_domain; typedef intptr_t cl_context_properties; typedef cl_uint cl_context_info; typedef cl_bitfield cl_queue_properties; typedef cl_uint cl_command_queue_info; typedef cl_uint cl_channel_order; typedef cl_uint cl_channel_type; typedef cl_bitfield cl_mem_flags; typedef cl_bitfield cl_svm_mem_flags; typedef cl_uint cl_mem_object_type; typedef cl_uint cl_mem_info; typedef cl_bitfield cl_mem_migration_flags; typedef cl_uint cl_image_info; typedef cl_uint cl_buffer_create_type; typedef cl_uint cl_addressing_mode; typedef cl_uint cl_filter_mode; typedef cl_uint cl_sampler_info; typedef cl_bitfield cl_map_flags; typedef intptr_t cl_pipe_properties; typedef cl_uint cl_pipe_info; typedef cl_uint cl_program_info; typedef cl_uint cl_program_build_info; typedef cl_uint cl_program_binary_type; typedef cl_int cl_build_status; typedef cl_uint cl_kernel_info; typedef cl_uint cl_kernel_arg_info; typedef cl_uint cl_kernel_arg_address_qualifier; typedef cl_uint cl_kernel_arg_access_qualifier; typedef cl_bitfield cl_kernel_arg_type_qualifier; typedef cl_uint cl_kernel_work_group_info; typedef cl_uint cl_kernel_sub_group_info; typedef cl_uint cl_event_info; typedef cl_uint cl_command_type; typedef cl_uint cl_profiling_info; typedef cl_bitfield cl_sampler_properties; typedef cl_uint cl_kernel_exec_info; typedef struct _cl_image_format { cl_channel_order image_channel_order; cl_channel_type image_channel_data_type; } cl_image_format; typedef struct _cl_image_desc { cl_mem_object_type image_type; size_t image_width; size_t image_height; size_t image_depth; size_t image_array_size; size_t image_row_pitch; size_t image_slice_pitch; cl_uint num_mip_levels; cl_uint num_samples; #ifdef __GNUC__ __extension__ /* Prevents warnings about anonymous union in -pedantic builds */ #endif union { cl_mem buffer; cl_mem mem_object; }; } cl_image_desc; typedef struct _cl_buffer_region { size_t origin; size_t size; } cl_buffer_region; /******************************************************************************/ /* Error Codes */ #define CL_SUCCESS 0 #define CL_DEVICE_NOT_FOUND -1 #define CL_DEVICE_NOT_AVAILABLE -2 #define CL_COMPILER_NOT_AVAILABLE -3 #define CL_MEM_OBJECT_ALLOCATION_FAILURE -4 #define CL_OUT_OF_RESOURCES -5 #define CL_OUT_OF_HOST_MEMORY -6 #define CL_PROFILING_INFO_NOT_AVAILABLE -7 #define CL_MEM_COPY_OVERLAP -8 #define CL_IMAGE_FORMAT_MISMATCH -9 #define CL_IMAGE_FORMAT_NOT_SUPPORTED -10 #define CL_BUILD_PROGRAM_FAILURE -11 #define CL_MAP_FAILURE -12 #define CL_MISALIGNED_SUB_BUFFER_OFFSET -13 #define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14 #define CL_COMPILE_PROGRAM_FAILURE -15 #define CL_LINKER_NOT_AVAILABLE -16 #define CL_LINK_PROGRAM_FAILURE -17 #define CL_DEVICE_PARTITION_FAILED -18 #define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19 #define CL_INVALID_VALUE -30 #define CL_INVALID_DEVICE_TYPE -31 #define CL_INVALID_PLATFORM -32 #define CL_INVALID_DEVICE -33 #define CL_INVALID_CONTEXT -34 #define CL_INVALID_QUEUE_PROPERTIES -35 #define CL_INVALID_COMMAND_QUEUE -36 #define CL_INVALID_HOST_PTR -37 #define CL_INVALID_MEM_OBJECT -38 #define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39 #define CL_INVALID_IMAGE_SIZE -40 #define CL_INVALID_SAMPLER -41 #define CL_INVALID_BINARY -42 #define CL_INVALID_BUILD_OPTIONS -43 #define CL_INVALID_PROGRAM -44 #define CL_INVALID_PROGRAM_EXECUTABLE -45 #define CL_INVALID_KERNEL_NAME -46 #define CL_INVALID_KERNEL_DEFINITION -47 #define CL_INVALID_KERNEL -48 #define CL_INVALID_ARG_INDEX -49 #define CL_INVALID_ARG_VALUE -50 #define CL_INVALID_ARG_SIZE -51 #define CL_INVALID_KERNEL_ARGS -52 #define CL_INVALID_WORK_DIMENSION -53 #define CL_INVALID_WORK_GROUP_SIZE -54 #define CL_INVALID_WORK_ITEM_SIZE -55 #define CL_INVALID_GLOBAL_OFFSET -56 #define CL_INVALID_EVENT_WAIT_LIST -57 #define CL_INVALID_EVENT -58 #define CL_INVALID_OPERATION -59 #define CL_INVALID_GL_OBJECT -60 #define CL_INVALID_BUFFER_SIZE -61 #define CL_INVALID_MIP_LEVEL -62 #define CL_INVALID_GLOBAL_WORK_SIZE -63 #define CL_INVALID_PROPERTY -64 #define CL_INVALID_IMAGE_DESCRIPTOR -65 #define CL_INVALID_COMPILER_OPTIONS -66 #define CL_INVALID_LINKER_OPTIONS -67 #define CL_INVALID_DEVICE_PARTITION_COUNT -68 #define CL_INVALID_PIPE_SIZE -69 #define CL_INVALID_DEVICE_QUEUE -70 /* OpenCL Version */ #define CL_VERSION_1_0 1 #define CL_VERSION_1_1 1 #define CL_VERSION_1_2 1 #define CL_VERSION_2_0 1 #define CL_VERSION_2_1 1 /* cl_bool */ #define CL_FALSE 0 #define CL_TRUE 1 #define CL_BLOCKING CL_TRUE #define CL_NON_BLOCKING CL_FALSE /* cl_platform_info */ #define CL_PLATFORM_PROFILE 0x0900 #define CL_PLATFORM_VERSION 0x0901 #define CL_PLATFORM_NAME 0x0902 #define CL_PLATFORM_VENDOR 0x0903 #define CL_PLATFORM_EXTENSIONS 0x0904 #define CL_PLATFORM_HOST_TIMER_RESOLUTION 0x0905 /* cl_device_type - bitfield */ #define CL_DEVICE_TYPE_DEFAULT (1 << 0) #define CL_DEVICE_TYPE_CPU (1 << 1) #define CL_DEVICE_TYPE_GPU (1 << 2) #define CL_DEVICE_TYPE_ACCELERATOR (1 << 3) #define CL_DEVICE_TYPE_CUSTOM (1 << 4) #define CL_DEVICE_TYPE_ALL 0xFFFFFFFF /* cl_device_info */ #define CL_DEVICE_TYPE 0x1000 #define CL_DEVICE_VENDOR_ID 0x1001 #define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002 #define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003 #define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004 #define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009 #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B #define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C #define CL_DEVICE_ADDRESS_BITS 0x100D #define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E #define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F #define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010 #define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011 #define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012 #define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013 #define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014 #define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015 #define CL_DEVICE_IMAGE_SUPPORT 0x1016 #define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017 #define CL_DEVICE_MAX_SAMPLERS 0x1018 #define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019 #define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A #define CL_DEVICE_SINGLE_FP_CONFIG 0x101B #define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C #define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D #define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E #define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F #define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020 #define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021 #define CL_DEVICE_LOCAL_MEM_TYPE 0x1022 #define CL_DEVICE_LOCAL_MEM_SIZE 0x1023 #define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024 #define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025 #define CL_DEVICE_ENDIAN_LITTLE 0x1026 #define CL_DEVICE_AVAILABLE 0x1027 #define CL_DEVICE_COMPILER_AVAILABLE 0x1028 #define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029 #define CL_DEVICE_QUEUE_PROPERTIES 0x102A /* deprecated */ #define CL_DEVICE_QUEUE_ON_HOST_PROPERTIES 0x102A #define CL_DEVICE_NAME 0x102B #define CL_DEVICE_VENDOR 0x102C #define CL_DRIVER_VERSION 0x102D #define CL_DEVICE_PROFILE 0x102E #define CL_DEVICE_VERSION 0x102F #define CL_DEVICE_EXTENSIONS 0x1030 #define CL_DEVICE_PLATFORM 0x1031 #define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032 /* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */ #define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034 #define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035 /* deprecated */ #define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039 #define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A #define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B #define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C #define CL_DEVICE_OPENCL_C_VERSION 0x103D #define CL_DEVICE_LINKER_AVAILABLE 0x103E #define CL_DEVICE_BUILT_IN_KERNELS 0x103F #define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040 #define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041 #define CL_DEVICE_PARENT_DEVICE 0x1042 #define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043 #define CL_DEVICE_PARTITION_PROPERTIES 0x1044 #define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045 #define CL_DEVICE_PARTITION_TYPE 0x1046 #define CL_DEVICE_REFERENCE_COUNT 0x1047 #define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048 #define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049 #define CL_DEVICE_IMAGE_PITCH_ALIGNMENT 0x104A #define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT 0x104B #define CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS 0x104C #define CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE 0x104D #define CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES 0x104E #define CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE 0x104F #define CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE 0x1050 #define CL_DEVICE_MAX_ON_DEVICE_QUEUES 0x1051 #define CL_DEVICE_MAX_ON_DEVICE_EVENTS 0x1052 #define CL_DEVICE_SVM_CAPABILITIES 0x1053 #define CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE 0x1054 #define CL_DEVICE_MAX_PIPE_ARGS 0x1055 #define CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS 0x1056 #define CL_DEVICE_PIPE_MAX_PACKET_SIZE 0x1057 #define CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT 0x1058 #define CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT 0x1059 #define CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT 0x105A #define CL_DEVICE_IL_VERSION 0x105B #define CL_DEVICE_MAX_NUM_SUB_GROUPS 0x105C #define CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS 0x105D /* cl_device_fp_config - bitfield */ #define CL_FP_DENORM (1 << 0) #define CL_FP_INF_NAN (1 << 1) #define CL_FP_ROUND_TO_NEAREST (1 << 2) #define CL_FP_ROUND_TO_ZERO (1 << 3) #define CL_FP_ROUND_TO_INF (1 << 4) #define CL_FP_FMA (1 << 5) #define CL_FP_SOFT_FLOAT (1 << 6) #define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7) /* cl_device_mem_cache_type */ #define CL_NONE 0x0 #define CL_READ_ONLY_CACHE 0x1 #define CL_READ_WRITE_CACHE 0x2 /* cl_device_local_mem_type */ #define CL_LOCAL 0x1 #define CL_GLOBAL 0x2 /* cl_device_exec_capabilities - bitfield */ #define CL_EXEC_KERNEL (1 << 0) #define CL_EXEC_NATIVE_KERNEL (1 << 1) /* cl_command_queue_properties - bitfield */ #define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0) #define CL_QUEUE_PROFILING_ENABLE (1 << 1) #define CL_QUEUE_ON_DEVICE (1 << 2) #define CL_QUEUE_ON_DEVICE_DEFAULT (1 << 3) /* cl_context_info */ #define CL_CONTEXT_REFERENCE_COUNT 0x1080 #define CL_CONTEXT_DEVICES 0x1081 #define CL_CONTEXT_PROPERTIES 0x1082 #define CL_CONTEXT_NUM_DEVICES 0x1083 /* cl_context_properties */ #define CL_CONTEXT_PLATFORM 0x1084 #define CL_CONTEXT_INTEROP_USER_SYNC 0x1085 /* cl_device_partition_property */ #define CL_DEVICE_PARTITION_EQUALLY 0x1086 #define CL_DEVICE_PARTITION_BY_COUNTS 0x1087 #define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0 #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088 /* cl_device_affinity_domain */ #define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0) #define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1) #define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2) #define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3) #define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4) #define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5) /* cl_device_svm_capabilities */ #define CL_DEVICE_SVM_COARSE_GRAIN_BUFFER (1 << 0) #define CL_DEVICE_SVM_FINE_GRAIN_BUFFER (1 << 1) #define CL_DEVICE_SVM_FINE_GRAIN_SYSTEM (1 << 2) #define CL_DEVICE_SVM_ATOMICS (1 << 3) /* cl_command_queue_info */ #define CL_QUEUE_CONTEXT 0x1090 #define CL_QUEUE_DEVICE 0x1091 #define CL_QUEUE_REFERENCE_COUNT 0x1092 #define CL_QUEUE_PROPERTIES 0x1093 #define CL_QUEUE_SIZE 0x1094 #define CL_QUEUE_DEVICE_DEFAULT 0x1095 /* cl_mem_flags and cl_svm_mem_flags - bitfield */ #define CL_MEM_READ_WRITE (1 << 0) #define CL_MEM_WRITE_ONLY (1 << 1) #define CL_MEM_READ_ONLY (1 << 2) #define CL_MEM_USE_HOST_PTR (1 << 3) #define CL_MEM_ALLOC_HOST_PTR (1 << 4) #define CL_MEM_COPY_HOST_PTR (1 << 5) /* reserved (1 << 6) */ #define CL_MEM_HOST_WRITE_ONLY (1 << 7) #define CL_MEM_HOST_READ_ONLY (1 << 8) #define CL_MEM_HOST_NO_ACCESS (1 << 9) #define CL_MEM_SVM_FINE_GRAIN_BUFFER (1 << 10) /* used by cl_svm_mem_flags only */ #define CL_MEM_SVM_ATOMICS (1 << 11) /* used by cl_svm_mem_flags only */ #define CL_MEM_KERNEL_READ_AND_WRITE (1 << 12) /* cl_mem_migration_flags - bitfield */ #define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0) #define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1) /* cl_channel_order */ #define CL_R 0x10B0 #define CL_A 0x10B1 #define CL_RG 0x10B2 #define CL_RA 0x10B3 #define CL_RGB 0x10B4 #define CL_RGBA 0x10B5 #define CL_BGRA 0x10B6 #define CL_ARGB 0x10B7 #define CL_INTENSITY 0x10B8 #define CL_LUMINANCE 0x10B9 #define CL_Rx 0x10BA #define CL_RGx 0x10BB #define CL_RGBx 0x10BC #define CL_DEPTH 0x10BD #define CL_DEPTH_STENCIL 0x10BE #define CL_sRGB 0x10BF #define CL_sRGBx 0x10C0 #define CL_sRGBA 0x10C1 #define CL_sBGRA 0x10C2 #define CL_ABGR 0x10C3 /* cl_channel_type */ #define CL_SNORM_INT8 0x10D0 #define CL_SNORM_INT16 0x10D1 #define CL_UNORM_INT8 0x10D2 #define CL_UNORM_INT16 0x10D3 #define CL_UNORM_SHORT_565 0x10D4 #define CL_UNORM_SHORT_555 0x10D5 #define CL_UNORM_INT_101010 0x10D6 #define CL_SIGNED_INT8 0x10D7 #define CL_SIGNED_INT16 0x10D8 #define CL_SIGNED_INT32 0x10D9 #define CL_UNSIGNED_INT8 0x10DA #define CL_UNSIGNED_INT16 0x10DB #define CL_UNSIGNED_INT32 0x10DC #define CL_HALF_FLOAT 0x10DD #define CL_FLOAT 0x10DE #define CL_UNORM_INT24 0x10DF #define CL_UNORM_INT_101010_2 0x10E0 /* cl_mem_object_type */ #define CL_MEM_OBJECT_BUFFER 0x10F0 #define CL_MEM_OBJECT_IMAGE2D 0x10F1 #define CL_MEM_OBJECT_IMAGE3D 0x10F2 #define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3 #define CL_MEM_OBJECT_IMAGE1D 0x10F4 #define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5 #define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6 #define CL_MEM_OBJECT_PIPE 0x10F7 /* cl_mem_info */ #define CL_MEM_TYPE 0x1100 #define CL_MEM_FLAGS 0x1101 #define CL_MEM_SIZE 0x1102 #define CL_MEM_HOST_PTR 0x1103 #define CL_MEM_MAP_COUNT 0x1104 #define CL_MEM_REFERENCE_COUNT 0x1105 #define CL_MEM_CONTEXT 0x1106 #define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107 #define CL_MEM_OFFSET 0x1108 #define CL_MEM_USES_SVM_POINTER 0x1109 /* cl_image_info */ #define CL_IMAGE_FORMAT 0x1110 #define CL_IMAGE_ELEMENT_SIZE 0x1111 #define CL_IMAGE_ROW_PITCH 0x1112 #define CL_IMAGE_SLICE_PITCH 0x1113 #define CL_IMAGE_WIDTH 0x1114 #define CL_IMAGE_HEIGHT 0x1115 #define CL_IMAGE_DEPTH 0x1116 #define CL_IMAGE_ARRAY_SIZE 0x1117 #define CL_IMAGE_BUFFER 0x1118 #define CL_IMAGE_NUM_MIP_LEVELS 0x1119 #define CL_IMAGE_NUM_SAMPLES 0x111A /* cl_pipe_info */ #define CL_PIPE_PACKET_SIZE 0x1120 #define CL_PIPE_MAX_PACKETS 0x1121 /* cl_addressing_mode */ #define CL_ADDRESS_NONE 0x1130 #define CL_ADDRESS_CLAMP_TO_EDGE 0x1131 #define CL_ADDRESS_CLAMP 0x1132 #define CL_ADDRESS_REPEAT 0x1133 #define CL_ADDRESS_MIRRORED_REPEAT 0x1134 /* cl_filter_mode */ #define CL_FILTER_NEAREST 0x1140 #define CL_FILTER_LINEAR 0x1141 /* cl_sampler_info */ #define CL_SAMPLER_REFERENCE_COUNT 0x1150 #define CL_SAMPLER_CONTEXT 0x1151 #define CL_SAMPLER_NORMALIZED_COORDS 0x1152 #define CL_SAMPLER_ADDRESSING_MODE 0x1153 #define CL_SAMPLER_FILTER_MODE 0x1154 #define CL_SAMPLER_MIP_FILTER_MODE 0x1155 #define CL_SAMPLER_LOD_MIN 0x1156 #define CL_SAMPLER_LOD_MAX 0x1157 /* cl_map_flags - bitfield */ #define CL_MAP_READ (1 << 0) #define CL_MAP_WRITE (1 << 1) #define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2) /* cl_program_info */ #define CL_PROGRAM_REFERENCE_COUNT 0x1160 #define CL_PROGRAM_CONTEXT 0x1161 #define CL_PROGRAM_NUM_DEVICES 0x1162 #define CL_PROGRAM_DEVICES 0x1163 #define CL_PROGRAM_SOURCE 0x1164 #define CL_PROGRAM_BINARY_SIZES 0x1165 #define CL_PROGRAM_BINARIES 0x1166 #define CL_PROGRAM_NUM_KERNELS 0x1167 #define CL_PROGRAM_KERNEL_NAMES 0x1168 #define CL_PROGRAM_IL 0x1169 /* cl_program_build_info */ #define CL_PROGRAM_BUILD_STATUS 0x1181 #define CL_PROGRAM_BUILD_OPTIONS 0x1182 #define CL_PROGRAM_BUILD_LOG 0x1183 #define CL_PROGRAM_BINARY_TYPE 0x1184 #define CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE 0x1185 /* cl_program_binary_type */ #define CL_PROGRAM_BINARY_TYPE_NONE 0x0 #define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1 #define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2 #define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4 /* cl_build_status */ #define CL_BUILD_SUCCESS 0 #define CL_BUILD_NONE -1 #define CL_BUILD_ERROR -2 #define CL_BUILD_IN_PROGRESS -3 /* cl_kernel_info */ #define CL_KERNEL_FUNCTION_NAME 0x1190 #define CL_KERNEL_NUM_ARGS 0x1191 #define CL_KERNEL_REFERENCE_COUNT 0x1192 #define CL_KERNEL_CONTEXT 0x1193 #define CL_KERNEL_PROGRAM 0x1194 #define CL_KERNEL_ATTRIBUTES 0x1195 #define CL_KERNEL_MAX_NUM_SUB_GROUPS 0x11B9 #define CL_KERNEL_COMPILE_NUM_SUB_GROUPS 0x11BA /* cl_kernel_arg_info */ #define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196 #define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197 #define CL_KERNEL_ARG_TYPE_NAME 0x1198 #define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199 #define CL_KERNEL_ARG_NAME 0x119A /* cl_kernel_arg_address_qualifier */ #define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B #define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C #define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D #define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E /* cl_kernel_arg_access_qualifier */ #define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0 #define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1 #define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2 #define CL_KERNEL_ARG_ACCESS_NONE 0x11A3 /* cl_kernel_arg_type_qualifer */ #define CL_KERNEL_ARG_TYPE_NONE 0 #define CL_KERNEL_ARG_TYPE_CONST (1 << 0) #define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1) #define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2) #define CL_KERNEL_ARG_TYPE_PIPE (1 << 3) /* cl_kernel_work_group_info */ #define CL_KERNEL_WORK_GROUP_SIZE 0x11B0 #define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1 #define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2 #define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3 #define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4 #define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5 /* cl_kernel_sub_group_info */ #define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE 0x2033 #define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE 0x2034 #define CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT 0x11B8 /* cl_kernel_exec_info */ #define CL_KERNEL_EXEC_INFO_SVM_PTRS 0x11B6 #define CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM 0x11B7 /* cl_event_info */ #define CL_EVENT_COMMAND_QUEUE 0x11D0 #define CL_EVENT_COMMAND_TYPE 0x11D1 #define CL_EVENT_REFERENCE_COUNT 0x11D2 #define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3 #define CL_EVENT_CONTEXT 0x11D4 /* cl_command_type */ #define CL_COMMAND_NDRANGE_KERNEL 0x11F0 #define CL_COMMAND_TASK 0x11F1 #define CL_COMMAND_NATIVE_KERNEL 0x11F2 #define CL_COMMAND_READ_BUFFER 0x11F3 #define CL_COMMAND_WRITE_BUFFER 0x11F4 #define CL_COMMAND_COPY_BUFFER 0x11F5 #define CL_COMMAND_READ_IMAGE 0x11F6 #define CL_COMMAND_WRITE_IMAGE 0x11F7 #define CL_COMMAND_COPY_IMAGE 0x11F8 #define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9 #define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA #define CL_COMMAND_MAP_BUFFER 0x11FB #define CL_COMMAND_MAP_IMAGE 0x11FC #define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD #define CL_COMMAND_MARKER 0x11FE #define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF #define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200 #define CL_COMMAND_READ_BUFFER_RECT 0x1201 #define CL_COMMAND_WRITE_BUFFER_RECT 0x1202 #define CL_COMMAND_COPY_BUFFER_RECT 0x1203 #define CL_COMMAND_USER 0x1204 #define CL_COMMAND_BARRIER 0x1205 #define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206 #define CL_COMMAND_FILL_BUFFER 0x1207 #define CL_COMMAND_FILL_IMAGE 0x1208 #define CL_COMMAND_SVM_FREE 0x1209 #define CL_COMMAND_SVM_MEMCPY 0x120A #define CL_COMMAND_SVM_MEMFILL 0x120B #define CL_COMMAND_SVM_MAP 0x120C #define CL_COMMAND_SVM_UNMAP 0x120D /* command execution status */ #define CL_COMPLETE 0x0 #define CL_RUNNING 0x1 #define CL_SUBMITTED 0x2 #define CL_QUEUED 0x3 /* cl_buffer_create_type */ #define CL_BUFFER_CREATE_TYPE_REGION 0x1220 /* cl_profiling_info */ #define CL_PROFILING_COMMAND_QUEUED 0x1280 #define CL_PROFILING_COMMAND_SUBMIT 0x1281 #define CL_PROFILING_COMMAND_START 0x1282 #define CL_PROFILING_COMMAND_END 0x1283 #define CL_PROFILING_COMMAND_COMPLETE 0x1284 /********************************************************************************************************/ /* Platform API */ extern CL_API_ENTRY cl_int CL_API_CALL clGetPlatformIDs(cl_uint /* num_entries */, cl_platform_id * /* platforms */, cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetPlatformInfo(cl_platform_id /* platform */, cl_platform_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; /* Device APIs */ extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id /* platform */, cl_device_type /* device_type */, cl_uint /* num_entries */, cl_device_id * /* devices */, cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceInfo(cl_device_id /* device */, cl_device_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clCreateSubDevices(cl_device_id /* in_device */, const cl_device_partition_property * /* properties */, cl_uint /* num_devices */, cl_device_id * /* out_devices */, cl_uint * /* num_devices_ret */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clRetainDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clSetDefaultDeviceCommandQueue(cl_context /* context */, cl_device_id /* device */, cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_2_1; extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceAndHostTimer(cl_device_id /* device */, cl_ulong* /* device_timestamp */, cl_ulong* /* host_timestamp */) CL_API_SUFFIX__VERSION_2_1; extern CL_API_ENTRY cl_int CL_API_CALL clGetHostTimer(cl_device_id /* device */, cl_ulong * /* host_timestamp */) CL_API_SUFFIX__VERSION_2_1; /* Context APIs */ extern CL_API_ENTRY cl_context CL_API_CALL clCreateContext(const cl_context_properties * /* properties */, cl_uint /* num_devices */, const cl_device_id * /* devices */, void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *), void * /* user_data */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties * /* properties */, cl_device_type /* device_type */, void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *), void * /* user_data */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetContextInfo(cl_context /* context */, cl_context_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; /* Command Queue APIs */ extern CL_API_ENTRY cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties(cl_context /* context */, cl_device_id /* device */, const cl_queue_properties * /* properties */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetCommandQueueInfo(cl_command_queue /* command_queue */, cl_command_queue_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; /* Memory Object APIs */ extern CL_API_ENTRY cl_mem CL_API_CALL clCreateBuffer(cl_context /* context */, cl_mem_flags /* flags */, size_t /* size */, void * /* host_ptr */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_mem CL_API_CALL clCreateSubBuffer(cl_mem /* buffer */, cl_mem_flags /* flags */, cl_buffer_create_type /* buffer_create_type */, const void * /* buffer_create_info */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_mem CL_API_CALL clCreateImage(cl_context /* context */, cl_mem_flags /* flags */, const cl_image_format * /* image_format */, const cl_image_desc * /* image_desc */, void * /* host_ptr */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_mem CL_API_CALL clCreatePipe(cl_context /* context */, cl_mem_flags /* flags */, cl_uint /* pipe_packet_size */, cl_uint /* pipe_max_packets */, const cl_pipe_properties * /* properties */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetSupportedImageFormats(cl_context /* context */, cl_mem_flags /* flags */, cl_mem_object_type /* image_type */, cl_uint /* num_entries */, cl_image_format * /* image_formats */, cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetMemObjectInfo(cl_mem /* memobj */, cl_mem_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetImageInfo(cl_mem /* image */, cl_image_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetPipeInfo(cl_mem /* pipe */, cl_pipe_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clSetMemObjectDestructorCallback(cl_mem /* memobj */, void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1; /* SVM Allocation APIs */ extern CL_API_ENTRY void * CL_API_CALL clSVMAlloc(cl_context /* context */, cl_svm_mem_flags /* flags */, size_t /* size */, cl_uint /* alignment */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY void CL_API_CALL clSVMFree(cl_context /* context */, void * /* svm_pointer */) CL_API_SUFFIX__VERSION_2_0; /* Sampler APIs */ extern CL_API_ENTRY cl_sampler CL_API_CALL clCreateSamplerWithProperties(cl_context /* context */, const cl_sampler_properties * /* normalized_coords */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetSamplerInfo(cl_sampler /* sampler */, cl_sampler_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; /* Program Object APIs */ extern CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithSource(cl_context /* context */, cl_uint /* count */, const char ** /* strings */, const size_t * /* lengths */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithBinary(cl_context /* context */, cl_uint /* num_devices */, const cl_device_id * /* device_list */, const size_t * /* lengths */, const unsigned char ** /* binaries */, cl_int * /* binary_status */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithBuiltInKernels(cl_context /* context */, cl_uint /* num_devices */, const cl_device_id * /* device_list */, const char * /* kernel_names */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_program CL_API_CALL clCreateProgramWithIL(cl_context /* context */, const void* /* il */, size_t /* length */, cl_int* /* errcode_ret */) CL_API_SUFFIX__VERSION_2_1; extern CL_API_ENTRY cl_int CL_API_CALL clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clBuildProgram(cl_program /* program */, cl_uint /* num_devices */, const cl_device_id * /* device_list */, const char * /* options */, void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), void * /* user_data */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clCompileProgram(cl_program /* program */, cl_uint /* num_devices */, const cl_device_id * /* device_list */, const char * /* options */, cl_uint /* num_input_headers */, const cl_program * /* input_headers */, const char ** /* header_include_names */, void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), void * /* user_data */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_program CL_API_CALL clLinkProgram(cl_context /* context */, cl_uint /* num_devices */, const cl_device_id * /* device_list */, const char * /* options */, cl_uint /* num_input_programs */, const cl_program * /* input_programs */, void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */), void * /* user_data */, cl_int * /* errcode_ret */ ) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clUnloadPlatformCompiler(cl_platform_id /* platform */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clGetProgramInfo(cl_program /* program */, cl_program_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetProgramBuildInfo(cl_program /* program */, cl_device_id /* device */, cl_program_build_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; /* Kernel Object APIs */ extern CL_API_ENTRY cl_kernel CL_API_CALL clCreateKernel(cl_program /* program */, const char * /* kernel_name */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clCreateKernelsInProgram(cl_program /* program */, cl_uint /* num_kernels */, cl_kernel * /* kernels */, cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_kernel CL_API_CALL clCloneKernel(cl_kernel /* source_kernel */, cl_int* /* errcode_ret */) CL_API_SUFFIX__VERSION_2_1; extern CL_API_ENTRY cl_int CL_API_CALL clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clSetKernelArg(cl_kernel /* kernel */, cl_uint /* arg_index */, size_t /* arg_size */, const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clSetKernelArgSVMPointer(cl_kernel /* kernel */, cl_uint /* arg_index */, const void * /* arg_value */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clSetKernelExecInfo(cl_kernel /* kernel */, cl_kernel_exec_info /* param_name */, size_t /* param_value_size */, const void * /* param_value */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetKernelInfo(cl_kernel /* kernel */, cl_kernel_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetKernelArgInfo(cl_kernel /* kernel */, cl_uint /* arg_indx */, cl_kernel_arg_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clGetKernelWorkGroupInfo(cl_kernel /* kernel */, cl_device_id /* device */, cl_kernel_work_group_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetKernelSubGroupInfo(cl_kernel /* kernel */, cl_device_id /* device */, cl_kernel_sub_group_info /* param_name */, size_t /* input_value_size */, const void* /*input_value */, size_t /* param_value_size */, void* /* param_value */, size_t* /* param_value_size_ret */ ) CL_API_SUFFIX__VERSION_2_1; /* Event Object APIs */ extern CL_API_ENTRY cl_int CL_API_CALL clWaitForEvents(cl_uint /* num_events */, const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetEventInfo(cl_event /* event */, cl_event_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_event CL_API_CALL clCreateUserEvent(cl_context /* context */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_int CL_API_CALL clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clSetUserEventStatus(cl_event /* event */, cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_int CL_API_CALL clSetEventCallback( cl_event /* event */, cl_int /* command_exec_callback_type */, void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *), void * /* user_data */) CL_API_SUFFIX__VERSION_1_1; /* Profiling APIs */ extern CL_API_ENTRY cl_int CL_API_CALL clGetEventProfilingInfo(cl_event /* event */, cl_profiling_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; /* Flush and Finish APIs */ extern CL_API_ENTRY cl_int CL_API_CALL clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0; /* Enqueued Commands APIs */ extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadBuffer(cl_command_queue /* command_queue */, cl_mem /* buffer */, cl_bool /* blocking_read */, size_t /* offset */, size_t /* size */, void * /* ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadBufferRect(cl_command_queue /* command_queue */, cl_mem /* buffer */, cl_bool /* blocking_read */, const size_t * /* buffer_offset */, const size_t * /* host_offset */, const size_t * /* region */, size_t /* buffer_row_pitch */, size_t /* buffer_slice_pitch */, size_t /* host_row_pitch */, size_t /* host_slice_pitch */, void * /* ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteBuffer(cl_command_queue /* command_queue */, cl_mem /* buffer */, cl_bool /* blocking_write */, size_t /* offset */, size_t /* size */, const void * /* ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteBufferRect(cl_command_queue /* command_queue */, cl_mem /* buffer */, cl_bool /* blocking_write */, const size_t * /* buffer_offset */, const size_t * /* host_offset */, const size_t * /* region */, size_t /* buffer_row_pitch */, size_t /* buffer_slice_pitch */, size_t /* host_row_pitch */, size_t /* host_slice_pitch */, const void * /* ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueFillBuffer(cl_command_queue /* command_queue */, cl_mem /* buffer */, const void * /* pattern */, size_t /* pattern_size */, size_t /* offset */, size_t /* size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBuffer(cl_command_queue /* command_queue */, cl_mem /* src_buffer */, cl_mem /* dst_buffer */, size_t /* src_offset */, size_t /* dst_offset */, size_t /* size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBufferRect(cl_command_queue /* command_queue */, cl_mem /* src_buffer */, cl_mem /* dst_buffer */, const size_t * /* src_origin */, const size_t * /* dst_origin */, const size_t * /* region */, size_t /* src_row_pitch */, size_t /* src_slice_pitch */, size_t /* dst_row_pitch */, size_t /* dst_slice_pitch */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReadImage(cl_command_queue /* command_queue */, cl_mem /* image */, cl_bool /* blocking_read */, const size_t * /* origin[3] */, const size_t * /* region[3] */, size_t /* row_pitch */, size_t /* slice_pitch */, void * /* ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueWriteImage(cl_command_queue /* command_queue */, cl_mem /* image */, cl_bool /* blocking_write */, const size_t * /* origin[3] */, const size_t * /* region[3] */, size_t /* input_row_pitch */, size_t /* input_slice_pitch */, const void * /* ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueFillImage(cl_command_queue /* command_queue */, cl_mem /* image */, const void * /* fill_color */, const size_t * /* origin[3] */, const size_t * /* region[3] */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImage(cl_command_queue /* command_queue */, cl_mem /* src_image */, cl_mem /* dst_image */, const size_t * /* src_origin[3] */, const size_t * /* dst_origin[3] */, const size_t * /* region[3] */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */, cl_mem /* src_image */, cl_mem /* dst_buffer */, const size_t * /* src_origin[3] */, const size_t * /* region[3] */, size_t /* dst_offset */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */, cl_mem /* src_buffer */, cl_mem /* dst_image */, size_t /* src_offset */, const size_t * /* dst_origin[3] */, const size_t * /* region[3] */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY void * CL_API_CALL clEnqueueMapBuffer(cl_command_queue /* command_queue */, cl_mem /* buffer */, cl_bool /* blocking_map */, cl_map_flags /* map_flags */, size_t /* offset */, size_t /* size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY void * CL_API_CALL clEnqueueMapImage(cl_command_queue /* command_queue */, cl_mem /* image */, cl_bool /* blocking_map */, cl_map_flags /* map_flags */, const size_t * /* origin[3] */, const size_t * /* region[3] */, size_t * /* image_row_pitch */, size_t * /* image_slice_pitch */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueUnmapMemObject(cl_command_queue /* command_queue */, cl_mem /* memobj */, void * /* mapped_ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueMigrateMemObjects(cl_command_queue /* command_queue */, cl_uint /* num_mem_objects */, const cl_mem * /* mem_objects */, cl_mem_migration_flags /* flags */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueNDRangeKernel(cl_command_queue /* command_queue */, cl_kernel /* kernel */, cl_uint /* work_dim */, const size_t * /* global_work_offset */, const size_t * /* global_work_size */, const size_t * /* local_work_size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueNativeKernel(cl_command_queue /* command_queue */, void (CL_CALLBACK * /*user_func*/)(void *), void * /* args */, size_t /* cb_args */, cl_uint /* num_mem_objects */, const cl_mem * /* mem_list */, const void ** /* args_mem_loc */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueMarkerWithWaitList(cl_command_queue /* command_queue */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueBarrierWithWaitList(cl_command_queue /* command_queue */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMFree(cl_command_queue /* command_queue */, cl_uint /* num_svm_pointers */, void *[] /* svm_pointers[] */, void (CL_CALLBACK * /*pfn_free_func*/)(cl_command_queue /* queue */, cl_uint /* num_svm_pointers */, void *[] /* svm_pointers[] */, void * /* user_data */), void * /* user_data */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMemcpy(cl_command_queue /* command_queue */, cl_bool /* blocking_copy */, void * /* dst_ptr */, const void * /* src_ptr */, size_t /* size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMemFill(cl_command_queue /* command_queue */, void * /* svm_ptr */, const void * /* pattern */, size_t /* pattern_size */, size_t /* size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMap(cl_command_queue /* command_queue */, cl_bool /* blocking_map */, cl_map_flags /* flags */, void * /* svm_ptr */, size_t /* size */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMUnmap(cl_command_queue /* command_queue */, void * /* svm_ptr */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_2_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueSVMMigrateMem(cl_command_queue /* command_queue */, cl_uint /* num_svm_pointers */, const void ** /* svm_pointers */, const size_t * /* sizes */, cl_mem_migration_flags /* flags */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_2_1; /* Extension function access * * Returns the extension function address for the given function name, * or NULL if a valid function can not be found. The client must * check to make sure the address is not NULL, before using or * calling the returned function address. */ extern CL_API_ENTRY void * CL_API_CALL clGetExtensionFunctionAddressForPlatform(cl_platform_id /* platform */, const char * /* func_name */) CL_API_SUFFIX__VERSION_1_2; /* Deprecated OpenCL 1.1 APIs */ extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateImage2D(cl_context /* context */, cl_mem_flags /* flags */, const cl_image_format * /* image_format */, size_t /* image_width */, size_t /* image_height */, size_t /* image_row_pitch */, void * /* host_ptr */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateImage3D(cl_context /* context */, cl_mem_flags /* flags */, const cl_image_format * /* image_format */, size_t /* image_width */, size_t /* image_height */, size_t /* image_depth */, size_t /* image_row_pitch */, size_t /* image_slice_pitch */, void * /* host_ptr */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueMarker(cl_command_queue /* command_queue */, cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueWaitForEvents(cl_command_queue /* command_queue */, cl_uint /* num_events */, const cl_event * /* event_list */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clEnqueueBarrier(cl_command_queue /* command_queue */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED void * CL_API_CALL clGetExtensionFunctionAddress(const char * /* func_name */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; /* Deprecated OpenCL 2.0 APIs */ extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_command_queue CL_API_CALL clCreateCommandQueue(cl_context /* context */, cl_device_id /* device */, cl_command_queue_properties /* properties */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_sampler CL_API_CALL clCreateSampler(cl_context /* context */, cl_bool /* normalized_coords */, cl_addressing_mode /* addressing_mode */, cl_filter_mode /* filter_mode */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_2_DEPRECATED cl_int CL_API_CALL clEnqueueTask(cl_command_queue /* command_queue */, cl_kernel /* kernel */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED; #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_d3d10.h ================================================ /********************************************************************************** * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. **********************************************************************************/ /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ #ifndef __OPENCL_CL_D3D10_H #define __OPENCL_CL_D3D10_H #include #include #include #ifdef __cplusplus extern "C" { #endif /****************************************************************************** * cl_khr_d3d10_sharing */ #define cl_khr_d3d10_sharing 1 typedef cl_uint cl_d3d10_device_source_khr; typedef cl_uint cl_d3d10_device_set_khr; /******************************************************************************/ /* Error Codes */ #define CL_INVALID_D3D10_DEVICE_KHR -1002 #define CL_INVALID_D3D10_RESOURCE_KHR -1003 #define CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR -1004 #define CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR -1005 /* cl_d3d10_device_source_nv */ #define CL_D3D10_DEVICE_KHR 0x4010 #define CL_D3D10_DXGI_ADAPTER_KHR 0x4011 /* cl_d3d10_device_set_nv */ #define CL_PREFERRED_DEVICES_FOR_D3D10_KHR 0x4012 #define CL_ALL_DEVICES_FOR_D3D10_KHR 0x4013 /* cl_context_info */ #define CL_CONTEXT_D3D10_DEVICE_KHR 0x4014 #define CL_CONTEXT_D3D10_PREFER_SHARED_RESOURCES_KHR 0x402C /* cl_mem_info */ #define CL_MEM_D3D10_RESOURCE_KHR 0x4015 /* cl_image_info */ #define CL_IMAGE_D3D10_SUBRESOURCE_KHR 0x4016 /* cl_command_type */ #define CL_COMMAND_ACQUIRE_D3D10_OBJECTS_KHR 0x4017 #define CL_COMMAND_RELEASE_D3D10_OBJECTS_KHR 0x4018 /******************************************************************************/ typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D10KHR_fn)( cl_platform_id platform, cl_d3d10_device_source_khr d3d_device_source, void * d3d_object, cl_d3d10_device_set_khr d3d_device_set, cl_uint num_entries, cl_device_id * devices, cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10BufferKHR_fn)( cl_context context, cl_mem_flags flags, ID3D10Buffer * resource, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture2DKHR_fn)( cl_context context, cl_mem_flags flags, ID3D10Texture2D * resource, UINT subresource, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D10Texture3DKHR_fn)( cl_context context, cl_mem_flags flags, ID3D10Texture3D * resource, UINT subresource, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D10ObjectsKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D10ObjectsKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) CL_API_SUFFIX__VERSION_1_0; #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_D3D10_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_d3d11.h ================================================ /********************************************************************************** * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. **********************************************************************************/ /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ #ifndef __OPENCL_CL_D3D11_H #define __OPENCL_CL_D3D11_H #include #include #include #ifdef __cplusplus extern "C" { #endif /****************************************************************************** * cl_khr_d3d11_sharing */ #define cl_khr_d3d11_sharing 1 typedef cl_uint cl_d3d11_device_source_khr; typedef cl_uint cl_d3d11_device_set_khr; /******************************************************************************/ /* Error Codes */ #define CL_INVALID_D3D11_DEVICE_KHR -1006 #define CL_INVALID_D3D11_RESOURCE_KHR -1007 #define CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR -1008 #define CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR -1009 /* cl_d3d11_device_source */ #define CL_D3D11_DEVICE_KHR 0x4019 #define CL_D3D11_DXGI_ADAPTER_KHR 0x401A /* cl_d3d11_device_set */ #define CL_PREFERRED_DEVICES_FOR_D3D11_KHR 0x401B #define CL_ALL_DEVICES_FOR_D3D11_KHR 0x401C /* cl_context_info */ #define CL_CONTEXT_D3D11_DEVICE_KHR 0x401D #define CL_CONTEXT_D3D11_PREFER_SHARED_RESOURCES_KHR 0x402D /* cl_mem_info */ #define CL_MEM_D3D11_RESOURCE_KHR 0x401E /* cl_image_info */ #define CL_IMAGE_D3D11_SUBRESOURCE_KHR 0x401F /* cl_command_type */ #define CL_COMMAND_ACQUIRE_D3D11_OBJECTS_KHR 0x4020 #define CL_COMMAND_RELEASE_D3D11_OBJECTS_KHR 0x4021 /******************************************************************************/ typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromD3D11KHR_fn)( cl_platform_id platform, cl_d3d11_device_source_khr d3d_device_source, void * d3d_object, cl_d3d11_device_set_khr d3d_device_set, cl_uint num_entries, cl_device_id * devices, cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11BufferKHR_fn)( cl_context context, cl_mem_flags flags, ID3D11Buffer * resource, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture2DKHR_fn)( cl_context context, cl_mem_flags flags, ID3D11Texture2D * resource, UINT subresource, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromD3D11Texture3DKHR_fn)( cl_context context, cl_mem_flags flags, ID3D11Texture3D * resource, UINT subresource, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireD3D11ObjectsKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseD3D11ObjectsKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) CL_API_SUFFIX__VERSION_1_2; #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_D3D11_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_dx9_media_sharing.h ================================================ /********************************************************************************** * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. **********************************************************************************/ /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ #ifndef __OPENCL_CL_DX9_MEDIA_SHARING_H #define __OPENCL_CL_DX9_MEDIA_SHARING_H #include #include #ifdef __cplusplus extern "C" { #endif /******************************************************************************/ /* cl_khr_dx9_media_sharing */ #define cl_khr_dx9_media_sharing 1 typedef cl_uint cl_dx9_media_adapter_type_khr; typedef cl_uint cl_dx9_media_adapter_set_khr; #if defined(_WIN32) #include typedef struct _cl_dx9_surface_info_khr { IDirect3DSurface9 *resource; HANDLE shared_handle; } cl_dx9_surface_info_khr; #endif /******************************************************************************/ /* Error Codes */ #define CL_INVALID_DX9_MEDIA_ADAPTER_KHR -1010 #define CL_INVALID_DX9_MEDIA_SURFACE_KHR -1011 #define CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR -1012 #define CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR -1013 /* cl_media_adapter_type_khr */ #define CL_ADAPTER_D3D9_KHR 0x2020 #define CL_ADAPTER_D3D9EX_KHR 0x2021 #define CL_ADAPTER_DXVA_KHR 0x2022 /* cl_media_adapter_set_khr */ #define CL_PREFERRED_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2023 #define CL_ALL_DEVICES_FOR_DX9_MEDIA_ADAPTER_KHR 0x2024 /* cl_context_info */ #define CL_CONTEXT_ADAPTER_D3D9_KHR 0x2025 #define CL_CONTEXT_ADAPTER_D3D9EX_KHR 0x2026 #define CL_CONTEXT_ADAPTER_DXVA_KHR 0x2027 /* cl_mem_info */ #define CL_MEM_DX9_MEDIA_ADAPTER_TYPE_KHR 0x2028 #define CL_MEM_DX9_MEDIA_SURFACE_INFO_KHR 0x2029 /* cl_image_info */ #define CL_IMAGE_DX9_MEDIA_PLANE_KHR 0x202A /* cl_command_type */ #define CL_COMMAND_ACQUIRE_DX9_MEDIA_SURFACES_KHR 0x202B #define CL_COMMAND_RELEASE_DX9_MEDIA_SURFACES_KHR 0x202C /******************************************************************************/ typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetDeviceIDsFromDX9MediaAdapterKHR_fn)( cl_platform_id platform, cl_uint num_media_adapters, cl_dx9_media_adapter_type_khr * media_adapter_type, void * media_adapters, cl_dx9_media_adapter_set_khr media_adapter_set, cl_uint num_entries, cl_device_id * devices, cl_uint * num_devices) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromDX9MediaSurfaceKHR_fn)( cl_context context, cl_mem_flags flags, cl_dx9_media_adapter_type_khr adapter_type, void * surface_info, cl_uint plane, cl_int * errcode_ret) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireDX9MediaSurfacesKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) CL_API_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseDX9MediaSurfacesKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) CL_API_SUFFIX__VERSION_1_2; #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_DX9_MEDIA_SHARING_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_egl.h ================================================ /******************************************************************************* * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ******************************************************************************/ #ifndef __OPENCL_CL_EGL_H #define __OPENCL_CL_EGL_H #ifdef __APPLE__ #else #include #endif #ifdef __cplusplus extern "C" { #endif /* Command type for events created with clEnqueueAcquireEGLObjectsKHR */ #define CL_COMMAND_EGL_FENCE_SYNC_OBJECT_KHR 0x202F #define CL_COMMAND_ACQUIRE_EGL_OBJECTS_KHR 0x202D #define CL_COMMAND_RELEASE_EGL_OBJECTS_KHR 0x202E /* Error type for clCreateFromEGLImageKHR */ #define CL_INVALID_EGL_OBJECT_KHR -1093 #define CL_EGL_RESOURCE_NOT_ACQUIRED_KHR -1092 /* CLeglImageKHR is an opaque handle to an EGLImage */ typedef void* CLeglImageKHR; /* CLeglDisplayKHR is an opaque handle to an EGLDisplay */ typedef void* CLeglDisplayKHR; /* CLeglSyncKHR is an opaque handle to an EGLSync object */ typedef void* CLeglSyncKHR; /* properties passed to clCreateFromEGLImageKHR */ typedef intptr_t cl_egl_image_properties_khr; #define cl_khr_egl_image 1 extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromEGLImageKHR(cl_context /* context */, CLeglDisplayKHR /* egldisplay */, CLeglImageKHR /* eglimage */, cl_mem_flags /* flags */, const cl_egl_image_properties_khr * /* properties */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_mem (CL_API_CALL *clCreateFromEGLImageKHR_fn)( cl_context context, CLeglDisplayKHR egldisplay, CLeglImageKHR eglimage, cl_mem_flags flags, const cl_egl_image_properties_khr * properties, cl_int * errcode_ret); extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireEGLObjectsKHR(cl_command_queue /* command_queue */, cl_uint /* num_objects */, const cl_mem * /* mem_objects */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event); extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseEGLObjectsKHR(cl_command_queue /* command_queue */, cl_uint /* num_objects */, const cl_mem * /* mem_objects */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR_fn)( cl_command_queue command_queue, cl_uint num_objects, const cl_mem * mem_objects, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event); #define cl_khr_egl_event 1 extern CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromEGLSyncKHR(cl_context /* context */, CLeglSyncKHR /* sync */, CLeglDisplayKHR /* display */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_event (CL_API_CALL *clCreateEventFromEGLSyncKHR_fn)( cl_context context, CLeglSyncKHR sync, CLeglDisplayKHR display, cl_int * errcode_ret); #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_EGL_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_ext.h ================================================ /******************************************************************************* * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ******************************************************************************/ /* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */ /* cl_ext.h contains OpenCL extensions which don't have external */ /* (OpenGL, D3D) dependencies. */ #ifndef __CL_EXT_H #define __CL_EXT_H #ifdef __cplusplus extern "C" { #endif #ifdef __APPLE__ #include #include #else #include #endif /* cl_khr_fp16 extension - no extension #define since it has no functions */ #define CL_DEVICE_HALF_FP_CONFIG 0x1033 /* Memory object destruction * * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR * * Registers a user callback function that will be called when the memory object is deleted and its resources * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback * stack associated with memobj. The registered user callback functions are called in the reverse order in * which they were registered. The user callback functions are called and then the memory object is deleted * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be * notified when the memory referenced by host_ptr, specified when the memory object is created and used as * the storage bits for the memory object, can be reused or freed. * * The application may not call CL api's with the cl_mem object passed to the pfn_notify. * * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) * before using. */ #define cl_APPLE_SetMemObjectDestructor 1 cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */, void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/), void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; /* Context Logging Functions * * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext(). * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS) * before using. * * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger */ #define cl_APPLE_ContextLoggingFunctions 1 extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */, const void * /* private_info */, size_t /* cb */, void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; /* clLogMessagesToStdout sends all log messages to the file descriptor stdout */ extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */, const void * /* private_info */, size_t /* cb */, void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; /* clLogMessagesToStderr sends all log messages to the file descriptor stderr */ extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */, const void * /* private_info */, size_t /* cb */, void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0; /************************ * cl_khr_icd extension * ************************/ #define cl_khr_icd 1 /* cl_platform_info */ #define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920 /* Additional Error Codes */ #define CL_PLATFORM_NOT_FOUND_KHR -1001 extern CL_API_ENTRY cl_int CL_API_CALL clIcdGetPlatformIDsKHR(cl_uint /* num_entries */, cl_platform_id * /* platforms */, cl_uint * /* num_platforms */); typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)( cl_uint /* num_entries */, cl_platform_id * /* platforms */, cl_uint * /* num_platforms */); /* Extension: cl_khr_image2D_buffer * * This extension allows a 2D image to be created from a cl_mem buffer without a copy. * The type associated with a 2D image created from a buffer in an OpenCL program is image2d_t. * Both the sampler and sampler-less read_image built-in functions are supported for 2D images * and 2D images created from a buffer. Similarly, the write_image built-ins are also supported * for 2D images created from a buffer. * * When the 2D image from buffer is created, the client must specify the width, * height, image format (i.e. channel order and channel data type) and optionally the row pitch * * The pitch specified must be a multiple of CL_DEVICE_IMAGE_PITCH_ALIGNMENT pixels. * The base address of the buffer must be aligned to CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT pixels. */ /************************************* * cl_khr_initalize_memory extension * *************************************/ #define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x2030 /************************************** * cl_khr_terminate_context extension * **************************************/ #define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x2031 #define CL_CONTEXT_TERMINATE_KHR 0x2032 #define cl_khr_terminate_context 1 extern CL_API_ENTRY cl_int CL_API_CALL clTerminateContextKHR(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2; typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2; /* * Extension: cl_khr_spir * * This extension adds support to create an OpenCL program object from a * Standard Portable Intermediate Representation (SPIR) instance */ #define CL_DEVICE_SPIR_VERSIONS 0x40E0 #define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1 /****************************************** * cl_nv_device_attribute_query extension * ******************************************/ /* cl_nv_device_attribute_query extension - no extension #define since it has no functions */ #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 #define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 #define CL_DEVICE_WARP_SIZE_NV 0x4003 #define CL_DEVICE_GPU_OVERLAP_NV 0x4004 #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 #define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 /********************************* * cl_amd_device_attribute_query * *********************************/ #define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036 /********************************* * cl_arm_printf extension *********************************/ #define CL_PRINTF_CALLBACK_ARM 0x40B0 #define CL_PRINTF_BUFFERSIZE_ARM 0x40B1 #ifdef CL_VERSION_1_1 /*********************************** * cl_ext_device_fission extension * ***********************************/ #define cl_ext_device_fission 1 extern CL_API_ENTRY cl_int CL_API_CALL clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; typedef CL_API_ENTRY cl_int (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; extern CL_API_ENTRY cl_int CL_API_CALL clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; typedef CL_API_ENTRY cl_int (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1; typedef cl_ulong cl_device_partition_property_ext; extern CL_API_ENTRY cl_int CL_API_CALL clCreateSubDevicesEXT( cl_device_id /*in_device*/, const cl_device_partition_property_ext * /* properties */, cl_uint /*num_entries*/, cl_device_id * /*out_devices*/, cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; typedef CL_API_ENTRY cl_int ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/, const cl_device_partition_property_ext * /* properties */, cl_uint /*num_entries*/, cl_device_id * /*out_devices*/, cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; /* cl_device_partition_property_ext */ #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050 #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051 #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052 #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053 /* clDeviceGetInfo selectors */ #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054 #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055 #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056 #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057 #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058 /* error codes */ #define CL_DEVICE_PARTITION_FAILED_EXT -1057 #define CL_INVALID_PARTITION_COUNT_EXT -1058 #define CL_INVALID_PARTITION_NAME_EXT -1059 /* CL_AFFINITY_DOMAINs */ #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1 #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2 #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3 #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4 #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10 #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100 /* cl_device_partition_property_ext list terminators */ #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0) #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0) #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1) /********************************* * cl_qcom_ext_host_ptr extension *********************************/ #define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29) #define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0 #define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1 #define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2 #define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3 #define CL_MEM_HOST_UNCACHED_QCOM 0x40A4 #define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5 #define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6 #define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7 typedef cl_uint cl_image_pitch_info_qcom; extern CL_API_ENTRY cl_int CL_API_CALL clGetDeviceImageInfoQCOM(cl_device_id device, size_t image_width, size_t image_height, const cl_image_format *image_format, cl_image_pitch_info_qcom param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); typedef struct _cl_mem_ext_host_ptr { /* Type of external memory allocation. */ /* Legal values will be defined in layered extensions. */ cl_uint allocation_type; /* Host cache policy for this external memory allocation. */ cl_uint host_cache_policy; } cl_mem_ext_host_ptr; /********************************* * cl_qcom_ion_host_ptr extension *********************************/ #define CL_MEM_ION_HOST_PTR_QCOM 0x40A8 typedef struct _cl_mem_ion_host_ptr { /* Type of external memory allocation. */ /* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */ cl_mem_ext_host_ptr ext_host_ptr; /* ION file descriptor */ int ion_filedesc; /* Host pointer to the ION allocated memory */ void* ion_hostptr; } cl_mem_ion_host_ptr; #endif /* CL_VERSION_1_1 */ #ifdef CL_VERSION_2_0 /********************************* * cl_khr_sub_groups extension *********************************/ #define cl_khr_sub_groups 1 typedef cl_uint cl_kernel_sub_group_info_khr; /* cl_khr_sub_group_info */ #define CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE_KHR 0x2033 #define CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE_KHR 0x2034 extern CL_API_ENTRY cl_int CL_API_CALL clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */, cl_device_id /*in_device*/, cl_kernel_sub_group_info_khr /* param_name */, size_t /*input_value_size*/, const void * /*input_value*/, size_t /*param_value_size*/, void* /*param_value*/, size_t* /*param_value_size_ret*/ ) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED; typedef CL_API_ENTRY cl_int ( CL_API_CALL * clGetKernelSubGroupInfoKHR_fn)(cl_kernel /* in_kernel */, cl_device_id /*in_device*/, cl_kernel_sub_group_info_khr /* param_name */, size_t /*input_value_size*/, const void * /*input_value*/, size_t /*param_value_size*/, void* /*param_value*/, size_t* /*param_value_size_ret*/ ) CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED; #endif /* CL_VERSION_2_0 */ #ifdef CL_VERSION_2_1 /********************************* * cl_khr_priority_hints extension *********************************/ #define cl_khr_priority_hints 1 typedef cl_uint cl_queue_priority_khr; /* cl_command_queue_properties */ #define CL_QUEUE_PRIORITY_KHR 0x1096 /* cl_queue_priority_khr */ #define CL_QUEUE_PRIORITY_HIGH_KHR (1<<0) #define CL_QUEUE_PRIORITY_MED_KHR (1<<1) #define CL_QUEUE_PRIORITY_LOW_KHR (1<<2) #endif /* CL_VERSION_2_1 */ #ifdef CL_VERSION_2_1 /********************************* * cl_khr_throttle_hints extension *********************************/ #define cl_khr_throttle_hints 1 typedef cl_uint cl_queue_throttle_khr; /* cl_command_queue_properties */ #define CL_QUEUE_THROTTLE_KHR 0x1097 /* cl_queue_throttle_khr */ #define CL_QUEUE_THROTTLE_HIGH_KHR (1<<0) #define CL_QUEUE_THROTTLE_MED_KHR (1<<1) #define CL_QUEUE_THROTTLE_LOW_KHR (1<<2) #endif /* CL_VERSION_2_1 */ #ifdef __cplusplus } #endif #endif /* __CL_EXT_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_ext_qcom.h ================================================ /* Copyright (c) 2009-2017 Qualcomm Technologies, Inc. All Rights Reserved. * Qualcomm Technologies Proprietary and Confidential. */ #ifndef __OPENCL_CL_EXT_QCOM_H #define __OPENCL_CL_EXT_QCOM_H // Needed by cl_khr_egl_event extension #include #include #include #ifdef __cplusplus extern "C" { #endif /************************************ * cl_qcom_create_buffer_from_image * ************************************/ #define CL_BUFFER_FROM_IMAGE_ROW_PITCH_QCOM 0x40C0 #define CL_BUFFER_FROM_IMAGE_SLICE_PITCH_QCOM 0x40C1 extern CL_API_ENTRY cl_mem CL_API_CALL clCreateBufferFromImageQCOM(cl_mem image, cl_mem_flags flags, cl_int *errcode_ret); /************************************ * cl_qcom_limited_printf extension * ************************************/ /* Builtin printf function buffer size in bytes. */ #define CL_DEVICE_PRINTF_BUFFER_SIZE_QCOM 0x1049 /************************************* * cl_qcom_extended_images extension * *************************************/ #define CL_CONTEXT_ENABLE_EXTENDED_IMAGES_QCOM 0x40AA #define CL_DEVICE_EXTENDED_IMAGE2D_MAX_WIDTH_QCOM 0x40AB #define CL_DEVICE_EXTENDED_IMAGE2D_MAX_HEIGHT_QCOM 0x40AC #define CL_DEVICE_EXTENDED_IMAGE3D_MAX_WIDTH_QCOM 0x40AD #define CL_DEVICE_EXTENDED_IMAGE3D_MAX_HEIGHT_QCOM 0x40AE #define CL_DEVICE_EXTENDED_IMAGE3D_MAX_DEPTH_QCOM 0x40AF /************************************* * cl_qcom_perf_hint extension * *************************************/ typedef cl_uint cl_perf_hint; #define CL_CONTEXT_PERF_HINT_QCOM 0x40C2 /*cl_perf_hint*/ #define CL_PERF_HINT_HIGH_QCOM 0x40C3 #define CL_PERF_HINT_NORMAL_QCOM 0x40C4 #define CL_PERF_HINT_LOW_QCOM 0x40C5 extern CL_API_ENTRY cl_int CL_API_CALL clSetPerfHintQCOM(cl_context context, cl_perf_hint perf_hint); // This extension is published at Khronos, so its definitions are made in cl_ext.h. // This duplication is for backward compatibility. #ifndef CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM /********************************* * cl_qcom_android_native_buffer_host_ptr extension *********************************/ #define CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM 0x40C6 typedef struct _cl_mem_android_native_buffer_host_ptr { // Type of external memory allocation. // Must be CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM for Android native buffers. cl_mem_ext_host_ptr ext_host_ptr; // Virtual pointer to the android native buffer void* anb_ptr; } cl_mem_android_native_buffer_host_ptr; #endif //#ifndef CL_MEM_ANDROID_NATIVE_BUFFER_HOST_PTR_QCOM /*********************************** * cl_img_egl_image extension * ************************************/ typedef void* CLeglImageIMG; typedef void* CLeglDisplayIMG; extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromEGLImageIMG(cl_context context, cl_mem_flags flags, CLeglImageIMG image, CLeglDisplayIMG display, cl_int *errcode_ret); /********************************* * cl_qcom_other_image extension *********************************/ // Extended flag for creating/querying QCOM non-standard images #define CL_MEM_OTHER_IMAGE_QCOM (1<<25) // cl_channel_type #define CL_QCOM_UNORM_MIPI10 0x4159 #define CL_QCOM_UNORM_MIPI12 0x415A #define CL_QCOM_UNSIGNED_MIPI10 0x415B #define CL_QCOM_UNSIGNED_MIPI12 0x415C #define CL_QCOM_UNORM_INT10 0x415D #define CL_QCOM_UNORM_INT12 0x415E #define CL_QCOM_UNSIGNED_INT16 0x415F // cl_channel_order // Dedicate 0x4130-0x415F range for QCOM extended image formats // 0x4130 - 0x4132 range is assigned to pixel-oriented compressed format #define CL_QCOM_BAYER 0x414E #define CL_QCOM_NV12 0x4133 #define CL_QCOM_NV12_Y 0x4134 #define CL_QCOM_NV12_UV 0x4135 #define CL_QCOM_TILED_NV12 0x4136 #define CL_QCOM_TILED_NV12_Y 0x4137 #define CL_QCOM_TILED_NV12_UV 0x4138 #define CL_QCOM_P010 0x413C #define CL_QCOM_P010_Y 0x413D #define CL_QCOM_P010_UV 0x413E #define CL_QCOM_TILED_P010 0x413F #define CL_QCOM_TILED_P010_Y 0x4140 #define CL_QCOM_TILED_P010_UV 0x4141 #define CL_QCOM_TP10 0x4145 #define CL_QCOM_TP10_Y 0x4146 #define CL_QCOM_TP10_UV 0x4147 #define CL_QCOM_TILED_TP10 0x4148 #define CL_QCOM_TILED_TP10_Y 0x4149 #define CL_QCOM_TILED_TP10_UV 0x414A /********************************* * cl_qcom_compressed_image extension *********************************/ // Extended flag for creating/querying QCOM non-planar compressed images #define CL_MEM_COMPRESSED_IMAGE_QCOM (1<<27) // Extended image format // cl_channel_order #define CL_QCOM_COMPRESSED_RGBA 0x4130 #define CL_QCOM_COMPRESSED_RGBx 0x4131 #define CL_QCOM_COMPRESSED_NV12_Y 0x413A #define CL_QCOM_COMPRESSED_NV12_UV 0x413B #define CL_QCOM_COMPRESSED_P010 0x4142 #define CL_QCOM_COMPRESSED_P010_Y 0x4143 #define CL_QCOM_COMPRESSED_P010_UV 0x4144 #define CL_QCOM_COMPRESSED_TP10 0x414B #define CL_QCOM_COMPRESSED_TP10_Y 0x414C #define CL_QCOM_COMPRESSED_TP10_UV 0x414D #define CL_QCOM_COMPRESSED_NV12_4R 0x414F #define CL_QCOM_COMPRESSED_NV12_4R_Y 0x4150 #define CL_QCOM_COMPRESSED_NV12_4R_UV 0x4151 /********************************* * cl_qcom_compressed_yuv_image_read extension *********************************/ // Extended flag for creating/querying QCOM compressed images #define CL_MEM_COMPRESSED_YUV_IMAGE_QCOM (1<<28) // Extended image format #define CL_QCOM_COMPRESSED_NV12 0x10C4 // Extended flag for setting ION buffer allocation type #define CL_MEM_ION_HOST_PTR_COMPRESSED_YUV_QCOM 0x40CD #define CL_MEM_ION_HOST_PTR_PROTECTED_COMPRESSED_YUV_QCOM 0x40CE /********************************* * cl_qcom_accelerated_image_ops *********************************/ #define CL_MEM_OBJECT_WEIGHT_IMAGE_QCOM 0x4110 #define CL_DEVICE_HOF_MAX_NUM_PHASES_QCOM 0x4111 #define CL_DEVICE_HOF_MAX_FILTER_SIZE_X_QCOM 0x4112 #define CL_DEVICE_HOF_MAX_FILTER_SIZE_Y_QCOM 0x4113 #define CL_DEVICE_BLOCK_MATCHING_MAX_REGION_SIZE_X_QCOM 0x4114 #define CL_DEVICE_BLOCK_MATCHING_MAX_REGION_SIZE_Y_QCOM 0x4115 //Extended flag for specifying weight image type #define CL_WEIGHT_IMAGE_SEPARABLE_QCOM (1<<0) // Box Filter typedef struct _cl_box_filter_size_qcom { // Width of box filter on X direction. float box_filter_width; // Height of box filter on Y direction. float box_filter_height; } cl_box_filter_size_qcom; // HOF Weight Image Desc typedef struct _cl_weight_desc_qcom { /** Coordinate of the "center" point of the weight image, based on the weight image's top-left corner as the origin. */ size_t center_coord_x; size_t center_coord_y; cl_bitfield flags; } cl_weight_desc_qcom; typedef struct _cl_weight_image_desc_qcom { cl_image_desc image_desc; cl_weight_desc_qcom weight_desc; } cl_weight_image_desc_qcom; /************************************* * cl_qcom_protected_context extension * *************************************/ #define CL_CONTEXT_PROTECTED_QCOM 0x40C7 #define CL_MEM_ION_HOST_PTR_PROTECTED_QCOM 0x40C8 /************************************* * cl_qcom_priority_hint extension * *************************************/ #define CL_PRIORITY_HINT_NONE_QCOM 0 typedef cl_uint cl_priority_hint; #define CL_CONTEXT_PRIORITY_HINT_QCOM 0x40C9 /*cl_priority_hint*/ #define CL_PRIORITY_HINT_HIGH_QCOM 0x40CA #define CL_PRIORITY_HINT_NORMAL_QCOM 0x40CB #define CL_PRIORITY_HINT_LOW_QCOM 0x40CC #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_EXT_QCOM_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_gl.h ================================================ /********************************************************************************** * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. **********************************************************************************/ #ifndef __OPENCL_CL_GL_H #define __OPENCL_CL_GL_H #ifdef __APPLE__ #include #else #include #endif #ifdef __cplusplus extern "C" { #endif typedef cl_uint cl_gl_object_type; typedef cl_uint cl_gl_texture_info; typedef cl_uint cl_gl_platform_info; typedef struct __GLsync *cl_GLsync; /* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */ #define CL_GL_OBJECT_BUFFER 0x2000 #define CL_GL_OBJECT_TEXTURE2D 0x2001 #define CL_GL_OBJECT_TEXTURE3D 0x2002 #define CL_GL_OBJECT_RENDERBUFFER 0x2003 #define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E #define CL_GL_OBJECT_TEXTURE1D 0x200F #define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010 #define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011 /* cl_gl_texture_info */ #define CL_GL_TEXTURE_TARGET 0x2004 #define CL_GL_MIPMAP_LEVEL 0x2005 #define CL_GL_NUM_SAMPLES 0x2012 extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLBuffer(cl_context /* context */, cl_mem_flags /* flags */, cl_GLuint /* bufobj */, int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLTexture(cl_context /* context */, cl_mem_flags /* flags */, cl_GLenum /* target */, cl_GLint /* miplevel */, cl_GLuint /* texture */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2; extern CL_API_ENTRY cl_mem CL_API_CALL clCreateFromGLRenderbuffer(cl_context /* context */, cl_mem_flags /* flags */, cl_GLuint /* renderbuffer */, cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetGLObjectInfo(cl_mem /* memobj */, cl_gl_object_type * /* gl_object_type */, cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clGetGLTextureInfo(cl_mem /* memobj */, cl_gl_texture_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */, cl_uint /* num_objects */, const cl_mem * /* mem_objects */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; extern CL_API_ENTRY cl_int CL_API_CALL clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */, cl_uint /* num_objects */, const cl_mem * /* mem_objects */, cl_uint /* num_events_in_wait_list */, const cl_event * /* event_wait_list */, cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0; /* Deprecated OpenCL 1.1 APIs */ extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateFromGLTexture2D(cl_context /* context */, cl_mem_flags /* flags */, cl_GLenum /* target */, cl_GLint /* miplevel */, cl_GLuint /* texture */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL clCreateFromGLTexture3D(cl_context /* context */, cl_mem_flags /* flags */, cl_GLenum /* target */, cl_GLint /* miplevel */, cl_GLuint /* texture */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; /* cl_khr_gl_sharing extension */ #define cl_khr_gl_sharing 1 typedef cl_uint cl_gl_context_info; /* Additional Error Codes */ #define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000 /* cl_gl_context_info */ #define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006 #define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007 /* Additional cl_context_properties */ #define CL_GL_CONTEXT_KHR 0x2008 #define CL_EGL_DISPLAY_KHR 0x2009 #define CL_GLX_DISPLAY_KHR 0x200A #define CL_WGL_HDC_KHR 0x200B #define CL_CGL_SHAREGROUP_KHR 0x200C extern CL_API_ENTRY cl_int CL_API_CALL clGetGLContextInfoKHR(const cl_context_properties * /* properties */, cl_gl_context_info /* param_name */, size_t /* param_value_size */, void * /* param_value */, size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)( const cl_context_properties * properties, cl_gl_context_info param_name, size_t param_value_size, void * param_value, size_t * param_value_size_ret); #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_GL_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_gl_ext.h ================================================ /********************************************************************************** * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. **********************************************************************************/ /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ /* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */ /* OpenGL dependencies. */ #ifndef __OPENCL_CL_GL_EXT_H #define __OPENCL_CL_GL_EXT_H #ifdef __cplusplus extern "C" { #endif #ifdef __APPLE__ #include #else #include #endif /* * For each extension, follow this template * cl_VEN_extname extension */ /* #define cl_VEN_extname 1 * ... define new types, if any * ... define new tokens, if any * ... define new APIs, if any * * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header * This allows us to avoid having to decide whether to include GL headers or GLES here. */ /* * cl_khr_gl_event extension * See section 9.9 in the OpenCL 1.1 spec for more information */ #define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D extern CL_API_ENTRY cl_event CL_API_CALL clCreateEventFromGLsyncKHR(cl_context /* context */, cl_GLsync /* cl_GLsync */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1; #ifdef __cplusplus } #endif #endif /* __OPENCL_CL_GL_EXT_H */ ================================================ FILE: phonelibs/opencl/include/CL/cl_platform.h ================================================ /********************************************************************************** * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. **********************************************************************************/ /* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */ #ifndef __CL_PLATFORM_H #define __CL_PLATFORM_H #ifdef __APPLE__ /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */ #include #endif #ifdef __cplusplus extern "C" { #endif #if defined(_WIN32) #define CL_API_ENTRY #define CL_API_CALL __stdcall #define CL_CALLBACK __stdcall #else #define CL_API_ENTRY #define CL_API_CALL #define CL_CALLBACK #endif /* * Deprecation flags refer to the last version of the header in which the * feature was not deprecated. * * E.g. VERSION_1_1_DEPRECATED means the feature is present in 1.1 without * deprecation but is deprecated in versions later than 1.1. */ #ifdef __APPLE__ #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import)) #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER #define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 #ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 #else #warning This path should never happen outside of internal operating system development. AvailabilityMacros do not function correctly here! #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER #endif #else #define CL_EXTENSION_WEAK_LINK #define CL_API_SUFFIX__VERSION_1_0 #define CL_EXT_SUFFIX__VERSION_1_0 #define CL_API_SUFFIX__VERSION_1_1 #define CL_EXT_SUFFIX__VERSION_1_1 #define CL_API_SUFFIX__VERSION_1_2 #define CL_EXT_SUFFIX__VERSION_1_2 #define CL_API_SUFFIX__VERSION_2_0 #define CL_EXT_SUFFIX__VERSION_2_0 #define CL_API_SUFFIX__VERSION_2_1 #define CL_EXT_SUFFIX__VERSION_2_1 #ifdef __GNUC__ #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated)) #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated)) #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED __attribute__((deprecated)) #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED #endif #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED __attribute__((deprecated)) #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED #endif #elif _WIN32 #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated) #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated) #endif #ifdef CL_USE_DEPRECATED_OPENCL_1_2_APIS #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED __declspec(deprecated) #endif #ifdef CL_USE_DEPRECATED_OPENCL_2_0_APIS #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED #else #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED __declspec(deprecated) #endif #else #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED #define CL_EXT_SUFFIX__VERSION_1_2_DEPRECATED #define CL_EXT_PREFIX__VERSION_1_2_DEPRECATED #define CL_EXT_SUFFIX__VERSION_2_0_DEPRECATED #define CL_EXT_PREFIX__VERSION_2_0_DEPRECATED #endif #endif #if (defined (_WIN32) && defined(_MSC_VER)) /* scalar types */ typedef signed __int8 cl_char; typedef unsigned __int8 cl_uchar; typedef signed __int16 cl_short; typedef unsigned __int16 cl_ushort; typedef signed __int32 cl_int; typedef unsigned __int32 cl_uint; typedef signed __int64 cl_long; typedef unsigned __int64 cl_ulong; typedef unsigned __int16 cl_half; typedef float cl_float; typedef double cl_double; /* Macro names and corresponding values defined by OpenCL */ #define CL_CHAR_BIT 8 #define CL_SCHAR_MAX 127 #define CL_SCHAR_MIN (-127-1) #define CL_CHAR_MAX CL_SCHAR_MAX #define CL_CHAR_MIN CL_SCHAR_MIN #define CL_UCHAR_MAX 255 #define CL_SHRT_MAX 32767 #define CL_SHRT_MIN (-32767-1) #define CL_USHRT_MAX 65535 #define CL_INT_MAX 2147483647 #define CL_INT_MIN (-2147483647-1) #define CL_UINT_MAX 0xffffffffU #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) #define CL_FLT_DIG 6 #define CL_FLT_MANT_DIG 24 #define CL_FLT_MAX_10_EXP +38 #define CL_FLT_MAX_EXP +128 #define CL_FLT_MIN_10_EXP -37 #define CL_FLT_MIN_EXP -125 #define CL_FLT_RADIX 2 #define CL_FLT_MAX 340282346638528859811704183484516925440.0f #define CL_FLT_MIN 1.175494350822287507969e-38f #define CL_FLT_EPSILON 0x1.0p-23f #define CL_DBL_DIG 15 #define CL_DBL_MANT_DIG 53 #define CL_DBL_MAX_10_EXP +308 #define CL_DBL_MAX_EXP +1024 #define CL_DBL_MIN_10_EXP -307 #define CL_DBL_MIN_EXP -1021 #define CL_DBL_RADIX 2 #define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0 #define CL_DBL_MIN 2.225073858507201383090e-308 #define CL_DBL_EPSILON 2.220446049250313080847e-16 #define CL_M_E 2.718281828459045090796 #define CL_M_LOG2E 1.442695040888963387005 #define CL_M_LOG10E 0.434294481903251816668 #define CL_M_LN2 0.693147180559945286227 #define CL_M_LN10 2.302585092994045901094 #define CL_M_PI 3.141592653589793115998 #define CL_M_PI_2 1.570796326794896557999 #define CL_M_PI_4 0.785398163397448278999 #define CL_M_1_PI 0.318309886183790691216 #define CL_M_2_PI 0.636619772367581382433 #define CL_M_2_SQRTPI 1.128379167095512558561 #define CL_M_SQRT2 1.414213562373095145475 #define CL_M_SQRT1_2 0.707106781186547572737 #define CL_M_E_F 2.71828174591064f #define CL_M_LOG2E_F 1.44269502162933f #define CL_M_LOG10E_F 0.43429449200630f #define CL_M_LN2_F 0.69314718246460f #define CL_M_LN10_F 2.30258512496948f #define CL_M_PI_F 3.14159274101257f #define CL_M_PI_2_F 1.57079637050629f #define CL_M_PI_4_F 0.78539818525314f #define CL_M_1_PI_F 0.31830987334251f #define CL_M_2_PI_F 0.63661974668503f #define CL_M_2_SQRTPI_F 1.12837922573090f #define CL_M_SQRT2_F 1.41421353816986f #define CL_M_SQRT1_2_F 0.70710676908493f #define CL_NAN (CL_INFINITY - CL_INFINITY) #define CL_HUGE_VALF ((cl_float) 1e50) #define CL_HUGE_VAL ((cl_double) 1e500) #define CL_MAXFLOAT CL_FLT_MAX #define CL_INFINITY CL_HUGE_VALF #else #include /* scalar types */ typedef int8_t cl_char; typedef uint8_t cl_uchar; typedef int16_t cl_short __attribute__((aligned(2))); typedef uint16_t cl_ushort __attribute__((aligned(2))); typedef int32_t cl_int __attribute__((aligned(4))); typedef uint32_t cl_uint __attribute__((aligned(4))); typedef int64_t cl_long __attribute__((aligned(8))); typedef uint64_t cl_ulong __attribute__((aligned(8))); typedef uint16_t cl_half __attribute__((aligned(2))); typedef float cl_float __attribute__((aligned(4))); typedef double cl_double __attribute__((aligned(8))); /* Macro names and corresponding values defined by OpenCL */ #define CL_CHAR_BIT 8 #define CL_SCHAR_MAX 127 #define CL_SCHAR_MIN (-127-1) #define CL_CHAR_MAX CL_SCHAR_MAX #define CL_CHAR_MIN CL_SCHAR_MIN #define CL_UCHAR_MAX 255 #define CL_SHRT_MAX 32767 #define CL_SHRT_MIN (-32767-1) #define CL_USHRT_MAX 65535 #define CL_INT_MAX 2147483647 #define CL_INT_MIN (-2147483647-1) #define CL_UINT_MAX 0xffffffffU #define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL) #define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL) #define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL) #define CL_FLT_DIG 6 #define CL_FLT_MANT_DIG 24 #define CL_FLT_MAX_10_EXP +38 #define CL_FLT_MAX_EXP +128 #define CL_FLT_MIN_10_EXP -37 #define CL_FLT_MIN_EXP -125 #define CL_FLT_RADIX 2 #define CL_FLT_MAX 0x1.fffffep127f #define CL_FLT_MIN 0x1.0p-126f #define CL_FLT_EPSILON 0x1.0p-23f #define CL_DBL_DIG 15 #define CL_DBL_MANT_DIG 53 #define CL_DBL_MAX_10_EXP +308 #define CL_DBL_MAX_EXP +1024 #define CL_DBL_MIN_10_EXP -307 #define CL_DBL_MIN_EXP -1021 #define CL_DBL_RADIX 2 #define CL_DBL_MAX 0x1.fffffffffffffp1023 #define CL_DBL_MIN 0x1.0p-1022 #define CL_DBL_EPSILON 0x1.0p-52 #define CL_M_E 2.718281828459045090796 #define CL_M_LOG2E 1.442695040888963387005 #define CL_M_LOG10E 0.434294481903251816668 #define CL_M_LN2 0.693147180559945286227 #define CL_M_LN10 2.302585092994045901094 #define CL_M_PI 3.141592653589793115998 #define CL_M_PI_2 1.570796326794896557999 #define CL_M_PI_4 0.785398163397448278999 #define CL_M_1_PI 0.318309886183790691216 #define CL_M_2_PI 0.636619772367581382433 #define CL_M_2_SQRTPI 1.128379167095512558561 #define CL_M_SQRT2 1.414213562373095145475 #define CL_M_SQRT1_2 0.707106781186547572737 #define CL_M_E_F 2.71828174591064f #define CL_M_LOG2E_F 1.44269502162933f #define CL_M_LOG10E_F 0.43429449200630f #define CL_M_LN2_F 0.69314718246460f #define CL_M_LN10_F 2.30258512496948f #define CL_M_PI_F 3.14159274101257f #define CL_M_PI_2_F 1.57079637050629f #define CL_M_PI_4_F 0.78539818525314f #define CL_M_1_PI_F 0.31830987334251f #define CL_M_2_PI_F 0.63661974668503f #define CL_M_2_SQRTPI_F 1.12837922573090f #define CL_M_SQRT2_F 1.41421353816986f #define CL_M_SQRT1_2_F 0.70710676908493f #if defined( __GNUC__ ) #define CL_HUGE_VALF __builtin_huge_valf() #define CL_HUGE_VAL __builtin_huge_val() #define CL_NAN __builtin_nanf( "" ) #else #define CL_HUGE_VALF ((cl_float) 1e50) #define CL_HUGE_VAL ((cl_double) 1e500) float nanf( const char * ); #define CL_NAN nanf( "" ) #endif #define CL_MAXFLOAT CL_FLT_MAX #define CL_INFINITY CL_HUGE_VALF #endif #include /* Mirror types to GL types. Mirror types allow us to avoid deciding which 87s to load based on whether we are using GL or GLES here. */ typedef unsigned int cl_GLuint; typedef int cl_GLint; typedef unsigned int cl_GLenum; /* * Vector types * * Note: OpenCL requires that all types be naturally aligned. * This means that vector types must be naturally aligned. * For example, a vector of four floats must be aligned to * a 16 byte boundary (calculated as 4 * the natural 4-byte * alignment of the float). The alignment qualifiers here * will only function properly if your compiler supports them * and if you don't actively work to defeat them. For example, * in order for a cl_float4 to be 16 byte aligned in a struct, * the start of the struct must itself be 16-byte aligned. * * Maintaining proper alignment is the user's responsibility. */ /* Define basic vector types */ #if defined( __VEC__ ) #include /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */ typedef vector unsigned char __cl_uchar16; typedef vector signed char __cl_char16; typedef vector unsigned short __cl_ushort8; typedef vector signed short __cl_short8; typedef vector unsigned int __cl_uint4; typedef vector signed int __cl_int4; typedef vector float __cl_float4; #define __CL_UCHAR16__ 1 #define __CL_CHAR16__ 1 #define __CL_USHORT8__ 1 #define __CL_SHORT8__ 1 #define __CL_UINT4__ 1 #define __CL_INT4__ 1 #define __CL_FLOAT4__ 1 #endif #if defined( __SSE__ ) #if defined( __MINGW64__ ) #include #else #include #endif #if defined( __GNUC__ ) typedef float __cl_float4 __attribute__((vector_size(16))); #else typedef __m128 __cl_float4; #endif #define __CL_FLOAT4__ 1 #endif #if defined( __SSE2__ ) #if defined( __MINGW64__ ) #include #else #include #endif #if defined( __GNUC__ ) typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16))); typedef cl_char __cl_char16 __attribute__((vector_size(16))); typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16))); typedef cl_short __cl_short8 __attribute__((vector_size(16))); typedef cl_uint __cl_uint4 __attribute__((vector_size(16))); typedef cl_int __cl_int4 __attribute__((vector_size(16))); typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16))); typedef cl_long __cl_long2 __attribute__((vector_size(16))); typedef cl_double __cl_double2 __attribute__((vector_size(16))); #else typedef __m128i __cl_uchar16; typedef __m128i __cl_char16; typedef __m128i __cl_ushort8; typedef __m128i __cl_short8; typedef __m128i __cl_uint4; typedef __m128i __cl_int4; typedef __m128i __cl_ulong2; typedef __m128i __cl_long2; typedef __m128d __cl_double2; #endif #define __CL_UCHAR16__ 1 #define __CL_CHAR16__ 1 #define __CL_USHORT8__ 1 #define __CL_SHORT8__ 1 #define __CL_INT4__ 1 #define __CL_UINT4__ 1 #define __CL_ULONG2__ 1 #define __CL_LONG2__ 1 #define __CL_DOUBLE2__ 1 #endif #if defined( __MMX__ ) #include #if defined( __GNUC__ ) typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8))); typedef cl_char __cl_char8 __attribute__((vector_size(8))); typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8))); typedef cl_short __cl_short4 __attribute__((vector_size(8))); typedef cl_uint __cl_uint2 __attribute__((vector_size(8))); typedef cl_int __cl_int2 __attribute__((vector_size(8))); typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8))); typedef cl_long __cl_long1 __attribute__((vector_size(8))); typedef cl_float __cl_float2 __attribute__((vector_size(8))); #else typedef __m64 __cl_uchar8; typedef __m64 __cl_char8; typedef __m64 __cl_ushort4; typedef __m64 __cl_short4; typedef __m64 __cl_uint2; typedef __m64 __cl_int2; typedef __m64 __cl_ulong1; typedef __m64 __cl_long1; typedef __m64 __cl_float2; #endif #define __CL_UCHAR8__ 1 #define __CL_CHAR8__ 1 #define __CL_USHORT4__ 1 #define __CL_SHORT4__ 1 #define __CL_INT2__ 1 #define __CL_UINT2__ 1 #define __CL_ULONG1__ 1 #define __CL_LONG1__ 1 #define __CL_FLOAT2__ 1 #endif #if defined( __AVX__ ) #if defined( __MINGW64__ ) #include #else #include #endif #if defined( __GNUC__ ) typedef cl_float __cl_float8 __attribute__((vector_size(32))); typedef cl_double __cl_double4 __attribute__((vector_size(32))); #else typedef __m256 __cl_float8; typedef __m256d __cl_double4; #endif #define __CL_FLOAT8__ 1 #define __CL_DOUBLE4__ 1 #endif /* Define capabilities for anonymous struct members. */ #if defined( __GNUC__) && ! defined( __STRICT_ANSI__ ) #define __CL_HAS_ANON_STRUCT__ 1 #define __CL_ANON_STRUCT__ __extension__ #elif defined( _WIN32) && (_MSC_VER >= 1500) /* Microsoft Developer Studio 2008 supports anonymous structs, but * complains by default. */ #define __CL_HAS_ANON_STRUCT__ 1 #define __CL_ANON_STRUCT__ /* Disable warning C4201: nonstandard extension used : nameless * struct/union */ #pragma warning( push ) #pragma warning( disable : 4201 ) #else #define __CL_HAS_ANON_STRUCT__ 0 #define __CL_ANON_STRUCT__ #endif /* Define alignment keys */ #if defined( __GNUC__ ) #define CL_ALIGNED(_x) __attribute__ ((aligned(_x))) #elif defined( _WIN32) && (_MSC_VER) /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */ /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */ /* #include */ /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */ #define CL_ALIGNED(_x) #else #warning Need to implement some method to align data here #define CL_ALIGNED(_x) #endif /* Indicate whether .xyzw, .s0123 and .hi.lo are supported */ #if __CL_HAS_ANON_STRUCT__ /* .xyzw and .s0123...{f|F} are supported */ #define CL_HAS_NAMED_VECTOR_FIELDS 1 /* .hi and .lo are supported */ #define CL_HAS_HI_LO_VECTOR_FIELDS 1 #endif /* Define cl_vector types */ /* ---- cl_charn ---- */ typedef union { cl_char CL_ALIGNED(2) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_char x, y; }; __CL_ANON_STRUCT__ struct{ cl_char s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_char lo, hi; }; #endif #if defined( __CL_CHAR2__) __cl_char2 v2; #endif }cl_char2; typedef union { cl_char CL_ALIGNED(4) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; }; #endif #if defined( __CL_CHAR2__) __cl_char2 v2[2]; #endif #if defined( __CL_CHAR4__) __cl_char4 v4; #endif }cl_char4; /* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */ typedef cl_char4 cl_char3; typedef union { cl_char CL_ALIGNED(8) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; }; #endif #if defined( __CL_CHAR2__) __cl_char2 v2[4]; #endif #if defined( __CL_CHAR4__) __cl_char4 v4[2]; #endif #if defined( __CL_CHAR8__ ) __cl_char8 v8; #endif }cl_char8; typedef union { cl_char CL_ALIGNED(16) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; }; #endif #if defined( __CL_CHAR2__) __cl_char2 v2[8]; #endif #if defined( __CL_CHAR4__) __cl_char4 v4[4]; #endif #if defined( __CL_CHAR8__ ) __cl_char8 v8[2]; #endif #if defined( __CL_CHAR16__ ) __cl_char16 v16; #endif }cl_char16; /* ---- cl_ucharn ---- */ typedef union { cl_uchar CL_ALIGNED(2) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uchar x, y; }; __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; }; #endif #if defined( __cl_uchar2__) __cl_uchar2 v2; #endif }cl_uchar2; typedef union { cl_uchar CL_ALIGNED(4) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; }; #endif #if defined( __CL_UCHAR2__) __cl_uchar2 v2[2]; #endif #if defined( __CL_UCHAR4__) __cl_uchar4 v4; #endif }cl_uchar4; /* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */ typedef cl_uchar4 cl_uchar3; typedef union { cl_uchar CL_ALIGNED(8) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; }; #endif #if defined( __CL_UCHAR2__) __cl_uchar2 v2[4]; #endif #if defined( __CL_UCHAR4__) __cl_uchar4 v4[2]; #endif #if defined( __CL_UCHAR8__ ) __cl_uchar8 v8; #endif }cl_uchar8; typedef union { cl_uchar CL_ALIGNED(16) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; }; #endif #if defined( __CL_UCHAR2__) __cl_uchar2 v2[8]; #endif #if defined( __CL_UCHAR4__) __cl_uchar4 v4[4]; #endif #if defined( __CL_UCHAR8__ ) __cl_uchar8 v8[2]; #endif #if defined( __CL_UCHAR16__ ) __cl_uchar16 v16; #endif }cl_uchar16; /* ---- cl_shortn ---- */ typedef union { cl_short CL_ALIGNED(4) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_short x, y; }; __CL_ANON_STRUCT__ struct{ cl_short s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_short lo, hi; }; #endif #if defined( __CL_SHORT2__) __cl_short2 v2; #endif }cl_short2; typedef union { cl_short CL_ALIGNED(8) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; }; #endif #if defined( __CL_SHORT2__) __cl_short2 v2[2]; #endif #if defined( __CL_SHORT4__) __cl_short4 v4; #endif }cl_short4; /* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */ typedef cl_short4 cl_short3; typedef union { cl_short CL_ALIGNED(16) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; }; #endif #if defined( __CL_SHORT2__) __cl_short2 v2[4]; #endif #if defined( __CL_SHORT4__) __cl_short4 v4[2]; #endif #if defined( __CL_SHORT8__ ) __cl_short8 v8; #endif }cl_short8; typedef union { cl_short CL_ALIGNED(32) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; }; #endif #if defined( __CL_SHORT2__) __cl_short2 v2[8]; #endif #if defined( __CL_SHORT4__) __cl_short4 v4[4]; #endif #if defined( __CL_SHORT8__ ) __cl_short8 v8[2]; #endif #if defined( __CL_SHORT16__ ) __cl_short16 v16; #endif }cl_short16; /* ---- cl_ushortn ---- */ typedef union { cl_ushort CL_ALIGNED(4) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ushort x, y; }; __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; }; #endif #if defined( __CL_USHORT2__) __cl_ushort2 v2; #endif }cl_ushort2; typedef union { cl_ushort CL_ALIGNED(8) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; }; #endif #if defined( __CL_USHORT2__) __cl_ushort2 v2[2]; #endif #if defined( __CL_USHORT4__) __cl_ushort4 v4; #endif }cl_ushort4; /* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */ typedef cl_ushort4 cl_ushort3; typedef union { cl_ushort CL_ALIGNED(16) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; }; #endif #if defined( __CL_USHORT2__) __cl_ushort2 v2[4]; #endif #if defined( __CL_USHORT4__) __cl_ushort4 v4[2]; #endif #if defined( __CL_USHORT8__ ) __cl_ushort8 v8; #endif }cl_ushort8; typedef union { cl_ushort CL_ALIGNED(32) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; }; #endif #if defined( __CL_USHORT2__) __cl_ushort2 v2[8]; #endif #if defined( __CL_USHORT4__) __cl_ushort4 v4[4]; #endif #if defined( __CL_USHORT8__ ) __cl_ushort8 v8[2]; #endif #if defined( __CL_USHORT16__ ) __cl_ushort16 v16; #endif }cl_ushort16; /* ---- cl_intn ---- */ typedef union { cl_int CL_ALIGNED(8) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_int x, y; }; __CL_ANON_STRUCT__ struct{ cl_int s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_int lo, hi; }; #endif #if defined( __CL_INT2__) __cl_int2 v2; #endif }cl_int2; typedef union { cl_int CL_ALIGNED(16) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; }; #endif #if defined( __CL_INT2__) __cl_int2 v2[2]; #endif #if defined( __CL_INT4__) __cl_int4 v4; #endif }cl_int4; /* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */ typedef cl_int4 cl_int3; typedef union { cl_int CL_ALIGNED(32) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; }; #endif #if defined( __CL_INT2__) __cl_int2 v2[4]; #endif #if defined( __CL_INT4__) __cl_int4 v4[2]; #endif #if defined( __CL_INT8__ ) __cl_int8 v8; #endif }cl_int8; typedef union { cl_int CL_ALIGNED(64) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; }; #endif #if defined( __CL_INT2__) __cl_int2 v2[8]; #endif #if defined( __CL_INT4__) __cl_int4 v4[4]; #endif #if defined( __CL_INT8__ ) __cl_int8 v8[2]; #endif #if defined( __CL_INT16__ ) __cl_int16 v16; #endif }cl_int16; /* ---- cl_uintn ---- */ typedef union { cl_uint CL_ALIGNED(8) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uint x, y; }; __CL_ANON_STRUCT__ struct{ cl_uint s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_uint lo, hi; }; #endif #if defined( __CL_UINT2__) __cl_uint2 v2; #endif }cl_uint2; typedef union { cl_uint CL_ALIGNED(16) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; }; #endif #if defined( __CL_UINT2__) __cl_uint2 v2[2]; #endif #if defined( __CL_UINT4__) __cl_uint4 v4; #endif }cl_uint4; /* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */ typedef cl_uint4 cl_uint3; typedef union { cl_uint CL_ALIGNED(32) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; }; #endif #if defined( __CL_UINT2__) __cl_uint2 v2[4]; #endif #if defined( __CL_UINT4__) __cl_uint4 v4[2]; #endif #if defined( __CL_UINT8__ ) __cl_uint8 v8; #endif }cl_uint8; typedef union { cl_uint CL_ALIGNED(64) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; }; #endif #if defined( __CL_UINT2__) __cl_uint2 v2[8]; #endif #if defined( __CL_UINT4__) __cl_uint4 v4[4]; #endif #if defined( __CL_UINT8__ ) __cl_uint8 v8[2]; #endif #if defined( __CL_UINT16__ ) __cl_uint16 v16; #endif }cl_uint16; /* ---- cl_longn ---- */ typedef union { cl_long CL_ALIGNED(16) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_long x, y; }; __CL_ANON_STRUCT__ struct{ cl_long s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_long lo, hi; }; #endif #if defined( __CL_LONG2__) __cl_long2 v2; #endif }cl_long2; typedef union { cl_long CL_ALIGNED(32) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; }; #endif #if defined( __CL_LONG2__) __cl_long2 v2[2]; #endif #if defined( __CL_LONG4__) __cl_long4 v4; #endif }cl_long4; /* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */ typedef cl_long4 cl_long3; typedef union { cl_long CL_ALIGNED(64) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; }; #endif #if defined( __CL_LONG2__) __cl_long2 v2[4]; #endif #if defined( __CL_LONG4__) __cl_long4 v4[2]; #endif #if defined( __CL_LONG8__ ) __cl_long8 v8; #endif }cl_long8; typedef union { cl_long CL_ALIGNED(128) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; }; #endif #if defined( __CL_LONG2__) __cl_long2 v2[8]; #endif #if defined( __CL_LONG4__) __cl_long4 v4[4]; #endif #if defined( __CL_LONG8__ ) __cl_long8 v8[2]; #endif #if defined( __CL_LONG16__ ) __cl_long16 v16; #endif }cl_long16; /* ---- cl_ulongn ---- */ typedef union { cl_ulong CL_ALIGNED(16) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ulong x, y; }; __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; }; #endif #if defined( __CL_ULONG2__) __cl_ulong2 v2; #endif }cl_ulong2; typedef union { cl_ulong CL_ALIGNED(32) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; }; #endif #if defined( __CL_ULONG2__) __cl_ulong2 v2[2]; #endif #if defined( __CL_ULONG4__) __cl_ulong4 v4; #endif }cl_ulong4; /* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */ typedef cl_ulong4 cl_ulong3; typedef union { cl_ulong CL_ALIGNED(64) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; }; #endif #if defined( __CL_ULONG2__) __cl_ulong2 v2[4]; #endif #if defined( __CL_ULONG4__) __cl_ulong4 v4[2]; #endif #if defined( __CL_ULONG8__ ) __cl_ulong8 v8; #endif }cl_ulong8; typedef union { cl_ulong CL_ALIGNED(128) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; }; #endif #if defined( __CL_ULONG2__) __cl_ulong2 v2[8]; #endif #if defined( __CL_ULONG4__) __cl_ulong4 v4[4]; #endif #if defined( __CL_ULONG8__ ) __cl_ulong8 v8[2]; #endif #if defined( __CL_ULONG16__ ) __cl_ulong16 v16; #endif }cl_ulong16; /* --- cl_floatn ---- */ typedef union { cl_float CL_ALIGNED(8) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_float x, y; }; __CL_ANON_STRUCT__ struct{ cl_float s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_float lo, hi; }; #endif #if defined( __CL_FLOAT2__) __cl_float2 v2; #endif }cl_float2; typedef union { cl_float CL_ALIGNED(16) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; }; #endif #if defined( __CL_FLOAT2__) __cl_float2 v2[2]; #endif #if defined( __CL_FLOAT4__) __cl_float4 v4; #endif }cl_float4; /* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */ typedef cl_float4 cl_float3; typedef union { cl_float CL_ALIGNED(32) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; }; #endif #if defined( __CL_FLOAT2__) __cl_float2 v2[4]; #endif #if defined( __CL_FLOAT4__) __cl_float4 v4[2]; #endif #if defined( __CL_FLOAT8__ ) __cl_float8 v8; #endif }cl_float8; typedef union { cl_float CL_ALIGNED(64) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; }; #endif #if defined( __CL_FLOAT2__) __cl_float2 v2[8]; #endif #if defined( __CL_FLOAT4__) __cl_float4 v4[4]; #endif #if defined( __CL_FLOAT8__ ) __cl_float8 v8[2]; #endif #if defined( __CL_FLOAT16__ ) __cl_float16 v16; #endif }cl_float16; /* --- cl_doublen ---- */ typedef union { cl_double CL_ALIGNED(16) s[2]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_double x, y; }; __CL_ANON_STRUCT__ struct{ cl_double s0, s1; }; __CL_ANON_STRUCT__ struct{ cl_double lo, hi; }; #endif #if defined( __CL_DOUBLE2__) __cl_double2 v2; #endif }cl_double2; typedef union { cl_double CL_ALIGNED(32) s[4]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; }; __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; }; #endif #if defined( __CL_DOUBLE2__) __cl_double2 v2[2]; #endif #if defined( __CL_DOUBLE4__) __cl_double4 v4; #endif }cl_double4; /* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */ typedef cl_double4 cl_double3; typedef union { cl_double CL_ALIGNED(64) s[8]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; }; __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; }; __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; }; #endif #if defined( __CL_DOUBLE2__) __cl_double2 v2[4]; #endif #if defined( __CL_DOUBLE4__) __cl_double4 v4[2]; #endif #if defined( __CL_DOUBLE8__ ) __cl_double8 v8; #endif }cl_double8; typedef union { cl_double CL_ALIGNED(128) s[16]; #if __CL_HAS_ANON_STRUCT__ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; }; __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; }; __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; }; #endif #if defined( __CL_DOUBLE2__) __cl_double2 v2[8]; #endif #if defined( __CL_DOUBLE4__) __cl_double4 v4[4]; #endif #if defined( __CL_DOUBLE8__ ) __cl_double8 v8[2]; #endif #if defined( __CL_DOUBLE16__ ) __cl_double16 v16; #endif }cl_double16; /* Macro to facilitate debugging * Usage: * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source. * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \" * Each line thereafter of OpenCL C source must end with: \n\ * The last line ends in "; * * Example: * * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\ * kernel void foo( int a, float * b ) \n\ * { \n\ * // my comment \n\ * *b[ get_global_id(0)] = a; \n\ * } \n\ * "; * * This should correctly set up the line, (column) and file information for your source * string so you can do source level debugging. */ #define __CL_STRINGIFY( _x ) # _x #define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x ) #define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n" #ifdef __cplusplus } #endif #undef __CL_HAS_ANON_STRUCT__ #undef __CL_ANON_STRUCT__ #if defined( _WIN32) && (_MSC_VER >= 1500) #pragma warning( pop ) #endif #endif /* __CL_PLATFORM_H */ ================================================ FILE: phonelibs/opencl/include/CL/opencl.h ================================================ /******************************************************************************* * Copyright (c) 2008-2015 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and/or associated documentation files (the * "Materials"), to deal in the Materials without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Materials, and to * permit persons to whom the Materials are furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Materials. * * MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS * KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS * SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT * https://www.khronos.org/registry/ * * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. ******************************************************************************/ /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */ #ifndef __OPENCL_H #define __OPENCL_H #ifdef __cplusplus extern "C" { #endif #ifdef __APPLE__ #include #include #include #include #else #include #include #include #include #endif #ifdef __cplusplus } #endif #endif /* __OPENCL_H */ ================================================ FILE: phonelibs/openmax/include/OMX_Audio.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** @file OMX_Audio.h - OpenMax IL version 1.1.2 * The structures needed by Audio components to exchange * parameters and configuration data with the componenmilts. */ #ifndef OMX_Audio_h #define OMX_Audio_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header must include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** @defgroup midi MIDI * @ingroup audio */ /** @defgroup effects Audio effects * @ingroup audio */ /** @defgroup audio OpenMAX IL Audio Domain * Structures for OpenMAX IL Audio domain * @{ */ /** Enumeration used to define the possible audio codings. * If "OMX_AUDIO_CodingUnused" is selected, the coding selection must * be done in a vendor specific way. Since this is for an audio * processing element this enum is relevant. However, for another * type of component other enums would be in this area. */ typedef enum OMX_AUDIO_CODINGTYPE { OMX_AUDIO_CodingUnused = 0, /**< Placeholder value when coding is N/A */ OMX_AUDIO_CodingAutoDetect, /**< auto detection of audio format */ OMX_AUDIO_CodingPCM, /**< Any variant of PCM coding */ OMX_AUDIO_CodingADPCM, /**< Any variant of ADPCM encoded data */ OMX_AUDIO_CodingAMR, /**< Any variant of AMR encoded data */ OMX_AUDIO_CodingGSMFR, /**< Any variant of GSM fullrate (i.e. GSM610) */ OMX_AUDIO_CodingGSMEFR, /**< Any variant of GSM Enhanced Fullrate encoded data*/ OMX_AUDIO_CodingGSMHR, /**< Any variant of GSM Halfrate encoded data */ OMX_AUDIO_CodingPDCFR, /**< Any variant of PDC Fullrate encoded data */ OMX_AUDIO_CodingPDCEFR, /**< Any variant of PDC Enhanced Fullrate encoded data */ OMX_AUDIO_CodingPDCHR, /**< Any variant of PDC Halfrate encoded data */ OMX_AUDIO_CodingTDMAFR, /**< Any variant of TDMA Fullrate encoded data (TIA/EIA-136-420) */ OMX_AUDIO_CodingTDMAEFR, /**< Any variant of TDMA Enhanced Fullrate encoded data (TIA/EIA-136-410) */ OMX_AUDIO_CodingQCELP8, /**< Any variant of QCELP 8kbps encoded data */ OMX_AUDIO_CodingQCELP13, /**< Any variant of QCELP 13kbps encoded data */ OMX_AUDIO_CodingEVRC, /**< Any variant of EVRC encoded data */ OMX_AUDIO_CodingSMV, /**< Any variant of SMV encoded data */ OMX_AUDIO_CodingG711, /**< Any variant of G.711 encoded data */ OMX_AUDIO_CodingG723, /**< Any variant of G.723 dot 1 encoded data */ OMX_AUDIO_CodingG726, /**< Any variant of G.726 encoded data */ OMX_AUDIO_CodingG729, /**< Any variant of G.729 encoded data */ OMX_AUDIO_CodingAAC, /**< Any variant of AAC encoded data */ OMX_AUDIO_CodingMP3, /**< Any variant of MP3 encoded data */ OMX_AUDIO_CodingSBC, /**< Any variant of SBC encoded data */ OMX_AUDIO_CodingVORBIS, /**< Any variant of VORBIS encoded data */ OMX_AUDIO_CodingWMA, /**< Any variant of WMA encoded data */ OMX_AUDIO_CodingRA, /**< Any variant of RA encoded data */ OMX_AUDIO_CodingMIDI, /**< Any variant of MIDI encoded data */ OMX_AUDIO_CodingAC3, /**< Any variant of AC3 encoded data */ OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_CodingMax = 0x7FFFFFFF } OMX_AUDIO_CODINGTYPE; /** The PortDefinition structure is used to define all of the parameters * necessary for the compliant component to setup an input or an output audio * path. If additional information is needed to define the parameters of the * port (such as frequency), additional structures must be sent such as the * OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port. */ typedef struct OMX_AUDIO_PORTDEFINITIONTYPE { OMX_STRING cMIMEType; /**< MIME type of data for the port */ OMX_NATIVE_DEVICETYPE pNativeRender; /** < platform specific reference for an output device, otherwise this field is 0 */ OMX_BOOL bFlagErrorConcealment; /**< Turns on error concealment if it is supported by the OMX component */ OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */ } OMX_AUDIO_PORTDEFINITIONTYPE; /** Port format parameter. This structure is used to enumerate * the various data input/output format supported by the port. */ typedef struct OMX_AUDIO_PARAM_PORTFORMATTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Indicates which port to set */ OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ OMX_AUDIO_CODINGTYPE eEncoding; /**< Type of data expected for this port (e.g. PCM, AMR, MP3, etc) */ } OMX_AUDIO_PARAM_PORTFORMATTYPE; /** PCM mode type */ typedef enum OMX_AUDIO_PCMMODETYPE { OMX_AUDIO_PCMModeLinear = 0, /**< Linear PCM encoded data */ OMX_AUDIO_PCMModeALaw, /**< A law PCM encoded data (G.711) */ OMX_AUDIO_PCMModeMULaw, /**< Mu law PCM encoded data (G.711) */ OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_PCMModeMax = 0x7FFFFFFF } OMX_AUDIO_PCMMODETYPE; typedef enum OMX_AUDIO_CHANNELTYPE { OMX_AUDIO_ChannelNone = 0x0, /**< Unused or empty */ OMX_AUDIO_ChannelLF = 0x1, /**< Left front */ OMX_AUDIO_ChannelRF = 0x2, /**< Right front */ OMX_AUDIO_ChannelCF = 0x3, /**< Center front */ OMX_AUDIO_ChannelLS = 0x4, /**< Left surround */ OMX_AUDIO_ChannelRS = 0x5, /**< Right surround */ OMX_AUDIO_ChannelLFE = 0x6, /**< Low frequency effects */ OMX_AUDIO_ChannelCS = 0x7, /**< Back surround */ OMX_AUDIO_ChannelLR = 0x8, /**< Left rear. */ OMX_AUDIO_ChannelRR = 0x9, /**< Right rear. */ OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_ChannelMax = 0x7FFFFFFF } OMX_AUDIO_CHANNELTYPE; #define OMX_AUDIO_MAXCHANNELS 16 /**< maximum number distinct audio channels that a buffer may contain */ #define OMX_MIN_PCMPAYLOAD_MSEC 5 /**< Minimum audio buffer payload size for uncompressed (PCM) audio */ /** PCM format description */ typedef struct OMX_AUDIO_PARAM_PCMMODETYPE { OMX_U32 nSize; /**< Size of this structure, in Bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels (e.g. 2 for stereo) */ OMX_NUMERICALDATATYPE eNumData; /**< indicates PCM data as signed or unsigned */ OMX_ENDIANTYPE eEndian; /**< indicates PCM data as little or big endian */ OMX_BOOL bInterleaved; /**< True for normal interleaved data; false for non-interleaved data (e.g. block data) */ OMX_U32 nBitPerSample; /**< Bit per sample */ OMX_U32 nSamplingRate; /**< Sampling rate of the source data. Use 0 for variable or unknown sampling rate. */ OMX_AUDIO_PCMMODETYPE ePCMMode; /**< PCM mode enumeration */ OMX_AUDIO_CHANNELTYPE eChannelMapping[OMX_AUDIO_MAXCHANNELS]; /**< Slot i contains channel defined by eChannelMap[i] */ } OMX_AUDIO_PARAM_PCMMODETYPE; /** Audio channel mode. This is used by both AAC and MP3, although the names are more appropriate * for the MP3. For example, JointStereo for MP3 is CouplingChannels for AAC. */ typedef enum OMX_AUDIO_CHANNELMODETYPE { OMX_AUDIO_ChannelModeStereo = 0, /**< 2 channels, the bitrate allocation between those two channels changes accordingly to each channel information */ OMX_AUDIO_ChannelModeJointStereo, /**< mode that takes advantage of what is common between 2 channels for higher compression gain */ OMX_AUDIO_ChannelModeDual, /**< 2 mono-channels, each channel is encoded with half the bitrate of the overall bitrate */ OMX_AUDIO_ChannelModeMono, /**< Mono channel mode */ OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF } OMX_AUDIO_CHANNELMODETYPE; typedef enum OMX_AUDIO_MP3STREAMFORMATTYPE { OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */ OMX_AUDIO_MP3StreamFormatMP2Layer3, /**< MP3 Audio MPEG 2 Layer 3 Stream format */ OMX_AUDIO_MP3StreamFormatMP2_5Layer3, /**< MP3 Audio MPEG2.5 Layer 3 Stream format */ OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF } OMX_AUDIO_MP3STREAMFORMATTYPE; /** MP3 params */ typedef struct OMX_AUDIO_PARAM_MP3TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels */ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable rate or unknown bit rates */ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for variable or unknown sampling rate. */ OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should limit the audio signal. Use 0 to let encoder decide */ OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ OMX_AUDIO_MP3STREAMFORMATTYPE eFormat; /**< MP3 stream format */ } OMX_AUDIO_PARAM_MP3TYPE; typedef enum OMX_AUDIO_AACSTREAMFORMATTYPE { OMX_AUDIO_AACStreamFormatMP2ADTS = 0, /**< AAC Audio Data Transport Stream 2 format */ OMX_AUDIO_AACStreamFormatMP4ADTS, /**< AAC Audio Data Transport Stream 4 format */ OMX_AUDIO_AACStreamFormatMP4LOAS, /**< AAC Low Overhead Audio Stream format */ OMX_AUDIO_AACStreamFormatMP4LATM, /**< AAC Low overhead Audio Transport Multiplex */ OMX_AUDIO_AACStreamFormatADIF, /**< AAC Audio Data Interchange Format */ OMX_AUDIO_AACStreamFormatMP4FF, /**< AAC inside MPEG-4/ISO File Format */ OMX_AUDIO_AACStreamFormatRAW, /**< AAC Raw Format */ OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF } OMX_AUDIO_AACSTREAMFORMATTYPE; /** AAC mode type. Note that the term profile is used with the MPEG-2 * standard and the term object type and profile is used with MPEG-4 */ typedef enum OMX_AUDIO_AACPROFILETYPE{ OMX_AUDIO_AACObjectNull = 0, /**< Null, not used */ OMX_AUDIO_AACObjectMain = 1, /**< AAC Main object */ OMX_AUDIO_AACObjectLC, /**< AAC Low Complexity object (AAC profile) */ OMX_AUDIO_AACObjectSSR, /**< AAC Scalable Sample Rate object */ OMX_AUDIO_AACObjectLTP, /**< AAC Long Term Prediction object */ OMX_AUDIO_AACObjectHE, /**< AAC High Efficiency (object type SBR, HE-AAC profile) */ OMX_AUDIO_AACObjectScalable, /**< AAC Scalable object */ OMX_AUDIO_AACObjectERLC = 17, /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */ OMX_AUDIO_AACObjectLD = 23, /**< AAC Low Delay object (Error Resilient) */ OMX_AUDIO_AACObjectHE_PS = 29, /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */ OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_AACObjectMax = 0x7FFFFFFF } OMX_AUDIO_AACPROFILETYPE; /** AAC tool usage (for nAACtools in OMX_AUDIO_PARAM_AACPROFILETYPE). * Required for encoder configuration and optional as decoder info output. * For MP3, OMX_AUDIO_CHANNELMODETYPE is sufficient. */ #define OMX_AUDIO_AACToolNone 0x00000000 /**< no AAC tools allowed (encoder config) or active (decoder info output) */ #define OMX_AUDIO_AACToolMS 0x00000001 /**< MS: Mid/side joint coding tool allowed or active */ #define OMX_AUDIO_AACToolIS 0x00000002 /**< IS: Intensity stereo tool allowed or active */ #define OMX_AUDIO_AACToolTNS 0x00000004 /**< TNS: Temporal Noise Shaping tool allowed or active */ #define OMX_AUDIO_AACToolPNS 0x00000008 /**< PNS: MPEG-4 Perceptual Noise substitution tool allowed or active */ #define OMX_AUDIO_AACToolLTP 0x00000010 /**< LTP: MPEG-4 Long Term Prediction tool allowed or active */ #define OMX_AUDIO_AACToolAll 0x7FFFFFFF /**< all AAC tools allowed or active (*/ /** MPEG-4 AAC error resilience (ER) tool usage (for nAACERtools in OMX_AUDIO_PARAM_AACPROFILETYPE). * Required for ER encoder configuration and optional as decoder info output */ #define OMX_AUDIO_AACERNone 0x00000000 /**< no AAC ER tools allowed/used */ #define OMX_AUDIO_AACERVCB11 0x00000001 /**< VCB11: Virtual Code Books for AAC section data */ #define OMX_AUDIO_AACERRVLC 0x00000002 /**< RVLC: Reversible Variable Length Coding */ #define OMX_AUDIO_AACERHCR 0x00000004 /**< HCR: Huffman Codeword Reordering */ #define OMX_AUDIO_AACERAll 0x7FFFFFFF /**< all AAC ER tools allowed/used */ /** AAC params */ typedef struct OMX_AUDIO_PARAM_AACPROFILETYPE { OMX_U32 nSize; /**< Size of this structure, in Bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels */ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for variable or unknown sampling rate. */ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable rate or unknown bit rates */ OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should limit the audio signal. Use 0 to let encoder decide */ OMX_U32 nFrameLength; /**< Frame length (in audio samples per channel) of the codec. Can be 1024 or 960 (AAC-LC), 2048 (HE-AAC), 480 or 512 (AAC-LD). Use 0 to let encoder decide */ OMX_U32 nAACtools; /**< AAC tool usage */ OMX_U32 nAACERtools; /**< MPEG-4 AAC error resilience tool usage */ OMX_AUDIO_AACPROFILETYPE eAACProfile; /**< AAC profile enumeration */ OMX_AUDIO_AACSTREAMFORMATTYPE eAACStreamFormat; /**< AAC stream format enumeration */ OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ } OMX_AUDIO_PARAM_AACPROFILETYPE; /** VORBIS params */ typedef struct OMX_AUDIO_PARAM_VORBISTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels */ OMX_U32 nBitRate; /**< Bit rate of the encoded data data. Use 0 for variable rate or unknown bit rates. Encoding is set to the bitrate closest to specified value (in bps) */ OMX_U32 nMinBitRate; /**< Sets minimum bitrate (in bps). */ OMX_U32 nMaxBitRate; /**< Sets maximum bitrate (in bps). */ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for variable or unknown sampling rate. */ OMX_U32 nAudioBandWidth; /**< Audio band width (in Hz) to which an encoder should limit the audio signal. Use 0 to let encoder decide */ OMX_S32 nQuality; /**< Sets encoding quality to n, between -1 (low) and 10 (high). In the default mode of operation, teh quality level is 3. Normal quality range is 0 - 10. */ OMX_BOOL bManaged; /**< Set bitrate management mode. This turns off the normal VBR encoding, but allows hard or soft bitrate constraints to be enforced by the encoder. This mode can be slower, and may also be lower quality. It is primarily useful for streaming. */ OMX_BOOL bDownmix; /**< Downmix input from stereo to mono (has no effect on non-stereo streams). Useful for lower-bitrate encoding. */ } OMX_AUDIO_PARAM_VORBISTYPE; /** WMA Version */ typedef enum OMX_AUDIO_WMAFORMATTYPE { OMX_AUDIO_WMAFormatUnused = 0, /**< format unused or unknown */ OMX_AUDIO_WMAFormat7, /**< Windows Media Audio format 7 */ OMX_AUDIO_WMAFormat8, /**< Windows Media Audio format 8 */ OMX_AUDIO_WMAFormat9, /**< Windows Media Audio format 9 */ OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF } OMX_AUDIO_WMAFORMATTYPE; /** WMA Profile */ typedef enum OMX_AUDIO_WMAPROFILETYPE { OMX_AUDIO_WMAProfileUnused = 0, /**< profile unused or unknown */ OMX_AUDIO_WMAProfileL1, /**< Windows Media audio version 9 profile L1 */ OMX_AUDIO_WMAProfileL2, /**< Windows Media audio version 9 profile L2 */ OMX_AUDIO_WMAProfileL3, /**< Windows Media audio version 9 profile L3 */ OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF } OMX_AUDIO_WMAPROFILETYPE; /** WMA params */ typedef struct OMX_AUDIO_PARAM_WMATYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U16 nChannels; /**< Number of channels */ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable rate or unknown bit rates */ OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */ OMX_AUDIO_WMAPROFILETYPE eProfile; /**< Profile of WMA stream / data */ OMX_U32 nSamplingRate; /**< Sampling rate of the source data */ OMX_U16 nBlockAlign; /**< is the block alignment, or block size, in bytes of the audio codec */ OMX_U16 nEncodeOptions; /**< WMA Type-specific data */ OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */ } OMX_AUDIO_PARAM_WMATYPE; /** * RealAudio format */ typedef enum OMX_AUDIO_RAFORMATTYPE { OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */ OMX_AUDIO_RA8, /**< RealAudio 8 codec */ OMX_AUDIO_RA9, /**< RealAudio 9 codec */ OMX_AUDIO_RA10_AAC, /**< MPEG-4 AAC codec for bitrates of more than 128kbps */ OMX_AUDIO_RA10_CODEC, /**< RealAudio codec for bitrates less than 128 kbps */ OMX_AUDIO_RA10_LOSSLESS, /**< RealAudio Lossless */ OMX_AUDIO_RA10_MULTICHANNEL, /**< RealAudio Multichannel */ OMX_AUDIO_RA10_VOICE, /**< RealAudio Voice for bitrates below 15 kbps */ OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_RAFormatMax = 0x7FFFFFFF } OMX_AUDIO_RAFORMATTYPE; /** RA (Real Audio) params */ typedef struct OMX_AUDIO_PARAM_RATYPE { OMX_U32 nSize; /**< Size of this structure, in Bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels */ OMX_U32 nSamplingRate; /**< is the sampling rate of the source data */ OMX_U32 nBitsPerFrame; /**< is the value for bits per frame */ OMX_U32 nSamplePerFrame; /**< is the value for samples per frame */ OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ OMX_U32 nCouplingStartRegion; /**< is the coupling start region in the stream */ OMX_U32 nNumRegions; /**< is the number of regions value */ OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */ } OMX_AUDIO_PARAM_RATYPE; /** SBC Allocation Method Type */ typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE { OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */ OMX_AUDIO_SBCAllocMethodSNR, /**< SNR allocation method */ OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF } OMX_AUDIO_SBCALLOCMETHODTYPE; /** SBC params */ typedef struct OMX_AUDIO_PARAM_SBCTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels */ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable rate or unknown bit rates */ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for variable or unknown sampling rate. */ OMX_U32 nBlocks; /**< Number of blocks */ OMX_U32 nSubbands; /**< Number of subbands */ OMX_U32 nBitPool; /**< Bitpool value */ OMX_BOOL bEnableBitrate; /**< Use bitrate value instead of bitpool */ OMX_AUDIO_CHANNELMODETYPE eChannelMode; /**< Channel mode enumeration */ OMX_AUDIO_SBCALLOCMETHODTYPE eSBCAllocType; /**< SBC Allocation method type */ } OMX_AUDIO_PARAM_SBCTYPE; /** ADPCM stream format parameters */ typedef struct OMX_AUDIO_PARAM_ADPCMTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_U32 nBitsPerSample; /**< Number of bits in each sample */ OMX_U32 nSampleRate; /**< Sampling rate of the source data. Use 0 for variable or unknown sampling rate. */ } OMX_AUDIO_PARAM_ADPCMTYPE; /** G723 rate */ typedef enum OMX_AUDIO_G723RATE { OMX_AUDIO_G723ModeUnused = 0, /**< AMRNB Mode unused / unknown */ OMX_AUDIO_G723ModeLow, /**< 5300 bps */ OMX_AUDIO_G723ModeHigh, /**< 6300 bps */ OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_G723ModeMax = 0x7FFFFFFF } OMX_AUDIO_G723RATE; /** G723 - Sample rate must be 8 KHz */ typedef struct OMX_AUDIO_PARAM_G723TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_AUDIO_G723RATE eBitRate; /**< todo: Should this be moved to a config? */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ OMX_BOOL bPostFilter; /**< Enable Post Filter */ } OMX_AUDIO_PARAM_G723TYPE; /** ITU G726 (ADPCM) rate */ typedef enum OMX_AUDIO_G726MODE { OMX_AUDIO_G726ModeUnused = 0, /**< G726 Mode unused / unknown */ OMX_AUDIO_G726Mode16, /**< 16 kbps */ OMX_AUDIO_G726Mode24, /**< 24 kbps */ OMX_AUDIO_G726Mode32, /**< 32 kbps, most common rate, also G721 */ OMX_AUDIO_G726Mode40, /**< 40 kbps */ OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_G726ModeMax = 0x7FFFFFFF } OMX_AUDIO_G726MODE; /** G.726 stream format parameters - must be at 8KHz */ typedef struct OMX_AUDIO_PARAM_G726TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_AUDIO_G726MODE eG726Mode; } OMX_AUDIO_PARAM_G726TYPE; /** G729 coder type */ typedef enum OMX_AUDIO_G729TYPE { OMX_AUDIO_G729 = 0, /**< ITU G.729 encoded data */ OMX_AUDIO_G729A, /**< ITU G.729 annex A encoded data */ OMX_AUDIO_G729B, /**< ITU G.729 with annex B encoded data */ OMX_AUDIO_G729AB, /**< ITU G.729 annexes A and B encoded data */ OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_G729Max = 0x7FFFFFFF } OMX_AUDIO_G729TYPE; /** G729 stream format parameters - fixed 6KHz sample rate */ typedef struct OMX_AUDIO_PARAM_G729TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_AUDIO_G729TYPE eBitType; } OMX_AUDIO_PARAM_G729TYPE; /** AMR Frame format */ typedef enum OMX_AUDIO_AMRFRAMEFORMATTYPE { OMX_AUDIO_AMRFrameFormatConformance = 0, /**< Frame Format is AMR Conformance (Standard) Format */ OMX_AUDIO_AMRFrameFormatIF1, /**< Frame Format is AMR Interface Format 1 */ OMX_AUDIO_AMRFrameFormatIF2, /**< Frame Format is AMR Interface Format 2*/ OMX_AUDIO_AMRFrameFormatFSF, /**< Frame Format is AMR File Storage Format */ OMX_AUDIO_AMRFrameFormatRTPPayload, /**< Frame Format is AMR Real-Time Transport Protocol Payload Format */ OMX_AUDIO_AMRFrameFormatITU, /**< Frame Format is ITU Format (added at Motorola request) */ OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF } OMX_AUDIO_AMRFRAMEFORMATTYPE; /** AMR band mode */ typedef enum OMX_AUDIO_AMRBANDMODETYPE { OMX_AUDIO_AMRBandModeUnused = 0, /**< AMRNB Mode unused / unknown */ OMX_AUDIO_AMRBandModeNB0, /**< AMRNB Mode 0 = 4750 bps */ OMX_AUDIO_AMRBandModeNB1, /**< AMRNB Mode 1 = 5150 bps */ OMX_AUDIO_AMRBandModeNB2, /**< AMRNB Mode 2 = 5900 bps */ OMX_AUDIO_AMRBandModeNB3, /**< AMRNB Mode 3 = 6700 bps */ OMX_AUDIO_AMRBandModeNB4, /**< AMRNB Mode 4 = 7400 bps */ OMX_AUDIO_AMRBandModeNB5, /**< AMRNB Mode 5 = 7950 bps */ OMX_AUDIO_AMRBandModeNB6, /**< AMRNB Mode 6 = 10200 bps */ OMX_AUDIO_AMRBandModeNB7, /**< AMRNB Mode 7 = 12200 bps */ OMX_AUDIO_AMRBandModeWB0, /**< AMRWB Mode 0 = 6600 bps */ OMX_AUDIO_AMRBandModeWB1, /**< AMRWB Mode 1 = 8850 bps */ OMX_AUDIO_AMRBandModeWB2, /**< AMRWB Mode 2 = 12650 bps */ OMX_AUDIO_AMRBandModeWB3, /**< AMRWB Mode 3 = 14250 bps */ OMX_AUDIO_AMRBandModeWB4, /**< AMRWB Mode 4 = 15850 bps */ OMX_AUDIO_AMRBandModeWB5, /**< AMRWB Mode 5 = 18250 bps */ OMX_AUDIO_AMRBandModeWB6, /**< AMRWB Mode 6 = 19850 bps */ OMX_AUDIO_AMRBandModeWB7, /**< AMRWB Mode 7 = 23050 bps */ OMX_AUDIO_AMRBandModeWB8, /**< AMRWB Mode 8 = 23850 bps */ OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF } OMX_AUDIO_AMRBANDMODETYPE; /** AMR Discontinuous Transmission mode */ typedef enum OMX_AUDIO_AMRDTXMODETYPE { OMX_AUDIO_AMRDTXModeOff = 0, /**< AMR Discontinuous Transmission Mode is disabled */ OMX_AUDIO_AMRDTXModeOnVAD1, /**< AMR Discontinuous Transmission Mode using Voice Activity Detector 1 (VAD1) is enabled */ OMX_AUDIO_AMRDTXModeOnVAD2, /**< AMR Discontinuous Transmission Mode using Voice Activity Detector 2 (VAD2) is enabled */ OMX_AUDIO_AMRDTXModeOnAuto, /**< The codec will automatically select between Off, VAD1 or VAD2 modes */ OMX_AUDIO_AMRDTXasEFR, /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */ OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF } OMX_AUDIO_AMRDTXMODETYPE; /** AMR params */ typedef struct OMX_AUDIO_PARAM_AMRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels */ OMX_U32 nBitRate; /**< Bit rate read only field */ OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ OMX_AUDIO_AMRDTXMODETYPE eAMRDTXMode; /**< AMR DTX Mode enumeration */ OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */ } OMX_AUDIO_PARAM_AMRTYPE; /** GSM_FR (ETSI 06.10, 3GPP 46.010) stream format parameters */ typedef struct OMX_AUDIO_PARAM_GSMFRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_GSMFRTYPE; /** GSM-HR (ETSI 06.20, 3GPP 46.020) stream format parameters */ typedef struct OMX_AUDIO_PARAM_GSMHRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_GSMHRTYPE; /** GSM-EFR (ETSI 06.60, 3GPP 46.060) stream format parameters */ typedef struct OMX_AUDIO_PARAM_GSMEFRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_GSMEFRTYPE; /** TDMA FR (TIA/EIA-136-420, VSELP 7.95kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_TDMAFRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_TDMAFRTYPE; /** TDMA EFR (TIA/EIA-136-410, ACELP 7.4kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_TDMAEFRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_TDMAEFRTYPE; /** PDC FR ( RCR-27, VSELP 6.7kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_PDCFRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_PDCFRTYPE; /** PDC EFR ( RCR-27, ACELP 6.7kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_PDCEFRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_PDCEFRTYPE; /** PDC HR ( RCR-27, PSI-CELP 3.45kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_PDCHRTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_BOOL bDTX; /**< Enable Discontinuous Transmisssion */ OMX_BOOL bHiPassFilter; /**< Enable High Pass Filter */ } OMX_AUDIO_PARAM_PDCHRTYPE; /** CDMA Rate types */ typedef enum OMX_AUDIO_CDMARATETYPE { OMX_AUDIO_CDMARateBlank = 0, /**< CDMA encoded frame is blank */ OMX_AUDIO_CDMARateFull, /**< CDMA encoded frame in full rate */ OMX_AUDIO_CDMARateHalf, /**< CDMA encoded frame in half rate */ OMX_AUDIO_CDMARateQuarter, /**< CDMA encoded frame in quarter rate */ OMX_AUDIO_CDMARateEighth, /**< CDMA encoded frame in eighth rate (DTX)*/ OMX_AUDIO_CDMARateErasure, /**< CDMA erasure frame */ OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_CDMARateMax = 0x7FFFFFFF } OMX_AUDIO_CDMARATETYPE; /** QCELP8 (TIA/EIA-96, up to 8kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_QCELP8TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_U32 nBitRate; /**< Bit rate of the input data. Use 0 for variable rate or unknown bit rates */ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ } OMX_AUDIO_PARAM_QCELP8TYPE; /** QCELP13 ( CDMA, EIA/TIA-733, 13.3kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_QCELP13TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ } OMX_AUDIO_PARAM_QCELP13TYPE; /** EVRC ( CDMA, EIA/TIA-127, RCELP up to 8.55kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_EVRCTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< actual Frame rate */ OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 */ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 */ OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter */ OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ OMX_BOOL bPostFilter; /**< Enable decoder's post Filter */ } OMX_AUDIO_PARAM_EVRCTYPE; /** SMV ( up to 8.55kbps coder) stream format parameters */ typedef struct OMX_AUDIO_PARAM_SMVTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannels; /**< Number of channels in the data stream (not necessarily the same as the number of channels to be rendered. */ OMX_AUDIO_CDMARATETYPE eCDMARate; /**< Frame rate */ OMX_BOOL bRATE_REDUCon; /**< RATE_REDUCtion is requested for this frame */ OMX_U32 nMinBitRate; /**< minmal rate for the encoder = 1,2,3,4, default = 1 ??*/ OMX_U32 nMaxBitRate; /**< maximal rate for the encoder = 1,2,3,4, default = 4 ??*/ OMX_BOOL bHiPassFilter; /**< Enable encoder's High Pass Filter ??*/ OMX_BOOL bNoiseSuppressor; /**< Enable encoder's noise suppressor pre-processing */ OMX_BOOL bPostFilter; /**< Enable decoder's post Filter ??*/ } OMX_AUDIO_PARAM_SMVTYPE; /** MIDI Format * @ingroup midi */ typedef enum OMX_AUDIO_MIDIFORMATTYPE { OMX_AUDIO_MIDIFormatUnknown = 0, /**< MIDI Format unknown or don't care */ OMX_AUDIO_MIDIFormatSMF0, /**< Standard MIDI File Type 0 */ OMX_AUDIO_MIDIFormatSMF1, /**< Standard MIDI File Type 1 */ OMX_AUDIO_MIDIFormatSMF2, /**< Standard MIDI File Type 2 */ OMX_AUDIO_MIDIFormatSPMIDI, /**< SP-MIDI */ OMX_AUDIO_MIDIFormatXMF0, /**< eXtensible Music Format type 0 */ OMX_AUDIO_MIDIFormatXMF1, /**< eXtensible Music Format type 1 */ OMX_AUDIO_MIDIFormatMobileXMF, /**< Mobile XMF (eXtensible Music Format type 2) */ OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF } OMX_AUDIO_MIDIFORMATTYPE; /** MIDI params * @ingroup midi */ typedef struct OMX_AUDIO_PARAM_MIDITYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nFileSize; /**< size of the MIDI file in bytes, where the entire MIDI file passed in, otherwise if 0x0, the MIDI data is merged and streamed (instead of passed as an entire MIDI file) */ OMX_BU32 sMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic voices. A value of zero indicates that the default polyphony of the device is used */ OMX_BOOL bLoadDefaultSound; /**< Whether to load default sound bank at initialization */ OMX_AUDIO_MIDIFORMATTYPE eMidiFormat; /**< Version of the MIDI file */ } OMX_AUDIO_PARAM_MIDITYPE; /** Type of the MIDI sound bank * @ingroup midi */ typedef enum OMX_AUDIO_MIDISOUNDBANKTYPE { OMX_AUDIO_MIDISoundBankUnused = 0, /**< unused/unknown soundbank type */ OMX_AUDIO_MIDISoundBankDLS1, /**< DLS version 1 */ OMX_AUDIO_MIDISoundBankDLS2, /**< DLS version 2 */ OMX_AUDIO_MIDISoundBankMobileDLSBase, /**< Mobile DLS, using the base functionality */ OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */ OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF } OMX_AUDIO_MIDISOUNDBANKTYPE; /** Bank Layout describes how bank MSB & LSB are used in the DLS instrument definitions sound bank * @ingroup midi */ typedef enum OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE { OMX_AUDIO_MIDISoundBankLayoutUnused = 0, /**< unused/unknown soundbank type */ OMX_AUDIO_MIDISoundBankLayoutGM, /**< GS layout (based on bank MSB 0x00) */ OMX_AUDIO_MIDISoundBankLayoutGM2, /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */ OMX_AUDIO_MIDISoundBankLayoutUser, /**< Does not conform to any bank numbering standards */ OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF } OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE; /** MIDI params to load/unload user soundbank * @ingroup midi */ typedef struct OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nDLSIndex; /**< DLS file index to be loaded */ OMX_U32 nDLSSize; /**< Size in bytes */ OMX_PTR pDLSData; /**< Pointer to DLS file data */ OMX_AUDIO_MIDISOUNDBANKTYPE eMidiSoundBank; /**< Midi sound bank type enumeration */ OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE eMidiSoundBankLayout; /**< Midi sound bank layout enumeration */ } OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE; /** Structure for Live MIDI events and MIP messages. * (MIP = Maximum Instantaneous Polyphony; part of the SP-MIDI standard.) * @ingroup midi */ typedef struct OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port that this structure applies to */ OMX_U32 nMidiEventSize; /**< Size of immediate MIDI events or MIP message in bytes */ OMX_U8 nMidiEvents[1]; /**< MIDI event array to be rendered immediately, or an array for the MIP message buffer, where the size is indicated by nMidiEventSize */ } OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE; /** MIDI sound bank/ program pair in a given channel * @ingroup midi */ typedef struct OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port that this structure applies to */ OMX_U32 nChannel; /**< Valid channel values range from 1 to 16 */ OMX_U16 nIDProgram; /**< Valid program ID range is 1 to 128 */ OMX_U16 nIDSoundBank; /**< Sound bank ID */ OMX_U32 nUserSoundBankIndex;/**< User soundbank index, easier to access soundbanks by index if multiple banks are present */ } OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE; /** MIDI control * @ingroup midi */ typedef struct OMX_AUDIO_CONFIG_MIDICONTROLTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BS32 sPitchTransposition; /**< Pitch transposition in semitones, stored as Q22.10 format based on JAVA MMAPI (JSR-135) requirement */ OMX_BU32 sPlayBackRate; /**< Relative playback rate, stored as Q14.17 fixed-point number based on JSR-135 requirement */ OMX_BU32 sTempo ; /**< Tempo in beats per minute (BPM), stored as Q22.10 fixed-point number based on JSR-135 requirement */ OMX_U32 nMaxPolyphony; /**< Specifies the maximum simultaneous polyphonic voices. A value of zero indicates that the default polyphony of the device is used */ OMX_U32 nNumRepeat; /**< Number of times to repeat playback */ OMX_U32 nStopTime; /**< Time in milliseconds to indicate when playback will stop automatically. Set to zero if not used */ OMX_U16 nChannelMuteMask; /**< 16 bit mask for channel mute status */ OMX_U16 nChannelSoloMask; /**< 16 bit mask for channel solo status */ OMX_U32 nTrack0031MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 0-31 */ OMX_U32 nTrack3263MuteMask; /**< 32 bit mask for track mute status. Note: This is for tracks 32-63 */ OMX_U32 nTrack0031SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 0-31 */ OMX_U32 nTrack3263SoloMask; /**< 32 bit mask for track solo status. Note: This is for tracks 32-63 */ } OMX_AUDIO_CONFIG_MIDICONTROLTYPE; /** MIDI Playback States * @ingroup midi */ typedef enum OMX_AUDIO_MIDIPLAYBACKSTATETYPE { OMX_AUDIO_MIDIPlayBackStateUnknown = 0, /**< Unknown state or state does not map to other defined states */ OMX_AUDIO_MIDIPlayBackStateClosedEngaged, /**< No MIDI resource is currently open. The MIDI engine is currently processing MIDI events. */ OMX_AUDIO_MIDIPlayBackStateParsing, /**< A MIDI resource is open and is being primed. The MIDI engine is currently processing MIDI events. */ OMX_AUDIO_MIDIPlayBackStateOpenEngaged, /**< A MIDI resource is open and primed but not playing. The MIDI engine is currently processing MIDI events. The transition to this state is only possible from the OMX_AUDIO_MIDIPlayBackStatePlaying state, when the 'playback head' reaches the end of media data or the playback stops due to stop time set.*/ OMX_AUDIO_MIDIPlayBackStatePlaying, /**< A MIDI resource is open and currently playing. The MIDI engine is currently processing MIDI events.*/ OMX_AUDIO_MIDIPlayBackStatePlayingPartially, /**< Best-effort playback due to SP-MIDI/DLS resource constraints */ OMX_AUDIO_MIDIPlayBackStatePlayingSilently, /**< Due to system resource constraints and SP-MIDI content constraints, there is no audible MIDI content during playback currently. The situation may change if resources are freed later.*/ OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF } OMX_AUDIO_MIDIPLAYBACKSTATETYPE; /** MIDI status * @ingroup midi */ typedef struct OMX_AUDIO_CONFIG_MIDISTATUSTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U16 nNumTracks; /**< Number of MIDI tracks in the file, read only field. NOTE: May not return a meaningful value until the entire file is parsed and buffered. */ OMX_U32 nDuration; /**< The length of the currently open MIDI resource in milliseconds. NOTE: May not return a meaningful value until the entire file is parsed and buffered. */ OMX_U32 nPosition; /**< Current Position of the MIDI resource being played in milliseconds */ OMX_BOOL bVibra; /**< Does Vibra track exist? NOTE: May not return a meaningful value until the entire file is parsed and buffered. */ OMX_U32 nNumMetaEvents; /**< Total number of MIDI Meta Events in the currently open MIDI resource. NOTE: May not return a meaningful value until the entire file is parsed and buffered. */ OMX_U32 nNumActiveVoices; /**< Number of active voices in the currently playing MIDI resource. NOTE: May not return a meaningful value until the entire file is parsed and buffered. */ OMX_AUDIO_MIDIPLAYBACKSTATETYPE eMIDIPlayBackState; /**< MIDI playback state enumeration, read only field */ } OMX_AUDIO_CONFIG_MIDISTATUSTYPE; /** MIDI Meta Event structure one per Meta Event. * MIDI Meta Events are like audio metadata, except that they are interspersed * with the MIDI content throughout the file and are not localized in the header. * As such, it is necessary to retrieve information about these Meta Events from * the engine, as it encounters these Meta Events within the MIDI content. * For example, SMF files can have up to 14 types of MIDI Meta Events (copyright, * author, default tempo, etc.) scattered throughout the file. * @ingroup midi */ typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE{ OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nIndex; /**< Index of Meta Event */ OMX_U8 nMetaEventType; /**< Meta Event Type, 7bits (i.e. 0 - 127) */ OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ OMX_U32 nTrack; /**< track number for the meta event */ OMX_U32 nPosition; /**< Position of the meta-event in milliseconds */ } OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE; /** MIDI Meta Event Data structure - one per Meta Event. * @ingroup midi */ typedef struct OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE{ OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nIndex; /**< Index of Meta Event */ OMX_U32 nMetaEventSize; /**< size of the Meta Event in bytes */ OMX_U8 nData[1]; /**< array of one or more bytes of meta data as indicated by the nMetaEventSize field */ } OMX_AUDIO_CONFIG__MIDIMETAEVENTDATATYPE; /** Audio Volume adjustment for a port */ typedef struct OMX_AUDIO_CONFIG_VOLUMETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port index indicating which port to set. Select the input port to set just that port's volume. Select the output port to adjust the master volume. */ OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) or logarithmic scale (mB) */ OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR Volume logarithmic setting for this port. The values for volume are in mB (millibels = 1/100 dB) relative to a gain of 1 (e.g. the output is the same as the input level). Values are in mB from nMax (maximum volume) to nMin mB (typically negative). Since the volume is "voltage" and not a "power", it takes a setting of -600 mB to decrease the volume by 1/2. If a component cannot accurately set the volume to the requested value, it must set the volume to the closest value BELOW the requested value. When getting the volume setting, the current actual volume must be returned. */ } OMX_AUDIO_CONFIG_VOLUMETYPE; /** Audio Volume adjustment for a channel */ typedef struct OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port index indicating which port to set. Select the input port to set just that port's volume. Select the output port to adjust the master volume. */ OMX_U32 nChannel; /**< channel to select from 0 to N-1, using OMX_ALL to apply volume settings to all channels */ OMX_BOOL bLinear; /**< Is the volume to be set in linear (0.100) or logarithmic scale (mB) */ OMX_BS32 sVolume; /**< Volume linear setting in the 0..100 range, OR Volume logarithmic setting for this port. The values for volume are in mB (millibels = 1/100 dB) relative to a gain of 1 (e.g. the output is the same as the input level). Values are in mB from nMax (maximum volume) to nMin mB (typically negative). Since the volume is "voltage" and not a "power", it takes a setting of -600 mB to decrease the volume by 1/2. If a component cannot accurately set the volume to the requested value, it must set the volume to the closest value BELOW the requested value. When getting the volume setting, the current actual volume must be returned. */ OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, FALSE otherwise */ } OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE; /** Audio balance setting */ typedef struct OMX_AUDIO_CONFIG_BALANCETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port index indicating which port to set. Select the input port to set just that port's balance. Select the output port to adjust the master balance. */ OMX_S32 nBalance; /**< balance setting for this port (-100 to 100, where -100 indicates all left, and no right */ } OMX_AUDIO_CONFIG_BALANCETYPE; /** Audio Port mute */ typedef struct OMX_AUDIO_CONFIG_MUTETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port index indicating which port to set. Select the input port to set just that port's mute. Select the output port to adjust the master mute. */ OMX_BOOL bMute; /**< Mute setting for this port */ } OMX_AUDIO_CONFIG_MUTETYPE; /** Audio Channel mute */ typedef struct OMX_AUDIO_CONFIG_CHANNELMUTETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nChannel; /**< channel to select from 0 to N-1, using OMX_ALL to apply mute settings to all channels */ OMX_BOOL bMute; /**< Mute setting for this channel */ OMX_BOOL bIsMIDI; /**< TRUE if nChannel refers to a MIDI channel, FALSE otherwise */ } OMX_AUDIO_CONFIG_CHANNELMUTETYPE; /** Enable / Disable for loudness control, which boosts bass and to a * smaller extent high end frequencies to compensate for hearing * ability at the extreme ends of the audio spectrum */ typedef struct OMX_AUDIO_CONFIG_LOUDNESSTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bLoudness; /**< Enable/disable for loudness */ } OMX_AUDIO_CONFIG_LOUDNESSTYPE; /** Enable / Disable for bass, which controls low frequencies */ typedef struct OMX_AUDIO_CONFIG_BASSTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bEnable; /**< Enable/disable for bass control */ OMX_S32 nBass; /**< bass setting for the port, as a continuous value from -100 to 100 (0 means no change in bass level)*/ } OMX_AUDIO_CONFIG_BASSTYPE; /** Enable / Disable for treble, which controls high frequencies tones */ typedef struct OMX_AUDIO_CONFIG_TREBLETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bEnable; /**< Enable/disable for treble control */ OMX_S32 nTreble; /**< treble setting for the port, as a continuous value from -100 to 100 (0 means no change in treble level) */ } OMX_AUDIO_CONFIG_TREBLETYPE; /** An equalizer is typically used for two reasons: to compensate for an * sub-optimal frequency response of a system to make it sound more natural * or to create intentionally some unnatural coloring to the sound to create * an effect. * @ingroup effects */ typedef struct OMX_AUDIO_CONFIG_EQUALIZERTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bEnable; /**< Enable/disable for equalizer */ OMX_BU32 sBandIndex; /**< Band number to be set. Upper Limit is N-1, where N is the number of bands, lower limit is 0 */ OMX_BU32 sCenterFreq; /**< Center frequecies in Hz. This is a read only element and is used to determine the lower, center and upper frequency of this band. */ OMX_BS32 sBandLevel; /**< band level in millibels */ } OMX_AUDIO_CONFIG_EQUALIZERTYPE; /** Stereo widening mode type * @ingroup effects */ typedef enum OMX_AUDIO_STEREOWIDENINGTYPE { OMX_AUDIO_StereoWideningHeadphones, /**< Stereo widening for loudspeakers */ OMX_AUDIO_StereoWideningLoudspeakers, /**< Stereo widening for closely spaced loudspeakers */ OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF } OMX_AUDIO_STEREOWIDENINGTYPE; /** Control for stereo widening, which is a special 2-channel * case of the audio virtualizer effect. For example, for 5.1-channel * output, it translates to virtual surround sound. * @ingroup effects */ typedef struct OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bEnable; /**< Enable/disable for stereo widening control */ OMX_AUDIO_STEREOWIDENINGTYPE eWideningType; /**< Stereo widening algorithm type */ OMX_U32 nStereoWidening; /**< stereo widening setting for the port, as a continuous value from 0 to 100 */ } OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE; /** The chorus effect (or ``choralizer'') is any signal processor which makes * one sound source (such as a voice) sound like many such sources singing * (or playing) in unison. Since performance in unison is never exact, chorus * effects simulate this by making independently modified copies of the input * signal. Modifications may include (1) delay, (2) frequency shift, and * (3) amplitude modulation. * @ingroup effects */ typedef struct OMX_AUDIO_CONFIG_CHORUSTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bEnable; /**< Enable/disable for chorus */ OMX_BU32 sDelay; /**< average delay in milliseconds */ OMX_BU32 sModulationRate; /**< rate of modulation in millihertz */ OMX_U32 nModulationDepth; /**< depth of modulation as a percentage of delay (i.e. 0 to 100) */ OMX_BU32 nFeedback; /**< Feedback from chorus output to input in percentage */ } OMX_AUDIO_CONFIG_CHORUSTYPE; /** Reverberation is part of the reflected sound that follows the early * reflections. In a typical room, this consists of a dense succession of * echoes whose energy decays exponentially. The reverberation effect structure * as defined here includes both (early) reflections as well as (late) reverberations. * @ingroup effects */ typedef struct OMX_AUDIO_CONFIG_REVERBERATIONTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bEnable; /**< Enable/disable for reverberation control */ OMX_BS32 sRoomLevel; /**< Intensity level for the whole room effect (i.e. both early reflections and late reverberation) in millibels */ OMX_BS32 sRoomHighFreqLevel; /**< Attenuation at high frequencies relative to the intensity at low frequencies in millibels */ OMX_BS32 sReflectionsLevel; /**< Intensity level of early reflections (relative to room value), in millibels */ OMX_BU32 sReflectionsDelay; /**< Delay time of the first reflection relative to the direct path, in milliseconds */ OMX_BS32 sReverbLevel; /**< Intensity level of late reverberation relative to room level, in millibels */ OMX_BU32 sReverbDelay; /**< Time delay from the first early reflection to the beginning of the late reverberation section, in milliseconds */ OMX_BU32 sDecayTime; /**< Late reverberation decay time at low frequencies, in milliseconds */ OMX_BU32 nDecayHighFreqRatio; /**< Ratio of high frequency decay time relative to low frequency decay time in percent */ OMX_U32 nDensity; /**< Modal density in the late reverberation decay, in percent (i.e. 0 - 100) */ OMX_U32 nDiffusion; /**< Echo density in the late reverberation decay, in percent (i.e. 0 - 100) */ OMX_BU32 sReferenceHighFreq; /**< Reference high frequency in Hertz. This is the frequency used as the reference for all the high-frequency settings above */ } OMX_AUDIO_CONFIG_REVERBERATIONTYPE; /** Possible settings for the Echo Cancelation structure to use * @ingroup effects */ typedef enum OMX_AUDIO_ECHOCANTYPE { OMX_AUDIO_EchoCanOff = 0, /**< Echo Cancellation is disabled */ OMX_AUDIO_EchoCanNormal, /**< Echo Cancellation normal operation - echo from plastics and face */ OMX_AUDIO_EchoCanHFree, /**< Echo Cancellation optimized for Hands Free operation */ OMX_AUDIO_EchoCanCarKit, /**< Echo Cancellation optimized for Car Kit (longer echo) */ OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_AUDIO_EchoCanMax = 0x7FFFFFFF } OMX_AUDIO_ECHOCANTYPE; /** Enable / Disable for echo cancelation, which removes undesired echo's * from the audio * @ingroup effects */ typedef struct OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_AUDIO_ECHOCANTYPE eEchoCancelation; /**< Echo cancelation settings */ } OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE; /** Enable / Disable for noise reduction, which undesired noise from * the audio * @ingroup effects */ typedef struct OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BOOL bNoiseReduction; /**< Enable/disable for noise reduction */ } OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE; /** @} */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_Component.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_Component.h - OpenMax IL version 1.1.2 * The OMX_Component header file contains the definitions used to define * the public interface of a component. This header file is intended to * be used by both the application and the component. */ #ifndef OMX_Component_h #define OMX_Component_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header must include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include #include #include #include /** @ingroup comp */ typedef enum OMX_PORTDOMAINTYPE { OMX_PortDomainAudio, OMX_PortDomainVideo, OMX_PortDomainImage, OMX_PortDomainOther, OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_PortDomainMax = 0x7ffffff } OMX_PORTDOMAINTYPE; /** @ingroup comp */ typedef struct OMX_PARAM_PORTDEFINITIONTYPE { OMX_U32 nSize; /**< Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port number the structure applies to */ OMX_DIRTYPE eDir; /**< Direction (input or output) of this port */ OMX_U32 nBufferCountActual; /**< The actual number of buffers allocated on this port */ OMX_U32 nBufferCountMin; /**< The minimum number of buffers this port requires */ OMX_U32 nBufferSize; /**< Size, in bytes, for buffers to be used for this channel */ OMX_BOOL bEnabled; /**< Ports default to enabled and are enabled/disabled by OMX_CommandPortEnable/OMX_CommandPortDisable. When disabled a port is unpopulated. A disabled port is not populated with buffers on a transition to IDLE. */ OMX_BOOL bPopulated; /**< Port is populated with all of its buffers as indicated by nBufferCountActual. A disabled port is always unpopulated. An enabled port is populated on a transition to OMX_StateIdle and unpopulated on a transition to loaded. */ OMX_PORTDOMAINTYPE eDomain; /**< Domain of the port. Determines the contents of metadata below. */ union { OMX_AUDIO_PORTDEFINITIONTYPE audio; OMX_VIDEO_PORTDEFINITIONTYPE video; OMX_IMAGE_PORTDEFINITIONTYPE image; OMX_OTHER_PORTDEFINITIONTYPE other; } format; OMX_BOOL bBuffersContiguous; OMX_U32 nBufferAlignment; } OMX_PARAM_PORTDEFINITIONTYPE; /** @ingroup comp */ typedef struct OMX_PARAM_U32TYPE { OMX_U32 nSize; /**< Size of this structure, in Bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_U32 nU32; /**< U32 value */ } OMX_PARAM_U32TYPE; /** @ingroup rpm */ typedef enum OMX_SUSPENSIONPOLICYTYPE { OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */ OMX_SuspensionEnabled, /**< Suspension allowed */ OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_SuspensionPolicyMax = 0x7fffffff } OMX_SUSPENSIONPOLICYTYPE; /** @ingroup rpm */ typedef struct OMX_PARAM_SUSPENSIONPOLICYTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_SUSPENSIONPOLICYTYPE ePolicy; } OMX_PARAM_SUSPENSIONPOLICYTYPE; /** @ingroup rpm */ typedef enum OMX_SUSPENSIONTYPE { OMX_NotSuspended, /**< component is not suspended */ OMX_Suspended, /**< component is suspended */ OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_SuspendMax = 0x7FFFFFFF } OMX_SUSPENSIONTYPE; /** @ingroup rpm */ typedef struct OMX_PARAM_SUSPENSIONTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_SUSPENSIONTYPE eType; } OMX_PARAM_SUSPENSIONTYPE ; typedef struct OMX_CONFIG_BOOLEANTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_BOOL bEnabled; } OMX_CONFIG_BOOLEANTYPE; /* Parameter specifying the content uri to use. */ /** @ingroup cp */ typedef struct OMX_PARAM_CONTENTURITYPE { OMX_U32 nSize; /**< size of the structure in bytes, including actual URI name */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U8 contentURI[1]; /**< The URI name */ } OMX_PARAM_CONTENTURITYPE; /* Parameter specifying the pipe to use. */ /** @ingroup cp */ typedef struct OMX_PARAM_CONTENTPIPETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_HANDLETYPE hPipe; /**< The pipe handle*/ } OMX_PARAM_CONTENTPIPETYPE; /** @ingroup rpm */ typedef struct OMX_RESOURCECONCEALMENTTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_BOOL bResourceConcealmentForbidden; /**< disallow the use of resource concealment methods (like degrading algorithm quality to lower resource consumption or functional bypass) on a component as a resolution to resource conflicts. */ } OMX_RESOURCECONCEALMENTTYPE; /** @ingroup metadata */ typedef enum OMX_METADATACHARSETTYPE { OMX_MetadataCharsetUnknown = 0, OMX_MetadataCharsetASCII, OMX_MetadataCharsetBinary, OMX_MetadataCharsetCodePage1252, OMX_MetadataCharsetUTF8, OMX_MetadataCharsetJavaConformantUTF8, OMX_MetadataCharsetUTF7, OMX_MetadataCharsetImapUTF7, OMX_MetadataCharsetUTF16LE, OMX_MetadataCharsetUTF16BE, OMX_MetadataCharsetGB12345, OMX_MetadataCharsetHZGB2312, OMX_MetadataCharsetGB2312, OMX_MetadataCharsetGB18030, OMX_MetadataCharsetGBK, OMX_MetadataCharsetBig5, OMX_MetadataCharsetISO88591, OMX_MetadataCharsetISO88592, OMX_MetadataCharsetISO88593, OMX_MetadataCharsetISO88594, OMX_MetadataCharsetISO88595, OMX_MetadataCharsetISO88596, OMX_MetadataCharsetISO88597, OMX_MetadataCharsetISO88598, OMX_MetadataCharsetISO88599, OMX_MetadataCharsetISO885910, OMX_MetadataCharsetISO885913, OMX_MetadataCharsetISO885914, OMX_MetadataCharsetISO885915, OMX_MetadataCharsetShiftJIS, OMX_MetadataCharsetISO2022JP, OMX_MetadataCharsetISO2022JP1, OMX_MetadataCharsetISOEUCJP, OMX_MetadataCharsetSMS7Bit, OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_MetadataCharsetTypeMax= 0x7FFFFFFF } OMX_METADATACHARSETTYPE; /** @ingroup metadata */ typedef enum OMX_METADATASCOPETYPE { OMX_MetadataScopeAllLevels, OMX_MetadataScopeTopLevel, OMX_MetadataScopePortLevel, OMX_MetadataScopeNodeLevel, OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_MetadataScopeTypeMax = 0x7fffffff } OMX_METADATASCOPETYPE; /** @ingroup metadata */ typedef enum OMX_METADATASEARCHMODETYPE { OMX_MetadataSearchValueSizeByIndex, OMX_MetadataSearchItemByIndex, OMX_MetadataSearchNextItemByKey, OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_MetadataSearchTypeMax = 0x7fffffff } OMX_METADATASEARCHMODETYPE; /** @ingroup metadata */ typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_METADATASCOPETYPE eScopeMode; OMX_U32 nScopeSpecifier; OMX_U32 nMetadataItemCount; } OMX_CONFIG_METADATAITEMCOUNTTYPE; /** @ingroup metadata */ typedef struct OMX_CONFIG_METADATAITEMTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_METADATASCOPETYPE eScopeMode; OMX_U32 nScopeSpecifier; OMX_U32 nMetadataItemIndex; OMX_METADATASEARCHMODETYPE eSearchMode; OMX_METADATACHARSETTYPE eKeyCharset; OMX_U8 nKeySizeUsed; OMX_U8 nKey[128]; OMX_METADATACHARSETTYPE eValueCharset; OMX_STRING sLanguageCountry; OMX_U32 nValueMaxSize; OMX_U32 nValueSizeUsed; OMX_U8 nValue[1]; } OMX_CONFIG_METADATAITEMTYPE; /* @ingroup metadata */ typedef struct OMX_CONFIG_CONTAINERNODECOUNTTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_BOOL bAllKeys; OMX_U32 nParentNodeID; OMX_U32 nNumNodes; } OMX_CONFIG_CONTAINERNODECOUNTTYPE; /** @ingroup metadata */ typedef struct OMX_CONFIG_CONTAINERNODEIDTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_BOOL bAllKeys; OMX_U32 nParentNodeID; OMX_U32 nNodeIndex; OMX_U32 nNodeID; OMX_STRING cNodeName; OMX_BOOL bIsLeafType; } OMX_CONFIG_CONTAINERNODEIDTYPE; /** @ingroup metadata */ typedef struct OMX_PARAM_METADATAFILTERTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_BOOL bAllKeys; /* if true then this structure refers to all keys and * the three key fields below are ignored */ OMX_METADATACHARSETTYPE eKeyCharset; OMX_U32 nKeySizeUsed; OMX_U8 nKey [128]; OMX_U32 nLanguageCountrySizeUsed; OMX_U8 nLanguageCountry[128]; OMX_BOOL bEnabled; /* if true then key is part of filter (e.g. * retained for query later). If false then * key is not part of filter */ } OMX_PARAM_METADATAFILTERTYPE; /** The OMX_HANDLETYPE structure defines the component handle. The component * handle is used to access all of the component's public methods and also * contains pointers to the component's private data area. The component * handle is initialized by the OMX core (with help from the component) * during the process of loading the component. After the component is * successfully loaded, the application can safely access any of the * component's public functions (although some may return an error because * the state is inappropriate for the access). * * @ingroup comp */ typedef struct OMX_COMPONENTTYPE { /** The size of this structure, in bytes. It is the responsibility of the allocator of this structure to fill in this value. Since this structure is allocated by the GetHandle function, this function will fill in this value. */ OMX_U32 nSize; /** nVersion is the version of the OMX specification that the structure is built against. It is the responsibility of the creator of this structure to initialize this value and every user of this structure should verify that it knows how to use the exact version of this structure found herein. */ OMX_VERSIONTYPE nVersion; /** pComponentPrivate is a pointer to the component private data area. This member is allocated and initialized by the component when the component is first loaded. The application should not access this data area. */ OMX_PTR pComponentPrivate; /** pApplicationPrivate is a pointer that is a parameter to the OMX_GetHandle method, and contains an application private value provided by the IL client. This application private data is returned to the IL Client by OMX in all callbacks */ OMX_PTR pApplicationPrivate; /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL specification for details on the GetComponentVersion method. */ OMX_ERRORTYPE (*GetComponentVersion)( OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STRING pComponentName, OMX_OUT OMX_VERSIONTYPE* pComponentVersion, OMX_OUT OMX_VERSIONTYPE* pSpecVersion, OMX_OUT OMX_UUIDTYPE* pComponentUUID); /** refer to OMX_SendCommand in OMX_core.h or the OMX IL specification for details on the SendCommand method. */ OMX_ERRORTYPE (*SendCommand)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_COMMANDTYPE Cmd, OMX_IN OMX_U32 nParam1, OMX_IN OMX_PTR pCmdData); /** refer to OMX_GetParameter in OMX_core.h or the OMX IL specification for details on the GetParameter method. */ OMX_ERRORTYPE (*GetParameter)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure); /** refer to OMX_SetParameter in OMX_core.h or the OMX IL specification for details on the SetParameter method. */ OMX_ERRORTYPE (*SetParameter)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentParameterStructure); /** refer to OMX_GetConfig in OMX_core.h or the OMX IL specification for details on the GetConfig method. */ OMX_ERRORTYPE (*GetConfig)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_INOUT OMX_PTR pComponentConfigStructure); /** refer to OMX_SetConfig in OMX_core.h or the OMX IL specification for details on the SetConfig method. */ OMX_ERRORTYPE (*SetConfig)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentConfigStructure); /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL specification for details on the GetExtensionIndex method. */ OMX_ERRORTYPE (*GetExtensionIndex)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE* pIndexType); /** refer to OMX_GetState in OMX_core.h or the OMX IL specification for details on the GetState method. */ OMX_ERRORTYPE (*GetState)( OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE* pState); /** The ComponentTunnelRequest method will interact with another OMX component to determine if tunneling is possible and to setup the tunneling. The return codes for this method can be used to determine if tunneling is not possible, or if tunneling is not supported. Base profile components (i.e. non-interop) do not support this method and should return OMX_ErrorNotImplemented The interop profile component MUST support tunneling to another interop profile component with a compatible port parameters. A component may also support proprietary communication. If proprietary communication is supported the negotiation of proprietary communication is done outside of OMX in a vendor specific way. It is only required that the proper result be returned and the details of how the setup is done is left to the component implementation. When this method is invoked when nPort in an output port, the component will: 1. Populate the pTunnelSetup structure with the output port's requirements and constraints for the tunnel. When this method is invoked when nPort in an input port, the component will: 1. Query the necessary parameters from the output port to determine if the ports are compatible for tunneling 2. If the ports are compatible, the component should store the tunnel step provided by the output port 3. Determine which port (either input or output) is the buffer supplier, and call OMX_SetParameter on the output port to indicate this selection. The component will return from this call within 5 msec. @param [in] hComp Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle method. @param [in] nPort nPort is used to select the port on the component to be used for tunneling. @param [in] hTunneledComp Handle of the component to tunnel with. This is the component handle returned by the call to the OMX_GetHandle method. When this parameter is 0x0 the component should setup the port for communication with the application / IL Client. @param [in] nPortOutput nPortOutput is used indicate the port the component should tunnel with. @param [in] pTunnelSetup Pointer to the tunnel setup structure. When nPort is an output port the component should populate the fields of this structure. When When nPort is an input port the component should review the setup provided by the component with the output port. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup tun */ OMX_ERRORTYPE (*ComponentTunnelRequest)( OMX_IN OMX_HANDLETYPE hComp, OMX_IN OMX_U32 nPort, OMX_IN OMX_HANDLETYPE hTunneledComp, OMX_IN OMX_U32 nTunneledPort, OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup); /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL specification for details on the UseBuffer method. @ingroup buf */ OMX_ERRORTYPE (*UseBuffer)( OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes, OMX_IN OMX_U8* pBuffer); /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL specification for details on the AllocateBuffer method. @ingroup buf */ OMX_ERRORTYPE (*AllocateBuffer)( OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes); /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL specification for details on the FreeBuffer method. @ingroup buf */ OMX_ERRORTYPE (*FreeBuffer)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL specification for details on the EmptyThisBuffer method. @ingroup buf */ OMX_ERRORTYPE (*EmptyThisBuffer)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL specification for details on the FillThisBuffer method. @ingroup buf */ OMX_ERRORTYPE (*FillThisBuffer)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); /** The SetCallbacks method is used by the core to specify the callback structure from the application to the component. This is a blocking call. The component will return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the GetHandle function. @param [in] pCallbacks pointer to an OMX_CALLBACKTYPE structure used to provide the callback information to the component @param [in] pAppData pointer to an application defined value. It is anticipated that the application will pass a pointer to a data structure or a "this pointer" in this area to allow the callback (in the application) to determine the context of the call @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. */ OMX_ERRORTYPE (*SetCallbacks)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_CALLBACKTYPE* pCallbacks, OMX_IN OMX_PTR pAppData); /** ComponentDeInit method is used to deinitialize the component providing a means to free any resources allocated at component initialization. NOTE: After this call the component handle is not valid for further use. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the GetHandle function. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. */ OMX_ERRORTYPE (*ComponentDeInit)( OMX_IN OMX_HANDLETYPE hComponent); /** @ingroup buf */ OMX_ERRORTYPE (*UseEGLImage)( OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN void* eglImage); OMX_ERRORTYPE (*ComponentRoleEnum)( OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_U8 *cRole, OMX_IN OMX_U32 nIndex); } OMX_COMPONENTTYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_ContentPipe.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_ContentPipe.h - OpenMax IL version 1.1.2 * The OMX_ContentPipe header file contains the definitions used to define * the public interface for content piples. This header file is intended to * be used by the component. */ #ifndef OMX_CONTENTPIPE_H #define OMX_CONTENTPIPE_H #ifndef KD_EACCES /* OpenKODE error codes. CPResult values may be zero (indicating success or one of the following values) */ #define KD_EACCES (1) #define KD_EADDRINUSE (2) #define KD_EAGAIN (5) #define KD_EBADF (7) #define KD_EBUSY (8) #define KD_ECONNREFUSED (9) #define KD_ECONNRESET (10) #define KD_EDEADLK (11) #define KD_EDESTADDRREQ (12) #define KD_ERANGE (35) #define KD_EEXIST (13) #define KD_EFBIG (14) #define KD_EHOSTUNREACH (15) #define KD_EINVAL (17) #define KD_EIO (18) #define KD_EISCONN (20) #define KD_EISDIR (21) #define KD_EMFILE (22) #define KD_ENAMETOOLONG (23) #define KD_ENOENT (24) #define KD_ENOMEM (25) #define KD_ENOSPC (26) #define KD_ENOSYS (27) #define KD_ENOTCONN (28) #define KD_EPERM (33) #define KD_ETIMEDOUT (36) #define KD_EILSEQ (19) #endif /** Map types from OMX standard types only here so interface is as generic as possible. */ typedef OMX_U32 CPresult; typedef char * CPstring; typedef void * CPhandle; typedef OMX_U32 CPuint; typedef OMX_S32 CPint; typedef char CPbyte; typedef OMX_BOOL CPbool; /** enumeration of origin types used in the CP_PIPETYPE's Seek function * @ingroup cp */ typedef enum CP_ORIGINTYPE { CP_OriginBegin, CP_OriginCur, CP_OriginEnd, CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_OriginMax = 0X7FFFFFFF } CP_ORIGINTYPE; /** enumeration of contact access types used in the CP_PIPETYPE's Open function * @ingroup cp */ typedef enum CP_ACCESSTYPE { CP_AccessRead, CP_AccessWrite, CP_AccessReadWrite , CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_AccessMax = 0X7FFFFFFF } CP_ACCESSTYPE; /** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function * @ingroup cp */ typedef enum CP_CHECKBYTESRESULTTYPE { CP_CheckBytesOk, /**< There are at least the request number of bytes available */ CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes and presently lacks sufficient bytes. Client will be called when they are sufficient bytes are available. */ CP_CheckBytesInsufficientBytes , /**< The pipe has retrieved all bytes but those available are less than those requested */ CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream and no more bytes are available. */ CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */ CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_CheckBytesMax = 0X7FFFFFFF } CP_CHECKBYTESRESULTTYPE; /** enumeration of content pipe events sent to the client callback. * @ingroup cp */ typedef enum CP_EVENTTYPE{ CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/ CP_Overflow, /** enumeration of content pipe events sent to the client callback*/ CP_PipeDisconnected , /** enumeration of content pipe events sent to the client callback*/ CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_EventMax = 0X7FFFFFFF } CP_EVENTTYPE; /** content pipe definition * @ingroup cp */ typedef struct CP_PIPETYPE { /** Open a content stream for reading or writing. */ CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess ); /** Close a content stream. */ CPresult (*Close)( CPhandle hContent ); /** Create a content source and open it for writing. */ CPresult (*Create)( CPhandle *hContent, CPstring szURI ); /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/ CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult ); /** Seek to certain position in the content relative to the specified origin. */ CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin); /** Retrieve the current position relative to the start of the content. */ CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition); /** Retrieve data of the specified size from the content stream (advance content pointer by size of data). Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */ CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also returns the size of the block actually read. Content pointer advances the by the returned size. Note: pipe provides pointer. This function is appropriate for large reads. The client must call ReleaseReadBuffer when done with buffer. In some cases the requested block may not reside in contiguous memory within the pipe implementation. For instance if the pipe leverages a circular buffer then the requested block may straddle the boundary of the circular buffer. By default a pipe implementation performs a copy in this case to provide the block to the pipe client in one contiguous buffer. If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory boundary. Here the client may retrieve the data in segments over successive calls. */ CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy); /** Release a buffer obtained by ReadBuffer back to the pipe. */ CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer); /** Write data of the specified size to the content (advance content pointer by size of data). Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */ CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); /** Retrieve a buffer allocated by the pipe used to write data to the content. Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/ CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize); /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the the contents of the buffer to content and advance content pointer by the size of the buffer */ CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize); /** Register a per-handle client callback with the content pipe. */ CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam)); } CP_PIPETYPE; #endif ================================================ FILE: phonelibs/openmax/include/OMX_Core.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_Core.h - OpenMax IL version 1.1.2 * The OMX_Core header file contains the definitions used by both the * application and the component to access common items. */ #ifndef OMX_Core_h #define OMX_Core_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header shall include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** The OMX_COMMANDTYPE enumeration is used to specify the action in the * OMX_SendCommand macro. * @ingroup core */ typedef enum OMX_COMMANDTYPE { OMX_CommandStateSet, /**< Change the component state */ OMX_CommandFlush, /**< Flush the data queue(s) of a component */ OMX_CommandPortDisable, /**< Disable a port on a component. */ OMX_CommandPortEnable, /**< Enable a port on a component. */ OMX_CommandMarkBuffer, /**< Mark a component/buffer for observation */ OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_CommandMax = 0X7FFFFFFF } OMX_COMMANDTYPE; /** The OMX_STATETYPE enumeration is used to indicate or change the component * state. This enumeration reflects the current state of the component when * used with the OMX_GetState macro or becomes the parameter in a state change * command when used with the OMX_SendCommand macro. * * The component will be in the Loaded state after the component is initially * loaded into memory. In the Loaded state, the component is not allowed to * allocate or hold resources other than to build it's internal parameter * and configuration tables. The application will send one or more * SetParameters/GetParameters and SetConfig/GetConfig commands to the * component and the component will record each of these parameter and * configuration changes for use later. When the application sends the * Idle command, the component will acquire the resources needed for the * specified configuration and will transition to the idle state if the * allocation is successful. If the component cannot successfully * transition to the idle state for any reason, the state of the component * shall be fully rolled back to the Loaded state (e.g. all allocated * resources shall be released). When the component receives the command * to go to the Executing state, it shall begin processing buffers by * sending all input buffers it holds to the application. While * the component is in the Idle state, the application may also send the * Pause command. If the component receives the pause command while in the * Idle state, the component shall send all input buffers it holds to the * application, but shall not begin processing buffers. This will allow the * application to prefill buffers. * * @ingroup comp */ typedef enum OMX_STATETYPE { OMX_StateInvalid, /**< component has detected that it's internal data structures are corrupted to the point that it cannot determine it's state properly */ OMX_StateLoaded, /**< component has been loaded but has not completed initialization. The OMX_SetParameter macro and the OMX_GetParameter macro are the only valid macros allowed to be sent to the component in this state. */ OMX_StateIdle, /**< component initialization has been completed successfully and the component is ready to to start. */ OMX_StateExecuting, /**< component has accepted the start command and is processing data (if data is available) */ OMX_StatePause, /**< component has received pause command */ OMX_StateWaitForResources, /**< component is waiting for resources, either after preemption or before it gets the resources requested. See specification for complete details. */ OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_StateMax = 0X7FFFFFFF } OMX_STATETYPE; /** The OMX_ERRORTYPE enumeration defines the standard OMX Errors. These * errors should cover most of the common failure cases. However, * vendors are free to add additional error messages of their own as * long as they follow these rules: * 1. Vendor error messages shall be in the range of 0x90000000 to * 0x9000FFFF. * 2. Vendor error messages shall be defined in a header file provided * with the component. No error messages are allowed that are * not defined. */ typedef enum OMX_ERRORTYPE { OMX_ErrorNone = 0, /** There were insufficient resources to perform the requested operation */ OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000, /** There was an error, but the cause of the error could not be determined */ OMX_ErrorUndefined = (OMX_S32) 0x80001001, /** The component name string was not valid */ OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002, /** No component with the specified name string was found */ OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003, /** The component specified did not have a "OMX_ComponentInit" or "OMX_ComponentDeInit entry point */ OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004, /** One or more parameters were not valid */ OMX_ErrorBadParameter = (OMX_S32) 0x80001005, /** The requested function is not implemented */ OMX_ErrorNotImplemented = (OMX_S32) 0x80001006, /** The buffer was emptied before the next buffer was ready */ OMX_ErrorUnderflow = (OMX_S32) 0x80001007, /** The buffer was not available when it was needed */ OMX_ErrorOverflow = (OMX_S32) 0x80001008, /** The hardware failed to respond as expected */ OMX_ErrorHardware = (OMX_S32) 0x80001009, /** The component is in the state OMX_StateInvalid */ OMX_ErrorInvalidState = (OMX_S32) 0x8000100A, /** Stream is found to be corrupt */ OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B, /** Ports being connected are not compatible */ OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C, /** Resources allocated to an idle component have been lost resulting in the component returning to the loaded state */ OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D, /** No more indicies can be enumerated */ OMX_ErrorNoMore = (OMX_S32) 0x8000100E, /** The component detected a version mismatch */ OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F, /** The component is not ready to return data at this time */ OMX_ErrorNotReady = (OMX_S32) 0x80001010, /** There was a timeout that occurred */ OMX_ErrorTimeout = (OMX_S32) 0x80001011, /** This error occurs when trying to transition into the state you are already in */ OMX_ErrorSameState = (OMX_S32) 0x80001012, /** Resources allocated to an executing or paused component have been preempted, causing the component to return to the idle state */ OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, /** A non-supplier port sends this error to the IL client (via the EventHandler callback) during the allocation of buffers (on a transition from the LOADED to the IDLE state or on a port restart) when it deems that it has waited an unusually long time for the supplier to send it an allocated buffer via a UseBuffer call. */ OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014, /** A non-supplier port sends this error to the IL client (via the EventHandler callback) during the deallocation of buffers (on a transition from the IDLE to LOADED state or on a port stop) when it deems that it has waited an unusually long time for the supplier to request the deallocation of a buffer header via a FreeBuffer call. */ OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015, /** A supplier port sends this error to the IL client (via the EventHandler callback) during the stopping of a port (either on a transition from the IDLE to LOADED state or a port stop) when it deems that it has waited an unusually long time for the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */ OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016, /** Attempting a state transtion that is not allowed */ OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017, /* Attempting a command that is not allowed during the present state. */ OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, /** The values encapsulated in the parameter or config structure are not supported. */ OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019, /** The parameter or config indicated by the given index is not supported. */ OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A, /** The port index supplied is incorrect. */ OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B, /** The port has lost one or more of its buffers and it thus unpopulated. */ OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C, /** Component suspended due to temporary loss of resources */ OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D, /** Component suspended due to an inability to acquire dynamic resources */ OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E, /** When the macroblock error reporting is enabled the component returns new error for every frame that has errors */ OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F, /** A component reports this error when it cannot parse or determine the format of an input stream. */ OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, /** The content open operation failed. */ OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021, /** The content creation operation failed. */ OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022, /** Separate table information is being used */ OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023, /** Tunneling is unsupported by the component*/ OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024, OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */ OMX_ErrorMax = 0x7FFFFFFF } OMX_ERRORTYPE; /** @ingroup core */ typedef OMX_ERRORTYPE (* OMX_COMPONENTINITTYPE)(OMX_IN OMX_HANDLETYPE hComponent); /** @ingroup core */ typedef struct OMX_COMPONENTREGISTERTYPE { const char * pName; /* Component name, 128 byte limit (including '\0') applies */ OMX_COMPONENTINITTYPE pInitialize; /* Component instance initialization function */ } OMX_COMPONENTREGISTERTYPE; /** @ingroup core */ extern OMX_COMPONENTREGISTERTYPE OMX_ComponentRegistered[]; /** @ingroup rpm */ typedef struct OMX_PRIORITYMGMTTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nGroupPriority; /**< Priority of the component group */ OMX_U32 nGroupID; /**< ID of the component group */ } OMX_PRIORITYMGMTTYPE; /* Component name and Role names are limited to 128 characters including the terminating '\0'. */ #define OMX_MAX_STRINGNAME_SIZE 128 /** @ingroup comp */ typedef struct OMX_PARAM_COMPONENTROLETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE]; /**< name of standard component which defines component role */ } OMX_PARAM_COMPONENTROLETYPE; /** End of Stream Buffer Flag: * * A component sets EOS when it has no more data to emit on a particular * output port. Thus an output port shall set EOS on the last buffer it * emits. A component's determination of when an output port should * cease sending data is implemenation specific. * @ingroup buf */ #define OMX_BUFFERFLAG_EOS 0x00000001 /** Start Time Buffer Flag: * * The source of a stream (e.g. a demux component) sets the STARTTIME * flag on the buffer that contains the starting timestamp for the * stream. The starting timestamp corresponds to the first data that * should be displayed at startup or after a seek. * The first timestamp of the stream is not necessarily the start time. * For instance, in the case of a seek to a particular video frame, * the target frame may be an interframe. Thus the first buffer of * the stream will be the intra-frame preceding the target frame and * the starttime will occur with the target frame (with any other * required frames required to reconstruct the target intervening). * * The STARTTIME flag is directly associated with the buffer's * timestamp ' thus its association to buffer data and its * propagation is identical to the timestamp's. * * When a Sync Component client receives a buffer with the * STARTTIME flag it shall perform a SetConfig on its sync port * using OMX_ConfigTimeClientStartTime and passing the buffer's * timestamp. * * @ingroup buf */ #define OMX_BUFFERFLAG_STARTTIME 0x00000002 /** Decode Only Buffer Flag: * * The source of a stream (e.g. a demux component) sets the DECODEONLY * flag on any buffer that should shall be decoded but should not be * displayed. This flag is used, for instance, when a source seeks to * a target interframe that requires the decode of frames preceding the * target to facilitate the target's reconstruction. In this case the * source would emit the frames preceding the target downstream * but mark them as decode only. * * The DECODEONLY is associated with buffer data and propagated in a * manner identical to the buffer timestamp. * * A component that renders data should ignore all buffers with * the DECODEONLY flag set. * * @ingroup buf */ #define OMX_BUFFERFLAG_DECODEONLY 0x00000004 /* Data Corrupt Flag: This flag is set when the IL client believes the data in the associated buffer is corrupt * @ingroup buf */ #define OMX_BUFFERFLAG_DATACORRUPT 0x00000008 /* End of Frame: The buffer contains exactly one end of frame and no data * occurs after the end of frame. This flag is an optional hint. The absence * of this flag does not imply the absence of an end of frame within the buffer. * @ingroup buf */ #define OMX_BUFFERFLAG_ENDOFFRAME 0x00000010 /* Sync Frame Flag: This flag is set when the buffer content contains a coded sync frame ' * a frame that has no dependency on any other frame information * @ingroup buf */ #define OMX_BUFFERFLAG_SYNCFRAME 0x00000020 /* Extra data present flag: there is extra data appended to the data stream * residing in the buffer * @ingroup buf */ #define OMX_BUFFERFLAG_EXTRADATA 0x00000040 /** Codec Config Buffer Flag: * OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an * output port when all bytes in the buffer form part or all of a set of * codec specific configuration data. Examples include SPS/PPS nal units * for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for * OMX_AUDIO_CodingAAC. Any component that for a given stream sets * OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes * with frame data in the same buffer, and shall send all buffers * containing codec configuration bytes before any buffers containing * frame data that those configurations bytes describe. * If the stream format for a particular codec has a frame specific * header at the start of each frame, for example OMX_AUDIO_CodingMP3 or * OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as * normal without setting OMX_BUFFERFLAG_CODECCONFIG. * @ingroup buf */ #define OMX_BUFFERFLAG_CODECCONFIG 0x00000080 /* * OMX_BUFFERFLAG_READONLY: This flag is set when a component emitting the * buffer on an output port or the IL client wishes to identify the buffer * payload contents to be read-only. An IL client or an input port * shall not alter the contents of the buffer. This flag shall only be * cleared by the originator of the buffer when the buffer is returned. * For tunneled ports, the usage of this flag shall be allowed only if the * components negotiated a read-only tunnel */ #define OMX_BUFFERFLAG_READONLY 0x00000200 /** @ingroup buf */ typedef struct OMX_BUFFERHEADERTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U8* pBuffer; /**< Pointer to actual block of memory that is acting as the buffer */ OMX_U32 nAllocLen; /**< size of the buffer allocated, in bytes */ OMX_U32 nFilledLen; /**< number of bytes currently in the buffer */ OMX_U32 nOffset; /**< start offset of valid data in bytes from the start of the buffer */ OMX_PTR pAppPrivate; /**< pointer to any data the application wants to associate with this buffer */ OMX_PTR pPlatformPrivate; /**< pointer to any data the platform wants to associate with this buffer */ OMX_PTR pInputPortPrivate; /**< pointer to any data the input port wants to associate with this buffer */ OMX_PTR pOutputPortPrivate; /**< pointer to any data the output port wants to associate with this buffer */ OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a mark event upon processing this buffer. */ OMX_PTR pMarkData; /**< Application specific data associated with the mark sent on a mark event to disambiguate this mark from others. */ OMX_U32 nTickCount; /**< Optional entry that the component and application can update with a tick count when they access the component. This value should be in microseconds. Since this is a value relative to an arbitrary starting point, this value cannot be used to determine absolute time. This is an optional entry and not all components will update it.*/ OMX_TICKS nTimeStamp; /**< Timestamp corresponding to the sample starting at the first logical sample boundary in the buffer. Timestamps of successive samples within the buffer may be inferred by adding the duration of the of the preceding buffer to the timestamp of the preceding buffer.*/ OMX_U32 nFlags; /**< buffer specific flags */ OMX_U32 nOutputPortIndex; /**< The index of the output port (if any) using this buffer */ OMX_U32 nInputPortIndex; /**< The index of the input port (if any) using this buffer */ } OMX_BUFFERHEADERTYPE; /** The OMX_EXTRADATATYPE enumeration is used to define the * possible extra data payload types. * NB: this enum is binary backwards compatible with the previous * OMX_EXTRADATA_QUANT define. This should be replaced with * OMX_ExtraDataQuantization. */ typedef enum OMX_EXTRADATATYPE { OMX_ExtraDataNone = 0, /**< Indicates that no more extra data sections follow */ OMX_ExtraDataQuantization, /**< The data payload contains quantization data */ OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_ExtraDataMax = 0x7FFFFFFF } OMX_EXTRADATATYPE; typedef struct OMX_OTHER_EXTRADATATYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_EXTRADATATYPE eType; /* Extra Data type */ OMX_U32 nDataSize; /* Size of the supporting data to follow */ OMX_U8 data[1]; /* Supporting data hint */ } OMX_OTHER_EXTRADATATYPE; /** @ingroup comp */ typedef struct OMX_PORT_PARAM_TYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPorts; /**< The number of ports for this component */ OMX_U32 nStartPortNumber; /** first port number for this type of port */ } OMX_PORT_PARAM_TYPE; /** @ingroup comp */ typedef enum OMX_EVENTTYPE { OMX_EventCmdComplete, /**< component has sucessfully completed a command */ OMX_EventError, /**< component has detected an error condition */ OMX_EventMark, /**< component has detected a buffer mark */ OMX_EventPortSettingsChanged, /**< component is reported a port settings change */ OMX_EventBufferFlag, /**< component has detected an EOS */ OMX_EventResourcesAcquired, /**< component has been granted resources and is automatically starting the state change from OMX_StateWaitForResources to OMX_StateIdle. */ OMX_EventComponentResumed, /**< Component resumed due to reacquisition of resources */ OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */ OMX_EventPortFormatDetected, /**< Component has detected a supported format. */ OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_EventMax = 0x7FFFFFFF } OMX_EVENTTYPE; typedef struct OMX_CALLBACKTYPE { /** The EventHandler method is used to notify the application when an event of interest occurs. Events are defined in the OMX_EVENTTYPE enumeration. Please see that enumeration for details of what will be returned for each type of event. Callbacks should not return an error to the component, so if an error occurs, the application shall handle it internally. This is a blocking call. The application should return from this call within 5 msec to avoid blocking the component for an excessively long period of time. @param hComponent handle of the component to access. This is the component handle returned by the call to the GetHandle function. @param pAppData pointer to an application defined value that was provided in the pAppData parameter to the OMX_GetHandle method for the component. This application defined value is provided so that the application can have a component specific context when receiving the callback. @param eEvent Event that the component wants to notify the application about. @param nData1 nData will be the OMX_ERRORTYPE for an error event and will be an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event. @param nData2 nData2 will hold further information related to the event. Can be OMX_STATETYPE for a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event. Default value is 0 if not used. ) @param pEventData Pointer to additional event-specific data (see spec for meaning). */ OMX_ERRORTYPE (*EventHandler)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData); /** The EmptyBufferDone method is used to return emptied buffers from an input port back to the application for reuse. This is a blocking call so the application should not attempt to refill the buffers during this call, but should queue them and refill them in another thread. There is no error return, so the application shall handle any errors generated internally. The application should return from this call within 5 msec. @param hComponent handle of the component to access. This is the component handle returned by the call to the GetHandle function. @param pAppData pointer to an application defined value that was provided in the pAppData parameter to the OMX_GetHandle method for the component. This application defined value is provided so that the application can have a component specific context when receiving the callback. @param pBuffer pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer or AllocateBuffer indicating the buffer that was emptied. @ingroup buf */ OMX_ERRORTYPE (*EmptyBufferDone)( OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer); /** The FillBufferDone method is used to return filled buffers from an output port back to the application for emptying and then reuse. This is a blocking call so the application should not attempt to empty the buffers during this call, but should queue the buffers and empty them in another thread. There is no error return, so the application shall handle any errors generated internally. The application shall also update the buffer header to indicate the number of bytes placed into the buffer. The application should return from this call within 5 msec. @param hComponent handle of the component to access. This is the component handle returned by the call to the GetHandle function. @param pAppData pointer to an application defined value that was provided in the pAppData parameter to the OMX_GetHandle method for the component. This application defined value is provided so that the application can have a component specific context when receiving the callback. @param pBuffer pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer or AllocateBuffer indicating the buffer that was filled. @ingroup buf */ OMX_ERRORTYPE (*FillBufferDone)( OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer); } OMX_CALLBACKTYPE; /** The OMX_BUFFERSUPPLIERTYPE enumeration is used to dictate port supplier preference when tunneling between two ports. @ingroup tun buf */ typedef enum OMX_BUFFERSUPPLIERTYPE { OMX_BufferSupplyUnspecified = 0x0, /**< port supplying the buffers is unspecified, or don't care */ OMX_BufferSupplyInput, /**< input port supplies the buffers */ OMX_BufferSupplyOutput, /**< output port supplies the buffers */ OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_BufferSupplyMax = 0x7FFFFFFF } OMX_BUFFERSUPPLIERTYPE; /** buffer supplier parameter * @ingroup tun */ typedef struct OMX_PARAM_BUFFERSUPPLIERTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_BUFFERSUPPLIERTYPE eBufferSupplier; /**< buffer supplier */ } OMX_PARAM_BUFFERSUPPLIERTYPE; /**< indicates that buffers received by an input port of a tunnel may not modify the data in the buffers @ingroup tun */ #define OMX_PORTTUNNELFLAG_READONLY 0x00000001 /** The OMX_TUNNELSETUPTYPE structure is used to pass data from an output port to an input port as part the two ComponentTunnelRequest calls resulting from a OMX_SetupTunnel call from the IL Client. @ingroup tun */ typedef struct OMX_TUNNELSETUPTYPE { OMX_U32 nTunnelFlags; /**< bit flags for tunneling */ OMX_BUFFERSUPPLIERTYPE eSupplier; /**< supplier preference */ } OMX_TUNNELSETUPTYPE; /* OMX Component headers is included to enable the core to use macros for functions into the component for OMX release 1.0. Developers should not access any structures or data from within the component header directly */ /* TO BE REMOVED - #include */ /** GetComponentVersion will return information about the component. This is a blocking call. This macro will go directly from the application to the component (via a core macro). The component will return from this call within 5 msec. @param [in] hComponent handle of component to execute the command @param [out] pComponentName pointer to an empty string of length 128 bytes. The component will write its name into this string. The name will be terminated by a single zero byte. The name of a component will be 127 bytes or less to leave room for the trailing zero byte. An example of a valid component name is "OMX.ABC.ChannelMixer\0". @param [out] pComponentVersion pointer to an OMX Version structure that the component will fill in. The component will fill in a value that indicates the component version. NOTE: the component version is NOT the same as the OMX Specification version (found in all structures). The component version is defined by the vendor of the component and its value is entirely up to the component vendor. @param [out] pSpecVersion pointer to an OMX Version structure that the component will fill in. The SpecVersion is the version of the specification that the component was built against. Please note that this value may or may not match the structure's version. For example, if the component was built against the 2.0 specification, but the application (which creates the structure is built against the 1.0 specification the versions would be different. @param [out] pComponentUUID pointer to the UUID of the component which will be filled in by the component. The UUID is a unique identifier that is set at RUN time for the component and is unique to each instantion of the component. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_GetComponentVersion( \ hComponent, \ pComponentName, \ pComponentVersion, \ pSpecVersion, \ pComponentUUID) \ ((OMX_COMPONENTTYPE*)hComponent)->GetComponentVersion( \ hComponent, \ pComponentName, \ pComponentVersion, \ pSpecVersion, \ pComponentUUID) /* Macro End */ /** Send a command to the component. This call is a non-blocking call. The component should check the parameters and then queue the command to the component thread to be executed. The component thread shall send the EventHandler() callback at the conclusion of the command. This macro will go directly from the application to the component (via a core macro). The component will return from this call within 5 msec. When the command is "OMX_CommandStateSet" the component will queue a state transition to the new state idenfied in nParam. When the command is "OMX_CommandFlush", to flush a port's buffer queues, the command will force the component to return all buffers NOT CURRENTLY BEING PROCESSED to the application, in the order in which the buffers were received. When the command is "OMX_CommandPortDisable" or "OMX_CommandPortEnable", the component's port (given by the value of nParam) will be stopped or restarted. When the command "OMX_CommandMarkBuffer" is used to mark a buffer, the pCmdData will point to a OMX_MARKTYPE structure containing the component handle of the component to examine the buffer chain for the mark. nParam1 contains the index of the port on which the buffer mark is applied. Specification text for more details. @param [in] hComponent handle of component to execute the command @param [in] Cmd Command for the component to execute @param [in] nParam Parameter for the command to be executed. When Cmd has the value OMX_CommandStateSet, value is a member of OMX_STATETYPE. When Cmd has the value OMX_CommandFlush, value of nParam indicates which port(s) to flush. -1 is used to flush all ports a single port index will only flush that port. When Cmd has the value "OMX_CommandPortDisable" or "OMX_CommandPortEnable", the component's port is given by the value of nParam. When Cmd has the value "OMX_CommandMarkBuffer" the components pot is given by the value of nParam. @param [in] pCmdData Parameter pointing to the OMX_MARKTYPE structure when Cmd has the value "OMX_CommandMarkBuffer". @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_SendCommand( \ hComponent, \ Cmd, \ nParam, \ pCmdData) \ ((OMX_COMPONENTTYPE*)hComponent)->SendCommand( \ hComponent, \ Cmd, \ nParam, \ pCmdData) /* Macro End */ /** The OMX_GetParameter macro will get one of the current parameter settings from the component. This macro cannot only be invoked when the component is in the OMX_StateInvalid state. The nParamIndex parameter is used to indicate which structure is being requested from the component. The application shall allocate the correct structure and shall fill in the structure size and version information before invoking this macro. When the parameter applies to a port, the caller shall fill in the appropriate nPortIndex value indicating the port on which the parameter applies. If the component has not had any settings changed, then the component should return a set of valid DEFAULT parameters for the component. This is a blocking call. The component should return from this call within 20 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] nParamIndex Index of the structure to be filled. This value is from the OMX_INDEXTYPE enumeration. @param [in,out] pComponentParameterStructure Pointer to application allocated structure to be filled by the component. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_GetParameter( \ hComponent, \ nParamIndex, \ pComponentParameterStructure) \ ((OMX_COMPONENTTYPE*)hComponent)->GetParameter( \ hComponent, \ nParamIndex, \ pComponentParameterStructure) /* Macro End */ /** The OMX_SetParameter macro will send an initialization parameter structure to a component. Each structure shall be sent one at a time, in a separate invocation of the macro. This macro can only be invoked when the component is in the OMX_StateLoaded state, or the port is disabled (when the parameter applies to a port). The nParamIndex parameter is used to indicate which structure is being passed to the component. The application shall allocate the correct structure and shall fill in the structure size and version information (as well as the actual data) before invoking this macro. The application is free to dispose of this structure after the call as the component is required to copy any data it shall retain. This is a blocking call. The component should return from this call within 20 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] nIndex Index of the structure to be sent. This value is from the OMX_INDEXTYPE enumeration. @param [in] pComponentParameterStructure pointer to application allocated structure to be used for initialization by the component. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_SetParameter( \ hComponent, \ nParamIndex, \ pComponentParameterStructure) \ ((OMX_COMPONENTTYPE*)hComponent)->SetParameter( \ hComponent, \ nParamIndex, \ pComponentParameterStructure) /* Macro End */ /** The OMX_GetConfig macro will get one of the configuration structures from a component. This macro can be invoked anytime after the component has been loaded. The nParamIndex call parameter is used to indicate which structure is being requested from the component. The application shall allocate the correct structure and shall fill in the structure size and version information before invoking this macro. If the component has not had this configuration parameter sent before, then the component should return a set of valid DEFAULT values for the component. This is a blocking call. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] nIndex Index of the structure to be filled. This value is from the OMX_INDEXTYPE enumeration. @param [in,out] pComponentConfigStructure pointer to application allocated structure to be filled by the component. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_GetConfig( \ hComponent, \ nConfigIndex, \ pComponentConfigStructure) \ ((OMX_COMPONENTTYPE*)hComponent)->GetConfig( \ hComponent, \ nConfigIndex, \ pComponentConfigStructure) /* Macro End */ /** The OMX_SetConfig macro will send one of the configuration structures to a component. Each structure shall be sent one at a time, each in a separate invocation of the macro. This macro can be invoked anytime after the component has been loaded. The application shall allocate the correct structure and shall fill in the structure size and version information (as well as the actual data) before invoking this macro. The application is free to dispose of this structure after the call as the component is required to copy any data it shall retain. This is a blocking call. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] nConfigIndex Index of the structure to be sent. This value is from the OMX_INDEXTYPE enumeration above. @param [in] pComponentConfigStructure pointer to application allocated structure to be used for initialization by the component. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_SetConfig( \ hComponent, \ nConfigIndex, \ pComponentConfigStructure) \ ((OMX_COMPONENTTYPE*)hComponent)->SetConfig( \ hComponent, \ nConfigIndex, \ pComponentConfigStructure) /* Macro End */ /** The OMX_GetExtensionIndex macro will invoke a component to translate a vendor specific configuration or parameter string into an OMX structure index. There is no requirement for the vendor to support this command for the indexes already found in the OMX_INDEXTYPE enumeration (this is done to save space in small components). The component shall support all vendor supplied extension indexes not found in the master OMX_INDEXTYPE enumeration. This is a blocking call. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the GetHandle function. @param [in] cParameterName OMX_STRING that shall be less than 128 characters long including the trailing null byte. This is the string that will get translated by the component into a configuration index. @param [out] pIndexType a pointer to a OMX_INDEXTYPE to receive the index value. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_GetExtensionIndex( \ hComponent, \ cParameterName, \ pIndexType) \ ((OMX_COMPONENTTYPE*)hComponent)->GetExtensionIndex( \ hComponent, \ cParameterName, \ pIndexType) /* Macro End */ /** The OMX_GetState macro will invoke the component to get the current state of the component and place the state value into the location pointed to by pState. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [out] pState pointer to the location to receive the state. The value returned is one of the OMX_STATETYPE members @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp */ #define OMX_GetState( \ hComponent, \ pState) \ ((OMX_COMPONENTTYPE*)hComponent)->GetState( \ hComponent, \ pState) /* Macro End */ /** The OMX_UseBuffer macro will request that the component use a buffer (and allocate its own buffer header) already allocated by another component, or by the IL Client. This is a blocking call. The component should return from this call within 20 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [out] ppBuffer pointer to an OMX_BUFFERHEADERTYPE structure used to receive the pointer to the buffer header @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp buf */ #define OMX_UseBuffer( \ hComponent, \ ppBufferHdr, \ nPortIndex, \ pAppPrivate, \ nSizeBytes, \ pBuffer) \ ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer( \ hComponent, \ ppBufferHdr, \ nPortIndex, \ pAppPrivate, \ nSizeBytes, \ pBuffer) /** The OMX_AllocateBuffer macro will request that the component allocate a new buffer and buffer header. The component will allocate the buffer and the buffer header and return a pointer to the buffer header. This is a blocking call. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [out] ppBuffer pointer to an OMX_BUFFERHEADERTYPE structure used to receive the pointer to the buffer header @param [in] nPortIndex nPortIndex is used to select the port on the component the buffer will be used with. The port can be found by using the nPortIndex value as an index into the Port Definition array of the component. @param [in] pAppPrivate pAppPrivate is used to initialize the pAppPrivate member of the buffer header structure. @param [in] nSizeBytes size of the buffer to allocate. Used when bAllocateNew is true. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp buf */ #define OMX_AllocateBuffer( \ hComponent, \ ppBuffer, \ nPortIndex, \ pAppPrivate, \ nSizeBytes) \ ((OMX_COMPONENTTYPE*)hComponent)->AllocateBuffer( \ hComponent, \ ppBuffer, \ nPortIndex, \ pAppPrivate, \ nSizeBytes) /* Macro End */ /** The OMX_FreeBuffer macro will release a buffer header from the component which was allocated using either OMX_AllocateBuffer or OMX_UseBuffer. If the component allocated the buffer (see the OMX_UseBuffer macro) then the component shall free the buffer and buffer header. This is a blocking call. The component should return from this call within 20 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] nPortIndex nPortIndex is used to select the port on the component the buffer will be used with. @param [in] pBuffer pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer or AllocateBuffer. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp buf */ #define OMX_FreeBuffer( \ hComponent, \ nPortIndex, \ pBuffer) \ ((OMX_COMPONENTTYPE*)hComponent)->FreeBuffer( \ hComponent, \ nPortIndex, \ pBuffer) /* Macro End */ /** The OMX_EmptyThisBuffer macro will send a buffer full of data to an input port of a component. The buffer will be emptied by the component and returned to the application via the EmptyBufferDone call back. This is a non-blocking call in that the component will record the buffer and return immediately and then empty the buffer, later, at the proper time. As expected, this macro may be invoked only while the component is in the OMX_StateExecuting. If nPortIndex does not specify an input port, the component shall return an error. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] pBuffer pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer or AllocateBuffer. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp buf */ #define OMX_EmptyThisBuffer( \ hComponent, \ pBuffer) \ ((OMX_COMPONENTTYPE*)hComponent)->EmptyThisBuffer( \ hComponent, \ pBuffer) /* Macro End */ /** The OMX_FillThisBuffer macro will send an empty buffer to an output port of a component. The buffer will be filled by the component and returned to the application via the FillBufferDone call back. This is a non-blocking call in that the component will record the buffer and return immediately and then fill the buffer, later, at the proper time. As expected, this macro may be invoked only while the component is in the OMX_ExecutingState. If nPortIndex does not specify an output port, the component shall return an error. The component should return from this call within 5 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [in] pBuffer pointer to an OMX_BUFFERHEADERTYPE structure allocated with UseBuffer or AllocateBuffer. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp buf */ #define OMX_FillThisBuffer( \ hComponent, \ pBuffer) \ ((OMX_COMPONENTTYPE*)hComponent)->FillThisBuffer( \ hComponent, \ pBuffer) /* Macro End */ /** The OMX_UseEGLImage macro will request that the component use a EGLImage provided by EGL (and allocate its own buffer header) This is a blocking call. The component should return from this call within 20 msec. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the OMX_GetHandle function. @param [out] ppBuffer pointer to an OMX_BUFFERHEADERTYPE structure used to receive the pointer to the buffer header. Note that the memory location used for this buffer is NOT visible to the IL Client. @param [in] nPortIndex nPortIndex is used to select the port on the component the buffer will be used with. The port can be found by using the nPortIndex value as an index into the Port Definition array of the component. @param [in] pAppPrivate pAppPrivate is used to initialize the pAppPrivate member of the buffer header structure. @param [in] eglImage eglImage contains the handle of the EGLImage to use as a buffer on the specified port. The component is expected to validate properties of the EGLImage against the configuration of the port to ensure the component can use the EGLImage as a buffer. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup comp buf */ #define OMX_UseEGLImage( \ hComponent, \ ppBufferHdr, \ nPortIndex, \ pAppPrivate, \ eglImage) \ ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage( \ hComponent, \ ppBufferHdr, \ nPortIndex, \ pAppPrivate, \ eglImage) /** The OMX_Init method is used to initialize the OMX core. It shall be the first call made into OMX and it should only be executed one time without an interviening OMX_Deinit call. The core should return from this call within 20 msec. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void); /** The OMX_Deinit method is used to deinitialize the OMX core. It shall be the last call made into OMX. In the event that the core determines that thare are components loaded when this call is made, the core may return with an error rather than try to unload the components. The core should return from this call within 20 msec. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void); /** The OMX_ComponentNameEnum method will enumerate through all the names of recognised valid components in the system. This function is provided as a means to detect all the components in the system run-time. There is no strict ordering to the enumeration order of component names, although each name will only be enumerated once. If the OMX core supports run-time installation of new components, it is only requried to detect newly installed components when the first call to enumerate component names is made (i.e. when nIndex is 0x0). The core should return from this call in 20 msec. @param [out] cComponentName pointer to a null terminated string with the component name. The names of the components are strings less than 127 bytes in length plus the trailing null for a maximum size of 128 bytes. An example of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are assigned by the vendor, but shall start with "OMX." and then have the Vendor designation next. @param [in] nNameLength number of characters in the cComponentName string. With all component name strings restricted to less than 128 characters (including the trailing null) it is recomended that the caller provide a input string for the cComponentName of 128 characters. @param [in] nIndex number containing the enumeration index for the component. Multiple calls to OMX_ComponentNameEnum with increasing values of nIndex will enumerate through the component names in the system until OMX_ErrorNoMore is returned. The value of nIndex is 0 to (N-1), where N is the number of valid installed components in the system. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. When the value of nIndex exceeds the number of components in the system minus 1, OMX_ErrorNoMore will be returned. Otherwise the appropriate OMX error will be returned. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum( OMX_OUT OMX_STRING cComponentName, OMX_IN OMX_U32 nNameLength, OMX_IN OMX_U32 nIndex); /** The OMX_GetHandle method will locate the component specified by the component name given, load that component into memory and then invoke the component's methods to create an instance of the component. The core should return from this call within 20 msec. @param [out] pHandle pointer to an OMX_HANDLETYPE pointer to be filled in by this method. @param [in] cComponentName pointer to a null terminated string with the component name. The names of the components are strings less than 127 bytes in length plus the trailing null for a maximum size of 128 bytes. An example of a valid component name is "OMX.TI.AUDIO.DSP.MIXER\0". Names are assigned by the vendor, but shall start with "OMX." and then have the Vendor designation next. @param [in] pAppData pointer to an application defined value that will be returned during callbacks so that the application can identify the source of the callback. @param [in] pCallBacks pointer to a OMX_CALLBACKTYPE structure that will be passed to the component to initialize it with. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle( OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_STRING cComponentName, OMX_IN OMX_PTR pAppData, OMX_IN OMX_CALLBACKTYPE* pCallBacks); /** The OMX_FreeHandle method will free a handle allocated by the OMX_GetHandle method. If the component reference count goes to zero, the component will be unloaded from memory. The core should return from this call within 20 msec when the component is in the OMX_StateLoaded state. @param [in] hComponent Handle of the component to be accessed. This is the component handle returned by the call to the GetHandle function. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle( OMX_IN OMX_HANDLETYPE hComponent); /** The OMX_SetupTunnel method will handle the necessary calls to the components to setup the specified tunnel the two components. NOTE: This is an actual method (not a #define macro). This method will make calls into the component ComponentTunnelRequest method to do the actual tunnel connection. The ComponentTunnelRequest method on both components will be called. This method shall not be called unless the component is in the OMX_StateLoaded state except when the ports used for the tunnel are disabled. In this case, the component may be in the OMX_StateExecuting, OMX_StatePause, or OMX_StateIdle states. The core should return from this call within 20 msec. @param [in] hOutput Handle of the component to be accessed. Also this is the handle of the component whose port, specified in the nPortOutput parameter will be used the source for the tunnel. This is the component handle returned by the call to the OMX_GetHandle function. There is a requirement that hOutput be the source for the data when tunelling (i.e. nPortOutput is an output port). If 0x0, the component specified in hInput will have it's port specified in nPortInput setup for communication with the application / IL client. @param [in] nPortOutput nPortOutput is used to select the source port on component to be used in the tunnel. @param [in] hInput This is the component to setup the tunnel with. This is the handle of the component whose port, specified in the nPortInput parameter will be used the destination for the tunnel. This is the component handle returned by the call to the OMX_GetHandle function. There is a requirement that hInput be the destination for the data when tunelling (i.e. nPortInut is an input port). If 0x0, the component specified in hOutput will have it's port specified in nPortPOutput setup for communication with the application / IL client. @param [in] nPortInput nPortInput is used to select the destination port on component to be used in the tunnel. @return OMX_ERRORTYPE If the command successfully executes, the return code will be OMX_ErrorNone. Otherwise the appropriate OMX error will be returned. When OMX_ErrorNotImplemented is returned, one or both components is a non-interop component and does not support tunneling. On failure, the ports of both components are setup for communication with the application / IL Client. @ingroup core tun */ OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_SetupTunnel( OMX_IN OMX_HANDLETYPE hOutput, OMX_IN OMX_U32 nPortOutput, OMX_IN OMX_HANDLETYPE hInput, OMX_IN OMX_U32 nPortInput); /** @ingroup cp */ OMX_API OMX_ERRORTYPE OMX_GetContentPipe( OMX_OUT OMX_HANDLETYPE *hPipe, OMX_IN OMX_STRING szURI); /** The OMX_GetComponentsOfRole method will return the number of components that support the given role and (if the compNames field is non-NULL) the names of those components. The call will fail if an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the client should: * first call this function with the compNames field NULL to determine the number of component names * second call this function with the compNames field pointing to an array of names allocated according to the number returned by the first call. The core should return from this call within 5 msec. @param [in] role This is generic standard component name consisting only of component class name and the type within that class (e.g. 'audio_decoder.aac'). @param [inout] pNumComps This is used both as input and output. If compNames is NULL, the input is ignored and the output specifies how many components support the given role. If compNames is not NULL, on input it bounds the size of the input structure and on output, it specifies the number of components string names listed within the compNames parameter. @param [inout] compNames If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts a list of the names of all physical components that implement the specified standard component name. Each name is NULL terminated. numComps indicates the number of names. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_GetComponentsOfRole ( OMX_IN OMX_STRING role, OMX_INOUT OMX_U32 *pNumComps, OMX_INOUT OMX_U8 **compNames); /** The OMX_GetRolesOfComponent method will return the number of roles supported by the given component and (if the roles field is non-NULL) the names of those roles. The call will fail if an insufficiently sized array of names is supplied. To ensure the array is sufficiently sized the client should: * first call this function with the roles field NULL to determine the number of role names * second call this function with the roles field pointing to an array of names allocated according to the number returned by the first call. The core should return from this call within 5 msec. @param [in] compName This is the name of the component being queried about. @param [inout] pNumRoles This is used both as input and output. If roles is NULL, the input is ignored and the output specifies how many roles the component supports. If compNames is not NULL, on input it bounds the size of the input structure and on output, it specifies the number of roles string names listed within the roles parameter. @param [out] roles If NULL this field is ignored. If non-NULL this points to an array of 128-byte strings which accepts a list of the names of all standard components roles implemented on the specified component name. numComps indicates the number of names. @ingroup core */ OMX_API OMX_ERRORTYPE OMX_GetRolesOfComponent ( OMX_IN OMX_STRING compName, OMX_INOUT OMX_U32 *pNumRoles, OMX_OUT OMX_U8 **roles); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_CoreExt.h ================================================ /* * Copyright (c) 2009 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_CoreExt.h - OpenMax IL version 1.1.2 * The OMX_CoreExt header file contains extensions to the definitions used * by both the application and the component to access common items. */ #ifndef OMX_CoreExt_h #define OMX_CoreExt_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header shall include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** Event type extensions. */ typedef enum OMX_EVENTEXTTYPE { OMX_EventIndexSettingChanged = OMX_EventKhronosExtensions, /**< component signals the IL client of a change in a param, config, or extension */ OMX_EventExtMax = 0x7FFFFFFF } OMX_EVENTEXTTYPE; /** Enable or disable a callback event. */ typedef struct OMX_CONFIG_CALLBACKREQUESTTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_INDEXTYPE nIndex; /**< the index the callback is requested for */ OMX_BOOL bEnable; /**< enable (OMX_TRUE) or disable (OMX_FALSE) the callback */ } OMX_CONFIG_CALLBACKREQUESTTYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* OMX_CoreExt_h */ /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_IVCommon.h ================================================ /** * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** * @file OMX_IVCommon.h - OpenMax IL version 1.1.2 * The structures needed by Video and Image components to exchange * parameters and configuration data with the components. */ #ifndef OMX_IVCommon_h #define OMX_IVCommon_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * Each OMX header must include all required header files to allow the header * to compile without errors. The includes below are required for this header * file to compile successfully */ #include /** @defgroup iv OpenMAX IL Imaging and Video Domain * Common structures for OpenMAX IL Imaging and Video domains * @{ */ /** * Enumeration defining possible uncompressed image/video formats. * * ENUMS: * Unused : Placeholder value when format is N/A * Monochrome : black and white * 8bitRGB332 : Red 7:5, Green 4:2, Blue 1:0 * 12bitRGB444 : Red 11:8, Green 7:4, Blue 3:0 * 16bitARGB4444 : Alpha 15:12, Red 11:8, Green 7:4, Blue 3:0 * 16bitARGB1555 : Alpha 15, Red 14:10, Green 9:5, Blue 4:0 * 16bitRGB565 : Red 15:11, Green 10:5, Blue 4:0 * 16bitBGR565 : Blue 15:11, Green 10:5, Red 4:0 * 18bitRGB666 : Red 17:12, Green 11:6, Blue 5:0 * 18bitARGB1665 : Alpha 17, Red 16:11, Green 10:5, Blue 4:0 * 19bitARGB1666 : Alpha 18, Red 17:12, Green 11:6, Blue 5:0 * 24bitRGB888 : Red 24:16, Green 15:8, Blue 7:0 * 24bitBGR888 : Blue 24:16, Green 15:8, Red 7:0 * 24bitARGB1887 : Alpha 23, Red 22:15, Green 14:7, Blue 6:0 * 25bitARGB1888 : Alpha 24, Red 23:16, Green 15:8, Blue 7:0 * 32bitBGRA8888 : Blue 31:24, Green 23:16, Red 15:8, Alpha 7:0 * 32bitARGB8888 : Alpha 31:24, Red 23:16, Green 15:8, Blue 7:0 * YUV411Planar : U,Y are subsampled by a factor of 4 horizontally * YUV411PackedPlanar : packed per payload in planar slices * YUV420Planar : Three arrays Y,U,V. * YUV420PackedPlanar : packed per payload in planar slices * YUV420SemiPlanar : Two arrays, one is all Y, the other is U and V * YUV422Planar : Three arrays Y,U,V. * YUV422PackedPlanar : packed per payload in planar slices * YUV422SemiPlanar : Two arrays, one is all Y, the other is U and V * YCbYCr : Organized as 16bit YUYV (i.e. YCbYCr) * YCrYCb : Organized as 16bit YVYU (i.e. YCrYCb) * CbYCrY : Organized as 16bit UYVY (i.e. CbYCrY) * CrYCbY : Organized as 16bit VYUY (i.e. CrYCbY) * YUV444Interleaved : Each pixel contains equal parts YUV * RawBayer8bit : SMIA camera output format * RawBayer10bit : SMIA camera output format * RawBayer8bitcompressed : SMIA camera output format */ typedef enum OMX_COLOR_FORMATTYPE { OMX_COLOR_FormatUnused, OMX_COLOR_FormatMonochrome, OMX_COLOR_Format8bitRGB332, OMX_COLOR_Format12bitRGB444, OMX_COLOR_Format16bitARGB4444, OMX_COLOR_Format16bitARGB1555, OMX_COLOR_Format16bitRGB565, OMX_COLOR_Format16bitBGR565, OMX_COLOR_Format18bitRGB666, OMX_COLOR_Format18bitARGB1665, OMX_COLOR_Format19bitARGB1666, OMX_COLOR_Format24bitRGB888, OMX_COLOR_Format24bitBGR888, OMX_COLOR_Format24bitARGB1887, OMX_COLOR_Format25bitARGB1888, OMX_COLOR_Format32bitBGRA8888, OMX_COLOR_Format32bitARGB8888, OMX_COLOR_FormatYUV411Planar, OMX_COLOR_FormatYUV411PackedPlanar, OMX_COLOR_FormatYUV420Planar, OMX_COLOR_FormatYUV420PackedPlanar, OMX_COLOR_FormatYUV420SemiPlanar, OMX_COLOR_FormatYUV422Planar, OMX_COLOR_FormatYUV422PackedPlanar, OMX_COLOR_FormatYUV422SemiPlanar, OMX_COLOR_FormatYCbYCr, OMX_COLOR_FormatYCrYCb, OMX_COLOR_FormatCbYCrY, OMX_COLOR_FormatCrYCbY, OMX_COLOR_FormatYUV444Interleaved, OMX_COLOR_FormatRawBayer8bit, OMX_COLOR_FormatRawBayer10bit, OMX_COLOR_FormatRawBayer8bitcompressed, OMX_COLOR_FormatL2, OMX_COLOR_FormatL4, OMX_COLOR_FormatL8, OMX_COLOR_FormatL16, OMX_COLOR_FormatL24, OMX_COLOR_FormatL32, OMX_COLOR_FormatYUV420PackedSemiPlanar, OMX_COLOR_FormatYUV422PackedSemiPlanar, OMX_COLOR_Format18BitBGR666, OMX_COLOR_Format24BitARGB6666, OMX_COLOR_Format24BitABGR6666, OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ /** /** @defgroup imaging OpenMAX IL Imaging Domain * @ingroup iv * Structures for OpenMAX IL Imaging domain * @{ */ /** * Enumeration used to define the possible image compression coding. */ typedef enum OMX_IMAGE_CODINGTYPE { OMX_IMAGE_CodingUnused, /**< Value when format is N/A */ OMX_IMAGE_CodingAutoDetect, /**< Auto detection of image format */ OMX_IMAGE_CodingJPEG, /**< JPEG/JFIF image format */ OMX_IMAGE_CodingJPEG2K, /**< JPEG 2000 image format */ OMX_IMAGE_CodingEXIF, /**< EXIF image format */ OMX_IMAGE_CodingTIFF, /**< TIFF image format */ OMX_IMAGE_CodingGIF, /**< Graphics image format */ OMX_IMAGE_CodingPNG, /**< PNG image format */ OMX_IMAGE_CodingLZW, /**< LZW image format */ OMX_IMAGE_CodingBMP, /**< Windows Bitmap format */ OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_IMAGE_CodingMax = 0x7FFFFFFF } OMX_IMAGE_CODINGTYPE; /** * Data structure used to define an image path. The number of image paths * for input and output will vary by type of the image component. * * Input (aka Source) : Zero Inputs, one Output, * Splitter : One Input, 2 or more Outputs, * Processing Element : One Input, one output, * Mixer : 2 or more inputs, one output, * Output (aka Sink) : One Input, zero outputs. * * The PortDefinition structure is used to define all of the parameters * necessary for the compliant component to setup an input or an output * image path. If additional vendor specific data is required, it should * be transmitted to the component using the CustomCommand function. * Compliant components will prepopulate this structure with optimal * values during the OMX_GetParameter() command. * * STRUCT MEMBERS: * cMIMEType : MIME type of data for the port * pNativeRender : Platform specific reference for a display if a * sync, otherwise this field is 0 * nFrameWidth : Width of frame to be used on port if * uncompressed format is used. Use 0 for * unknown, don't care or variable * nFrameHeight : Height of frame to be used on port if * uncompressed format is used. Use 0 for * unknown, don't care or variable * nStride : Number of bytes per span of an image (i.e. * indicates the number of bytes to get from * span N to span N+1, where negative stride * indicates the image is bottom up * nSliceHeight : Height used when encoding in slices * bFlagErrorConcealment : Turns on error concealment if it is supported by * the OMX component * eCompressionFormat : Compression format used in this instance of * the component. When OMX_IMAGE_CodingUnused is * specified, eColorFormat is valid * eColorFormat : Decompressed format used by this component * pNativeWindow : Platform specific reference for a window object if a * display sink , otherwise this field is 0x0. */ typedef struct OMX_IMAGE_PORTDEFINITIONTYPE { OMX_STRING cMIMEType; OMX_NATIVE_DEVICETYPE pNativeRender; OMX_U32 nFrameWidth; OMX_U32 nFrameHeight; OMX_S32 nStride; OMX_U32 nSliceHeight; OMX_BOOL bFlagErrorConcealment; OMX_IMAGE_CODINGTYPE eCompressionFormat; OMX_COLOR_FORMATTYPE eColorFormat; OMX_NATIVE_WINDOWTYPE pNativeWindow; } OMX_IMAGE_PORTDEFINITIONTYPE; /** * Port format parameter. This structure is used to enumerate the various * data input/output format supported by the port. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Indicates which port to set * nIndex : Indicates the enumeration index for the format from * 0x0 to N-1 * eCompressionFormat : Compression format used in this instance of the * component. When OMX_IMAGE_CodingUnused is specified, * eColorFormat is valid * eColorFormat : Decompressed format used by this component */ typedef struct OMX_IMAGE_PARAM_PORTFORMATTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nIndex; OMX_IMAGE_CODINGTYPE eCompressionFormat; OMX_COLOR_FORMATTYPE eColorFormat; } OMX_IMAGE_PARAM_PORTFORMATTYPE; /** * Flash control type * * ENUMS * Torch : Flash forced constantly on */ typedef enum OMX_IMAGE_FLASHCONTROLTYPE { OMX_IMAGE_FlashControlOn = 0, OMX_IMAGE_FlashControlOff, OMX_IMAGE_FlashControlAuto, OMX_IMAGE_FlashControlRedEyeReduction, OMX_IMAGE_FlashControlFillin, OMX_IMAGE_FlashControlTorch, OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_IMAGE_FlashControlMax = 0x7FFFFFFF } OMX_IMAGE_FLASHCONTROLTYPE; /** * Flash control configuration * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFlashControl : Flash control type */ typedef struct OMX_IMAGE_PARAM_FLASHCONTROLTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_IMAGE_FLASHCONTROLTYPE eFlashControl; } OMX_IMAGE_PARAM_FLASHCONTROLTYPE; /** * Focus control type */ typedef enum OMX_IMAGE_FOCUSCONTROLTYPE { OMX_IMAGE_FocusControlOn = 0, OMX_IMAGE_FocusControlOff, OMX_IMAGE_FocusControlAuto, OMX_IMAGE_FocusControlAutoLock, OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_IMAGE_FocusControlMax = 0x7FFFFFFF } OMX_IMAGE_FOCUSCONTROLTYPE; /** * Focus control configuration * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFocusControl : Focus control * nFocusSteps : Focus can take on values from 0 mm to infinity. * Interest is only in number of steps over this range. * nFocusStepIndex : Current focus step index */ typedef struct OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_IMAGE_FOCUSCONTROLTYPE eFocusControl; OMX_U32 nFocusSteps; OMX_U32 nFocusStepIndex; } OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE; /** * Q Factor for JPEG compression, which controls the tradeoff between image * quality and size. Q Factor provides a more simple means of controlling * JPEG compression quality, without directly programming Quantization * tables for chroma and luma * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nQFactor : JPEG Q factor value in the range of 1-100. A factor of 1 * produces the smallest, worst quality images, and a factor * of 100 produces the largest, best quality images. A * typical default is 75 for small good quality images */ typedef struct OMX_IMAGE_PARAM_QFACTORTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nQFactor; } OMX_IMAGE_PARAM_QFACTORTYPE; /** * Quantization table type */ typedef enum OMX_IMAGE_QUANTIZATIONTABLETYPE { OMX_IMAGE_QuantizationTableLuma = 0, OMX_IMAGE_QuantizationTableChroma, OMX_IMAGE_QuantizationTableChromaCb, OMX_IMAGE_QuantizationTableChromaCr, OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF } OMX_IMAGE_QUANTIZATIONTABLETYPE; /** * JPEG quantization tables are used to determine DCT compression for * YUV data, as an alternative to specifying Q factor, providing exact * control of compression * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eQuantizationTable : Quantization table type * nQuantizationMatrix[64] : JPEG quantization table of coefficients stored * in increasing columns then by rows of data (i.e. * row 1, ... row 8). Quantization values are in * the range 0-255 and stored in linear order * (i.e. the component will zig-zag the * quantization table data if required internally) */ typedef struct OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_IMAGE_QUANTIZATIONTABLETYPE eQuantizationTable; OMX_U8 nQuantizationMatrix[64]; } OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE; /** * Huffman table type, the same Huffman table is applied for chroma and * luma component */ typedef enum OMX_IMAGE_HUFFMANTABLETYPE { OMX_IMAGE_HuffmanTableAC = 0, OMX_IMAGE_HuffmanTableDC, OMX_IMAGE_HuffmanTableACLuma, OMX_IMAGE_HuffmanTableACChroma, OMX_IMAGE_HuffmanTableDCLuma, OMX_IMAGE_HuffmanTableDCChroma, OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF } OMX_IMAGE_HUFFMANTABLETYPE; /** * JPEG Huffman table * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eHuffmanTable : Huffman table type * nNumberOfHuffmanCodeOfLength[16] : 0-16, number of Huffman codes of each * possible length * nHuffmanTable[256] : 0-255, the size used for AC and DC * HuffmanTable are 16 and 162 */ typedef struct OMX_IMAGE_PARAM_HUFFMANTTABLETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_IMAGE_HUFFMANTABLETYPE eHuffmanTable; OMX_U8 nNumberOfHuffmanCodeOfLength[16]; OMX_U8 nHuffmanTable[256]; }OMX_IMAGE_PARAM_HUFFMANTTABLETYPE; /** @} */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_Index.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** @file OMX_Index.h - OpenMax IL version 1.1.2 * The OMX_Index header file contains the definitions for both applications * and components . */ #ifndef OMX_Index_h #define OMX_Index_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header must include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** The OMX_INDEXTYPE enumeration is used to select a structure when either * getting or setting parameters and/or configuration data. Each entry in * this enumeration maps to an OMX specified structure. When the * OMX_GetParameter, OMX_SetParameter, OMX_GetConfig or OMX_SetConfig methods * are used, the second parameter will always be an entry from this enumeration * and the third entry will be the structure shown in the comments for the entry. * For example, if the application is initializing a cropping function, the * OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter * and would send a pointer to an initialized OMX_RECTTYPE structure as the * third parameter. * * The enumeration entries named with the OMX_Config prefix are sent using * the OMX_SetConfig command and the enumeration entries named with the * OMX_PARAM_ prefix are sent using the OMX_SetParameter command. */ typedef enum OMX_INDEXTYPE { OMX_IndexComponentStartUnused = 0x01000000, OMX_IndexParamPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ OMX_IndexParamAudioInit, /**< reference: OMX_PORT_PARAM_TYPE */ OMX_IndexParamImageInit, /**< reference: OMX_PORT_PARAM_TYPE */ OMX_IndexParamVideoInit, /**< reference: OMX_PORT_PARAM_TYPE */ OMX_IndexParamOtherInit, /**< reference: OMX_PORT_PARAM_TYPE */ OMX_IndexParamNumAvailableStreams, /**< reference: OMX_PARAM_U32TYPE */ OMX_IndexParamActiveStream, /**< reference: OMX_PARAM_U32TYPE */ OMX_IndexParamSuspensionPolicy, /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */ OMX_IndexParamComponentSuspended, /**< reference: OMX_PARAM_SUSPENSIONTYPE */ OMX_IndexConfigCapturing, /**< reference: OMX_CONFIG_BOOLEANTYPE */ OMX_IndexConfigCaptureMode, /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ OMX_IndexAutoPauseAfterCapture, /**< reference: OMX_CONFIG_BOOLEANTYPE */ OMX_IndexParamContentURI, /**< reference: OMX_PARAM_CONTENTURITYPE */ OMX_IndexParamCustomContentPipe, /**< reference: OMX_PARAM_CONTENTPIPETYPE */ OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */ OMX_IndexConfigMetadataItemCount, /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */ OMX_IndexConfigContainerNodeCount, /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */ OMX_IndexConfigMetadataItem, /**< reference: OMX_CONFIG_METADATAITEMTYPE */ OMX_IndexConfigCounterNodeID, /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */ OMX_IndexParamMetadataFilterType, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ OMX_IndexParamMetadataKeyFilter, /**< reference: OMX_PARAM_METADATAFILTERTYPE */ OMX_IndexConfigPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */ OMX_IndexParamStandardComponentRole, /**< reference: OMX_PARAM_COMPONENTROLETYPE */ OMX_IndexPortStartUnused = 0x02000000, OMX_IndexParamPortDefinition, /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */ OMX_IndexParamCompBufferSupplier, /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */ OMX_IndexReservedStartUnused = 0x03000000, /* Audio parameters and configurations */ OMX_IndexAudioStartUnused = 0x04000000, OMX_IndexParamAudioPortFormat, /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */ OMX_IndexParamAudioPcm, /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */ OMX_IndexParamAudioAac, /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */ OMX_IndexParamAudioRa, /**< reference: OMX_AUDIO_PARAM_RATYPE */ OMX_IndexParamAudioMp3, /**< reference: OMX_AUDIO_PARAM_MP3TYPE */ OMX_IndexParamAudioAdpcm, /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */ OMX_IndexParamAudioG723, /**< reference: OMX_AUDIO_PARAM_G723TYPE */ OMX_IndexParamAudioG729, /**< reference: OMX_AUDIO_PARAM_G729TYPE */ OMX_IndexParamAudioAmr, /**< reference: OMX_AUDIO_PARAM_AMRTYPE */ OMX_IndexParamAudioWma, /**< reference: OMX_AUDIO_PARAM_WMATYPE */ OMX_IndexParamAudioSbc, /**< reference: OMX_AUDIO_PARAM_SBCTYPE */ OMX_IndexParamAudioMidi, /**< reference: OMX_AUDIO_PARAM_MIDITYPE */ OMX_IndexParamAudioGsm_FR, /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */ OMX_IndexParamAudioMidiLoadUserSound, /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */ OMX_IndexParamAudioG726, /**< reference: OMX_AUDIO_PARAM_G726TYPE */ OMX_IndexParamAudioGsm_EFR, /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */ OMX_IndexParamAudioGsm_HR, /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */ OMX_IndexParamAudioPdc_FR, /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */ OMX_IndexParamAudioPdc_EFR, /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */ OMX_IndexParamAudioPdc_HR, /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */ OMX_IndexParamAudioTdma_FR, /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */ OMX_IndexParamAudioTdma_EFR, /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */ OMX_IndexParamAudioQcelp8, /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */ OMX_IndexParamAudioQcelp13, /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */ OMX_IndexParamAudioEvrc, /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */ OMX_IndexParamAudioSmv, /**< reference: OMX_AUDIO_PARAM_SMVTYPE */ OMX_IndexParamAudioVorbis, /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */ OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */ OMX_IndexConfigAudioMidiControl, /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */ OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */ OMX_IndexConfigAudioMidiStatus, /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */ OMX_IndexConfigAudioMidiMetaEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */ OMX_IndexConfigAudioMidiMetaEventData, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */ OMX_IndexConfigAudioVolume, /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */ OMX_IndexConfigAudioBalance, /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */ OMX_IndexConfigAudioChannelMute, /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */ OMX_IndexConfigAudioMute, /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */ OMX_IndexConfigAudioLoudness, /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */ OMX_IndexConfigAudioEchoCancelation, /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */ OMX_IndexConfigAudioNoiseReduction, /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */ OMX_IndexConfigAudioBass, /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */ OMX_IndexConfigAudioTreble, /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */ OMX_IndexConfigAudioStereoWidening, /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */ OMX_IndexConfigAudioChorus, /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */ OMX_IndexConfigAudioEqualizer, /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */ OMX_IndexConfigAudioReverberation, /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */ OMX_IndexConfigAudioChannelVolume, /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */ /* Image specific parameters and configurations */ OMX_IndexImageStartUnused = 0x05000000, OMX_IndexParamImagePortFormat, /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */ OMX_IndexParamFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ OMX_IndexConfigFocusControl, /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */ OMX_IndexParamQFactor, /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */ OMX_IndexParamQuantizationTable, /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */ OMX_IndexParamHuffmanTable, /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */ OMX_IndexConfigFlashControl, /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */ /* Video specific parameters and configurations */ OMX_IndexVideoStartUnused = 0x06000000, OMX_IndexParamVideoPortFormat, /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */ OMX_IndexParamVideoQuantization, /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */ OMX_IndexParamVideoFastUpdate, /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */ OMX_IndexParamVideoBitrate, /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */ OMX_IndexParamVideoMotionVector, /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */ OMX_IndexParamVideoIntraRefresh, /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */ OMX_IndexParamVideoErrorCorrection, /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */ OMX_IndexParamVideoVBSMC, /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */ OMX_IndexParamVideoMpeg2, /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */ OMX_IndexParamVideoMpeg4, /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */ OMX_IndexParamVideoWmv, /**< reference: OMX_VIDEO_PARAM_WMVTYPE */ OMX_IndexParamVideoRv, /**< reference: OMX_VIDEO_PARAM_RVTYPE */ OMX_IndexParamVideoAvc, /**< reference: OMX_VIDEO_PARAM_AVCTYPE */ OMX_IndexParamVideoH263, /**< reference: OMX_VIDEO_PARAM_H263TYPE */ OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */ OMX_IndexConfigVideoBitrate, /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */ OMX_IndexConfigVideoFramerate, /**< reference: OMX_CONFIG_FRAMERATETYPE */ OMX_IndexConfigVideoIntraVOPRefresh, /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */ OMX_IndexConfigVideoIntraMBRefresh, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ OMX_IndexConfigVideoMBErrorReporting, /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */ OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */ OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */ OMX_IndexParamVideoSliceFMO, /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */ OMX_IndexConfigVideoAVCIntraPeriod, /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */ OMX_IndexConfigVideoNalSize, /**< reference: OMX_VIDEO_CONFIG_NALSIZE */ OMX_IndexConfigCommonDeinterlace, /**< reference: OMX_VIDEO_CONFIG_DEINTERLACE */ /* Image & Video common Configurations */ OMX_IndexCommonStartUnused = 0x07000000, OMX_IndexParamCommonDeblocking, /**< reference: OMX_PARAM_DEBLOCKINGTYPE */ OMX_IndexParamCommonSensorMode, /**< reference: OMX_PARAM_SENSORMODETYPE */ OMX_IndexParamCommonInterleave, /**< reference: OMX_PARAM_INTERLEAVETYPE */ OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */ OMX_IndexConfigCommonScale, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ OMX_IndexConfigCommonImageFilter, /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */ OMX_IndexConfigCommonColorEnhancement, /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */ OMX_IndexConfigCommonColorKey, /**< reference: OMX_CONFIG_COLORKEYTYPE */ OMX_IndexConfigCommonColorBlend, /**< reference: OMX_CONFIG_COLORBLENDTYPE */ OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */ OMX_IndexConfigCommonRotate, /**< reference: OMX_CONFIG_ROTATIONTYPE */ OMX_IndexConfigCommonMirror, /**< reference: OMX_CONFIG_MIRRORTYPE */ OMX_IndexConfigCommonOutputPosition, /**< reference: OMX_CONFIG_POINTTYPE */ OMX_IndexConfigCommonInputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ OMX_IndexConfigCommonOutputCrop, /**< reference: OMX_CONFIG_RECTTYPE */ OMX_IndexConfigCommonDigitalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE */ OMX_IndexConfigCommonOpticalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/ OMX_IndexConfigCommonWhiteBalance, /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */ OMX_IndexConfigCommonExposure, /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */ OMX_IndexConfigCommonContrast, /**< reference: OMX_CONFIG_CONTRASTTYPE */ OMX_IndexConfigCommonBrightness, /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */ OMX_IndexConfigCommonBacklight, /**< reference: OMX_CONFIG_BACKLIGHTTYPE */ OMX_IndexConfigCommonGamma, /**< reference: OMX_CONFIG_GAMMATYPE */ OMX_IndexConfigCommonSaturation, /**< reference: OMX_CONFIG_SATURATIONTYPE */ OMX_IndexConfigCommonLightness, /**< reference: OMX_CONFIG_LIGHTNESSTYPE */ OMX_IndexConfigCommonExclusionRect, /**< reference: OMX_CONFIG_RECTTYPE */ OMX_IndexConfigCommonDithering, /**< reference: OMX_CONFIG_DITHERTYPE */ OMX_IndexConfigCommonPlaneBlend, /**< reference: OMX_CONFIG_PLANEBLENDTYPE */ OMX_IndexConfigCommonExposureValue, /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */ OMX_IndexConfigCommonOutputSize, /**< reference: OMX_FRAMESIZETYPE */ OMX_IndexParamCommonExtraQuantData, /**< reference: OMX_OTHER_EXTRADATATYPE */ OMX_IndexConfigCommonFocusRegion, /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */ OMX_IndexConfigCommonFocusStatus, /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */ OMX_IndexConfigCommonTransitionEffect, /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */ /* Reserved Configuration range */ OMX_IndexOtherStartUnused = 0x08000000, OMX_IndexParamOtherPortFormat, /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */ OMX_IndexConfigOtherPower, /**< reference: OMX_OTHER_CONFIG_POWERTYPE */ OMX_IndexConfigOtherStats, /**< reference: OMX_OTHER_CONFIG_STATSTYPE */ /* Reserved Time range */ OMX_IndexTimeStartUnused = 0x09000000, OMX_IndexConfigTimeScale, /**< reference: OMX_TIME_CONFIG_SCALETYPE */ OMX_IndexConfigTimeClockState, /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */ OMX_IndexConfigTimeActiveRefClock, /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */ OMX_IndexConfigTimeCurrentMediaTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ OMX_IndexConfigTimeCurrentWallTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */ OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */ OMX_IndexConfigTimeMediaTimeRequest, /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */ OMX_IndexConfigTimeClientStartTime, /** /** Khronos standard extension indices. This enum lists the current Khronos extension indices to OpenMAX IL. */ typedef enum OMX_INDEXEXTTYPE { /* Component parameters and configurations */ OMX_IndexExtComponentStartUnused = OMX_IndexKhronosExtensions + 0x00100000, OMX_IndexConfigCallbackRequest, /**< reference: OMX_CONFIG_CALLBACKREQUESTTYPE */ OMX_IndexConfigCommitMode, /**< reference: OMX_CONFIG_COMMITMODETYPE */ OMX_IndexConfigCommit, /**< reference: OMX_CONFIG_COMMITTYPE */ /* Port parameters and configurations */ OMX_IndexExtPortStartUnused = OMX_IndexKhronosExtensions + 0x00200000, /* Audio parameters and configurations */ OMX_IndexExtAudioStartUnused = OMX_IndexKhronosExtensions + 0x00400000, /* Image parameters and configurations */ OMX_IndexExtImageStartUnused = OMX_IndexKhronosExtensions + 0x00500000, /* Video parameters and configurations */ OMX_IndexExtVideoStartUnused = OMX_IndexKhronosExtensions + 0x00600000, OMX_IndexParamNalStreamFormatSupported, /**< reference: OMX_NALSTREAMFORMATTYPE */ OMX_IndexParamNalStreamFormat, /**< reference: OMX_NALSTREAMFORMATTYPE */ OMX_IndexParamNalStreamFormatSelect, /**< reference: OMX_NALSTREAMFORMATTYPE */ OMX_IndexParamVideoVp8, /**< reference: OMX_VIDEO_PARAM_VP8TYPE */ OMX_IndexConfigVideoVp8ReferenceFrame, /**< reference: OMX_VIDEO_VP8REFERENCEFRAMETYPE */ OMX_IndexConfigVideoVp8ReferenceFrameType, /**< reference: OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE */ OMX_IndexParamVideoReserved, /**< Reserved for future index */ OMX_IndexParamVideoHevc, /**< reference: OMX_VIDEO_PARAM_HEVCTYPE */ /* Image & Video common configurations */ OMX_IndexExtCommonStartUnused = OMX_IndexKhronosExtensions + 0x00700000, /* Other configurations */ OMX_IndexExtOtherStartUnused = OMX_IndexKhronosExtensions + 0x00800000, OMX_IndexConfigAutoFramerateConversion, /**< reference: OMX_CONFIG_BOOLEANTYPE */ OMX_IndexConfigPriority, /**< reference: OMX_PARAM_U32TYPE */ OMX_IndexConfigOperatingRate, /**< reference: OMX_PARAM_U32TYPE in Q16 format for video and in Hz for audio */ /* Time configurations */ OMX_IndexExtTimeStartUnused = OMX_IndexKhronosExtensions + 0x00900000, OMX_IndexExtMax = 0x7FFFFFFF } OMX_INDEXEXTTYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* OMX_IndexExt_h */ /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_Other.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** @file OMX_Other.h - OpenMax IL version 1.1.2 * The structures needed by Other components to exchange * parameters and configuration data with the components. */ #ifndef OMX_Other_h #define OMX_Other_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header must include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** * Enumeration of possible data types which match to multiple domains or no * domain at all. For types which are vendor specific, a value above * OMX_OTHER_VENDORTSTART should be used. */ typedef enum OMX_OTHER_FORMATTYPE { OMX_OTHER_FormatTime = 0, /**< Transmission of various timestamps, elapsed time, time deltas, etc */ OMX_OTHER_FormatPower, /**< Perhaps used for enabling/disabling power management, setting clocks? */ OMX_OTHER_FormatStats, /**< Could be things such as frame rate, frames dropped, etc */ OMX_OTHER_FormatBinary, /**< Arbitrary binary data */ OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific formats */ OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_OTHER_FormatMax = 0x7FFFFFFF } OMX_OTHER_FORMATTYPE; /** * Enumeration of seek modes. */ typedef enum OMX_TIME_SEEKMODETYPE { OMX_TIME_SeekModeFast = 0, /**< Prefer seeking to an approximation * of the requested seek position over * the actual seek position if it * results in a faster seek. */ OMX_TIME_SeekModeAccurate, /**< Prefer seeking to the actual seek * position over an approximation * of the requested seek position even * if it results in a slower seek. */ OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_TIME_SeekModeMax = 0x7FFFFFFF } OMX_TIME_SEEKMODETYPE; /* Structure representing the seekmode of the component */ typedef struct OMX_TIME_CONFIG_SEEKMODETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_TIME_SEEKMODETYPE eType; /**< The seek mode */ } OMX_TIME_CONFIG_SEEKMODETYPE; /** Structure representing a time stamp used with the following configs * on the Clock Component (CC): * * OMX_IndexConfigTimeCurrentWallTime: query of the CCs current wall * time * OMX_IndexConfigTimeCurrentMediaTime: query of the CCs current media * time * OMX_IndexConfigTimeCurrentAudioReference and * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference * clock sending SC its reference time * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends * this structure to the Clock Component via a SetConfig on its * client port when it receives a buffer with * OMX_BUFFERFLAG_STARTTIME set. It must use the timestamp * specified by that buffer for nStartTimestamp. * * Its also used with the following config on components in general: * * OMX_IndexConfigTimePosition: IL client querying component position * (GetConfig) or commanding a component to seek to the given location * (SetConfig) */ typedef struct OMX_TIME_CONFIG_TIMESTAMPTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version * information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_TICKS nTimestamp; /**< timestamp .*/ } OMX_TIME_CONFIG_TIMESTAMPTYPE; /** Enumeration of possible reference clocks to the media time. */ typedef enum OMX_TIME_UPDATETYPE { OMX_TIME_UpdateRequestFulfillment, /**< Update is the fulfillment of a media time request. */ OMX_TIME_UpdateScaleChanged, /**< Update was generated because the scale chagned. */ OMX_TIME_UpdateClockStateChanged, /**< Update was generated because the clock state changed. */ OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_TIME_UpdateMax = 0x7FFFFFFF } OMX_TIME_UPDATETYPE; /** Enumeration of possible reference clocks to the media time. */ typedef enum OMX_TIME_REFCLOCKTYPE { OMX_TIME_RefClockNone, /**< Use no references. */ OMX_TIME_RefClockAudio, /**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */ OMX_TIME_RefClockVideo, /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */ OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_TIME_RefClockMax = 0x7FFFFFFF } OMX_TIME_REFCLOCKTYPE; /** Enumeration of clock states. */ typedef enum OMX_TIME_CLOCKSTATE { OMX_TIME_ClockStateRunning, /**< Clock running. */ OMX_TIME_ClockStateWaitingForStartTime, /**< Clock waiting until the * prescribed clients emit their * start time. */ OMX_TIME_ClockStateStopped, /**< Clock stopped. */ OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_TIME_ClockStateMax = 0x7FFFFFFF } OMX_TIME_CLOCKSTATE; /** Structure representing a media time request to the clock component. * * A client component sends this structure to the Clock Component via a SetConfig * on its client port to specify a media timestamp the Clock Component * should emit. The Clock Component should fulfill the request by sending a * OMX_TIME_MEDIATIMETYPE when its media clock matches the requested * timestamp. * * The client may require a media time request be fulfilled slightly * earlier than the media time specified. In this case the client specifies * an offset which is equal to the difference between wall time corresponding * to the requested media time and the wall time when it will be * fulfilled. * * A client component may uses these requests and the OMX_TIME_MEDIATIMETYPE to * time events according to timestamps. If a client must perform an operation O at * a time T (e.g. deliver a video frame at its corresponding timestamp), it makes a * media time request at T (perhaps specifying an offset to ensure the request fulfillment * is a little early). When the clock component passes the resulting OMX_TIME_MEDIATIMETYPE * structure back to the client component, the client may perform operation O (perhaps having * to wait a slight amount more time itself as specified by the return values). */ typedef struct OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< port that this structure applies to */ OMX_PTR pClientPrivate; /**< Client private data to disabiguate this media time * from others (e.g. the number of the frame to deliver). * Duplicated in the media time structure that fulfills * this request. A value of zero is reserved for time scale * updates. */ OMX_TICKS nMediaTimestamp; /**< Media timestamp requested.*/ OMX_TICKS nOffset; /**< Amount of wall clock time by which this * request should be fulfilled early */ } OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE; /**< Structure sent from the clock component client either when fulfilling * a media time request or when the time scale has changed. * * In the former case the Clock Component fills this structure and times its emission * to a client component (via the client port) according to the corresponding media * time request sent by the client. The Clock Component should time the emission to occur * when the requested timestamp matches the Clock Component's media time but also the * prescribed offset early. * * Upon scale changes the clock component clears the nClientPrivate data, sends the current * media time and sets the nScale to the new scale via the client port. It emits a * OMX_TIME_MEDIATIMETYPE to all clients independent of any requests. This allows clients to * alter processing to accomodate scaling. For instance a video component might skip inter-frames * in the case of extreme fastforward. Likewise an audio component might add or remove samples * from an audio frame to scale audio data. * * It is expected that some clock components may not be able to fulfill requests * at exactly the prescribed time. This is acceptable so long as the request is * fulfilled at least as early as described and not later. This structure provides * fields the client may use to wait for the remaining time. * * The client may use either the nOffset or nWallTimeAtMedia fields to determine the * wall time until the nMediaTimestamp actually occurs. In the latter case the * client can get a more accurate value for offset by getting the current wall * from the cloc component and subtracting it from nWallTimeAtMedia. */ typedef struct OMX_TIME_MEDIATIMETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nClientPrivate; /**< Client private data to disabiguate this media time * from others. Copied from the media time request. * A value of zero is reserved for time scale updates. */ OMX_TIME_UPDATETYPE eUpdateType; /**< Reason for the update */ OMX_TICKS nMediaTimestamp; /**< Media time requested. If no media time was * requested then this is the current media time. */ OMX_TICKS nOffset; /**< Amount of wall clock time by which this * request was actually fulfilled early */ OMX_TICKS nWallTimeAtMediaTime; /**< Wall time corresponding to nMediaTimeStamp. * A client may compare this value to current * media time obtained from the Clock Component to determine * the wall time until the media timestamp is really * current. */ OMX_S32 xScale; /**< Current media time scale in Q16 format. */ OMX_TIME_CLOCKSTATE eState; /* Seeking Change. Added 7/12.*/ /**< State of the media time. */ } OMX_TIME_MEDIATIMETYPE; /** Structure representing the current media time scale factor. Applicable only to clock * component, other components see scale changes via OMX_TIME_MEDIATIMETYPE buffers sent via * the clock component client ports. Upon recieving this config the clock component changes * the rate by which the media time increases or decreases effectively implementing trick modes. */ typedef struct OMX_TIME_CONFIG_SCALETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_S32 xScale; /**< This is a value in Q16 format which is used for * scaling the media time */ } OMX_TIME_CONFIG_SCALETYPE; /** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPEs nWaitMask field */ #define OMX_CLOCKPORT0 0x00000001 #define OMX_CLOCKPORT1 0x00000002 #define OMX_CLOCKPORT2 0x00000004 #define OMX_CLOCKPORT3 0x00000008 #define OMX_CLOCKPORT4 0x00000010 #define OMX_CLOCKPORT5 0x00000020 #define OMX_CLOCKPORT6 0x00000040 #define OMX_CLOCKPORT7 0x00000080 /** Structure representing the current mode of the media clock. * IL Client uses this config to change or query the mode of the * media clock of the clock component. Applicable only to clock * component. * * On a SetConfig if eState is OMX_TIME_ClockStateRunning media time * starts immediately at the prescribed start time. If * OMX_TIME_ClockStateWaitingForStartTime the Clock Component ignores * the given nStartTime and waits for all clients specified in the * nWaitMask to send starttimes (via * OMX_IndexConfigTimeClientStartTime). The Clock Component then starts * the media clock using the earliest start time supplied. */ typedef struct OMX_TIME_CONFIG_CLOCKSTATETYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version * information */ OMX_TIME_CLOCKSTATE eState; /**< State of the media time. */ OMX_TICKS nStartTime; /**< Start time of the media time. */ OMX_TICKS nOffset; /**< Time to offset the media time by * (e.g. preroll). Media time will be * reported to be nOffset ticks earlier. */ OMX_U32 nWaitMask; /**< Mask of OMX_CLOCKPORT values. */ } OMX_TIME_CONFIG_CLOCKSTATETYPE; /** Structure representing the reference clock currently being used to * compute media time. IL client uses this config to change or query the * clock component's active reference clock */ typedef struct OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_TIME_REFCLOCKTYPE eClock; /**< Reference clock used to compute media time */ } OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE; /** Descriptor for setting specifics of power type. * Note: this structure is listed for backwards compatibility. */ typedef struct OMX_OTHER_CONFIG_POWERTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_BOOL bEnablePM; /**< Flag to enable Power Management */ } OMX_OTHER_CONFIG_POWERTYPE; /** Descriptor for setting specifics of stats type. * Note: this structure is listed for backwards compatibility. */ typedef struct OMX_OTHER_CONFIG_STATSTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ /* what goes here */ } OMX_OTHER_CONFIG_STATSTYPE; /** * The PortDefinition structure is used to define all of the parameters * necessary for the compliant component to setup an input or an output other * path. */ typedef struct OMX_OTHER_PORTDEFINITIONTYPE { OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ } OMX_OTHER_PORTDEFINITIONTYPE; /** Port format parameter. This structure is used to enumerate * the various data input/output format supported by the port. */ typedef struct OMX_OTHER_PARAM_PORTFORMATTYPE { OMX_U32 nSize; /**< size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Indicates which port to set */ OMX_U32 nIndex; /**< Indicates the enumeration index for the format from 0x0 to N-1 */ OMX_OTHER_FORMATTYPE eFormat; /**< Type of data expected for this channel */ } OMX_OTHER_PARAM_PORTFORMATTYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_QCOMExtns.h ================================================ /*-------------------------------------------------------------------------- Copyright (c) 2009-2015, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of The Linux Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------*/ #ifndef __OMX_QCOM_EXTENSIONS_H__ #define __OMX_QCOM_EXTENSIONS_H__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /*============================================================================ *//** @file OMX_QCOMExtns.h This header contains constants and type definitions that specify the extensions added to the OpenMAX Vendor specific APIs. *//*========================================================================*/ /////////////////////////////////////////////////////////////////////////////// // Include Files /////////////////////////////////////////////////////////////////////////////// #include "OMX_Core.h" #include "OMX_Video.h" #define OMX_VIDEO_MAX_HP_LAYERS 6 /** * This extension is used to register mapping of a virtual * address to a physical address. This extension is a parameter * which can be set using the OMX_SetParameter macro. The data * pointer corresponding to this extension is * OMX_QCOM_MemMapEntry. This parameter is a 'write only' * parameter (Current value cannot be queried using * OMX_GetParameter macro). */ #define OMX_QCOM_EXTN_REGISTER_MMAP "OMX.QCOM.index.param.register_mmap" /** * This structure describes the data pointer corresponding to * the OMX_QCOM_MMAP_REGISTER_EXTN extension. This parameter * must be set only 'after' populating a port with a buffer * using OMX_UseBuffer, wherein the data pointer of the buffer * corresponds to the virtual address as specified in this * structure. */ struct OMX_QCOM_PARAM_MEMMAPENTRYTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /**< OMX specification version information */ OMX_U32 nPortIndex; /**< Port number the structure applies to */ /** * The virtual address of memory block */ OMX_U64 nVirtualAddress; /** * The physical address corresponding to the virtual address. The physical * address is contiguous for the entire valid range of the virtual * address. */ OMX_U64 nPhysicalAddress; }; #define QOMX_VIDEO_IntraRefreshRandom (OMX_VIDEO_IntraRefreshVendorStartUnused + 0) /* This error event is used for H.264 long-term reference (LTR) encoding. * When IL client specifies an LTR frame with its identifier via * OMX_QCOM_INDEX_CONFIG_VIDEO_LTRUSE to the encoder, if the specified * LTR frame can not be located by the encoder in its LTR list, the encoder * issues this error event to IL client to notify the failure of LTRUse config. */ #define QOMX_ErrorLTRUseFailed (OMX_ErrorVendorStartUnused + 1) #define QOMX_VIDEO_BUFFERFLAG_BFRAME 0x00100000 #define QOMX_VIDEO_BUFFERFLAG_EOSEQ 0x00200000 #define QOMX_VIDEO_BUFFERFLAG_MBAFF 0x00400000 #define QOMX_VIDEO_BUFFERFLAG_CANCEL 0x00800000 #define OMX_QCOM_PORTDEFN_EXTN "OMX.QCOM.index.param.portdefn" /* Allowed APIs on the above Index: OMX_GetParameter() and OMX_SetParameter() */ typedef enum OMX_QCOMMemoryRegion { OMX_QCOM_MemRegionInvalid, OMX_QCOM_MemRegionEBI1, OMX_QCOM_MemRegionSMI, OMX_QCOM_MemRegionMax = 0X7FFFFFFF } OMX_QCOMMemoryRegion; typedef enum OMX_QCOMCacheAttr { OMX_QCOM_CacheAttrNone, OMX_QCOM_CacheAttrWriteBack, OMX_QCOM_CacheAttrWriteThrough, OMX_QCOM_CacheAttrMAX = 0X7FFFFFFF } OMX_QCOMCacheAttr; typedef struct OMX_QCOMRectangle { OMX_S32 x; OMX_S32 y; OMX_S32 dx; OMX_S32 dy; } OMX_QCOMRectangle; /** OMX_QCOMFramePackingFormat * Input or output buffer format */ typedef enum OMX_QCOMFramePackingFormat { /* 0 - unspecified */ OMX_QCOM_FramePacking_Unspecified, /* 1 - Partial frames may be present OMX IL 1.1.1 Figure 2-10: * Case 1??Each Buffer Filled In Whole or In Part */ OMX_QCOM_FramePacking_Arbitrary, /* 2 - Multiple complete frames per buffer (integer number) * OMX IL 1.1.1 Figure 2-11: Case 2Each Buffer Filled with * Only Complete Frames of Data */ OMX_QCOM_FramePacking_CompleteFrames, /* 3 - Only one complete frame per buffer, no partial frame * OMX IL 1.1.1 Figure 2-12: Case 3Each Buffer Filled with * Only One Frame of Compressed Data. Usually at least one * complete unit of data will be delivered in a buffer for * uncompressed data formats. */ OMX_QCOM_FramePacking_OnlyOneCompleteFrame, /* 4 - Only one complete subframe per buffer, no partial subframe * Example: In H264, one complete NAL per buffer, where one frame * can contatin multiple NAL */ OMX_QCOM_FramePacking_OnlyOneCompleteSubFrame, OMX_QCOM_FramePacking_MAX = 0X7FFFFFFF } OMX_QCOMFramePackingFormat; typedef struct OMX_QCOM_PARAM_PORTDEFINITIONTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ /** Platform specific memory region EBI1, SMI, etc.,*/ OMX_QCOMMemoryRegion nMemRegion; OMX_QCOMCacheAttr nCacheAttr; /** Cache attributes */ /** Input or output buffer format */ OMX_U32 nFramePackingFormat; } OMX_QCOM_PARAM_PORTDEFINITIONTYPE; typedef struct OMX_QCOM_VIDEO_PARAM_QPRANGETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 minQP; OMX_U32 maxQP; } OMX_QCOM_VIDEO_PARAM_QPRANGETYPE; #define OMX_QCOM_PLATFORMPVT_EXTN "OMX.QCOM.index.param.platformprivate" /** Allowed APIs on the above Index: OMX_SetParameter() */ typedef enum OMX_QCOM_PLATFORM_PRIVATE_ENTRY_TYPE { /** Enum for PMEM information */ OMX_QCOM_PLATFORM_PRIVATE_PMEM = 0x1 } OMX_QCOM_PLATFORM_PRIVATE_ENTRY_TYPE; /** IL client will set the following structure. A failure * code will be returned if component does not support the * value provided for 'type'. */ struct OMX_QCOM_PLATFORMPRIVATE_EXTN { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX spec version information */ OMX_U32 nPortIndex; /** Port number on which usebuffer extn is applied */ /** Type of extensions should match an entry from OMX_QCOM_PLATFORM_PRIVATE_ENTRY_TYPE */ OMX_QCOM_PLATFORM_PRIVATE_ENTRY_TYPE type; }; typedef struct OMX_QCOM_PLATFORM_PRIVATE_PMEM_INFO { /** pmem file descriptor */ unsigned long pmem_fd; /** Offset from pmem device base address */ OMX_U32 offset; OMX_U32 size; OMX_U32 mapped_size; OMX_PTR buffer; }OMX_QCOM_PLATFORM_PRIVATE_PMEM_INFO; typedef struct OMX_QCOM_PLATFORM_PRIVATE_ENTRY { /** Entry type */ OMX_QCOM_PLATFORM_PRIVATE_ENTRY_TYPE type; /** Pointer to platform specific entry */ OMX_PTR entry; }OMX_QCOM_PLATFORM_PRIVATE_ENTRY; typedef struct OMX_QCOM_PLATFORM_PRIVATE_LIST { /** Number of entries */ OMX_U32 nEntries; /** Pointer to array of platform specific entries * * Contiguous block of OMX_QCOM_PLATFORM_PRIVATE_ENTRY element */ OMX_QCOM_PLATFORM_PRIVATE_ENTRY* entryList; }OMX_QCOM_PLATFORM_PRIVATE_LIST; #define OMX_QCOM_FRAME_PACKING_FORMAT "OMX.QCOM.index.param.framepackfmt" /* Allowed API call: OMX_GetParameter() */ /* IL client can use this index to rerieve the list of frame formats * * supported by the component */ typedef struct OMX_QCOM_FRAME_PACKINGFORMAT_TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nIndex; OMX_QCOMFramePackingFormat eframePackingFormat; } OMX_QCOM_FRAME_PACKINGFORMAT_TYPE; /** * Following is the enum for color formats supported on Qualcomm * MSMs YVU420SemiPlanar color format is not defined in OpenMAX * 1.1.1 and prior versions of OpenMAX specification. */ enum OMX_QCOM_COLOR_FORMATTYPE { /** YVU420SemiPlanar: YVU planar format, organized with a first * plane containing Y pixels, and a second plane containing * interleaved V and U pixels. V and U pixels are sub-sampled * by a factor of two both horizontally and vertically. */ QOMX_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00, QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka, QOMX_COLOR_FormatYUV420PackedSemiPlanar16m2ka, QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka, QOMX_COLOR_FORMATYUV420PackedSemiPlanar32m, QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mMultiView, QOMX_COLOR_FORMATYUV420PackedSemiPlanar32mCompressed, QOMX_COLOR_Format32bitRGBA8888, QOMX_COLOR_Format32bitRGBA8888Compressed, QOMX_COLOR_FormatAndroidOpaque = (OMX_COLOR_FORMATTYPE) OMX_COLOR_FormatVendorStartUnused + 0x789, }; enum OMX_QCOM_VIDEO_CODINGTYPE { /** Codecs support by qualcomm which are not listed in OMX 1.1.x * spec * */ OMX_QCOM_VIDEO_CodingVC1 = 0x7FA30C00 , OMX_QCOM_VIDEO_CodingWMV9 = 0x7FA30C01, QOMX_VIDEO_CodingDivx = 0x7FA30C02, /**< Value when coding is Divx */ QOMX_VIDEO_CodingSpark = 0x7FA30C03, /**< Value when coding is Sorenson Spark */ QOMX_VIDEO_CodingVp = 0x7FA30C04, QOMX_VIDEO_CodingVp8 = OMX_VIDEO_CodingVP8, /**< keeping old enum for backwards compatibility*/ QOMX_VIDEO_CodingHevc = OMX_VIDEO_CodingHEVC, /**< keeping old enum for backwards compatibility*/ QOMX_VIDEO_CodingMVC = 0x7FA30C07, QOMX_VIDEO_CodingVp9 = OMX_VIDEO_CodingVP9, /**< keeping old enum for backwards compatibility*/ }; enum OMX_QCOM_EXTN_INDEXTYPE { /** Qcom proprietary extension index list */ /* "OMX.QCOM.index.param.register_mmap" */ OMX_QcomIndexRegmmap = 0x7F000000, /* "OMX.QCOM.index.param.platformprivate" */ OMX_QcomIndexPlatformPvt = 0x7F000001, /* "OMX.QCOM.index.param.portdefn" */ OMX_QcomIndexPortDefn = 0x7F000002, /* "OMX.QCOM.index.param.framepackingformat" */ OMX_QcomIndexPortFramePackFmt = 0x7F000003, /*"OMX.QCOM.index.param.Interlaced */ OMX_QcomIndexParamInterlaced = 0x7F000004, /*"OMX.QCOM.index.config.interlaceformat */ OMX_QcomIndexConfigInterlaced = 0x7F000005, /*"OMX.QCOM.index.param.syntaxhdr" */ QOMX_IndexParamVideoSyntaxHdr = 0x7F000006, /*"OMX.QCOM.index.config.intraperiod" */ QOMX_IndexConfigVideoIntraperiod = 0x7F000007, /*"OMX.QCOM.index.config.randomIntrarefresh" */ QOMX_IndexConfigVideoIntraRefresh = 0x7F000008, /*"OMX.QCOM.index.config.video.TemporalSpatialTradeOff" */ QOMX_IndexConfigVideoTemporalSpatialTradeOff = 0x7F000009, /*"OMX.QCOM.index.param.video.EncoderMode" */ QOMX_IndexParamVideoEncoderMode = 0x7F00000A, /*"OMX.QCOM.index.param.Divxtype */ OMX_QcomIndexParamVideoDivx = 0x7F00000B, /*"OMX.QCOM.index.param.Sparktype */ OMX_QcomIndexParamVideoSpark = 0x7F00000C, /*"OMX.QCOM.index.param.Vptype */ OMX_QcomIndexParamVideoVp = 0x7F00000D, OMX_QcomIndexQueryNumberOfVideoDecInstance = 0x7F00000E, OMX_QcomIndexParamVideoSyncFrameDecodingMode = 0x7F00000F, OMX_QcomIndexParamVideoDecoderPictureOrder = 0x7F000010, /* "OMX.QCOM.index.config.video.FramePackingInfo" */ OMX_QcomIndexConfigVideoFramePackingArrangement = 0x7F000011, OMX_QcomIndexParamConcealMBMapExtraData = 0x7F000012, OMX_QcomIndexParamFrameInfoExtraData = 0x7F000013, OMX_QcomIndexParamInterlaceExtraData = 0x7F000014, OMX_QcomIndexParamH264TimeInfo = 0x7F000015, OMX_QcomIndexParamIndexExtraDataType = 0x7F000016, OMX_GoogleAndroidIndexEnableAndroidNativeBuffers = 0x7F000017, OMX_GoogleAndroidIndexUseAndroidNativeBuffer = 0x7F000018, OMX_GoogleAndroidIndexGetAndroidNativeBufferUsage = 0x7F000019, /*"OMX.QCOM.index.config.video.QPRange" */ OMX_QcomIndexConfigVideoQPRange = 0x7F00001A, /*"OMX.QCOM.index.param.EnableTimeStampReoder"*/ OMX_QcomIndexParamEnableTimeStampReorder = 0x7F00001B, /*"OMX.google.android.index.storeMetaDataInBuffers"*/ OMX_QcomIndexParamVideoMetaBufferMode = 0x7F00001C, /*"OMX.google.android.index.useAndroidNativeBuffer2"*/ OMX_GoogleAndroidIndexUseAndroidNativeBuffer2 = 0x7F00001D, /*"OMX.QCOM.index.param.VideoMaxAllowedBitrateCheck"*/ OMX_QcomIndexParamVideoMaxAllowedBitrateCheck = 0x7F00001E, OMX_QcomIndexEnableSliceDeliveryMode = 0x7F00001F, /* "OMX.QCOM.index.param.video.ExtnUserExtraData" */ OMX_QcomIndexEnableExtnUserData = 0x7F000020, /*"OMX.QCOM.index.param.video.EnableSmoothStreaming"*/ OMX_QcomIndexParamEnableSmoothStreaming = 0x7F000021, /*"OMX.QCOM.index.param.video.QPRange" */ OMX_QcomIndexParamVideoQPRange = 0x7F000022, OMX_QcomIndexEnableH263PlusPType = 0x7F000023, /*"OMX.QCOM.index.param.video.LTRCountRangeSupported"*/ QOMX_IndexParamVideoLTRCountRangeSupported = 0x7F000024, /*"OMX.QCOM.index.param.video.LTRMode"*/ QOMX_IndexParamVideoLTRMode = 0x7F000025, /*"OMX.QCOM.index.param.video.LTRCount"*/ QOMX_IndexParamVideoLTRCount = 0x7F000026, /*"OMX.QCOM.index.config.video.LTRPeriod"*/ QOMX_IndexConfigVideoLTRPeriod = 0x7F000027, /*"OMX.QCOM.index.config.video.LTRUse"*/ QOMX_IndexConfigVideoLTRUse = 0x7F000028, /*"OMX.QCOM.index.config.video.LTRMark"*/ QOMX_IndexConfigVideoLTRMark = 0x7F000029, /* OMX.google.android.index.prependSPSPPSToIDRFrames */ OMX_QcomIndexParamSequenceHeaderWithIDR = 0x7F00002A, OMX_QcomIndexParamH264AUDelimiter = 0x7F00002B, OMX_QcomIndexParamVideoDownScalar = 0x7F00002C, /* "OMX.QCOM.index.param.video.FramePackingExtradata" */ OMX_QcomIndexParamVideoFramePackingExtradata = 0x7F00002D, /* "OMX.QCOM.index.config.activeregiondetection" */ OMX_QcomIndexConfigActiveRegionDetection = 0x7F00002E, /* "OMX.QCOM.index.config.activeregiondetectionstatus" */ OMX_QcomIndexConfigActiveRegionDetectionStatus = 0x7F00002F, /* "OMX.QCOM.index.config.scalingmode" */ OMX_QcomIndexConfigScalingMode = 0x7F000030, /* "OMX.QCOM.index.config.noisereduction" */ OMX_QcomIndexConfigNoiseReduction = 0x7F000031, /* "OMX.QCOM.index.config.imageenhancement" */ OMX_QcomIndexConfigImageEnhancement = 0x7F000032, /* google smooth-streaming support */ OMX_QcomIndexParamVideoAdaptivePlaybackMode = 0x7F000033, /* H.264 MVC codec index */ QOMX_IndexParamVideoMvc = 0x7F000034, /* "OMX.QCOM.index.param.video.QPExtradata" */ OMX_QcomIndexParamVideoQPExtraData = 0x7F000035, /* "OMX.QCOM.index.param.video.InputBitsInfoExtradata" */ OMX_QcomIndexParamVideoInputBitsInfoExtraData = 0x7F000036, /* VP8 Hierarchical P support */ OMX_QcomIndexHierarchicalStructure = 0x7F000037, OMX_QcomIndexParamPerfLevel = 0x7F000038, OMX_QcomIndexParamH264VUITimingInfo = 0x7F000039, OMX_QcomIndexParamPeakBitrate = 0x7F00003A, /* Enable InitialQP index */ QOMX_IndexParamVideoInitialQp = 0x7F00003B, OMX_QcomIndexParamSetMVSearchrange = 0x7F00003C, OMX_QcomIndexConfigPerfLevel = 0x7F00003D, /*"OMX.QCOM.index.param.video.LTRCount"*/ OMX_QcomIndexParamVideoLTRCount = QOMX_IndexParamVideoLTRCount, /*"OMX.QCOM.index.config.video.LTRUse"*/ OMX_QcomIndexConfigVideoLTRUse = QOMX_IndexConfigVideoLTRUse, /*"OMX.QCOM.index.config.video.LTRMark"*/ OMX_QcomIndexConfigVideoLTRMark = QOMX_IndexConfigVideoLTRMark, /*"OMX.QCOM.index.param.video.CustomBufferSize"*/ OMX_QcomIndexParamVideoCustomBufferSize = 0x7F00003E, /* Max Hierarchical P layers */ OMX_QcomIndexMaxHierarchicallayers = 0x7F000041, /* Set Encoder Performance Index */ OMX_QcomIndexConfigVideoVencPerfMode = 0x7F000042, /* Set Hybrid Hier-p layers */ OMX_QcomIndexParamVideoHybridHierpMode = 0x7F000043, OMX_QcomIndexFlexibleYUVDescription = 0x7F000044, /* Vpp Hqv Control Type */ OMX_QcomIndexParamVppHqvControl = 0x7F000045, /* Enable VPP */ OMX_QcomIndexParamEnableVpp = 0x7F000046, /* MBI statistics mode */ OMX_QcomIndexParamMBIStatisticsMode = 0x7F000047, /* Set PictureTypeDecode */ OMX_QcomIndexConfigPictureTypeDecode = 0x7F000048, OMX_QcomIndexConfigH264EntropyCodingCabac = 0x7F000049, /* "OMX.QCOM.index.param.video.InputBatch" */ OMX_QcomIndexParamBatchSize = 0x7F00004A, OMX_QcomIndexConfigNumHierPLayers = 0x7F00004B, OMX_QcomIndexConfigRectType = 0x7F00004C, OMX_QcomIndexConfigBaseLayerId = 0x7F00004E, OMX_QcomIndexParamDriverVersion = 0x7F00004F, OMX_QcomIndexConfigQp = 0x7F000050, OMX_QcomIndexParamVencAspectRatio = 0x7F000051, OMX_QTIIndexParamVQZipSEIExtraData = 0x7F000052, /* Enable VQZIP SEI NAL type */ OMX_QTIIndexParamVQZIPSEIType = 0x7F000053, OMX_QTIIndexParamPassInputBufferFd = 0x7F000054, /* Set Prefer-adaptive playback*/ /* "OMX.QTI.index.param.video.PreferAdaptivePlayback" */ OMX_QTIIndexParamVideoPreferAdaptivePlayback = 0x7F000055, /* Set time params */ OMX_QTIIndexConfigSetTimeData = 0x7F000056, /* Force Compressed format for DPB when resolution <=1080p * and OPB is cpu_access */ /* OMX.QTI.index.param.video.ForceCompressedForDPB */ OMX_QTIIndexParamForceCompressedForDPB = 0x7F000057, /* Enable ROI info */ OMX_QTIIndexParamVideoEnableRoiInfo = 0x7F000058, /* Configure ROI info */ OMX_QTIIndexConfigVideoRoiInfo = 0x7F000059, /* Set Low Latency Mode */ OMX_QTIIndexParamLowLatencyMode = 0x7F00005A, /* Force OPB to UnCompressed mode */ OMX_QTIIndexParamForceUnCompressedForOPB = 0x7F00005B, }; /** * This is custom extension to configure Low Latency Mode. * * STRUCT MEMBERS * * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * bLowLatencyMode : Enable/Disable Low Latency mode */ typedef struct QOMX_EXTNINDEX_VIDEO_VENC_LOW_LATENCY_MODE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_BOOL bLowLatencyMode; } QOMX_EXTNINDEX_VIDEO_VENC_LOW_LATENCY_MODE; /** * This is custom extension to configure Encoder Aspect Ratio. * * STRUCT MEMBERS * * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nSARWidth : Horizontal aspect size * nSARHeight : Vertical aspect size */ typedef struct QOMX_EXTNINDEX_VIDEO_VENC_SAR { OMX_U32 nSize; OMX_U32 nVersion; OMX_U32 nSARWidth; OMX_U32 nSARHeight; } QOMX_EXTNINDEX_VIDEO_VENC_SAR; /** * This is custom extension to configure Hier-p layers. * This mode configures Hier-p layers dynamically. * * STRUCT MEMBERS * * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nNumHierLayers: Set the number of Hier-p layers for the session * - This should be less than the MAX Hier-P * layers set for the session. */ typedef struct QOMX_EXTNINDEX_VIDEO_HIER_P_LAYERS { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nNumHierLayers; } QOMX_EXTNINDEX_VIDEO_HIER_P_LAYERS; /** * This is custom extension to configure Hybrid Hier-p settings. * This mode is different from enabling Hier-p mode. This * property enables Hier-p encoding with LTR referencing in each * sub-GOP. * * STRUCT MEMBERS * * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nKeyFrameInterval : Indicates the I frame interval * nHpLayers : Set the number of Hier-p layers for the session * - This should be <= 6. (1 Base layer + * 5 Enhancement layers) * nTemporalLayerBitrateRatio[OMX_VIDEO_MAX_HP_LAYERS] : Bitrate to * be set for each enhancement layer * nMinQuantizer : minimum session QP * nMaxQuantizer : Maximun session QP */ typedef struct QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nKeyFrameInterval; OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_MAX_HP_LAYERS]; OMX_U32 nMinQuantizer; OMX_U32 nMaxQuantizer; OMX_U32 nHpLayers; } QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE; /** * Encoder Performance Mode. This structure is used to set * performance mode or power save mode when encoding. The search * range is modified to save power or improve quality. * * STRUCT MEMBERS: * OMX_U32 nPerfMode : Performance mode: * 1: MAX_QUALITY * 2: POWER_SAVE */ typedef struct QOMX_EXTNINDEX_VIDEO_PERFMODE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPerfMode; } QOMX_EXTNINDEX_VIDEO_PERFMODE; /** * Initial QP parameter. This structure is used to enable * vendor specific extension to let client enable setting * initial QP values to I P B Frames * * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * OMX_U32 nQpI : First Iframe QP * OMX_U32 nQpP : First Pframe QP * OMX_U32 nQpB : First Bframe QP * OMX_U32 bEnableInitQp : Bit field indicating which frame type(s) shall * use the specified initial QP. * Bit 0: Enable initial QP for I/IDR * and use value specified in nInitQpI * Bit 1: Enable initial QP for P * and use value specified in nInitQpP * Bit 2: Enable initial QP for B * and use value specified in nInitQpB */ typedef struct QOMX_EXTNINDEX_VIDEO_INITIALQP { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nQpI; OMX_U32 nQpP; OMX_U32 nQpB; OMX_U32 bEnableInitQp; } QOMX_EXTNINDEX_VIDEO_INITIALQP; /** * Extension index parameter. This structure is used to enable * vendor specific extension on input/output port and * to pass the required flags and data, if any. * The format of flags and data being passed is known to * the client and component apriori. * * STRUCT MEMBERS: * nSize : Size of Structure plus pData size * nVersion : OMX specification version information * nPortIndex : Indicates which port to set * bEnable : Extension index enable (1) or disable (0) * nFlags : Extension index flags, if any * nDataSize : Size of the extension index data to follow * pData : Extension index data, if present. */ typedef struct QOMX_EXTNINDEX_PARAMTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnable; OMX_U32 nFlags; OMX_U32 nDataSize; OMX_PTR pData; } QOMX_EXTNINDEX_PARAMTYPE; /** * Range index parameter. This structure is used to enable * vendor specific extension on input/output port and * to pass the required minimum and maximum values * * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * nMin : Minimum value * nMax : Maximum value * nSteSize : Step size */ typedef struct QOMX_EXTNINDEX_RANGETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_S32 nMin; OMX_S32 nMax; OMX_S32 nStepSize; } QOMX_EXTNINDEX_RANGETYPE; /** * Specifies LTR mode types. */ typedef enum QOMX_VIDEO_LTRMODETYPE { QOMX_VIDEO_LTRMode_Disable = 0x0, /**< LTR encoding is disabled */ QOMX_VIDEO_LTRMode_Manual = 0x1, /**< In this mode, IL client configures ** the encoder the LTR count and manually ** controls the marking and use of LTR ** frames during video encoding. */ QOMX_VIDEO_LTRMode_Auto = 0x2, /**< In this mode, IL client configures ** the encoder the LTR count and LTR ** period. The encoder marks LTR frames ** automatically based on the LTR period ** during video encoding. IL client controls ** the use of LTR frames. */ QOMX_VIDEO_LTRMode_MAX = 0x7FFFFFFF /** Maximum LTR Mode type */ } QOMX_VIDEO_LTRMODETYPE; /** * LTR mode index parameter. This structure is used * to enable vendor specific extension on output port * to pass the LTR mode information. * * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * eLTRMode : Specifies the LTR mode used in encoder */ typedef struct QOMX_VIDEO_PARAM_LTRMODE_TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; QOMX_VIDEO_LTRMODETYPE eLTRMode; } QOMX_VIDEO_PARAM_LTRMODE_TYPE; /** * LTR count index parameter. This structure is used * to enable vendor specific extension on output port * to pass the LTR count information. * * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * nCount : Specifies the number of LTR frames stored in the * encoder component */ typedef struct QOMX_VIDEO_PARAM_LTRCOUNT_TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nCount; } QOMX_VIDEO_PARAM_LTRCOUNT_TYPE; /** * This should be used with OMX_QcomIndexParamVideoLTRCount extension. */ typedef QOMX_VIDEO_PARAM_LTRCOUNT_TYPE OMX_QCOM_VIDEO_PARAM_LTRCOUNT_TYPE; /** * LTR period index parameter. This structure is used * to enable vendor specific extension on output port * to pass the LTR period information. * * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * nFrames : Specifies the number of frames between two consecutive * LTR frames. */ typedef struct QOMX_VIDEO_CONFIG_LTRPERIOD_TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nFrames; } QOMX_VIDEO_CONFIG_LTRPERIOD_TYPE; /** * Marks the next encoded frame as an LTR frame. * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * nID : Specifies the identifier of the LTR frame to be marked * as reference frame for encoding subsequent frames. */ typedef struct QOMX_VIDEO_CONFIG_LTRMARK_TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nID; } QOMX_VIDEO_CONFIG_LTRMARK_TYPE; /** * This should be used with OMX_QcomIndexConfigVideoLTRMark extension. */ typedef QOMX_VIDEO_CONFIG_LTRMARK_TYPE OMX_QCOM_VIDEO_CONFIG_LTRMARK_TYPE; /** * Specifies an LTR frame to encode subsequent frames. * STRUCT MEMBERS: * nSize : Size of Structure in bytes * nVersion : OpenMAX IL specification version information * nPortIndex : Index of the port to which this structure applies * nID : Specifies the identifier of the LTR frame to be used as reference frame for encoding subsequent frames. * nFrames : Specifies the number of subsequent frames to be encoded using the LTR frame with its identifier nID as reference frame. Short-term reference frames will be used thereafter. The value of 0xFFFFFFFF indicates that all subsequent frames will be encodedusing this LTR frame as reference frame. */ typedef struct QOMX_VIDEO_CONFIG_LTRUSE_TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nID; OMX_U32 nFrames; } QOMX_VIDEO_CONFIG_LTRUSE_TYPE; /** * This should be used with OMX_QcomIndexConfigVideoLTRUse extension. */ typedef QOMX_VIDEO_CONFIG_LTRUSE_TYPE OMX_QCOM_VIDEO_CONFIG_LTRUSE_TYPE; /** * Enumeration used to define the video encoder modes * * ENUMS: * EncoderModeDefault : Default video recording mode. * All encoder settings made through * OMX_SetParameter/OMX_SetConfig are applied. No * parameter is overridden. * EncoderModeMMS : Video recording mode for MMS (Multimedia Messaging * Service). This mode is similar to EncoderModeDefault * except that here the Rate control mode is overridden * internally and set as a variant of variable bitrate with * variable frame rate. After this mode is set if the IL * client tries to set OMX_VIDEO_CONTROLRATETYPE via * OMX_IndexParamVideoBitrate that would be rejected. For * this, client should set mode back to EncoderModeDefault * first and then change OMX_VIDEO_CONTROLRATETYPE. */ typedef enum QOMX_VIDEO_ENCODERMODETYPE { QOMX_VIDEO_EncoderModeDefault = 0x00, QOMX_VIDEO_EncoderModeMMS = 0x01, QOMX_VIDEO_EncoderModeMax = 0x7FFFFFFF } QOMX_VIDEO_ENCODERMODETYPE; /** * This structure is used to set the video encoder mode. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version info * nPortIndex : Port that this structure applies to * nMode : defines the video encoder mode */ typedef struct QOMX_VIDEO_PARAM_ENCODERMODETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; QOMX_VIDEO_ENCODERMODETYPE nMode; } QOMX_VIDEO_PARAM_ENCODERMODETYPE; /** * This structure describes the parameters corresponding to the * QOMX_VIDEO_SYNTAXHDRTYPE extension. This parameter can be queried * during the loaded state. */ typedef struct QOMX_VIDEO_SYNTAXHDRTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nBytes; /** The number of bytes filled in to the buffer */ OMX_U8 data[1]; /** Buffer to store the header information */ } QOMX_VIDEO_SYNTAXHDRTYPE; /** * This structure describes the parameters corresponding to the * QOMX_VIDEO_TEMPORALSPATIALTYPE extension. This parameter can be set * dynamically during any state except the state invalid. This is primarily * used for setting MaxQP from the application. This is set on the out port. */ typedef struct QOMX_VIDEO_TEMPORALSPATIALTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nTSFactor; /** Temoral spatial tradeoff factor value in 0-100 */ } QOMX_VIDEO_TEMPORALSPATIALTYPE; /** * This structure describes the parameters corresponding to the * OMX_QCOM_VIDEO_CONFIG_INTRAPERIODTYPE extension. This parameter can be set * dynamically during any state except the state invalid. This is set on the out port. */ typedef struct QOMX_VIDEO_INTRAPERIODTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nIDRPeriod; /** This specifies coding a frame as IDR after every nPFrames of intra frames. If this parameter is set to 0, only the first frame of the encode session is an IDR frame. This field is ignored for non-AVC codecs and is used only for codecs that support IDR Period */ OMX_U32 nPFrames; /** The number of "P" frames between two "I" frames */ OMX_U32 nBFrames; /** The number of "B" frames between two "I" frames */ } QOMX_VIDEO_INTRAPERIODTYPE; /** * This structure describes the parameters corresponding to the * OMX_QCOM_VIDEO_CONFIG_ULBUFFEROCCUPANCYTYPE extension. This parameter can be set * dynamically during any state except the state invalid. This is used for the buffer negotiation * with other clients. This is set on the out port. */ typedef struct OMX_QCOM_VIDEO_CONFIG_ULBUFFEROCCUPANCYTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nBufferOccupancy; /** The number of bytes to be set for the buffer occupancy */ } OMX_QCOM_VIDEO_CONFIG_ULBUFFEROCCUPANCYTYPE; /** * This structure describes the parameters corresponding to the * OMX_QCOM_VIDEO_CONFIG_RANDOMINTRAREFRESHTYPE extension. This parameter can be set * dynamically during any state except the state invalid. This is primarily used for the dynamic/random * intrarefresh. This is set on the out port. */ typedef struct OMX_QCOM_VIDEO_CONFIG_RANDOMINTRAREFRESHTYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nRirMBs; /** The number of MBs to be set for intrarefresh */ } OMX_QCOM_VIDEO_CONFIG_RANDOMINTRAREFRESHTYPE; /** * This structure describes the parameters corresponding to the * OMX_QCOM_VIDEO_CONFIG_QPRANGE extension. This parameter can be set * dynamically during any state except the state invalid. This is primarily * used for the min/max QP to be set from the application. This * is set on the out port. */ typedef struct OMX_QCOM_VIDEO_CONFIG_QPRANGE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nMinQP; /** The number for minimum quantization parameter */ OMX_U32 nMaxQP; /** The number for maximum quantization parameter */ } OMX_QCOM_VIDEO_CONFIG_QPRANGE; /** * This structure describes the parameters for the * OMX_QcomIndexParamH264AUDelimiter extension. It enables/disables * the AU delimiters in the H264 stream, which is used by WFD. */ typedef struct OMX_QCOM_VIDEO_CONFIG_H264_AUD { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_BOOL bEnable; /** Enable/disable the setting */ } OMX_QCOM_VIDEO_CONFIG_H264_AUD; typedef enum QOMX_VIDEO_PERF_LEVEL { OMX_QCOM_PerfLevelNominal, OMX_QCOM_PerfLevelTurbo } QOMX_VIDEO_PERF_LEVEL; /** * This structure describes the parameters corresponding * to OMX_QcomIndexParamPerfLevel extension. It will set * the performance mode specified as QOMX_VIDEO_PERF_LEVEL. */ typedef struct OMX_QCOM_VIDEO_PARAM_PERF_LEVEL { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ QOMX_VIDEO_PERF_LEVEL ePerfLevel; /** Performance level */ } OMX_QCOM_VIDEO_PARAM_PERF_LEVEL; /** * This structure describes the parameters corresponding * to OMX_QcomIndexConfigPerfLevel extension. It will set * the performance mode specified as QOMX_VIDEO_PERF_LEVEL. */ typedef struct OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ QOMX_VIDEO_PERF_LEVEL ePerfLevel; /** Performance level */ } OMX_QCOM_VIDEO_CONFIG_PERF_LEVEL; typedef enum QOMX_VIDEO_PICTURE_TYPE_DECODE { OMX_QCOM_PictypeDecode_IPB, OMX_QCOM_PictypeDecode_I } QOMX_VIDEO_PICTURE_TYPE_DECODE; /** * This structure describes the parameters corresponding * to OMX_QcomIndexConfigPictureTypeDecode extension. It * will set the picture type decode specified by eDecodeType. */ typedef struct OMX_QCOM_VIDEO_CONFIG_PICTURE_TYPE_DECODE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ QOMX_VIDEO_PICTURE_TYPE_DECODE eDecodeType; /** Decode type */ } OMX_QCOM_VIDEO_CONFIG_PICTURE_TYPE_DECODE; /** * This structure describes the parameters corresponding * to OMX_QcomIndexParamH264VUITimingInfo extension. It * will enable/disable the VUI timing info. */ typedef struct OMX_QCOM_VIDEO_PARAM_VUI_TIMING_INFO { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ OMX_BOOL bEnable; /** Enable/disable the setting */ } OMX_QCOM_VIDEO_PARAM_VUI_TIMING_INFO; /** * This structure describes the parameters corresponding * to OMX_QcomIndexParamVQZIPSEIType extension. It * will enable/disable the VQZIP SEI info. */ typedef struct OMX_QTI_VIDEO_PARAM_VQZIP_SEI_TYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ OMX_BOOL bEnable; /** Enable/disable the setting */ } OMX_QTI_VIDEO_PARAM_VQZIP_SEI_TYPE; /** * This structure describes the parameters corresponding * to OMX_QcomIndexParamPeakBitrate extension. It will * set the peak bitrate specified by nPeakBitrate. */ typedef struct OMX_QCOM_VIDEO_PARAM_PEAK_BITRATE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ OMX_U32 nPeakBitrate; /** Peak bitrate value */ } OMX_QCOM_VIDEO_PARAM_PEAK_BITRATE; /** * This structure describes the parameters corresponding * to OMX_QTIIndexParamForceCompressedForDPB extension. Enabling * this extension will force the split mode DPB(compressed)/OPB(Linear) * for all resolutions.On some chipsets preferred mode would be combined * Linear for both DPB/OPB to save memory. For example on 8996 preferred mode * would be combined linear for resolutions <= 1080p . * Enabling this might save power but with the cost * of increased memory i.e almost double the number on output YUV buffers. */ typedef struct OMX_QTI_VIDEO_PARAM_FORCE_COMPRESSED_FOR_DPB_TYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ OMX_BOOL bEnable; /** Enable/disable the setting */ } OMX_QTI_VIDEO_PARAM_FORCE_COMPRESSED_FOR_DPB_TYPE; /** * This structure describes the parameters corresponding * to OMX_QTIIndexParamForceUnCompressedForOPB extension. Enabling this * extension will force the OPB to be linear for the current video session. * If this property is not set, then the OPB will be set to linear or compressed * based on resolution selected and/or if cpu access is requested on the * OPB buffer. */ typedef struct OMX_QTI_VIDEO_PARAM_FORCE_UNCOMPRESSED_FOR_OPB_TYPE { OMX_U32 nSize; /** Sizeo f the structure in bytes */ OMX_VERSIONTYPE nVersion; /** OMX specification version information */ OMX_BOOL bEnable; /** Enable/disable the setting */ } OMX_QTI_VIDEO_PARAM_FORCE_UNCOMPRESSED_FOR_OPB_TYPE; typedef struct OMX_VENDOR_EXTRADATATYPE { OMX_U32 nPortIndex; OMX_U32 nDataSize; OMX_U8 *pData; // cdata (codec_data/extradata) } OMX_VENDOR_EXTRADATATYPE; /** * This structure describes the parameters corresponding to the * OMX_VENDOR_VIDEOFRAMERATE extension. This parameter can be set * dynamically during any state except the state invalid. This is * used for frame rate to be set from the application. This * is set on the in port. */ typedef struct OMX_VENDOR_VIDEOFRAMERATE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_U32 nFps; /** Frame rate value */ OMX_BOOL bEnabled; /** Flag to enable or disable client's frame rate value */ } OMX_VENDOR_VIDEOFRAMERATE; typedef enum OMX_INDEXVENDORTYPE { OMX_IndexVendorFileReadInputFilename = 0xFF000001, OMX_IndexVendorParser3gpInputFilename = 0xFF000002, OMX_IndexVendorVideoExtraData = 0xFF000003, OMX_IndexVendorAudioExtraData = 0xFF000004, OMX_IndexVendorVideoFrameRate = 0xFF000005, } OMX_INDEXVENDORTYPE; typedef enum OMX_QCOM_VC1RESOLUTIONTYPE { OMX_QCOM_VC1_PICTURE_RES_1x1, OMX_QCOM_VC1_PICTURE_RES_2x1, OMX_QCOM_VC1_PICTURE_RES_1x2, OMX_QCOM_VC1_PICTURE_RES_2x2 } OMX_QCOM_VC1RESOLUTIONTYPE; typedef enum OMX_QCOM_INTERLACETYPE { OMX_QCOM_InterlaceFrameProgressive, OMX_QCOM_InterlaceInterleaveFrameTopFieldFirst, OMX_QCOM_InterlaceInterleaveFrameBottomFieldFirst, OMX_QCOM_InterlaceFrameTopFieldFirst, OMX_QCOM_InterlaceFrameBottomFieldFirst, OMX_QCOM_InterlaceFieldTop, OMX_QCOM_InterlaceFieldBottom }OMX_QCOM_INTERLACETYPE; typedef struct OMX_QCOM_PARAM_VIDEO_INTERLACETYPE { OMX_U32 nSize; /** Size of the structure in bytes */ OMX_VERSIONTYPE nVersion;/** OMX specification version information */ OMX_U32 nPortIndex; /** Portindex which is extended by this structure */ OMX_BOOL bInterlace; /** Interlace content **/ }OMX_QCOM_PARAM_VIDEO_INTERLACETYPE; typedef struct OMX_QCOM_CONFIG_INTERLACETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nIndex; OMX_QCOM_INTERLACETYPE eInterlaceType; }OMX_QCOM_CONFIG_INTERLACETYPE; #define MAX_PAN_SCAN_WINDOWS 4 typedef struct OMX_QCOM_PANSCAN { OMX_U32 numWindows; OMX_QCOMRectangle window[MAX_PAN_SCAN_WINDOWS]; } OMX_QCOM_PANSCAN; typedef struct OMX_QCOM_ASPECT_RATIO { OMX_U32 aspectRatioX; OMX_U32 aspectRatioY; } OMX_QCOM_ASPECT_RATIO; typedef struct OMX_QCOM_DISPLAY_ASPECT_RATIO { OMX_U32 displayVerticalSize; OMX_U32 displayHorizontalSize; } OMX_QCOM_DISPLAY_ASPECT_RATIO; typedef struct OMX_QCOM_FRAME_PACK_ARRANGEMENT { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 id; OMX_U32 cancel_flag; OMX_U32 type; OMX_U32 quincunx_sampling_flag; OMX_U32 content_interpretation_type; OMX_U32 spatial_flipping_flag; OMX_U32 frame0_flipped_flag; OMX_U32 field_views_flag; OMX_U32 current_frame_is_frame0_flag; OMX_U32 frame0_self_contained_flag; OMX_U32 frame1_self_contained_flag; OMX_U32 frame0_grid_position_x; OMX_U32 frame0_grid_position_y; OMX_U32 frame1_grid_position_x; OMX_U32 frame1_grid_position_y; OMX_U32 reserved_byte; OMX_U32 repetition_period; OMX_U32 extension_flag; } OMX_QCOM_FRAME_PACK_ARRANGEMENT; typedef struct OMX_QCOM_EXTRADATA_QP { OMX_U32 nQP; } OMX_QCOM_EXTRADATA_QP; typedef struct OMX_QCOM_EXTRADATA_BITS_INFO { OMX_U32 header_bits; OMX_U32 frame_bits; } OMX_QCOM_EXTRADATA_BITS_INFO; typedef struct OMX_QCOM_EXTRADATA_USERDATA { OMX_U32 type; OMX_U32 data[1]; } OMX_QCOM_EXTRADATA_USERDATA; typedef struct OMX_QCOM_EXTRADATA_FRAMEINFO { // common frame meta data. interlace related info removed OMX_VIDEO_PICTURETYPE ePicType; OMX_QCOM_INTERLACETYPE interlaceType; OMX_QCOM_PANSCAN panScan; OMX_QCOM_ASPECT_RATIO aspectRatio; OMX_QCOM_DISPLAY_ASPECT_RATIO displayAspectRatio; OMX_U32 nConcealedMacroblocks; OMX_U32 nFrameRate; OMX_TICKS nTimeStamp; } OMX_QCOM_EXTRADATA_FRAMEINFO; typedef struct OMX_QCOM_EXTRADATA_FRAMEDIMENSION { /** Frame Dimensions added to each YUV buffer */ OMX_U32 nDecWidth; /** Width rounded to multiple of 16 */ OMX_U32 nDecHeight; /** Height rounded to multiple of 16 */ OMX_U32 nActualWidth; /** Actual Frame Width */ OMX_U32 nActualHeight; /** Actual Frame Height */ } OMX_QCOM_EXTRADATA_FRAMEDIMENSION; typedef struct OMX_QCOM_H264EXTRADATA { OMX_U64 seiTimeStamp; } OMX_QCOM_H264EXTRADATA; typedef struct OMX_QCOM_VC1EXTRADATA { OMX_U32 nVC1RangeY; OMX_U32 nVC1RangeUV; OMX_QCOM_VC1RESOLUTIONTYPE eVC1PicResolution; } OMX_QCOM_VC1EXTRADATA; typedef union OMX_QCOM_EXTRADATA_CODEC_DATA { OMX_QCOM_H264EXTRADATA h264ExtraData; OMX_QCOM_VC1EXTRADATA vc1ExtraData; } OMX_QCOM_EXTRADATA_CODEC_DATA; typedef struct OMX_QCOM_EXTRADATA_MBINFO { OMX_U32 nFormat; OMX_U32 nDataSize; OMX_U8 data[0]; } OMX_QCOM_EXTRADATA_MBINFO; typedef struct OMX_QCOM_EXTRADATA_VQZIPSEI { OMX_U32 nSize; OMX_U8 data[0]; } OMX_QCOM_EXTRADATA_VQZIPSEI; typedef struct OMX_QTI_VIDEO_PARAM_ENABLE_ROIINFO { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnableRoiInfo; } OMX_QTI_VIDEO_PARAM_ENABLE_ROIINFO; typedef struct OMX_QTI_VIDEO_CONFIG_ROIINFO { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_S32 nUpperQpOffset; OMX_S32 nLowerQpOffset; OMX_BOOL bUseRoiInfo; OMX_S32 nRoiMBInfoSize; OMX_PTR pRoiMBInfo; } OMX_QTI_VIDEO_CONFIG_ROIINFO; typedef enum OMX_QCOM_EXTRADATATYPE { OMX_ExtraDataFrameInfo = 0x7F000001, OMX_ExtraDataH264 = 0x7F000002, OMX_ExtraDataVC1 = 0x7F000003, OMX_ExtraDataFrameDimension = 0x7F000004, OMX_ExtraDataVideoEncoderSliceInfo = 0x7F000005, OMX_ExtraDataConcealMB = 0x7F000006, OMX_ExtraDataInterlaceFormat = 0x7F000007, OMX_ExtraDataPortDef = 0x7F000008, OMX_ExtraDataMP2ExtnData = 0x7F000009, OMX_ExtraDataMP2UserData = 0x7F00000a, OMX_ExtraDataVideoLTRInfo = 0x7F00000b, OMX_ExtraDataFramePackingArrangement = 0x7F00000c, OMX_ExtraDataQP = 0x7F00000d, OMX_ExtraDataInputBitsInfo = 0x7F00000e, OMX_ExtraDataVideoEncoderMBInfo = 0x7F00000f, OMX_ExtraDataVQZipSEI = 0x7F000010, } OMX_QCOM_EXTRADATATYPE; typedef struct OMX_STREAMINTERLACEFORMATTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bInterlaceFormat; OMX_U32 nInterlaceFormats; } OMX_STREAMINTERLACEFORMAT; typedef enum OMX_INTERLACETYPE { OMX_InterlaceFrameProgressive, OMX_InterlaceInterleaveFrameTopFieldFirst, OMX_InterlaceInterleaveFrameBottomFieldFirst, OMX_InterlaceFrameTopFieldFirst, OMX_InterlaceFrameBottomFieldFirst } OMX_INTERLACES; #define OMX_EXTRADATA_HEADER_SIZE 20 /** * AVC profile types, each profile indicates support for various * performance bounds and different annexes. */ typedef enum QOMX_VIDEO_AVCPROFILETYPE { QOMX_VIDEO_AVCProfileBaseline = OMX_VIDEO_AVCProfileBaseline, QOMX_VIDEO_AVCProfileMain = OMX_VIDEO_AVCProfileMain, QOMX_VIDEO_AVCProfileExtended = OMX_VIDEO_AVCProfileExtended, QOMX_VIDEO_AVCProfileHigh = OMX_VIDEO_AVCProfileHigh, QOMX_VIDEO_AVCProfileHigh10 = OMX_VIDEO_AVCProfileHigh10, QOMX_VIDEO_AVCProfileHigh422 = OMX_VIDEO_AVCProfileHigh422, QOMX_VIDEO_AVCProfileHigh444 = OMX_VIDEO_AVCProfileHigh444, /* QCom specific profile indexes */ QOMX_VIDEO_AVCProfileConstrained = OMX_VIDEO_AVCProfileVendorStartUnused, QOMX_VIDEO_AVCProfileConstrainedBaseline, QOMX_VIDEO_AVCProfileConstrainedHigh, } QOMX_VIDEO_AVCPROFILETYPE; /** * H.264 MVC Profiles */ typedef enum QOMX_VIDEO_MVCPROFILETYPE { QOMX_VIDEO_MVCProfileStereoHigh = 0x1, QOMX_VIDEO_MVCProfileMultiViewHigh = 0x2, QOMX_VIDEO_MVCProfileKhronosExtensions = 0x6F000000, QOMX_VIDEO_MVCProfileVendorStartUnused = 0x7F000000, QOMX_VIDEO_MVCProfileMax = 0x7FFFFFFF } QOMX_VIDEO_MVCPROFILETYPE; /** * H.264 MVC Levels */ typedef enum QOMX_VIDEO_MVCLEVELTYPE { QOMX_VIDEO_MVCLevel1 = 0x01, /**< Level 1 */ QOMX_VIDEO_MVCLevel1b = 0x02, /**< Level 1b */ QOMX_VIDEO_MVCLevel11 = 0x04, /**< Level 1.1 */ QOMX_VIDEO_MVCLevel12 = 0x08, /**< Level 1.2 */ QOMX_VIDEO_MVCLevel13 = 0x10, /**< Level 1.3 */ QOMX_VIDEO_MVCLevel2 = 0x20, /**< Level 2 */ QOMX_VIDEO_MVCLevel21 = 0x40, /**< Level 2.1 */ QOMX_VIDEO_MVCLevel22 = 0x80, /**< Level 2.2 */ QOMX_VIDEO_MVCLevel3 = 0x100, /**< Level 3 */ QOMX_VIDEO_MVCLevel31 = 0x200, /**< Level 3.1 */ QOMX_VIDEO_MVCLevel32 = 0x400, /**< Level 3.2 */ QOMX_VIDEO_MVCLevel4 = 0x800, /**< Level 4 */ QOMX_VIDEO_MVCLevel41 = 0x1000, /**< Level 4.1 */ QOMX_VIDEO_MVCLevel42 = 0x2000, /**< Level 4.2 */ QOMX_VIDEO_MVCLevel5 = 0x4000, /**< Level 5 */ QOMX_VIDEO_MVCLevel51 = 0x8000, /**< Level 5.1 */ QOMX_VIDEO_MVCLevelKhronosExtensions = 0x6F000000, QOMX_VIDEO_MVCLevelVendorStartUnused = 0x7F000000, QOMX_VIDEO_MVCLevelMax = 0x7FFFFFFF } QOMX_VIDEO_MVCLEVELTYPE; /** * DivX Versions */ typedef enum QOMX_VIDEO_DIVXFORMATTYPE { QOMX_VIDEO_DIVXFormatUnused = 0x01, /**< Format unused or unknown */ QOMX_VIDEO_DIVXFormat311 = 0x02, /**< DivX 3.11 */ QOMX_VIDEO_DIVXFormat4 = 0x04, /**< DivX 4 */ QOMX_VIDEO_DIVXFormat5 = 0x08, /**< DivX 5 */ QOMX_VIDEO_DIVXFormat6 = 0x10, /**< DivX 6 */ QOMX_VIDEO_DIVXFormatKhronosExtensions = 0x6F000000, QOMX_VIDEO_DIVXFormatVendorStartUnused = 0x7F000000, QOMX_VIDEO_DIVXFormatMax = 0x7FFFFFFF } QOMX_VIDEO_DIVXFORMATTYPE; /** * DivX profile types, each profile indicates support for * various performance bounds. */ typedef enum QOMX_VIDEO_DIVXPROFILETYPE { QOMX_VIDEO_DivXProfileqMobile = 0x01, /**< qMobile Profile */ QOMX_VIDEO_DivXProfileMobile = 0x02, /**< Mobile Profile */ QOMX_VIDEO_DivXProfileMT = 0x04, /**< Mobile Theatre Profile */ QOMX_VIDEO_DivXProfileHT = 0x08, /**< Home Theatre Profile */ QOMX_VIDEO_DivXProfileHD = 0x10, /**< High Definition Profile */ QOMX_VIDEO_DIVXProfileKhronosExtensions = 0x6F000000, QOMX_VIDEO_DIVXProfileVendorStartUnused = 0x7F000000, QOMX_VIDEO_DIVXProfileMax = 0x7FFFFFFF } QOMX_VIDEO_DIVXPROFILETYPE; /** * DivX Video Params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFormat : Version of DivX stream / data * eProfile : Profile of DivX stream / data */ typedef struct QOMX_VIDEO_PARAM_DIVXTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; QOMX_VIDEO_DIVXFORMATTYPE eFormat; QOMX_VIDEO_DIVXPROFILETYPE eProfile; } QOMX_VIDEO_PARAM_DIVXTYPE; /** * VP Versions */ typedef enum QOMX_VIDEO_VPFORMATTYPE { QOMX_VIDEO_VPFormatUnused = 0x01, /**< Format unused or unknown */ QOMX_VIDEO_VPFormat6 = 0x02, /**< VP6 Video Format */ QOMX_VIDEO_VPFormat7 = 0x04, /**< VP7 Video Format */ QOMX_VIDEO_VPFormat8 = 0x08, /**< VP8 Video Format */ QOMX_VIDEO_VPFormat9 = 0x10, /**< VP9 Video Format */ QOMX_VIDEO_VPFormatKhronosExtensions = 0x6F000000, QOMX_VIDEO_VPFormatVendorStartUnused = 0x7F000000, QOMX_VIDEO_VPFormatMax = 0x7FFFFFFF } QOMX_VIDEO_VPFORMATTYPE; /** * VP profile types, each profile indicates support for various * encoding tools. */ typedef enum QOMX_VIDEO_VPPROFILETYPE { QOMX_VIDEO_VPProfileSimple = 0x01, /**< Simple Profile, applies to VP6 only */ QOMX_VIDEO_VPProfileAdvanced = 0x02, /**< Advanced Profile, applies to VP6 only */ QOMX_VIDEO_VPProfileVersion0 = 0x04, /**< Version 0, applies to VP7 and VP8 */ QOMX_VIDEO_VPProfileVersion1 = 0x08, /**< Version 1, applies to VP7 and VP8 */ QOMX_VIDEO_VPProfileVersion2 = 0x10, /**< Version 2, applies to VP8 only */ QOMX_VIDEO_VPProfileVersion3 = 0x20, /**< Version 3, applies to VP8 only */ QOMX_VIDEO_VPProfileKhronosExtensions = 0x6F000000, QOMX_VIDEO_VPProfileVendorStartUnused = 0x7F000000, QOMX_VIDEO_VPProfileMax = 0x7FFFFFFF } QOMX_VIDEO_VPPROFILETYPE; /** * VP Video Params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFormat : Format of VP stream / data * eProfile : Profile or Version of VP stream / data */ typedef struct QOMX_VIDEO_PARAM_VPTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; QOMX_VIDEO_VPFORMATTYPE eFormat; QOMX_VIDEO_VPPROFILETYPE eProfile; } QOMX_VIDEO_PARAM_VPTYPE; /** * Spark Versions */ typedef enum QOMX_VIDEO_SPARKFORMATTYPE { QOMX_VIDEO_SparkFormatUnused = 0x01, /**< Format unused or unknown */ QOMX_VIDEO_SparkFormat0 = 0x02, /**< Video Format Version 0 */ QOMX_VIDEO_SparkFormat1 = 0x04, /**< Video Format Version 1 */ QOMX_VIDEO_SparkFormatKhronosExtensions = 0x6F000000, QOMX_VIDEO_SparkFormatVendorStartUnused = 0x7F000000, QOMX_VIDEO_SparkFormatMax = 0x7FFFFFFF } QOMX_VIDEO_SPARKFORMATTYPE; /** * Spark Video Params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFormat : Version of Spark stream / data */ typedef struct QOMX_VIDEO_PARAM_SPARKTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; QOMX_VIDEO_SPARKFORMATTYPE eFormat; } QOMX_VIDEO_PARAM_SPARKTYPE; typedef struct QOMX_VIDEO_QUERY_DECODER_INSTANCES { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nNumOfInstances; } QOMX_VIDEO_QUERY_DECODER_INSTANCES; typedef struct QOMX_ENABLETYPE { OMX_BOOL bEnable; } QOMX_ENABLETYPE; typedef enum QOMX_VIDEO_EVENTS { OMX_EventIndexsettingChanged = OMX_EventVendorStartUnused } QOMX_VIDEO_EVENTS; typedef enum QOMX_VIDEO_PICTURE_ORDER { QOMX_VIDEO_DISPLAY_ORDER = 0x1, QOMX_VIDEO_DECODE_ORDER = 0x2 } QOMX_VIDEO_PICTURE_ORDER; typedef struct QOMX_VIDEO_DECODER_PICTURE_ORDER { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; QOMX_VIDEO_PICTURE_ORDER eOutputPictureOrder; } QOMX_VIDEO_DECODER_PICTURE_ORDER; typedef struct QOMX_INDEXEXTRADATATYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnabled; OMX_INDEXTYPE nIndex; } QOMX_INDEXEXTRADATATYPE; typedef struct QOMX_INDEXTIMESTAMPREORDER { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnable; } QOMX_INDEXTIMESTAMPREORDER; typedef struct QOMX_INDEXDOWNSCALAR { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnable; } QOMX_INDEXDOWNSCALAR; typedef struct QOMX_VIDEO_CUSTOM_BUFFERSIZE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nBufferSize; } QOMX_VIDEO_CUSTOM_BUFFERSIZE; #define OMX_QCOM_INDEX_PARAM_VIDEO_SYNCFRAMEDECODINGMODE "OMX.QCOM.index.param.video.SyncFrameDecodingMode" #define OMX_QCOM_INDEX_PARAM_INDEXEXTRADATA "OMX.QCOM.index.param.IndexExtraData" #define OMX_QCOM_INDEX_PARAM_VIDEO_SLICEDELIVERYMODE "OMX.QCOM.index.param.SliceDeliveryMode" #define OMX_QCOM_INDEX_PARAM_VIDEO_FRAMEPACKING_EXTRADATA "OMX.QCOM.index.param.video.FramePackingExtradata" #define OMX_QCOM_INDEX_PARAM_VIDEO_QP_EXTRADATA "OMX.QCOM.index.param.video.QPExtradata" #define OMX_QCOM_INDEX_PARAM_VIDEO_INPUTBITSINFO_EXTRADATA "OMX.QCOM.index.param.video.InputBitsInfoExtradata" #define OMX_QCOM_INDEX_PARAM_VIDEO_EXTNUSER_EXTRADATA "OMX.QCOM.index.param.video.ExtnUserExtraData" #define OMX_QCOM_INDEX_CONFIG_VIDEO_FRAMEPACKING_INFO "OMX.QCOM.index.config.video.FramePackingInfo" #define OMX_QCOM_INDEX_PARAM_VIDEO_MPEG2SEQDISP_EXTRADATA "OMX.QCOM.index.param.video.Mpeg2SeqDispExtraData" #define OMX_QCOM_INDEX_PARAM_VIDEO_HIERSTRUCTURE "OMX.QCOM.index.param.video.HierStructure" #define OMX_QCOM_INDEX_PARAM_VIDEO_LTRCOUNT "OMX.QCOM.index.param.video.LTRCount" #define OMX_QCOM_INDEX_PARAM_VIDEO_LTRPERIOD "OMX.QCOM.index.param.video.LTRPeriod" #define OMX_QCOM_INDEX_CONFIG_VIDEO_LTRUSE "OMX.QCOM.index.config.video.LTRUse" #define OMX_QCOM_INDEX_CONFIG_VIDEO_LTRMARK "OMX.QCOM.index.config.video.LTRMark" #define OMX_QCOM_INDEX_CONFIG_VIDEO_HIER_P_LAYERS "OMX.QCOM.index.config.video.hierplayers" #define OMX_QCOM_INDEX_CONFIG_RECTANGLE_TYPE "OMX.QCOM.index.config.video.rectangle" #define OMX_QCOM_INDEX_PARAM_VIDEO_BASE_LAYER_ID "OMX.QCOM.index.param.video.baselayerid" #define OMX_QCOM_INDEX_CONFIG_VIDEO_QP "OMX.QCOM.index.config.video.qp" #define OMX_QCOM_INDEX_PARAM_VIDEO_SAR "OMX.QCOM.index.param.video.sar" #define OMX_QTI_INDEX_PARAM_VIDEO_LOW_LATENCY "OMX.QTI.index.param.video.LowLatency" #define OMX_QCOM_INDEX_PARAM_VIDEO_PASSINPUTBUFFERFD "OMX.QCOM.index.param.video.PassInputBufferFd" #define OMX_QTI_INDEX_PARAM_VIDEO_PREFER_ADAPTIVE_PLAYBACK "OMX.QTI.index.param.video.PreferAdaptivePlayback" #define OMX_QTI_INDEX_CONFIG_VIDEO_SETTIMEDATA "OMX.QTI.index.config.video.settimedata" #define OMX_QTI_INDEX_PARAM_VIDEO_FORCE_COMPRESSED_FOR_DPB "OMX.QTI.index.param.video.ForceCompressedForDPB" #define OMX_QTI_INDEX_PARAM_VIDEO_ENABLE_ROIINFO "OMX.QTI.index.param.enableRoiInfo" #define OMX_QTI_INDEX_CONFIG_VIDEO_ROIINFO "OMX.QTI.index.config.RoiInfo" typedef enum { QOMX_VIDEO_FRAME_PACKING_CHECKERBOARD = 0, QOMX_VIDEO_FRAME_PACKING_COLUMN_INTERLEAVE = 1, QOMX_VIDEO_FRAME_PACKING_ROW_INTERLEAVE = 2, QOMX_VIDEO_FRAME_PACKING_SIDE_BY_SIDE = 3, QOMX_VIDEO_FRAME_PACKING_TOP_BOTTOM = 4, QOMX_VIDEO_FRAME_PACKING_TEMPORAL = 5, } QOMX_VIDEO_FRAME_PACKING_ARRANGEMENT; typedef enum { QOMX_VIDEO_CONTENT_UNSPECIFIED = 0, QOMX_VIDEO_CONTENT_LR_VIEW = 1, QOMX_VIDEO_CONTENT_RL_VIEW = 2, } QOMX_VIDEO_CONTENT_INTERPRETATION; /** * Specifies the extended picture types. These values should be * OR'd along with the types defined in OMX_VIDEO_PICTURETYPE to * signal all pictures types which are allowed. * * ENUMS: * H.264 Specific Picture Types: IDR */ typedef enum QOMX_VIDEO_PICTURETYPE { QOMX_VIDEO_PictureTypeIDR = OMX_VIDEO_PictureTypeVendorStartUnused + 0x1000 } QOMX_VIDEO_PICTURETYPE; #define OMX_QCOM_INDEX_CONFIG_ACTIVE_REGION_DETECTION "OMX.QCOM.index.config.activeregiondetection" #define OMX_QCOM_INDEX_CONFIG_ACTIVE_REGION_DETECTION_STATUS "OMX.QCOM.index.config.activeregiondetectionstatus" #define OMX_QCOM_INDEX_CONFIG_SCALING_MODE "OMX.QCOM.index.config.scalingmode" #define OMX_QCOM_INDEX_CONFIG_NOISEREDUCTION "OMX.QCOM.index.config.noisereduction" #define OMX_QCOM_INDEX_CONFIG_IMAGEENHANCEMENT "OMX.QCOM.index.config.imageenhancement" #define OMX_QCOM_INDEX_PARAM_HELDBUFFERCOUNT "OMX.QCOM.index.param.HeldBufferCount" /**< reference: QOMX_HELDBUFFERCOUNTTYPE */ typedef struct QOMX_RECTTYPE { OMX_S32 nLeft; OMX_S32 nTop; OMX_U32 nWidth; OMX_U32 nHeight; } QOMX_RECTTYPE; typedef struct QOMX_ACTIVEREGIONDETECTIONTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnable; QOMX_RECTTYPE sROI; OMX_U32 nNumExclusionRegions; QOMX_RECTTYPE sExclusionRegions[1]; } QOMX_ACTIVEREGIONDETECTIONTYPE; typedef struct QOMX_ACTIVEREGIONDETECTION_STATUSTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bDetected; QOMX_RECTTYPE sDetectedRegion; } QOMX_ACTIVEREGIONDETECTION_STATUSTYPE; typedef enum QOMX_SCALE_MODETYPE { QOMX_SCALE_MODE_Normal, QOMX_SCALE_MODE_Anamorphic, QOMX_SCALE_MODE_Max = 0x7FFFFFFF } QOMX_SCALE_MODETYPE; typedef struct QOMX_SCALINGMODETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; QOMX_SCALE_MODETYPE eScaleMode; } QOMX_SCALINGMODETYPE; typedef struct QOMX_NOISEREDUCTIONTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnable; OMX_BOOL bAutoMode; OMX_S32 nNoiseReduction; } QOMX_NOISEREDUCTIONTYPE; typedef struct QOMX_IMAGEENHANCEMENTTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnable; OMX_BOOL bAutoMode; OMX_S32 nImageEnhancement; } QOMX_IMAGEENHANCEMENTTYPE; /* * these are part of OMX1.2 but JB MR2 branch doesn't have them defined * OMX_IndexParamInterlaceFormat * OMX_INTERLACEFORMATTYPE */ #ifndef OMX_IndexParamInterlaceFormat #define OMX_IndexParamInterlaceFormat (0x7FF00000) typedef struct OMX_INTERLACEFORMATTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nFormat; OMX_TICKS nTimeStamp; } OMX_INTERLACEFORMATTYPE; #endif /** * This structure is used to indicate the maximum number of buffers * that a port will hold during data flow. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version info * nPortIndex : Port that this structure applies to * nHeldBufferCount : Read-only, maximum number of buffers that will be held */ typedef struct QOMX_HELDBUFFERCOUNTTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nHeldBufferCount; } QOMX_HELDBUFFERCOUNTTYPE; typedef enum QOMX_VIDEO_HIERARCHICALCODINGTYPE { QOMX_HIERARCHICALCODING_P = 0x01, QOMX_HIERARCHICALCODING_B = 0x02, } QOMX_VIDEO_HIERARCHICALCODINGTYPE; typedef struct QOMX_VIDEO_HIERARCHICALLAYERS { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nNumLayers; QOMX_VIDEO_HIERARCHICALCODINGTYPE eHierarchicalCodingType; } QOMX_VIDEO_HIERARCHICALLAYERS; typedef struct QOMX_VIDEO_H264ENTROPYCODINGTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_BOOL bCabac; OMX_U32 nCabacInitIdc; } QOMX_VIDEO_H264ENTROPYCODINGTYPE; /* VIDEO POSTPROCESSING CTRLS AND ENUMS */ #define QOMX_VPP_HQV_CUSTOMPAYLOAD_SZ 256 #define VPP_HQV_CONTROL_GLOBAL_START (VPP_HQV_CONTROL_CUST + 1) typedef enum QOMX_VPP_HQV_MODE { VPP_HQV_MODE_OFF, VPP_HQV_MODE_AUTO, VPP_HQV_MODE_MANUAL, VPP_HQV_MODE_MAX } QOMX_VPP_HQV_MODE; typedef enum QOMX_VPP_HQVCONTROLTYPE { VPP_HQV_CONTROL_CADE = 0x1, VPP_HQV_CONTROL_CNR = 0x04, VPP_HQV_CONTROL_AIE = 0x05, VPP_HQV_CONTROL_FRC = 0x06, VPP_HQV_CONTROL_CUST = 0x07, VPP_HQV_CONTROL_GLOBAL_DEMO = VPP_HQV_CONTROL_GLOBAL_START, VPP_HQV_CONTROL_MAX, } QOMX_VPP_HQVCONTROLTYPE; typedef enum QOMX_VPP_HQV_HUE_MODE { VPP_HQV_HUE_MODE_OFF, VPP_HQV_HUE_MODE_ON, VPP_HQV_HUE_MODE_MAX, } QOMX_VPP_HQV_HUE_MODE; typedef enum QOMX_VPP_HQV_FRC_MODE { VPP_HQV_FRC_MODE_OFF, VPP_HQV_FRC_MODE_LOW, VPP_HQV_FRC_MODE_MED, VPP_HQV_FRC_MODE_HIGH, VPP_HQV_FRC_MODE_MAX, } QOMX_VPP_HQV_FRC_MODE; typedef struct QOMX_VPP_HQVCTRL_CADE { QOMX_VPP_HQV_MODE mode; OMX_U32 level; OMX_S32 contrast; OMX_S32 saturation; } QOMX_VPP_HQVCTRL_CADE; typedef struct QOMX_VPP_HQVCTRL_CNR { QOMX_VPP_HQV_MODE mode; OMX_U32 level; } QOMX_VPP_HQVCTRL_CNR; typedef struct QOMX_VPP_HQVCTRL_AIE { QOMX_VPP_HQV_MODE mode; QOMX_VPP_HQV_HUE_MODE hue_mode; OMX_U32 cade_level; OMX_U32 ltm_level; } QOMX_VPP_HQVCTRL_AIE; typedef struct QOMX_VPP_HQVCTRL_CUSTOM { OMX_U32 id; OMX_U32 len; OMX_U8 data[QOMX_VPP_HQV_CUSTOMPAYLOAD_SZ]; } QOMX_VPP_HQVCTRL_CUSTOM; typedef struct QOMX_VPP_HQVCTRL_GLOBAL_DEMO { OMX_U32 process_percent; } QOMX_VPP_HQVCTRL_GLOBAL_DEMO; typedef struct QOMX_VPP_HQVCTRL_FRC { QOMX_VPP_HQV_FRC_MODE mode; } QOMX_VPP_HQVCTRL_FRC; typedef struct QOMX_VPP_HQVCONTROL { QOMX_VPP_HQV_MODE mode; QOMX_VPP_HQVCONTROLTYPE ctrl_type; union { QOMX_VPP_HQVCTRL_CADE cade; QOMX_VPP_HQVCTRL_CNR cnr; QOMX_VPP_HQVCTRL_AIE aie; QOMX_VPP_HQVCTRL_CUSTOM custom; QOMX_VPP_HQVCTRL_GLOBAL_DEMO global_demo; QOMX_VPP_HQVCTRL_FRC frc; }; } QOMX_VPP_HQVCONTROL; /* STRUCTURE TO TURN VPP ON */ typedef struct QOMX_VPP_ENABLE { OMX_BOOL enable_vpp; } QOMX_VPP_ENABLE; typedef enum OMX_QOMX_VIDEO_MBISTATISTICSTYPE { QOMX_MBI_STATISTICS_MODE_DEFAULT = 0, QOMX_MBI_STATISTICS_MODE_1 = 0x01, QOMX_MBI_STATISTICS_MODE_2 = 0x02, } OMX_QOMX_VIDEO_MBISTATISTICSTYPE; typedef struct OMX_QOMX_VIDEO_MBI_STATISTICS { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_QOMX_VIDEO_MBISTATISTICSTYPE eMBIStatisticsType; } OMX_QOMX_VIDEO_MBI_STATISTICS; typedef struct QOMX_VIDEO_BATCHSIZETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nBatchSize; } QOMX_VIDEO_BATCHSIZETYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* __OMX_QCOM_EXTENSIONS_H__ */ ================================================ FILE: phonelibs/openmax/include/OMX_Skype_VideoExtensions.h ================================================ /*@@@+++@@@@****************************************************************** Microsoft Skype Engineering Copyright (C) 2014 Microsoft Corporation. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *@@@---@@@@******************************************************************/ #ifndef __OMX_SKYPE_VIDEOEXTENSIONS_H__ #define __OMX_SKYPE_VIDEOEXTENSIONS_H__ #ifdef __cplusplus extern "C" { #endif #include #pragma pack(push, 1) typedef enum OMX_SKYPE_VIDEO_SliceControlMode { OMX_SKYPE_VIDEO_SliceControlModeNone = 0, OMX_SKYPE_VIDEO_SliceControlModeMB = 1, OMX_SKYPE_VIDEO_SliceControlModeByte = 2, OMX_SKYPE_VIDEO_SliceControlModMBRow = 3, } OMX_SKYPE_VIDEO_SliceControlMode; typedef enum OMX_SKYPE_VIDEO_HierarType { OMX_SKYPE_VIDEO_HierarType_P = 0x01, OMX_SKYPE_VIDEO_HierarType_B = 0x02, } OMX_SKYPE_VIDEO_HIERAR_HierarType; typedef enum OMX_VIDEO_EXTENSION_AVCPROFILETYPE { OMX_VIDEO_EXT_AVCProfileConstrainedBaseline = 0x01, OMX_VIDEO_EXT_AVCProfileConstrainedHigh = 0x02, } OMX_VIDEO_EXTENSION_AVCPROFILETYPE; typedef struct OMX_SKYPE_VIDEO_ENCODERPARAMS { OMX_BOOL bLowLatency; OMX_BOOL bUseExtendedProfile; OMX_BOOL bSequenceHeaderWithIDR; OMX_VIDEO_EXTENSION_AVCPROFILETYPE eProfile; OMX_U32 nLTRFrames; OMX_SKYPE_VIDEO_HierarType eHierarType; OMX_U32 nMaxTemporalLayerCount; OMX_SKYPE_VIDEO_SliceControlMode eSliceControlMode; OMX_U32 nSarIndex; OMX_U32 nSarWidth; OMX_U32 nSarHeight; } OMX_SKYPE_VIDEO_ENCODERPARAMS; typedef struct OMX_SKYPE_VIDEO_PARAM_ENCODERSETTING { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_SKYPE_VIDEO_ENCODERPARAMS stEncParam; } OMX_SKYPE_VIDEO_PARAM_ENCODESETTING; typedef struct OMX_SKYPE_VIDEO_ENCODERCAP { OMX_BOOL bLowLatency; OMX_U32 nMaxFrameWidth; OMX_U32 nMaxFrameHeight; OMX_U32 nMaxInstances; OMX_U32 nMaxTemporaLayerCount; OMX_U32 nMaxRefFrames; OMX_U32 nMaxLTRFrames; OMX_VIDEO_AVCLEVELTYPE nMaxLevel; OMX_U32 nSliceControlModesBM; OMX_U32 nMaxMacroblockProcessingRate; OMX_U32 xMinScaleFactor; } OMX_SKYPE_VIDEO_ENCODERCAP; typedef struct OMX_SKYPE_VIDEO_PARAM_ENCODERCAP { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_SKYPE_VIDEO_ENCODERCAP stEncCap; } OMX_SKYPE_VIDEO_PARAM_ENCODERCAP; typedef struct OMX_SKYPE_VIDEO_DECODERCAP { OMX_BOOL bLowLatency; OMX_U32 nMaxFrameWidth; OMX_U32 nMaxFrameHeight; OMX_U32 nMaxInstances; OMX_VIDEO_AVCLEVELTYPE nMaxLevel; OMX_U32 nMaxMacroblockProcessingRate; } OMX_SKYPE_VIDEO_DECODERCAP; typedef struct OMX_SKYPE_VIDEO_PARAM_DECODERCAP { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_SKYPE_VIDEO_DECODERCAP stDecoderCap; } OMX_SKYPE_VIDEO_PARAM_DECODERCAP; typedef struct OMX_SKYPE_VIDEO_CONFIG_QP { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nQP; } OMX_SKYPE_VIDEO_CONFIG_QP; typedef struct OMX_SKYPE_VIDEO_CONFIG_BASELAYERPID{ OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nPID; } OMX_SKYPE_VIDEO_CONFIG_BASELAYERPID; typedef struct OMX_SKYPE_VIDEO_PARAM_DRIVERVER { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U64 nDriverVersion; } OMX_SKYPE_VIDEO_PARAM_DRIVERVER; typedef enum OMX_SKYPE_VIDEO_DownScaleFactor { OMX_SKYPE_VIDEO_DownScaleFactor_1_1 = 0, OMX_SKYPE_VIDEO_DownScaleFactor_Equal_AR = 1, OMX_SKYPE_VIDEO_DownScaleFactor_Any = 2, } OMX_SKYPE_VIDEO_DownScaleFactor; #pragma pack(pop) #ifdef __cplusplus } #endif #endif ================================================ FILE: phonelibs/openmax/include/OMX_Types.h ================================================ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_Types.h - OpenMax IL version 1.1.2 * The OMX_Types header file contains the primitive type definitions used by * the core, the application and the component. This file may need to be * modified to be used on systems that do not have "char" set to 8 bits, * "short" set to 16 bits and "long" set to 32 bits. */ #ifndef OMX_Types_h #define OMX_Types_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** The OMX_API and OMX_APIENTRY are platform specific definitions used * to declare OMX function prototypes. They are modified to meet the * requirements for a particular platform */ #ifdef __SYMBIAN32__ # ifdef __OMX_EXPORTS # define OMX_API __declspec(dllexport) # else # ifdef _WIN32 # define OMX_API __declspec(dllexport) # else # define OMX_API __declspec(dllimport) # endif # endif #else # ifdef _WIN32 # ifdef __OMX_EXPORTS # define OMX_API __declspec(dllexport) # else # define OMX_API __declspec(dllimport) # endif # else # ifdef __OMX_EXPORTS # define OMX_API # else # define OMX_API extern # endif # endif #endif #ifndef OMX_APIENTRY #define OMX_APIENTRY #endif /** OMX_IN is used to identify inputs to an OMX function. This designation will also be used in the case of a pointer that points to a parameter that is used as an output. */ #ifndef OMX_IN #define OMX_IN #endif /** OMX_OUT is used to identify outputs from an OMX function. This designation will also be used in the case of a pointer that points to a parameter that is used as an input. */ #ifndef OMX_OUT #define OMX_OUT #endif /** OMX_INOUT is used to identify parameters that may be either inputs or outputs from an OMX function at the same time. This designation will also be used in the case of a pointer that points to a parameter that is used both as an input and an output. */ #ifndef OMX_INOUT #define OMX_INOUT #endif /** OMX_ALL is used to as a wildcard to select all entities of the same type * when specifying the index, or referring to a object by an index. (i.e. * use OMX_ALL to indicate all N channels). When used as a port index * for a config or parameter this OMX_ALL denotes that the config or * parameter applies to the entire component not just one port. */ #define OMX_ALL 0xFFFFFFFF /** In the following we define groups that help building doxygen documentation */ /** @defgroup core OpenMAX IL core * Functions and structure related to the OMX IL core */ /** @defgroup comp OpenMAX IL component * Functions and structure related to the OMX IL component */ /** @defgroup rpm Resource and Policy Management * Structures for resource and policy management of components */ /** @defgroup buf Buffer Management * Buffer handling functions and structures */ /** @defgroup tun Tunneling * @ingroup core comp * Structures and functions to manage tunnels among component ports */ /** @defgroup cp Content Pipes * @ingroup core */ /** @defgroup metadata Metadata handling * */ /** OMX_U8 is an 8 bit unsigned quantity that is byte aligned */ typedef unsigned char OMX_U8; /** OMX_S8 is an 8 bit signed quantity that is byte aligned */ typedef signed char OMX_S8; /** OMX_U16 is a 16 bit unsigned quantity that is 16 bit word aligned */ typedef unsigned short OMX_U16; /** OMX_S16 is a 16 bit signed quantity that is 16 bit word aligned */ typedef signed short OMX_S16; /** OMX_U32 is a 32 bit unsigned quantity that is 32 bit word aligned */ typedef unsigned int OMX_U32; /** OMX_S32 is a 32 bit signed quantity that is 32 bit word aligned */ typedef signed int OMX_S32; /* Users with compilers that cannot accept the "long long" designation should define the OMX_SKIP64BIT macro. It should be noted that this may cause some components to fail to compile if the component was written to require 64 bit integral types. However, these components would NOT compile anyway since the compiler does not support the way the component was written. */ #ifndef OMX_SKIP64BIT #ifdef __SYMBIAN32__ /** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ typedef unsigned long long OMX_U64; /** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ typedef signed long long OMX_S64; #elif defined(WIN32) /** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ typedef unsigned __int64 OMX_U64; /** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ typedef signed __int64 OMX_S64; #else /* WIN32 */ /** OMX_U64 is a 64 bit unsigned quantity that is 64 bit word aligned */ typedef unsigned long long OMX_U64; /** OMX_S64 is a 64 bit signed quantity that is 64 bit word aligned */ typedef signed long long OMX_S64; #endif /* WIN32 */ #endif /** The OMX_BOOL type is intended to be used to represent a true or a false value when passing parameters to and from the OMX core and components. The OMX_BOOL is a 32 bit quantity and is aligned on a 32 bit word boundary. */ typedef enum OMX_BOOL { OMX_FALSE = 0, OMX_TRUE = !OMX_FALSE, OMX_BOOL_MAX = 0x7FFFFFFF } OMX_BOOL; #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS typedef OMX_U32 OMX_PTR; typedef OMX_PTR OMX_STRING; typedef OMX_PTR OMX_BYTE; #else /** The OMX_PTR type is intended to be used to pass pointers between the OMX applications and the OMX Core and components. This is a 32 bit pointer and is aligned on a 32 bit boundary. */ typedef void* OMX_PTR; /** The OMX_STRING type is intended to be used to pass "C" type strings between the application and the core and component. The OMX_STRING type is a 32 bit pointer to a zero terminated string. The pointer is word aligned and the string is byte aligned. */ typedef char* OMX_STRING; /** The OMX_BYTE type is intended to be used to pass arrays of bytes such as buffers between the application and the component and core. The OMX_BYTE type is a 32 bit pointer to a zero terminated string. The pointer is word aligned and the string is byte aligned. */ typedef unsigned char* OMX_BYTE; /** OMX_UUIDTYPE is a very long unique identifier to uniquely identify at runtime. This identifier should be generated by a component in a way that guarantees that every instance of the identifier running on the system is unique. */ #endif typedef unsigned char OMX_UUIDTYPE[128]; /** The OMX_DIRTYPE enumeration is used to indicate if a port is an input or an output port. This enumeration is common across all component types. */ typedef enum OMX_DIRTYPE { OMX_DirInput, /**< Port is an input port */ OMX_DirOutput, /**< Port is an output port */ OMX_DirMax = 0x7FFFFFFF } OMX_DIRTYPE; /** The OMX_ENDIANTYPE enumeration is used to indicate the bit ordering for numerical data (i.e. big endian, or little endian). */ typedef enum OMX_ENDIANTYPE { OMX_EndianBig, /**< big endian */ OMX_EndianLittle, /**< little endian */ OMX_EndianMax = 0x7FFFFFFF } OMX_ENDIANTYPE; /** The OMX_NUMERICALDATATYPE enumeration is used to indicate if data is signed or unsigned */ typedef enum OMX_NUMERICALDATATYPE { OMX_NumericalDataSigned, /**< signed data */ OMX_NumericalDataUnsigned, /**< unsigned data */ OMX_NumercialDataMax = 0x7FFFFFFF } OMX_NUMERICALDATATYPE; /** Unsigned bounded value type */ typedef struct OMX_BU32 { OMX_U32 nValue; /**< actual value */ OMX_U32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ OMX_U32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ } OMX_BU32; /** Signed bounded value type */ typedef struct OMX_BS32 { OMX_S32 nValue; /**< actual value */ OMX_S32 nMin; /**< minimum for value (i.e. nValue >= nMin) */ OMX_S32 nMax; /**< maximum for value (i.e. nValue <= nMax) */ } OMX_BS32; /** Structure representing some time or duration in microseconds. This structure * must be interpreted as a signed 64 bit value. The quantity is signed to accommodate * negative deltas and preroll scenarios. The quantity is represented in microseconds * to accomodate high resolution timestamps (e.g. DVD presentation timestamps based * on a 90kHz clock) and to allow more accurate and synchronized delivery (e.g. * individual audio samples delivered at 192 kHz). The quantity is 64 bit to * accommodate a large dynamic range (signed 32 bit values would allow only for plus * or minus 35 minutes). * * Implementations with limited precision may convert the signed 64 bit value to * a signed 32 bit value internally but risk loss of precision. */ #ifndef OMX_SKIP64BIT typedef OMX_S64 OMX_TICKS; #else typedef struct OMX_TICKS { OMX_U32 nLowPart; /** low bits of the signed 64 bit tick value */ OMX_U32 nHighPart; /** high bits of the signed 64 bit tick value */ } OMX_TICKS; #endif #define OMX_TICKS_PER_SECOND 1000000 /** Define the public interface for the OMX Handle. The core will not use this value internally, but the application should only use this value. */ typedef void* OMX_HANDLETYPE; typedef struct OMX_MARKTYPE { OMX_HANDLETYPE hMarkTargetComponent; /**< The component that will generate a mark event upon processing the mark. */ OMX_PTR pMarkData; /**< Application specific data associated with the mark sent on a mark event to disambiguate this mark from others. */ } OMX_MARKTYPE; /** OMX_NATIVE_DEVICETYPE is used to map a OMX video port to the * platform & operating specific object used to reference the display * or can be used by a audio port for native audio rendering */ typedef void* OMX_NATIVE_DEVICETYPE; /** OMX_NATIVE_WINDOWTYPE is used to map a OMX video port to the * platform & operating specific object used to reference the window */ typedef void* OMX_NATIVE_WINDOWTYPE; /** The OMX_VERSIONTYPE union is used to specify the version for a structure or component. For a component, the version is entirely specified by the component vendor. Components doing the same function from different vendors may or may not have the same version. For structures, the version shall be set by the entity that allocates the structure. For structures specified in the OMX 1.1 specification, the value of the version shall be set to 1.1.0.0 in all cases. Access to the OMX_VERSIONTYPE can be by a single 32 bit access (e.g. by nVersion) or by accessing one of the structure elements to, for example, check only the Major revision. */ typedef union OMX_VERSIONTYPE { struct { OMX_U8 nVersionMajor; /**< Major version accessor element */ OMX_U8 nVersionMinor; /**< Minor version accessor element */ OMX_U8 nRevision; /**< Revision version accessor element */ OMX_U8 nStep; /**< Step version accessor element */ } s; OMX_U32 nVersion; /**< 32 bit value to make accessing the version easily done in a single word size copy/compare operation */ } OMX_VERSIONTYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_Video.h ================================================ /** * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** * @file OMX_Video.h - OpenMax IL version 1.1.2 * The structures is needed by Video components to exchange parameters * and configuration data with OMX components. */ #ifndef OMX_Video_h #define OMX_Video_h /** @defgroup video OpenMAX IL Video Domain * @ingroup iv * Structures for OpenMAX IL Video domain * @{ */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** * Each OMX header must include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** * Enumeration used to define the possible video compression codings. * NOTE: This essentially refers to file extensions. If the coding is * being used to specify the ENCODE type, then additional work * must be done to configure the exact flavor of the compression * to be used. For decode cases where the user application can * not differentiate between MPEG-4 and H.264 bit streams, it is * up to the codec to handle this. */ typedef enum OMX_VIDEO_CODINGTYPE { OMX_VIDEO_CodingUnused, /**< Value when coding is N/A */ OMX_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */ OMX_VIDEO_CodingMPEG2, /**< AKA: H.262 */ OMX_VIDEO_CodingH263, /**< H.263 */ OMX_VIDEO_CodingMPEG4, /**< MPEG-4 */ OMX_VIDEO_CodingWMV, /**< all versions of Windows Media Video */ OMX_VIDEO_CodingRV, /**< all versions of Real Video */ OMX_VIDEO_CodingAVC, /**< H.264/AVC */ OMX_VIDEO_CodingMJPEG, /**< Motion JPEG */ OMX_VIDEO_CodingVP8, /**< Google VP8, formerly known as On2 VP8 */ OMX_VIDEO_CodingVP9, /**< Google VP9 */ OMX_VIDEO_CodingHEVC, /**< HEVC */ OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_CodingMax = 0x7FFFFFFF } OMX_VIDEO_CODINGTYPE; /** * Data structure used to define a video path. The number of Video paths for * input and output will vary by type of the Video component. * * Input (aka Source) : zero Inputs, one Output, * Splitter : one Input, 2 or more Outputs, * Processing Element : one Input, one output, * Mixer : 2 or more inputs, one output, * Output (aka Sink) : one Input, zero outputs. * * The PortDefinition structure is used to define all of the parameters * necessary for the compliant component to setup an input or an output video * path. If additional vendor specific data is required, it should be * transmitted to the component using the CustomCommand function. Compliant * components will prepopulate this structure with optimal values during the * GetDefaultInitParams command. * * STRUCT MEMBERS: * cMIMEType : MIME type of data for the port * pNativeRender : Platform specific reference for a display if a * sync, otherwise this field is 0 * nFrameWidth : Width of frame to be used on channel if * uncompressed format is used. Use 0 for unknown, * don't care or variable * nFrameHeight : Height of frame to be used on channel if * uncompressed format is used. Use 0 for unknown, * don't care or variable * nStride : Number of bytes per span of an image * (i.e. indicates the number of bytes to get * from span N to span N+1, where negative stride * indicates the image is bottom up * nSliceHeight : Height used when encoding in slices * nBitrate : Bit rate of frame to be used on channel if * compressed format is used. Use 0 for unknown, * don't care or variable * xFramerate : Frame rate to be used on channel if uncompressed * format is used. Use 0 for unknown, don't care or * variable. Units are Q16 frames per second. * bFlagErrorConcealment : Turns on error concealment if it is supported by * the OMX component * eCompressionFormat : Compression format used in this instance of the * component. When OMX_VIDEO_CodingUnused is * specified, eColorFormat is used * eColorFormat : Decompressed format used by this component * pNativeWindow : Platform specific reference for a window object if a * display sink , otherwise this field is 0x0. */ typedef struct OMX_VIDEO_PORTDEFINITIONTYPE { OMX_STRING cMIMEType; OMX_NATIVE_DEVICETYPE pNativeRender; OMX_U32 nFrameWidth; OMX_U32 nFrameHeight; OMX_S32 nStride; OMX_U32 nSliceHeight; OMX_U32 nBitrate; OMX_U32 xFramerate; OMX_BOOL bFlagErrorConcealment; OMX_VIDEO_CODINGTYPE eCompressionFormat; OMX_COLOR_FORMATTYPE eColorFormat; OMX_NATIVE_WINDOWTYPE pNativeWindow; } OMX_VIDEO_PORTDEFINITIONTYPE; /** * Port format parameter. This structure is used to enumerate the various * data input/output format supported by the port. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Indicates which port to set * nIndex : Indicates the enumeration index for the format from * 0x0 to N-1 * eCompressionFormat : Compression format used in this instance of the * component. When OMX_VIDEO_CodingUnused is specified, * eColorFormat is used * eColorFormat : Decompressed format used by this component * xFrameRate : Indicates the video frame rate in Q16 format */ typedef struct OMX_VIDEO_PARAM_PORTFORMATTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nIndex; OMX_VIDEO_CODINGTYPE eCompressionFormat; OMX_COLOR_FORMATTYPE eColorFormat; OMX_U32 xFramerate; } OMX_VIDEO_PARAM_PORTFORMATTYPE; /** * This is a structure for configuring video compression quantization * parameter values. Codecs may support different QP values for different * frame types. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version info * nPortIndex : Port that this structure applies to * nQpI : QP value to use for index frames * nQpP : QP value to use for P frames * nQpB : QP values to use for bidirectional frames */ typedef struct OMX_VIDEO_PARAM_QUANTIZATIONTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nQpI; OMX_U32 nQpP; OMX_U32 nQpB; } OMX_VIDEO_PARAM_QUANTIZATIONTYPE; /** * Structure for configuration of video fast update parameters. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version info * nPortIndex : Port that this structure applies to * bEnableVFU : Enable/Disable video fast update * nFirstGOB : Specifies the number of the first macroblock row * nFirstMB : specifies the first MB relative to the specified first GOB * nNumMBs : Specifies the number of MBs to be refreshed from nFirstGOB * and nFirstMB */ typedef struct OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnableVFU; OMX_U32 nFirstGOB; OMX_U32 nFirstMB; OMX_U32 nNumMBs; } OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE; /** * Enumeration of possible bitrate control types */ typedef enum OMX_VIDEO_CONTROLRATETYPE { OMX_Video_ControlRateDisable, OMX_Video_ControlRateVariable, OMX_Video_ControlRateConstant, OMX_Video_ControlRateVariableSkipFrames, OMX_Video_ControlRateConstantSkipFrames, OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_Video_ControlRateMax = 0x7FFFFFFF } OMX_VIDEO_CONTROLRATETYPE; /** * Structure for configuring bitrate mode of a codec. * * STRUCT MEMBERS: * nSize : Size of the struct in bytes * nVersion : OMX spec version info * nPortIndex : Port that this struct applies to * eControlRate : Control rate type enum * nTargetBitrate : Target bitrate to encode with */ typedef struct OMX_VIDEO_PARAM_BITRATETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_CONTROLRATETYPE eControlRate; OMX_U32 nTargetBitrate; } OMX_VIDEO_PARAM_BITRATETYPE; /** * Enumeration of possible motion vector (MV) types */ typedef enum OMX_VIDEO_MOTIONVECTORTYPE { OMX_Video_MotionVectorPixel, OMX_Video_MotionVectorHalfPel, OMX_Video_MotionVectorQuarterPel, OMX_Video_MotionVectorEighthPel, OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_Video_MotionVectorMax = 0x7FFFFFFF } OMX_VIDEO_MOTIONVECTORTYPE; /** * Structure for configuring the number of motion vectors used as well * as their accuracy. * * STRUCT MEMBERS: * nSize : Size of the struct in bytes * nVersion : OMX spec version info * nPortIndex : port that this structure applies to * eAccuracy : Enumerated MV accuracy * bUnrestrictedMVs : Allow unrestricted MVs * bFourMV : Allow use of 4 MVs * sXSearchRange : Search range in horizontal direction for MVs * sYSearchRange : Search range in vertical direction for MVs */ typedef struct OMX_VIDEO_PARAM_MOTIONVECTORTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_MOTIONVECTORTYPE eAccuracy; OMX_BOOL bUnrestrictedMVs; OMX_BOOL bFourMV; OMX_S32 sXSearchRange; OMX_S32 sYSearchRange; } OMX_VIDEO_PARAM_MOTIONVECTORTYPE; /** * Enumeration of possible methods to use for Intra Refresh */ typedef enum OMX_VIDEO_INTRAREFRESHTYPE { OMX_VIDEO_IntraRefreshCyclic, OMX_VIDEO_IntraRefreshAdaptive, OMX_VIDEO_IntraRefreshBoth, OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_IntraRefreshRandom, OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF } OMX_VIDEO_INTRAREFRESHTYPE; /** * Structure for configuring intra refresh mode * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eRefreshMode : Cyclic, Adaptive, or Both * nAirMBs : Number of intra macroblocks to refresh in a frame when * AIR is enabled * nAirRef : Number of times a motion marked macroblock has to be * intra coded * nCirMBs : Number of consecutive macroblocks to be coded as "intra" * when CIR is enabled */ typedef struct OMX_VIDEO_PARAM_INTRAREFRESHTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_INTRAREFRESHTYPE eRefreshMode; OMX_U32 nAirMBs; OMX_U32 nAirRef; OMX_U32 nCirMBs; } OMX_VIDEO_PARAM_INTRAREFRESHTYPE; /** * Structure for enabling various error correction methods for video * compression. * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * bEnableHEC : Enable/disable header extension codes (HEC) * bEnableResync : Enable/disable resynchronization markers * nResynchMarkerSpacing : Resynch markers interval (in bits) to be * applied in the stream * bEnableDataPartitioning : Enable/disable data partitioning * bEnableRVLC : Enable/disable reversible variable length * coding */ typedef struct OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnableHEC; OMX_BOOL bEnableResync; OMX_U32 nResynchMarkerSpacing; OMX_BOOL bEnableDataPartitioning; OMX_BOOL bEnableRVLC; } OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE; /** * Configuration of variable block-size motion compensation (VBSMC) * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * b16x16 : Enable inter block search 16x16 * b16x8 : Enable inter block search 16x8 * b8x16 : Enable inter block search 8x16 * b8x8 : Enable inter block search 8x8 * b8x4 : Enable inter block search 8x4 * b4x8 : Enable inter block search 4x8 * b4x4 : Enable inter block search 4x4 */ typedef struct OMX_VIDEO_PARAM_VBSMCTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL b16x16; OMX_BOOL b16x8; OMX_BOOL b8x16; OMX_BOOL b8x8; OMX_BOOL b8x4; OMX_BOOL b4x8; OMX_BOOL b4x4; } OMX_VIDEO_PARAM_VBSMCTYPE; /** * H.263 profile types, each profile indicates support for various * performance bounds and different annexes. * * ENUMS: * Baseline : Baseline Profile: H.263 (V1), no optional modes * H320 Coding : H.320 Coding Efficiency Backward Compatibility * Profile: H.263+ (V2), includes annexes I, J, L.4 * and T * BackwardCompatible : Backward Compatibility Profile: H.263 (V1), * includes annex F * ISWV2 : Interactive Streaming Wireless Profile: H.263+ * (V2), includes annexes I, J, K and T * ISWV3 : Interactive Streaming Wireless Profile: H.263++ * (V3), includes profile 3 and annexes V and W.6.3.8 * HighCompression : Conversational High Compression Profile: H.263++ * (V3), includes profiles 1 & 2 and annexes D and U * Internet : Conversational Internet Profile: H.263++ (V3), * includes profile 5 and annex K * Interlace : Conversational Interlace Profile: H.263++ (V3), * includes profile 5 and annex W.6.3.11 * HighLatency : High Latency Profile: H.263++ (V3), includes * profile 6 and annexes O.1 and P.5 */ typedef enum OMX_VIDEO_H263PROFILETYPE { OMX_VIDEO_H263ProfileBaseline = 0x01, OMX_VIDEO_H263ProfileH320Coding = 0x02, OMX_VIDEO_H263ProfileBackwardCompatible = 0x04, OMX_VIDEO_H263ProfileISWV2 = 0x08, OMX_VIDEO_H263ProfileISWV3 = 0x10, OMX_VIDEO_H263ProfileHighCompression = 0x20, OMX_VIDEO_H263ProfileInternet = 0x40, OMX_VIDEO_H263ProfileInterlace = 0x80, OMX_VIDEO_H263ProfileHighLatency = 0x100, OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_H263ProfileMax = 0x7FFFFFFF } OMX_VIDEO_H263PROFILETYPE; /** * H.263 level types, each level indicates support for various frame sizes, * bit rates, decoder frame rates. */ typedef enum OMX_VIDEO_H263LEVELTYPE { OMX_VIDEO_H263Level10 = 0x01, OMX_VIDEO_H263Level20 = 0x02, OMX_VIDEO_H263Level30 = 0x04, OMX_VIDEO_H263Level40 = 0x08, OMX_VIDEO_H263Level45 = 0x10, OMX_VIDEO_H263Level50 = 0x20, OMX_VIDEO_H263Level60 = 0x40, OMX_VIDEO_H263Level70 = 0x80, OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_H263LevelMax = 0x7FFFFFFF } OMX_VIDEO_H263LEVELTYPE; /** * Specifies the picture type. These values should be OR'd to signal all * pictures types which are allowed. * * ENUMS: * Generic Picture Types: I, P and B * H.263 Specific Picture Types: SI and SP * H.264 Specific Picture Types: EI and EP * MPEG-4 Specific Picture Types: S */ typedef enum OMX_VIDEO_PICTURETYPE { OMX_VIDEO_PictureTypeI = 0x01, OMX_VIDEO_PictureTypeP = 0x02, OMX_VIDEO_PictureTypeB = 0x04, OMX_VIDEO_PictureTypeSI = 0x08, OMX_VIDEO_PictureTypeSP = 0x10, OMX_VIDEO_PictureTypeEI = 0x11, OMX_VIDEO_PictureTypeEP = 0x12, OMX_VIDEO_PictureTypeS = 0x14, OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF } OMX_VIDEO_PICTURETYPE; /** * H.263 Params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nPFrames : Number of P frames between each I frame * nBFrames : Number of B frames between each I frame * eProfile : H.263 profile(s) to use * eLevel : H.263 level(s) to use * bPLUSPTYPEAllowed : Indicating that it is allowed to use PLUSPTYPE * (specified in the 1998 version of H.263) to * indicate custom picture sizes or clock * frequencies * nAllowedPictureTypes : Specifies the picture types allowed in the * bitstream * bForceRoundingTypeToZero : value of the RTYPE bit (bit 6 of MPPTYPE) is * not constrained. It is recommended to change * the value of the RTYPE bit for each reference * picture in error-free communication * nPictureHeaderRepetition : Specifies the frequency of picture header * repetition * nGOBHeaderInterval : Specifies the interval of non-empty GOB * headers in units of GOBs */ typedef struct OMX_VIDEO_PARAM_H263TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nPFrames; OMX_U32 nBFrames; OMX_VIDEO_H263PROFILETYPE eProfile; OMX_VIDEO_H263LEVELTYPE eLevel; OMX_BOOL bPLUSPTYPEAllowed; OMX_U32 nAllowedPictureTypes; OMX_BOOL bForceRoundingTypeToZero; OMX_U32 nPictureHeaderRepetition; OMX_U32 nGOBHeaderInterval; } OMX_VIDEO_PARAM_H263TYPE; /** * MPEG-2 profile types, each profile indicates support for various * performance bounds and different annexes. */ typedef enum OMX_VIDEO_MPEG2PROFILETYPE { OMX_VIDEO_MPEG2ProfileSimple = 0, /**< Simple Profile */ OMX_VIDEO_MPEG2ProfileMain, /**< Main Profile */ OMX_VIDEO_MPEG2Profile422, /**< 4:2:2 Profile */ OMX_VIDEO_MPEG2ProfileSNR, /**< SNR Profile */ OMX_VIDEO_MPEG2ProfileSpatial, /**< Spatial Profile */ OMX_VIDEO_MPEG2ProfileHigh, /**< High Profile */ OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF } OMX_VIDEO_MPEG2PROFILETYPE; /** * MPEG-2 level types, each level indicates support for various frame * sizes, bit rates, decoder frame rates. No need */ typedef enum OMX_VIDEO_MPEG2LEVELTYPE { OMX_VIDEO_MPEG2LevelLL = 0, /**< Low Level */ OMX_VIDEO_MPEG2LevelML, /**< Main Level */ OMX_VIDEO_MPEG2LevelH14, /**< High 1440 */ OMX_VIDEO_MPEG2LevelHL, /**< High Level */ OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF } OMX_VIDEO_MPEG2LEVELTYPE; /** * MPEG-2 params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nPFrames : Number of P frames between each I frame * nBFrames : Number of B frames between each I frame * eProfile : MPEG-2 profile(s) to use * eLevel : MPEG-2 levels(s) to use */ typedef struct OMX_VIDEO_PARAM_MPEG2TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nPFrames; OMX_U32 nBFrames; OMX_VIDEO_MPEG2PROFILETYPE eProfile; OMX_VIDEO_MPEG2LEVELTYPE eLevel; } OMX_VIDEO_PARAM_MPEG2TYPE; /** * MPEG-4 profile types, each profile indicates support for various * performance bounds and different annexes. * * ENUMS: * - Simple Profile, Levels 1-3 * - Simple Scalable Profile, Levels 1-2 * - Core Profile, Levels 1-2 * - Main Profile, Levels 2-4 * - N-bit Profile, Level 2 * - Scalable Texture Profile, Level 1 * - Simple Face Animation Profile, Levels 1-2 * - Simple Face and Body Animation (FBA) Profile, Levels 1-2 * - Basic Animated Texture Profile, Levels 1-2 * - Hybrid Profile, Levels 1-2 * - Advanced Real Time Simple Profiles, Levels 1-4 * - Core Scalable Profile, Levels 1-3 * - Advanced Coding Efficiency Profile, Levels 1-4 * - Advanced Core Profile, Levels 1-2 * - Advanced Scalable Texture, Levels 2-3 */ typedef enum OMX_VIDEO_MPEG4PROFILETYPE { OMX_VIDEO_MPEG4ProfileSimple = 0x01, OMX_VIDEO_MPEG4ProfileSimpleScalable = 0x02, OMX_VIDEO_MPEG4ProfileCore = 0x04, OMX_VIDEO_MPEG4ProfileMain = 0x08, OMX_VIDEO_MPEG4ProfileNbit = 0x10, OMX_VIDEO_MPEG4ProfileScalableTexture = 0x20, OMX_VIDEO_MPEG4ProfileSimpleFace = 0x40, OMX_VIDEO_MPEG4ProfileSimpleFBA = 0x80, OMX_VIDEO_MPEG4ProfileBasicAnimated = 0x100, OMX_VIDEO_MPEG4ProfileHybrid = 0x200, OMX_VIDEO_MPEG4ProfileAdvancedRealTime = 0x400, OMX_VIDEO_MPEG4ProfileCoreScalable = 0x800, OMX_VIDEO_MPEG4ProfileAdvancedCoding = 0x1000, OMX_VIDEO_MPEG4ProfileAdvancedCore = 0x2000, OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000, OMX_VIDEO_MPEG4ProfileAdvancedSimple = 0x8000, OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_MPEG4ProfileMax = 0x7FFFFFFF } OMX_VIDEO_MPEG4PROFILETYPE; /** * MPEG-4 level types, each level indicates support for various frame * sizes, bit rates, decoder frame rates. No need */ typedef enum OMX_VIDEO_MPEG4LEVELTYPE { OMX_VIDEO_MPEG4Level0 = 0x01, /**< Level 0 */ OMX_VIDEO_MPEG4Level0b = 0x02, /**< Level 0b */ OMX_VIDEO_MPEG4Level1 = 0x04, /**< Level 1 */ OMX_VIDEO_MPEG4Level2 = 0x08, /**< Level 2 */ OMX_VIDEO_MPEG4Level3 = 0x10, /**< Level 3 */ OMX_VIDEO_MPEG4Level4 = 0x20, /**< Level 4 */ OMX_VIDEO_MPEG4Level4a = 0x40, /**< Level 4a */ OMX_VIDEO_MPEG4Level5 = 0x80, /**< Level 5 */ OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF } OMX_VIDEO_MPEG4LEVELTYPE; /** * MPEG-4 configuration. This structure handles configuration options * which are specific to MPEG4 algorithms * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nSliceHeaderSpacing : Number of macroblocks between slice header (H263+ * Annex K). Put zero if not used * bSVH : Enable Short Video Header mode * bGov : Flag to enable GOV * nPFrames : Number of P frames between each I frame (also called * GOV period) * nBFrames : Number of B frames between each I frame * nIDCVLCThreshold : Value of intra DC VLC threshold * bACPred : Flag to use ac prediction * nMaxPacketSize : Maximum size of packet in bytes. * nTimeIncRes : Used to pass VOP time increment resolution for MPEG4. * Interpreted as described in MPEG4 standard. * eProfile : MPEG-4 profile(s) to use. * eLevel : MPEG-4 level(s) to use. * nAllowedPictureTypes : Specifies the picture types allowed in the bitstream * nHeaderExtension : Specifies the number of consecutive video packet * headers within a VOP * bReversibleVLC : Specifies whether reversible variable length coding * is in use */ typedef struct OMX_VIDEO_PARAM_MPEG4TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nSliceHeaderSpacing; OMX_BOOL bSVH; OMX_BOOL bGov; OMX_U32 nPFrames; OMX_U32 nBFrames; OMX_U32 nIDCVLCThreshold; OMX_BOOL bACPred; OMX_U32 nMaxPacketSize; OMX_U32 nTimeIncRes; OMX_VIDEO_MPEG4PROFILETYPE eProfile; OMX_VIDEO_MPEG4LEVELTYPE eLevel; OMX_U32 nAllowedPictureTypes; OMX_U32 nHeaderExtension; OMX_BOOL bReversibleVLC; } OMX_VIDEO_PARAM_MPEG4TYPE; /** * WMV Versions */ typedef enum OMX_VIDEO_WMVFORMATTYPE { OMX_VIDEO_WMVFormatUnused = 0x01, /**< Format unused or unknown */ OMX_VIDEO_WMVFormat7 = 0x02, /**< Windows Media Video format 7 */ OMX_VIDEO_WMVFormat8 = 0x04, /**< Windows Media Video format 8 */ OMX_VIDEO_WMVFormat9 = 0x08, /**< Windows Media Video format 9 */ OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_WMVFormatMax = 0x7FFFFFFF } OMX_VIDEO_WMVFORMATTYPE; /** * WMV Params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFormat : Version of WMV stream / data */ typedef struct OMX_VIDEO_PARAM_WMVTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_WMVFORMATTYPE eFormat; } OMX_VIDEO_PARAM_WMVTYPE; /** * Real Video Version */ typedef enum OMX_VIDEO_RVFORMATTYPE { OMX_VIDEO_RVFormatUnused = 0, /**< Format unused or unknown */ OMX_VIDEO_RVFormat8, /**< Real Video format 8 */ OMX_VIDEO_RVFormat9, /**< Real Video format 9 */ OMX_VIDEO_RVFormatG2, /**< Real Video Format G2 */ OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_RVFormatMax = 0x7FFFFFFF } OMX_VIDEO_RVFORMATTYPE; /** * Real Video Params * * STUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * eFormat : Version of RV stream / data * nBitsPerPixel : Bits per pixel coded in the frame * nPaddedWidth : Padded width in pixel of a video frame * nPaddedHeight : Padded Height in pixels of a video frame * nFrameRate : Rate of video in frames per second * nBitstreamFlags : Flags which internal information about the bitstream * nBitstreamVersion : Bitstream version * nMaxEncodeFrameSize: Max encoded frame size * bEnablePostFilter : Turn on/off post filter * bEnableTemporalInterpolation : Turn on/off temporal interpolation * bEnableLatencyMode : When enabled, the decoder does not display a decoded * frame until it has detected that no enhancement layer * frames or dependent B frames will be coming. This * detection usually occurs when a subsequent non-B * frame is encountered */ typedef struct OMX_VIDEO_PARAM_RVTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_RVFORMATTYPE eFormat; OMX_U16 nBitsPerPixel; OMX_U16 nPaddedWidth; OMX_U16 nPaddedHeight; OMX_U32 nFrameRate; OMX_U32 nBitstreamFlags; OMX_U32 nBitstreamVersion; OMX_U32 nMaxEncodeFrameSize; OMX_BOOL bEnablePostFilter; OMX_BOOL bEnableTemporalInterpolation; OMX_BOOL bEnableLatencyMode; } OMX_VIDEO_PARAM_RVTYPE; /** * AVC profile types, each profile indicates support for various * performance bounds and different annexes. */ typedef enum OMX_VIDEO_AVCPROFILETYPE { OMX_VIDEO_AVCProfileBaseline = 0x01, /**< Baseline profile */ OMX_VIDEO_AVCProfileMain = 0x02, /**< Main profile */ OMX_VIDEO_AVCProfileExtended = 0x04, /**< Extended profile */ OMX_VIDEO_AVCProfileHigh = 0x08, /**< High profile */ OMX_VIDEO_AVCProfileHigh10 = 0x10, /**< High 10 profile */ OMX_VIDEO_AVCProfileHigh422 = 0x20, /**< High 4:2:2 profile */ OMX_VIDEO_AVCProfileHigh444 = 0x40, /**< High 4:4:4 profile */ OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_AVCProfileMax = 0x7FFFFFFF } OMX_VIDEO_AVCPROFILETYPE; /** * AVC level types, each level indicates support for various frame sizes, * bit rates, decoder frame rates. No need */ typedef enum OMX_VIDEO_AVCLEVELTYPE { OMX_VIDEO_AVCLevel1 = 0x01, /**< Level 1 */ OMX_VIDEO_AVCLevel1b = 0x02, /**< Level 1b */ OMX_VIDEO_AVCLevel11 = 0x04, /**< Level 1.1 */ OMX_VIDEO_AVCLevel12 = 0x08, /**< Level 1.2 */ OMX_VIDEO_AVCLevel13 = 0x10, /**< Level 1.3 */ OMX_VIDEO_AVCLevel2 = 0x20, /**< Level 2 */ OMX_VIDEO_AVCLevel21 = 0x40, /**< Level 2.1 */ OMX_VIDEO_AVCLevel22 = 0x80, /**< Level 2.2 */ OMX_VIDEO_AVCLevel3 = 0x100, /**< Level 3 */ OMX_VIDEO_AVCLevel31 = 0x200, /**< Level 3.1 */ OMX_VIDEO_AVCLevel32 = 0x400, /**< Level 3.2 */ OMX_VIDEO_AVCLevel4 = 0x800, /**< Level 4 */ OMX_VIDEO_AVCLevel41 = 0x1000, /**< Level 4.1 */ OMX_VIDEO_AVCLevel42 = 0x2000, /**< Level 4.2 */ OMX_VIDEO_AVCLevel5 = 0x4000, /**< Level 5 */ OMX_VIDEO_AVCLevel51 = 0x8000, /**< Level 5.1 */ OMX_VIDEO_AVCLevel52 = 0x10000, /**< Level 5.2 */ OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF } OMX_VIDEO_AVCLEVELTYPE; /** * AVC loop filter modes * * OMX_VIDEO_AVCLoopFilterEnable : Enable * OMX_VIDEO_AVCLoopFilterDisable : Disable * OMX_VIDEO_AVCLoopFilterDisableSliceBoundary : Disabled on slice boundaries */ typedef enum OMX_VIDEO_AVCLOOPFILTERTYPE { OMX_VIDEO_AVCLoopFilterEnable = 0, OMX_VIDEO_AVCLoopFilterDisable, OMX_VIDEO_AVCLoopFilterDisableSliceBoundary, OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF } OMX_VIDEO_AVCLOOPFILTERTYPE; /** * AVC params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nSliceHeaderSpacing : Number of macroblocks between slice header, put * zero if not used * nPFrames : Number of P frames between each I frame * nBFrames : Number of B frames between each I frame * bUseHadamard : Enable/disable Hadamard transform * nRefFrames : Max number of reference frames to use for inter * motion search (1-16) * nRefIdxTrailing : Pic param set ref frame index (index into ref * frame buffer of trailing frames list), B frame * support * nRefIdxForward : Pic param set ref frame index (index into ref * frame buffer of forward frames list), B frame * support * bEnableUEP : Enable/disable unequal error protection. This * is only valid of data partitioning is enabled. * bEnableFMO : Enable/disable flexible macroblock ordering * bEnableASO : Enable/disable arbitrary slice ordering * bEnableRS : Enable/disable sending of redundant slices * eProfile : AVC profile(s) to use * eLevel : AVC level(s) to use * nAllowedPictureTypes : Specifies the picture types allowed in the * bitstream * bFrameMBsOnly : specifies that every coded picture of the * coded video sequence is a coded frame * containing only frame macroblocks * bMBAFF : Enable/disable switching between frame and * field macroblocks within a picture * bEntropyCodingCABAC : Entropy decoding method to be applied for the * syntax elements for which two descriptors appear * in the syntax tables * bWeightedPPrediction : Enable/disable weighted prediction shall not * be applied to P and SP slices * nWeightedBipredicitonMode : Default weighted prediction is applied to B * slices * bconstIpred : Enable/disable intra prediction * bDirect8x8Inference : Specifies the method used in the derivation * process for luma motion vectors for B_Skip, * B_Direct_16x16 and B_Direct_8x8 as specified * in subclause 8.4.1.2 of the AVC spec * bDirectSpatialTemporal : Flag indicating spatial or temporal direct * mode used in B slice coding (related to * bDirect8x8Inference) . Spatial direct mode is * more common and should be the default. * nCabacInitIdx : Index used to init CABAC contexts * eLoopFilterMode : Enable/disable loop filter */ typedef struct OMX_VIDEO_PARAM_AVCTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nSliceHeaderSpacing; OMX_U32 nPFrames; OMX_U32 nBFrames; OMX_BOOL bUseHadamard; OMX_U32 nRefFrames; OMX_U32 nRefIdx10ActiveMinus1; OMX_U32 nRefIdx11ActiveMinus1; OMX_BOOL bEnableUEP; OMX_BOOL bEnableFMO; OMX_BOOL bEnableASO; OMX_BOOL bEnableRS; OMX_VIDEO_AVCPROFILETYPE eProfile; OMX_VIDEO_AVCLEVELTYPE eLevel; OMX_U32 nAllowedPictureTypes; OMX_BOOL bFrameMBsOnly; OMX_BOOL bMBAFF; OMX_BOOL bEntropyCodingCABAC; OMX_BOOL bWeightedPPrediction; OMX_U32 nWeightedBipredicitonMode; OMX_BOOL bconstIpred ; OMX_BOOL bDirect8x8Inference; OMX_BOOL bDirectSpatialTemporal; OMX_U32 nCabacInitIdc; OMX_VIDEO_AVCLOOPFILTERTYPE eLoopFilterMode; } OMX_VIDEO_PARAM_AVCTYPE; typedef struct OMX_VIDEO_PARAM_PROFILELEVELTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 eProfile; /**< type is OMX_VIDEO_AVCPROFILETYPE, OMX_VIDEO_H263PROFILETYPE, or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ OMX_U32 eLevel; /**< type is OMX_VIDEO_AVCLEVELTYPE, OMX_VIDEO_H263LEVELTYPE, or OMX_VIDEO_MPEG4PROFILETYPE depending on context */ OMX_U32 nProfileIndex; /**< Used to query for individual profile support information, This parameter is valid only for OMX_IndexParamVideoProfileLevelQuerySupported index, For all other indices this parameter is to be ignored. */ } OMX_VIDEO_PARAM_PROFILELEVELTYPE; /** * Structure for dynamically configuring bitrate mode of a codec. * * STRUCT MEMBERS: * nSize : Size of the struct in bytes * nVersion : OMX spec version info * nPortIndex : Port that this struct applies to * nEncodeBitrate : Target average bitrate to be generated in bps */ typedef struct OMX_VIDEO_CONFIG_BITRATETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nEncodeBitrate; } OMX_VIDEO_CONFIG_BITRATETYPE; /** * Defines Encoder Frame Rate setting * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * xEncodeFramerate : Encoding framerate represented in Q16 format */ typedef struct OMX_CONFIG_FRAMERATETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 xEncodeFramerate; /* Q16 format */ } OMX_CONFIG_FRAMERATETYPE; typedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL IntraRefreshVOP; } OMX_CONFIG_INTRAREFRESHVOPTYPE; typedef struct OMX_CONFIG_MACROBLOCKERRORMAPTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nErrMapSize; /* Size of the Error Map in bytes */ OMX_U8 ErrMap[1]; /* Error map hint */ } OMX_CONFIG_MACROBLOCKERRORMAPTYPE; typedef struct OMX_CONFIG_MBERRORREPORTINGTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bEnabled; } OMX_CONFIG_MBERRORREPORTINGTYPE; typedef struct OMX_PARAM_MACROBLOCKSTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nMacroblocks; } OMX_PARAM_MACROBLOCKSTYPE; /** * AVC Slice Mode modes * * OMX_VIDEO_SLICEMODE_AVCDefault : Normal frame encoding, one slice per frame * OMX_VIDEO_SLICEMODE_AVCMBSlice : NAL mode, number of MBs per frame * OMX_VIDEO_SLICEMODE_AVCByteSlice : NAL mode, number of bytes per frame */ typedef enum OMX_VIDEO_AVCSLICEMODETYPE { OMX_VIDEO_SLICEMODE_AVCDefault = 0, OMX_VIDEO_SLICEMODE_AVCMBSlice, OMX_VIDEO_SLICEMODE_AVCByteSlice, OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF } OMX_VIDEO_AVCSLICEMODETYPE; /** * AVC FMO Slice Mode Params * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nNumSliceGroups : Specifies the number of slice groups * nSliceGroupMapType : Specifies the type of slice groups * eSliceMode : Specifies the type of slice */ typedef struct OMX_VIDEO_PARAM_AVCSLICEFMO { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U8 nNumSliceGroups; OMX_U8 nSliceGroupMapType; OMX_VIDEO_AVCSLICEMODETYPE eSliceMode; } OMX_VIDEO_PARAM_AVCSLICEFMO; /** * AVC IDR Period Configs * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nIDRPeriod : Specifies periodicity of IDR frames * nPFrames : Specifies internal of coding Intra frames */ typedef struct OMX_VIDEO_CONFIG_AVCINTRAPERIOD { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nIDRPeriod; OMX_U32 nPFrames; } OMX_VIDEO_CONFIG_AVCINTRAPERIOD; /** * AVC NAL Size Configs * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nNaluBytes : Specifies the NAL unit size */ typedef struct OMX_VIDEO_CONFIG_NALSIZE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nNaluBytes; } OMX_VIDEO_CONFIG_NALSIZE; /** * Deinterlace Config * * STRUCT MEMBERS: * nSize : Size of the structure in bytes * nVersion : OMX specification version information * nPortIndex : Port that this structure applies to * nEnable : Specifies to enable deinterlace */ typedef struct OMX_VIDEO_CONFIG_DEINTERLACE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_U32 nEnable; } OMX_VIDEO_CONFIG_DEINTERLACE; /** @} */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* File EOF */ ================================================ FILE: phonelibs/openmax/include/OMX_VideoExt.h ================================================ /* * Copyright (c) 2010 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_VideoExt.h - OpenMax IL version 1.1.2 * The OMX_VideoExt header file contains extensions to the * definitions used by both the application and the component to * access video items. */ #ifndef OMX_VideoExt_h #define OMX_VideoExt_h #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Each OMX header shall include all required header files to allow the * header to compile without errors. The includes below are required * for this header file to compile successfully */ #include /** NALU Formats */ typedef enum OMX_NALUFORMATSTYPE { OMX_NaluFormatStartCodes = 1, OMX_NaluFormatOneNaluPerBuffer = 2, OMX_NaluFormatOneByteInterleaveLength = 4, OMX_NaluFormatTwoByteInterleaveLength = 8, OMX_NaluFormatFourByteInterleaveLength = 16, OMX_NaluFormatCodingMax = 0x7FFFFFFF } OMX_NALUFORMATSTYPE; /** NAL Stream Format */ typedef struct OMX_NALSTREAMFORMATTYPE{ OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_NALUFORMATSTYPE eNaluFormat; } OMX_NALSTREAMFORMATTYPE; /** VP8 profiles */ typedef enum OMX_VIDEO_VP8PROFILETYPE { OMX_VIDEO_VP8ProfileMain = 0x01, OMX_VIDEO_VP8ProfileUnknown = 0x6EFFFFFF, OMX_VIDEO_VP8ProfileMax = 0x7FFFFFFF } OMX_VIDEO_VP8PROFILETYPE; /** VP8 levels */ typedef enum OMX_VIDEO_VP8LEVELTYPE { OMX_VIDEO_VP8Level_Version0 = 0x01, OMX_VIDEO_VP8Level_Version1 = 0x02, OMX_VIDEO_VP8Level_Version2 = 0x04, OMX_VIDEO_VP8Level_Version3 = 0x08, OMX_VIDEO_VP8LevelUnknown = 0x6EFFFFFF, OMX_VIDEO_VP8LevelMax = 0x7FFFFFFF } OMX_VIDEO_VP8LEVELTYPE; /** VP8 Param */ typedef struct OMX_VIDEO_PARAM_VP8TYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_VP8PROFILETYPE eProfile; OMX_VIDEO_VP8LEVELTYPE eLevel; OMX_U32 nDCTPartitions; OMX_BOOL bErrorResilientMode; } OMX_VIDEO_PARAM_VP8TYPE; /** Structure for configuring VP8 reference frames */ typedef struct OMX_VIDEO_VP8REFERENCEFRAMETYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bPreviousFrameRefresh; OMX_BOOL bGoldenFrameRefresh; OMX_BOOL bAlternateFrameRefresh; OMX_BOOL bUsePreviousFrame; OMX_BOOL bUseGoldenFrame; OMX_BOOL bUseAlternateFrame; } OMX_VIDEO_VP8REFERENCEFRAMETYPE; /** Structure for querying VP8 reference frame type */ typedef struct OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_BOOL bIsIntraFrame; OMX_BOOL bIsGoldenOrAlternateFrame; } OMX_VIDEO_VP8REFERENCEFRAMEINFOTYPE; /** HEVC Profiles */ typedef enum OMX_VIDEO_HEVCPROFILETYPE { OMX_VIDEO_HEVCProfileMain = 0x01, OMX_VIDEO_HEVCProfileMain10 = 0x02, OMX_VIDEO_HEVCProfileUnknown = 0x6EFFFFFF, OMX_VIDEO_HEVCProfileMax = 0x7FFFFFFF } OMX_VIDEO_HEVCPROFILETYPE; /** HEVC levels */ typedef enum OMX_VIDEO_HEVCLEVELTYPE { OMX_VIDEO_HEVCLevel_Version0 = 0x0, OMX_VIDEO_HEVCMainTierLevel1 = 0x1, OMX_VIDEO_HEVCHighTierLevel1 = 0x2, OMX_VIDEO_HEVCMainTierLevel2 = 0x4, OMX_VIDEO_HEVCHighTierLevel2 = 0x8, OMX_VIDEO_HEVCMainTierLevel21 = 0x10, OMX_VIDEO_HEVCHighTierLevel21 = 0x20, OMX_VIDEO_HEVCMainTierLevel3 = 0x40, OMX_VIDEO_HEVCHighTierLevel3 = 0x80, OMX_VIDEO_HEVCMainTierLevel31 = 0x100, OMX_VIDEO_HEVCHighTierLevel31 = 0x200, OMX_VIDEO_HEVCMainTierLevel4 = 0x400, OMX_VIDEO_HEVCHighTierLevel4 = 0x800, OMX_VIDEO_HEVCMainTierLevel41 = 0x1000, OMX_VIDEO_HEVCHighTierLevel41 = 0x2000, OMX_VIDEO_HEVCMainTierLevel5 = 0x4000, OMX_VIDEO_HEVCHighTierLevel5 = 0x8000, OMX_VIDEO_HEVCMainTierLevel51 = 0x10000, OMX_VIDEO_HEVCHighTierLevel51 = 0x20000, OMX_VIDEO_HEVCMainTierLevel52 = 0x40000, OMX_VIDEO_HEVCHighTierLevel52 = 0x80000, OMX_VIDEO_HEVCMainTierLevel6 = 0x100000, OMX_VIDEO_HEVCHighTierLevel6 = 0x200000, OMX_VIDEO_HEVCMainTierLevel61 = 0x400000, OMX_VIDEO_HEVCHighTierLevel61 = 0x800000, OMX_VIDEO_HEVCMainTierLevel62 = 0x1000000, OMX_VIDEO_HEVCLevelUnknown = 0x6EFFFFFF, OMX_VIDEO_HEVCLevelMax = 0x7FFFFFFF } OMX_VIDEO_HEVCLEVELTYPE; /** HEVC Param */ typedef struct OMX_VIDEO_PARAM_HEVCTYPE { OMX_U32 nSize; OMX_VERSIONTYPE nVersion; OMX_U32 nPortIndex; OMX_VIDEO_HEVCPROFILETYPE eProfile; OMX_VIDEO_HEVCLEVELTYPE eLevel; } OMX_VIDEO_PARAM_HEVCTYPE; #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* OMX_VideoExt_h */ /* File EOF */ ================================================ FILE: phonelibs/qpoases/EXAMPLES/example1.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file EXAMPLES/example1.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Very simple example for testing qpOASES (using QProblem class). */ #include /** Example for qpOASES main function using the QProblem class. */ int main( ) { /* Setup data of first QP. */ real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; real_t A[1*2] = { 1.0, 1.0 }; real_t g[2] = { 1.5, 1.0 }; real_t lb[2] = { 0.5, -2.0 }; real_t ub[2] = { 5.0, 2.0 }; real_t lbA[1] = { -1.0 }; real_t ubA[1] = { 2.0 }; /* Setup data of second QP. */ real_t g_new[2] = { 1.0, 1.5 }; real_t lb_new[2] = { 0.0, -1.0 }; real_t ub_new[2] = { 5.0, -0.5 }; real_t lbA_new[1] = { -2.0 }; real_t ubA_new[1] = { 1.0 }; /* Setting up QProblem object. */ QProblem example( 2,1 ); /* Solve first QP. */ int nWSR = 10; example.init( H,g,A,lb,ub,lbA,ubA, nWSR,0 ); /* Solve second QP. */ nWSR = 10; example.hotstart( g_new,lb_new,ub_new,lbA_new,ubA_new, nWSR,0 ); return 0; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/EXAMPLES/example1b.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file EXAMPLES/example1b.cpp * \author Hans Joachim Ferreau * \version 1.3 * \date 2007-2008 * * Very simple example for testing qpOASES using the QProblemB class. */ #include /** Example for qpOASES main function using the QProblemB class. */ int main( ) { /* Setup data of first QP. */ real_t H[2*2] = { 1.0, 0.0, 0.0, 0.5 }; real_t g[2] = { 1.5, 1.0 }; real_t lb[2] = { 0.5, -2.0 }; real_t ub[2] = { 5.0, 2.0 }; /* Setup data of second QP. */ real_t g_new[2] = { 1.0, 1.5 }; real_t lb_new[2] = { 0.0, -1.0 }; real_t ub_new[2] = { 5.0, -0.5 }; /* Setting up QProblemB object. */ QProblemB example( 2 ); /* Solve first QP. */ int nWSR = 10; example.init( H,g,lb,ub, nWSR,0 ); /* Solve second QP. */ nWSR = 10; example.hotstart( g_new,lb_new,ub_new, nWSR,0 ); return 0; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/Bounds.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/Bounds.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the Bounds class designed to manage working sets of * bounds within a QProblem. */ #ifndef QPOASES_BOUNDS_HPP #define QPOASES_BOUNDS_HPP #include /** This class manages working sets of bounds by storing * index sets and other status information. * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class Bounds : public SubjectTo { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ Bounds( ); /** Copy constructor (deep copy). */ Bounds( const Bounds& rhs /**< Rhs object. */ ); /** Destructor. */ ~Bounds( ); /** Assignment operator (deep copy). */ Bounds& operator=( const Bounds& rhs /**< Rhs object. */ ); /** Pseudo-constructor takes the number of bounds. * \return SUCCESSFUL_RETURN */ returnValue init( int n /**< Number of bounds. */ ); /** Initially adds number of a new (i.e. not yet in the list) bound to * given index set. * \return SUCCESSFUL_RETURN \n RET_SETUP_BOUND_FAILED \n RET_INDEX_OUT_OF_BOUNDS \n RET_INVALID_ARGUMENTS */ returnValue setupBound( int _number, /**< Number of new bound. */ SubjectToStatus _status /**< Status of new bound. */ ); /** Initially adds all numbers of new (i.e. not yet in the list) bounds to * to the index set of free bounds; the order depends on the SujectToType * of each index. * \return SUCCESSFUL_RETURN \n RET_SETUP_BOUND_FAILED */ returnValue setupAllFree( ); /** Moves index of a bound from index list of fixed to that of free bounds. * \return SUCCESSFUL_RETURN \n RET_MOVING_BOUND_FAILED \n RET_INDEX_OUT_OF_BOUNDS */ returnValue moveFixedToFree( int _number /**< Number of bound to be freed. */ ); /** Moves index of a bound from index list of free to that of fixed bounds. * \return SUCCESSFUL_RETURN \n RET_MOVING_BOUND_FAILED \n RET_INDEX_OUT_OF_BOUNDS */ returnValue moveFreeToFixed( int _number, /**< Number of bound to be fixed. */ SubjectToStatus _status /**< Status of bound to be fixed. */ ); /** Swaps the indices of two free bounds within the index set. * \return SUCCESSFUL_RETURN \n RET_SWAPINDEX_FAILED */ returnValue swapFree( int number1, /**< Number of first constraint or bound. */ int number2 /**< Number of second constraint or bound. */ ); /** Returns number of variables. * \return Number of variables. */ inline int getNV( ) const; /** Returns number of implicitly fixed variables. * \return Number of implicitly fixed variables. */ inline int getNFV( ) const; /** Returns number of bounded (but possibly free) variables. * \return Number of bounded (but possibly free) variables. */ inline int getNBV( ) const; /** Returns number of unbounded variables. * \return Number of unbounded variables. */ inline int getNUV( ) const; /** Sets number of implicitly fixed variables. * \return SUCCESSFUL_RETURN */ inline returnValue setNFV( int n /**< Number of implicitly fixed variables. */ ); /** Sets number of bounded (but possibly free) variables. * \return SUCCESSFUL_RETURN */ inline returnValue setNBV( int n /**< Number of bounded (but possibly free) variables. */ ); /** Sets number of unbounded variables. * \return SUCCESSFUL_RETURN */ inline returnValue setNUV( int n /**< Number of unbounded variables */ ); /** Returns number of free variables. * \return Number of free variables. */ inline int getNFR( ); /** Returns number of fixed variables. * \return Number of fixed variables. */ inline int getNFX( ); /** Returns a pointer to free variables index list. * \return Pointer to free variables index list. */ inline Indexlist* getFree( ); /** Returns a pointer to fixed variables index list. * \return Pointer to fixed variables index list. */ inline Indexlist* getFixed( ); /* * PROTECTED MEMBER VARIABLES */ protected: int nV; /**< Number of variables (nV = nFV + nBV + nUV). */ int nFV; /**< Number of implicitly fixed variables. */ int nBV; /**< Number of bounded (but possibly free) variables. */ int nUV; /**< Number of unbounded variables. */ Indexlist free; /**< Index list of free variables. */ Indexlist fixed; /**< Index list of fixed variables. */ }; #include #endif /* QPOASES_BOUNDS_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/Constants.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/Constants.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2008 * * Definition of all global constants. */ #ifndef QPOASES_CONSTANTS_HPP #define QPOASES_CONSTANTS_HPP #ifndef QPOASES_CUSTOM_INTERFACE #include "acado_qpoases_interface.hpp" #else #define XSTR(x) #x #define STR(x) XSTR(x) #include STR(QPOASES_CUSTOM_INTERFACE) #endif /** Maximum number of variables within a QP formulation. Note: this value has to be positive! */ const int NVMAX = QPOASES_NVMAX; /** Maximum number of constraints within a QP formulation. Note: this value has to be positive! */ const int NCMAX = QPOASES_NCMAX; /** Redefinition of NCMAX used for memory allocation, to avoid zero sized arrays and compiler errors. */ const int NCMAX_ALLOC = (NCMAX == 0) ? 1 : NCMAX; /**< Maximum number of working set recalculations. Note: this value has to be positive! */ const int NWSRMAX = QPOASES_NWSRMAX; /** Desired KKT tolerance of QP solution; a warning RET_INACCURATE_SOLUTION is * issued if this tolerance is not met. * Note: this value has to be positive! */ const real_t DESIREDACCURACY = (real_t) 1.0e-3; /** Critical KKT tolerance of QP solution; an error is issued if this * tolerance is not met. * Note: this value has to be positive! */ const real_t CRITICALACCURACY = (real_t) 1.0e-2; /** Numerical value of machine precision (min eps, s.t. 1+eps > 1). Note: this value has to be positive! */ const real_t EPS = (real_t) QPOASES_EPS; /** Numerical value of zero (for situations in which it would be * unreasonable to compare with 0.0). * Note: this value has to be positive! */ const real_t ZERO = (real_t) 1.0e-50; /** Numerical value of infinity (e.g. for non-existing bounds). * Note: this value has to be positive! */ const real_t INFTY = (real_t) 1.0e12; /** Lower/upper (constraints') bound tolerance (an inequality constraint * whose lower and upper bound differ by less than BOUNDTOL is regarded * to be an equality constraint). * Note: this value has to be positive! */ const real_t BOUNDTOL = (real_t) 1.0e-10; /** Offset for relaxing (constraints') bounds at beginning of an initial homotopy. * Note: this value has to be positive! */ const real_t BOUNDRELAXATION = (real_t) 1.0e3; /** Factor that determines physical lengths of index lists. * Note: this value has to be greater than 1! */ const int INDEXLISTFACTOR = 5; #endif /* QPOASES_CONSTANTS_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/Constraints.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/Constraints.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the Constraints class designed to manage working sets of * constraints within a QProblem. */ #ifndef QPOASES_CONSTRAINTS_HPP #define QPOASES_CONSTRAINTS_HPP #include /** This class manages working sets of constraints by storing * index sets and other status information. * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class Constraints : public SubjectTo { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ Constraints( ); /** Copy constructor (deep copy). */ Constraints( const Constraints& rhs /**< Rhs object. */ ); /** Destructor. */ ~Constraints( ); /** Assignment operator (deep copy). */ Constraints& operator=( const Constraints& rhs /**< Rhs object. */ ); /** Pseudo-constructor takes the number of constraints. * \return SUCCESSFUL_RETURN */ returnValue init( int n /**< Number of constraints. */ ); /** Initially adds number of a new (i.e. not yet in the list) constraint to * a given index set. * \return SUCCESSFUL_RETURN \n RET_SETUP_CONSTRAINT_FAILED \n RET_INDEX_OUT_OF_BOUNDS \n RET_INVALID_ARGUMENTS */ returnValue setupConstraint( int _number, /**< Number of new constraint. */ SubjectToStatus _status /**< Status of new constraint. */ ); /** Initially adds all enabled numbers of new (i.e. not yet in the list) constraints to * to the index set of inactive constraints; the order depends on the SujectToType * of each index. Only disabled constraints are added to index set of disabled constraints! * \return SUCCESSFUL_RETURN \n RET_SETUP_CONSTRAINT_FAILED */ returnValue setupAllInactive( ); /** Moves index of a constraint from index list of active to that of inactive constraints. * \return SUCCESSFUL_RETURN \n RET_MOVING_CONSTRAINT_FAILED */ returnValue moveActiveToInactive( int _number /**< Number of constraint to become inactive. */ ); /** Moves index of a constraint from index list of inactive to that of active constraints. * \return SUCCESSFUL_RETURN \n RET_MOVING_CONSTRAINT_FAILED */ returnValue moveInactiveToActive( int _number, /**< Number of constraint to become active. */ SubjectToStatus _status /**< Status of constraint to become active. */ ); /** Returns the number of constraints. * \return Number of constraints. */ inline int getNC( ) const; /** Returns the number of implicit equality constraints. * \return Number of implicit equality constraints. */ inline int getNEC( ) const; /** Returns the number of "real" inequality constraints. * \return Number of "real" inequality constraints. */ inline int getNIC( ) const; /** Returns the number of unbounded constraints (i.e. without any bounds). * \return Number of unbounded constraints (i.e. without any bounds). */ inline int getNUC( ) const; /** Sets number of implicit equality constraints. * \return SUCCESSFUL_RETURN */ inline returnValue setNEC( int n /**< Number of implicit equality constraints. */ ); /** Sets number of "real" inequality constraints. * \return SUCCESSFUL_RETURN */ inline returnValue setNIC( int n /**< Number of "real" inequality constraints. */ ); /** Sets number of unbounded constraints (i.e. without any bounds). * \return SUCCESSFUL_RETURN */ inline returnValue setNUC( int n /**< Number of unbounded constraints (i.e. without any bounds). */ ); /** Returns the number of active constraints. * \return Number of constraints. */ inline int getNAC( ); /** Returns the number of inactive constraints. * \return Number of constraints. */ inline int getNIAC( ); /** Returns a pointer to active constraints index list. * \return Pointer to active constraints index list. */ inline Indexlist* getActive( ); /** Returns a pointer to inactive constraints index list. * \return Pointer to inactive constraints index list. */ inline Indexlist* getInactive( ); /* * PROTECTED MEMBER VARIABLES */ protected: int nC; /**< Number of constraints (nC = nEC + nIC + nUC). */ int nEC; /**< Number of implicit equality constraints. */ int nIC; /**< Number of "real" inequality constraints. */ int nUC; /**< Number of unbounded constraints (i.e. without any bounds). */ Indexlist active; /**< Index list of active constraints. */ Indexlist inactive; /**< Index list of inactive constraints. */ }; #include #endif /* QPOASES_CONSTRAINTS_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/CyclingManager.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/CyclingManager.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the CyclingManager class designed to detect * and handle possible cycling during QP iterations. */ #ifndef QPOASES_CYCLINGMANAGER_HPP #define QPOASES_CYCLINGMANAGER_HPP #include /** This class is intended to detect and handle possible cycling during QP iterations. * As cycling seems to occur quite rarely, this class is NOT FULLY IMPLEMENTED YET! * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class CyclingManager { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ CyclingManager( ); /** Copy constructor (deep copy). */ CyclingManager( const CyclingManager& rhs /**< Rhs object. */ ); /** Destructor. */ ~CyclingManager( ); /** Copy asingment operator (deep copy). */ CyclingManager& operator=( const CyclingManager& rhs /**< Rhs object. */ ); /** Pseudo-constructor which takes the number of bounds/constraints. * \return SUCCESSFUL_RETURN */ returnValue init( int _nV, /**< Number of bounds to be managed. */ int _nC /**< Number of constraints to be managed. */ ); /** Stores index of a bound/constraint that might cause cycling. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ returnValue setCyclingStatus( int number, /**< Number of bound/constraint. */ BooleanType isBound, /**< Flag that indicates if given number corresponds to a * bound (BT_TRUE) or a constraint (BT_FALSE). */ CyclingStatus _status /**< Cycling status of bound/constraint. */ ); /** Returns if bound/constraint might cause cycling. * \return BT_TRUE: bound/constraint might cause cycling \n BT_FALSE: otherwise */ CyclingStatus getCyclingStatus( int number, /**< Number of bound/constraint. */ BooleanType isBound /**< Flag that indicates if given number corresponds to * a bound (BT_TRUE) or a constraint (BT_FALSE). */ ) const; /** Clears all previous cycling information. * \return SUCCESSFUL_RETURN */ returnValue clearCyclingData( ); /** Returns if cycling was detected. * \return BT_TRUE iff cycling was detected. */ inline BooleanType isCyclingDetected( ) const; /* * PROTECTED MEMBER VARIABLES */ protected: int nV; /**< Number of managed bounds. */ int nC; /**< Number of managed constraints. */ CyclingStatus status[NVMAX+NCMAX]; /**< Array to store cycling status of all bounds/constraints. */ BooleanType cyclingDetected; /**< Flag if cycling was detected. */ }; #include #endif /* QPOASES_CYCLINGMANAGER_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/EXTRAS/SolutionAnalysis.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/EXTRAS/SolutionAnalysis.hpp * \author Milan Vukov, Boris Houska, Hans Joachim Ferreau * \version 1.3embedded * \date 2012 * * Solution analysis class, based on a class in the standard version of the qpOASES */ // #ifndef QPOASES_SOLUTIONANALYSIS_HPP #define QPOASES_SOLUTIONANALYSIS_HPP #include /** Enables the computation of variance as is in the standard version of qpOASES */ #define QPOASES_USE_OLD_VERSION 0 #if QPOASES_USE_OLD_VERSION #define KKT_DIM (2 * NVMAX + NCMAX) #endif class SolutionAnalysis { public: /** Default constructor. */ SolutionAnalysis( ); /** Copy constructor (deep copy). */ SolutionAnalysis( const SolutionAnalysis& rhs /**< Rhs object. */ ); /** Destructor. */ ~SolutionAnalysis( ); /** Copy asingment operator (deep copy). */ SolutionAnalysis& operator=( const SolutionAnalysis& rhs /**< Rhs object. */ ); /** A routine for computation of inverse of the Hessian matrix. */ returnValue getHessianInverse( QProblem* qp, /** QP */ real_t* hessianInverse /** Inverse of the Hessian matrix*/ ); /** A routine for computation of inverse of the Hessian matrix. */ returnValue getHessianInverse( QProblemB* qp, /** QP */ real_t* hessianInverse /** Inverse of the Hessian matrix*/ ); #if QPOASES_USE_OLD_VERSION returnValue getVarianceCovariance( QProblem* qp, real_t* g_b_bA_VAR, real_t* Primal_Dual_VAR ); #endif private: real_t delta_g_cov[ NVMAX ]; /** A covariance-vector of g */ real_t delta_lb_cov[ NVMAX ]; /** A covariance-vector of lb */ real_t delta_ub_cov[ NVMAX ]; /** A covariance-vector of ub */ real_t delta_lbA_cov[ NCMAX_ALLOC ]; /** A covariance-vector of lbA */ real_t delta_ubA_cov[ NCMAX_ALLOC ]; /** A covariance-vector of ubA */ #if QPOASES_USE_OLD_VERSION real_t K[KKT_DIM * KKT_DIM]; /** A matrix to store an intermediate result */ #endif int FR_idx[ NVMAX ]; /** Index array for free variables */ int FX_idx[ NVMAX ]; /** Index array for fixed variables */ int AC_idx[ NCMAX_ALLOC ]; /** Index array for active constraints */ real_t delta_xFR[ NVMAX ]; /** QP reaction, primal, w.r.t. free */ real_t delta_xFX[ NVMAX ]; /** QP reaction, primal, w.r.t. fixed */ real_t delta_yAC[ NVMAX ]; /** QP reaction, dual, w.r.t. active */ real_t delta_yFX[ NVMAX ]; /** QP reaction, dual, w.r.t. fixed*/ }; #endif // QPOASES_SOLUTIONANALYSIS_HPP ================================================ FILE: phonelibs/qpoases/INCLUDE/Indexlist.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/Indexlist.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the Indexlist class designed to manage index lists of * constraints and bounds within a SubjectTo object. */ #ifndef QPOASES_INDEXLIST_HPP #define QPOASES_INDEXLIST_HPP #include /** This class manages index lists. * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class Indexlist { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ Indexlist( ); /** Copy constructor (deep copy). */ Indexlist( const Indexlist& rhs /**< Rhs object. */ ); /** Destructor. */ ~Indexlist( ); /** Assingment operator (deep copy). */ Indexlist& operator=( const Indexlist& rhs /**< Rhs object. */ ); /** Pseudo-constructor. * \return SUCCESSFUL_RETURN */ returnValue init( ); /** Creates an array of all numbers within the index set in correct order. * \return SUCCESSFUL_RETURN \n RET_INDEXLIST_CORRUPTED */ returnValue getNumberArray( int* const numberarray /**< Output: Array of numbers (NULL on error). */ ) const; /** Determines the index within the index list at with a given number is stored. * \return >= 0: Index of given number. \n -1: Number not found. */ int getIndex( int givennumber /**< Number whose index shall be determined. */ ) const; /** Determines the physical index within the index list at with a given number is stored. * \return >= 0: Index of given number. \n -1: Number not found. */ int getPhysicalIndex( int givennumber /**< Number whose physical index shall be determined. */ ) const; /** Returns the number stored at a given physical index. * \return >= 0: Number stored at given physical index. \n -RET_INDEXLIST_OUTOFBOUNDS */ int getNumber( int physicalindex /**< Physical index of the number to be returned. */ ) const; /** Returns the current length of the index list. * \return Current length of the index list. */ inline int getLength( ); /** Returns last number within the index list. * \return Last number within the index list. */ inline int getLastNumber( ) const; /** Adds number to index list. * \return SUCCESSFUL_RETURN \n RET_INDEXLIST_MUST_BE_REORDERD \n RET_INDEXLIST_EXCEEDS_MAX_LENGTH */ returnValue addNumber( int addnumber /**< Number to be added. */ ); /** Removes number from index list. * \return SUCCESSFUL_RETURN */ returnValue removeNumber( int removenumber /**< Number to be removed. */ ); /** Swaps two numbers within index list. * \return SUCCESSFUL_RETURN */ returnValue swapNumbers( int number1,/**< First number for swapping. */ int number2 /**< Second number for swapping. */ ); /** Determines if a given number is contained in the index set. * \return BT_TRUE iff number is contain in the index set */ inline BooleanType isMember( int _number /**< Number to be tested for membership. */ ) const; /* * PROTECTED MEMBER VARIABLES */ protected: int number[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store numbers of constraints or bounds. */ int next[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of successor. */ int previous[INDEXLISTFACTOR*(NVMAX+NCMAX)]; /**< Array to store physical index of predecossor. */ int length; /**< Length of index list. */ int first; /**< Physical index of first element. */ int last; /**< Physical index of last element. */ int lastusedindex; /**< Physical index of last entry in index list. */ int physicallength; /**< Physical length of index list. */ }; #include #endif /* QPOASES_INDEXLIST_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/MessageHandling.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/MessageHandling.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the MessageHandling class including global return values. */ #ifndef QPOASES_MESSAGEHANDLING_HPP #define QPOASES_MESSAGEHANDLING_HPP // #define PC_DEBUG #ifdef PC_DEBUG #include /** Defines an alias for FILE from stdio.h. */ #define myFILE FILE /** Defines an alias for stderr from stdio.h. */ #define myStderr stderr /** Defines an alias for stdout from stdio.h. */ #define myStdout stdout #else /** Defines an alias for FILE from stdio.h. */ #define myFILE int /** Defines an alias for stderr from stdio.h. */ #define myStderr 0 /** Defines an alias for stdout from stdio.h. */ #define myStdout 0 #endif #include #include /** Defines symbols for global return values. \n * Important: All return values are assumed to be nonnegative! */ enum returnValue { TERMINAL_LIST_ELEMENT = -1, /**< Terminal list element, internal usage only! */ /* miscellaneous */ SUCCESSFUL_RETURN = 0, /**< Successful return. */ RET_DIV_BY_ZERO, /**< Division by zero. */ RET_INDEX_OUT_OF_BOUNDS, /**< Index out of bounds. */ RET_INVALID_ARGUMENTS, /**< At least one of the arguments is invalid. */ RET_ERROR_UNDEFINED, /**< Error number undefined. */ RET_WARNING_UNDEFINED, /**< Warning number undefined. */ RET_INFO_UNDEFINED, /**< Info number undefined. */ RET_EWI_UNDEFINED, /**< Error/warning/info number undefined. */ RET_AVAILABLE_WITH_LINUX_ONLY, /**< This function is available under Linux only. */ RET_UNKNOWN_BUG, /**< The error occured is not yet known. */ RET_PRINTLEVEL_CHANGED, /**< 10 Print level changed. */ RET_NOT_YET_IMPLEMENTED, /**< Requested function is not yet implemented in this version of qpOASES. */ /* Indexlist */ RET_INDEXLIST_MUST_BE_REORDERD, /**< Index list has to be reordered. */ RET_INDEXLIST_EXCEEDS_MAX_LENGTH, /**< Index list exceeds its maximal physical length. */ RET_INDEXLIST_CORRUPTED, /**< Index list corrupted. */ RET_INDEXLIST_OUTOFBOUNDS, /**< Physical index is out of bounds. */ RET_INDEXLIST_ADD_FAILED, /**< Adding indices from another index set failed. */ RET_INDEXLIST_INTERSECT_FAILED, /**< Intersection with another index set failed. */ /* SubjectTo / Bounds / Constraints */ RET_INDEX_ALREADY_OF_DESIRED_STATUS, /**< Index is already of desired status. */ RET_ADDINDEX_FAILED, /**< Cannot swap between different indexsets. */ RET_SWAPINDEX_FAILED, /**< 20 Adding index to index set failed. */ RET_NOTHING_TO_DO, /**< Nothing to do. */ RET_SETUP_BOUND_FAILED, /**< Setting up bound index failed. */ RET_SETUP_CONSTRAINT_FAILED, /**< Setting up constraint index failed. */ RET_MOVING_BOUND_FAILED, /**< Moving bound between index sets failed. */ RET_MOVING_CONSTRAINT_FAILED, /**< Moving constraint between index sets failed. */ /* QProblem */ RET_QP_ALREADY_INITIALISED, /**< QProblem has already been initialised. */ RET_NO_INIT_WITH_STANDARD_SOLVER, /**< Initialisation via extern QP solver is not yet implemented. */ RET_RESET_FAILED, /**< Reset failed. */ RET_INIT_FAILED, /**< Initialisation failed. */ RET_INIT_FAILED_TQ, /**< 30 Initialisation failed due to TQ factorisation. */ RET_INIT_FAILED_CHOLESKY, /**< Initialisation failed due to Cholesky decomposition. */ RET_INIT_FAILED_HOTSTART, /**< Initialisation failed! QP could not be solved! */ RET_INIT_FAILED_INFEASIBILITY, /**< Initial QP could not be solved due to infeasibility! */ RET_INIT_FAILED_UNBOUNDEDNESS, /**< Initial QP could not be solved due to unboundedness! */ RET_INIT_SUCCESSFUL, /**< Initialisation done. */ RET_OBTAINING_WORKINGSET_FAILED, /**< Failed to obtain working set for auxiliary QP. */ RET_SETUP_WORKINGSET_FAILED, /**< Failed to setup working set for auxiliary QP. */ RET_SETUP_AUXILIARYQP_FAILED, /**< Failed to setup auxiliary QP for initialised homotopy. */ RET_NO_EXTERN_SOLVER, /**< No extern QP solver available. */ RET_QP_UNBOUNDED, /**< 40 QP is unbounded. */ RET_QP_INFEASIBLE, /**< QP is infeasible. */ RET_QP_NOT_SOLVED, /**< Problems occured while solving QP with standard solver. */ RET_QP_SOLVED, /**< QP successfully solved. */ RET_UNABLE_TO_SOLVE_QP, /**< Problems occured while solving QP. */ RET_INITIALISATION_STARTED, /**< Starting problem initialisation. */ RET_HOTSTART_FAILED, /**< Unable to perform homotopy due to internal error. */ RET_HOTSTART_FAILED_TO_INIT, /**< Unable to initialise problem. */ RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, /**< Unable to perform homotopy as previous QP is not solved. */ RET_ITERATION_STARTED, /**< Iteration... */ RET_SHIFT_DETERMINATION_FAILED, /**< 50 Determination of shift of the QP data failed. */ RET_STEPDIRECTION_DETERMINATION_FAILED, /**< Determination of step direction failed. */ RET_STEPLENGTH_DETERMINATION_FAILED, /**< Determination of step direction failed. */ RET_OPTIMAL_SOLUTION_FOUND, /**< Optimal solution of neighbouring QP found. */ RET_HOMOTOPY_STEP_FAILED, /**< Unable to perform homotopy step. */ RET_HOTSTART_STOPPED_INFEASIBILITY, /**< Premature homotopy termination because QP is infeasible. */ RET_HOTSTART_STOPPED_UNBOUNDEDNESS, /**< Premature homotopy termination because QP is unbounded. */ RET_WORKINGSET_UPDATE_FAILED, /**< Unable to update working sets according to initial guesses. */ RET_MAX_NWSR_REACHED, /**< Maximum number of working set recalculations performed. */ RET_CONSTRAINTS_NOT_SPECIFIED, /**< Problem does comprise constraints! You also have to specify new constraints' bounds. */ RET_INVALID_FACTORISATION_FLAG, /**< 60 Invalid factorisation flag. */ RET_UNABLE_TO_SAVE_QPDATA, /**< Unable to save QP data. */ RET_STEPDIRECTION_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ RET_STEPDIRECTION_FAILED_CHOLESKY, /**< Abnormal termination due to Cholesky factorisation. */ RET_CYCLING_DETECTED, /**< Cycling detected. */ RET_CYCLING_NOT_RESOLVED, /**< Cycling cannot be resolved, QP probably infeasible. */ RET_CYCLING_RESOLVED, /**< Cycling probably resolved. */ RET_STEPSIZE, /**< For displaying performed stepsize. */ RET_STEPSIZE_NONPOSITIVE, /**< For displaying non-positive stepsize. */ RET_SETUPSUBJECTTOTYPE_FAILED, /**< Setup of SubjectToTypes failed. */ RET_ADDCONSTRAINT_FAILED, /**< 70 Addition of constraint to working set failed. */ RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, /**< Addition of constraint to working set failed (due to QP infeasibility). */ RET_ADDBOUND_FAILED, /**< Addition of bound to working set failed. */ RET_ADDBOUND_FAILED_INFEASIBILITY, /**< Addition of bound to working set failed (due to QP infeasibility). */ RET_REMOVECONSTRAINT_FAILED, /**< Removal of constraint from working set failed. */ RET_REMOVEBOUND_FAILED, /**< Removal of bound from working set failed. */ RET_REMOVE_FROM_ACTIVESET, /**< Removing from active set... */ RET_ADD_TO_ACTIVESET, /**< Adding to active set... */ RET_REMOVE_FROM_ACTIVESET_FAILED, /**< Removing from active set failed. */ RET_ADD_TO_ACTIVESET_FAILED, /**< Adding to active set failed. */ RET_CONSTRAINT_ALREADY_ACTIVE, /**< 80 Constraint is already active. */ RET_ALL_CONSTRAINTS_ACTIVE, /**< All constraints are active, no further constraint can be added. */ RET_LINEARLY_DEPENDENT, /**< New bound/constraint is linearly dependent. */ RET_LINEARLY_INDEPENDENT, /**< New bound/constraint is linearly independent. */ RET_LI_RESOLVED, /**< Linear independence of active contraint matrix successfully resolved. */ RET_ENSURELI_FAILED, /**< Failed to ensure linear indepence of active contraint matrix. */ RET_ENSURELI_FAILED_TQ, /**< Abnormal termination due to TQ factorisation. */ RET_ENSURELI_FAILED_NOINDEX, /**< No index found, QP probably infeasible. */ RET_ENSURELI_FAILED_CYCLING, /**< Cycling detected, QP probably infeasible. */ RET_BOUND_ALREADY_ACTIVE, /**< Bound is already active. */ RET_ALL_BOUNDS_ACTIVE, /**< 90 All bounds are active, no further bound can be added. */ RET_CONSTRAINT_NOT_ACTIVE, /**< Constraint is not active. */ RET_BOUND_NOT_ACTIVE, /**< Bound is not active. */ RET_HESSIAN_NOT_SPD, /**< Projected Hessian matrix not positive definite. */ RET_MATRIX_SHIFT_FAILED, /**< Unable to update matrices or to transform vectors. */ RET_MATRIX_FACTORISATION_FAILED, /**< Unable to calculate new matrix factorisations. */ RET_PRINT_ITERATION_FAILED, /**< Unable to print information on current iteration. */ RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, /**< No global message output file initialised. */ /* Utils */ RET_UNABLE_TO_OPEN_FILE, /**< Unable to open file. */ RET_UNABLE_TO_WRITE_FILE, /**< Unable to write into file. */ RET_UNABLE_TO_READ_FILE, /**< 100 Unable to read from file. */ RET_FILEDATA_INCONSISTENT, /**< File contains inconsistent data. */ /* SolutionAnalysis */ RET_NO_SOLUTION, /**< QP solution does not satisfy KKT optimality conditions. */ RET_INACCURATE_SOLUTION /**< KKT optimality conditions not satisfied to sufficient accuracy. */ }; /** This class handles all kinds of messages (errors, warnings, infos) initiated * by qpOASES modules and stores the correspoding global preferences. * * \author Hans Joachim Ferreau (special thanks to Leonard Wirsching) * \version 1.3embedded * \date 2007-2008 */ class MessageHandling { /* * INTERNAL DATA STRUCTURES */ public: /** Data structure for entries in global message list. */ typedef struct { returnValue key; /**< Global return value. */ const char* data; /**< Corresponding message. */ VisibilityStatus globalVisibilityStatus; /**< Determines if message can be printed. * If this value is set to VS_HIDDEN, no message is printed! */ } ReturnValueList; /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ MessageHandling( ); /** Constructor which takes the desired output file. */ MessageHandling( myFILE* _outputFile /**< Output file. */ ); /** Constructor which takes the desired visibility states. */ MessageHandling( VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ ); /** Constructor which takes the desired output file and desired visibility states. */ MessageHandling( myFILE* _outputFile, /**< Output file. */ VisibilityStatus _errorVisibility, /**< Visibility status for error messages. */ VisibilityStatus _warningVisibility,/**< Visibility status for warning messages. */ VisibilityStatus _infoVisibility /**< Visibility status for info messages. */ ); /** Copy constructor (deep copy). */ MessageHandling( const MessageHandling& rhs /**< Rhs object. */ ); /** Destructor. */ ~MessageHandling( ); /** Assignment operator (deep copy). */ MessageHandling& operator=( const MessageHandling& rhs /**< Rhs object. */ ); /** Prints an error message(a simplified macro THROWERROR is also provided). \n * Errors are definied as abnormal events which cause an immediate termination of the current (sub) function. * Errors of a sub function should be commented by the calling function by means of a warning message * (if this error does not cause an error of the calling function, either)! * \return Error number returned by sub function call */ returnValue throwError( returnValue Enumber, /**< Error number returned by sub function call. */ const char* additionaltext, /**< Additional error text (0, if none). */ const char* functionname, /**< Name of function which caused the error. */ const char* filename, /**< Name of file which caused the error. */ const unsigned long linenumber, /**< Number of line which caused the error.incompatible binary file */ VisibilityStatus localVisibilityStatus /**< Determines (locally) if error message can be printed to myStderr. * If GLOBAL visibility status of the message is set to VS_HIDDEN, * no message is printed, anyway! */ ); /** Prints a warning message (a simplified macro THROWWARNING is also provided). * Warnings are definied as abnormal events which does NOT cause an immediate termination of the current (sub) function. * \return Warning number returned by sub function call */ returnValue throwWarning( returnValue Wnumber, /**< Warning number returned by sub function call. */ const char* additionaltext, /**< Additional warning text (0, if none). */ const char* functionname, /**< Name of function which caused the warning. */ const char* filename, /**< Name of file which caused the warning. */ const unsigned long linenumber, /**< Number of line which caused the warning. */ VisibilityStatus localVisibilityStatus /**< Determines (locally) if warning message can be printed to myStderr. * If GLOBAL visibility status of the message is set to VS_HIDDEN, * no message is printed, anyway! */ ); /** Prints a info message (a simplified macro THROWINFO is also provided). * \return Info number returned by sub function call */ returnValue throwInfo( returnValue Inumber, /**< Info number returned by sub function call. */ const char* additionaltext, /**< Additional warning text (0, if none). */ const char* functionname, /**< Name of function which submitted the info. */ const char* filename, /**< Name of file which submitted the info. */ const unsigned long linenumber, /**< Number of line which submitted the info. */ VisibilityStatus localVisibilityStatus /**< Determines (locally) if info message can be printed to myStderr. * If GLOBAL visibility status of the message is set to VS_HIDDEN, * no message is printed, anyway! */ ); /** Resets all preferences to default values. * \return SUCCESSFUL_RETURN */ returnValue reset( ); /** Prints a complete list of all messages to output file. * \return SUCCESSFUL_RETURN */ returnValue listAllMessages( ); /** Returns visibility status for error messages. * \return Visibility status for error messages. */ inline VisibilityStatus getErrorVisibilityStatus( ) const; /** Returns visibility status for warning messages. * \return Visibility status for warning messages. */ inline VisibilityStatus getWarningVisibilityStatus( ) const; /** Returns visibility status for info messages. * \return Visibility status for info messages. */ inline VisibilityStatus getInfoVisibilityStatus( ) const; /** Returns pointer to output file. * \return Pointer to output file. */ inline myFILE* getOutputFile( ) const; /** Returns error count value. * \return Error count value. */ inline int getErrorCount( ) const; /** Changes visibility status for error messages. */ inline void setErrorVisibilityStatus( VisibilityStatus _errorVisibility /**< New visibility status for error messages. */ ); /** Changes visibility status for warning messages. */ inline void setWarningVisibilityStatus( VisibilityStatus _warningVisibility /**< New visibility status for warning messages. */ ); /** Changes visibility status for info messages. */ inline void setInfoVisibilityStatus( VisibilityStatus _infoVisibility /**< New visibility status for info messages. */ ); /** Changes output file for messages. */ inline void setOutputFile( myFILE* _outputFile /**< New output file for messages. */ ); /** Changes error count. * \return SUCCESSFUL_RETURN \n * RET_INVALID_ARGUMENT */ inline returnValue setErrorCount( int _errorCount /**< New error count value. */ ); /** Return the error code string. */ static const char* getErrorString(int error); /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Prints a info message to myStderr (auxiliary function). * \return Error/warning/info number returned by sub function call */ returnValue throwMessage( returnValue RETnumber, /**< Error/warning/info number returned by sub function call. */ const char* additionaltext, /**< Additional warning text (0, if none). */ const char* functionname, /**< Name of function which caused the error/warning/info. */ const char* filename, /**< Name of file which caused the error/warning/info. */ const unsigned long linenumber, /**< Number of line which caused the error/warning/info. */ VisibilityStatus localVisibilityStatus, /**< Determines (locally) if info message can be printed to myStderr. * If GLOBAL visibility status of the message is set to VS_HIDDEN, * no message is printed, anyway! */ const char* RETstring /**< Leading string of error/warning/info message. */ ); /* * PROTECTED MEMBER VARIABLES */ protected: VisibilityStatus errorVisibility; /**< Error messages visible? */ VisibilityStatus warningVisibility; /**< Warning messages visible? */ VisibilityStatus infoVisibility; /**< Info messages visible? */ myFILE* outputFile; /**< Output file for messages. */ int errorCount; /**< Counts number of errors (for nicer output only). */ }; #ifndef __FUNCTION__ /** Ensures that __FUNCTION__ macro is defined. */ #define __FUNCTION__ 0 #endif #ifndef __FILE__ /** Ensures that __FILE__ macro is defined. */ #define __FILE__ 0 #endif #ifndef __LINE__ /** Ensures that __LINE__ macro is defined. */ #define __LINE__ 0 #endif /** Short version of throwError with default values, only returnValue is needed */ #define THROWERROR(retval) ( getGlobalMessageHandler( )->throwError((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) /** Short version of throwWarning with default values, only returnValue is needed */ #define THROWWARNING(retval) ( getGlobalMessageHandler( )->throwWarning((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) /** Short version of throwInfo with default values, only returnValue is needed */ #define THROWINFO(retval) ( getGlobalMessageHandler( )->throwInfo((retval),0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE) ) /** Returns a pointer to global message handler. * \return Pointer to global message handler. */ MessageHandling* getGlobalMessageHandler( ); #include #endif /* QPOASES_MESSAGEHANDLING_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/QProblem.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/QProblem.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the QProblem class which is able to use the newly * developed online active set strategy for parametric quadratic programming. */ #ifndef QPOASES_QPROBLEM_HPP #define QPOASES_QPROBLEM_HPP #include #include #include /** A class for setting up and solving quadratic programs. The main feature is * the possibily to use the newly developed online active set strategy for * parametric quadratic programming. * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class QProblem : public QProblemB { /* allow SolutionAnalysis class to access private members */ friend class SolutionAnalysis; /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ QProblem( ); /** Constructor which takes the QP dimensions only. */ QProblem( int _nV, /**< Number of variables. */ int _nC /**< Number of constraints. */ ); /** Copy constructor (deep copy). */ QProblem( const QProblem& rhs /**< Rhs object. */ ); /** Destructor. */ ~QProblem( ); /** Assignment operator (deep copy). */ QProblem& operator=( const QProblem& rhs /**< Rhs object. */ ); /** Clears all data structures of QProblemB except for QP data. * \return SUCCESSFUL_RETURN \n RET_RESET_FAILED */ returnValue reset( ); /** Initialises a QProblem with given QP data and solves it * using an initial homotopy with empty working set (at most nWSR iterations). * \return SUCCESSFUL_RETURN \n RET_INIT_FAILED \n RET_INIT_FAILED_CHOLESKY \n RET_INIT_FAILED_TQ \n RET_INIT_FAILED_HOTSTART \n RET_INIT_FAILED_INFEASIBILITY \n RET_INIT_FAILED_UNBOUNDEDNESS \n RET_MAX_NWSR_REACHED \n RET_INVALID_ARGUMENTS \n RET_INACCURATE_SOLUTION \n RET_NO_SOLUTION */ returnValue init( const real_t* const _H, /**< Hessian matrix. */ const real_t* const _g, /**< Gradient vector. */ const real_t* const _A, /**< Constraint matrix. */ const real_t* const _lb, /**< Lower bound vector (on variables). \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const _ub, /**< Upper bound vector (on variables). \n If no upper bounds exist, a NULL pointer can be passed. */ const real_t* const _lbA, /**< Lower constraints' bound vector. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ const real_t* const _ubA, /**< Upper constraints' bound vector. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. Output: Number of performed working set recalculations. */ const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ ); /** Initialises a QProblem with given QP data and solves it * using an initial homotopy with empty working set (at most nWSR iterations). * \return SUCCESSFUL_RETURN \n RET_INIT_FAILED \n RET_INIT_FAILED_CHOLESKY \n RET_INIT_FAILED_TQ \n RET_INIT_FAILED_HOTSTART \n RET_INIT_FAILED_INFEASIBILITY \n RET_INIT_FAILED_UNBOUNDEDNESS \n RET_MAX_NWSR_REACHED \n RET_INVALID_ARGUMENTS \n RET_INACCURATE_SOLUTION \n RET_NO_SOLUTION */ returnValue init( const real_t* const _H, /**< Hessian matrix. */ const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ const real_t* const _g, /**< Gradient vector. */ const real_t* const _A, /**< Constraint matrix. */ const real_t* const _lb, /**< Lower bound vector (on variables). \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const _ub, /**< Upper bound vector (on variables). \n If no upper bounds exist, a NULL pointer can be passed. */ const real_t* const _lbA, /**< Lower constraints' bound vector. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ const real_t* const _ubA, /**< Upper constraints' bound vector. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. Output: Number of performed working set recalculations. */ const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ ); /** Solves QProblem using online active set strategy. * \return SUCCESSFUL_RETURN \n RET_MAX_NWSR_REACHED \n RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n RET_HOTSTART_FAILED \n RET_SHIFT_DETERMINATION_FAILED \n RET_STEPDIRECTION_DETERMINATION_FAILED \n RET_STEPLENGTH_DETERMINATION_FAILED \n RET_HOMOTOPY_STEP_FAILED \n RET_HOTSTART_STOPPED_INFEASIBILITY \n RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n RET_INACCURATE_SOLUTION \n RET_NO_SOLUTION */ returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n If no upper bounds exist, a NULL pointer can be passed. */ const real_t* const lbA_new, /**< Lower constraints' bounds of neighbouring QP to be solved. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ const real_t* const ubA_new, /**< Upper constraints' bounds of neighbouring QP to be solved. \n If no upper constraints' bounds exist, a NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations; \n Output: Number of performed working set recalculations. */ real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ ); /** Returns constraint matrix of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getA( real_t* const _A /**< Array of appropriate dimension for copying constraint matrix.*/ ) const; /** Returns a single row of constraint matrix of the QP (deep copy). * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue getA( int number, /**< Number of entry to be returned. */ real_t* const row /**< Array of appropriate dimension for copying (number)th constraint. */ ) const; /** Returns lower constraints' bound vector of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getLBA( real_t* const _lbA /**< Array of appropriate dimension for copying lower constraints' bound vector.*/ ) const; /** Returns single entry of lower constraints' bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue getLBA( int number, /**< Number of entry to be returned. */ real_t& value /**< Output: lbA[number].*/ ) const; /** Returns upper constraints' bound vector of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getUBA( real_t* const _ubA /**< Array of appropriate dimension for copying upper constraints' bound vector.*/ ) const; /** Returns single entry of upper constraints' bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue getUBA( int number, /**< Number of entry to be returned. */ real_t& value /**< Output: ubA[number].*/ ) const; /** Returns current constraints object of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getConstraints( Constraints* const _constraints /** Output: Constraints object. */ ) const; /** Returns the number of constraints. * \return Number of constraints. */ inline int getNC( ) const; /** Returns the number of (implicitly defined) equality constraints. * \return Number of (implicitly defined) equality constraints. */ inline int getNEC( ) const; /** Returns the number of active constraints. * \return Number of active constraints. */ inline int getNAC( ); /** Returns the number of inactive constraints. * \return Number of inactive constraints. */ inline int getNIAC( ); /** Returns the dimension of null space. * \return Dimension of null space. */ int getNZ( ); /** Returns the dual solution vector (deep copy). * \return SUCCESSFUL_RETURN \n RET_QP_NOT_SOLVED */ returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ ) const; /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). * \return SUCCESSFUL_RETURN \n RET_SETUPSUBJECTTOTYPE_FAILED */ returnValue setupSubjectToType( ); /** Computes the Cholesky decomposition R of the projected Hessian (i.e. R^T*R = Z^T*H*Z). * \return SUCCESSFUL_RETURN \n * RET_INDEXLIST_CORRUPTED */ returnValue setupCholeskyDecompositionProjected( ); /** Initialises TQ factorisation of A (i.e. A*Q = [0 T]) if NO constraint is active. * \return SUCCESSFUL_RETURN \n RET_INDEXLIST_CORRUPTED */ returnValue setupTQfactorisation( ); /** Solves a QProblem whose QP data is assumed to be stored in the member variables. * A guess for its primal/dual optimal solution vectors and the corresponding * working sets of bounds and constraints can be provided. * \return SUCCESSFUL_RETURN \n RET_INIT_FAILED \n RET_INIT_FAILED_CHOLESKY \n RET_INIT_FAILED_TQ \n RET_INIT_FAILED_HOTSTART \n RET_INIT_FAILED_INFEASIBILITY \n RET_INIT_FAILED_UNBOUNDEDNESS \n RET_MAX_NWSR_REACHED */ returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. * A NULL pointer can be passed. */ const real_t* const yOpt, /**< Optimal dual solution vector. * A NULL pointer can be passed. */ const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). * A NULL pointer can be passed. */ const Constraints* const guessedConstraints, /**< Optimal working set of constraints for solution (xOpt,yOpt). * A NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations; \n * Output: Number of performed working set recalculations. */ real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ ); /** Obtains the desired working set for the auxiliary initial QP in * accordance with the user specifications * (assumes that member AX has already been initialised!) * \return SUCCESSFUL_RETURN \n RET_OBTAINING_WORKINGSET_FAILED \n RET_INVALID_ARGUMENTS */ returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. * If a NULL pointer is passed, all entries are assumed to be zero. */ const real_t* const yOpt, /**< Optimal dual solution vector. * If a NULL pointer is passed, all entries are assumed to be zero. */ const Bounds* const guessedBounds, /**< Guessed working set of bounds for solution (xOpt,yOpt). */ const Constraints* const guessedConstraints, /**< Guessed working set for solution (xOpt,yOpt). */ Bounds* auxiliaryBounds, /**< Input: Allocated bound object. \n * Ouput: Working set of constraints for auxiliary QP. */ Constraints* auxiliaryConstraints /**< Input: Allocated bound object. \n * Ouput: Working set for auxiliary QP. */ ) const; /** Setups bound and constraints data structures according to auxiliaryBounds/Constraints. * (If the working set shall be setup afresh, make sure that * bounds and constraints data structure have been resetted * and the TQ factorisation has been initialised!) * \return SUCCESSFUL_RETURN \n RET_SETUP_WORKINGSET_FAILED \n RET_INVALID_ARGUMENTS \n RET_UNKNOWN BUG */ returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ BooleanType setupAfresh /**< Flag indicating if given working set shall be * setup afresh or by updating the current one. */ ); /** Setups the optimal primal/dual solution of the auxiliary initial QP. * \return SUCCESSFUL_RETURN */ returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. * If a NULL pointer is passed, all entries are set to zero. */ const real_t* const yOpt /**< Optimal dual solution vector. * If a NULL pointer is passed, all entries are set to zero. */ ); /** Setups gradient of the auxiliary initial QP for given * optimal primal/dual solution and given initial working set * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). * \return SUCCESSFUL_RETURN */ returnValue setupAuxiliaryQPgradient( ); /** Setups (constraints') bounds of the auxiliary initial QP for given * optimal primal/dual solution and given initial working set * (assumes that members X, Y and BOUNDS, CONSTRAINTS have already been initialised!). * \return SUCCESSFUL_RETURN \n RET_UNKNOWN BUG */ returnValue setupAuxiliaryQPbounds( const Bounds* const auxiliaryBounds, /**< Working set of bounds for auxiliary QP. */ const Constraints* const auxiliaryConstraints, /**< Working set of constraints for auxiliary QP. */ BooleanType useRelaxation /**< Flag indicating if inactive (constraints') bounds shall be relaxed. */ ); /** Adds a constraint to active set. * \return SUCCESSFUL_RETURN \n RET_ADDCONSTRAINT_FAILED \n RET_ADDCONSTRAINT_FAILED_INFEASIBILITY \n RET_ENSURELI_FAILED */ returnValue addConstraint( int number, /**< Number of constraint to be added to active set. */ SubjectToStatus C_status, /**< Status of new active constraint. */ BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ ); /** Checks if new active constraint to be added is linearly dependent from * from row of the active constraints matrix. * \return RET_LINEARLY_DEPENDENT \n RET_LINEARLY_INDEPENDENT \n RET_INDEXLIST_CORRUPTED */ returnValue addConstraint_checkLI( int number /**< Number of constraint to be added to active set. */ ); /** Ensures linear independence of constraint matrix when a new constraint is added. * To this end a bound or constraint is removed simultaneously if necessary. * \return SUCCESSFUL_RETURN \n RET_LI_RESOLVED \n RET_ENSURELI_FAILED \n RET_ENSURELI_FAILED_TQ \n RET_ENSURELI_FAILED_NOINDEX \n RET_REMOVE_FROM_ACTIVESET */ returnValue addConstraint_ensureLI( int number, /**< Number of constraint to be added to active set. */ SubjectToStatus C_status /**< Status of new active bound. */ ); /** Adds a bound to active set. * \return SUCCESSFUL_RETURN \n RET_ADDBOUND_FAILED \n RET_ADDBOUND_FAILED_INFEASIBILITY \n RET_ENSURELI_FAILED */ returnValue addBound( int number, /**< Number of bound to be added to active set. */ SubjectToStatus B_status, /**< Status of new active bound. */ BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ ); /** Checks if new active bound to be added is linearly dependent from * from row of the active constraints matrix. * \return RET_LINEARLY_DEPENDENT \n RET_LINEARLY_INDEPENDENT */ returnValue addBound_checkLI( int number /**< Number of bound to be added to active set. */ ); /** Ensures linear independence of constraint matrix when a new bound is added. * To this end a bound or constraint is removed simultaneously if necessary. * \return SUCCESSFUL_RETURN \n RET_LI_RESOLVED \n RET_ENSURELI_FAILED \n RET_ENSURELI_FAILED_TQ \n RET_ENSURELI_FAILED_NOINDEX \n RET_REMOVE_FROM_ACTIVESET */ returnValue addBound_ensureLI( int number, /**< Number of bound to be added to active set. */ SubjectToStatus B_status /**< Status of new active bound. */ ); /** Removes a constraint from active set. * \return SUCCESSFUL_RETURN \n RET_CONSTRAINT_NOT_ACTIVE \n RET_REMOVECONSTRAINT_FAILED \n RET_HESSIAN_NOT_SPD */ returnValue removeConstraint( int number, /**< Number of constraint to be removed from active set. */ BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ ); /** Removes a bounds from active set. * \return SUCCESSFUL_RETURN \n RET_BOUND_NOT_ACTIVE \n RET_HESSIAN_NOT_SPD \n RET_REMOVEBOUND_FAILED */ returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ ); /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. * \return SUCCESSFUL_RETURN \n RET_DIV_BY_ZERO */ returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ real_t* const a /**< Output: Solution vector */ ); /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n * Special variant for the case that this function is called from within "removeBound()". * \return SUCCESSFUL_RETURN \n RET_DIV_BY_ZERO */ returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ real_t* const a /**< Output: Solution vector */ ); /** Solves the system Ta = b or T^Ta = b where T is a reverse upper triangular matrix. * \return SUCCESSFUL_RETURN \n RET_DIV_BY_ZERO */ returnValue backsolveT( const real_t* const b, /**< Right hand side vector. */ BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ real_t* const a /**< Output: Solution vector */ ); /** Determines step direction of the shift of the QP data. * \return SUCCESSFUL_RETURN */ returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ const int* const AC_idx, /**< Index array of active constraints. */ const real_t* const g_new, /**< New gradient vector. */ const real_t* const lbA_new,/**< New lower constraints' bounds. */ const real_t* const ubA_new,/**< New upper constraints' bounds. */ const real_t* const lb_new, /**< New lower bounds. */ const real_t* const ub_new, /**< New upper bounds. */ real_t* const delta_g, /**< Output: Step direction of gradient vector. */ real_t* const delta_lbA, /**< Output: Step direction of lower constraints' bounds. */ real_t* const delta_ubA, /**< Output: Step direction of upper constraints' bounds. */ real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ BooleanType& Delta_bC_isZero,/**< Output: Indicates if active constraints' bounds are to be shifted. */ BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ ); /** Determines step direction of the homotopy path. * \return SUCCESSFUL_RETURN \n RET_STEPDIRECTION_FAILED_TQ \n RET_STEPDIRECTION_FAILED_CHOLESKY */ returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ const int* const FX_idx, /**< Index array of fixed variables. */ const int* const AC_idx, /**< Index array of active constraints. */ const real_t* const delta_g, /**< Step direction of gradient vector. */ const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ BooleanType Delta_bC_isZero, /**< Indicates if active constraints' bounds are to be shifted. */ BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ real_t* const delta_yAC, /**< Output: Dual homotopy step direction of active constraints' multiplier. */ real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ ); /** Determines the maximum possible step length along the homotopy path. * \return SUCCESSFUL_RETURN */ returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ const int* const FX_idx, /**< Index array of fixed variables. */ const int* const AC_idx, /**< Index array of active constraints. */ const int* const IAC_idx, /**< Index array of inactive constraints. */ const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ real_t* const delta_Ax, /**< Output: Step in vector Ax. */ int& BC_idx, /**< Output: Index of blocking constraint. */ SubjectToStatus& BC_status, /**< Output: Status of blocking constraint. */ BooleanType& BC_isBound /**< Output: Indicates if blocking constraint is a bound. */ ); /** Performs a step along the homotopy path (and updates active set). * \return SUCCESSFUL_RETURN \n RET_OPTIMAL_SOLUTION_FOUND \n RET_REMOVE_FROM_ACTIVESET_FAILED \n RET_ADD_TO_ACTIVESET_FAILED \n RET_QP_INFEASIBLE */ returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ const int* const FX_idx, /**< Index array of fixed variables. */ const int* const AC_idx, /**< Index array of active constraints. */ const int* const IAC_idx, /**< Index array of inactive constraints. */ const real_t* const delta_g, /**< Step direction of gradient vector. */ const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ const real_t* const delta_ubA, /**< Step direction of upper constraints' bounds. */ const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ const real_t* const delta_yAC, /**< Dual homotopy step direction of active constraints' multiplier. */ const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ const real_t* const delta_Ax, /**< Step in vector Ax. */ int BC_idx, /**< Index of blocking constraint. */ SubjectToStatus BC_status, /**< Status of blocking constraint. */ BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ ); /** Checks if lower/upper (constraints') bounds remain consistent * (i.e. if lb <= ub and lbA <= ubA ) during the current step. * \return BT_TRUE iff (constraints") bounds remain consistent */ BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ const real_t* const delta_lbA, /**< Step direction of lower constraints' bounds. */ const real_t* const delta_ubA /**< Step direction of upper constraints' bounds. */ ) const; /** Setups internal QP data. * \return SUCCESSFUL_RETURN \n RET_INVALID_ARGUMENTS */ returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ const real_t* const _g, /**< Gradient vector. */ const real_t* const _A, /**< Constraint matrix. */ const real_t* const _lb, /**< Lower bound vector (on variables). \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const _ub, /**< Upper bound vector (on variables). \n If no upper bounds exist, a NULL pointer can be passed. */ const real_t* const _lbA, /**< Lower constraints' bound vector. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ const real_t* const _ubA /**< Upper constraints' bound vector. \n If no lower constraints' bounds exist, a NULL pointer can be passed. */ ); #ifdef PC_DEBUG /* Define print functions only for debugging! */ /** Prints concise information on the current iteration. * \return SUCCESSFUL_RETURN \n */ returnValue printIteration( int iteration, /**< Number of current iteration. */ int BC_idx, /**< Index of blocking constraint. */ SubjectToStatus BC_status, /**< Status of blocking constraint. */ BooleanType BC_isBound /**< Indicates if blocking constraint is a bound. */ ); /** Prints concise information on the current iteration. * NOTE: ONLY DEFINED FOR SUPPRESSING A COMPILER WARNING!! * \return SUCCESSFUL_RETURN \n */ returnValue printIteration( int iteration, /**< Number of current iteration. */ int BC_idx, /**< Index of blocking bound. */ SubjectToStatus BC_status /**< Status of blocking bound. */ ); #endif /* PC_DEBUG */ /** Determines the maximum violation of the KKT optimality conditions * of the current iterate within the QProblem object. * \return SUCCESSFUL_RETURN \n * RET_INACCURATE_SOLUTION \n * RET_NO_SOLUTION */ returnValue checkKKTconditions( ); /** Sets constraint matrix of the QP. \n (Remark: Also internal vector Ax is recomputed!) * \return SUCCESSFUL_RETURN */ inline returnValue setA( const real_t* const A_new /**< New constraint matrix (with correct dimension!). */ ); /** Changes single row of constraint matrix of the QP. \n (Remark: Also correponding component of internal vector Ax is recomputed!) * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setA( int number, /**< Number of row to be changed. */ const real_t* const value /**< New (number)th constraint (with correct dimension!). */ ); /** Sets constraints' lower bound vector of the QP. * \return SUCCESSFUL_RETURN */ inline returnValue setLBA( const real_t* const lbA_new /**< New constraints' lower bound vector (with correct dimension!). */ ); /** Changes single entry of lower constraints' bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setLBA( int number, /**< Number of entry to be changed. */ real_t value /**< New value for entry of lower constraints' bound vector (with correct dimension!). */ ); /** Sets constraints' upper bound vector of the QP. * \return SUCCESSFUL_RETURN */ inline returnValue setUBA( const real_t* const ubA_new /**< New constraints' upper bound vector (with correct dimension!). */ ); /** Changes single entry of upper constraints' bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setUBA( int number, /**< Number of entry to be changed. */ real_t value /**< New value for entry of upper constraints' bound vector (with correct dimension!). */ ); /* * PROTECTED MEMBER VARIABLES */ protected: real_t A[NCMAX_ALLOC*NVMAX]; /**< Constraint matrix. */ real_t lbA[NCMAX_ALLOC]; /**< Lower constraints' bound vector. */ real_t ubA[NCMAX_ALLOC]; /**< Upper constraints' bound vector. */ Constraints constraints; /**< Data structure for problem's constraints. */ real_t T[NVMAX*NVMAX]; /**< Reverse triangular matrix, A = [0 T]*Q'. */ real_t Q[NVMAX*NVMAX]; /**< Orthonormal quadratic matrix, A = [0 T]*Q'. */ int sizeT; /**< Matrix T is stored in a (sizeT x sizeT) array. */ real_t Ax[NCMAX_ALLOC]; /**< Stores the current product A*x (for increased efficiency only). */ CyclingManager cyclingManager; /**< Data structure for storing (possible) cycling information (NOT YET IMPLEMENTED!). */ }; #include #endif /* QPOASES_QPROBLEM_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/QProblemB.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/QProblemB.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the QProblemB class which is able to use the newly * developed online active set strategy for parametric quadratic programming * for problems with (simple) bounds only. */ #ifndef QPOASES_QPROBLEMB_HPP #define QPOASES_QPROBLEMB_HPP #include class SolutionAnalysis; /** Class for setting up and solving quadratic programs with (simple) bounds only. * The main feature is the possibily to use the newly developed online active set strategy * for parametric quadratic programming. * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class QProblemB { /* allow SolutionAnalysis class to access private members */ friend class SolutionAnalysis; /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ QProblemB( ); /** Constructor which takes the QP dimension only. */ QProblemB( int _nV /**< Number of variables. */ ); /** Copy constructor (deep copy). */ QProblemB( const QProblemB& rhs /**< Rhs object. */ ); /** Destructor. */ ~QProblemB( ); /** Assignment operator (deep copy). */ QProblemB& operator=( const QProblemB& rhs /**< Rhs object. */ ); /** Clears all data structures of QProblemB except for QP data. * \return SUCCESSFUL_RETURN \n RET_RESET_FAILED */ returnValue reset( ); /** Initialises a QProblemB with given QP data and solves it * using an initial homotopy with empty working set (at most nWSR iterations). * \return SUCCESSFUL_RETURN \n RET_INIT_FAILED \n RET_INIT_FAILED_CHOLESKY \n RET_INIT_FAILED_HOTSTART \n RET_INIT_FAILED_INFEASIBILITY \n RET_INIT_FAILED_UNBOUNDEDNESS \n RET_MAX_NWSR_REACHED \n RET_INVALID_ARGUMENTS \n RET_INACCURATE_SOLUTION \n RET_NO_SOLUTION */ returnValue init( const real_t* const _H, /**< Hessian matrix. */ const real_t* const _g, /**< Gradient vector. */ const real_t* const _lb, /**< Lower bounds (on variables). \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const _ub, /**< Upper bounds (on variables). \n If no upper bounds exist, a NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n Output: Number of performed working set recalculations. */ const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ ); /** Initialises a QProblemB with given QP data and solves it * using an initial homotopy with empty working set (at most nWSR iterations). * \return SUCCESSFUL_RETURN \n RET_INIT_FAILED \n RET_INIT_FAILED_CHOLESKY \n RET_INIT_FAILED_HOTSTART \n RET_INIT_FAILED_INFEASIBILITY \n RET_INIT_FAILED_UNBOUNDEDNESS \n RET_MAX_NWSR_REACHED \n RET_INVALID_ARGUMENTS \n RET_INACCURATE_SOLUTION \n RET_NO_SOLUTION */ returnValue init( const real_t* const _H, /**< Hessian matrix. */ const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ const real_t* const _g, /**< Gradient vector. */ const real_t* const _lb, /**< Lower bounds (on variables). \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const _ub, /**< Upper bounds (on variables). \n If no upper bounds exist, a NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations when using initial homotopy. \n Output: Number of performed working set recalculations. */ const real_t* const yOpt = 0, /**< Initial guess for dual solution vector. */ real_t* const cputime = 0 /**< Output: CPU time required to initialise QP. */ ); /** Solves an initialised QProblemB using online active set strategy. * \return SUCCESSFUL_RETURN \n RET_MAX_NWSR_REACHED \n RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED \n RET_HOTSTART_FAILED \n RET_SHIFT_DETERMINATION_FAILED \n RET_STEPDIRECTION_DETERMINATION_FAILED \n RET_STEPLENGTH_DETERMINATION_FAILED \n RET_HOMOTOPY_STEP_FAILED \n RET_HOTSTART_STOPPED_INFEASIBILITY \n RET_HOTSTART_STOPPED_UNBOUNDEDNESS \n RET_INACCURATE_SOLUTION \n RET_NO_SOLUTION */ returnValue hotstart( const real_t* const g_new, /**< Gradient of neighbouring QP to be solved. */ const real_t* const lb_new, /**< Lower bounds of neighbouring QP to be solved. \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const ub_new, /**< Upper bounds of neighbouring QP to be solved. \n If no upper bounds exist, a NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations; \n Output: Number of performed working set recalculations. */ real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ ); /** Returns Hessian matrix of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getH( real_t* const _H /**< Array of appropriate dimension for copying Hessian matrix.*/ ) const; /** Returns gradient vector of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getG( real_t* const _g /**< Array of appropriate dimension for copying gradient vector.*/ ) const; /** Returns lower bound vector of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getLB( real_t* const _lb /**< Array of appropriate dimension for copying lower bound vector.*/ ) const; /** Returns single entry of lower bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue getLB( int number, /**< Number of entry to be returned. */ real_t& value /**< Output: lb[number].*/ ) const; /** Returns upper bound vector of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getUB( real_t* const _ub /**< Array of appropriate dimension for copying upper bound vector.*/ ) const; /** Returns single entry of upper bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue getUB( int number, /**< Number of entry to be returned. */ real_t& value /**< Output: ub[number].*/ ) const; /** Returns current bounds object of the QP (deep copy). * \return SUCCESSFUL_RETURN */ inline returnValue getBounds( Bounds* const _bounds /** Output: Bounds object. */ ) const; /** Returns the number of variables. * \return Number of variables. */ inline int getNV( ) const; /** Returns the number of free variables. * \return Number of free variables. */ inline int getNFR( ); /** Returns the number of fixed variables. * \return Number of fixed variables. */ inline int getNFX( ); /** Returns the number of implicitly fixed variables. * \return Number of implicitly fixed variables. */ inline int getNFV( ) const; /** Returns the dimension of null space. * \return Dimension of null space. */ int getNZ( ); /** Returns the optimal objective function value. * \return finite value: Optimal objective function value (QP was solved) \n +infinity: QP was not yet solved */ real_t getObjVal( ) const; /** Returns the objective function value at an arbitrary point x. * \return Objective function value at point x */ real_t getObjVal( const real_t* const _x /**< Point at which the objective function shall be evaluated. */ ) const; /** Returns the primal solution vector. * \return SUCCESSFUL_RETURN \n RET_QP_NOT_SOLVED */ returnValue getPrimalSolution( real_t* const xOpt /**< Output: Primal solution vector (if QP has been solved). */ ) const; /** Returns the dual solution vector. * \return SUCCESSFUL_RETURN \n RET_QP_NOT_SOLVED */ returnValue getDualSolution( real_t* const yOpt /**< Output: Dual solution vector (if QP has been solved). */ ) const; /** Returns status of the solution process. * \return Status of solution process. */ inline QProblemStatus getStatus( ) const; /** Returns if the QProblem object is initialised. * \return BT_TRUE: QProblemB initialised \n BT_FALSE: QProblemB not initialised */ inline BooleanType isInitialised( ) const; /** Returns if the QP has been solved. * \return BT_TRUE: QProblemB solved \n BT_FALSE: QProblemB not solved */ inline BooleanType isSolved( ) const; /** Returns if the QP is infeasible. * \return BT_TRUE: QP infeasible \n BT_FALSE: QP feasible (or not known to be infeasible!) */ inline BooleanType isInfeasible( ) const; /** Returns if the QP is unbounded. * \return BT_TRUE: QP unbounded \n BT_FALSE: QP unbounded (or not known to be unbounded!) */ inline BooleanType isUnbounded( ) const; /** Returns the print level. * \return Print level. */ inline PrintLevel getPrintLevel( ) const; /** Changes the print level. * \return SUCCESSFUL_RETURN */ returnValue setPrintLevel( PrintLevel _printlevel /**< New print level. */ ); /** Returns Hessian type flag (type is not determined due to this call!). * \return Hessian type. */ inline HessianType getHessianType( ) const; /** Changes the print level. * \return SUCCESSFUL_RETURN */ inline returnValue setHessianType( HessianType _hessianType /**< New Hessian type. */ ); /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Checks if Hessian happens to be the identity matrix, * and sets corresponding status flag (otherwise the flag remains unaltered!). * \return SUCCESSFUL_RETURN */ returnValue checkForIdentityHessian( ); /** Determines type of constraints and bounds (i.e. implicitly fixed, unbounded etc.). * \return SUCCESSFUL_RETURN \n RET_SETUPSUBJECTTOTYPE_FAILED */ returnValue setupSubjectToType( ); /** Computes the Cholesky decomposition R of the (simply projected) Hessian (i.e. R^T*R = Z^T*H*Z). * It only works in the case where Z is a simple projection matrix! * \return SUCCESSFUL_RETURN \n * RET_INDEXLIST_CORRUPTED */ returnValue setupCholeskyDecomposition( ); /** Solves a QProblemB whose QP data is assumed to be stored in the member variables. * A guess for its primal/dual optimal solution vectors and the corresponding * optimal working set can be provided. * \return SUCCESSFUL_RETURN \n RET_INIT_FAILED \n RET_INIT_FAILED_CHOLESKY \n RET_INIT_FAILED_HOTSTART \n RET_INIT_FAILED_INFEASIBILITY \n RET_INIT_FAILED_UNBOUNDEDNESS \n RET_MAX_NWSR_REACHED */ returnValue solveInitialQP( const real_t* const xOpt, /**< Optimal primal solution vector. * A NULL pointer can be passed. */ const real_t* const yOpt, /**< Optimal dual solution vector. * A NULL pointer can be passed. */ const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). * A NULL pointer can be passed. */ int& nWSR, /**< Input: Maximum number of working set recalculations; \n * Output: Number of performed working set recalculations. */ real_t* const cputime /**< Output: CPU time required to solve QP (or to perform nWSR iterations). */ ); /** Obtains the desired working set for the auxiliary initial QP in * accordance with the user specifications * \return SUCCESSFUL_RETURN \n RET_OBTAINING_WORKINGSET_FAILED \n RET_INVALID_ARGUMENTS */ returnValue obtainAuxiliaryWorkingSet( const real_t* const xOpt, /**< Optimal primal solution vector. * If a NULL pointer is passed, all entries are assumed to be zero. */ const real_t* const yOpt, /**< Optimal dual solution vector. * If a NULL pointer is passed, all entries are assumed to be zero. */ const Bounds* const guessedBounds, /**< Guessed working set for solution (xOpt,yOpt). */ Bounds* auxiliaryBounds /**< Input: Allocated bound object. \n * Ouput: Working set for auxiliary QP. */ ) const; /** Setups bound data structure according to auxiliaryBounds. * (If the working set shall be setup afresh, make sure that * bounds data structure has been resetted!) * \return SUCCESSFUL_RETURN \n RET_SETUP_WORKINGSET_FAILED \n RET_INVALID_ARGUMENTS \n RET_UNKNOWN BUG */ returnValue setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, /**< Working set for auxiliary QP. */ BooleanType setupAfresh /**< Flag indicating if given working set shall be * setup afresh or by updating the current one. */ ); /** Setups the optimal primal/dual solution of the auxiliary initial QP. * \return SUCCESSFUL_RETURN */ returnValue setupAuxiliaryQPsolution( const real_t* const xOpt, /**< Optimal primal solution vector. * If a NULL pointer is passed, all entries are set to zero. */ const real_t* const yOpt /**< Optimal dual solution vector. * If a NULL pointer is passed, all entries are set to zero. */ ); /** Setups gradient of the auxiliary initial QP for given * optimal primal/dual solution and given initial working set * (assumes that members X, Y and BOUNDS have already been initialised!). * \return SUCCESSFUL_RETURN */ returnValue setupAuxiliaryQPgradient( ); /** Setups bounds of the auxiliary initial QP for given * optimal primal/dual solution and given initial working set * (assumes that members X, Y and BOUNDS have already been initialised!). * \return SUCCESSFUL_RETURN \n RET_UNKNOWN BUG */ returnValue setupAuxiliaryQPbounds( BooleanType useRelaxation /**< Flag indicating if inactive bounds shall be relaxed. */ ); /** Adds a bound to active set (specialised version for the case where no constraints exist). * \return SUCCESSFUL_RETURN \n RET_ADDBOUND_FAILED */ returnValue addBound( int number, /**< Number of bound to be added to active set. */ SubjectToStatus B_status, /**< Status of new active bound. */ BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ ); /** Removes a bounds from active set (specialised version for the case where no constraints exist). * \return SUCCESSFUL_RETURN \n RET_HESSIAN_NOT_SPD \n RET_REMOVEBOUND_FAILED */ returnValue removeBound( int number, /**< Number of bound to be removed from active set. */ BooleanType updateCholesky /**< Flag indicating if Cholesky decomposition shall be updated. */ ); /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. * \return SUCCESSFUL_RETURN \n RET_DIV_BY_ZERO */ returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ real_t* const a /**< Output: Solution vector */ ); /** Solves the system Ra = b or R^Ta = b where R is an upper triangular matrix. \n * Special variant for the case that this function is called from within "removeBound()". * \return SUCCESSFUL_RETURN \n RET_DIV_BY_ZERO */ returnValue backsolveR( const real_t* const b, /**< Right hand side vector. */ BooleanType transposed, /**< Indicates if the transposed system shall be solved. */ BooleanType removingBound, /**< Indicates if function is called from "removeBound()". */ real_t* const a /**< Output: Solution vector */ ); /** Determines step direction of the shift of the QP data. * \return SUCCESSFUL_RETURN */ returnValue hotstart_determineDataShift(const int* const FX_idx, /**< Index array of fixed variables. */ const real_t* const g_new, /**< New gradient vector. */ const real_t* const lb_new, /**< New lower bounds. */ const real_t* const ub_new, /**< New upper bounds. */ real_t* const delta_g, /**< Output: Step direction of gradient vector. */ real_t* const delta_lb, /**< Output: Step direction of lower bounds. */ real_t* const delta_ub, /**< Output: Step direction of upper bounds. */ BooleanType& Delta_bB_isZero/**< Output: Indicates if active bounds are to be shifted. */ ); /** Checks if lower/upper bounds remain consistent * (i.e. if lb <= ub) during the current step. * \return BT_TRUE iff bounds remain consistent */ BooleanType areBoundsConsistent( const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub /**< Step direction of upper bounds. */ ) const; /** Setups internal QP data. * \return SUCCESSFUL_RETURN \n RET_INVALID_ARGUMENTS */ returnValue setupQPdata( const real_t* const _H, /**< Hessian matrix. */ const real_t* const _R, /**< Cholesky factorization of the Hessian matrix. */ const real_t* const _g, /**< Gradient vector. */ const real_t* const _lb, /**< Lower bounds (on variables). \n If no lower bounds exist, a NULL pointer can be passed. */ const real_t* const _ub /**< Upper bounds (on variables). \n If no upper bounds exist, a NULL pointer can be passed. */ ); /** Sets Hessian matrix of the QP. * \return SUCCESSFUL_RETURN */ inline returnValue setH( const real_t* const H_new /**< New Hessian matrix (with correct dimension!). */ ); /** Changes gradient vector of the QP. * \return SUCCESSFUL_RETURN */ inline returnValue setG( const real_t* const g_new /**< New gradient vector (with correct dimension!). */ ); /** Changes lower bound vector of the QP. * \return SUCCESSFUL_RETURN */ inline returnValue setLB( const real_t* const lb_new /**< New lower bound vector (with correct dimension!). */ ); /** Changes single entry of lower bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setLB( int number, /**< Number of entry to be changed. */ real_t value /**< New value for entry of lower bound vector. */ ); /** Changes upper bound vector of the QP. * \return SUCCESSFUL_RETURN */ inline returnValue setUB( const real_t* const ub_new /**< New upper bound vector (with correct dimension!). */ ); /** Changes single entry of upper bound vector of the QP. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setUB( int number, /**< Number of entry to be changed. */ real_t value /**< New value for entry of upper bound vector. */ ); /** Computes parameters for the Givens matrix G for which [x,y]*G = [z,0] * \return SUCCESSFUL_RETURN */ inline void computeGivens( real_t xold, /**< Matrix entry to be normalised. */ real_t yold, /**< Matrix entry to be annihilated. */ real_t& xnew, /**< Output: Normalised matrix entry. */ real_t& ynew, /**< Output: Annihilated matrix entry. */ real_t& c, /**< Output: Cosine entry of Givens matrix. */ real_t& s /**< Output: Sine entry of Givens matrix. */ ) const; /** Applies Givens matrix determined by c and s (cf. computeGivens). * \return SUCCESSFUL_RETURN */ inline void applyGivens( real_t c, /**< Cosine entry of Givens matrix. */ real_t s, /**< Sine entry of Givens matrix. */ real_t xold, /**< Matrix entry to be transformed corresponding to * the normalised entry of the original matrix. */ real_t yold, /**< Matrix entry to be transformed corresponding to * the annihilated entry of the original matrix. */ real_t& xnew, /**< Output: Transformed matrix entry corresponding to * the normalised entry of the original matrix. */ real_t& ynew /**< Output: Transformed matrix entry corresponding to * the annihilated entry of the original matrix. */ ) const; /* * PRIVATE MEMBER FUNCTIONS */ private: /** Determines step direction of the homotopy path. * \return SUCCESSFUL_RETURN \n RET_STEPDIRECTION_FAILED_CHOLESKY */ returnValue hotstart_determineStepDirection(const int* const FR_idx, /**< Index array of free variables. */ const int* const FX_idx, /**< Index array of fixed variables. */ const real_t* const delta_g, /**< Step direction of gradient vector. */ const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ BooleanType Delta_bB_isZero, /**< Indicates if active bounds are to be shifted. */ real_t* const delta_xFX, /**< Output: Primal homotopy step direction of fixed variables. */ real_t* const delta_xFR, /**< Output: Primal homotopy step direction of free variables. */ real_t* const delta_yFX /**< Output: Dual homotopy step direction of fixed variables' multiplier. */ ); /** Determines the maximum possible step length along the homotopy path. * \return SUCCESSFUL_RETURN */ returnValue hotstart_determineStepLength( const int* const FR_idx, /**< Index array of free variables. */ const int* const FX_idx, /**< Index array of fixed variables. */ const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ int& BC_idx, /**< Output: Index of blocking constraint. */ SubjectToStatus& BC_status /**< Output: Status of blocking constraint. */ ); /** Performs a step along the homotopy path (and updates active set). * \return SUCCESSFUL_RETURN \n RET_OPTIMAL_SOLUTION_FOUND \n RET_REMOVE_FROM_ACTIVESET_FAILED \n RET_ADD_TO_ACTIVESET_FAILED \n RET_QP_INFEASIBLE */ returnValue hotstart_performStep( const int* const FR_idx, /**< Index array of free variables. */ const int* const FX_idx, /**< Index array of fixed variables. */ const real_t* const delta_g, /**< Step direction of gradient vector. */ const real_t* const delta_lb, /**< Step direction of lower bounds. */ const real_t* const delta_ub, /**< Step direction of upper bounds. */ const real_t* const delta_xFX, /**< Primal homotopy step direction of fixed variables. */ const real_t* const delta_xFR, /**< Primal homotopy step direction of free variables. */ const real_t* const delta_yFX, /**< Dual homotopy step direction of fixed variables' multiplier. */ int BC_idx, /**< Index of blocking constraint. */ SubjectToStatus BC_status /**< Status of blocking constraint. */ ); #ifdef PC_DEBUG /* Define print functions only for debugging! */ /** Prints concise information on the current iteration. * \return SUCCESSFUL_RETURN \n */ returnValue printIteration( int iteration, /**< Number of current iteration. */ int BC_idx, /**< Index of blocking bound. */ SubjectToStatus BC_status /**< Status of blocking bound. */ ); #endif /* PC_DEBUG */ /** Determines the maximum violation of the KKT optimality conditions * of the current iterate within the QProblemB object. * \return SUCCESSFUL_RETURN \n * RET_INACCURATE_SOLUTION \n * RET_NO_SOLUTION */ returnValue checkKKTconditions( ); /* * PROTECTED MEMBER VARIABLES */ protected: real_t H[NVMAX*NVMAX]; /**< Hessian matrix. */ BooleanType hasHessian; /**< Flag indicating whether H contains Hessian or corresponding Cholesky factor R; \sa init. */ real_t g[NVMAX]; /**< Gradient. */ real_t lb[NVMAX]; /**< Lower bound vector (on variables). */ real_t ub[NVMAX]; /**< Upper bound vector (on variables). */ Bounds bounds; /**< Data structure for problem's bounds. */ real_t R[NVMAX*NVMAX]; /**< Cholesky decomposition of H (i.e. H = R^T*R). */ BooleanType hasCholesky; /**< Flag indicating whether Cholesky decomposition has already been setup. */ real_t x[NVMAX]; /**< Primal solution vector. */ real_t y[NVMAX+NCMAX]; /**< Dual solution vector. */ real_t tau; /**< Last homotopy step length. */ QProblemStatus status; /**< Current status of the solution process. */ BooleanType infeasible; /**< QP infeasible? */ BooleanType unbounded; /**< QP unbounded? */ HessianType hessianType; /**< Type of Hessian matrix. */ PrintLevel printlevel; /**< Print level. */ int count; /**< Counts the number of hotstart function calls (internal usage only!). */ }; #include #endif /* QPOASES_QPROBLEMB_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/SubjectTo.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/SubjectTo.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of the SubjectTo class designed to manage working sets of * constraints and bounds within a QProblem. */ #ifndef QPOASES_SUBJECTTO_HPP #define QPOASES_SUBJECTTO_HPP #include /** This class manages working sets of constraints and bounds by storing * index sets and other status information. * * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 */ class SubjectTo { /* * PUBLIC MEMBER FUNCTIONS */ public: /** Default constructor. */ SubjectTo( ); /** Copy constructor (deep copy). */ SubjectTo( const SubjectTo& rhs /**< Rhs object. */ ); /** Destructor. */ ~SubjectTo( ); /** Assignment operator (deep copy). */ SubjectTo& operator=( const SubjectTo& rhs /**< Rhs object. */ ); /** Pseudo-constructor takes the number of constraints or bounds. * \return SUCCESSFUL_RETURN */ returnValue init( int n /**< Number of constraints or bounds. */ ); /** Returns type of (constraints') bound. * \return Type of (constraints') bound \n RET_INDEX_OUT_OF_BOUNDS */ inline SubjectToType getType( int i /**< Number of (constraints') bound. */ ) const ; /** Returns status of (constraints') bound. * \return Status of (constraints') bound \n ST_UNDEFINED */ inline SubjectToStatus getStatus( int i /**< Number of (constraints') bound. */ ) const; /** Sets type of (constraints') bound. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setType( int i, /**< Number of (constraints') bound. */ SubjectToType value /**< Type of (constraints') bound. */ ); /** Sets status of (constraints') bound. * \return SUCCESSFUL_RETURN \n RET_INDEX_OUT_OF_BOUNDS */ inline returnValue setStatus( int i, /**< Number of (constraints') bound. */ SubjectToStatus value /**< Status of (constraints') bound. */ ); /** Sets status of lower (constraints') bounds. */ inline void setNoLower( BooleanType _status /**< Status of lower (constraints') bounds. */ ); /** Sets status of upper (constraints') bounds. */ inline void setNoUpper( BooleanType _status /**< Status of upper (constraints') bounds. */ ); /** Returns status of lower (constraints') bounds. * \return BT_TRUE if there is no lower (constraints') bound on any variable. */ inline BooleanType isNoLower( ) const; /** Returns status of upper bounds. * \return BT_TRUE if there is no upper (constraints') bound on any variable. */ inline BooleanType isNoUpper( ) const; /* * PROTECTED MEMBER FUNCTIONS */ protected: /** Adds the index of a new constraint or bound to index set. * \return SUCCESSFUL_RETURN \n RET_ADDINDEX_FAILED */ returnValue addIndex( Indexlist* const indexlist, /**< Index list to which the new index shall be added. */ int newnumber, /**< Number of new constraint or bound. */ SubjectToStatus newstatus /**< Status of new constraint or bound. */ ); /** Removes the index of a constraint or bound from index set. * \return SUCCESSFUL_RETURN \n RET_UNKNOWN_BUG */ returnValue removeIndex( Indexlist* const indexlist, /**< Index list from which the new index shall be removed. */ int removenumber /**< Number of constraint or bound to be removed. */ ); /** Swaps the indices of two constraints or bounds within the index set. * \return SUCCESSFUL_RETURN \n RET_SWAPINDEX_FAILED */ returnValue swapIndex( Indexlist* const indexlist, /**< Index list in which the indices shold be swapped. */ int number1, /**< Number of first constraint or bound. */ int number2 /**< Number of second constraint or bound. */ ); /* * PROTECTED MEMBER VARIABLES */ protected: SubjectToType type[NVMAX+NCMAX]; /**< Type of constraints/bounds. */ SubjectToStatus status[NVMAX+NCMAX]; /**< Status of constraints/bounds. */ BooleanType noLower; /**< This flag indicates if there is no lower bound on any variable. */ BooleanType noUpper; /**< This flag indicates if there is no upper bound on any variable. */ /* * PRIVATE MEMBER VARIABLES */ private: int size; }; #include #endif /* QPOASES_SUBJECTTO_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/Types.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/Types.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2008 * * Declaration of all non-built-in types (except for classes). */ #ifndef QPOASES_TYPES_HPP #define QPOASES_TYPES_HPP /** Define real_t for facilitating switching between double and float. */ // typedef double real_t; /** Summarises all possible logical values. */ enum BooleanType { BT_FALSE, /**< Logical value for "false". */ BT_TRUE /**< Logical value for "true". */ }; /** Summarises all possible print levels. Print levels are used to describe * the desired amount of output during runtime of qpOASES. */ enum PrintLevel { PL_NONE, /**< No output. */ PL_LOW, /**< Print error messages only. */ PL_MEDIUM, /**< Print error and warning messages as well as concise info messages. */ PL_HIGH /**< Print all messages with full details. */ }; /** Defines visibility status of a message. */ enum VisibilityStatus { VS_VISIBLE, /**< Message visible. */ VS_HIDDEN /**< Message not visible. */ }; /** Summarises all possible states of the (S)QProblem(B) object during the solution process of a QP sequence. */ enum QProblemStatus { QPS_NOTINITIALISED, /**< QProblem object is freshly instantiated or reset. */ QPS_PREPARINGAUXILIARYQP, /**< An auxiliary problem is currently setup, either at the very beginning * via an initial homotopy or after changing the QP matrices. */ QPS_AUXILIARYQPSOLVED, /**< An auxilary problem was solved, either at the very beginning * via an initial homotopy or after changing the QP matrices. */ QPS_PERFORMINGHOMOTOPY, /**< A homotopy according to the main idea of the online active * set strategy is performed. */ QPS_HOMOTOPYQPSOLVED, /**< An intermediate QP along the homotopy path was solved. */ QPS_SOLVED /**< The solution of the actual QP was found. */ }; /** Summarises all possible types of bounds and constraints. */ enum SubjectToType { ST_UNBOUNDED, /**< Bound/constraint is unbounded. */ ST_BOUNDED, /**< Bound/constraint is bounded but not fixed. */ ST_EQUALITY, /**< Bound/constraint is fixed (implicit equality bound/constraint). */ ST_UNKNOWN /**< Type of bound/constraint unknown. */ }; /** Summarises all possible states of bounds and constraints. */ enum SubjectToStatus { ST_INACTIVE, /**< Bound/constraint is inactive. */ ST_LOWER, /**< Bound/constraint is at its lower bound. */ ST_UPPER, /**< Bound/constraint is at its upper bound. */ ST_UNDEFINED /**< Status of bound/constraint undefined. */ }; /** Summarises all possible cycling states of bounds and constraints. */ enum CyclingStatus { CYC_NOT_INVOLVED, /**< Bound/constraint is not involved in current cycling. */ CYC_PREV_ADDED, /**< Bound/constraint has previously been added during the current cycling. */ CYC_PREV_REMOVED /**< Bound/constraint has previously been removed during the current cycling. */ }; /** Summarises all possible types of the QP's Hessian matrix. */ enum HessianType { HST_SEMIDEF, /**< Hessian is positive semi-definite. */ HST_POSDEF_NULLSPACE, /**< Hessian is positive definite on null space of active bounds/constraints. */ HST_POSDEF, /**< Hessian is (strictly) positive definite. */ HST_IDENTITY /**< Hessian is identity matrix. */ }; #endif /* QPOASES_TYPES_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/INCLUDE/Utils.hpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file INCLUDE/Utils.hpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of global utility functions for working with qpOASES. */ #ifndef QPOASES_UTILS_HPP #define QPOASES_UTILS_HPP #include #ifdef PC_DEBUG /* Define print functions only for debugging! */ /** Prints a vector. * \return SUCCESSFUL_RETURN */ returnValue print( const real_t* const v, /**< Vector to be printed. */ int n /**< Length of vector. */ ); /** Prints a permuted vector. * \return SUCCESSFUL_RETURN */ returnValue print( const real_t* const v, /**< Vector to be printed. */ int n, /**< Length of vector. */ const int* const V_idx /**< Pemutation vector. */ ); /** Prints a named vector. * \return SUCCESSFUL_RETURN */ returnValue print( const real_t* const v, /**< Vector to be printed. */ int n, /**< Length of vector. */ const char* name /** Name of vector. */ ); /** Prints a matrix. * \return SUCCESSFUL_RETURN */ returnValue print( const real_t* const M, /**< Matrix to be printed. */ int nrow, /**< Row number of matrix. */ int ncol /**< Column number of matrix. */ ); /** Prints a permuted matrix. * \return SUCCESSFUL_RETURN */ returnValue print( const real_t* const M, /**< Matrix to be printed. */ int nrow, /**< Row number of matrix. */ int ncol , /**< Column number of matrix. */ const int* const ROW_idx, /**< Row pemutation vector. */ const int* const COL_idx /**< Column pemutation vector. */ ); /** Prints a named matrix. * \return SUCCESSFUL_RETURN */ returnValue print( const real_t* const M, /**< Matrix to be printed. */ int nrow, /**< Row number of matrix. */ int ncol, /**< Column number of matrix. */ const char* name /** Name of matrix. */ ); /** Prints an index array. * \return SUCCESSFUL_RETURN */ returnValue print( const int* const index, /**< Index array to be printed. */ int n /**< Length of index array. */ ); /** Prints a named index array. * \return SUCCESSFUL_RETURN */ returnValue print( const int* const index, /**< Index array to be printed. */ int n, /**< Length of index array. */ const char* name /**< Name of index array. */ ); /** Prints a string to desired output target (useful also for MATLAB output!). * \return SUCCESSFUL_RETURN */ returnValue myPrintf( const char* s /**< String to be written. */ ); /** Prints qpOASES copyright notice. * \return SUCCESSFUL_RETURN */ returnValue printCopyrightNotice( ); /** Reads a real_t matrix from file. * \return SUCCESSFUL_RETURN \n RET_UNABLE_TO_OPEN_FILE \n RET_UNABLE_TO_READ_FILE */ returnValue readFromFile( real_t* data, /**< Matrix to be read from file. */ int nrow, /**< Row number of matrix. */ int ncol, /**< Column number of matrix. */ const char* datafilename /**< Data file name. */ ); /** Reads a real_t vector from file. * \return SUCCESSFUL_RETURN \n RET_UNABLE_TO_OPEN_FILE \n RET_UNABLE_TO_READ_FILE */ returnValue readFromFile( real_t* data, /**< Vector to be read from file. */ int n, /**< Length of vector. */ const char* datafilename /**< Data file name. */ ); /** Reads an integer (column) vector from file. * \return SUCCESSFUL_RETURN \n RET_UNABLE_TO_OPEN_FILE \n RET_UNABLE_TO_READ_FILE */ returnValue readFromFile( int* data, /**< Vector to be read from file. */ int n, /**< Length of vector. */ const char* datafilename /**< Data file name. */ ); /** Writes a real_t matrix into a file. * \return SUCCESSFUL_RETURN \n RET_UNABLE_TO_OPEN_FILE */ returnValue writeIntoFile( const real_t* const data, /**< Matrix to be written into file. */ int nrow, /**< Row number of matrix. */ int ncol, /**< Column number of matrix. */ const char* datafilename, /**< Data file name. */ BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ ); /** Writes a real_t vector into a file. * \return SUCCESSFUL_RETURN \n RET_UNABLE_TO_OPEN_FILE */ returnValue writeIntoFile( const real_t* const data, /**< Vector to be written into file. */ int n, /**< Length of vector. */ const char* datafilename, /**< Data file name. */ BooleanType append /**< Indicates if data shall be appended if the file already exists (otherwise it is overwritten). */ ); /** Writes an integer (column) vector into a file. * \return SUCCESSFUL_RETURN \n RET_UNABLE_TO_OPEN_FILE */ returnValue writeIntoFile( const int* const integer, /**< Integer vector to be written into file. */ int n, /**< Length of vector. */ const char* datafilename, /**< Data file name. */ BooleanType append /**< Indicates if integer shall be appended if the file already exists (otherwise it is overwritten). */ ); #endif /* PC_DEBUG */ /** Returns the current system time. * \return current system time */ real_t getCPUtime( ); /** Returns the Euclidean norm of a vector. * \return 0: successful */ real_t getNorm( const real_t* const v, /**< Vector. */ int n /**< Vector's dimension. */ ); /** Returns the absolute value of a real_t. * \return Absolute value of a real_t */ inline real_t getAbs( real_t x /**< Input argument. */ ); #include #endif /* QPOASES_UTILS_HPP */ /* * end of file */ ================================================ FILE: phonelibs/qpoases/LICENSE.txt ================================================ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ================================================ FILE: phonelibs/qpoases/README.txt ================================================ ## ## qpOASES -- An Implementation of the Online Active Set Strategy. ## Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. ## ## qpOASES is free software; you can redistribute it and/or ## modify it under the terms of the GNU Lesser General Public ## License as published by the Free Software Foundation; either ## version 2.1 of the License, or (at your option) any later version. ## ## qpOASES is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## Lesser General Public License for more details. ## ## You should have received a copy of the GNU Lesser General Public ## License along with qpOASES; if not, write to the Free Software ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## INTRODUCTION ============= qpOASES is an open-source C++ implementation of the recently proposed online active set strategy (see [1], [2]), which was inspired by important observations from the field of parametric quadratic programming. It has several theoretical features that make it particularly suited for model predictive control (MPC) applications. The software package qpOASES implements these ideas and has already been successfully used for closed-loop control of a real-world Diesel engine [3]. References: [1] H.J. Ferreau. An Online Active Set Strategy for Fast Solution of Parametric Quadratic Programs with Applications to Predictive Engine Control. Diplom thesis, University of Heidelberg, 2006. [2] H.J. Ferreau, H.G. Bock, M. Diehl. An online active set strategy to overcome the limitations of explicit MPC. International Journal of Robust and Nonlinear Control, 18 (8), pp. 816-830, 2008. [3] H.J. Ferreau, P. Ortner, P. Langthaler, L. del Re, M. Diehl. Predictive Control of a Real-World Diesel Engine using an Extended Online Active Set Strategy. Annual Reviews in Control, 31 (2), pp. 293-301, 2007. GETTING STARTED ================ 1. For installation, usage and additional information on this software package see the qpOASES User's Manual located at ./DOC/manual.pdf! 2. The file ./LICENSE.txt contains a copy of the GNU Lesser General Public License. Please read it carefully before using qpOASES! 3. The whole software package can be downloaded from http://homes.esat.kuleuven.be/~optec/software/qpOASES/ On this webpage you will also find a list of frequently asked questions. CONTACT THE AUTHORS ==================== If you have got questions, remarks or comments on qpOASES please contact the main author: Hans Joachim Ferreau Katholieke Universiteit Leuven Department of Electrical Engineering (ESAT) Kasteelpark Arenberg 10, bus 2446 B-3001 Leuven-Heverlee, Belgium Phone: +32 16 32 03 63 E-mail: joachim.ferreau@esat.kuleuven.be qpOASES@esat.kuleuven.be Also bug reports and source code extensions are most welcome! ## ## end of file ## ================================================ FILE: phonelibs/qpoases/SConscript ================================================ Import('env', 'interface_dir') qp_files = [ Glob("SRC/*.cpp"), Glob("SRC/EXTRAS/*.cpp"), ] cpp_path = [ ".", "INCLUDE", "INCLUDE/EXTRAS", "SRC/", interface_dir, ] env.Library('qpoases', qp_files, CPPPATH=cpp_path) ================================================ FILE: phonelibs/qpoases/SRC/Bounds.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/Bounds.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the Bounds class designed to manage working sets of * bounds within a QProblem. */ #include /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * B o u n d s */ Bounds::Bounds( ) : SubjectTo( ), nV( 0 ), nFV( 0 ), nBV( 0 ), nUV( 0 ) { } /* * B o u n d s */ Bounds::Bounds( const Bounds& rhs ) : SubjectTo( rhs ), nV( rhs.nV ), nFV( rhs.nFV ), nBV( rhs.nBV ), nUV( rhs.nUV ) { free = rhs.free; fixed = rhs.fixed; } /* * ~ B o u n d s */ Bounds::~Bounds( ) { } /* * o p e r a t o r = */ Bounds& Bounds::operator=( const Bounds& rhs ) { if ( this != &rhs ) { SubjectTo::operator=( rhs ); nV = rhs.nV; nFV = rhs.nFV; nBV = rhs.nBV; nUV = rhs.nUV; free = rhs.free; fixed = rhs.fixed; } return *this; } /* * i n i t */ returnValue Bounds::init( int n ) { nV = n; nFV = 0; nBV = 0; nUV = 0; free.init( ); fixed.init( ); return SubjectTo::init( n ); } /* * s e t u p B o u n d */ returnValue Bounds::setupBound( int _number, SubjectToStatus _status ) { /* consistency check */ if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Add bound index to respective index list. */ switch ( _status ) { case ST_INACTIVE: if ( this->addIndex( this->getFree( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_BOUND_FAILED ); break; case ST_LOWER: if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_BOUND_FAILED ); break; case ST_UPPER: if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_BOUND_FAILED ); break; default: return THROWERROR( RET_INVALID_ARGUMENTS ); } return SUCCESSFUL_RETURN; } /* * s e t u p A l l F r e e */ returnValue Bounds::setupAllFree( ) { int i; /* 1) Place unbounded variables at the beginning of the index list of free variables. */ for( i=0; i= getNV( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Move index from indexlist of fixed variables to that of free ones. */ if ( this->removeIndex( this->getFixed( ),_number ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); if ( this->addIndex( this->getFree( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); return SUCCESSFUL_RETURN; } /* * m o v e F r e e T o F i x e d */ returnValue Bounds::moveFreeToFixed( int _number, SubjectToStatus _status ) { /* consistency check */ if ( ( _number < 0 ) || ( _number >= getNV( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Move index from indexlist of free variables to that of fixed ones. */ if ( this->removeIndex( this->getFree( ),_number ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); if ( this->addIndex( this->getFixed( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); return SUCCESSFUL_RETURN; } /* * s w a p F r e e */ returnValue Bounds::swapFree( int number1, int number2 ) { /* consistency check */ if ( ( number1 < 0 ) || ( number1 >= getNV( ) ) || ( number2 < 0 ) || ( number2 >= getNV( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Swap index within indexlist of free variables. */ return this->swapIndex( this->getFree( ),number1,number2 ); } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/Bounds.ipp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/Bounds.ipp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of inlined member functions of the Bounds class designed * to manage working sets of bounds within a QProblem. */ /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * g e t N V */ inline int Bounds::getNV( ) const { return nV; } /* * g e t N F X */ inline int Bounds::getNFV( ) const { return nFV; } /* * g e t N B V */ inline int Bounds::getNBV( ) const { return nBV; } /* * g e t N U V */ inline int Bounds::getNUV( ) const { return nUV; } /* * s e t N F X */ inline returnValue Bounds::setNFV( int n ) { nFV = n; return SUCCESSFUL_RETURN; } /* * s e t N B V */ inline returnValue Bounds::setNBV( int n ) { nBV = n; return SUCCESSFUL_RETURN; } /* * s e t N U V */ inline returnValue Bounds::setNUV( int n ) { nUV = n; return SUCCESSFUL_RETURN; } /* * g e t N F R */ inline int Bounds::getNFR( ) { return free.getLength( ); } /* * g e t N F X */ inline int Bounds::getNFX( ) { return fixed.getLength( ); } /* * g e t F r e e */ inline Indexlist* Bounds::getFree( ) { return &free; } /* * g e t F i x e d */ inline Indexlist* Bounds::getFixed( ) { return &fixed; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/Constraints.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/Constraints.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the Constraints class designed to manage working sets of * constraints within a QProblem. */ #include /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * C o n s t r a i n t s */ Constraints::Constraints( ) : SubjectTo( ), nC( 0 ), nEC( 0 ), nIC( 0 ), nUC( 0 ) { } /* * C o n s t r a i n t s */ Constraints::Constraints( const Constraints& rhs ) : SubjectTo( rhs ), nC( rhs.nC ), nEC( rhs.nEC ), nIC( rhs.nIC ), nUC( rhs.nUC ) { active = rhs.active; inactive = rhs.inactive; } /* * ~ C o n s t r a i n t s */ Constraints::~Constraints( ) { } /* * o p e r a t o r = */ Constraints& Constraints::operator=( const Constraints& rhs ) { if ( this != &rhs ) { SubjectTo::operator=( rhs ); nC = rhs.nC; nEC = rhs.nEC; nIC = rhs.nIC; nUC = rhs.nUC; active = rhs.active; inactive = rhs.inactive; } return *this; } /* * i n i t */ returnValue Constraints::init( int n ) { nC = n; nEC = 0; nIC = 0; nUC = 0; active.init( ); inactive.init( ); return SubjectTo::init( n ); } /* * s e t u p C o n s t r a i n t */ returnValue Constraints::setupConstraint( int _number, SubjectToStatus _status ) { /* consistency check */ if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Add constraint index to respective index list. */ switch ( _status ) { case ST_INACTIVE: if ( this->addIndex( this->getInactive( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); break; case ST_LOWER: if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); break; case ST_UPPER: if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_CONSTRAINT_FAILED ); break; default: return THROWERROR( RET_INVALID_ARGUMENTS ); } return SUCCESSFUL_RETURN; } /* * s e t u p A l l I n a c t i v e */ returnValue Constraints::setupAllInactive( ) { int i; /* 1) Place unbounded constraints at the beginning of the index list of inactive constraints. */ for( i=0; i= getNC( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Move index from indexlist of active constraints to that of inactive ones. */ if ( this->removeIndex( this->getActive( ),_number ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); if ( this->addIndex( this->getInactive( ),_number,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); return SUCCESSFUL_RETURN; } /* * m o v e I n a c t i v e T o A c t i v e */ returnValue Constraints::moveInactiveToActive( int _number, SubjectToStatus _status ) { /* consistency check */ if ( ( _number < 0 ) || ( _number >= getNC( ) ) ) return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); /* Move index from indexlist of inactive constraints to that of active ones. */ if ( this->removeIndex( this->getInactive( ),_number ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); if ( this->addIndex( this->getActive( ),_number,_status ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_MOVING_BOUND_FAILED ); return SUCCESSFUL_RETURN; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/Constraints.ipp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/Constraints.ipp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Declaration of inlined member functions of the Constraints class designed * to manage working sets of constraints within a QProblem. */ /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * g e t N C */ inline int Constraints::getNC( ) const { return nC; } /* * g e t N E C */ inline int Constraints::getNEC( ) const { return nEC; } /* * g e t N I C */ inline int Constraints::getNIC( ) const { return nIC; } /* * g e t N U C */ inline int Constraints::getNUC( ) const { return nUC; } /* * s e t N E C */ inline returnValue Constraints::setNEC( int n ) { nEC = n; return SUCCESSFUL_RETURN; } /* * s e t N I C */ inline returnValue Constraints::setNIC( int n ) { nIC = n; return SUCCESSFUL_RETURN; } /* * s e t N U C */ inline returnValue Constraints::setNUC( int n ) { nUC = n; return SUCCESSFUL_RETURN; } /* * g e t N A C */ inline int Constraints::getNAC( ) { return active.getLength( ); } /* * g e t N I A C */ inline int Constraints::getNIAC( ) { return inactive.getLength( ); } /* * g e t A c t i v e */ inline Indexlist* Constraints::getActive( ) { return &active; } /* * g e t I n a c t i v e */ inline Indexlist* Constraints::getInactive( ) { return &inactive; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/CyclingManager.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/CyclingManager.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the CyclingManager class designed to detect * and handle possible cycling during QP iterations. * */ #include /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * C y c l i n g M a n a g e r */ CyclingManager::CyclingManager( ) : nV( 0 ), nC( 0 ) { cyclingDetected = BT_FALSE; } /* * C y c l i n g M a n a g e r */ CyclingManager::CyclingManager( const CyclingManager& rhs ) : nV( rhs.nV ), nC( rhs.nC ), cyclingDetected( rhs.cyclingDetected ) { int i; for( i=0; i= 0 ) && ( number < nV ) ) { status[number] = _status; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } else { /* Set cycling status of a constraint. */ if ( ( number >= 0 ) && ( number < nC ) ) { status[nV+number] = _status; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } } /* * g e t C y c l i n g S t a t u s */ CyclingStatus CyclingManager::getCyclingStatus( int number, BooleanType isBound ) const { if ( isBound == BT_TRUE ) { /* Return cycling status of a bound. */ if ( ( number >= 0 ) && ( number < nV ) ) return status[number]; } else { /* Return cycling status of a constraint. */ if ( ( number >= 0 ) && ( number < nC ) ) return status[nV+number]; } return CYC_NOT_INVOLVED; } /* * c l e a r C y c l i n g D a t a */ returnValue CyclingManager::clearCyclingData( ) { int i; /* Reset all status values ... */ for( i=0; i /* * S o l u t i o n A n a l y s i s */ SolutionAnalysis::SolutionAnalysis( ) { } /* * S o l u t i o n A n a l y s i s */ SolutionAnalysis::SolutionAnalysis( const SolutionAnalysis& rhs ) { } /* * ~ S o l u t i o n A n a l y s i s */ SolutionAnalysis::~SolutionAnalysis( ) { } /* * o p e r a t o r = */ SolutionAnalysis& SolutionAnalysis::operator=( const SolutionAnalysis& rhs ) { if ( this != &rhs ) { } return *this; } /* * g e t H e s s i a n I n v e r s e */ returnValue SolutionAnalysis::getHessianInverse( QProblem* qp, real_t* hessianInverse ) { returnValue returnvalue; /* the return value */ BooleanType Delta_bC_isZero = BT_FALSE; /* (just use FALSE here) */ BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ register int run1, run2, run3; register int nFR, nFX; /* Ask for the number of free and fixed variables, assumes that active set * is constant for the covariance evaluation */ nFR = qp->getNFR( ); nFX = qp->getNFX( ); /* Ask for the corresponding index arrays: */ if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( qp->constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); /* Initialization: */ for( run1 = 0; run1 < NVMAX; run1++ ) delta_g_cov[ run1 ] = 0.0; for( run1 = 0; run1 < NVMAX; run1++ ) delta_lb_cov[ run1 ] = 0.0; for( run1 = 0; run1 < NVMAX; run1++ ) delta_ub_cov[ run1 ] = 0.0; for( run1 = 0; run1 < NCMAX; run1++ ) delta_lbA_cov[ run1 ] = 0.0; for( run1 = 0; run1 < NCMAX; run1++ ) delta_ubA_cov[ run1 ] = 0.0; /* The following loop solves the following: * * KKT * x = * [delta_g_cov', delta_lbA_cov', delta_ubA_cov', delta_lb_cov', delta_ub_cov]' * * for the first NVMAX (negative) elementary vectors in order to get * transposed inverse of the Hessian. Assuming that the Hessian is * symmetric, the function will return transposed inverse, instead of the * true inverse. * * Note, that we use negative elementary vectors due because internal * implementation of the function hotstart_determineStepDirection requires * so. * * */ for( run3 = 0; run3 < NVMAX; run3++ ) { /* Line wise loading of the corresponding (negative) elementary vector: */ delta_g_cov[ run3 ] = -1.0; /* Evaluation of the step: */ returnvalue = qp->hotstart_determineStepDirection( FR_idx, FX_idx, AC_idx, delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, Delta_bC_isZero, Delta_bB_isZero, delta_xFX, delta_xFR, delta_yAC, delta_yFX ); if ( returnvalue != SUCCESSFUL_RETURN ) { return returnvalue; } /* Line wise storage of the QP reaction: */ for( run1 = 0; run1 < nFR; run1++ ) { run2 = FR_idx[ run1 ]; hessianInverse[run3 * NVMAX + run2] = delta_xFR[ run1 ]; } for( run1 = 0; run1 < nFX; run1++ ) { run2 = FX_idx[ run1 ]; hessianInverse[run3 * NVMAX + run2] = delta_xFX[ run1 ]; } /* Prepare for the next iteration */ delta_g_cov[ run3 ] = 0.0; } // TODO: Perform the transpose of the inverse of the Hessian matrix return SUCCESSFUL_RETURN; } /* * g e t H e s s i a n I n v e r s e */ returnValue SolutionAnalysis::getHessianInverse( QProblemB* qp, real_t* hessianInverse ) { returnValue returnvalue; /* the return value */ BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ register int run1, run2, run3; register int nFR, nFX; /* Ask for the number of free and fixed variables, assumes that active set * is constant for the covariance evaluation */ nFR = qp->getNFR( ); nFX = qp->getNFX( ); /* Ask for the corresponding index arrays: */ if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); /* Initialization: */ for( run1 = 0; run1 < NVMAX; run1++ ) delta_g_cov[ run1 ] = 0.0; for( run1 = 0; run1 < NVMAX; run1++ ) delta_lb_cov[ run1 ] = 0.0; for( run1 = 0; run1 < NVMAX; run1++ ) delta_ub_cov[ run1 ] = 0.0; /* The following loop solves the following: * * KKT * x = * [delta_g_cov', delta_lb_cov', delta_ub_cov']' * * for the first NVMAX (negative) elementary vectors in order to get * transposed inverse of the Hessian. Assuming that the Hessian is * symmetric, the function will return transposed inverse, instead of the * true inverse. * * Note, that we use negative elementary vectors due because internal * implementation of the function hotstart_determineStepDirection requires * so. * * */ for( run3 = 0; run3 < NVMAX; run3++ ) { /* Line wise loading of the corresponding (negative) elementary vector: */ delta_g_cov[ run3 ] = -1.0; /* Evaluation of the step: */ returnvalue = qp->hotstart_determineStepDirection( FR_idx, FX_idx, delta_g_cov, delta_lb_cov, delta_ub_cov, Delta_bB_isZero, delta_xFX, delta_xFR, delta_yFX ); if ( returnvalue != SUCCESSFUL_RETURN ) { return returnvalue; } /* Line wise storage of the QP reaction: */ for( run1 = 0; run1 < nFR; run1++ ) { run2 = FR_idx[ run1 ]; hessianInverse[run3 * NVMAX + run2] = delta_xFR[ run1 ]; } for( run1 = 0; run1 < nFX; run1++ ) { run2 = FX_idx[ run1 ]; hessianInverse[run3 * NVMAX + run2] = delta_xFX[ run1 ]; } /* Prepare for the next iteration */ delta_g_cov[ run3 ] = 0.0; } // TODO: Perform the transpose of the inverse of the Hessian matrix return SUCCESSFUL_RETURN; } /* * g e t V a r i a n c e C o v a r i a n c e */ #if QPOASES_USE_OLD_VERSION returnValue SolutionAnalysis::getVarianceCovariance( QProblem* qp, real_t* g_b_bA_VAR, real_t* Primal_Dual_VAR ) { int run1, run2, run3; /* simple run variables (for loops). */ returnValue returnvalue; /* the return value */ BooleanType Delta_bC_isZero = BT_FALSE; /* (just use FALSE here) */ BooleanType Delta_bB_isZero = BT_FALSE; /* (just use FALSE here) */ /* ASK FOR THE NUMBER OF FREE AND FIXED VARIABLES: * (ASSUMES THAT ACTIVE SET IS CONSTANT FOR THE * VARIANCE-COVARIANCE EVALUATION) * ----------------------------------------------- */ int nFR, nFX, nAC; nFR = qp->getNFR( ); nFX = qp->getNFX( ); nAC = qp->getNAC( ); if ( qp->bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( qp->bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( qp->constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); /* SOME INITIALIZATIONS: * --------------------- */ for( run1 = 0; run1 < KKT_DIM * KKT_DIM; run1++ ) { K [run1] = 0.0; Primal_Dual_VAR[run1] = 0.0; } /* ================================================================= */ /* FIRST MATRIX MULTIPLICATION (OBTAINS THE INTERMEDIATE RESULT * K := [ ("ACTIVE" KKT-MATRIX OF THE QP)^(-1) * g_b_bA_VAR ]^T ) * THE EVALUATION OF THE INVERSE OF THE KKT-MATRIX OF THE QP * WITH RESPECT TO THE CURRENT ACTIVE SET * USES THE EXISTING CHOLESKY AND TQ-DECOMPOSITIONS. FOR DETAILS * cf. THE (protected) FUNCTION determineStepDirection. */ for( run3 = 0; run3 < KKT_DIM; run3++ ) { for( run1 = 0; run1 < NVMAX; run1++ ) { delta_g_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+run1]; delta_lb_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+NVMAX+run1]; /* LINE-WISE LOADING OF THE INPUT */ delta_ub_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+NVMAX+run1]; /* VARIANCE-COVARIANCE */ } for( run1 = 0; run1 < NCMAX; run1++ ) { delta_lbA_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+2*NVMAX+run1]; delta_ubA_cov [run1] = g_b_bA_VAR[run3*KKT_DIM+2*NVMAX+run1]; } /* EVALUATION OF THE STEP: * ------------------------------------------------------------------------------ */ returnvalue = qp->hotstart_determineStepDirection( FR_idx, FX_idx, AC_idx, delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR, delta_yAC,delta_yFX ); /* ------------------------------------------------------------------------------ */ /* STOP THE ALGORITHM IN THE CASE OF NO SUCCESFUL RETURN: * ------------------------------------------------------ */ if ( returnvalue != SUCCESSFUL_RETURN ) { return returnvalue; } /* LINE WISE */ /* STORAGE OF THE QP-REACTION */ /* (uses the index list) */ for( run1=0; run1hotstart_determineStepDirection( FR_idx, FX_idx, AC_idx, delta_g_cov, delta_lbA_cov, delta_ubA_cov, delta_lb_cov, delta_ub_cov, Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR, delta_yAC,delta_yFX ); /* ------------------------------------------------------------------------------ */ /* STOP THE ALGORITHM IN THE CASE OF NO SUCCESFUL RETURN: * ------------------------------------------------------ */ if ( returnvalue != SUCCESSFUL_RETURN ) { return returnvalue; } /* ROW-WISE STORAGE */ /* OF THE RESULT. */ for( run1=0; run1 /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * I n d e x l i s t */ Indexlist::Indexlist( ) : length( 0 ), first( -1 ), last( -1 ), lastusedindex( -1 ), physicallength( INDEXLISTFACTOR*(NVMAX+NCMAX) ) { int i; for( i=0; i= 0 ) && ( number[n] >= 0 ) ) numberarray[i] = number[n]; else return THROWERROR( RET_INDEXLIST_CORRUPTED ); n = next[n]; } return SUCCESSFUL_RETURN; } /* * g e t I n d e x */ int Indexlist::getIndex( int givennumber ) const { int i; int n = first; int index = -1; /* return -1 by default */ /* Run trough indexlist until number is found, if so return it index. */ for ( i=0; i length ) ) return -RET_INDEXLIST_OUTOFBOUNDS; return number[physicalindex]; } /* * g e t L e n g t h */ inline int Indexlist::getLength( ) { return length; } /* * g e t L a s t N u m b e r */ inline int Indexlist::getLastNumber( ) const { return number[last]; } /* * g e t L a s t N u m b e r */ inline BooleanType Indexlist::isMember( int _number ) const { if ( getIndex( _number ) >= 0 ) return BT_TRUE; else return BT_FALSE; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/MessageHandling.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/MessageHandling.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the MessageHandling class including global return values. * */ #include #include /** Defines pairs of global return values and messages. */ MessageHandling::ReturnValueList returnValueList[] = { /* miscellaneous */ { SUCCESSFUL_RETURN, "Successful return", VS_VISIBLE }, { RET_DIV_BY_ZERO, "Division by zero", VS_VISIBLE }, { RET_INDEX_OUT_OF_BOUNDS, "Index out of bounds", VS_VISIBLE }, { RET_INVALID_ARGUMENTS, "At least one of the arguments is invalid", VS_VISIBLE }, { RET_ERROR_UNDEFINED, "Error number undefined", VS_VISIBLE }, { RET_WARNING_UNDEFINED, "Warning number undefined", VS_VISIBLE }, { RET_INFO_UNDEFINED, "Info number undefined", VS_VISIBLE }, { RET_EWI_UNDEFINED, "Error/warning/info number undefined", VS_VISIBLE }, { RET_AVAILABLE_WITH_LINUX_ONLY, "This function is available under Linux only", VS_HIDDEN }, { RET_UNKNOWN_BUG, "The error occured is not yet known", VS_VISIBLE }, { RET_PRINTLEVEL_CHANGED, "Print level changed", VS_VISIBLE }, { RET_NOT_YET_IMPLEMENTED, "Requested function is not yet implemented.", VS_VISIBLE }, /* Indexlist */ { RET_INDEXLIST_MUST_BE_REORDERD, "Index list has to be reordered", VS_VISIBLE }, { RET_INDEXLIST_EXCEEDS_MAX_LENGTH, "Index list exceeds its maximal physical length", VS_VISIBLE }, { RET_INDEXLIST_CORRUPTED, "Index list corrupted", VS_VISIBLE }, { RET_INDEXLIST_OUTOFBOUNDS, "Physical index is out of bounds", VS_VISIBLE }, { RET_INDEXLIST_ADD_FAILED, "Adding indices from another index set failed", VS_VISIBLE }, { RET_INDEXLIST_INTERSECT_FAILED, "Intersection with another index set failed", VS_VISIBLE }, /* SubjectTo / Bounds / Constraints */ { RET_INDEX_ALREADY_OF_DESIRED_STATUS, "Index is already of desired status", VS_VISIBLE }, { RET_SWAPINDEX_FAILED, "Cannot swap between different indexsets", VS_VISIBLE }, { RET_ADDINDEX_FAILED, "Adding index to index set failed", VS_VISIBLE }, { RET_NOTHING_TO_DO, "Nothing to do", VS_VISIBLE }, { RET_SETUP_BOUND_FAILED, "Setting up bound index failed", VS_VISIBLE }, { RET_SETUP_CONSTRAINT_FAILED, "Setting up constraint index failed", VS_VISIBLE }, { RET_MOVING_BOUND_FAILED, "Moving bound between index sets failed", VS_VISIBLE }, { RET_MOVING_CONSTRAINT_FAILED, "Moving constraint between index sets failed", VS_VISIBLE }, /* QProblem */ { RET_QP_ALREADY_INITIALISED, "QProblem has already been initialised", VS_VISIBLE }, { RET_NO_INIT_WITH_STANDARD_SOLVER, "Initialisation via extern QP solver is not yet implemented", VS_VISIBLE }, { RET_RESET_FAILED, "Reset failed", VS_VISIBLE }, { RET_INIT_FAILED, "Initialisation failed", VS_VISIBLE }, { RET_INIT_FAILED_TQ, "Initialisation failed due to TQ factorisation", VS_VISIBLE }, { RET_INIT_FAILED_CHOLESKY, "Initialisation failed due to Cholesky decomposition", VS_VISIBLE }, { RET_INIT_FAILED_HOTSTART, "Initialisation failed! QP could not be solved!", VS_VISIBLE }, { RET_INIT_FAILED_INFEASIBILITY, "Initial QP could not be solved due to infeasibility!", VS_VISIBLE }, { RET_INIT_FAILED_UNBOUNDEDNESS, "Initial QP could not be solved due to unboundedness!", VS_VISIBLE }, { RET_INIT_SUCCESSFUL, "Initialisation done", VS_VISIBLE }, { RET_OBTAINING_WORKINGSET_FAILED, "Failed to obtain working set for auxiliary QP", VS_VISIBLE }, { RET_SETUP_WORKINGSET_FAILED, "Failed to setup working set for auxiliary QP", VS_VISIBLE }, { RET_SETUP_AUXILIARYQP_FAILED, "Failed to setup auxiliary QP for initialised homotopy", VS_VISIBLE }, { RET_NO_EXTERN_SOLVER, "No extern QP solver available", VS_VISIBLE }, { RET_QP_UNBOUNDED, "QP is unbounded", VS_VISIBLE }, { RET_QP_INFEASIBLE, "QP is infeasible", VS_VISIBLE }, { RET_QP_NOT_SOLVED, "Problems occured while solving QP with standard solver", VS_VISIBLE }, { RET_QP_SOLVED, "QP successfully solved", VS_VISIBLE }, { RET_UNABLE_TO_SOLVE_QP, "Problems occured while solving QP", VS_VISIBLE }, { RET_INITIALISATION_STARTED, "Starting problem initialisation...", VS_VISIBLE }, { RET_HOTSTART_FAILED, "Unable to perform homotopy due to internal error", VS_VISIBLE }, { RET_HOTSTART_FAILED_TO_INIT, "Unable to initialise problem", VS_VISIBLE }, { RET_HOTSTART_FAILED_AS_QP_NOT_INITIALISED, "Unable to perform homotopy as previous QP is not solved", VS_VISIBLE }, { RET_ITERATION_STARTED, "Iteration", VS_VISIBLE }, { RET_SHIFT_DETERMINATION_FAILED, "Determination of shift of the QP data failed", VS_VISIBLE }, { RET_STEPDIRECTION_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, { RET_STEPLENGTH_DETERMINATION_FAILED, "Determination of step direction failed", VS_VISIBLE }, { RET_OPTIMAL_SOLUTION_FOUND, "Optimal solution of neighbouring QP found", VS_VISIBLE }, { RET_HOMOTOPY_STEP_FAILED, "Unable to perform homotopy step", VS_VISIBLE }, { RET_HOTSTART_STOPPED_INFEASIBILITY, "Premature homotopy termination because QP is infeasible", VS_VISIBLE }, { RET_HOTSTART_STOPPED_UNBOUNDEDNESS, "Premature homotopy termination because QP is unbounded", VS_VISIBLE }, { RET_WORKINGSET_UPDATE_FAILED, "Unable to update working sets according to initial guesses", VS_VISIBLE }, { RET_MAX_NWSR_REACHED, "Maximum number of working set recalculations performed", VS_VISIBLE }, { RET_CONSTRAINTS_NOT_SPECIFIED, "Problem does comprise constraints! You have to specify new constraints' bounds", VS_VISIBLE }, { RET_INVALID_FACTORISATION_FLAG, "Invalid factorisation flag", VS_VISIBLE }, { RET_UNABLE_TO_SAVE_QPDATA, "Unable to save QP data", VS_VISIBLE }, { RET_STEPDIRECTION_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, { RET_STEPDIRECTION_FAILED_CHOLESKY, "Abnormal termination due to Cholesky factorisation", VS_VISIBLE }, { RET_CYCLING_DETECTED, "Cycling detected", VS_VISIBLE }, { RET_CYCLING_NOT_RESOLVED, "Cycling cannot be resolved, QP is probably infeasible", VS_VISIBLE }, { RET_CYCLING_RESOLVED, "Cycling probably resolved", VS_VISIBLE }, { RET_STEPSIZE, "", VS_VISIBLE }, { RET_STEPSIZE_NONPOSITIVE, "", VS_VISIBLE }, { RET_SETUPSUBJECTTOTYPE_FAILED, "Setup of SubjectToTypes failed", VS_VISIBLE }, { RET_ADDCONSTRAINT_FAILED, "Addition of constraint to working set failed", VS_VISIBLE }, { RET_ADDCONSTRAINT_FAILED_INFEASIBILITY, "Addition of constraint to working set failed", VS_VISIBLE }, { RET_ADDBOUND_FAILED, "Addition of bound to working set failed", VS_VISIBLE }, { RET_ADDBOUND_FAILED_INFEASIBILITY, "Addition of bound to working set failed", VS_VISIBLE }, { RET_REMOVECONSTRAINT_FAILED, "Removal of constraint from working set failed", VS_VISIBLE }, { RET_REMOVEBOUND_FAILED, "Removal of bound from working set failed", VS_VISIBLE }, { RET_REMOVE_FROM_ACTIVESET, "Removing from active set:", VS_VISIBLE }, { RET_ADD_TO_ACTIVESET, "Adding to active set:", VS_VISIBLE }, { RET_REMOVE_FROM_ACTIVESET_FAILED, "Removing from active set failed", VS_VISIBLE }, { RET_ADD_TO_ACTIVESET_FAILED, "Adding to active set failed", VS_VISIBLE }, { RET_CONSTRAINT_ALREADY_ACTIVE, "Constraint is already active", VS_VISIBLE }, { RET_ALL_CONSTRAINTS_ACTIVE, "All constraints are active, no further constraint can be added", VS_VISIBLE }, { RET_LINEARLY_DEPENDENT, "New bound/constraint is linearly dependent", VS_VISIBLE }, { RET_LINEARLY_INDEPENDENT, "New bound/constraint is linearly independent", VS_VISIBLE }, { RET_LI_RESOLVED, "Linear independence of active contraint matrix successfully resolved", VS_VISIBLE }, { RET_ENSURELI_FAILED, "Failed to ensure linear indepence of active contraint matrix", VS_VISIBLE }, { RET_ENSURELI_FAILED_TQ, "Abnormal termination due to TQ factorisation", VS_VISIBLE }, { RET_ENSURELI_FAILED_NOINDEX, "No index found, QP is probably infeasible", VS_VISIBLE }, { RET_ENSURELI_FAILED_CYCLING, "Cycling detected, QP is probably infeasible", VS_VISIBLE }, { RET_BOUND_ALREADY_ACTIVE, "Bound is already active", VS_VISIBLE }, { RET_ALL_BOUNDS_ACTIVE, "All bounds are active, no further bound can be added", VS_VISIBLE }, { RET_CONSTRAINT_NOT_ACTIVE, "Constraint is not active", VS_VISIBLE }, { RET_BOUND_NOT_ACTIVE, "Bound is not active", VS_VISIBLE }, { RET_HESSIAN_NOT_SPD, "Projected Hessian matrix not positive definite", VS_VISIBLE }, { RET_MATRIX_SHIFT_FAILED, "Unable to update matrices or to transform vectors", VS_VISIBLE }, { RET_MATRIX_FACTORISATION_FAILED, "Unable to calculate new matrix factorisations", VS_VISIBLE }, { RET_PRINT_ITERATION_FAILED, "Unable to print information on current iteration", VS_VISIBLE }, { RET_NO_GLOBAL_MESSAGE_OUTPUTFILE, "No global message output file initialised", VS_VISIBLE }, /* Utils */ { RET_UNABLE_TO_OPEN_FILE, "Unable to open file", VS_VISIBLE }, { RET_UNABLE_TO_WRITE_FILE, "Unable to write into file", VS_VISIBLE }, { RET_UNABLE_TO_READ_FILE, "Unable to read from file", VS_VISIBLE }, { RET_FILEDATA_INCONSISTENT, "File contains inconsistent data", VS_VISIBLE }, /* SolutionAnalysis */ { RET_NO_SOLUTION, "QP solution does not satisfy KKT optimality conditions", VS_VISIBLE }, { RET_INACCURATE_SOLUTION, "KKT optimality conditions not satisfied to sufficient accuracy", VS_VISIBLE }, { TERMINAL_LIST_ELEMENT, "", VS_HIDDEN } /* IMPORTANT: Terminal list element! */ }; /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * M e s s a g e H a n d l i n g */ MessageHandling::MessageHandling( ) : errorVisibility( VS_VISIBLE ), warningVisibility( VS_VISIBLE ), infoVisibility( VS_VISIBLE ), outputFile( myStdout ), errorCount( 0 ) { } /* * M e s s a g e H a n d l i n g */ MessageHandling::MessageHandling( myFILE* _outputFile ) : errorVisibility( VS_VISIBLE ), warningVisibility( VS_VISIBLE ), infoVisibility( VS_VISIBLE ), outputFile( _outputFile ), errorCount( 0 ) { } /* * M e s s a g e H a n d l i n g */ MessageHandling::MessageHandling( VisibilityStatus _errorVisibility, VisibilityStatus _warningVisibility, VisibilityStatus _infoVisibility ) : errorVisibility( _errorVisibility ), warningVisibility( _warningVisibility ), infoVisibility( _infoVisibility ), outputFile( myStderr ), errorCount( 0 ) { } /* * M e s s a g e H a n d l i n g */ MessageHandling::MessageHandling( myFILE* _outputFile, VisibilityStatus _errorVisibility, VisibilityStatus _warningVisibility, VisibilityStatus _infoVisibility ) : errorVisibility( _errorVisibility ), warningVisibility( _warningVisibility ), infoVisibility( _infoVisibility ), outputFile( _outputFile ), errorCount( 0 ) { } /* * M e s s a g e H a n d l i n g */ MessageHandling::MessageHandling( const MessageHandling& rhs ) : errorVisibility( rhs.errorVisibility ), warningVisibility( rhs.warningVisibility ), infoVisibility( rhs.infoVisibility ), outputFile( rhs.outputFile ), errorCount( rhs.errorCount ) { } /* * ~ M e s s a g e H a n d l i n g */ MessageHandling::~MessageHandling( ) { #ifdef PC_DEBUG if ( outputFile != 0 ) fclose( outputFile ); #endif } /* * o p e r a t o r = */ MessageHandling& MessageHandling::operator=( const MessageHandling& rhs ) { if ( this != &rhs ) { errorVisibility = rhs.errorVisibility; warningVisibility = rhs.warningVisibility; infoVisibility = rhs.infoVisibility; outputFile = rhs.outputFile; errorCount = rhs.errorCount; } return *this; } /* * t h r o w E r r o r */ returnValue MessageHandling::throwError( returnValue Enumber, const char* additionaltext, const char* functionname, const char* filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus ) { /* consistency check */ if ( Enumber <= SUCCESSFUL_RETURN ) return throwError( RET_ERROR_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); /* Call to common throwMessage function if error shall be displayed. */ if ( errorVisibility == VS_VISIBLE ) return throwMessage( Enumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"ERROR" ); else return Enumber; } /* * t h r o w W a r n i n g */ returnValue MessageHandling::throwWarning( returnValue Wnumber, const char* additionaltext, const char* functionname, const char* filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus ) { /* consistency check */ if ( Wnumber <= SUCCESSFUL_RETURN ) return throwError( RET_WARNING_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); /* Call to common throwMessage function if warning shall be displayed. */ if ( warningVisibility == VS_VISIBLE ) return throwMessage( Wnumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"WARNING" ); else return Wnumber; } /* * t h r o w I n f o */ returnValue MessageHandling::throwInfo( returnValue Inumber, const char* additionaltext, const char* functionname, const char* filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus ) { /* consistency check */ if ( Inumber < SUCCESSFUL_RETURN ) return throwError( RET_INFO_UNDEFINED,0,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); /* Call to common throwMessage function if info shall be displayed. */ if ( infoVisibility == VS_VISIBLE ) return throwMessage( Inumber,additionaltext,functionname,filename,linenumber,localVisibilityStatus,"INFO" ); else return Inumber; } /* * r e s e t */ returnValue MessageHandling::reset( ) { setErrorVisibilityStatus( VS_VISIBLE ); setWarningVisibilityStatus( VS_VISIBLE ); setInfoVisibilityStatus( VS_VISIBLE ); setOutputFile( myStderr ); setErrorCount( 0 ); return SUCCESSFUL_RETURN; } /* * l i s t A l l M e s s a g e s */ returnValue MessageHandling::listAllMessages( ) { #ifdef PC_DEBUG int keypos = 0; char myPrintfString[160]; /* Run through whole returnValueList and print each item. */ while ( returnValueList[keypos].key != TERMINAL_LIST_ELEMENT ) { sprintf( myPrintfString," %d - %s \n",keypos,returnValueList[keypos].data ); myPrintf( myPrintfString ); ++keypos; } #endif return SUCCESSFUL_RETURN; } /***************************************************************************** * P R O T E C T E D * *****************************************************************************/ #ifdef PC_DEBUG /* Re-define throwMessage function for embedded code! */ /* * t h r o w M e s s a g e */ returnValue MessageHandling::throwMessage( returnValue RETnumber, const char* additionaltext, const char* functionname, const char* filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus, const char* RETstring ) { int i; int keypos = 0; char myPrintfString[160]; /* 1) Determine number of whitespace for output. */ char whitespaces[41]; int numberOfWhitespaces = (errorCount-1)*2; if ( numberOfWhitespaces < 0 ) numberOfWhitespaces = 0; if ( numberOfWhitespaces > 40 ) numberOfWhitespaces = 40; for( i=0; i 0 ) { sprintf( myPrintfString,"%s->", whitespaces ); myPrintf( myPrintfString ); } if ( additionaltext == 0 ) { sprintf( myPrintfString,"%s (%s, %s:%d): \t%s\n", RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data ); myPrintf( myPrintfString ); } else { sprintf( myPrintfString,"%s (%s, %s:%d): \t%s %s\n", RETstring,functionname,filename,(int)linenumber,returnValueList[keypos].data,additionaltext ); myPrintf( myPrintfString ); } /* take care of proper indention for subsequent error messages */ if ( RETstring[0] == 'E' ) { ++errorCount; } else { if ( errorCount > 0 ) myPrintf( "\n" ); errorCount = 0; } } return RETnumber; } #else /* = PC_DEBUG not defined */ /* * t h r o w M e s s a g e */ returnValue MessageHandling::throwMessage( returnValue RETnumber, const char* additionaltext, const char* functionname, const char* filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus, const char* RETstring ) { /* DUMMY CODE FOR PRETENDING USE OF ARGUMENTS * FOR SUPPRESSING COMPILER WARNINGS! */ int i = 0; if ( additionaltext == 0 ) i++; if ( functionname == 0 ) i++; if ( filename == 0 ) i++; if ( linenumber == 0 ) i++; if ( localVisibilityStatus == VS_VISIBLE ) i++; if ( RETstring == 0 ) i++; /* END OF DUMMY CODE */ return RETnumber; } #endif /* PC_DEBUG */ /***************************************************************************** * G L O B A L M E S S A G E H A N D L E R * *****************************************************************************/ /** Global message handler for all qpOASES modules.*/ MessageHandling globalMessageHandler( myStderr,VS_VISIBLE,VS_VISIBLE,VS_VISIBLE ); /* * g e t G l o b a l M e s s a g e H a n d l e r */ MessageHandling* getGlobalMessageHandler( ) { return &globalMessageHandler; } const char* MessageHandling::getErrorString(int error) { return returnValueList[ error ].data; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/MessageHandling.ipp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/MessageHandling.ipp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of inlined member functions of the MessageHandling class. */ /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * g e t E r r o r V i s i b i l i t y S t a t u s */ inline VisibilityStatus MessageHandling::getErrorVisibilityStatus( ) const { return errorVisibility; } /* * g e t W a r n i n g V i s i b i l i t y S t a t u s */ inline VisibilityStatus MessageHandling::getWarningVisibilityStatus( ) const { return warningVisibility; } /* * g e t I n f o V i s i b i l i t y S t a t u s */ inline VisibilityStatus MessageHandling::getInfoVisibilityStatus( ) const { return infoVisibility; } /* * g e t O u t p u t F i l e */ inline myFILE* MessageHandling::getOutputFile( ) const { return outputFile; } /* * g e t E r r o r C o u n t */ inline int MessageHandling::getErrorCount( ) const { return errorCount; } /* * s e t E r r o r V i s i b i l i t y S t a t u s */ inline void MessageHandling::setErrorVisibilityStatus( VisibilityStatus _errorVisibility ) { errorVisibility = _errorVisibility; } /* * s e t W a r n i n g V i s i b i l i t y S t a t u s */ inline void MessageHandling::setWarningVisibilityStatus( VisibilityStatus _warningVisibility ) { warningVisibility = _warningVisibility; } /* * s e t I n f o V i s i b i l i t y S t a t u s */ inline void MessageHandling::setInfoVisibilityStatus( VisibilityStatus _infoVisibility ) { infoVisibility = _infoVisibility; } /* * s e t O u t p u t F i l e */ inline void MessageHandling::setOutputFile( myFILE* _outputFile ) { outputFile = _outputFile; } /* * s e t E r r o r C o u n t */ inline returnValue MessageHandling::setErrorCount( int _errorCount ) { if ( _errorCount >= 0 ) { errorCount = _errorCount; return SUCCESSFUL_RETURN; } else return RET_INVALID_ARGUMENTS; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/QProblem.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/QProblem.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the QProblem class which is able to use the newly * developed online active set strategy for parametric quadratic programming. */ #include #include void printmatrix2(char *name, double *A, int m, int n) { int i, j; printf("%s = [...\n", name); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) printf(" % 9.4f", A[i*n+j]); printf(",\n"); } printf("];\n"); } //#define __PERFORM_KKT_TEST__ /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * Q P r o b l e m */ QProblem::QProblem( ) : QProblemB( ) { constraints.init( 0 ); sizeT = 0; cyclingManager.init( 0,0 ); } /* * Q P r o b l e m */ QProblem::QProblem( int _nV, int _nC ) : QProblemB( _nV ) { /* consistency checks */ if ( _nV <= 0 ) _nV = 1; if ( _nC < 0 ) { _nC = 0; THROWERROR( RET_INVALID_ARGUMENTS ); } constraints.init( _nC ); sizeT = _nC; if ( _nC > _nV ) sizeT = _nV; cyclingManager.init( _nV,_nC ); } /* * Q P r o b l e m */ QProblem::QProblem( const QProblem& rhs ) : QProblemB( rhs ) { int i, j; int _nV = rhs.bounds.getNV( ); int _nC = rhs.constraints.getNC( ); for( i=0; i<_nC; ++i ) for( j=0; j<_nV; ++j ) A[i*NVMAX + j] = rhs.A[i*NVMAX + j]; for( i=0; i<_nC; ++i ) lbA[i] = rhs.lbA[i]; for( i=0; i<_nC; ++i ) ubA[i] = rhs.ubA[i]; constraints = rhs.constraints; for( i=0; i<(_nV+_nC); ++i ) y[i] = rhs.y[i]; sizeT = rhs.sizeT; for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } /* 1) Setup index arrays. */ if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( constraints.getInactive( )->getNumberArray( IAC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); /* 2) Detemination of shift direction of the gradient and the (constraints') bounds. */ returnvalue = hotstart_determineDataShift( FX_idx, AC_idx, g_new,lbA_new,ubA_new,lb_new,ub_new, delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, Delta_bC_isZero, Delta_bB_isZero ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); return returnvalue; } /* 3) Determination of step direction of X and Y. */ returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx,AC_idx, delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, Delta_bC_isZero, Delta_bB_isZero, delta_xFX,delta_xFR,delta_yAC,delta_yFX ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); return returnvalue; } /* 4) Determination of step length TAU. */ returnvalue = hotstart_determineStepLength( FR_idx,FX_idx,AC_idx,IAC_idx, delta_lbA,delta_ubA,delta_lb,delta_ub, delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, BC_idx,BC_status,BC_isBound ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); return returnvalue; } /* 5) Realisation of the homotopy step. */ returnvalue = hotstart_performStep( FR_idx,FX_idx,AC_idx,IAC_idx, delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub, delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax, BC_idx,BC_status,BC_isBound ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; /* stop runtime measurement */ if ( cputime != 0 ) *cputime = getCPUtime( ) - starttime; /* optimal solution found? */ if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) { status = QPS_SOLVED; if ( printlevel == PL_HIGH ) THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); #ifdef PC_DEBUG if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ #endif /* check KKT optimality conditions */ return checkKKTconditions( ); } else { /* checks for infeasibility... */ if ( isInfeasible( ) == BT_TRUE ) { status = QPS_HOMOTOPYQPSOLVED; return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); } /* ...unboundedness... */ if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); /* ... and throw unspecific error otherwise */ THROWERROR( RET_HOMOTOPY_STEP_FAILED ); return returnvalue; } } /* 6) Output information of successful QP iteration. */ status = QPS_HOMOTOPYQPSOLVED; #ifdef PC_DEBUG if ( printIteration( l,BC_idx,BC_status,BC_isBound ) != SUCCESSFUL_RETURN ) THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ #endif } /* stop runtime measurement */ if ( cputime != 0 ) *cputime = getCPUtime( ) - starttime; /* if programm gets to here, output information that QP could not be solved * within the given maximum numbers of working set changes */ if ( printlevel == PL_HIGH ) { #ifdef PC_DEBUG sprintf( messageString,"(nWSR = %d)",nWSR ); return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } /* Finally check KKT optimality conditions. */ returnValue returnvalueKKTcheck = checkKKTconditions( ); if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) return returnvalueKKTcheck; else return RET_MAX_NWSR_REACHED; } /* * g e t N Z */ int QProblem::getNZ( ) { /* nZ = nFR - nAC */ return bounds.getFree( )->getLength( ) - constraints.getActive( )->getLength( ); } /* * g e t D u a l S o l u t i o n */ returnValue QProblem::getDualSolution( real_t* const yOpt ) const { int i; /* return optimal dual solution vector * only if current QP has been solved */ if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || ( getStatus( ) == QPS_SOLVED ) ) { for( i=0; i -INFTY ) { constraints.setNoLower( BT_FALSE ); break; } } /* 2) Check if upper constraints' bounds are present. */ constraints.setNoUpper( BT_TRUE ); for( i=0; i INFTY - BOUNDTOL ) ) { constraints.setType( i,ST_UNBOUNDED ); ++nUC; } else { if ( lbA[i] > ubA[i] - BOUNDTOL ) { constraints.setType( i,ST_EQUALITY ); ++nEC; } else { constraints.setType( i,ST_BOUNDED ); } } } /* 4) Set dimensions of constraints structure. */ constraints.setNEC( nEC ); constraints.setNUC( nUC ); constraints.setNIC( nC - nEC - nUC ); return SUCCESSFUL_RETURN; } /* * c h o l e s k y D e c o m p o s i t i o n P r o j e c t e d */ returnValue QProblem::setupCholeskyDecompositionProjected( ) { int i, j, k, ii, kk; int nV = getNV( ); int nFR = getNFR( ); int nZ = getNZ( ); /* 1) Initialises R with all zeros. */ for( i=0; i 0 ) { int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INDEXLIST_CORRUPTED ); #if 0 real_t HZ[NVMAX*NVMAX]; real_t ZHZ[NVMAX*NVMAX]; /* calculate H*Z */ for ( i=0; i=0; --k ) sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; if ( sum > 0.0 ) { R[i*NVMAX + i] = sqrt( sum ); inv = 1.0 / R[i * NVMAX + i]; } else { hessianType = HST_SEMIDEF; return THROWERROR( RET_HESSIAN_NOT_SPD ); } for( j=(i+1); j=0; --k ) sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; R[i*NVMAX + j] = sum * inv; } } #else real_t HZ[NVMAX]; real_t ZHZ[NVMAX]; real_t sum, inv; for (j = 0; j < nZ; ++j) { /* Cache one column of Z. */ for (i = 0; i < NVMAX; ++i) ZHZ[i] = Q[i * NVMAX + j]; /* Create one column of the product H * Z. */ for (i = 0; i < nFR; ++i) { ii = FR_idx[i]; sum = 0.0; for (k = 0; k < nFR; ++k) { kk = FR_idx[k]; sum += H[ii * NVMAX + kk] * ZHZ[kk]; } HZ[ii] = sum; } /* Create one column of the product Z^T * H * Z. */ for (i = j; i < nZ; ++i) ZHZ[ i ] = 0.0; for (k = 0; k < nFR; ++k) { kk = FR_idx[k]; real_t q = HZ[kk]; for (i = j; i < nZ; ++i) { ZHZ[i] += Q[kk * NVMAX + i] * q; } } /* Use the computed column to update the factorization. */ /* j == i */ sum = ZHZ[j]; for (k = (j - 1); k >= 0; --k) sum -= R[k * NVMAX + j] * R[k * NVMAX + j]; if (sum > 0.0) { R[j * NVMAX + j] = sqrt(sum); inv = 1.0 / R[j * NVMAX + j]; } else { hessianType = HST_SEMIDEF; return THROWERROR( RET_HESSIAN_NOT_SPD ); } for (i = (j + 1); i < nZ; ++i) { sum = ZHZ[i]; for (k = (j - 1); k >= 0; --k) sum -= R[k * NVMAX + j] * R[k * NVMAX + i]; R[j * NVMAX + i] = sum * inv; } } #endif } } return SUCCESSFUL_RETURN; } /* * s e t u p T Q f a c t o r i s a t i o n */ returnValue QProblem::setupTQfactorisation( ) { int i, j, ii; int nV = getNV( ); int nFR = getNFR( ); int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INDEXLIST_CORRUPTED ); /* 1) Set Q to unity matrix. */ for( i=0; igetStatus( i ); if ( constraints.getType( i ) == ST_EQUALITY ) { if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryConstraints->setupConstraint( i,guessedStatus ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } else /* No initial working set specified. */ { /* Obtain initial working set by "clipping". */ if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) { for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } if ( Ax[i] >= ubA[i] - BOUNDTOL ) { if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } /* Moreover, add all equality constraints if specified. */ if ( constraints.getType( i ) == ST_EQUALITY ) { if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } /* Obtain initial working set in accordance to sign of dual solution vector. */ if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) { for( i=0; i ZERO ) { if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } if ( yOpt[nV+i] < -ZERO ) { if ( auxiliaryConstraints->setupConstraint( i,ST_UPPER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } /* Moreover, add all equality constraints if specified. */ if ( constraints.getType( i ) == ST_EQUALITY ) { if ( auxiliaryConstraints->setupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } /* If xOpt and yOpt are null pointer and no initial working is specified, * start with empty working set (or implicitly fixed bounds and equality constraints only) * for auxiliary QP. */ if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) { for( i=0; isetupConstraint( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryConstraints->setupConstraint( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } } return SUCCESSFUL_RETURN; } /* * s e t u p A u x i l i a r y W o r k i n g S e t */ returnValue QProblem::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, const Constraints* const auxiliaryConstraints, BooleanType setupAfresh ) { int i; int nV = getNV( ); int nC = getNC( ); /* consistency checks */ if ( auxiliaryBounds != 0 ) { for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) return THROWERROR( RET_UNKNOWN_BUG ); } else { return THROWERROR( RET_INVALID_ARGUMENTS ); } if ( auxiliaryConstraints != 0 ) { for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) return THROWERROR( RET_UNKNOWN_BUG ); } else { return THROWERROR( RET_INVALID_ARGUMENTS ); } /* I) SETUP CHOLESKY FLAG: * Cholesky decomposition shall only be updated if working set * shall be updated (i.e. NOT setup afresh!) */ BooleanType updateCholesky; if ( setupAfresh == BT_TRUE ) updateCholesky = BT_FALSE; else updateCholesky = BT_TRUE; /* II) REMOVE FORMERLY ACTIVE (CONSTRAINTS') BOUNDS (IF NECESSARY): */ if ( setupAfresh == BT_FALSE ) { /* 1) Remove all active constraints that shall be inactive AND * all active constraints that are active at the wrong bound. */ for( i=0; igetStatus( i ) != ST_LOWER ) ) if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); if ( ( constraints.getStatus( i ) == ST_UPPER ) && ( auxiliaryConstraints->getStatus( i ) != ST_UPPER ) ) if ( removeConstraint( i,updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); } /* 2) Remove all active bounds that shall be inactive AND * all active bounds that are active at the wrong bound. */ for( i=0; igetStatus( i ) != ST_LOWER ) ) if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); } } /* III) ADD NEWLY ACTIVE (CONSTRAINTS') BOUNDS: */ /* 1) Add all inactive bounds that shall be active AND * all formerly active bounds that have been active at the wrong bound. */ for( i=0; igetStatus( i ) != ST_INACTIVE ) ) { /* Add bound only if it is linearly independent from the current working set. */ if ( addBound_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) { if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); } } } /* 2) Add all inactive constraints that shall be active AND * all formerly active constraints that have been active at the wrong bound. */ for( i=0; igetStatus( i ) == ST_LOWER ) || ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) ) { /* formerly inactive */ if ( constraints.getStatus( i ) == ST_INACTIVE ) { /* Add constraint only if it is linearly independent from the current working set. */ if ( addConstraint_checkLI( i ) == RET_LINEARLY_INDEPENDENT ) { if ( addConstraint( i,auxiliaryConstraints->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); } } } } return SUCCESSFUL_RETURN; } /* * s e t u p A u x i l i a r y Q P s o l u t i o n */ returnValue QProblem::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt ) { int i, j; int nV = getNV( ); int nC = getNC( ); /* Setup primal/dual solution vector for auxiliary initial QP: * if a null pointer is passed, a zero vector is assigned; * old solution vector is kept if pointer to internal solution vevtor is passed. */ if ( xOpt != 0 ) { if ( xOpt != x ) for( i=0; igetStatus( i ) == ST_LOWER ) lb[i] = x[i]; else lb[i] = x[i] - BOUNDRELAXATION; if ( auxiliaryBounds->getStatus( i ) == ST_UPPER ) ub[i] = x[i]; else ub[i] = x[i] + BOUNDRELAXATION; } } break; case ST_LOWER: lb[i] = x[i]; if ( bounds.getType( i ) == ST_EQUALITY ) { ub[i] = x[i]; } else { if ( useRelaxation == BT_TRUE ) ub[i] = x[i] + BOUNDRELAXATION; } break; case ST_UPPER: ub[i] = x[i]; if ( bounds.getType( i ) == ST_EQUALITY ) { lb[i] = x[i]; } else { if ( useRelaxation == BT_TRUE ) lb[i] = x[i] - BOUNDRELAXATION; } break; default: return THROWERROR( RET_UNKNOWN_BUG ); } } /* 2) Setup constraints vectors. */ for ( i=0; igetStatus( i ) == ST_LOWER ) lbA[i] = Ax[i]; else lbA[i] = Ax[i] - BOUNDRELAXATION; if ( auxiliaryConstraints->getStatus( i ) == ST_UPPER ) ubA[i] = Ax[i]; else ubA[i] = Ax[i] + BOUNDRELAXATION; } } break; case ST_LOWER: lbA[i] = Ax[i]; if ( constraints.getType( i ) == ST_EQUALITY ) { ubA[i] = Ax[i]; } else { if ( useRelaxation == BT_TRUE ) ubA[i] = Ax[i] + BOUNDRELAXATION; } break; case ST_UPPER: ubA[i] = Ax[i]; if ( constraints.getType( i ) == ST_EQUALITY ) { lbA[i] = Ax[i]; } else { if ( useRelaxation == BT_TRUE ) lbA[i] = Ax[i] - BOUNDRELAXATION; } break; default: return THROWERROR( RET_UNKNOWN_BUG ); } } return SUCCESSFUL_RETURN; } /* * a d d C o n s t r a i n t */ returnValue QProblem::addConstraint( int number, SubjectToStatus C_status, BooleanType updateCholesky ) { int i, j, ii; /* consistency checks */ if ( constraints.getStatus( number ) != ST_INACTIVE ) return THROWERROR( RET_CONSTRAINT_ALREADY_ACTIVE ); if ( ( constraints.getNC( ) - getNAC( ) ) == constraints.getNUC( ) ) return THROWERROR( RET_ALL_CONSTRAINTS_ACTIVE ); if ( ( getStatus( ) == QPS_NOTINITIALISED ) || ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || ( getStatus( ) == QPS_SOLVED ) ) { return THROWERROR( RET_UNKNOWN_BUG ); } /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, * i.e. remove a constraint or bound if linear dependence occurs. */ /* check for LI only if Cholesky decomposition shall be updated! */ if ( updateCholesky == BT_TRUE ) { returnValue ensureLIreturnvalue = addConstraint_ensureLI( number,C_status ); switch ( ensureLIreturnvalue ) { case SUCCESSFUL_RETURN: break; case RET_LI_RESOLVED: break; case RET_ENSURELI_FAILED_NOINDEX: return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); case RET_ENSURELI_FAILED_CYCLING: return THROWERROR( RET_ADDCONSTRAINT_FAILED_INFEASIBILITY ); default: return THROWERROR( RET_ENSURELI_FAILED ); } } /* some definitions */ int nFR = getNFR( ); int nAC = getNAC( ); int nZ = getNZ( ); int tcol = sizeT - nAC; int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ADDCONSTRAINT_FAILED ); real_t aFR[NVMAX]; real_t wZ[NVMAX]; for( i=0; i 0 ) { for( j=0; j 0 ) { /* II) RESTORE TRIANGULAR FORM OF T: */ /* Use column-wise Givens rotations to restore reverse triangular form * of T, simultanenous change of Q (i.e. Z) and R. */ for( j=0; jgetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INDEXLIST_CORRUPTED ); /* Check if constraint is linearly independent from the the active ones (<=> is element of null space of Afr). */ real_t sum; for( i=0; i 10.0*EPS ) return RET_LINEARLY_INDEPENDENT; } return RET_LINEARLY_DEPENDENT; } /* * a d d C o n s t r a i n t _ e n s u r e L I */ returnValue QProblem::addConstraint_ensureLI( int number, SubjectToStatus C_status ) { int i, j, ii, jj; int nV = getNV( ); int nFR = getNFR( ); int nFX = getNFX( ); int nAC = getNAC( ); int nZ = getNZ( ); /* I) Check if new constraint is linearly independent from the active ones. */ returnValue returnvalueCheckLI = addConstraint_checkLI( number ); if ( returnvalueCheckLI == RET_INDEXLIST_CORRUPTED ) return THROWERROR( RET_ENSURELI_FAILED ); if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) return SUCCESSFUL_RETURN; /* II) NEW CONSTRAINT IS LINEARLY DEPENDENT: */ /* 1) Determine coefficients of linear combination, * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: * An Algorithm for the Solution of the Parametric Quadratic Programming * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ENSURELI_FAILED ); int FX_idx[NVMAX]; if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ENSURELI_FAILED ); real_t xiC[NCMAX_ALLOC]; real_t xiC_TMP[NCMAX_ALLOC]; real_t xiB[NVMAX]; /* 2) Calculate xiC */ if ( nAC > 0 ) { if ( C_status == ST_LOWER ) { for( i=0; igetNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ENSURELI_FAILED ); if ( C_status == ST_LOWER ) { for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) { if ( y[nV+ii]/xiC[i] < y_min ) { y_min = y[nV+ii]/xiC[i]; y_min_number = ii; } } } else { if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) { if ( y[nV+ii]/xiC[i] < y_min ) { y_min = y[nV+ii]/xiC[i]; y_min_number = ii; } } } } /* 2) Bounds. */ for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) { if ( y[ii]/xiB[i] < y_min ) { y_min = y[ii]/xiB[i]; y_min_number = ii; y_min_isBound = BT_TRUE; } } } else { if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) { if ( y[ii]/xiB[i] < y_min ) { y_min = y[ii]/xiB[i]; y_min_number = ii; y_min_isBound = BT_TRUE; } } } } /* setup output preferences */ #ifdef PC_DEBUG char messageString[80]; VisibilityStatus visibilityStatus; if ( printlevel == PL_HIGH ) visibilityStatus = VS_VISIBLE; else visibilityStatus = VS_HIDDEN; #endif /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ if ( y_min_number >= 0 ) { /* 1) Check for cycling due to infeasibility. */ if ( ( cyclingManager.getCyclingStatus( number,BT_FALSE ) == CYC_PREV_REMOVED ) && ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) { infeasible = BT_TRUE; return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); } else { /* set cycling data */ cyclingManager.clearCyclingData( ); cyclingManager.setCyclingStatus( number,BT_FALSE, CYC_PREV_ADDED ); cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); } /* 2) Update Lagrange multiplier... */ for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[y_min_number] = 0.0; } else { #ifdef PC_DEBUG sprintf( messageString,"constraint no. %d.",y_min_number ); getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[nV+y_min_number] = 0.0; } } else { /* no constraint/bound can be removed => QP is infeasible! */ infeasible = BT_TRUE; return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); } return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); } /* * a d d B o u n d */ returnValue QProblem::addBound( int number, SubjectToStatus B_status, BooleanType updateCholesky ) { int i, j, ii; /* consistency checks */ if ( bounds.getStatus( number ) != ST_INACTIVE ) return THROWERROR( RET_BOUND_ALREADY_ACTIVE ); if ( getNFR( ) == bounds.getNUV( ) ) return THROWERROR( RET_ALL_BOUNDS_ACTIVE ); if ( ( getStatus( ) == QPS_NOTINITIALISED ) || ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || ( getStatus( ) == QPS_SOLVED ) ) { return THROWERROR( RET_UNKNOWN_BUG ); } /* I) ENSURE LINEAR INDEPENDENCE OF THE WORKING SET, * i.e. remove a constraint or bound if linear dependence occurs. */ /* check for LI only if Cholesky decomposition shall be updated! */ if ( updateCholesky == BT_TRUE ) { returnValue ensureLIreturnvalue = addBound_ensureLI( number,B_status ); switch ( ensureLIreturnvalue ) { case SUCCESSFUL_RETURN: break; case RET_LI_RESOLVED: break; case RET_ENSURELI_FAILED_NOINDEX: return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); case RET_ENSURELI_FAILED_CYCLING: return THROWERROR( RET_ADDBOUND_FAILED_INFEASIBILITY ); default: return THROWERROR( RET_ENSURELI_FAILED ); } } /* some definitions */ int nFR = getNFR( ); int nAC = getNAC( ); int nZ = getNZ( ); int tcol = sizeT - nAC; /* I) SWAP INDEXLIST OF FREE VARIABLES: * move the variable to be fixed to the end of the list of free variables. */ int lastfreenumber = bounds.getFree( )->getLastNumber( ); if ( lastfreenumber != number ) if ( bounds.swapFree( number,lastfreenumber ) != SUCCESSFUL_RETURN ) THROWERROR( RET_ADDBOUND_FAILED ); int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ADDBOUND_FAILED ); real_t w[NVMAX]; /* II) ADD NEW ACTIVE BOUND TO TOP OF MATRIX T: */ /* 1) add row [wZ wY] = [Z Y](number) at the top of T: assign w */ for( i=0; i 0 ) /* ( nAC == 0 ) <=> ( nZ == nFR ) <=> Y and T are empty => nothing to do */ { /* store new column a in a temporary vector instead of shifting T one column to the left */ real_t tmp[NCMAX_ALLOC]; for( i=0; i is linearly independent from the the active ones (<=> is element of null space of Afr). */ for( i=0; i EPS ) return RET_LINEARLY_INDEPENDENT; } return RET_LINEARLY_DEPENDENT; } /* * a d d B o u n d _ e n s u r e L I */ returnValue QProblem::addBound_ensureLI( int number, SubjectToStatus B_status ) { int i, j, ii, jj; int nV = getNV( ); int nFX = getNFX( ); int nAC = getNAC( ); int nZ = getNZ( ); /* I) Check if new constraint is linearly independent from the active ones. */ returnValue returnvalueCheckLI = addBound_checkLI( number ); if ( returnvalueCheckLI == RET_LINEARLY_INDEPENDENT ) return SUCCESSFUL_RETURN; /* II) NEW BOUND IS LINEARLY DEPENDENT: */ /* 1) Determine coefficients of linear combination, * cf. M.J. Best. Applied Mathematics and Parallel Computing, chapter: * An Algorithm for the Solution of the Parametric Quadratic Programming * Problem, pages 57-76. Physica-Verlag, Heidelberg, 1996. */ int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ENSURELI_FAILED ); int FX_idx[NVMAX]; if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ENSURELI_FAILED ); int AC_idx[NCMAX_ALLOC]; if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ENSURELI_FAILED ); real_t xiC[NCMAX_ALLOC]; real_t xiC_TMP[NCMAX_ALLOC]; real_t xiB[NVMAX]; /* 2) Calculate xiC. */ if ( nAC > 0 ) { if ( B_status == ST_LOWER ) { for( i=0; i ZERO ) && ( y[nV+ii] >= 0.0 ) ) { if ( y[nV+ii]/xiC[i] < y_min ) { y_min = y[nV+ii]/xiC[i]; y_min_number = ii; } } } else { if ( ( xiC[i] < -ZERO ) && ( y[nV+ii] <= 0.0 ) ) { if ( y[nV+ii]/xiC[i] < y_min ) { y_min = y[nV+ii]/xiC[i]; y_min_number = ii; } } } } /* 2) Bounds. */ for( i=0; i ZERO ) && ( y[ii] >= 0.0 ) ) { if ( y[ii]/xiB[i] < y_min ) { y_min = y[ii]/xiB[i]; y_min_number = ii; y_min_isBound = BT_TRUE; } } } else { if ( ( xiB[i] < -ZERO ) && ( y[ii] <= 0.0 ) ) { if ( y[ii]/xiB[i] < y_min ) { y_min = y[ii]/xiB[i]; y_min_number = ii; y_min_isBound = BT_TRUE; } } } } /* setup output preferences */ #ifdef PC_DEBUG char messageString[80]; VisibilityStatus visibilityStatus; if ( printlevel == PL_HIGH ) visibilityStatus = VS_VISIBLE; else visibilityStatus = VS_HIDDEN; #endif /* IV) REMOVE CONSTRAINT/BOUND FOR RESOLVING LINEAR DEPENDENCE: */ if ( y_min_number >= 0 ) { /* 1) Check for cycling due to infeasibility. */ if ( ( cyclingManager.getCyclingStatus( number,BT_TRUE ) == CYC_PREV_REMOVED ) && ( cyclingManager.getCyclingStatus( y_min_number,y_min_isBound ) == CYC_PREV_ADDED ) ) { infeasible = BT_TRUE; return THROWERROR( RET_ENSURELI_FAILED_CYCLING ); } else { /* set cycling data */ cyclingManager.clearCyclingData( ); cyclingManager.setCyclingStatus( number,BT_TRUE, CYC_PREV_ADDED ); cyclingManager.setCyclingStatus( y_min_number,y_min_isBound, CYC_PREV_REMOVED ); } /* 2) Update Lagrange multiplier... */ for( i=0; ithrowInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeBound( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[y_min_number] = 0.0; } else { #ifdef PC_DEBUG sprintf( messageString,"constraint no. %d.",y_min_number ); getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeConstraint( y_min_number,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[nV+y_min_number] = 0.0; } } else { /* no constraint/bound can be removed => QP is infeasible! */ infeasible = BT_TRUE; return THROWERROR( RET_ENSURELI_FAILED_NOINDEX ); } return getGlobalMessageHandler( )->throwInfo( RET_LI_RESOLVED,0,__FUNCTION__,__FILE__,__LINE__,VS_HIDDEN ); } /* * r e m o v e C o n s t r a i n t */ returnValue QProblem::removeConstraint( int number, BooleanType updateCholesky ) { int i, j, ii, jj; /* consistency check */ if ( ( getStatus( ) == QPS_NOTINITIALISED ) || ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || ( getStatus( ) == QPS_SOLVED ) ) { return THROWERROR( RET_UNKNOWN_BUG ); } /* some definitions */ int nFR = getNFR( ); int nAC = getNAC( ); int nZ = getNZ( ); int tcol = sizeT - nAC; int number_idx = constraints.getActive( )->getIndex( number ); /* consistency checks */ if ( constraints.getStatus( number ) == ST_INACTIVE ) return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); if ( ( number_idx < 0 ) || ( number_idx >= nAC ) ) return THROWERROR( RET_CONSTRAINT_NOT_ACTIVE ); int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); /* I) REMOVE th ROW FROM T, * i.e. shift rows number+1 through nAC upwards (instead of the actual * constraint number its corresponding index within matrix A is used). */ if ( number_idx < nAC-1 ) { for( i=(number_idx+1); i=0; --j ) { computeGivens( T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j], T[(nAC-2-j)*NVMAX + tcol+1+j],T[(nAC-2-j)*NVMAX + tcol+j],c,s ); for( i=(nAC-j-1); i<(nAC-1); ++i ) applyGivens( c,s,T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j], T[i*NVMAX + tcol+1+j],T[i*NVMAX + tcol+j] ); for( i=0; i 0 ) { real_t ZHz[NVMAX]; for ( i=0; i 0.0 ) R[nZ*NVMAX + nZ] = sqrt( rho2 ); else { hessianType = HST_SEMIDEF; return THROWERROR( RET_HESSIAN_NOT_SPD ); } } /* IV) UPDATE INDICES */ if ( constraints.moveActiveToInactive( number ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVECONSTRAINT_FAILED ); return SUCCESSFUL_RETURN; } /* * r e m o v e B o u n d */ returnValue QProblem::removeBound( int number, BooleanType updateCholesky ) { int i, j, ii, jj; /* consistency checks */ if ( bounds.getStatus( number ) == ST_INACTIVE ) return THROWERROR( RET_BOUND_NOT_ACTIVE ); if ( ( getStatus( ) == QPS_NOTINITIALISED ) || ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || ( getStatus( ) == QPS_SOLVED ) ) { return THROWERROR( RET_UNKNOWN_BUG ); } /* some definitions */ int nFR = getNFR( ); int nAC = getNAC( ); int nZ = getNZ( ); int tcol = sizeT - nAC; /* I) UPDATE INDICES */ if ( bounds.moveFixedToFree( number ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVEBOUND_FAILED ); int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVEBOUND_FAILED ); /* I) APPEND th UNITY VECOTR TO Q. */ int nnFRp1 = FR_idx[nFR]; for( i=0; i 0 ) { /* store new column a in a temporary vector instead of shifting T one column to the left and appending a */ int AC_idx[NCMAX_ALLOC]; if ( constraints.getActive( )->getNumberArray( AC_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVEBOUND_FAILED ); real_t tmp[NCMAX_ALLOC]; for( i=0; i=0; --j ) { computeGivens( tmp[nAC-1-j],T[(nAC-1-j)*NVMAX + tcol+j],T[(nAC-1-j)*NVMAX + tcol+j],tmp[nAC-1-j],c,s ); for( i=(nAC-j); i 0 ) { real_t Hz[NVMAX]; for( i=0; i 0 ) { real_t r[NVMAX]; real_t rhs[NVMAX]; for( i=0; i 0.0 ) R[nZ*NVMAX + nZ] = sqrt( rho2 ); else { hessianType = HST_SEMIDEF; return THROWERROR( RET_HESSIAN_NOT_SPD ); } } return SUCCESSFUL_RETURN; } /* * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) */ returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, real_t* const a ) { /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ return backsolveR( b,transposed,BT_FALSE,a ); } /* * b a c k s o l v e R (CODE DUPLICATE OF QProblemB CLASS!!!) */ returnValue QProblem::backsolveR( const real_t* const b, BooleanType transposed, BooleanType removingBound, real_t* const a ) { int i, j; int nR = getNZ( ); real_t sum; /* if backsolve is called while removing a bound, reduce nZ by one. */ if ( removingBound == BT_TRUE ) --nR; /* nothing to do */ if ( nR <= 0 ) return SUCCESSFUL_RETURN; /* Solve Ra = b, where R might be transposed. */ if ( transposed == BT_FALSE ) { /* solve Ra = b */ for( i=(nR-1); i>=0; --i ) { sum = b[i]; for( j=(i+1); j ZERO ) a[i] = sum / R[i*NVMAX + i]; else return THROWERROR( RET_DIV_BY_ZERO ); } } else { /* solve R^T*a = b */ for( i=0; i ZERO ) a[i] = sum / R[i*NVMAX + i]; else return THROWERROR( RET_DIV_BY_ZERO ); } } return SUCCESSFUL_RETURN; } /* * b a c k s o l v e T */ returnValue QProblem::backsolveT( const real_t* const b, BooleanType transposed, real_t* const a ) { int i, j; int nT = getNAC( ); int tcol = sizeT - nT; real_t sum; /* nothing to do */ if ( nT <= 0 ) return SUCCESSFUL_RETURN; /* Solve Ta = b, where T might be transposed. */ if ( transposed == BT_FALSE ) { /* solve Ta = b */ for( i=0; i ZERO ) a[nT-1-i] = sum / T[i*NVMAX + sizeT-1-i]; else return THROWERROR( RET_DIV_BY_ZERO ); } } else { /* solve T^T*a = b */ for( i=0; i ZERO ) a[nT-1-i] = sum / T[(nT-1-i)*NVMAX + tcol+i]; else return THROWERROR( RET_DIV_BY_ZERO ); } } return SUCCESSFUL_RETURN; } /* * h o t s t a r t _ d e t e r m i n e D a t a S h i f t */ returnValue QProblem::hotstart_determineDataShift( const int* const FX_idx, const int* const AC_idx, const real_t* const g_new, const real_t* const lbA_new, const real_t* const ubA_new, const real_t* const lb_new, const real_t* const ub_new, real_t* const delta_g, real_t* const delta_lbA, real_t* const delta_ubA, real_t* const delta_lb, real_t* const delta_ub, BooleanType& Delta_bC_isZero, BooleanType& Delta_bB_isZero ) { int i, ii; int nC = getNC( ); int nAC = getNAC( ); /* I) DETERMINE DATA SHIFT FOR BOUNDS */ QProblemB::hotstart_determineDataShift( FX_idx,g_new,lb_new,ub_new, delta_g,delta_lb,delta_ub, Delta_bB_isZero ); /* II) DETERMINE DATA SHIFT FOR CONSTRAINTS */ /* 1) Calculate shift directions. */ for( i=0; i EPS ) || ( getAbs( delta_ubA[ii] ) > EPS ) ) { Delta_bC_isZero = BT_FALSE; break; } } return SUCCESSFUL_RETURN; } /* * h o t s t a r t _ d e t e r m i n e S t e p D i r e c t i o n */ returnValue QProblem::hotstart_determineStepDirection( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, const real_t* const delta_lb, const real_t* const delta_ub, BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero, real_t* const delta_xFX, real_t* const delta_xFR, real_t* const delta_yAC, real_t* const delta_yFX ) { int i, j, ii, jj; int nFR = getNFR( ); int nFX = getNFX( ); int nAC = getNAC( ); int nZ = getNZ( ); /* initialise auxiliary vectors */ real_t HMX_delta_xFX[NVMAX]; real_t YFR_delta_xFRy[NVMAX]; real_t ZFR_delta_xFRz[NVMAX]; real_t HFR_YFR_delta_xFRy[NVMAX]; for( i=0; i 0 ) { for( i=0; i 0 ) { /* 1) Determine delta_xFRy. */ if ( nAC > 0 ) { if ( ( Delta_bC_isZero == BT_TRUE ) && ( Delta_bB_isZero == BT_TRUE ) ) { for( i=0; i 0 ) { for( i=0; i 0 ) { if ( ( Delta_bC_isZero == BT_FALSE ) || ( Delta_bB_isZero == BT_FALSE ) ) { for( i=0; i 0 ) { /* auxiliary variable */ real_t delta_xFRz_TMP[NVMAX]; real_t delta_xFRz_RHS[NVMAX]; if ( ( nAC > 0 ) && ( nFX > 0 ) && ( Delta_bB_isZero == BT_FALSE ) ) { for( j=0; j 0 ) /* => Delta_bB_isZero == BT_TRUE, as BT_FALSE would imply nFX>0 */ { for( j=0; j 0 ) /* => ( nFR = nZ + nAC > 0 ) */ { /* auxiliary variables */ real_t delta_yAC_TMP[NCMAX_ALLOC]; for( i=0; i 0 ) { for( i=0; i 0 ) { if ( Delta_bB_isZero == BT_FALSE ) { for( i=0; i 0 ) { for( i=0; i 0.0 ) maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); else maxStepLength[nV+ii] = 0.0; } } else { /* active upper constraints' bounds */ if ( delta_yAC[i] > ZERO ) { if ( y[nV+ii] < 0.0 ) maxStepLength[nV+ii] = y[nV+ii] / ( -delta_yAC[i] ); else maxStepLength[nV+ii] = 0.0; } } } } /* 2) Ensure that active dual bounds remain valid * (ignoring implicitly fixed variables). */ for( i=0; i 0.0 ) maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); else maxStepLength[ii] = 0.0; } } else { /* active upper bounds */ if ( delta_yFX[i] > ZERO ) { if ( y[ii] < 0.0 ) maxStepLength[ii] = y[ii] / ( -delta_yFX[i] ); else maxStepLength[ii] = 0.0; } } } } /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH */ /* 1) Ensure that inactive constraints' bounds remain valid * (ignoring unbounded constraints). */ real_t delta_x[NVMAX]; for( j=0; j delta_Ax[ii] ) { if ( Ax[ii] > lbA[ii] ) maxStepLength[nV+ii] = ( Ax[ii] - lbA[ii] ) / ( delta_lbA[ii] - delta_Ax[ii] ); else maxStepLength[nV+ii] = 0.0; } } /* inactive upper constraints' bounds */ if ( constraints.isNoUpper( ) == BT_FALSE ) { if ( delta_ubA[ii] < delta_Ax[ii] ) { if ( Ax[ii] < ubA[ii] ) maxStepLength[nV+nC+nV+ii] = ( Ax[ii] - ubA[ii] ) / ( delta_ubA[ii] - delta_Ax[ii] ); else maxStepLength[nV+nC+nV+ii] = 0.0; } } } } /* 2) Ensure that inactive bounds remain valid * (ignoring unbounded variables). */ /* inactive lower bounds */ if ( bounds.isNoLower( ) == BT_FALSE ) { for( i=0; i delta_xFR[i] ) { if ( x[ii] > lb[ii] ) maxStepLength[ii] = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); else maxStepLength[ii] = 0.0; } } } /* inactive upper bounds */ if ( bounds.isNoUpper( ) == BT_FALSE ) { for( i=0; i EPS ) cyclingManager.clearCyclingData( ); /* V) SET MAXIMUM HOMOTOPY STEPLENGTH */ tau = tau_new; #ifdef PC_DEBUG if ( printlevel == PL_HIGH ) { char messageString[80]; if ( BC_status == ST_UNDEFINED ) sprintf( messageString,"Stepsize is %.6e!",tau ); else sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_isBound = %d, BC_status = %d)",tau,BC_idx,BC_isBound,BC_status ); getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } #endif return SUCCESSFUL_RETURN; } /* * h o t s t a r t _ p e r f o r m S t e p */ returnValue QProblem::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, const int* const AC_idx, const int* const IAC_idx, const real_t* const delta_g, const real_t* const delta_lbA, const real_t* const delta_ubA, const real_t* const delta_lb, const real_t* const delta_ub, const real_t* const delta_xFX, const real_t* const delta_xFR, const real_t* const delta_yAC, const real_t* const delta_yFX, const real_t* const delta_Ax, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound ) { int i, j, ii; int nV = getNV( ); int nC = getNC( ); int nFR = getNFR( ); int nFX = getNFX( ); int nAC = getNAC( ); int nIAC = getNIAC( ); /* I) CHECK (CONSTRAINTS') BOUNDS' CONSISTENCY */ if ( areBoundsConsistent( delta_lb,delta_ub,delta_lbA,delta_ubA ) == BT_FALSE ) { infeasible = BT_TRUE; tau = 0.0; return THROWERROR( RET_QP_INFEASIBLE ); } /* II) GO TO ACTIVE SET CHANGE */ if ( tau > ZERO ) { /* 1) Perform step in primal und dual space... */ for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } /* setup output preferences */ #ifdef PC_DEBUG char messageString[80]; VisibilityStatus visibilityStatus; if ( printlevel == PL_HIGH ) visibilityStatus = VS_VISIBLE; else visibilityStatus = VS_HIDDEN; #endif /* III) UPDATE ACTIVE SET */ switch ( BC_status ) { /* Optimal solution found as no working set change detected. */ case ST_UNDEFINED: return RET_OPTIMAL_SOLUTION_FOUND; /* Remove one variable from active set. */ case ST_INACTIVE: if ( BC_isBound == BT_TRUE ) { #ifdef PC_DEBUG sprintf( messageString,"bound no. %d.", BC_idx ); getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[BC_idx] = 0.0; } else { #ifdef PC_DEBUG sprintf( messageString,"constraint no. %d.", BC_idx ); getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeConstraint( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[nV+BC_idx] = 0.0; } break; /* Add one variable to active set. */ default: if ( BC_isBound == BT_TRUE ) { #ifdef PC_DEBUG if ( BC_status == ST_LOWER ) sprintf( messageString,"lower bound no. %d.", BC_idx ); else sprintf( messageString,"upper bound no. %d.", BC_idx ); getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); } else { #ifdef PC_DEBUG if ( BC_status == ST_LOWER ) sprintf( messageString,"lower constraint's bound no. %d.", BC_idx ); else sprintf( messageString,"upper constraint's bound no. %d.", BC_idx ); getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( addConstraint( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); } break; } return SUCCESSFUL_RETURN; } /* * a r e B o u n d s C o n s i s t e n t */ BooleanType QProblem::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub, const real_t* const delta_lbA, const real_t* const delta_ubA ) const { int i; /* 1) Check bounds' consistency. */ if ( QProblemB::areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) return BT_FALSE; /* 2) Check constraints' consistency, i.e. * check if delta_lb[i] is greater than delta_ub[i] * for a component i whose bounds are already (numerically) equal. */ for( i=0; i ubA[i] - BOUNDTOL ) && ( delta_lbA[i] > delta_ubA[i] + EPS ) ) return BT_FALSE; return BT_TRUE; } /* * s e t u p Q P d a t a */ returnValue QProblem::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, const real_t* const _A, const real_t* const _lb, const real_t* const _ub, const real_t* const _lbA, const real_t* const _ubA ) { int i, j; int nV = getNV( ); int nC = getNC( ); /* 1) Load Hessian matrix as well as lower and upper bounds vectors. */ if (QProblemB::setupQPdata(_H, _R, _g, _lb, _ub) != SUCCESSFUL_RETURN) return THROWERROR( RET_INVALID_ARGUMENTS ); /* 2) Load constraint matrix. */ if ( ( nC > 0 ) && ( _A == 0 ) ) return THROWERROR( RET_INVALID_ARGUMENTS ); if ( nC > 0 ) { for( i=0; igetNumberArray( AC_idx ); /* 1) check for Hx + g - [yFX yAC]*[Id A]' = 0. */ for( i=0; i maxKKTviolation ) maxKKTviolation = getAbs( tmp ); } /* 2) Check for [lb lbA] <= [Id A]*x <= [ub ubA]. */ /* lbA <= Ax <= ubA */ for( i=0; i maxKKTviolation ) maxKKTviolation = lbA[i] - Ax[i]; if ( Ax[i] - ubA[i] > maxKKTviolation ) maxKKTviolation = Ax[i] - ubA[i]; } /* lb <= x <= ub */ for( i=0; i maxKKTviolation ) maxKKTviolation = lb[i] - x[i]; if ( x[i] - ub[i] > maxKKTviolation ) maxKKTviolation = x[i] - ub[i]; } /* 3) Check for correct sign of y and for complementary slackness. */ /* bounds */ for( i=0; i maxKKTviolation ) maxKKTviolation = -y[i]; if ( getAbs( x[i] - lb[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( x[i] - lb[i] ); break; case ST_UPPER: if ( y[i] > maxKKTviolation ) maxKKTviolation = y[i]; if ( getAbs( ub[i] - x[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( ub[i] - x[i] ); break; default: /* inactive */ if ( getAbs( y[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( y[i] ); break; } } /* constraints */ for( i=0; i maxKKTviolation ) maxKKTviolation = -y[nV+i]; if ( getAbs( Ax[i] - lbA[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( Ax[i] - lbA[i] ); break; case ST_UPPER: if ( y[nV+i] > maxKKTviolation ) maxKKTviolation = y[nV+i]; if ( getAbs( ubA[i] - Ax[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( ubA[i] - Ax[i] ); break; default: /* inactive */ if ( getAbs( y[nV+i] ) > maxKKTviolation ) maxKKTviolation = getAbs( y[nV+i] ); break; } } if ( maxKKTviolation > CRITICALACCURACY ) return RET_NO_SOLUTION; if ( maxKKTviolation > DESIREDACCURACY ) return RET_INACCURATE_SOLUTION; #endif /* __PERFORM_KKT_TEST__ */ return SUCCESSFUL_RETURN; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/QProblem.ipp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/QProblem.ipp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of inlined member functions of the QProblem class which * is able to use the newly developed online active set strategy for * parametric quadratic programming. */ /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * g e t A */ inline returnValue QProblem::getA( real_t* const _A ) const { int i; for ( i=0; i= 0 ) && ( number < getNC( ) ) ) { for ( int i=0; i= 0 ) && ( number < getNC( ) ) ) { value = lbA[number]; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } /* * g e t U B A */ inline returnValue QProblem::getUBA( real_t* const _ubA ) const { int i; for ( i=0; i= 0 ) && ( number < getNC( ) ) ) { value = ubA[number]; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } /* * g e t C o n s t r a i n t s */ inline returnValue QProblem::getConstraints( Constraints* const _constraints ) const { *_constraints = constraints; return SUCCESSFUL_RETURN; } /* * g e t N C */ inline int QProblem::getNC( ) const { return constraints.getNC( ); } /* * g e t N E C */ inline int QProblem::getNEC( ) const { return constraints.getNEC( ); } /* * g e t N A C */ inline int QProblem::getNAC( ) { return constraints.getNAC( ); } /* * g e t N I A C */ inline int QProblem::getNIAC( ) { return constraints.getNIAC( ); } /***************************************************************************** * P R O T E C T E D * *****************************************************************************/ /* * s e t A */ inline returnValue QProblem::setA( const real_t* const A_new ) { int i, j; int nV = getNV( ); int nC = getNC( ); /* Set constraint matrix AND update member AX. */ for( j=0; j= 0 ) && ( number < getNC( ) ) ) { Ax[number] = 0.0; for( i=0; i= 0 ) && ( number < getNC( ) ) ) { lbA[number] = value; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } /* * s e t U B A */ inline returnValue QProblem::setUBA( const real_t* const ubA_new ) { int i; int nC = getNC(); for( i=0; i= 0 ) && ( number < getNC( ) ) ) { ubA[number] = value; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/QProblemB.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/QProblemB.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the QProblemB class which is able to use the newly * developed online active set strategy for parametric quadratic programming. */ #include #include void printmatrix(char *name, double *A, int m, int n) { int i, j; printf("%s = [...\n", name); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) printf(" % 9.4f", A[i*n+j]); printf(",\n"); } printf("];\n"); } /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * Q P r o b l e m B */ QProblemB::QProblemB( ) { /* reset global message handler */ getGlobalMessageHandler( )->reset( ); hasHessian = BT_FALSE; bounds.init( 0 ); hasCholesky = BT_FALSE; tau = 0.0; hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ infeasible = BT_FALSE; unbounded = BT_FALSE; status = QPS_NOTINITIALISED; #ifdef PC_DEBUG printlevel = PL_MEDIUM; setPrintLevel( PL_MEDIUM ); #else printlevel = QPOASES_PRINTLEVEL; #endif count = 0; } /* * Q P r o b l e m B */ QProblemB::QProblemB( int _nV ) { /* consistency check */ if ( _nV <= 0 ) { _nV = 1; THROWERROR( RET_INVALID_ARGUMENTS ); } hasHessian = BT_FALSE; /* reset global message handler */ getGlobalMessageHandler( )->reset( ); bounds.init( _nV ); hasCholesky = BT_FALSE; tau = 0.0; hessianType = HST_POSDEF_NULLSPACE; /* Hessian is assumed to be positive definite by default */ infeasible = BT_FALSE; unbounded = BT_FALSE; status = QPS_NOTINITIALISED; #ifdef PC_DEBUG printlevel = PL_MEDIUM; setPrintLevel( PL_MEDIUM ); #else printlevel = QPOASES_PRINTLEVEL; #endif count = 0; } /* * Q P r o b l e m B */ QProblemB::QProblemB( const QProblemB& rhs ) { int i, j; int _nV = rhs.bounds.getNV( ); for( i=0; i<_nV; ++i ) for( j=0; j<_nV; ++j ) H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; hasHessian = rhs.hasHessian; for( i=0; i<_nV; ++i ) g[i] = rhs.g[i]; for( i=0; i<_nV; ++i ) lb[i] = rhs.lb[i]; for( i=0; i<_nV; ++i ) ub[i] = rhs.ub[i]; bounds = rhs.bounds; for( i=0; i<_nV; ++i ) for( j=0; j<_nV; ++j ) R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; hasCholesky = rhs.hasCholesky; for( i=0; i<_nV; ++i ) x[i] = rhs.x[i]; for( i=0; i<_nV; ++i ) y[i] = rhs.y[i]; tau = rhs.tau; hessianType = rhs.hessianType; infeasible = rhs.infeasible; unbounded = rhs.unbounded; status = rhs.status; printlevel = rhs.printlevel; count = rhs.count; } /* * ~ Q P r o b l e m B */ QProblemB::~QProblemB( ) { } /* * o p e r a t o r = */ QProblemB& QProblemB::operator=( const QProblemB& rhs ) { int i, j; if ( this != &rhs ) { int _nV = rhs.bounds.getNV( ); for( i=0; i<_nV; ++i ) for( j=0; j<_nV; ++j ) H[i*NVMAX + j] = rhs.H[i*NVMAX + j]; hasHessian = rhs.hasHessian; for( i=0; i<_nV; ++i ) g[i] = rhs.g[i]; for( i=0; i<_nV; ++i ) lb[i] = rhs.lb[i]; for( i=0; i<_nV; ++i ) ub[i] = rhs.ub[i]; bounds = rhs.bounds; for( i=0; i<_nV; ++i ) for( j=0; j<_nV; ++j ) R[i*NVMAX + j] = rhs.R[i*NVMAX + j]; hasCholesky = rhs.hasCholesky; for( i=0; i<_nV; ++i ) x[i] = rhs.x[i]; for( i=0; i<_nV; ++i ) y[i] = rhs.y[i]; tau = rhs.tau; hessianType = rhs.hessianType; infeasible = rhs.infeasible; unbounded = rhs.unbounded; status = rhs.status; printlevel = rhs.printlevel; setPrintLevel( rhs.printlevel ); count = rhs.count; } return *this; } /* * r e s e t */ returnValue QProblemB::reset( ) { int i, j; int nV = getNV( ); /** 0) Reset has Hessian flag. */ hasHessian = BT_FALSE; /* 1) Reset bounds. */ bounds.init( nV ); /* 2) Reset Cholesky decomposition. */ for( i=0; ithrowInfo( RET_ITERATION_STARTED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } /* 1) Setup index arrays. */ if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); if ( bounds.getFixed( )->getNumberArray( FX_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_HOTSTART_FAILED ); /* 2) Initialize shift direction of the gradient and the bounds. */ returnvalue = hotstart_determineDataShift( FX_idx, g_new,lb_new,ub_new, delta_g,delta_lb,delta_ub, Delta_bB_isZero ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; THROWERROR( RET_SHIFT_DETERMINATION_FAILED ); return returnvalue; } /* 3) Determination of step direction of X and Y. */ returnvalue = hotstart_determineStepDirection( FR_idx,FX_idx, delta_g,delta_lb,delta_ub, Delta_bB_isZero, delta_xFX,delta_xFR,delta_yFX ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; THROWERROR( RET_STEPDIRECTION_DETERMINATION_FAILED ); return returnvalue; } /* 4) Determination of step length TAU. */ returnvalue = hotstart_determineStepLength( FR_idx,FX_idx, delta_lb,delta_ub, delta_xFR,delta_yFX, BC_idx,BC_status ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; THROWERROR( RET_STEPLENGTH_DETERMINATION_FAILED ); return returnvalue; } /* 5) Realization of the homotopy step. */ returnvalue = hotstart_performStep( FR_idx,FX_idx, delta_g,delta_lb,delta_ub, delta_xFX,delta_xFR,delta_yFX, BC_idx,BC_status ); if ( returnvalue != SUCCESSFUL_RETURN ) { nWSR = l; /* stop runtime measurement */ if ( cputime != 0 ) *cputime = getCPUtime( ) - starttime; /* optimal solution found? */ if ( returnvalue == RET_OPTIMAL_SOLUTION_FOUND ) { status = QPS_SOLVED; if ( printlevel == PL_HIGH ) THROWINFO( RET_OPTIMAL_SOLUTION_FOUND ); #ifdef PC_DEBUG if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ #endif /* check KKT optimality conditions */ return checkKKTconditions( ); } else { /* checks for infeasibility... */ if ( infeasible == BT_TRUE ) { status = QPS_HOMOTOPYQPSOLVED; return THROWERROR( RET_HOTSTART_STOPPED_INFEASIBILITY ); } /* ...unboundedness... */ if ( unbounded == BT_TRUE ) /* not necessary since objective function convex! */ return THROWERROR( RET_HOTSTART_STOPPED_UNBOUNDEDNESS ); /* ... and throw unspecific error otherwise */ THROWERROR( RET_HOMOTOPY_STEP_FAILED ); return returnvalue; } } /* 6) Output information of successful QP iteration. */ status = QPS_HOMOTOPYQPSOLVED; #ifdef PC_DEBUG if ( printIteration( l,BC_idx,BC_status ) != SUCCESSFUL_RETURN ) THROWERROR( RET_PRINT_ITERATION_FAILED ); /* do not pass this as return value! */ #endif } /* stop runtime measurement */ if ( cputime != 0 ) *cputime = getCPUtime( ) - starttime; /* if programm gets to here, output information that QP could not be solved * within the given maximum numbers of working set changes */ if ( printlevel == PL_HIGH ) { #ifdef PC_DEBUG sprintf( messageString,"(nWSR = %d)",nWSR ); return getGlobalMessageHandler( )->throwWarning( RET_MAX_NWSR_REACHED,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } /* Finally check KKT optimality conditions. */ returnValue returnvalueKKTcheck = checkKKTconditions( ); if ( returnvalueKKTcheck != SUCCESSFUL_RETURN ) return returnvalueKKTcheck; else return RET_MAX_NWSR_REACHED; } /* * g e t N Z */ int QProblemB::getNZ( ) { /* if no constraints are present: nZ=nFR */ return bounds.getFree( )->getLength( ); } /* * g e t O b j V a l */ real_t QProblemB::getObjVal( ) const { real_t objVal; /* calculated optimal objective function value * only if current QP has been solved */ if ( ( getStatus( ) == QPS_AUXILIARYQPSOLVED ) || ( getStatus( ) == QPS_HOMOTOPYQPSOLVED ) || ( getStatus( ) == QPS_SOLVED ) ) { objVal = getObjVal( x ); } else { objVal = INFTY; } return objVal; } /* * g e t O b j V a l */ real_t QProblemB::getObjVal( const real_t* const _x ) const { int i, j; int nV = getNV( ); real_t obj_tmp = 0.0; for( i=0; i= PL_MEDIUM ) && ( printlevel != _printlevel ) ) THROWINFO( RET_PRINTLEVEL_CHANGED ); #endif printlevel = _printlevel; /* update message handler preferences */ switch ( printlevel ) { case PL_NONE: getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_HIDDEN ); getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); break; case PL_LOW: getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_HIDDEN ); getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_HIDDEN ); break; default: /* PL_MEDIUM, PL_HIGH */ getGlobalMessageHandler( )->setErrorVisibilityStatus( VS_VISIBLE ); getGlobalMessageHandler( )->setWarningVisibilityStatus( VS_VISIBLE ); getGlobalMessageHandler( )->setInfoVisibilityStatus( VS_VISIBLE ); break; } return SUCCESSFUL_RETURN; } /***************************************************************************** * P R O T E C T E D * *****************************************************************************/ /* * c h e c k F o r I d e n t i t y H e s s i a n */ returnValue QProblemB::checkForIdentityHessian( ) { int i, j; int nV = getNV( ); /* nothing to do as status flag remains unaltered * if Hessian differs from identity matrix */ if ( hessianType == HST_IDENTITY ) return SUCCESSFUL_RETURN; /* 1) If Hessian differs from identity matrix, * return without changing the internal HessianType. */ for ( i=0; i EPS ) return SUCCESSFUL_RETURN; for ( i=0; i EPS ) || ( getAbs( H[j*NVMAX + i] ) > EPS ) ) return SUCCESSFUL_RETURN; } /* 2) If this point is reached, Hessian equals the idetity matrix. */ hessianType = HST_IDENTITY; return SUCCESSFUL_RETURN; } /* * s e t u p S u b j e c t T o T y p e */ returnValue QProblemB::setupSubjectToType( ) { int i; int nV = getNV( ); /* 1) Check if lower bounds are present. */ bounds.setNoLower( BT_TRUE ); for( i=0; i -INFTY ) { bounds.setNoLower( BT_FALSE ); break; } /* 2) Check if upper bounds are present. */ bounds.setNoUpper( BT_TRUE ); for( i=0; i INFTY - BOUNDTOL ) ) { bounds.setType( i,ST_UNBOUNDED ); ++nUV; } else { if ( lb[i] > ub[i] - BOUNDTOL ) { bounds.setType( i,ST_EQUALITY ); ++nFV; } else { bounds.setType( i,ST_BOUNDED ); } } /* 4) Set dimensions of bounds structure. */ bounds.setNFV( nFV ); bounds.setNUV( nUV ); bounds.setNBV( nV - nFV - nUV ); return SUCCESSFUL_RETURN; } /* * c h o l e s k y D e c o m p o s i t i o n */ returnValue QProblemB::setupCholeskyDecomposition( ) { int i, j, k, ii, jj; int nV = getNV( ); int nFR = getNFR( ); /* If Hessian flag is false, it means that H & R already contain Cholesky * factorization -- provided from outside. */ if (hasHessian == BT_FALSE) return SUCCESSFUL_RETURN; /* 1) Initialises R with all zeros. */ for( i=0; i 0 ) { int FR_idx[NVMAX]; if ( bounds.getFree( )->getNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INDEXLIST_CORRUPTED ); /* R'*R = H */ real_t sum; real_t inv; for( i=0; i=0; --k ) sum -= R[k*NVMAX + i] * R[k*NVMAX + i]; if ( sum > 0.0 ) { R[i*NVMAX + i] = sqrt( sum ); inv = 1.0 / R[i*NVMAX + i]; } else { hessianType = HST_SEMIDEF; return THROWERROR( RET_HESSIAN_NOT_SPD ); } /* j > i */ for( j=(i+1); j=0; --k ) sum -= R[k*NVMAX + i] * R[k*NVMAX + j]; R[i*NVMAX + j] = sum * inv; } } } } return SUCCESSFUL_RETURN; } /* * s o l v e I n i t i a l Q P */ returnValue QProblemB::solveInitialQP( const real_t* const xOpt, const real_t* const yOpt, const Bounds* const guessedBounds, int& nWSR, real_t* const cputime ) { int i, nFR; int nV = getNV( ); /* start runtime measurement */ real_t starttime = 0.0; if ( cputime != 0 ) starttime = getCPUtime( ); status = QPS_NOTINITIALISED; /* I) ANALYSE QP DATA: */ /* 1) Check if Hessian happens to be the identity matrix. */ if ( checkForIdentityHessian( ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INIT_FAILED ); /* 2) Setup type of bounds (i.e. unbounded, implicitly fixed etc.). */ if ( setupSubjectToType( ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INIT_FAILED ); status = QPS_PREPARINGAUXILIARYQP; /* II) SETUP AUXILIARY QP WITH GIVEN OPTIMAL SOLUTION: */ /* 1) Setup bounds data structure. */ if ( bounds.setupAllFree( ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INIT_FAILED ); /* 2) Setup optimal primal/dual solution for auxiliary QP. */ if ( setupAuxiliaryQPsolution( xOpt,yOpt ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INIT_FAILED ); /* 3) Obtain linear independent working set for auxiliary QP. */ static Bounds auxiliaryBounds; auxiliaryBounds.init( nV ); if ( obtainAuxiliaryWorkingSet( xOpt,yOpt,guessedBounds, &auxiliaryBounds ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INIT_FAILED ); /* 4) Setup working set of auxiliary QP and setup cholesky decomposition. */ if ( setupAuxiliaryWorkingSet( &auxiliaryBounds,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_INIT_FAILED ); nFR = getNFR(); /* At the moment we can only provide a Cholesky of the Hessian if * the solver is cold-started. */ if (hasCholesky == BT_FALSE || nFR != nV) if (setupCholeskyDecomposition() != SUCCESSFUL_RETURN) return THROWERROR( RET_INIT_FAILED_CHOLESKY ); /* 5) Store original QP formulation... */ real_t g_original[NVMAX]; real_t lb_original[NVMAX]; real_t ub_original[NVMAX]; for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryBounds->setupBound( i,guessedBounds->getStatus( i ) ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } else /* No initial working set specified. */ { if ( ( xOpt != 0 ) && ( yOpt == 0 ) ) { /* Obtain initial working set by "clipping". */ for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } if ( xOpt[i] >= ub[i] - BOUNDTOL ) { if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } /* Moreover, add all implictly fixed variables if specified. */ if ( bounds.getType( i ) == ST_EQUALITY ) { if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } if ( ( xOpt == 0 ) && ( yOpt != 0 ) ) { /* Obtain initial working set in accordance to sign of dual solution vector. */ for( i=0; i ZERO ) { if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } if ( yOpt[i] < -ZERO ) { if ( auxiliaryBounds->setupBound( i,ST_UPPER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); continue; } /* Moreover, add all implictly fixed variables if specified. */ if ( bounds.getType( i ) == ST_EQUALITY ) { if ( auxiliaryBounds->setupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } /* If xOpt and yOpt are null pointer and no initial working is specified, * start with empty working set (or implicitly fixed bounds only) * for auxiliary QP. */ if ( ( xOpt == 0 ) && ( yOpt == 0 ) ) { for( i=0; isetupBound( i,ST_LOWER ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } else { if ( auxiliaryBounds->setupBound( i,ST_INACTIVE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_OBTAINING_WORKINGSET_FAILED ); } } } } return SUCCESSFUL_RETURN; } /* * s e t u p A u x i l i a r y W o r k i n g S e t */ returnValue QProblemB::setupAuxiliaryWorkingSet( const Bounds* const auxiliaryBounds, BooleanType setupAfresh ) { int i; int nV = getNV( ); /* consistency checks */ if ( auxiliaryBounds != 0 ) { for( i=0; igetStatus( i ) == ST_UNDEFINED ) ) return THROWERROR( RET_UNKNOWN_BUG ); } else { return THROWERROR( RET_INVALID_ARGUMENTS ); } /* I) SETUP CHOLESKY FLAG: * Cholesky decomposition shall only be updated if working set * shall be updated (i.e. NOT setup afresh!) */ BooleanType updateCholesky; if ( setupAfresh == BT_TRUE ) updateCholesky = BT_FALSE; else updateCholesky = BT_TRUE; /* II) REMOVE FORMERLY ACTIVE BOUNDS (IF NECESSARY): */ if ( setupAfresh == BT_FALSE ) { /* Remove all active bounds that shall be inactive AND * all active bounds that are active at the wrong bound. */ for( i=0; igetStatus( i ) != ST_LOWER ) ) if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); if ( ( bounds.getStatus( i ) == ST_UPPER ) && ( auxiliaryBounds->getStatus( i ) != ST_UPPER ) ) if ( removeBound( i,updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); } } /* III) ADD NEWLY ACTIVE BOUNDS: */ /* Add all inactive bounds that shall be active AND * all formerly active bounds that have been active at the wrong bound. */ for( i=0; igetStatus( i ) != ST_INACTIVE ) ) { if ( addBound( i,auxiliaryBounds->getStatus( i ),updateCholesky ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SETUP_WORKINGSET_FAILED ); } } return SUCCESSFUL_RETURN; } /* * s e t u p A u x i l i a r y Q P s o l u t i o n */ returnValue QProblemB::setupAuxiliaryQPsolution( const real_t* const xOpt, const real_t* const yOpt ) { int i; int nV = getNV( ); /* Setup primal/dual solution vectors for auxiliary initial QP: * if a null pointer is passed, a zero vector is assigned; * old solution vector is kept if pointer to internal solution vector is passed. */ if ( xOpt != 0 ) { if ( xOpt != x ) for( i=0; igetIndex( number ); real_t c, s; /* 2) Use row-wise Givens rotations to restore upper triangular form of R. */ for( i=number_idx+1; ith column and ... */ for( i=0; igetNumberArray( FR_idx ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVEBOUND_FAILED ); /* 1) Calculate new column of cholesky decomposition. */ real_t rhs[NVMAX]; real_t r[NVMAX]; real_t r0 = H[number*NVMAX + number]; for( i=0; i 0.0 ) R[nFR*NVMAX + nFR] = sqrt( r0 ); else { hessianType = HST_SEMIDEF; return THROWERROR( RET_HESSIAN_NOT_SPD ); } return SUCCESSFUL_RETURN; } /* * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) */ returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, real_t* const a ) { /* Call standard backsolve procedure (i.e. removingBound == BT_FALSE). */ return backsolveR( b,transposed,BT_FALSE,a ); } /* * b a c k s o l v e R (CODE DUPLICATED IN QProblem CLASS!!!) */ returnValue QProblemB::backsolveR( const real_t* const b, BooleanType transposed, BooleanType removingBound, real_t* const a ) { int i, j; int nR = getNZ( ); real_t sum; /* if backsolve is called while removing a bound, reduce nZ by one. */ if ( removingBound == BT_TRUE ) --nR; /* nothing to do */ if ( nR <= 0 ) return SUCCESSFUL_RETURN; /* Solve Ra = b, where R might be transposed. */ if ( transposed == BT_FALSE ) { /* solve Ra = b */ for( i=(nR-1); i>=0; --i ) { sum = b[i]; for( j=(i+1); j ZERO ) a[i] = sum / R[i*NVMAX + i]; else return THROWERROR( RET_DIV_BY_ZERO ); } } else { /* solve R^T*a = b */ for( i=0; i ZERO ) a[i] = sum / R[i*NVMAX + i]; else return THROWERROR( RET_DIV_BY_ZERO ); } } return SUCCESSFUL_RETURN; } /* * h o t s t a r t _ d e t e r m i n e D a t a S h i f t */ returnValue QProblemB::hotstart_determineDataShift( const int* const FX_idx, const real_t* const g_new, const real_t* const lb_new, const real_t* const ub_new, real_t* const delta_g, real_t* const delta_lb, real_t* const delta_ub, BooleanType& Delta_bB_isZero ) { int i, ii; int nV = getNV( ); int nFX = getNFX( ); /* 1) Calculate shift directions. */ for( i=0; i EPS ) || ( getAbs( delta_ub[ii] ) > EPS ) ) { Delta_bB_isZero = BT_FALSE; break; } } return SUCCESSFUL_RETURN; } /* * a r e B o u n d s C o n s i s t e n t */ BooleanType QProblemB::areBoundsConsistent( const real_t* const delta_lb, const real_t* const delta_ub ) const { int i; /* Check if delta_lb[i] is greater than delta_ub[i] * for a component i whose bounds are already (numerically) equal. */ for( i=0; i ub[i] - BOUNDTOL ) && ( delta_lb[i] > delta_ub[i] + EPS ) ) return BT_FALSE; return BT_TRUE; } /* * s e t u p Q P d a t a */ returnValue QProblemB::setupQPdata( const real_t* const _H, const real_t* const _R, const real_t* const _g, const real_t* const _lb, const real_t* const _ub ) { int i, j; int nV = getNV( ); /* 1) Setup Hessian matrix and it's Cholesky factorization. */ if (_H != 0) { for( i=0; i 0 ) { for( i=0; i 0 ) { /* auxiliary variables */ real_t delta_xFRz_TMP[NVMAX]; real_t delta_xFRz_RHS[NVMAX]; /* Determine delta_xFRz. */ if ( Delta_bB_isZero == BT_FALSE ) { for( i=0; i 0 ) { for( i=0; i= 0.0 ) ) { tau_tmp = y[ii] / ( -delta_yFX[i] ); if ( tau_tmp < tau_new ) { if ( tau_tmp >= 0.0 ) { tau_new = tau_tmp; BC_idx = ii; BC_status = ST_INACTIVE; } } } } else { /* 2) Active upper bounds. */ if ( ( delta_yFX[i] > ZERO ) && ( y[ii] <= 0.0 ) ) { tau_tmp = y[ii] / ( -delta_yFX[i] ); if ( tau_tmp < tau_new ) { if ( tau_tmp >= 0.0 ) { tau_new = tau_tmp; BC_idx = ii; BC_status = ST_INACTIVE; } } } } } } /* II) DETERMINE MAXIMUM PRIMAL STEPLENGTH, i.e. ensure that * inactive bounds remain valid (ignoring unbounded variables). */ /* 1) Inactive lower bounds. */ if ( bounds.isNoLower( ) == BT_FALSE ) { for( i=0; i delta_xFR[i] ) { if ( x[ii] > lb[ii] ) tau_tmp = ( x[ii] - lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] ); else tau_tmp = 0.0; if ( tau_tmp < tau_new ) { if ( tau_tmp >= 0.0 ) { tau_new = tau_tmp; BC_idx = ii; BC_status = ST_LOWER; } } } } } } /* 2) Inactive upper bounds. */ if ( bounds.isNoUpper( ) == BT_FALSE ) { for( i=0; i= 0.0 ) { tau_new = tau_tmp; BC_idx = ii; BC_status = ST_UPPER; } } } } } } /* III) SET MAXIMUM HOMOTOPY STEPLENGTH */ tau = tau_new; if ( printlevel == PL_HIGH ) { #ifdef PC_DEBUG char messageString[80]; if ( BC_status == ST_UNDEFINED ) sprintf( messageString,"Stepsize is %.6e!",tau ); else sprintf( messageString,"Stepsize is %.6e! (BC_idx = %d, BC_status = %d)",tau,BC_idx,BC_status ); getGlobalMessageHandler( )->throwInfo( RET_STEPSIZE_NONPOSITIVE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } return SUCCESSFUL_RETURN; } /* * h o t s t a r t _ p e r f o r m S t e p */ returnValue QProblemB::hotstart_performStep( const int* const FR_idx, const int* const FX_idx, const real_t* const delta_g, const real_t* const delta_lb, const real_t* const delta_ub, const real_t* const delta_xFX, const real_t* const delta_xFR, const real_t* const delta_yFX, int BC_idx, SubjectToStatus BC_status ) { int i, ii; int nV = getNV( ); int nFR = getNFR( ); int nFX = getNFX( ); /* I) CHECK BOUNDS' CONSISTENCY */ if ( areBoundsConsistent( delta_lb,delta_ub ) == BT_FALSE ) { infeasible = BT_TRUE; tau = 0.0; return THROWERROR( RET_QP_INFEASIBLE ); } /* II) GO TO ACTIVE SET CHANGE */ if ( tau > ZERO ) { /* 1) Perform step in primal und dual space. */ for( i=0; ithrowWarning( RET_STEPSIZE,messageString,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); #endif } /* setup output preferences */ #ifdef PC_DEBUG char messageString[80]; VisibilityStatus visibilityStatus; if ( printlevel == PL_HIGH ) visibilityStatus = VS_VISIBLE; else visibilityStatus = VS_HIDDEN; #endif /* III) UPDATE ACTIVE SET */ switch ( BC_status ) { /* Optimal solution found as no working set change detected. */ case ST_UNDEFINED: return RET_OPTIMAL_SOLUTION_FOUND; /* Remove one variable from active set. */ case ST_INACTIVE: #ifdef PC_DEBUG sprintf( messageString,"bound no. %d.", BC_idx ); getGlobalMessageHandler( )->throwInfo( RET_REMOVE_FROM_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( removeBound( BC_idx,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_REMOVE_FROM_ACTIVESET_FAILED ); y[BC_idx] = 0.0; break; /* Add one variable to active set. */ default: #ifdef PC_DEBUG if ( BC_status == ST_LOWER ) sprintf( messageString,"lower bound no. %d.", BC_idx ); else sprintf( messageString,"upper bound no. %d.", BC_idx ); getGlobalMessageHandler( )->throwInfo( RET_ADD_TO_ACTIVESET,messageString,__FUNCTION__,__FILE__,__LINE__,visibilityStatus ); #endif if ( addBound( BC_idx,BC_status,BT_TRUE ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_ADD_TO_ACTIVESET_FAILED ); break; } return SUCCESSFUL_RETURN; } #ifdef PC_DEBUG /* Define print functions only for debugging! */ /* * p r i n t I t e r a t i o n */ returnValue QProblemB::printIteration( int iteration, int BC_idx, SubjectToStatus BC_status ) { char myPrintfString[160]; /* consistency check */ if ( iteration < 0 ) return THROWERROR( RET_INVALID_ARGUMENTS ); /* nothing to do */ if ( printlevel != PL_MEDIUM ) return SUCCESSFUL_RETURN; /* 1) Print header at first iteration. */ if ( iteration == 0 ) { sprintf( myPrintfString,"\n############## qpOASES -- QP NO.%4.1d ###############\n", count ); myPrintf( myPrintfString ); sprintf( myPrintfString," Iter | StepLength | Info | nFX \n" ); myPrintf( myPrintfString ); } /* 2) Print iteration line. */ if ( BC_status == ST_UNDEFINED ) { sprintf( myPrintfString," %4.1d | %1.5e | QP SOLVED | %4.1d \n", iteration,tau,getNFX( ) ); myPrintf( myPrintfString ); } else { char info[8]; if ( BC_status == ST_INACTIVE ) sprintf( info,"REM BND" ); else sprintf( info,"ADD BND" ); sprintf( myPrintfString," %4.1d | %1.5e | %s%4.1d | %4.1d \n", iteration,tau,info,BC_idx,getNFX( ) ); myPrintf( myPrintfString ); } return SUCCESSFUL_RETURN; } #endif /* PC_DEBUG */ /* * c h e c k K K T c o n d i t i o n s */ returnValue QProblemB::checkKKTconditions( ) { #ifdef __PERFORM_KKT_TEST__ int i, j; int nV = getNV( ); real_t tmp; real_t maxKKTviolation = 0.0; /* 1) Check for Hx + g - y*A' = 0 (here: A = Id). */ for( i=0; i maxKKTviolation ) maxKKTviolation = getAbs( tmp ); } /* 2) Check for lb <= x <= ub. */ for( i=0; i maxKKTviolation ) maxKKTviolation = lb[i] - x[i]; if ( x[i] - ub[i] > maxKKTviolation ) maxKKTviolation = x[i] - ub[i]; } /* 3) Check for correct sign of y and for complementary slackness. */ for( i=0; i maxKKTviolation ) maxKKTviolation = -y[i]; if ( getAbs( ( x[i] - lb[i] ) * y[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( ( x[i] - lb[i] ) * y[i] ); break; case ST_UPPER: if ( y[i] > maxKKTviolation ) maxKKTviolation = y[i]; if ( getAbs( ( ub[i] - x[i] ) * y[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( ( ub[i] - x[i] ) * y[i] ); break; default: /* inactive */ if ( getAbs( y[i] ) > maxKKTviolation ) maxKKTviolation = getAbs( y[i] ); break; } } if ( maxKKTviolation > CRITICALACCURACY ) return RET_NO_SOLUTION; if ( maxKKTviolation > DESIREDACCURACY ) return RET_INACCURATE_SOLUTION; #endif /* __PERFORM_KKT_TEST__ */ return SUCCESSFUL_RETURN; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/QProblemB.ipp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/QProblemB.ipp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of inlined member functions of the QProblemB class which * is able to use the newly developed online active set strategy for * parametric quadratic programming. */ #include /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * g e t H */ inline returnValue QProblemB::getH( real_t* const _H ) const { int i; for ( i=0; i= 0 ) && ( number < getNV( ) ) ) { value = lb[number]; return SUCCESSFUL_RETURN; } else { return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } } /* * g e t U B */ inline returnValue QProblemB::getUB( real_t* const _ub ) const { int i; for ( i=0; i= 0 ) && ( number < getNV( ) ) ) { value = ub[number]; return SUCCESSFUL_RETURN; } else { return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } } /* * g e t B o u n d s */ inline returnValue QProblemB::getBounds( Bounds* const _bounds ) const { *_bounds = bounds; return SUCCESSFUL_RETURN; } /* * g e t N V */ inline int QProblemB::getNV( ) const { return bounds.getNV( ); } /* * g e t N F R */ inline int QProblemB::getNFR( ) { return bounds.getNFR( ); } /* * g e t N F X */ inline int QProblemB::getNFX( ) { return bounds.getNFX( ); } /* * g e t N F V */ inline int QProblemB::getNFV( ) const { return bounds.getNFV( ); } /* * g e t S t a t u s */ inline QProblemStatus QProblemB::getStatus( ) const { return status; } /* * i s I n i t i a l i s e d */ inline BooleanType QProblemB::isInitialised( ) const { if ( status == QPS_NOTINITIALISED ) return BT_FALSE; else return BT_TRUE; } /* * i s S o l v e d */ inline BooleanType QProblemB::isSolved( ) const { if ( status == QPS_SOLVED ) return BT_TRUE; else return BT_FALSE; } /* * i s I n f e a s i b l e */ inline BooleanType QProblemB::isInfeasible( ) const { return infeasible; } /* * i s U n b o u n d e d */ inline BooleanType QProblemB::isUnbounded( ) const { return unbounded; } /* * g e t P r i n t L e v e l */ inline PrintLevel QProblemB::getPrintLevel( ) const { return printlevel; } /* * g e t H e s s i a n T y p e */ inline HessianType QProblemB::getHessianType( ) const { return hessianType; } /* * s e t H e s s i a n T y p e */ inline returnValue QProblemB::setHessianType( HessianType _hessianType ) { hessianType = _hessianType; return SUCCESSFUL_RETURN; } /***************************************************************************** * P R O T E C T E D * *****************************************************************************/ /* * s e t H */ inline returnValue QProblemB::setH( const real_t* const H_new ) { int i, j; int nV = getNV(); for( i=0; i= 0 ) && ( number < getNV( ) ) ) { lb[number] = value; return SUCCESSFUL_RETURN; } else { return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } } /* * s e t U B */ inline returnValue QProblemB::setUB( const real_t* const ub_new ) { int i; int nV = getNV(); for( i=0; i= 0 ) && ( number < getNV( ) ) ) { ub[number] = value; return SUCCESSFUL_RETURN; } else { return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } } /* * c o m p u t e G i v e n s */ inline void QProblemB::computeGivens( real_t xold, real_t yold, real_t& xnew, real_t& ynew, real_t& c, real_t& s ) const { if ( getAbs( yold ) <= ZERO ) { c = 1.0; s = 0.0; xnew = xold; ynew = yold; } else { real_t t, mu; mu = getAbs( xold ); if ( getAbs( yold ) > mu ) mu = getAbs( yold ); t = mu * sqrt( (xold/mu)*(xold/mu) + (yold/mu)*(yold/mu) ); if ( xold < 0.0 ) t = -t; c = xold/t; s = yold/t; xnew = t; ynew = 0.0; } return; } /* * a p p l y G i v e n s */ inline void QProblemB::applyGivens( real_t c, real_t s, real_t xold, real_t yold, real_t& xnew, real_t& ynew ) const { /* Usual Givens plane rotation requiring four multiplications. */ xnew = c*xold + s*yold; ynew = -s*xold + c*yold; // double nu = s/(1.0+c); // // xnew = xold*c + yold*s; // ynew = (xnew+xold)*nu - yold; return; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/SubjectTo.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/SubjectTo.cpp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the SubjectTo class designed to manage working sets of * constraints and bounds within a QProblem. */ #include /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * S u b j e c t T o */ SubjectTo::SubjectTo( ) : noLower( BT_TRUE ), noUpper( BT_TRUE ), size( 0 ) { int i; for( i=0; iaddNumber( newnumber ) == RET_INDEXLIST_EXCEEDS_MAX_LENGTH ) return THROWERROR( RET_ADDINDEX_FAILED ); return SUCCESSFUL_RETURN; } /* * r e m o v e I n d e x */ returnValue SubjectTo::removeIndex( Indexlist* const indexlist, int removenumber ) { status[removenumber] = ST_UNDEFINED; if ( indexlist->removeNumber( removenumber ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_UNKNOWN_BUG ); return SUCCESSFUL_RETURN; } /* * s w a p I n d e x */ returnValue SubjectTo::swapIndex( Indexlist* const indexlist, int number1, int number2 ) { /* consistency checks */ if ( status[number1] != status[number2] ) return THROWERROR( RET_SWAPINDEX_FAILED ); if ( number1 == number2 ) { THROWWARNING( RET_NOTHING_TO_DO ); return SUCCESSFUL_RETURN; } if ( indexlist->swapNumbers( number1,number2 ) != SUCCESSFUL_RETURN ) return THROWERROR( RET_SWAPINDEX_FAILED ); return SUCCESSFUL_RETURN; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/SubjectTo.ipp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/SubjectTo.ipp * \author Hans Joachim Ferreau * \version 1.3embedded * \date 2007-2008 * * Implementation of the inlined member functions of the SubjectTo class * designed to manage working sets of constraints and bounds within a QProblem. */ /***************************************************************************** * P U B L I C * *****************************************************************************/ /* * g e t T y p e */ inline SubjectToType SubjectTo::getType( int i ) const { if ( ( i >= 0 ) && ( i < size ) ) return type[i]; else return ST_UNKNOWN; } /* * g e t S t a t u s */ inline SubjectToStatus SubjectTo::getStatus( int i ) const { if ( ( i >= 0 ) && ( i < size ) ) return status[i]; else return ST_UNDEFINED; } /* * s e t T y p e */ inline returnValue SubjectTo::setType( int i, SubjectToType value ) { if ( ( i >= 0 ) && ( i < size ) ) { type[i] = value; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } /* * s e t S t a t u s */ inline returnValue SubjectTo::setStatus( int i, SubjectToStatus value ) { if ( ( i >= 0 ) && ( i < size ) ) { status[i] = value; return SUCCESSFUL_RETURN; } else return THROWERROR( RET_INDEX_OUT_OF_BOUNDS ); } /* * s e t N o L o w e r */ inline void SubjectTo::setNoLower( BooleanType _status ) { noLower = _status; } /* * s e t N o U p p e r */ inline void SubjectTo::setNoUpper( BooleanType _status ) { noUpper = _status; } /* * i s N o L o w e r */ inline BooleanType SubjectTo::isNoLower( ) const { return noLower; } /* * i s N o L o w e r */ inline BooleanType SubjectTo::isNoUpper( ) const { return noUpper; } /* * end of file */ ================================================ FILE: phonelibs/qpoases/SRC/Utils.cpp ================================================ /* * This file is part of qpOASES. * * qpOASES -- An Implementation of the Online Active Set Strategy. * Copyright (C) 2007-2008 by Hans Joachim Ferreau et al. All rights reserved. * * qpOASES is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * qpOASES is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with qpOASES; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * \file SRC/Utils.cpp * \author Hans Joachim Ferreau, Eckhard Arnold * \version 1.3embedded * \date 2007-2008 * * Implementation of some inlined utilities for working with the different QProblem * classes. */ #include #if defined(__WIN32__) || defined(WIN32) #include #elif defined(LINUX) #include #include #endif #ifdef __MATLAB__ #include #endif #include #ifdef PC_DEBUG /* Define print functions only for debugging! */ /* * p r i n t */ returnValue print( const real_t* const v, int n ) { int i; char myPrintfString[160]; /* Print a vector. */ myPrintf( "[\t" ); for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } /* 2) Read data from file. */ for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } data[i*ncol + j] = ( (real_t) float_data ); } } /* 3) Close file. */ fclose( datafile ); return SUCCESSFUL_RETURN; } /* * r e a d F r o m F i l e */ returnValue readFromFile( real_t* data, int n, const char* datafilename ) { return readFromFile( data, n, 1, datafilename ); } /* * r e a d F r o m F i l e */ returnValue readFromFile( int* data, int n, const char* datafilename ) { int i; myFILE* datafile; /* 1) Open file. */ if ( ( datafile = fopen( datafilename, "r" ) ) == 0 ) { char errstr[80]; sprintf( errstr,"(%s)",datafilename ); return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } /* 2) Read data from file. */ for( i=0; ithrowError( RET_UNABLE_TO_READ_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } } /* 3) Close file. */ fclose( datafile ); return SUCCESSFUL_RETURN; } /* * w r i t e I n t o F i l e */ returnValue writeIntoFile( const real_t* const data, int nrow, int ncol, const char* datafilename, BooleanType append ) { int i, j; myFILE* datafile; /* 1) Open file. */ if ( append == BT_TRUE ) { /* append data */ if ( ( datafile = fopen( datafilename, "a" ) ) == 0 ) { char errstr[80]; sprintf( errstr,"(%s)",datafilename ); return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } } else { /* do not append data */ if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) { char errstr[80]; sprintf( errstr,"(%s)",datafilename ); return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } } /* 2) Write data into file. */ for( i=0; ithrowError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } } else { /* do not append data */ if ( ( datafile = fopen( datafilename, "w" ) ) == 0 ) { char errstr[80]; sprintf( errstr,"(%s)",datafilename ); return getGlobalMessageHandler( )->throwError( RET_UNABLE_TO_OPEN_FILE,errstr,__FUNCTION__,__FILE__,__LINE__,VS_VISIBLE ); } } /* 2) Write data into file. */ for( i=0; i #include #include #include #include #include #include #include #include "QrCode.hpp" using std::int8_t; using std::uint8_t; using std::size_t; using std::vector; namespace qrcodegen { QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) : modeBits(mode) { numBitsCharCount[0] = cc0; numBitsCharCount[1] = cc1; numBitsCharCount[2] = cc2; } int QrSegment::Mode::getModeBits() const { return modeBits; } int QrSegment::Mode::numCharCountBits(int ver) const { return numBitsCharCount[(ver + 7) / 17]; } const QrSegment::Mode QrSegment::Mode::NUMERIC (0x1, 10, 12, 14); const QrSegment::Mode QrSegment::Mode::ALPHANUMERIC(0x2, 9, 11, 13); const QrSegment::Mode QrSegment::Mode::BYTE (0x4, 8, 16, 16); const QrSegment::Mode QrSegment::Mode::KANJI (0x8, 8, 10, 12); const QrSegment::Mode QrSegment::Mode::ECI (0x7, 0, 0, 0); QrSegment QrSegment::makeBytes(const vector &data) { if (data.size() > static_cast(INT_MAX)) throw std::length_error("Data too long"); BitBuffer bb; for (uint8_t b : data) bb.appendBits(b, 8); return QrSegment(Mode::BYTE, static_cast(data.size()), std::move(bb)); } QrSegment QrSegment::makeNumeric(const char *digits) { BitBuffer bb; int accumData = 0; int accumCount = 0; int charCount = 0; for (; *digits != '\0'; digits++, charCount++) { char c = *digits; if (c < '0' || c > '9') throw std::domain_error("String contains non-numeric characters"); accumData = accumData * 10 + (c - '0'); accumCount++; if (accumCount == 3) { bb.appendBits(static_cast(accumData), 10); accumData = 0; accumCount = 0; } } if (accumCount > 0) // 1 or 2 digits remaining bb.appendBits(static_cast(accumData), accumCount * 3 + 1); return QrSegment(Mode::NUMERIC, charCount, std::move(bb)); } QrSegment QrSegment::makeAlphanumeric(const char *text) { BitBuffer bb; int accumData = 0; int accumCount = 0; int charCount = 0; for (; *text != '\0'; text++, charCount++) { const char *temp = std::strchr(ALPHANUMERIC_CHARSET, *text); if (temp == nullptr) throw std::domain_error("String contains unencodable characters in alphanumeric mode"); accumData = accumData * 45 + static_cast(temp - ALPHANUMERIC_CHARSET); accumCount++; if (accumCount == 2) { bb.appendBits(static_cast(accumData), 11); accumData = 0; accumCount = 0; } } if (accumCount > 0) // 1 character remaining bb.appendBits(static_cast(accumData), 6); return QrSegment(Mode::ALPHANUMERIC, charCount, std::move(bb)); } vector QrSegment::makeSegments(const char *text) { // Select the most efficient segment encoding automatically vector result; if (*text == '\0'); // Leave result empty else if (isNumeric(text)) result.push_back(makeNumeric(text)); else if (isAlphanumeric(text)) result.push_back(makeAlphanumeric(text)); else { vector bytes; for (; *text != '\0'; text++) bytes.push_back(static_cast(*text)); result.push_back(makeBytes(bytes)); } return result; } QrSegment QrSegment::makeEci(long assignVal) { BitBuffer bb; if (assignVal < 0) throw std::domain_error("ECI assignment value out of range"); else if (assignVal < (1 << 7)) bb.appendBits(static_cast(assignVal), 8); else if (assignVal < (1 << 14)) { bb.appendBits(2, 2); bb.appendBits(static_cast(assignVal), 14); } else if (assignVal < 1000000L) { bb.appendBits(6, 3); bb.appendBits(static_cast(assignVal), 21); } else throw std::domain_error("ECI assignment value out of range"); return QrSegment(Mode::ECI, 0, std::move(bb)); } QrSegment::QrSegment(Mode md, int numCh, const std::vector &dt) : mode(md), numChars(numCh), data(dt) { if (numCh < 0) throw std::domain_error("Invalid value"); } QrSegment::QrSegment(Mode md, int numCh, std::vector &&dt) : mode(md), numChars(numCh), data(std::move(dt)) { if (numCh < 0) throw std::domain_error("Invalid value"); } int QrSegment::getTotalBits(const vector &segs, int version) { int result = 0; for (const QrSegment &seg : segs) { int ccbits = seg.mode.numCharCountBits(version); if (seg.numChars >= (1L << ccbits)) return -1; // The segment's length doesn't fit the field's bit width if (4 + ccbits > INT_MAX - result) return -1; // The sum will overflow an int type result += 4 + ccbits; if (seg.data.size() > static_cast(INT_MAX - result)) return -1; // The sum will overflow an int type result += static_cast(seg.data.size()); } return result; } bool QrSegment::isAlphanumeric(const char *text) { for (; *text != '\0'; text++) { if (std::strchr(ALPHANUMERIC_CHARSET, *text) == nullptr) return false; } return true; } bool QrSegment::isNumeric(const char *text) { for (; *text != '\0'; text++) { char c = *text; if (c < '0' || c > '9') return false; } return true; } QrSegment::Mode QrSegment::getMode() const { return mode; } int QrSegment::getNumChars() const { return numChars; } const std::vector &QrSegment::getData() const { return data; } const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; int QrCode::getFormatBits(Ecc ecl) { switch (ecl) { case Ecc::LOW : return 1; case Ecc::MEDIUM : return 0; case Ecc::QUARTILE: return 3; case Ecc::HIGH : return 2; default: throw std::logic_error("Assertion error"); } } QrCode QrCode::encodeText(const char *text, Ecc ecl) { vector segs = QrSegment::makeSegments(text); return encodeSegments(segs, ecl); } QrCode QrCode::encodeBinary(const vector &data, Ecc ecl) { vector segs{QrSegment::makeBytes(data)}; return encodeSegments(segs, ecl); } QrCode QrCode::encodeSegments(const vector &segs, Ecc ecl, int minVersion, int maxVersion, int mask, bool boostEcl) { if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) throw std::invalid_argument("Invalid value"); // Find the minimal version number to use int version, dataUsedBits; for (version = minVersion; ; version++) { int dataCapacityBits = getNumDataCodewords(version, ecl) * 8; // Number of data bits available dataUsedBits = QrSegment::getTotalBits(segs, version); if (dataUsedBits != -1 && dataUsedBits <= dataCapacityBits) break; // This version number is found to be suitable if (version >= maxVersion) { // All versions in the range could not fit the given data std::ostringstream sb; if (dataUsedBits == -1) sb << "Segment too long"; else { sb << "Data length = " << dataUsedBits << " bits, "; sb << "Max capacity = " << dataCapacityBits << " bits"; } throw data_too_long(sb.str()); } } if (dataUsedBits == -1) throw std::logic_error("Assertion error"); // Increase the error correction level while the data still fits in the current version number for (Ecc newEcl : vector{Ecc::MEDIUM, Ecc::QUARTILE, Ecc::HIGH}) { // From low to high if (boostEcl && dataUsedBits <= getNumDataCodewords(version, newEcl) * 8) ecl = newEcl; } // Concatenate all segments to create the data bit string BitBuffer bb; for (const QrSegment &seg : segs) { bb.appendBits(static_cast(seg.getMode().getModeBits()), 4); bb.appendBits(static_cast(seg.getNumChars()), seg.getMode().numCharCountBits(version)); bb.insert(bb.end(), seg.getData().begin(), seg.getData().end()); } if (bb.size() != static_cast(dataUsedBits)) throw std::logic_error("Assertion error"); // Add terminator and pad up to a byte if applicable size_t dataCapacityBits = static_cast(getNumDataCodewords(version, ecl)) * 8; if (bb.size() > dataCapacityBits) throw std::logic_error("Assertion error"); bb.appendBits(0, std::min(4, static_cast(dataCapacityBits - bb.size()))); bb.appendBits(0, (8 - static_cast(bb.size() % 8)) % 8); if (bb.size() % 8 != 0) throw std::logic_error("Assertion error"); // Pad with alternating bytes until data capacity is reached for (uint8_t padByte = 0xEC; bb.size() < dataCapacityBits; padByte ^= 0xEC ^ 0x11) bb.appendBits(padByte, 8); // Pack bits into bytes in big endian vector dataCodewords(bb.size() / 8); for (size_t i = 0; i < bb.size(); i++) dataCodewords[i >> 3] |= (bb.at(i) ? 1 : 0) << (7 - (i & 7)); // Create the QR Code object return QrCode(version, ecl, dataCodewords, mask); } QrCode::QrCode(int ver, Ecc ecl, const vector &dataCodewords, int msk) : // Initialize fields and check arguments version(ver), errorCorrectionLevel(ecl) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw std::domain_error("Version value out of range"); if (msk < -1 || msk > 7) throw std::domain_error("Mask value out of range"); size = ver * 4 + 17; size_t sz = static_cast(size); modules = vector >(sz, vector(sz)); // Initially all white isFunction = vector >(sz, vector(sz)); // Compute ECC, draw modules drawFunctionPatterns(); const vector allCodewords = addEccAndInterleave(dataCodewords); drawCodewords(allCodewords); // Do masking if (msk == -1) { // Automatically choose best mask long minPenalty = LONG_MAX; for (int i = 0; i < 8; i++) { applyMask(i); drawFormatBits(i); long penalty = getPenaltyScore(); if (penalty < minPenalty) { msk = i; minPenalty = penalty; } applyMask(i); // Undoes the mask due to XOR } } if (msk < 0 || msk > 7) throw std::logic_error("Assertion error"); this->mask = msk; applyMask(msk); // Apply the final choice of mask drawFormatBits(msk); // Overwrite old format bits isFunction.clear(); isFunction.shrink_to_fit(); } int QrCode::getVersion() const { return version; } int QrCode::getSize() const { return size; } QrCode::Ecc QrCode::getErrorCorrectionLevel() const { return errorCorrectionLevel; } int QrCode::getMask() const { return mask; } bool QrCode::getModule(int x, int y) const { return 0 <= x && x < size && 0 <= y && y < size && module(x, y); } std::string QrCode::toSvgString(int border) const { if (border < 0) throw std::domain_error("Border must be non-negative"); if (border > INT_MAX / 2 || border * 2 > INT_MAX - size) throw std::overflow_error("Border too large"); std::ostringstream sb; sb << "\n"; sb << "\n"; sb << "\n"; sb << "\t\n"; sb << "\t\n"; sb << "\n"; return sb.str(); } void QrCode::drawFunctionPatterns() { // Draw horizontal and vertical timing patterns for (int i = 0; i < size; i++) { setFunctionModule(6, i, i % 2 == 0); setFunctionModule(i, 6, i % 2 == 0); } // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) drawFinderPattern(3, 3); drawFinderPattern(size - 4, 3); drawFinderPattern(3, size - 4); // Draw numerous alignment patterns const vector alignPatPos = getAlignmentPatternPositions(); size_t numAlign = alignPatPos.size(); for (size_t i = 0; i < numAlign; i++) { for (size_t j = 0; j < numAlign; j++) { // Don't draw on the three finder corners if (!((i == 0 && j == 0) || (i == 0 && j == numAlign - 1) || (i == numAlign - 1 && j == 0))) drawAlignmentPattern(alignPatPos.at(i), alignPatPos.at(j)); } } // Draw configuration data drawFormatBits(0); // Dummy mask value; overwritten later in the constructor drawVersion(); } void QrCode::drawFormatBits(int msk) { // Calculate error correction code and pack bits int data = getFormatBits(errorCorrectionLevel) << 3 | msk; // errCorrLvl is uint2, msk is uint3 int rem = data; for (int i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >> 9) * 0x537); int bits = (data << 10 | rem) ^ 0x5412; // uint15 if (bits >> 15 != 0) throw std::logic_error("Assertion error"); // Draw first copy for (int i = 0; i <= 5; i++) setFunctionModule(8, i, getBit(bits, i)); setFunctionModule(8, 7, getBit(bits, 6)); setFunctionModule(8, 8, getBit(bits, 7)); setFunctionModule(7, 8, getBit(bits, 8)); for (int i = 9; i < 15; i++) setFunctionModule(14 - i, 8, getBit(bits, i)); // Draw second copy for (int i = 0; i < 8; i++) setFunctionModule(size - 1 - i, 8, getBit(bits, i)); for (int i = 8; i < 15; i++) setFunctionModule(8, size - 15 + i, getBit(bits, i)); setFunctionModule(8, size - 8, true); // Always black } void QrCode::drawVersion() { if (version < 7) return; // Calculate error correction code and pack bits int rem = version; // version is uint6, in the range [7, 40] for (int i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >> 11) * 0x1F25); long bits = static_cast(version) << 12 | rem; // uint18 if (bits >> 18 != 0) throw std::logic_error("Assertion error"); // Draw two copies for (int i = 0; i < 18; i++) { bool bit = getBit(bits, i); int a = size - 11 + i % 3; int b = i / 3; setFunctionModule(a, b, bit); setFunctionModule(b, a, bit); } } void QrCode::drawFinderPattern(int x, int y) { for (int dy = -4; dy <= 4; dy++) { for (int dx = -4; dx <= 4; dx++) { int dist = std::max(std::abs(dx), std::abs(dy)); // Chebyshev/infinity norm int xx = x + dx, yy = y + dy; if (0 <= xx && xx < size && 0 <= yy && yy < size) setFunctionModule(xx, yy, dist != 2 && dist != 4); } } } void QrCode::drawAlignmentPattern(int x, int y) { for (int dy = -2; dy <= 2; dy++) { for (int dx = -2; dx <= 2; dx++) setFunctionModule(x + dx, y + dy, std::max(std::abs(dx), std::abs(dy)) != 1); } } void QrCode::setFunctionModule(int x, int y, bool isBlack) { size_t ux = static_cast(x); size_t uy = static_cast(y); modules .at(uy).at(ux) = isBlack; isFunction.at(uy).at(ux) = true; } bool QrCode::module(int x, int y) const { return modules.at(static_cast(y)).at(static_cast(x)); } vector QrCode::addEccAndInterleave(const vector &data) const { if (data.size() != static_cast(getNumDataCodewords(version, errorCorrectionLevel))) throw std::invalid_argument("Invalid argument"); // Calculate parameter numbers int numBlocks = NUM_ERROR_CORRECTION_BLOCKS[static_cast(errorCorrectionLevel)][version]; int blockEccLen = ECC_CODEWORDS_PER_BLOCK [static_cast(errorCorrectionLevel)][version]; int rawCodewords = getNumRawDataModules(version) / 8; int numShortBlocks = numBlocks - rawCodewords % numBlocks; int shortBlockLen = rawCodewords / numBlocks; // Split data into blocks and append ECC to each block vector > blocks; const vector rsDiv = reedSolomonComputeDivisor(blockEccLen); for (int i = 0, k = 0; i < numBlocks; i++) { vector dat(data.cbegin() + k, data.cbegin() + (k + shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1))); k += static_cast(dat.size()); const vector ecc = reedSolomonComputeRemainder(dat, rsDiv); if (i < numShortBlocks) dat.push_back(0); dat.insert(dat.end(), ecc.cbegin(), ecc.cend()); blocks.push_back(std::move(dat)); } // Interleave (not concatenate) the bytes from every block into a single sequence vector result; for (size_t i = 0; i < blocks.at(0).size(); i++) { for (size_t j = 0; j < blocks.size(); j++) { // Skip the padding byte in short blocks if (i != static_cast(shortBlockLen - blockEccLen) || j >= static_cast(numShortBlocks)) result.push_back(blocks.at(j).at(i)); } } if (result.size() != static_cast(rawCodewords)) throw std::logic_error("Assertion error"); return result; } void QrCode::drawCodewords(const vector &data) { if (data.size() != static_cast(getNumRawDataModules(version) / 8)) throw std::invalid_argument("Invalid argument"); size_t i = 0; // Bit index into the data // Do the funny zigzag scan for (int right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair if (right == 6) right = 5; for (int vert = 0; vert < size; vert++) { // Vertical counter for (int j = 0; j < 2; j++) { size_t x = static_cast(right - j); // Actual x coordinate bool upward = ((right + 1) & 2) == 0; size_t y = static_cast(upward ? size - 1 - vert : vert); // Actual y coordinate if (!isFunction.at(y).at(x) && i < data.size() * 8) { modules.at(y).at(x) = getBit(data.at(i >> 3), 7 - static_cast(i & 7)); i++; } // If this QR Code has any remainder bits (0 to 7), they were assigned as // 0/false/white by the constructor and are left unchanged by this method } } } if (i != data.size() * 8) throw std::logic_error("Assertion error"); } void QrCode::applyMask(int msk) { if (msk < 0 || msk > 7) throw std::domain_error("Mask value out of range"); size_t sz = static_cast(size); for (size_t y = 0; y < sz; y++) { for (size_t x = 0; x < sz; x++) { bool invert; switch (msk) { case 0: invert = (x + y) % 2 == 0; break; case 1: invert = y % 2 == 0; break; case 2: invert = x % 3 == 0; break; case 3: invert = (x + y) % 3 == 0; break; case 4: invert = (x / 3 + y / 2) % 2 == 0; break; case 5: invert = x * y % 2 + x * y % 3 == 0; break; case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; default: throw std::logic_error("Assertion error"); } modules.at(y).at(x) = modules.at(y).at(x) ^ (invert & !isFunction.at(y).at(x)); } } } long QrCode::getPenaltyScore() const { long result = 0; // Adjacent modules in row having same color, and finder-like patterns for (int y = 0; y < size; y++) { bool runColor = false; int runX = 0; std::array runHistory = {}; for (int x = 0; x < size; x++) { if (module(x, y) == runColor) { runX++; if (runX == 5) result += PENALTY_N1; else if (runX > 5) result++; } else { finderPenaltyAddHistory(runX, runHistory); if (!runColor) result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3; runColor = module(x, y); runX = 1; } } result += finderPenaltyTerminateAndCount(runColor, runX, runHistory) * PENALTY_N3; } // Adjacent modules in column having same color, and finder-like patterns for (int x = 0; x < size; x++) { bool runColor = false; int runY = 0; std::array runHistory = {}; for (int y = 0; y < size; y++) { if (module(x, y) == runColor) { runY++; if (runY == 5) result += PENALTY_N1; else if (runY > 5) result++; } else { finderPenaltyAddHistory(runY, runHistory); if (!runColor) result += finderPenaltyCountPatterns(runHistory) * PENALTY_N3; runColor = module(x, y); runY = 1; } } result += finderPenaltyTerminateAndCount(runColor, runY, runHistory) * PENALTY_N3; } // 2*2 blocks of modules having same color for (int y = 0; y < size - 1; y++) { for (int x = 0; x < size - 1; x++) { bool color = module(x, y); if ( color == module(x + 1, y) && color == module(x, y + 1) && color == module(x + 1, y + 1)) result += PENALTY_N2; } } // Balance of black and white modules int black = 0; for (const vector &row : modules) { for (bool color : row) { if (color) black++; } } int total = size * size; // Note that size is odd, so black/total != 1/2 // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)% int k = static_cast((std::abs(black * 20L - total * 10L) + total - 1) / total) - 1; result += k * PENALTY_N4; return result; } vector QrCode::getAlignmentPatternPositions() const { if (version == 1) return vector(); else { int numAlign = version / 7 + 2; int step = (version == 32) ? 26 : (version*4 + numAlign*2 + 1) / (numAlign*2 - 2) * 2; vector result; for (int i = 0, pos = size - 7; i < numAlign - 1; i++, pos -= step) result.insert(result.begin(), pos); result.insert(result.begin(), 6); return result; } } int QrCode::getNumRawDataModules(int ver) { if (ver < MIN_VERSION || ver > MAX_VERSION) throw std::domain_error("Version number out of range"); int result = (16 * ver + 128) * ver + 64; if (ver >= 2) { int numAlign = ver / 7 + 2; result -= (25 * numAlign - 10) * numAlign - 55; if (ver >= 7) result -= 36; } if (!(208 <= result && result <= 29648)) throw std::logic_error("Assertion error"); return result; } int QrCode::getNumDataCodewords(int ver, Ecc ecl) { return getNumRawDataModules(ver) / 8 - ECC_CODEWORDS_PER_BLOCK [static_cast(ecl)][ver] * NUM_ERROR_CORRECTION_BLOCKS[static_cast(ecl)][ver]; } vector QrCode::reedSolomonComputeDivisor(int degree) { if (degree < 1 || degree > 255) throw std::domain_error("Degree out of range"); // Polynomial coefficients are stored from highest to lowest power, excluding the leading term which is always 1. // For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. vector result(static_cast(degree)); result.at(result.size() - 1) = 1; // Start off with the monomial x^0 // Compute the product polynomial (x - r^0) * (x - r^1) * (x - r^2) * ... * (x - r^{degree-1}), // and drop the highest monomial term which is always 1x^degree. // Note that r = 0x02, which is a generator element of this field GF(2^8/0x11D). uint8_t root = 1; for (int i = 0; i < degree; i++) { // Multiply the current product by (x - r^i) for (size_t j = 0; j < result.size(); j++) { result.at(j) = reedSolomonMultiply(result.at(j), root); if (j + 1 < result.size()) result.at(j) ^= result.at(j + 1); } root = reedSolomonMultiply(root, 0x02); } return result; } vector QrCode::reedSolomonComputeRemainder(const vector &data, const vector &divisor) { vector result(divisor.size()); for (uint8_t b : data) { // Polynomial division uint8_t factor = b ^ result.at(0); result.erase(result.begin()); result.push_back(0); for (size_t i = 0; i < result.size(); i++) result.at(i) ^= reedSolomonMultiply(divisor.at(i), factor); } return result; } uint8_t QrCode::reedSolomonMultiply(uint8_t x, uint8_t y) { // Russian peasant multiplication int z = 0; for (int i = 7; i >= 0; i--) { z = (z << 1) ^ ((z >> 7) * 0x11D); z ^= ((y >> i) & 1) * x; } if (z >> 8 != 0) throw std::logic_error("Assertion error"); return static_cast(z); } int QrCode::finderPenaltyCountPatterns(const std::array &runHistory) const { int n = runHistory.at(1); if (n > size * 3) throw std::logic_error("Assertion error"); bool core = n > 0 && runHistory.at(2) == n && runHistory.at(3) == n * 3 && runHistory.at(4) == n && runHistory.at(5) == n; return (core && runHistory.at(0) >= n * 4 && runHistory.at(6) >= n ? 1 : 0) + (core && runHistory.at(6) >= n * 4 && runHistory.at(0) >= n ? 1 : 0); } int QrCode::finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLength, std::array &runHistory) const { if (currentRunColor) { // Terminate black run finderPenaltyAddHistory(currentRunLength, runHistory); currentRunLength = 0; } currentRunLength += size; // Add white border to final run finderPenaltyAddHistory(currentRunLength, runHistory); return finderPenaltyCountPatterns(runHistory); } void QrCode::finderPenaltyAddHistory(int currentRunLength, std::array &runHistory) const { if (runHistory.at(0) == 0) currentRunLength += size; // Add white border to initial run std::copy_backward(runHistory.cbegin(), runHistory.cend() - 1, runHistory.end()); runHistory.at(0) = currentRunLength; } bool QrCode::getBit(long x, int i) { return ((x >> i) & 1) != 0; } /*---- Tables of constants ----*/ const int QrCode::PENALTY_N1 = 3; const int QrCode::PENALTY_N2 = 3; const int QrCode::PENALTY_N3 = 40; const int QrCode::PENALTY_N4 = 10; const int8_t QrCode::ECC_CODEWORDS_PER_BLOCK[4][41] = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Low {-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28}, // Medium {-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // Quartile {-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30}, // High }; const int8_t QrCode::NUM_ERROR_CORRECTION_BLOCKS[4][41] = { // Version: (note that index 0 is for padding, and is set to an illegal value) //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level {-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25}, // Low {-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49}, // Medium {-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68}, // Quartile {-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81}, // High }; data_too_long::data_too_long(const std::string &msg) : std::length_error(msg) {} BitBuffer::BitBuffer() : std::vector() {} void BitBuffer::appendBits(std::uint32_t val, int len) { if (len < 0 || len > 31 || val >> len != 0) throw std::domain_error("Value out of range"); for (int i = len - 1; i >= 0; i--) // Append bit by bit this->push_back(((val >> i) & 1) != 0); } } ================================================ FILE: phonelibs/qrcode/QrCode.hpp ================================================ /* * QR Code generator library (C++) * * Copyright (c) Project Nayuki. (MIT License) * https://www.nayuki.io/page/qr-code-generator-library * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * - The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - The Software is provided "as is", without warranty of any kind, express or * implied, including but not limited to the warranties of merchantability, * fitness for a particular purpose and noninfringement. In no event shall the * authors or copyright holders be liable for any claim, damages or other * liability, whether in an action of contract, tort or otherwise, arising from, * out of or in connection with the Software or the use or other dealings in the * Software. */ #pragma once #include #include #include #include #include namespace qrcodegen { /* * A segment of character/binary/control data in a QR Code symbol. * Instances of this class are immutable. * The mid-level way to create a segment is to take the payload data * and call a static factory function such as QrSegment::makeNumeric(). * The low-level way to create a segment is to custom-make the bit buffer * and call the QrSegment() constructor with appropriate values. * This segment class imposes no length restrictions, but QR Codes have restrictions. * Even in the most favorable conditions, a QR Code can only hold 7089 characters of data. * Any segment longer than this is meaningless for the purpose of generating QR Codes. */ class QrSegment final { /*---- Public helper enumeration ----*/ /* * Describes how a segment's data bits are interpreted. Immutable. */ public: class Mode final { /*-- Constants --*/ public: static const Mode NUMERIC; public: static const Mode ALPHANUMERIC; public: static const Mode BYTE; public: static const Mode KANJI; public: static const Mode ECI; /*-- Fields --*/ // The mode indicator bits, which is a uint4 value (range 0 to 15). private: int modeBits; // Number of character count bits for three different version ranges. private: int numBitsCharCount[3]; /*-- Constructor --*/ private: Mode(int mode, int cc0, int cc1, int cc2); /*-- Methods --*/ /* * (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15). */ public: int getModeBits() const; /* * (Package-private) Returns the bit width of the character count field for a segment in * this mode in a QR Code at the given version number. The result is in the range [0, 16]. */ public: int numCharCountBits(int ver) const; }; /*---- Static factory functions (mid level) ----*/ /* * Returns a segment representing the given binary data encoded in * byte mode. All input byte vectors are acceptable. Any text string * can be converted to UTF-8 bytes and encoded as a byte mode segment. */ public: static QrSegment makeBytes(const std::vector &data); /* * Returns a segment representing the given string of decimal digits encoded in numeric mode. */ public: static QrSegment makeNumeric(const char *digits); /* * Returns a segment representing the given text string encoded in alphanumeric mode. * The characters allowed are: 0 to 9, A to Z (uppercase only), space, * dollar, percent, asterisk, plus, hyphen, period, slash, colon. */ public: static QrSegment makeAlphanumeric(const char *text); /* * Returns a list of zero or more segments to represent the given text string. The result * may use various segment modes and switch modes to optimize the length of the bit stream. */ public: static std::vector makeSegments(const char *text); /* * Returns a segment representing an Extended Channel Interpretation * (ECI) designator with the given assignment value. */ public: static QrSegment makeEci(long assignVal); /*---- Public static helper functions ----*/ /* * Tests whether the given string can be encoded as a segment in alphanumeric mode. * A string is encodable iff each character is in the following set: 0 to 9, A to Z * (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon. */ public: static bool isAlphanumeric(const char *text); /* * Tests whether the given string can be encoded as a segment in numeric mode. * A string is encodable iff each character is in the range 0 to 9. */ public: static bool isNumeric(const char *text); /*---- Instance fields ----*/ /* The mode indicator of this segment. Accessed through getMode(). */ private: Mode mode; /* The length of this segment's unencoded data. Measured in characters for * numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode. * Always zero or positive. Not the same as the data's bit length. * Accessed through getNumChars(). */ private: int numChars; /* The data bits of this segment. Accessed through getData(). */ private: std::vector data; /*---- Constructors (low level) ----*/ /* * Creates a new QR Code segment with the given attributes and data. * The character count (numCh) must agree with the mode and the bit buffer length, * but the constraint isn't checked. The given bit buffer is copied and stored. */ public: QrSegment(Mode md, int numCh, const std::vector &dt); /* * Creates a new QR Code segment with the given parameters and data. * The character count (numCh) must agree with the mode and the bit buffer length, * but the constraint isn't checked. The given bit buffer is moved and stored. */ public: QrSegment(Mode md, int numCh, std::vector &&dt); /*---- Methods ----*/ /* * Returns the mode field of this segment. */ public: Mode getMode() const; /* * Returns the character count field of this segment. */ public: int getNumChars() const; /* * Returns the data bits of this segment. */ public: const std::vector &getData() const; // (Package-private) Calculates the number of bits needed to encode the given segments at // the given version. Returns a non-negative number if successful. Otherwise returns -1 if a // segment has too many characters to fit its length field, or the total bits exceeds INT_MAX. public: static int getTotalBits(const std::vector &segs, int version); /*---- Private constant ----*/ /* The set of all legal characters in alphanumeric mode, where * each character value maps to the index in the string. */ private: static const char *ALPHANUMERIC_CHARSET; }; /* * A QR Code symbol, which is a type of two-dimension barcode. * Invented by Denso Wave and described in the ISO/IEC 18004 standard. * Instances of this class represent an immutable square grid of black and white cells. * The class provides static factory functions to create a QR Code from text or binary data. * The class covers the QR Code Model 2 specification, supporting all versions (sizes) * from 1 to 40, all 4 error correction levels, and 4 character encoding modes. * * Ways to create a QR Code object: * - High level: Take the payload data and call QrCode::encodeText() or QrCode::encodeBinary(). * - Mid level: Custom-make the list of segments and call QrCode::encodeSegments(). * - Low level: Custom-make the array of data codeword bytes (including * segment headers and final padding, excluding error correction codewords), * supply the appropriate version number, and call the QrCode() constructor. * (Note that all ways require supplying the desired error correction level.) */ class QrCode final { /*---- Public helper enumeration ----*/ /* * The error correction level in a QR Code symbol. */ public: enum class Ecc { LOW = 0 , // The QR Code can tolerate about 7% erroneous codewords MEDIUM , // The QR Code can tolerate about 15% erroneous codewords QUARTILE, // The QR Code can tolerate about 25% erroneous codewords HIGH , // The QR Code can tolerate about 30% erroneous codewords }; // Returns a value in the range 0 to 3 (unsigned 2-bit integer). private: static int getFormatBits(Ecc ecl); /*---- Static factory functions (high level) ----*/ /* * Returns a QR Code representing the given Unicode text string at the given error correction level. * As a conservative upper bound, this function is guaranteed to succeed for strings that have 2953 or fewer * UTF-8 code units (not Unicode code points) if the low error correction level is used. The smallest possible * QR Code version is automatically chosen for the output. The ECC level of the result may be higher than * the ecl argument if it can be done without increasing the version. */ public: static QrCode encodeText(const char *text, Ecc ecl); /* * Returns a QR Code representing the given binary data at the given error correction level. * This function always encodes using the binary segment mode, not any text mode. The maximum number of * bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output. * The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version. */ public: static QrCode encodeBinary(const std::vector &data, Ecc ecl); /*---- Static factory functions (mid level) ----*/ /* * Returns a QR Code representing the given segments with the given encoding parameters. * The smallest possible QR Code version within the given range is automatically * chosen for the output. Iff boostEcl is true, then the ECC level of the result * may be higher than the ecl argument if it can be done without increasing the * version. The mask number is either between 0 to 7 (inclusive) to force that * mask, or -1 to automatically choose an appropriate mask (which may be slow). * This function allows the user to create a custom sequence of segments that switches * between modes (such as alphanumeric and byte) to encode text in less space. * This is a mid-level API; the high-level API is encodeText() and encodeBinary(). */ public: static QrCode encodeSegments(const std::vector &segs, Ecc ecl, int minVersion=1, int maxVersion=40, int mask=-1, bool boostEcl=true); // All optional parameters /*---- Instance fields ----*/ // Immutable scalar parameters: /* The version number of this QR Code, which is between 1 and 40 (inclusive). * This determines the size of this barcode. */ private: int version; /* The width and height of this QR Code, measured in modules, between * 21 and 177 (inclusive). This is equal to version * 4 + 17. */ private: int size; /* The error correction level used in this QR Code. */ private: Ecc errorCorrectionLevel; /* The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). * Even if a QR Code is created with automatic masking requested (mask = -1), * the resulting object still has a mask value between 0 and 7. */ private: int mask; // Private grids of modules/pixels, with dimensions of size*size: // The modules of this QR Code (false = white, true = black). // Immutable after constructor finishes. Accessed through getModule(). private: std::vector > modules; // Indicates function modules that are not subjected to masking. Discarded when constructor finishes. private: std::vector > isFunction; /*---- Constructor (low level) ----*/ /* * Creates a new QR Code with the given version number, * error correction level, data codeword bytes, and mask number. * This is a low-level API that most users should not use directly. * A mid-level API is the encodeSegments() function. */ public: QrCode(int ver, Ecc ecl, const std::vector &dataCodewords, int msk); /*---- Public instance methods ----*/ /* * Returns this QR Code's version, in the range [1, 40]. */ public: int getVersion() const; /* * Returns this QR Code's size, in the range [21, 177]. */ public: int getSize() const; /* * Returns this QR Code's error correction level. */ public: Ecc getErrorCorrectionLevel() const; /* * Returns this QR Code's mask, in the range [0, 7]. */ public: int getMask() const; /* * Returns the color of the module (pixel) at the given coordinates, which is false * for white or true for black. The top left corner has the coordinates (x=0, y=0). * If the given coordinates are out of bounds, then false (white) is returned. */ public: bool getModule(int x, int y) const; /* * Returns a string of SVG code for an image depicting this QR Code, with the given number * of border modules. The string always uses Unix newlines (\n), regardless of the platform. */ public: std::string toSvgString(int border) const; /*---- Private helper methods for constructor: Drawing function modules ----*/ // Reads this object's version field, and draws and marks all function modules. private: void drawFunctionPatterns(); // Draws two copies of the format bits (with its own error correction code) // based on the given mask and this object's error correction level field. private: void drawFormatBits(int msk); // Draws two copies of the version bits (with its own error correction code), // based on this object's version field, iff 7 <= version <= 40. private: void drawVersion(); // Draws a 9*9 finder pattern including the border separator, // with the center module at (x, y). Modules can be out of bounds. private: void drawFinderPattern(int x, int y); // Draws a 5*5 alignment pattern, with the center module // at (x, y). All modules must be in bounds. private: void drawAlignmentPattern(int x, int y); // Sets the color of a module and marks it as a function module. // Only used by the constructor. Coordinates must be in bounds. private: void setFunctionModule(int x, int y, bool isBlack); // Returns the color of the module at the given coordinates, which must be in range. private: bool module(int x, int y) const; /*---- Private helper methods for constructor: Codewords and masking ----*/ // Returns a new byte string representing the given data with the appropriate error correction // codewords appended to it, based on this object's version and error correction level. private: std::vector addEccAndInterleave(const std::vector &data) const; // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // data area of this QR Code. Function modules need to be marked off before this is called. private: void drawCodewords(const std::vector &data); // XORs the codeword modules in this QR Code with the given mask pattern. // The function modules must be marked and the codeword bits must be drawn // before masking. Due to the arithmetic of XOR, calling applyMask() with // the same mask value a second time will undo the mask. A final well-formed // QR Code needs exactly one (not zero, two, etc.) mask applied. private: void applyMask(int msk); // Calculates and returns the penalty score based on state of this QR Code's current modules. // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score. private: long getPenaltyScore() const; /*---- Private helper functions ----*/ // Returns an ascending list of positions of alignment patterns for this version number. // Each position is in the range [0,177), and are used on both the x and y axes. // This could be implemented as lookup table of 40 variable-length lists of unsigned bytes. private: std::vector getAlignmentPatternPositions() const; // Returns the number of data bits that can be stored in a QR Code of the given version number, after // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. private: static int getNumRawDataModules(int ver); // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any // QR Code of the given version number and error correction level, with remainder bits discarded. // This stateless pure function could be implemented as a (40*4)-cell lookup table. private: static int getNumDataCodewords(int ver, Ecc ecl); // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be // implemented as a lookup table over all possible parameter values, instead of as an algorithm. private: static std::vector reedSolomonComputeDivisor(int degree); // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials. private: static std::vector reedSolomonComputeRemainder(const std::vector &data, const std::vector &divisor); // Returns the product of the two given field elements modulo GF(2^8/0x11D). // All inputs are valid. This could be implemented as a 256*256 lookup table. private: static std::uint8_t reedSolomonMultiply(std::uint8_t x, std::uint8_t y); // Can only be called immediately after a white run is added, and // returns either 0, 1, or 2. A helper function for getPenaltyScore(). private: int finderPenaltyCountPatterns(const std::array &runHistory) const; // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore(). private: int finderPenaltyTerminateAndCount(bool currentRunColor, int currentRunLength, std::array &runHistory) const; // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore(). private: void finderPenaltyAddHistory(int currentRunLength, std::array &runHistory) const; // Returns true iff the i'th bit of x is set to 1. private: static bool getBit(long x, int i); /*---- Constants and tables ----*/ // The minimum version number supported in the QR Code Model 2 standard. public: static constexpr int MIN_VERSION = 1; // The maximum version number supported in the QR Code Model 2 standard. public: static constexpr int MAX_VERSION = 40; // For use in getPenaltyScore(), when evaluating which mask is best. private: static const int PENALTY_N1; private: static const int PENALTY_N2; private: static const int PENALTY_N3; private: static const int PENALTY_N4; private: static const std::int8_t ECC_CODEWORDS_PER_BLOCK[4][41]; private: static const std::int8_t NUM_ERROR_CORRECTION_BLOCKS[4][41]; }; /*---- Public exception class ----*/ /* * Thrown when the supplied data does not fit any QR Code version. Ways to handle this exception include: * - Decrease the error correction level if it was greater than Ecc::LOW. * - If the encodeSegments() function was called with a maxVersion argument, then increase * it if it was less than QrCode::MAX_VERSION. (This advice does not apply to the other * factory functions because they search all versions up to QrCode::MAX_VERSION.) * - Split the text data into better or optimal segments in order to reduce the number of bits required. * - Change the text or binary data to be shorter. * - Change the text to fit the character set of a particular segment mode (e.g. alphanumeric). * - Propagate the error upward to the caller/user. */ class data_too_long : public std::length_error { public: explicit data_too_long(const std::string &msg); }; /* * An appendable sequence of bits (0s and 1s). Mainly used by QrSegment. */ class BitBuffer final : public std::vector { /*---- Constructor ----*/ // Creates an empty bit buffer (length 0). public: BitBuffer(); /*---- Method ----*/ // Appends the given number of low-order bits of the given value // to this buffer. Requires 0 <= len <= 31 and val < 2^len. public: void appendBits(std::uint32_t val, int len); }; } ================================================ FILE: phonelibs/snpe/include/DiagLog/IDiagLog.hpp ================================================ //============================================================================= // // Copyright (c) 2015, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef __IDIAGLOG_HPP_ #define __IDIAGLOG_HPP_ #include #include "DiagLog/Options.hpp" #include "DlSystem/String.hpp" #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace DiagLog { /** @addtogroup c_plus_plus_apis C++ @{ */ /// @brief . /// /// Interface for controlling logging for zdl components. class ZDL_EXPORT IDiagLog { public: /// @brief . /// /// Sets the options after initialization occurs. /// /// @param[in] loggingOptions The options to set up diagnostic logging. /// /// @return False if the options could not be set. Ensure logging is not started. virtual bool setOptions(const Options& loggingOptions) = 0; /// @brief . /// /// Gets the curent options for the diag logger. /// /// @return Diag log options object. virtual Options getOptions() = 0; /// @brief . /// /// Allows for setting the log mask once diag logging has started /// /// @return True if the level was set successfully, false if a failure occurred. virtual bool setDiagLogMask(const std::string& mask) = 0; /// @brief . /// /// Allows for setting the log mask once diag logging has started /// /// @return True if the level was set successfully, false if a failure occurred. virtual bool setDiagLogMask(const zdl::DlSystem::String& mask) = 0; /// @brief . /// /// Enables logging for zdl components. /// /// Logging should be started prior to the instantiation of zdl components /// to ensure all events are captured. /// /// @return False if diagnostic logging could not be started. virtual bool start(void) = 0; /// @brief Disables logging for zdl components. virtual bool stop(void) = 0; virtual ~IDiagLog() {}; }; } // DiagLog namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif ================================================ FILE: phonelibs/snpe/include/DiagLog/Options.hpp ================================================ //============================================================================= // // Copyright (c) 2015, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef __DIAGLOG_OPTIONS_HPP_ #define __DIAGLOG_OPTIONS_HPP_ #include #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace DiagLog { /** @addtogroup c_plus_plus_apis C++ @{ */ /// @brief . /// /// Options for setting up diagnostic logging for zdl components. class ZDL_EXPORT Options { public: Options() : DiagLogMask(""), LogFileDirectory("diaglogs"), LogFileName("DiagLog"), LogFileRotateCount(20), LogFileReplace(true) { // Solves the empty string problem with multiple std libs DiagLogMask.reserve(1); } /// @brief . /// /// Enables diag logging only on the specified area mask (DNN_RUNTIME=ON | OFF) std::string DiagLogMask; /// @brief . /// /// The path to the directory where log files will be written. /// The path may be relative or absolute. Relative paths are interpreted /// from the current working directory. /// Default value is "diaglogs" std::string LogFileDirectory; /// @brief . /// //// The name used for log files. If this value is empty then BaseName will be /// used as the default file name. /// Default value is "DiagLog" std::string LogFileName; /// @brief . /// /// The maximum number of log files to create. If set to 0 no log rotation /// will be used and the log file name specified will be used each time, overwriting /// any existing log file that may exist. /// Default value is 20 uint32_t LogFileRotateCount; /// @brief /// /// If the log file already exists, control whether it will be replaced /// (existing contents truncated), or appended. /// Default value is true bool LogFileReplace; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // DiagLog namespace } // zdl namespace #endif ================================================ FILE: phonelibs/snpe/include/DlContainer/IDlContainer.hpp ================================================ //============================================================================= // // Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef ZEROTH_IDNC_CONTAINER_HPP #define ZEROTH_IDNC_CONTAINER_HPP #include #include #include #include #include #include "DlSystem/ZdlExportDefine.hpp" #include "DlSystem/String.hpp" namespace zdl { namespace DlContainer { /** @addtogroup c_plus_plus_apis C++ @{ */ class IDlContainer; class dlc_error; /** * The structure of a record in a DL container. */ struct ZDL_EXPORT DlcRecord { /// Name of the record. std::string name; /// Byte blob holding the data for the record. std::vector data; DlcRecord(); DlcRecord( DlcRecord&& other ) : name(std::move(other.name)) , data(std::move(other.data)) {} DlcRecord(const std::string& new_name) : name(new_name) , data() { if(name.empty()) { name.reserve(1); } } DlcRecord(const DlcRecord&) = delete; }; // The maximum length of any record name. extern const uint32_t RECORD_NAME_MAX_SIZE; // The maximum size of the record payload (bytes). extern const uint32_t RECORD_DATA_MAX_SIZE; // The maximum number of records in an archive at one time. extern const uint32_t ARCHIVE_MAX_RECORDS; /** * Represents a container for a neural network model which can * be used to load the model into the SNPE runtime. */ class ZDL_EXPORT IDlContainer { public: /** * Initializes a container from a container archive file. * * @param[in] filename Container archive file path. * * @return A pointer to the initialized container */ static std::unique_ptr open(const std::string &filename) noexcept; /** * Initializes a container from a container archive file. * * @param[in] filename Container archive file path. * * @return A pointer to the initialized container */ static std::unique_ptr open(const zdl::DlSystem::String &filename) noexcept; /** * Initializes a container from a byte buffer. * * @param[in] buffer Byte buffer holding the contents of an archive * file. * * @return A pointer to the initialized container */ static std::unique_ptr open(const std::vector &buffer) noexcept; /** * Initializes a container from a byte buffer. * * @param[in] buffer Byte buffer holding the contents of an archive * file. * * @param[in] size Size of the byte buffer. * * @return A pointer to the initialized container */ static std::unique_ptr open(const uint8_t* buffer, const size_t size) noexcept; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ /** * Get the record catalog for a container. * * @param[out] catalog Buffer that will hold the record names on * return. */ virtual void getCatalog(std::set &catalog) const = 0; /** * Get the record catalog for a container. * * @param[out] catalog Buffer that will hold the record names on * return. */ virtual void getCatalog(std::set &catalog) const = 0; /** * Get a record from a container by name. * * @param[in] name Name of the record to fetch. * @param[out] record The passed in record will be populated with the * record data on return. Note that the caller * will own the data in the record and is * responsible for freeing it if needed. */ virtual void getRecord(const std::string &name, DlcRecord &record) const = 0; /** * Get a record from a container by name. * * @param[in] name Name of the record to fetch. * @param[out] record The passed in record will be populated with the * record data on return. Note that the caller * will own the data in the record and is * responsible for freeing it if needed. */ virtual void getRecord(const zdl::DlSystem::String &name, DlcRecord &record) const = 0; /** * Save the container to an archive on disk. This function will save the * container if the filename is different from the file that it was opened * from, or if at least one record was modified since the container was * opened. * * It will truncate any existing file at the target path. * * @param filename Container archive file path. * * @return indication of success/failure */ virtual bool save(const std::string &filename) = 0; /** * Save the container to an archive on disk. This function will save the * container if the filename is different from the file that it was opened * from, or if at least one record was modified since the container was * opened. * * It will truncate any existing file at the target path. * * @param filename Container archive file path. * * @return indication of success/failure */ virtual bool save (const zdl::DlSystem::String &filename) = 0; virtual ~IDlContainer() {} }; } // ns DlContainer } // ns zdl #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/DlEnums.hpp ================================================ //============================================================================== // // Copyright (c) 2014-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _DL_ENUMS_HPP_ #define _DL_ENUMS_HPP_ #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * Enumeration of supported target runtimes. */ enum class Runtime_t { /// Run the processing on Snapdragon CPU. /// Data: float 32bit /// Math: float 32bit CPU_FLOAT32 = 0, /// Run the processing on the Adreno GPU. /// Data: float 16bit /// Math: float 32bit GPU_FLOAT32_16_HYBRID = 1, /// Run the processing on the Hexagon DSP. /// Data: 8bit fixed point Tensorflow style format /// Math: 8bit fixed point Tensorflow style format DSP_FIXED8_TF = 2, /// Run the processing on the Adreno GPU. /// Data: float 16bit /// Math: float 16bit GPU_FLOAT16 = 3, /// Run the processing on Snapdragon AIX+HVX. /// Data: 8bit fixed point Tensorflow style format /// Math: 8bit fixed point Tensorflow style format AIP_FIXED8_TF = 5, AIP_FIXED_TF = AIP_FIXED8_TF, /// Default legacy enum to retain backward compatibility. /// CPU = CPU_FLOAT32 CPU = CPU_FLOAT32, /// Default legacy enum to retain backward compatibility. /// GPU = GPU_FLOAT32_16_HYBRID GPU = GPU_FLOAT32_16_HYBRID, /// Default legacy enum to retain backward compatibility. /// DSP = DSP_FIXED8_TF DSP = DSP_FIXED8_TF, /// Special value indicating the property is unset. UNSET = -1 }; /** * Enumeration of runtime available check options. */ enum class RuntimeCheckOption_t { /// Perform standard runtime available check DEFAULT = 0, /// Perform standard runtime available check NORMAL_CHECK = 0, /// Perform basic runtime available check, may be runtime specific BASIC_CHECK = 1, }; /** * Enumeration of various performance profiles that can be requested. */ enum class PerformanceProfile_t { /// Run in a standard mode. /// This mode will be deprecated in the future and replaced with BALANCED. DEFAULT = 0, /// Run in a balanced mode. BALANCED = 0, /// Run in high performance mode HIGH_PERFORMANCE = 1, /// Run in a power sensitive mode, at the expense of performance. POWER_SAVER = 2, /// Use system settings. SNPE makes no calls to any performance related APIs. SYSTEM_SETTINGS = 3, /// Run in sustained high performance mode SUSTAINED_HIGH_PERFORMANCE = 4, /// Run in burst mode BURST = 5, /// Run in lower clock than POWER_SAVER, at the expense of performance. LOW_POWER_SAVER = 6, /// Run in higher clock and provides better performance than POWER_SAVER. HIGH_POWER_SAVER = 7, /// Run in lower balanced mode LOW_BALANCED = 8, }; /** * Enumeration of various profilngLevels that can be requested. */ enum class ProfilingLevel_t { /// No profiling. /// Collects no runtime stats in the DiagLog OFF = 0, /// Basic profiling /// Collects some runtime stats in the DiagLog BASIC = 1, /// Detailed profiling /// Collects more runtime stats in the DiagLog, including per-layer statistics /// Performance may be impacted DETAILED = 2, /// Moderate profiling /// Collects more runtime stats in the DiagLog, no per-layer statistics MODERATE = 3 }; /** * Enumeration of various execution priority hints. */ enum class ExecutionPriorityHint_t { /// Normal priority NORMAL = 0, /// Higher than normal priority HIGH = 1, /// Lower priority LOW = 2 }; /** @} */ /* end_addtogroup c_plus_plus_apis C++*/ /** * Enumeration that lists the supported image encoding formats. */ enum class ImageEncoding_t { /// For unknown image type. Also used as a default value for ImageEncoding_t. UNKNOWN = 0, /// The RGB format consists of 3 bytes per pixel: one byte for /// Red, one for Green, and one for Blue. The byte ordering is /// endian independent and is always in RGB byte order. RGB = 1, /// The ARGB32 format consists of 4 bytes per pixel: one byte for /// Red, one for Green, one for Blue, and one for the alpha channel. /// The alpha channel is ignored. The byte ordering depends on the /// underlying CPU. For little endian CPUs, the byte order is BGRA. /// For big endian CPUs, the byte order is ARGB. ARGB32 = 2, /// The RGBA format consists of 4 bytes per pixel: one byte for /// Red, one for Green, one for Blue, and one for the alpha channel. /// The alpha channel is ignored. The byte ordering is endian independent /// and is always in RGBA byte order. RGBA = 3, /// The GRAYSCALE format is for 8-bit grayscale. GRAYSCALE = 4, /// NV21 is the Android version of YUV. The Chrominance is down /// sampled and has a subsampling ratio of 4:2:0. Note that this /// image format has 3 channels, but the U and V channels /// are subsampled. For every four Y pixels there is one U and one V pixel. @newpage NV21 = 5, /// The BGR format consists of 3 bytes per pixel: one byte for /// Red, one for Green and one for Blue. The byte ordering is /// endian independent and is always BGR byte order. BGR = 6 }; }} // namespaces end #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/DlError.hpp ================================================ //============================================================================== // // Copyright (c) 2016-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _DL_ERROR_HPP_ #define _DL_ERROR_HPP_ #include #include // numeric_limits #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { // clang and arm gcc different in how ZDL_EXPORT is used with enum class #if !defined (__clang__) enum class ErrorCode : uint32_t ZDL_EXPORT { #else enum class ZDL_EXPORT ErrorCode : uint32_t { #endif // ARM64V8A NONE = 0, // System config errors SNPE_CONFIG_MISSING_PARAM = 100, SNPE_CONFIG_INVALID_PARAM = 101, SNPE_CONFIG_MISSING_FILE = 102, SNPE_CONFIG_NNCONFIG_NOT_SET = 103, SNPE_CONFIG_NNCONFIG_INVALID = 104, SNPE_CONFIG_WRONG_INPUT_NAME = 105, SNPE_CONFIG_INCORRECT_INPUT_DIMENSIONS = 106, SNPE_CONFIG_DIMENSIONS_MODIFICATION_NOT_SUPPORTED = 107, SNPE_CONFIG_BOTH_OUTPUT_LAYER_TENSOR_NAMES_SET = 108, SNPE_CONFIG_NNCONFIG_ONLY_TENSOR_SUPPORTED = 120, SNPE_CONFIG_NNCONFIG_ONLY_USER_BUFFER_SUPPORTED = 121, // DlSystem errors SNPE_DLSYSTEM_MISSING_BUFFER = 200, SNPE_DLSYSTEM_TENSOR_CAST_FAILED = 201, SNPE_DLSYSTEM_FIXED_POINT_PARAM_INVALID = 202, SNPE_DLSYSTEM_SIZE_MISMATCH = 203, SNPE_DLSYSTEM_NAME_NOT_FOUND = 204, SNPE_DLSYSTEM_VALUE_MISMATCH = 205, SNPE_DLSYSTEM_INSERT_FAILED = 206, SNPE_DLSYSTEM_TENSOR_FILE_READ_FAILED = 207, SNPE_DLSYSTEM_DIAGLOG_FAILURE = 208, SNPE_DLSYSTEM_LAYER_NOT_SET = 209, SNPE_DLSYSTEM_WRONG_NUMBER_INPUT_BUFFERS = 210, SNPE_DLSYSTEM_RUNTIME_TENSOR_SHAPE_MISMATCH = 211, SNPE_DLSYSTEM_TENSOR_MISSING = 212, SNPE_DLSYSTEM_TENSOR_ITERATION_UNSUPPORTED = 213, SNPE_DLSYSTEM_BUFFER_MANAGER_MISSING = 214, SNPE_DLSYSTEM_RUNTIME_BUFFER_SOURCE_UNSUPPORTED = 215, SNPE_DLSYSTEM_BUFFER_CAST_FAILED = 216, SNPE_DLSYSTEM_WRONG_TRANSITION_TYPE = 217, SNPE_DLSYSTEM_LAYER_ALREADY_REGISTERED = 218, SNPE_DLSYSTEM_BUFFERENCODING_UNKNOWN = 240, SNPE_DLSYSTEM_BUFFER_INVALID_PARAM = 241, // DlContainer errors SNPE_DLCONTAINER_MODEL_PARSING_FAILED = 300, SNPE_DLCONTAINER_UNKNOWN_LAYER_CODE = 301, SNPE_DLCONTAINER_MISSING_LAYER_PARAM = 302, SNPE_DLCONTAINER_LAYER_PARAM_NOT_SUPPORTED = 303, SNPE_DLCONTAINER_LAYER_PARAM_INVALID = 304, SNPE_DLCONTAINER_TENSOR_DATA_MISSING = 305, SNPE_DLCONTAINER_MODEL_LOAD_FAILED = 306, SNPE_DLCONTAINER_MISSING_RECORDS = 307, SNPE_DLCONTAINER_INVALID_RECORD = 308, SNPE_DLCONTAINER_WRITE_FAILURE = 309, SNPE_DLCONTAINER_READ_FAILURE = 310, SNPE_DLCONTAINER_BAD_CONTAINER = 311, SNPE_DLCONTAINER_BAD_DNN_FORMAT_VERSION = 312, SNPE_DLCONTAINER_UNKNOWN_AXIS_ANNOTATION = 313, SNPE_DLCONTAINER_UNKNOWN_SHUFFLE_TYPE = 314, SNPE_DLCONTAINER_TEMP_FILE_FAILURE = 315, // Network errors SNPE_NETWORK_EMPTY_NETWORK = 400, SNPE_NETWORK_CREATION_FAILED = 401, SNPE_NETWORK_PARTITION_FAILED = 402, SNPE_NETWORK_NO_OUTPUT_DEFINED = 403, SNPE_NETWORK_MISMATCH_BETWEEN_NAMES_AND_DIMS = 404, SNPE_NETWORK_MISSING_INPUT_NAMES = 405, SNPE_NETWORK_MISSING_OUTPUT_NAMES = 406, // Host runtime errors SNPE_HOST_RUNTIME_TARGET_UNAVAILABLE = 500, // CPU runtime errors SNPE_CPU_LAYER_NOT_SUPPORTED = 600, SNPE_CPU_LAYER_PARAM_NOT_SUPPORTED = 601, SNPE_CPU_LAYER_PARAM_INVALID = 602, SNPE_CPU_LAYER_PARAM_COMBINATION_INVALID = 603, SNPE_CPU_BUFFER_NOT_FOUND = 604, SNPE_CPU_NETWORK_NOT_SUPPORTED = 605, SNPE_CPU_UDO_OPERATION_FAILED = 606, // CPU fixed-point runtime errors SNPE_CPU_FXP_LAYER_NOT_SUPPORTED = 700, SNPE_CPU_FXP_LAYER_PARAM_NOT_SUPPORTED = 701, SNPE_CPU_FXP_LAYER_PARAM_INVALID = 702, // GPU runtime errors SNPE_GPU_LAYER_NOT_SUPPORTED = 800, SNPE_GPU_LAYER_PARAM_NOT_SUPPORTED = 801, SNPE_GPU_LAYER_PARAM_INVALID = 802, SNPE_GPU_LAYER_PARAM_COMBINATION_INVALID = 803, SNPE_GPU_KERNEL_COMPILATION_FAILED = 804, SNPE_GPU_CONTEXT_NOT_SET = 805, SNPE_GPU_KERNEL_NOT_SET = 806, SNPE_GPU_KERNEL_PARAM_INVALID = 807, SNPE_GPU_OPENCL_CHECK_FAILED = 808, SNPE_GPU_OPENCL_FUNCTION_ERROR = 809, SNPE_GPU_BUFFER_NOT_FOUND = 810, SNPE_GPU_TENSOR_DIM_INVALID = 811, SNPE_GPU_MEMORY_FLAGS_INVALID = 812, SNPE_GPU_UNEXPECTED_NUMBER_OF_IO = 813, SNPE_GPU_LAYER_PROXY_ERROR = 814, SNPE_GPU_BUFFER_IN_USE = 815, SNPE_GPU_BUFFER_MODIFICATION_ERROR = 816, SNPE_GPU_DATA_ARRANGEMENT_INVALID = 817, SNPE_GPU_UDO_OPERATION_FAILED = 818, // DSP runtime errors SNPE_DSP_LAYER_NOT_SUPPORTED = 900, SNPE_DSP_LAYER_PARAM_NOT_SUPPORTED = 901, SNPE_DSP_LAYER_PARAM_INVALID = 902, SNPE_DSP_LAYER_PARAM_COMBINATION_INVALID = 903, SNPE_DSP_STUB_NOT_PRESENT = 904, SNPE_DSP_LAYER_NAME_TRUNCATED = 905, SNPE_DSP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 906, SNPE_DSP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 907, SNPE_DSP_RUNTIME_COMMUNICATION_ERROR = 908, SNPE_DSP_RUNTIME_INVALID_PARAM_ERROR = 909, SNPE_DSP_RUNTIME_SYSTEM_ERROR = 910, SNPE_DSP_RUNTIME_CRASHED_ERROR = 911, // Model validataion errors SNPE_MODEL_VALIDATION_LAYER_NOT_SUPPORTED = 1000, SNPE_MODEL_VALIDATION_LAYER_PARAM_NOT_SUPPORTED = 1001, SNPE_MODEL_VALIDATION_LAYER_PARAM_INVALID = 1002, SNPE_MODEL_VALIDATION_LAYER_PARAM_MISSING = 1003, SNPE_MODEL_VALIDATION_LAYER_PARAM_COMBINATION_INVALID = 1004, SNPE_MODEL_VALIDATION_LAYER_ORDERING_INVALID = 1005, SNPE_MODEL_VALIDATION_INVALID_CONSTRAINT = 1006, SNPE_MODEL_VALIDATION_MISSING_BUFFER = 1007, SNPE_MODEL_VALIDATION_BUFFER_REUSE_NOT_SUPPORTED = 1008, SNPE_MODEL_VALIDATION_LAYER_COULD_NOT_BE_ASSIGNED = 1009, SNPE_MODEL_VALIDATION_UDO_LAYER_FAILED = 1010, // UDL errors SNPE_UDL_LAYER_EMPTY_UDL_NETWORK = 1100, SNPE_UDL_LAYER_PARAM_INVALID = 1101, SNPE_UDL_LAYER_INSTANCE_MISSING = 1102, SNPE_UDL_LAYER_SETUP_FAILED = 1103, SNPE_UDL_EXECUTE_FAILED = 1104, SNPE_UDL_BUNDLE_INVALID = 1105, SNPE_UDO_REGISTRATION_FAILED = 1106, SNPE_UDO_GET_PACKAGE_FAILED = 1107, SNPE_UDO_GET_IMPLEMENTATION_FAILED = 1108, // Dependent library errors SNPE_STD_LIBRARY_ERROR = 1200, // Unknown exception (catch (...)), Has no component attached to this SNPE_UNKNOWN_EXCEPTION = 1210, // Storage Errors SNPE_STORAGE_INVALID_KERNEL_REPO = 1300, // AIP runtime errors SNPE_AIP_LAYER_NOT_SUPPORTED = 1400, SNPE_AIP_LAYER_PARAM_NOT_SUPPORTED = 1401, SNPE_AIP_LAYER_PARAM_INVALID = 1402, SNPE_AIP_LAYER_PARAM_COMBINATION_INVALID = 1403, SNPE_AIP_STUB_NOT_PRESENT = 1404, SNPE_AIP_LAYER_NAME_TRUNCATED = 1405, SNPE_AIP_LAYER_INPUT_BUFFER_NAME_TRUNCATED = 1406, SNPE_AIP_LAYER_OUTPUT_BUFFER_NAME_TRUNCATED = 1407, SNPE_AIP_RUNTIME_COMMUNICATION_ERROR = 1408, SNPE_AIP_RUNTIME_INVALID_PARAM_ERROR = 1409, SNPE_AIP_RUNTIME_SYSTEM_ERROR = 1410, SNPE_AIP_RUNTIME_TENSOR_MISSING = 1411, SNPE_AIP_RUNTIME_TENSOR_SHAPE_MISMATCH = 1412, SNPE_AIP_RUNTIME_BAD_AIX_RECORD = 1413, // DlCaching errors SNPE_DLCACHING_INVALID_METADATA = 1500, SNPE_DLCACHING_INVALID_INITBLOB = 1501, // Infrastructure Errors SNPE_INFRA_CLUSTERMGR_INSTANCE_INVALID = 1600, SNPE_INFRA_CLUSTERMGR_EXECUTE_SYNC_FAILED = 1601 }; /** @addtogroup c_plus_plus_apis C++ @{ */ /** * Returns the error code of the last error encountered. * * @return The error code. * * @note The returned error code is significant only when the return * value of the call indicated an error. */ ZDL_EXPORT ErrorCode getLastErrorCode(); /** * Returns the error string of the last error encountered. * * @return The error string. * * @note The returned error string is significant only when the return * value of the call indicated an error. */ ZDL_EXPORT const char* getLastErrorString(); /** * Returns the info string of the last error encountered. */ ZDL_EXPORT const char* getLastInfoString(); /** * Returns the uint32_t representation of the error code enum. * * @param[in] code The error code to be converted. * * @return uint32_t representation of the error code. */ ZDL_EXPORT uint32_t enumToUInt32(zdl::DlSystem::ErrorCode code); /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // DlSystem } // zdl #endif // _DL_ERROR_HPP_ ================================================ FILE: phonelibs/snpe/include/DlSystem/DlOptional.hpp ================================================ //============================================================================== // // Copyright (c) 2016, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _DL_SYSTEM_OPTIONAL_HPP_ #define _DL_SYSTEM_OPTIONAL_HPP_ #include #include #include #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { template /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * Class to manage a value that may or may not exist. The boolean value * of the Optional class is true if the object contains a value and false * if it does not contain a value. * * The class must be evaluated and confirmed as true (containing a value) * before being dereferenced. */ class ZDL_EXPORT Optional final { public: enum class LIFECYCLE { NONE = 0, REFERENCE_OWNED = 1, POINTER_OWNED = 2, POINTER_NOT_OWNED = 3 }; struct ReferenceCount { size_t count = 0; void increment() { count++; } size_t decrement() { if (count > 0) { count--; } return count; } }; using U = typename std::remove_pointer::type; /** * The default constructor is set to not have any value, and is * therefore evaluated as false. */ // Do not explicit it so we can return {} Optional() { m_Type = LIFECYCLE::NONE; } /** * Construct an Optional class using an object. * @param[in] Reference to an object v * @param[out] Optional instance of object v */ template Optional (const T& v, typename std::enable_if::value>::type* = 0) : m_Type(LIFECYCLE::REFERENCE_OWNED) { try { m_StoragePtr = new T(v); } catch (...) { m_StoragePtr = nullptr; m_Type = LIFECYCLE::NONE; } } template Optional(U* v, LIFECYCLE type, typename std::enable_if::value>::type* = 0) : m_Type(type) { switch (m_Type) { case LIFECYCLE::POINTER_OWNED: m_StoragePtr = v; m_Count = new ReferenceCount(); m_Count->increment(); break; case LIFECYCLE::POINTER_NOT_OWNED: m_StoragePtr = v; break; case LIFECYCLE::REFERENCE_OWNED: throw std::bad_exception(); case LIFECYCLE::NONE: break; } } Optional(const Optional &other) : m_Type(other.m_Type), m_Count(other.m_Count) { if (isReference()) { m_StoragePtr = new U(*other.m_StoragePtr); } else if (isPointer()) { m_StoragePtr = other.m_StoragePtr; if (isOwned()) { m_Count->increment(); } } } Optional& operator=(const Optional& other) noexcept { Optional tmp(other); swap(std::move(tmp)); return *this; } Optional(Optional&& other) noexcept { swap(std::move(other)); } Optional& operator=(Optional&& other) noexcept { swap(std::move(other)); return *this; } ~Optional() { if (isOwned()) { if (isReference() || (isPointer() && m_Count->decrement() == 0)) { delete m_StoragePtr; delete m_Count; } } } /** * Boolean value of Optional class is only true when there exists a value. */ operator bool() const noexcept { return isValid(); } bool operator!() const noexcept { return !isValid(); } /** * Get reference of Optional object * @warning User must validate Optional has value before. */ const T& operator*() { return this->GetReference(); } /** * Get reference of Optional object * @warning User must validate Optional has value before. */ const T& operator*() const { return this->GetReference(); } operator T&() { return this->GetReference(); } T operator->() { T self = this->GetReference(); return self; } private: void swap(Optional&& other) { m_Type = other.m_Type; m_StoragePtr = other.m_StoragePtr; m_Count = other.m_Count; other.m_Type = LIFECYCLE::NONE; other.m_StoragePtr = nullptr; other.m_Count = nullptr; } template typename std::enable_if::value, const Q&>::type GetReference() const noexcept { if (!isReference()) std::terminate(); return *static_cast(m_StoragePtr); } template typename std::enable_if::value, const Q&>::type GetReference() const noexcept { if (!isPointer()) std::terminate(); return static_cast(m_StoragePtr); } template typename std::enable_if::value, Q&>::type GetReference() noexcept { if (!isReference()) std::terminate(); return *m_StoragePtr; } template typename std::enable_if::value, Q&>::type GetReference() noexcept { if (!isPointer()) std::terminate(); return m_StoragePtr; } bool isPointer() const { return m_Type == LIFECYCLE::POINTER_OWNED || m_Type == LIFECYCLE::POINTER_NOT_OWNED; } bool isOwned() const { return m_Type == LIFECYCLE::REFERENCE_OWNED || m_Type == LIFECYCLE::POINTER_OWNED; } bool isReference() const { return m_Type == LIFECYCLE::REFERENCE_OWNED; } bool isValid() const { return m_Type != LIFECYCLE::NONE; } U* m_StoragePtr = nullptr; LIFECYCLE m_Type; ReferenceCount *m_Count = nullptr; }; } // ns DlSystem } // ns zdl /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // _DL_SYSTEM_OPTIONAL_HPP_ ================================================ FILE: phonelibs/snpe/include/DlSystem/DlVersion.hpp ================================================ //============================================================================== // // Copyright (c) 2014-2015 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _DL_VERSION_HPP_ #define _DL_VERSION_HPP_ #include "ZdlExportDefine.hpp" #include #include #include "DlSystem/String.hpp" namespace zdl { namespace DlSystem { class Version_t; }} namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * A class that contains the different portions of a version number. */ class ZDL_EXPORT Version_t { public: /// Holds the major version number. Changes in this value indicate /// major changes that break backward compatibility. int32_t Major; /// Holds the minor version number. Changes in this value indicate /// minor changes made to library that are backwards compatible /// (such as additions to the interface). int32_t Minor; /// Holds the teeny version number. Changes in this value indicate /// changes such as bug fixes and patches made to the library that /// do not affect the interface. int32_t Teeny; /// This string holds information about the build version. /// std::string Build; static zdl::DlSystem::Version_t fromString(const std::string &stringValue); static zdl::DlSystem::Version_t fromString(const zdl::DlSystem::String &stringValue); /** * @brief Returns a string in the form Major.Minor.Teeny.Build * * @return A formatted string holding the version information. */ const std::string toString() const; /** * @brief Returns a string in the form Major.Minor.Teeny.Build * * @return A formatted string holding the version information. */ const zdl::DlSystem::String asString() const; }; }} /** @} */ /* end_addtogroup c_plus_plus_apis */ #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/IBufferAttributes.hpp ================================================ //============================================================================== // // Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _IBUFFER_ATTRIBUTES_HPP #define _IBUFFER_ATTRIBUTES_HPP #include "IUserBuffer.hpp" #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { class UserBufferEncoding; } } namespace zdl { namespace DlSystem { /** * @brief IBufferAttributes returns a buffer's dimension and alignment * requirements, along with info on its encoding type */ class ZDL_EXPORT IBufferAttributes { public: /** * @brief Gets the buffer's element size, in bytes * * This can be used to compute the memory size required * to back this buffer. * * @return Element size, in bytes */ virtual size_t getElementSize() const noexcept = 0; /** * @brief Gets the element's encoding type * * @return encoding type */ virtual zdl::DlSystem::UserBufferEncoding::ElementType_t getEncodingType() const noexcept = 0; /** * @brief Gets the number of elements in each dimension * * @return Dimension size, in terms of number of elements */ virtual const TensorShape getDims() const noexcept = 0; /** * @brief Gets the alignment requirement of each dimension * * Alignment per each dimension is expressed as an multiple, for * example, if one particular dimension can accept multiples of 8, * the alignment will be 8. * * @return Alignment in each dimension, in terms of multiple of * number of elements */ virtual const TensorShape getAlignments() const noexcept = 0; /** * @brief Gets the buffer encoding returned from the network responsible * for generating this buffer. Depending on the encoding type, this will * be an instance of an encoding type specific derived class. * * @return Derived user buffer encoding object. */ virtual zdl::DlSystem::UserBufferEncoding* getEncoding() const noexcept = 0; virtual ~IBufferAttributes() {} }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } } #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/ITensor.hpp ================================================ //============================================================================= // // Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _ITENSOR_HPP_ #define _ITENSOR_HPP_ #include "ITensorItr.hpp" #include "ITensorItrImpl.hpp" #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" #include #include #include namespace zdl { namespace DlSystem { class ITensor; }} namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * Represents a tensor which holds n-dimensional data. It is important to * understand how the tensor data is represented in memory * relative to the tensor dimensions. Tensors store data in * memory in row-major order (i.e. the last tensor dimension is * the fastest varying one). For example, if you have a two * dimensional tensor with 3 rows and 2 columns (i.e. the tensor * dimensions are 3,2 as returned in tensor dimension vectors) * with the following data in terms rows and columns: * * | 1 2 |
* | 3 4 |
* | 5 6 |
* * This data would be stored in memory as 1,2,3,4,5,6. */ class ZDL_EXPORT ITensor { public: typedef zdl::DlSystem::ITensorItr iterator; typedef zdl::DlSystem::ITensorItr const_iterator; virtual ~ITensor() {} /** * Returns a tensor iterator pointing to the beginning * of the data in the tensor. * * @return A tensor iterator that points to the first data * element in the tensor. */ virtual iterator begin() = 0; /** * Returns the const version of a tensor iterator * pointing to the beginning of the data in the tensor. * * @return A tensor const iterator that points to the first data * element in the tensor. */ virtual const_iterator cbegin() const = 0; /** * Returns a tensor iterator pointing to the end of the * data in the tensor. This tensor should not be * dereferenced. * * @return A tensor iterator that points to the end of the data * (one past the last element) in the tensor. */ virtual iterator end() = 0; /** * Returns the const version of a tensor iterator * pointing to the end of the data in the tensor. This * tensor should not be dereferenced. * * @return A tensor const iterator that points to the end of the * data (one past the last element) in the tensor. */ virtual const_iterator cend() const = 0; /** * @brief Gets the shape of this tensor. * * The last element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying dimension, etc. * * @return A shape class holding the tensor dimensions. */ virtual TensorShape getShape() const = 0; /** * Returns the element size of the data in the tensor * (discounting strides). This is how big a buffer would * need to be to hold the tensor data contiguously in * memory. * * @return The size of the tensor (in elements). */ virtual size_t getSize() const = 0; /** * @brief Serializes the tensor to an output stream. * * @param[in] output The output stream to which to write the tensor * * @throw std::runtime_error If the stream is ever in a bad * state before the tensor is fully serialized. */ virtual void serialize(std::ostream &output) const = 0; friend iterator; friend const_iterator; virtual bool isQuantized() {return false;} virtual float GetDelta() {return NAN;}; virtual float GetOffset() {return NAN;}; protected: /** * Returns the tensor iterator implementation. * * @return A pointer to the tensor iterator implementation. */ virtual std::unique_ptr<::DlSystem::ITensorItrImpl> getItrImpl() const = 0; }; }} /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/ITensorFactory.hpp ================================================ //============================================================================= // // Copyright (c) 2015-2016 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _ITENSOR_FACTORY_HPP #define _ITENSOR_FACTORY_HPP #include "ITensor.hpp" #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" #include namespace zdl { namespace DlSystem { class ITensor; class TensorShape; } } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * Factory interface class to create ITensor objects. */ class ZDL_EXPORT ITensorFactory { public: virtual ~ITensorFactory() = default; /** * Creates a new ITensor with uninitialized data. * * The strides for the tensor will match the tensor dimensions * (i.e., the tensor data is contiguous in memory). * * @param[in] shape The dimensions for the tensor in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * * @return A pointer to the created tensor or nullptr if creating failed. */ virtual std::unique_ptr createTensor(const TensorShape &shape) noexcept = 0; /** * Creates a new ITensor by loading it from a file. * * @param[in] input The input stream from which to read the tensor * data. * * @return A pointer to the created tensor or nullptr if creating failed. * */ virtual std::unique_ptr createTensor(std::istream &input) noexcept = 0; /** * Create a new ITensor with specific data. * (i.e. the tensor data is contiguous in memory). This tensor is * primarily used to create a tensor where tensor size can't be * computed directly from dimension. One such example is * NV21-formatted image, or any YUV formatted image * * @param[in] shape The dimensions for the tensor in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * * @param[in] data The actual data with which the Tensor object is filled. * * @param[in] dataSize The size of data * * @return A pointer to the created tensor */ virtual std::unique_ptr createTensor(const TensorShape &shape, const unsigned char *data, size_t dataSize) noexcept = 0; }; }} /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/ITensorItr.hpp ================================================ //============================================================================= // // Copyright (c) 2015 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _ITENSOR_ITR_HPP_ #define _ITENSOR_ITR_HPP_ #include "ZdlExportDefine.hpp" #include "ITensorItrImpl.hpp" #include #include #include namespace zdl { namespace DlSystem { template class ITensorItr; class ITensor; void ZDL_EXPORT fill(ITensorItr first, ITensorItr end, float val); template OutItr ZDL_EXPORT copy(InItr first, InItr last, OutItr result) { return std::copy(first, last, result); } }} namespace DlSystem { class ITensorItrImpl; } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * A bidirectional iterator (with limited random access * capabilities) for the zdl::DlSystem::ITensor class. * * This is a standard bidrectional iterator and is compatible * with standard algorithm functions that operate on bidirectional * access iterators (e.g., std::copy, std::fill, etc.). It uses a * template parameter to create const and non-const iterators * from the same code. Iterators are easiest to declare via the * typedefs iterator and const_iterator in the ITensor class * (e.g., zdl::DlSystem::ITensor::iterator). * * Note that if the tensor the iterator is traversing was * created with nondefault (i.e., nontrivial) strides, the * iterator will obey the strides when traversing the tensor * data. * * Also note that nontrivial strides dramatically affect the * performance of the iterator (on the order of 20x slower). */ template class ZDL_EXPORT ITensorItr : public std::iterator { public: typedef typename std::conditional::type VALUE_REF; ITensorItr() = delete; virtual ~ITensorItr() {} ITensorItr(std::unique_ptr<::DlSystem::ITensorItrImpl> impl, bool isTrivial = false, float* data = nullptr) : m_Impl(impl->clone()) , m_IsTrivial(isTrivial) , m_Data(data) , m_DataStart(data) {} ITensorItr(const ITensorItr& itr) : m_Impl(itr.m_Impl->clone()), m_IsTrivial(itr.m_IsTrivial), m_Data(itr.m_Data), m_DataStart(itr.m_DataStart) {} zdl::DlSystem::ITensorItr& operator=(const ITensorItr& other) { if (this == &other) return *this; m_Impl = std::move(other.m_Impl->clone()); m_IsTrivial = other.m_IsTrivial; m_Data = other.m_Data; m_DataStart = other.m_DataStart; return *this; } inline zdl::DlSystem::ITensorItr& operator++() { if (m_IsTrivial) m_Data++; else m_Impl->increment(); return *this; } inline zdl::DlSystem::ITensorItr operator++(int) { ITensorItr tmp(*this); operator++(); return tmp; } inline zdl::DlSystem::ITensorItr& operator--() { if (m_IsTrivial) m_Data--; else m_Impl->decrement(); return *this; } inline zdl::DlSystem::ITensorItr operator--(int) { ITensorItr tmp(*this); operator--(); return tmp; } inline zdl::DlSystem::ITensorItr& operator+=(int rhs) { if (m_IsTrivial) m_Data += rhs; else m_Impl->increment(rhs); return *this; } inline friend zdl::DlSystem::ITensorItr operator+(zdl::DlSystem::ITensorItr lhs, int rhs) { lhs += rhs; return lhs; } inline zdl::DlSystem::ITensorItr& operator-=(int rhs) { if (m_IsTrivial) m_Data -= rhs; else m_Impl->decrement(rhs); return *this; } inline friend zdl::DlSystem::ITensorItr operator-(zdl::DlSystem::ITensorItr lhs, int rhs) { lhs -= rhs; return lhs; } inline size_t operator-(const zdl::DlSystem::ITensorItr& rhs) { if (m_IsTrivial) return (m_Data - m_DataStart) - (rhs.m_Data - rhs.m_DataStart); return m_Impl->getPosition() - rhs.m_Impl->getPosition(); } inline friend bool operator<(const ITensorItr& lhs, const ITensorItr& rhs) { if (lhs.m_IsTrivial) return lhs.m_Data < rhs.m_Data; return lhs.m_Impl->dataPointer() < rhs.m_Impl->dataPointer(); } inline friend bool operator>(const ITensorItr& lhs, const ITensorItr& rhs) { return rhs < lhs; } inline friend bool operator<=(const ITensorItr& lhs, const ITensorItr& rhs) { return !(lhs > rhs); } inline friend bool operator>=(const ITensorItr& lhs, const ITensorItr& rhs) { return !(lhs < rhs); } inline bool operator==(const ITensorItr& rhs) const { if (m_IsTrivial) return m_Data == rhs.m_Data; return m_Impl->dataPointer() == rhs.m_Impl->dataPointer(); } inline bool operator!=(const ITensorItr& rhs) const { return !operator==(rhs); } inline VALUE_REF operator[](size_t idx) { if (m_IsTrivial) return *(m_DataStart + idx); return m_Impl->getReferenceAt(idx); } inline VALUE_REF operator*() { if (m_IsTrivial) return *m_Data; else return m_Impl->getReference(); } inline VALUE_REF operator->() { return *(*this); } inline float* dataPointer() const { if (m_IsTrivial) return m_Data; else return m_Impl->dataPointer(); } protected: std::unique_ptr<::DlSystem::ITensorItrImpl> m_Impl; bool m_IsTrivial = false; float* m_Data = nullptr; float* m_DataStart = nullptr; }; }} /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/ITensorItrImpl.hpp ================================================ //============================================================================= // // Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _ITENSOR_ITR_IMPL_HPP_ #define _ITENSOR_ITR_IMPL_HPP_ #include "ZdlExportDefine.hpp" #include #include namespace DlSystem { class ITensorItrImpl; } class ZDL_EXPORT DlSystem::ITensorItrImpl { public: ITensorItrImpl() {} virtual ~ITensorItrImpl() {} virtual float getValue() const = 0; virtual float& getReference() = 0; virtual float& getReferenceAt(size_t idx) = 0; virtual float* dataPointer() const = 0; virtual void increment(int incVal = 1) = 0; virtual void decrement(int decVal = 1) = 0; virtual size_t getPosition() = 0; virtual std::unique_ptr clone() = 0; private: ITensorItrImpl& operator=(const ITensorItrImpl& other) = delete; ITensorItrImpl(const ITensorItrImpl& other) = delete; }; #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/IUDL.hpp ================================================ //============================================================================= // // Copyright (c) 2016-2017 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _DL_SYSTEM_IUDL_HPP_ #define _DL_SYSTEM_IUDL_HPP_ #include "ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * Base class user concrete UDL implementation. * * All functions are marked as: * * - virtual * - noexcept * * User should make sure no exceptions are propagated outside of * their module. Errors can be communicated via return values. */ class ZDL_EXPORT IUDL { public: /** * @brief . * * Destructor */ virtual ~IUDL() = default; /** * @brief Sets up the user's environment. * This is called by the SNPE framework to allow the user the * opportunity to setup anything which is needed for running * user defined layers. * * @param cookie User provided opaque data returned by the SNPE * runtime * * @param insz How many elements in input size array * @param indim Pointer to a buffer that holds input dimension * array * @param indimsz Input dimension size array of the buffer * 'indim'. Corresponds to indim * * @param outsz How many elements in output size array * @param outdim Pointer to a buffer that holds output * dimension array * @param outdimsz Output dimension size of the buffer 'oudim'. * Corresponds to indim * * @return true on success, false otherwise */ virtual bool setup(void *cookie, size_t insz, const size_t **indim, const size_t *indimsz, size_t outsz, const size_t **outdim, const size_t *outdimsz) = 0; /** * @brief Close the instance. Invoked by the SNPE * framework to allow the user the opportunity to release any resources * allocated during setup. * * @param cookie - User provided opaque data returned by the SNPE runtime */ virtual void close(void *cookie) noexcept = 0; /** * @brief Execute the user defined layer * * @param cookie User provided opaque data returned by the SNPE * runtime * * @param input Const pointer to a float buffer that contains * the input * * @param output Float pointer to a buffer that would hold * the user defined layer's output. This buffer * is allocated and owned by SNPE runtime. */ virtual bool execute(void *cookie, const float **input, float **output) = 0; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // ns DlSystem } // ns zdl #endif // _DL_SYSTEM_IUDL_HPP_ ================================================ FILE: phonelibs/snpe/include/DlSystem/IUserBuffer.hpp ================================================ //============================================================================== // // Copyright (c) 2017-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _IUSER_BUFFER_HPP #define _IUSER_BUFFER_HPP #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" #include namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A base class buffer encoding type */ class ZDL_EXPORT UserBufferEncoding { public: /** * @brief . * * An enum class of all supported element types in a IUserBuffer */ enum class ElementType_t { /// Unknown element type. UNKNOWN = 0, /// Each element is presented by float. FLOAT = 1, /// Each element is presented by an unsigned int. UNSIGNED8BIT = 2, /// Each element is presented by an 8-bit quantized value. TF8 = 10, /// Each element is presented by an 16-bit quantized value. TF16 = 11 }; /** * @brief Retrieves the size of the element, in bytes. * * @return Size of the element, in bytes. */ virtual size_t getElementSize() const noexcept = 0; /** * @brief Retrieves the element type * * @return Element type */ ElementType_t getElementType() const noexcept {return m_ElementType;}; virtual ~UserBufferEncoding() {} protected: UserBufferEncoding(ElementType_t elementType) : m_ElementType(elementType) {}; private: const ElementType_t m_ElementType; }; /** * @brief . * * A base class buffer source type * * @note User buffer from CPU support all kinds of runtimes; * User buffer from GLBUFFER support only GPU runtime. */ class ZDL_EXPORT UserBufferSource { public: enum class SourceType_t { /// Unknown buffer source type. UNKNOWN = 0, /// The network inputs are from CPU buffer. CPU = 1, /// The network inputs are from OpenGL buffer. GLBUFFER = 2 }; /** * @brief Retrieves the source type * * @return Source type */ SourceType_t getSourceType() const noexcept {return m_SourceType;}; protected: UserBufferSource(SourceType_t sourceType): m_SourceType(sourceType) {}; private: const SourceType_t m_SourceType; }; /** * @brief . * * An source type where input data is delivered from OpenGL buffer */ class ZDL_EXPORT UserBufferSourceGLBuffer : public UserBufferSource{ public: UserBufferSourceGLBuffer() : UserBufferSource(SourceType_t::GLBUFFER) {}; }; /** * @brief . * * An encoding type where each element is represented by an unsigned int */ class ZDL_EXPORT UserBufferEncodingUnsigned8Bit : public UserBufferEncoding { public: UserBufferEncodingUnsigned8Bit() : UserBufferEncoding(ElementType_t::UNSIGNED8BIT) {}; size_t getElementSize() const noexcept override; protected: UserBufferEncodingUnsigned8Bit(ElementType_t elementType) : UserBufferEncoding(elementType) {}; }; /** * @brief . * * An encoding type where each element is represented by a float */ class ZDL_EXPORT UserBufferEncodingFloat : public UserBufferEncoding { public: UserBufferEncodingFloat() : UserBufferEncoding(ElementType_t::FLOAT) {}; size_t getElementSize() const noexcept override; }; /** * @brief . * * An encoding type where each element is represented by tf8, which is an * 8-bit quantizd value, which has an exact representation of 0.0 */ class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit { public: UserBufferEncodingTf8() = delete; UserBufferEncodingTf8(unsigned char stepFor0, float stepSize) : UserBufferEncodingUnsigned8Bit(ElementType_t::TF8), m_StepExactly0(stepFor0), m_QuantizedStepSize(stepSize) {}; UserBufferEncodingTf8(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncodingUnsigned8Bit(ubEncoding.getElementType()){ const zdl::DlSystem::UserBufferEncodingTf8* ubEncodingTf8 = dynamic_cast (&ubEncoding); if (ubEncodingTf8) { m_StepExactly0 = ubEncodingTf8->getStepExactly0(); m_QuantizedStepSize = ubEncodingTf8->getQuantizedStepSize(); } } /** * @brief Sets the step value that represents 0 * * @param[in] stepExactly0 The step value that represents 0 * */ void setStepExactly0(const unsigned char stepExactly0) { m_StepExactly0 = stepExactly0; } /** * @brief Sets the float value that each step represents * * @param[in] quantizedStepSize The float value of each step size * */ void setQuantizedStepSize(const float quantizedStepSize) { m_QuantizedStepSize = quantizedStepSize; } /** * @brief Retrieves the step that represents 0.0 * * @return Step value */ unsigned char getStepExactly0() const { return m_StepExactly0; } /** * Calculates the minimum floating point value that * can be represented with this encoding. * * @return Minimum representable floating point value */ float getMin() const { return m_QuantizedStepSize * (0 - m_StepExactly0); } /** * Calculates the maximum floating point value that * can be represented with this encoding. * * @return Maximum representable floating point value */ float getMax() const { return m_QuantizedStepSize * (255 - m_StepExactly0); } /** * @brief Retrieves the step size * * @return Step size */ float getQuantizedStepSize() const { return m_QuantizedStepSize; } private: unsigned char m_StepExactly0; float m_QuantizedStepSize; }; class ZDL_EXPORT UserBufferEncodingTfN : public UserBufferEncoding { public: UserBufferEncodingTfN() = delete; UserBufferEncodingTfN(uint64_t stepFor0, float stepSize, uint8_t bWidth=8): UserBufferEncoding(getTypeFromWidth(bWidth)), bitWidth(bWidth), m_StepExactly0(stepFor0), m_QuantizedStepSize(stepSize){}; UserBufferEncodingTfN(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncoding(ubEncoding.getElementType()){ const zdl::DlSystem::UserBufferEncodingTfN* ubEncodingTfN = dynamic_cast (&ubEncoding); if (ubEncodingTfN) { m_StepExactly0 = ubEncodingTfN->getStepExactly0(); m_QuantizedStepSize = ubEncodingTfN->getQuantizedStepSize(); bitWidth = ubEncodingTfN->bitWidth; } } size_t getElementSize() const noexcept override; /** * @brief Sets the step value that represents 0 * * @param[in] stepExactly0 The step value that represents 0 * */ void setStepExactly0(uint64_t stepExactly0) { m_StepExactly0 = stepExactly0; } /** * @brief Sets the float value that each step represents * * @param[in] quantizedStepSize The float value of each step size * */ void setQuantizedStepSize(const float quantizedStepSize) { m_QuantizedStepSize = quantizedStepSize; } /** * @brief Retrieves the step that represents 0.0 * * @return Step value */ uint64_t getStepExactly0() const { return m_StepExactly0; } /** * Calculates the minimum floating point value that * can be represented with this encoding. * * @return Minimum representable floating point value */ float getMin() const { return static_cast(m_QuantizedStepSize * (0 - (double)m_StepExactly0)); } /** * Calculates the maximum floating point value that * can be represented with this encoding. * * @return Maximum representable floating point value */ float getMax() const{ return static_cast(m_QuantizedStepSize * (pow(2,bitWidth)-1 - (double)m_StepExactly0)); }; /** * @brief Retrieves the step size * * @return Step size */ float getQuantizedStepSize() const { return m_QuantizedStepSize; } ElementType_t getTypeFromWidth(uint8_t width); uint8_t bitWidth; private: uint64_t m_StepExactly0; float m_QuantizedStepSize; }; /** * @brief UserBuffer contains a pointer and info on how to walk it and interpret its content. */ class ZDL_EXPORT IUserBuffer { public: virtual ~IUserBuffer() = default; /** * @brief Retrieves the total number of bytes between elements in each dimension if * the buffer were to be interpreted as a multi-dimensional array. * * @return Number of bytes between elements in each dimension. * e.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would * return strides of [24, 8, 4]. */ virtual const TensorShape& getStrides() const = 0; /** * @brief Retrieves the size of the buffer, in bytes. * * @return Size of the underlying buffer, in bytes. */ virtual size_t getSize() const = 0; /** * @brief Retrieves the size of the inference data in the buffer, in bytes. * * The inference results from a dynamic-sized model may not be exactly the same size * as the UserBuffer provided to SNPE. This function can be used to get the amount * of output inference data, which may be less or greater than the size of the UserBuffer. * * If the inference results fit in the UserBuffer, getOutputSize() would be less than * or equal to getSize(). But if the inference results were more than the capacity of * the provided UserBuffer, the results would be truncated to fit the UserBuffer. But, * getOutputSize() would be greater than getSize(), which indicates a bigger buffer * needs to be provided to SNPE to hold all of the inference results. * * @return Size required for the buffer to hold all inference results, which can be less * or more than the size of the buffer, in bytes. */ virtual size_t getOutputSize() const = 0; /** * @brief Changes the underlying memory that backs the UserBuffer. * * This can be used to avoid creating multiple UserBuffer objects * when the only thing that differs is the memory location. * * @param[in] buffer Pointer to the memory location * * @return Whether the set succeeds. */ virtual bool setBufferAddress(void *buffer) noexcept = 0; /** * @brief Gets a const reference to the data encoding object of * the underlying buffer * * This is necessary when the UserBuffer is filled by SNPE with * data types such as TF8, where the caller needs to know the quantization * parameters in order to interpret the data properly * * @return A read-only encoding object */ virtual const UserBufferEncoding& getEncoding() const noexcept = 0; /** * @brief Gets a reference to the data encoding object of * the underlying buffer * * This is necessary when the UserBuffer is re-used, and the encoding * parameters can change. For example, each input can be quantized with * different step sizes. * * @return Data encoding meta-data */ virtual UserBufferEncoding& getEncoding() noexcept = 0; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } } #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/IUserBufferFactory.hpp ================================================ //============================================================================= // // Copyright (c) 2017 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _IUSERBUFFER_FACTORY_HPP #define _IUSERBUFFER_FACTORY_HPP #include "IUserBuffer.hpp" #include "TensorShape.hpp" #include "ZdlExportDefine.hpp" #include "DlEnums.hpp" namespace zdl { namespace DlSystem { class IUserBuffer; class TensorShape; } } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * Factory interface class to create IUserBuffer objects. */ class ZDL_EXPORT IUserBufferFactory { public: virtual ~IUserBufferFactory() = default; /** * @brief Creates a UserBuffer * * @param[in] buffer Pointer to the buffer that the caller supplies * * @param[in] bufSize Buffer size, in bytes * * @param[in] strides Total number of bytes between elements in each dimension. * E.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would have strides of [24, 8, 4]. * * @param[in] userBufferEncoding Reference to an UserBufferEncoding object * * @note Caller has to ensure that memory pointed to by buffer stays accessible * for the lifetime of the object created */ virtual std::unique_ptr createUserBuffer(void *buffer, size_t bufSize, const zdl::DlSystem::TensorShape &strides, zdl::DlSystem::UserBufferEncoding* userBufferEncoding) noexcept = 0; /** * @brief Creates a UserBuffer * * @param[in] buffer Pointer to the buffer that the caller supplies * * @param[in] bufSize Buffer size, in bytes * * @param[in] strides Total number of bytes between elements in each dimension. * E.g. A tightly packed tensor of floats with dimensions [4, 3, 2] would have strides of [24, 8, 4]. * * @param[in] userBufferEncoding Reference to an UserBufferEncoding object * * @param[in] userBufferSource Reference to an UserBufferSource object * * @note Caller has to ensure that memory pointed to by buffer stays accessible * for the lifetime of the object created */ virtual std::unique_ptr createUserBuffer(void *buffer, size_t bufSize, const zdl::DlSystem::TensorShape &strides, zdl::DlSystem::UserBufferEncoding* userBufferEncoding, zdl::DlSystem::UserBufferSource* userBufferSource) noexcept = 0; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } } #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/PlatformConfig.hpp ================================================ //============================================================================= // // Copyright (c) 2017-2018 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef _DL_SYSTEM_PLATFORM_CONFIG_HPP_ #define _DL_SYSTEM_PLATFORM_CONFIG_HPP_ #include "DlSystem/ZdlExportDefine.hpp" #include namespace zdl{ namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A structure OpenGL configuration * * @note When certain OpenGL context and display are provided to UserGLConfig for using * GPU buffer as input directly, the user MUST ensure the particular OpenGL * context and display remain vaild throughout the execution of neural network models. */ struct ZDL_EXPORT UserGLConfig { /// Holds user EGL context. /// void* userGLContext = nullptr; /// Holds user EGL display. void* userGLDisplay = nullptr; }; /** * @brief . * * A structure Gpu configuration */ struct ZDL_EXPORT UserGpuConfig{ /// Holds user OpenGL configuration. /// UserGLConfig userGLConfig; }; /** * @brief . * * A class user platform configuration */ class ZDL_EXPORT PlatformConfig { public: /** * @brief . * * An enum class of all supported platform types */ enum class PlatformType_t { /// Unknown platform type. UNKNOWN = 0, /// Snapdragon CPU. CPU = 1, /// Adreno GPU. GPU = 2, /// Hexagon DSP. DSP = 3 }; /** * @brief . * * A union class user platform configuration information */ union PlatformConfigInfo { /// Holds user GPU Configuration. /// UserGpuConfig userGpuConfig; PlatformConfigInfo(){}; }; PlatformConfig() : m_PlatformType(PlatformType_t::UNKNOWN), m_PlatformOptions("") {}; /** * @brief Retrieves the platform type * * @return Platform type */ PlatformType_t getPlatformType() const {return m_PlatformType;}; /** * @brief Indicates whther the plaform configuration is valid. * * @return True if the platform configuration is valid; false otherwise. */ bool isValid() const {return (PlatformType_t::UNKNOWN != m_PlatformType);}; /** * @brief Retrieves the Gpu configuration * * @param[out] userGpuConfig The passed in userGpuConfig populated with the Gpu configuration on return. * * @return True if Gpu configuration was retrieved; false otherwise. */ bool getUserGpuConfig(UserGpuConfig& userGpuConfig) const { if(m_PlatformType == PlatformType_t::GPU) { userGpuConfig = m_PlatformConfigInfo.userGpuConfig; return true; } else { return false; } } /** * @brief Sets the Gpu configuration * * @param[in] userGpuConfig Gpu Configuration * * @return True if Gpu configuration was successfully set; false otherwise. */ bool setUserGpuConfig(UserGpuConfig& userGpuConfig) { if((userGpuConfig.userGLConfig.userGLContext != nullptr) && (userGpuConfig.userGLConfig.userGLDisplay != nullptr)) { switch (m_PlatformType) { case PlatformType_t::GPU: m_PlatformConfigInfo.userGpuConfig = userGpuConfig; return true; case PlatformType_t::UNKNOWN: m_PlatformType = PlatformType_t::GPU; m_PlatformConfigInfo.userGpuConfig = userGpuConfig; return true; default: return false; } } else return false; } /** * @brief Sets the platform options * * @param[in] options Options as a string in the form of "keyword:options" * * @return True if options are pass validation; otherwise false. If false, the options are not updated. */ bool setPlatformOptions(std::string options) { std::string oldOptions = m_PlatformOptions; m_PlatformOptions = options; if (isOptionsValid()) { return true; } else { m_PlatformOptions = oldOptions; return false; } } /** * @brief Indicates whther the plaform configuration is valid. * * @return True if the platform configuration is valid; false otherwise. */ bool isOptionsValid() const; /** * @brief Gets the platform options * * @return Options as a string */ std::string getPlatformOptions() const { return m_PlatformOptions; } private: PlatformType_t m_PlatformType; PlatformConfigInfo m_PlatformConfigInfo; std::string m_PlatformOptions; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} //namespace end #endif ================================================ FILE: phonelibs/snpe/include/DlSystem/RuntimeList.hpp ================================================ //============================================================================= // // Copyright (c) 2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #include "ZdlExportDefine.hpp" #include "DlSystem/DlEnums.hpp" #include "DlSystem/StringList.hpp" #include #include #ifndef DL_SYSTEM_RUNTIME_LIST_HPP #define DL_SYSTEM_RUNTIME_LIST_HPP namespace DlSystem { // Forward declaration of Runtime List implementation. class RuntimeListImpl; } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A class representing list of runtimes */ class ZDL_EXPORT RuntimeList final { public: /** * @brief . * * Creates a new runtime list * */ RuntimeList(); /** * @brief . * * copy constructor. * @param[in] other object to copy. */ RuntimeList(const RuntimeList& other); /** * @brief . * * constructor with single Runtime_t object * @param[in] Runtime_t object */ RuntimeList(const zdl::DlSystem::Runtime_t& runtime); /** * @brief . * * assignment operator. */ RuntimeList& operator=(const RuntimeList& other); /** * @brief . * * subscript operator. */ Runtime_t& operator[](size_t index); /** * @brief Adds runtime to the end of the runtime list * order of precedence is former followed by latter entry * * @param[in] runtime to add * * Ruturns false If the runtime already exists */ bool add(const zdl::DlSystem::Runtime_t& runtime); /** * @brief Removes the runtime from the list * * @param[in] runtime to be removed * * @note If the runtime is not found, nothing is done. */ void remove(const zdl::DlSystem::Runtime_t runtime) noexcept; /** * @brief Returns the number of runtimes in the list */ size_t size() const noexcept; /** * @brief Returns true if the list is empty */ bool empty() const noexcept; /** * @brief . * * Removes all runtime from the list */ void clear() noexcept; /** * @brief . * * Returns a StringList of names from the runtime list in * order of precedence */ zdl::DlSystem::StringList getRuntimeListNames() const; /** * @brief . * * @param[in] runtime string * Returns a Runtime enum corresponding to the in param string * */ static zdl::DlSystem::Runtime_t stringToRuntime(const char* runtimeStr); /** * @brief . * * @param[in] runtime * Returns a string corresponding to the in param runtime enum * */ static const char* runtimeToString(const zdl::DlSystem::Runtime_t runtime); ~RuntimeList(); private: void deepCopy(const RuntimeList &other); std::unique_ptr<::DlSystem::RuntimeListImpl> m_RuntimeListImpl; }; } // DlSystem namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // DL_SYSTEM_RUNTIME_LIST_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/String.hpp ================================================ //============================================================================= // // Copyright (c) 2017, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #ifndef PLATFORM_STANDARD_STRING_HPP #define PLATFORM_STANDARD_STRING_HPP #include #include #include #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * Class for wrapping char * as a really stripped down std::string replacement. */ class ZDL_EXPORT String final { public: String() = delete; /** * Construct a string from std::string reference. * @param str Reference to a std::string */ explicit String(const std::string& str); /** * Construct a string from char* reference. * @param a char* */ explicit String(const char* str); /** * move constructor. */ String(String&& other) noexcept; /** * copy constructor. */ String(const String& other) = delete; /** * assignment operator. */ String& operator=(const String&) = delete; /** * move assignment operator. */ String& operator=(String&&) = delete; /** * class comparators */ bool operator<(const String& rhs) const noexcept; bool operator>(const String& rhs) const noexcept; bool operator<=(const String& rhs) const noexcept; bool operator>=(const String& rhs) const noexcept; bool operator==(const String& rhs) const noexcept; bool operator!=(const String& rhs) const noexcept; /** * class comparators against std::string */ bool operator<(const std::string& rhs) const noexcept; bool operator>(const std::string& rhs) const noexcept; bool operator<=(const std::string& rhs) const noexcept; bool operator>=(const std::string& rhs) const noexcept; bool operator==(const std::string& rhs) const noexcept; bool operator!=(const std::string& rhs) const noexcept; const char* c_str() const noexcept; ~String(); private: char* m_string; }; /** * overloaded << operator */ ZDL_EXPORT std::ostream& operator<<(std::ostream& os, const String& str) noexcept; } // DlSystem namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // PLATFORM_STANDARD_STRING_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/StringList.hpp ================================================ //============================================================================= // // Copyright (c) 2016 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #include #include "ZdlExportDefine.hpp" #ifndef DL_SYSTEM_STRINGLIST_HPP #define DL_SYSTEM_STRINGLIST_HPP namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * Class for holding an order list of null-terminated ASCII strings. */ class ZDL_EXPORT StringList final { public: StringList() {} /** * Construct a string list with some pre-allocated memory. * @warning Contents of the list will be uninitialized * @param[in] length Number of elements for which to pre-allocate space. */ explicit StringList(size_t length); /** * Append a string to the list. * @param[in] str Null-terminated ASCII string to append to the list. */ void append(const char* str); /** * Returns the string at the indicated position, * or an empty string if the positions is greater than the size * of the list. * @param[in] idx Position in the list of the desired string */ const char* at(size_t idx) const noexcept; /** * Pointer to the first string in the list. * Can be used to iterate through the list. */ const char** begin() const noexcept; /** * Pointer to one after the last string in the list. * Can be used to iterate through the list. */ const char** end() const noexcept; /** * Return the number of valid string pointers held by this list. */ size_t size() const noexcept; /** * assignment operator. */ StringList& operator=(const StringList&) noexcept; /** * copy constructor. * @param[in] other object to copy. */ StringList(const StringList& other); /** * move constructor. * @param[in] other object to move. */ StringList(StringList&& other) noexcept; ~StringList(); private: void copy(const StringList& other); void resize(size_t length); void clear(); static const char* s_Empty; const char** m_Strings = nullptr; const char** m_End = nullptr; size_t m_Size = 0; }; } // DlSystem namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // DL_SYSTEM_STRINGLIST_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/TensorMap.hpp ================================================ //============================================================================= // // Copyright (c) 2016 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #include #include "ZdlExportDefine.hpp" #include "ITensor.hpp" #include "StringList.hpp" #ifndef DL_SYSTEM_TENSOR_MAP_HPP #define DL_SYSTEM_TENSOR_MAP_HPP namespace DlSystem { // Forward declaration of tensor map implementation. class TensorMapImpl; } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A class representing the map of tensor. */ class ZDL_EXPORT TensorMap final { public: /** * @brief . * * Creates a new empty tensor map */ TensorMap(); /** * copy constructor. * @param[in] other object to copy. */ TensorMap(const TensorMap& other); /** * assignment operator. */ TensorMap& operator=(const TensorMap& other); /** * @brief Adds a name and the corresponding tensor pointer * to the map * * @param[in] name The name of the tensor * @param[out] tensor The pointer to the tensor * * @note If a tensor with the same name already exists, the * tensor is replaced with the existing tensor. */ void add(const char *name, zdl::DlSystem::ITensor *tensor); /** * @brief Removes a mapping of tensor and its name by its name * * @param[in] name The name of tensor to be removed * * @note If no tensor with the specified name is found, nothing * is done. */ void remove(const char *name) noexcept; /** * @brief Returns the number of tensors in the map */ size_t size() const noexcept; /** * @brief . * * Removes all tensors from the map */ void clear() noexcept; /** * @brief Returns the tensor given its name. * * @param[in] name The name of the tensor to get. * * @return nullptr if no tensor with the specified name is * found; otherwise, a valid pointer to the tensor. */ zdl::DlSystem::ITensor* getTensor(const char *name) const noexcept; /** * @brief . * * Returns the names of all tensors */ zdl::DlSystem::StringList getTensorNames() const; ~TensorMap(); private: void swap(const TensorMap &other); std::unique_ptr<::DlSystem::TensorMapImpl> m_TensorMapImpl; }; } // DlSystem namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // DL_SYSTEM_TENSOR_MAP_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/TensorShape.hpp ================================================ //============================================================================= // // Copyright (c) 2016 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #include #include #include #include #include "ZdlExportDefine.hpp" #ifndef DL_SYSTEM_TENSOR_SHAPE_HPP #define DL_SYSTEM_TENSOR_SHAPE_HPP namespace DlSystem { // Forward declaration of tensor shape implementation. class TensorShapeImpl; } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * Convenient typedef to represent dimension */ using Dimension = size_t; /** * @brief . * * A class representing the shape of tensor. It is used at the * time of creation of tensor. */ class ZDL_EXPORT TensorShape final { public: /** * @brief . * * Creates a new shape with a list of dims specified in * initializer list fashion. * * @param[in] dims The dimensions are specified in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * */ TensorShape(std::initializer_list dims); /** * @brief . * * Creates a new shape with a list of dims specified in array * * @param[in] dims The dimensions are specified in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * * @param[in] size Size of the array. * */ TensorShape(const Dimension *dims, size_t size); /** * @brief . * * Creates a new shape with a vector of dims specified in * vector fashion. * * @param[in] dims The dimensions are specified in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * */ TensorShape(std::vector dims); /** * @brief . * * copy constructor. * @param[in] other object to copy. */ TensorShape(const TensorShape& other); /** * @brief . * * assignment operator. */ TensorShape& operator=(const TensorShape& other); /** * @brief . * * Creates a new shape with no dims. It can be extended later * by invoking concatenate. */ TensorShape(); /** * @brief . * * Concatenates additional dimensions specified in * initializer list fashion to the existing dimensions. * * @param[in] dims The dimensions are specified in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * */ void concatenate(std::initializer_list dims); /** * @brief . * * Concatenates additional dimensions specified in * the array to the existing dimensions. * * @param[in] dims The dimensions are specified in which the last * element of the vector represents the fastest varying * dimension and the zeroth element represents the slowest * varying, etc. * * @param[in] size Size of the array. * */ void concatenate(const Dimension *dims, size_t size); /** * @brief . * * Concatenates an additional dimension to the existing * dimensions. * * @param[in] dim The dimensions are specified in which the last element * of the vector represents the fastest varying dimension and the * zeroth element represents the slowest varying, etc. * */ void concatenate(const Dimension &dim); /** * @brief . * * Retrieves a single dimension, based on its index. * * @return The value of dimension * * @throws std::out_of_range if the index is >= the number of * dimensions (or rank). */ Dimension& operator[](size_t index); Dimension& operator[](size_t index) const; /** * @brief . * * Retrieves the rank i.e. number of dimensions. * * @return The rank */ size_t rank() const; /** * @brief . * * Retrieves a pointer to the first dimension of shape * * @return nullptr if no dimension exists; otherwise, points to * the first dimension. * */ const Dimension* getDimensions() const; ~TensorShape(); private: void swap(const TensorShape &other); std::unique_ptr<::DlSystem::TensorShapeImpl> m_TensorShapeImpl; }; } // DlSystem namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // DL_SYSTEM_TENSOR_SHAPE_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/TensorShapeMap.hpp ================================================ //============================================================================= // // Copyright (c) 2017-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #include #include #include #include "ZdlExportDefine.hpp" #include "DlSystem/TensorShape.hpp" #include "DlSystem/StringList.hpp" #ifndef DL_SYSTEM_TENSOR_SHAPE_MAP_HPP #define DL_SYSTEM_TENSOR_SHAPE_MAP_HPP namespace DlSystem { // Forward declaration of tensor shape map implementation. class TensorShapeMapImpl; } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A class representing the map of names and tensorshapes. */ class ZDL_EXPORT TensorShapeMap final { public: /** * @brief . * * Creates a new tensor shape map * */ TensorShapeMap(); /** * @brief . * * copy constructor. * @param[in] other object to copy. */ TensorShapeMap(const TensorShapeMap& other); /** * @brief . * * assignment operator. */ TensorShapeMap& operator=(const TensorShapeMap& other); /** * @brief Adds a name and the corresponding tensor pointer * to the map * * @param[in] name The name of the tensor * @param[out] tensor The pointer to the tensor * * @note If a tensor with the same name already exists, no new * tensor is added. */ void add(const char *name, const zdl::DlSystem::TensorShape& tensorShape); /** * @brief Removes a mapping of tensor and its name by its name * * @param[in] name The name of tensor to be removed * * @note If no tensor with the specified name is found, nothing * is done. */ void remove(const char *name) noexcept; /** * @brief Returns the number of tensors in the map */ size_t size() const noexcept; /** * @brief . * * Removes all tensors from the map */ void clear() noexcept; /** * @brief Returns the tensor given its name. * * @param[in] name The name of the tensor to get. * * @return nullptr if no tensor with the specified name is * found; otherwise, a valid pointer to the tensor. */ zdl::DlSystem::TensorShape getTensorShape(const char *name) const noexcept; /** * @brief . * * Returns the names of all tensor shapes */ zdl::DlSystem::StringList getTensorShapeNames() const; ~TensorShapeMap(); private: void swap(const TensorShapeMap &other); std::unique_ptr<::DlSystem::TensorShapeMapImpl> m_TensorShapeMapImpl; }; } // DlSystem namespace } // zdl namespace /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // DL_SYSTEM_TENSOR_SHAPE_MAP_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/UDLContext.hpp ================================================ //============================================================================== // // Copyright (c) 2016 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef UDL_CONTEXT_HPP #define UDL_CONTEXT_HPP #include // memset #include #include "ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * UDLContext holds the user defined layer context which * consists of a layer name, layer ID, blob and blob size. * * An instance of UDLContext is passed as an argument to the * UDLFactoryFunc provided by the user every time the SNPE * runtime encounters an unknown layer descriptor. The instance * of a UDLContext is created by the SNPE runtime and is * consumed by the user's factory function. The user should * obtain a copy of this class and should not assume any * prolonged object lifetime beyond the UDLFactoryFunction. */ class ZDL_EXPORT UDLContext final { public: /** * @brief Constructor * * @param[in] name name of the layer * * @param[in] type layer type * * @param[in] id identifier for the layer * * @param[in] id Blob/bytes as packed by the user code as part of * the Python converter script */ UDLContext(const std::string& name, const std::string& type, int32_t id, const std::string& blob) : m_Name(name), m_Type(type), m_Size(blob.size()), m_Id(id) { // FIXME not dealing with alloc error m_Buffer = new uint8_t[m_Size]; std::memcpy(m_Buffer, blob.data(), m_Size); } /** * @brief . * * Empty constructor is useful for * creating an empty UDLContext and then run copy constructor * from a fully initialized one. */ explicit UDLContext() {} /** * @brief . * * destructor Deallocates any internal allocated memory */ ~UDLContext() { release(); } /** * @brief . * * Deallocate any internally allocated memory */ void release() { if (m_Buffer && m_Size) std::memset(m_Buffer, 0, m_Size); delete []m_Buffer; m_Buffer = nullptr; m_Size = 0; } /** * @brief . * * Copy Constructor - makes a copy from ctx * * @param[in] ctx Source UDLContext to copy from */ UDLContext(const UDLContext& ctx) : m_Name(ctx.m_Name), m_Type(ctx.m_Type), m_Id(ctx.m_Id) { std::tuple cpy = ctx.getCopy(); // current compiler does not support get m_Buffer = std::get<0>(cpy); m_Size = std::get<1>(cpy); } /** * @brief * * Assignment operator - makes a copy from ctx * * @param[in] ctx Source UDLContext to copy from * * @return this */ UDLContext& operator=(const UDLContext& ctx) { UDLContext c (ctx); this->swap(c); // non throwing swap return *this; } /** * @brief . * * Move Constructor - Move internals from ctx into this * * @param[in] ctx Source UDLContext to move from */ UDLContext(UDLContext&& ctx) : m_Name(std::move(ctx.m_Name)), m_Type(std::move(ctx.m_Type)), m_Buffer(ctx.m_Buffer), m_Size(ctx.m_Size), m_Id(ctx.m_Id) { ctx.clear(); } /** * @brief . * * Assignment move - Move assignment operator from ctx * * @param[in] ctx Source UDLContext to move from * * @return this */ UDLContext& operator=(UDLContext&& ctx) { m_Name = std::move(ctx.m_Name); m_Type = std::move(ctx.m_Type); m_Buffer = ctx.m_Buffer; m_Size = ctx.m_Size; m_Id = ctx.m_Id; ctx.clear(); return *this; } /** * @brief . * * Obtain the name of the layer * * @return const reference to the name of the layer */ const std::string& getName() const noexcept { return m_Name; } /** * @brief . * * Obtain the type of the layer * * @return const reference to the type of the layer */ const std::string& getType() const noexcept { return m_Type; } /** * @brief . * * Obtain the Id of the layer * * @return The id of the layer */ int32_t getId() const noexcept { return m_Id; } /** * @brief . * * Obtain the size of the blob * * @return Size of the internal blob */ size_t getSize() const noexcept { return m_Size; } /** * @brief . * * Get a const pointer to the internal blob * * @return Const pointer to the internal blob */ const uint8_t* getBlob() const noexcept { return m_Buffer; } /** * @brief . * * Get a copy of the blob/size into a tuple * * @return A tuple with a pointer to a copy of the blob and a * size */ std::tuple getCopy() const { uint8_t* buf = new uint8_t[m_Size]; // FIXME missing memcpy std::memcpy(buf, m_Buffer, m_Size); return std::make_tuple(buf, m_Size); } /** * @brief . * * Set zeros in the internals members */ void clear() { m_Name.clear(); m_Type.clear(); m_Buffer = 0; m_Size = 0; m_Id = -1; } private: void swap(UDLContext& c) noexcept { std::swap(m_Name, c.m_Name); std::swap(m_Type, c.m_Type); std::swap(m_Id, c.m_Id); std::swap(m_Buffer, c.m_Buffer); std::swap(m_Size, c.m_Size); } std::string m_Name; // name of the layer instance std::string m_Type; // The actual layer type uint8_t* m_Buffer = nullptr; size_t m_Size = 0; int32_t m_Id = -1; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} #endif /* UDL_CONTEXT_HPP */ ================================================ FILE: phonelibs/snpe/include/DlSystem/UDLFunc.hpp ================================================ //============================================================================== // // Copyright (c) 2015 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _UDL_FUNC_HPP_ #define _UDL_FUNC_HPP_ #include #include "ZdlExportDefine.hpp" #include namespace zdl { namespace DlSystem { class UDLContext; } } namespace zdl { namespace DlSystem { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * Definition of UDLFactoyFunc, using/typedef and default FactoryFunction * UDLBundle - a simple way to bundle func and cookie into one type */ /** * @brief . * * Convenient typedef for user defined layer creation factory * * @param[out] void* Cookie - a user opaque data that was passed during SNPE's runtime's * CreateInstance. SNPE's runtime is passing this back to the user. * * @param[out] DlSystem::UDLContext* - The specific Layer Description context what is passe * SNPE runtime. * * @return IUDL* - a Concrete instance of IUDL derivative */ using UDLFactoryFunc = std::function; /** * @brief . * * default UDL factory implementation * * @param[out] DlSystem::UDLContext* - The specific Layer Description context what is passe * SNPE runtime. * * @param[out] void* Cookie - a user opaque data that was passed during SNPE's runtime's * CreateInstance. SNPE's runtime is passing this back to the user. * * @return IUDL* - nullptr to indicate SNPE's runtime that there is no specific * implementation for UDL. When SNPE's runtime sees nullptr as a return * value from the factory, it will halt execution if model has an unknown layer * */ inline ZDL_EXPORT zdl::DlSystem::IUDL* DefaultUDLFunc(void*, const zdl::DlSystem::UDLContext*) { return nullptr; } /** * @brief . * * Simple struct to bundle 2 elements. * A user defined cookie that would be returned for each * IUDL call. The user can place anything there and the * SNPE runtime will provide it back */ struct ZDL_EXPORT UDLBundle { void *cookie = nullptr; UDLFactoryFunc func = DefaultUDLFunc; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} #endif // _UDL_FUNC_HPP_ ================================================ FILE: phonelibs/snpe/include/DlSystem/UserBufferMap.hpp ================================================ //============================================================================= // // Copyright (c) 2017 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #include #include "ZdlExportDefine.hpp" #include "StringList.hpp" #ifndef DL_SYSTEM_USER_BUFFER_MAP_HPP #define DL_SYSTEM_USER_BUFFER_MAP_HPP namespace DlSystem { // Forward declaration of UserBuffer map implementation. class UserBufferMapImpl; } namespace zdl { namespace DlSystem { class IUserBuffer; /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A class representing the map of UserBuffer. */ class ZDL_EXPORT UserBufferMap final { public: /** * @brief . * * Creates a new empty UserBuffer map */ UserBufferMap(); /** * copy constructor. * @param[in] other object to copy. */ UserBufferMap(const UserBufferMap& other); /** * assignment operator. */ UserBufferMap& operator=(const UserBufferMap& other); /** * @brief Adds a name and the corresponding UserBuffer pointer * to the map * * @param[in] name The name of the UserBuffer * @param[in] userBuffer The pointer to the UserBuffer * * @note If a UserBuffer with the same name already exists, the new * UserBuffer pointer would be updated. */ void add(const char *name, zdl::DlSystem::IUserBuffer *buffer); /** * @brief Removes a mapping of one UserBuffer and its name by its name * * @param[in] name The name of UserBuffer to be removed * * @note If no UserBuffer with the specified name is found, nothing * is done. */ void remove(const char *name) noexcept; /** * @brief Returns the number of UserBuffers in the map */ size_t size() const noexcept; /** * @brief . * * Removes all UserBuffers from the map */ void clear() noexcept; /** * @brief Returns the UserBuffer given its name. * * @param[in] name The name of the UserBuffer to get. * * @return nullptr if no UserBuffer with the specified name is * found; otherwise, a valid pointer to the UserBuffer. */ zdl::DlSystem::IUserBuffer* getUserBuffer(const char *name) const noexcept; /** * @brief . * * Returns the names of all UserBuffers * * @return A list of UserBuffer names. */ zdl::DlSystem::StringList getUserBufferNames() const; ~UserBufferMap(); private: void swap(const UserBufferMap &other); std::unique_ptr<::DlSystem::UserBufferMapImpl> m_UserBufferMapImpl; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // DlSystem namespace } // zdl namespace #endif // DL_SYSTEM_TENSOR_MAP_HPP ================================================ FILE: phonelibs/snpe/include/DlSystem/ZdlExportDefine.hpp ================================================ //============================================================================= // // Copyright (c) 2015, 2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================= #pragma once #ifndef ZDL_EXPORT #define ZDL_EXPORT #endif ================================================ FILE: phonelibs/snpe/include/PlatformValidator/PlatformValidator.hpp ================================================ // ============================================================================= // // Copyright (c) 2018-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // // ============================================================================= #ifndef SNPE_PLATFORMVALIDATOR_HPP #define SNPE_PLATFORMVALIDATOR_HPP #include "DlSystem/DlEnums.hpp" #include "DlSystem/DlMacros.hpp" SNPE_DISABLE_WARNINGS("-Wdelete-non-virtual-dtor","-Wdelete-non-virtual-dtor") #include #include SNPE_ENABLE_WARNINGS namespace zdl { namespace SNPE { class PlatformValidator; class IPlatformValidatorRuntime; } } /** @addtogroup c_plus_plus_apis C++ @{ */ /** * The class for checking SNPE compatibility/capability of a device. * */ class zdl::SNPE::PlatformValidator { public: /** * @brief Default Constructor of the PlatformValidator Class * * @return A new instance of a PlatformValidator object * that can be used to check the SNPE compatibility * of a device */ PlatformValidator(); ~PlatformValidator(); /** * @brief Sets the runtime processor for compatibility check * * @return Void */ void setRuntime(zdl::DlSystem::Runtime_t runtime); /** * @brief Checks if the Runtime prerequisites for SNPE are available. * * @return True if the Runtime prerequisites are available, else false. */ bool isRuntimeAvailable(); /** * @brief Returns the core version for the Runtime selected. * * @return String which contains the actual core version value */ std::string getCoreVersion(); /** * @brief Returns the library version for the Runtime selected. * * @return String which contains the actual lib version value */ std::string getLibVersion(); /** * @brief Runs a small program on the runtime and Checks if SNPE is supported for Runtime. * * @return If True, the device is ready for SNPE execution, else not. */ bool runtimeCheck(); private: zdl::DlSystem::Runtime_t m_runtimeType; std::unique_ptr m_platformValidatorRuntime; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif //SNPE_PLATFORMVALIDATOR_HPP ================================================ FILE: phonelibs/snpe/include/SNPE/ApplicationBufferMap.hpp ================================================ //============================================================================== // // Copyright (c) 2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef PSNPE_APPLICATIONBUFFERMAP_HPP #define PSNPE_APPLICATIONBUFFERMAP_HPP #include #include #include #include "DlSystem/UserBufferMap.hpp" #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace PSNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * A class representing the UserBufferMap of Input and Output asynchronous mode. */ class ZDL_EXPORT ApplicationBufferMap final { public: /** * @brief Adds a name and the corresponding buffer * to the map * * @param[in] name The name of the UserBuffer * @param[in] buffer The vector of the uint8_t data * * @note If a UserBuffer with the same name already exists, the new * UserBuffer pointer would be updated. */ void add(const char* name, std::vector& buff) noexcept; void add(const char* name, std::vector& buff) noexcept; /** * @brief Removes a mapping of one UserBuffer and its name by its name * * @param[in] name The name of UserBuffer to be removed * * @note If no UserBuffer with the specified name is found, nothing * is done. */ void remove(const char* name) noexcept; /** * @brief Returns the number of UserBuffers in the map */ size_t size() const noexcept; /** * @brief . * * Removes all UserBuffers from the map */ void clear() noexcept; /** * @brief Returns the UserBuffer given its name. * * @param[in] name The name of the UserBuffer to get. * * @return nullptr if no UserBuffer with the specified name is * found; otherwise, a valid pointer to the UserBuffer. */ const std::vector& getUserBuffer(const char* name) const; const std::vector& operator[](const char* name) const; /** * @brief . * * Returns the names of all UserAsyncBufferMap * * @return A list of UserBuffer names. */ zdl::DlSystem::StringList getUserBufferNames() const; const std::unordered_map>& getUserBuffer() const; explicit ApplicationBufferMap(); ~ApplicationBufferMap(); explicit ApplicationBufferMap( const std::unordered_map> buffer); private: std::unordered_map> m_UserMap; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // namespace PSNPE } // namespace zdl #endif // PSNPE_APPLICATIONBUFFERMAP_HPP ================================================ FILE: phonelibs/snpe/include/SNPE/PSNPE.hpp ================================================ // ============================================================================= // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // // ============================================================================= #ifndef PSNPE_HPP #define PSNPE_HPP #include #include #include "SNPE/SNPE.hpp" #include "DlSystem/UserBufferMap.hpp" #include "DlContainer/IDlContainer.hpp" #include "DlSystem/DlEnums.hpp" #include "DlSystem/ZdlExportDefine.hpp" #include "UserBufferList.hpp" #include "RuntimeConfigList.hpp" #include "ApplicationBufferMap.hpp" namespace zdl { namespace PSNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** *@ brief build snpe instance in serial or parallel * */ enum ZDL_EXPORT BuildMode { SERIAL = 0, PARALLEL = 1 }; /** * @brief Input and output transmission mode */ enum ZDL_EXPORT InputOutputTransmissionMode { sync = 0, outputAsync = 1, inputOutputAsync = 2 }; /** * @brief A structure representing parameters of callback function of Async Output mode */ struct ZDL_EXPORT OutputAsyncCallbackParam { size_t dataIndex; bool executeStatus; OutputAsyncCallbackParam(size_t _index,bool _status) : dataIndex(_index),executeStatus(_status){}; }; /** * @brief A structure representing parameters of callback function of Async Input/Output mode */ struct ZDL_EXPORT InputOutputAsyncCallbackParam { size_t dataIndex; const ApplicationBufferMap& outputMap; bool executeStatus; InputOutputAsyncCallbackParam(size_t _index, const ApplicationBufferMap& output_map,bool _status) : dataIndex(_index) , outputMap(output_map) ,executeStatus(_status){ }; }; /** * @brief This callback is called when the output data is ready, only use for Output Async mode */ using OutputAsyncCallbackFunc = std::function; /** * @brief This callback is called when the output data is ready, only use for Output-Input Async mode */ using InputOutputAsyncCallbackFunc = std::function; /** * @brief This callback is called when the input data is ready,only use for Output-Input Async mode */ using InputOutputAsyncInputCallback = std::function(const std::vector &, const zdl::DlSystem::StringList &)>; /** * @brief . * * A structure PSNPE configuration * */ struct ZDL_EXPORT BuildConfig final { BuildMode buildMode = BuildMode::SERIAL; ///< Specify build in serial mode or parallel mode zdl::DlContainer::IDlContainer* container;///< The opened container ptr zdl::DlSystem::StringList outputBufferNames;///< Specify the output layer name RuntimeConfigList runtimeConfigList;///< The runtime config list for PSNPE, @see RuntimeConfig size_t inputThreadNumbers = 1;///< Specify the number of threads used in the execution phase to process input data, only used in inputOutputAsync mode size_t outputThreadNumbers = 1;///< Specify the number of threads used in the execution phase to process output data, only used in inputOutputAsync and outputAsync mode OutputAsyncCallbackFunc outputCallback;///< The callback to deal with output data ,only used in outputAsync mode InputOutputAsyncCallbackFunc inputOutputCallback;///< The callback to deal with output data ,only used in inputOutputAsync mode InputOutputAsyncInputCallback inputOutputInputCallback;///< The callback to deal with input data ,only used in inputOutputAsync mode InputOutputTransmissionMode inputOutputTransmissionMode = InputOutputTransmissionMode::sync;///< Specify execution mode zdl::DlSystem::ProfilingLevel_t profilingLevel = zdl::DlSystem::ProfilingLevel_t::OFF;///< Specify profiling level for Diaglog uint64_t encode[2] = {0, 0}; bool enableInitCache = false; }; /** * @brief . * * The class for executing SNPE instances in parallel. */ class ZDL_EXPORT PSNPE final { public: ~PSNPE(); explicit PSNPE() noexcept :m_TransmissionMode(InputOutputTransmissionMode::sync){}; /** * @brief Build snpe instances. * */ bool build(BuildConfig& buildConfig) noexcept; /** * @brief Execute snpe instances in Async Output mode and Sync mode * * @param[in] inputBufferList A list of user buffers that contains the input data * * @param[in,out] outputBufferList A list of user buffers that will hold the output data * */ bool execute(UserBufferList& inputBufferList, UserBufferList& outputBufferList) noexcept; /** * @brief Execute snpe instances in Async Input/Output mode * * @param[in]inputMap A map of input buffers that contains input data. The names of buffers * need to be matched with names retrived through getInputTensorNames() * * @param dataIndex Index of the input data * * @param isTF8buff Whether prefer to using 8 bit quantized element for inference * * @return True if executed successfully; flase, otherwise. */ bool executeInputOutputAsync(const std::vector& inputMap, size_t dataIndex, bool isTF8buff) noexcept; bool executeInputOutputAsync(const std::vector& inputMap, size_t dataIndex, bool isTF8buff,bool isTF8Outputbuff) noexcept; /** * @brief Returns the input layer names of the network. * * @return StringList which contains the input layer names */ const zdl::DlSystem::StringList getInputTensorNames() const noexcept; /** * @brief Returns the output layer names of the network. * * @return StringList which contains the output layer names */ const zdl::DlSystem::StringList getOutputTensorNames() const noexcept; /** * @brief Returns the input tensor dimensions of the network. * * @return TensorShape which contains the dimensions. */ const zdl::DlSystem::TensorShape getInputDimensions() const noexcept; /** * @brief Returns attributes of buffers. * * @see zdl::SNPE * * @return BufferAttributes of input/output tensor named. */ const zdl::DlSystem::TensorShape getBufferAttributesDims(const char *name) const noexcept; zdl::DlSystem::Optional getInputOutputBufferAttributes(const char *name) const noexcept; private: PSNPE(const PSNPE&) = delete; PSNPE& operator=(const PSNPE&) = delete; zdl::PSNPE::InputOutputTransmissionMode m_TransmissionMode; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // namespace PSNPE } // namespace zdl #endif // PSNPE_HPP ================================================ FILE: phonelibs/snpe/include/SNPE/RuntimeConfigList.hpp ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef PSNPE_RUNTIMECONFIGLIST_HPP #define PSNPE_RUNTIMECONFIGLIST_HPP #include #include "DlContainer/IDlContainer.hpp" #include "DlSystem/DlEnums.hpp" #include "DlSystem/RuntimeList.hpp" #include "DlSystem/TensorShapeMap.hpp" #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace PSNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * The structure for configuring a BulkSNPE runtime * */ struct ZDL_EXPORT RuntimeConfig final { zdl::DlSystem::Runtime_t runtime; zdl::DlSystem::RuntimeList runtimeList; zdl::DlSystem::PerformanceProfile_t perfProfile; zdl::DlSystem::TensorShapeMap inputDimensionsMap; bool enableCPUFallback; RuntimeConfig() : runtime{zdl::DlSystem::Runtime_t::CPU_FLOAT32}, perfProfile{zdl::DlSystem::PerformanceProfile_t::HIGH_PERFORMANCE}, enableCPUFallback{false} {} RuntimeConfig(const RuntimeConfig& other) { runtime = other.runtime; runtimeList = other.runtimeList; perfProfile = other.perfProfile; enableCPUFallback = other.enableCPUFallback; inputDimensionsMap = other.inputDimensionsMap; } RuntimeConfig& operator=(const RuntimeConfig& other) { this->runtimeList = other.runtimeList; this->runtime = other.runtime; this->perfProfile = other.perfProfile; this->enableCPUFallback = other.enableCPUFallback; this->inputDimensionsMap = other.inputDimensionsMap; return *this; } ~RuntimeConfig() {} }; /** * @brief . * * The class for creating a RuntimeConfig container. * */ class ZDL_EXPORT RuntimeConfigList final { public: RuntimeConfigList(); RuntimeConfigList(const size_t size); void push_back(const RuntimeConfig& runtimeConfig); RuntimeConfig& operator[](const size_t index); RuntimeConfigList& operator=(const RuntimeConfigList& other); size_t size() const noexcept; size_t capacity() const noexcept; void clear() noexcept; ~RuntimeConfigList() = default; private: void swap(const RuntimeConfigList& other); std::vector m_runtimeConfigs; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // namespace PSNPE } // namespace zdl #endif // PSNPE_RUNTIMECONFIGLIST_HPP ================================================ FILE: phonelibs/snpe/include/SNPE/SNPE.hpp ================================================ //============================================================================== // // Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _SNPE_SNPE_HPP_ #define _SNPE_SNPE_HPP_ #include "DlSystem/DlOptional.hpp" #include "DlSystem/DlVersion.hpp" #include "DlSystem/IBufferAttributes.hpp" #include "DlSystem/ITensor.hpp" #include "DlSystem/TensorShape.hpp" #include "DlSystem/TensorMap.hpp" #include "DlSystem/String.hpp" #include "DlSystem/StringList.hpp" #include "DlSystem/IUserBuffer.hpp" #include "DlSystem/UserBufferMap.hpp" #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace SNPE { class SnpeRuntime; } } namespace zdl { namespace DiagLog { class IDiagLog; } } namespace zdl { namespace SNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * The SNPE interface class definition */ class ZDL_EXPORT SNPE final { public: // keep this undocumented to be hidden in doxygen using HIDE_UNDOC_MEMBERS explicit SNPE(std::unique_ptr&& runtime) noexcept; ~SNPE(); /** * @brief Gets the names of input tensors to the network * * To support multiple input scenarios, where multiple tensors are * passed through execute() in a TensorMap, each tensor needs to * be uniquely named. The names of tensors can be retrieved * through this function. * * In the case of a single input, one name will be returned. * * @note Note that because the returned value is an Optional list, * the list must be verified as boolean true value before being * dereferenced. * * @return An Optional List of input tensor names. * * @see zdl::DlSystem::Optional */ zdl::DlSystem::Optional getInputTensorNames() const noexcept; /** * @brief Gets the names of output tensors to the network * * @return List of output tensor names. */ zdl::DlSystem::Optional getOutputTensorNames() const noexcept; /** * @brief Gets the name of output tensor from the input layer name * * @return Output tensor name. */ zdl::DlSystem::StringList getOutputTensorNamesByLayerName(const char *name) const noexcept; /** * @brief Processes the input data and returns the output * * @param[in] A map of tensors that contains the input data for * each input. The names of tensors needs to be * matched with names retrieved through * getInputTensorNames() * * @param[in,out] An empty map of tensors that will contain the output * data of potentially multiple layers (the key * in the map is the layer name) upon return * * @note output tensormap has to be empty. To forward propagate * and get results in user-supplied tensors, use * executeWithSuppliedOutputTensors. */ bool execute(const zdl::DlSystem::TensorMap &input, zdl::DlSystem::TensorMap &output) noexcept; /** * @brief Processes the input data and returns the output * * @param[in] A single tensor contains the input data. * * @param[in,out] An empty map of tensors that will contain the output * data of potentially multiple layers (the key * in the map is the layer name) upon return * * @note output tensormap has to be empty. */ bool execute(const zdl::DlSystem::ITensor *input, zdl::DlSystem::TensorMap &output) noexcept; /** * @brief Processes the input data and returns the output, using * user-supplied buffers * * @param[in] A map of UserBuffers that contains the input data for * each input. The names of UserBuffers needs to be * matched with names retrieved through * getInputTensorNames() * * @param[in,out] A map of UserBuffers that will hold the output * data of potentially multiple layers (the key * in the map is the UserBuffer name) * * @note input and output UserBuffer maps must be fully pre-populated. with * dimensions matching what the network expects. * For example, if there are 5 output UserBuffers they all have to be * present in map. * * Caller must guarantee that for the duration of execute(), the buffer * stored in UserBuffer would remain valid. For more detail on buffer * ownership and lifetime requirements, please refer to zdl::DlSystem::UserBuffer * documentation. */ bool execute(const zdl::DlSystem::UserBufferMap &input, const zdl::DlSystem::UserBufferMap &output) noexcept; /** * @brief Returns the version string embedded at model conversion * time. * * @return Model version string, which is a free-form string * supplied at the time of the conversion * */ zdl::DlSystem::String getModelVersion() const noexcept; /** * @brief Returns the dimensions of the input data to the model in the * form of TensorShape. The dimensions in TensorShape corresponds to * what the tensor dimensions would need to be for an input tensor to * the model. * * @param[in] layer input name. * * @note Note that this function only makes sense for networks * that have a fixed input size. For networks in which the * input size varies with each call of Execute(), this * function should not be used. * * @note Because the returned type is an Optional instance, it must * be verified as a boolean true value before being dereferenced. * * @return An Optional instance of TensorShape that maintains dimensions, * matching the tensor dimensions for input to the model, * where the last entry is the fastest varying dimension, etc. * * @see zdl::DlSystem::ITensor * @see zdl::DlSystem::TensorShape * @see zdl::DlSystem::Optional */ zdl::DlSystem::Optional getInputDimensions() const noexcept; zdl::DlSystem::Optional getInputDimensions(const char *name) const noexcept; /** * @brief Gets the output layer(s) for the network. * * Note that the output layers returned by this function may be * different than those specified when the network was created * via the zdl::SNPE::SNPEBuilder. For example, if the * network was created in debug mode with no explicit output * layers specified, this will contain all layers. * * @note Note that because the returned value is an Optional StringList, * the list must be verified as a boolean true value before being * dereferenced. * * @return A List of output layer names. * * @see zdl::DlSystem::Optional */ zdl::DlSystem::Optional getOutputLayerNames() const noexcept; /** * @brief Returns attributes of buffers used to feed input tensors and receive result from output tensors. * * @param[in] Tensor name. * * @return BufferAttributes of input/output tensor named */ zdl::DlSystem::Optional getInputOutputBufferAttributes(const char *name) const noexcept; zdl::DlSystem::Optional getInputOutputBufferAttributesTf8(const char *name) const noexcept; /** * @brief . * * Get the diagnostic logging interface * * @note Note that because the returned type is an Optional instance, * it must be verified as a boolean true value before being * dereferenced. * * @see zdl::DlSystem::Optional */ zdl::DlSystem::Optional getDiagLogInterface() noexcept; private: SNPE(const SNPE&) = delete; SNPE& operator=(const SNPE&) = delete; std::unique_ptr m_Runtime; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} #endif ================================================ FILE: phonelibs/snpe/include/SNPE/SNPEBuilder.hpp ================================================ //============================================================================== // // Copyright (c) 2017-2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _SNPE_BUILDER_HPP_ #define _SNPE_BUILDER_HPP_ #include "SNPE/SNPE.hpp" #include "DlSystem/DlEnums.hpp" #include "DlSystem/UDLFunc.hpp" #include "DlSystem/DlOptional.hpp" #include "DlSystem/TensorShapeMap.hpp" #include "DlSystem/PlatformConfig.hpp" #include "DlSystem/RuntimeList.hpp" namespace zdl { namespace DlContainer { class IDlContainer; } } struct SNPEBuilderImpl; namespace zdl { namespace SNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * The builder class for creating SNPE objects. * Not meant to be extended. */ class ZDL_EXPORT SNPEBuilder final { private: std::unique_ptr<::SNPEBuilderImpl> m_Impl; public: /** * @brief Constructor of NeuralNetwork Builder with a supplied model. * * @param[in] container A container holding the model. * * @return A new instance of a SNPEBuilder object * that can be used to configure and build * an instance of SNPE. * */ explicit SNPEBuilder( zdl::DlContainer::IDlContainer* container); ~SNPEBuilder(); /** * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use * setRuntimeProcessorOrder() * * @brief Sets the runtime processor. * * @param[in] targetRuntimeProcessor The target runtime. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setRuntimeProcessor( zdl::DlSystem::Runtime_t targetRuntimeProcessor); /** * @brief Requests a performance profile. * * @param[in] targetRuntimeProfile The target performance profile. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setPerformanceProfile( zdl::DlSystem::PerformanceProfile_t performanceProfile); /** * @brief Sets the profiling level. Default profiling level for * SNPEBuilder is off. Off and basic only applies to DSP runtime. * * @param[in] profilingLevel The target profiling level. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setProfilingLevel( zdl::DlSystem::ProfilingLevel_t profilingLevel); /** * @brief Sets a preference for execution priority. * * This allows the caller to give coarse hint to SNPE runtime * about the priority of the network. SNPE runtime is free to use * this information to co-ordinate between different workloads * that may or may not extend beyond SNPE. * * @param[in] ExecutionPriorityHint_t The target performance profile. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setExecutionPriorityHint( zdl::DlSystem::ExecutionPriorityHint_t priority); /** * @brief Sets the layers that will generate output. * * @param[in] outputLayerNames List of layer names to * output. An empty list will * result in only the final * layer of the model being * the output layer. The list * will be copied. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setOutputLayers( const zdl::DlSystem::StringList& outputLayerNames); /** * @brief Sets the output tensor names. * * @param[in] outputTensorNames List of tensor names to * output. An empty list will * result in producing output for the final * output tensor of the model. * The list will be copied. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setOutputTensors( const zdl::DlSystem::StringList& outputTensorNames); /** * @brief Passes in a User-defined layer. * * @param udlBundle Bundle of udl factory function and a cookie * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setUdlBundle( zdl::DlSystem::UDLBundle udlBundle); /** * @brief Sets whether this neural network will perform inference with * input from user-supplied buffers, and write output to user-supplied * buffers. Default behaviour is to use tensors created by * ITensorFactory. * * @param[in] bufferMode Whether to use user-supplied buffer or not. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setUseUserSuppliedBuffers( bool bufferMode); /** * @brief Sets the debug mode of the runtime. * * @param[in] debugMode This enables debug mode for the runtime. It * does two things. For an empty * outputLayerNames list, all layers will be * output. It might also disable some internal * runtime optimizations (e.g., some networks * might be optimized by combining layers, * etc.). * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setDebugMode( bool debugMode); /** * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. Please use * setRuntimeProcessorOrder() * * @brief Sets the mode of CPU fallback functionality. * * @param[in] mode This flag enables/disables the functionality * of CPU fallback. When the CPU fallback * functionality is enabled, layers in model that * violates runtime constraints will run on CPU * while the rest of non-violating layers will * run on the chosen runtime processor. In * disabled mode, models with layers violating * runtime constraints will NOT run on the chosen * runtime processor and will result in runtime * exception. By default, the functionality is * enabled. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setCPUFallbackMode( bool mode); /** * @brief Sets network's input dimensions to enable resizing of * the spatial dimensions of each layer for fully convolutional networks, * and the batch dimension for all networks. * * @param[in] tensorShapeMap The map of input names and their new dimensions. * The new dimensions overwrite the input dimensions * embedded in the model and then resize each layer * of the model. If the model contains * layers whose dimensions cannot be resized e.g FullyConnected, * exception will be thrown when SNPE instance is actually built. * In general the batch dimension is always resizable. * After resizing of layers' dimensions in model based * on new input dimensions, the new model is revalidated * against all runtime constraints, whose failures may * result in cpu fallback situation. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setInputDimensions(const zdl::DlSystem::TensorShapeMap& inputDimensionsMap); /** * @brief Sets the mode of init caching functionality. * * @param[in] mode This flag enables/disables the functionality of init caching. * When init caching functionality is enabled, a set of init caches * will be created during network building/initialization process * and will be added to DLC container. If such DLC container is saved * by the user, in subsequent network building/initialization processes * these init caches will be loaded from the DLC so as to reduce initialization time. * In disable mode, no init caches will be added to DLC container. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setInitCacheMode( bool cacheMode); /** * @brief Returns an instance of SNPE based on the current parameters. * * @return A new instance of a SNPE object that can be used * to execute models or null if any errors occur. */ std::unique_ptr build() noexcept; /** * @brief Sets the platform configuration. * * @param[in] platformConfig The platform configuration. * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setPlatformConfig(const zdl::DlSystem::PlatformConfig& platformConfig); /** * @brief Sets network's runtime order of precedence. Example: * CPU_FLOAT32, GPU_FLOAT16, AIP_FIXED8_TF * Note:- setRuntimeProcessor() or setCPUFallbackMode() will be silently ignored when * setRuntimeProcessorOrder() is invoked * * @param[in] runtimeList The list of runtime in order of precedence * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setRuntimeProcessorOrder(const zdl::DlSystem::RuntimeList& runtimeList); /** * @brief Sets the unconsumed tensors as output * * @param[in] setOutput This enables unconsumed tensors (i.e) * outputs which are not inputs to any * layer (basically dead ends) to be marked * for output * * @return The current instance of SNPEBuilder. */ SNPEBuilder& setUnconsumedTensorsAsOutputs( bool setOutput); }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} #endif ================================================ FILE: phonelibs/snpe/include/SNPE/SNPEFactory.hpp ================================================ //============================================================================== // // Copyright (c) 2015-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef _SNPE_FACTORY_HPP_ #define _SNPE_FACTORY_HPP_ #include "SNPE/SNPE.hpp" #include "DlSystem/DlEnums.hpp" #include "DlSystem/UDLFunc.hpp" #include "DlSystem/ZdlExportDefine.hpp" #include "DlSystem/DlOptional.hpp" namespace zdl { namespace DlSystem { class ITensorFactory; class IUserBufferFactory; } namespace DlContainer { class IDlContainer; } } namespace zdl { namespace SNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * The factory class for creating SNPE objects. * */ class ZDL_EXPORT SNPEFactory { public: /** * Indicates whether the supplied runtime is available on the * current platform. * * @param[in] runtime The target runtime to check. * * @param[in] option Extent to perform runtime available check. * * @return True if the supplied runtime is available; false, * otherwise. */ static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime); /** * Indicates whether the supplied runtime is available on the * current platform. * * @param[in] runtime The target runtime to check. * * @param[in] option Extent to perform runtime available check. * * @return True if the supplied runtime is available; false, * otherwise. */ static bool isRuntimeAvailable(zdl::DlSystem::Runtime_t runtime, zdl::DlSystem::RuntimeCheckOption_t option); /** * Gets a reference to the tensor factory. * * @return A reference to the tensor factory. */ static zdl::DlSystem::ITensorFactory& getTensorFactory(); /** * Gets a reference to the UserBuffer factory. * * @return A reference to the UserBuffer factory. */ static zdl::DlSystem::IUserBufferFactory& getUserBufferFactory(); /** * Gets the version of the SNPE library. * * @return Version of the SNPE library. * */ static zdl::DlSystem::Version_t getLibraryVersion(); /** * Set the SNPE storage location for all SNPE instances in this * process. Note that this may only be called once, and if so * must be called before creating any SNPE instances. * * @param[in] storagePath Absolute path to a directory which SNPE may * use for caching and other storage purposes. * * @return True if the supplied path was succesfully set as * the SNPE storage location, false otherwise. */ static bool setSNPEStorageLocation(const char* storagePath); /** * @brief Register a user-defined op package with SNPE. * * @param[in] regLibraryPath Path to the registration library * that allows clients to register a set of operations that are * part of the package, and share op info with SNPE * * @return True if successful, False otherwise. */ static bool addOpPackage( const std::string& regLibraryPath ); /** * Indicates whether the OpenGL and OpenCL interoperability is supported * on GPU platform. * * @return True if the OpenGL and OpenCl interop is supported; false, * otherwise. */ static bool isGLCLInteropSupported(); }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} #endif ================================================ FILE: phonelibs/snpe/include/SNPE/UserBufferList.hpp ================================================ //============================================================================== // // Copyright (c) 2019 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef PSNPE_USERBUFFERLIST_HPP #define PSNPE_USERBUFFERLIST_HPP #include #include "DlSystem/UserBufferMap.hpp" #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { namespace PSNPE { /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief . * * The class for creating a UserBufferMap container. * */ class ZDL_EXPORT UserBufferList final { public: UserBufferList(); UserBufferList(const size_t size); void push_back(const zdl::DlSystem::UserBufferMap &userBufferMap); zdl::DlSystem::UserBufferMap& operator[](const size_t index); UserBufferList& operator =(const UserBufferList &other); size_t size() const noexcept; size_t capacity() const noexcept; void clear() noexcept; ~UserBufferList() = default; private: void swap(const UserBufferList &other); std::vector m_userBufferMaps; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // namespace PSNPE } // namespace zdl #endif //PSNPE_USERBUFFERLIST_HPP ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoBase.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef SNPE_UDO_BASE_H #define SNPE_UDO_BASE_H #include // Provide values to use for API version. #define API_VERSION_MAJOR 1 #define API_VERSION_MINOR 5 #define API_VERSION_TEENY 0 /** @addtogroup c_plus_plus_apis C++ @{ */ // Defines a bitmask of enum values. typedef uint32_t SnpeUdo_Bitmask_t; // A string of characters, rather than an array of bytes. // Assumed to be UTF-8. typedef char* SnpeUdo_String_t; // The maximum allowable length of a SnpeUdo_String_t in bytes, // including null terminator. SNPE will truncate strings longer // than this. #define SNPE_UDO_MAX_STRING_SIZE 1024 /** * An enum which holds the various error types. * The error types are divided to classes : * 0 - 99 : generic errors * 100 - 200 : errors related to configuration * */ typedef enum { /// No Error SNPE_UDO_NO_ERROR = 0, /// Unsupported value for core type SNPE_UDO_WRONG_CORE = 1, /// Invalid attribute/argument passed into UDO API SNPE_UDO_INVALID_ARGUMENT = 2, /// Unsupported feature error SNPE_UDO_UNSUPPORTED_FEATURE = 3, /// Error relating to memory allocation SNPE_UDO_MEM_ALLOC_ERROR = 4, /* Configuration Specific errors */ /// No op with given attributes available in library SNPE_UDO_WRONG_OPERATION = 100, /// Unsupported value for core type in UDO configuration SNPE_UDO_WRONG_CORE_TYPE = 101, /// Wrong number of params in UDO definition SNPE_UDO_WRONG_NUM_OF_PARAMS = 102, /// Wrong number of dimensions for tensor(s) in UDO definition SNPE_UDO_WRONG_NUM_OF_DIMENSIONS = 103, /// Wrong number of input tensors in UDO definition SNPE_UDO_WRONG_NUM_OF_INPUTS = 104, /// Wrong number of output tensors in UDO definition SNPE_UDO_WRONG_NUM_OF_OUTPUTS = 105, SNPE_UDO_PROGRAM_CACHE_NOT_FOUND = 106, SNPE_UDO_UNKNOWN_ERROR = 0xFFFFFFFF } SnpeUdo_ErrorType_t; /** * An enum which holds the various data types. * Designed to be used as single values or combined into a bitfield parameter * (0x1, 0x2, 0x4, etc) * \n FIXED_XX types are targeted for data in tensors. * \n UINT / INT types are targeted for scalar params */ typedef enum { /// data type: 16-bit floating point SNPE_UDO_DATATYPE_FLOAT_16 = 0x01, /// data type: 32-bit floating point SNPE_UDO_DATATYPE_FLOAT_32 = 0x02, /// data type: 4-bit fixed point SNPE_UDO_DATATYPE_FIXED_4 = 0x04, /// data type: 8-bit fixed point SNPE_UDO_DATATYPE_FIXED_8 = 0x08, /// data type: 16-bit fixed point SNPE_UDO_DATATYPE_FIXED_16 = 0x10, /// data type: 32-bit fixed point SNPE_UDO_DATATYPE_FIXED_32 = 0x20, /// data type: 8-bit unsigned integer SNPE_UDO_DATATYPE_UINT_8 = 0x100, /// data type: 16-bit unsigned integer SNPE_UDO_DATATYPE_UINT_16 = 0x200, /// data type: 32-bit unsigned integer SNPE_UDO_DATATYPE_UINT_32 = 0x400, /// data type: 8-bit signed integer SNPE_UDO_DATATYPE_INT_8 = 0x1000, /// data type: 16-bit signed integer SNPE_UDO_DATATYPE_INT_16 = 0x2000, /// data type: 32-bit signed integer SNPE_UDO_DATATYPE_INT_32 = 0x4000, SNPE_UDO_DATATYPE_LAST = 0xFFFFFFFF } SnpeUdo_DataType_t; /** * An enum which holds the various layouts. * Designed to be used as single values or combined into a bitfield parameter * (0x1, 0x2, 0x4, etc) */ typedef enum { /// data layout (4D): NHWC (batch-height-width-channel) SNPE_UDO_LAYOUT_NHWC = 0x01, /// data layout (4D): NCHW (batch-channel-height-width) SNPE_UDO_LAYOUT_NCHW = 0x02, /// data layout (5D): NDHWC (batch-dimension-height-width-channel) SNPE_UDO_LAYOUT_NDHWC = 0x04, SNPE_UDO_LAYOUT_GPU_OPTIMAL1 = 0x08, SNPE_UDO_LAYOUT_GPU_OPTIMAL2 = 0x10, SNPE_UDO_LAYOUT_DSP_OPTIMAL1 = 0x11, SNPE_UDO_LAYOUT_DSP_OPTIMAL2 = 0x12, // Indicates no data will be allocated for this tensor. // Used to specify optional inputs/outputs positionally. SNPE_UDO_LAYOUT_NULL = 0x13, SNPE_UDO_LAYOUT_LAST = 0xFFFFFFFF } SnpeUdo_TensorLayout_t; /** * An enum which holds the UDO library Core type . * Designed to be used as single values or combined into a bitfield parameter * (0x1, 0x2, 0x4, etc) */ typedef enum { /// Library target IP Core is undefined SNPE_UDO_CORETYPE_UNDEFINED = 0x00, /// Library target IP Core is CPU SNPE_UDO_CORETYPE_CPU = 0x01, /// Library target IP Core is GPU SNPE_UDO_CORETYPE_GPU = 0x02, /// Library target IP Core is DSP SNPE_UDO_CORETYPE_DSP = 0x04, SNPE_UDO_CORETYPE_LAST = 0xFFFFFFFF } SnpeUdo_CoreType_t; /** * An enum to specify the parameter type : Scalar or Tensor */ typedef enum { /// UDO static param type: scalar SNPE_UDO_PARAMTYPE_SCALAR, /// UDO static param type: string SNPE_UDO_PARAMTYPE_STRING, /// UDO static param type: tensor SNPE_UDO_PARAMTYPE_TENSOR, SNPE_UDO_PARAMTYPE_LAST = 0xFFFFFFFF } SnpeUdo_ParamType_t; /** * An enum to specify quantization type */ typedef enum { /// Tensor Quantization type: NONE. Signifies unquantized tensor data SNPE_UDO_QUANTIZATION_NONE, /// Tensor Quantization type: Tensorflow-style SNPE_UDO_QUANTIZATION_TF, SNPE_UDO_QUANTIZATION_QMN, SNPE_UDO_QUANTIZATION_LAST = 0xFFFFFFFF } SnpeUdo_QuantizationType_t; /** * @brief A struct which is used to provide a version number using 3 values : major, minor, teeny * */ typedef struct { /// version field: major - for backward-incompatible changes uint32_t major; /// version field: minor - for backward-compatible feature updates uint32_t minor; /// version field: teeny - for minor bug-fixes and clean-up uint32_t teeny; } SnpeUdo_Version_t; /** * @brief A struct returned from version query, contains the Library version and API version * */ typedef struct { /// Version of UDO library. Controlled by users SnpeUdo_Version_t libVersion; /// Version of SNPE UDO API used in compiling library. Determined by SNPE SnpeUdo_Version_t apiVersion; } SnpeUdo_LibVersion_t; /** * @brief A union to hold the value of a generic type. Allows defining a parameter struct * in a generic way, with a "value" location that holds the data regardless of the type. * */ typedef union { /// value type: float float floatValue; /// value type: unsigned 32-bit integer uint32_t uint32Value; /// value type: signed 32-bit integer int32_t int32Value; /// value type: unsigned 16-bit integer uint16_t uint16Value; /// value type: signed 16-bit integer int16_t int16Value; /// value type: unsigned 8-bit integer uint8_t uint8Value; /// value type: signed 8-bit integer int8_t int8Value; } SnpeUdo_Value_t; /** * @brief A struct which defines a scalar parameter : name, data type, and union of values * */ typedef struct { /// The parameter data type : float, int, etc. SnpeUdo_DataType_t dataType; /// a union of specified type which holds the data SnpeUdo_Value_t dataValue; } SnpeUdo_ScalarParam_t; /** * @brief A struct which defines the quantization parameters in case of Tensorflow style quantization * */ typedef struct { /// minimum value of the quantization range of data float minValue; /// maximum value of the quantization range of data float maxValue; } SnpeUdo_TFQuantize_t; /** * @brief A struct which defines the quantization type, and union of supported quantization structs * */ typedef struct { /// quantization type (only TF-style currently supported) SnpeUdo_QuantizationType_t quantizeType; union { /// TF-style min-max quantization ranges SnpeUdo_TFQuantize_t TFParams; }; } SnpeUdo_QuantizeParams_t; /** * @brief A struct which defines the datatype associated with a specified core-type * This should be used to denote the datatypes for a single tensor info, depending * on the intended execution core. * */ typedef struct { /// The IP Core SnpeUdo_CoreType_t coreType; /// The associated datatype for this coreType SnpeUdo_DataType_t dataType; } SnpeUdo_PerCoreDatatype_t; /** * @brief A struct which defines a tensor parameter : name, data type, layout, quantization, more. * Also holds a pointer to the tensor data. * */ typedef struct { /// The maximum allowable dimensions of the tensor. The memory held in /// _tensorData_ is guaranteed to be large enough for this. uint32_t* maxDimensions; /// The current dimensions of the tensor. An operation may modify the current /// dimensions of its output, to indicate cases where the output has been /// "resized". /// Note that for static parameters, the current and max dimensions must /// match. uint32_t* currDimensions; /// Quantization params applicable to the tensor. Currently only supports /// Tensorflow quantization style. SnpeUdo_QuantizeParams_t quantizeParams; /// Number of dimensions to the tensor: 3D, 4D, etc. uint32_t tensorRank; /// The parameter data type: float, int, etc. SnpeUdo_DataType_t dataType; /// The tensor layout type: NCHW, NHWC, etc. SnpeUdo_TensorLayout_t layout; /// Opaque pointer to tensor data. User may be required to re-interpret the pointer /// based on core-specific definitions. void* tensorData; } SnpeUdo_TensorParam_t; /** * @brief A struct which defines tensor information for activation tensors only * * It describes an activation tensor object using its name, the intended layout and the datatype * it will take depending on the intended runtime core. The repeated field indicates that * that the tensor info describes several input/output activation tensors, which all share the * aforementioned properties. */ typedef struct { /// The tensor name SnpeUdo_String_t tensorName; /// The tensor layout type: NCHW, NHWC, etc. SnpeUdo_TensorLayout_t layout; /// The per core datatype: {SNPE_UDO_DATATYPE, SNPE_UDO_CORE_TYPE} SnpeUdo_PerCoreDatatype_t* perCoreDatatype; /// A boolean field indicating that this tensorinfo will be repeated e.x for ops such as Concat or Split bool repeated; } SnpeUdo_TensorInfo_t; /** * @brief struct which defines a UDO parameter - a union of scalar, tensor and string parameters * */ typedef struct { /// Type is scalar or tensor SnpeUdo_ParamType_t paramType; /// The param name, for example : "offset", "activation_type" SnpeUdo_String_t paramName; union { /// scalar param value SnpeUdo_ScalarParam_t scalarParam; /// tensor param value SnpeUdo_TensorParam_t tensorParam; /// string param value SnpeUdo_String_t stringParam; }; } SnpeUdo_Param_t; /** * @brief A struct which defines Operation information which is specific for IP core (CPU, GPU, DSP ...) * */ typedef struct { /// The IP Core SnpeUdo_CoreType_t udoCoreType; /// Bitmask, defines supported internal calculation types (like FLOAT_32, etc) /// Based on SnpeUdo_DataType SnpeUdo_Bitmask_t operationCalculationTypes; } SnpeUdo_OpCoreInfo_t; /** * @brief A struct which defines the common and core-specific Operation information * */ typedef struct { /// Operation type SnpeUdo_String_t operationType; /// A bitmask describing which IP Cores (CPU, GPU, DSP ...) support this operation /// Translated based on SnpeUdo_CoreType SnpeUdo_Bitmask_t supportedByCores; /// Number of static parameters defined by the op uint32_t numOfStaticParams; /// Array of static parameters. Can be scalar or tensor params SnpeUdo_Param_t* staticParams; /// Number of input tensors this op receives uint32_t numOfInputs; /// Array of input tensor names to this operation SnpeUdo_String_t* inputNames; /// Number of output tensors this op receives uint32_t numOfOutputs; /// Array of output tensor names to this operation SnpeUdo_String_t* outputNames; /// Number of cores that the op can execute on uint32_t numOfCoreInfo; /// Array of per-core information entries SnpeUdo_OpCoreInfo_t* opPerCoreInfo; /// Array of input tensor infos for this operation SnpeUdo_TensorInfo_t* inputInfos; /// Array of output tensor infos for this operation SnpeUdo_TensorInfo_t* outputInfos; } SnpeUdo_OperationInfo_t; /** * @brief A struct which provides the implementation library info : type, name * */ typedef struct { /// Defines the IP Core that this implementation library is targeting SnpeUdo_CoreType_t udoCoreType; /// library name. will be looked at in the standard library path SnpeUdo_String_t libraryName; } SnpeUdo_LibraryInfo_t; /** * @brief A struct returned by the registration library and contains information on the UDO package : * name, operations, libraries, etc. * */ typedef struct { /// A string containing the package name SnpeUdo_String_t packageName; /// A bitmask describing supported IP cores (CPU, GPU, DSP ...) /// Translated based on SnpeUdo_CoreType SnpeUdo_Bitmask_t supportedCoreTypes; /// The number of implementation libraries in the package uint32_t numOfImplementationLib; /// Array of implementation libraries names/types SnpeUdo_LibraryInfo_t* implementationLib; /// A string containing all operation types separated by space SnpeUdo_String_t operationsString; /// Number of supported operations uint32_t numOfOperations; /// Array of Operation info structs. Each entry describes one /// Operation (name, params, inputs, outputs) SnpeUdo_OperationInfo_t* operationsInfo; } SnpeUdo_RegInfo_t; /** * @brief A struct returned by the implementation library and contains information on the * specific library: name, IP Core, operations, etc. * */ typedef struct { /// Defines the IP Core that this implementation library is targeting SnpeUdo_CoreType_t udoCoreType; /// A string containing the package name SnpeUdo_String_t packageName; /// A string containing all operation types separated by space SnpeUdo_String_t operationsString; /// Number of supported operations uint32_t numOfOperations; } SnpeUdo_ImpInfo_t; /** * @brief This struct defines an operation. It is used for validation * or creation of an operation. * In case of using it for creation, the static params which are tensors * contain pointers to the real data (weights, for example), and input/output * tensors also include pointers to the buffers used. */ typedef struct { /// The IP Core that the operation is defined for - CPU, GPU, DSP... SnpeUdo_CoreType_t udoCoreType; /// Operation type SnpeUdo_String_t operationType; /// The number of static parameters provided in the staticParams array. /// this number has to match the number provided by the UDO Registration library information uint32_t numOfStaticParams; /// Array of static parameters SnpeUdo_Param_t* staticParams; /// The number of input parameters provided in inputs array. /// this number has to match the number provided by the UDO Registration library information uint32_t numOfInputs; /// Array of input tensors, providing layout, data type, sizes, etc /// When used to create an operation, also contains the initial location of the data SnpeUdo_TensorParam_t* inputs; /// The number of output parameters provided in inputs array. /// this number has to match the number provided by the UDO Registration library information uint32_t numOfOutputs; /// Array of output tensors, providing layout, data type, sizes, etc /// When used to create an operation, also contains the initial location of the data SnpeUdo_TensorParam_t* outputs; } SnpeUdo_OpDefinition_t; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif //SNPE_UDO_BASE_H ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoImpl.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef SNPE_UDO_IMPL_H #define SNPE_UDO_IMPL_H #include #include "SnpeUdo/UdoShared.h" #ifdef __cplusplus extern "C" { #endif /** @addtogroup c_plus_plus_apis C++ @{ */ typedef struct _SnpeUdo_OpFactory_t* SnpeUdo_OpFactory_t; typedef struct _SnpeUdo_Operation_t* SnpeUdo_Operation_t; /** * @brief Initialize the shared library's data structures. Calling any other * library function before this one will result in error. * * @param[in] globalInfrastructure Global core-specific infrastructure to be * used by operations created in this library. The definition and * semantics of this object will be defined in the corresponding * implementation header for the core type. * @return Error code */ SnpeUdo_ErrorType_t SnpeUdo_initImplLibrary(void* globalInfrastructure); typedef SnpeUdo_ErrorType_t (*SnpeUdo_InitImplLibraryFunction_t)(void*); /** * @brief A function to query the API version of the UDO implementation library. * The function populates a SnpeUdo_LibVersion_t struct, which contains a SnpeUdo_Version_t * struct for API version and library version. * * @param[in, out] version A pointer to struct which contains major, minor, teeny information for * library and api versions. * * @return Error code */ SnpeUdo_ErrorType_t SnpeUdo_getImplVersion(SnpeUdo_LibVersion_t** version); typedef SnpeUdo_ErrorType_t (*SnpeUdo_getImplVersion_t)(SnpeUdo_LibVersion_t** version); /** * @brief Release the shared library's data structures, and invalidate any * handles returned by the library. The behavior of any outstanding * asynchronous calls made to this library when this function is called * are undefined. All library functions (except SnpeUdo_initImplLibrary) will * return an error after this function has been successfully called. * * It should be possible to call SnpeUdo_initImplLibrary after calling this * function, and re-initialize the library. * * @return Error code */ SnpeUdo_ErrorType_t SnpeUdo_terminateImplLibrary(void); typedef SnpeUdo_ErrorType_t (*SnpeUdo_TerminateImplLibraryFunction_t)(void); /** * @brief A function to query info on the UDO implementation library. * The function populates a structure which contains information about * operations that are part of this library * * @param[in, out] implementationInfo A pointer to struct which contains information * on the operations * * @return error code * */ SnpeUdo_ErrorType_t SnpeUdo_getImpInfo(SnpeUdo_ImpInfo_t** implementationInfo); typedef SnpeUdo_ErrorType_t (*SnpeUdo_GetImpInfoFunction_t)(SnpeUdo_ImpInfo_t** implementationInfo); /** * @brief A function to create an operation factory. * The function receives the operation type, and an array of static parameters, * and returns operation factory handler * * @param[in] udoCoreType The Core type to create the operation on. An error will * be returned if this does not match the core type of the library. * * @param[in] perFactoryInfrastructure CreateOpFactory infrastructure appropriate to this * core type. The definition and semantics of this object will be defined * in the corresponding implementation header for the core type. * * @param[in] operationType A string containing Operation type. for example "MY_CONV" * * @param[in] numOfStaticParams The number of static parameters. * * @param[in] staticParams Array of static parameters * * @param[in,out] opFactory Handler to Operation Factory, to be used when creating operations * * @return Error Code */ SnpeUdo_ErrorType_t SnpeUdo_createOpFactory(SnpeUdo_CoreType_t udoCoreType, void* perFactoryInfrastructure, SnpeUdo_String_t operationType, uint32_t numOfStaticParams, SnpeUdo_Param_t* staticParams, SnpeUdo_OpFactory_t* opFactory); typedef SnpeUdo_ErrorType_t (*SnpeUdo_CreateOpFactoryFunction_t)(SnpeUdo_CoreType_t, void*, SnpeUdo_String_t, uint32_t, SnpeUdo_Param_t*, SnpeUdo_OpFactory_t*); /** * @brief A function to release the resources allocated for an operation factory * created by this library. * * @param[in] factory The operation factory to release. Upon success this handle will be invalidated. * * @return Error Code */ SnpeUdo_ErrorType_t SnpeUdo_releaseOpFactory(SnpeUdo_OpFactory_t opFactory); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ReleaseOpFactoryFunction_t)(SnpeUdo_OpFactory_t); /** * @brief A function to create an operation from the factory. * The function receives array of inputs and array of outputs, and creates an operation * instance, returning the operation instance handler. * * @param[in] opFactory OpFactory instance containing the parameters for this operation. * * @param[in] perOpInfrastructure Per-Op infrastructure for this operation. The definition * and semantics of this object will be defined in the implementation header * appropriate to this core type. * * @param[in] numOfInputs The number of input tensors this operation will receive. * * @param[in] inputs Array of input tensors, providing both the sizes and initial * location of the data. * * @param[in] numOfOutputs Number of output tensors this operation will produce. * * @param[in] outputs Array of output tensors, providing both the sizes and * initial location of the data. * * @param[in,out] operation Handle for newly created operation instance. * * @return Error Code */ SnpeUdo_ErrorType_t SnpeUdo_createOperation(SnpeUdo_OpFactory_t opFactory, void* perOpInfrastructure, uint32_t numOfInputs, SnpeUdo_TensorParam_t* inputs, uint32_t numOfOutputs, SnpeUdo_TensorParam_t* outputs, SnpeUdo_Operation_t* operation); typedef SnpeUdo_ErrorType_t (*SnpeUdo_CreateOperationFunction_t)(SnpeUdo_OpFactory_t, void*, uint32_t, SnpeUdo_TensorParam_t*, uint32_t, SnpeUdo_TensorParam_t*, SnpeUdo_Operation_t*); /** * @brief A pointer to notification function. * * The notification function supports the non-blocking (e.g. asynchronous) execution use-case. * In case an "executeUdoOp" function is called with "blocking" set to zero, and a * notify function, this function will be called by the implementation library at the * end of execution. The implementation library will pass the notify function the ID * that was provided to it when "executeUdoOp" was called. * * @param[in] ID 32-bit value, that was provided to executeUdoOp by the calling entity. * Can be used to track the notifications, in case of multiple execute calls issued. * * @return Error code * */ typedef SnpeUdo_ErrorType_t (*SnpeUdo_ExternalNotify_t)(const uint32_t ID); /** * @brief Operation execution function. * * Calling this function will run the operation on set of inputs, generating a set of outputs. * The call can be blocking (synchronous) or non-blocking (asynchronous). To support the * non-blocking mode, the calling entity can pass an ID and a notification function. * At the end of the execution this notification function would be called, passing it the ID. * NOTE: Asynchronous execution mode not supported in this release. * * @param[in] operation handle to the operation on which execute is invoked * @param[in] blocking flag to indicate execution mode. * If set, execution is blocking, * e.g SnpeUdo_executeOp call does not return until execution is done. * If not set, SnpeUdo_executeOp returns immediately, and the * library will call the notification function (if set) when execution is done. * * @param[in] ID 32-bit number that can be used by the calling entity to track execution * in case of non-blocking execution. * For example, it can be a sequence number, increased by one on each call. * * @param[in] notifyFunc Pointer to notification function. if the pointer is set, and execution is * non-blocking, the library will call this function at end of execution, * passing the number provided as ID * * @return Error code * */ SnpeUdo_ErrorType_t SnpeUdo_executeOp(SnpeUdo_Operation_t operation, bool blocking, const uint32_t ID, SnpeUdo_ExternalNotify_t notifyFunc); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ExecuteOpFunction_t)(SnpeUdo_Operation_t, bool, const uint32_t, SnpeUdo_ExternalNotify_t); /** * @brief A function to setting the inputs & outputs. part of SnpeUdo_Operation struct, * returned from creation of a new operation instance. * Not supported in this release. * * This function allows the calling entity to change some of the inputs and outputs * between calls to execute. * Note that the change is limited to changing the pointer to the tensor data only. * Any other change may be rejected by the implementation library, causing * immediate invalidation of the operation instance * * @param[in] operation Operation on which IO tensors are set * * @param[in] inputs array of tensor parameters. The calling entity may provide a subset of the * operation inputs, providing only those that it wants to change. * * @param[in] outputs array of tensor parameters. The calling entity may provide a subset of the * operation outputs, providing only those that it wants to change. * * @return Error code * */ SnpeUdo_ErrorType_t SnpeUdo_setOpIO(SnpeUdo_Operation_t operation, SnpeUdo_TensorParam_t* inputs, SnpeUdo_TensorParam_t* outputs); typedef SnpeUdo_ErrorType_t (*SnpeUdo_SetOpIOFunction_t)(SnpeUdo_Operation_t, SnpeUdo_TensorParam_t*, SnpeUdo_TensorParam_t*); /** * @brief A function to return execution times. * * This function can be called to query the operation execution times on the IP core * on which the operation is run. The time is provided in micro-seconds * * @param[in] operation Handle to operation whose execution time is being profiled * * @param[in,out] executionTime pointer to a uint32 value.This function writes the operation * execution time in usec into this value. * * @return Error code * */ SnpeUdo_ErrorType_t SnpeUdo_profileOp(SnpeUdo_Operation_t operation, uint32_t *executionTime); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ProfileOpFunction_t)(SnpeUdo_Operation_t, uint32_t*); /** * @brief A function to release the operation instance * \n When it is called, the implementation library needs to release all resources * allocated for this operation instance. * \n Note that all function pointers which are part of SnpeUdo_Operation become * invalid once releaseUdoOp call returns. * * @param[in] operation Handle to operation to be released * @return Error code * */ SnpeUdo_ErrorType_t SnpeUdo_releaseOp(SnpeUdo_Operation_t operation); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ReleaseOpFunction_t)(SnpeUdo_Operation_t); /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #ifdef __cplusplus } // extern "C" #endif #endif //SNPE_UDO_IMPL_H ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoImplCpu.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== // Header to be used by a CPU UDO Implementation library #ifndef SNPE_UDO_IMPL_CPU_H #define SNPE_UDO_IMPL_CPU_H #include /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief This struct provides the infrastructure needed by a developer of * CPU UDO Implementation library. * * The framework/runtime which loads the CPU UDO implementation library provides * this infrastructure data to the loaded library at the time of op factory creation. * as an opaque pointer. It contains hooks for the UDO library to invoke supported * functionality at the time of execution * * @param getData function pointer to retrieve raw tensor data from opaque pointer * passed into the UDO when creating an instance. * @param getDataSize function pointer to retrieve tensor data size from opaque pointer */ typedef struct { /// function pointer to retrieve raw tensor data from opaque pointer /// passed into the UDO when creating an instance. float* (*getData)(void*); /// function pointer to retrieve tensor data size from opaque pointer size_t (*getDataSize) (void*); } SnpeUdo_CpuInfrastructure_t; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // SNPE_UDO_IMPL_CPU_H ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoImplDsp.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== //============================================================================== /* * THIS HEADER FILE IS COPIED FROM HEXAGON-NN PROJECT * */ //============================================================================== // Header to be used by a DSP Hexnn UDO Implementation library #ifndef SNPE_UDO_IMPL_DSP_H #define SNPE_UDO_IMPL_DSP_H #include #include "SnpeUdo/UdoImpl.h" /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief A function to validate that a set of params is supported by an operation * This function is HexNN specific, use case is when registration library is not in use. * Optional function. * * @param[in] operationType Operation type * @param[in] numOfStaticParams Number of static params defined by the op * @param[in] staticParams Array of static params to the op * @return Error code, indicating if the operation can be created on this set of configuration or not. * */ SnpeUdo_ErrorType_t SnpeUdo_validateOperation (SnpeUdo_String_t operationType, uint32_t numOfStaticParams, const SnpeUdo_Param_t* staticParams); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ValidateOperationFunction_t) (SnpeUdo_String_t, uint32_t, const SnpeUdo_Param_t*); // enum used for indicating input/outout tensor data layouts on DSP, plain vs d32 typedef enum { SNPE_UDO_DSP_TENSOR_LAYOUT_PLAIN, SNPE_UDO_DSP_TENSOR_LAYOUT_D32 } SnpeUdo_HexNNTensorLayout_t; /** * @brief A function to query numbers of inputs and outputs, * quantization type of each input and each output as arrays, * and data layout (plain vs d32) of each input and each output as arrays * of an operation. * inputsQuantTypes and inputsLayouts should point to arrays of size numOfInputs * outputsQuantTypes and outputsLayouts should point to arrays of size numOfOutputs * * Note: inputsLayouts and inputsLayouts can point to NULL, in this case, it is * assumed all inputs and/or outputs have plain data layouts, i.e. no D32 * * @param[in] operationType Operation type * @param[in] numOfStaticParams Number of static params defined by the op * @param[in] staticParams Array of static params to the op * @param[in,out] numOfInputs Number of input tensors to the op * @param[in,out] inputsQuantTypes Array of Quantization info for each input tensor * @param[in,out] inputsLayouts Array of layout type for each input tensor * @param[in,out] numOfOutputs Number of output tensors to the op * @param[in,out] outputsQuantTypes Array of Quantization info for each output tensor * @param[in,out] outputsLayouts Array of layout type for each output tensor * @return error code, indicating status of query */ SnpeUdo_ErrorType_t SnpeUdo_queryOperation (SnpeUdo_String_t operationType, uint32_t numOfStaticParams, const SnpeUdo_Param_t* staticParams, uint32_t* numOfInputs, SnpeUdo_QuantizationType_t** inputsQuantTypes, SnpeUdo_HexNNTensorLayout_t** inputsLayouts, uint32_t* numOfOutputs, SnpeUdo_QuantizationType_t** outputsQuantTypes, SnpeUdo_HexNNTensorLayout_t** outputsLayouts); typedef SnpeUdo_ErrorType_t (*SnpeUdo_QueryOperationFunction_t) (SnpeUdo_String_t, uint32_t, const SnpeUdo_Param_t*, uint32_t*, SnpeUdo_QuantizationType_t**, SnpeUdo_HexNNTensorLayout_t**, uint32_t*, SnpeUdo_QuantizationType_t**, SnpeUdo_HexNNTensorLayout_t**); // Global infrastructure functions supported by Hexagon-NN v2 typedef void (*workerThread_t) (void* perOpInfrastructure, void* userData); typedef int (*udoSetOutputTensorSize_t) (void* perOpInfrastructure, uint32_t outIdx, uint32_t size); typedef int (*udoGetInputD32Paddings_t) (void* perOpInfrastructure, uint32_t inIdx, uint32_t* heightPadBefore, uint32_t* heightPadAfter, uint32_t* widthPadBefore, uint32_t* widthPadAfter, uint32_t* depthPadBefore, uint32_t* depthPadAfter); typedef int (*udoSetOutputD32ShapeSizePaddings_t) (void* perOpInfrastructure, uint32_t outIdx, uint32_t batch, uint32_t height, uint32_t heightPadBefore, uint32_t heightPadAfter, uint32_t width, uint32_t widthPadBefore, uint32_t widthPadAfter, uint32_t depth, uint32_t depthPadBefore, uint32_t depthPadAfter, SnpeUdo_DataType_t dataType); typedef void* (*udoMemalign_t) (size_t n, size_t size); typedef void* (*udoMalloc_t) (size_t size); typedef void* (*udoCalloc_t) (size_t n, size_t size); typedef void (*udoFree_t) (void* ptr); typedef uint32_t (*udoGetVtcmSize_t) (void* perOpInfrastructure); typedef void* (*udoGetVtcmPtr_t) (void* perOpInfrastructure); typedef uint32_t (*udoVtcmIsReal_t) (void* perOpInfrastructure); typedef void (*udoRunWorkerThreads_t) (void* perOpInfrastructure, uint32_t nThreads, workerThread_t w, void* userData); typedef struct hexNNv2GlobalInfra { udoSetOutputTensorSize_t udoSetOutputTensorSize; udoGetInputD32Paddings_t udoGetInputD32Paddings; udoSetOutputD32ShapeSizePaddings_t udoSetOutputD32ShapeSizePaddings; udoMemalign_t udoMemalign; udoMalloc_t udoMalloc; udoCalloc_t udoCalloc; udoFree_t udoFree; udoGetVtcmSize_t udoGetVtcmSize; udoGetVtcmPtr_t udoGetVtcmPtr; udoVtcmIsReal_t udoVtcmIsReal; udoRunWorkerThreads_t udoRunWorkerThreads; } SnpeUdo_HexNNv2GlobalInfra_t; // hexnn types typedef enum hexnnInfraType { UDO_INFRA_HEXNN_V2, UDO_INFRA_HEXNN_V3 // reserved, do not use } SnpeUdo_HexNNInfraType_t; /** * @brief Infrastructures needed by a developer of DSP Hexnn UDO Implementation library. * * The framework/runtime which loads the Hexnn UDO implementation library provides * this infrastructure to the loaded library by calling "SnpeUdo_initImplLibrary" * function, and passing it (cast to void*). The Hexnn UDO library is expected * to cast it back to this structure. * */ typedef struct dspGlobalInfrastructure { SnpeUdo_Version_t dspInfraVersion; // api version SnpeUdo_HexNNInfraType_t infraType; SnpeUdo_HexNNv2GlobalInfra_t hexNNv2Infra; } SnpeUdo_DspGlobalInfrastructure_t; /** * hexnn v2 per op factory infrastructure * * The framework/runtime passes per op factory infrastructure as a void pointer * to HexNN UDO implementation library by calling function "SnpeUdo_createOpFactory". * UDO implementation library is expected to cast it back to this following struct. * */ typedef struct hexnnv2OpFactoryInfra { unsigned long graphId; } SnpeUdo_HexNNv2OpFactoryInfra_t; /** * hexnn v2 per operation infrastructure * * The framework/runtime passes per operation infrastructure as a void pointer * to HexNN UDO implementation library by calling function "SnpeUdo_createOperation". * UDO implementation library is expected to cast it to the following type and save it. * * This is needed to be passed back into some functions from global infrastructure. * */ typedef void* SnpeUdo_HexNNv2OpInfra_t; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // SNPE_UDO_IMPL_DSP_H ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoImplGpu.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== // Header to be used by a GPU UDO Implementation library #ifndef SNPE_UDO_IMPL_GPU_H #define SNPE_UDO_IMPL_GPU_H #include "CL/cl.h" #include "SnpeUdo/UdoBase.h" /** @addtogroup c_plus_plus_apis C++ @{ */ /** * This header defines version 0.0.0 of the GPU UDO Infrastructure. * It defines the interpretation of the global and per-OpFactory infrastructure pointers * as well as the interpretation of tensorData pointers. * * The per-Operation infrastructure pointer is defined to be null, and should not be used. * * The SnpeUdoTensorParam_t struct below provides the interpretation for * the tensorData opaque pointer for SnpeUdoTensorParams representing inputs or outputs. * * The tensorData opaque pointer populated in SnpeUdoScalarParam_t structs should be interpreted * as a host-readable data pointer. * */ /** * @brief Function to retrieve opencl program from Program Cache repository. * @param programCache is opaque pointer to Program Cache repository provided by * SNPE GPU UDO runtime. * @param programName is name associated with opencl program for UDO. * @param program is pointer to opencl program which will be populated with * valid opencl program if found in Program Cache repository. * @return SnpeUdo_ErrorType_t is error type returned. SNPE_UDO_NO_ERROR is returned * on success. */ typedef SnpeUdo_ErrorType_t (*SnpeUdo_getProgram_t) (void* programCache, const char* programName, cl_program* program); /** * @brief Function to store valid opencl program in Program Cache repository. * @param programCache is opaque pointer to Program Cache repository provided by * SNPE GPU UDO runtime. * @param programName is name associated with opencl program for UDO. * @param program is valid opencl program after program is built. * @return SnpeUdo_ErrorType_t is error type returned. SNPE_UDO_NO_ERROR is returned * on success. * */ typedef SnpeUdo_ErrorType_t (*SnpeUdo_storeProgram_t) (void* programCache, const char * programName, cl_program program); /** * @brief Global Infrastructure Definition for GPU UDO Implementations. */ typedef struct { // Infrastructure definition version. This header is 0.0.0 SnpeUdo_Version_t gpuInfraVersion; SnpeUdo_getProgram_t SnpeUdo_getProgram; SnpeUdo_storeProgram_t SnpeUdo_storeProgram; } SnpeUdo_GpuInfrastructure_t; /** * @brief Per OpFactory Infrastructure Definition for GPU UDO Implementations. * @note This version of the infrastructure definition guarantees that the same * Per OpFactory infrastructure pointer will be provided to all OpFactories * in the same network. */ typedef struct { cl_context context; cl_command_queue commandQueue; void* programCache; } SnpeUdo_GpuOpFactoryInfrastructure_t; /** * @brief Opaque tensorData definition for operation inputs and outputs. * * The following is a list of all SnpeUdoTensorLayout_t values supported by the * GPU UDO implementation, and how the parameters of the struct should be * interpreted in each case: * * SNPE_UDO_LAYOUT_NHWC: * mem shall be single-element array, pointing to a cl buffer memory object. * the dimensions of this object match the dimensions specified in the encompassing * SnpeUdoTensorParam_t's currDimensions. * * memCount shall be 1. * * paddedRank and paddedDimensions are undefined and shall be ignored by the UDO * implementation. * */ typedef struct { cl_mem* mem; uint32_t memCount; uint32_t paddedRank; uint32_t* paddedDimensions; } SnpeUdo_GpuTensorData_t; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // SNPE_UDO_IMPL_GPU_H ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoReg.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef SNPE_UDO_REG_H #define SNPE_UDO_REG_H #include "SnpeUdo/UdoShared.h" #ifdef __cplusplus extern "C" { #endif /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief Initialize the shared library's data structures. Calling any other * library function before this one will result in an error being returned. * * @return Error code */ SnpeUdo_ErrorType_t SnpeUdo_initRegLibrary(void); typedef SnpeUdo_ErrorType_t (*SnpeUdo_InitRegLibraryFunction_t)(void); /** * @brief A function to query the API version of the UDO registration library. * The function populates a SnpeUdo_LibVersion_t struct, which contains a SnpeUdo_Version_t * struct for API version and library version. * * @param[in, out] version A pointer to struct which contains major, minor, teeny information for * library and api versions. * * @return Error code */ SnpeUdo_ErrorType_t SnpeUdo_getRegLibraryVersion(SnpeUdo_LibVersion_t** version); typedef SnpeUdo_ErrorType_t (*SnpeUdo_getRegLibraryVersion_t)(SnpeUdo_LibVersion_t** version); /** * @brief Release the shared library's data structures, and invalidate any * handles returned by the library. The behavior of any outstanding * asynchronous calls made to this library when this function is called * are undefined. All library functions (except SnpeUdo_InitRegLibrary) will * return an error after this function has been successfully called. * * It should be possible to call SnpeUdo_InitRegLibrary after calling this * function, and re-initialize the library. * * @return Error code */ SnpeUdo_ErrorType_t SnpeUdo_terminateRegLibrary(void); typedef SnpeUdo_ErrorType_t (*SnpeUdo_TerminateRegLibraryFunction_t)(void); /** * @brief A function to query the info on the UDO set. * The function populates a structure which contains information about * the package and operations contained in it. * * @param[in, out] registrationInfo A struct which contains information on the set of UDOs * * @return Error code * */ SnpeUdo_ErrorType_t SnpeUdo_getRegInfo(SnpeUdo_RegInfo_t** registrationInfo); typedef SnpeUdo_ErrorType_t (*SnpeUdo_GetRegInfoFunction_t)(SnpeUdo_RegInfo_t** registrationInfo); /** * @brief A function to validate that a set of params is supported by an operation * The function receives an operation definition struct, and returns if this configuration is * supported (e.g. if an operation can be created using this configuration) * * @param[in] opDefinition A struct of SnpeUdo_OpDefinition type, containing the information needed to * validate that an operation can be created with this configuration. * * @return Error code, indicating is the operation can be created on this set or not. * */ SnpeUdo_ErrorType_t SnpeUdo_validateOperation(SnpeUdo_OpDefinition_t* opDefinition); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ValidateOperationFunction_t)(SnpeUdo_OpDefinition_t* opDefinition); /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #ifdef __cplusplus } // extern "C" #endif #endif //SNPE_UDO_REG_H ================================================ FILE: phonelibs/snpe/include/SnpeUdo/UdoShared.h ================================================ //============================================================================== // // Copyright (c) 2019-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // //============================================================================== #ifndef SNPE_UDO_SHARED_H #define SNPE_UDO_SHARED_H #include "SnpeUdo/UdoBase.h" #ifdef __cplusplus extern "C" { #endif /** @addtogroup c_plus_plus_apis C++ @{ */ /** * @brief A function to return the various versions as they relate to the UDO * The function returns a struct containing the the following: * libVersion: the version of the implementation library compiled for the UDO. Set by user * apiVersion: the version of the UDO API used in compiling the implementation library. * Set by SNPE * * @param[in, out] version A pointer to Version struct of type SnpeUdo_LibVersion_t * * @return Error code * */ SnpeUdo_ErrorType_t SnpeUdo_getVersion (SnpeUdo_LibVersion_t** version); typedef SnpeUdo_ErrorType_t (*SnpeUdo_GetVersionFunction_t) (SnpeUdo_LibVersion_t** version); #ifdef __cplusplus } // extern "C" #endif /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // SNPE_UDO_SHARED_H ================================================ FILE: phonelibs/zlib/build.txt ================================================ # with neos tree cd ~/android/system mka libz cp ~/android/system/out/target/product/oneplus3/obj/STATIC_LIBRARIES/libz_intermediates/libz.a lib/ ================================================ FILE: pyextra/.gitignore ================================================ *.pyc ================================================ FILE: rednose/SConscript ================================================ Import('env', 'envCython', 'arch', 'rednose_config') generated_folder = rednose_config['generated_folder'] templates = Glob('#rednose/templates/*') sympy_helpers = "#rednose/helpers/sympy_helpers.py" ekf_sym = "#rednose/helpers/ekf_sym.py" ekf_sym_pyx = "#rednose/helpers/ekf_sym_pyx.pyx" ekf_sym_cc = env.Object("#rednose/helpers/ekf_sym.cc") common_ekf = "#rednose/helpers/common_ekf.cc" found = {} for target, (command, combined_lib, extra_generated) in rednose_config['to_build'].items(): if File(command).exists(): found[target] = (command, combined_lib, extra_generated) lib_target = [common_ekf] for target, (command, combined_lib, extra_generated) in found.items(): target_files = File([f'{generated_folder}/{target}.cpp', f'{generated_folder}/{target}.h']) extra_generated = [File(f'{generated_folder}/{x}') for x in extra_generated] command_file = File(command) env.Command(target_files + extra_generated, [templates, command_file, sympy_helpers, ekf_sym], command_file.get_abspath() + " " + target + " " + Dir(generated_folder).get_abspath()) if combined_lib: lib_target.append(target_files[0]) else: env.SharedLibrary(f'{generated_folder}/' + target, [target_files[0], common_ekf]) libkf = env.SharedLibrary(f'{generated_folder}/libkf', lib_target) lenv = envCython.Clone() lenv["LINKFLAGS"] += [libkf[0].get_labspath()] ekf_sym_so = lenv.Program('#rednose/helpers/ekf_sym_pyx.so', [ekf_sym_pyx, ekf_sym_cc, common_ekf]) lenv.Depends(ekf_sym_so, libkf) Export('libkf') ================================================ FILE: rednose/helpers/__init__.py ================================================ import os import platform from cffi import FFI TEMPLATE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'templates')) def write_code(folder, name, code, header): if not os.path.exists(folder): os.mkdir(folder) open(os.path.join(folder, f"{name}.cpp"), 'w').write(code) open(os.path.join(folder, f"{name}.h"), 'w').write(header) def load_code(folder, name, lib_name=None): if lib_name is None: lib_name = name shared_ext = "dylib" if platform.system() == "Darwin" else "so" shared_fn = os.path.join(folder, f"lib{lib_name}.{shared_ext}") header_fn = os.path.join(folder, f"{name}.h") with open(header_fn) as f: header = f.read() # is the only thing that can be parsed by cffi header = "\n".join([line for line in header.split("\n") if line.startswith("void ")]) ffi = FFI() ffi.cdef(header) return (ffi, ffi.dlopen(shared_fn)) class KalmanError(Exception): pass ================================================ FILE: rednose/helpers/chi2_lookup.py ================================================ import os import numpy as np def gen_chi2_ppf_lookup(max_dim=200): from scipy.stats import chi2 table = np.zeros((max_dim, 98)) for dim in range(1, max_dim): table[dim] = chi2.ppf(np.arange(.01, .99, .01), dim) np.save('chi2_lookup_table', table) def chi2_ppf(p, dim): table = np.load(os.path.dirname(os.path.realpath(__file__)) + '/chi2_lookup_table.npy') result = np.interp(p, np.arange(.01, .99, .01), table[dim]) return result if __name__ == "__main__": gen_chi2_ppf_lookup() ================================================ FILE: rednose/helpers/common_ekf.cc ================================================ #include "common_ekf.h" std::vector& get_ekfs() { static std::vector vec; return vec; } void ekf_register(const EKF* ekf) { get_ekfs().push_back(ekf); } const EKF* ekf_lookup(const std::string& ekf_name) { for (const auto& ekfi : get_ekfs()) { if (ekf_name == ekfi->name) { return ekfi; } } return NULL; } ================================================ FILE: rednose/helpers/common_ekf.h ================================================ #pragma once #include #include #include #include #include #include #include #include #include typedef void (*extra_routine_t)(double *, double *); struct EKF { std::string name; std::vector kinds; std::vector feature_kinds; void (*f_fun)(double *, double, double *); void (*F_fun)(double *, double, double *); void (*err_fun)(double *, double *, double *); void (*inv_err_fun)(double *, double *, double *); void (*H_mod_fun)(double *, double *); void (*predict)(double *, double *, double *, double); std::unordered_map hs = {}; std::unordered_map Hs = {}; std::unordered_map updates = {}; std::unordered_map Hes = {}; std::unordered_map sets = {}; std::unordered_map extra_routines = {}; }; std::vector& get_ekfs(); const EKF* ekf_lookup(const std::string& ekf_name); void ekf_register(const EKF* ekf); #define ekf_init(ekf) \ static void __attribute__((constructor)) do_ekf_init_ ## ekf(void) { \ ekf_register(&ekf); \ } ================================================ FILE: rednose/helpers/ekf_sym.cc ================================================ #include "ekf_sym.h" using namespace EKFS; using namespace Eigen; EKFSym::EKFSym(std::string name, Map Q, Map x_initial, Map P_initial, int dim_main, int dim_main_err, int N, int dim_augment, int dim_augment_err, std::vector maha_test_kinds, std::vector quaternion_idxs, std::vector global_vars, double max_rewind_age) { // TODO: add logger this->ekf = ekf_lookup(name); assert(this->ekf); this->msckf = N > 0; this->N = N; this->dim_augment = dim_augment; this->dim_augment_err = dim_augment_err; this->dim_main = dim_main; this->dim_main_err = dim_main_err; this->dim_x = x_initial.rows(); this->dim_err = P_initial.rows(); assert(dim_main + dim_augment * N == dim_x); assert(dim_main_err + dim_augment_err * N == this->dim_err); assert(Q.rows() == P_initial.rows() && Q.cols() == P_initial.cols()); // kinds that should get mahalanobis distance // tested for outlier rejection this->maha_test_kinds = maha_test_kinds; // quaternions need normalization this->quaternion_idxs = quaternion_idxs; this->global_vars = global_vars; // Process noise this->Q = Q; this->max_rewind_age = max_rewind_age; this->init_state(x_initial, P_initial, NAN); } void EKFSym::init_state(Map state, Map covs, double filter_time) { this->x = state; this->P = covs; this->filter_time = filter_time; this->augment_times = VectorXd::Zero(this->N); this->reset_rewind(); } VectorXd EKFSym::state() { return this->x; } MatrixXdr EKFSym::covs() { return this->P; } void EKFSym::set_filter_time(double t) { this->filter_time = t; } double EKFSym::get_filter_time() { return this->filter_time; } void EKFSym::normalize_quaternions() { for(std::size_t i = 0; i < this->quaternion_idxs.size(); ++i) { this->normalize_slice(this->quaternion_idxs[i], this->quaternion_idxs[i] + 4); } } void EKFSym::normalize_slice(int slice_start, int slice_end_ex) { this->x.block(slice_start, 0, slice_end_ex - slice_start, this->x.cols()).normalize(); } void EKFSym::set_global(std::string global_var, double val) { this->ekf->sets.at(global_var)(val); } std::optional EKFSym::predict_and_update_batch(double t, int kind, std::vector> z_map, std::vector> R_map, std::vector> extra_args, bool augment) { // TODO handle rewinding at this level std::deque rewound; if (!std::isnan(this->filter_time) && t < this->filter_time) { if (this->rewind_t.empty() || t < this->rewind_t.front() || t < this->rewind_t.back() - this->max_rewind_age) { std::cout << "observation too old at " << t << " with filter at " << this->filter_time << ", ignoring" << std::endl; return std::nullopt; } rewound = this->rewind(t); } Observation obs; obs.t = t; obs.kind = kind; obs.extra_args = extra_args; for (Map zi : z_map) { obs.z.push_back(zi); } for (Map Ri : R_map) { obs.R.push_back(Ri); } std::optional res = std::make_optional(this->predict_and_update_batch(obs, augment)); // optional fast forward while (!rewound.empty()) { this->predict_and_update_batch(rewound.front(), false); rewound.pop_front(); } return res; } void EKFSym::reset_rewind() { this->rewind_obscache.clear(); this->rewind_t.clear(); this->rewind_states.clear(); } std::deque EKFSym::rewind(double t) { std::deque rewound; // rewind observations until t is after previous observation while (this->rewind_t.back() > t) { rewound.push_front(this->rewind_obscache.back()); this->rewind_t.pop_back(); this->rewind_states.pop_back(); this->rewind_obscache.pop_back(); } // set the state to the time right before that this->filter_time = this->rewind_t.back(); this->x = this->rewind_states.back().first; this->P = this->rewind_states.back().second; return rewound; } void EKFSym::checkpoint(Observation& obs) { // push to rewinder this->rewind_t.push_back(this->filter_time); this->rewind_states.push_back(std::make_pair(this->x, this->P)); this->rewind_obscache.push_back(obs); // only keep a certain number around if (this->rewind_t.size() > REWIND_TO_KEEP) { this->rewind_t.pop_front(); this->rewind_states.pop_front(); this->rewind_obscache.pop_front(); } } Estimate EKFSym::predict_and_update_batch(Observation& obs, bool augment) { assert(obs.z.size() == obs.R.size()); assert(obs.z.size() == obs.extra_args.size()); this->predict(obs.t); Estimate res; res.t = obs.t; res.kind = obs.kind; res.z = obs.z; res.extra_args = obs.extra_args; res.xk1 = this->x; res.Pk1 = this->P; // update batch std::vector y; for (int i = 0; i < obs.z.size(); i++) { assert(obs.z[i].rows() == obs.R[i].rows()); assert(obs.z[i].rows() == obs.R[i].cols()); // update state y.push_back(this->update(obs.kind, obs.z[i], obs.R[i], obs.extra_args[i])); } res.xk = this->x; res.Pk = this->P; res.y = y; assert(!augment); // TODO // if (augment) { // this->augment(); // } this->checkpoint(obs); return res; } void EKFSym::predict(double t) { // initialize time if (std::isnan(this->filter_time)) { this->filter_time = t; } // predict double dt = t - this->filter_time; assert(dt >= 0.0); this->ekf->predict(this->x.data(), this->P.data(), this->Q.data(), dt); this->normalize_quaternions(); this->filter_time = t; } VectorXd EKFSym::update(int kind, VectorXd z, MatrixXdr R, std::vector extra_args) { this->ekf->updates.at(kind)(this->x.data(), this->P.data(), z.data(), R.data(), extra_args.data()); this->normalize_quaternions(); if (this->msckf && std::find(this->feature_track_kinds.begin(), this->feature_track_kinds.end(), kind) != this->feature_track_kinds.end()) { return z.head(z.rows() - extra_args.size()); } return z; } extra_routine_t EKFSym::get_extra_routine(const std::string& routine) { return this->ekf->extra_routines.at(routine); } ================================================ FILE: rednose/helpers/ekf_sym.h ================================================ #pragma once #include #include #include #include #include #include #include #include #include #include #include "common_ekf.h" #define REWIND_TO_KEEP 512 namespace EKFS { typedef Eigen::Matrix MatrixXdr; typedef struct Observation { double t; int kind; std::vector z; std::vector R; std::vector> extra_args; } Observation; typedef struct Estimate { Eigen::VectorXd xk1; Eigen::VectorXd xk; MatrixXdr Pk1; MatrixXdr Pk; double t; int kind; std::vector y; std::vector z; std::vector> extra_args; } Estimate; class EKFSym { public: EKFSym(std::string name, Eigen::Map Q, Eigen::Map x_initial, Eigen::Map P_initial, int dim_main, int dim_main_err, int N = 0, int dim_augment = 0, int dim_augment_err = 0, std::vector maha_test_kinds = std::vector(), std::vector quaternion_idxs = std::vector(), std::vector global_vars = std::vector(), double max_rewind_age = 1.0); void init_state(Eigen::Map state, Eigen::Map covs, double filter_time); Eigen::VectorXd state(); MatrixXdr covs(); void set_filter_time(double t); double get_filter_time(); void normalize_quaternions(); void normalize_slice(int slice_start, int slice_end_ex); void set_global(std::string global_var, double val); void reset_rewind(); void predict(double t); std::optional predict_and_update_batch(double t, int kind, std::vector> z, std::vector> R, std::vector> extra_args = {{}}, bool augment = false); extra_routine_t get_extra_routine(const std::string& routine); private: std::deque rewind(double t); void checkpoint(Observation& obs); Estimate predict_and_update_batch(Observation& obs, bool augment); Eigen::VectorXd update(int kind, Eigen::VectorXd z, MatrixXdr R, std::vector extra_args); // stuct with linked sympy generated functions const EKF *ekf = NULL; Eigen::VectorXd x; // state MatrixXdr P; // covs bool msckf; int N; int dim_augment; int dim_augment_err; int dim_main; int dim_main_err; // state int dim_x; int dim_err; double filter_time; std::vector maha_test_kinds; std::vector quaternion_idxs; std::vector global_vars; // process noise MatrixXdr Q; // rewind stuff double max_rewind_age; std::deque rewind_t; std::deque> rewind_states; std::deque rewind_obscache; Eigen::VectorXd augment_times; std::vector feature_track_kinds; }; } ================================================ FILE: rednose/helpers/ekf_sym.py ================================================ import os import logging from bisect import bisect_right import numpy as np import sympy as sp from numpy import dot from rednose.helpers.sympy_helpers import sympy_into_c from rednose.helpers import TEMPLATE_DIR, load_code from rednose.helpers.chi2_lookup import chi2_ppf def solve(a, b): if a.shape[0] == 1 and a.shape[1] == 1: return b / a[0][0] else: return np.linalg.solve(a, b) def null(H, eps=1e-12): _, s, vh = np.linalg.svd(H) padding = max(0, np.shape(H)[1] - np.shape(s)[0]) null_mask = np.concatenate(((s <= eps), np.ones((padding,), dtype=bool)), axis=0) null_space = np.compress(null_mask, vh, axis=0) return np.transpose(null_space) def gen_code(folder, name, f_sym, dt_sym, x_sym, obs_eqs, dim_x, dim_err, eskf_params=None, msckf_params=None, # pylint: disable=dangerous-default-value maha_test_kinds=[], quaternion_idxs=[], global_vars=None, extra_routines=[]): # optional state transition matrix, H modifier # and err_function if an error-state kalman filter (ESKF) # is desired. Best described in "Quaternion kinematics # for the error-state Kalman filter" by Joan Sola if eskf_params: err_eqs = eskf_params[0] inv_err_eqs = eskf_params[1] H_mod_sym = eskf_params[2] f_err_sym = eskf_params[3] x_err_sym = eskf_params[4] else: nom_x = sp.MatrixSymbol('nom_x', dim_x, 1) true_x = sp.MatrixSymbol('true_x', dim_x, 1) delta_x = sp.MatrixSymbol('delta_x', dim_x, 1) err_function_sym = sp.Matrix(nom_x + delta_x) inv_err_function_sym = sp.Matrix(true_x - nom_x) err_eqs = [err_function_sym, nom_x, delta_x] inv_err_eqs = [inv_err_function_sym, nom_x, true_x] H_mod_sym = sp.Matrix(np.eye(dim_x)) f_err_sym = f_sym x_err_sym = x_sym # This configures the multi-state augmentation # needed for EKF-SLAM with MSCKF (Mourikis et al 2007) if msckf_params: msckf = True dim_main = msckf_params[0] # size of the main state dim_augment = msckf_params[1] # size of one augment state chunk dim_main_err = msckf_params[2] dim_augment_err = msckf_params[3] N = msckf_params[4] feature_track_kinds = msckf_params[5] assert dim_main + dim_augment * N == dim_x assert dim_main_err + dim_augment_err * N == dim_err else: msckf = False dim_main = dim_x dim_augment = 0 dim_main_err = dim_err dim_augment_err = 0 N = 0 # linearize with jacobians F_sym = f_err_sym.jacobian(x_err_sym) if eskf_params: for sym in x_err_sym: F_sym = F_sym.subs(sym, 0) assert dt_sym in F_sym.free_symbols for i in range(len(obs_eqs)): obs_eqs[i].append(obs_eqs[i][0].jacobian(x_sym)) if msckf and obs_eqs[i][1] in feature_track_kinds: obs_eqs[i].append(obs_eqs[i][0].jacobian(obs_eqs[i][2])) else: obs_eqs[i].append(None) # collect sympy functions sympy_functions = [] # extra routines sympy_functions += extra_routines # error functions sympy_functions.append(('err_fun', err_eqs[0], [err_eqs[1], err_eqs[2]])) sympy_functions.append(('inv_err_fun', inv_err_eqs[0], [inv_err_eqs[1], inv_err_eqs[2]])) # H modifier for ESKF updates sympy_functions.append(('H_mod_fun', H_mod_sym, [x_sym])) # state propagation function sympy_functions.append(('f_fun', f_sym, [x_sym, dt_sym])) sympy_functions.append(('F_fun', F_sym, [x_sym, dt_sym])) # observation functions for h_sym, kind, ea_sym, H_sym, He_sym in obs_eqs: sympy_functions.append(('h_%d' % kind, h_sym, [x_sym, ea_sym])) sympy_functions.append(('H_%d' % kind, H_sym, [x_sym, ea_sym])) if msckf and kind in feature_track_kinds: sympy_functions.append(('He_%d' % kind, He_sym, [x_sym, ea_sym])) # Generate and wrap all th c code sympy_header, code = sympy_into_c(sympy_functions, global_vars) header = "#pragma once\n" header += "#include \"rednose/helpers/common_ekf.h\"\n" header += "extern \"C\" {\n" pre_code = f"#include \"{name}.h\"\n" pre_code += "\nnamespace {\n" pre_code += "#define DIM %d\n" % dim_x pre_code += "#define EDIM %d\n" % dim_err pre_code += "#define MEDIM %d\n" % dim_main_err pre_code += "typedef void (*Hfun)(double *, double *, double *);\n" if global_vars is not None: for var in global_vars: pre_code += f"\ndouble {var.name};\n" pre_code += f"\nvoid set_{var.name}(double x){{ {var.name} = x;}}\n" post_code = "\n}\n" # namespace post_code += "extern \"C\" {\n\n" for h_sym, kind, ea_sym, H_sym, He_sym in obs_eqs: if msckf and kind in feature_track_kinds: He_str = 'He_%d' % kind # ea_dim = ea_sym.shape[0] else: He_str = 'NULL' # ea_dim = 1 # not really dim of ea but makes c function work maha_thresh = chi2_ppf(0.95, int(h_sym.shape[0])) # mahalanobis distance for outlier detection maha_test = kind in maha_test_kinds pre_code += f"const static double MAHA_THRESH_{kind} = {maha_thresh};\n" header += f"void {name}_update_{kind}(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea);\n" post_code += f"void {name}_update_{kind}(double *in_x, double *in_P, double *in_z, double *in_R, double *in_ea) {{\n" post_code += f" update<{h_sym.shape[0]}, 3, {int(maha_test)}>(in_x, in_P, h_{kind}, H_{kind}, {He_str}, in_z, in_R, in_ea, MAHA_THRESH_{kind});\n" post_code += "}\n" # For ffi loading of specific functions for line in sympy_header.split("\n"): if line.startswith("void "): # sympy functions func_call = line[5: line.index(')') + 1] header += f"void {name}_{func_call};\n" post_code += f"void {name}_{func_call} {{\n" post_code += f" {func_call.replace('double *', '').replace('double', '')};\n" post_code += "}\n" header += f"void {name}_predict(double *in_x, double *in_P, double *in_Q, double dt);\n" post_code += f"void {name}_predict(double *in_x, double *in_P, double *in_Q, double dt) {{\n" post_code += " predict(in_x, in_P, in_Q, dt);\n" post_code += "}\n" if global_vars is not None: for var in global_vars: header += f"void {name}_set_{var.name}(double x);\n" post_code += f"void {name}_set_{var.name}(double x) {{\n" post_code += f" set_{var.name}(x);\n" post_code += "}\n" post_code += "}\n\n" # extern c funcs = ['f_fun', 'F_fun', 'err_fun', 'inv_err_fun', 'H_mod_fun', 'predict'] func_lists = { 'h': [kind for _, kind, _, _, _ in obs_eqs], 'H': [kind for _, kind, _, _, _ in obs_eqs], 'update': [kind for _, kind, _, _, _ in obs_eqs], 'He': [kind for _, kind, _, _, _ in obs_eqs if msckf and kind in feature_track_kinds], 'set': [var.name for var in global_vars] if global_vars is not None else [], } func_extra = [x[0] for x in extra_routines] # For dynamic loading of specific functions post_code += f"const EKF {name} = {{\n" post_code += f" .name = \"{name}\",\n" post_code += f" .kinds = {{ {', '.join([str(kind) for _, kind, _, _, _ in obs_eqs])} }},\n" post_code += f" .feature_kinds = {{ {', '.join([str(kind) for _, kind, _, _, _ in obs_eqs if msckf and kind in feature_track_kinds])} }},\n" for func in funcs: post_code += f" .{func} = {name}_{func},\n" for group, kinds in func_lists.items(): post_code += f" .{group}s = {{\n" for kind in kinds: str_kind = f"\"{kind}\"" if type(kind) == str else kind post_code += f" {{ {str_kind}, {name}_{group}_{kind} }},\n" post_code += " },\n" post_code += " .extra_routines = {\n" for f in func_extra: post_code += f" {{ \"{f}\", {name}_{f} }},\n" post_code += " },\n" post_code += "};\n\n" post_code += f"ekf_init({name});\n" # merge code blocks header += "}" code = "\n".join([pre_code, code, open(os.path.join(TEMPLATE_DIR, "ekf_c.c")).read(), post_code]) # write to file if not os.path.exists(folder): os.mkdir(folder) open(os.path.join(folder, f"{name}.h"), 'w').write(header) # header is used for ffi import open(os.path.join(folder, f"{name}.cpp"), 'w').write(code) class EKF_sym(): def __init__(self, folder, name, Q, x_initial, P_initial, dim_main, dim_main_err, # pylint: disable=dangerous-default-value N=0, dim_augment=0, dim_augment_err=0, maha_test_kinds=[], quaternion_idxs=[], global_vars=None, max_rewind_age=1.0, logger=logging): """Generates process function and all observation functions for the kalman filter.""" self.msckf = N > 0 self.N = N self.dim_augment = dim_augment self.dim_augment_err = dim_augment_err self.dim_main = dim_main self.dim_main_err = dim_main_err self.logger = logger # state x_initial = x_initial.reshape((-1, 1)) self.dim_x = x_initial.shape[0] self.dim_err = P_initial.shape[0] assert dim_main + dim_augment * N == self.dim_x assert dim_main_err + dim_augment_err * N == self.dim_err assert Q.shape == P_initial.shape # kinds that should get mahalanobis distance # tested for outlier rejection self.maha_test_kinds = maha_test_kinds # quaternions need normalization self.quaternion_idxs = quaternion_idxs # process noise self.Q = Q # rewind stuff self.max_rewind_age = max_rewind_age self.rewind_t = [] self.rewind_states = [] self.rewind_obscache = [] self.init_state(x_initial, P_initial, None) ffi, lib = load_code(folder, name, "kf") kinds, self.feature_track_kinds = [], [] for func in dir(lib): if func[:len(name) + 3] == f'{name}_h_': kinds.append(int(func[len(name) + 3:])) if func[:len(name) + 4] == f'{name}_He_': self.feature_track_kinds.append(int(func[len(name) + 4:])) # wrap all the sympy functions def wrap_1lists(func_name): func = eval(f"lib.{name}_{func_name}", {"lib": lib}) # pylint: disable=eval-used def ret(lst1, out): func(ffi.cast("double *", lst1.ctypes.data), ffi.cast("double *", out.ctypes.data)) return ret def wrap_2lists(func_name): func = eval(f"lib.{name}_{func_name}", {"lib": lib}) # pylint: disable=eval-used def ret(lst1, lst2, out): func(ffi.cast("double *", lst1.ctypes.data), ffi.cast("double *", lst2.ctypes.data), ffi.cast("double *", out.ctypes.data)) return ret def wrap_1list_1float(func_name): func = eval(f"lib.{name}_{func_name}", {"lib": lib}) # pylint: disable=eval-used def ret(lst1, fl, out): func(ffi.cast("double *", lst1.ctypes.data), ffi.cast("double", fl), ffi.cast("double *", out.ctypes.data)) return ret self.f = wrap_1list_1float("f_fun") self.F = wrap_1list_1float("F_fun") self.err_function = wrap_2lists("err_fun") self.inv_err_function = wrap_2lists("inv_err_fun") self.H_mod = wrap_1lists("H_mod_fun") self.hs, self.Hs, self.Hes = {}, {}, {} for kind in kinds: self.hs[kind] = wrap_2lists(f"h_{kind}") self.Hs[kind] = wrap_2lists(f"H_{kind}") if self.msckf and kind in self.feature_track_kinds: self.Hes[kind] = wrap_2lists(f"He_{kind}") self.set_globals = {} if global_vars is not None: for global_var in global_vars: self.set_globals[global_var] = getattr(lib, f"{name}_set_{global_var}") # wrap the C++ predict function def _predict_blas(x, P, dt): func = eval(f"lib.{name}_predict", {"lib": lib}) # pylint: disable=eval-used func(ffi.cast("double *", x.ctypes.data), ffi.cast("double *", P.ctypes.data), ffi.cast("double *", self.Q.ctypes.data), ffi.cast("double", dt)) return x, P # wrap the C++ update function def fun_wrapper(f, kind): f = eval(f"lib.{name}_{f}", {"lib": lib}) # pylint: disable=eval-used def _update_inner_blas(x, P, z, R, extra_args): f(ffi.cast("double *", x.ctypes.data), ffi.cast("double *", P.ctypes.data), ffi.cast("double *", z.ctypes.data), ffi.cast("double *", R.ctypes.data), ffi.cast("double *", extra_args.ctypes.data)) if self.msckf and kind in self.feature_track_kinds: y = z[:-len(extra_args)] else: y = z return x, P, y return _update_inner_blas self._updates = {} for kind in kinds: self._updates[kind] = fun_wrapper("update_%d" % kind, kind) def _update_blas(x, P, kind, z, R, extra_args=[]): # pylint: disable=dangerous-default-value return self._updates[kind](x, P, z, R, extra_args) # assign the functions self._predict = _predict_blas # self._predict = self._predict_python self._update = _update_blas # self._update = self._update_python def init_state(self, state, covs, filter_time): self.x = np.array(state.reshape((-1, 1))).astype(np.float64) self.P = np.array(covs).astype(np.float64) self.filter_time = filter_time self.augment_times = [0] * self.N self.rewind_obscache = [] self.rewind_t = [] self.rewind_states = [] def reset_rewind(self): self.rewind_obscache = [] self.rewind_t = [] self.rewind_states = [] def augment(self): # TODO this is not a generalized way of doing this and implies that the augmented states # are simply the first (dim_augment_state) elements of the main state. assert self.msckf d1 = self.dim_main d2 = self.dim_main_err d3 = self.dim_augment d4 = self.dim_augment_err # push through augmented states self.x[d1:-d3] = self.x[d1 + d3:] self.x[-d3:] = self.x[:d3] assert self.x.shape == (self.dim_x, 1) # push through augmented covs assert self.P.shape == (self.dim_err, self.dim_err) P_reduced = self.P P_reduced = np.delete(P_reduced, np.s_[d2:d2 + d4], axis=1) P_reduced = np.delete(P_reduced, np.s_[d2:d2 + d4], axis=0) assert P_reduced.shape == (self.dim_err - d4, self.dim_err - d4) to_mult = np.zeros((self.dim_err, self.dim_err - d4)) to_mult[:-d4, :] = np.eye(self.dim_err - d4) to_mult[-d4:, :d4] = np.eye(d4) self.P = to_mult.dot(P_reduced.dot(to_mult.T)) self.augment_times = self.augment_times[1:] self.augment_times.append(self.filter_time) assert self.P.shape == (self.dim_err, self.dim_err) def state(self): return np.array(self.x).flatten() def covs(self): return self.P def set_filter_time(self, t): self.filter_time = t def get_filter_time(self): return self.filter_time def normalize_quaternions(self): for idx in self.quaternion_idxs: self.normalize_slice(idx, idx+4) def normalize_slice(self, slice_start, slice_end_ex): self.x[slice_start:slice_end_ex] /= np.linalg.norm(self.x[slice_start:slice_end_ex]) def get_augment_times(self): return self.augment_times def set_global(self, global_var, val): self.set_globals[global_var](val) def rewind(self, t): # find where we are rewinding to idx = bisect_right(self.rewind_t, t) assert self.rewind_t[idx - 1] <= t assert self.rewind_t[idx] > t # must be true, or rewind wouldn't be called # set the state to the time right before that self.filter_time = self.rewind_t[idx - 1] self.x[:] = self.rewind_states[idx - 1][0] self.P[:] = self.rewind_states[idx - 1][1] # return the observations we rewound over for fast forwarding ret = self.rewind_obscache[idx:] # throw away the old future # TODO: is this making a copy? self.rewind_t = self.rewind_t[:idx] self.rewind_states = self.rewind_states[:idx] self.rewind_obscache = self.rewind_obscache[:idx] return ret def checkpoint(self, obs): # push to rewinder self.rewind_t.append(self.filter_time) self.rewind_states.append((np.copy(self.x), np.copy(self.P))) self.rewind_obscache.append(obs) # only keep a certain number around REWIND_TO_KEEP = 512 self.rewind_t = self.rewind_t[-REWIND_TO_KEEP:] self.rewind_states = self.rewind_states[-REWIND_TO_KEEP:] self.rewind_obscache = self.rewind_obscache[-REWIND_TO_KEEP:] def predict(self, t): # initialize time if self.filter_time is None: self.filter_time = t # predict dt = t - self.filter_time assert dt >= 0 self.x, self.P = self._predict(self.x, self.P, dt) self.normalize_quaternions() self.filter_time = t def predict_and_update_batch(self, t, kind, z, R, extra_args=[[]], augment=False): # pylint: disable=dangerous-default-value # TODO handle rewinding at this level" # rewind if self.filter_time is not None and t < self.filter_time: if len(self.rewind_t) == 0 or t < self.rewind_t[0] or t < self.rewind_t[-1] - self.max_rewind_age: self.logger.error("observation too old at %.3f with filter at %.3f, ignoring" % (t, self.filter_time)) return None rewound = self.rewind(t) else: rewound = [] ret = self._predict_and_update_batch(t, kind, z, R, extra_args, augment) # optional fast forward for r in rewound: self._predict_and_update_batch(*r) return ret def _predict_and_update_batch(self, t, kind, z, R, extra_args, augment=False): """The main kalman filter function Predicts the state and then updates a batch of observations dim_x: dimensionality of the state space dim_z: dimensionality of the observation and depends on kind n: number of observations Args: t (float): Time of observation kind (int): Type of observation z (vec [n,dim_z]): Measurements R (mat [n,dim_z, dim_z]): Measurement Noise extra_args (list, [n]): Values used in H computations """ assert z.shape[0] == R.shape[0] assert z.shape[1] == R.shape[1] assert z.shape[1] == R.shape[2] # initialize time if self.filter_time is None: self.filter_time = t # predict dt = t - self.filter_time assert dt >= 0 self.x, self.P = self._predict(self.x, self.P, dt) self.filter_time = t xk_km1, Pk_km1 = np.copy(self.x).flatten(), np.copy(self.P) # update batch y = [] for i in range(len(z)): # these are from the user, so we canonicalize them z_i = np.array(z[i], dtype=np.float64, order='F') R_i = np.array(R[i], dtype=np.float64, order='F') extra_args_i = np.array(extra_args[i], dtype=np.float64, order='F') # update self.x, self.P, y_i = self._update(self.x, self.P, kind, z_i, R_i, extra_args=extra_args_i) self.normalize_quaternions() y.append(y_i) xk_k, Pk_k = np.copy(self.x).flatten(), np.copy(self.P) if augment: self.augment() # checkpoint self.checkpoint((t, kind, z, R, extra_args)) return xk_km1, xk_k, Pk_km1, Pk_k, t, kind, y, z, extra_args def _predict_python(self, x, P, dt): x_new = np.zeros(x.shape, dtype=np.float64) self.f(x, dt, x_new) F = np.zeros(P.shape, dtype=np.float64) self.F(x, dt, F) if not self.msckf: P = dot(dot(F, P), F.T) else: # Update the predicted state covariance: # Pk+1|k = |F*Pii*FT + Q*dt F*Pij | # |PijT*FT Pjj | # Where F is the jacobian of the main state # predict function, Pii is the main state's # covariance and Q its process noise. Pij # is the covariance between the augmented # states and the main state. # d2 = self.dim_main_err # known at compile time F_curr = F[:d2, :d2] P[:d2, :d2] = (F_curr.dot(P[:d2, :d2])).dot(F_curr.T) P[:d2, d2:] = F_curr.dot(P[:d2, d2:]) P[d2:, :d2] = P[d2:, :d2].dot(F_curr.T) P += dt * self.Q return x_new, P def _update_python(self, x, P, kind, z, R, extra_args=[]): # pylint: disable=dangerous-default-value # init vars z = z.reshape((-1, 1)) h = np.zeros(z.shape, dtype=np.float64) H = np.zeros((z.shape[0], self.dim_x), dtype=np.float64) # C functions self.hs[kind](x, extra_args, h) self.Hs[kind](x, extra_args, H) # y is the "loss" y = z - h # *** same above this line *** if self.msckf and kind in self.Hes: # Do some algebraic magic to decorrelate He = np.zeros((z.shape[0], len(extra_args)), dtype=np.float64) self.Hes[kind](x, extra_args, He) # TODO: Don't call a function here, do projection locally A = null(He.T) y = A.T.dot(y) H = A.T.dot(H) R = A.T.dot(R.dot(A)) # TODO If nullspace isn't the dimension we want if A.shape[1] + He.shape[1] != A.shape[0]: self.logger.warning('Warning: null space projection failed, measurement ignored') return x, P, np.zeros(A.shape[0] - He.shape[1]) # if using eskf H_mod = np.zeros((x.shape[0], P.shape[0]), dtype=np.float64) self.H_mod(x, H_mod) H = H.dot(H_mod) # Do mahalobis distance test # currently just runs on msckf observations # could run on anything if needed if self.msckf and kind in self.maha_test_kinds: a = np.linalg.inv(H.dot(P).dot(H.T) + R) maha_dist = y.T.dot(a.dot(y)) if maha_dist > chi2_ppf(0.95, y.shape[0]): R = 10e16 * R # *** same below this line *** # Outlier resilient weighting as described in: # "A Kalman Filter for Robust Outlier Detection - Jo-Anne Ting, ..." weight = 1 # (1.5)/(1 + np.sum(y**2)/np.sum(R)) S = dot(dot(H, P), H.T) + R / weight K = solve(S, dot(H, P.T)).T I_KH = np.eye(P.shape[0]) - dot(K, H) # update actual state delta_x = dot(K, y) P = dot(dot(I_KH, P), I_KH.T) + dot(dot(K, R), K.T) # inject observed error into state x_new = np.zeros(x.shape, dtype=np.float64) self.err_function(x, delta_x, x_new) return x_new, P, y.flatten() def maha_test(self, x, P, kind, z, R, extra_args=[], maha_thresh=0.95): # pylint: disable=dangerous-default-value # init vars z = z.reshape((-1, 1)) h = np.zeros(z.shape, dtype=np.float64) H = np.zeros((z.shape[0], self.dim_x), dtype=np.float64) # C functions self.hs[kind](x, extra_args, h) self.Hs[kind](x, extra_args, H) # y is the "loss" y = z - h # if using eskf H_mod = np.zeros((x.shape[0], P.shape[0]), dtype=np.float64) self.H_mod(x, H_mod) H = H.dot(H_mod) a = np.linalg.inv(H.dot(P).dot(H.T) + R) maha_dist = y.T.dot(a.dot(y)) if maha_dist > chi2_ppf(maha_thresh, y.shape[0]): return False else: return True def rts_smooth(self, estimates, norm_quats=False): ''' Returns rts smoothed results of kalman filter estimates If the kalman state is augmented with old states only the main state is smoothed ''' xk_n = estimates[-1][0] Pk_n = estimates[-1][2] Fk_1 = np.zeros(Pk_n.shape, dtype=np.float64) states_smoothed = [xk_n] covs_smoothed = [Pk_n] for k in range(len(estimates) - 2, -1, -1): xk1_n = xk_n if norm_quats: xk1_n[3:7] /= np.linalg.norm(xk1_n[3:7]) Pk1_n = Pk_n xk1_k, _, Pk1_k, _, t2, _, _, _, _ = estimates[k + 1] _, xk_k, _, Pk_k, t1, _, _, _, _ = estimates[k] dt = t2 - t1 self.F(xk_k, dt, Fk_1) d1 = self.dim_main d2 = self.dim_main_err Ck = np.linalg.solve(Pk1_k[:d2, :d2], Fk_1[:d2, :d2].dot(Pk_k[:d2, :d2].T)).T xk_n = xk_k delta_x = np.zeros((Pk_n.shape[0], 1), dtype=np.float64) self.inv_err_function(xk1_k, xk1_n, delta_x) delta_x[:d2] = Ck.dot(delta_x[:d2]) x_new = np.zeros((xk_n.shape[0], 1), dtype=np.float64) self.err_function(xk_k, delta_x, x_new) xk_n[:d1] = x_new[:d1, 0] Pk_n = Pk_k Pk_n[:d2, :d2] = Pk_k[:d2, :d2] + Ck.dot(Pk1_n[:d2, :d2] - Pk1_k[:d2, :d2]).dot(Ck.T) states_smoothed.append(xk_n) covs_smoothed.append(Pk_n) return np.flipud(np.vstack(states_smoothed)), np.stack(covs_smoothed, 0)[::-1] ================================================ FILE: rednose/helpers/ekf_sym_pyx.pyx ================================================ # cython: language_level=3 # cython: profile=True # distutils: language = c++ cimport cython from libcpp.string cimport string from libcpp.vector cimport vector from libcpp cimport bool cimport numpy as np import numpy as np cdef extern from "" namespace "std" nogil: cdef cppclass optional[T]: ctypedef T value_type bool has_value() T& value() cdef extern from "rednose/helpers/ekf_sym.h" namespace "EKFS": cdef cppclass MapVectorXd "Eigen::Map": MapVectorXd(double*, int) cdef cppclass MapMatrixXdr "Eigen::Map >": MapMatrixXdr(double*, int, int) cdef cppclass VectorXd "Eigen::VectorXd": VectorXd() double* data() int rows() cdef cppclass MatrixXdr "Eigen::Matrix": MatrixXdr() double* data() int rows() int cols() ctypedef struct Estimate: VectorXd xk1 VectorXd xk MatrixXdr Pk1 MatrixXdr Pk double t int kind vector[VectorXd] y vector[VectorXd] z vector[vector[double]] extra_args cdef cppclass EKFSym: EKFSym(string name, MapMatrixXdr Q, MapVectorXd x_initial, MapMatrixXdr P_initial, int dim_main, int dim_main_err, int N, int dim_augment, int dim_augment_err, vector[int] maha_test_kinds, vector[int] quaternion_idxs, vector[string] global_vars, double max_rewind_age) void init_state(MapVectorXd state, MapMatrixXdr covs, double filter_time) VectorXd state() MatrixXdr covs() void set_filter_time(double t) double get_filter_time() void set_global(string name, double val) void reset_rewind() void predict(double t) optional[Estimate] predict_and_update_batch(double t, int kind, vector[MapVectorXd] z, vector[MapMatrixXdr] z, vector[vector[double]] extra_args, bool augment) # Functions like `numpy_to_matrix` are not possible, cython requires default # constructor for return variable types which aren't available with Eigen::Map @cython.wraparound(False) @cython.boundscheck(False) cdef np.ndarray[np.float64_t, ndim=2, mode="c"] matrix_to_numpy(MatrixXdr arr): cdef double[:,:] mem_view = arr.data() return np.copy(np.asarray(mem_view, dtype=np.double, order="C")) @cython.wraparound(False) @cython.boundscheck(False) cdef np.ndarray[np.float64_t, ndim=1, mode="c"] vector_to_numpy(VectorXd arr): cdef double[:] mem_view = arr.data() return np.copy(np.asarray(mem_view, dtype=np.double, order="C")) cdef class EKF_sym: cdef EKFSym* ekf def __cinit__(self, str gen_dir, str name, np.ndarray[np.float64_t, ndim=2] Q, np.ndarray[np.float64_t, ndim=1] x_initial, np.ndarray[np.float64_t, ndim=2] P_initial, int dim_main, int dim_main_err, int N=0, int dim_augment=0, int dim_augment_err=0, list maha_test_kinds=[], list quaternion_idxs=[], list global_vars=[], double max_rewind_age=1.0, logger=None): # TODO logger cdef np.ndarray[np.float64_t, ndim=2, mode='c'] Q_b = np.ascontiguousarray(Q, dtype=np.double) cdef np.ndarray[np.float64_t, ndim=1, mode='c'] x_initial_b = np.ascontiguousarray(x_initial, dtype=np.double) cdef np.ndarray[np.float64_t, ndim=2, mode='c'] P_initial_b = np.ascontiguousarray(P_initial, dtype=np.double) self.ekf = new EKFSym( name.encode('utf8'), MapMatrixXdr( Q_b.data, Q.shape[0], Q.shape[1]), MapVectorXd( x_initial_b.data, x_initial.shape[0]), MapMatrixXdr( P_initial_b.data, P_initial.shape[0], P_initial.shape[1]), dim_main, dim_main_err, N, dim_augment, dim_augment_err, maha_test_kinds, quaternion_idxs, [x.encode('utf8') for x in global_vars], max_rewind_age ) def init_state(self, np.ndarray[np.float64_t, ndim=1] state, np.ndarray[np.float64_t, ndim=2] covs, filter_time): cdef np.ndarray[np.float64_t, ndim=1, mode='c'] state_b = np.ascontiguousarray(state, dtype=np.double) cdef np.ndarray[np.float64_t, ndim=2, mode='c'] covs_b = np.ascontiguousarray(covs, dtype=np.double) self.ekf.init_state( MapVectorXd( state_b.data, state.shape[0]), MapMatrixXdr( covs_b.data, covs.shape[0], covs.shape[1]), np.nan if filter_time is None else filter_time ) def state(self): cdef np.ndarray res = vector_to_numpy(self.ekf.state()) return res def covs(self): return matrix_to_numpy(self.ekf.covs()) def set_filter_time(self, double t): self.ekf.set_filter_time(t) def get_filter_time(self): return self.ekf.get_filter_time() def set_global(self, str global_var, double val): self.ekf.set_global(global_var.encode('utf8'), val) def reset_rewind(self): self.ekf.reset_rewind() def predict(self, double t): self.ekf.predict(t) def predict_and_update_batch(self, double t, int kind, z, R, extra_args=[[]], bool augment=False): cdef vector[MapVectorXd] z_map cdef np.ndarray[np.float64_t, ndim=1, mode='c'] zi_b for zi in z: zi_b = np.ascontiguousarray(zi, dtype=np.double) z_map.push_back(MapVectorXd( zi_b.data, zi.shape[0])) cdef vector[MapMatrixXdr] R_map cdef np.ndarray[np.float64_t, ndim=2, mode='c'] Ri_b for Ri in R: Ri_b = np.ascontiguousarray(Ri, dtype=np.double) R_map.push_back(MapMatrixXdr( Ri_b.data, Ri.shape[0], Ri.shape[1])) cdef vector[vector[double]] extra_args_map cdef vector[double] args_map for args in extra_args: args_map.clear() for a in args: args_map.push_back(a) extra_args_map.push_back(args_map) cdef optional[Estimate] res = self.ekf.predict_and_update_batch(t, kind, z_map, R_map, extra_args_map, augment) if not res.has_value(): return None cdef VectorXd tmpvec return ( vector_to_numpy(res.value().xk1), vector_to_numpy(res.value().xk), matrix_to_numpy(res.value().Pk1), matrix_to_numpy(res.value().Pk), res.value().t, res.value().kind, [vector_to_numpy(tmpvec) for tmpvec in res.value().y], z, # TODO: take return values? extra_args, ) def augment(self): raise NotImplementedError() # TODO def get_augment_times(self): raise NotImplementedError() # TODO def rts_smooth(self, estimates, norm_quats=False): raise NotImplementedError() # TODO def maha_test(self, x, P, kind, z, R, extra_args=[], maha_thresh=0.95): raise NotImplementedError() # TODO def __dealloc__(self): del self.ekf ================================================ FILE: rednose/helpers/feature_handler.py ================================================ #!/usr/bin/env python3 import os import sys import numpy as np from rednose.helpers import TEMPLATE_DIR, load_code, write_code from rednose.helpers.sympy_helpers import quat_matrix_l, rot_matrix def sane(track): img_pos = track[1:, 2:4] diffs_x = abs(img_pos[1:, 0] - img_pos[:-1, 0]) diffs_y = abs(img_pos[1:, 1] - img_pos[:-1, 1]) for i in range(1, len(diffs_x)): if ((diffs_x[i] > 0.05 or diffs_x[i - 1] > 0.05) and (diffs_x[i] > 2 * diffs_x[i - 1] or diffs_x[i] < .5 * diffs_x[i - 1])) or \ ((diffs_y[i] > 0.05 or diffs_y[i - 1] > 0.05) and (diffs_y[i] > 2 * diffs_y[i - 1] or diffs_y[i] < .5 * diffs_y[i - 1])): return False return True class FeatureHandler(): name = 'feature_handler' @staticmethod def generate_code(generated_dir, K=5): # Wrap c code for slow matching c_header = "\nvoid merge_features(double *tracks, double *features, long long *empty_idxs);" c_code = "#include \n" c_code += "#include \n" c_code += "#define K %d\n" % K c_code += "extern \"C\" {\n" c_code += "\n" + open(os.path.join(TEMPLATE_DIR, "feature_handler.c")).read() c_code += "\n}\n" filename = f"{FeatureHandler.name}_{K}" write_code(generated_dir, filename, c_code, c_header) def __init__(self, generated_dir, K=5): self.MAX_TRACKS = 6000 self.K = K # Array of tracks, each track has K 5D features preceded # by 5 params that inidicate [f_idx, last_idx, updated, complete, valid] # f_idx: idx of current last feature in track # idx of of last feature in frame # bool for whether this track has been update # bool for whether this track is complete # bool for whether this track is valid self.tracks = np.zeros((self.MAX_TRACKS, K + 1, 5)) self.tracks[:] = np.nan name = f"{FeatureHandler.name}_{K}" ffi, lib = load_code(generated_dir, name) def merge_features_c(tracks, features, empty_idxs): lib.merge_features(ffi.cast("double *", tracks.ctypes.data), ffi.cast("double *", features.ctypes.data), ffi.cast("long long *", empty_idxs.ctypes.data)) # self.merge_features = self.merge_features_python self.merge_features = merge_features_c def reset(self): self.tracks[:] = np.nan def merge_features_python(self, tracks, features, empty_idxs): empty_idx = 0 for f in features: match_idx = int(f[4]) if tracks[match_idx, 0, 1] == match_idx and tracks[match_idx, 0, 2] == 0: tracks[match_idx, 0, 0] += 1 tracks[match_idx, 0, 1] = f[1] tracks[match_idx, 0, 2] = 1 tracks[match_idx, int(tracks[match_idx, 0, 0])] = f if tracks[match_idx, 0, 0] == self.K: tracks[match_idx, 0, 3] = 1 if sane(tracks[match_idx]): tracks[match_idx, 0, 4] = 1 else: if empty_idx == len(empty_idxs): print('need more empty space') continue tracks[empty_idxs[empty_idx], 0, 0] = 1 tracks[empty_idxs[empty_idx], 0, 1] = f[1] tracks[empty_idxs[empty_idx], 0, 2] = 1 tracks[empty_idxs[empty_idx], 1] = f empty_idx += 1 def update_tracks(self, features): last_idxs = np.copy(self.tracks[:, 0, 1]) real = np.isfinite(last_idxs) self.tracks[last_idxs[real].astype(int)] = self.tracks[real] mask = np.ones(self.MAX_TRACKS, np.bool) mask[last_idxs[real].astype(int)] = 0 empty_idxs = np.arange(self.MAX_TRACKS)[mask] self.tracks[empty_idxs] = np.nan self.tracks[:, 0, 2] = 0 self.merge_features(self.tracks, features, empty_idxs) def handle_features(self, features): self.update_tracks(features) valid_idxs = self.tracks[:, 0, 4] == 1 complete_idxs = self.tracks[:, 0, 3] == 1 stale_idxs = self.tracks[:, 0, 2] == 0 valid_tracks = self.tracks[valid_idxs] self.tracks[complete_idxs] = np.nan self.tracks[stale_idxs] = np.nan return valid_tracks[:, 1:, :4].reshape((len(valid_tracks), self.K * 4)) def generate_orient_error_jac(K): import sympy as sp from rednose.helpers.sympy_helpers import quat_rotate x_sym = sp.MatrixSymbol('abr', 3, 1) dtheta = sp.MatrixSymbol('dtheta', 3, 1) delta_quat = sp.Matrix(np.ones(4)) delta_quat[1:, :] = sp.Matrix(0.5 * dtheta[0:3, :]) poses_sym = sp.MatrixSymbol('poses', 7 * K, 1) img_pos_sym = sp.MatrixSymbol('img_positions', 2 * K, 1) alpha, beta, rho = x_sym to_c = sp.Matrix(rot_matrix(-np.pi / 2, -np.pi / 2, 0)) pos_0 = sp.Matrix(np.array(poses_sym[K * 7 - 7:K * 7 - 4])[:, 0]) q = quat_matrix_l(poses_sym[K * 7 - 4:K * 7]) * delta_quat quat_rot = quat_rotate(*q) rot_g_to_0 = to_c * quat_rot.T rows = [] for i in range(K): pos_i = sp.Matrix(np.array(poses_sym[i * 7:i * 7 + 3])[:, 0]) q = quat_matrix_l(poses_sym[7 * i + 3:7 * i + 7]) * delta_quat quat_rot = quat_rotate(*q) rot_g_to_i = to_c * quat_rot.T rot_0_to_i = rot_g_to_i * (rot_g_to_0.T) trans_0_to_i = rot_g_to_i * (pos_0 - pos_i) funct_vec = rot_0_to_i * sp.Matrix([alpha, beta, 1]) + rho * trans_0_to_i h1, h2, h3 = funct_vec rows.append(h1 / h3 - img_pos_sym[i * 2 + 0]) rows.append(h2 / h3 - img_pos_sym[i * 2 + 1]) img_pos_residual_sym = sp.Matrix(rows) # sympy into c sympy_functions = [] sympy_functions.append(('orient_error_jac', img_pos_residual_sym.jacobian(dtheta), [x_sym, poses_sym, img_pos_sym, dtheta])) return sympy_functions if __name__ == "__main__": K = int(sys.argv[1].split("_")[-1]) generated_dir = sys.argv[2] FeatureHandler.generate_code(generated_dir, K=K) ================================================ FILE: rednose/helpers/kalmanfilter.py ================================================ from typing import Any, Dict import numpy as np class KalmanFilter: name = "" initial_x = np.zeros((0, 0)) initial_P_diag = np.zeros((0, 0)) Q = np.zeros((0, 0)) obs_noise: Dict[int, Any] = {} filter = None # Should be initialized when initializating a KalmanFilter implementation @property def x(self): return self.filter.state() @property def t(self): return self.filter.get_filter_time() @property def P(self): return self.filter.covs() def init_state(self, state, covs_diag=None, covs=None, filter_time=None): if covs_diag is not None: P = np.diag(covs_diag) elif covs is not None: P = covs else: P = self.filter.covs() self.filter.init_state(state, P, filter_time) def get_R(self, kind, n): obs_noise = self.obs_noise[kind] dim = obs_noise.shape[0] R = np.zeros((n, dim, dim)) for i in range(n): R[i, :, :] = obs_noise return R def predict_and_observe(self, t, kind, data, R=None): if len(data) > 0: data = np.atleast_2d(data) if R is None: R = self.get_R(kind, len(data)) self.filter.predict_and_update_batch(t, kind, data, R) ================================================ FILE: rednose/helpers/lst_sq_computer.py ================================================ #!/usr/bin/env python3 import os import sys import numpy as np import sympy as sp from rednose.helpers import TEMPLATE_DIR, load_code, write_code from rednose.helpers.sympy_helpers import quat_rotate, sympy_into_c, rot_matrix, rotations_from_quats def generate_residual(K): x_sym = sp.MatrixSymbol('abr', 3, 1) poses_sym = sp.MatrixSymbol('poses', 7 * K, 1) img_pos_sym = sp.MatrixSymbol('img_positions', 2 * K, 1) alpha, beta, rho = x_sym to_c = sp.Matrix(rot_matrix(-np.pi / 2, -np.pi / 2, 0)) pos_0 = sp.Matrix(np.array(poses_sym[K * 7 - 7:K * 7 - 4])[:, 0]) q = poses_sym[K * 7 - 4:K * 7] quat_rot = quat_rotate(*q) rot_g_to_0 = to_c * quat_rot.T rows = [] for i in range(K): pos_i = sp.Matrix(np.array(poses_sym[i * 7:i * 7 + 3])[:, 0]) q = poses_sym[7 * i + 3:7 * i + 7] quat_rot = quat_rotate(*q) rot_g_to_i = to_c * quat_rot.T rot_0_to_i = rot_g_to_i * rot_g_to_0.T trans_0_to_i = rot_g_to_i * (pos_0 - pos_i) funct_vec = rot_0_to_i * sp.Matrix([alpha, beta, 1]) + rho * trans_0_to_i h1, h2, h3 = funct_vec rows.append(h1 / h3 - img_pos_sym[i * 2 + 0]) rows.append(h2 / h3 - img_pos_sym[i * 2 + 1]) img_pos_residual_sym = sp.Matrix(rows) # sympy into c sympy_functions = [] sympy_functions.append(('res_fun', img_pos_residual_sym, [x_sym, poses_sym, img_pos_sym])) sympy_functions.append(('jac_fun', img_pos_residual_sym.jacobian(x_sym), [x_sym, poses_sym, img_pos_sym])) return sympy_functions class LstSqComputer(): name = 'pos_computer' @staticmethod def generate_code(generated_dir, K=4): sympy_functions = generate_residual(K) header, sympy_code = sympy_into_c(sympy_functions) code = "\n#include \"rednose/helpers/common_ekf.h\"\n" code += "\n#define KDIM %d\n" % K code += "extern \"C\" {\n" code += sympy_code code += "\n" + open(os.path.join(TEMPLATE_DIR, "compute_pos.c")).read() + "\n" code += "}\n" header += "\nvoid compute_pos(double *to_c, double *in_poses, double *in_img_positions, double *param, double *pos);\n" filename = f"{LstSqComputer.name}_{K}" write_code(generated_dir, filename, code, header) def __init__(self, generated_dir, K=4, MIN_DEPTH=2, MAX_DEPTH=500): self.to_c = rot_matrix(-np.pi / 2, -np.pi / 2, 0) self.MAX_DEPTH = MAX_DEPTH self.MIN_DEPTH = MIN_DEPTH name = f"{LstSqComputer.name}_{K}" ffi, lib = load_code(generated_dir, name) # wrap c functions def residual_jac(x, poses, img_positions): out = np.zeros(((K * 2, 3)), dtype=np.float64) lib.jac_fun(ffi.cast("double *", x.ctypes.data), ffi.cast("double *", poses.ctypes.data), ffi.cast("double *", img_positions.ctypes.data), ffi.cast("double *", out.ctypes.data)) return out self.residual_jac = residual_jac def residual(x, poses, img_positions): out = np.zeros((K * 2), dtype=np.float64) lib.res_fun(ffi.cast("double *", x.ctypes.data), ffi.cast("double *", poses.ctypes.data), ffi.cast("double *", img_positions.ctypes.data), ffi.cast("double *", out.ctypes.data)) return out self.residual = residual def compute_pos_c(poses, img_positions): pos = np.zeros(3, dtype=np.float64) param = np.zeros(3, dtype=np.float64) # Can't be a view for the ctype img_positions = np.copy(img_positions) lib.compute_pos(ffi.cast("double *", self.to_c.ctypes.data), ffi.cast("double *", poses.ctypes.data), ffi.cast("double *", img_positions.ctypes.data), ffi.cast("double *", param.ctypes.data), ffi.cast("double *", pos.ctypes.data)) return pos, param self.compute_pos_c = compute_pos_c def compute_pos(self, poses, img_positions, debug=False): pos, param = self.compute_pos_c(poses, img_positions) # pos, param = self.compute_pos_python(poses, img_positions) depth = 1 / param[2] if debug: # orient_err_jac = self.orient_error_jac(param, poses, img_positions, np.zeros(3)).reshape((-1,2,3)) jac = self.residual_jac(param, poses, img_positions).reshape((-1, 2, 3)) res = self.residual(param, poses, img_positions).reshape((-1, 2)) return pos, param, res, jac # , orient_err_jac elif (self.MIN_DEPTH < depth < self.MAX_DEPTH): return pos else: return None def gauss_newton(self, fun, jac, x, args): poses, img_positions = args delta = 1 counter = 0 while abs(np.linalg.norm(delta)) > 1e-4 and counter < 30: delta = np.linalg.pinv(jac(x, poses, img_positions)).dot(fun(x, poses, img_positions)) x = x - delta counter += 1 return [x] def compute_pos_python(self, poses, img_positions, check_quality=False): import scipy.optimize as opt # This procedure is also described # in the MSCKF paper (Mourikis et al. 2007) x = np.array([img_positions[-1][0], img_positions[-1][1], 0.1]) res = opt.leastsq(self.residual, x, Dfun=self.residual_jac, args=(poses, img_positions)) # scipy opt # res = self.gauss_newton(self.residual, self.residual_jac, x, (poses, img_positions)) # diy gauss_newton alpha, beta, rho = res[0] rot_0_to_g = (rotations_from_quats(poses[-1, 3:])).dot(self.to_c.T) return (rot_0_to_g.dot(np.array([alpha, beta, 1]))) / rho + poses[-1, :3] # EXPERIMENTAL CODE def unroll_shutter(img_positions, poses, v, rot_rates, ecef_pos): # only speed correction for now t_roll = 0.016 # 16ms rolling shutter? vroll, vpitch, vyaw = rot_rates A = 0.5 * np.array([[-1, -vroll, -vpitch, -vyaw], [vroll, 0, vyaw, -vpitch], [vpitch, -vyaw, 0, vroll], [vyaw, vpitch, -vroll, 0]]) q_dot = A.dot(poses[-1][3:7]) v = np.append(v, q_dot) v = np.array([v[0], v[1], v[2], 0, 0, 0, 0]) current_pose = poses[-1] + v * 0.05 poses = np.vstack((current_pose, poses)) dt = -img_positions[:, 1] * t_roll / 0.48 errs = project(poses, ecef_pos) - project(poses + np.atleast_2d(dt).T.dot(np.atleast_2d(v)), ecef_pos) return img_positions - errs def project(poses, ecef_pos): img_positions = np.zeros((len(poses), 2)) for i, p in enumerate(poses): cam_frame = rotations_from_quats(p[3:]).T.dot(ecef_pos - p[:3]) img_positions[i] = np.array([cam_frame[1] / cam_frame[0], cam_frame[2] / cam_frame[0]]) return img_positions if __name__ == "__main__": K = int(sys.argv[1].split("_")[-1]) generated_dir = sys.argv[2] LstSqComputer.generate_code(generated_dir, K=K) ================================================ FILE: rednose/helpers/sympy_helpers.py ================================================ #!/usr/bin/env python3 import sympy as sp import numpy as np # TODO: remove code duplication between openpilot.common.orientation def quat2rot(quats): quats = np.array(quats) input_shape = quats.shape quats = np.atleast_2d(quats) Rs = np.zeros((quats.shape[0], 3, 3)) q0 = quats[:, 0] q1 = quats[:, 1] q2 = quats[:, 2] q3 = quats[:, 3] Rs[:, 0, 0] = q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3 Rs[:, 0, 1] = 2 * (q1 * q2 - q0 * q3) Rs[:, 0, 2] = 2 * (q0 * q2 + q1 * q3) Rs[:, 1, 0] = 2 * (q1 * q2 + q0 * q3) Rs[:, 1, 1] = q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3 Rs[:, 1, 2] = 2 * (q2 * q3 - q0 * q1) Rs[:, 2, 0] = 2 * (q1 * q3 - q0 * q2) Rs[:, 2, 1] = 2 * (q0 * q1 + q2 * q3) Rs[:, 2, 2] = q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3 if len(input_shape) < 2: return Rs[0] else: return Rs def euler2quat(eulers): eulers = np.array(eulers) if len(eulers.shape) > 1: output_shape = (-1,4) else: output_shape = (4,) eulers = np.atleast_2d(eulers) gamma, theta, psi = eulers[:,0], eulers[:,1], eulers[:,2] q0 = np.cos(gamma / 2) * np.cos(theta / 2) * np.cos(psi / 2) + \ np.sin(gamma / 2) * np.sin(theta / 2) * np.sin(psi / 2) q1 = np.sin(gamma / 2) * np.cos(theta / 2) * np.cos(psi / 2) - \ np.cos(gamma / 2) * np.sin(theta / 2) * np.sin(psi / 2) q2 = np.cos(gamma / 2) * np.sin(theta / 2) * np.cos(psi / 2) + \ np.sin(gamma / 2) * np.cos(theta / 2) * np.sin(psi / 2) q3 = np.cos(gamma / 2) * np.cos(theta / 2) * np.sin(psi / 2) - \ np.sin(gamma / 2) * np.sin(theta / 2) * np.cos(psi / 2) quats = np.array([q0, q1, q2, q3]).T for i in range(len(quats)): if quats[i,0] < 0: # pylint: disable=unsubscriptable-object quats[i] = -quats[i] # pylint: disable=unsupported-assignment-operation,unsubscriptable-object return quats.reshape(output_shape) def euler2rot(eulers): return quat2rot(euler2quat(eulers)) rotations_from_quats = quat2rot def cross(x): ret = sp.Matrix(np.zeros((3, 3))) ret[0, 1], ret[0, 2] = -x[2], x[1] ret[1, 0], ret[1, 2] = x[2], -x[0] ret[2, 0], ret[2, 1] = -x[1], x[0] return ret def rot_matrix(roll, pitch, yaw): cr, sr = np.cos(roll), np.sin(roll) cp, sp = np.cos(pitch), np.sin(pitch) cy, sy = np.cos(yaw), np.sin(yaw) rr = np.array([[1,0,0],[0, cr,-sr],[0, sr, cr]]) rp = np.array([[cp,0,sp],[0, 1,0],[-sp, 0, cp]]) ry = np.array([[cy,-sy,0],[sy, cy,0],[0, 0, 1]]) return ry.dot(rp.dot(rr)) def euler_rotate(roll, pitch, yaw): # make symbolic rotation matrix from eulers matrix_roll = sp.Matrix([[1, 0, 0], [0, sp.cos(roll), -sp.sin(roll)], [0, sp.sin(roll), sp.cos(roll)]]) matrix_pitch = sp.Matrix([[sp.cos(pitch), 0, sp.sin(pitch)], [0, 1, 0], [-sp.sin(pitch), 0, sp.cos(pitch)]]) matrix_yaw = sp.Matrix([[sp.cos(yaw), -sp.sin(yaw), 0], [sp.sin(yaw), sp.cos(yaw), 0], [0, 0, 1]]) return matrix_yaw * matrix_pitch * matrix_roll def quat_rotate(q0, q1, q2, q3): # make symbolic rotation matrix from quat return sp.Matrix([[q0**2 + q1**2 - q2**2 - q3**2, 2 * (q1 * q2 + q0 * q3), 2 * (q1 * q3 - q0 * q2)], [2 * (q1 * q2 - q0 * q3), q0**2 - q1**2 + q2**2 - q3**2, 2 * (q2 * q3 + q0 * q1)], [2 * (q1 * q3 + q0 * q2), 2 * (q2 * q3 - q0 * q1), q0**2 - q1**2 - q2**2 + q3**2]]).T def quat_matrix_l(p): return sp.Matrix([[p[0], -p[1], -p[2], -p[3]], [p[1], p[0], -p[3], p[2]], [p[2], p[3], p[0], -p[1]], [p[3], -p[2], p[1], p[0]]]) def quat_matrix_r(p): return sp.Matrix([[p[0], -p[1], -p[2], -p[3]], [p[1], p[0], p[3], -p[2]], [p[2], -p[3], p[0], p[1]], [p[3], p[2], -p[1], p[0]]]) def sympy_into_c(sympy_functions, global_vars=None): from sympy.utilities import codegen routines = [] for name, expr, args in sympy_functions: r = codegen.make_routine(name, expr, language="C99", global_vars=global_vars) # argument ordering input to sympy is broken with function with output arguments nargs = [] # reorder the input arguments for aa in args: if aa is None: nargs.append(codegen.InputArgument(sp.Symbol('unused'), dimensions=[1, 1])) continue found = False for a in r.arguments: if str(aa.name) == str(a.name): nargs.append(a) found = True break if not found: # [1,1] is a hack for Matrices nargs.append(codegen.InputArgument(aa, dimensions=[1, 1])) # add the output arguments for a in r.arguments: if type(a) == codegen.OutputArgument: nargs.append(a) # assert len(r.arguments) == len(args)+1 r.arguments = nargs # add routine to list routines.append(r) [(_, c_code), (_, c_header)] = codegen.get_code_generator('C', 'ekf', 'C99').write(routines, "ekf") c_header = '\n'.join(x for x in c_header.split("\n") if len(x) > 0 and x[0] != '#') c_code = '\n'.join(x for x in c_code.split("\n") if len(x) > 0 and x[0] != '#') return c_header, c_code ================================================ FILE: rednose/templates/compute_pos.c ================================================ #include #include #include typedef Eigen::Matrix R3M; typedef Eigen::Matrix R1M; typedef Eigen::Matrix O1M; typedef Eigen::Matrix M3D; void gauss_newton(double *in_x, double *in_poses, double *in_img_positions) { double res[KDIM*2] = {0}; double jac[KDIM*6] = {0}; O1M x(in_x); O1M delta; int counter = 0; while ((delta.squaredNorm() > 0.0001 and counter < 30) or counter == 0){ res_fun(in_x, in_poses, in_img_positions, res); jac_fun(in_x, in_poses, in_img_positions, jac); R1M E(res); R3M J(jac); delta = (J.transpose()*J).inverse() * J.transpose() * E; x = x - delta; memcpy(in_x, x.data(), 3 * sizeof(double)); counter = counter + 1; } } void compute_pos(double *to_c, double *poses, double *img_positions, double *param, double *pos) { param[0] = img_positions[KDIM*2-2]; param[1] = img_positions[KDIM*2-1]; param[2] = 0.1; gauss_newton(param, poses, img_positions); Eigen::Quaterniond q; q.w() = poses[KDIM*7-4]; q.x() = poses[KDIM*7-3]; q.y() = poses[KDIM*7-2]; q.z() = poses[KDIM*7-1]; M3D RC(to_c); Eigen::Matrix3d R = q.normalized().toRotationMatrix(); Eigen::Matrix3d rot = R * RC.transpose(); pos[0] = param[0]/param[2]; pos[1] = param[1]/param[2]; pos[2] = 1.0/param[2]; O1M ecef_offset(poses + KDIM*7-7); O1M ecef_output(pos); ecef_output = rot*ecef_output + ecef_offset; memcpy(pos, ecef_output.data(), 3 * sizeof(double)); } ================================================ FILE: rednose/templates/ekf_c.c ================================================ #include #include typedef Eigen::Matrix DDM; typedef Eigen::Matrix EEM; typedef Eigen::Matrix DEM; void predict(double *in_x, double *in_P, double *in_Q, double dt) { typedef Eigen::Matrix RRM; double nx[DIM] = {0}; double in_F[EDIM*EDIM] = {0}; // functions from sympy f_fun(in_x, dt, nx); F_fun(in_x, dt, in_F); EEM F(in_F); EEM P(in_P); EEM Q(in_Q); RRM F_main = F.topLeftCorner(MEDIM, MEDIM); P.topLeftCorner(MEDIM, MEDIM) = (F_main * P.topLeftCorner(MEDIM, MEDIM)) * F_main.transpose(); P.topRightCorner(MEDIM, EDIM - MEDIM) = F_main * P.topRightCorner(MEDIM, EDIM - MEDIM); P.bottomLeftCorner(EDIM - MEDIM, MEDIM) = P.bottomLeftCorner(EDIM - MEDIM, MEDIM) * F_main.transpose(); P = P + dt*Q; // copy out state memcpy(in_x, nx, DIM * sizeof(double)); memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double)); } // note: extra_args dim only correct when null space projecting // otherwise 1 template void update(double *in_x, double *in_P, Hfun h_fun, Hfun H_fun, Hfun Hea_fun, double *in_z, double *in_R, double *in_ea, double MAHA_THRESHOLD) { typedef Eigen::Matrix ZZM; typedef Eigen::Matrix ZDM; typedef Eigen::Matrix XEM; //typedef Eigen::Matrix EZM; typedef Eigen::Matrix X1M; typedef Eigen::Matrix XXM; double in_hx[ZDIM] = {0}; double in_H[ZDIM * DIM] = {0}; double in_H_mod[EDIM * DIM] = {0}; double delta_x[EDIM] = {0}; double x_new[DIM] = {0}; // state x, P Eigen::Matrix z(in_z); EEM P(in_P); ZZM pre_R(in_R); // functions from sympy h_fun(in_x, in_ea, in_hx); H_fun(in_x, in_ea, in_H); ZDM pre_H(in_H); // get y (y = z - hx) Eigen::Matrix pre_y(in_hx); pre_y = z - pre_y; X1M y; XXM H; XXM R; if (Hea_fun){ typedef Eigen::Matrix ZAM; double in_Hea[ZDIM * EADIM] = {0}; Hea_fun(in_x, in_ea, in_Hea); ZAM Hea(in_Hea); XXM A = Hea.transpose().fullPivLu().kernel(); y = A.transpose() * pre_y; H = A.transpose() * pre_H; R = A.transpose() * pre_R * A; } else { y = pre_y; H = pre_H; R = pre_R; } // get modified H H_mod_fun(in_x, in_H_mod); DEM H_mod(in_H_mod); XEM H_err = H * H_mod; // Do mahalobis distance test if (MAHA_TEST){ XXM a = (H_err * P * H_err.transpose() + R).inverse(); double maha_dist = y.transpose() * a * y; if (maha_dist > MAHA_THRESHOLD){ R = 1.0e16 * R; } } // Outlier resilient weighting double weight = 1;//(1.5)/(1 + y.squaredNorm()/R.sum()); // kalman gains and I_KH XXM S = ((H_err * P) * H_err.transpose()) + R/weight; XEM KT = S.fullPivLu().solve(H_err * P.transpose()); //EZM K = KT.transpose(); TODO: WHY DOES THIS NOT COMPILE? //EZM K = S.fullPivLu().solve(H_err * P.transpose()).transpose(); //std::cout << "Here is the matrix rot:\n" << K << std::endl; EEM I_KH = Eigen::Matrix::Identity() - (KT.transpose() * H_err); // update state by injecting dx Eigen::Matrix dx(delta_x); dx = (KT.transpose() * y); memcpy(delta_x, dx.data(), EDIM * sizeof(double)); err_fun(in_x, delta_x, x_new); Eigen::Matrix x(x_new); // update cov P = ((I_KH * P) * I_KH.transpose()) + ((KT.transpose() * R) * KT); // copy out state memcpy(in_x, x.data(), DIM * sizeof(double)); memcpy(in_P, P.data(), EDIM * EDIM * sizeof(double)); memcpy(in_z, y.data(), y.rows() * sizeof(double)); } ================================================ FILE: rednose/templates/feature_handler.c ================================================ bool sane(double track [K + 1][5]) { double diffs_x [K-1]; double diffs_y [K-1]; int i; for (i = 0; i < K-1; i++) { diffs_x[i] = fabs(track[i+2][2] - track[i+1][2]); diffs_y[i] = fabs(track[i+2][3] - track[i+1][3]); } for (i = 1; i < K-1; i++) { if (((diffs_x[i] > 0.05 or diffs_x[i-1] > 0.05) and (diffs_x[i] > 2*diffs_x[i-1] or diffs_x[i] < .5*diffs_x[i-1])) or ((diffs_y[i] > 0.05 or diffs_y[i-1] > 0.05) and (diffs_y[i] > 2*diffs_y[i-1] or diffs_y[i] < .5*diffs_y[i-1]))){ return false; } } return true; } void merge_features(double *tracks, double *features, long long *empty_idxs) { double feature_arr [3000][5]; memcpy(feature_arr, features, 3000 * 5 * sizeof(double)); double track_arr [6000][K + 1][5]; memcpy(track_arr, tracks, (K+1) * 6000 * 5 * sizeof(double)); int match; int empty_idx = 0; int idx; for (int i = 0; i < 3000; i++) { match = feature_arr[i][4]; if (track_arr[match][0][1] == match and track_arr[match][0][2] == 0){ track_arr[match][0][0] = track_arr[match][0][0] + 1; track_arr[match][0][1] = feature_arr[i][1]; track_arr[match][0][2] = 1; idx = track_arr[match][0][0]; memcpy(track_arr[match][idx], feature_arr[i], 5 * sizeof(double)); if (idx == K){ // label complete track_arr[match][0][3] = 1; if (sane(track_arr[match])){ // label valid track_arr[match][0][4] = 1; } } } else { // gen new track with this feature track_arr[empty_idxs[empty_idx]][0][0] = 1; track_arr[empty_idxs[empty_idx]][0][1] = feature_arr[i][1]; track_arr[empty_idxs[empty_idx]][0][2] = 1; memcpy(track_arr[empty_idxs[empty_idx]][1], feature_arr[i], 5 * sizeof(double)); empty_idx = empty_idx + 1; } } memcpy(tracks, track_arr, (K+1) * 6000 * 5 * sizeof(double)); } ================================================ FILE: release/build_devel.sh ================================================ #!/usr/bin/bash -e DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" TARGET_DIR=/data/openpilot SOURCE_DIR="$(git rev-parse --show-toplevel)" # set git identity source $DIR/identity.sh echo "[-] Setting up repo T=$SECONDS" if [ ! -d "$TARGET_DIR" ]; then mkdir -p $TARGET_DIR cd $TARGET_DIR git init git remote add origin git@github.com:commaai/openpilot.git fi echo "[-] bringing master-ci and devel in sync T=$SECONDS" cd $TARGET_DIR git prune || true git remote prune origin || true git fetch origin master-ci git fetch origin devel git checkout -f --track origin/master-ci git reset --hard master-ci git checkout master-ci git reset --hard origin/devel git clean -xdf # remove everything except .git echo "[-] erasing old openpilot T=$SECONDS" find . -maxdepth 1 -not -path './.git' -not -name '.' -not -name '..' -exec rm -rf '{}' \; # reset source tree cd $SOURCE_DIR git clean -xdf # do the files copy echo "[-] copying files T=$SECONDS" cd $SOURCE_DIR cp -pR --parents $(cat release/files_common) $TARGET_DIR/ cp -pR --parents $(cat release/files_tici) $TARGET_DIR/ if [ ! -z "$EXTRA_FILES" ]; then cp -pR --parents $EXTRA_FILES $TARGET_DIR/ fi # append source commit hash and build date to version GIT_HASH=$(git --git-dir=$SOURCE_DIR/.git rev-parse --short HEAD) DATETIME=$(date '+%Y-%m-%dT%H:%M:%S') VERSION=$(cat selfdrive/common/version.h | awk -F\" '{print $2}') echo "#define COMMA_VERSION \"$VERSION-$GIT_HASH-$DATETIME\"" > selfdrive/common/version.h # in the directory cd $TARGET_DIR rm -f panda/board/obj/panda.bin.signed echo "[-] committing version $VERSION T=$SECONDS" git add -f . git status git commit -a -m "openpilot v$VERSION release" if [ ! -z "$PUSH" ]; then echo "[-] Pushing to $PUSH T=$SECONDS" git remote set-url origin git@github.com:commaai/openpilot.git git push -f origin master-ci:$PUSH fi echo "[-] done T=$SECONDS" ================================================ FILE: release/build_release2.sh ================================================ #!/usr/bin/env bash set -e export GIT_COMMITTER_NAME="Vehicle Researcher" export GIT_COMMITTER_EMAIL="user@comma.ai" export GIT_AUTHOR_NAME="Vehicle Researcher" export GIT_AUTHOR_EMAIL="user@comma.ai" export GIT_SSH_COMMAND="ssh -i /data/gitkey" # set CLEAN to build outside of CI if [ ! -z "$CLEAN" ]; then # Create folders rm -rf /data/openpilot mkdir -p /data/openpilot cd /data/openpilot # Create git repo git init git remote add origin git@github.com:commaai/openpilot.git git fetch origin devel-staging else cd /data/openpilot git clean -xdf git branch -D release2-staging || true fi git fetch origin release2-staging git fetch origin dashcam-staging # Create release2 with no history if [ ! -z "$CLEAN" ]; then git checkout --orphan release2-staging origin/devel-staging else git checkout --orphan release2-staging fi VERSION=$(cat selfdrive/common/version.h | awk -F[\"-] '{print $2}') echo "#define COMMA_VERSION \"$VERSION-release\"" > selfdrive/common/version.h git commit -m "openpilot v$VERSION" # Build signed panda firmware pushd panda/ CERT=/tmp/pandaextra/certs/release RELEASE=1 scons -u . mv board/obj/panda.bin.signed /tmp/panda.bin.signed popd # Build stuff ln -sfn /data/openpilot /data/pythonpath export PYTHONPATH="/data/openpilot:/data/openpilot/pyextra" scons -j3 # Run tests python selfdrive/manager/test/test_manager.py selfdrive/car/tests/test_car_interfaces.py # Ensure no submodules in release if test "$(git submodule--helper list | wc -l)" -gt "0"; then echo "submodules found:" git submodule--helper list exit 1 fi git submodule status # Cleanup find . -name '*.a' -delete find . -name '*.o' -delete find . -name '*.os' -delete find . -name '*.pyc' -delete find . -name '__pycache__' -delete rm -rf panda/board panda/certs panda/crypto rm -rf .sconsign.dblite Jenkinsfile release/ rm models/supercombo.dlc # Move back signed panda fw mkdir -p panda/board/obj mv /tmp/panda.bin.signed panda/board/obj/panda.bin.signed # Restore phonelibs git checkout phonelibs/ # Mark as prebuilt release touch prebuilt # Add built files to git git add -f . git commit --amend -m "openpilot v$VERSION" # Print committed files that are normally gitignored #git status --ignored if [ ! -z "$PUSH" ]; then git remote set-url origin git@github.com:commaai/openpilot.git # Push to release2-staging git push -f origin release2-staging # Create dashcam release git rm selfdrive/car/*/carcontroller.py git commit -m "create dashcam release from release2" git push -f origin release2-staging:dashcam-staging fi ================================================ FILE: release/build_release3.sh ================================================ #!/usr/bin/bash -e # git diff --name-status origin/release3-staging | grep "^A" | less DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" cd $DIR BUILD_DIR=/data/openpilot SOURCE_DIR="$(git rev-parse --show-toplevel)" BRANCH=release3-staging # set git identity source $DIR/identity.sh echo "[-] Setting up repo T=$SECONDS" rm -rf $BUILD_DIR mkdir -p $BUILD_DIR cd $BUILD_DIR git init git remote add origin git@github.com:commaai/openpilot.git git checkout -f -B $BRANCH # do the files copy echo "[-] copying files T=$SECONDS" cd $SOURCE_DIR cp -pR --parents $(cat release/files_common) $BUILD_DIR/ cp -pR --parents $(cat release/files_tici) $BUILD_DIR/ # in the directory cd $BUILD_DIR rm -f panda/board/obj/panda.bin.signed VERSION=$(cat selfdrive/common/version.h | awk -F[\"-] '{print $2}') echo "#define COMMA_VERSION \"$VERSION-release\"" > selfdrive/common/version.h echo "[-] committing version $VERSION T=$SECONDS" git add -f . git commit -a -m "openpilot v$VERSION release" # Build panda firmware pushd panda/ CERT=/data/pandaextra/certs/release RELEASE=1 scons -u . mv board/obj/panda.bin.signed /tmp/panda.bin.signed popd # Build export PYTHONPATH="$BUILD_DIR" scons -j$(nproc) # Run tests #python selfdrive/manager/test/test_manager.py selfdrive/car/tests/test_car_interfaces.py # Cleanup find . -name '*.a' -delete find . -name '*.o' -delete find . -name '*.os' -delete find . -name '*.pyc' -delete find . -name '__pycache__' -delete rm -rf panda/board panda/certs panda/crypto rm -rf .sconsign.dblite Jenkinsfile release/ rm models/supercombo.dlc # Move back signed panda fw mkdir -p panda/board/obj mv /tmp/panda.bin.signed panda/board/obj/panda.bin.signed # Restore phonelibs git checkout phonelibs/ # Mark as prebuilt release touch prebuilt # Add built files to git git add -f . git commit --amend -m "openpilot v$VERSION" if [ ! -z "$PUSH" ]; then echo "[-] pushing T=$SECONDS" git remote set-url origin git@github.com:commaai/openpilot.git git push -f origin $BRANCH # Create dashcam git rm selfdrive/car/*/carcontroller.py git commit -m "create dashcam release from release" git push -f origin $BRANCH:dashcam3-staging fi echo "[-] done T=$SECONDS" ================================================ FILE: release/check-submodules.sh ================================================ #!/bin/bash while read hash submodule ref; do git -C $submodule fetch --depth 100 origin master git -C $submodule branch -r --contains $hash | grep "origin/master" if [ "$?" -eq 0 ]; then echo "$submodule ok" else echo "$submodule: $hash is not on master" exit 1 fi done <<< $(git submodule status --recursive) ================================================ FILE: release/files_common ================================================ .gitignore LICENSE launch_env.sh launch_chffrplus.sh launch_openpilot.sh Jenkinsfile SConstruct CONTRIBUTING.md README.md RELEASES.md SAFETY.md site_scons/site_tools/cython.py common/.gitignore common/__init__.py common/gpio.py common/realtime.py common/clock.pyx common/timeout.py common/ffi_wrapper.py common/file_helpers.py common/logging_extra.py common/numpy_fast.py common/params.py common/params_pxd.pxd common/params_pyx.pyx common/xattr.py common/profiler.py common/basedir.py common/dict_helpers.py common/filter_simple.py common/stat_live.py common/spinner.py common/text_window.py common/cython_hacks.py common/SConscript common/kalman/.gitignore common/kalman/* common/transformations/__init__.py common/transformations/camera.py common/transformations/model.py common/transformations/SConscript common/transformations/coordinates.py common/transformations/coordinates.cc common/transformations/coordinates.hpp common/transformations/orientation.py common/transformations/orientation.cc common/transformations/orientation.hpp common/transformations/transformations.pxd common/transformations/transformations.pyx common/api/__init__.py models/supercombo.dlc models/dmonitoring_model_q.dlc release/* selfdrive/version.py selfdrive/__init__.py selfdrive/config.py selfdrive/crash.py selfdrive/swaglog.py selfdrive/logmessaged.py selfdrive/tombstoned.py selfdrive/pandad.py selfdrive/updated.py selfdrive/rtshield.py selfdrive/athena/__init__.py selfdrive/athena/athenad.py selfdrive/athena/manage_athenad.py selfdrive/athena/registration.py selfdrive/boardd/.gitignore selfdrive/boardd/SConscript selfdrive/boardd/__init__.py selfdrive/boardd/boardd.cc selfdrive/boardd/boardd.py selfdrive/boardd/boardd_api_impl.pyx selfdrive/boardd/can_list_to_can_capnp.cc selfdrive/boardd/panda.cc selfdrive/boardd/panda.h selfdrive/boardd/pigeon.cc selfdrive/boardd/pigeon.h selfdrive/boardd/set_time.py selfdrive/car/__init__.py selfdrive/car/car_helpers.py selfdrive/car/fingerprints.py selfdrive/car/interfaces.py selfdrive/car/vin.py selfdrive/car/fw_versions.py selfdrive/car/isotp_parallel_query.py selfdrive/car/tests/__init__.py selfdrive/car/tests/test_car_interfaces.py selfdrive/car/chrysler/__init__.py selfdrive/car/chrysler/carstate.py selfdrive/car/chrysler/interface.py selfdrive/car/chrysler/radar_interface.py selfdrive/car/chrysler/values.py selfdrive/car/chrysler/carcontroller.py selfdrive/car/chrysler/chryslercan.py selfdrive/car/honda/__init__.py selfdrive/car/honda/carstate.py selfdrive/car/honda/interface.py selfdrive/car/honda/radar_interface.py selfdrive/car/honda/values.py selfdrive/car/honda/carcontroller.py selfdrive/car/honda/hondacan.py selfdrive/car/hyundai/__init__.py selfdrive/car/hyundai/carstate.py selfdrive/car/hyundai/interface.py selfdrive/car/hyundai/radar_interface.py selfdrive/car/hyundai/values.py selfdrive/car/hyundai/carcontroller.py selfdrive/car/hyundai/hyundaican.py selfdrive/car/toyota/__init__.py selfdrive/car/toyota/carstate.py selfdrive/car/toyota/interface.py selfdrive/car/toyota/radar_interface.py selfdrive/car/toyota/values.py selfdrive/car/toyota/carcontroller.py selfdrive/car/toyota/toyotacan.py selfdrive/car/nissan/__init__.py selfdrive/car/nissan/carcontroller.py selfdrive/car/nissan/carstate.py selfdrive/car/nissan/interface.py selfdrive/car/nissan/nissancan.py selfdrive/car/nissan/radar_interface.py selfdrive/car/nissan/values.py selfdrive/car/volkswagen/__init__.py selfdrive/car/volkswagen/carstate.py selfdrive/car/volkswagen/interface.py selfdrive/car/volkswagen/radar_interface.py selfdrive/car/volkswagen/values.py selfdrive/car/volkswagen/carcontroller.py selfdrive/car/volkswagen/volkswagencan.py selfdrive/car/gm/__init__.py selfdrive/car/gm/carstate.py selfdrive/car/gm/interface.py selfdrive/car/gm/radar_interface.py selfdrive/car/gm/values.py selfdrive/car/gm/carcontroller.py selfdrive/car/gm/gmcan.py selfdrive/car/ford/__init__.py selfdrive/car/ford/carstate.py selfdrive/car/ford/interface.py selfdrive/car/ford/radar_interface.py selfdrive/car/ford/values.py selfdrive/car/ford/carcontroller.py selfdrive/car/ford/fordcan.py selfdrive/car/subaru/__init__.py selfdrive/car/subaru/carstate.py selfdrive/car/subaru/interface.py selfdrive/car/subaru/radar_interface.py selfdrive/car/subaru/values.py selfdrive/car/subaru/carcontroller.py selfdrive/car/subaru/subarucan.py selfdrive/car/mazda/__init__.py selfdrive/car/mazda/carstate.py selfdrive/car/mazda/interface.py selfdrive/car/mazda/radar_interface.py selfdrive/car/mazda/values.py selfdrive/car/mazda/carcontroller.py selfdrive/car/mazda/mazdacan.py selfdrive/car/tesla/__init__.py selfdrive/car/tesla/teslacan.py selfdrive/car/tesla/carcontroller.py selfdrive/car/tesla/radar_interface.py selfdrive/car/tesla/values.py selfdrive/car/tesla/carstate.py selfdrive/car/tesla/interface.py selfdrive/car/mock/*.py selfdrive/clocksd/.gitignore selfdrive/clocksd/SConscript selfdrive/clocksd/clocksd.cc selfdrive/debug/*.py selfdrive/common/SConscript selfdrive/common/version.h selfdrive/common/framebuffer.h selfdrive/common/framebuffer.cc selfdrive/common/glutil.cc selfdrive/common/glutil.h selfdrive/common/touch.[c,h] selfdrive/common/swaglog.h selfdrive/common/swaglog.cc selfdrive/common/util.cc selfdrive/common/util.h selfdrive/common/queue.h selfdrive/common/clutil.cc selfdrive/common/clutil.h selfdrive/common/params.h selfdrive/common/params.cc selfdrive/common/watchdog.cc selfdrive/common/watchdog.h selfdrive/common/modeldata.h selfdrive/common/mat.h selfdrive/common/timing.h selfdrive/common/visionimg.cc selfdrive/common/visionimg.h selfdrive/common/gpio.cc selfdrive/common/gpio.h selfdrive/common/i2c.cc selfdrive/common/i2c.h selfdrive/controls/__init__.py selfdrive/controls/controlsd.py selfdrive/controls/plannerd.py selfdrive/controls/radard.py selfdrive/controls/lib/__init__.py selfdrive/controls/lib/alertmanager.py selfdrive/controls/lib/alerts_offroad.json selfdrive/controls/lib/events.py selfdrive/controls/lib/drive_helpers.py selfdrive/controls/lib/latcontrol_pid.py selfdrive/controls/lib/latcontrol_indi.py selfdrive/controls/lib/latcontrol_lqr.py selfdrive/controls/lib/latcontrol_angle.py selfdrive/controls/lib/longcontrol.py selfdrive/controls/lib/lateral_planner.py selfdrive/controls/lib/lane_planner.py selfdrive/controls/lib/pid.py selfdrive/controls/lib/longitudinal_planner.py selfdrive/controls/lib/radar_helpers.py selfdrive/controls/lib/vehicle_model.py selfdrive/controls/lib/fcw.py selfdrive/controls/lib/long_mpc.py selfdrive/controls/lib/lead_mpc.py selfdrive/controls/lib/cluster/* selfdrive/controls/lib/lateral_mpc/lib_mpc_export/* selfdrive/controls/lib/lateral_mpc/.gitignore selfdrive/controls/lib/lateral_mpc/SConscript selfdrive/controls/lib/lateral_mpc/__init__.py selfdrive/controls/lib/lateral_mpc/generator.cpp selfdrive/controls/lib/lateral_mpc/libmpc_py.py selfdrive/controls/lib/lateral_mpc/lateral_mpc.c selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/* selfdrive/controls/lib/lead_mpc_lib/.gitignore selfdrive/controls/lib/lead_mpc_lib/SConscript selfdrive/controls/lib/lead_mpc_lib/__init__.py selfdrive/controls/lib/lead_mpc_lib/generator.cpp selfdrive/controls/lib/lead_mpc_lib/libmpc_py.py selfdrive/controls/lib/lead_mpc_lib/longitudinal_mpc.c selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/* selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore selfdrive/controls/lib/longitudinal_mpc_lib/SConscript selfdrive/controls/lib/longitudinal_mpc_lib/__init__.py selfdrive/controls/lib/longitudinal_mpc_lib/generator.cpp selfdrive/controls/lib/longitudinal_mpc_lib/libmpc_py.py selfdrive/controls/lib/longitudinal_mpc_lib/longitudinal_mpc.c selfdrive/hardware/__init__.py selfdrive/hardware/base.h selfdrive/hardware/base.py selfdrive/hardware/hw.h selfdrive/hardware/eon/__init__.py selfdrive/hardware/eon/hardware.h selfdrive/hardware/eon/hardware.py selfdrive/hardware/eon/androidd.py selfdrive/hardware/tici/__init__.py selfdrive/hardware/tici/hardware.py selfdrive/hardware/tici/amplifier.py selfdrive/hardware/tici/iwlist.py selfdrive/hardware/pc/__init__.py selfdrive/hardware/pc/hardware.py selfdrive/locationd/__init__.py selfdrive/locationd/.gitignore selfdrive/locationd/SConscript selfdrive/locationd/ubloxd.cc selfdrive/locationd/ublox_msg.cc selfdrive/locationd/ublox_msg.h selfdrive/locationd/generated/ubx.cpp selfdrive/locationd/generated/ubx.h selfdrive/locationd/generated/gps.cpp selfdrive/locationd/generated/gps.h selfdrive/locationd/locationd.h selfdrive/locationd/locationd.cc selfdrive/locationd/paramsd.py selfdrive/locationd/models/.gitignore selfdrive/locationd/models/live_kf.py selfdrive/locationd/models/car_kf.py selfdrive/locationd/models/constants.py selfdrive/locationd/models/live_kf.h selfdrive/locationd/models/live_kf.cc selfdrive/locationd/calibrationd.py selfdrive/logcatd/SConscript selfdrive/logcatd/logcatd_android.cc selfdrive/logcatd/logcatd_systemd.cc selfdrive/proclogd/SConscript selfdrive/proclogd/main.cc selfdrive/proclogd/proclog.cc selfdrive/proclogd/proclog.h selfdrive/loggerd/SConscript selfdrive/loggerd/encoder.h selfdrive/loggerd/omx_encoder.cc selfdrive/loggerd/omx_encoder.h selfdrive/loggerd/logger.cc selfdrive/loggerd/logger.h selfdrive/loggerd/loggerd.cc selfdrive/loggerd/bootlog.cc selfdrive/loggerd/raw_logger.cc selfdrive/loggerd/raw_logger.h selfdrive/loggerd/include/msm_media_info.h selfdrive/loggerd/__init__.py selfdrive/loggerd/config.py selfdrive/loggerd/uploader.py selfdrive/loggerd/deleter.py selfdrive/loggerd/xattr_cache.py selfdrive/sensord/SConscript selfdrive/sensord/libdiag.h selfdrive/sensord/sensors_qcom.cc selfdrive/sensord/sensors_qcom2.cc selfdrive/sensord/sensors/*.cc selfdrive/sensord/sensors/*.h selfdrive/sensord/sensord selfdrive/thermald/thermald.py selfdrive/thermald/power_monitoring.py selfdrive/test/__init__.py selfdrive/test/helpers.py selfdrive/test/setup_device_ci.sh selfdrive/test/test_fingerprints.py selfdrive/test/test_onroad.py selfdrive/ui/.gitignore selfdrive/ui/SConscript selfdrive/ui/*.cc selfdrive/ui/*.h selfdrive/ui/ui selfdrive/ui/text selfdrive/ui/spinner selfdrive/ui/soundd selfdrive/ui/qt/*.cc selfdrive/ui/qt/*.h selfdrive/ui/qt/offroad/*.cc selfdrive/ui/qt/offroad/*.h selfdrive/ui/qt/offroad/*.qml selfdrive/ui/qt/widgets/*.cc selfdrive/ui/qt/widgets/*.h selfdrive/ui/qt/spinner_aarch64 selfdrive/ui/qt/text_aarch64 selfdrive/camerad/SConscript selfdrive/camerad/main.cc selfdrive/camerad/snapshot/* selfdrive/camerad/include/* selfdrive/camerad/cameras/camera_common.h selfdrive/camerad/cameras/camera_common.cc selfdrive/camerad/cameras/camera_frame_stream.cc selfdrive/camerad/cameras/camera_frame_stream.h selfdrive/camerad/cameras/camera_qcom.cc selfdrive/camerad/cameras/camera_qcom.h selfdrive/camerad/cameras/debayer.cl selfdrive/camerad/cameras/sensor_i2c.h selfdrive/camerad/cameras/sensor2_i2c.h selfdrive/camerad/transforms/rgb_to_yuv.cc selfdrive/camerad/transforms/rgb_to_yuv.h selfdrive/camerad/transforms/rgb_to_yuv.cl selfdrive/camerad/transforms/rgb_to_yuv_test.cc selfdrive/camerad/imgproc/conv.cl selfdrive/camerad/imgproc/pool.cl selfdrive/camerad/imgproc/utils.cc selfdrive/camerad/imgproc/utils.h selfdrive/manager/__init__.py selfdrive/manager/build.py selfdrive/manager/helpers.py selfdrive/manager/manager.py selfdrive/manager/process_config.py selfdrive/manager/process.py selfdrive/manager/test/__init__.py selfdrive/manager/test/test_manager.py selfdrive/modeld/SConscript selfdrive/modeld/modeld.cc selfdrive/modeld/dmonitoringmodeld.cc selfdrive/modeld/constants.py selfdrive/modeld/modeld selfdrive/modeld/dmonitoringmodeld selfdrive/modeld/models/commonmodel.cc selfdrive/modeld/models/commonmodel.h selfdrive/modeld/models/driving.cc selfdrive/modeld/models/driving.h selfdrive/modeld/models/dmonitoring.cc selfdrive/modeld/models/dmonitoring.h selfdrive/modeld/transforms/loadyuv.cc selfdrive/modeld/transforms/loadyuv.h selfdrive/modeld/transforms/loadyuv.cl selfdrive/modeld/transforms/transform.cc selfdrive/modeld/transforms/transform.h selfdrive/modeld/transforms/transform.cl selfdrive/modeld/thneed/thneed.* selfdrive/modeld/thneed/serialize.cc selfdrive/modeld/thneed/compile.cc selfdrive/modeld/thneed/include/* selfdrive/modeld/runners/snpemodel.cc selfdrive/modeld/runners/snpemodel.h selfdrive/modeld/runners/thneedmodel.cc selfdrive/modeld/runners/thneedmodel.h selfdrive/modeld/runners/runmodel.h selfdrive/modeld/runners/run.h selfdrive/monitoring/dmonitoringd.py selfdrive/monitoring/driver_monitor.py selfdrive/assets/.gitignore selfdrive/assets/assets.qrc selfdrive/assets/*.png selfdrive/assets/*.svg selfdrive/assets/fonts/*.ttf selfdrive/assets/images/* selfdrive/assets/offroad/* selfdrive/assets/sounds/* selfdrive/assets/training/* phonelibs/SConscript phonelibs/nanovg/*.c phonelibs/nanovg/*.h phonelibs/libgralloc/** phonelibs/linux/** phonelibs/opencl/** phonelibs/zlib/* phonelibs/bzip2/* phonelibs/openmax/** phonelibs/json11/json11.cpp phonelibs/json11/json11.hpp phonelibs/qpoases/** phonelibs/qrcode/*.cc phonelibs/qrcode/*.hpp phonelibs/kaitai/*.h phonelibs/kaitai/*.cpp phonelibs/libyuv/include/** phonelibs/libyuv/lib/** phonelibs/libyuv/larch64/** phonelibs/snpe/include/** phonelibs/snpe/aarch64** phonelibs/snpe/larch64** phonelibs/snpe/dsp** phonelibs/android_frameworks_native/** phonelibs/android_hardware_libhardware/** phonelibs/android_system_core/** installer/updater/updater installer/updater/updater.cc installer/updater/update.json installer/updater/Makefile scripts/update_now.sh scripts/stop_updater.sh pyextra/.gitignore rednose/** cereal/.gitignore cereal/__init__.py cereal/car.capnp cereal/legacy.capnp cereal/log.capnp cereal/services.py cereal/SConscript cereal/include/** cereal/logger/logger.h cereal/messaging/.gitignore cereal/messaging/__init__.py cereal/messaging/bridge.cc cereal/messaging/impl_msgq.cc cereal/messaging/impl_msgq.h cereal/messaging/impl_zmq.cc cereal/messaging/impl_zmq.h cereal/messaging/messaging.cc cereal/messaging/messaging.h cereal/messaging/messaging.pxd cereal/messaging/messaging_pyx.pyx cereal/messaging/msgq.cc cereal/messaging/msgq.h cereal/messaging/socketmaster.cc cereal/visionipc/.gitignore cereal/visionipc/__init__.py cereal/visionipc/*.cc cereal/visionipc/*.h cereal/visionipc/*.pyx cereal/visionipc/*.pxd panda/.gitignore panda/__init__.py panda/board/** panda/certs/** panda/crypto/** panda/examples/query_fw_versions.py panda/python/** opendbc/.gitignore opendbc/__init__.py opendbc/can/__init__.py opendbc/can/SConscript opendbc/can/can_define.py opendbc/can/common.cc opendbc/can/common.h opendbc/can/common.pxd opendbc/can/common_dbc.h opendbc/can/dbc.cc opendbc/can/dbc.py opendbc/can/dbc_template.cc opendbc/can/packer.cc opendbc/can/packer.py opendbc/can/packer_pyx.pyx opendbc/can/parser.cc opendbc/can/parser.py opendbc/can/parser_pyx.pyx opendbc/can/process_dbc.py opendbc/can/dbc_out/.gitkeep opendbc/can/dbc_out/.gitignore opendbc/chrysler_pacifica_2017_hybrid.dbc opendbc/chrysler_pacifica_2017_hybrid_private_fusion.dbc opendbc/gm_global_a_powertrain.dbc opendbc/gm_global_a_object.dbc opendbc/gm_global_a_chassis.dbc opendbc/ford_fusion_2018_pt.dbc opendbc/ford_fusion_2018_adas.dbc opendbc/honda_accord_2018_can_generated.dbc opendbc/acura_ilx_2016_can_generated.dbc opendbc/acura_rdx_2018_can_generated.dbc opendbc/acura_rdx_2020_can_generated.dbc opendbc/honda_civic_touring_2016_can_generated.dbc opendbc/honda_civic_hatchback_ex_2017_can_generated.dbc opendbc/honda_civic_sedan_16_diesel_2019_can_generated.dbc opendbc/honda_crv_touring_2016_can_generated.dbc opendbc/honda_crv_ex_2017_can_generated.dbc opendbc/honda_crv_ex_2017_body_generated.dbc opendbc/honda_crv_executive_2016_can_generated.dbc opendbc/honda_crv_hybrid_2019_can_generated.dbc opendbc/honda_fit_ex_2018_can_generated.dbc opendbc/honda_odyssey_exl_2018_generated.dbc opendbc/honda_odyssey_extreme_edition_2018_china_can_generated.dbc opendbc/honda_pilot_touring_2017_can_generated.dbc opendbc/honda_ridgeline_black_edition_2017_can_generated.dbc opendbc/honda_insight_ex_2019_can_generated.dbc opendbc/acura_ilx_2016_nidec.dbc opendbc/hyundai_kia_generic.dbc opendbc/mazda_2017.dbc opendbc/nissan_x_trail_2017.dbc opendbc/nissan_leaf_2018.dbc opendbc/subaru_global_2017_generated.dbc opendbc/subaru_outback_2015_generated.dbc opendbc/subaru_outback_2019_generated.dbc opendbc/subaru_forester_2017_generated.dbc opendbc/toyota_rav4_hybrid_2017_pt_generated.dbc opendbc/toyota_rav4_2017_pt_generated.dbc opendbc/toyota_prius_2017_pt_generated.dbc opendbc/toyota_corolla_2017_pt_generated.dbc opendbc/lexus_rx_350_2016_pt_generated.dbc opendbc/lexus_rx_hybrid_2017_pt_generated.dbc opendbc/toyota_nodsu_pt_generated.dbc opendbc/toyota_nodsu_hybrid_pt_generated.dbc opendbc/toyota_camry_hybrid_2018_pt_generated.dbc opendbc/toyota_highlander_2017_pt_generated.dbc opendbc/toyota_highlander_hybrid_2018_pt_generated.dbc opendbc/toyota_avalon_2017_pt_generated.dbc opendbc/toyota_sienna_xle_2018_pt_generated.dbc opendbc/lexus_is_2018_pt_generated.dbc opendbc/lexus_ct200h_2018_pt_generated.dbc opendbc/lexus_nx300h_2018_pt_generated.dbc opendbc/lexus_nx300_2018_pt_generated.dbc opendbc/toyota_adas.dbc opendbc/toyota_tss2_adas.dbc opendbc/vw_mqb_2010.dbc opendbc/tesla_can.dbc opendbc/tesla_radar.dbc ================================================ FILE: release/files_pc ================================================ phonelibs/mapbox-gl-native-qt/x86_64/** phonelibs/qt-plugins/x86_64/** ================================================ FILE: release/files_tici ================================================ phonelibs/mapbox-gl-native-qt/include/* selfdrive/timezoned.py selfdrive/assets/navigation/* selfdrive/assets/training_wide/* selfdrive/assets/sounds_tici/* selfdrive/camerad/cameras/camera_qcom2.cc selfdrive/camerad/cameras/camera_qcom2.h selfdrive/camerad/cameras/real_debayer.cl selfdrive/hardware/tici/__init__.py selfdrive/hardware/tici/hardware.h selfdrive/hardware/tici/hardware.py selfdrive/hardware/tici/pins.py selfdrive/hardware/tici/agnos.py selfdrive/hardware/tici/agnos.json selfdrive/hardware/tici/amplifier.py selfdrive/hardware/tici/updater selfdrive/ui/qt/spinner_larch64 selfdrive/ui/qt/text_larch64 selfdrive/ui/qt/maps/*.cc selfdrive/ui/qt/maps/*.h ================================================ FILE: release/identity.sh ================================================ export GIT_COMMITTER_NAME="Vehicle Researcher" export GIT_COMMITTER_EMAIL="user@comma.ai" export GIT_AUTHOR_NAME="Vehicle Researcher" export GIT_AUTHOR_EMAIL="user@comma.ai" export GIT_SSH_COMMAND="ssh -i /data/gitkey" ================================================ FILE: scripts/complete_setup.sh ================================================ #!/usr/bin/bash touch /data/data/com.termux/files/continue.sh echo "#!/usr/bin/bash" >> /data/data/com.termux/files/continue.sh echo "cd /data/openpilot" >> /data/data/com.termux/files/continue.sh echo "exec ./launch_openpilot.sh" >> /data/data/com.termux/files/continue.sh chmod u+x /data/data/com.termux/files/continue.sh reboot ================================================ FILE: scripts/installers/font_installer.py ================================================ #!/usr/bin/env python3 import os if __name__ == "__main__": install_font = False if os.path.isfile("/EON"): if not os.path.isfile("/system/fonts/NotoSansCJKtc-Regular.otf"): os.system("mount -o remount,rw /system") os.system("rm -fr /system/fonts/NotoSansTC*.otf") os.system("rm -fr /system/fonts/NotoSansSC*.otf") os.system("rm -fr /system/fonts/NotoSansKR*.otf") os.system("rm -fr /system/fonts/NotoSansJP*.otf") os.system("cp -rf /data/openpilot/selfdrive/assets/fonts/NotoSansCJKtc-* /system/fonts/") os.system("cp -rf /data/openpilot/selfdrive/assets/fonts/fonts.xml /system/etc/fonts.xml") os.system("chmod 644 /system/etc/fonts.xml") os.system("chmod 644 /system/fonts/NotoSansCJKtc-*") os.system("mount -o remount,r /system") elif os.path.isfile("/TICI"): pass else: pass ================================================ FILE: scripts/installers/language_installer.py ================================================ #!/usr/bin/env python3 import os import subprocess if __name__ == "__main__": if os.path.isfile("/EON"): language = subprocess.check_output(["getprop", "persist.sys.locale"], encoding='utf8').strip() if language != "": os.system("echo -n %s > /data/params/d/dp_locale" % language) elif os.path.isfile("/TICI"): pass else: pass ================================================ FILE: scripts/installers/sshkey_installer.py ================================================ #!/usr/bin/env python3 import os if __name__ == "__main__": install_key = False if os.path.isfile("/EON"): os.system("setprop persist.neos.ssh 1") os.system("echo -n 1 > /data/params/d/SshEnabled") if not os.path.isfile("/data/params/d/GithubSshKeys"): install_key = True else: with open('/data/params/d/GithubSshKeys') as f: if f.read().strip() == "": install_key = True if install_key: os.system("echo -n openpilot > /data/params/d/GithubUsername") os.system("cp /data/openpilot/scripts/ssh_key/setup_keys /data/params/d/GithubSshKeys") elif os.path.isfile("/TICI"): pass else: pass ================================================ FILE: scripts/oneplus_update_neos.sh ================================================ #!/usr/bin/bash if [ -z "$BASEDIR" ]; then BASEDIR="/data/openpilot" fi source "$BASEDIR/launch_env.sh" cp -f "$BASEDIR/installer/updater/update.zip" "/data/media/0/update.zip" || exit pm disable ai.comma.plus.offroad killall _ui "$BASEDIR/installer/updater/updater" "file://$BASEDIR/installer/updater/oneplus.json" ================================================ FILE: scripts/rebuild.sh ================================================ #!/usr/bin/bash export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib export HOME=/data/data/com.termux/files/home export PATH=/usr/local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/sbin:/data/data/com.termux/files/usr/bin/applets:/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/data/com.termux/files/usr/bin/git printf %s "1" > /data/params/d/DragonUpdating cd /data/openpilot || exit #git reset --hard @{u} git clean -xdf rm -fr /tmp/scons_cache/ find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete scons --clean reboot ================================================ FILE: scripts/reset_dp.sh ================================================ #!/usr/bin/bash export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib export HOME=/data/data/com.termux/files/home export PATH=/usr/local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/sbin:/data/data/com.termux/files/usr/bin/applets:/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/data/com.termux/files/usr/bin/git export PYTHONPATH=/data/openpilot rm -fr /data/params/d/dp_* rm -fr /data/params/d/Dragon* reboot ================================================ FILE: scripts/reset_update.sh ================================================ #!/usr/bin/bash export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib export HOME=/data/data/com.termux/files/home export PATH=/usr/local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/sbin:/data/data/com.termux/files/usr/bin/applets:/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/data/com.termux/files/usr/bin/git export PYTHONPATH=/data/openpilot rm /data/openpilot/panda/board/obj/panda.bin cd /data/openpilot && git fetch --all && git reset --hard @{u} && git clean -xdf && scons --clean && reboot ================================================ FILE: scripts/reset_usb.py ================================================ #!/usr/bin/env python import os import sys from subprocess import Popen, PIPE import fcntl def create_usb_list(): device_list = list() try: lsusb_out = Popen('lsusb -v', shell=True, bufsize=64, stdin=PIPE, stdout=PIPE, close_fds=True).stdout.read().strip().decode('utf-8') usb_devices = lsusb_out.split('%s%s' % (os.linesep, os.linesep)) for device_categories in usb_devices: if not device_categories: continue categories = device_categories.split(os.linesep) device_stuff = categories[0].strip().split() bus = device_stuff[1] device = device_stuff[3][:-1] device_dict = {'bus': bus, 'device': device} device_info = ' '.join(device_stuff[6:]) device_dict['description'] = device_info for category in categories: if not category: continue categoryinfo = category.strip().split() if categoryinfo[0] == 'iManufacturer': manufacturer_info = ' '.join(categoryinfo[2:]) device_dict['manufacturer'] = manufacturer_info if categoryinfo[0] == 'iProduct': device_info = ' '.join(categoryinfo[2:]) device_dict['device'] = device_info path = '/dev/bus/usb/%s/%s' % (bus, device) device_dict['path'] = path device_list.append(device_dict) except Exception as ex: print('Failed to list usb devices! Error: %s' % ex) sys.exit(-1) return device_list def kill_usb(dev_path): USBDEVFS_RESET = 21780 try: f = open(dev_path, 'w', os.O_WRONLY) fcntl.ioctl(f, USBDEVFS_RESET, 0) print('Successfully reset %s' % dev_path) sys.exit(0) except Exception as ex: print('Failed to reset device! Error: %s' % ex) sys.exit(-1) if __name__ == "__main__": usb_list = create_usb_list() for device in usb_list: if device['manufacturer'] == 'comma.ai': kill_usb(device['path']) sys.exit(0) ================================================ FILE: scripts/ssh_key/id_rsa ================================================ -----BEGIN RSA PRIVATE KEY----- MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC+iXXq30Tq+J5N Kat3KWHCzcmwZ55nGh6WggAqECa5CasBlM9VeROpVu3beA+5h0MibRgbD4DMtVXB t6gEvZ8nd04E7eLA9LTZyFDZ7SkSOVj4oXOQsT0GnJmKrASW5KslTWqVzTfo2XCt Z+004ikLxmyFeBO8NOcErW1pa8gFdQDToH9FrA7kgysic/XVESTOoe7XlzRoe/eZ acEQ+jtnmFd21A4aEADkk00Ahjr0uKaJiLUAPatxs2icIXWpgYtfqqtaKF23wSt6 1OTu6cAwXbOWr3m+IUSRUO0IRzEIQS3z1jfd1svgzSgSSwZ1Lhj4AoKxIEAIc8qJ rO4uymCJAgMBAAECggEBAISFevxHGdoL3Z5xkw6oO5SQKO2GxEeVhRzNgmu/HA+q x8OryqD6O1CWY4037kft6iWxlwiLOdwna2P25ueVM3LxqdQH2KS4DmlCx+kq6FwC gv063fQPMhC9LpWimvaQSPEC7VUPjQlo4tPY6sTTYBUOh0A1ihRm/x7juKuQCWix Cq8C/DVnB1X4mGj+W3nJc5TwVJtgJbbiBrq6PWrhvB/3qmkxHRL7dU2SBb2iNRF1 LLY30dJx/cD73UDKNHrlrsjk3UJc29Mp4/MladKvUkRqNwlYxSuAtJV0nZ3+iFkL s3adSTHdJpClQer45R51rFDlVsDz2ZBpb/hRNRoGDuECgYEA6A1EixLq7QYOh3cb Xhyh3W4kpVvA/FPfKH1OMy3ONOD/Y9Oa+M/wthW1wSoRL2n+uuIW5OAhTIvIEivj 6bAZsTT3twrvOrvYu9rx9aln4p8BhyvdjeW4kS7T8FP5ol6LoOt2sTP3T1LOuJPO uQvOjlKPKIMh3c3RFNWTnGzMPa0CgYEA0jNiPLxP3A2nrX0keKDI+VHuvOY88gdh 0W5BuLMLovOIDk9aQFIbBbMuW1OTjHKv9NK+Lrw+YbCFqOGf1dU/UN5gSyE8lX/Q FsUGUqUZx574nJZnOIcy3ONOnQLcvHAQToLFAGUd7PWgP3CtHkt9hEv2koUwL4vo ikTP1u9Gkc0CgYEA2apoWxPZrY963XLKBxNQecYxNbLFaWq67t3rFnKm9E8BAICi 4zUaE5J1tMVi7Vi9iks9Ml9SnNyZRQJKfQ+kaebHXbkyAaPmfv+26rqHKboA0uxA nDOZVwXX45zBkp6g1sdHxJx8JLoGEnkC9eyvSi0C//tRLx86OhLErXwYcNkCf1it VMRKrWYoXJTUNo6tRhvodM88UnnIo3u3CALjhgU4uC1RTMHV4ZCGBwiAOb8GozSl s5YD1E1iKwEULloHnK6BIh6P5v8q7J6uf/xdqoKMjlWBHgq6/roxKvkSPA1DOZ3l jTadcgKFnRUmc+JT9p/ZbCxkA/ALFg8++G+0ghECgYA8vG3M/utweLvq4RI7l7U7 b+i2BajfK2OmzNi/xugfeLjY6k2tfQGRuv6ppTjehtji2uvgDWkgjJUgPfZpir3I RsVMUiFgloWGHETOy0Qvc5AwtqTJFLTD1Wza2uBilSVIEsg6Y83Gickh+ejOmEsY 6co17RFaAZHwGfCFFjO76Q== -----END RSA PRIVATE KEY----- ================================================ FILE: scripts/ssh_key/setup_keys ================================================ from="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+iXXq30Tq+J5NKat3KWHCzcmwZ55nGh6WggAqECa5CasBlM9VeROpVu3beA+5h0MibRgbD4DMtVXBt6gEvZ8nd04E7eLA9LTZyFDZ7SkSOVj4oXOQsT0GnJmKrASW5KslTWqVzTfo2XCtZ+004ikLxmyFeBO8NOcErW1pa8gFdQDToH9FrA7kgysic/XVESTOoe7XlzRoe/eZacEQ+jtnmFd21A4aEADkk00Ahjr0uKaJiLUAPatxs2icIXWpgYtfqqtaKF23wSt61OTu6cAwXbOWr3m+IUSRUO0IRzEIQS3z1jfd1svgzSgSSwZ1Lhj4AoKxIEAIc8qJrO4uymCJ public ================================================ FILE: scripts/stop_updater.sh ================================================ #!/usr/bin/env sh # Stop updater pkill -2 -f selfdrive.updated # Remove pending update rm -f /data/safe_staging/finalized/.overlay_consistent ================================================ FILE: scripts/update_now.sh ================================================ #!/usr/bin/env sh # Send SIGHUP to updater pkill -1 -f selfdrive.updated ================================================ FILE: scripts/update_panda_firmware.sh ================================================ #!/usr/bin/bash export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib export HOME=/data/data/com.termux/files/home export PATH=/usr/local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/sbin:/data/data/com.termux/files/usr/bin/applets:/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/data/com.termux/files/usr/bin/python export PYTHONPATH=/data/openpilot rm /data/openpilot/panda/board/obj/panda.bin cd /data/openpilot/panda || exit ; pkill -f boardd ; python -c "from panda import Panda; Panda().flash()" && reboot ================================================ FILE: scripts/vw.sh ================================================ #!/usr/bin/bash if [ $1 -eq 1 ]; then printf %s "1" > /data/params/d/dp_vw_panda fi if [ $1 -eq 0 ]; then printf %s "0" > /data/params/d/dp_vw_panda fi rm /data/openpilot/panda/board/obj/panda.bin ================================================ FILE: selfdrive/__init__.py ================================================ ================================================ FILE: selfdrive/assets/.gitignore ================================================ *.cc ================================================ FILE: selfdrive/assets/assets.qrc ================================================ img_continue_triangle.svg img_circled_check.svg img_circled_slash.svg img_eye_open.svg img_eye_closed.svg offroad/icon_lock_closed.svg offroad/icon_checkmark.svg offroad/icon_wifi_strength_low.svg offroad/icon_wifi_strength_medium.svg offroad/icon_wifi_strength_high.svg offroad/icon_wifi_strength_full.svg ================================================ FILE: selfdrive/assets/fonts/NotoSansCJKtc-Bold.otf ================================================ [File too large to display: 16.2 MB] ================================================ FILE: selfdrive/assets/fonts/NotoSansCJKtc-Medium.otf ================================================ [File too large to display: 15.7 MB] ================================================ FILE: selfdrive/assets/fonts/NotoSansCJKtc-Regular.otf ================================================ [File too large to display: 15.7 MB] ================================================ FILE: selfdrive/assets/fonts/fonts.xml ================================================ Roboto-Thin.ttf Roboto-ThinItalic.ttf Roboto-Light.ttf Roboto-LightItalic.ttf Roboto-Regular.ttf Roboto-Italic.ttf Roboto-Medium.ttf Roboto-MediumItalic.ttf Roboto-Black.ttf Roboto-BlackItalic.ttf Roboto-Bold.ttf Roboto-BoldItalic.ttf RobotoCondensed-Light.ttf RobotoCondensed-LightItalic.ttf RobotoCondensed-Regular.ttf RobotoCondensed-Italic.ttf RobotoCondensed-Bold.ttf RobotoCondensed-BoldItalic.ttf NotoSerif-Regular.ttf NotoSerif-Bold.ttf NotoSerif-Italic.ttf NotoSerif-BoldItalic.ttf DroidSansMono.ttf CutiveMono.ttf ComingSoon.ttf DancingScript-Regular.ttf DancingScript-Bold.ttf CarroisGothicSC-Regular.ttf NotoNaskhArabic-Regular.ttf NotoNaskhArabic-Bold.ttf NotoNaskhArabicUI-Regular.ttf NotoNaskhArabicUI-Bold.ttf NotoSansEthiopic-Regular.ttf NotoSansEthiopic-Bold.ttf NotoSansHebrew-Regular.ttf NotoSansHebrew-Bold.ttf NotoSansThai-Regular.ttf NotoSansThai-Bold.ttf NotoSansThaiUI-Regular.ttf NotoSansThaiUI-Bold.ttf NotoSansArmenian-Regular.ttf NotoSansArmenian-Bold.ttf NotoSansGeorgian-Regular.ttf NotoSansGeorgian-Bold.ttf NotoSansDevanagari-Regular.ttf NotoSansDevanagari-Bold.ttf NotoSansDevanagariUI-Regular.ttf NotoSansDevanagariUI-Bold.ttf NotoSansGujarati-Regular.ttf NotoSansGujarati-Bold.ttf NotoSansGujaratiUI-Regular.ttf NotoSansGujaratiUI-Bold.ttf NotoSansGurmukhi-Regular.ttf NotoSansGurmukhi-Bold.ttf NotoSansGurmukhiUI-Regular.ttf NotoSansGurmukhiUI-Bold.ttf NotoSansTamil-Regular.ttf NotoSansTamil-Bold.ttf NotoSansTamilUI-Regular.ttf NotoSansTamilUI-Bold.ttf NotoSansMalayalam-Regular.ttf NotoSansMalayalam-Bold.ttf NotoSansMalayalamUI-Regular.ttf NotoSansMalayalamUI-Bold.ttf NotoSansBengali-Regular.ttf NotoSansBengali-Bold.ttf NotoSansBengaliUI-Regular.ttf NotoSansBengaliUI-Bold.ttf NotoSansTelugu-Regular.ttf NotoSansTelugu-Bold.ttf NotoSansTeluguUI-Regular.ttf NotoSansTeluguUI-Bold.ttf NotoSansKannada-Regular.ttf NotoSansKannada-Bold.ttf NotoSansKannadaUI-Regular.ttf NotoSansKannadaUI-Bold.ttf NotoSansOriya-Regular.ttf NotoSansOriya-Bold.ttf NotoSansOriyaUI-Regular.ttf NotoSansOriyaUI-Bold.ttf NotoSansSinhala-Regular.ttf NotoSansSinhala-Bold.ttf NotoSansKhmer-Regular.ttf NotoSansKhmer-Bold.ttf NotoSansKhmerUI-Regular.ttf NotoSansKhmerUI-Bold.ttf NotoSansLao-Regular.ttf NotoSansLao-Bold.ttf NotoSansLaoUI-Regular.ttf NotoSansLaoUI-Bold.ttf NotoSansMyanmar-Regular.ttf NotoSansMyanmar-Bold.ttf NotoSansMyanmarUI-Regular.ttf NotoSansMyanmarUI-Bold.ttf NotoSansThaana-Regular.ttf NotoSansThaana-Bold.ttf NotoSansCham-Regular.ttf NotoSansCham-Bold.ttf NotoSansBalinese-Regular.ttf NotoSansBamum-Regular.ttf NotoSansBatak-Regular.ttf NotoSansBuginese-Regular.ttf NotoSansBuhid-Regular.ttf NotoSansCanadianAboriginal-Regular.ttf NotoSansCherokee-Regular.ttf NotoSansCoptic-Regular.ttf NotoSansGlagolitic-Regular.ttf NotoSansHanunoo-Regular.ttf NotoSansJavanese-Regular.ttf NotoSansKayahLi-Regular.ttf NotoSansLepcha-Regular.ttf NotoSansLimbu-Regular.ttf NotoSansLisu-Regular.ttf NotoSansMandaic-Regular.ttf NotoSansMeeteiMayek-Regular.ttf NotoSansNewTaiLue-Regular.ttf NotoSansNKo-Regular.ttf NotoSansOlChiki-Regular.ttf NotoSansRejang-Regular.ttf NotoSansSaurashtra-Regular.ttf NotoSansSundanese-Regular.ttf NotoSansSylotiNagri-Regular.ttf NotoSansSyriacEstrangela-Regular.ttf NotoSansTagbanwa-Regular.ttf NotoSansTaiTham-Regular.ttf NotoSansTaiViet-Regular.ttf NotoSansTibetan-Regular.ttf NotoSansTifinagh-Regular.ttf NotoSansVai-Regular.ttf NotoSansYi-Regular.ttf NotoSansSymbols-Regular-Subsetted.ttf NotoSansJP-Regular.otf NotoSansKR-Regular.otf NanumGothic.ttf NotoColorEmoji.ttf NotoSansCJKtc-Regular.otf NotoSansCJKtc-Medium.otf NotoSansCJKtc-Bold.otf NotoSansCJKtc-Regular.otf NotoSansCJKtc-Medium.otf NotoSansCJKtc-Bold.otf MTLmr3m.ttf NotoSansTaiLe-Regular.ttf NotoSansMongolian-Regular.ttf ================================================ FILE: selfdrive/assets/locales/events.pot ================================================ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-10-15 13:37+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: selfdrive/controls/lib/events.py:153 msgid "openpilot Unavailable" msgstr "" #: selfdrive/controls/lib/events.py:160 selfdrive/controls/lib/events.py:167 msgid "TAKE CONTROL IMMEDIATELY" msgstr "" #: selfdrive/controls/lib/events.py:187 selfdrive/controls/lib/events.py:328 #: selfdrive/controls/lib/events.py:354 selfdrive/controls/lib/events.py:418 #: selfdrive/controls/lib/events.py:470 selfdrive/controls/lib/events.py:522 #: selfdrive/controls/lib/events.py:532 msgid "TAKE CONTROL" msgstr "" #: selfdrive/controls/lib/events.py:188 #, python-format msgid "Steer Unavailable Below %(speed)d %(unit)s" msgstr "" #: selfdrive/controls/lib/events.py:196 #, python-format msgid "Calibration in Progress: %d%%" msgstr "" #: selfdrive/controls/lib/events.py:197 #, python-format msgid "Drive Above %(speed)d %(unit)s" msgstr "" #: selfdrive/controls/lib/events.py:204 msgid "Poor GPS reception" msgstr "" #: selfdrive/controls/lib/events.py:205 msgid "If sky is visible, contact support" msgstr "" #: selfdrive/controls/lib/events.py:205 msgid "Check GPS antenna placement" msgstr "" #: selfdrive/controls/lib/events.py:210 msgid "Cruise Mode Disabled" msgstr "" #: selfdrive/controls/lib/events.py:212 msgid "Main Switch Off" msgstr "" #: selfdrive/controls/lib/events.py:222 msgid "DEBUG ALERT" msgstr "" #: selfdrive/controls/lib/events.py:230 msgid "Be ready to take over at any time" msgstr "" #: selfdrive/controls/lib/events.py:231 selfdrive/controls/lib/events.py:239 #: selfdrive/controls/lib/events.py:247 selfdrive/controls/lib/events.py:255 msgid "Always keep hands on wheel and eyes on road" msgstr "" #: selfdrive/controls/lib/events.py:238 msgid "WARNING: This branch is not tested" msgstr "" #: selfdrive/controls/lib/events.py:246 msgid "Dashcam mode" msgstr "" #: selfdrive/controls/lib/events.py:254 msgid "Dashcam mode for unsupported car" msgstr "" #: selfdrive/controls/lib/events.py:262 msgid "Unsupported Giraffe Configuration" msgstr "" #: selfdrive/controls/lib/events.py:263 msgid "Visit comma.ai/tg" msgstr "" #: selfdrive/controls/lib/events.py:270 msgid "White Panda Is No Longer Supported" msgstr "" #: selfdrive/controls/lib/events.py:271 msgid "Upgrade to comma two or black panda" msgstr "" #: selfdrive/controls/lib/events.py:274 msgid "White panda is no longer supported" msgstr "" #: selfdrive/controls/lib/events.py:279 msgid "Stock LKAS is turned on" msgstr "" #: selfdrive/controls/lib/events.py:280 msgid "Turn off stock LKAS to engage" msgstr "" #: selfdrive/controls/lib/events.py:288 msgid "Community Feature Detected" msgstr "" #: selfdrive/controls/lib/events.py:289 msgid "Enable Community Features in Developer Settings" msgstr "" #: selfdrive/controls/lib/events.py:296 msgid "Dashcam Mode" msgstr "" #: selfdrive/controls/lib/events.py:297 msgid "Car Unrecognized" msgstr "" #: selfdrive/controls/lib/events.py:304 selfdrive/controls/lib/events.py:312 #: selfdrive/controls/lib/events.py:320 msgid "BRAKE!" msgstr "" #: selfdrive/controls/lib/events.py:305 msgid "Stock AEB: Risk of Collision" msgstr "" #: selfdrive/controls/lib/events.py:313 msgid "Stock FCW: Risk of Collision" msgstr "" #: selfdrive/controls/lib/events.py:321 msgid "Risk of Collision" msgstr "" #: selfdrive/controls/lib/events.py:329 msgid "Lane Departure Detected" msgstr "" #: selfdrive/controls/lib/events.py:338 msgid "openpilot will not brake while gas pressed" msgstr "" #: selfdrive/controls/lib/events.py:346 msgid "Vehicle Parameter Identification Failed" msgstr "" #: selfdrive/controls/lib/events.py:355 selfdrive/controls/lib/events.py:523 #: selfdrive/controls/lib/events.py:526 msgid "Steering Temporarily Unavailable" msgstr "" #: selfdrive/controls/lib/events.py:362 msgid "KEEP EYES ON ROAD: Driver Distracted" msgstr "" #: selfdrive/controls/lib/events.py:370 msgid "KEEP EYES ON ROAD" msgstr "" #: selfdrive/controls/lib/events.py:371 msgid "Driver Appears Distracted" msgstr "" #: selfdrive/controls/lib/events.py:378 selfdrive/controls/lib/events.py:402 msgid "DISENGAGE IMMEDIATELY" msgstr "" #: selfdrive/controls/lib/events.py:379 msgid "Driver Was Distracted" msgstr "" #: selfdrive/controls/lib/events.py:386 msgid "TOUCH STEERING WHEEL: No Face Detected" msgstr "" #: selfdrive/controls/lib/events.py:394 msgid "TOUCH STEERING WHEEL" msgstr "" #: selfdrive/controls/lib/events.py:395 msgid "Driver Is Unresponsive" msgstr "" #: selfdrive/controls/lib/events.py:403 msgid "Driver Was Unresponsive" msgstr "" #: selfdrive/controls/lib/events.py:410 msgid "CHECK DRIVER FACE VISIBILITY" msgstr "" #: selfdrive/controls/lib/events.py:411 msgid "Driver Monitor Model Output Uncertain" msgstr "" #: selfdrive/controls/lib/events.py:419 msgid "Resume Driving Manually" msgstr "" #: selfdrive/controls/lib/events.py:426 msgid "STOPPED" msgstr "" #: selfdrive/controls/lib/events.py:427 msgid "Press Resume to Move" msgstr "" #: selfdrive/controls/lib/events.py:438 msgid "Steer Left to Start Lane Change" msgstr "" #: selfdrive/controls/lib/events.py:439 selfdrive/controls/lib/events.py:447 #: selfdrive/controls/lib/events.py:455 selfdrive/controls/lib/events.py:463 #: selfdrive/controls/lib/events.py:802 selfdrive/controls/lib/events.py:810 msgid "Monitor Other Vehicles" msgstr "" #: selfdrive/controls/lib/events.py:446 msgid "Steer Right to Start Lane Change" msgstr "" #: selfdrive/controls/lib/events.py:454 msgid "Car Detected in Blindspot" msgstr "" #: selfdrive/controls/lib/events.py:462 msgid "Changing Lane" msgstr "" #: selfdrive/controls/lib/events.py:471 msgid "Turn Exceeds Steering Limit" msgstr "" #: selfdrive/controls/lib/events.py:496 msgid "Brake Hold Active" msgstr "" #: selfdrive/controls/lib/events.py:501 msgid "Park Brake Engaged" msgstr "" #: selfdrive/controls/lib/events.py:506 msgid "Pedal Pressed During Attempt" msgstr "" #: selfdrive/controls/lib/events.py:517 msgid "Enable Adaptive Cruise" msgstr "" #: selfdrive/controls/lib/events.py:533 msgid "Attempting Refocus: Camera Focus Invalid" msgstr "" #: selfdrive/controls/lib/events.py:539 msgid "Out of Storage Space" msgstr "" #: selfdrive/controls/lib/events.py:544 msgid "Speed Too Low" msgstr "" #: selfdrive/controls/lib/events.py:549 selfdrive/controls/lib/events.py:553 msgid "NEOS Update Required" msgstr "" #: selfdrive/controls/lib/events.py:550 msgid "Please Wait for Update" msgstr "" #: selfdrive/controls/lib/events.py:558 selfdrive/controls/lib/events.py:562 msgid "No Data from Device Sensors" msgstr "" #: selfdrive/controls/lib/events.py:559 selfdrive/controls/lib/events.py:572 #: selfdrive/controls/lib/events.py:669 msgid "Reboot your Device" msgstr "" #: selfdrive/controls/lib/events.py:571 selfdrive/controls/lib/events.py:575 msgid "Speaker not found" msgstr "" #: selfdrive/controls/lib/events.py:579 msgid "Distraction Level Too High" msgstr "" #: selfdrive/controls/lib/events.py:583 msgid "System Overheated" msgstr "" #: selfdrive/controls/lib/events.py:584 msgid "System overheated" msgstr "" #: selfdrive/controls/lib/events.py:588 selfdrive/controls/lib/events.py:589 msgid "Gear not D" msgstr "" #: selfdrive/controls/lib/events.py:594 msgid "Calibration Invalid" msgstr "" #: selfdrive/controls/lib/events.py:595 msgid "Reposition Device and Recalibrate" msgstr "" #: selfdrive/controls/lib/events.py:598 selfdrive/controls/lib/events.py:599 msgid "Calibration Invalid: Reposition Device & Recalibrate" msgstr "" #: selfdrive/controls/lib/events.py:603 selfdrive/controls/lib/events.py:605 msgid "Calibration in Progress" msgstr "" #: selfdrive/controls/lib/events.py:609 msgid "Door Open" msgstr "" #: selfdrive/controls/lib/events.py:610 msgid "Door open" msgstr "" #: selfdrive/controls/lib/events.py:614 msgid "Seatbelt Unlatched" msgstr "" #: selfdrive/controls/lib/events.py:615 msgid "Seatbelt unlatched" msgstr "" #: selfdrive/controls/lib/events.py:619 selfdrive/controls/lib/events.py:620 msgid "ESP Off" msgstr "" #: selfdrive/controls/lib/events.py:624 selfdrive/controls/lib/events.py:625 msgid "Low Battery" msgstr "" #: selfdrive/controls/lib/events.py:629 selfdrive/controls/lib/events.py:630 msgid "Communication Issue between Processes" msgstr "" #: selfdrive/controls/lib/events.py:635 selfdrive/controls/lib/events.py:636 msgid "Radar Communication Issue" msgstr "" #: selfdrive/controls/lib/events.py:641 selfdrive/controls/lib/events.py:642 #: selfdrive/controls/lib/events.py:646 selfdrive/controls/lib/events.py:647 msgid "Radar Error: Restart the Car" msgstr "" #: selfdrive/controls/lib/events.py:651 selfdrive/controls/lib/events.py:652 msgid "Driving model lagging" msgstr "" #: selfdrive/controls/lib/events.py:656 selfdrive/controls/lib/events.py:657 msgid "Vision Model Output Uncertain" msgstr "" #: selfdrive/controls/lib/events.py:661 selfdrive/controls/lib/events.py:662 msgid "Device Fell Off Mount" msgstr "" #: selfdrive/controls/lib/events.py:666 selfdrive/controls/lib/events.py:672 msgid "Low Memory: Reboot Your Device" msgstr "" #: selfdrive/controls/lib/events.py:668 msgid "RAM Critically Low" msgstr "" #: selfdrive/controls/lib/events.py:677 selfdrive/controls/lib/events.py:678 msgid "Controls Failed" msgstr "" #: selfdrive/controls/lib/events.py:682 msgid "Controls Mismatch" msgstr "" #: selfdrive/controls/lib/events.py:686 selfdrive/controls/lib/events.py:688 #: selfdrive/controls/lib/events.py:692 msgid "CAN Error: Check Connections" msgstr "" #: selfdrive/controls/lib/events.py:696 selfdrive/controls/lib/events.py:702 msgid "LKAS Fault: Restart the Car" msgstr "" #: selfdrive/controls/lib/events.py:698 msgid "LKAS Fault: Restart the car to engage" msgstr "" #: selfdrive/controls/lib/events.py:706 selfdrive/controls/lib/events.py:712 #: selfdrive/controls/lib/events.py:795 msgid "Cruise Fault: Restart the Car" msgstr "" #: selfdrive/controls/lib/events.py:708 selfdrive/controls/lib/events.py:791 msgid "Cruise Fault: Restart the car to engage" msgstr "" #: selfdrive/controls/lib/events.py:716 msgid "Gas Fault: Restart the Car" msgstr "" #: selfdrive/controls/lib/events.py:717 msgid "Gas Error: Restart the Car" msgstr "" #: selfdrive/controls/lib/events.py:722 msgid "" "Reverse\n" "Gear" msgstr "" #: selfdrive/controls/lib/events.py:726 msgid "Reverse Gear" msgstr "" #: selfdrive/controls/lib/events.py:731 msgid "Cruise Is Off" msgstr "" #: selfdrive/controls/lib/events.py:735 selfdrive/controls/lib/events.py:736 msgid "Planner Solution Error" msgstr "" #: selfdrive/controls/lib/events.py:740 selfdrive/controls/lib/events.py:742 #: selfdrive/controls/lib/events.py:746 msgid "Harness Malfunction" msgstr "" #: selfdrive/controls/lib/events.py:743 msgid "Please Check Hardware" msgstr "" #: selfdrive/controls/lib/events.py:751 selfdrive/controls/lib/events.py:760 msgid "openpilot Canceled" msgstr "" #: selfdrive/controls/lib/events.py:752 msgid "No close lead car" msgstr "" #: selfdrive/controls/lib/events.py:755 msgid "No Close Lead Car" msgstr "" #: selfdrive/controls/lib/events.py:761 msgid "Speed too low" msgstr "" #: selfdrive/controls/lib/events.py:768 selfdrive/controls/lib/events.py:773 msgid "Speed Too High" msgstr "" #: selfdrive/controls/lib/events.py:769 msgid "Slow down to resume operation" msgstr "" #: selfdrive/controls/lib/events.py:774 msgid "Slow down to engage" msgstr "" #: selfdrive/controls/lib/events.py:781 msgid "Please connect to Internet" msgstr "" #: selfdrive/controls/lib/events.py:782 msgid "An Update Check Is Required to Engage" msgstr "" #: selfdrive/controls/lib/events.py:785 msgid "Please Connect to Internet" msgstr "" #: selfdrive/controls/lib/events.py:801 msgid "Left ALC will start in 3s" msgstr "" #: selfdrive/controls/lib/events.py:809 msgid "Right ALC will start in 3s" msgstr "" #: selfdrive/controls/lib/events.py:817 msgid "STEERING REQUIRED: Lane Keeping OFF" msgstr "" #: selfdrive/controls/lib/events.py:825 msgid "STEERING REQUIRED: Blinkers ON" msgstr "" #: selfdrive/controls/lib/events.py:833 selfdrive/controls/lib/events.py:838 msgid "Lead Car Is Moving" msgstr "" #: selfdrive/controls/lib/events.py:847 msgid "WARNING" msgstr "" #: selfdrive/controls/lib/events.py:848 msgid "Grab wheel to start bypass" msgstr "" #: selfdrive/controls/lib/events.py:855 msgid "BYPASSING" msgstr "" #: selfdrive/controls/lib/events.py:856 msgid "HOLD WHEEL" msgstr "" #: selfdrive/controls/lib/events.py:863 msgid "Bypassed!" msgstr "" #: selfdrive/controls/lib/events.py:864 msgid "Release wheel when ready" msgstr "" ================================================ FILE: selfdrive/assets/locales/ja-JP/LC_MESSAGES/events.po ================================================ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-10-15 13:37+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: nikkurie <@nikkurie>\n" "Language-Team: LANGUAGE \n" "Language: ja-JP\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: selfdrive/controls/lib/events.py:153 msgid "openpilot Unavailable" msgstr "オープンパイロットは利用できません" #: selfdrive/controls/lib/events.py:160 selfdrive/controls/lib/events.py:167 msgid "TAKE CONTROL IMMEDIATELY" msgstr "すぐにハンドルを持って" #: selfdrive/controls/lib/events.py:187 selfdrive/controls/lib/events.py:328 #: selfdrive/controls/lib/events.py:354 selfdrive/controls/lib/events.py:418 #: selfdrive/controls/lib/events.py:470 selfdrive/controls/lib/events.py:522 #: selfdrive/controls/lib/events.py:532 msgid "TAKE CONTROL" msgstr "ハンドルを持って" #: selfdrive/controls/lib/events.py:188 #, fuzzy, python-format msgid "Steer Unavailable Below %(speed)d %(unit)s" msgstr "横の制御が無効になり速度が以下になります" #: selfdrive/controls/lib/events.py:196 #, fuzzy, python-format msgid "Calibration in Progress: %d%%" msgstr "キャリブレーション中:" #: selfdrive/controls/lib/events.py:197 #, python-format msgid "Drive Above %(speed)d %(unit)s" msgstr "%(speed)d %(unit)s 制限速度以上の運転をしてください" #: selfdrive/controls/lib/events.py:204 msgid "Poor GPS reception" msgstr "GPS受信不良" #: selfdrive/controls/lib/events.py:205 msgid "If sky is visible, contact support" msgstr "地下・トンネルでない場合は、カスタマーサービスに連絡ください" #: selfdrive/controls/lib/events.py:205 msgid "Check GPS antenna placement" msgstr "GPSアンテナの位置を確認してください。" #: selfdrive/controls/lib/events.py:210 msgid "Cruise Mode Disabled" msgstr "クルーズモードをオフ" #: selfdrive/controls/lib/events.py:212 msgid "Main Switch Off" msgstr "メインスイッチをオフ" #: selfdrive/controls/lib/events.py:222 msgid "DEBUG ALERT" msgstr "テストメッセージを削除" #: selfdrive/controls/lib/events.py:230 msgid "Be ready to take over at any time" msgstr "いつでも引き継げるよう準備しておいてください。" #: selfdrive/controls/lib/events.py:231 selfdrive/controls/lib/events.py:239 #: selfdrive/controls/lib/events.py:247 selfdrive/controls/lib/events.py:255 msgid "Always keep hands on wheel and eyes on road" msgstr "常にハンドルに触れ、道路から目を離さない" #: selfdrive/controls/lib/events.py:238 msgid "WARNING: This branch is not tested" msgstr "警告: このブランチはテストされていません" #: selfdrive/controls/lib/events.py:246 msgid "Dashcam mode" msgstr "ダッシュカムモード" #: selfdrive/controls/lib/events.py:254 msgid "Dashcam mode for unsupported car" msgstr "未対応車のためダッシュカムモードのみ" #: selfdrive/controls/lib/events.py:262 msgid "Unsupported Giraffe Configuration" msgstr "サポートされていないGiraffeの設定" #: selfdrive/controls/lib/events.py:263 msgid "Visit comma.ai/tg" msgstr "comma.ai/tg を参照" #: selfdrive/controls/lib/events.py:270 msgid "White Panda Is No Longer Supported" msgstr "ホワイトパンダはサポート終了しました" #: selfdrive/controls/lib/events.py:271 msgid "Upgrade to comma two or black panda" msgstr "コンマ2やブラックパンダにアップグレード" #: selfdrive/controls/lib/events.py:274 msgid "White panda is no longer supported" msgstr "ホワイトパンダはサポート終了しました" #: selfdrive/controls/lib/events.py:279 msgid "Stock LKAS is turned on" msgstr "純正LKASがオン" #: selfdrive/controls/lib/events.py:280 msgid "Turn off stock LKAS to engage" msgstr "純正LKASをオフにしてエンゲージ" #: selfdrive/controls/lib/events.py:288 msgid "Community Feature Detected" msgstr "コミュニティ開発の機能を検出" #: selfdrive/controls/lib/events.py:289 msgid "Enable Community Features in Developer Settings" msgstr "開発者設定でコミュニティ機能を有効にする" #: selfdrive/controls/lib/events.py:296 msgid "Dashcam Mode" msgstr "ダッシュカムモード" #: selfdrive/controls/lib/events.py:297 msgid "Car Unrecognized" msgstr "認識できない車" #: selfdrive/controls/lib/events.py:304 selfdrive/controls/lib/events.py:312 #: selfdrive/controls/lib/events.py:320 msgid "BRAKE!" msgstr "ブレーキ!" #: selfdrive/controls/lib/events.py:305 msgid "Stock AEB: Risk of Collision" msgstr "衝突の危険" #: selfdrive/controls/lib/events.py:313 msgid "Stock FCW: Risk of Collision" msgstr "衝突の危険" #: selfdrive/controls/lib/events.py:321 msgid "Risk of Collision" msgstr "衝突の危険" #: selfdrive/controls/lib/events.py:329 msgid "Lane Departure Detected" msgstr "車線逸脱を検知" #: selfdrive/controls/lib/events.py:338 msgid "openpilot will not brake while gas pressed" msgstr "アクセル中、オープンパイロットはブレーキをかけません" #: selfdrive/controls/lib/events.py:346 msgid "Vehicle Parameter Identification Failed" msgstr "車両パラメータの識別に失敗しました。" #: selfdrive/controls/lib/events.py:355 selfdrive/controls/lib/events.py:523 #: selfdrive/controls/lib/events.py:526 msgid "Steering Temporarily Unavailable" msgstr "ステアリングは一時的に利用不可" #: selfdrive/controls/lib/events.py:362 msgid "KEEP EYES ON ROAD: Driver Distracted" msgstr "道路から目を離さないで:注意散漫です" #: selfdrive/controls/lib/events.py:370 msgid "KEEP EYES ON ROAD" msgstr "道路から目を離さないで" #: selfdrive/controls/lib/events.py:371 msgid "Driver Appears Distracted" msgstr "ドライバーは注意散漫に見えます" #: selfdrive/controls/lib/events.py:378 selfdrive/controls/lib/events.py:402 msgid "DISENGAGE IMMEDIATELY" msgstr "すぐに解除してください" #: selfdrive/controls/lib/events.py:379 msgid "Driver Was Distracted" msgstr "ドライバーは注意力散漫" #: selfdrive/controls/lib/events.py:386 msgid "TOUCH STEERING WHEEL: No Face Detected" msgstr "ハンドルに触れて:顔が検出できない" #: selfdrive/controls/lib/events.py:394 msgid "TOUCH STEERING WHEEL" msgstr "ハンドルに触れて" #: selfdrive/controls/lib/events.py:395 msgid "Driver Is Unresponsive" msgstr "ドライバーが無反応" #: selfdrive/controls/lib/events.py:403 msgid "Driver Was Unresponsive" msgstr "ドライバーが無反応でした" #: selfdrive/controls/lib/events.py:410 msgid "CHECK DRIVER FACE VISIBILITY" msgstr "ドライバーの顔の視認性を確認" #: selfdrive/controls/lib/events.py:411 msgid "Driver Monitor Model Output Uncertain" msgstr "ドライバー監視モデルが不完全" #: selfdrive/controls/lib/events.py:419 msgid "Resume Driving Manually" msgstr "手動で運転を再開" #: selfdrive/controls/lib/events.py:426 msgid "STOPPED" msgstr "停止" #: selfdrive/controls/lib/events.py:427 msgid "Press Resume to Move" msgstr "Resumeを押して移動します。" #: selfdrive/controls/lib/events.py:438 msgid "Steer Left to Start Lane Change" msgstr "左ハンドルで車線変更を開始" #: selfdrive/controls/lib/events.py:439 selfdrive/controls/lib/events.py:447 #: selfdrive/controls/lib/events.py:455 selfdrive/controls/lib/events.py:463 #: selfdrive/controls/lib/events.py:802 selfdrive/controls/lib/events.py:810 msgid "Monitor Other Vehicles" msgstr "他の車両を監視" #: selfdrive/controls/lib/events.py:446 msgid "Steer Right to Start Lane Change" msgstr "右ハンドルで車線変更を開始" #: selfdrive/controls/lib/events.py:454 msgid "Car Detected in Blindspot" msgstr "ブラインドスポットで車両を発見" #: selfdrive/controls/lib/events.py:462 msgid "Changing Lane" msgstr "レーンチェンジ中" #: selfdrive/controls/lib/events.py:471 msgid "Turn Exceeds Steering Limit" msgstr "ステアリングリミットを超えています" #: selfdrive/controls/lib/events.py:496 msgid "Brake Hold Active" msgstr "サイドブレーキが作動" #: selfdrive/controls/lib/events.py:501 msgid "Park Brake Engaged" msgstr "サイドブレーキ作動中" #: selfdrive/controls/lib/events.py:506 msgid "Pedal Pressed During Attempt" msgstr "ペダル/ブレーキを検出" #: selfdrive/controls/lib/events.py:517 msgid "Enable Adaptive Cruise" msgstr "ACCを有効化" #: selfdrive/controls/lib/events.py:533 msgid "Attempting Refocus: Camera Focus Invalid" msgstr "再フォーカス中です" #: selfdrive/controls/lib/events.py:539 msgid "Out of Storage Space" msgstr "空き容量不足" #: selfdrive/controls/lib/events.py:544 msgid "Speed Too Low" msgstr "速度が遅すぎます" #: selfdrive/controls/lib/events.py:549 selfdrive/controls/lib/events.py:553 msgid "NEOS Update Required" msgstr "NEOSの更新が必要" #: selfdrive/controls/lib/events.py:550 msgid "Please Wait for Update" msgstr "更新をお待ちください" #: selfdrive/controls/lib/events.py:558 selfdrive/controls/lib/events.py:562 msgid "No Data from Device Sensors" msgstr "デバイスセンサからのデータがありません" #: selfdrive/controls/lib/events.py:559 selfdrive/controls/lib/events.py:572 #: selfdrive/controls/lib/events.py:669 msgid "Reboot your Device" msgstr "デバイスを再起動" #: selfdrive/controls/lib/events.py:571 selfdrive/controls/lib/events.py:575 msgid "Speaker not found" msgstr "スピーカーが見つかりません" #: selfdrive/controls/lib/events.py:579 msgid "Distraction Level Too High" msgstr "注意力散漫すぎます" #: selfdrive/controls/lib/events.py:583 msgid "System Overheated" msgstr "オーバーヒート" #: selfdrive/controls/lib/events.py:584 msgid "System overheated" msgstr "オーバーヒート" #: selfdrive/controls/lib/events.py:588 selfdrive/controls/lib/events.py:589 msgid "Gear not D" msgstr "Dではない" #: selfdrive/controls/lib/events.py:594 #, fuzzy msgid "Calibration Invalid" msgstr "キャリブレーション" #: selfdrive/controls/lib/events.py:595 #, fuzzy msgid "Reposition Device and Recalibrate" msgstr "キャリブレーションが無効です。再実行してください。" #: selfdrive/controls/lib/events.py:598 selfdrive/controls/lib/events.py:599 msgid "Calibration Invalid: Reposition Device & Recalibrate" msgstr "キャリブレーションが無効です。再実行してください。" #: selfdrive/controls/lib/events.py:603 selfdrive/controls/lib/events.py:605 msgid "Calibration in Progress" msgstr "キャリブレーション" #: selfdrive/controls/lib/events.py:609 msgid "Door Open" msgstr "ドアが開いています" #: selfdrive/controls/lib/events.py:610 msgid "Door open" msgstr "ドアが開いています" #: selfdrive/controls/lib/events.py:614 msgid "Seatbelt Unlatched" msgstr "シートベルト未着用" #: selfdrive/controls/lib/events.py:615 msgid "Seatbelt unlatched" msgstr "シートベルト未着用" #: selfdrive/controls/lib/events.py:619 selfdrive/controls/lib/events.py:620 msgid "ESP Off" msgstr "ESPオフ" #: selfdrive/controls/lib/events.py:624 selfdrive/controls/lib/events.py:625 msgid "Low Battery" msgstr "低バッテリー" #: selfdrive/controls/lib/events.py:629 selfdrive/controls/lib/events.py:630 msgid "Communication Issue between Processes" msgstr "プロセス間の通信の問題" #: selfdrive/controls/lib/events.py:635 selfdrive/controls/lib/events.py:636 msgid "Radar Communication Issue" msgstr "レーダー通信問題" #: selfdrive/controls/lib/events.py:641 selfdrive/controls/lib/events.py:642 #: selfdrive/controls/lib/events.py:646 selfdrive/controls/lib/events.py:647 msgid "Radar Error: Restart the Car" msgstr "レーダーエラー:車を再起動" #: selfdrive/controls/lib/events.py:651 selfdrive/controls/lib/events.py:652 msgid "Driving model lagging" msgstr "制御モデルに遅延がある" #: selfdrive/controls/lib/events.py:656 selfdrive/controls/lib/events.py:657 msgid "Vision Model Output Uncertain" msgstr "映像が不明瞭です" #: selfdrive/controls/lib/events.py:661 selfdrive/controls/lib/events.py:662 msgid "Device Fell Off Mount" msgstr "" #: selfdrive/controls/lib/events.py:666 selfdrive/controls/lib/events.py:672 msgid "Low Memory: Reboot Your Device" msgstr "ローメモリ:デバイスを再起動" #: selfdrive/controls/lib/events.py:668 msgid "RAM Critically Low" msgstr "RAMが致命的に低い" #: selfdrive/controls/lib/events.py:677 selfdrive/controls/lib/events.py:678 msgid "Controls Failed" msgstr "制御失敗" #: selfdrive/controls/lib/events.py:682 msgid "Controls Mismatch" msgstr "制御不一致" #: selfdrive/controls/lib/events.py:686 selfdrive/controls/lib/events.py:688 #: selfdrive/controls/lib/events.py:692 msgid "CAN Error: Check Connections" msgstr "CANエラー:接続を確認" #: selfdrive/controls/lib/events.py:696 selfdrive/controls/lib/events.py:702 msgid "LKAS Fault: Restart the Car" msgstr "LKASの故障:車を再起動" #: selfdrive/controls/lib/events.py:698 msgid "LKAS Fault: Restart the car to engage" msgstr "LKASの故障:車を再起動後発進" #: selfdrive/controls/lib/events.py:706 selfdrive/controls/lib/events.py:712 #: selfdrive/controls/lib/events.py:795 msgid "Cruise Fault: Restart the Car" msgstr "クルーズ失敗:車を再起動" #: selfdrive/controls/lib/events.py:708 selfdrive/controls/lib/events.py:791 msgid "Cruise Fault: Restart the car to engage" msgstr "クルーズ失敗:車を再起動後発進" #: selfdrive/controls/lib/events.py:716 msgid "Gas Fault: Restart the Car" msgstr "アクセル故障:車を再起動" #: selfdrive/controls/lib/events.py:717 msgid "Gas Error: Restart the Car" msgstr "アクセルエラー:車を再起動" #: selfdrive/controls/lib/events.py:722 #, fuzzy msgid "" "Reverse\n" "Gear" msgstr "Rに切り替え" #: selfdrive/controls/lib/events.py:726 msgid "Reverse Gear" msgstr "Rに切り替え" #: selfdrive/controls/lib/events.py:731 msgid "Cruise Is Off" msgstr "クルーズコントロールオフ" #: selfdrive/controls/lib/events.py:735 selfdrive/controls/lib/events.py:736 msgid "Planner Solution Error" msgstr "Planner Solution エラー" #: selfdrive/controls/lib/events.py:740 selfdrive/controls/lib/events.py:742 #: selfdrive/controls/lib/events.py:746 msgid "Harness Malfunction" msgstr "ハーネスが故障" #: selfdrive/controls/lib/events.py:743 msgid "Please Check Hardware" msgstr "ハードウェアを確認して" #: selfdrive/controls/lib/events.py:751 selfdrive/controls/lib/events.py:760 msgid "openpilot Canceled" msgstr "オープンパイロットはキャンセルされました" #: selfdrive/controls/lib/events.py:752 msgid "No close lead car" msgstr "リードカー不在" #: selfdrive/controls/lib/events.py:755 msgid "No Close Lead Car" msgstr "リードカー不在" #: selfdrive/controls/lib/events.py:761 msgid "Speed too low" msgstr "速度が遅すぎる" #: selfdrive/controls/lib/events.py:768 selfdrive/controls/lib/events.py:773 msgid "Speed Too High" msgstr "速度が速すぎる" #: selfdrive/controls/lib/events.py:769 msgid "Slow down to resume operation" msgstr "速度を下げてオープンパイロットを再開" #: selfdrive/controls/lib/events.py:774 msgid "Slow down to engage" msgstr "速度を落として発進" #: selfdrive/controls/lib/events.py:781 msgid "Please connect to Internet" msgstr "インターネット接続を確認" #: selfdrive/controls/lib/events.py:782 msgid "An Update Check Is Required to Engage" msgstr "発進するには更新が必要です" #: selfdrive/controls/lib/events.py:785 msgid "Please Connect to Internet" msgstr "インターネット接続を確認" #: selfdrive/controls/lib/events.py:801 msgid "Left ALC will start in 3s" msgstr "左車線に移動します" #: selfdrive/controls/lib/events.py:809 msgid "Right ALC will start in 3s" msgstr "右車線に移動します" #: selfdrive/controls/lib/events.py:817 msgid "STEERING REQUIRED: Lane Keeping OFF" msgstr "操作が必要:レーンキープオフ" #: selfdrive/controls/lib/events.py:825 msgid "STEERING REQUIRED: Blinkers ON" msgstr "操作が必要:ウインカーオン" #: selfdrive/controls/lib/events.py:833 selfdrive/controls/lib/events.py:838 msgid "Lead Car Is Moving" msgstr "リードカーが移動しました" #: selfdrive/controls/lib/events.py:847 msgid "WARNING" msgstr "" #: selfdrive/controls/lib/events.py:848 msgid "Grab wheel to start bypass" msgstr "" #: selfdrive/controls/lib/events.py:855 msgid "BYPASSING" msgstr "" #: selfdrive/controls/lib/events.py:856 msgid "HOLD WHEEL" msgstr "" #: selfdrive/controls/lib/events.py:863 msgid "Bypassed!" msgstr "" #: selfdrive/controls/lib/events.py:864 msgid "Release wheel when ready" msgstr "" #~ msgid "Drive Above" #~ msgstr "制限速度以上の運転をしてください" ================================================ FILE: selfdrive/assets/locales/ko-KR/LC_MESSAGES/events.po ================================================ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-10-15 13:37+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: ko-KR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: selfdrive/controls/lib/events.py:153 msgid "openpilot Unavailable" msgstr "오픈파일럿 사용불가" #: selfdrive/controls/lib/events.py:160 selfdrive/controls/lib/events.py:167 msgid "TAKE CONTROL IMMEDIATELY" msgstr "핸들을 잡아주세요" #: selfdrive/controls/lib/events.py:187 selfdrive/controls/lib/events.py:328 #: selfdrive/controls/lib/events.py:354 selfdrive/controls/lib/events.py:418 #: selfdrive/controls/lib/events.py:470 selfdrive/controls/lib/events.py:522 #: selfdrive/controls/lib/events.py:532 msgid "TAKE CONTROL" msgstr "핸들을 잡아주세요" #: selfdrive/controls/lib/events.py:188 #, fuzzy, python-format msgid "Steer Unavailable Below %(speed)d %(unit)s" msgstr "%d %s 이하에서는 조향제어가 불가합니다" #: selfdrive/controls/lib/events.py:196 #, fuzzy, python-format msgid "Calibration in Progress: %d%%" msgstr "캘리브레이션 진행중: %d%%" #: selfdrive/controls/lib/events.py:197 #, fuzzy, python-format msgid "Drive Above %(speed)d %(unit)s" msgstr "%(speed)d %(unit)s 이상의 속도로 주행하세요" #: selfdrive/controls/lib/events.py:204 msgid "Poor GPS reception" msgstr "GPS 신호 약함" #: selfdrive/controls/lib/events.py:205 msgid "If sky is visible, contact support" msgstr "환경에 문제가 없을경우 서비스팀에 연락하세요" #: selfdrive/controls/lib/events.py:205 msgid "Check GPS antenna placement" msgstr "GPS안테나 위치를 점검하세요" #: selfdrive/controls/lib/events.py:210 msgid "Cruise Mode Disabled" msgstr "크루즈 모드 꺼짐" #: selfdrive/controls/lib/events.py:212 msgid "Main Switch Off" msgstr "" #: selfdrive/controls/lib/events.py:222 msgid "DEBUG ALERT" msgstr "" #: selfdrive/controls/lib/events.py:230 msgid "Be ready to take over at any time" msgstr "오픈파일럿 사용준비가 되었습니다" #: selfdrive/controls/lib/events.py:231 selfdrive/controls/lib/events.py:239 #: selfdrive/controls/lib/events.py:247 selfdrive/controls/lib/events.py:255 msgid "Always keep hands on wheel and eyes on road" msgstr "안전운전을 위해 항상 핸들을 잡고 도로교통 상황을 주시하세요" #: selfdrive/controls/lib/events.py:238 msgid "WARNING: This branch is not tested" msgstr "경고: 이 Branch는 테스트되지 않았습니다" #: selfdrive/controls/lib/events.py:246 msgid "Dashcam mode" msgstr "대시캠 모드" #: selfdrive/controls/lib/events.py:254 msgid "Dashcam mode for unsupported car" msgstr "안전운전을 위해 항상 핸들을 잡고 도로교통 상황을 주시하세요" #: selfdrive/controls/lib/events.py:262 msgid "Unsupported Giraffe Configuration" msgstr "지원되지 않는 지라프 설정" #: selfdrive/controls/lib/events.py:263 msgid "Visit comma.ai/tg" msgstr "comma.ai/tg 방문하세요" #: selfdrive/controls/lib/events.py:270 msgid "White Panda Is No Longer Supported" msgstr "화이트판다는 더 이상 지원되지 않습니다" #: selfdrive/controls/lib/events.py:271 msgid "Upgrade to comma two or black panda" msgstr "콤마2나 블랙판다로 업그레이드 하세요" #: selfdrive/controls/lib/events.py:274 msgid "White panda is no longer supported" msgstr "화이트판다는 더 이상 지원되지 않습니다" #: selfdrive/controls/lib/events.py:279 msgid "Stock LKAS is turned on" msgstr "차량의 LKAS 기능이 켜져 있습니다" #: selfdrive/controls/lib/events.py:280 msgid "Turn off stock LKAS to engage" msgstr "오픈파일럿 사용을 위해 LKAS를 끄세요" #: selfdrive/controls/lib/events.py:288 msgid "Community Feature Detected" msgstr "커뮤니티 기능 감지됨" #: selfdrive/controls/lib/events.py:289 msgid "Enable Community Features in Developer Settings" msgstr "개발자 설정에서 커뮤니티 기능을 활성화하세요" #: selfdrive/controls/lib/events.py:296 msgid "Dashcam Mode" msgstr "대시캠 모드" #: selfdrive/controls/lib/events.py:297 msgid "Car Unrecognized" msgstr "미인식 차량" #: selfdrive/controls/lib/events.py:304 selfdrive/controls/lib/events.py:312 #: selfdrive/controls/lib/events.py:320 msgid "BRAKE!" msgstr "브레이크!" #: selfdrive/controls/lib/events.py:305 msgid "Stock AEB: Risk of Collision" msgstr "순정 AEB: 충돌 위험" #: selfdrive/controls/lib/events.py:313 msgid "Stock FCW: Risk of Collision" msgstr "순정 FCW: 충돌 위험" #: selfdrive/controls/lib/events.py:321 msgid "Risk of Collision" msgstr "충돌 위험" #: selfdrive/controls/lib/events.py:329 msgid "Lane Departure Detected" msgstr "차선이탈이 감지되었습니다" #: selfdrive/controls/lib/events.py:338 msgid "openpilot will not brake while gas pressed" msgstr "가속중에는 오픈파일럿 브레이크 작동불가" #: selfdrive/controls/lib/events.py:346 msgid "Vehicle Parameter Identification Failed" msgstr "차량 매개 변수 식별 실패" #: selfdrive/controls/lib/events.py:355 selfdrive/controls/lib/events.py:523 #: selfdrive/controls/lib/events.py:526 msgid "Steering Temporarily Unavailable" msgstr "조향제어가 일시적으로 비활성화 되었습니다" #: selfdrive/controls/lib/events.py:362 msgid "KEEP EYES ON ROAD: Driver Distracted" msgstr "도로상황에 주의를 기울이세요" #: selfdrive/controls/lib/events.py:370 msgid "KEEP EYES ON ROAD" msgstr "도로상황에 주의하세요" #: selfdrive/controls/lib/events.py:371 msgid "Driver Appears Distracted" msgstr "전방주시 필요" #: selfdrive/controls/lib/events.py:378 selfdrive/controls/lib/events.py:402 msgid "DISENGAGE IMMEDIATELY" msgstr "경고: 조향제어가 즉시 해제됩니다" #: selfdrive/controls/lib/events.py:379 msgid "Driver Was Distracted" msgstr "운전자 전방주시 불안" #: selfdrive/controls/lib/events.py:386 msgid "TOUCH STEERING WHEEL: No Face Detected" msgstr "핸들을 터치하세요: 모니터링 없음" #: selfdrive/controls/lib/events.py:394 msgid "TOUCH STEERING WHEEL" msgstr "핸들을 터치하세요" #: selfdrive/controls/lib/events.py:395 msgid "Driver Is Unresponsive" msgstr "운전자 모니터링 없음" #: selfdrive/controls/lib/events.py:403 msgid "Driver Was Unresponsive" msgstr "운전자 모니터링 없음" #: selfdrive/controls/lib/events.py:410 msgid "CHECK DRIVER FACE VISIBILITY" msgstr "운전자 얼굴 확인 중" #: selfdrive/controls/lib/events.py:411 msgid "Driver Monitor Model Output Uncertain" msgstr "운전자 얼굴 인식이 어렵습니다" #: selfdrive/controls/lib/events.py:419 msgid "Resume Driving Manually" msgstr "수동으로 재출발 하세요" #: selfdrive/controls/lib/events.py:426 msgid "STOPPED" msgstr "잠시멈춤" #: selfdrive/controls/lib/events.py:427 msgid "Press Resume to Move" msgstr "재출발을 위해 RES버튼을 누르세요" #: selfdrive/controls/lib/events.py:438 msgid "Steer Left to Start Lane Change" msgstr "차선 변경을 위해 핸들을 좌측으로 살짝 돌리세요" #: selfdrive/controls/lib/events.py:439 selfdrive/controls/lib/events.py:447 #: selfdrive/controls/lib/events.py:455 selfdrive/controls/lib/events.py:463 #: selfdrive/controls/lib/events.py:802 selfdrive/controls/lib/events.py:810 msgid "Monitor Other Vehicles" msgstr "다른 차량에 주의하세요" #: selfdrive/controls/lib/events.py:446 msgid "Steer Right to Start Lane Change" msgstr "차선 변경을 위해 핸들을 우측으로 살짝 돌리세요" #: selfdrive/controls/lib/events.py:454 msgid "Car Detected in Blindspot" msgstr "측면 차량 접근 중" #: selfdrive/controls/lib/events.py:462 msgid "Changing Lane" msgstr "차선 변경 중" #: selfdrive/controls/lib/events.py:471 msgid "Turn Exceeds Steering Limit" msgstr "" #: selfdrive/controls/lib/events.py:496 msgid "Brake Hold Active" msgstr "브레이크 홀드 중" #: selfdrive/controls/lib/events.py:501 msgid "Park Brake Engaged" msgstr "파킹브레이크 체결 됨" #: selfdrive/controls/lib/events.py:506 msgid "Pedal Pressed During Attempt" msgstr "시작 중 페달 밟음" #: selfdrive/controls/lib/events.py:517 msgid "Enable Adaptive Cruise" msgstr "어댑티브 크루즈를 활성화하세요" #: selfdrive/controls/lib/events.py:533 msgid "Attempting Refocus: Camera Focus Invalid" msgstr "카메라 포커스 조정중: 카메라 포커스 부정확" #: selfdrive/controls/lib/events.py:539 msgid "Out of Storage Space" msgstr "저장공간 부족" #: selfdrive/controls/lib/events.py:544 msgid "Speed Too Low" msgstr "차량의 속도 낮음" #: selfdrive/controls/lib/events.py:549 selfdrive/controls/lib/events.py:553 msgid "NEOS Update Required" msgstr "NEOS 업데이트 필요" #: selfdrive/controls/lib/events.py:550 msgid "Please Wait for Update" msgstr "업데이트를 위해 기다리세요" #: selfdrive/controls/lib/events.py:558 selfdrive/controls/lib/events.py:562 msgid "No Data from Device Sensors" msgstr "EON센서로부터 데이터를 받지 못했습니다" #: selfdrive/controls/lib/events.py:559 selfdrive/controls/lib/events.py:572 #: selfdrive/controls/lib/events.py:669 msgid "Reboot your Device" msgstr "장치를 재시작 하세요" #: selfdrive/controls/lib/events.py:571 selfdrive/controls/lib/events.py:575 msgid "Speaker not found" msgstr "스피커를 찾을 수 없습니다" #: selfdrive/controls/lib/events.py:579 msgid "Distraction Level Too High" msgstr "운전자 전방주시 매우 불안" #: selfdrive/controls/lib/events.py:583 msgid "System Overheated" msgstr "시스템이 과열되었습니다" #: selfdrive/controls/lib/events.py:584 msgid "System overheated" msgstr "시스템이 과열되었습니다" #: selfdrive/controls/lib/events.py:588 selfdrive/controls/lib/events.py:589 msgid "Gear not D" msgstr "기어가 드라이브모드가 아닙니다" #: selfdrive/controls/lib/events.py:594 #, fuzzy msgid "Calibration Invalid" msgstr "캘리브레이션 진행 중" #: selfdrive/controls/lib/events.py:595 #, fuzzy msgid "Reposition Device and Recalibrate" msgstr "캘리브레이션 유효하지 않음: 장치 위치 조정 및 재 캘리브레이션" #: selfdrive/controls/lib/events.py:598 selfdrive/controls/lib/events.py:599 msgid "Calibration Invalid: Reposition Device & Recalibrate" msgstr "캘리브레이션 유효하지 않음: 장치 위치 조정 및 재 캘리브레이션" #: selfdrive/controls/lib/events.py:603 selfdrive/controls/lib/events.py:605 msgid "Calibration in Progress" msgstr "캘리브레이션 진행 중" #: selfdrive/controls/lib/events.py:609 msgid "Door Open" msgstr "도어가 열려있습니다" #: selfdrive/controls/lib/events.py:610 msgid "Door open" msgstr "도어가 열려있습니다" #: selfdrive/controls/lib/events.py:614 msgid "Seatbelt Unlatched" msgstr "안전벨트를 체결하세요" #: selfdrive/controls/lib/events.py:615 msgid "Seatbelt unlatched" msgstr "안전벨트를 체결하세요" #: selfdrive/controls/lib/events.py:619 selfdrive/controls/lib/events.py:620 msgid "ESP Off" msgstr "ESP 꺼짐" #: selfdrive/controls/lib/events.py:624 selfdrive/controls/lib/events.py:625 msgid "Low Battery" msgstr "배터리 부족" #: selfdrive/controls/lib/events.py:629 selfdrive/controls/lib/events.py:630 msgid "Communication Issue between Processes" msgstr "프로세스 간 통신 오류가 있습니다" #: selfdrive/controls/lib/events.py:635 selfdrive/controls/lib/events.py:636 msgid "Radar Communication Issue" msgstr "레이더 오류: 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:641 selfdrive/controls/lib/events.py:642 #: selfdrive/controls/lib/events.py:646 selfdrive/controls/lib/events.py:647 msgid "Radar Error: Restart the Car" msgstr "레이더 오류: 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:651 selfdrive/controls/lib/events.py:652 msgid "Driving model lagging" msgstr "주행 모델 지연" #: selfdrive/controls/lib/events.py:656 selfdrive/controls/lib/events.py:657 msgid "Vision Model Output Uncertain" msgstr "전방 영상 인식 불안" #: selfdrive/controls/lib/events.py:661 selfdrive/controls/lib/events.py:662 msgid "Device Fell Off Mount" msgstr "" #: selfdrive/controls/lib/events.py:666 selfdrive/controls/lib/events.py:672 msgid "Low Memory: Reboot Your Device" msgstr "메모리 부족: 장치를 재시작하세요" #: selfdrive/controls/lib/events.py:668 msgid "RAM Critically Low" msgstr "메모리 부족 심각" #: selfdrive/controls/lib/events.py:677 selfdrive/controls/lib/events.py:678 msgid "Controls Failed" msgstr "차량제어 불가" #: selfdrive/controls/lib/events.py:682 msgid "Controls Mismatch" msgstr "" #: selfdrive/controls/lib/events.py:686 selfdrive/controls/lib/events.py:688 #: selfdrive/controls/lib/events.py:692 msgid "CAN Error: Check Connections" msgstr "CAN 오류: CAN 신호를 확인하세요" #: selfdrive/controls/lib/events.py:696 selfdrive/controls/lib/events.py:702 msgid "LKAS Fault: Restart the Car" msgstr "LKAS 오류: 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:698 msgid "LKAS Fault: Restart the car to engage" msgstr "LKAS 오류: 시작을 위해 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:706 selfdrive/controls/lib/events.py:712 #: selfdrive/controls/lib/events.py:795 msgid "Cruise Fault: Restart the Car" msgstr "크루즈 오류: 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:708 selfdrive/controls/lib/events.py:791 msgid "Cruise Fault: Restart the car to engage" msgstr "크루즈 오류: 시작을 위해 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:716 msgid "Gas Fault: Restart the Car" msgstr "가속페달 오류: 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:717 msgid "Gas Error: Restart the Car" msgstr "가속페달 오류: 차량을 재시작하세요" #: selfdrive/controls/lib/events.py:722 #, fuzzy msgid "" "Reverse\n" "Gear" msgstr "후진 기어" #: selfdrive/controls/lib/events.py:726 msgid "Reverse Gear" msgstr "후진 기어" #: selfdrive/controls/lib/events.py:731 msgid "Cruise Is Off" msgstr "크루즈 꺼짐" #: selfdrive/controls/lib/events.py:735 selfdrive/controls/lib/events.py:736 msgid "Planner Solution Error" msgstr "" #: selfdrive/controls/lib/events.py:740 selfdrive/controls/lib/events.py:742 #: selfdrive/controls/lib/events.py:746 msgid "Harness Malfunction" msgstr "하네스 오작동" #: selfdrive/controls/lib/events.py:743 msgid "Please Check Hardware" msgstr "장치를 점검하세요" #: selfdrive/controls/lib/events.py:751 selfdrive/controls/lib/events.py:760 msgid "openpilot Canceled" msgstr "오픈파일럿 시작불가" #: selfdrive/controls/lib/events.py:752 msgid "No close lead car" msgstr "선행차량이 없습니다" #: selfdrive/controls/lib/events.py:755 msgid "No Close Lead Car" msgstr "선행차량이 없습니다" #: selfdrive/controls/lib/events.py:761 msgid "Speed too low" msgstr "선행차량이 없습니다" #: selfdrive/controls/lib/events.py:768 selfdrive/controls/lib/events.py:773 msgid "Speed Too High" msgstr "속도가 너무 높습니다" #: selfdrive/controls/lib/events.py:769 msgid "Slow down to resume operation" msgstr "재 작동을 위해 차량의 속도를 낮추세요" #: selfdrive/controls/lib/events.py:774 msgid "Slow down to engage" msgstr "시작을 위해 차량의 속도를 낮추세요" #: selfdrive/controls/lib/events.py:781 msgid "Please connect to Internet" msgstr "인터넷에 연결하세요" #: selfdrive/controls/lib/events.py:782 msgid "An Update Check Is Required to Engage" msgstr "시작을 위해 업데이트를 확인해야 합니다" #: selfdrive/controls/lib/events.py:785 msgid "Please Connect to Internet" msgstr "인터넷에 연결하세요" #: selfdrive/controls/lib/events.py:801 msgid "Left ALC will start in 3s" msgstr "" #: selfdrive/controls/lib/events.py:809 msgid "Right ALC will start in 3s" msgstr "" #: selfdrive/controls/lib/events.py:817 msgid "STEERING REQUIRED: Lane Keeping OFF" msgstr "" #: selfdrive/controls/lib/events.py:825 msgid "STEERING REQUIRED: Blinkers ON" msgstr "" #: selfdrive/controls/lib/events.py:833 selfdrive/controls/lib/events.py:838 msgid "Lead Car Is Moving" msgstr "" #: selfdrive/controls/lib/events.py:847 msgid "WARNING" msgstr "" #: selfdrive/controls/lib/events.py:848 msgid "Grab wheel to start bypass" msgstr "" #: selfdrive/controls/lib/events.py:855 msgid "BYPASSING" msgstr "" #: selfdrive/controls/lib/events.py:856 msgid "HOLD WHEEL" msgstr "" #: selfdrive/controls/lib/events.py:863 msgid "Bypassed!" msgstr "" #: selfdrive/controls/lib/events.py:864 msgid "Release wheel when ready" msgstr "" ================================================ FILE: selfdrive/assets/locales/zh-CN/LC_MESSAGES/events.po ================================================ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-10-15 13:37+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Rick Lan \n" "Language-Team: LANGUAGE \n" "Language: zh-CN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: selfdrive/controls/lib/events.py:153 msgid "openpilot Unavailable" msgstr "无法使用 openpilot" #: selfdrive/controls/lib/events.py:160 selfdrive/controls/lib/events.py:167 msgid "TAKE CONTROL IMMEDIATELY" msgstr "即刻接管控制" #: selfdrive/controls/lib/events.py:187 selfdrive/controls/lib/events.py:328 #: selfdrive/controls/lib/events.py:354 selfdrive/controls/lib/events.py:418 #: selfdrive/controls/lib/events.py:470 selfdrive/controls/lib/events.py:522 #: selfdrive/controls/lib/events.py:532 msgid "TAKE CONTROL" msgstr "接管控制" #: selfdrive/controls/lib/events.py:188 #, fuzzy, python-format msgid "Steer Unavailable Below %(speed)d %(unit)s" msgstr "横向控制暂时失效,车速低于 %d %s" #: selfdrive/controls/lib/events.py:196 #, fuzzy, python-format msgid "Calibration in Progress: %d%%" msgstr "正在校准中:%d%%" #: selfdrive/controls/lib/events.py:197 #, fuzzy, python-format msgid "Drive Above %(speed)d %(unit)s" msgstr "车速请高于 %(speed)d %(unit)s" #: selfdrive/controls/lib/events.py:204 msgid "Poor GPS reception" msgstr "GPS 讯号不良" #: selfdrive/controls/lib/events.py:205 msgid "If sky is visible, contact support" msgstr "如果您不在地下室/隧道,请联系客服" #: selfdrive/controls/lib/events.py:205 msgid "Check GPS antenna placement" msgstr "请检查 GPS 天线位置" #: selfdrive/controls/lib/events.py:210 msgid "Cruise Mode Disabled" msgstr "巡航模式关闭" #: selfdrive/controls/lib/events.py:212 msgid "Main Switch Off" msgstr "主开关已关闭" #: selfdrive/controls/lib/events.py:222 msgid "DEBUG ALERT" msgstr "除错用警示讯息" #: selfdrive/controls/lib/events.py:230 msgid "Be ready to take over at any time" msgstr "请准备好随时接管" #: selfdrive/controls/lib/events.py:231 selfdrive/controls/lib/events.py:239 #: selfdrive/controls/lib/events.py:247 selfdrive/controls/lib/events.py:255 msgid "Always keep hands on wheel and eyes on road" msgstr "将手放在方向盘上并持续监视路况" #: selfdrive/controls/lib/events.py:238 msgid "WARNING: This branch is not tested" msgstr "注意:这个分支未经过测试" #: selfdrive/controls/lib/events.py:246 msgid "Dashcam mode" msgstr "行车记录模式" #: selfdrive/controls/lib/events.py:254 msgid "Dashcam mode for unsupported car" msgstr "行车记录模式 (尚未支援车种)" #: selfdrive/controls/lib/events.py:262 msgid "Unsupported Giraffe Configuration" msgstr "未支援的 Giraffe 设置" #: selfdrive/controls/lib/events.py:263 msgid "Visit comma.ai/tg" msgstr "请查阅 comma.ai/tg" #: selfdrive/controls/lib/events.py:270 msgid "White Panda Is No Longer Supported" msgstr "不再支持 White Panda" #: selfdrive/controls/lib/events.py:271 msgid "Upgrade to comma two or black panda" msgstr "请升级至 comma two 或是使用 black panda" #: selfdrive/controls/lib/events.py:274 msgid "White panda is no longer supported" msgstr "不再支持 White panda" #: selfdrive/controls/lib/events.py:279 msgid "Stock LKAS is turned on" msgstr "原厂 LKAS 已开启" #: selfdrive/controls/lib/events.py:280 msgid "Turn off stock LKAS to engage" msgstr "需关闭原厂 LKAS 才能启用" #: selfdrive/controls/lib/events.py:288 msgid "Community Feature Detected" msgstr "检测到社群开发功能" #: selfdrive/controls/lib/events.py:289 msgid "Enable Community Features in Developer Settings" msgstr "请至开发人员设定裡启用社群开发功能" #: selfdrive/controls/lib/events.py:296 msgid "Dashcam Mode" msgstr "行车记录模式" #: selfdrive/controls/lib/events.py:297 msgid "Car Unrecognized" msgstr "无法辨识车款" #: selfdrive/controls/lib/events.py:304 selfdrive/controls/lib/events.py:312 #: selfdrive/controls/lib/events.py:320 msgid "BRAKE!" msgstr "刹车!" #: selfdrive/controls/lib/events.py:305 msgid "Stock AEB: Risk of Collision" msgstr "有碰撞的风险" #: selfdrive/controls/lib/events.py:313 msgid "Stock FCW: Risk of Collision" msgstr "有碰撞的风险" #: selfdrive/controls/lib/events.py:321 msgid "Risk of Collision" msgstr "有碰撞的风险" #: selfdrive/controls/lib/events.py:329 msgid "Lane Departure Detected" msgstr "偏离车道" #: selfdrive/controls/lib/events.py:338 msgid "openpilot will not brake while gas pressed" msgstr "在您踩着油门的时候 openpilot 将不会刹车" #: selfdrive/controls/lib/events.py:346 msgid "Vehicle Parameter Identification Failed" msgstr "车子参数识别失败" #: selfdrive/controls/lib/events.py:355 selfdrive/controls/lib/events.py:523 #: selfdrive/controls/lib/events.py:526 msgid "Steering Temporarily Unavailable" msgstr "横向控制暂时失效" #: selfdrive/controls/lib/events.py:362 msgid "KEEP EYES ON ROAD: Driver Distracted" msgstr "注意路况:驾驶分心" #: selfdrive/controls/lib/events.py:370 msgid "KEEP EYES ON ROAD" msgstr "注意路况" #: selfdrive/controls/lib/events.py:371 msgid "Driver Appears Distracted" msgstr "驾驶分心" #: selfdrive/controls/lib/events.py:378 selfdrive/controls/lib/events.py:402 msgid "DISENGAGE IMMEDIATELY" msgstr "立即解除" #: selfdrive/controls/lib/events.py:379 msgid "Driver Was Distracted" msgstr "驾驶分心" #: selfdrive/controls/lib/events.py:386 msgid "TOUCH STEERING WHEEL: No Face Detected" msgstr "请触碰方向盘:未侦测到驾驶面容" #: selfdrive/controls/lib/events.py:394 msgid "TOUCH STEERING WHEEL" msgstr "请触碰方向盘" #: selfdrive/controls/lib/events.py:395 msgid "Driver Is Unresponsive" msgstr "驾驶没有反应" #: selfdrive/controls/lib/events.py:403 msgid "Driver Was Unresponsive" msgstr "驾驶没有反应" #: selfdrive/controls/lib/events.py:410 msgid "CHECK DRIVER FACE VISIBILITY" msgstr "请检查驾驶面部的可见度" #: selfdrive/controls/lib/events.py:411 msgid "Driver Monitor Model Output Uncertain" msgstr "驾驶监控模型判断不明确" #: selfdrive/controls/lib/events.py:419 msgid "Resume Driving Manually" msgstr "请自行恢復驾驶" #: selfdrive/controls/lib/events.py:426 msgid "STOPPED" msgstr "已停止" #: selfdrive/controls/lib/events.py:427 msgid "Press Resume to Move" msgstr "请按 RES 继续" #: selfdrive/controls/lib/events.py:438 msgid "Steer Left to Start Lane Change" msgstr "请往左打方向盘切换至左车道" #: selfdrive/controls/lib/events.py:439 selfdrive/controls/lib/events.py:447 #: selfdrive/controls/lib/events.py:455 selfdrive/controls/lib/events.py:463 #: selfdrive/controls/lib/events.py:802 selfdrive/controls/lib/events.py:810 msgid "Monitor Other Vehicles" msgstr "请注意其它车辆" #: selfdrive/controls/lib/events.py:446 msgid "Steer Right to Start Lane Change" msgstr "请往右打方向盘切换至右车道" #: selfdrive/controls/lib/events.py:454 msgid "Car Detected in Blindspot" msgstr "盲点侦测到车辆" #: selfdrive/controls/lib/events.py:462 msgid "Changing Lane" msgstr "切换车道中" #: selfdrive/controls/lib/events.py:471 msgid "Turn Exceeds Steering Limit" msgstr "弯道超过横向操控限制" #: selfdrive/controls/lib/events.py:496 msgid "Brake Hold Active" msgstr "驻车煞车已启用" #: selfdrive/controls/lib/events.py:501 msgid "Park Brake Engaged" msgstr "电子驻车已启动" #: selfdrive/controls/lib/events.py:506 msgid "Pedal Pressed During Attempt" msgstr "启用时侦测到驾驶踩踏油门/刹车" #: selfdrive/controls/lib/events.py:517 msgid "Enable Adaptive Cruise" msgstr "启用自适应巡航" #: selfdrive/controls/lib/events.py:533 msgid "Attempting Refocus: Camera Focus Invalid" msgstr "尝试对焦:相机已失焦" #: selfdrive/controls/lib/events.py:539 msgid "Out of Storage Space" msgstr "存储空间不足" #: selfdrive/controls/lib/events.py:544 msgid "Speed Too Low" msgstr "车速过慢" #: selfdrive/controls/lib/events.py:549 selfdrive/controls/lib/events.py:553 msgid "NEOS Update Required" msgstr "NEOS 需要更新" #: selfdrive/controls/lib/events.py:550 msgid "Please Wait for Update" msgstr "更新中请稍候" #: selfdrive/controls/lib/events.py:558 selfdrive/controls/lib/events.py:562 msgid "No Data from Device Sensors" msgstr "未收到装置传感器数据" #: selfdrive/controls/lib/events.py:559 selfdrive/controls/lib/events.py:572 #: selfdrive/controls/lib/events.py:669 msgid "Reboot your Device" msgstr "请重启装置" #: selfdrive/controls/lib/events.py:571 selfdrive/controls/lib/events.py:575 msgid "Speaker not found" msgstr "找不到音效装置" #: selfdrive/controls/lib/events.py:579 msgid "Distraction Level Too High" msgstr "驾驶分心太多次" #: selfdrive/controls/lib/events.py:583 msgid "System Overheated" msgstr "系统过热" #: selfdrive/controls/lib/events.py:584 msgid "System overheated" msgstr "系统过热" #: selfdrive/controls/lib/events.py:588 selfdrive/controls/lib/events.py:589 msgid "Gear not D" msgstr "不在 D 档位" #: selfdrive/controls/lib/events.py:594 #, fuzzy msgid "Calibration Invalid" msgstr "正在校准中" #: selfdrive/controls/lib/events.py:595 #, fuzzy msgid "Reposition Device and Recalibrate" msgstr "校准无效:请将装置放于新的位置并重新校准" #: selfdrive/controls/lib/events.py:598 selfdrive/controls/lib/events.py:599 msgid "Calibration Invalid: Reposition Device & Recalibrate" msgstr "校准无效:请将装置放于新的位置并重新校准" #: selfdrive/controls/lib/events.py:603 selfdrive/controls/lib/events.py:605 msgid "Calibration in Progress" msgstr "正在校准中" #: selfdrive/controls/lib/events.py:609 msgid "Door Open" msgstr "车门开启" #: selfdrive/controls/lib/events.py:610 msgid "Door open" msgstr "车门未关" #: selfdrive/controls/lib/events.py:614 msgid "Seatbelt Unlatched" msgstr "安全带未繫" #: selfdrive/controls/lib/events.py:615 msgid "Seatbelt unlatched" msgstr "安全带未繫" #: selfdrive/controls/lib/events.py:619 selfdrive/controls/lib/events.py:620 msgid "ESP Off" msgstr "ESP 关闭" #: selfdrive/controls/lib/events.py:624 selfdrive/controls/lib/events.py:625 msgid "Low Battery" msgstr "电量过低" #: selfdrive/controls/lib/events.py:629 selfdrive/controls/lib/events.py:630 msgid "Communication Issue between Processes" msgstr "行程间出现通讯问题" #: selfdrive/controls/lib/events.py:635 selfdrive/controls/lib/events.py:636 msgid "Radar Communication Issue" msgstr "雷达通讯出现问题" #: selfdrive/controls/lib/events.py:641 selfdrive/controls/lib/events.py:642 #: selfdrive/controls/lib/events.py:646 selfdrive/controls/lib/events.py:647 msgid "Radar Error: Restart the Car" msgstr "雷达讯号错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:651 selfdrive/controls/lib/events.py:652 msgid "Driving model lagging" msgstr "操控模型有延迟" #: selfdrive/controls/lib/events.py:656 selfdrive/controls/lib/events.py:657 msgid "Vision Model Output Uncertain" msgstr "视觉模型判断不明确" #: selfdrive/controls/lib/events.py:661 selfdrive/controls/lib/events.py:662 msgid "Device Fell Off Mount" msgstr "装置掉落侦测" #: selfdrive/controls/lib/events.py:666 selfdrive/controls/lib/events.py:672 msgid "Low Memory: Reboot Your Device" msgstr "记忆体不足:请重启您的装置" #: selfdrive/controls/lib/events.py:668 msgid "RAM Critically Low" msgstr "记忆体严重不足" #: selfdrive/controls/lib/events.py:677 selfdrive/controls/lib/events.py:678 msgid "Controls Failed" msgstr "控制发生错误" #: selfdrive/controls/lib/events.py:682 msgid "Controls Mismatch" msgstr "控制不匹配" #: selfdrive/controls/lib/events.py:686 selfdrive/controls/lib/events.py:688 #: selfdrive/controls/lib/events.py:692 msgid "CAN Error: Check Connections" msgstr "CAN 讯号错误:请检查线路" #: selfdrive/controls/lib/events.py:696 selfdrive/controls/lib/events.py:702 msgid "LKAS Fault: Restart the Car" msgstr "LKAS 错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:698 msgid "LKAS Fault: Restart the car to engage" msgstr "LKAS 错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:706 selfdrive/controls/lib/events.py:712 #: selfdrive/controls/lib/events.py:795 msgid "Cruise Fault: Restart the Car" msgstr "巡航系统错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:708 selfdrive/controls/lib/events.py:791 msgid "Cruise Fault: Restart the car to engage" msgstr "巡航系统错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:716 msgid "Gas Fault: Restart the Car" msgstr "油门错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:717 msgid "Gas Error: Restart the Car" msgstr "油门错误:请重新发动车辆" #: selfdrive/controls/lib/events.py:722 #, fuzzy msgid "" "Reverse\n" "Gear" msgstr "切换至倒车档" #: selfdrive/controls/lib/events.py:726 msgid "Reverse Gear" msgstr "切换至倒车档" #: selfdrive/controls/lib/events.py:731 msgid "Cruise Is Off" msgstr "巡航系统关闭" #: selfdrive/controls/lib/events.py:735 selfdrive/controls/lib/events.py:736 msgid "Planner Solution Error" msgstr "Planner Solution 错误" #: selfdrive/controls/lib/events.py:740 selfdrive/controls/lib/events.py:742 #: selfdrive/controls/lib/events.py:746 msgid "Harness Malfunction" msgstr "Harness 故障" #: selfdrive/controls/lib/events.py:743 msgid "Please Check Hardware" msgstr "请检查硬体" #: selfdrive/controls/lib/events.py:751 selfdrive/controls/lib/events.py:760 msgid "openpilot Canceled" msgstr "openpilot 已取消" #: selfdrive/controls/lib/events.py:752 msgid "No close lead car" msgstr "前方没有车辆" #: selfdrive/controls/lib/events.py:755 msgid "No Close Lead Car" msgstr "前方没有车辆" #: selfdrive/controls/lib/events.py:761 msgid "Speed too low" msgstr "车速过慢" #: selfdrive/controls/lib/events.py:768 selfdrive/controls/lib/events.py:773 msgid "Speed Too High" msgstr "车速过快" #: selfdrive/controls/lib/events.py:769 msgid "Slow down to resume operation" msgstr "请减速后再启用" #: selfdrive/controls/lib/events.py:774 msgid "Slow down to engage" msgstr "请减速后再启用" #: selfdrive/controls/lib/events.py:781 msgid "Please connect to Internet" msgstr "请连接网路" #: selfdrive/controls/lib/events.py:782 msgid "An Update Check Is Required to Engage" msgstr "需检查更新后才能启用" #: selfdrive/controls/lib/events.py:785 msgid "Please Connect to Internet" msgstr "请连接网路" #: selfdrive/controls/lib/events.py:801 msgid "Left ALC will start in 3s" msgstr "准备自动切至左车道" #: selfdrive/controls/lib/events.py:809 msgid "Right ALC will start in 3s" msgstr "准备自动切至右车道" #: selfdrive/controls/lib/events.py:817 msgid "STEERING REQUIRED: Lane Keeping OFF" msgstr "请接管方向盘:车道维持关闭" #: selfdrive/controls/lib/events.py:825 msgid "STEERING REQUIRED: Blinkers ON" msgstr "请接管方向盘:方向灯开启" #: selfdrive/controls/lib/events.py:833 selfdrive/controls/lib/events.py:838 msgid "Lead Car Is Moving" msgstr "前方车辆车移动中" #: selfdrive/controls/lib/events.py:847 msgid "WARNING" msgstr "警告" #: selfdrive/controls/lib/events.py:848 msgid "Grab wheel to start bypass" msgstr "请握好方向盘以绕过时间限制" #: selfdrive/controls/lib/events.py:855 msgid "BYPASSING" msgstr "绕过时间限制中" #: selfdrive/controls/lib/events.py:856 msgid "HOLD WHEEL" msgstr "握好方向盘" #: selfdrive/controls/lib/events.py:863 msgid "Bypassed!" msgstr "时间限制已绕过" #: selfdrive/controls/lib/events.py:864 msgid "Release wheel when ready" msgstr "准备好后请松开放向盘" ================================================ FILE: selfdrive/assets/locales/zh-TW/LC_MESSAGES/events.po ================================================ # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-10-15 13:37+1000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Rick Lan \n" "Language-Team: LANGUAGE \n" "Language: zh-TW\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: selfdrive/controls/lib/events.py:153 msgid "openpilot Unavailable" msgstr "無法使用 openpilot" #: selfdrive/controls/lib/events.py:160 selfdrive/controls/lib/events.py:167 msgid "TAKE CONTROL IMMEDIATELY" msgstr "即刻接管控制" #: selfdrive/controls/lib/events.py:187 selfdrive/controls/lib/events.py:328 #: selfdrive/controls/lib/events.py:354 selfdrive/controls/lib/events.py:418 #: selfdrive/controls/lib/events.py:470 selfdrive/controls/lib/events.py:522 #: selfdrive/controls/lib/events.py:532 msgid "TAKE CONTROL" msgstr "接管控制" #: selfdrive/controls/lib/events.py:188 #, fuzzy, python-format msgid "Steer Unavailable Below %(speed)d %(unit)s" msgstr "橫向控制暫時失效,車速低於 %d %s" #: selfdrive/controls/lib/events.py:196 #, fuzzy, python-format msgid "Calibration in Progress: %d%%" msgstr "正在校準中:%d%%" #: selfdrive/controls/lib/events.py:197 #, fuzzy, python-format msgid "Drive Above %(speed)d %(unit)s" msgstr "車速請高於 %(speed)d %(unit)s" #: selfdrive/controls/lib/events.py:204 msgid "Poor GPS reception" msgstr "GPS 訊號不良" #: selfdrive/controls/lib/events.py:205 msgid "If sky is visible, contact support" msgstr "如果您不在地下室/隧道,請聯系客服" #: selfdrive/controls/lib/events.py:205 msgid "Check GPS antenna placement" msgstr "請檢查 GPS 天線位置" #: selfdrive/controls/lib/events.py:210 msgid "Cruise Mode Disabled" msgstr "巡航模式關閉" #: selfdrive/controls/lib/events.py:212 msgid "Main Switch Off" msgstr "主開關已關閉" #: selfdrive/controls/lib/events.py:222 msgid "DEBUG ALERT" msgstr "除錯用警示訊息" #: selfdrive/controls/lib/events.py:230 msgid "Be ready to take over at any time" msgstr "請準備好隨時接管" #: selfdrive/controls/lib/events.py:231 selfdrive/controls/lib/events.py:239 #: selfdrive/controls/lib/events.py:247 selfdrive/controls/lib/events.py:255 msgid "Always keep hands on wheel and eyes on road" msgstr "將手放在方向盤上並持續監視路況" #: selfdrive/controls/lib/events.py:238 msgid "WARNING: This branch is not tested" msgstr "注意:這個分支未經過測試" #: selfdrive/controls/lib/events.py:246 msgid "Dashcam mode" msgstr "行車記錄模式" #: selfdrive/controls/lib/events.py:254 msgid "Dashcam mode for unsupported car" msgstr "行車記錄模式 (尚未支援車種)" #: selfdrive/controls/lib/events.py:262 msgid "Unsupported Giraffe Configuration" msgstr "未支援的 Giraffe 設置" #: selfdrive/controls/lib/events.py:263 msgid "Visit comma.ai/tg" msgstr "請查閱 comma.ai/tg" #: selfdrive/controls/lib/events.py:270 msgid "White Panda Is No Longer Supported" msgstr "不再支援 White Panda" #: selfdrive/controls/lib/events.py:271 msgid "Upgrade to comma two or black panda" msgstr "請升級至 comma two 或是使用 black panda" #: selfdrive/controls/lib/events.py:274 msgid "White panda is no longer supported" msgstr "不再支援 White panda" #: selfdrive/controls/lib/events.py:279 msgid "Stock LKAS is turned on" msgstr "原廠 LKAS 已開啟" #: selfdrive/controls/lib/events.py:280 msgid "Turn off stock LKAS to engage" msgstr "需關閉原廠 LKAS 才能啟用" #: selfdrive/controls/lib/events.py:288 msgid "Community Feature Detected" msgstr "檢測到社群開發功能" #: selfdrive/controls/lib/events.py:289 msgid "Enable Community Features in Developer Settings" msgstr "請至開發人員設定裡啟用社群開發功能" #: selfdrive/controls/lib/events.py:296 msgid "Dashcam Mode" msgstr "行車記錄模式" #: selfdrive/controls/lib/events.py:297 msgid "Car Unrecognized" msgstr "無法辨識車款" #: selfdrive/controls/lib/events.py:304 selfdrive/controls/lib/events.py:312 #: selfdrive/controls/lib/events.py:320 msgid "BRAKE!" msgstr "剎車!" #: selfdrive/controls/lib/events.py:305 msgid "Stock AEB: Risk of Collision" msgstr "有碰撞的風險" #: selfdrive/controls/lib/events.py:313 msgid "Stock FCW: Risk of Collision" msgstr "有碰撞的風險" #: selfdrive/controls/lib/events.py:321 msgid "Risk of Collision" msgstr "有碰撞的風險" #: selfdrive/controls/lib/events.py:329 msgid "Lane Departure Detected" msgstr "偏離車道" #: selfdrive/controls/lib/events.py:338 msgid "openpilot will not brake while gas pressed" msgstr "在您踩著油門的時候 openpilot 將不會剎車" #: selfdrive/controls/lib/events.py:346 msgid "Vehicle Parameter Identification Failed" msgstr "車子參數識別失敗" #: selfdrive/controls/lib/events.py:355 selfdrive/controls/lib/events.py:523 #: selfdrive/controls/lib/events.py:526 msgid "Steering Temporarily Unavailable" msgstr "橫向控制暫時失效" #: selfdrive/controls/lib/events.py:362 msgid "KEEP EYES ON ROAD: Driver Distracted" msgstr "注意路況:駕駛分心" #: selfdrive/controls/lib/events.py:370 msgid "KEEP EYES ON ROAD" msgstr "注意路況" #: selfdrive/controls/lib/events.py:371 msgid "Driver Appears Distracted" msgstr "駕駛分心" #: selfdrive/controls/lib/events.py:378 selfdrive/controls/lib/events.py:402 msgid "DISENGAGE IMMEDIATELY" msgstr "立即解除" #: selfdrive/controls/lib/events.py:379 msgid "Driver Was Distracted" msgstr "駕駛分心" #: selfdrive/controls/lib/events.py:386 msgid "TOUCH STEERING WHEEL: No Face Detected" msgstr "請觸碰方向盤:未偵測到駕駛面容" #: selfdrive/controls/lib/events.py:394 msgid "TOUCH STEERING WHEEL" msgstr "請觸碰方向盤" #: selfdrive/controls/lib/events.py:395 msgid "Driver Is Unresponsive" msgstr "駕駛沒有反應" #: selfdrive/controls/lib/events.py:403 msgid "Driver Was Unresponsive" msgstr "駕駛沒有反應" #: selfdrive/controls/lib/events.py:410 msgid "CHECK DRIVER FACE VISIBILITY" msgstr "請檢查駕駛面部的可見度" #: selfdrive/controls/lib/events.py:411 msgid "Driver Monitor Model Output Uncertain" msgstr "駕駛監控模型判斷不明確" #: selfdrive/controls/lib/events.py:419 msgid "Resume Driving Manually" msgstr "請自行恢復駕駛" #: selfdrive/controls/lib/events.py:426 msgid "STOPPED" msgstr "已停止" #: selfdrive/controls/lib/events.py:427 msgid "Press Resume to Move" msgstr "請按 RES 繼續" #: selfdrive/controls/lib/events.py:438 msgid "Steer Left to Start Lane Change" msgstr "請往左打方向盤切換至左車道" #: selfdrive/controls/lib/events.py:439 selfdrive/controls/lib/events.py:447 #: selfdrive/controls/lib/events.py:455 selfdrive/controls/lib/events.py:463 #: selfdrive/controls/lib/events.py:802 selfdrive/controls/lib/events.py:810 msgid "Monitor Other Vehicles" msgstr "請注意其它車輛" #: selfdrive/controls/lib/events.py:446 msgid "Steer Right to Start Lane Change" msgstr "請往右打方向盤切換至右車道" #: selfdrive/controls/lib/events.py:454 msgid "Car Detected in Blindspot" msgstr "盲點偵測到車輛" #: selfdrive/controls/lib/events.py:462 msgid "Changing Lane" msgstr "切換車道中" #: selfdrive/controls/lib/events.py:471 msgid "Turn Exceeds Steering Limit" msgstr "彎道超過橫向操控限制" #: selfdrive/controls/lib/events.py:496 msgid "Brake Hold Active" msgstr "駐車煞車已啟用" #: selfdrive/controls/lib/events.py:501 msgid "Park Brake Engaged" msgstr "電子駐車已啟動" #: selfdrive/controls/lib/events.py:506 msgid "Pedal Pressed During Attempt" msgstr "啟用時偵測到駕駛踩踏油門/剎車" #: selfdrive/controls/lib/events.py:517 msgid "Enable Adaptive Cruise" msgstr "啟用主動定速巡航" #: selfdrive/controls/lib/events.py:533 msgid "Attempting Refocus: Camera Focus Invalid" msgstr "嘗試對焦:相機已失焦" #: selfdrive/controls/lib/events.py:539 msgid "Out of Storage Space" msgstr "儲存空間不足" #: selfdrive/controls/lib/events.py:544 msgid "Speed Too Low" msgstr "車速過慢" #: selfdrive/controls/lib/events.py:549 selfdrive/controls/lib/events.py:553 msgid "NEOS Update Required" msgstr "NEOS 需要更新" #: selfdrive/controls/lib/events.py:550 msgid "Please Wait for Update" msgstr "更新中請稍候" #: selfdrive/controls/lib/events.py:558 selfdrive/controls/lib/events.py:562 msgid "No Data from Device Sensors" msgstr "未收到裝置傳感器數據" #: selfdrive/controls/lib/events.py:559 selfdrive/controls/lib/events.py:572 #: selfdrive/controls/lib/events.py:669 msgid "Reboot your Device" msgstr "請重啟裝置" #: selfdrive/controls/lib/events.py:571 selfdrive/controls/lib/events.py:575 msgid "Speaker not found" msgstr "找不到音效裝置" #: selfdrive/controls/lib/events.py:579 msgid "Distraction Level Too High" msgstr "駕駛分心太多次" #: selfdrive/controls/lib/events.py:583 msgid "System Overheated" msgstr "系統過熱" #: selfdrive/controls/lib/events.py:584 msgid "System overheated" msgstr "系統過熱" #: selfdrive/controls/lib/events.py:588 selfdrive/controls/lib/events.py:589 msgid "Gear not D" msgstr "不在 D 檔位" #: selfdrive/controls/lib/events.py:594 #, fuzzy msgid "Calibration Invalid" msgstr "正在校準中" #: selfdrive/controls/lib/events.py:595 #, fuzzy msgid "Reposition Device and Recalibrate" msgstr "校準無效:請將裝置放於新的位置並重新校準" #: selfdrive/controls/lib/events.py:598 selfdrive/controls/lib/events.py:599 msgid "Calibration Invalid: Reposition Device & Recalibrate" msgstr "校準無效:請將裝置放於新的位置並重新校準" #: selfdrive/controls/lib/events.py:603 selfdrive/controls/lib/events.py:605 msgid "Calibration in Progress" msgstr "正在校準中" #: selfdrive/controls/lib/events.py:609 msgid "Door Open" msgstr "車門開啟" #: selfdrive/controls/lib/events.py:610 msgid "Door open" msgstr "車門未關" #: selfdrive/controls/lib/events.py:614 msgid "Seatbelt Unlatched" msgstr "安全帶未繫" #: selfdrive/controls/lib/events.py:615 msgid "Seatbelt unlatched" msgstr "安全帶未繫" #: selfdrive/controls/lib/events.py:619 selfdrive/controls/lib/events.py:620 msgid "ESP Off" msgstr "ESP 關閉" #: selfdrive/controls/lib/events.py:624 selfdrive/controls/lib/events.py:625 msgid "Low Battery" msgstr "電量過低" #: selfdrive/controls/lib/events.py:629 selfdrive/controls/lib/events.py:630 msgid "Communication Issue between Processes" msgstr "行程間出現通訊問題" #: selfdrive/controls/lib/events.py:635 selfdrive/controls/lib/events.py:636 msgid "Radar Communication Issue" msgstr "雷達通訊出現問題" #: selfdrive/controls/lib/events.py:641 selfdrive/controls/lib/events.py:642 #: selfdrive/controls/lib/events.py:646 selfdrive/controls/lib/events.py:647 msgid "Radar Error: Restart the Car" msgstr "雷達訊號錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:651 selfdrive/controls/lib/events.py:652 msgid "Driving model lagging" msgstr "操控模型有延遲" #: selfdrive/controls/lib/events.py:656 selfdrive/controls/lib/events.py:657 msgid "Vision Model Output Uncertain" msgstr "視覺模型判斷不明確" #: selfdrive/controls/lib/events.py:661 selfdrive/controls/lib/events.py:662 msgid "Device Fell Off Mount" msgstr "裝置掉落偵測" #: selfdrive/controls/lib/events.py:666 selfdrive/controls/lib/events.py:672 msgid "Low Memory: Reboot Your Device" msgstr "記憶體不足:請重啟您的裝置" #: selfdrive/controls/lib/events.py:668 msgid "RAM Critically Low" msgstr "記憶體嚴重不足" #: selfdrive/controls/lib/events.py:677 selfdrive/controls/lib/events.py:678 msgid "Controls Failed" msgstr "控制發生錯誤" #: selfdrive/controls/lib/events.py:682 msgid "Controls Mismatch" msgstr "控制不匹配" #: selfdrive/controls/lib/events.py:686 selfdrive/controls/lib/events.py:688 #: selfdrive/controls/lib/events.py:692 msgid "CAN Error: Check Connections" msgstr "CAN 訊號錯誤:請檢查線路" #: selfdrive/controls/lib/events.py:696 selfdrive/controls/lib/events.py:702 msgid "LKAS Fault: Restart the Car" msgstr "LKAS 錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:698 msgid "LKAS Fault: Restart the car to engage" msgstr "LKAS 錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:706 selfdrive/controls/lib/events.py:712 #: selfdrive/controls/lib/events.py:795 msgid "Cruise Fault: Restart the Car" msgstr "巡航系統錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:708 selfdrive/controls/lib/events.py:791 msgid "Cruise Fault: Restart the car to engage" msgstr "巡航系統錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:716 msgid "Gas Fault: Restart the Car" msgstr "油門錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:717 msgid "Gas Error: Restart the Car" msgstr "油門錯誤:請重新發動車輛" #: selfdrive/controls/lib/events.py:722 #, fuzzy msgid "" "Reverse\n" "Gear" msgstr "切換至倒車檔" #: selfdrive/controls/lib/events.py:726 msgid "Reverse Gear" msgstr "切換至倒車檔" #: selfdrive/controls/lib/events.py:731 msgid "Cruise Is Off" msgstr "巡航系統關閉" #: selfdrive/controls/lib/events.py:735 selfdrive/controls/lib/events.py:736 msgid "Planner Solution Error" msgstr "Planner Solution 錯誤" #: selfdrive/controls/lib/events.py:740 selfdrive/controls/lib/events.py:742 #: selfdrive/controls/lib/events.py:746 msgid "Harness Malfunction" msgstr "Harness 故障" #: selfdrive/controls/lib/events.py:743 msgid "Please Check Hardware" msgstr "請檢查硬體" #: selfdrive/controls/lib/events.py:751 selfdrive/controls/lib/events.py:760 msgid "openpilot Canceled" msgstr "openpilot 已取消" #: selfdrive/controls/lib/events.py:752 msgid "No close lead car" msgstr "前方沒有車輛" #: selfdrive/controls/lib/events.py:755 msgid "No Close Lead Car" msgstr "前方沒有車輛" #: selfdrive/controls/lib/events.py:761 msgid "Speed too low" msgstr "車速過慢" #: selfdrive/controls/lib/events.py:768 selfdrive/controls/lib/events.py:773 msgid "Speed Too High" msgstr "車速過快" #: selfdrive/controls/lib/events.py:769 msgid "Slow down to resume operation" msgstr "請減速後再啟用" #: selfdrive/controls/lib/events.py:774 msgid "Slow down to engage" msgstr "請減速後再啟用" #: selfdrive/controls/lib/events.py:781 msgid "Please connect to Internet" msgstr "請連接網路" #: selfdrive/controls/lib/events.py:782 msgid "An Update Check Is Required to Engage" msgstr "需檢查更新後才能啟用" #: selfdrive/controls/lib/events.py:785 msgid "Please Connect to Internet" msgstr "請連接網路" #: selfdrive/controls/lib/events.py:801 msgid "Left ALC will start in 3s" msgstr "準備自動切至左車道" #: selfdrive/controls/lib/events.py:809 msgid "Right ALC will start in 3s" msgstr "準備自動切至右車道" #: selfdrive/controls/lib/events.py:817 msgid "STEERING REQUIRED: Lane Keeping OFF" msgstr "請接管方向盤:車道維持關閉" #: selfdrive/controls/lib/events.py:825 msgid "STEERING REQUIRED: Blinkers ON" msgstr "請接管方向盤:方向燈開啟" #: selfdrive/controls/lib/events.py:833 selfdrive/controls/lib/events.py:838 msgid "Lead Car Is Moving" msgstr "前方車輛車移動中" #: selfdrive/controls/lib/events.py:847 msgid "WARNING" msgstr "警告" #: selfdrive/controls/lib/events.py:848 msgid "Grab wheel to start bypass" msgstr "請握好方向盤以繞過時間限制" #: selfdrive/controls/lib/events.py:855 msgid "BYPASSING" msgstr "繞過時間限制中" #: selfdrive/controls/lib/events.py:856 msgid "HOLD WHEEL" msgstr "握好方向盤" #: selfdrive/controls/lib/events.py:863 msgid "Bypassed!" msgstr "時間限制已繞過" #: selfdrive/controls/lib/events.py:864 msgid "Release wheel when ready" msgstr "準備好後請鬆開放向盤" ================================================ FILE: selfdrive/assets/offroad/fcc.html ================================================

Supplier's Declaration of Conformity: 47 CFR § 2.1077 Compliance Information

Unique Identifier

comma three

Authorized Components

Thundersoft TurboX D845 SOM

FCC ID: 2AOHHTURBOXSOMD845

Quectel/EG25-G

FCC ID: XMR201903EG25GM

This device complies with Part 15 of the FCC Rules. Operation is subject to the following two conditions:

(1) this device may not cause harmful interference, and

(2) this device must accept any interference received, including interference that may cause undesired operation.

The following test reports are subject to this declaration: Test report number: HR20191001605 Issue date: 2019-2-21 The following manufacturer/importer/entity (located in the USA) is responsible for this declaration: Company name: Quectel Wireless Solutions Co., Ltd. Name/Title (legal representative): Yin JiXiong Address: 7th Floor, Hongye Building, No.1801 Hongmei Road, Xuhui District, Shanghai 200233, China Phone: +8602150086326 Extension: 800 Fax: +862153253668 E-mail: johnny.xiang@quectel.com

Responsible Party - U.S. Contact Information

comma.ai

501 W Broadway St

STE A #403

San Diego, California

92101

United States

support@comma.ai

FCC Compliance Statement

This device complies with part 15 of the FCC Rules. Operation is subject to the following two conditions: (1) This device may not cause harmful interference, and (2) this device must accept any interference received, including interference that may cause undesired operation. Note: This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to part 15 of the FCC Rules. These limits are designed to provide reasonable protection against harmful interference in a residential installation.

This equipment generates, uses, and can radiate radio frequency energy and, if not installed and used in accordance with the instructions, may cause harmful interference to radio communications. However, there is no guarantee that interference will not occur in a particular installation.

If this equipment does cause harmful interference to radio or television reception, which can be determined by turning the equipment off and on, the user is encouraged to try to correct the interference by one or more of the following measures:

Reorient or relocate the receiving antenna.

Increase the separation between the equipment and receiver.

Connect the equipment to an outlet on a circuit different from that to which the receiver is connected.

Consult the dealer or an experienced radio/TV technician for help.

Changes or modifications to this product not expressly approved by the party responsible for compliance could void the electromagnetic compatibility (EMC) and wireless compliance and negate your authority to operate the product.

This product has demonstrated EMC compliance under conditions that included the use of compliant peripheral devices and shielded cables between system components. It is important that you use compliant peripheral devices and shielded cables between system components to reduce the possibility of causing interference to radios, televisions, and other electronic devices.

The radiated output power of this device meets the limits of FCC/IC radio frequency exposure limits. This device should be operated with a minimum separation distance of 20 cm (8 inches) between the equipment and a person's body.

================================================ FILE: selfdrive/assets/offroad/tc.html ================================================ openpilot Terms of Service

The Terms and Conditions below are effective for all users

Last Updated on October 18, 2019

Please read these Terms of Use (“Terms”) carefully before using openpilot which is open-sourced software developed by Comma.ai, Inc., a corporation organized under the laws of Delaware (“comma,” “us,” “we,” or “our”).

Before using and by accessing openpilot, you indicate that you have read, understood, and agree to these Terms. These Terms apply to all users and others who access or use openpilot. If others use openpilot through your user account or vehicle, you are responsible to ensure that they only use openpilot when it is safe to do so, and in compliance with these Terms and with applicable law. If you disagree with any part of the Terms, you should not access or use openpilot.

Communications

You agree that comma may contact you by email or telephone in connection with openpilot or for other business purposes. You may opt out of receiving email messages at any time by contacting us at support@comma.ai.

We collect, use, and share information from and about you and your vehicle in connection with openpilot. You consent to comma accessing the systems associated with openpilot, without additional notice or consent, for the purposes of providing openpilot, data collection, software updates, safety and cybersecurity, suspension or removal of your account, and as disclosed in the Privacy Policy (available at https://connect.comma.ai/privacy).

Safety

openpilot performs the functions of Adaptive Cruise Control (ACC) and Lane Keeping Assist System (LKAS) designed for use in compatible motor vehicles. While using openpilot, it is your responsibility to obey all laws, traffic rules, and traffic regulations governing your vehicle and its operation. Access to and use of openpilot is at your own risk and responsibility, and openpilot should be accessed and/or used only when you can do so safely.

openpilot does not make your vehicle “autonomous” or capable of operation without the active monitoring of a licensed driver. It is designed to assist a licensed driver. A licensed driver must pay attention to the road, remain aware of navigation at all times, and be prepared to take immediate action. Failure to do so can cause damage, injury, or death.

Supported Locations and Models

openpilot is compatible only with particular makes and models of vehicles. For a complete list of currently supported vehicles, visit https://comma.ai. openpilot will not function properly when installed in an incompatible vehicle. openpilot is compatible only within the geographical boundaries of the United States of America.

Indemnification

To the maximum extent allowable by law, you agree to defend, indemnify and hold harmless comma, and its employees, partners, suppliers, contractors, investors, agents, officers, directors, and affiliates, from and against any and all claims, damages, causes of action, penalties, interest, demands, obligations, losses, liabilities, costs or debt, additional taxes, and expenses (including but not limited to attorneys’ fees), resulting from or arising out of (i) your use and access of, or inability to use or access, openpilot, (ii) your breach of these Terms, (iii) the inaccuracy of any information, representation or warranty made by you, (iv) activities of anyone other than you in connection with openpilot conducted through your comma device or account, (v) any other of your activities under or in connection with these Terms or openpilot.

Limitation of Liability

In no event shall comma, nor its directors, employees, partners, agents, suppliers, or affiliates, be liable for any indirect, incidental, special, consequential or punitive damages, including without limitation, loss of profits, data, use, goodwill, or other intangible losses, resulting from (i) your access to or use of or inability to access or use of the Software; or (ii) any conduct or content of any third party on the Software whether based on warranty, contract, tort (including negligence) or any other legal theory, whether or not we have been informed of the possibility of such damage, and even if a remedy set forth herein is found to have failed of its essential purpose.

No Warranty or Obligations to Maintain or Service

comma provides openpilot without representations, conditions, or warranties of any kind. openpilot is provided on an “AS IS” and “AS AVAILABLE” basis, including with all faults and errors as may occur. To the extent permitted by law and unless prohibited by law, comma on behalf of itself and all persons and parties acting by, through, or for comma, explicitly disclaims all warranties or conditions, express, implied, or collateral, including any implied warranties of merchantability, satisfactory quality, and fitness for a particular purpose in respect of openpilot.

To the extent permitted by law, comma does not warrant the operation, performance, or availability of openpilot under all conditions. comma is not responsible for any failures caused by server errors, misdirected or redirected transmissions, failed internet connections, interruptions or failures in the transmission of data, any computer virus, or any acts or omissions of third parties that damage the network or impair wireless service.

We undertake reasonable measures to preserve and secure information collected through our openpilot. However, no data collection, transmission or storage system is 100% secure, and there is always a risk that your information may be intercepted without our consent. In using openpilot, you acknowledge that comma is not responsible for intercepted information, and you hereby release us from any and all claims arising out of or related to the use of intercepted information in any unauthorized manner.

By providing openpilot, comma does not transfer or license its intellectual property or grant rights in its brand names, nor does comma make representations with respect to third-party intellectual property rights.

We are not obligated to provide any maintenance or support for openpilot, technical or otherwise. If we voluntarily provide any maintenance or support for openpilot, we may stop any such maintenance, support, or services at any time in our sole discretion.

Modification of Software

In no event shall comma, nor its directors, employees, partners, agents, suppliers, or affiliates, be liable if you choose to modify the software.

Changes

We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material we will provide at least 15 days’ notice prior to any new terms taking effect. What constitutes a material change will be determined at our sole discretion.

By continuing to access or use our Software after any revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, you are no longer authorized to use the Software.

Contact Us

If you have any questions about these Terms, please contact us at support@comma.ai.

================================================ FILE: selfdrive/athena/__init__.py ================================================ ================================================ FILE: selfdrive/athena/athenad.py ================================================ #!/usr/bin/env python3 import base64 import hashlib import io import json import os import sys import queue import random import select import socket import threading import time from collections import namedtuple from functools import partial from typing import Any import requests from jsonrpc import JSONRPCResponseManager, dispatcher from websocket import ABNF, WebSocketTimeoutException, WebSocketException, create_connection from common.params import Params API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com') if not Params().get_bool("dp_api_custom") else Params().get("dp_api_custom_url", encoding='utf-8') import cereal.messaging as messaging from cereal.services import service_list from common.api import Api from common.file_helpers import CallbackReader from common.basedir import PERSIST from common.params import Params from common.realtime import sec_since_boot from selfdrive.hardware import HARDWARE, PC, TICI from selfdrive.loggerd.config import ROOT from selfdrive.loggerd.xattr_cache import getxattr, setxattr from selfdrive.swaglog import cloudlog, SWAGLOG_DIR from selfdrive.version import version, get_version, get_git_remote, get_git_branch, get_git_commit ATHENA_HOST = os.getenv('ATHENA_HOST', 'wss://athena.comma.ai') HANDLER_THREADS = int(os.getenv('HANDLER_THREADS', "4")) LOCAL_PORT_WHITELIST = set([8022]) LOG_ATTR_NAME = 'user.upload' LOG_ATTR_VALUE_MAX_UNIX_TIME = int.to_bytes(2147483647, 4, sys.byteorder) RECONNECT_TIMEOUT_S = 70 RETRY_DELAY = 10 # seconds MAX_RETRY_COUNT = 30 # Try for at most 5 minutes if upload fails immediately WS_FRAME_SIZE = 4096 dispatcher["echo"] = lambda s: s recv_queue: Any = queue.Queue() send_queue: Any = queue.Queue() upload_queue: Any = queue.Queue() log_send_queue: Any = queue.Queue() log_recv_queue: Any = queue.Queue() cancelled_uploads: Any = set() UploadItem = namedtuple('UploadItem', ['path', 'url', 'headers', 'created_at', 'id', 'retry_count', 'current', 'progress'], defaults=(0, False, 0)) cur_upload_items = {} def handle_long_poll(ws): end_event = threading.Event() threads = [ threading.Thread(target=ws_recv, args=(ws, end_event), name='ws_recv'), threading.Thread(target=ws_send, args=(ws, end_event), name='ws_send'), threading.Thread(target=upload_handler, args=(end_event,), name='upload_handler'), threading.Thread(target=log_handler, args=(end_event,), name='log_handler'), ] + [ threading.Thread(target=jsonrpc_handler, args=(end_event,), name=f'worker_{x}') for x in range(HANDLER_THREADS) ] for thread in threads: thread.start() try: while not end_event.is_set(): time.sleep(0.1) except (KeyboardInterrupt, SystemExit): end_event.set() raise finally: for thread in threads: cloudlog.debug(f"athena.joining {thread.name}") thread.join() def jsonrpc_handler(end_event): dispatcher["startLocalProxy"] = partial(startLocalProxy, end_event) while not end_event.is_set(): try: data = recv_queue.get(timeout=1) if "method" in data: cloudlog.debug(f"athena.jsonrpc_handler.call_method {data}") response = JSONRPCResponseManager.handle(data, dispatcher) send_queue.put_nowait(response.json) elif "id" in data and ("result" in data or "error" in data): log_recv_queue.put_nowait(data) else: raise Exception("not a valid request or response") except queue.Empty: pass except Exception as e: cloudlog.exception("athena jsonrpc handler failed") send_queue.put_nowait(json.dumps({"error": str(e)})) def upload_handler(end_event): tid = threading.get_ident() while not end_event.is_set(): cur_upload_items[tid] = None try: cur_upload_items[tid] = upload_queue.get(timeout=1)._replace(current=True) if cur_upload_items[tid].id in cancelled_uploads: cancelled_uploads.remove(cur_upload_items[tid].id) continue try: def cb(sz, cur): cur_upload_items[tid] = cur_upload_items[tid]._replace(progress=cur / sz if sz else 1) _do_upload(cur_upload_items[tid], cb) except (requests.exceptions.Timeout, requests.exceptions.ConnectionError, requests.exceptions.SSLError) as e: cloudlog.warning(f"athena.upload_handler.retry {e} {cur_upload_items[tid]}") if cur_upload_items[tid].retry_count < MAX_RETRY_COUNT: item = cur_upload_items[tid] item = item._replace( retry_count=item.retry_count + 1, progress=0, current=False ) upload_queue.put_nowait(item) cur_upload_items[tid] = None for _ in range(RETRY_DELAY): time.sleep(1) if end_event.is_set(): break except queue.Empty: pass except Exception: cloudlog.exception("athena.upload_handler.exception") def _do_upload(upload_item, callback=None): with open(upload_item.path, "rb") as f: size = os.fstat(f.fileno()).st_size if callback: f = CallbackReader(f, callback, size) return requests.put(upload_item.url, data=f, headers={**upload_item.headers, 'Content-Length': str(size)}, timeout=30) # security: user should be able to request any message from their car @dispatcher.add_method def getMessage(service=None, timeout=1000): if service is None or service not in service_list: raise Exception("invalid service") socket = messaging.sub_sock(service, timeout=timeout) ret = messaging.recv_one(socket) if ret is None: raise TimeoutError return ret.to_dict() @dispatcher.add_method def getVersion(): return { "version": get_version(), "remote": get_git_remote(), "branch": get_git_branch(), "commit": get_git_commit(), } @dispatcher.add_method def setNavDestination(latitude=0, longitude=0): destination = { "latitude": latitude, "longitude": longitude, } Params().put("NavDestination", json.dumps(destination)) return {"success": 1} def scan_dir(path, prefix): files = list() # only walk directories that match the prefix # (glob and friends traverse entire dir tree) with os.scandir(path) as i: for e in i: rel_path = os.path.relpath(e.path, ROOT) if e.is_dir(follow_symlinks=False): # add trailing slash rel_path = os.path.join(rel_path, '') # if prefix is a partial dir name, current dir will start with prefix # if prefix is a partial file name, prefix with start with dir name if rel_path.startswith(prefix) or prefix.startswith(rel_path): files.extend(scan_dir(e.path, prefix)) else: if rel_path.startswith(prefix): files.append(rel_path) return files @dispatcher.add_method def listDataDirectory(prefix=''): return scan_dir(ROOT, prefix) @dispatcher.add_method def reboot(): sock = messaging.sub_sock("deviceState", timeout=1000) ret = messaging.recv_one(sock) if ret is None or ret.deviceState.started: raise Exception("Reboot unavailable") def do_reboot(): time.sleep(2) HARDWARE.reboot() threading.Thread(target=do_reboot).start() return {"success": 1} @dispatcher.add_method def uploadFileToUrl(fn, url, headers): if len(fn) == 0 or fn[0] == '/' or '..' in fn: return 500 path = os.path.join(ROOT, fn) if not os.path.exists(path): return 404 item = UploadItem(path=path, url=url, headers=headers, created_at=int(time.time() * 1000), id=None) upload_id = hashlib.sha1(str(item).encode()).hexdigest() item = item._replace(id=upload_id) upload_queue.put_nowait(item) return {"enqueued": 1, "item": item._asdict()} @dispatcher.add_method def listUploadQueue(): items = list(upload_queue.queue) + list(cur_upload_items.values()) return [i._asdict() for i in items if i is not None] @dispatcher.add_method def cancelUpload(upload_id): upload_ids = set(item.id for item in list(upload_queue.queue)) if upload_id not in upload_ids: return 404 cancelled_uploads.add(upload_id) return {"success": 1} @dispatcher.add_method def primeActivated(activated): dongle_id = Params().get("DongleId", encoding='utf-8') api = Api(dongle_id) manage_tokens(api) return {"success": 1} def startLocalProxy(global_end_event, remote_ws_uri, local_port): try: if local_port not in LOCAL_PORT_WHITELIST: raise Exception("Requested local port not whitelisted") cloudlog.debug("athena.startLocalProxy.starting") params = Params() dongle_id = params.get("DongleId").decode('utf8') identity_token = Api(dongle_id).get_token() ws = create_connection(remote_ws_uri, cookie="jwt=" + identity_token, enable_multithread=True) ssock, csock = socket.socketpair() local_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) local_sock.connect(('127.0.0.1', local_port)) local_sock.setblocking(0) proxy_end_event = threading.Event() threads = [ threading.Thread(target=ws_proxy_recv, args=(ws, local_sock, ssock, proxy_end_event, global_end_event)), threading.Thread(target=ws_proxy_send, args=(ws, local_sock, csock, proxy_end_event)) ] for thread in threads: thread.start() cloudlog.debug("athena.startLocalProxy.started") return {"success": 1} except Exception as e: cloudlog.exception("athenad.startLocalProxy.exception") raise e @dispatcher.add_method def getPublicKey(): if not os.path.isfile(PERSIST + '/comma/id_rsa.pub'): return None with open(PERSIST + '/comma/id_rsa.pub', 'r') as f: return f.read() @dispatcher.add_method def getSshAuthorizedKeys(): return Params().get("GithubSshKeys", encoding='utf8') or '' @dispatcher.add_method def getSimInfo(): return HARDWARE.get_sim_info() @dispatcher.add_method def getNetworkType(): return HARDWARE.get_network_type() @dispatcher.add_method def getNetworks(): return HARDWARE.get_networks() @dispatcher.add_method def takeSnapshot(): from selfdrive.camerad.snapshot.snapshot import snapshot, jpeg_write ret = snapshot() if ret is not None: def b64jpeg(x): if x is not None: f = io.BytesIO() jpeg_write(f, x) return base64.b64encode(f.getvalue()).decode("utf-8") else: return None return {'jpegBack': b64jpeg(ret[0]), 'jpegFront': b64jpeg(ret[1])} else: raise Exception("not available while camerad is started") def get_logs_to_send_sorted(): # TODO: scan once then use inotify to detect file creation/deletion curr_time = int(time.time()) logs = [] for log_entry in os.listdir(SWAGLOG_DIR): log_path = os.path.join(SWAGLOG_DIR, log_entry) try: time_sent = int.from_bytes(getxattr(log_path, LOG_ATTR_NAME), sys.byteorder) except (ValueError, TypeError): time_sent = 0 # assume send failed and we lost the response if sent more than one hour ago if not time_sent or curr_time - time_sent > 3600: logs.append(log_entry) # excluding most recent (active) log file return sorted(logs)[:-1] def log_handler(end_event): if PC: return log_files = [] last_scan = 0 while not end_event.is_set(): try: curr_scan = sec_since_boot() if curr_scan - last_scan > 10: log_files = get_logs_to_send_sorted() last_scan = curr_scan # send one log curr_log = None if len(log_files) > 0: log_entry = log_files.pop() # newest log file cloudlog.debug(f"athena.log_handler.forward_request {log_entry}") try: curr_time = int(time.time()) log_path = os.path.join(SWAGLOG_DIR, log_entry) setxattr(log_path, LOG_ATTR_NAME, int.to_bytes(curr_time, 4, sys.byteorder)) with open(log_path, "r") as f: jsonrpc = { "method": "forwardLogs", "params": { "logs": f.read() }, "jsonrpc": "2.0", "id": log_entry } log_send_queue.put_nowait(json.dumps(jsonrpc)) curr_log = log_entry except OSError: pass # file could be deleted by log rotation # wait for response up to ~100 seconds # always read queue at least once to process any old responses that arrive for _ in range(100): if end_event.is_set(): break try: log_resp = json.loads(log_recv_queue.get(timeout=1)) log_entry = log_resp.get("id") log_success = "result" in log_resp and log_resp["result"].get("success") cloudlog.debug(f"athena.log_handler.forward_response {log_entry} {log_success}") if log_entry and log_success: log_path = os.path.join(SWAGLOG_DIR, log_entry) try: setxattr(log_path, LOG_ATTR_NAME, LOG_ATTR_VALUE_MAX_UNIX_TIME) except OSError: pass # file could be deleted by log rotation if curr_log == log_entry: break except queue.Empty: if curr_log is None: break except Exception: cloudlog.exception("athena.log_handler.exception") def ws_proxy_recv(ws, local_sock, ssock, end_event, global_end_event): while not (end_event.is_set() or global_end_event.is_set()): try: data = ws.recv() local_sock.sendall(data) except WebSocketTimeoutException: pass except Exception: cloudlog.exception("athenad.ws_proxy_recv.exception") break cloudlog.debug("athena.ws_proxy_recv closing sockets") ssock.close() local_sock.close() cloudlog.debug("athena.ws_proxy_recv done closing sockets") end_event.set() def ws_proxy_send(ws, local_sock, signal_sock, end_event): while not end_event.is_set(): try: r, _, _ = select.select((local_sock, signal_sock), (), ()) if r: if r[0].fileno() == signal_sock.fileno(): # got end signal from ws_proxy_recv end_event.set() break data = local_sock.recv(4096) if not data: # local_sock is dead end_event.set() break ws.send(data, ABNF.OPCODE_BINARY) except Exception: cloudlog.exception("athenad.ws_proxy_send.exception") end_event.set() cloudlog.debug("athena.ws_proxy_send closing sockets") signal_sock.close() cloudlog.debug("athena.ws_proxy_send done closing sockets") def ws_recv(ws, end_event): last_ping = int(sec_since_boot() * 1e9) while not end_event.is_set(): try: opcode, data = ws.recv_data(control_frame=True) if opcode in (ABNF.OPCODE_TEXT, ABNF.OPCODE_BINARY): if opcode == ABNF.OPCODE_TEXT: data = data.decode("utf-8") recv_queue.put_nowait(data) elif opcode == ABNF.OPCODE_PING: last_ping = int(sec_since_boot() * 1e9) Params().put("LastAthenaPingTime", str(last_ping)) except WebSocketTimeoutException: ns_since_last_ping = int(sec_since_boot() * 1e9) - last_ping if ns_since_last_ping > RECONNECT_TIMEOUT_S * 1e9: cloudlog.exception("athenad.ws_recv.timeout") end_event.set() except Exception: cloudlog.exception("athenad.ws_recv.exception") end_event.set() def ws_send(ws, end_event): while not end_event.is_set(): try: try: data = send_queue.get_nowait() except queue.Empty: data = log_send_queue.get(timeout=1) for i in range(0, len(data), WS_FRAME_SIZE): frame = data[i:i+WS_FRAME_SIZE] last = i + WS_FRAME_SIZE >= len(data) opcode = ABNF.OPCODE_TEXT if i == 0 else ABNF.OPCODE_CONT ws.send_frame(ABNF.create_frame(frame, opcode, last)) except queue.Empty: pass except Exception: cloudlog.exception("athenad.ws_send.exception") end_event.set() def backoff(retries): return random.randrange(0, min(128, int(2 ** retries))) def manage_tokens(api): if not TICI: return try: params = Params() mapbox = api.get(f"/v1/tokens/mapbox/{api.dongle_id}/", timeout=5.0, access_token=api.get_token()) if mapbox.status_code == 200: params.put("MapboxToken", mapbox.json()["token"]) else: params.delete("MapboxToken") except Exception: cloudlog.exception("Failed to update tokens") def main(): params = Params() dongle_id = params.get("DongleId", encoding='utf-8') ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id api = Api(dongle_id) conn_retries = 0 while 1: try: cloudlog.event("athenad.main.connecting_ws", ws_uri=ws_uri) ws = create_connection(ws_uri, cookie="jwt=" + api.get_token(), enable_multithread=True, timeout=30.0) cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri) params.delete("PrimeRedirected") manage_tokens(api) conn_retries = 0 cur_upload_items.clear() handle_long_poll(ws) except (KeyboardInterrupt, SystemExit): break except (ConnectionError, TimeoutError, WebSocketException): conn_retries += 1 params.delete("PrimeRedirected") params.delete("LastAthenaPingTime") except socket.timeout: try: r = requests.get(API_HOST + "/v1/me", allow_redirects=False, headers={"User-Agent": f"openpilot-{version}"}, timeout=15.0) if r.status_code == 302 and r.headers['Location'].startswith("http://u.web2go.com"): params.put_bool("PrimeRedirected", True) except Exception: cloudlog.exception("athenad.socket_timeout.exception") params.delete("LastAthenaPingTime") except Exception: cloudlog.exception("athenad.main.exception") conn_retries += 1 params.delete("PrimeRedirected") params.delete("LastAthenaPingTime") time.sleep(backoff(conn_retries)) if __name__ == "__main__": main() ================================================ FILE: selfdrive/athena/manage_athenad.py ================================================ #!/usr/bin/env python3 import time from multiprocessing import Process from common.params import Params from selfdrive.manager.process import launcher from selfdrive.swaglog import cloudlog from selfdrive.version import version, dirty ATHENA_MGR_PID_PARAM = "AthenadPid" def main(): params = Params() dongle_id = params.get("DongleId").decode('utf-8') cloudlog.bind_global(dongle_id=dongle_id, version=version, dirty=dirty) try: while 1: cloudlog.info("starting athena daemon") proc = Process(name='athenad', target=launcher, args=('selfdrive.athena.athenad',)) proc.start() proc.join() cloudlog.event("athenad exited", exitcode=proc.exitcode) time.sleep(5) except Exception: cloudlog.exception("manage_athenad.exception") finally: params.delete(ATHENA_MGR_PID_PARAM) if __name__ == '__main__': main() ================================================ FILE: selfdrive/athena/registration.py ================================================ #!/usr/bin/env python3 import os import time import json import jwt from datetime import datetime, timedelta from common.api import api_get from common.params import Params from common.spinner import Spinner from common.file_helpers import mkdirs_exists_ok from common.basedir import PERSIST from selfdrive.controls.lib.alertmanager import set_offroad_alert from selfdrive.hardware import HARDWARE from selfdrive.swaglog import cloudlog UNREGISTERED_DONGLE_ID = "UnregisteredDevice" def register(show_spinner=False) -> str: params = Params() params.put("SubscriberInfo", HARDWARE.get_subscriber_info()) IMEI = params.get("IMEI", encoding='utf8') HardwareSerial = params.get("HardwareSerial", encoding='utf8') dongle_id = params.get("DongleId", encoding='utf8') needs_registration = None in (IMEI, HardwareSerial, dongle_id) # create a key for auth # your private key is kept on your device persist partition and never sent to our servers # do not erase your persist partition if not os.path.isfile(PERSIST+"/comma/id_rsa.pub"): needs_registration = True cloudlog.warning("generating your personal RSA key") mkdirs_exists_ok(PERSIST+"/comma") assert os.system("openssl genrsa -out "+PERSIST+"/comma/id_rsa.tmp 2048") == 0 assert os.system("openssl rsa -in "+PERSIST+"/comma/id_rsa.tmp -pubout -out "+PERSIST+"/comma/id_rsa.tmp.pub") == 0 os.rename(PERSIST+"/comma/id_rsa.tmp", PERSIST+"/comma/id_rsa") os.rename(PERSIST+"/comma/id_rsa.tmp.pub", PERSIST+"/comma/id_rsa.pub") if needs_registration: if show_spinner: spinner = Spinner() spinner.update("registering device") # Create registration token, in the future, this key will make JWTs directly with open(PERSIST+"/comma/id_rsa.pub") as f1, open(PERSIST+"/comma/id_rsa") as f2: public_key = f1.read() private_key = f2.read() # Block until we get the imei serial = HARDWARE.get_serial() start_time = time.monotonic() imei1, imei2 = None, None while imei1 is None and imei2 is None: try: imei1, imei2 = HARDWARE.get_imei(0), HARDWARE.get_imei(1) except Exception: cloudlog.exception("Error getting imei, trying again...") time.sleep(1) if time.monotonic() - start_time > 60 and show_spinner: spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") params.put("IMEI", imei1) params.put("HardwareSerial", serial) backoff = 0 start_time = time.monotonic() while True: try: register_token = jwt.encode({'register': True, 'exp': datetime.utcnow() + timedelta(hours=1)}, private_key, algorithm='RS256') cloudlog.info("getting pilotauth") resp = api_get("v2/pilotauth/", method='POST', timeout=15, imei=imei1, imei2=imei2, serial=serial, public_key=public_key, register_token=register_token) if resp.status_code in (402, 403): cloudlog.info(f"Unable to register device, got {resp.status_code}") dongle_id = UNREGISTERED_DONGLE_ID else: dongleauth = json.loads(resp.text) dongle_id = dongleauth["dongle_id"] break except Exception: cloudlog.exception("failed to authenticate") backoff = min(backoff + 1, 15) time.sleep(backoff) if time.monotonic() - start_time > 60 and show_spinner: spinner.update(f"registering device - serial: {serial}, IMEI: ({imei1}, {imei2})") if show_spinner: spinner.close() if dongle_id: params.put("DongleId", dongle_id) set_offroad_alert("Offroad_UnofficialHardware", dongle_id == UNREGISTERED_DONGLE_ID) return dongle_id if __name__ == "__main__": print(register()) ================================================ FILE: selfdrive/camerad/SConscript ================================================ Import('env', 'arch', 'cereal', 'messaging', 'common', 'gpucommon', 'visionipc', 'USE_WEBCAM', 'USE_MIPI') libs = ['m', 'pthread', common, 'jpeg', 'OpenCL', cereal, messaging, 'zmq', 'capnp', 'kj', visionipc, gpucommon] if arch == "aarch64": libs += ['gsl', 'CB', 'adreno_utils', 'EGL', 'GLESv3', 'cutils', 'ui'] cameras = ['cameras/camera_qcom.cc'] elif arch == "larch64": libs += ['atomic'] cameras = ['cameras/camera_qcom2.cc'] else: if USE_MIPI or USE_WEBCAM: flag = "MIPI" if USE_MIPI else "WEBCAM" libs += ['opencv_core', 'opencv_highgui', 'opencv_imgproc', 'opencv_videoio'] if USE_MIPI: libs += ['opencv_cudawarping'] cameras = ['cameras/camera_%s.cc' % flag.lower()] env = env.Clone() env.Append(CXXFLAGS = "-D%s" % flag) env.Append(CFLAGS = "-D%s" % flag) env.Append(CPPPATH = ['/usr/include/opencv4', '/usr/local/include/opencv4']) else: cameras = ['cameras/camera_frame_stream.cc'] if arch == "Darwin": del libs[libs.index('OpenCL')] del libs[libs.index(gpucommon)][gpucommon.index('GL')] env = env.Clone() env['FRAMEWORKS'] = ['OpenCL', 'OpenGL'] env.Program('camerad', [ 'main.cc', 'cameras/camera_common.cc', 'transforms/rgb_to_yuv.cc', 'imgproc/utils.cc', cameras, ], LIBS=libs) if GetOption("test"): env.Program('test/ae_gray_test', [ 'test/ae_gray_test.cc', 'cameras/camera_common.cc', 'transforms/rgb_to_yuv.cc', ], LIBS=libs) ================================================ FILE: selfdrive/camerad/cameras/camera_common.cc ================================================ #include "selfdrive/camerad/cameras/camera_common.h" #include #include #include #include #include #include "libyuv.h" #include #include "selfdrive/camerad/imgproc/utils.h" #include "selfdrive/common/clutil.h" #include "selfdrive/common/modeldata.h" #include "selfdrive/common/params.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/common/util.h" #include "selfdrive/hardware/hw.h" #ifdef QCOM #include "selfdrive/camerad/cameras/camera_qcom.h" #elif QCOM2 #include "selfdrive/camerad/cameras/camera_qcom2.h" #elif WEBCAM #include "selfdrive/camerad/cameras/camera_webcam.h" #elif MIPI #include "selfdrive/camerad/cameras/camera_mipi.h" #else #include "selfdrive/camerad/cameras/camera_frame_stream.h" #endif const int YUV_COUNT = 100; static cl_program build_debayer_program(cl_device_id device_id, cl_context context, const CameraInfo *ci, const CameraBuf *b, const CameraState *s) { char args[4096]; snprintf(args, sizeof(args), "-cl-fast-relaxed-math -cl-denorms-are-zero " "-DFRAME_WIDTH=%d -DFRAME_HEIGHT=%d -DFRAME_STRIDE=%d " "-DRGB_WIDTH=%d -DRGB_HEIGHT=%d -DRGB_STRIDE=%d " "-DBAYER_FLIP=%d -DHDR=%d -DCAM_NUM=%d", ci->frame_width, ci->frame_height, ci->frame_stride, b->rgb_width, b->rgb_height, b->rgb_stride, ci->bayer_flip, ci->hdr, s->camera_num); const char *cl_file = Hardware::TICI() ? "cameras/real_debayer.cl" : "cameras/debayer.cl"; return cl_program_from_file(context, device_id, cl_file, args); } void CameraBuf::init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType rgb_type, VisionStreamType yuv_type, release_cb release_callback) { vipc_server = v; this->rgb_type = rgb_type; this->yuv_type = yuv_type; this->release_callback = release_callback; const CameraInfo *ci = &s->ci; camera_state = s; frame_buf_count = frame_cnt; // RAW frame const int frame_size = ci->frame_height * ci->frame_stride; camera_bufs = std::make_unique(frame_buf_count); camera_bufs_metadata = std::make_unique(frame_buf_count); for (int i = 0; i < frame_buf_count; i++) { camera_bufs[i].allocate(frame_size); camera_bufs[i].init_cl(device_id, context); } rgb_width = ci->frame_width; rgb_height = ci->frame_height; if (!Hardware::TICI() && ci->bayer) { // debayering does a 2x downscale rgb_width = ci->frame_width / 2; rgb_height = ci->frame_height / 2; } yuv_transform = get_model_yuv_transform(ci->bayer); vipc_server->create_buffers(rgb_type, UI_BUF_COUNT, true, rgb_width, rgb_height); rgb_stride = vipc_server->get_buffer(rgb_type)->stride; vipc_server->create_buffers(yuv_type, YUV_COUNT, false, rgb_width, rgb_height); if (ci->bayer) { cl_program prg_debayer = build_debayer_program(device_id, context, ci, this, s); krnl_debayer = CL_CHECK_ERR(clCreateKernel(prg_debayer, "debayer10", &err)); CL_CHECK(clReleaseProgram(prg_debayer)); } rgb2yuv = std::make_unique(context, device_id, rgb_width, rgb_height, rgb_stride); #ifdef __APPLE__ q = CL_CHECK_ERR(clCreateCommandQueue(context, device_id, 0, &err)); #else const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0}; q = CL_CHECK_ERR(clCreateCommandQueueWithProperties(context, device_id, props, &err)); #endif } CameraBuf::~CameraBuf() { for (int i = 0; i < frame_buf_count; i++) { camera_bufs[i].free(); } if (krnl_debayer) CL_CHECK(clReleaseKernel(krnl_debayer)); if (q) CL_CHECK(clReleaseCommandQueue(q)); } bool CameraBuf::acquire() { if (!safe_queue.try_pop(cur_buf_idx, 1)) return false; if (camera_bufs_metadata[cur_buf_idx].frame_id == -1) { LOGE("no frame data? wtf"); release(); return false; } cur_frame_data = camera_bufs_metadata[cur_buf_idx]; cur_rgb_buf = vipc_server->get_buffer(rgb_type); cl_event debayer_event; cl_mem camrabuf_cl = camera_bufs[cur_buf_idx].buf_cl; if (camera_state->ci.bayer) { CL_CHECK(clSetKernelArg(krnl_debayer, 0, sizeof(cl_mem), &camrabuf_cl)); CL_CHECK(clSetKernelArg(krnl_debayer, 1, sizeof(cl_mem), &cur_rgb_buf->buf_cl)); #ifdef QCOM2 constexpr int localMemSize = (DEBAYER_LOCAL_WORKSIZE + 2 * (3 / 2)) * (DEBAYER_LOCAL_WORKSIZE + 2 * (3 / 2)) * sizeof(short int); const size_t globalWorkSize[] = {size_t(camera_state->ci.frame_width), size_t(camera_state->ci.frame_height)}; const size_t localWorkSize[] = {DEBAYER_LOCAL_WORKSIZE, DEBAYER_LOCAL_WORKSIZE}; CL_CHECK(clSetKernelArg(krnl_debayer, 2, localMemSize, 0)); CL_CHECK(clEnqueueNDRangeKernel(q, krnl_debayer, 2, NULL, globalWorkSize, localWorkSize, 0, 0, &debayer_event)); #else float digital_gain = camera_state->digital_gain; if ((int)digital_gain == 0) { digital_gain = 1.0; } CL_CHECK(clSetKernelArg(krnl_debayer, 2, sizeof(float), &digital_gain)); const size_t debayer_work_size = rgb_height; // doesn't divide evenly, is this okay? CL_CHECK(clEnqueueNDRangeKernel(q, krnl_debayer, 1, NULL, &debayer_work_size, NULL, 0, 0, &debayer_event)); #endif } else { assert(rgb_stride == camera_state->ci.frame_stride); CL_CHECK(clEnqueueCopyBuffer(q, camrabuf_cl, cur_rgb_buf->buf_cl, 0, 0, cur_rgb_buf->len, 0, 0, &debayer_event)); } clWaitForEvents(1, &debayer_event); CL_CHECK(clReleaseEvent(debayer_event)); cur_yuv_buf = vipc_server->get_buffer(yuv_type); rgb2yuv->queue(q, cur_rgb_buf->buf_cl, cur_yuv_buf->buf_cl); VisionIpcBufExtra extra = { cur_frame_data.frame_id, cur_frame_data.timestamp_sof, cur_frame_data.timestamp_eof, }; vipc_server->send(cur_rgb_buf, &extra); vipc_server->send(cur_yuv_buf, &extra); return true; } void CameraBuf::release() { if (release_callback) { release_callback((void*)camera_state, cur_buf_idx); } } void CameraBuf::queue(size_t buf_idx) { safe_queue.push(buf_idx); } // common functions void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data) { framed.setFrameId(frame_data.frame_id); framed.setTimestampEof(frame_data.timestamp_eof); framed.setTimestampSof(frame_data.timestamp_sof); framed.setFrameLength(frame_data.frame_length); framed.setIntegLines(frame_data.integ_lines); framed.setGain(frame_data.gain); framed.setHighConversionGain(frame_data.high_conversion_gain); framed.setMeasuredGreyFraction(frame_data.measured_grey_fraction); framed.setTargetGreyFraction(frame_data.target_grey_fraction); framed.setLensPos(frame_data.lens_pos); framed.setLensSag(frame_data.lens_sag); framed.setLensErr(frame_data.lens_err); framed.setLensTruePos(frame_data.lens_true_pos); } kj::Array get_frame_image(const CameraBuf *b) { static const int x_min = util::getenv("XMIN", 0); static const int y_min = util::getenv("YMIN", 0); static const int env_xmax = util::getenv("XMAX", -1); static const int env_ymax = util::getenv("YMAX", -1); static const int scale = util::getenv("SCALE", 1); assert(b->cur_rgb_buf); const int x_max = env_xmax != -1 ? env_xmax : b->rgb_width - 1; const int y_max = env_ymax != -1 ? env_ymax : b->rgb_height - 1; const int new_width = (x_max - x_min + 1) / scale; const int new_height = (y_max - y_min + 1) / scale; const uint8_t *dat = (const uint8_t *)b->cur_rgb_buf->addr; kj::Array frame_image = kj::heapArray(new_width*new_height*3); uint8_t *resized_dat = frame_image.begin(); int goff = x_min*3 + y_min*b->rgb_stride; for (int r=0;rrgb_stride*scale+c*3*scale], 3*sizeof(uint8_t)); } } return kj::mv(frame_image); } static void publish_thumbnail(PubMaster *pm, const CameraBuf *b) { uint8_t* thumbnail_buffer = NULL; unsigned long thumbnail_len = 0; unsigned char *row = (unsigned char *)malloc(b->rgb_width/4*3); struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jpeg_create_compress(&cinfo); jpeg_mem_dest(&cinfo, &thumbnail_buffer, &thumbnail_len); cinfo.image_width = b->rgb_width / 4; cinfo.image_height = b->rgb_height / 4; cinfo.input_components = 3; cinfo.in_color_space = JCS_RGB; jpeg_set_defaults(&cinfo); #ifndef __APPLE__ jpeg_set_quality(&cinfo, 50, true); jpeg_start_compress(&cinfo, true); #else jpeg_set_quality(&cinfo, 50, static_cast(true) ); jpeg_start_compress(&cinfo, static_cast(true) ); #endif JSAMPROW row_pointer[1]; const uint8_t *bgr_ptr = (const uint8_t *)b->cur_rgb_buf->addr; for (int ii = 0; ii < b->rgb_height/4; ii+=1) { for (int j = 0; j < b->rgb_width*3; j+=12) { for (int k = 0; k < 3; k++) { uint16_t dat = 0; int i = ii * 4; dat += bgr_ptr[b->rgb_stride*i + j + k]; dat += bgr_ptr[b->rgb_stride*i + j+3 + k]; dat += bgr_ptr[b->rgb_stride*(i+1) + j + k]; dat += bgr_ptr[b->rgb_stride*(i+1) + j+3 + k]; dat += bgr_ptr[b->rgb_stride*(i+2) + j + k]; dat += bgr_ptr[b->rgb_stride*(i+2) + j+3 + k]; dat += bgr_ptr[b->rgb_stride*(i+3) + j + k]; dat += bgr_ptr[b->rgb_stride*(i+3) + j+3 + k]; row[(j/4) + (2-k)] = dat/8; } } row_pointer[0] = row; jpeg_write_scanlines(&cinfo, row_pointer, 1); } jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); free(row); MessageBuilder msg; auto thumbnaild = msg.initEvent().initThumbnail(); thumbnaild.setFrameId(b->cur_frame_data.frame_id); thumbnaild.setTimestampEof(b->cur_frame_data.timestamp_eof); thumbnaild.setThumbnail(kj::arrayPtr((const uint8_t*)thumbnail_buffer, thumbnail_len)); pm->send("thumbnail", msg); free(thumbnail_buffer); } float set_exposure_target(const CameraBuf *b, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip) { int lum_med; uint32_t lum_binning[256] = {0}; const uint8_t *pix_ptr = b->cur_yuv_buf->y; unsigned int lum_total = 0; for (int y = y_start; y < y_end; y += y_skip) { for (int x = x_start; x < x_end; x += x_skip) { uint8_t lum = pix_ptr[(y * b->rgb_width) + x]; lum_binning[lum]++; lum_total += 1; } } // Find mean lumimance value unsigned int lum_cur = 0; for (lum_med = 255; lum_med >= 0; lum_med--) { lum_cur += lum_binning[lum_med]; if (lum_cur >= lum_total / 2) { break; } } return lum_med / 256.0; } extern ExitHandler do_exit; void *processing_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback) { const char *thread_name = nullptr; if (cs == &cameras->road_cam) { thread_name = "RoadCamera"; } else if (cs == &cameras->driver_cam) { thread_name = "DriverCamera"; } else { thread_name = "WideRoadCamera"; } set_thread_name(thread_name); uint32_t cnt = 0; while (!do_exit) { if (!cs->buf.acquire()) continue; callback(cameras, cs, cnt); if (cs == &(cameras->road_cam) && cameras->pm && cnt % 100 == 3) { // this takes 10ms??? publish_thumbnail(cameras->pm, &(cs->buf)); } cs->buf.release(); ++cnt; } return NULL; } std::thread start_process_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback) { return std::thread(processing_thread, cameras, cs, callback); } static void driver_cam_auto_exposure(CameraState *c, SubMaster &sm) { static const bool is_rhd = Params().getBool("IsRHD"); struct ExpRect {int x1, x2, x_skip, y1, y2, y_skip;}; const CameraBuf *b = &c->buf; int x_offset = 0, y_offset = 0; int frame_width = b->rgb_width, frame_height = b->rgb_height; ExpRect def_rect; if (Hardware::TICI()) { x_offset = 630, y_offset = 156; frame_width = 668, frame_height = frame_width / 1.33; def_rect = {96, 1832, 2, 242, 1148, 4}; } else { def_rect = {is_rhd ? 0 : b->rgb_width * 3 / 5, is_rhd ? b->rgb_width * 2 / 5 : b->rgb_width, 2, b->rgb_height / 3, b->rgb_height, 1}; } static ExpRect rect = def_rect; // use driver face crop for AE if (Hardware::EON() && sm.updated("driverState")) { if (auto state = sm["driverState"].getDriverState(); state.getFaceProb() > 0.4) { auto face_position = state.getFacePosition(); int x = is_rhd ? 0 : frame_width - (0.5 * frame_height); x += (face_position[0] * (is_rhd ? -1.0 : 1.0) + 0.5) * (0.5 * frame_height) + x_offset; int y = (face_position[1] + 0.5) * frame_height + y_offset; rect = {std::max(0, x - 72), std::min(b->rgb_width - 1, x + 72), 2, std::max(0, y - 72), std::min(b->rgb_height - 1, y + 72), 1}; } } camera_autoexposure(c, set_exposure_target(b, rect.x1, rect.x2, rect.x_skip, rect.y1, rect.y2, rect.y_skip)); } void common_process_driver_camera(SubMaster *sm, PubMaster *pm, CameraState *c, int cnt) { int j = Hardware::TICI() ? 1 : 3; if (cnt % j == 0) { sm->update(0); driver_cam_auto_exposure(c, *sm); } MessageBuilder msg; auto framed = msg.initEvent().initDriverCameraState(); framed.setFrameType(cereal::FrameData::FrameType::FRONT); fill_frame_data(framed, c->buf.cur_frame_data); if (env_send_driver) { framed.setImage(get_frame_image(&c->buf)); } pm->send("driverCameraState", msg); } ================================================ FILE: selfdrive/camerad/cameras/camera_common.h ================================================ #pragma once #include #include #include #include #include "cereal/messaging/messaging.h" #include "cereal/visionipc/visionbuf.h" #include "cereal/visionipc/visionipc.h" #include "cereal/visionipc/visionipc_server.h" #include "selfdrive/camerad/transforms/rgb_to_yuv.h" #include "selfdrive/common/mat.h" #include "selfdrive/common/queue.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/common/visionimg.h" #define CAMERA_ID_IMX298 0 #define CAMERA_ID_IMX179 1 #define CAMERA_ID_S5K3P8SP 2 #define CAMERA_ID_OV8865 3 #define CAMERA_ID_IMX298_FLIPPED 4 #define CAMERA_ID_OV10640 5 #define CAMERA_ID_LGC920 6 #define CAMERA_ID_LGC615 7 #define CAMERA_ID_AR0231 8 #define CAMERA_ID_IMX477 9 #define CAMERA_ID_MAX 10 #define UI_BUF_COUNT 4 enum CameraType { RoadCam = 0, DriverCam, WideRoadCam }; const bool env_send_driver = getenv("SEND_DRIVER") != NULL; const bool env_send_road = getenv("SEND_ROAD") != NULL; const bool env_send_wide_road = getenv("SEND_WIDE_ROAD") != NULL; typedef void (*release_cb)(void *cookie, int buf_idx); typedef struct CameraInfo { int frame_width, frame_height; int frame_stride; bool bayer; int bayer_flip; bool hdr; } CameraInfo; typedef struct LogCameraInfo { CameraType type; const char* filename; const char* frame_packet_name; const char* encode_idx_name; VisionStreamType stream_type; int frame_width, frame_height; int fps; int bitrate; bool is_h265; bool downscale; bool has_qcamera; bool trigger_rotate; bool enable; } LogCameraInfo; typedef struct FrameMetadata { uint32_t frame_id; unsigned int frame_length; // Timestamps uint64_t timestamp_sof; // only set on tici uint64_t timestamp_eof; // Exposure unsigned int integ_lines; bool high_conversion_gain; float gain; float measured_grey_fraction; float target_grey_fraction; // Focus unsigned int lens_pos; float lens_sag; float lens_err; float lens_true_pos; } FrameMetadata; typedef struct CameraExpInfo { int op_id; float grey_frac; } CameraExpInfo; struct MultiCameraState; struct CameraState; class CameraBuf { private: VisionIpcServer *vipc_server; CameraState *camera_state; cl_kernel krnl_debayer; std::unique_ptr rgb2yuv; VisionStreamType rgb_type, yuv_type; int cur_buf_idx; SafeQueue safe_queue; int frame_buf_count; release_cb release_callback; public: cl_command_queue q; FrameMetadata cur_frame_data; VisionBuf *cur_rgb_buf; VisionBuf *cur_yuv_buf; std::unique_ptr camera_bufs; std::unique_ptr camera_bufs_metadata; int rgb_width, rgb_height, rgb_stride; mat3 yuv_transform; CameraBuf() = default; ~CameraBuf(); void init(cl_device_id device_id, cl_context context, CameraState *s, VisionIpcServer * v, int frame_cnt, VisionStreamType rgb_type, VisionStreamType yuv_type, release_cb release_callback=nullptr); bool acquire(); void release(); void queue(size_t buf_idx); }; typedef void (*process_thread_cb)(MultiCameraState *s, CameraState *c, int cnt); void fill_frame_data(cereal::FrameData::Builder &framed, const FrameMetadata &frame_data); kj::Array get_frame_image(const CameraBuf *b); float set_exposure_target(const CameraBuf *b, int x_start, int x_end, int x_skip, int y_start, int y_end, int y_skip); std::thread start_process_thread(MultiCameraState *cameras, CameraState *cs, process_thread_cb callback); void common_process_driver_camera(SubMaster *sm, PubMaster *pm, CameraState *c, int cnt); void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx); void cameras_open(MultiCameraState *s); void cameras_run(MultiCameraState *s); void cameras_close(MultiCameraState *s); void camera_autoexposure(CameraState *s, float grey_frac); ================================================ FILE: selfdrive/camerad/cameras/camera_frame_stream.cc ================================================ #include "selfdrive/camerad/cameras/camera_frame_stream.h" #include #include #include #include "cereal/messaging/messaging.h" #include "selfdrive/common/util.h" #define FRAME_WIDTH 1164 #define FRAME_HEIGHT 874 extern ExitHandler do_exit; namespace { // TODO: make this more generic CameraInfo cameras_supported[CAMERA_ID_MAX] = { [CAMERA_ID_IMX298] = { .frame_width = FRAME_WIDTH, .frame_height = FRAME_HEIGHT, .frame_stride = FRAME_WIDTH*3, .bayer = false, .bayer_flip = false, }, [CAMERA_ID_OV8865] = { .frame_width = 1632, .frame_height = 1224, .frame_stride = 2040, // seems right .bayer = false, .bayer_flip = 3, .hdr = false }, }; void camera_init(VisionIpcServer * v, CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) { assert(camera_id < std::size(cameras_supported)); s->ci = cameras_supported[camera_id]; assert(s->ci.frame_width != 0); s->camera_num = camera_id; s->fps = fps; s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type); } void run_frame_stream(CameraState &camera, const char* frame_pkt) { SubMaster sm({frame_pkt}); size_t buf_idx = 0; while (!do_exit) { sm.update(1000); if(sm.updated(frame_pkt)) { auto msg = static_cast(sm[frame_pkt]); auto frame = msg.get(frame_pkt).as(); camera.buf.camera_bufs_metadata[buf_idx] = { .frame_id = frame.get("frameId").as(), .timestamp_eof = frame.get("timestampEof").as(), .timestamp_sof = frame.get("timestampSof").as(), }; cl_command_queue q = camera.buf.camera_bufs[buf_idx].copy_q; cl_mem yuv_cl = camera.buf.camera_bufs[buf_idx].buf_cl; auto image = frame.get("image").as(); clEnqueueWriteBuffer(q, yuv_cl, CL_TRUE, 0, image.size(), image.begin(), 0, NULL, NULL); camera.buf.queue(buf_idx); buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT; } } } } // namespace void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { camera_init(v, &s->road_cam, CAMERA_ID_IMX298, 20, device_id, ctx, VISION_STREAM_RGB_BACK, VISION_STREAM_YUV_BACK); camera_init(v, &s->driver_cam, CAMERA_ID_OV8865, 10, device_id, ctx, VISION_STREAM_RGB_FRONT, VISION_STREAM_YUV_FRONT); } void cameras_open(MultiCameraState *s) {} void cameras_close(MultiCameraState *s) {} void camera_autoexposure(CameraState *s, float grey_frac) {} void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) {} void cameras_run(MultiCameraState *s) { std::thread t = start_process_thread(s, &s->road_cam, process_road_camera); set_thread_name("frame_streaming"); run_frame_stream(s->road_cam, "roadCameraState"); t.join(); } ================================================ FILE: selfdrive/camerad/cameras/camera_frame_stream.h ================================================ #pragma once #define CL_USE_DEPRECATED_OPENCL_1_2_APIS #ifdef __APPLE__ #include #else #include #endif #include "camera_common.h" #define FRAME_BUF_COUNT 16 typedef struct CameraState { int camera_num; CameraInfo ci; int fps; float digital_gain; CameraBuf buf; } CameraState; typedef struct MultiCameraState { CameraState road_cam; CameraState driver_cam; SubMaster *sm; PubMaster *pm; } MultiCameraState; ================================================ FILE: selfdrive/camerad/cameras/camera_mipi.cc ================================================ #include "selfdrive/camerad/cameras/camera_mipi.h" #include #include #include #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundefined-inline" #include #include #include #pragma clang diagnostic pop #include "selfdrive/common/clutil.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/common/timing.h" #include "selfdrive/common/util.h" #define FRAME_WIDTH 1164 #define FRAME_HEIGHT 874 extern ExitHandler do_exit; namespace { CameraInfo cameras_supported[CAMERA_ID_MAX] = { // road facing [CAMERA_ID_IMX477] = { .frame_width = FRAME_WIDTH, .frame_height = FRAME_HEIGHT, .frame_stride = FRAME_WIDTH*3, .bayer = false, .bayer_flip = false, }, }; std::string gstreamer_pipeline(int sensor_mode, int sensor_id, int flip_method, int display_width, int display_height) { // sensor mode 1 = 1920 x 1080 return "nvarguscamerasrc sensor_mode=" + std::to_string(sensor_mode) + " sensor_id=" + std::to_string(sensor_id) + " ! video/x-raw(memory:NVMM)" + ", format=(string)NV12" + ", framerate=(fraction)20/1" + ", width=(int)" + std::to_string(display_width) + ", height=(int)" + std::to_string(display_height) + " ! nvvidconv flip-method=" + std::to_string(flip_method) + " ! video/x-raw, format=BGRx" + " ! videoconvert ! video/x-raw, format=(string)BGR" + " ! appsink"; } void camera_open(CameraState *s, bool rear) { // empty } void camera_close(CameraState *s) { // empty } void camera_init(VisionIpcServer * v, CameraState *s, int camera_id, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) { assert(camera_id < std::size(cameras_supported)); s->ci = cameras_supported[camera_id]; assert(s->ci.frame_width != 0); s->camera_num = camera_id; s->fps = fps; s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type); } void run_camera(CameraState *s, cv::VideoCapture &video_cap, float *ts) { assert(video_cap.isOpened()); cv::Size size(s->ci.frame_width, s->ci.frame_height); const cv::Mat transform = cv::Mat(3, 3, CV_32F, ts); uint32_t frame_id = 0; size_t buf_idx = 0; while (!do_exit) { cv::Mat frame_mat, transformed_mat; video_cap >> frame_mat; cv::warpPerspective(frame_mat, transformed_mat, transform, size, cv::INTER_LINEAR, cv::BORDER_CONSTANT, 0); s->buf.camera_bufs_metadata[buf_idx] = {.frame_id = frame_id}; auto &buf = s->buf.camera_bufs[buf_idx]; int transformed_size = transformed_mat.total() * transformed_mat.elemSize(); CL_CHECK(clEnqueueWriteBuffer(buf.copy_q, buf.buf_cl, CL_TRUE, 0, transformed_size, transformed_mat.data, 0, NULL, NULL)); s->buf.queue(buf_idx); ++frame_id; buf_idx = (buf_idx + 1) % FRAME_BUF_COUNT; } } static void road_camera_thread(CameraState *s) { set_thread_name("mipi_road_camera_thread"); std::string pipeline = gstreamer_pipeline( 1, // sensor mode 0, // sensor id 2, // flip method 864, // width 486); // height cv::VideoCapture cap_road(pipeline, cv::CAP_GSTREAMER); // road float ts[9] = {1.50330396, 0.0, -59.40969163, 0.0, 1.50330396, 76.20704846, 0.0, 0.0, 1.0}; run_camera(s, cap_road, ts); } } // namespace void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { camera_init(v, &s->road_cam, CAMERA_ID_IMX477, 20, device_id, ctx, VISION_STREAM_RGB_BACK, VISION_STREAM_YUV_BACK); s->pm = new PubMaster({"roadCameraState", "thumbnail"}); } void camera_autoexposure(CameraState *s, float grey_frac) {} void cameras_open(MultiCameraState *s) { camera_open(&s->road_cam, true); } void cameras_close(MultiCameraState *s) { camera_close(&s->road_cam); delete s->pm; } void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { const CameraBuf *b = &c->buf; MessageBuilder msg; auto framed = msg.initEvent().initRoadCameraState(); fill_frame_data(framed, b->cur_frame_data); framed.setImage(kj::arrayPtr((const uint8_t *)b->cur_yuv_buf->addr, b->cur_yuv_buf->len)); framed.setTransform(b->yuv_transform.v); s->pm->send("roadCameraState", msg); } void cameras_run(MultiCameraState *s) { std::vector threads; threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); std::thread t_rear = std::thread(road_camera_thread, &s->road_cam); set_thread_name("mipi_thread"); t_rear.join(); for (auto &t : threads) t.join(); cameras_close(s); } ================================================ FILE: selfdrive/camerad/cameras/camera_mipi.h ================================================ #pragma once #ifdef __APPLE__ #include #else #include #endif #include "selfdrive/camerad/cameras/camera_common.h" #define FRAME_BUF_COUNT 16 typedef struct CameraState { CameraInfo ci; int camera_num; int fps; float digital_gain; CameraBuf buf; } CameraState; typedef struct MultiCameraState { CameraState road_cam; CameraState driver_cam; SubMaster *sm; PubMaster *pm; } MultiCameraState; ================================================ FILE: selfdrive/camerad/cameras/camera_qcom.cc ================================================ #include "selfdrive/camerad/cameras/camera_qcom.h" #include #include #include #include #include #include #include #include #include #include #include #include "selfdrive/camerad/cameras/sensor_i2c.h" #include "selfdrive/camerad/include/msm_cam_sensor.h" #include "selfdrive/camerad/include/msmb_camera.h" #include "selfdrive/camerad/include/msmb_isp.h" #include "selfdrive/camerad/include/msmb_ispif.h" #include "selfdrive/common/clutil.h" #include "selfdrive/common/params.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/common/timing.h" #include "selfdrive/common/util.h" // leeco actuator (DW9800W H-Bridge Driver IC) // from sniff //const uint16_t INFINITY_DAC = 364; extern ExitHandler do_exit; static int cam_ioctl(int fd, unsigned long int request, void *arg, const char *log_msg = nullptr) { int err = HANDLE_EINTR(ioctl(fd, request, arg)); if (err != 0 && log_msg) { LOG(util::string_format("%s: %d", log_msg, err).c_str()); } return err; } // global var for AE/AF ops std::atomic road_cam_exp{{0}}; std::atomic driver_cam_exp{{0}}; CameraInfo cameras_supported[CAMERA_ID_MAX] = { [CAMERA_ID_IMX298] = { .frame_width = 2328, .frame_height = 1748, .frame_stride = 2912, .bayer = true, .bayer_flip = 0, .hdr = true }, [CAMERA_ID_IMX179] = { .frame_width = 3280, .frame_height = 2464, .frame_stride = 4104, .bayer = true, .bayer_flip = 0, .hdr = false }, [CAMERA_ID_S5K3P8SP] = { .frame_width = 2304, .frame_height = 1728, .frame_stride = 2880, .bayer = true, .bayer_flip = 1, .hdr = false }, [CAMERA_ID_OV8865] = { .frame_width = 1632, .frame_height = 1224, .frame_stride = 2040, // seems right .bayer = true, .bayer_flip = 3, .hdr = false }, // this exists to get the kernel to build for the LeEco in release [CAMERA_ID_IMX298_FLIPPED] = { .frame_width = 2328, .frame_height = 1748, .frame_stride = 2912, .bayer = true, .bayer_flip = 3, .hdr = true }, [CAMERA_ID_OV10640] = { .frame_width = 1280, .frame_height = 1080, .frame_stride = 2040, .bayer = true, .bayer_flip = 0, .hdr = true }, }; static void camera_release_buffer(void* cookie, int buf_idx) { CameraState *s = (CameraState *)cookie; // printf("camera_release_buffer %d\n", buf_idx); s->ss[0].qbuf_info[buf_idx].dirty_buf = 1; HANDLE_EINTR(ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &s->ss[0].qbuf_info[buf_idx])); } int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, msm_camera_i2c_data_type data_type) { struct msm_camera_i2c_reg_setting out_settings = { .reg_setting = arr, .size = (uint16_t)size, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .data_type = data_type, .delay = 0, }; sensorb_cfg_data cfg_data = {.cfgtype = CFG_WRITE_I2C_ARRAY, .cfg.setting = &out_settings}; return HANDLE_EINTR(ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &cfg_data)); } static int imx298_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { int analog_gain = std::min(gain, 448); s->digital_gain = gain > 448 ? (512.0/(512-(gain))) / 8.0 : 1.0; //printf("%5d/%5d %5d %f\n", s->cur_integ_lines, s->frame_length, analog_gain, s->digital_gain); struct msm_camera_i2c_reg_array reg_array[] = { // REG_HOLD {0x104,0x1,0}, {0x3002,0x0,0}, // long autoexposure off // FRM_LENGTH {0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0}, // INTEG_TIME aka coarse_int_time_addr aka shutter speed {0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0}, // global_gain_addr // if you assume 1x gain is 32, 448 is 14x gain, aka 2^14=16384 {0x204, (uint16_t)(analog_gain >> 8), 0}, {0x205, (uint16_t)(analog_gain & 0xff),0}, // digital gain for colors: gain_greenR, gain_red, gain_blue, gain_greenB /*{0x20e, digital_gain_gr >> 8, 0}, {0x20f,digital_gain_gr & 0xFF,0}, {0x210, digital_gain_r >> 8, 0}, {0x211,digital_gain_r & 0xFF,0}, {0x212, digital_gain_b >> 8, 0}, {0x213,digital_gain_b & 0xFF,0}, {0x214, digital_gain_gb >> 8, 0}, {0x215,digital_gain_gb & 0xFF,0},*/ // REG_HOLD {0x104,0x0,0}, }; return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); } static int ov8865_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { //printf("driver camera: %d %d %d\n", gain, integ_lines, frame_length); int coarse_gain_bitmap, fine_gain_bitmap; // get bitmaps from iso static const int gains[] = {0, 100, 200, 400, 800}; int i; for (i = 1; i < std::size(gains); i++) { if (gain >= gains[i - 1] && gain < gains[i]) break; } int coarse_gain = i - 1; float fine_gain = (gain - gains[coarse_gain])/(float)(gains[coarse_gain+1]-gains[coarse_gain]); coarse_gain_bitmap = (1 << coarse_gain) - 1; fine_gain_bitmap = ((int)(16*fine_gain) << 3) + 128; // 7th is always 1, 0-2nd are always 0 integ_lines *= 16; // The exposure value in reg is in 16ths of a line struct msm_camera_i2c_reg_array reg_array[] = { //{0x104,0x1,0}, // FRM_LENGTH {0x380e, (uint16_t)(frame_length >> 8), 0}, {0x380f, (uint16_t)(frame_length & 0xff), 0}, // AEC EXPO {0x3500, (uint16_t)(integ_lines >> 16), 0}, {0x3501, (uint16_t)(integ_lines >> 8), 0}, {0x3502, (uint16_t)(integ_lines & 0xff),0}, // AEC MANUAL {0x3503, 0x4, 0}, // AEC GAIN {0x3508, (uint16_t)(coarse_gain_bitmap), 0}, {0x3509, (uint16_t)(fine_gain_bitmap), 0}, //{0x104,0x0,0}, }; return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); } static int imx179_s5k3p8sp_apply_exposure(CameraState *s, int gain, int integ_lines, uint32_t frame_length) { //printf("driver camera: %d %d %d\n", gain, integ_lines, frame_length); struct msm_camera_i2c_reg_array reg_array[] = { {0x104,0x1,0}, // FRM_LENGTH {0x340, (uint16_t)(frame_length >> 8), 0}, {0x341, (uint16_t)(frame_length & 0xff), 0}, // coarse_int_time {0x202, (uint16_t)(integ_lines >> 8), 0}, {0x203, (uint16_t)(integ_lines & 0xff),0}, // global_gain {0x204, (uint16_t)(gain >> 8), 0}, {0x205, (uint16_t)(gain & 0xff),0}, // REG_HOLD {0x104,0x0,0}, }; return sensor_write_regs(s, reg_array, std::size(reg_array), MSM_CAMERA_I2C_BYTE_DATA); } static void camera_init(VisionIpcServer *v, CameraState *s, int camera_id, int camera_num, uint32_t pixel_clock, uint32_t line_length_pclk, uint32_t max_gain, uint32_t fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) { s->camera_num = camera_num; s->camera_id = camera_id; assert(camera_id < std::size(cameras_supported)); s->ci = cameras_supported[camera_id]; assert(s->ci.frame_width != 0); s->pixel_clock = pixel_clock; s->max_gain = max_gain; s->fps = fps; s->frame_length = s->pixel_clock / line_length_pclk / s->fps; s->self_recover = 0; if (camera_id == CAMERA_ID_IMX298) { s->apply_exposure = imx298_apply_exposure; } else if (camera_id == CAMERA_ID_S5K3P8SP || camera_id == CAMERA_ID_IMX179) { s->apply_exposure = imx179_s5k3p8sp_apply_exposure; } else { s->apply_exposure = ov8865_apply_exposure; } s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type, camera_release_buffer); } void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { char project_name[1024] = {0}; property_get("ro.boot.project_name", project_name, ""); char product_name[1024] = {0}; property_get("ro.product.name", product_name, ""); if (strlen(project_name) == 0) { LOGD("LePro 3 op system detected"); s->device = DEVICE_LP3; // sensor is flipped in LP3 // IMAGE_ORIENT = 3 init_array_imx298[0].reg_data = 3; cameras_supported[CAMERA_ID_IMX298].bayer_flip = 3; } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") != 0) { // no more OP3 support s->device = DEVICE_OP3; assert(false); } else if (strcmp(product_name, "OnePlus3") == 0 && strcmp(project_name, "15811") == 0) { // only OP3T support s->device = DEVICE_OP3T; } else { assert(false); } // 0 = ISO 100 // 256 = ISO 200 // 384 = ISO 400 // 448 = ISO 800 // 480 = ISO 1600 // 496 = ISO 3200 // 504 = ISO 6400, 8x digital gain // 508 = ISO 12800, 16x digital gain // 510 = ISO 25600, 32x digital gain camera_init(v, &s->road_cam, CAMERA_ID_IMX298, 0, /*pixel_clock=*/600000000, /*line_length_pclk=*/5536, /*max_gain=*/510, //0 (ISO 100)- 448 (ISO 800, max analog gain) - 511 (super noisy) #ifdef HIGH_FPS /*fps*/ 60, #else /*fps*/ 20, #endif device_id, ctx, VISION_STREAM_RGB_BACK, VISION_STREAM_YUV_BACK); s->road_cam.apply_exposure = imx298_apply_exposure; if (s->device == DEVICE_OP3T) { camera_init(v, &s->driver_cam, CAMERA_ID_S5K3P8SP, 1, /*pixel_clock=*/560000000, /*line_length_pclk=*/5120, /*max_gain=*/510, 10, device_id, ctx, VISION_STREAM_RGB_FRONT, VISION_STREAM_YUV_FRONT); s->driver_cam.apply_exposure = imx179_s5k3p8sp_apply_exposure; } else if (s->device == DEVICE_LP3) { camera_init(v, &s->driver_cam, CAMERA_ID_OV8865, 1, /*pixel_clock=*/72000000, /*line_length_pclk=*/1602, /*max_gain=*/510, 10, device_id, ctx, VISION_STREAM_RGB_FRONT, VISION_STREAM_YUV_FRONT); s->driver_cam.apply_exposure = ov8865_apply_exposure; } else { camera_init(v, &s->driver_cam, CAMERA_ID_IMX179, 1, /*pixel_clock=*/251200000, /*line_length_pclk=*/3440, /*max_gain=*/224, 20, device_id, ctx, VISION_STREAM_RGB_FRONT, VISION_STREAM_YUV_FRONT); s->driver_cam.apply_exposure = imx179_s5k3p8sp_apply_exposure; } s->road_cam.device = s->device; s->driver_cam.device = s->device; s->sm = new SubMaster({"driverState"}); s->pm = new PubMaster({"roadCameraState", "driverCameraState", "thumbnail"}); for (int i = 0; i < FRAME_BUF_COUNT; i++) { // TODO: make lengths correct s->focus_bufs[i].allocate(0xb80); s->stats_bufs[i].allocate(0xb80); } std::fill_n(s->lapres, std::size(s->lapres), 16160); s->lap_conv = new LapConv(device_id, ctx, s->road_cam.buf.rgb_width, s->road_cam.buf.rgb_height, 3); } static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) { int err = 0; uint32_t gain = s->cur_gain; uint32_t integ_lines = s->cur_integ_lines; if (exposure_frac >= 0) { exposure_frac = std::clamp(exposure_frac, 2.0f / s->frame_length, 1.0f); integ_lines = s->frame_length * exposure_frac; // See page 79 of the datasheet, this is the max allowed (-1 for phase adjust) integ_lines = std::min(integ_lines, s->frame_length - 11); } if (gain_frac >= 0) { // ISO200 is minimum gain gain_frac = std::clamp(gain_frac, 1.0f/64, 1.0f); // linearize gain response // TODO: will be wrong for driver camera // 0.125 -> 448 // 0.25 -> 480 // 0.5 -> 496 // 1.0 -> 504 // 512 - 512/(128*gain_frac) gain = (s->max_gain/510) * (512 - 512/(256*gain_frac)); } if (gain != s->cur_gain || integ_lines != s->cur_integ_lines) { if (s->apply_exposure == ov8865_apply_exposure) { gain = 800 * gain_frac; // ISO err = s->apply_exposure(s, gain, integ_lines, s->frame_length); } else if (s->apply_exposure) { err = s->apply_exposure(s, gain, integ_lines, s->frame_length); } if (err == 0) { std::lock_guard lk(s->frame_info_lock); s->cur_gain = gain; s->cur_integ_lines = integ_lines; } else { LOGE("camera %d apply_exposure err: %d", s->camera_num, err); } } if (err == 0) { s->cur_exposure_frac = exposure_frac; std::lock_guard lk(s->frame_info_lock); s->cur_gain_frac = gain_frac; } //LOGD("set exposure: %f %f - %d", exposure_frac, gain_frac, err); } static void do_autoexposure(CameraState *s, float grey_frac) { const float target_grey = 0.3; s->frame_info_lock.lock(); s->measured_grey_fraction = grey_frac; s->target_grey_fraction = target_grey; s->frame_info_lock.unlock(); if (s->apply_exposure == ov8865_apply_exposure) { // gain limits downstream const float gain_frac_min = 0.015625; const float gain_frac_max = 1.0; // exposure time limits const uint32_t exposure_time_min = 16; const uint32_t exposure_time_max = s->frame_length - 11; // copied from set_exposure() float cur_gain_frac = s->cur_gain_frac; float exposure_factor = pow(1.05, (target_grey - grey_frac) / 0.05); if (cur_gain_frac > 0.125 && exposure_factor < 1) { cur_gain_frac *= exposure_factor; } else if (s->cur_integ_lines * exposure_factor <= exposure_time_max && s->cur_integ_lines * exposure_factor >= exposure_time_min) { // adjust exposure time first s->cur_exposure_frac *= exposure_factor; } else if (cur_gain_frac * exposure_factor <= gain_frac_max && cur_gain_frac * exposure_factor >= gain_frac_min) { cur_gain_frac *= exposure_factor; } s->frame_info_lock.lock(); s->cur_gain_frac = cur_gain_frac; s->frame_info_lock.unlock(); set_exposure(s, s->cur_exposure_frac, cur_gain_frac); } else { // keep the old for others float new_exposure = s->cur_exposure_frac; new_exposure *= pow(1.05, (target_grey - grey_frac) / 0.05 ); //LOGD("diff %f: %f to %f", target_grey - grey_frac, s->cur_exposure_frac, new_exposure); float new_gain = s->cur_gain_frac; if (new_exposure < 0.10) { new_gain *= 0.95; } else if (new_exposure > 0.40) { new_gain *= 1.05; } set_exposure(s, new_exposure, new_gain); } } static uint8_t* get_eeprom(int eeprom_fd, size_t *out_len) { msm_eeprom_cfg_data cfg = {.cfgtype = CFG_EEPROM_GET_CAL_DATA}; int err = cam_ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg, "get_eeprom begin"); assert(err >= 0); uint32_t num_bytes = cfg.cfg.get_data.num_bytes; assert(num_bytes > 100); uint8_t* buffer = (uint8_t*)malloc(num_bytes); assert(buffer); memset(buffer, 0, num_bytes); cfg.cfgtype = CFG_EEPROM_READ_CAL_DATA; cfg.cfg.read_data.num_bytes = num_bytes; cfg.cfg.read_data.dbuffer = buffer; err = cam_ioctl(eeprom_fd, VIDIOC_MSM_EEPROM_CFG, &cfg, "get_eeprom end"); assert(err >= 0); *out_len = num_bytes; return buffer; } static void imx298_ois_calibration(int ois_fd, uint8_t* eeprom) { const int ois_registers[][2] = { // == SET_FADJ_PARAM() == (factory adjustment) // Set Hall Current DAC {0x8230, *(uint16_t*)(eeprom+0x102)}, //_P_30_ADC_CH0 (CURDAT) // Set Hall PreAmp Offset {0x8231, *(uint16_t*)(eeprom+0x104)}, //_P_31_ADC_CH1 (HALOFS_X) {0x8232, *(uint16_t*)(eeprom+0x106)}, //_P_32_ADC_CH2 (HALOFS_Y) // Set Hall-X/Y PostAmp Offset {0x841e, *(uint16_t*)(eeprom+0x108)}, //_M_X_H_ofs {0x849e, *(uint16_t*)(eeprom+0x10a)}, //_M_Y_H_ofs // Set Residual Offset {0x8239, *(uint16_t*)(eeprom+0x10c)}, //_P_39_Ch3_VAL_1 (PSTXOF) {0x823b, *(uint16_t*)(eeprom+0x10e)}, //_P_3B_Ch3_VAL_3 (PSTYOF) // DIGITAL GYRO OFFSET {0x8406, *(uint16_t*)(eeprom+0x110)}, //_M_Kgx00 {0x8486, *(uint16_t*)(eeprom+0x112)}, //_M_Kgy00 {0x846a, *(uint16_t*)(eeprom+0x120)}, //_M_TMP_X_ {0x846b, *(uint16_t*)(eeprom+0x122)}, //_M_TMP_Y_ // HALLSENSE // Set Hall Gain {0x8446, *(uint16_t*)(eeprom+0x114)}, //_M_KgxHG {0x84c6, *(uint16_t*)(eeprom+0x116)}, //_M_KgyHG // Set Cross Talk Canceller {0x8470, *(uint16_t*)(eeprom+0x124)}, //_M_KgxH0 {0x8472, *(uint16_t*)(eeprom+0x126)}, //_M_KgyH0 // LOOPGAIN {0x840f, *(uint16_t*)(eeprom+0x118)}, //_M_KgxG {0x848f, *(uint16_t*)(eeprom+0x11a)}, //_M_KgyG // Position Servo ON ( OIS OFF ) {0x847f, 0x0c0c}, //_M_EQCTL }; struct msm_camera_i2c_seq_reg_array ois_reg_settings[std::size(ois_registers)] = {{0}}; for (int i=0; i> 8) & 0xff; ois_reg_settings[i].reg_data_size = 2; } struct msm_camera_i2c_seq_reg_setting ois_reg_setting = { .reg_setting = &ois_reg_settings[0], .size = std::size(ois_reg_settings), .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .delay = 0, }; msm_ois_cfg_data cfg = {.cfgtype = CFG_OIS_I2C_WRITE_SEQ_TABLE, .cfg.settings = &ois_reg_setting}; cam_ioctl(ois_fd, VIDIOC_MSM_OIS_CFG, &cfg, "ois reg calibration"); } static void sensors_init(MultiCameraState *s) { int err; unique_fd sensorinit_fd; if (s->device == DEVICE_LP3) { sensorinit_fd = HANDLE_EINTR(open("/dev/v4l-subdev11", O_RDWR | O_NONBLOCK)); } else { sensorinit_fd = (open("/dev/v4l-subdev12", O_RDWR | O_NONBLOCK)); } assert(sensorinit_fd >= 0); // init road camera sensor struct msm_camera_sensor_slave_info slave_info = {0}; if (s->device == DEVICE_LP3) { slave_info = (struct msm_camera_sensor_slave_info){ .sensor_name = "imx298", .eeprom_name = "sony_imx298", .actuator_name = "dw9800w", .ois_name = "", .flash_name = "pmic", .camera_id = CAMERA_0, .slave_addr = 32, .i2c_freq_mode = I2C_FAST_MODE, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .sensor_id_info = {.sensor_id_reg_addr = 22, .sensor_id = 664, .module_id = 9, .vcm_id = 6}, .power_setting_array = { .power_setting_a = { {.seq_type = SENSOR_GPIO, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 2}, {.seq_type = SENSOR_GPIO, .seq_val = 5, .config_val = 2}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 1}, {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 10}, }, .size = 7, .power_down_setting_a = { {.seq_type = SENSOR_CLK, .delay = 1}, {.seq_type = SENSOR_GPIO, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_GPIO, .seq_val = 5}, {.seq_type = SENSOR_VREG, .seq_val = 2}, {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 1}, }, .size_down = 6, }, .is_init_params_valid = 0, .sensor_init_params = {.modes_supported = 1, .position = BACK_CAMERA_B, .sensor_mount_angle = 90}, .output_format = MSM_SENSOR_BAYER, }; } else { slave_info = (struct msm_camera_sensor_slave_info){ .sensor_name = "imx298", .eeprom_name = "sony_imx298", .actuator_name = "rohm_bu63165gwl", .ois_name = "rohm_bu63165gwl", .camera_id = CAMERA_0, .slave_addr = 52, .i2c_freq_mode = I2C_CUSTOM_MODE, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .sensor_id_info = {.sensor_id_reg_addr = 22, .sensor_id = 664}, .power_setting_array = { .power_setting_a = { {.seq_type = SENSOR_GPIO, .delay = 2}, {.seq_type = SENSOR_VREG, .seq_val = 2, .delay = 2}, {.seq_type = SENSOR_VREG, .delay = 2}, {.seq_type = SENSOR_VREG, .seq_val = 1, .delay = 2}, {.seq_type = SENSOR_GPIO, .seq_val = 6, .config_val = 2}, {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 5}, {.seq_type = SENSOR_VREG, .seq_val = 4, .delay = 5}, {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 2}, {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 2}, }, .size = 9, .power_down_setting_a = { {.seq_type = SENSOR_GPIO, .delay = 10}, {.seq_type = SENSOR_CLK, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 4}, {.seq_type = SENSOR_VREG, .seq_val = 3, .delay = 1}, {.seq_type = SENSOR_GPIO, .seq_val = 6}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_VREG}, {.seq_type = SENSOR_VREG, .seq_val = 2}, }, .size_down = 8, }, .is_init_params_valid = 0, .sensor_init_params = {.modes_supported = 1, .position = BACK_CAMERA_B, .sensor_mount_angle = 360}, .output_format = MSM_SENSOR_BAYER, }; } slave_info.power_setting_array.power_setting = (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_setting_a[0]; slave_info.power_setting_array.power_down_setting = (struct msm_sensor_power_setting *)&slave_info.power_setting_array.power_down_setting_a[0]; sensor_init_cfg_data sensor_init_cfg = {.cfgtype = CFG_SINIT_PROBE, .cfg.setting = &slave_info}; err = cam_ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg, "sensor init cfg (road)"); assert(err >= 0); struct msm_camera_sensor_slave_info slave_info2 = {0}; if (s->device == DEVICE_LP3) { slave_info2 = (struct msm_camera_sensor_slave_info){ .sensor_name = "ov8865_sunny", .eeprom_name = "ov8865_plus", .actuator_name = "", .ois_name = "", .flash_name = "", .camera_id = CAMERA_2, .slave_addr = 108, .i2c_freq_mode = I2C_FAST_MODE, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .sensor_id_info = {.sensor_id_reg_addr = 12299, .sensor_id = 34917, .module_id = 2}, .power_setting_array = { .power_setting_a = { {.seq_type = SENSOR_GPIO, .delay = 5}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_VREG, .seq_val = 2}, {.seq_type = SENSOR_VREG}, {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 1}, }, .size = 6, .power_down_setting_a = { {.seq_type = SENSOR_GPIO, .delay = 5}, {.seq_type = SENSOR_CLK, .delay = 1}, {.seq_type = SENSOR_VREG}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_VREG, .seq_val = 2, .delay = 1}, }, .size_down = 5, }, .is_init_params_valid = 0, .sensor_init_params = {.modes_supported = 1, .position = FRONT_CAMERA_B, .sensor_mount_angle = 270}, .output_format = MSM_SENSOR_BAYER, }; } else if (s->driver_cam.camera_id == CAMERA_ID_S5K3P8SP) { // init driver camera slave_info2 = (struct msm_camera_sensor_slave_info){ .sensor_name = "s5k3p8sp", .eeprom_name = "s5k3p8sp_m24c64s", .actuator_name = "", .ois_name = "", .camera_id = CAMERA_1, .slave_addr = 32, .i2c_freq_mode = I2C_FAST_MODE, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .sensor_id_info = {.sensor_id = 12552}, .power_setting_array = { .power_setting_a = { {.seq_type = SENSOR_GPIO, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 2, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 1, .delay = 1}, {.seq_type = SENSOR_VREG, .delay = 1}, {.seq_type = SENSOR_CLK, .config_val = 24000000, .delay = 1}, {.seq_type = SENSOR_GPIO, .config_val = 2, .delay = 1}, }, .size = 6, .power_down_setting_a = { {.seq_type = SENSOR_CLK, .delay = 1}, {.seq_type = SENSOR_GPIO, .delay = 1}, {.seq_type = SENSOR_VREG, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 1, .delay = 1}, {.seq_type = SENSOR_VREG, .seq_val = 2, .delay = 1}, }, .size_down = 5, }, .is_init_params_valid = 0, .sensor_init_params = {.modes_supported = 1, .position = FRONT_CAMERA_B, .sensor_mount_angle = 270}, .output_format = MSM_SENSOR_BAYER, }; } else { // init driver camera slave_info2 = (struct msm_camera_sensor_slave_info){ .sensor_name = "imx179", .eeprom_name = "sony_imx179", .actuator_name = "", .ois_name = "", .camera_id = CAMERA_1, .slave_addr = 32, .i2c_freq_mode = I2C_FAST_MODE, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .sensor_id_info = {.sensor_id_reg_addr = 2, .sensor_id = 377, .sensor_id_mask = 4095}, .power_setting_array = { .power_setting_a = { {.seq_type = SENSOR_VREG, .seq_val = 2}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_VREG}, {.seq_type = SENSOR_GPIO, .config_val = 2}, {.seq_type = SENSOR_CLK, .config_val = 24000000}, }, .size = 5, .power_down_setting_a = { {.seq_type = SENSOR_CLK}, {.seq_type = SENSOR_GPIO, .delay = 1}, {.seq_type = SENSOR_VREG, .delay = 2}, {.seq_type = SENSOR_VREG, .seq_val = 1}, {.seq_type = SENSOR_VREG, .seq_val = 2}, }, .size_down = 5, }, .is_init_params_valid = 0, .sensor_init_params = {.modes_supported = 1, .position = FRONT_CAMERA_B, .sensor_mount_angle = 270}, .output_format = MSM_SENSOR_BAYER, }; } slave_info2.power_setting_array.power_setting = (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_setting_a[0]; slave_info2.power_setting_array.power_down_setting = (struct msm_sensor_power_setting *)&slave_info2.power_setting_array.power_down_setting_a[0]; sensor_init_cfg.cfgtype = CFG_SINIT_PROBE; sensor_init_cfg.cfg.setting = &slave_info2; err = cam_ioctl(sensorinit_fd, VIDIOC_MSM_SENSOR_INIT_CFG, &sensor_init_cfg, "sensor init cfg (driver)"); assert(err >= 0); } static void camera_open(CameraState *s, bool is_road_cam) { int err; struct csid_cfg_data csid_cfg_data = {}; struct v4l2_event_subscription sub = {}; struct msm_actuator_cfg_data actuator_cfg_data = {}; struct msm_ois_cfg_data ois_cfg_data = {}; // open devices const char *sensor_dev; if (is_road_cam) { s->csid_fd = HANDLE_EINTR(open("/dev/v4l-subdev3", O_RDWR | O_NONBLOCK)); assert(s->csid_fd >= 0); s->csiphy_fd = HANDLE_EINTR(open("/dev/v4l-subdev0", O_RDWR | O_NONBLOCK)); assert(s->csiphy_fd >= 0); if (s->device == DEVICE_LP3) { sensor_dev = "/dev/v4l-subdev17"; } else { sensor_dev = "/dev/v4l-subdev18"; } if (s->device == DEVICE_LP3) { s->isp_fd = HANDLE_EINTR(open("/dev/v4l-subdev13", O_RDWR | O_NONBLOCK)); } else { s->isp_fd = HANDLE_EINTR(open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK)); } assert(s->isp_fd >= 0); s->eeprom_fd = HANDLE_EINTR(open("/dev/v4l-subdev8", O_RDWR | O_NONBLOCK)); assert(s->eeprom_fd >= 0); s->actuator_fd = HANDLE_EINTR(open("/dev/v4l-subdev7", O_RDWR | O_NONBLOCK)); assert(s->actuator_fd >= 0); if (s->device != DEVICE_LP3) { s->ois_fd = HANDLE_EINTR(open("/dev/v4l-subdev10", O_RDWR | O_NONBLOCK)); assert(s->ois_fd >= 0); } } else { s->csid_fd = HANDLE_EINTR(open("/dev/v4l-subdev5", O_RDWR | O_NONBLOCK)); assert(s->csid_fd >= 0); s->csiphy_fd = HANDLE_EINTR(open("/dev/v4l-subdev2", O_RDWR | O_NONBLOCK)); assert(s->csiphy_fd >= 0); if (s->device == DEVICE_LP3) { sensor_dev = "/dev/v4l-subdev18"; } else { sensor_dev = "/dev/v4l-subdev19"; } if (s->device == DEVICE_LP3) { s->isp_fd = open("/dev/v4l-subdev14", O_RDWR | O_NONBLOCK); } else { s->isp_fd = open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK); } assert(s->isp_fd >= 0); s->eeprom_fd = open("/dev/v4l-subdev9", O_RDWR | O_NONBLOCK); assert(s->eeprom_fd >= 0); } // wait for sensor device // on first startup, these devices aren't present yet for (int i = 0; i < 10; i++) { s->sensor_fd = HANDLE_EINTR(open(sensor_dev, O_RDWR | O_NONBLOCK)); if (s->sensor_fd >= 0) break; LOGW("waiting for sensors..."); util::sleep_for(1000); // sleep one second } assert(s->sensor_fd >= 0); // *** SHUTDOWN ALL *** // CSIPHY: release csiphy struct msm_camera_csi_lane_params csi_lane_params = {0}; csi_lane_params.csi_lane_mask = 0x1f; csiphy_cfg_data csiphy_cfg_data = { .cfg.csi_lane_params = &csi_lane_params, .cfgtype = CSIPHY_RELEASE}; err = cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "release csiphy"); // CSID: release csid csid_cfg_data.cfgtype = CSID_RELEASE; cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "release csid"); // SENSOR: send power down struct sensorb_cfg_data sensorb_cfg_data = {.cfgtype = CFG_POWER_DOWN}; cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "sensor power down"); // actuator powerdown actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERDOWN; cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator powerdown"); if (is_road_cam && s->device != DEVICE_LP3) { // ois powerdown ois_cfg_data.cfgtype = CFG_OIS_POWERDOWN; err = cam_ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data, "ois powerdown"); } // reset isp // struct msm_vfe_axi_halt_cmd halt_cmd = { // .stop_camif = 1, // .overflow_detected = 1, // .blocking_halt = 1, // }; // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_HALT, &halt_cmd); // printf("axi halt: %d\n", err); // struct msm_vfe_axi_reset_cmd reset_cmd = { // .blocking = 1, // .frame_id = 1, // }; // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESET, &reset_cmd); // printf("axi reset: %d\n", err); // struct msm_vfe_axi_restart_cmd restart_cmd = { // .enable_camif = 1, // }; // err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_AXI_RESTART, &restart_cmd); // printf("axi restart: %d\n", err); // **** GO GO GO **** LOG("******************** GO GO GO ************************"); s->eeprom = get_eeprom(s->eeprom_fd, &s->eeprom_size); // CSID: init csid csid_cfg_data.cfgtype = CSID_INIT; cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "init csid"); // CSIPHY: init csiphy csiphy_cfg_data = {.cfgtype = CSIPHY_INIT}; cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "init csiphy"); // SENSOR: stop stream struct msm_camera_i2c_reg_setting stop_settings = { .reg_setting = stop_reg_array, .size = std::size(stop_reg_array), .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .data_type = MSM_CAMERA_I2C_BYTE_DATA, .delay = 0 }; sensorb_cfg_data.cfgtype = CFG_SET_STOP_STREAM_SETTING; sensorb_cfg_data.cfg.setting = &stop_settings; cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "stop stream"); // SENSOR: send power up sensorb_cfg_data = {.cfgtype = CFG_POWER_UP}; cam_ioctl(s->sensor_fd, VIDIOC_MSM_SENSOR_CFG, &sensorb_cfg_data, "sensor power up"); // **** configure the sensor **** // SENSOR: send i2c configuration if (s->camera_id == CAMERA_ID_IMX298) { err = sensor_write_regs(s, init_array_imx298, std::size(init_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); } else if (s->camera_id == CAMERA_ID_S5K3P8SP) { err = sensor_write_regs(s, init_array_s5k3p8sp, std::size(init_array_s5k3p8sp), MSM_CAMERA_I2C_WORD_DATA); } else if (s->camera_id == CAMERA_ID_IMX179) { err = sensor_write_regs(s, init_array_imx179, std::size(init_array_imx179), MSM_CAMERA_I2C_BYTE_DATA); } else if (s->camera_id == CAMERA_ID_OV8865) { err = sensor_write_regs(s, init_array_ov8865, std::size(init_array_ov8865), MSM_CAMERA_I2C_BYTE_DATA); } else { assert(false); } LOG("sensor init i2c: %d", err); if (is_road_cam) { // init the actuator actuator_cfg_data.cfgtype = CFG_ACTUATOR_POWERUP; cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator powerup"); actuator_cfg_data.cfgtype = CFG_ACTUATOR_INIT; cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator init"); // no OIS in LP3 if (s->device != DEVICE_LP3) { // see sony_imx298_eeprom_format_afdata in libmmcamera_sony_imx298_eeprom.so const float far_margin = -0.28; uint16_t macro_dac = *(uint16_t*)(s->eeprom + 0x24); s->infinity_dac = *(uint16_t*)(s->eeprom + 0x26); LOG("macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac); int dac_range = macro_dac - s->infinity_dac; s->infinity_dac += far_margin * dac_range; LOG(" -> macro_dac: %d infinity_dac: %d", macro_dac, s->infinity_dac); struct msm_actuator_reg_params_t actuator_reg_params[] = { {.reg_write_type = MSM_ACTUATOR_WRITE_DAC, .reg_addr = 240, .data_type = 10, .addr_type = 4}, {.reg_write_type = MSM_ACTUATOR_WRITE_DAC, .reg_addr = 241, .data_type = 10, .addr_type = 4}, {.reg_write_type = MSM_ACTUATOR_WRITE_DAC, .reg_addr = 242, .data_type = 10, .addr_type = 4}, {.reg_write_type = MSM_ACTUATOR_WRITE_DAC, .reg_addr = 243, .data_type = 10, .addr_type = 4}, }; //... struct reg_settings_t actuator_init_settings[1] = {0}; struct region_params_t region_params[] = { {.step_bound = {512, 0,}, .code_per_step = 118, .qvalue = 128} }; actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ .actuator_params = { .act_type = ACTUATOR_VCM, .reg_tbl_size = 4, .data_size = 10, .init_setting_size = 0, .i2c_freq_mode = I2C_CUSTOM_MODE, .i2c_addr = 28, .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, .i2c_data_type = MSM_ACTUATOR_BYTE_DATA, .reg_tbl_params = &actuator_reg_params[0], .init_settings = &actuator_init_settings[0], .park_lens = { .damping_step = 1023, .damping_delay = 15000, .hw_params = 58404, .max_step = 20, } }, .af_tuning_params = { .initial_code = (int16_t)s->infinity_dac, .pwd_step = 0, .region_size = 1, .total_steps = 512, .region_params = ®ion_params[0], }, }; err = cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set info"); // power up ois ois_cfg_data.cfgtype = CFG_OIS_POWERUP; err = cam_ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data, "ois powerup"); ois_cfg_data.cfgtype = CFG_OIS_INIT; err = cam_ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data, "ois init"); ois_cfg_data.cfgtype = CFG_OIS_CONTROL; ois_cfg_data.cfg.set_info.ois_params = (struct msm_ois_params_t){ // .data_size = 26312, .setting_size = 120, .i2c_addr = 28, .i2c_freq_mode = I2C_CUSTOM_MODE, // .i2c_addr_type = wtf // .i2c_data_type = wtf .settings = &ois_init_settings[0], }; cam_ioctl(s->ois_fd, VIDIOC_MSM_OIS_CFG, &ois_cfg_data, "ois init settings"); } else { // leeco actuator (DW9800W H-Bridge Driver IC) // from sniff s->infinity_dac = 364; struct msm_actuator_reg_params_t actuator_reg_params[] = { { .reg_write_type = MSM_ACTUATOR_WRITE_DAC, // MSB here at address 3 .reg_addr = 3, .data_type = 9, .addr_type = 4, }, }; struct reg_settings_t actuator_init_settings[] = { { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=1, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // PD = power down { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=0, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, // 0 = power up { .reg_addr=2, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=2, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 2 }, // RING = SAC mode { .reg_addr=6, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=64, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // 0x40 = SAC3 mode { .reg_addr=7, .addr_type=MSM_ACTUATOR_BYTE_ADDR, .reg_data=113, .data_type = MSM_ACTUATOR_BYTE_DATA, .i2c_operation = MSM_ACT_WRITE, .delay = 0 }, // 0x71 = DIV1 | DIV0 | SACT0 -- Tvib x 1/4 (quarter) // SAC Tvib = 6.3 ms + 0.1 ms = 6.4 ms / 4 = 1.6 ms // LSC 1-step = 252 + 1*4 = 256 ms / 4 = 64 ms }; struct region_params_t region_params[] = { {.step_bound = {238, 0,}, .code_per_step = 235, .qvalue = 128} }; actuator_cfg_data.cfgtype = CFG_SET_ACTUATOR_INFO; actuator_cfg_data.cfg.set_info = (struct msm_actuator_set_info_t){ .actuator_params = { .act_type = ACTUATOR_BIVCM, .reg_tbl_size = 1, .data_size = 10, .init_setting_size = 5, .i2c_freq_mode = I2C_STANDARD_MODE, .i2c_addr = 24, .i2c_addr_type = MSM_ACTUATOR_BYTE_ADDR, .i2c_data_type = MSM_ACTUATOR_WORD_DATA, .reg_tbl_params = &actuator_reg_params[0], .init_settings = &actuator_init_settings[0], .park_lens = {.damping_step = 1023, .damping_delay = 14000, .hw_params = 11, .max_step = 20}, }, .af_tuning_params = { .initial_code = (int16_t)s->infinity_dac, .pwd_step = 0, .region_size = 1, .total_steps = 238, .region_params = ®ion_params[0], }, }; cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set info"); } } if (s->camera_id == CAMERA_ID_IMX298) { err = sensor_write_regs(s, mode_setting_array_imx298, std::size(mode_setting_array_imx298), MSM_CAMERA_I2C_BYTE_DATA); LOG("sensor setup: %d", err); } // CSIPHY: configure csiphy struct msm_camera_csiphy_params csiphy_params = {}; if (s->camera_id == CAMERA_ID_IMX298) { csiphy_params = {.lane_cnt = 4, .settle_cnt = 14, .lane_mask = 0x1f, .csid_core = 0}; } else if (s->camera_id == CAMERA_ID_S5K3P8SP) { csiphy_params = {.lane_cnt = 4, .settle_cnt = 24, .lane_mask = 0x1f, .csid_core = 0}; } else if (s->camera_id == CAMERA_ID_IMX179) { csiphy_params = {.lane_cnt = 4, .settle_cnt = 11, .lane_mask = 0x1f, .csid_core = 2}; } else if (s->camera_id == CAMERA_ID_OV8865) { // guess! csiphy_params = {.lane_cnt = 4, .settle_cnt = 24, .lane_mask = 0x1f, .csid_core = 2}; } csiphy_cfg_data.cfgtype = CSIPHY_CFG; csiphy_cfg_data.cfg.csiphy_params = &csiphy_params; cam_ioctl(s->csiphy_fd, VIDIOC_MSM_CSIPHY_IO_CFG, &csiphy_cfg_data, "csiphy configure"); // CSID: configure csid #define CSI_STATS 0x35 #define CSI_PD 0x36 struct msm_camera_csid_params csid_params = { .lane_cnt = 4, .lane_assign = 0x4320, .phy_sel = (uint8_t)(is_road_cam ? 0 : 2), .lut_params.num_cid = (uint8_t)(is_road_cam ? 3 : 1), .lut_params.vc_cfg_a = { {.cid = 0, .dt = CSI_RAW10, .decode_format = CSI_DECODE_10BIT}, {.cid = 1, .dt = CSI_PD, .decode_format = CSI_DECODE_10BIT}, {.cid = 2, .dt = CSI_STATS, .decode_format = CSI_DECODE_10BIT}, }, }; csid_params.lut_params.vc_cfg[0] = &csid_params.lut_params.vc_cfg_a[0]; csid_params.lut_params.vc_cfg[1] = &csid_params.lut_params.vc_cfg_a[1]; csid_params.lut_params.vc_cfg[2] = &csid_params.lut_params.vc_cfg_a[2]; csid_cfg_data.cfgtype = CSID_CFG; csid_cfg_data.cfg.csid_params = &csid_params; cam_ioctl(s->csid_fd, VIDIOC_MSM_CSID_IO_CFG, &csid_cfg_data, "csid configure"); // ISP: SMMU_ATTACH msm_vfe_smmu_attach_cmd smmu_attach_cmd = {.security_mode = 0, .iommu_attach_mode = IOMMU_ATTACH}; cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_SMMU_ATTACH, &smmu_attach_cmd, "isp smmu attach"); // ******************* STREAM RAW ***************************** // configure QMET input struct msm_vfe_input_cfg input_cfg = {}; for (int i = 0; i < (is_road_cam ? 3 : 1); i++) { StreamState *ss = &s->ss[i]; memset(&input_cfg, 0, sizeof(struct msm_vfe_input_cfg)); input_cfg.input_src = (msm_vfe_input_src)(VFE_RAW_0+i); input_cfg.input_pix_clk = s->pixel_clock; input_cfg.d.rdi_cfg.cid = i; input_cfg.d.rdi_cfg.frame_based = 1; err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_INPUT_CFG, &input_cfg); LOG("configure input(%d): %d", i, err); // ISP: REQUEST_STREAM ss->stream_req.axi_stream_handle = 0; if (is_road_cam) { ss->stream_req.session_id = 2; ss->stream_req.stream_id = /*ISP_META_CHANNEL_BIT | */ISP_NATIVE_BUF_BIT | (1+i); } else { ss->stream_req.session_id = 3; ss->stream_req.stream_id = ISP_NATIVE_BUF_BIT | 1; } if (i == 0) { ss->stream_req.output_format = v4l2_fourcc('R', 'G', '1', '0'); } else { ss->stream_req.output_format = v4l2_fourcc('Q', 'M', 'E', 'T'); } ss->stream_req.stream_src = (msm_vfe_axi_stream_src)(RDI_INTF_0+i); #ifdef HIGH_FPS if (is_road_cam) { ss->stream_req.frame_skip_pattern = EVERY_3FRAME; } #endif ss->stream_req.frame_base = 1; ss->stream_req.buf_divert = 1; //i == 0; // setup stream plane. doesn't even matter? /*s->stream_req.plane_cfg[0].output_plane_format = Y_PLANE; s->stream_req.plane_cfg[0].output_width = s->ci.frame_width; s->stream_req.plane_cfg[0].output_height = s->ci.frame_height; s->stream_req.plane_cfg[0].output_stride = s->ci.frame_width; s->stream_req.plane_cfg[0].output_scan_lines = s->ci.frame_height; s->stream_req.plane_cfg[0].rdi_cid = 0;*/ err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_STREAM, &ss->stream_req); LOG("isp request stream: %d -> 0x%x", err, ss->stream_req.axi_stream_handle); // ISP: REQUEST_BUF ss->buf_request.session_id = ss->stream_req.session_id; ss->buf_request.stream_id = ss->stream_req.stream_id; ss->buf_request.num_buf = FRAME_BUF_COUNT; ss->buf_request.buf_type = ISP_PRIVATE_BUF; ss->buf_request.handle = 0; cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_REQUEST_BUF, &ss->buf_request, "isp request buf"); LOG("got buf handle: 0x%x", ss->buf_request.handle); // ENQUEUE all buffers for (int j = 0; j < ss->buf_request.num_buf; j++) { ss->qbuf_info[j].handle = ss->buf_request.handle; ss->qbuf_info[j].buf_idx = j; ss->qbuf_info[j].buffer.num_planes = 1; ss->qbuf_info[j].buffer.planes[0].addr = ss->bufs[j].fd; ss->qbuf_info[j].buffer.planes[0].length = ss->bufs[j].len; err = ioctl(s->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss->qbuf_info[j]); } // ISP: UPDATE_STREAM struct msm_vfe_axi_stream_update_cmd update_cmd = {}; update_cmd.num_streams = 1; update_cmd.update_info[0].user_stream_id = ss->stream_req.stream_id; update_cmd.update_info[0].stream_handle = ss->stream_req.axi_stream_handle; update_cmd.update_type = UPDATE_STREAM_ADD_BUFQ; cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_UPDATE_STREAM, &update_cmd, "isp update stream"); } LOG("******** START STREAMS ********"); sub.id = 0; sub.type = 0x1ff; cam_ioctl(s->isp_fd, VIDIOC_SUBSCRIBE_EVENT, &sub, "isp subscribe"); // ISP: START_STREAM s->stream_cfg.cmd = START_STREAM; s->stream_cfg.num_streams = is_road_cam ? 3 : 1; for (int i = 0; i < s->stream_cfg.num_streams; i++) { s->stream_cfg.stream_handle[i] = s->ss[i].stream_req.axi_stream_handle; } cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg, "isp start stream"); } static struct damping_params_t actuator_ringing_params = { .damping_step = 1023, .damping_delay = 15000, .hw_params = 0x0000e422, }; static void road_camera_start(CameraState *s) { struct msm_actuator_cfg_data actuator_cfg_data = {0}; set_exposure(s, 1.0, 1.0); int inf_step; int err = sensor_write_regs(s, start_reg_array, std::size(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); LOG("sensor start regs: %d", err); if (s->device != DEVICE_LP3) { imx298_ois_calibration(s->ois_fd, s->eeprom); inf_step = 332 - s->infinity_dac; // initial guess s->lens_true_pos = 300; } else { // default is OP3, this is for LeEco actuator_ringing_params.damping_step = 1023; actuator_ringing_params.damping_delay = 20000; actuator_ringing_params.hw_params = 13; // focus on infinity assuming phone is perpendicular inf_step = 512 - s->infinity_dac; // initial guess s->lens_true_pos = 400; } // reset lens position memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); actuator_cfg_data.cfgtype = CFG_SET_POSITION; actuator_cfg_data.cfg.setpos = (struct msm_actuator_set_position_t){ .number_of_steps = 1, .hw_params = (uint32_t)((s->device != DEVICE_LP3) ? 0x0000e424 : 7), .pos = {s->infinity_dac, 0}, .delay = {0,} }; cam_ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data, "actuator set pos"); // TODO: confirm this isn't needed /*memset(&actuator_cfg_data, 0, sizeof(actuator_cfg_data)); actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ .dir = 0, .sign_dir = 1, .dest_step_pos = inf_step, .num_steps = inf_step, .curr_lens_pos = 0, .ringing_params = &actuator_ringing_params, }; err = ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data); // should be ~332 at startup ? LOG("init actuator move focus: %d", err);*/ //actuator_cfg_data.cfg.move.curr_lens_pos; s->cur_lens_pos = 0; s->cur_step_pos = inf_step; actuator_move(s, s->cur_lens_pos); LOG("init lens pos: %d", s->cur_lens_pos); } void actuator_move(CameraState *s, uint16_t target) { int step = target - s->cur_lens_pos; // LP3 moves only on even positions. TODO: use proper sensor params if (s->device == DEVICE_LP3) { step /= 2; } int dest_step_pos = s->cur_step_pos + step; dest_step_pos = std::clamp(dest_step_pos, 0, 255); struct msm_actuator_cfg_data actuator_cfg_data = {0}; actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS; actuator_cfg_data.cfg.move = (struct msm_actuator_move_params_t){ .dir = (int8_t)((step > 0) ? MOVE_NEAR : MOVE_FAR), .sign_dir = (int8_t)((step > 0) ? MSM_ACTUATOR_MOVE_SIGNED_NEAR : MSM_ACTUATOR_MOVE_SIGNED_FAR), .dest_step_pos = (int16_t)dest_step_pos, .num_steps = abs(step), .curr_lens_pos = s->cur_lens_pos, .ringing_params = &actuator_ringing_params, }; HANDLE_EINTR(ioctl(s->actuator_fd, VIDIOC_MSM_ACTUATOR_CFG, &actuator_cfg_data)); s->cur_step_pos = dest_step_pos; s->cur_lens_pos = actuator_cfg_data.cfg.move.curr_lens_pos; //LOGD("step %d target: %d lens pos: %d", dest_step_pos, target, s->cur_lens_pos); } static void parse_autofocus(CameraState *s, uint8_t *d) { int good_count = 0; int16_t max_focus = -32767; int avg_focus = 0; /*printf("FOCUS: "); for (int i = 0; i < 0x10; i++) { printf("%2.2X ", d[i]); }*/ for (int i = 0; i < NUM_FOCUS; i++) { int doff = i*5+5; s->confidence[i] = d[doff]; // this should just be a 10-bit signed int instead of 11 // TODO: write it in a nicer way int16_t focus_t = (d[doff+1] << 3) | (d[doff+2] >> 5); if (focus_t >= 1024) focus_t = -(2048-focus_t); s->focus[i] = focus_t; //printf("%x->%d ", d[doff], focus_t); if (s->confidence[i] > 0x20) { good_count++; max_focus = std::max(max_focus, s->focus[i]); avg_focus += s->focus[i]; } } // self recover override if (s->self_recover > 1) { s->focus_err = 200 * ((s->self_recover % 2 == 0) ? 1:-1); // far for even numbers, close for odd s->self_recover -= 2; return; } if (good_count < 4) { s->focus_err = nan(""); return; } avg_focus /= good_count; // outlier rejection if (abs(avg_focus - max_focus) > 200) { s->focus_err = nan(""); return; } s->focus_err = max_focus*1.0; } static std::optional get_accel_z(SubMaster *sm) { sm->update(0); if(sm->updated("sensorEvents")) { for (auto event : (*sm)["sensorEvents"].getSensorEvents()) { if (event.which() == cereal::SensorEventData::ACCELERATION) { if (auto v = event.getAcceleration().getV(); v.size() >= 3) return -v[2]; break; } } } return std::nullopt; } static void do_autofocus(CameraState *s, SubMaster *sm) { const int dac_down = s->device == DEVICE_LP3 ? LP3_AF_DAC_DOWN : OP3T_AF_DAC_DOWN; const int dac_up = s->device == DEVICE_LP3 ? LP3_AF_DAC_UP : OP3T_AF_DAC_UP; float lens_true_pos = s->lens_true_pos.load(); if (!isnan(s->focus_err)) { // learn lens_true_pos const float focus_kp = 0.005; lens_true_pos -= s->focus_err*focus_kp; } if (auto accel_z = get_accel_z(sm)) { s->last_sag_acc_z = *accel_z; } const float sag = (s->last_sag_acc_z / 9.8) * 128; // stay off the walls lens_true_pos = std::clamp(lens_true_pos, float(dac_down), float(dac_up)); int target = std::clamp(lens_true_pos - sag, float(dac_down), float(dac_up)); s->lens_true_pos.store(lens_true_pos); /*char debug[4096]; char *pdebug = debug; pdebug += sprintf(pdebug, "focus "); for (int i = 0; i < NUM_FOCUS; i++) pdebug += sprintf(pdebug, "%2x(%4d) ", s->confidence[i], s->focus[i]); pdebug += sprintf(pdebug, " err: %7.2f offset: %6.2f sag: %6.2f lens_true_pos: %6.2f cur_lens_pos: %4d->%4d", err * focus_kp, offset, sag, s->lens_true_pos, s->cur_lens_pos, target); LOGD(debug);*/ actuator_move(s, target); } void camera_autoexposure(CameraState *s, float grey_frac) { if (s->camera_num == 0) { CameraExpInfo tmp = road_cam_exp.load(); tmp.op_id++; tmp.grey_frac = grey_frac; road_cam_exp.store(tmp); } else { CameraExpInfo tmp = driver_cam_exp.load(); tmp.op_id++; tmp.grey_frac = grey_frac; driver_cam_exp.store(tmp); } } static void driver_camera_start(CameraState *s) { set_exposure(s, 1.0, 1.0); int err = sensor_write_regs(s, start_reg_array, std::size(start_reg_array), MSM_CAMERA_I2C_BYTE_DATA); LOG("sensor start regs: %d", err); } void cameras_open(MultiCameraState *s) { struct msm_ispif_param_data ispif_params = { .num = 4, .entries = { // road camera {.vfe_intf = VFE0, .intftype = RDI0, .num_cids = 1, .cids[0] = CID0, .csid = CSID0}, // driver camera {.vfe_intf = VFE1, .intftype = RDI0, .num_cids = 1, .cids[0] = CID0, .csid = CSID2}, // road camera (focus) {.vfe_intf = VFE0, .intftype = RDI1, .num_cids = 1, .cids[0] = CID1, .csid = CSID0}, // road camera (stats, for AE) {.vfe_intf = VFE0, .intftype = RDI2, .num_cids = 1, .cids[0] = CID2, .csid = CSID0}, }, }; s->msmcfg_fd = HANDLE_EINTR(open("/dev/media0", O_RDWR | O_NONBLOCK)); assert(s->msmcfg_fd >= 0); sensors_init(s); s->v4l_fd = HANDLE_EINTR(open("/dev/video0", O_RDWR | O_NONBLOCK)); assert(s->v4l_fd >= 0); if (s->device == DEVICE_LP3) { s->ispif_fd = HANDLE_EINTR(open("/dev/v4l-subdev15", O_RDWR | O_NONBLOCK)); } else { s->ispif_fd = HANDLE_EINTR(open("/dev/v4l-subdev16", O_RDWR | O_NONBLOCK)); } assert(s->ispif_fd >= 0); // ISPIF: stop // memset(&ispif_cfg_data, 0, sizeof(ispif_cfg_data)); // ispif_cfg_data.cfg_type = ISPIF_STOP_FRAME_BOUNDARY; // ispif_cfg_data.params = ispif_params; // err = ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data); // LOG("ispif stop: %d", err); LOG("*** open driver camera ***"); s->driver_cam.ss[0].bufs = s->driver_cam.buf.camera_bufs.get(); camera_open(&s->driver_cam, false); LOG("*** open road camera ***"); s->road_cam.ss[0].bufs = s->road_cam.buf.camera_bufs.get(); s->road_cam.ss[1].bufs = s->focus_bufs; s->road_cam.ss[2].bufs = s->stats_bufs; camera_open(&s->road_cam, true); if (getenv("CAMERA_TEST")) { cameras_close(s); exit(0); } // ISPIF: set vfe info struct ispif_cfg_data ispif_cfg_data = {.cfg_type = ISPIF_SET_VFE_INFO, .vfe_info.num_vfe = 2}; int err = HANDLE_EINTR(ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data)); LOG("ispif set vfe info: %d", err); // ISPIF: setup ispif_cfg_data = {.cfg_type = ISPIF_INIT, .csid_version = 0x30050000 /* CSID_VERSION_V35*/}; cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif setup"); ispif_cfg_data = {.cfg_type = ISPIF_CFG, .params = ispif_params}; cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif cfg"); ispif_cfg_data.cfg_type = ISPIF_START_FRAME_BOUNDARY; cam_ioctl(s->ispif_fd, VIDIOC_MSM_ISPIF_CFG, &ispif_cfg_data, "ispif start_frame_boundary"); driver_camera_start(&s->driver_cam); road_camera_start(&s->road_cam); } static void camera_close(CameraState *s) { // ISP: STOP_STREAM s->stream_cfg.cmd = STOP_STREAM; cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_CFG_STREAM, &s->stream_cfg, "isp stop stream"); for (int i = 0; i < 3; i++) { StreamState *ss = &s->ss[i]; if (ss->stream_req.axi_stream_handle != 0) { cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_BUF, &ss->buf_request, "isp release buf"); struct msm_vfe_axi_stream_release_cmd stream_release = { .stream_handle = ss->stream_req.axi_stream_handle, }; cam_ioctl(s->isp_fd, VIDIOC_MSM_ISP_RELEASE_STREAM, &stream_release, "isp release stream"); } } free(s->eeprom); } const char* get_isp_event_name(uint32_t type) { switch (type) { case ISP_EVENT_REG_UPDATE: return "ISP_EVENT_REG_UPDATE"; case ISP_EVENT_EPOCH_0: return "ISP_EVENT_EPOCH_0"; case ISP_EVENT_EPOCH_1: return "ISP_EVENT_EPOCH_1"; case ISP_EVENT_START_ACK: return "ISP_EVENT_START_ACK"; case ISP_EVENT_STOP_ACK: return "ISP_EVENT_STOP_ACK"; case ISP_EVENT_IRQ_VIOLATION: return "ISP_EVENT_IRQ_VIOLATION"; case ISP_EVENT_STATS_OVERFLOW: return "ISP_EVENT_STATS_OVERFLOW"; case ISP_EVENT_ERROR: return "ISP_EVENT_ERROR"; case ISP_EVENT_SOF: return "ISP_EVENT_SOF"; case ISP_EVENT_EOF: return "ISP_EVENT_EOF"; case ISP_EVENT_BUF_DONE: return "ISP_EVENT_BUF_DONE"; case ISP_EVENT_BUF_DIVERT: return "ISP_EVENT_BUF_DIVERT"; case ISP_EVENT_STATS_NOTIFY: return "ISP_EVENT_STATS_NOTIFY"; case ISP_EVENT_COMP_STATS_NOTIFY: return "ISP_EVENT_COMP_STATS_NOTIFY"; case ISP_EVENT_FE_READ_DONE: return "ISP_EVENT_FE_READ_DONE"; case ISP_EVENT_IOMMU_P_FAULT: return "ISP_EVENT_IOMMU_P_FAULT"; case ISP_EVENT_HW_FATAL_ERROR: return "ISP_EVENT_HW_FATAL_ERROR"; case ISP_EVENT_PING_PONG_MISMATCH: return "ISP_EVENT_PING_PONG_MISMATCH"; case ISP_EVENT_REG_UPDATE_MISSING: return "ISP_EVENT_REG_UPDATE_MISSING"; case ISP_EVENT_BUF_FATAL_ERROR: return "ISP_EVENT_BUF_FATAL_ERROR"; case ISP_EVENT_STREAM_UPDATE_DONE: return "ISP_EVENT_STREAM_UPDATE_DONE"; default: return "unknown"; } } static FrameMetadata get_frame_metadata(CameraState *s, uint32_t frame_id) { std::lock_guard lk(s->frame_info_lock); for (auto &i : s->frame_metadata) { if (i.frame_id == frame_id) { return i; } } // should never happen return (FrameMetadata){ .frame_id = (uint32_t)-1, }; } static void ops_thread(MultiCameraState *s) { int last_road_cam_op_id = 0; int last_driver_cam_op_id = 0; CameraExpInfo road_cam_op; CameraExpInfo driver_cam_op; set_thread_name("camera_settings"); SubMaster sm({"sensorEvents"}); while(!do_exit) { road_cam_op = road_cam_exp.load(); if (road_cam_op.op_id != last_road_cam_op_id) { do_autoexposure(&s->road_cam, road_cam_op.grey_frac); do_autofocus(&s->road_cam, &sm); last_road_cam_op_id = road_cam_op.op_id; } driver_cam_op = driver_cam_exp.load(); if (driver_cam_op.op_id != last_driver_cam_op_id) { do_autoexposure(&s->driver_cam, driver_cam_op.grey_frac); last_driver_cam_op_id = driver_cam_op.op_id; } util::sleep_for(50); } } static void setup_self_recover(CameraState *c, const uint16_t *lapres, size_t lapres_size) { const int dac_down = c->device == DEVICE_LP3 ? LP3_AF_DAC_DOWN : OP3T_AF_DAC_DOWN; const int dac_up = c->device == DEVICE_LP3 ? LP3_AF_DAC_UP : OP3T_AF_DAC_UP; const int dac_m = c->device == DEVICE_LP3 ? LP3_AF_DAC_M : OP3T_AF_DAC_M; const int dac_3sig = c->device == DEVICE_LP3 ? LP3_AF_DAC_3SIG : OP3T_AF_DAC_3SIG; const float lens_true_pos = c->lens_true_pos.load(); int self_recover = c->self_recover.load(); if (self_recover < 2 && (lens_true_pos < (dac_down + 1) || lens_true_pos > (dac_up - 1)) && is_blur(lapres, lapres_size)) { // truly stuck, needs help if (--self_recover < -FOCUS_RECOVER_PATIENCE) { LOGD("road camera bad state detected. attempting recovery from %.1f, recover state is %d", lens_true_pos, self_recover); // parity determined by which end is stuck at self_recover = FOCUS_RECOVER_STEPS + (lens_true_pos < dac_m ? 1 : 0); } } else if (self_recover < 2 && (lens_true_pos < (dac_m - dac_3sig) || lens_true_pos > (dac_m + dac_3sig))) { // in suboptimal position with high prob, but may still recover by itself if (--self_recover < -(FOCUS_RECOVER_PATIENCE * 3)) { self_recover = FOCUS_RECOVER_STEPS / 2 + (lens_true_pos < dac_m ? 1 : 0); } } else if (self_recover < 0) { self_recover += 1; // reset if fine } c->self_recover.store(self_recover); } void process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) { common_process_driver_camera(s->sm, s->pm, c, cnt); } // called by processing_thread void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { const CameraBuf *b = &c->buf; const int roi_id = cnt % std::size(s->lapres); // rolling roi s->lapres[roi_id] = s->lap_conv->Update(b->q, (uint8_t *)b->cur_rgb_buf->addr, roi_id); setup_self_recover(c, &s->lapres[0], std::size(s->lapres)); MessageBuilder msg; auto framed = msg.initEvent().initRoadCameraState(); fill_frame_data(framed, b->cur_frame_data); if (env_send_road) { framed.setImage(get_frame_image(b)); } framed.setFocusVal(s->road_cam.focus); framed.setFocusConf(s->road_cam.confidence); framed.setRecoverState(s->road_cam.self_recover); framed.setSharpnessScore(s->lapres); framed.setTransform(b->yuv_transform.v); s->pm->send("roadCameraState", msg); if (cnt % 3 == 0) { const int x = 290, y = 322, width = 560, height = 314; const int skip = 1; camera_autoexposure(c, set_exposure_target(b, x, x + width, skip, y, y + height, skip)); } } void cameras_run(MultiCameraState *s) { std::vector threads; threads.push_back(std::thread(ops_thread, s)); threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); threads.push_back(start_process_thread(s, &s->driver_cam, process_driver_camera)); CameraState* cameras[2] = {&s->road_cam, &s->driver_cam}; while (!do_exit) { struct pollfd fds[2] = {{.fd = cameras[0]->isp_fd, .events = POLLPRI}, {.fd = cameras[1]->isp_fd, .events = POLLPRI}}; int ret = poll(fds, std::size(fds), 1000); if (ret < 0) { if (errno == EINTR || errno == EAGAIN) continue; LOGE("poll failed (%d - %d)", ret, errno); break; } // process cameras for (int i=0; i<2; i++) { if (!fds[i].revents) continue; CameraState *c = cameras[i]; struct v4l2_event ev = {}; ret = HANDLE_EINTR(ioctl(c->isp_fd, VIDIOC_DQEVENT, &ev)); const msm_isp_event_data *isp_event_data = (const msm_isp_event_data *)ev.u.data; if (ev.type == ISP_EVENT_BUF_DIVERT) { const int buf_idx = isp_event_data->u.buf_done.buf_idx; const int buffer = (isp_event_data->u.buf_done.stream_id & 0xFFFF) - 1; if (buffer == 0) { c->buf.camera_bufs_metadata[buf_idx] = get_frame_metadata(c, isp_event_data->frame_id); c->buf.queue(buf_idx); } else { auto &ss = c->ss[buffer]; if (buffer == 1) { parse_autofocus(c, (uint8_t *)(ss.bufs[buf_idx].addr)); } ss.qbuf_info[buf_idx].dirty_buf = 1; HANDLE_EINTR(ioctl(c->isp_fd, VIDIOC_MSM_ISP_ENQUEUE_BUF, &ss.qbuf_info[buf_idx])); } } else if (ev.type == ISP_EVENT_EOF) { const uint64_t timestamp = (isp_event_data->mono_timestamp.tv_sec * 1000000000ULL + isp_event_data->mono_timestamp.tv_usec * 1000); std::lock_guard lk(c->frame_info_lock); c->frame_metadata[c->frame_metadata_idx] = (FrameMetadata){ .frame_id = isp_event_data->frame_id, .timestamp_eof = timestamp, .frame_length = (uint32_t)c->frame_length, .integ_lines = (uint32_t)c->cur_integ_lines, .lens_pos = c->cur_lens_pos, .lens_sag = c->last_sag_acc_z, .lens_err = c->focus_err, .lens_true_pos = c->lens_true_pos, .gain = c->cur_gain_frac, .measured_grey_fraction = c->measured_grey_fraction, .target_grey_fraction = c->target_grey_fraction, .high_conversion_gain = false, }; c->frame_metadata_idx = (c->frame_metadata_idx + 1) % METADATA_BUF_COUNT; } else if (ev.type == ISP_EVENT_ERROR) { LOGE("ISP_EVENT_ERROR! err type: 0x%08x", isp_event_data->u.error_info.err_type); } } } LOG(" ************** STOPPING **************"); for (auto &t : threads) t.join(); cameras_close(s); } void cameras_close(MultiCameraState *s) { camera_close(&s->road_cam); camera_close(&s->driver_cam); for (int i = 0; i < FRAME_BUF_COUNT; i++) { s->focus_bufs[i].free(); s->stats_bufs[i].free(); } delete s->lap_conv; delete s->sm; delete s->pm; } ================================================ FILE: selfdrive/camerad/cameras/camera_qcom.h ================================================ #pragma once #include #include #include #include "cereal/messaging/messaging.h" #include "cereal/visionipc/visionbuf.h" #include "selfdrive/camerad/cameras/camera_common.h" #include "selfdrive/camerad/imgproc/utils.h" #include "selfdrive/camerad/include/msm_cam_sensor.h" #include "selfdrive/camerad/include/msmb_camera.h" #include "selfdrive/camerad/include/msmb_isp.h" #include "selfdrive/camerad/include/msmb_ispif.h" #include "selfdrive/common/mat.h" #include "selfdrive/common/util.h" #define FRAME_BUF_COUNT 4 #define METADATA_BUF_COUNT 4 #define DEVICE_OP3 0 #define DEVICE_OP3T 1 #define DEVICE_LP3 2 #define NUM_FOCUS 8 #define LP3_AF_DAC_DOWN 366 #define LP3_AF_DAC_UP 634 #define LP3_AF_DAC_M 440 #define LP3_AF_DAC_3SIG 52 #define OP3T_AF_DAC_DOWN 224 #define OP3T_AF_DAC_UP 456 #define OP3T_AF_DAC_M 300 #define OP3T_AF_DAC_3SIG 96 #define FOCUS_RECOVER_PATIENCE 50 // 2.5 seconds of complete blur #define FOCUS_RECOVER_STEPS 240 // 6 seconds typedef struct CameraState CameraState; typedef int (*camera_apply_exposure_func)(CameraState *s, int gain, int integ_lines, uint32_t frame_length); typedef struct StreamState { struct msm_isp_buf_request buf_request; struct msm_vfe_axi_stream_request_cmd stream_req; struct msm_isp_qbuf_info qbuf_info[FRAME_BUF_COUNT]; VisionBuf *bufs; } StreamState; typedef struct CameraState { int camera_num; int camera_id; int device; int fps; CameraInfo ci; unique_fd csid_fd; unique_fd csiphy_fd; unique_fd sensor_fd; unique_fd isp_fd; struct msm_vfe_axi_stream_cfg_cmd stream_cfg; StreamState ss[3]; CameraBuf buf; std::mutex frame_info_lock; FrameMetadata frame_metadata[METADATA_BUF_COUNT]; int frame_metadata_idx; // exposure uint32_t pixel_clock, line_length_pclk; uint32_t frame_length; unsigned int max_gain; float cur_exposure_frac, cur_gain_frac; int cur_gain, cur_integ_lines; float measured_grey_fraction; float target_grey_fraction; std::atomic digital_gain; camera_apply_exposure_func apply_exposure; // rear camera only,used for focusing unique_fd actuator_fd, ois_fd, eeprom_fd; std::atomic focus_err; std::atomic last_sag_acc_z; std::atomic lens_true_pos; std::atomic self_recover; // af recovery counter, neg is patience, pos is active uint16_t cur_step_pos; uint16_t cur_lens_pos; int16_t focus[NUM_FOCUS]; uint8_t confidence[NUM_FOCUS]; uint16_t infinity_dac; size_t eeprom_size; uint8_t *eeprom; } CameraState; typedef struct MultiCameraState { int device; unique_fd ispif_fd; unique_fd msmcfg_fd; unique_fd v4l_fd; uint16_t lapres[(ROI_X_MAX-ROI_X_MIN+1)*(ROI_Y_MAX-ROI_Y_MIN+1)]; VisionBuf focus_bufs[FRAME_BUF_COUNT]; VisionBuf stats_bufs[FRAME_BUF_COUNT]; CameraState road_cam; CameraState driver_cam; SubMaster *sm; PubMaster *pm; LapConv *lap_conv; } MultiCameraState; void actuator_move(CameraState *s, uint16_t target); int sensor_write_regs(CameraState *s, struct msm_camera_i2c_reg_array* arr, size_t size, int data_type); ================================================ FILE: selfdrive/camerad/cameras/camera_qcom2.cc ================================================ #include "selfdrive/camerad/cameras/camera_qcom2.h" #include #include #include #include #include #include #include #include #include #include #include #include "media/cam_defs.h" #include "media/cam_isp.h" #include "media/cam_isp_ife.h" #include "media/cam_sensor.h" #include "media/cam_sensor_cmn_header.h" #include "media/cam_sync.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/camerad/cameras/sensor2_i2c.h" extern ExitHandler do_exit; const size_t FRAME_WIDTH = 1928; const size_t FRAME_HEIGHT = 1208; const size_t FRAME_STRIDE = 2416; // for 10 bit output const int MIPI_SETTLE_CNT = 33; // Calculated by camera_freqs.py CameraInfo cameras_supported[CAMERA_ID_MAX] = { [CAMERA_ID_AR0231] = { .frame_width = FRAME_WIDTH, .frame_height = FRAME_HEIGHT, .frame_stride = FRAME_STRIDE, .bayer = true, .bayer_flip = 1, .hdr = false }, }; const float DC_GAIN = 2.5; const float sensor_analog_gains[] = { 1.0/8.0, 2.0/8.0, 2.0/7.0, 3.0/7.0, // 0, 1, 2, 3 3.0/6.0, 4.0/6.0, 4.0/5.0, 5.0/5.0, // 4, 5, 6, 7 5.0/4.0, 6.0/4.0, 6.0/3.0, 7.0/3.0, // 8, 9, 10, 11 7.0/2.0, 8.0/2.0, 8.0/1.0}; // 12, 13, 14, 15 = bypass const int ANALOG_GAIN_MIN_IDX = 0x1; // 0.25x const int ANALOG_GAIN_REC_IDX = 0x6; // 0.8x const int ANALOG_GAIN_MAX_IDX = 0xD; // 4.0x const int EXPOSURE_TIME_MIN = 2; // with HDR, fastest ss const int EXPOSURE_TIME_MAX = 1904; // with HDR, slowest ss // ************** low level camera helpers **************** int cam_control(int fd, int op_code, void *handle, int size) { struct cam_control camcontrol = {0}; camcontrol.op_code = op_code; camcontrol.handle = (uint64_t)handle; if (size == 0) { camcontrol.size = 8; camcontrol.handle_type = CAM_HANDLE_MEM_HANDLE; } else { camcontrol.size = size; camcontrol.handle_type = CAM_HANDLE_USER_POINTER; } int ret = HANDLE_EINTR(ioctl(fd, VIDIOC_CAM_CONTROL, &camcontrol)); if (ret == -1) { printf("OP CODE ERR - %d \n", op_code); perror("wat"); } return ret; } std::optional device_acquire(int fd, int32_t session_handle, void *data) { struct cam_acquire_dev_cmd cmd = { .session_handle = session_handle, .handle_type = CAM_HANDLE_USER_POINTER, .num_resources = (uint32_t)(data ? 1 : 0), .resource_hdl = (uint64_t)data, }; int err = cam_control(fd, CAM_ACQUIRE_DEV, &cmd, sizeof(cmd)); return err == 0 ? std::make_optional(cmd.dev_handle) : std::nullopt; }; int device_config(int fd, int32_t session_handle, int32_t dev_handle, uint64_t packet_handle) { struct cam_config_dev_cmd cmd = { .session_handle = session_handle, .dev_handle = dev_handle, .packet_handle = packet_handle, }; return cam_control(fd, CAM_CONFIG_DEV, &cmd, sizeof(cmd)); } int device_control(int fd, int op_code, int session_handle, int dev_handle) { // start stop and release are all the same struct cam_start_stop_dev_cmd cmd { .session_handle = session_handle, .dev_handle = dev_handle }; return cam_control(fd, op_code, &cmd, sizeof(cmd)); } void *alloc_w_mmu_hdl(int video0_fd, int len, uint32_t *handle, int align = 8, int flags = CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE, int mmu_hdl = 0, int mmu_hdl2 = 0) { struct cam_mem_mgr_alloc_cmd mem_mgr_alloc_cmd = {0}; mem_mgr_alloc_cmd.len = len; mem_mgr_alloc_cmd.align = align; mem_mgr_alloc_cmd.flags = flags; mem_mgr_alloc_cmd.num_hdl = 0; if (mmu_hdl != 0) { mem_mgr_alloc_cmd.mmu_hdls[0] = mmu_hdl; mem_mgr_alloc_cmd.num_hdl++; } if (mmu_hdl2 != 0) { mem_mgr_alloc_cmd.mmu_hdls[1] = mmu_hdl2; mem_mgr_alloc_cmd.num_hdl++; } cam_control(video0_fd, CAM_REQ_MGR_ALLOC_BUF, &mem_mgr_alloc_cmd, sizeof(mem_mgr_alloc_cmd)); *handle = mem_mgr_alloc_cmd.out.buf_handle; void *ptr = NULL; if (mem_mgr_alloc_cmd.out.fd > 0) { ptr = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, mem_mgr_alloc_cmd.out.fd, 0); assert(ptr != MAP_FAILED); } // LOGD("allocated: %x %d %llx mapped %p", mem_mgr_alloc_cmd.out.buf_handle, mem_mgr_alloc_cmd.out.fd, mem_mgr_alloc_cmd.out.vaddr, ptr); return ptr; } void release(int video0_fd, uint32_t handle) { int ret; struct cam_mem_mgr_release_cmd mem_mgr_release_cmd = {0}; mem_mgr_release_cmd.buf_handle = handle; ret = cam_control(video0_fd, CAM_REQ_MGR_RELEASE_BUF, &mem_mgr_release_cmd, sizeof(mem_mgr_release_cmd)); assert(ret == 0); } void release_fd(int video0_fd, uint32_t handle) { // handle to fd close(handle>>16); release(video0_fd, handle); } void clear_req_queue(int fd, int32_t session_hdl, int32_t link_hdl) { struct cam_req_mgr_flush_info req_mgr_flush_request = {0}; req_mgr_flush_request.session_hdl = session_hdl; req_mgr_flush_request.link_hdl = link_hdl; req_mgr_flush_request.flush_type = CAM_REQ_MGR_FLUSH_TYPE_ALL; int ret; ret = cam_control(fd, CAM_REQ_MGR_FLUSH_REQ, &req_mgr_flush_request, sizeof(req_mgr_flush_request)); // LOGD("flushed all req: %d", ret); } // ************** high level camera helpers **************** void sensors_poke(struct CameraState *s, int request_id) { uint32_t cam_packet_handle = 0; int size = sizeof(struct cam_packet); struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); pkt->num_cmd_buf = 0; pkt->kmd_cmd_buf_index = -1; pkt->header.size = size; pkt->header.op_code = 0x7f; pkt->header.request_id = request_id; int ret = device_config(s->sensor_fd, s->session_handle, s->sensor_dev_handle, cam_packet_handle); assert(ret == 0); munmap(pkt, size); release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); } void sensors_i2c(struct CameraState *s, struct i2c_random_wr_payload* dat, int len, int op_code) { // LOGD("sensors_i2c: %d", len); uint32_t cam_packet_handle = 0; int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*1; struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); pkt->num_cmd_buf = 1; pkt->kmd_cmd_buf_index = -1; pkt->header.size = size; pkt->header.op_code = op_code; struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; buf_desc[0].size = buf_desc[0].length = sizeof(struct i2c_rdwr_header) + len*sizeof(struct i2c_random_wr_payload); buf_desc[0].type = CAM_CMD_BUF_I2C; struct cam_cmd_i2c_random_wr *i2c_random_wr = (struct cam_cmd_i2c_random_wr *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle); i2c_random_wr->header.count = len; i2c_random_wr->header.op_code = 1; i2c_random_wr->header.cmd_type = CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR; i2c_random_wr->header.data_type = CAMERA_SENSOR_I2C_TYPE_WORD; i2c_random_wr->header.addr_type = CAMERA_SENSOR_I2C_TYPE_WORD; memcpy(i2c_random_wr->random_wr_payload, dat, len*sizeof(struct i2c_random_wr_payload)); int ret = device_config(s->sensor_fd, s->session_handle, s->sensor_dev_handle, cam_packet_handle); assert(ret == 0); munmap(i2c_random_wr, buf_desc[0].size); release_fd(s->multi_cam_state->video0_fd, buf_desc[0].mem_handle); munmap(pkt, size); release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); } static cam_cmd_power *power_set_wait(cam_cmd_power *power, int16_t delay_ms) { cam_cmd_unconditional_wait *unconditional_wait = (cam_cmd_unconditional_wait *)((char *)power + (sizeof(struct cam_cmd_power) + (power->count - 1) * sizeof(struct cam_power_settings))); unconditional_wait->cmd_type = CAMERA_SENSOR_CMD_TYPE_WAIT; unconditional_wait->delay = delay_ms; unconditional_wait->op_code = CAMERA_SENSOR_WAIT_OP_SW_UCND; return (struct cam_cmd_power *)(unconditional_wait + 1); }; void sensors_init(int video0_fd, int sensor_fd, int camera_num) { uint32_t cam_packet_handle = 0; int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*2; struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(video0_fd, size, &cam_packet_handle); pkt->num_cmd_buf = 2; pkt->kmd_cmd_buf_index = -1; pkt->header.op_code = 0x1000003; pkt->header.size = size; struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; buf_desc[0].size = buf_desc[0].length = sizeof(struct cam_cmd_i2c_info) + sizeof(struct cam_cmd_probe); buf_desc[0].type = CAM_CMD_BUF_LEGACY; struct cam_cmd_i2c_info *i2c_info = (struct cam_cmd_i2c_info *)alloc_w_mmu_hdl(video0_fd, buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle); struct cam_cmd_probe *probe = (struct cam_cmd_probe *)((uint8_t *)i2c_info) + sizeof(struct cam_cmd_i2c_info); switch (camera_num) { case 0: // port 0 i2c_info->slave_addr = 0x20; probe->camera_id = 0; break; case 1: // port 1 i2c_info->slave_addr = 0x30; probe->camera_id = 1; break; case 2: // port 2 i2c_info->slave_addr = 0x20; probe->camera_id = 2; break; } // 0(I2C_STANDARD_MODE) = 100khz, 1(I2C_FAST_MODE) = 400khz //i2c_info->i2c_freq_mode = I2C_STANDARD_MODE; i2c_info->i2c_freq_mode = I2C_FAST_MODE; i2c_info->cmd_type = CAMERA_SENSOR_CMD_TYPE_I2C_INFO; probe->data_type = CAMERA_SENSOR_I2C_TYPE_WORD; probe->addr_type = CAMERA_SENSOR_I2C_TYPE_WORD; probe->op_code = 3; // don't care? probe->cmd_type = CAMERA_SENSOR_CMD_TYPE_PROBE; probe->reg_addr = 0x3000; //0x300a; //0x300b; probe->expected_data = 0x354; //0x7750; //0x885a; probe->data_mask = 0; //buf_desc[1].size = buf_desc[1].length = 148; buf_desc[1].size = buf_desc[1].length = 196; buf_desc[1].type = CAM_CMD_BUF_I2C; struct cam_cmd_power *power_settings = (struct cam_cmd_power *)alloc_w_mmu_hdl(video0_fd, buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle); memset(power_settings, 0, buf_desc[1].size); // 7750 /*power->count = 2; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; power->power_settings[0].power_seq_type = 2; power->power_settings[1].power_seq_type = 8; power = (void*)power + (sizeof(struct cam_cmd_power) + (power->count-1)*sizeof(struct cam_power_settings));*/ // 885a struct cam_cmd_power *power = power_settings; power->count = 4; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; power->power_settings[0].power_seq_type = 3; // clock?? power->power_settings[1].power_seq_type = 1; // analog power->power_settings[2].power_seq_type = 2; // digital power->power_settings[3].power_seq_type = 8; // reset low power = power_set_wait(power, 5); // set clock power->count = 1; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; power->power_settings[0].power_seq_type = 0; power->power_settings[0].config_val_low = 19200000; //Hz power = power_set_wait(power, 10); // 8,1 is this reset? power->count = 1; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_UP; power->power_settings[0].power_seq_type = 8; power->power_settings[0].config_val_low = 1; power = power_set_wait(power, 100); // probe happens here // disable clock power->count = 1; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; power->power_settings[0].power_seq_type = 0; power->power_settings[0].config_val_low = 0; power = power_set_wait(power, 1); // reset high power->count = 1; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; power->power_settings[0].power_seq_type = 8; power->power_settings[0].config_val_low = 1; power = power_set_wait(power, 1); // reset low power->count = 1; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; power->power_settings[0].power_seq_type = 8; power->power_settings[0].config_val_low = 0; power = power_set_wait(power, 1); // 7750 /*power->count = 1; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; power->power_settings[0].power_seq_type = 2; power = (void*)power + (sizeof(struct cam_cmd_power) + (power->count-1)*sizeof(struct cam_power_settings));*/ // 885a power->count = 3; power->cmd_type = CAMERA_SENSOR_CMD_TYPE_PWR_DOWN; power->power_settings[0].power_seq_type = 2; power->power_settings[1].power_seq_type = 1; power->power_settings[2].power_seq_type = 3; LOGD("probing the sensor"); int ret = cam_control(sensor_fd, CAM_SENSOR_PROBE_CMD, (void *)(uintptr_t)cam_packet_handle, 0); assert(ret == 0); munmap(i2c_info, buf_desc[0].size); release_fd(video0_fd, buf_desc[0].mem_handle); munmap(power_settings, buf_desc[1].size); release_fd(video0_fd, buf_desc[1].mem_handle); munmap(pkt, size); release_fd(video0_fd, cam_packet_handle); } void config_isp(struct CameraState *s, int io_mem_handle, int fence, int request_id, int buf0_mem_handle, int buf0_offset) { uint32_t cam_packet_handle = 0; int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*2; if (io_mem_handle != 0) { size += sizeof(struct cam_buf_io_cfg); } struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); pkt->num_cmd_buf = 2; pkt->kmd_cmd_buf_index = 0; if (io_mem_handle != 0) { pkt->io_configs_offset = sizeof(struct cam_cmd_buf_desc)*2; pkt->num_io_configs = 1; } if (io_mem_handle != 0) { pkt->header.op_code = 0xf000001; pkt->header.request_id = request_id; } else { pkt->header.op_code = 0xf000000; } pkt->header.size = size; struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; struct cam_buf_io_cfg *io_cfg = (struct cam_buf_io_cfg *)((char*)&pkt->payload + pkt->io_configs_offset); // TODO: support MMU buf_desc[0].size = 65624; buf_desc[0].length = 0; buf_desc[0].type = CAM_CMD_BUF_DIRECT; buf_desc[0].meta_data = 3; buf_desc[0].mem_handle = buf0_mem_handle; buf_desc[0].offset = buf0_offset; buf_desc[1].size = 324; if (io_mem_handle != 0) { buf_desc[1].length = 228; // 0 works here too buf_desc[1].offset = 0x60; } else { buf_desc[1].length = 324; } buf_desc[1].type = CAM_CMD_BUF_GENERIC; buf_desc[1].meta_data = CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON; uint32_t *buf2 = (uint32_t *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, buf_desc[1].size, (uint32_t*)&buf_desc[1].mem_handle, 0x20); // cam_isp_packet_generic_blob_handler uint32_t tmp[] = { // size is 0x20, type is 0(CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG) 0x2000, 0x1, 0x0, CAM_ISP_IFE_OUT_RES_RDI_0, 0x1, 0x0, 0x1, 0x0, 0x0, // 1 port, CAM_ISP_IFE_OUT_RES_RDI_0 // size is 0x38, type is 1(CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG), clocks 0x3801, 0x1, 0x4, // Dual mode, 4 RDI wires 0x18148d00, 0x0, 0x18148d00, 0x0, 0x18148d00, 0x0, // rdi clock 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // junk? // offset 0x60 // size is 0xe0, type is 2(CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG), bandwidth 0xe002, 0x1, 0x4, // 4 RDI 0x0, 0x0, 0x1ad27480, 0x0, 0x1ad27480, 0x0, // left_pix_vote 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, // right_pix_vote 0x0, 0x0, 0x6ee11c0, 0x2, 0x6ee11c0, 0x2, // rdi_vote 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; memcpy(buf2, tmp, sizeof(tmp)); if (io_mem_handle != 0) { io_cfg[0].mem_handle[0] = io_mem_handle; io_cfg[0].planes[0] = (struct cam_plane_cfg){ .width = FRAME_WIDTH, .height = FRAME_HEIGHT, .plane_stride = FRAME_STRIDE, .slice_height = FRAME_HEIGHT, .meta_stride = 0x0, .meta_size = 0x0, .meta_offset = 0x0, .packer_config = 0x0, .mode_config = 0x0, .tile_config = 0x0, .h_init = 0x0, .v_init = 0x0, }; io_cfg[0].format = CAM_FORMAT_MIPI_RAW_10; io_cfg[0].color_pattern = 0x5; io_cfg[0].bpp = 0xc; io_cfg[0].resource_type = CAM_ISP_IFE_OUT_RES_RDI_0; io_cfg[0].fence = fence; io_cfg[0].direction = CAM_BUF_OUTPUT; io_cfg[0].subsample_pattern = 0x1; io_cfg[0].framedrop_pattern = 0x1; } int ret = device_config(s->multi_cam_state->isp_fd, s->session_handle, s->isp_dev_handle, cam_packet_handle); assert(ret == 0); if (ret != 0) { printf("ISP CONFIG FAILED\n"); } munmap(buf2, buf_desc[1].size); release_fd(s->multi_cam_state->video0_fd, buf_desc[1].mem_handle); // release_fd(s->multi_cam_state->video0_fd, buf_desc[0].mem_handle); munmap(pkt, size); release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); } void enqueue_buffer(struct CameraState *s, int i, bool dp) { int ret; int request_id = s->request_ids[i]; if (s->buf_handle[i]) { release(s->multi_cam_state->video0_fd, s->buf_handle[i]); // wait struct cam_sync_wait sync_wait = {0}; sync_wait.sync_obj = s->sync_objs[i]; sync_wait.timeout_ms = 50; // max dt tolerance, typical should be 23 ret = cam_control(s->multi_cam_state->video1_fd, CAM_SYNC_WAIT, &sync_wait, sizeof(sync_wait)); // LOGD("fence wait: %d %d", ret, sync_wait.sync_obj); s->buf.camera_bufs_metadata[i].timestamp_eof = (uint64_t)nanos_since_boot(); // set true eof if (dp) s->buf.queue(i); // destroy old output fence struct cam_sync_info sync_destroy = {0}; strcpy(sync_destroy.name, "NodeOutputPortFence"); sync_destroy.sync_obj = s->sync_objs[i]; ret = cam_control(s->multi_cam_state->video1_fd, CAM_SYNC_DESTROY, &sync_destroy, sizeof(sync_destroy)); // LOGD("fence destroy: %d %d", ret, sync_destroy.sync_obj); } // do stuff struct cam_req_mgr_sched_request req_mgr_sched_request = {0}; req_mgr_sched_request.session_hdl = s->session_handle; req_mgr_sched_request.link_hdl = s->link_handle; req_mgr_sched_request.req_id = request_id; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_SCHED_REQ, &req_mgr_sched_request, sizeof(req_mgr_sched_request)); // LOGD("sched req: %d %d", ret, request_id); // create output fence struct cam_sync_info sync_create = {0}; strcpy(sync_create.name, "NodeOutputPortFence"); ret = cam_control(s->multi_cam_state->video1_fd, CAM_SYNC_CREATE, &sync_create, sizeof(sync_create)); // LOGD("fence req: %d %d", ret, sync_create.sync_obj); s->sync_objs[i] = sync_create.sync_obj; // configure ISP to put the image in place struct cam_mem_mgr_map_cmd mem_mgr_map_cmd = {0}; mem_mgr_map_cmd.mmu_hdls[0] = s->multi_cam_state->device_iommu; mem_mgr_map_cmd.num_hdl = 1; mem_mgr_map_cmd.flags = CAM_MEM_FLAG_HW_READ_WRITE; mem_mgr_map_cmd.fd = s->buf.camera_bufs[i].fd; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_MAP_BUF, &mem_mgr_map_cmd, sizeof(mem_mgr_map_cmd)); // LOGD("map buf req: (fd: %d) 0x%x %d", s->bufs[i].fd, mem_mgr_map_cmd.out.buf_handle, ret); s->buf_handle[i] = mem_mgr_map_cmd.out.buf_handle; // poke sensor sensors_poke(s, request_id); // LOGD("Poked sensor"); // push the buffer config_isp(s, s->buf_handle[i], s->sync_objs[i], request_id, s->buf0_handle, 65632*(i+1)); } void enqueue_req_multi(struct CameraState *s, int start, int n, bool dp) { for (int i=start;irequest_ids[(i - 1) % FRAME_BUF_COUNT] = i; enqueue_buffer(s, (i - 1) % FRAME_BUF_COUNT, dp); } } // ******************* camera ******************* static void camera_init(MultiCameraState *multi_cam_state, VisionIpcServer * v, CameraState *s, int camera_id, int camera_num, unsigned int fps, cl_device_id device_id, cl_context ctx, VisionStreamType rgb_type, VisionStreamType yuv_type) { LOGD("camera init %d", camera_num); s->multi_cam_state = multi_cam_state; assert(camera_id < std::size(cameras_supported)); s->ci = cameras_supported[camera_id]; assert(s->ci.frame_width != 0); s->camera_num = camera_num; s->request_id_last = 0; s->skipped = true; s->min_ev = EXPOSURE_TIME_MIN * sensor_analog_gains[ANALOG_GAIN_MIN_IDX]; s->max_ev = EXPOSURE_TIME_MAX * sensor_analog_gains[ANALOG_GAIN_MAX_IDX] * DC_GAIN; s->target_grey_fraction = 0.3; s->dc_gain_enabled = false; s->gain_idx = ANALOG_GAIN_REC_IDX; s->exposure_time = 5; s->cur_ev[0] = s->cur_ev[1] = s->cur_ev[2] = (s->dc_gain_enabled ? DC_GAIN : 1) * sensor_analog_gains[s->gain_idx] * s->exposure_time; s->buf.init(device_id, ctx, s, v, FRAME_BUF_COUNT, rgb_type, yuv_type); } int open_v4l_by_name_and_index(const char name[], int index, int flags = O_RDWR | O_NONBLOCK) { for (int v4l_index = 0; /**/; ++v4l_index) { std::string v4l_name = util::read_file(util::string_format("/sys/class/video4linux/v4l-subdev%d/name", v4l_index)); if (v4l_name.empty()) return -1; if (v4l_name.find(name) == 0) { if (index == 0) { return open(util::string_format("/dev/v4l-subdev%d", v4l_index).c_str(), flags); } index--; } } } static void camera_open(CameraState *s) { int ret; s->sensor_fd = open_v4l_by_name_and_index("cam-sensor-driver", s->camera_num); assert(s->sensor_fd >= 0); LOGD("opened sensor"); s->csiphy_fd = open_v4l_by_name_and_index("cam-csiphy-driver", s->camera_num); assert(s->csiphy_fd >= 0); LOGD("opened csiphy"); // probe the sensor LOGD("-- Probing sensor %d", s->camera_num); sensors_init(s->multi_cam_state->video0_fd, s->sensor_fd, s->camera_num); // create session struct cam_req_mgr_session_info session_info = {}; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_CREATE_SESSION, &session_info, sizeof(session_info)); LOGD("get session: %d 0x%X", ret, session_info.session_hdl); s->session_handle = session_info.session_hdl; // access the sensor LOGD("-- Accessing sensor"); auto sensor_dev_handle = device_acquire(s->sensor_fd, s->session_handle, nullptr); assert(sensor_dev_handle); s->sensor_dev_handle = *sensor_dev_handle; LOGD("acquire sensor dev"); static struct cam_isp_resource isp_resource = {0}; isp_resource.resource_id = CAM_ISP_RES_ID_PORT; isp_resource.length = sizeof(struct cam_isp_in_port_info) + sizeof(struct cam_isp_out_port_info)*(1-1); isp_resource.handle_type = CAM_HANDLE_USER_POINTER; struct cam_isp_in_port_info *in_port_info = (struct cam_isp_in_port_info *)malloc(isp_resource.length); isp_resource.res_hdl = (uint64_t)in_port_info; switch (s->camera_num) { case 0: in_port_info->res_type = CAM_ISP_IFE_IN_RES_PHY_0; break; case 1: in_port_info->res_type = CAM_ISP_IFE_IN_RES_PHY_1; break; case 2: in_port_info->res_type = CAM_ISP_IFE_IN_RES_PHY_2; break; } in_port_info->lane_type = CAM_ISP_LANE_TYPE_DPHY; in_port_info->lane_num = 4; in_port_info->lane_cfg = 0x3210; in_port_info->vc = 0x0; //in_port_info->dt = 0x2C; //CSI_RAW12 //in_port_info->format = CAM_FORMAT_MIPI_RAW_12; in_port_info->dt = 0x2B; //CSI_RAW10 in_port_info->format = CAM_FORMAT_MIPI_RAW_10; in_port_info->test_pattern = 0x2; // 0x3? in_port_info->usage_type = 0x0; in_port_info->left_start = 0x0; in_port_info->left_stop = FRAME_WIDTH - 1; in_port_info->left_width = FRAME_WIDTH; in_port_info->right_start = 0x0; in_port_info->right_stop = FRAME_WIDTH - 1; in_port_info->right_width = FRAME_WIDTH; in_port_info->line_start = 0x0; in_port_info->line_stop = FRAME_HEIGHT - 1; in_port_info->height = FRAME_HEIGHT; in_port_info->pixel_clk = 0x0; in_port_info->batch_size = 0x0; in_port_info->dsp_mode = 0x0; in_port_info->hbi_cnt = 0x0; in_port_info->custom_csid = 0x0; in_port_info->num_out_res = 0x1; in_port_info->data[0] = (struct cam_isp_out_port_info){ .res_type = CAM_ISP_IFE_OUT_RES_RDI_0, //.format = CAM_FORMAT_MIPI_RAW_12, .format = CAM_FORMAT_MIPI_RAW_10, .width = FRAME_WIDTH, .height = FRAME_HEIGHT, .comp_grp_id = 0x0, .split_point = 0x0, .secure_mode = 0x0, }; auto isp_dev_handle = device_acquire(s->multi_cam_state->isp_fd, s->session_handle, &isp_resource); assert(isp_dev_handle); s->isp_dev_handle = *isp_dev_handle; LOGD("acquire isp dev"); free(in_port_info); struct cam_csiphy_acquire_dev_info csiphy_acquire_dev_info = {.combo_mode = 0}; auto csiphy_dev_handle = device_acquire(s->csiphy_fd, s->session_handle, &csiphy_acquire_dev_info); assert(csiphy_dev_handle); s->csiphy_dev_handle = *csiphy_dev_handle; LOGD("acquire csiphy dev"); // acquires done // config ISP alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, 984480, (uint32_t*)&s->buf0_handle, 0x20, CAM_MEM_FLAG_HW_READ_WRITE | CAM_MEM_FLAG_KMD_ACCESS | CAM_MEM_FLAG_UMD_ACCESS | CAM_MEM_FLAG_CMD_BUF_TYPE, s->multi_cam_state->device_iommu, s->multi_cam_state->cdm_iommu); config_isp(s, 0, 0, 1, s->buf0_handle, 0); LOG("-- Configuring sensor"); sensors_i2c(s, init_array_ar0231, sizeof(init_array_ar0231)/sizeof(struct i2c_random_wr_payload), CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); //sensors_i2c(s, start_reg_array, sizeof(start_reg_array)/sizeof(struct i2c_random_wr_payload), //CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON); //sensors_i2c(s, stop_reg_array, sizeof(stop_reg_array)/sizeof(struct i2c_random_wr_payload), //CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMOFF); // config csiphy LOG("-- Config CSI PHY"); { uint32_t cam_packet_handle = 0; int size = sizeof(struct cam_packet)+sizeof(struct cam_cmd_buf_desc)*1; struct cam_packet *pkt = (struct cam_packet *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, size, &cam_packet_handle); pkt->num_cmd_buf = 1; pkt->kmd_cmd_buf_index = -1; pkt->header.size = size; struct cam_cmd_buf_desc *buf_desc = (struct cam_cmd_buf_desc *)&pkt->payload; buf_desc[0].size = buf_desc[0].length = sizeof(struct cam_csiphy_info); buf_desc[0].type = CAM_CMD_BUF_GENERIC; struct cam_csiphy_info *csiphy_info = (struct cam_csiphy_info *)alloc_w_mmu_hdl(s->multi_cam_state->video0_fd, buf_desc[0].size, (uint32_t*)&buf_desc[0].mem_handle); csiphy_info->lane_mask = 0x1f; csiphy_info->lane_assign = 0x3210;// skip clk. How is this 16 bit for 5 channels?? csiphy_info->csiphy_3phase = 0x0; // no 3 phase, only 2 conductors per lane csiphy_info->combo_mode = 0x0; csiphy_info->lane_cnt = 0x4; csiphy_info->secure_mode = 0x0; csiphy_info->settle_time = MIPI_SETTLE_CNT * 200000000ULL; csiphy_info->data_rate = 48000000; // Calculated by camera_freqs.py int ret = device_config(s->csiphy_fd, s->session_handle, s->csiphy_dev_handle, cam_packet_handle); assert(ret == 0); munmap(csiphy_info, buf_desc[0].size); release_fd(s->multi_cam_state->video0_fd, buf_desc[0].mem_handle); munmap(pkt, size); release_fd(s->multi_cam_state->video0_fd, cam_packet_handle); } // link devices LOG("-- Link devices"); static struct cam_req_mgr_link_info req_mgr_link_info = {0}; req_mgr_link_info.session_hdl = s->session_handle; req_mgr_link_info.num_devices = 2; req_mgr_link_info.dev_hdls[0] = s->isp_dev_handle; req_mgr_link_info.dev_hdls[1] = s->sensor_dev_handle; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_LINK, &req_mgr_link_info, sizeof(req_mgr_link_info)); LOGD("link: %d", ret); s->link_handle = req_mgr_link_info.link_hdl; static struct cam_req_mgr_link_control req_mgr_link_control = {0}; req_mgr_link_control.ops = CAM_REQ_MGR_LINK_ACTIVATE; req_mgr_link_control.session_hdl = s->session_handle; req_mgr_link_control.num_links = 1; req_mgr_link_control.link_hdls[0] = s->link_handle; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_LINK_CONTROL, &req_mgr_link_control, sizeof(req_mgr_link_control)); LOGD("link control: %d", ret); ret = device_control(s->csiphy_fd, CAM_START_DEV, s->session_handle, s->csiphy_dev_handle); LOGD("start csiphy: %d", ret); ret = device_control(s->multi_cam_state->isp_fd, CAM_START_DEV, s->session_handle, s->isp_dev_handle); LOGD("start isp: %d", ret); ret = device_control(s->sensor_fd, CAM_START_DEV, s->session_handle, s->sensor_dev_handle); LOGD("start sensor: %d", ret); enqueue_req_multi(s, 1, FRAME_BUF_COUNT, 0); } void cameras_init(VisionIpcServer *v, MultiCameraState *s, cl_device_id device_id, cl_context ctx) { camera_init(s, v, &s->road_cam, CAMERA_ID_AR0231, 1, 20, device_id, ctx, VISION_STREAM_RGB_BACK, VISION_STREAM_YUV_BACK); // swap left/right printf("road camera initted \n"); camera_init(s, v, &s->wide_road_cam, CAMERA_ID_AR0231, 0, 20, device_id, ctx, VISION_STREAM_RGB_WIDE, VISION_STREAM_YUV_WIDE); printf("wide road camera initted \n"); camera_init(s, v, &s->driver_cam, CAMERA_ID_AR0231, 2, 20, device_id, ctx, VISION_STREAM_RGB_FRONT, VISION_STREAM_YUV_FRONT); printf("driver camera initted \n"); s->sm = new SubMaster({"driverState"}); s->pm = new PubMaster({"roadCameraState", "driverCameraState", "wideRoadCameraState", "thumbnail"}); } void cameras_open(MultiCameraState *s) { int ret; LOG("-- Opening devices"); // video0 is req_mgr, the target of many ioctls s->video0_fd = HANDLE_EINTR(open("/dev/v4l/by-path/platform-soc:qcom_cam-req-mgr-video-index0", O_RDWR | O_NONBLOCK)); assert(s->video0_fd >= 0); LOGD("opened video0"); // video1 is cam_sync, the target of some ioctls s->video1_fd = HANDLE_EINTR(open("/dev/v4l/by-path/platform-cam_sync-video-index0", O_RDWR | O_NONBLOCK)); assert(s->video1_fd >= 0); LOGD("opened video1"); // looks like there's only one of these s->isp_fd = HANDLE_EINTR(open("/dev/v4l-subdev1", O_RDWR | O_NONBLOCK)); assert(s->isp_fd >= 0); LOGD("opened isp"); // query icp for MMU handles LOG("-- Query ICP for MMU handles"); static struct cam_isp_query_cap_cmd isp_query_cap_cmd = {0}; static struct cam_query_cap_cmd query_cap_cmd = {0}; query_cap_cmd.handle_type = 1; query_cap_cmd.caps_handle = (uint64_t)&isp_query_cap_cmd; query_cap_cmd.size = sizeof(isp_query_cap_cmd); ret = cam_control(s->isp_fd, CAM_QUERY_CAP, &query_cap_cmd, sizeof(query_cap_cmd)); assert(ret == 0); LOGD("using MMU handle: %x", isp_query_cap_cmd.device_iommu.non_secure); LOGD("using MMU handle: %x", isp_query_cap_cmd.cdm_iommu.non_secure); s->device_iommu = isp_query_cap_cmd.device_iommu.non_secure; s->cdm_iommu = isp_query_cap_cmd.cdm_iommu.non_secure; // subscribe LOG("-- Subscribing"); static struct v4l2_event_subscription sub = {0}; sub.type = V4L_EVENT_CAM_REQ_MGR_EVENT; sub.id = 2; // should use boot time for sof ret = HANDLE_EINTR(ioctl(s->video0_fd, VIDIOC_SUBSCRIBE_EVENT, &sub)); printf("req mgr subscribe: %d\n", ret); camera_open(&s->road_cam); printf("road camera opened \n"); camera_open(&s->wide_road_cam); printf("wide road camera opened \n"); camera_open(&s->driver_cam); printf("driver camera opened \n"); } static void camera_close(CameraState *s) { int ret; // stop devices LOG("-- Stop devices"); // ret = device_control(s->sensor_fd, CAM_STOP_DEV, s->session_handle, s->sensor_dev_handle); // LOGD("stop sensor: %d", ret); ret = device_control(s->multi_cam_state->isp_fd, CAM_STOP_DEV, s->session_handle, s->isp_dev_handle); LOGD("stop isp: %d", ret); ret = device_control(s->csiphy_fd, CAM_STOP_DEV, s->session_handle, s->csiphy_dev_handle); LOGD("stop csiphy: %d", ret); // link control stop LOG("-- Stop link control"); static struct cam_req_mgr_link_control req_mgr_link_control = {0}; req_mgr_link_control.ops = CAM_REQ_MGR_LINK_DEACTIVATE; req_mgr_link_control.session_hdl = s->session_handle; req_mgr_link_control.num_links = 1; req_mgr_link_control.link_hdls[0] = s->link_handle; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_LINK_CONTROL, &req_mgr_link_control, sizeof(req_mgr_link_control)); LOGD("link control stop: %d", ret); // unlink LOG("-- Unlink"); static struct cam_req_mgr_unlink_info req_mgr_unlink_info = {0}; req_mgr_unlink_info.session_hdl = s->session_handle; req_mgr_unlink_info.link_hdl = s->link_handle; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_UNLINK, &req_mgr_unlink_info, sizeof(req_mgr_unlink_info)); LOGD("unlink: %d", ret); // release devices LOGD("-- Release devices"); ret = device_control(s->sensor_fd, CAM_RELEASE_DEV, s->session_handle, s->sensor_dev_handle); LOGD("release sensor: %d", ret); ret = device_control(s->multi_cam_state->isp_fd, CAM_RELEASE_DEV, s->session_handle, s->isp_dev_handle); LOGD("release isp: %d", ret); ret = device_control(s->csiphy_fd, CAM_RELEASE_DEV, s->session_handle, s->csiphy_dev_handle); LOGD("release csiphy: %d", ret); // destroyed session struct cam_req_mgr_session_info session_info = {.session_hdl = s->session_handle}; ret = cam_control(s->multi_cam_state->video0_fd, CAM_REQ_MGR_DESTROY_SESSION, &session_info, sizeof(session_info)); LOGD("destroyed session: %d", ret); } void cameras_close(MultiCameraState *s) { camera_close(&s->road_cam); camera_close(&s->wide_road_cam); camera_close(&s->driver_cam); delete s->sm; delete s->pm; } // ******************* just a helper ******************* void handle_camera_event(CameraState *s, void *evdat) { struct cam_req_mgr_message *event_data = (struct cam_req_mgr_message *)evdat; uint64_t timestamp = event_data->u.frame_msg.timestamp; int main_id = event_data->u.frame_msg.frame_id; int real_id = event_data->u.frame_msg.request_id; if (real_id != 0) { // next ready if (real_id == 1) {s->idx_offset = main_id;} int buf_idx = (real_id - 1) % FRAME_BUF_COUNT; // check for skipped frames if (main_id > s->frame_id_last + 1 && !s->skipped) { // realign clear_req_queue(s->multi_cam_state->video0_fd, event_data->session_hdl, event_data->u.frame_msg.link_hdl); enqueue_req_multi(s, real_id + 1, FRAME_BUF_COUNT - 1, 0); s->skipped = true; } else if (main_id == s->frame_id_last + 1) { s->skipped = false; } // check for dropped requests if (real_id > s->request_id_last + 1) { enqueue_req_multi(s, s->request_id_last + 1 + FRAME_BUF_COUNT, real_id - (s->request_id_last + 1), 0); } // metas s->frame_id_last = main_id; s->request_id_last = real_id; auto &meta_data = s->buf.camera_bufs_metadata[buf_idx]; meta_data.frame_id = main_id - s->idx_offset; meta_data.timestamp_sof = timestamp; s->exp_lock.lock(); meta_data.gain = s->dc_gain_enabled ? s->analog_gain_frac * DC_GAIN : s->analog_gain_frac; meta_data.high_conversion_gain = s->dc_gain_enabled; meta_data.integ_lines = s->exposure_time; meta_data.measured_grey_fraction = s->measured_grey_fraction; meta_data.target_grey_fraction = s->target_grey_fraction; s->exp_lock.unlock(); // dispatch enqueue_req_multi(s, real_id + FRAME_BUF_COUNT, 1, 1); } else { // not ready // reset after half second of no response if (main_id > s->frame_id_last + 10) { clear_req_queue(s->multi_cam_state->video0_fd, event_data->session_hdl, event_data->u.frame_msg.link_hdl); enqueue_req_multi(s, s->request_id_last + 1, FRAME_BUF_COUNT, 0); s->frame_id_last = main_id; s->skipped = true; } } } static void set_camera_exposure(CameraState *s, float grey_frac) { const float dt = 0.05; const float ts_grey = 10.0; const float ts_ev = 0.05; const float k_grey = (dt / ts_grey) / (1.0 + dt / ts_grey); const float k_ev = (dt / ts_ev) / (1.0 + dt / ts_ev); // It takes 3 frames for the commanded exposure settings to take effect. The first frame is already started by the time // we reach this function, the other 2 are due to the register buffering in the sensor. // Therefore we use the target EV from 3 frames ago, the grey fraction that was just measured was the result of that control action. // TODO: Lower latency to 2 frames, by using the histogram outputed by the sensor we can do AE before the debayering is complete const float cur_ev = s->cur_ev[s->buf.cur_frame_data.frame_id % 3]; // Scale target grey between 0.1 and 0.4 depending on lighting conditions float new_target_grey = std::clamp(0.4 - 0.3 * log2(1.0 + cur_ev) / log2(6000.0), 0.1, 0.4); float target_grey = (1.0 - k_grey) * s->target_grey_fraction + k_grey * new_target_grey; float desired_ev = std::clamp(cur_ev * target_grey / grey_frac, s->min_ev, s->max_ev); float k = (1.0 - k_ev) / 3.0; desired_ev = (k * s->cur_ev[0]) + (k * s->cur_ev[1]) + (k * s->cur_ev[2]) + (k_ev * desired_ev); float best_ev_score = 1e6; int new_g = 0; int new_t = 0; // Hysteresis around high conversion gain // We usually want this on since it results in lower noise, but turn off in very bright day scenes bool enable_dc_gain = s->dc_gain_enabled; if (!enable_dc_gain && target_grey < 0.2) { enable_dc_gain = true; } else if (enable_dc_gain && target_grey > 0.3) { enable_dc_gain = false; } // Simple brute force optimizer to choose sensor parameters // to reach desired EV for (int g = std::max((int)ANALOG_GAIN_MIN_IDX, s->gain_idx - 1); g <= std::min((int)ANALOG_GAIN_MAX_IDX, s->gain_idx + 1); g++) { float gain = sensor_analog_gains[g] * (enable_dc_gain ? DC_GAIN : 1); // Compute optimal time for given gain int t = std::clamp(int(std::round(desired_ev / gain)), EXPOSURE_TIME_MIN, EXPOSURE_TIME_MAX); // Only go below recomended gain when absolutely necessary to not overexpose if (g < ANALOG_GAIN_REC_IDX && t > 20 && g < s->gain_idx) { continue; } // Compute error to desired ev float score = std::abs(desired_ev - (t * gain)) * 10; // Going below recomended gain needs lower penalty to not overexpose float m = g > ANALOG_GAIN_REC_IDX ? 5.0 : 0.1; score += std::abs(g - (int)ANALOG_GAIN_REC_IDX) * m; // LOGE("cam: %d - gain: %d, t: %d (%.2f), score %.2f, score + gain %.2f, %.3f, %.3f", s->camera_num, g, t, desired_ev / gain, score, score + std::abs(g - s->gain_idx) * (score + 1.0) / 10.0, desired_ev, s->min_ev); // Small penalty on changing gain score += std::abs(g - s->gain_idx) * (score + 1.0) / 10.0; if (score < best_ev_score) { new_t = t; new_g = g; best_ev_score = score; } } s->exp_lock.lock(); s->measured_grey_fraction = grey_frac; s->target_grey_fraction = target_grey; s->analog_gain_frac = sensor_analog_gains[new_g]; s->gain_idx = new_g; s->exposure_time = new_t; s->dc_gain_enabled = enable_dc_gain; float gain = s->analog_gain_frac * (s->dc_gain_enabled ? DC_GAIN : 1.0); s->cur_ev[s->buf.cur_frame_data.frame_id % 3] = s->exposure_time * gain; s->exp_lock.unlock(); // Processing a frame takes right about 50ms, so we need to wait a few ms // so we don't send i2c commands around the frame start. int ms = (nanos_since_boot() - s->buf.cur_frame_data.timestamp_sof) / 1000000; if (ms < 60) { util::sleep_for(60 - ms); } // LOGE("ae - camera %d, cur_t %.5f, sof %.5f, dt %.5f", s->camera_num, 1e-9 * nanos_since_boot(), 1e-9 * s->buf.cur_frame_data.timestamp_sof, 1e-9 * (nanos_since_boot() - s->buf.cur_frame_data.timestamp_sof)); uint16_t analog_gain_reg = 0xFF00 | (new_g << 4) | new_g; struct i2c_random_wr_payload exp_reg_array[] = { {0x3366, analog_gain_reg}, {0x3362, (uint16_t)(s->dc_gain_enabled ? 0x1 : 0x0)}, {0x3012, (uint16_t)s->exposure_time}, }; sensors_i2c(s, exp_reg_array, sizeof(exp_reg_array)/sizeof(struct i2c_random_wr_payload), CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); } void camera_autoexposure(CameraState *s, float grey_frac) { set_camera_exposure(s, grey_frac); } void process_driver_camera(MultiCameraState *s, CameraState *c, int cnt) { common_process_driver_camera(s->sm, s->pm, c, cnt); } // called by processing_thread void process_road_camera(MultiCameraState *s, CameraState *c, int cnt) { const CameraBuf *b = &c->buf; MessageBuilder msg; auto framed = c == &s->road_cam ? msg.initEvent().initRoadCameraState() : msg.initEvent().initWideRoadCameraState(); fill_frame_data(framed, b->cur_frame_data); if ((c == &s->road_cam && env_send_road) || (c == &s->wide_road_cam && env_send_wide_road)) { framed.setImage(get_frame_image(b)); } if (c == &s->road_cam) { framed.setTransform(b->yuv_transform.v); } s->pm->send(c == &s->road_cam ? "roadCameraState" : "wideRoadCameraState", msg); const auto [x, y, w, h] = (c == &s->wide_road_cam) ? std::tuple(96, 250, 1734, 524) : std::tuple(96, 160, 1734, 986); const int skip = 2; camera_autoexposure(c, set_exposure_target(b, x, x + w, skip, y, y + h, skip)); } void cameras_run(MultiCameraState *s) { LOG("-- Starting threads"); std::vector threads; threads.push_back(start_process_thread(s, &s->road_cam, process_road_camera)); threads.push_back(start_process_thread(s, &s->driver_cam, process_driver_camera)); threads.push_back(start_process_thread(s, &s->wide_road_cam, process_road_camera)); // start devices LOG("-- Starting devices"); int start_reg_len = sizeof(start_reg_array) / sizeof(struct i2c_random_wr_payload); sensors_i2c(&s->road_cam, start_reg_array, start_reg_len, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); sensors_i2c(&s->wide_road_cam, start_reg_array, start_reg_len, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); sensors_i2c(&s->driver_cam, start_reg_array, start_reg_len, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG); // poll events LOG("-- Dequeueing Video events"); while (!do_exit) { struct pollfd fds[1] = {{0}}; fds[0].fd = s->video0_fd; fds[0].events = POLLPRI; int ret = poll(fds, std::size(fds), 1000); if (ret < 0) { if (errno == EINTR || errno == EAGAIN) continue; LOGE("poll failed (%d - %d)", ret, errno); break; } if (!fds[0].revents) continue; struct v4l2_event ev = {0}; ret = HANDLE_EINTR(ioctl(fds[0].fd, VIDIOC_DQEVENT, &ev)); if (ret == 0) { if (ev.type == V4L_EVENT_CAM_REQ_MGR_EVENT) { struct cam_req_mgr_message *event_data = (struct cam_req_mgr_message *)ev.u.data; // LOGD("v4l2 event: sess_hdl %d, link_hdl %d, frame_id %d, req_id %lld, timestamp 0x%llx, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp, event_data->u.frame_msg.sof_status); // printf("sess_hdl %d, link_hdl %d, frame_id %lu, req_id %lu, timestamp 0x%lx, sof_status %d\n", event_data->session_hdl, event_data->u.frame_msg.link_hdl, event_data->u.frame_msg.frame_id, event_data->u.frame_msg.request_id, event_data->u.frame_msg.timestamp, event_data->u.frame_msg.sof_status); if (event_data->session_hdl == s->road_cam.session_handle) { handle_camera_event(&s->road_cam, event_data); } else if (event_data->session_hdl == s->wide_road_cam.session_handle) { handle_camera_event(&s->wide_road_cam, event_data); } else if (event_data->session_hdl == s->driver_cam.session_handle) { handle_camera_event(&s->driver_cam, event_data); } else { printf("Unknown vidioc event source\n"); assert(false); } } } else { LOGE("VIDIOC_DQEVENT failed, errno=%d", errno); } } LOG(" ************** STOPPING **************"); for (auto &t : threads) t.join(); cameras_close(s); } ================================================ FILE: selfdrive/camerad/cameras/camera_qcom2.h ================================================ #pragma once #include #include #include "selfdrive/camerad/cameras/camera_common.h" #include "selfdrive/common/util.h" #define FRAME_BUF_COUNT 4 #define DEBAYER_LOCAL_WORKSIZE 16 typedef struct CameraState { MultiCameraState *multi_cam_state; CameraInfo ci; std::mutex exp_lock; int exposure_time; bool dc_gain_enabled; float analog_gain_frac; float cur_ev[3]; float min_ev, max_ev; float measured_grey_fraction; float target_grey_fraction; int gain_idx; unique_fd sensor_fd; unique_fd csiphy_fd; int camera_num; int32_t session_handle; int32_t sensor_dev_handle; int32_t isp_dev_handle; int32_t csiphy_dev_handle; int32_t link_handle; int buf0_handle; int buf_handle[FRAME_BUF_COUNT]; int sync_objs[FRAME_BUF_COUNT]; int request_ids[FRAME_BUF_COUNT]; int request_id_last; int frame_id_last; int idx_offset; bool skipped; CameraBuf buf; } CameraState; typedef struct MultiCameraState { unique_fd video0_fd; unique_fd video1_fd; unique_fd isp_fd; int device_iommu; int cdm_iommu; CameraState road_cam; CameraState wide_road_cam; CameraState driver_cam; SubMaster *sm; PubMaster *pm; } MultiCameraState; ================================================ FILE: selfdrive/camerad/cameras/debayer.cl ================================================ const __constant float3 color_correction[3] = { // Matrix from WBraw -> sRGBD65 (normalized) (float3)( 1.62393627, -0.2092988, 0.00119886), (float3)(-0.45734315, 1.5534676, -0.59296798), (float3)(-0.16659312, -0.3441688, 1.59176912), }; float3 color_correct(float3 x) { float3 ret = (0,0,0); // white balance of daylight x /= (float3)(0.4609375, 1.0, 0.546875); x = max(0.0, min(1.0, x)); // fix up the colors ret += x.x * color_correction[0]; ret += x.y * color_correction[1]; ret += x.z * color_correction[2]; return ret; } float3 srgb_gamma(float3 p) { // go all out and add an sRGB gamma curve const float3 ph = (1.0f + 0.055f)*pow(p, 1/2.4f) - 0.055f; const float3 pl = p*12.92f; return select(ph, pl, islessequal(p, 0.0031308f)); } __constant int dpcm_lookup[512] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, 935, 951, 967, 983, 999, 1015, 1031, 1047, 1063, 1079, 1095, 1111, 1127, 1143, 1159, 1175, 1191, 1207, 1223, 1239, 1255, 1271, 1287, 1303, 1319, 1335, 1351, 1367, 1383, 1399, 1415, 1431, -935, -951, -967, -983, -999, -1015, -1031, -1047, -1063, -1079, -1095, -1111, -1127, -1143, -1159, -1175, -1191, -1207, -1223, -1239, -1255, -1271, -1287, -1303, -1319, -1335, -1351, -1367, -1383, -1399, -1415, -1431, 419, 427, 435, 443, 451, 459, 467, 475, 483, 491, 499, 507, 515, 523, 531, 539, 547, 555, 563, 571, 579, 587, 595, 603, 611, 619, 627, 635, 643, 651, 659, 667, 675, 683, 691, 699, 707, 715, 723, 731, 739, 747, 755, 763, 771, 779, 787, 795, 803, 811, 819, 827, 835, 843, 851, 859, 867, 875, 883, 891, 899, 907, 915, 923, -419, -427, -435, -443, -451, -459, -467, -475, -483, -491, -499, -507, -515, -523, -531, -539, -547, -555, -563, -571, -579, -587, -595, -603, -611, -619, -627, -635, -643, -651, -659, -667, -675, -683, -691, -699, -707, -715, -723, -731, -739, -747, -755, -763, -771, -779, -787, -795, -803, -811, -819, -827, -835, -843, -851, -859, -867, -875, -883, -891, -899, -907, -915, -923, 161, 165, 169, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 365, 369, 373, 377, 381, 385, 389, 393, 397, 401, 405, 409, 413, -161, -165, -169, -173, -177, -181, -185, -189, -193, -197, -201, -205, -209, -213, -217, -221, -225, -229, -233, -237, -241, -245, -249, -253, -257, -261, -265, -269, -273, -277, -281, -285, -289, -293, -297, -301, -305, -309, -313, -317, -321, -325, -329, -333, -337, -341, -345, -349, -353, -357, -361, -365, -369, -373, -377, -381, -385, -389, -393, -397, -401, -405, -409, -413, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, -32, -34, -36, -38, -40, -42, -44, -46, -48, -50, -52, -54, -56, -58, -60, -62, -64, -66, -68, -70, -72, -74, -76, -78, -80, -82, -84, -86, -88, -90, -92, -94, -96, -98, -100, -102, -104, -106, -108, -110, -112, -114, -116, -118, -120, -122, -124, -126, -128, -130, -132, -134, -136, -138, -140, -142, -144, -146, -148, -150, -152, -154, -156, -158}; inline uint4 decompress(uint4 p, uint4 pl) { uint4 r1 = (pl + (uint4)(dpcm_lookup[p.s0], dpcm_lookup[p.s1], dpcm_lookup[p.s2], dpcm_lookup[p.s3])); uint4 r2 = ((p-0x200)<<5) | 0xF; r2 += select((uint4)(0,0,0,0), (uint4)(1,1,1,1), r2 <= pl); return select(r2, r1, p < 0x200); } __kernel void debayer10(__global uchar const * const in, __global uchar * out, float digital_gain) { const int oy = get_global_id(0); if (oy >= RGB_HEIGHT) return; const int iy = oy * 2; uint4 pint_last; for (int ox = 0; ox < RGB_WIDTH; ox += 2) { const int ix = (ox/2) * 5; // TODO: why doesn't this work for the frontview /*const uchar8 v1 = vload8(0, &in[iy * FRAME_STRIDE + ix]); const uchar ex1 = v1.s4; const uchar8 v2 = vload8(0, &in[(iy+1) * FRAME_STRIDE + ix]); const uchar ex2 = v2.s4;*/ const uchar4 v1 = vload4(0, &in[iy * FRAME_STRIDE + ix]); const uchar ex1 = in[iy * FRAME_STRIDE + ix + 4]; const uchar4 v2 = vload4(0, &in[(iy+1) * FRAME_STRIDE + ix]); const uchar ex2 = in[(iy+1) * FRAME_STRIDE + ix + 4]; uint4 pinta[2]; pinta[0] = (uint4)( (((uint)v1.s0 << 2) + ( (ex1 >> 0) & 3)), (((uint)v1.s1 << 2) + ( (ex1 >> 2) & 3)), (((uint)v2.s0 << 2) + ( (ex2 >> 0) & 3)), (((uint)v2.s1 << 2) + ( (ex2 >> 2) & 3))); pinta[1] = (uint4)( (((uint)v1.s2 << 2) + ( (ex1 >> 4) & 3)), (((uint)v1.s3 << 2) + ( (ex1 >> 6) & 3)), (((uint)v2.s2 << 2) + ( (ex2 >> 4) & 3)), (((uint)v2.s3 << 2) + ( (ex2 >> 6) & 3))); #pragma unroll for (uint px = 0; px < 2; px++) { uint4 pint = pinta[px]; #if HDR // decompress HDR pint = (ox == 0 && px == 0) ? ((pint<<4) | 8) : decompress(pint, pint_last); pint_last = pint; #endif float4 p = convert_float4(pint); // 64 is the black level of the sensor, remove // (changed to 56 for HDR) const float black_level = 56.0f; // TODO: switch to max here? p = (p - black_level); // correct vignetting (no pow function?) // see https://www.eecis.udel.edu/~jye/lab_research/09/JiUp.pdf the A (4th order) const float r = ((oy - RGB_HEIGHT/2)*(oy - RGB_HEIGHT/2) + (ox - RGB_WIDTH/2)*(ox - RGB_WIDTH/2)); const float fake_f = 700.0f; // should be 910, but this fits... const float lil_a = (1.0f + r/(fake_f*fake_f)); p = p * lil_a * lil_a; // rescale to 1.0 #if HDR p /= (16384.0f-black_level); #else p /= (1024.0f-black_level); #endif // digital gain p *= digital_gain; // use both green channels #if BAYER_FLIP == 3 float3 c1 = (float3)(p.s3, (p.s1+p.s2)/2.0f, p.s0); #elif BAYER_FLIP == 2 float3 c1 = (float3)(p.s2, (p.s0+p.s3)/2.0f, p.s1); #elif BAYER_FLIP == 1 float3 c1 = (float3)(p.s1, (p.s0+p.s3)/2.0f, p.s2); #elif BAYER_FLIP == 0 float3 c1 = (float3)(p.s0, (p.s1+p.s2)/2.0f, p.s3); #endif // color correction c1 = color_correct(c1); #if HDR // srgb gamma isn't right for YUV, so it's disabled for now c1 = srgb_gamma(c1); #endif // output BGR const int ooff = oy * RGB_STRIDE/3 + ox; vstore3(convert_uchar3_sat(c1.zyx * 255.0f), ooff+px, out); } } } ================================================ FILE: selfdrive/camerad/cameras/real_debayer.cl ================================================ #pragma OPENCL EXTENSION cl_khr_fp16 : enable const half black_level = 42.0; const __constant half3 color_correction[3] = { // post wb CCM (half3)(1.82717181, -0.31231438, 0.07307673), (half3)(-0.5743977, 1.36858544, -0.53183455), (half3)(-0.25277411, -0.05627105, 1.45875782), }; // tone mapping params const half cpk = 0.75; const half cpb = 0.125; const half cpxk = 0.0025; const half cpxb = 0.01; half mf(half x, half cp) { half rk = 9 - 100*cp; if (x > cp) { return (rk * (x-cp) * (1-(cpk*cp+cpb)) * (1+1/(rk*(1-cp))) / (1+rk*(x-cp))) + cpk*cp + cpb; } else if (x < cp) { return (rk * (x-cp) * (cpk*cp+cpb) * (1+1/(rk*cp)) / (1-rk*(x-cp))) + cpk*cp + cpb; } else { return x; } } half3 color_correct(half3 rgb) { half3 ret = (0,0,0); half cpx = 0.01; ret += (half)rgb.x * color_correction[0]; ret += (half)rgb.y * color_correction[1]; ret += (half)rgb.z * color_correction[2]; ret.x = mf(ret.x, cpx); ret.y = mf(ret.y, cpx); ret.z = mf(ret.z, cpx); ret = clamp(0.0h, 255.0h, ret*255.0h); return ret; } half val_from_10(const uchar * source, int gx, int gy) { // parse 10bit int start = gy * FRAME_STRIDE + (5 * (gx / 4)); int offset = gx % 4; uint major = (uint)source[start + offset] << 2; uint minor = (source[start + 4] >> (2 * offset)) & 3; half pv = (half)(major + minor); // normalize pv = max(0.0h, pv - black_level); pv *= 0.00101833h; // /= (1024.0f - black_level); // correct vignetting if (CAM_NUM == 1) { // fcamera gx = (gx - RGB_WIDTH/2); gy = (gy - RGB_HEIGHT/2); float r = gx*gx + gy*gy; half s; if (r < 62500) { s = (half)(1.0f + 0.0000008f*r); } else if (r < 490000) { s = (half)(0.9625f + 0.0000014f*r); } else if (r < 1102500) { s = (half)(1.26434f + 0.0000000000016f*r*r); } else { s = (half)(0.53503625f + 0.0000000000022f*r*r); } pv = s * pv; } pv = clamp(0.0h, 1.0h, pv); return pv; } half fabs_diff(half x, half y) { return fabs(x-y); } half phi(half x) { // detection funtion return 2 - x; // if (x > 1) { // return 1 / x; // } else { // return 2 - x; // } } __kernel void debayer10(const __global uchar * in, __global uchar * out, __local half * cached ) { const int x_global = get_global_id(0); const int y_global = get_global_id(1); const int localRowLen = 2 + get_local_size(0); // 2 padding const int x_local = get_local_id(0); // 0-15 const int y_local = get_local_id(1); // 0-15 const int localOffset = (y_local + 1) * localRowLen + x_local + 1; // max 18x18-1 int out_idx = 3 * x_global + 3 * y_global * RGB_WIDTH; half pv = val_from_10(in, x_global, y_global); cached[localOffset] = pv; // don't care if (x_global < 1 || x_global >= RGB_WIDTH - 1 || y_global < 1 || y_global >= RGB_HEIGHT - 1) { return; } // cache padding int localColOffset = -1; int globalColOffset = -1; // cache padding if (x_local < 1) { localColOffset = x_local; globalColOffset = -1; cached[(y_local + 1) * localRowLen + x_local] = val_from_10(in, x_global-1, y_global); } else if (x_local >= get_local_size(0) - 1) { localColOffset = x_local + 2; globalColOffset = 1; cached[localOffset + 1] = val_from_10(in, x_global+1, y_global); } if (y_local < 1) { cached[y_local * localRowLen + x_local + 1] = val_from_10(in, x_global, y_global-1); if (localColOffset != -1) { cached[y_local * localRowLen + localColOffset] = val_from_10(in, x_global+globalColOffset, y_global-1); } } else if (y_local >= get_local_size(1) - 1) { cached[(y_local + 2) * localRowLen + x_local + 1] = val_from_10(in, x_global, y_global+1); if (localColOffset != -1) { cached[(y_local + 2) * localRowLen + localColOffset] = val_from_10(in, x_global+globalColOffset, y_global+1); } } // sync barrier(CLK_LOCAL_MEM_FENCE); half d1 = cached[localOffset - localRowLen - 1]; half d2 = cached[localOffset - localRowLen + 1]; half d3 = cached[localOffset + localRowLen - 1]; half d4 = cached[localOffset + localRowLen + 1]; half n1 = cached[localOffset - localRowLen]; half n2 = cached[localOffset + 1]; half n3 = cached[localOffset + localRowLen]; half n4 = cached[localOffset - 1]; half3 rgb; // a simplified version of https://opensignalprocessingjournal.com/contents/volumes/V6/TOSIGPJ-6-1/TOSIGPJ-6-1.pdf if (x_global % 2 == 0) { if (y_global % 2 == 0) { rgb.y = pv; // G1(R) half k1 = phi(fabs_diff(d1, pv) + fabs_diff(d2, pv)); half k2 = phi(fabs_diff(d2, pv) + fabs_diff(d4, pv)); half k3 = phi(fabs_diff(d3, pv) + fabs_diff(d4, pv)); half k4 = phi(fabs_diff(d1, pv) + fabs_diff(d3, pv)); // R_G1 rgb.x = (k2*n2+k4*n4)/(k2+k4); // B_G1 rgb.z = (k1*n1+k3*n3)/(k1+k3); } else { rgb.z = pv; // B half k1 = phi(fabs_diff(d1, d3) + fabs_diff(d2, d4)); half k2 = phi(fabs_diff(n1, n4) + fabs_diff(n2, n3)); half k3 = phi(fabs_diff(d1, d2) + fabs_diff(d3, d4)); half k4 = phi(fabs_diff(n1, n2) + fabs_diff(n3, n4)); // G_B rgb.y = (k1*(n1+n3)*0.5+k3*(n2+n4)*0.5)/(k1+k3); // R_B rgb.x = (k2*(d2+d3)*0.5+k4*(d1+d4)*0.5)/(k2+k4); } } else { if (y_global % 2 == 0) { rgb.x = pv; // R half k1 = phi(fabs_diff(d1, d3) + fabs_diff(d2, d4)); half k2 = phi(fabs_diff(n1, n4) + fabs_diff(n2, n3)); half k3 = phi(fabs_diff(d1, d2) + fabs_diff(d3, d4)); half k4 = phi(fabs_diff(n1, n2) + fabs_diff(n3, n4)); // G_R rgb.y = (k1*(n1+n3)*0.5+k3*(n2+n4)*0.5)/(k1+k3); // B_R rgb.z = (k2*(d2+d3)*0.5+k4*(d1+d4)*0.5)/(k2+k4); } else { rgb.y = pv; // G2(B) half k1 = phi(fabs_diff(d1, pv) + fabs_diff(d2, pv)); half k2 = phi(fabs_diff(d2, pv) + fabs_diff(d4, pv)); half k3 = phi(fabs_diff(d3, pv) + fabs_diff(d4, pv)); half k4 = phi(fabs_diff(d1, pv) + fabs_diff(d3, pv)); // R_G2 rgb.x = (k1*n1+k3*n3)/(k1+k3); // B_G2 rgb.z = (k2*n2+k4*n4)/(k2+k4); } } rgb = clamp(0.0h, 1.0h, rgb); rgb = color_correct(rgb); out[out_idx + 0] = (uchar)(rgb.z); out[out_idx + 1] = (uchar)(rgb.y); out[out_idx + 2] = (uchar)(rgb.x); } ================================================ FILE: selfdrive/camerad/cameras/sensor2_i2c.h ================================================ struct i2c_random_wr_payload start_reg_array[] = {{0x301A, 0x91C}}; struct i2c_random_wr_payload stop_reg_array[] = {{0x301A, 0x918}}; struct i2c_random_wr_payload init_array_ar0231[] = { {0x301A, 0x0018}, // RESET_REGISTER // CLOCK Settings {0x302A, 0x0006}, // VT_PIX_CLK_DIV {0x302C, 0x0001}, // VT_SYS_CLK_DIV {0x302E, 0x0002}, // PRE_PLL_CLK_DIV {0x3030, 0x0032}, // PLL_MULTIPLIER {0x3036, 0x000A}, // OP_WORD_CLK_DIV {0x3038, 0x0001}, // OP_SYS_CLK_DIV // FORMAT {0x3040, 0xC000}, // READ_MODE {0x3004, 0x0000}, // X_ADDR_START_ (A) {0x308A, 0x0000}, // X_ADDR_START_ (B) {0x3008, 0x0787}, // X_ADDR_END_ (A) {0x308E, 0x0787}, // X_ADDR_END_ (B) {0x3002, 0x0000}, // Y_ADDR_START_ (A) {0x308C, 0x0000}, // Y_ADDR_START_ (B) {0x3006, 0x04B7}, // Y_ADDR_END_ (A) {0x3090, 0x04B7}, // Y_ADDR_END_ (B) {0x3032, 0x0000}, // SCALING_MODE {0x30A2, 0x0001}, // X_ODD_INC_ (A) {0x30AE, 0x0001}, // X_ODD_INC_ (B) {0x30A6, 0x0001}, // Y_ODD_INC_ (A) {0x30A8, 0x0001}, // Y_ODD_INC_ (B) {0x3402, 0x0F10}, // X_OUTPUT_CONTROL {0x3404, 0x0970}, // Y_OUTPUT_CONTROL {0x3064, 0x1802}, // SMIA_TEST {0x30BA, 0x11F2}, // DIGITAL_CTRL // SLAV* MODE {0x30CE, 0x0120}, {0x340A, 0xE6}, // E6 // 0000 1110 0110 {0x340C, 0x802}, // 2 // 0000 0000 0010 // Readout timing {0x300C, 0x07B9}, // LINE_LENGTH_PCK (A) {0x303E, 0x07B9}, // LINE_LENGTH_PCK (B) {0x300A, 0x07E7}, // FRAME_LENGTH_LINES (A) {0x30AA, 0x07E7}, // FRAME_LENGTH_LINES (B) {0x3042, 0x0000}, // EXTRA_DELAY // Readout Settings {0x31AE, 0x0204}, // SERIAL_FORMAT, 4-lane MIPI {0x31AC, 0x0C0A}, // DATA_FORMAT_BITS, 12 -> 10 {0x3342, 0x122B}, // MIPI_F1_PDT_EDT {0x3346, 0x122B}, // MIPI_F2_PDT_EDT {0x334A, 0x122B}, // MIPI_F3_PDT_EDT {0x334E, 0x122B}, // MIPI_F4_PDT_EDT {0x3344, 0x0011}, // MIPI_F1_VDT_VC {0x3348, 0x0111}, // MIPI_F2_VDT_VC {0x334C, 0x0211}, // MIPI_F3_VDT_VC {0x3350, 0x0311}, // MIPI_F4_VDT_VC {0x31B0, 0x0053}, // FRAME_PREAMBLE {0x31B2, 0x003B}, // LINE_PREAMBLE {0x301A, 0x001C}, // RESET_REGISTER // Noise Corrections {0x3092, 0x0C24}, // ROW_NOISE_CONTROL {0x337A, 0x0C80}, // DBLC_SCALE0 {0x3370, 0x03B1}, // DBLC {0x3044, 0x0400}, // DARK_CONTROL // Enable dead pixel correction using // the 1D line correction scheme {0x31E0, 0x0003}, // HDR Settings {0x3082, 0x0004}, // OPERATION_MODE_CTRL (A) {0x3084, 0x0004}, // OPERATION_MODE_CTRL (B) {0x3238, 0x0004}, // EXPOSURE_RATIO (A) {0x323A, 0x0004}, // EXPOSURE_RATIO (B) {0x3014, 0x098E}, // FINE_INTEGRATION_TIME_ (A) {0x3018, 0x098E}, // FINE_INTEGRATION_TIME_ (B) {0x321E, 0x098E}, // FINE_INTEGRATION_TIME2 (A) {0x3220, 0x098E}, // FINE_INTEGRATION_TIME2 (B) {0x31D0, 0x0000}, // COMPANDING, no good in 10 bit? {0x33DA, 0x0000}, // COMPANDING {0x318E, 0x0200}, // PRE_HDR_GAIN_EN // DLO Settings {0x3100, 0x4000}, // DLO_CONTROL0 {0x3280, 0x0CCC}, // T1 G1 {0x3282, 0x0CCC}, // T1 R {0x3284, 0x0CCC}, // T1 B {0x3286, 0x0CCC}, // T1 G2 {0x3288, 0x0FA0}, // T2 G1 {0x328A, 0x0FA0}, // T2 R {0x328C, 0x0FA0}, // T2 B {0x328E, 0x0FA0}, // T2 G2 // Initial Gains {0x3022, 0x0001}, // GROUPED_PARAMETER_HOLD_ {0x3366, 0xFF77}, // ANALOG_GAIN (1x) (A) {0x3368, 0xFF77}, // ANALOG_GAIN (1x) (B) {0x3060, 0x3333}, // ANALOG_COLOR_GAIN {0x3362, 0x0000}, // DC GAIN (A & B) {0x305A, 0x00F8}, // red gain (A) {0x3058, 0x0122}, // blue gain (A) {0x3056, 0x009A}, // g1 gain (A) {0x305C, 0x009A}, // g2 gain (A) {0x30C0, 0x00F8}, // red gain (B) {0x30BE, 0x0122}, // blue gain (B) {0x30BC, 0x009A}, // g1 gain (B) {0x30C2, 0x009A}, // g2 gain (B) {0x3022, 0x0000}, // GROUPED_PARAMETER_HOLD_ // Initial Integration Time {0x3012, 0x0005}, // (A) {0x3016, 0x0005}, // (B) }; ================================================ FILE: selfdrive/camerad/cameras/sensor_i2c.h ================================================ static struct msm_camera_i2c_reg_array init_array_imx298[] = { {0x101,0x0,0}, // IMAGE_ORIENT {0x601,0x0,0}, // test pattern //{0xb02,0,0}, // green correction? // external clock setting {0x136,0x18,0}, {0x137,0x0,0}, // EXCK_FREQ = Extclk_frequency_mhz // global setting? {0x30f4,0x1,0}, {0x30f5,0x7a,0}, {0x30f6,0x0,0}, {0x30f7,0xec,0}, {0x30fc,0x1,0}, {0x3101,0x1,0}, {0x5b2f,0x8,0}, {0x5d32,0x5,0}, {0x5d7c,0x0,0}, {0x5d7d,0x0,0}, {0x5db9,0x1,0}, {0x5e43,0x0,0}, {0x6300,0x0,0}, {0x6301,0xea,0}, {0x6302,0x0,0}, {0x6303,0xb4,0}, {0x6564,0x0,0}, {0x6565,0xb6,0}, {0x6566,0x0,0}, {0x6567,0xe6,0}, {0x6714,0x1,0}, {0x6758,0xb,0}, {0x6910,0x4,0}, {0x6916,0x1,0}, {0x6918,0x4,0}, {0x691e,0x1,0}, {0x6931,0x1,0}, {0x6937,0x2,0}, {0x693b,0x2,0}, {0x6d00,0x4a,0}, {0x6d01,0x41,0}, {0x6d02,0x23,0}, {0x6d05,0x4c,0}, {0x6d06,0x10,0}, {0x6d08,0x30,0}, {0x6d09,0x38,0}, {0x6d0a,0x2c,0}, {0x6d0b,0x2d,0}, {0x6d0c,0x34,0}, {0x6d0d,0x42,0}, {0x6d19,0x1c,0}, {0x6d1a,0x71,0}, {0x6d1b,0xc6,0}, {0x6d1c,0x94,0}, {0x6d24,0xe4,0}, {0x6d30,0xa,0}, {0x6d31,0x1,0}, {0x6d33,0xb,0}, {0x6d34,0x5,0}, {0x6d35,0x0,0}, {0x83c2,0x3,0}, {0x83c3,0x8,0}, {0x83c4,0x48,0}, {0x83c7,0x8,0}, {0x83cb,0x0,0}, {0xb101,0xff,0}, {0xb103,0xff,0}, {0xb105,0xff,0}, {0xb107,0xff,0}, {0xb109,0xff,0}, {0xb10b,0xff,0}, {0xb10d,0xff,0}, {0xb10f,0xff,0}, {0xb111,0xff,0}, {0xb163,0x3c,0}, {0xc2a0,0x8,0}, {0xc2a3,0x3,0}, {0xc2a5,0x8,0}, {0xc2a6,0x48,0}, {0xc2a9,0x0,0}, {0xf800,0x5e,0}, {0xf801,0x5e,0}, {0xf802,0xcd,0}, {0xf803,0x20,0}, {0xf804,0x55,0}, {0xf805,0xd4,0}, {0xf806,0x1f,0}, {0xf808,0xf8,0}, {0xf809,0x3a,0}, {0xf80a,0xf1,0}, {0xf80b,0x7e,0}, {0xf80c,0x55,0}, {0xf80d,0x38,0}, {0xf80e,0xe3,0}, {0xf810,0x74,0}, {0xf811,0x41,0}, {0xf812,0xbf,0}, {0xf844,0x40,0}, {0xf845,0xba,0}, {0xf846,0x70,0}, {0xf847,0x47,0}, {0xf848,0xc0,0}, {0xf849,0xba,0}, {0xf84a,0x70,0}, {0xf84b,0x47,0}, {0xf84c,0x82,0}, {0xf84d,0xf6,0}, {0xf84e,0x32,0}, {0xf84f,0xfd,0}, {0xf851,0xf0,0}, {0xf852,0x2,0}, {0xf853,0xf8,0}, {0xf854,0x81,0}, {0xf855,0xf6,0}, {0xf856,0xc0,0}, {0xf857,0xff,0}, {0xf858,0x10,0}, {0xf859,0xb5,0}, {0xf85a,0xd,0}, {0xf85b,0x48,0}, {0xf85c,0x40,0}, {0xf85d,0x7a,0}, {0xf85e,0x1,0}, {0xf85f,0x28,0}, {0xf860,0x15,0}, {0xf861,0xd1,0}, {0xf862,0xc,0}, {0xf863,0x49,0}, {0xf864,0xc,0}, {0xf865,0x46,0}, {0xf866,0x40,0}, {0xf867,0x3c,0}, {0xf868,0x48,0}, {0xf869,0x8a,0}, {0xf86a,0x62,0}, {0xf86b,0x8a,0}, {0xf86c,0x80,0}, {0xf86d,0x1a,0}, {0xf86e,0x8a,0}, {0xf86f,0x89,0}, {0xf871,0xb2,0}, {0xf872,0x10,0}, {0xf873,0x18,0}, {0xf874,0xa,0}, {0xf875,0x46,0}, {0xf876,0x20,0}, {0xf877,0x32,0}, {0xf878,0x12,0}, {0xf879,0x88,0}, {0xf87a,0x90,0}, {0xf87b,0x42,0}, {0xf87d,0xda,0}, {0xf87e,0x10,0}, {0xf87f,0x46,0}, {0xf880,0x80,0}, {0xf881,0xb2,0}, {0xf882,0x88,0}, {0xf883,0x81,0}, {0xf884,0x84,0}, {0xf885,0xf6,0}, {0xf886,0xd2,0}, {0xf887,0xf9,0}, {0xf888,0xe0,0}, {0xf889,0x67,0}, {0xf88a,0x85,0}, {0xf88b,0xf6,0}, {0xf88c,0xa1,0}, {0xf88d,0xfc,0}, {0xf88e,0x10,0}, {0xf88f,0xbd,0}, {0xf891,0x18,0}, {0xf892,0x21,0}, {0xf893,0x24,0}, {0xf895,0x18,0}, {0xf896,0x19,0}, {0xf897,0xb4,0}, {0x4e29,0x1,0}, // PDAF stuff {0x3166,0x1,0}, //AREA_EN_0 {0x3167,0x1,0}, {0x3168,0x1,0}, {0x3169,0x1,0}, {0x316a,0x1,0}, {0x316b,0x1,0}, {0x316c,0x1,0}, {0x316d,0x1,0}, {0x3158,0x2,0}, {0x3159,0x2,0}, {0x315a,0x2,0}, {0x315b,0x3,0}, {0x3013,0x7,0}, //RMSC_NR_MODE {0x3035,0x1,0}, {0x3051,0x0,0}, {0x3056,0x2,0}, {0x3057,0x1,0}, {0x3060,0x0,0}, {0x8435,0x0,0}, {0x8455,0x0,0}, {0x847c,0x0,0}, {0x84fb,0x1,0}, {0x9619,0xa0,0}, {0x961b,0xa0,0}, {0x961d,0xa0,0}, {0x961f,0x20,0}, {0x9621,0x20,0}, {0x9623,0x20,0}, {0x9625,0xa0,0}, {0x9627,0xa0,0}, {0x9629,0xa0,0}, {0x962b,0x20,0}, {0x962d,0x20,0}, {0x962f,0x20,0}, {0x9901,0x35,0}, {0x9903,0x23,0}, {0x9905,0x23,0}, {0x9906,0x0,0}, {0x9907,0x31,0}, {0x9908,0x0,0}, {0x9909,0x1b,0}, {0x990a,0x0,0}, {0x990b,0x15,0}, {0x990d,0x3f,0}, {0x990f,0x3f,0}, {0x9911,0x3f,0}, {0x9913,0x64,0}, {0x9915,0x64,0}, {0x9917,0x64,0}, {0x9919,0x50,0}, {0x991b,0x60,0}, {0x991d,0x65,0}, {0x991f,0x1,0}, {0x9921,0x1,0}, {0x9923,0x1,0}, {0x9925,0x23,0}, {0x9927,0x23,0}, {0x9929,0x23,0}, {0x992b,0x2f,0}, {0x992d,0x1a,0}, {0x992f,0x14,0}, {0x9931,0x3f,0}, {0x9933,0x3f,0}, {0x9935,0x3f,0}, {0x9937,0x6b,0}, {0x9939,0x7c,0}, {0x993b,0x81,0}, {0x9943,0xf,0}, {0x9945,0xf,0}, {0x9947,0xf,0}, {0x9949,0xf,0}, {0x994b,0xf,0}, {0x994d,0xf,0}, {0x994f,0x42,0}, {0x9951,0xf,0}, {0x9953,0xb,0}, {0x9955,0x5a,0}, {0x9957,0x13,0}, {0x9959,0xc,0}, {0x995a,0x0,0}, {0x995b,0x0,0}, {0x995c,0x0,0}, {0x996b,0x0,0}, {0x996d,0x10,0}, {0x996f,0x10,0}, {0x9971,0xc8,0}, {0x9973,0x32,0}, {0x9975,0x4,0}, {0x9976,0xa,0}, {0x9977,0xa,0}, {0x9978,0xa,0}, {0x99a4,0x2f,0}, {0x99a5,0x2f,0}, {0x99a6,0x2f,0}, {0x99a7,0xa,0}, {0x99a8,0xa,0}, {0x99a9,0xa,0}, {0x99aa,0x2f,0}, {0x99ab,0x2f,0}, {0x99ac,0x2f,0}, {0x99ad,0x0,0}, {0x99ae,0x0,0}, {0x99af,0x0,0}, {0x99b0,0x40,0}, {0x99b1,0x40,0}, {0x99b2,0x40,0}, {0x99b3,0x30,0}, {0x99b4,0x30,0}, {0x99b5,0x30,0}, {0x99bb,0xa,0}, {0x99bd,0xa,0}, {0x99bf,0xa,0}, {0x99c0,0x9,0}, {0x99c1,0x9,0}, {0x99c2,0x9,0}, {0x99c6,0x3c,0}, {0x99c7,0x3c,0}, {0x99c8,0x3c,0}, {0x99c9,0xff,0}, {0x99ca,0xff,0}, {0x99cb,0xff,0}, {0x9b01,0x35,0}, {0x9b03,0x14,0}, {0x9b05,0x14,0}, {0x9b07,0x31,0}, {0x9b09,0x1b,0}, {0x9b0b,0x15,0}, {0x9b0d,0x1e,0}, {0x9b0f,0x1e,0}, {0x9b11,0x1e,0}, {0x9b13,0x64,0}, {0x9b15,0x64,0}, {0x9b17,0x64,0}, {0x9b19,0x50,0}, {0x9b1b,0x60,0}, {0x9b1d,0x65,0}, {0x9b1f,0x1,0}, {0x9b21,0x1,0}, {0x9b23,0x1,0}, {0x9b25,0x14,0}, {0x9b27,0x14,0}, {0x9b29,0x14,0}, {0x9b2b,0x2f,0}, {0x9b2d,0x1a,0}, {0x9b2f,0x14,0}, {0x9b31,0x1e,0}, {0x9b33,0x1e,0}, {0x9b35,0x1e,0}, {0x9b37,0x6b,0}, {0x9b39,0x7c,0}, {0x9b3b,0x81,0}, {0x9b43,0xf,0}, {0x9b45,0xf,0}, {0x9b47,0xf,0}, {0x9b49,0xf,0}, {0x9b4b,0xf,0}, {0x9b4d,0xf,0}, {0x9b4f,0x2d,0}, {0x9b51,0xb,0}, {0x9b53,0x8,0}, {0x9b55,0x40,0}, {0x9b57,0xd,0}, {0x9b59,0x8,0}, {0x9b5a,0x0,0}, {0x9b5b,0x0,0}, {0x9b5c,0x0,0}, {0x9b6b,0x0,0}, {0x9b6d,0x10,0}, {0x9b6f,0x10,0}, {0x9b71,0xc8,0}, {0x9b73,0x32,0}, {0x9b75,0x4,0}, {0x9bb0,0x40,0}, {0x9bb1,0x40,0}, {0x9bb2,0x40,0}, {0x9bb3,0x30,0}, {0x9bb4,0x30,0}, {0x9bb5,0x30,0}, {0x9bbb,0xa,0}, {0x9bbd,0xa,0}, {0x9bbf,0xa,0}, {0x9bc0,0x9,0}, {0x9bc1,0x9,0}, {0x9bc2,0x9,0}, {0x9bc6,0x18,0}, {0x9bc7,0x18,0}, {0x9bc8,0x18,0}, {0x9bc9,0xff,0}, {0x9bca,0xff,0}, {0x9bcb,0xff,0}, {0xb2b2,0x1,0}, }; static struct msm_camera_i2c_reg_array mode_setting_array_imx298[] = { // i2c settings for mode 3 // { // .x_output = 2328, // .y_output = 1748, // .line_length_pclk = 5536, // .frame_length_lines = 1802, // .vt_pixel_clk = 299300000, // .op_pixel_clk = 299300000, // .binning_factor = 2, // .min_fps = 15.000000, // .max_fps = 30.020000, // .mode = 1, // .offset_x = 0, // .offset_y = 0, // .scale_factor = 1.000000, // .is_pdaf_supported = 1, // } // mode settings // hdr settings {0x0114, 0x03, 0}, // CSI_LANE_MODE = 4-lane /*{0x0220, 0x00, 0}, // HDR_MODE = disable {0x0221, 0x11, 0}, // HDR_RESO_REDU_H/V = Full Pixel {0x0222, 0x10, 0}, // EXPO_RATIO = 16*/ {0x0220, 0x01, 0}, // HDR_MODE = enable with combined gain and 16x ratio {0x0221, 0x22, 0}, // HDR_RESO_REDU_H/V = 2 binning {0x0222, 0x10, 0}, // EXPO_RATIO = 16 {0x0340, 0x07, 0}, {0x0341, 0x0a, 0}, // FRM_LENGTH = frame_length_lines = 1802 {0x0342, 0x15, 0}, {0x0343, 0xa0, 0}, // LINE_LENGTH = line_length_pclk = 5536 {0x0344, 0x00, 0}, {0x0345, 0x00, 0}, // x_addr_start {0x0346, 0x00, 0}, {0x0347, 0x00, 0}, // y_addr_start {0x0348, 0x12, 0}, {0x0349, 0x2f, 0}, // x_addr_end {0x034a, 0x0d, 0}, {0x034b, 0xa7, 0}, // y_addr_end {0x0381, 0x01, 0}, // x_even_inc {0x0383, 0x01, 0}, // x_odd_inc {0x0385, 0x01, 0}, // y_even_inc {0x0387, 0x01, 0}, // y_odd_inc {0x0900, 0x01, 0}, // BINNING_MODE = enable {0x0901, 0x22, 0}, // BINING_TYPE_H/V = 2binning {0x0902, 0x00, 0}, // binning_weighting = average {0x0b06, 1, 0}, // SING_DEF_CORR_EN {0x0b0a, 1, 0}, // combined defect correct {0x3010, 0x66, 0}, // HDR_OUTPUT_CTRL = ATR + HDR compose + DPC1D + DCP2D {0x3011, 0x01, 0}, // HDR_OUTPUT_CTRL2 = PD enable {0x30c0, 0x11, 0}, // RED_GAIN_CB? {0x300d, 0x00, 0}, // FORCE_FDSUM = disable {0x30fd, 0x00, 0}, {0x8493, 0x00, 0}, {0x8863, 0x00, 0}, {0x90d7, 0x19, 0}, // set black level {0x3090, 1, 0}, {0x3092, 0, 0}, {0x3093, 0x38, 0}, // output size settings {0x0112, 0x0a, 0}, {0x0113, 0x0a, 0}, // CS_DT_FMT_H = 0x0a0a (RAW10 output) {0x034c, 0x09, 0}, {0x034d, 0x18, 0}, // X_OUT_SIZE = 2328 (1164*2) {0x034e, 0x06, 0}, {0x034f, 0xd4, 0}, // Y_OUT_SIZE = 1748 (874*2) {0x0401, 0x00, 0}, // SCALING_MODE {0x0404, 0x00, 0}, {0x0405, 0x10, 0}, // SCALE_M {0x0408, 0x00, 0}, {0x0409, 0x00, 0}, // DCROP_XOFS {0x040a, 0x00, 0}, {0x040b, 0x00, 0}, // DCROP_YOFS {0x040c, 0x09, 0}, {0x040d, 0x18, 0}, // DCROP_WIDTH {0x040e, 0x06, 0}, {0x040f, 0xd4, 0}, // DCROP_HIGT // clock settings // 299300000 /* {0x0301, 0x05, 0}, // VT_PIX_CLK_DIV {0x0303, 0x02, 0}, // VT_SYS_CLK_DIV {0x0305, 0x04, 0}, // PRE_PLL_CLK_DIV {0x0306, 0x00, 0}, {0x0307, 0x7d, 0}, // PLL_MULTIPLIER . mode 1: 0xf6 {0x0309, 0x0a, 0}, // OP_PIX_CLK_DIV {0x030b, 0x01, 0}, // OP_SYS_CLK_DIV {0x030d, 0x0f, 0}, // PREPLLCK_OP_DIV {0x030e, 0x03, 0}, {0x030f, 0x41, 0}, // PLL_OP_MPY {0x0310, 0x00, 0}, // PLL_MULT_DRIV */ // 600000000 {0x0301, 0x05, 0}, {0x0303, 0x02, 0}, {0x0305, 0x04, 0}, {0x0306, 0x00, 0}, {0x0307, 0xfa, 0}, {0x0309, 0x0a, 0}, {0x030b, 0x01, 0}, {0x030d, 0x0f, 0}, {0x030e, 0x03, 0}, {0x030f, 0x41, 0}, {0x0310, 0x00, 0}, // data rate settings /*{0x0820, 0x0b, 0}, // requested_link_bit_rate_mbps = 3000 {0x0821, 0xb8, 0}, {0x0822, 0x00, 0}, {0x0823, 0x00, 0},*/ {0x0820, 0x17, 0}, // requested_link_bit_rate_mbps = 6000 {0x0821, 0x70, 0}, {0x0822, 0x00, 0}, {0x0823, 0x00, 0}, //integration time settings {0x0202, 0x07, 0}, {0x0203, 0x00, 0}, // INTEG_TIME = 1792 {0x0224, 0x01, 0}, {0x0225, 0xf4, 0}, // ST_COARSE_INTEG_TIME = 506 // gain settings {0x0204, 0x00, 0}, {0x0205, 0x00, 0}, // ANA_GAIN_GLOBAL = 512 / (512 - X) {0x0216, 0x00, 0}, {0x0217, 0x00, 0}, // ST_ANA_GAIN_GLOBAL[8] {0x020e, 0x01, 0}, {0x020f, 0x00, 0}, // DIG_GAIN_GR {0x0210, 0x01, 0}, {0x0211, 0x00, 0}, // DIG_GAIN_R {0x0212, 0x01, 0}, {0x0213, 0x00, 0}, // DIG_GAIN_B {0x0214, 0x01, 0}, {0x0215, 0x00, 0}, // DIG_GAIN_GB // HDR white balance settings (ABS_GAIN) {0xb8e, 0x01, 0}, {0xb8f, 0x00, 0}, // GR {0xb90, 0x02, 0}, {0xb91, 0x2b, 0}, // R {0xb92, 0x01, 0}, {0xb93, 0xd4, 0}, // B {0xb94, 0x01, 0}, {0xb95, 0x00, 0}, // GB // phase detection settings {0x3058, 0x00, 0}, // NML_NR_EN {0x3103, 0x01, 0}, // NML_PD_CAL_ENABLE = enable {0x3108, 0x00, 0}, {0x3109, 0x2c, 0}, //PD_AREA_X_OFFSET {0x310a, 0x00, 0}, {0x310b, 0x24, 0}, //PD_AREA_Y_OFFSET {0x310c, 0x01, 0}, {0x310d, 0xa4, 0}, //PD_AREA_WIDTH {0x310e, 0x01, 0}, {0x310f, 0xa4, 0}, //PD_AREA_HEIGHT // whole size is 0x918 x 0x6d4 {0x3110, 0x03, 0}, // PD_AREA_0 = 0x375-0x4d1, 0x258-0x3b6 {0x3111, 0x75, 0}, {0x3112, 0x02, 0}, {0x3113, 0x58, 0}, {0x3114, 0x04, 0}, {0x3115, 0xd1, 0}, {0x3116, 0x03, 0}, {0x3117, 0xb6, 0}, {0x3118, 0x04, 0}, // PD_AREA_1 = 0x446-0x5a2, 0x258-0x3b6 {0x3119, 0x46, 0}, {0x311a, 0x02, 0}, {0x311b, 0x58, 0}, {0x311c, 0x05, 0}, {0x311d, 0xa2, 0}, {0x311e, 0x03, 0}, {0x311f, 0xb6, 0}, {0x3120, 0x03, 0}, // PD_AREA_2 = 0x375-0x4d1, 0x32a-0x488 {0x3121, 0x75, 0}, {0x3122, 0x03, 0}, {0x3123, 0x2a, 0}, {0x3124, 0x04, 0}, {0x3125, 0xd1, 0}, {0x3126, 0x04, 0}, {0x3127, 0x88, 0}, {0x3128, 0x04, 0}, // PD_AREA_3 = 0x446-0x5a2, 0x32a-0x488 {0x3129, 0x46, 0}, {0x312a, 0x03, 0}, {0x312b, 0x2a, 0}, {0x312c, 0x05, 0}, {0x312d, 0xa2, 0}, {0x312e, 0x04, 0}, {0x312f, 0x88, 0}, {0x3130, 0x03, 0}, // PD_AREA_4 = 0x375-0x5a2, 0x258-0x488 {0x3131, 0x75, 0}, {0x3132, 0x02, 0}, {0x3133, 0x58, 0}, {0x3134, 0x05, 0}, {0x3135, 0xa2, 0}, {0x3136, 0x04, 0}, {0x3137, 0x88, 0}, {0x3138, 0x02, 0}, // PD_AREA_5 = 0x2ba-0x65d, 0x210-0x4d0 {0x3139, 0xba, 0}, {0x313a, 0x02, 0}, {0x313b, 0x10, 0}, {0x313c, 0x06, 0}, {0x313d, 0x5d, 0}, {0x313e, 0x04, 0}, {0x313f, 0xd0, 0}, {0x3140, 0x00, 0}, // PD_AREA_6 = 0xa1-0x876, 0x6b-0x676 {0x3141, 0xa1, 0}, {0x3142, 0x00, 0}, {0x3143, 0x6b, 0}, {0x3144, 0x08, 0}, {0x3145, 0x76, 0}, {0x3146, 0x06, 0}, {0x3147, 0x76, 0}, {0x3148, 0x00, 0}, // PD_AREA_7 = 0xa1-0x876, 0x5e-0x34c {0x3149, 0xa1, 0}, {0x314a, 0x00, 0}, {0x314b, 0x5e, 0}, {0x314c, 0x08, 0}, {0x314d, 0x76, 0}, {0x314e, 0x03, 0}, {0x314f, 0x4c, 0}, {0x3165, 0x02, 0}, // AREA_EN_0 = free area }; // static struct msm_camera_i2c_reg_array reg_array3[] = { // // REG_HOLD ON // {0x104,0x1,0}, // // from regression // {0x3002,0x0,0}, // // FRM_LENGTH, 1802 vs 3554 // // {0x340,0x7,0}, {0x341,0xa,0}, // camera start {0x340,0xd,0}, {0x341,0xe2,0}, // // INTEG_TIME aka coarse_int_time_addr aka shutter speed // {0x202,0x03,0}, {0x203,0xda,0}, // // global_gain_addr // {0x204,0x0,0}, {0x205,0x0,0}, // //?? // {0x20e,0x1,0}, {0x20f,0x0,0}, // {0x210,0x1,0}, {0x211,0x0,0}, // {0x212,0x1,0}, {0x213,0x0,0}, // {0x214,0x1,0}, {0x215,0x0,0}, // // REG_HOLD: mode setting // {0x104,0x0,0}, // }; // start, remove standby mode static struct msm_camera_i2c_reg_array start_reg_array[] = {{0x100,0x1,0}}; // stop, enable standby mode static struct msm_camera_i2c_reg_array stop_reg_array[] = {{0x100,0x0,0}}; /////////////////// static struct msm_camera_i2c_reg_array init_array_imx179[] = { { 0x100, 0x0, 0}, // MODE_SELECT { 0x101, 0x0, 0}, // IMAGE_ORIENT { 0x202, 0x9, 0}, { 0x203, 0xd2, 0}, // COARSE_INTEGRATION_TIME { 0x301, 0x5, 0}, // vt_pix_clk_div { 0x303, 0x1, 0}, // vt_sys_clk_div { 0x305, 0x6, 0}, // pre_pll_clk_div { 0x309, 0x5, 0}, // op_pix_clk_div { 0x30b, 0x1, 0}, // op_sys_clk_div { 0x30c, 0x0, 0}, { 0x30d, 0x9d, 0}, { 0x340, 0x9, 0}, { 0x341, 0xd6, 0}, // frame_length_lines { 0x342, 0xd, 0}, { 0x343, 0x70, 0}, // line_length_pclk { 0x344, 0x0, 0}, { 0x345, 0x0, 0}, // x_addr_start { 0x346, 0x0, 0}, { 0x347, 0x0, 0}, // y_addr_start { 0x348, 0xc, 0}, { 0x349, 0xcf, 0}, // last_pixel / x_addr_end { 0x34a, 0x9, 0}, { 0x34b, 0x9f, 0}, // last_line / y_addr_end { 0x34c, 0xc, 0}, { 0x34d, 0xd0, 0}, // pixels_per_line / x_output_size { 0x34e, 0x9, 0}, { 0x34f, 0xa0, 0}, // lines_per_frame / y_output_size { 0x383, 0x1, 0}, // x_odd_inc { 0x387, 0x1, 0}, // y_odd_inc { 0x390, 0x0, 0}, // binning_mode { 0x401, 0x0, 0}, // SCALING_MODE { 0x405, 0x10, 0}, // SCALE_M {0x3020, 0x10, 0}, {0x3041, 0x15, 0}, // READ_MODE? {0x3042, 0x87, 0}, {0x3089, 0x4f, 0}, {0x3309, 0x9a, 0}, {0x3344, 0x57, 0}, {0x3345, 0x1f, 0}, {0x3362, 0xa, 0}, {0x3363, 0xa, 0}, {0x3364, 0x0, 0}, {0x3368, 0x18, 0}, {0x3369, 0x0, 0}, {0x3370, 0x6f, 0}, {0x3371, 0x27, 0}, {0x3372, 0x4f, 0}, {0x3373, 0x2f, 0}, {0x3374, 0x27, 0}, {0x3375, 0x2f, 0}, {0x3376, 0x97, 0}, {0x3377, 0x37, 0}, {0x33c8, 0x0, 0}, {0x33d4, 0xc, 0}, {0x33d5, 0xd0, 0}, {0x33d6, 0x9, 0}, {0x33d7, 0xa0, 0}, // znr {0x4100, 0xe, 0}, {0x4108, 0x1, 0}, {0x4109, 0x7c, 0}, }; /////////////// ois stuff /////////////// /* #define _OP_FIRM_DWNLD 0x80 #define _OP_Periphe_RW 0x82 #define _OP_Memory__RW 0x84 #define _OP_AD_TRNSFER 0x86 #define _OP_COEF_DWNLD 0x88 #define _OP_PrgMem__RD 0x8A #define _OP_SpecialCMD 0x8C */ static struct reg_settings_ois_t ois_init_settings[] = { { .reg_addr = 0x8262, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0xbf03, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8263, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x9f05, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8264, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x6040, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8260, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x1130, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8265, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x8000, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8261, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0280, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8261, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0380, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8261, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0988, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x34\x84\x00\x03\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x03\x00\x10\x7e\x84\x50\x00\x08\x40\x7e\xa0\x00\x03\x00\x10\x7e\x84\x60\x00\x08\x40\x7e\xa0\x00\x03\x00\x90\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x10\x08\x80\x00\xa0\x10\x00\x08\x7f\xff\x11\x8f\x02\x07\x80\x00\x11\x40\xff\xa0\x90\x01\x84\x20\x8f\x08\x40\xfe\x90\x40\xf5", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x08\x80\x01\xa0\x00\x01\x11\x8f\x02\x07\xff\xff\x11\x08\x00\x20\x50\x12\x07\x00\x10\x08\x80\x00\xa0\x10\xff\x84\x20\x0a", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x7f\xff\x21\x08\xfe\x84\x00\x04\x07\x20\x0c\x08\x7f\xff\x21\x08\xfe\x84\x00\x03\x00\x90\x17\x84\x20\x1f\x08\x80\x17\xa0\x10\x10", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x7f\xff\x21\x10\x00\x08\x01\x00\x11\x40\x51\xa0\x90\x17\x84\x20\x0f\x08\x80\x47\xa0\x8d\x0c\x07\x00\x00\x11\x30\x03\x07\x80\x41", .reg_data_seq_size = 32, },{ .reg_addr = 0x8090, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x50\x00\x08\x40\xfc\x90\x88\x2f\x84\x00\x00\x11\x30\x02\x07\x40\xff\x90\x50\x00\x08\x40\xfd\x90\x40\x7f\xa0\x10\xff\x84\x20\x2c", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x7f\xff\x11\x20\x0d\x08\x80\x0f\x90\x80\x26\xa0\x90\x2e\x84\x00\x10\x08\x90\x26\x84\x00\x10\x08\x80\x1f\xa0\x20\x2e\x08\x40\xed", .reg_data_seq_size = 32, },{ .reg_addr = 0x8090, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x20\x0f\x08\x80\x0e\x90\x00\x00\x21\x30\x02\x07\x40\xeb\xa0\x50\x00\x08\x40\xfe\x90\x40\x7f\xa0\x04\xeb\x84\x10\x00\x20\x20\x0f", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x80\x00\x21\x60\x04\x07\x40\xff\xa0\x10\x00\x08\x40\xea\x90\x10\x00\x20\x20\x0f\x08\x80\x00\x11\x00\x0b\x07\x08\x00\x20\x60\x0d", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x00\x08\x40\xea\x90\x8f\x06\x07\x04\xff\x84\x20\x09\x60\x10\xfc\x84\x08\xfd\x84\x04\xfe\x84\x00\x03\x00\x00\x10\x08\x80\x37", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x90\x69\x84\x00\x10\x08\x80\x69\xa0\x20\x1a\x08\x40\x64\xa0\x10\x10\x08\x80\x4f\xa0\x20\x1d\x08\x40\x5f\xa0\x20\x1e\x08\x40\x5d", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x00\x08\x80\x68\x90\x40\xfe\xa0\x20\x0e\x07\x50\x00\x08\x40\x7f\xa0\x04\xfe\x84\x00\x04\x00\x10\xf0\x44\x50\x00\x08\x00\x7f", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x20\xf0\x60\x04\x5c\x84\x04\x61\x84\x04\x57\x84\x00\x00\x21\x04\x74\x84\x00\x40\x21\x00\x0b\x07\x04\x74\x84\x00\x00\x21\x10\x57", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x30\x20\x08\x00\x04\x11\x50\x00\x08\x03\xff\x11\x20\xfa\x60\x10\xf0\x44\x50\x20\x08\x00\x7f\x11\x60\x20\x08\x40\x00\x08\x00\x08", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x30\x1a\x07\x50\x00\x08\x07\x00\x11\x9f\x1d\x07\x8b\x1e\x07\x9c\x15\x07\x20\xf8\x60\x10\x28\x44\x60\x00\x08\x01\x00\x11\x20\x28", .reg_data_seq_size = 32, },{ .reg_addr = 0x8060, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x87\x1b\x07\x40\xf7\xa0\x81\x27\x07\x20\x48\x60\x10\x0a\x44\x10\xf4\x84\x3b\xd4\x00\xe0\x14\x43\x08\x00\x20\x00\x06\x07\x89\x02", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\xae\x90\x81\x04\x07\x40\x2e\x90\x40\x7f\xa0\x10\x2e\x44\x20\x2f\x08\x9f\x02\x07\x00\x00\x11\x10\x00\x20\x00\x00\x08\x40\x67", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x11\x84\x02\x07\x20\xf0\x60\x9f\x03\x07\x40\x7e\xa0\x40\x65\x90\x10\x62\x84\x10\x10\x08\x40\x61\xa0\x20\x1d\x08\x40\x5f", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x20\x1e\x08\x40\x5d\xa0\x10\x00\x08\x40\x5e\x90\x20\x30\x60\x10\xcf\x84\x20\x1c\x08\x7f\xff\x21\x3b\xf7\x00\xc8\x14\x43\x10\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8020, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x08\x40\xb5\x90\x40\xad\xa0\x00\x0a\x07\x10\x4f\x84\x20\x1c\x08\x7f\xff\x21\x3c\x01\x00\x48\x14\x43\x10\x00\x20\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x35\x90\x40\x2d\xa0\x00\x14\x07\x80\x0c\x07\x82\x03\x07\x04\x50\x84\x10\x00\x20\x20\x02\x07\x00\x08\x21\x40\x00\x08\x00\x01", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x50\xa0\x00\x04\x00\x20\x7f\x00\x80\x14\x43\x01\x00\x01\x04\x00\x11\x02\x00\x21\x10\x9f\x84\x10\x20\x08\x40\x97\x90\x10\xbf", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x20\x1d\x08\x40\xc6\xa0\x20\x8e\x08\x40\x72\x90\x40\x16\xa0\x10\x96\x84\x10\x00\x08\x40\x9e\x90\x20\x36\x60\x20\x91\x00\x00\x14", .reg_data_seq_size = 32, },{ .reg_addr = 0x8043, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x01\x01\x00\x04\x11\x00\x02\x21\x10\x1f\x84\x10\x20\x08\x40\x17\x90\x10\x3f\x84\x20\x1d\x08\x40\x46\xa0\x20\x8e\x08\x40\x70", .reg_data_seq_size = 32, },{ .reg_addr = 0x8090, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x96\xa0\x10\x16\x84\x10\x00\x08\x40\x1e\x90\x20\x34\x60\x10\x65\x84\x50\x10\x08\x00\x00\x21\x84\x03\x07\x20\xf0\x60\x9f\x03", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x7e\xa0\x00\x10\x08\x40\x65\xa0\x20\x0d\x08\x40\x64\x90\x40\x62\xa0\x00\x04\x00\x04\x1c\x44\x04\x1b\x44\xc3\xff\x21\x87\x04", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x7f\xa0\x10\x42\x84\x20\x1e\x08\x7f\xff\x21\x10\x20\x08\x40\x1c\x90\x10\x07\x84\x10\x00\x08\x40\x06\x90\x40\x55\xa0\x10\xc2", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x20\x1e\x08\x7f\xff\x21\x10\x20\x08\x40\x9c\x90\x10\x87\x84\x10\x00\x08\x40\x86\x90\x40\x56\xa0\x10\x56\x84\x20\x0f\x08\x40\x7b", .reg_data_seq_size = 32, },{ .reg_addr = 0x8090, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x22\x00\x60\x40\x00\x08\x40\x79\xa0\x00\x08\x11\x10\x55\x84\x20\x0f\x08\x40\x7a\x90\x22\x00\x60\x50\x00\x08\x40\x79\xa0\x00\xff", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x04\x6f\x84\x00\x05\x21\x21\x39\x00\x04\x00\x11\x10\xc1\x84\x20\x0f\x08\x70\x07\x07\x10\x10\x08\x40\xc0\xa0\x20\x0f\x08\x7f\xff", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x8f\x02\x07\x80\x00\x11\x08\x00\x20\x08\xc1\x84\x40\xbd\x90\x9e\x02\x07\x40\x7f\xa0\x40\xec\x90\x04\x6e\x84\x00\x05\x21\x21\x4c", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x04\x11\x10\x41\x84\x20\x0f\x08\x70\x07\x07\x10\x10\x08\x40\x40\xa0\x20\x0f\x08\x7f\xff\x11\x8f\x02\x07\x80\x00\x11\x08\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8020, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x08\x41\x84\x40\x3d\x90\x9e\x02\x07\x40\x7f\xa0\x40\x6d\x90\x10\x2d\x44\x20\xe7\x00\x08\x00\x11\x20\x32\x60\x80\x14\x43\x10\x2c", .reg_data_seq_size = 32, },{ .reg_addr = 0x8044, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x20\xec\x00\x00\x08\x11\x20\x31\x60\x00\x14\x43\x04\x34\x44\x40\x5b\xa0\x00\x04\x00\x21\x6a\x00\x80\x00\x11\x21\x70\x00\x3f\xff", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x08\xe8\x84\x20\x32\x50\x08\x68\x84\x20\x31\x50\x08\x5e\x84\x20\x30\x50\x0f\xc4\x07\x10\x34\x44\x10\x5b\x84\x6f\xf3\x07\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x02\x00\x21\x40\xfc\x90\x3d\xd4\x00\x04\xfc\x84\x00\x00\x21\x04\xfd\x84\x00\x08\x21\x00\x04\x00\x21\x81\x00\xc0\x00\x11\x04\x5b", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x02\x00\x21\x70\x06\x07\x10\xfe\x84\x30\x20\x08\x00\x03\x11\x10\x00\x08\x40\x59\x90\x04\xff\x84\x40\x58\xa0\x10\x59\x84\x20\x0f", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x59\xa0\x20\x00\x11\x70\x1e\x07\x10\x00\x08\x00\x0b\x11\x0f\xe4\x07\x10\x59\x84\x00\x00\x08\x20\x30\x50\x40\x59\xa0\x70\x06", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x00\x08\x00\x0a\x11\x0f\xec\x07\x08\x34\x44\x02\x10\x11\x10\x58\x84\x20\x0f\x08\x40\x58\xa0\x20\x00\x11\x30\x08\x07\x0f\xf4", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x58\x84\x00\x00\x08\x20\x30\x50\x40\x58\xa0\x70\x06\x07\x10\x00\x08\x00\x05\x11\x00\x04\x00\x10\x5a\x84\x00\x00\x08\x00\x01", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x5a\xa0\x08\x34\x44\x02\x00\x11\x30\x08\x07\x60\x00\x08\x00\x00\x11\x40\x5a\xa0\x8f\x4f\x07\x40\x7e\xa0\x00\x04\x00\x3c\xdd", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x00\x20\xa8\x14\x43\x04\xa7\x84\x20\x8e\x08\x40\xc4\x90\x40\xaf\xa0\x20\x0f\x08\x40\xc5\x90\x40\xa7\xa0\x3c\xe7\x00\x10\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8020, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x28\x14\x43\x04\x27\x84\x20\x8e\x08\x40\x44\x90\x40\x2f\xa0\x20\x0f\x08\x40\x45\x90\x40\x27\xa0\x00\x04\x00\x10\xf0\x44\x50\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\xff\xf7\x11\x93\x04\x07\x20\xf0\x60\x04\x61\x84\x04\x5c\x84\x40\x57\xa0\x00\x04\x00\x10\x61\x84\x00\x20\x08\x20\x1f\x08\x40\xff", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x00\x08\x40\x5c\x90\x40\x57\xa0\x04\x74\x84\x10\x00\x20\x00\x00\x08\x40\x74\xa0\x00\x01\x11\x20\x05\x07\x00\x40\x21\x70\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x7f\xff\x21\x08\xff\x84\x42\x00\x90\x85\x02\x07\x20\xf0\x60\x7f\xff\x11\x60\x20\x08\x00\xd0\x11\x40\x00\x08\x00\x02\x11\x86\x1b", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x74\xa0\x08\x6f\x84\x00\x00\x11\x04\xf1\x84\x00\x40\x21\x21\xf7\x00\x02\x00\x11\x60\x07\x07\x10\x20\x08\x40\xc3\x90\x20\x2f", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x80\x00\x11\x70\x02\x07\x7f\xff\x11\x10\x00\x08\x40\x8d\x90\x40\x85\xa0\x08\x6e\x84\x00\x00\x11\x04\xf0\x84\x00\x40\x21\x22\x07", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x02\x11\x60\x07\x07\x10\x20\x08\x40\x43\x90\x20\x2f\x08\x80\x00\x11\x70\x02\x07\x7f\xff\x11\x10\x00\x08\x40\x0d\x90\x40\x05", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\xec\x84\x00\x10\x08\x10\xe7\x84\x40\xe7\xa0\x20\x0f\x08\x40\xef\xa0\x10\x6d\x84\x00\x10\x08\x10\x6c\x84\x40\x6c\xa0\x20\x0f", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x7d\xa0\x7f\xff\x11\x00\x04\x00\x10\xef\x84\x00\x10\x08\x10\xee\x84\x40\xee\xa0\x20\x0f\x08\x40\xbd\xa0\x10\x7d\x84\x00\x10", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x7c\x84\x40\x7c\xa0\x20\x0f\x08\x40\x3d\xa0\x40\x00\x11\x3e\x9b\x00\xfb\xff\x21\x6f\x14\x43\x3e\x9e\x00\xff\xfb\x21\x6e\x14", .reg_data_seq_size = 32, },{ .reg_addr = 0x8043, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x3d\x57\x00\x40\xaf\xa0\xa0\x14\x43\x3d\x5a\x00\x40\x2f\xa0\x20\x14\x43\x00\x04\x00\x3d\x5e\x00\x40\xa5\xa0\xb0\x14\x43\x3d\x61", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x25\xa0\x30\x14\x43\x00\x00\x00\x22\x28\x00\x00\x02\x07\x22\x26\x00\x8a\x03\x07\x89\x04\x07\x40\x7e\xa0\x40\xbd\x90\x98\x14", .reg_data_seq_size = 32, },{ .reg_addr = 0x8043, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x9c\x84\x20\x8f\x08\x40\x9a\x90\x40\x99\xa0\x20\x2e\x08\x40\xbd\x90\x00\x10\x08\x40\x9b\xa0\x20\x0e\x08\x7f\xff\x21\x40\xf5", .reg_data_seq_size = 32, },{ .reg_addr = 0x8090, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x22\x3c\x00\x00\x02\x07\x22\x3a\x00\x82\x03\x07\x81\x04\x07\x40\x7e\xa0\x40\x3d\x90\x18\x14\x43\x10\x1c\x84\x20\x8f", .reg_data_seq_size = 32, },{ .reg_addr = 0x8008, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x1a\x90\x40\x19\xa0\x20\x2e\x08\x40\x3d\x90\x00\x10\x08\x40\x1b\xa0\x20\x0e\x08\x7f\xff\x21\x40\xf5\x90\x3d\x8c\x00\xb8\x14", .reg_data_seq_size = 32, },{ .reg_addr = 0x8043, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\xc2\xa0\x3d\x8f\x00\x38\x14\x43\x40\x42\xa0\x00\x04\x00\x10\x51\x84\x20\x0f\x08\x7f\xc0\x11\x40\x51\xa0\x08\xbb\x84\x08\x3b", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\xcb\x90\x11\x9e\x02\x07\xc7\x00\x11\x40\x7f\xa0\x08\xba\x84\x08\x3a\x84\x74\x70\x11\x9e\x02\x07\x59\x00\x11\x40\x7f\xa0\x3e\xed", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\xfd\xff\x21\xf1\x14\x43\x3e\xf0\x00\xff\xfd\x21\xf0\x14\x43\x00\x04\x00\x04\xb9\x84\x40\xb6\xa0\x04\x39\x84\x40\x36\xa0\x00\x04", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x3e\xc3\x00\x40\x87\xa0\x80\x14\x43\x3e\xc6\x00\x40\x07\xa0\x00\x14\x43\x00\x04\x00\x00\x00\x00\x04\xf5\x84\x00\x00\x21\x70\x03", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\xf5\x84\x10\x00\x08\x40\xf3\x90\x40\xf5\xa0\x3e\xd2\x00\x40\x85\xa0\x88\x14\x43\x3e\xd5\x00\x40\x05\xa0\x08\x14\x43\x00\x04", .reg_data_seq_size = 32, },{ .reg_addr = 0x8000, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x01\x07\x00\x02\x07\x00\x03\x07\x00\x04\x07\x00\x06\x07\x00\x16\x07\x00\x1e\x07\x00\x24\x07\x00\x3c\x07\x00\x72\x07\x00\x8d", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\xe0\x07\x00\xf6\x07\x01\x9f\x07\x01\xd1\x07\x00\x10\x07\x1f\xff\x07\x20\x03\x60\x0f\x5f\x07\x08\xfa\x84\x04\x11\x44\xff\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x2f\x63\x07\x70\x10\x08\x00\xf0\x21\x50\x00\x08\x00\xf0\x21\x40\xf9\x90\x00\x08\x07\x3e\x79\x00\x0f\x6b\x07\x90\x01\x07\x40\xf9", .reg_data_seq_size = 32, },{ .reg_addr = 0x80a0, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x3f\x6e\x07\x70\x00\x08\x00\x7f\x11\x40\xf8\xa0\x9d\x07\x07\x20\x12\x60\x08\xfa\x84\x04\x11\x44\x3e\x54\x00\x00\x16\x07\x48\x80", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x08\x09\x44\x40\x75\x90\x7f\xef\x07\x10\x00\x20\x00\x10\x08\xff\xff\x21\x06\x00\x84\x40\xfb\xa0\x60\x00\x08\x00\x00\x21\x40\xff", .reg_data_seq_size = 32, },{ .reg_addr = 0x8090, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\xfb\x84\x60\x20\x08\x40\xfb\x90\x30\x00\x08\x00\x08\x11\x3d\xea\x00\x04\xfb\x84\x3d\xec\x00\x04\xff\x84\x40\xf8\xa0\x04\x11", .reg_data_seq_size = 32, },{ .reg_addr = 0x8044, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x8f\xff\x07\x20\x19\x60\x3e\xd2\x00\x00\x31\x07\x00\x01\x00\x00\x33\x07\x00\x02\x00\x27\x18\x43\x75\x00\x43\x8f\xff\x07\x20\x19", .reg_data_seq_size = 32, },{ .reg_addr = 0x8060, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x04\xf5\x84\x40\xf2\xa0\x04\x51\x84\x7f\xff\x21\x04\xf5\x84\x00\x00\x21\x04\xf3\x84\x00\x10\x21\x04\xf2\x84\x0c\x00\x21\x04\x72", .reg_data_seq_size = 32, },{ .reg_addr = 0x8044, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x77\x21\x3f\xfa\x07\x70\x20\x08\x00\x00\x11\x10\x2d\x44\x10\x2c\x44\x00\x20\x08\x10\x00\x11\x00\x00\x08\x00\x00\x11\x80\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8021, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x04\x73\x44\x07\x07\x21\x04\x72\x44\x00\x07\x21\x04\x73\x44\x07\x77\x21\x04\x73\x44\x00\x70\x21\x04\x2e\x44\x04\x2d\x44\x04\x2c", .reg_data_seq_size = 32, },{ .reg_addr = 0x8044, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x80\x00\x21\x04\x1c\x44\x04\x1b\x44\x0d\x00\x21\x04\x1c\x44\x04\x1b\x44\x0c\x80\x21\x04\x1c\x44\x04\x1b\x44\x1f\x08\x21\x0f\x18", .reg_data_seq_size = 32, },{ .reg_addr = 0x8043, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x08\x28\x44\x01\x11\x11\x08\x5d\x84\x10\x00\x10\x10\x00\x08\x40\x00\x21\x30\x04\x07\x40\xff\x90\x50\x20\x08\xc0\x00\x11\x10\xff", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x20\x08\x00\x40\x11\x40\x00\x08\x00\x01\x11\x20\x51\x60\x10\x00\x44\x60\x00\x08\x40\x54\x90\x20\x00\x60\x00\x79\x07\x81\x48", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x80\x03\x07\x40\xf8\xa0\x48\xc0\x11\x00\x77\x07\x00\x78\x07\x00\x79\x07\x00\x04\x07\x00\x7b\x07\x00\x7c\x07\x00\x7d\x07\x00\x55", .reg_data_seq_size = 32, },{ .reg_addr = 0x8007, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x7f\x07\x00\x80\x07\x00\x81\x07\x00\x74\x07\x00\x83\x07\x00\x82\x07\x00\x85\x07\x00\x86\x07\x0f\xef\x07\x1f\xff\x07\xff\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8011, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x10\x00\x20\x30\x10\x08\x00\x01\x21\x50\x00\x08\x00\x0f\x21\x40\xf9\x90\x30\x90\x07\x70\x10\x08\x00\x80\x21\x50\x00\x08\x00\xf0", .reg_data_seq_size = 32, },{ .reg_addr = 0x8021, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x08\xf9\x84\x04\xf8\x84\x2f\xff\x07\x3e\x59\x00\x04\xf1\x84\x04\xf0\x84\x04\x5a\x84\x00\x00\x21\x04\xf6\x84\x00\x02\x21\x04\xfa", .reg_data_seq_size = 32, },{ .reg_addr = 0x8084, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x40\x00\x21\x04\xf7\x84\x01\x04\x21\x04\x1c\x44\x04\x1b\x44\x0b\x23\x21\x0f\x18\x43\x04\x70\x44\x06\x66\x21\x04\x3b\x44\x04\x39", .reg_data_seq_size = 32, },{ .reg_addr = 0x8044, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x80\x21\x04\x3c\x44\x2a\x0a\x21\x04\x2f\x44\x00\x44\x21\x04\x29\x44\x00\x00\x21\x03\x19\x42\x4e\x19\x43\x0c\x59\x43\x27\x18", .reg_data_seq_size = 32, },{ .reg_addr = 0x8043, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x15\x00\x43\x04\x22\x44\x03\x07\x21\x04\x21\x44\x11\x11\x21\x04\x20\x44\x33\x33\x21\x00\x00\x42\xc0\x3d\x42\x80\x3d\x43\x04\x35", .reg_data_seq_size = 32, },{ .reg_addr = 0x8044, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x21\x04\x05\x43\x42\xcd\x00", .reg_data_seq_size = 9, },{ .reg_addr = 0x88ef, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x20\x00\x18\x00\x00\x00\x00\xab\x0a\x00\x40\x00\x40\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x27\x83\x64\x7e\xca\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x88b2, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x7f\x59\x7f\xbe\x7f\xfe\x7f\xfe\x7f\xee\x73\x54\x4c\x70\x5a\x00\x6b\x0e\x6b\x1c\x5b\xcb\x32\x8c\x0b\xd2\x13\x07\x28\x01\x49\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\xff\x7f\x0b\x97\x14\xae\xf7\x53\x26\x63\x07\x46\x00\x20\x00\x89\x00\x40\x80\x41\x00\x7f\xff\x7f\xd3\x09\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x88ff, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x7f\x00\x00\x00\x00\x90\xcb\x70\x74\xfe\x7f\x52\x09\x00\x00\xfe\x7f\x00\x00\x00\x00\x00\xf2\x00\x40\xf0\x7f\x00\x0c\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x4a\x00\x4a\x00\x24\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x50\x00\x30\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\xa0\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\xff\x7f\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\xff\x7f\x00\x78\x00\x08\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x40\x00\x40\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x80\xff\x7f\x1c\x1b\xc5\x07\xc0\x20\x12\xf0\x00\x10\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\xcc\x59\x00\x00\x00\x40\x00\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x0b", .reg_data_seq_size = 32, },{ .reg_addr = 0x8897, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x14\xae\xf7\x53\x26\x63\x07\x46\x00\x20\x00\x89\x00\x40\x80\x41\x00\x7f\xff\x7f\xd3\x09\x00\x00\xff\x7f\x00\x00\x00\x00\x90\xcb", .reg_data_seq_size = 32, },{ .reg_addr = 0x8870, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x74\xfe\x7f\x52\x09\x00\x00\xfe\x7f\x00\x00\x00\x00\x00\xf2\x00\x40\xf0\x7f\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4a\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x884a, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x24\xff\x7f\x00\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x00\x00\x50\x00\x30\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x00\x00\x03", .reg_data_seq_size = 32, },{ .reg_addr = 0x8800, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\xff\x7f\x00\x00\x00\x00\x00\x00\xff\x7f\x00", .reg_data_seq_size = 32, },{ .reg_addr = 0x8878, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0000, .data_type = MSM_CAMERA_I2C_SEQ_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "\x00\x08\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xff\x7f\x00\x40\x00\x40", .reg_data_seq_size = 18, },{ .reg_addr = 0x8205, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0c00, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8205, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0d00, .data_type = MSM_CAMERA_I2C_WORD_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, },{ .reg_addr = 0x8c01, .addr_type = MSM_CAMERA_I2C_WORD_ADDR, .reg_data = 0x0001, .data_type = MSM_CAMERA_I2C_BYTE_DATA, .i2c_operation = MSM_OIS_WRITE, .delay = 0, .reg_data_seq = "", .reg_data_seq_size = 0, } }; /* // still mode settings: {0x847f, 0x0c0c,}, //_M_EQCTL {0x8436, 0xfd7f,}, //_M_Kgxdr {0x8440, 0xf07f,}, //_M_X_LMT {0x8443, 0xb41e,}, //_M_X_TGT {0x841b, 0x4001,}, //_M_Kgx10 {0x84b6, 0xfd7f,}, //_M_Kgydr {0x84c0, 0xf07f,}, //_M_Y_LMT {0x84c3, 0xb41e,}, //_M_Y_TGT {0x849b, 0x4001,}, //_M_Kgy10 {0x8438, 0x2d0f,}, //_M_Kgx11 {0x84b8, 0x2d0f,}, //_M_Kgy11 {0x8447, 0x002b,}, //_M_KgxTG {0x84c7, 0x002b,}, //_M_KgyTG {0x847f, 0x0d0d,}, //_M_EQCTL */ static struct msm_camera_i2c_reg_array init_array_s5k3p8sp[] = { {0x6028,0x2000,0}, {0x6214,0x7971,0}, {0x6218,0x7150,0}, {0x30e,0x3d,0}, {0x6028,0x2000,0}, {0x602a,0x2f38,0}, {0x6f12,0x88,0}, {0x6f12,0xd70,0}, {0x344,0x18,0}, {0x348,0x1217,0}, // last_pixel = 0x90C*2 {0x346,0x18,0}, {0x34a,0xd97,0}, // last_line = 0x6CC*2 {0x34c,0x900,0}, // width? {0x34e,0x6c0,0}, // height? {0x342,0x1400,0}, // line_length_pclk {0x340,0xe3b,0}, // frame_length_lines {0x202,0x200,0}, // integ_time {0x200,0x618,0}, {0x900,0x122,0}, {0x380,0x1,0}, {0x382,0x3,0}, {0x384,0x3,0}, {0x386,0x1,0}, {0x400,0x0,0}, {0x404,0x10,0}, {0x3604,0x2,0}, {0x3606,0x103,0}, {0xf496,0x48,0}, {0xf470,0x20,0}, {0xf43a,0x15,0}, {0xf484,0x6,0}, {0xf440,0xaf,0}, {0xf442,0x44c6,0}, {0xf408,0xfff7,0}, {0x3664,0x19,0}, {0xf494,0x1010,0}, {0x367a,0x100,0}, {0x362a,0x104,0}, {0x362e,0x404,0}, {0x32b2,0x8,0}, {0x3286,0x3,0}, {0x328a,0x5,0}, {0xf47c,0x1f,0}, {0xf62e,0xc5,0}, {0xf630,0xcd,0}, {0xf632,0xdd,0}, {0xf634,0xe5,0}, {0xf636,0xf5,0}, {0xf638,0xfd,0}, {0xf63a,0x10d,0}, {0xf63c,0x115,0}, {0xf63e,0x125,0}, {0xf640,0x12d,0}, {0x6028,0x2000,0}, {0x602a,0x1704,0}, {0x6f12,0x8011,0}, {0x3070,0x0,0}, {0xb0e,0x0,0}, {0x317a,0x7,0}, {0x31c0,0xc8,0}, {0x1006,0x4,0}, {0x31a4,0x102,0}, }; static struct msm_camera_i2c_reg_array init_array_ov8865[] = { // round 1 //{0x103,0x1,0}, // software reset {0x100,0x0,0}, // standby on {0x3638,0xff,0}, {0x302,0x1e,0}, {0x303,0x0,0}, {0x304,0x3,0}, {0x30d,0x1e,0}, {0x30e,0x0,0}, {0x30f,0x9,0}, {0x312,0x1,0}, {0x31e,0xc,0}, // PLL control {0x3015,0x1,0}, {0x3018,0x72,0}, {0x3020,0x93,0}, {0x3022,0x1,0}, {0x3031,0xa,0}, // 10-bit mode {0x3106,0x1,0}, {0x3305,0xf1,0}, {0x3308,0x0,0}, {0x3309,0x28,0}, {0x330a,0x0,0}, {0x330b,0x20,0}, {0x330c,0x0,0}, {0x330d,0x0,0}, {0x330e,0x0,0}, {0x330f,0x40,0}, {0x3307,0x4,0}, {0x3604,0x4,0}, {0x3602,0x30,0}, {0x3605,0x0,0}, {0x3607,0x20,0}, {0x3608,0x11,0}, {0x3609,0x68,0}, {0x360a,0x40,0}, {0x360c,0xdd,0}, {0x360e,0xc,0}, {0x3610,0x7,0}, {0x3612,0x86,0}, {0x3613,0x58,0}, {0x3614,0x28,0}, {0x3617,0x40,0}, {0x3618,0x5a,0}, {0x3619,0x9b,0}, {0x361c,0x0,0}, {0x361d,0x60,0}, {0x3631,0x60,0}, {0x3633,0x10,0}, {0x3634,0x10,0}, {0x3635,0x10,0}, {0x3636,0x10,0}, {0x3641,0x55,0}, {0x3646,0x86,0}, {0x3647,0x27,0}, {0x364a,0x1b,0}, {0x3500,0x0,0}, {0x3501,0x4c,0}, {0x3502,0x0,0}, {0x3503,0x0,0}, {0x3508,0x2,0}, {0x3509,0x0,0}, // AEC GAIN {0x3700,0x24,0}, {0x3701,0xc,0}, {0x3702,0x28,0}, {0x3703,0x19,0}, {0x3704,0x14,0}, {0x3705,0x0,0}, {0x3706,0x38,0}, {0x3707,0x4,0}, {0x3708,0x24,0}, {0x3709,0x40,0}, {0x370a,0x0,0}, {0x370b,0xb8,0}, {0x370c,0x4,0}, {0x3718,0x12,0}, {0x3719,0x31,0}, {0x3712,0x42,0}, {0x3714,0x12,0}, {0x371e,0x19,0}, {0x371f,0x40,0}, {0x3720,0x5,0}, {0x3721,0x5,0}, {0x3724,0x2,0}, {0x3725,0x2,0}, {0x3726,0x6,0}, {0x3728,0x5,0}, {0x3729,0x2,0}, {0x372a,0x3,0}, {0x372b,0x53,0}, {0x372c,0xa3,0}, {0x372d,0x53,0}, {0x372e,0x6,0}, {0x372f,0x10,0}, {0x3730,0x1,0}, {0x3731,0x6,0}, {0x3732,0x14,0}, {0x3733,0x10,0}, {0x3734,0x40,0}, {0x3736,0x20,0}, {0x373a,0x2,0}, {0x373b,0xc,0}, {0x373c,0xa,0}, {0x373e,0x3,0}, {0x3755,0x40,0}, {0x3758,0x0,0}, {0x3759,0x4c,0}, {0x375a,0x6,0}, {0x375b,0x13,0}, {0x375c,0x40,0}, {0x375d,0x2,0}, {0x375e,0x0,0}, {0x375f,0x14,0}, {0x3767,0x1c,0}, {0x3768,0x4,0}, {0x3769,0x20,0}, {0x376c,0xc0,0}, {0x376d,0xc0,0}, {0x376a,0x8,0}, {0x3761,0x0,0}, {0x3762,0x0,0}, {0x3763,0x0,0}, {0x3766,0xff,0}, {0x376b,0x42,0}, {0x3772,0x23,0}, {0x3773,0x2,0}, {0x3774,0x16,0}, {0x3775,0x12,0}, {0x3776,0x8,0}, {0x37a0,0x44,0}, {0x37a1,0x3d,0}, {0x37a2,0x3d,0}, {0x37a3,0x1,0}, {0x37a4,0x0,0}, {0x37a5,0x8,0}, {0x37a6,0x0,0}, {0x37a7,0x44,0}, {0x37a8,0x58,0}, {0x37a9,0x58,0}, {0x3760,0x0,0}, {0x376f,0x1,0}, {0x37aa,0x44,0}, {0x37ab,0x2e,0}, {0x37ac,0x2e,0}, {0x37ad,0x33,0}, {0x37ae,0xd,0}, {0x37af,0xd,0}, {0x37b0,0x0,0}, {0x37b1,0x0,0}, {0x37b2,0x0,0}, {0x37b3,0x42,0}, {0x37b4,0x42,0}, {0x37b5,0x33,0}, {0x37b6,0x0,0}, {0x37b7,0x0,0}, {0x37b8,0x0,0}, {0x37b9,0xff,0}, {0x3800,0x0,0}, {0x3801,0xc,0}, {0x3802,0x0,0}, {0x3803,0xc,0}, {0x3804,0xc,0}, {0x3805,0xd3,0}, // 3283 {0x3806,0x9,0}, {0x3807,0xa3,0}, // 2467 {0x3808,0x6,0}, {0x3809,0x60,0}, // 0x660 = 1632 (width) {0x380a,0x4,0}, {0x380b,0xc8,0}, // 0x4c8 = 1224 (height) {0x380c,0x6,0}, {0x380d,0x42,0}, // line_length_pck {0x380e,0x5,0}, {0x380f,0xda,0}, // frame_length_lines {0x3810,0x0,0}, {0x3811,0x4,0}, {0x3813,0x4,0}, {0x3814,0x3,0}, {0x3815,0x1,0}, // H-binning {0x3820,0x6,0}, // format1 {0x3821,0x40,0}, // format2 {0x382a,0x3,0}, {0x382b,0x1,0}, // V-binning {0x382d,0x7f,0}, {0x3830,0x8,0}, {0x3836,0x2,0}, {0x3837,0x18,0}, {0x3841,0xff,0}, {0x3846,0x88,0}, {0x3d85,0x6,0}, {0x3d8c,0x75,0}, {0x3d8d,0xef,0}, {0x3f08,0xb,0}, {0x4000,0xf1,0}, {0x4001,0x14,0}, {0x4005,0x10,0}, {0x4006,0x1,0}, {0x4007,0x1,0}, {0x400b,0xc,0}, {0x400d,0x10,0}, {0x401b,0x0,0}, {0x401d,0x0,0}, {0x4020,0x0,0}, {0x4021,0x0,0}, {0x4022,0x4,0}, {0x4023,0x1f,0}, {0x4024,0x6,0}, {0x4025,0x20,0}, {0x4026,0x6,0}, {0x4027,0x4f,0}, {0x4028,0x0,0}, {0x4029,0x2,0}, {0x402a,0x4,0}, {0x402b,0x4,0}, {0x402c,0x2,0}, {0x402d,0x2,0}, {0x402e,0x8,0}, {0x402f,0x2,0}, {0x401f,0x0,0}, {0x4034,0x3f,0}, {0x4300,0xff,0}, {0x4301,0x0,0}, {0x4302,0xf,0}, {0x4500,0x40,0}, {0x4503,0x10,0}, {0x4601,0x74,0}, {0x481f,0x32,0}, {0x4837,0x15,0}, {0x4850,0x10,0}, {0x4851,0x32,0}, {0x4b00,0x2a,0}, {0x4b0d,0x0,0}, {0x4d00,0x4,0}, {0x4d01,0x18,0}, {0x4d02,0xc3,0}, {0x4d03,0xff,0}, {0x4d04,0xff,0}, {0x4d05,0xff,0}, {0x5000,0x96,0}, {0x5001,0x1,0}, {0x5002,0x8,0}, {0x5901,0x0,0}, {0x5e00,0x0,0}, //{0x5e00,0x80,0}, {0x5e01,0x41,0}, {0x5b00,0x2,0}, {0x5b01,0xd0,0}, {0x5b02,0x3,0}, {0x5b03,0xff,0}, {0x5b05,0x6c,0}, {0x5780,0xfc,0}, {0x5781,0xdf,0}, {0x5782,0x3f,0}, {0x5783,0x8,0}, {0x5784,0xc,0}, {0x5786,0x20,0}, {0x5787,0x40,0}, {0x5788,0x8,0}, {0x5789,0x8,0}, {0x578a,0x2,0}, {0x578b,0x1,0}, {0x578c,0x1,0}, {0x578d,0xc,0}, {0x578e,0x2,0}, {0x578f,0x1,0}, {0x5790,0x1,0}, {0x5800,0x1d,0}, {0x5801,0xe,0}, {0x5802,0xc,0}, {0x5803,0xc,0}, {0x5804,0xf,0}, {0x5805,0x22,0}, {0x5806,0xa,0}, {0x5807,0x6,0}, {0x5808,0x5,0}, {0x5809,0x5,0}, {0x580a,0x7,0}, {0x580b,0xa,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x3,0}, {0x5811,0x7,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x3,0}, {0x5817,0x7,0}, {0x5818,0x9,0}, {0x5819,0x6,0}, {0x581a,0x4,0}, {0x581b,0x4,0}, {0x581c,0x6,0}, {0x581d,0xa,0}, {0x581e,0x19,0}, {0x581f,0xd,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xe,0}, {0x5823,0x22,0}, {0x5824,0x23,0}, {0x5825,0x28,0}, {0x5826,0x29,0}, {0x5827,0x27,0}, {0x5828,0x13,0}, {0x5829,0x26,0}, {0x582a,0x33,0}, {0x582b,0x32,0}, {0x582c,0x33,0}, {0x582d,0x16,0}, {0x582e,0x14,0}, {0x582f,0x30,0}, {0x5830,0x31,0}, {0x5831,0x30,0}, {0x5832,0x15,0}, {0x5833,0x26,0}, {0x5834,0x23,0}, {0x5835,0x21,0}, {0x5836,0x23,0}, {0x5837,0x5,0}, {0x5838,0x36,0}, {0x5839,0x27,0}, {0x583a,0x28,0}, {0x583b,0x26,0}, {0x583c,0x24,0}, {0x583d,0xdf,0}, //{0x100,0x1,0}, // round 2 (color calibration) {0x7010,0x0,0}, {0x7011,0x0,0}, {0x7012,0x0,0}, {0x7013,0x0,0}, {0x7014,0x0,0}, {0x7015,0x0,0}, {0x7016,0x0,0}, {0x7017,0x0,0}, {0x7018,0x0,0}, {0x7019,0x0,0}, {0x701a,0x0,0}, {0x701b,0x0,0}, {0x701c,0x0,0}, {0x701d,0x0,0}, {0x701e,0x0,0}, {0x701f,0x0,0}, {0x7020,0x0,0}, {0x7021,0x0,0}, {0x7022,0x0,0}, {0x7023,0x0,0}, {0x7024,0x0,0}, {0x7025,0x0,0}, {0x7026,0x0,0}, {0x7027,0x0,0}, {0x7028,0x0,0}, {0x7029,0x0,0}, {0x702a,0x0,0}, {0x702b,0x0,0}, {0x702c,0x0,0}, {0x702d,0x0,0}, {0x702e,0x0,0}, {0x702f,0x0,0}, {0x7030,0x0,0}, {0x7031,0x0,0}, {0x7032,0x0,0}, {0x7033,0x0,0}, {0x7034,0x0,0}, {0x7035,0x0,0}, {0x7036,0x0,0}, {0x7037,0x0,0}, {0x7038,0x0,0}, {0x7039,0x0,0}, {0x703a,0x0,0}, {0x703b,0x0,0}, {0x703c,0x0,0}, {0x703d,0x0,0}, {0x703e,0x0,0}, {0x703f,0x0,0}, {0x7040,0x0,0}, {0x7041,0x0,0}, {0x7042,0x0,0}, {0x7043,0x0,0}, {0x7044,0x0,0}, {0x7045,0x0,0}, {0x7046,0x0,0}, {0x7047,0x0,0}, {0x7048,0x0,0}, {0x7049,0x0,0}, {0x704a,0x0,0}, {0x704b,0x0,0}, {0x704c,0x0,0}, {0x704d,0x0,0}, {0x704e,0x0,0}, {0x704f,0x0,0}, {0x7050,0x0,0}, {0x7051,0x0,0}, {0x7052,0x0,0}, {0x7053,0x0,0}, {0x7054,0x0,0}, {0x7055,0x0,0}, {0x7056,0x0,0}, {0x7057,0x0,0}, {0x7058,0x0,0}, {0x7059,0x0,0}, {0x705a,0x0,0}, {0x705b,0x0,0}, {0x705c,0x0,0}, {0x705d,0x0,0}, {0x705e,0x0,0}, {0x705f,0x0,0}, {0x7060,0x0,0}, {0x7061,0x0,0}, {0x7062,0x0,0}, {0x7063,0x0,0}, {0x7064,0x0,0}, {0x7065,0x0,0}, {0x7066,0x0,0}, {0x7067,0x0,0}, {0x7068,0x0,0}, {0x7069,0x0,0}, {0x706a,0x0,0}, {0x706b,0x0,0}, {0x706c,0x0,0}, {0x706d,0x0,0}, {0x706e,0x0,0}, {0x706f,0x0,0}, {0x7070,0x0,0}, {0x7071,0x0,0}, {0x7072,0x0,0}, {0x7073,0x0,0}, {0x7074,0x0,0}, {0x7075,0x0,0}, {0x7076,0x0,0}, {0x7077,0x0,0}, {0x7078,0x0,0}, {0x7079,0x0,0}, {0x707a,0x0,0}, {0x707b,0x0,0}, {0x707c,0x0,0}, {0x707d,0x0,0}, {0x707e,0x0,0}, {0x707f,0x0,0}, {0x7080,0x0,0}, {0x7081,0x0,0}, {0x7082,0x0,0}, {0x7083,0x0,0}, {0x7084,0x0,0}, {0x7085,0x0,0}, {0x7086,0x0,0}, {0x7087,0x0,0}, {0x7088,0x0,0}, {0x7089,0x0,0}, {0x708a,0x0,0}, {0x708b,0x0,0}, {0x708c,0x0,0}, {0x708d,0x0,0}, {0x708e,0x0,0}, {0x708f,0x0,0}, {0x7090,0x0,0}, {0x7091,0x0,0}, {0x7092,0x0,0}, {0x7093,0x0,0}, {0x7094,0x0,0}, {0x7095,0x0,0}, {0x7096,0x0,0}, {0x7097,0x0,0}, {0x7098,0x0,0}, {0x7099,0x0,0}, {0x709a,0x0,0}, {0x709b,0x0,0}, {0x709c,0x0,0}, {0x709d,0x0,0}, {0x709e,0x0,0}, {0x709f,0x0,0}, {0x70a0,0x0,0}, {0x70a1,0x0,0}, {0x70a2,0x0,0}, {0x70a3,0x0,0}, {0x70a4,0x0,0}, {0x70a5,0x0,0}, {0x70a6,0x0,0}, {0x70a7,0x0,0}, {0x70a8,0x0,0}, {0x70a9,0x0,0}, {0x70aa,0x0,0}, {0x70ab,0x0,0}, {0x70ac,0x0,0}, {0x70ad,0x0,0}, {0x70ae,0x0,0}, {0x70af,0x0,0}, {0x70b0,0x0,0}, {0x70b1,0x0,0}, {0x70b2,0x0,0}, {0x70b3,0x0,0}, {0x70b4,0x0,0}, {0x70b5,0x0,0}, {0x70b6,0x0,0}, {0x70b7,0x0,0}, {0x70b8,0x0,0}, {0x70b9,0x0,0}, {0x70ba,0x0,0}, {0x70bb,0x0,0}, {0x70bc,0x0,0}, {0x70bd,0x0,0}, {0x70be,0x0,0}, {0x70bf,0x0,0}, {0x70c0,0x0,0}, {0x70c1,0x0,0}, {0x70c2,0x0,0}, {0x70c3,0x0,0}, {0x70c4,0x0,0}, {0x70c5,0x0,0}, {0x70c6,0x0,0}, {0x70c7,0x0,0}, {0x70c8,0x0,0}, {0x70c9,0x0,0}, {0x70ca,0x0,0}, {0x70cb,0x0,0}, {0x70cc,0x0,0}, {0x70cd,0x0,0}, {0x70ce,0x0,0}, {0x70cf,0x0,0}, {0x70d0,0x0,0}, {0x70d1,0x0,0}, {0x70d2,0x0,0}, {0x70d3,0x0,0}, {0x70d4,0x0,0}, {0x70d5,0x0,0}, {0x70d6,0x0,0}, {0x70d7,0x0,0}, {0x70d8,0x0,0}, {0x70d9,0x0,0}, {0x70da,0x0,0}, {0x70db,0x0,0}, {0x70dc,0x0,0}, {0x70dd,0x0,0}, {0x70de,0x0,0}, {0x70df,0x0,0}, {0x70e0,0x0,0}, {0x70e1,0x0,0}, {0x70e2,0x0,0}, {0x70e3,0x0,0}, {0x70e4,0x0,0}, {0x70e5,0x0,0}, {0x70e6,0x0,0}, {0x70e7,0x0,0}, {0x70e8,0x0,0}, {0x70e9,0x0,0}, {0x70ea,0x0,0}, {0x70eb,0x0,0}, {0x70ec,0x0,0}, {0x70ed,0x0,0}, {0x70ee,0x0,0}, {0x70ef,0x0,0}, {0x70f0,0x0,0}, {0x70f1,0x0,0}, {0x70f2,0x0,0}, {0x70f3,0x0,0}, {0x70f4,0x0,0}, {0x70f5,0x0,0}, {0x70f6,0x0,0}, {0x70f7,0x0,0}, {0x70f8,0x0,0}, {0x70f9,0x0,0}, {0x70fa,0x0,0}, {0x70fb,0x0,0}, {0x70fc,0x0,0}, {0x70fd,0x0,0}, {0x70fe,0x0,0}, {0x70ff,0x0,0}, {0x7100,0x0,0}, {0x7101,0x0,0}, {0x7102,0x0,0}, {0x7103,0x0,0}, {0x7104,0x0,0}, {0x7105,0x0,0}, {0x7106,0x0,0}, {0x7107,0x0,0}, {0x7108,0x0,0}, {0x7109,0x0,0}, {0x710a,0x0,0}, {0x710b,0x0,0}, {0x710c,0x0,0}, {0x710d,0x0,0}, {0x710e,0x0,0}, {0x710f,0x0,0}, {0x7110,0x0,0}, {0x7111,0x0,0}, {0x7112,0x0,0}, {0x7113,0x0,0}, {0x7114,0x0,0}, {0x7115,0x0,0}, {0x7116,0x0,0}, {0x7117,0x0,0}, {0x7118,0x0,0}, {0x7119,0x0,0}, {0x711a,0x0,0}, {0x711b,0x0,0}, {0x711c,0x0,0}, {0x711d,0x0,0}, {0x711e,0x0,0}, {0x711f,0x0,0}, {0x7120,0x0,0}, {0x7121,0x0,0}, {0x7122,0x0,0}, {0x7123,0x0,0}, {0x7124,0x0,0}, {0x7125,0x0,0}, {0x7126,0x0,0}, {0x7127,0x0,0}, {0x7128,0x0,0}, {0x7129,0x0,0}, {0x712a,0x0,0}, {0x712b,0x0,0}, {0x712c,0x0,0}, {0x712d,0x0,0}, {0x712e,0x0,0}, {0x712f,0x0,0}, {0x7130,0x0,0}, {0x7131,0x0,0}, {0x7132,0x0,0}, {0x501a,0x10,0}, {0x501b,0xd,0}, {0x501c,0x10,0}, {0x501d,0x13,0}, {0x5000,0x96,0}, {0x5800,0x14,0}, {0x5801,0xd,0}, {0x5802,0xa,0}, {0x5803,0xa,0}, {0x5804,0xd,0}, {0x5805,0x13,0}, {0x5806,0xa,0}, {0x5807,0x5,0}, {0x5808,0x3,0}, {0x5809,0x3,0}, {0x580a,0x5,0}, {0x580b,0x9,0}, {0x580c,0x6,0}, {0x580d,0x2,0}, {0x580e,0x0,0}, {0x580f,0x0,0}, {0x5810,0x2,0}, {0x5811,0x5,0}, {0x5812,0x6,0}, {0x5813,0x2,0}, {0x5814,0x0,0}, {0x5815,0x0,0}, {0x5816,0x2,0}, {0x5817,0x5,0}, {0x5818,0xb,0}, {0x5819,0x6,0}, {0x581a,0x3,0}, {0x581b,0x3,0}, {0x581c,0x5,0}, {0x581d,0xa,0}, {0x581e,0x16,0}, {0x581f,0xf,0}, {0x5820,0xb,0}, {0x5821,0xb,0}, {0x5822,0xf,0}, {0x5823,0x15,0}, {0x5824,0x32,0}, {0x5825,0x23,0}, {0x5826,0x23,0}, {0x5827,0x23,0}, {0x5828,0x22,0}, {0x5829,0x21,0}, {0x582a,0x21,0}, {0x582b,0x22,0}, {0x582c,0x21,0},{0x582d,0x11,0}, {0x582e,0x22,0}, {0x582f,0x31,0}, {0x5830,0x41,0}, {0x5831,0x31,0}, {0x5832,0x1,0}, {0x5833,0x21,0}, {0x5834,0x21,0}, {0x5835,0x21,0}, {0x5836,0x11,0}, {0x5837,0x11,0}, {0x5838,0x22,0}, {0x5839,0x22,0}, {0x583a,0x12,0}, {0x583b,0x22,0}, {0x583c,0x22,0}, {0x583d,0xdf,0}, }; ================================================ FILE: selfdrive/camerad/imgproc/conv.cl ================================================ // const __constant float3 rgb_weights = (0.299, 0.587, 0.114); // opencv rgb2gray weights // const __constant float3 bgr_weights = (0.114, 0.587, 0.299); // bgr2gray weights // convert input rgb image to single channel then conv __kernel void rgb2gray_conv2d( const __global uchar * input, __global short * output, __constant short * filter, __local uchar3 * cached ) { const int rowOffset = get_global_id(1) * IMAGE_W; const int my = get_global_id(0) + rowOffset; const int localRowLen = TWICE_HALF_FILTER_SIZE + get_local_size(0); const int localRowOffset = ( get_local_id(1) + HALF_FILTER_SIZE ) * localRowLen; const int myLocal = localRowOffset + get_local_id(0) + HALF_FILTER_SIZE; // cache local pixels cached[ myLocal ].x = input[ my * 3 ]; // r cached[ myLocal ].y = input[ my * 3 + 1]; // g cached[ myLocal ].z = input[ my * 3 + 2]; // b // pad if ( get_global_id(0) < HALF_FILTER_SIZE || get_global_id(0) > IMAGE_W - HALF_FILTER_SIZE - 1 || get_global_id(1) < HALF_FILTER_SIZE || get_global_id(1) > IMAGE_H - HALF_FILTER_SIZE - 1 ) { barrier(CLK_LOCAL_MEM_FENCE); return; } else { int localColOffset = -1; int globalColOffset = -1; // cache extra if ( get_local_id(0) < HALF_FILTER_SIZE ) { localColOffset = get_local_id(0); globalColOffset = -HALF_FILTER_SIZE; cached[ localRowOffset + get_local_id(0) ].x = input[ my * 3 - HALF_FILTER_SIZE * 3 ]; cached[ localRowOffset + get_local_id(0) ].y = input[ my * 3 - HALF_FILTER_SIZE * 3 + 1]; cached[ localRowOffset + get_local_id(0) ].z = input[ my * 3 - HALF_FILTER_SIZE * 3 + 2]; } else if ( get_local_id(0) >= get_local_size(0) - HALF_FILTER_SIZE ) { localColOffset = get_local_id(0) + TWICE_HALF_FILTER_SIZE; globalColOffset = HALF_FILTER_SIZE; cached[ myLocal + HALF_FILTER_SIZE ].x = input[ my * 3 + HALF_FILTER_SIZE * 3 ]; cached[ myLocal + HALF_FILTER_SIZE ].y = input[ my * 3 + HALF_FILTER_SIZE * 3 + 1]; cached[ myLocal + HALF_FILTER_SIZE ].z = input[ my * 3 + HALF_FILTER_SIZE * 3 + 2]; } if ( get_local_id(1) < HALF_FILTER_SIZE ) { cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].x = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 ]; cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].y = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + 1]; cached[ get_local_id(1) * localRowLen + get_local_id(0) + HALF_FILTER_SIZE ].z = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + 2]; if (localColOffset > 0) { cached[ get_local_id(1) * localRowLen + localColOffset ].x = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3]; cached[ get_local_id(1) * localRowLen + localColOffset ].y = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 1]; cached[ get_local_id(1) * localRowLen + localColOffset ].z = input[ my * 3 - HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 2]; } } else if ( get_local_id(1) >= get_local_size(1) -HALF_FILTER_SIZE ) { int offset = ( get_local_id(1) + TWICE_HALF_FILTER_SIZE ) * localRowLen; cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].x = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 ]; cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].y = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + 1]; cached[ offset + get_local_id(0) + HALF_FILTER_SIZE ].z = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + 2]; if (localColOffset > 0) { cached[ offset + localColOffset ].x = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3]; cached[ offset + localColOffset ].y = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 1]; cached[ offset + localColOffset ].z = input[ my * 3 + HALF_FILTER_SIZE_IMAGE_W * 3 + globalColOffset * 3 + 2]; } } // sync barrier(CLK_LOCAL_MEM_FENCE); // perform convolution int fIndex = 0; short sum = 0; for (int r = -HALF_FILTER_SIZE; r <= HALF_FILTER_SIZE; r++) { int curRow = r * localRowLen; for (int c = -HALF_FILTER_SIZE; c <= HALF_FILTER_SIZE; c++, fIndex++) { if (!FLIP_RB){ // sum += dot(rgb_weights, cached[ myLocal + curRow + c ]) * filter[ fIndex ]; sum += (cached[ myLocal + curRow + c ].x / 3 + cached[ myLocal + curRow + c ].y / 2 + cached[ myLocal + curRow + c ].z / 9) * filter[ fIndex ]; } else { // sum += dot(bgr_weights, cached[ myLocal + curRow + c ]) * filter[ fIndex ]; sum += (cached[ myLocal + curRow + c ].x / 9 + cached[ myLocal + curRow + c ].y / 2 + cached[ myLocal + curRow + c ].z / 3) * filter[ fIndex ]; } } } output[my] = sum; } } ================================================ FILE: selfdrive/camerad/imgproc/pool.cl ================================================ // calculate variance in each subregion __kernel void var_pool( const __global char * input, __global ushort * output // should not be larger than 128*128 so uint16 ) { const int xidx = get_global_id(0) + ROI_X_MIN; const int yidx = get_global_id(1) + ROI_Y_MIN; const int size = X_PITCH * Y_PITCH; float fsum = 0; char mean, max; for (int i = 0; i < size; i++) { int x_offset = i % X_PITCH; int y_offset = i / X_PITCH; fsum += input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]; max = input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]>max ? input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X]:max; } mean = convert_char_rte(fsum / size); float fvar = 0; for (int i = 0; i < size; i++) { int x_offset = i % X_PITCH; int y_offset = i / X_PITCH; fvar += (input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X] - mean) * (input[xidx*X_PITCH + yidx*Y_PITCH*FULL_STRIDE_X + x_offset + y_offset*FULL_STRIDE_X] - mean); } fvar = fvar / size; output[(xidx-ROI_X_MIN)+(yidx-ROI_Y_MIN)*(ROI_X_MAX-ROI_X_MIN+1)] = convert_ushort_rte(5 * fvar + convert_float_rte(max)); } ================================================ FILE: selfdrive/camerad/imgproc/utils.cc ================================================ #include "selfdrive/camerad/imgproc/utils.h" #include #include #include #include #include const int16_t lapl_conv_krnl[9] = {0, 1, 0, 1, -4, 1, 0, 1, 0}; // calculate score based on laplacians in one area uint16_t get_lapmap_one(const int16_t *lap, int x_pitch, int y_pitch) { const int size = x_pitch * y_pitch; // avg and max of roi int16_t max = 0; int sum = 0; for (int i = 0; i < size; ++i) { const int16_t v = lap[i]; sum += v; if (v > max) max = v; } const int16_t mean = sum / size; // var of roi int var = 0; for (int i = 0; i < size; ++i) { var += std::pow(lap[i] - mean, 2); } const float fvar = (float)var / size; return std::min(5 * fvar + max, (float)65535); } bool is_blur(const uint16_t *lapmap, const size_t size) { float bad_sum = 0; for (int i = 0; i < size; i++) { if (lapmap[i] < LM_THRESH) { bad_sum += 1 / (float)size; } } return (bad_sum > LM_PREC_THRESH); } static cl_program build_conv_program(cl_device_id device_id, cl_context context, int image_w, int image_h, int filter_size) { char args[4096]; snprintf(args, sizeof(args), "-cl-fast-relaxed-math -cl-denorms-are-zero " "-DIMAGE_W=%d -DIMAGE_H=%d -DFLIP_RB=%d " "-DFILTER_SIZE=%d -DHALF_FILTER_SIZE=%d -DTWICE_HALF_FILTER_SIZE=%d -DHALF_FILTER_SIZE_IMAGE_W=%d", image_w, image_h, 1, filter_size, filter_size/2, (filter_size/2)*2, (filter_size/2)*image_w); return cl_program_from_file(context, device_id, "imgproc/conv.cl", args); } LapConv::LapConv(cl_device_id device_id, cl_context ctx, int rgb_width, int rgb_height, int filter_size) : width(rgb_width / NUM_SEGMENTS_X), height(rgb_height / NUM_SEGMENTS_Y), roi_buf(width * height * 3), result_buf(width * height) { prg = build_conv_program(device_id, ctx, width, height, filter_size); krnl = CL_CHECK_ERR(clCreateKernel(prg, "rgb2gray_conv2d", &err)); // TODO: Removed CL_MEM_SVM_FINE_GRAIN_BUFFER, confirm it doesn't matter roi_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, roi_buf.size() * sizeof(roi_buf[0]), NULL, &err)); result_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_WRITE, result_buf.size() * sizeof(result_buf[0]), NULL, &err)); filter_cl = CL_CHECK_ERR(clCreateBuffer(ctx, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, 9 * sizeof(int16_t), (void *)&lapl_conv_krnl, &err)); } LapConv::~LapConv() { CL_CHECK(clReleaseMemObject(roi_cl)); CL_CHECK(clReleaseMemObject(result_cl)); CL_CHECK(clReleaseMemObject(filter_cl)); CL_CHECK(clReleaseKernel(krnl)); CL_CHECK(clReleaseProgram(prg)); } uint16_t LapConv::Update(cl_command_queue q, const uint8_t *rgb_buf, const int roi_id) { // sharpness scores const int x_offset = ROI_X_MIN + roi_id % (ROI_X_MAX - ROI_X_MIN + 1); const int y_offset = ROI_Y_MIN + roi_id / (ROI_X_MAX - ROI_X_MIN + 1); const uint8_t *rgb_offset = rgb_buf + y_offset * height * FULL_STRIDE_X * 3 + x_offset * width * 3; for (int i = 0; i < height; ++i) { memcpy(&roi_buf[i * width * 3], &rgb_offset[i * FULL_STRIDE_X * 3], width * 3); } constexpr int local_mem_size = (CONV_LOCAL_WORKSIZE + 2 * (3 / 2)) * (CONV_LOCAL_WORKSIZE + 2 * (3 / 2)) * (3 * sizeof(uint8_t)); const size_t global_work_size[] = {(size_t)width, (size_t)height}; const size_t local_work_size[] = {CONV_LOCAL_WORKSIZE, CONV_LOCAL_WORKSIZE}; CL_CHECK(clEnqueueWriteBuffer(q, roi_cl, CL_TRUE, 0, roi_buf.size() * sizeof(roi_buf[0]), roi_buf.data(), 0, 0, 0)); CL_CHECK(clSetKernelArg(krnl, 0, sizeof(cl_mem), (void *)&roi_cl)); CL_CHECK(clSetKernelArg(krnl, 1, sizeof(cl_mem), (void *)&result_cl)); CL_CHECK(clSetKernelArg(krnl, 2, sizeof(cl_mem), (void *)&filter_cl)); CL_CHECK(clSetKernelArg(krnl, 3, local_mem_size, 0)); cl_event conv_event; CL_CHECK(clEnqueueNDRangeKernel(q, krnl, 2, NULL, global_work_size, local_work_size, 0, 0, &conv_event)); CL_CHECK(clWaitForEvents(1, &conv_event)); CL_CHECK(clReleaseEvent(conv_event)); CL_CHECK(clEnqueueReadBuffer(q, result_cl, CL_TRUE, 0, result_buf.size() * sizeof(result_buf[0]), result_buf.data(), 0, 0, 0)); return get_lapmap_one(result_buf.data(), width, height); } ================================================ FILE: selfdrive/camerad/imgproc/utils.h ================================================ #pragma once #include #include #include #include "selfdrive/common/clutil.h" #define NUM_SEGMENTS_X 8 #define NUM_SEGMENTS_Y 6 #define ROI_X_MIN 1 #define ROI_X_MAX 6 #define ROI_Y_MIN 2 #define ROI_Y_MAX 3 #define LM_THRESH 120 #define LM_PREC_THRESH 0.9 // 90 perc is blur // only apply to QCOM #define FULL_STRIDE_X 1280 #define FULL_STRIDE_Y 896 #define CONV_LOCAL_WORKSIZE 16 class LapConv { public: LapConv(cl_device_id device_id, cl_context ctx, int rgb_width, int rgb_height, int filter_size); ~LapConv(); uint16_t Update(cl_command_queue q, const uint8_t *rgb_buf, const int roi_id); private: cl_mem roi_cl, result_cl, filter_cl; cl_program prg; cl_kernel krnl; const int width, height; std::vector roi_buf; std::vector result_buf; }; bool is_blur(const uint16_t *lapmap, const size_t size); ================================================ FILE: selfdrive/camerad/include/media/cam_cpas.h ================================================ #ifndef __UAPI_CAM_CPAS_H__ #define __UAPI_CAM_CPAS_H__ #include "cam_defs.h" #define CAM_FAMILY_CAMERA_SS 1 #define CAM_FAMILY_CPAS_SS 2 /** * struct cam_cpas_query_cap - CPAS query device capability payload * * @camera_family : Camera family type * @reserved : Reserved field for alignment * @camera_version : Camera platform version * @cpas_version : Camera CPAS version within camera platform * */ struct cam_cpas_query_cap { uint32_t camera_family; uint32_t reserved; struct cam_hw_version camera_version; struct cam_hw_version cpas_version; }; #endif /* __UAPI_CAM_CPAS_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_defs.h ================================================ #ifndef __UAPI_CAM_DEFS_H__ #define __UAPI_CAM_DEFS_H__ #include #include #include /* camera op codes */ #define CAM_COMMON_OPCODE_BASE 0x100 #define CAM_QUERY_CAP (CAM_COMMON_OPCODE_BASE + 0x1) #define CAM_ACQUIRE_DEV (CAM_COMMON_OPCODE_BASE + 0x2) #define CAM_START_DEV (CAM_COMMON_OPCODE_BASE + 0x3) #define CAM_STOP_DEV (CAM_COMMON_OPCODE_BASE + 0x4) #define CAM_CONFIG_DEV (CAM_COMMON_OPCODE_BASE + 0x5) #define CAM_RELEASE_DEV (CAM_COMMON_OPCODE_BASE + 0x6) #define CAM_SD_SHUTDOWN (CAM_COMMON_OPCODE_BASE + 0x7) #define CAM_FLUSH_REQ (CAM_COMMON_OPCODE_BASE + 0x8) #define CAM_COMMON_OPCODE_MAX (CAM_COMMON_OPCODE_BASE + 0x9) #define CAM_EXT_OPCODE_BASE 0x200 #define CAM_CONFIG_DEV_EXTERNAL (CAM_EXT_OPCODE_BASE + 0x1) /* camera handle type */ #define CAM_HANDLE_USER_POINTER 1 #define CAM_HANDLE_MEM_HANDLE 2 /* Generic Blob CmdBuffer header properties */ #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK 0xFFFFFF00 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT 8 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK 0xFF #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT 0 /* Command Buffer Types */ #define CAM_CMD_BUF_DMI 0x1 #define CAM_CMD_BUF_DMI16 0x2 #define CAM_CMD_BUF_DMI32 0x3 #define CAM_CMD_BUF_DMI64 0x4 #define CAM_CMD_BUF_DIRECT 0x5 #define CAM_CMD_BUF_INDIRECT 0x6 #define CAM_CMD_BUF_I2C 0x7 #define CAM_CMD_BUF_FW 0x8 #define CAM_CMD_BUF_GENERIC 0x9 #define CAM_CMD_BUF_LEGACY 0xA /** * enum flush_type_t - Identifies the various flush types * * @CAM_FLUSH_TYPE_REQ: Flush specific request * @CAM_FLUSH_TYPE_ALL: Flush all requests belonging to a context * @CAM_FLUSH_TYPE_MAX: Max enum to validate flush type * */ enum flush_type_t { CAM_FLUSH_TYPE_REQ, CAM_FLUSH_TYPE_ALL, CAM_FLUSH_TYPE_MAX }; /** * struct cam_control - Structure used by ioctl control for camera * * @op_code: This is the op code for camera control * @size: Control command size * @handle_type: User pointer or shared memory handle * @reserved: Reserved field for 64 bit alignment * @handle: Control command payload */ struct cam_control { uint32_t op_code; uint32_t size; uint32_t handle_type; uint32_t reserved; uint64_t handle; }; /* camera IOCTL */ #define VIDIOC_CAM_CONTROL \ _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control) /** * struct cam_hw_version - Structure for HW version of camera devices * * @major : Hardware version major * @minor : Hardware version minor * @incr : Hardware version increment * @reserved : Reserved for 64 bit aligngment */ struct cam_hw_version { uint32_t major; uint32_t minor; uint32_t incr; uint32_t reserved; }; /** * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices * * @non_secure: Device Non Secure IOMMU handle * @secure: Device Secure IOMMU handle * */ struct cam_iommu_handle { int32_t non_secure; int32_t secure; }; /* camera secure mode */ #define CAM_SECURE_MODE_NON_SECURE 0 #define CAM_SECURE_MODE_SECURE 1 /* Camera Format Type */ #define CAM_FORMAT_BASE 0 #define CAM_FORMAT_MIPI_RAW_6 1 #define CAM_FORMAT_MIPI_RAW_8 2 #define CAM_FORMAT_MIPI_RAW_10 3 #define CAM_FORMAT_MIPI_RAW_12 4 #define CAM_FORMAT_MIPI_RAW_14 5 #define CAM_FORMAT_MIPI_RAW_16 6 #define CAM_FORMAT_MIPI_RAW_20 7 #define CAM_FORMAT_QTI_RAW_8 8 #define CAM_FORMAT_QTI_RAW_10 9 #define CAM_FORMAT_QTI_RAW_12 10 #define CAM_FORMAT_QTI_RAW_14 11 #define CAM_FORMAT_PLAIN8 12 #define CAM_FORMAT_PLAIN16_8 13 #define CAM_FORMAT_PLAIN16_10 14 #define CAM_FORMAT_PLAIN16_12 15 #define CAM_FORMAT_PLAIN16_14 16 #define CAM_FORMAT_PLAIN16_16 17 #define CAM_FORMAT_PLAIN32_20 18 #define CAM_FORMAT_PLAIN64 19 #define CAM_FORMAT_PLAIN128 20 #define CAM_FORMAT_ARGB 21 #define CAM_FORMAT_ARGB_10 22 #define CAM_FORMAT_ARGB_12 23 #define CAM_FORMAT_ARGB_14 24 #define CAM_FORMAT_DPCM_10_6_10 25 #define CAM_FORMAT_DPCM_10_8_10 26 #define CAM_FORMAT_DPCM_12_6_12 27 #define CAM_FORMAT_DPCM_12_8_12 28 #define CAM_FORMAT_DPCM_14_8_14 29 #define CAM_FORMAT_DPCM_14_10_14 30 #define CAM_FORMAT_NV21 31 #define CAM_FORMAT_NV12 32 #define CAM_FORMAT_TP10 33 #define CAM_FORMAT_YUV422 34 #define CAM_FORMAT_PD8 35 #define CAM_FORMAT_PD10 36 #define CAM_FORMAT_UBWC_NV12 37 #define CAM_FORMAT_UBWC_NV12_4R 38 #define CAM_FORMAT_UBWC_TP10 39 #define CAM_FORMAT_UBWC_P010 40 #define CAM_FORMAT_PLAIN8_SWAP 41 #define CAM_FORMAT_PLAIN8_10 42 #define CAM_FORMAT_PLAIN8_10_SWAP 43 #define CAM_FORMAT_YV12 44 #define CAM_FORMAT_Y_ONLY 45 #define CAM_FORMAT_MAX 46 /* camera rotaion */ #define CAM_ROTATE_CW_0_DEGREE 0 #define CAM_ROTATE_CW_90_DEGREE 1 #define CAM_RORATE_CW_180_DEGREE 2 #define CAM_ROTATE_CW_270_DEGREE 3 /* camera Color Space */ #define CAM_COLOR_SPACE_BASE 0 #define CAM_COLOR_SPACE_BT601_FULL 1 #define CAM_COLOR_SPACE_BT601625 2 #define CAM_COLOR_SPACE_BT601525 3 #define CAM_COLOR_SPACE_BT709 4 #define CAM_COLOR_SPACE_DEPTH 5 #define CAM_COLOR_SPACE_MAX 6 /* camera buffer direction */ #define CAM_BUF_INPUT 1 #define CAM_BUF_OUTPUT 2 #define CAM_BUF_IN_OUT 3 /* camera packet device Type */ #define CAM_PACKET_DEV_BASE 0 #define CAM_PACKET_DEV_IMG_SENSOR 1 #define CAM_PACKET_DEV_ACTUATOR 2 #define CAM_PACKET_DEV_COMPANION 3 #define CAM_PACKET_DEV_EEPOM 4 #define CAM_PACKET_DEV_CSIPHY 5 #define CAM_PACKET_DEV_OIS 6 #define CAM_PACKET_DEV_FLASH 7 #define CAM_PACKET_DEV_FD 8 #define CAM_PACKET_DEV_JPEG_ENC 9 #define CAM_PACKET_DEV_JPEG_DEC 10 #define CAM_PACKET_DEV_VFE 11 #define CAM_PACKET_DEV_CPP 12 #define CAM_PACKET_DEV_CSID 13 #define CAM_PACKET_DEV_ISPIF 14 #define CAM_PACKET_DEV_IFE 15 #define CAM_PACKET_DEV_ICP 16 #define CAM_PACKET_DEV_LRME 17 #define CAM_PACKET_DEV_MAX 18 /* constants */ #define CAM_PACKET_MAX_PLANES 3 /** * struct cam_plane_cfg - Plane configuration info * * @width: Plane width in pixels * @height: Plane height in lines * @plane_stride: Plane stride in pixel * @slice_height: Slice height in line (not used by ISP) * @meta_stride: UBWC metadata stride * @meta_size: UBWC metadata plane size * @meta_offset: UBWC metadata offset * @packer_config: UBWC packer config * @mode_config: UBWC mode config * @tile_config: UBWC tile config * @h_init: UBWC horizontal initial coordinate in pixels * @v_init: UBWC vertical initial coordinate in lines * */ struct cam_plane_cfg { uint32_t width; uint32_t height; uint32_t plane_stride; uint32_t slice_height; uint32_t meta_stride; uint32_t meta_size; uint32_t meta_offset; uint32_t packer_config; uint32_t mode_config; uint32_t tile_config; uint32_t h_init; uint32_t v_init; }; /** * struct cam_cmd_buf_desc - Command buffer descriptor * * @mem_handle: Command buffer handle * @offset: Command start offset * @size: Size of the command buffer in bytes * @length: Used memory in command buffer in bytes * @type: Type of the command buffer * @meta_data: Data type for private command buffer * Between UMD and KMD * */ struct cam_cmd_buf_desc { int32_t mem_handle; uint32_t offset; uint32_t size; uint32_t length; uint32_t type; uint32_t meta_data; }; /** * struct cam_buf_io_cfg - Buffer io configuration for buffers * * @mem_handle: Mem_handle array for the buffers. * @offsets: Offsets for each planes in the buffer * @planes: Per plane information * @width: Main plane width in pixel * @height: Main plane height in lines * @format: Format of the buffer * @color_space: Color space for the buffer * @color_pattern: Color pattern in the buffer * @bpp: Bit per pixel * @rotation: Rotation information for the buffer * @resource_type: Resource type associated with the buffer * @fence: Fence handle * @early_fence: Fence handle for early signal * @aux_cmd_buf: An auxiliary command buffer that may be * used for programming the IO * @direction: Direction of the config * @batch_size: Batch size in HFR mode * @subsample_pattern: Subsample pattern. Used in HFR mode. It * should be consistent with batchSize and * CAMIF programming. * @subsample_period: Subsample period. Used in HFR mode. It * should be consistent with batchSize and * CAMIF programming. * @framedrop_pattern: Framedrop pattern * @framedrop_period: Framedrop period * @flag: Flags for extra information * @direction: Buffer direction: input or output * @padding: Padding for the structure * */ struct cam_buf_io_cfg { int32_t mem_handle[CAM_PACKET_MAX_PLANES]; uint32_t offsets[CAM_PACKET_MAX_PLANES]; struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES]; uint32_t format; uint32_t color_space; uint32_t color_pattern; uint32_t bpp; uint32_t rotation; uint32_t resource_type; int32_t fence; int32_t early_fence; struct cam_cmd_buf_desc aux_cmd_buf; uint32_t direction; uint32_t batch_size; uint32_t subsample_pattern; uint32_t subsample_period; uint32_t framedrop_pattern; uint32_t framedrop_period; uint32_t flag; uint32_t padding; }; /** * struct cam_packet_header - Camera packet header * * @op_code: Camera packet opcode * @size: Size of the camera packet in bytes * @request_id: Request id for this camera packet * @flags: Flags for the camera packet * @padding: Padding * */ struct cam_packet_header { uint32_t op_code; uint32_t size; uint64_t request_id; uint32_t flags; uint32_t padding; }; /** * struct cam_patch_desc - Patch structure * * @dst_buf_hdl: Memory handle for the dest buffer * @dst_offset: Offset byte in the dest buffer * @src_buf_hdl: Memory handle for the source buffer * @src_offset: Offset byte in the source buffer * */ struct cam_patch_desc { int32_t dst_buf_hdl; uint32_t dst_offset; int32_t src_buf_hdl; uint32_t src_offset; }; /** * struct cam_packet - Camera packet structure * * @header: Camera packet header * @cmd_buf_offset: Command buffer start offset * @num_cmd_buf: Number of the command buffer in the packet * @io_config_offset: Buffer io configuration start offset * @num_io_configs: Number of the buffer io configurations * @patch_offset: Patch offset for the patch structure * @num_patches: Number of the patch structure * @kmd_cmd_buf_index: Command buffer index which contains extra * space for the KMD buffer * @kmd_cmd_buf_offset: Offset from the beginning of the command * buffer for KMD usage. * @payload: Camera packet payload * */ struct cam_packet { struct cam_packet_header header; uint32_t cmd_buf_offset; uint32_t num_cmd_buf; uint32_t io_configs_offset; uint32_t num_io_configs; uint32_t patch_offset; uint32_t num_patches; uint32_t kmd_cmd_buf_index; uint32_t kmd_cmd_buf_offset; uint64_t payload[1]; }; /** * struct cam_release_dev_cmd - Control payload for release devices * * @session_handle: Session handle for the release * @dev_handle: Device handle for the release */ struct cam_release_dev_cmd { int32_t session_handle; int32_t dev_handle; }; /** * struct cam_start_stop_dev_cmd - Control payload for start/stop device * * @session_handle: Session handle for the start/stop command * @dev_handle: Device handle for the start/stop command * */ struct cam_start_stop_dev_cmd { int32_t session_handle; int32_t dev_handle; }; /** * struct cam_config_dev_cmd - Command payload for configure device * * @session_handle: Session handle for the command * @dev_handle: Device handle for the command * @offset: Offset byte in the packet handle. * @packet_handle: Packet memory handle for the actual packet: * struct cam_packet. * */ struct cam_config_dev_cmd { int32_t session_handle; int32_t dev_handle; uint64_t offset; uint64_t packet_handle; }; /** * struct cam_query_cap_cmd - Payload for query device capability * * @size: Handle size * @handle_type: User pointer or shared memory handle * @caps_handle: Device specific query command payload * */ struct cam_query_cap_cmd { uint32_t size; uint32_t handle_type; uint64_t caps_handle; }; /** * struct cam_acquire_dev_cmd - Control payload for acquire devices * * @session_handle: Session handle for the acquire command * @dev_handle: Device handle to be returned * @handle_type: Resource handle type: * 1 = user pointer, 2 = mem handle * @num_resources: Number of the resources to be acquired * @resources_hdl: Resource handle that refers to the actual * resource array. Each item in this * array is device specific resource structure * */ struct cam_acquire_dev_cmd { int32_t session_handle; int32_t dev_handle; uint32_t handle_type; uint32_t num_resources; uint64_t resource_hdl; }; /** * struct cam_flush_dev_cmd - Control payload for flush devices * * @version: Version * @session_handle: Session handle for the acquire command * @dev_handle: Device handle to be returned * @flush_type: Flush type: * 0 = flush specific request * 1 = flush all * @reserved: Reserved for 64 bit aligngment * @req_id: Request id that needs to cancel * */ struct cam_flush_dev_cmd { uint64_t version; int32_t session_handle; int32_t dev_handle; uint32_t flush_type; uint32_t reserved; int64_t req_id; }; #endif /* __UAPI_CAM_DEFS_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_fd.h ================================================ #ifndef __UAPI_CAM_FD_H__ #define __UAPI_CAM_FD_H__ #include "cam_defs.h" #define CAM_FD_MAX_FACES 35 #define CAM_FD_RAW_RESULT_ENTRIES 512 /* FD Op Codes */ #define CAM_PACKET_OPCODES_FD_FRAME_UPDATE 0x0 /* FD Command Buffer identifiers */ #define CAM_FD_CMD_BUFFER_ID_GENERIC 0x0 #define CAM_FD_CMD_BUFFER_ID_CDM 0x1 #define CAM_FD_CMD_BUFFER_ID_MAX 0x2 /* FD Blob types */ #define CAM_FD_BLOB_TYPE_SOC_CLOCK_BW_REQUEST 0x0 #define CAM_FD_BLOB_TYPE_RAW_RESULTS_REQUIRED 0x1 /* FD Resource IDs */ #define CAM_FD_INPUT_PORT_ID_IMAGE 0x0 #define CAM_FD_INPUT_PORT_ID_MAX 0x1 #define CAM_FD_OUTPUT_PORT_ID_RESULTS 0x0 #define CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS 0x1 #define CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER 0x2 #define CAM_FD_OUTPUT_PORT_ID_MAX 0x3 /** * struct cam_fd_soc_clock_bw_request - SOC clock, bandwidth request info * * @clock_rate : Clock rate required while processing frame * @bandwidth : Bandwidth required while processing frame * @reserved : Reserved for future use */ struct cam_fd_soc_clock_bw_request { uint64_t clock_rate; uint64_t bandwidth; uint64_t reserved[4]; }; /** * struct cam_fd_face - Face properties * * @prop1 : Property 1 of face * @prop2 : Property 2 of face * @prop3 : Property 3 of face * @prop4 : Property 4 of face * * Do not change this layout, this is inline with how HW writes * these values directly when the buffer is programmed to HW */ struct cam_fd_face { uint32_t prop1; uint32_t prop2; uint32_t prop3; uint32_t prop4; }; /** * struct cam_fd_results - FD results layout * * @faces : Array of faces with face properties * @face_count : Number of faces detected * @reserved : Reserved for alignment * * Do not change this layout, this is inline with how HW writes * these values directly when the buffer is programmed to HW */ struct cam_fd_results { struct cam_fd_face faces[CAM_FD_MAX_FACES]; uint32_t face_count; uint32_t reserved[3]; }; /** * struct cam_fd_hw_caps - Face properties * * @core_version : FD core version * @wrapper_version : FD wrapper version * @raw_results_available : Whether raw results are available on this HW * @supported_modes : Modes supported by this HW. * @reserved : Reserved for future use */ struct cam_fd_hw_caps { struct cam_hw_version core_version; struct cam_hw_version wrapper_version; uint32_t raw_results_available; uint32_t supported_modes; uint64_t reserved; }; /** * struct cam_fd_query_cap_cmd - FD Query capabilities information * * @device_iommu : FD IOMMU handles * @cdm_iommu : CDM iommu handles * @hw_caps : FD HW capabilities * @reserved : Reserved for alignment */ struct cam_fd_query_cap_cmd { struct cam_iommu_handle device_iommu; struct cam_iommu_handle cdm_iommu; struct cam_fd_hw_caps hw_caps; uint64_t reserved; }; /** * struct cam_fd_acquire_dev_info - FD acquire device information * * @clk_bw_request : SOC clock, bandwidth request * @priority : Priority for this acquire * @mode : Mode in which to run FD HW. * @get_raw_results : Whether this acquire needs face raw results * while frame processing * @reserved : Reserved field for 64 bit alignment */ struct cam_fd_acquire_dev_info { struct cam_fd_soc_clock_bw_request clk_bw_request; uint32_t priority; uint32_t mode; uint32_t get_raw_results; uint32_t reserved[13]; }; #endif /* __UAPI_CAM_FD_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_icp.h ================================================ #ifndef __UAPI_CAM_ICP_H__ #define __UAPI_CAM_ICP_H__ #include "cam_defs.h" /* icp, ipe, bps, cdm(ipe/bps) are used in querycap */ #define CAM_ICP_DEV_TYPE_A5 1 #define CAM_ICP_DEV_TYPE_IPE 2 #define CAM_ICP_DEV_TYPE_BPS 3 #define CAM_ICP_DEV_TYPE_IPE_CDM 4 #define CAM_ICP_DEV_TYPE_BPS_CDM 5 #define CAM_ICP_DEV_TYPE_MAX 5 /* definitions needed for icp aquire device */ #define CAM_ICP_RES_TYPE_BPS 1 #define CAM_ICP_RES_TYPE_IPE_RT 2 #define CAM_ICP_RES_TYPE_IPE 3 #define CAM_ICP_RES_TYPE_MAX 4 /* packet opcode types */ #define CAM_ICP_OPCODE_IPE_UPDATE 0 #define CAM_ICP_OPCODE_BPS_UPDATE 1 /* IPE input port resource type */ #define CAM_ICP_IPE_INPUT_IMAGE_FULL 0x0 #define CAM_ICP_IPE_INPUT_IMAGE_DS4 0x1 #define CAM_ICP_IPE_INPUT_IMAGE_DS16 0x2 #define CAM_ICP_IPE_INPUT_IMAGE_DS64 0x3 #define CAM_ICP_IPE_INPUT_IMAGE_FULL_REF 0x4 #define CAM_ICP_IPE_INPUT_IMAGE_DS4_REF 0x5 #define CAM_ICP_IPE_INPUT_IMAGE_DS16_REF 0x6 #define CAM_ICP_IPE_INPUT_IMAGE_DS64_REF 0x7 /* IPE output port resource type */ #define CAM_ICP_IPE_OUTPUT_IMAGE_DISPLAY 0x8 #define CAM_ICP_IPE_OUTPUT_IMAGE_VIDEO 0x9 #define CAM_ICP_IPE_OUTPUT_IMAGE_FULL_REF 0xA #define CAM_ICP_IPE_OUTPUT_IMAGE_DS4_REF 0xB #define CAM_ICP_IPE_OUTPUT_IMAGE_DS16_REF 0xC #define CAM_ICP_IPE_OUTPUT_IMAGE_DS64_REF 0xD #define CAM_ICP_IPE_IMAGE_MAX 0xE /* BPS input port resource type */ #define CAM_ICP_BPS_INPUT_IMAGE 0x0 /* BPS output port resource type */ #define CAM_ICP_BPS_OUTPUT_IMAGE_FULL 0x1 #define CAM_ICP_BPS_OUTPUT_IMAGE_DS4 0x2 #define CAM_ICP_BPS_OUTPUT_IMAGE_DS16 0x3 #define CAM_ICP_BPS_OUTPUT_IMAGE_DS64 0x4 #define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BG 0x5 #define CAM_ICP_BPS_OUTPUT_IMAGE_STATS_BHIST 0x6 #define CAM_ICP_BPS_OUTPUT_IMAGE_REG1 0x7 #define CAM_ICP_BPS_OUTPUT_IMAGE_REG2 0x8 #define CAM_ICP_BPS_IO_IMAGES_MAX 0x9 /* Command meta types */ #define CAM_ICP_CMD_META_GENERIC_BLOB 0x1 /* Generic blob types */ #define CAM_ICP_CMD_GENERIC_BLOB_CLK 0x1 #define CAM_ICP_CMD_GENERIC_BLOB_CFG_IO 0x2 /** * struct cam_icp_clk_bw_request * * @budget_ns: Time required to process frame * @frame_cycles: Frame cycles needed to process the frame * @rt_flag: Flag to indicate real time stream * @uncompressed_bw: Bandwidth required to process frame * @compressed_bw: Compressed bandwidth to process frame */ struct cam_icp_clk_bw_request { uint64_t budget_ns; uint32_t frame_cycles; uint32_t rt_flag; uint64_t uncompressed_bw; uint64_t compressed_bw; }; /** * struct cam_icp_dev_ver - Device information for particular hw type * * This is used to get device version info of * ICP, IPE, BPS and CDM related IPE and BPS from firmware * and use this info in CAM_QUERY_CAP IOCTL * * @dev_type: hardware type for the cap info(icp, ipe, bps, cdm(ipe/bps)) * @reserved: reserved field * @hw_ver: major, minor and incr values of a device version */ struct cam_icp_dev_ver { uint32_t dev_type; uint32_t reserved; struct cam_hw_version hw_ver; }; /** * struct cam_icp_ver - ICP version info * * This strcuture is used for fw and api version * this is used to get firmware version and api version from firmware * and use this info in CAM_QUERY_CAP IOCTL * * @major: FW version major * @minor: FW version minor * @revision: FW version increment */ struct cam_icp_ver { uint32_t major; uint32_t minor; uint32_t revision; uint32_t reserved; }; /** * struct cam_icp_query_cap_cmd - ICP query device capability payload * * @dev_iommu_handle: icp iommu handles for secure/non secure modes * @cdm_iommu_handle: iommu handles for secure/non secure modes * @fw_version: firmware version info * @api_version: api version info * @num_ipe: number of ipes * @num_bps: number of bps * @dev_ver: returned device capability array */ struct cam_icp_query_cap_cmd { struct cam_iommu_handle dev_iommu_handle; struct cam_iommu_handle cdm_iommu_handle; struct cam_icp_ver fw_version; struct cam_icp_ver api_version; uint32_t num_ipe; uint32_t num_bps; struct cam_icp_dev_ver dev_ver[CAM_ICP_DEV_TYPE_MAX]; }; /** * struct cam_icp_res_info - ICP output resource info * * @format: format of the resource * @width: width in pixels * @height: height in lines * @fps: fps */ struct cam_icp_res_info { uint32_t format; uint32_t width; uint32_t height; uint32_t fps; }; /** * struct cam_icp_acquire_dev_info - An ICP device info * * @scratch_mem_size: Output param - size of scratch memory * @dev_type: device type (IPE_RT/IPE_NON_RT/BPS) * @io_config_cmd_size: size of IO config command * @io_config_cmd_handle: IO config command for each acquire * @secure_mode: camera mode (secure/non secure) * @chain_info: chaining info of FW device handles * @in_res: resource info used for clock and bandwidth calculation * @num_out_res: number of output resources * @out_res: output resource */ struct cam_icp_acquire_dev_info { uint32_t scratch_mem_size; uint32_t dev_type; uint32_t io_config_cmd_size; int32_t io_config_cmd_handle; uint32_t secure_mode; int32_t chain_info; struct cam_icp_res_info in_res; uint32_t num_out_res; struct cam_icp_res_info out_res[1]; } __attribute__((__packed__)); #endif /* __UAPI_CAM_ICP_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_isp.h ================================================ #ifndef __UAPI_CAM_ISP_H__ #define __UAPI_CAM_ISP_H__ #include "cam_defs.h" #include "cam_isp_vfe.h" #include "cam_isp_ife.h" /* ISP driver name */ #define CAM_ISP_DEV_NAME "cam-isp" /* HW type */ #define CAM_ISP_HW_BASE 0 #define CAM_ISP_HW_CSID 1 #define CAM_ISP_HW_VFE 2 #define CAM_ISP_HW_IFE 3 #define CAM_ISP_HW_ISPIF 4 #define CAM_ISP_HW_MAX 5 /* Color Pattern */ #define CAM_ISP_PATTERN_BAYER_RGRGRG 0 #define CAM_ISP_PATTERN_BAYER_GRGRGR 1 #define CAM_ISP_PATTERN_BAYER_BGBGBG 2 #define CAM_ISP_PATTERN_BAYER_GBGBGB 3 #define CAM_ISP_PATTERN_YUV_YCBYCR 4 #define CAM_ISP_PATTERN_YUV_YCRYCB 5 #define CAM_ISP_PATTERN_YUV_CBYCRY 6 #define CAM_ISP_PATTERN_YUV_CRYCBY 7 #define CAM_ISP_PATTERN_MAX 8 /* Usage Type */ #define CAM_ISP_RES_USAGE_SINGLE 0 #define CAM_ISP_RES_USAGE_DUAL 1 #define CAM_ISP_RES_USAGE_MAX 2 /* Resource ID */ #define CAM_ISP_RES_ID_PORT 0 #define CAM_ISP_RES_ID_CLK 1 #define CAM_ISP_RES_ID_MAX 2 /* Resource Type - Type of resource for the resource id * defined in cam_isp_vfe.h, cam_isp_ife.h */ /* Lane Type in input resource for Port */ #define CAM_ISP_LANE_TYPE_DPHY 0 #define CAM_ISP_LANE_TYPE_CPHY 1 #define CAM_ISP_LANE_TYPE_MAX 2 /* ISP Resurce Composite Group ID */ #define CAM_ISP_RES_COMP_GROUP_NONE 0 #define CAM_ISP_RES_COMP_GROUP_ID_0 1 #define CAM_ISP_RES_COMP_GROUP_ID_1 2 #define CAM_ISP_RES_COMP_GROUP_ID_2 3 #define CAM_ISP_RES_COMP_GROUP_ID_3 4 #define CAM_ISP_RES_COMP_GROUP_ID_4 5 #define CAM_ISP_RES_COMP_GROUP_ID_5 6 #define CAM_ISP_RES_COMP_GROUP_ID_MAX 6 /* ISP packet opcode for ISP */ #define CAM_ISP_PACKET_OP_BASE 0 #define CAM_ISP_PACKET_INIT_DEV 1 #define CAM_ISP_PACKET_UPDATE_DEV 2 #define CAM_ISP_PACKET_OP_MAX 3 /* ISP packet meta_data type for command buffer */ #define CAM_ISP_PACKET_META_BASE 0 #define CAM_ISP_PACKET_META_LEFT 1 #define CAM_ISP_PACKET_META_RIGHT 2 #define CAM_ISP_PACKET_META_COMMON 3 #define CAM_ISP_PACKET_META_DMI_LEFT 4 #define CAM_ISP_PACKET_META_DMI_RIGHT 5 #define CAM_ISP_PACKET_META_DMI_COMMON 6 #define CAM_ISP_PACKET_META_CLOCK 7 #define CAM_ISP_PACKET_META_CSID 8 #define CAM_ISP_PACKET_META_DUAL_CONFIG 9 #define CAM_ISP_PACKET_META_GENERIC_BLOB_LEFT 10 #define CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT 11 #define CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON 12 /* DSP mode */ #define CAM_ISP_DSP_MODE_NONE 0 #define CAM_ISP_DSP_MODE_ONE_WAY 1 #define CAM_ISP_DSP_MODE_ROUND 2 /* ISP Generic Cmd Buffer Blob types */ #define CAM_ISP_GENERIC_BLOB_TYPE_HFR_CONFIG 0 #define CAM_ISP_GENERIC_BLOB_TYPE_CLOCK_CONFIG 1 #define CAM_ISP_GENERIC_BLOB_TYPE_BW_CONFIG 2 /* Query devices */ /** * struct cam_isp_dev_cap_info - A cap info for particular hw type * * @hw_type: Hardware type for the cap info * @reserved: reserved field for alignment * @hw_version: Hardware version * */ struct cam_isp_dev_cap_info { uint32_t hw_type; uint32_t reserved; struct cam_hw_version hw_version; }; /** * struct cam_isp_query_cap_cmd - ISP query device capability payload * * @device_iommu: returned iommu handles for device * @cdm_iommu: returned iommu handles for cdm * @num_dev: returned number of device capabilities * @reserved: reserved field for alignment * @dev_caps: returned device capability array * */ struct cam_isp_query_cap_cmd { struct cam_iommu_handle device_iommu; struct cam_iommu_handle cdm_iommu; int32_t num_dev; uint32_t reserved; struct cam_isp_dev_cap_info dev_caps[CAM_ISP_HW_MAX]; }; /* Acquire Device */ /** * struct cam_isp_out_port_info - An output port resource info * * @res_type: output resource type defined in file * cam_isp_vfe.h or cam_isp_ife.h * @format: output format of the resource * @wdith: output width in pixels * @height: output height in lines * @comp_grp_id: composite group id for the resource. * @split_point: split point in pixels for the dual VFE. * @secure_mode: flag to tell if output should be run in secure * mode or not. See cam_defs.h for definition * @reserved: reserved field for alignment * */ struct cam_isp_out_port_info { uint32_t res_type; uint32_t format; uint32_t width; uint32_t height; uint32_t comp_grp_id; uint32_t split_point; uint32_t secure_mode; uint32_t reserved; }; /** * struct cam_isp_in_port_info - An input port resource info * * @res_type: input resource type define in file * cam_isp_vfe.h or cam_isp_ife.h * @lane_type: lane type: c-phy or d-phy. * @lane_num: active lane number * @lane_cfg: lane configurations: 4 bits per lane * @vc: input virtual channel number * @dt: input data type number * @format: input format * @test_pattern: test pattern for the testgen * @usage_type: whether dual vfe is required * @left_start: left input start offset in pixels * @left_stop: left input stop offset in pixels * @left_width: left input width in pixels * @right_start: right input start offset in pixels. * Only for Dual VFE * @right_stop: right input stop offset in pixels. * Only for Dual VFE * @right_width: right input width in pixels. * Only for dual VFE * @line_start: top of the line number * @line_stop: bottome of the line number * @height: input height in lines * @pixel_clk; sensor output clock * @batch_size: batch size for HFR mode * @dsp_mode: DSP stream mode (Defines as CAM_ISP_DSP_MODE_*) * @hbi_cnt: HBI count for the camif input * @reserved: Reserved field for alignment * @num_out_res: number of the output resource associated * @data: payload that contains the output resources * */ struct cam_isp_in_port_info { uint32_t res_type; uint32_t lane_type; uint32_t lane_num; uint32_t lane_cfg; uint32_t vc; uint32_t dt; uint32_t format; uint32_t test_pattern; uint32_t usage_type; uint32_t left_start; uint32_t left_stop; uint32_t left_width; uint32_t right_start; uint32_t right_stop; uint32_t right_width; uint32_t line_start; uint32_t line_stop; uint32_t height; uint32_t pixel_clk; uint32_t batch_size; uint32_t dsp_mode; uint32_t hbi_cnt; uint32_t custom_csid; uint32_t reserved; uint32_t num_out_res; struct cam_isp_out_port_info data[1]; }; /** * struct cam_isp_resource - A resource bundle * * @resoruce_id: resource id for the resource bundle * @length: length of the while resource blob * @handle_type: type of the resource handle * @reserved: reserved field for alignment * @res_hdl: resource handle that points to the * resource array; * */ struct cam_isp_resource { uint32_t resource_id; uint32_t length; uint32_t handle_type; uint32_t reserved; uint64_t res_hdl; }; /** * struct cam_isp_port_hfr_config - HFR configuration for this port * * @resource_type: Resource type * @subsample_pattern: Subsample pattern. Used in HFR mode. It * should be consistent with batchSize and * CAMIF programming. * @subsample_period: Subsample period. Used in HFR mode. It * should be consistent with batchSize and * CAMIF programming. * @framedrop_pattern: Framedrop pattern * @framedrop_period: Framedrop period * @reserved: Reserved for alignment */ struct cam_isp_port_hfr_config { uint32_t resource_type; uint32_t subsample_pattern; uint32_t subsample_period; uint32_t framedrop_pattern; uint32_t framedrop_period; uint32_t reserved; } __attribute__((packed)); /** * struct cam_isp_resource_hfr_config - Resource HFR configuration * * @num_ports: Number of ports * @reserved: Reserved for alignment * @port_hfr_config: HFR configuration for each IO port */ struct cam_isp_resource_hfr_config { uint32_t num_ports; uint32_t reserved; struct cam_isp_port_hfr_config port_hfr_config[1]; } __attribute__((packed)); /** * struct cam_isp_dual_split_params - dual isp spilt parameters * * @split_point: Split point information x, where (0 < x < width) * left ISP's input ends at x + righ padding and * Right ISP's input starts at x - left padding * @right_padding: Padding added past the split point for left * ISP's input * @left_padding: Padding added before split point for right * ISP's input * @reserved: Reserved filed for alignment * */ struct cam_isp_dual_split_params { uint32_t split_point; uint32_t right_padding; uint32_t left_padding; uint32_t reserved; }; /** * struct cam_isp_dual_stripe_config - stripe config per bus client * * @offset: Start horizontal offset relative to * output buffer * In UBWC mode, this value indicates the H_INIT * value in pixel * @width: Width of the stripe in bytes * @tileconfig Ubwc meta tile config. Contain the partial * tile info * @port_id: port id of ISP output * */ struct cam_isp_dual_stripe_config { uint32_t offset; uint32_t width; uint32_t tileconfig; uint32_t port_id; }; /** * struct cam_isp_dual_config - dual isp configuration * * @num_ports Number of isp output ports * @reserved Reserved field for alignment * @split_params: Inpput split parameters * @stripes: Stripe information * */ struct cam_isp_dual_config { uint32_t num_ports; uint32_t reserved; struct cam_isp_dual_split_params split_params; struct cam_isp_dual_stripe_config stripes[1]; } __attribute__((packed)); /** * struct cam_isp_clock_config - Clock configuration * * @usage_type: Usage type (Single/Dual) * @num_rdi: Number of RDI votes * @left_pix_hz: Pixel Clock for Left ISP * @right_pix_hz: Pixel Clock for Right ISP, valid only if Dual * @rdi_hz: RDI Clock. ISP clock will be max of RDI and * PIX clocks. For a particular context which ISP * HW the RDI is allocated to is not known to UMD. * Hence pass the clock and let KMD decide. */ struct cam_isp_clock_config { uint32_t usage_type; uint32_t num_rdi; uint64_t left_pix_hz; uint64_t right_pix_hz; uint64_t rdi_hz[1]; } __attribute__((packed)); /** * struct cam_isp_bw_vote - Bandwidth vote information * * @resource_id: Resource ID * @reserved: Reserved field for alignment * @cam_bw_bps: Bandwidth vote for CAMNOC * @ext_bw_bps: Bandwidth vote for path-to-DDR after CAMNOC */ struct cam_isp_bw_vote { uint32_t resource_id; uint32_t reserved; uint64_t cam_bw_bps; uint64_t ext_bw_bps; } __attribute__((packed)); /** * struct cam_isp_bw_config - Bandwidth configuration * * @usage_type: Usage type (Single/Dual) * @num_rdi: Number of RDI votes * @left_pix_vote: Bandwidth vote for left ISP * @right_pix_vote: Bandwidth vote for right ISP * @rdi_vote: RDI bandwidth requirements */ struct cam_isp_bw_config { uint32_t usage_type; uint32_t num_rdi; struct cam_isp_bw_vote left_pix_vote; struct cam_isp_bw_vote right_pix_vote; struct cam_isp_bw_vote rdi_vote[1]; } __attribute__((packed)); #endif /* __UAPI_CAM_ISP_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_isp_ife.h ================================================ #ifndef __UAPI_CAM_ISP_IFE_H__ #define __UAPI_CAM_ISP_IFE_H__ /* IFE output port resource type (global unique)*/ #define CAM_ISP_IFE_OUT_RES_BASE 0x3000 #define CAM_ISP_IFE_OUT_RES_FULL (CAM_ISP_IFE_OUT_RES_BASE + 0) #define CAM_ISP_IFE_OUT_RES_DS4 (CAM_ISP_IFE_OUT_RES_BASE + 1) #define CAM_ISP_IFE_OUT_RES_DS16 (CAM_ISP_IFE_OUT_RES_BASE + 2) #define CAM_ISP_IFE_OUT_RES_RAW_DUMP (CAM_ISP_IFE_OUT_RES_BASE + 3) #define CAM_ISP_IFE_OUT_RES_FD (CAM_ISP_IFE_OUT_RES_BASE + 4) #define CAM_ISP_IFE_OUT_RES_PDAF (CAM_ISP_IFE_OUT_RES_BASE + 5) #define CAM_ISP_IFE_OUT_RES_RDI_0 (CAM_ISP_IFE_OUT_RES_BASE + 6) #define CAM_ISP_IFE_OUT_RES_RDI_1 (CAM_ISP_IFE_OUT_RES_BASE + 7) #define CAM_ISP_IFE_OUT_RES_RDI_2 (CAM_ISP_IFE_OUT_RES_BASE + 8) #define CAM_ISP_IFE_OUT_RES_RDI_3 (CAM_ISP_IFE_OUT_RES_BASE + 9) #define CAM_ISP_IFE_OUT_RES_STATS_HDR_BE (CAM_ISP_IFE_OUT_RES_BASE + 10) #define CAM_ISP_IFE_OUT_RES_STATS_HDR_BHIST (CAM_ISP_IFE_OUT_RES_BASE + 11) #define CAM_ISP_IFE_OUT_RES_STATS_TL_BG (CAM_ISP_IFE_OUT_RES_BASE + 12) #define CAM_ISP_IFE_OUT_RES_STATS_BF (CAM_ISP_IFE_OUT_RES_BASE + 13) #define CAM_ISP_IFE_OUT_RES_STATS_AWB_BG (CAM_ISP_IFE_OUT_RES_BASE + 14) #define CAM_ISP_IFE_OUT_RES_STATS_BHIST (CAM_ISP_IFE_OUT_RES_BASE + 15) #define CAM_ISP_IFE_OUT_RES_STATS_RS (CAM_ISP_IFE_OUT_RES_BASE + 16) #define CAM_ISP_IFE_OUT_RES_STATS_CS (CAM_ISP_IFE_OUT_RES_BASE + 17) #define CAM_ISP_IFE_OUT_RES_STATS_IHIST (CAM_ISP_IFE_OUT_RES_BASE + 18) #define CAM_ISP_IFE_OUT_RES_MAX (CAM_ISP_IFE_OUT_RES_BASE + 19) /* IFE input port resource type (global unique) */ #define CAM_ISP_IFE_IN_RES_BASE 0x4000 #define CAM_ISP_IFE_IN_RES_TPG (CAM_ISP_IFE_IN_RES_BASE + 0) #define CAM_ISP_IFE_IN_RES_PHY_0 (CAM_ISP_IFE_IN_RES_BASE + 1) #define CAM_ISP_IFE_IN_RES_PHY_1 (CAM_ISP_IFE_IN_RES_BASE + 2) #define CAM_ISP_IFE_IN_RES_PHY_2 (CAM_ISP_IFE_IN_RES_BASE + 3) #define CAM_ISP_IFE_IN_RES_PHY_3 (CAM_ISP_IFE_IN_RES_BASE + 4) #define CAM_ISP_IFE_IN_RES_MAX (CAM_ISP_IFE_IN_RES_BASE + 5) #endif /* __UAPI_CAM_ISP_IFE_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_isp_vfe.h ================================================ #ifndef __UAPI_CAM_ISP_VFE_H__ #define __UAPI_CAM_ISP_VFE_H__ /* VFE output port resource type (global unique) */ #define CAM_ISP_VFE_OUT_RES_BASE 0x1000 #define CAM_ISP_VFE_OUT_RES_ENC (CAM_ISP_VFE_OUT_RES_BASE + 0) #define CAM_ISP_VFE_OUT_RES_VIEW (CAM_ISP_VFE_OUT_RES_BASE + 1) #define CAM_ISP_VFE_OUT_RES_VID (CAM_ISP_VFE_OUT_RES_BASE + 2) #define CAM_ISP_VFE_OUT_RES_RDI_0 (CAM_ISP_VFE_OUT_RES_BASE + 3) #define CAM_ISP_VFE_OUT_RES_RDI_1 (CAM_ISP_VFE_OUT_RES_BASE + 4) #define CAM_ISP_VFE_OUT_RES_RDI_2 (CAM_ISP_VFE_OUT_RES_BASE + 5) #define CAM_ISP_VFE_OUT_RES_RDI_3 (CAM_ISP_VFE_OUT_RES_BASE + 6) #define CAM_ISP_VFE_OUT_RES_STATS_AEC (CAM_ISP_VFE_OUT_RES_BASE + 7) #define CAM_ISP_VFE_OUT_RES_STATS_AF (CAM_ISP_VFE_OUT_RES_BASE + 8) #define CAM_ISP_VFE_OUT_RES_STATS_AWB (CAM_ISP_VFE_OUT_RES_BASE + 9) #define CAM_ISP_VFE_OUT_RES_STATS_RS (CAM_ISP_VFE_OUT_RES_BASE + 10) #define CAM_ISP_VFE_OUT_RES_STATS_CS (CAM_ISP_VFE_OUT_RES_BASE + 11) #define CAM_ISP_VFE_OUT_RES_STATS_IHIST (CAM_ISP_VFE_OUT_RES_BASE + 12) #define CAM_ISP_VFE_OUT_RES_STATS_SKIN (CAM_ISP_VFE_OUT_RES_BASE + 13) #define CAM_ISP_VFE_OUT_RES_STATS_BG (CAM_ISP_VFE_OUT_RES_BASE + 14) #define CAM_ISP_VFE_OUT_RES_STATS_BF (CAM_ISP_VFE_OUT_RES_BASE + 15) #define CAM_ISP_VFE_OUT_RES_STATS_BE (CAM_ISP_VFE_OUT_RES_BASE + 16) #define CAM_ISP_VFE_OUT_RES_STATS_BHIST (CAM_ISP_VFE_OUT_RES_BASE + 17) #define CAM_ISP_VFE_OUT_RES_STATS_BF_SCALE (CAM_ISP_VFE_OUT_RES_BASE + 18) #define CAM_ISP_VFE_OUT_RES_STATS_HDR_BE (CAM_ISP_VFE_OUT_RES_BASE + 19) #define CAM_ISP_VFE_OUT_RES_STATS_HDR_BHIST (CAM_ISP_VFE_OUT_RES_BASE + 20) #define CAM_ISP_VFE_OUT_RES_STATS_AEC_BG (CAM_ISP_VFE_OUT_RES_BASE + 21) #define CAM_ISP_VFE_OUT_RES_CAMIF_RAW (CAM_ISP_VFE_OUT_RES_BASE + 22) #define CAM_ISP_VFE_OUT_RES_IDEAL_RAW (CAM_ISP_VFE_OUT_RES_BASE + 23) #define CAM_ISP_VFE_OUT_RES_MAX (CAM_ISP_VFE_OUT_RES_BASE + 24) /* VFE input port_ resource type (global unique) */ #define CAM_ISP_VFE_IN_RES_BASE 0x2000 #define CAM_ISP_VFE_IN_RES_TPG (CAM_ISP_VFE_IN_RES_BASE + 0) #define CAM_ISP_VFE_IN_RES_PHY_0 (CAM_ISP_VFE_IN_RES_BASE + 1) #define CAM_ISP_VFE_IN_RES_PHY_1 (CAM_ISP_VFE_IN_RES_BASE + 2) #define CAM_ISP_VFE_IN_RES_PHY_2 (CAM_ISP_VFE_IN_RES_BASE + 3) #define CAM_ISP_VFE_IN_RES_PHY_3 (CAM_ISP_VFE_IN_RES_BASE + 4) #define CAM_ISP_VFE_IN_RES_FE (CAM_ISP_VFE_IN_RES_BASE + 5) #define CAM_ISP_VFE_IN_RES_MAX (CAM_ISP_VFE_IN_RES_BASE + 6) #endif /* __UAPI_CAM_ISP_VFE_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_jpeg.h ================================================ #ifndef __UAPI_CAM_JPEG_H__ #define __UAPI_CAM_JPEG_H__ #include "cam_defs.h" /* enc, dma, cdm(enc/dma) are used in querycap */ #define CAM_JPEG_DEV_TYPE_ENC 0 #define CAM_JPEG_DEV_TYPE_DMA 1 #define CAM_JPEG_DEV_TYPE_MAX 2 #define CAM_JPEG_NUM_DEV_PER_RES_MAX 1 /* definitions needed for jpeg aquire device */ #define CAM_JPEG_RES_TYPE_ENC 0 #define CAM_JPEG_RES_TYPE_DMA 1 #define CAM_JPEG_RES_TYPE_MAX 2 /* packet opcode types */ #define CAM_JPEG_OPCODE_ENC_UPDATE 0 #define CAM_JPEG_OPCODE_DMA_UPDATE 1 /* ENC input port resource type */ #define CAM_JPEG_ENC_INPUT_IMAGE 0x0 /* ENC output port resource type */ #define CAM_JPEG_ENC_OUTPUT_IMAGE 0x1 #define CAM_JPEG_ENC_IO_IMAGES_MAX 0x2 /* DMA input port resource type */ #define CAM_JPEG_DMA_INPUT_IMAGE 0x0 /* DMA output port resource type */ #define CAM_JPEG_DMA_OUTPUT_IMAGE 0x1 #define CAM_JPEG_DMA_IO_IMAGES_MAX 0x2 #define CAM_JPEG_IMAGE_MAX 0x2 /** * struct cam_jpeg_dev_ver - Device information for particular hw type * * This is used to get device version info of JPEG ENC, JPEG DMA * from hardware and use this info in CAM_QUERY_CAP IOCTL * * @size : Size of struct passed * @dev_type: Hardware type for the cap info(jpeg enc, jpeg dma) * @hw_ver: Major, minor and incr values of a device version */ struct cam_jpeg_dev_ver { uint32_t size; uint32_t dev_type; struct cam_hw_version hw_ver; }; /** * struct cam_jpeg_query_cap_cmd - JPEG query device capability payload * * @dev_iommu_handle: Jpeg iommu handles for secure/non secure * modes * @cdm_iommu_handle: Iommu handles for secure/non secure modes * @num_enc: Number of encoder * @num_dma: Number of dma * @dev_ver: Returned device capability array */ struct cam_jpeg_query_cap_cmd { struct cam_iommu_handle dev_iommu_handle; struct cam_iommu_handle cdm_iommu_handle; uint32_t num_enc; uint32_t num_dma; struct cam_jpeg_dev_ver dev_ver[CAM_JPEG_DEV_TYPE_MAX]; }; /** * struct cam_jpeg_res_info - JPEG output resource info * * @format: Format of the resource * @width: Width in pixels * @height: Height in lines * @fps: Fps */ struct cam_jpeg_res_info { uint32_t format; uint32_t width; uint32_t height; uint32_t fps; }; /** * struct cam_jpeg_acquire_dev_info - An JPEG device info * * @dev_type: Device type (ENC/DMA) * @reserved: Reserved Bytes * @in_res: In resource info * @in_res: Iut resource info */ struct cam_jpeg_acquire_dev_info { uint32_t dev_type; uint32_t reserved; struct cam_jpeg_res_info in_res; struct cam_jpeg_res_info out_res; }; /** * struct cam_jpeg_config_inout_param_info - JPEG Config time * input output params * * @clk_index: Input Param- clock selection index.(-1 default) * @output_size: Output Param - jpeg encode/dma output size in * bytes */ struct cam_jpeg_config_inout_param_info { int32_t clk_index; int32_t output_size; }; #endif /* __UAPI_CAM_JPEG_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_lrme.h ================================================ #ifndef __UAPI_CAM_LRME_H__ #define __UAPI_CAM_LRME_H__ #include "cam_defs.h" /* LRME Resource Types */ enum CAM_LRME_IO_TYPE { CAM_LRME_IO_TYPE_TAR, CAM_LRME_IO_TYPE_REF, CAM_LRME_IO_TYPE_RES, CAM_LRME_IO_TYPE_DS2, }; #define CAM_LRME_INPUT_PORT_TYPE_TAR (1 << 0) #define CAM_LRME_INPUT_PORT_TYPE_REF (1 << 1) #define CAM_LRME_OUTPUT_PORT_TYPE_DS2 (1 << 0) #define CAM_LRME_OUTPUT_PORT_TYPE_RES (1 << 1) #define CAM_LRME_DEV_MAX 1 struct cam_lrme_hw_version { uint32_t gen; uint32_t rev; uint32_t step; }; struct cam_lrme_dev_cap { struct cam_lrme_hw_version clc_hw_version; struct cam_lrme_hw_version bus_rd_hw_version; struct cam_lrme_hw_version bus_wr_hw_version; struct cam_lrme_hw_version top_hw_version; struct cam_lrme_hw_version top_titan_version; }; /** * struct cam_lrme_query_cap_cmd - LRME query device capability payload * * @dev_iommu_handle: LRME iommu handles for secure/non secure * modes * @cdm_iommu_handle: Iommu handles for secure/non secure modes * @num_devices: number of hardware devices * @dev_caps: Returned device capability array */ struct cam_lrme_query_cap_cmd { struct cam_iommu_handle device_iommu; struct cam_iommu_handle cdm_iommu; uint32_t num_devices; struct cam_lrme_dev_cap dev_caps[CAM_LRME_DEV_MAX]; }; struct cam_lrme_soc_info { uint64_t clock_rate; uint64_t bandwidth; uint64_t reserved[4]; }; struct cam_lrme_acquire_args { struct cam_lrme_soc_info lrme_soc_info; }; #endif /* __UAPI_CAM_LRME_H__ */ ================================================ FILE: selfdrive/camerad/include/media/cam_req_mgr.h ================================================ #ifndef __UAPI_LINUX_CAM_REQ_MGR_H #define __UAPI_LINUX_CAM_REQ_MGR_H #include #include #include #include #include #define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode" #define CAM_DEVICE_TYPE_BASE (MEDIA_ENT_F_OLD_BASE) #define CAM_VNODE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE) #define CAM_SENSOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 1) #define CAM_IFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 2) #define CAM_ICP_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 3) #define CAM_LRME_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 4) #define CAM_JPEG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 5) #define CAM_FD_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 6) #define CAM_CPAS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 7) #define CAM_CSIPHY_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 8) #define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9) #define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10) #define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11) #define CAM_EEPROM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 12) #define CAM_OIS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 13) /* cam_req_mgr hdl info */ #define CAM_REQ_MGR_HDL_IDX_POS 8 #define CAM_REQ_MGR_HDL_IDX_MASK ((1 << CAM_REQ_MGR_HDL_IDX_POS) - 1) #define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK) /** * Max handles supported by cam_req_mgr * It includes both session and device handles */ #define CAM_REQ_MGR_MAX_HANDLES 64 #define MAX_LINKS_PER_SESSION 2 /* V4L event type which user space will subscribe to */ #define V4L_EVENT_CAM_REQ_MGR_EVENT (V4L2_EVENT_PRIVATE_START + 0) /* Specific event ids to get notified in user space */ #define V4L_EVENT_CAM_REQ_MGR_SOF 0 #define V4L_EVENT_CAM_REQ_MGR_ERROR 1 #define V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS 2 /* SOF Event status */ #define CAM_REQ_MGR_SOF_EVENT_SUCCESS 0 #define CAM_REQ_MGR_SOF_EVENT_ERROR 1 /* Link control operations */ #define CAM_REQ_MGR_LINK_ACTIVATE 0 #define CAM_REQ_MGR_LINK_DEACTIVATE 1 /** * Request Manager : flush_type * @CAM_REQ_MGR_FLUSH_TYPE_ALL: Req mgr will remove all the pending * requests from input/processing queue. * @CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ: Req mgr will remove only particular * request id from input/processing queue. * @CAM_REQ_MGR_FLUSH_TYPE_MAX: Max number of the flush type * @opcode: CAM_REQ_MGR_FLUSH_REQ */ #define CAM_REQ_MGR_FLUSH_TYPE_ALL 0 #define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1 #define CAM_REQ_MGR_FLUSH_TYPE_MAX 2 /** * Request Manager : Sync Mode type * @CAM_REQ_MGR_SYNC_MODE_NO_SYNC: Req mgr will apply non-sync mode for this * request. * @CAM_REQ_MGR_SYNC_MODE_SYNC: Req mgr will apply sync mode for this request. */ #define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0 #define CAM_REQ_MGR_SYNC_MODE_SYNC 1 /** * struct cam_req_mgr_event_data * @session_hdl: session handle * @link_hdl: link handle * @frame_id: frame id * @reserved: reserved for 64 bit aligngment * @req_id: request id * @tv_sec: timestamp in seconds * @tv_usec: timestamp in micro seconds */ struct cam_req_mgr_event_data { int32_t session_hdl; int32_t link_hdl; int32_t frame_id; int32_t reserved; int64_t req_id; uint64_t tv_sec; uint64_t tv_usec; }; /** * struct cam_req_mgr_session_info * @session_hdl: In/Output param - session_handle * @opcode1: CAM_REQ_MGR_CREATE_SESSION * @opcode2: CAM_REQ_MGR_DESTROY_SESSION */ struct cam_req_mgr_session_info { int32_t session_hdl; int32_t reserved; }; /** * struct cam_req_mgr_link_info * @session_hdl: Input param - Identifier for CSL session * @num_devices: Input Param - Num of devices to be linked * @dev_hdls: Input param - List of device handles to be linked * @link_hdl: Output Param -Identifier for link * @opcode: CAM_REQ_MGR_LINK */ struct cam_req_mgr_link_info { int32_t session_hdl; uint32_t num_devices; int32_t dev_hdls[CAM_REQ_MGR_MAX_HANDLES]; int32_t link_hdl; }; /** * struct cam_req_mgr_unlink_info * @session_hdl: input param - session handle * @link_hdl: input param - link handle * @opcode: CAM_REQ_MGR_UNLINK */ struct cam_req_mgr_unlink_info { int32_t session_hdl; int32_t link_hdl; }; /** * struct cam_req_mgr_flush_info * @brief: User can tell drivers to flush a particular request id or * flush all requests from its pending processing queue. Flush is a * blocking call and driver shall ensure all requests are flushed * before returning. * @session_hdl: Input param - Identifier for CSL session * @link_hdl: Input Param -Identifier for link * @flush_type: User can cancel a particular req id or can flush * all requests in queue * @reserved: reserved for 64 bit aligngment * @req_id: field is valid only if flush type is cancel request * for flush all this field value is not considered. * @opcode: CAM_REQ_MGR_FLUSH_REQ */ struct cam_req_mgr_flush_info { int32_t session_hdl; int32_t link_hdl; uint32_t flush_type; uint32_t reserved; int64_t req_id; }; /** struct cam_req_mgr_sched_info * @session_hdl: Input param - Identifier for CSL session * @link_hdl: Input Param -Identifier for link * inluding itself. * @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this * flag is set. * @sync_mode: Type of Sync mode for this request * @req_id: Input Param - Request Id from which all requests will be flushed */ struct cam_req_mgr_sched_request { int32_t session_hdl; int32_t link_hdl; int32_t bubble_enable; int32_t sync_mode; int64_t req_id; }; /** * struct cam_req_mgr_sync_mode * @session_hdl: Input param - Identifier for CSL session * @sync_mode: Input Param - Type of sync mode * @num_links: Input Param - Num of links in sync mode (Valid only * when sync_mode is one of SYNC enabled modes) * @link_hdls: Input Param - Array of link handles to be in sync mode * (Valid only when sync_mode is one of SYNC * enabled modes) * @master_link_hdl: Input Param - To dictate which link's SOF drives system * (Valid only when sync_mode is one of SYNC * enabled modes) * * @opcode: CAM_REQ_MGR_SYNC_MODE */ struct cam_req_mgr_sync_mode { int32_t session_hdl; int32_t sync_mode; int32_t num_links; int32_t link_hdls[MAX_LINKS_PER_SESSION]; int32_t master_link_hdl; int32_t reserved; }; /** * struct cam_req_mgr_link_control * @ops: Link operations: activate/deactive * @session_hdl: Input param - Identifier for CSL session * @num_links: Input Param - Num of links * @reserved: reserved field * @link_hdls: Input Param - Links to be activated/deactivated * * @opcode: CAM_REQ_MGR_LINK_CONTROL */ struct cam_req_mgr_link_control { int32_t ops; int32_t session_hdl; int32_t num_links; int32_t reserved; int32_t link_hdls[MAX_LINKS_PER_SESSION]; }; /** * cam_req_mgr specific opcode ids */ #define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1) #define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2) #define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3) #define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4) #define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5) #define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6) #define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7) #define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8) #define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9) #define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10) #define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11) #define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12) #define CAM_REQ_MGR_LINK_CONTROL (CAM_COMMON_OPCODE_MAX + 13) /* end of cam_req_mgr opcodes */ #define CAM_MEM_FLAG_HW_READ_WRITE (1<<0) #define CAM_MEM_FLAG_HW_READ_ONLY (1<<1) #define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2) #define CAM_MEM_FLAG_KMD_ACCESS (1<<3) #define CAM_MEM_FLAG_UMD_ACCESS (1<<4) #define CAM_MEM_FLAG_PROTECTED_MODE (1<<5) #define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6) #define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7) #define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8) #define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9) #define CAM_MEM_FLAG_CACHE (1<<10) #define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11) #define CAM_MEM_MMU_MAX_HANDLE 16 /* Maximum allowed buffers in existence */ #define CAM_MEM_BUFQ_MAX 1024 #define CAM_MEM_MGR_SECURE_BIT_POS 15 #define CAM_MEM_MGR_HDL_IDX_SIZE 15 #define CAM_MEM_MGR_HDL_FD_SIZE 16 #define CAM_MEM_MGR_HDL_IDX_END_POS 16 #define CAM_MEM_MGR_HDL_FD_END_POS 32 #define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1) #define GET_MEM_HANDLE(idx, fd) \ ((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \ (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \ #define GET_FD_FROM_HANDLE(hdl) \ (hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)) \ #define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK) #define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \ ((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : \ ((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS))) #define CAM_MEM_MGR_IS_SECURE_HDL(hdl) \ (((hdl) & \ (1<> CAM_MEM_MGR_SECURE_BIT_POS) /** * memory allocation type */ #define CAM_MEM_DMA_NONE 0 #define CAM_MEM_DMA_BIDIRECTIONAL 1 #define CAM_MEM_DMA_TO_DEVICE 2 #define CAM_MEM_DMA_FROM_DEVICE 3 /** * memory cache operation */ #define CAM_MEM_CLEAN_CACHE 1 #define CAM_MEM_INV_CACHE 2 #define CAM_MEM_CLEAN_INV_CACHE 3 /** * struct cam_mem_alloc_out_params * @buf_handle: buffer handle * @fd: output buffer file descriptor * @vaddr: virtual address pointer */ struct cam_mem_alloc_out_params { uint32_t buf_handle; int32_t fd; uint64_t vaddr; }; /** * struct cam_mem_map_out_params * @buf_handle: buffer handle * @reserved: reserved for future * @vaddr: virtual address pointer */ struct cam_mem_map_out_params { uint32_t buf_handle; uint32_t reserved; uint64_t vaddr; }; /** * struct cam_mem_mgr_alloc_cmd * @len: size of buffer to allocate * @align: alignment of the buffer * @mmu_hdls: array of mmu handles * @num_hdl: number of handles * @flags: flags of the buffer * @out: out params */ /* CAM_REQ_MGR_ALLOC_BUF */ struct cam_mem_mgr_alloc_cmd { uint64_t len; uint64_t align; int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE]; uint32_t num_hdl; uint32_t flags; struct cam_mem_alloc_out_params out; }; /** * struct cam_mem_mgr_map_cmd * @mmu_hdls: array of mmu handles * @num_hdl: number of handles * @flags: flags of the buffer * @fd: output buffer file descriptor * @reserved: reserved field * @out: out params */ /* CAM_REQ_MGR_MAP_BUF */ struct cam_mem_mgr_map_cmd { int32_t mmu_hdls[CAM_MEM_MMU_MAX_HANDLE]; uint32_t num_hdl; uint32_t flags; int32_t fd; uint32_t reserved; struct cam_mem_map_out_params out; }; /** * struct cam_mem_mgr_map_cmd * @buf_handle: buffer handle * @reserved: reserved field */ /* CAM_REQ_MGR_RELEASE_BUF */ struct cam_mem_mgr_release_cmd { int32_t buf_handle; uint32_t reserved; }; /** * struct cam_mem_mgr_map_cmd * @buf_handle: buffer handle * @ops: cache operations */ /* CAM_REQ_MGR_CACHE_OPS */ struct cam_mem_cache_ops_cmd { int32_t buf_handle; uint32_t mem_cache_ops; }; /** * Request Manager : error message type * @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session * @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal * @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal */ #define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0 #define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1 #define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2 /** * struct cam_req_mgr_error_msg * @error_type: type of error * @request_id: request id of frame * @device_hdl: device handle * @linke_hdl: link_hdl * @resource_size: size of the resource */ struct cam_req_mgr_error_msg { uint32_t error_type; uint32_t request_id; int32_t device_hdl; int32_t link_hdl; uint64_t resource_size; }; /** * struct cam_req_mgr_frame_msg * @request_id: request id of the frame * @frame_id: frame id of the frame * @timestamp: timestamp of the frame * @link_hdl: link handle associated with this message * @sof_status: sof status success or fail */ struct cam_req_mgr_frame_msg { uint64_t request_id; uint64_t frame_id; uint64_t timestamp; int32_t link_hdl; uint32_t sof_status; }; /** * struct cam_req_mgr_message * @session_hdl: session to which the frame belongs to * @reserved: reserved field * @u: union which can either be error or frame message */ struct cam_req_mgr_message { int32_t session_hdl; int32_t reserved; union { struct cam_req_mgr_error_msg err_msg; struct cam_req_mgr_frame_msg frame_msg; } u; }; #endif /* __UAPI_LINUX_CAM_REQ_MGR_H */ ================================================ FILE: selfdrive/camerad/include/media/cam_sensor.h ================================================ #ifndef __UAPI_CAM_SENSOR_H__ #define __UAPI_CAM_SENSOR_H__ #include #include #include #define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1) #define CAM_FLASH_MAX_LED_TRIGGERS 3 #define MAX_OIS_NAME_SIZE 32 #define CAM_CSIPHY_SECURE_MODE_ENABLED 1 /** * struct cam_sensor_query_cap - capabilities info for sensor * * @slot_info : Indicates about the slotId or cell Index * @secure_camera : Camera is in secure/Non-secure mode * @pos_pitch : Sensor position pitch * @pos_roll : Sensor position roll * @pos_yaw : Sensor position yaw * @actuator_slot_id : Actuator slot id which connected to sensor * @eeprom_slot_id : EEPROM slot id which connected to sensor * @ois_slot_id : OIS slot id which connected to sensor * @flash_slot_id : Flash slot id which connected to sensor * @csiphy_slot_id : CSIphy slot id which connected to sensor * */ struct cam_sensor_query_cap { uint32_t slot_info; uint32_t secure_camera; uint32_t pos_pitch; uint32_t pos_roll; uint32_t pos_yaw; uint32_t actuator_slot_id; uint32_t eeprom_slot_id; uint32_t ois_slot_id; uint32_t flash_slot_id; uint32_t csiphy_slot_id; } __attribute__((packed)); /** * struct cam_csiphy_query_cap - capabilities info for csiphy * * @slot_info : Indicates about the slotId or cell Index * @version : CSIphy version * @clk lane : Of the 5 lanes, informs lane configured * as clock lane * @reserved */ struct cam_csiphy_query_cap { uint32_t slot_info; uint32_t version; uint32_t clk_lane; uint32_t reserved; } __attribute__((packed)); /** * struct cam_actuator_query_cap - capabilities info for actuator * * @slot_info : Indicates about the slotId or cell Index * @reserved */ struct cam_actuator_query_cap { uint32_t slot_info; uint32_t reserved; } __attribute__((packed)); /** * struct cam_eeprom_query_cap_t - capabilities info for eeprom * * @slot_info : Indicates about the slotId or cell Index * @eeprom_kernel_probe : Indicates about the kernel or userspace probe */ struct cam_eeprom_query_cap_t { uint32_t slot_info; uint16_t eeprom_kernel_probe; uint16_t reserved; } __attribute__((packed)); /** * struct cam_ois_query_cap_t - capabilities info for ois * * @slot_info : Indicates about the slotId or cell Index */ struct cam_ois_query_cap_t { uint32_t slot_info; uint16_t reserved; } __attribute__((packed)); /** * struct cam_cmd_i2c_info - Contains slave I2C related info * * @slave_addr : Slave address * @i2c_freq_mode : 4 bits are used for I2c freq mode * @cmd_type : Explains type of command */ struct cam_cmd_i2c_info { uint16_t slave_addr; uint8_t i2c_freq_mode; uint8_t cmd_type; } __attribute__((packed)); /** * struct cam_ois_opcode - Contains OIS opcode * * @prog : OIS FW prog register address * @coeff : OIS FW coeff register address * @pheripheral : OIS pheripheral * @memory : OIS memory */ struct cam_ois_opcode { uint32_t prog; uint32_t coeff; uint32_t pheripheral; uint32_t memory; } __attribute__((packed)); /** * struct cam_cmd_ois_info - Contains OIS slave info * * @slave_addr : OIS i2c slave address * @i2c_freq_mode : i2c frequency mode * @cmd_type : Explains type of command * @ois_fw_flag : indicates if fw is present or not * @is_ois_calib : indicates the calibration data is available * @ois_name : OIS name * @opcode : opcode */ struct cam_cmd_ois_info { uint16_t slave_addr; uint8_t i2c_freq_mode; uint8_t cmd_type; uint8_t ois_fw_flag; uint8_t is_ois_calib; char ois_name[MAX_OIS_NAME_SIZE]; struct cam_ois_opcode opcode; } __attribute__((packed)); /** * struct cam_cmd_probe - Contains sensor slave info * * @data_type : Slave register data type * @addr_type : Slave register address type * @op_code : Don't Care * @cmd_type : Explains type of command * @reg_addr : Slave register address * @expected_data : Data expected at slave register address * @data_mask : Data mask if only few bits are valid * @camera_id : Indicates the slot to which camera * needs to be probed * @reserved */ struct cam_cmd_probe { uint8_t data_type; uint8_t addr_type; uint8_t op_code; uint8_t cmd_type; uint32_t reg_addr; uint32_t expected_data; uint32_t data_mask; uint16_t camera_id; uint16_t reserved; } __attribute__((packed)); /** * struct cam_power_settings - Contains sensor power setting info * * @power_seq_type : Type of power sequence * @reserved * @config_val_low : Lower 32 bit value configuration value * @config_val_high : Higher 32 bit value configuration value * */ struct cam_power_settings { uint16_t power_seq_type; uint16_t reserved; uint32_t config_val_low; uint32_t config_val_high; } __attribute__((packed)); /** * struct cam_cmd_power - Explains about the power settings * * @count : Number of power settings follows * @reserved * @cmd_type : Explains type of command * @power_settings : Contains power setting info */ struct cam_cmd_power { uint16_t count; uint8_t reserved; uint8_t cmd_type; struct cam_power_settings power_settings[1]; } __attribute__((packed)); /** * struct i2c_rdwr_header - header of READ/WRITE I2C command * * @ count : Number of registers / data / reg-data pairs * @ op_code : Operation code * @ cmd_type : Command buffer type * @ data_type : I2C data type * @ addr_type : I2C address type * @ reserved */ struct i2c_rdwr_header { uint16_t count; uint8_t op_code; uint8_t cmd_type; uint8_t data_type; uint8_t addr_type; uint16_t reserved; } __attribute__((packed)); /** * struct i2c_random_wr_payload - payload for I2C random write * * @ reg_addr : Register address * @ reg_data : Register data * */ struct i2c_random_wr_payload { uint32_t reg_addr; uint32_t reg_data; } __attribute__((packed)); /** * struct cam_cmd_i2c_random_wr - I2C random write command * @ header : header of READ/WRITE I2C command * @ random_wr_payload : payload for I2C random write */ struct cam_cmd_i2c_random_wr { struct i2c_rdwr_header header; struct i2c_random_wr_payload random_wr_payload[1]; } __attribute__((packed)); /** * struct cam_cmd_read - I2C read command * @ reg_data : Register data * @ reserved */ struct cam_cmd_read { uint32_t reg_data; uint32_t reserved; } __attribute__((packed)); /** * struct cam_cmd_i2c_continuous_wr - I2C continuous write command * @ header : header of READ/WRITE I2C command * @ reg_addr : Register address * @ data_read : I2C read command */ struct cam_cmd_i2c_continuous_wr { struct i2c_rdwr_header header; uint32_t reg_addr; struct cam_cmd_read data_read[1]; } __attribute__((packed)); /** * struct cam_cmd_i2c_random_rd - I2C random read command * @ header : header of READ/WRITE I2C command * @ data_read : I2C read command */ struct cam_cmd_i2c_random_rd { struct i2c_rdwr_header header; struct cam_cmd_read data_read[1]; } __attribute__((packed)); /** * struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command * @ header : header of READ/WRITE I2C command * @ reg_addr : Register address * */ struct cam_cmd_i2c_continuous_rd { struct i2c_rdwr_header header; uint32_t reg_addr; } __attribute__((packed)); /** * struct cam_cmd_conditional_wait - Conditional wait command * @data_type : Data type * @addr_type : Address type * @op_code : Opcode * @cmd_type : Explains type of command * @timeout : Timeout for retries * @reserved * @reg_addr : Register Address * @reg_data : Register data * @data_mask : Data mask if only few bits are valid * @camera_id : Indicates the slot to which camera * needs to be probed * */ struct cam_cmd_conditional_wait { uint8_t data_type; uint8_t addr_type; uint8_t op_code; uint8_t cmd_type; uint16_t timeout; uint16_t reserved; uint32_t reg_addr; uint32_t reg_data; uint32_t data_mask; } __attribute__((packed)); /** * struct cam_cmd_unconditional_wait - Un-conditional wait command * @delay : Delay * @op_code : Opcode * @cmd_type : Explains type of command */ struct cam_cmd_unconditional_wait { int16_t delay; uint8_t op_code; uint8_t cmd_type; } __attribute__((packed)); /** * cam_csiphy_info: Provides cmdbuffer structre * @lane_mask : Lane mask details * @lane_assign : Lane sensor will be using * @csiphy_3phase : Total number of lanes * @combo_mode : Info regarding combo_mode is enable / disable * @lane_cnt : Total number of lanes * @secure_mode : Secure mode flag to enable / disable * @3phase : Details whether 3Phase / 2Phase operation * @settle_time : Settling time in ms * @data_rate : Data rate * */ struct cam_csiphy_info { uint16_t lane_mask; uint16_t lane_assign; uint8_t csiphy_3phase; uint8_t combo_mode; uint8_t lane_cnt; uint8_t secure_mode; uint64_t settle_time; uint64_t data_rate; } __attribute__((packed)); /** * cam_csiphy_acquire_dev_info : Information needed for * csiphy at the time of acquire * @combo_mode : Indicates the device mode of operation * @reserved * */ struct cam_csiphy_acquire_dev_info { uint32_t combo_mode; uint32_t reserved; } __attribute__((packed)); /** * cam_sensor_acquire_dev : Updates sensor acuire cmd * @device_handle : Updates device handle * @session_handle : Session handle for acquiring device * @handle_type : Resource handle type * @reserved * @info_handle : Handle to additional info * needed for sensor sub modules * */ struct cam_sensor_acquire_dev { uint32_t session_handle; uint32_t device_handle; uint32_t handle_type; uint32_t reserved; uint64_t info_handle; } __attribute__((packed)); /** * cam_sensor_streamon_dev : StreamOn command for the sensor * @session_handle : Session handle for acquiring device * @device_handle : Updates device handle * @handle_type : Resource handle type * @reserved * @info_handle : Information Needed at the time of streamOn * */ struct cam_sensor_streamon_dev { uint32_t session_handle; uint32_t device_handle; uint32_t handle_type; uint32_t reserved; uint64_t info_handle; } __attribute__((packed)); /** * struct cam_flash_init : Init command for the flash * @flash_type : flash hw type * @reserved * @cmd_type : command buffer type */ struct cam_flash_init { uint8_t flash_type; uint16_t reserved; uint8_t cmd_type; } __attribute__((packed)); /** * struct cam_flash_set_rer : RedEyeReduction command buffer * * @count : Number of flash leds * @opcode : Command buffer opcode * CAM_FLASH_FIRE_RER * @cmd_type : command buffer operation type * @num_iteration : Number of led turn on/off sequence * @reserved * @led_on_delay_ms : flash led turn on time in ms * @led_off_delay_ms : flash led turn off time in ms * @led_current_ma : flash led current in ma * */ struct cam_flash_set_rer { uint16_t count; uint8_t opcode; uint8_t cmd_type; uint16_t num_iteration; uint16_t reserved; uint32_t led_on_delay_ms; uint32_t led_off_delay_ms; uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS]; } __attribute__((packed)); /** * struct cam_flash_set_on_off : led turn on/off command buffer * * @count : Number of Flash leds * @opcode : command buffer opcodes * CAM_FLASH_FIRE_LOW * CAM_FLASH_FIRE_HIGH * CAM_FLASH_OFF * @cmd_type : command buffer operation type * @led_current_ma : flash led current in ma * */ struct cam_flash_set_on_off { uint16_t count; uint8_t opcode; uint8_t cmd_type; uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS]; } __attribute__((packed)); /** * struct cam_flash_query_curr : query current command buffer * * @reserved * @opcode : command buffer opcode * @cmd_type : command buffer operation type * @query_current_ma : battery current in ma * */ struct cam_flash_query_curr { uint16_t reserved; uint8_t opcode; uint8_t cmd_type; uint32_t query_current_ma; } __attribute__ ((packed)); /** * struct cam_flash_query_cap : capabilities info for flash * * @slot_info : Indicates about the slotId or cell Index * @max_current_flash : max supported current for flash * @max_duration_flash : max flash turn on duration * @max_current_torch : max supported current for torch * */ struct cam_flash_query_cap_info { uint32_t slot_info; uint32_t max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS]; uint32_t max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS]; uint32_t max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS]; } __attribute__ ((packed)); #endif ================================================ FILE: selfdrive/camerad/include/media/cam_sensor_cmn_header.h ================================================ /* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef _CAM_SENSOR_CMN_HEADER_ #define _CAM_SENSOR_CMN_HEADER_ #include #include #include #define MAX_REGULATOR 5 #define MAX_POWER_CONFIG 12 #define MAX_PER_FRAME_ARRAY 32 #define BATCH_SIZE_MAX 16 #define CAM_SENSOR_NAME "cam-sensor" #define CAM_ACTUATOR_NAME "cam-actuator" #define CAM_CSIPHY_NAME "cam-csiphy" #define CAM_FLASH_NAME "cam-flash" #define CAM_EEPROM_NAME "cam-eeprom" #define CAM_OIS_NAME "cam-ois" #define MAX_SYSTEM_PIPELINE_DELAY 2 #define CAM_PKT_NOP_OPCODE 127 enum camera_sensor_cmd_type { CAMERA_SENSOR_CMD_TYPE_INVALID, CAMERA_SENSOR_CMD_TYPE_PROBE, CAMERA_SENSOR_CMD_TYPE_PWR_UP, CAMERA_SENSOR_CMD_TYPE_PWR_DOWN, CAMERA_SENSOR_CMD_TYPE_I2C_INFO, CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR, CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_RD, CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR, CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD, CAMERA_SENSOR_CMD_TYPE_WAIT, CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO, CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE, CAMERA_SENSOR_FLASH_CMD_TYPE_RER, CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR, CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET, CAMERA_SENSOR_CMD_TYPE_RD_DATA, CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE, CAMERA_SENSOR_CMD_TYPE_MAX, }; enum camera_sensor_i2c_op_code { CAMERA_SENSOR_I2C_OP_INVALID, CAMERA_SENSOR_I2C_OP_RNDM_WR, CAMERA_SENSOR_I2C_OP_RNDM_WR_VERF, CAMERA_SENSOR_I2C_OP_CONT_WR_BRST, CAMERA_SENSOR_I2C_OP_CONT_WR_BRST_VERF, CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN, CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN_VERF, CAMERA_SENSOR_I2C_OP_MAX, }; enum camera_sensor_wait_op_code { CAMERA_SENSOR_WAIT_OP_INVALID, CAMERA_SENSOR_WAIT_OP_COND, CAMERA_SENSOR_WAIT_OP_HW_UCND, CAMERA_SENSOR_WAIT_OP_SW_UCND, CAMERA_SENSOR_WAIT_OP_MAX, }; enum camera_flash_opcode { CAMERA_SENSOR_FLASH_OP_INVALID, CAMERA_SENSOR_FLASH_OP_OFF, CAMERA_SENSOR_FLASH_OP_FIRELOW, CAMERA_SENSOR_FLASH_OP_FIREHIGH, CAMERA_SENSOR_FLASH_OP_MAX, }; enum camera_sensor_i2c_type { CAMERA_SENSOR_I2C_TYPE_INVALID, CAMERA_SENSOR_I2C_TYPE_BYTE, CAMERA_SENSOR_I2C_TYPE_WORD, CAMERA_SENSOR_I2C_TYPE_3B, CAMERA_SENSOR_I2C_TYPE_DWORD, CAMERA_SENSOR_I2C_TYPE_MAX, }; enum i2c_freq_mode { I2C_STANDARD_MODE, I2C_FAST_MODE, I2C_CUSTOM_MODE, I2C_FAST_PLUS_MODE, I2C_MAX_MODES, }; enum position_roll { ROLL_0 = 0, ROLL_90 = 90, ROLL_180 = 180, ROLL_270 = 270, ROLL_INVALID = 360, }; enum position_yaw { FRONT_CAMERA_YAW = 0, REAR_CAMERA_YAW = 180, INVALID_YAW = 360, }; enum position_pitch { LEVEL_PITCH = 0, INVALID_PITCH = 360, }; enum sensor_sub_module { SUB_MODULE_SENSOR, SUB_MODULE_ACTUATOR, SUB_MODULE_EEPROM, SUB_MODULE_LED_FLASH, SUB_MODULE_CSID, SUB_MODULE_CSIPHY, SUB_MODULE_OIS, SUB_MODULE_EXT, SUB_MODULE_MAX, }; enum msm_camera_power_seq_type { SENSOR_MCLK, SENSOR_VANA, SENSOR_VDIG, SENSOR_VIO, SENSOR_VAF, SENSOR_VAF_PWDM, SENSOR_CUSTOM_REG1, SENSOR_CUSTOM_REG2, SENSOR_RESET, SENSOR_STANDBY, SENSOR_CUSTOM_GPIO1, SENSOR_CUSTOM_GPIO2, SENSOR_SEQ_TYPE_MAX, }; enum cam_sensor_packet_opcodes { CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON, CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE, CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG, CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE, CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG, CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMOFF, CAM_SENSOR_PACKET_OPCODE_SENSOR_NOP = 127 }; enum cam_actuator_packet_opcodes { CAM_ACTUATOR_PACKET_OPCODE_INIT, CAM_ACTUATOR_PACKET_AUTO_MOVE_LENS, CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS }; enum cam_eeprom_packet_opcodes { CAM_EEPROM_PACKET_OPCODE_INIT }; enum cam_ois_packet_opcodes { CAM_OIS_PACKET_OPCODE_INIT, CAM_OIS_PACKET_OPCODE_OIS_CONTROL }; enum msm_bus_perf_setting { S_INIT, S_PREVIEW, S_VIDEO, S_CAPTURE, S_ZSL, S_STEREO_VIDEO, S_STEREO_CAPTURE, S_DEFAULT, S_LIVESHOT, S_DUAL, S_EXIT }; enum msm_camera_device_type_t { MSM_CAMERA_I2C_DEVICE, MSM_CAMERA_PLATFORM_DEVICE, MSM_CAMERA_SPI_DEVICE, }; enum cam_flash_device_type { CAMERA_FLASH_DEVICE_TYPE_PMIC = 0, CAMERA_FLASH_DEVICE_TYPE_I2C, CAMERA_FLASH_DEVICE_TYPE_GPIO, }; enum cci_i2c_master_t { MASTER_0, MASTER_1, MASTER_MAX, }; enum camera_vreg_type { VREG_TYPE_DEFAULT, VREG_TYPE_CUSTOM, }; enum cam_sensor_i2c_cmd_type { CAM_SENSOR_I2C_WRITE_RANDOM, CAM_SENSOR_I2C_WRITE_BURST, CAM_SENSOR_I2C_WRITE_SEQ, CAM_SENSOR_I2C_READ, CAM_SENSOR_I2C_POLL }; struct common_header { uint16_t first_word; uint8_t third_byte; uint8_t cmd_type; }; struct camera_vreg_t { const char *reg_name; int min_voltage; int max_voltage; int op_mode; uint32_t delay; const char *custom_vreg_name; enum camera_vreg_type type; }; struct msm_camera_gpio_num_info { uint16_t gpio_num[SENSOR_SEQ_TYPE_MAX]; uint8_t valid[SENSOR_SEQ_TYPE_MAX]; }; struct msm_cam_clk_info { const char *clk_name; long clk_rate; uint32_t delay; }; struct msm_pinctrl_info { struct pinctrl *pinctrl; struct pinctrl_state *gpio_state_active; struct pinctrl_state *gpio_state_suspend; bool use_pinctrl; }; struct cam_sensor_i2c_reg_array { uint32_t reg_addr; uint32_t reg_data; uint32_t delay; uint32_t data_mask; }; struct cam_sensor_i2c_reg_setting { struct cam_sensor_i2c_reg_array *reg_setting; unsigned short size; enum camera_sensor_i2c_type addr_type; enum camera_sensor_i2c_type data_type; unsigned short delay; }; /*struct i2c_settings_list { struct cam_sensor_i2c_reg_setting i2c_settings; enum cam_sensor_i2c_cmd_type op_code; struct list_head list; }; struct i2c_settings_array { struct list_head list_head; int32_t is_settings_valid; int64_t request_id; }; struct i2c_data_settings { struct i2c_settings_array init_settings; struct i2c_settings_array config_settings; struct i2c_settings_array streamon_settings; struct i2c_settings_array streamoff_settings; struct i2c_settings_array *per_frame; };*/ struct cam_sensor_power_ctrl_t { struct device *dev; struct cam_sensor_power_setting *power_setting; uint16_t power_setting_size; struct cam_sensor_power_setting *power_down_setting; uint16_t power_down_setting_size; struct msm_camera_gpio_num_info *gpio_num_info; struct msm_pinctrl_info pinctrl_info; uint8_t cam_pinctrl_status; }; struct cam_camera_slave_info { uint16_t sensor_slave_addr; uint16_t sensor_id_reg_addr; uint16_t sensor_id; uint16_t sensor_id_mask; }; struct msm_sensor_init_params { int modes_supported; unsigned int sensor_mount_angle; }; enum msm_sensor_camera_id_t { CAMERA_0, CAMERA_1, CAMERA_2, CAMERA_3, CAMERA_4, CAMERA_5, CAMERA_6, MAX_CAMERAS, }; struct msm_sensor_id_info_t { unsigned short sensor_id_reg_addr; unsigned short sensor_id; unsigned short sensor_id_mask; }; enum msm_sensor_output_format_t { MSM_SENSOR_BAYER, MSM_SENSOR_YCBCR, MSM_SENSOR_META, }; struct cam_sensor_power_setting { enum msm_camera_power_seq_type seq_type; unsigned short seq_val; long config_val; unsigned short delay; void *data[10]; }; struct cam_sensor_board_info { struct cam_camera_slave_info slave_info; int32_t sensor_mount_angle; int32_t secure_mode; int modes_supported; int32_t pos_roll; int32_t pos_yaw; int32_t pos_pitch; int32_t subdev_id[SUB_MODULE_MAX]; int32_t subdev_intf[SUB_MODULE_MAX]; const char *misc_regulator; struct cam_sensor_power_ctrl_t power_info; }; enum msm_camera_vreg_name_t { CAM_VDIG, CAM_VIO, CAM_VANA, CAM_VAF, CAM_V_CUSTOM1, CAM_V_CUSTOM2, CAM_VREG_MAX, }; struct msm_camera_gpio_conf { void *cam_gpiomux_conf_tbl; uint8_t cam_gpiomux_conf_tbl_size; struct gpio *cam_gpio_common_tbl; uint8_t cam_gpio_common_tbl_size; struct gpio *cam_gpio_req_tbl; uint8_t cam_gpio_req_tbl_size; uint32_t gpio_no_mux; uint32_t *camera_off_table; uint8_t camera_off_table_size; uint32_t *camera_on_table; uint8_t camera_on_table_size; struct msm_camera_gpio_num_info *gpio_num_info; }; /*for tof camera Begin*/ enum EEPROM_DATA_OP_T{ EEPROM_DEFAULT_DATA = 0, EEPROM_INIT_DATA, EEPROM_CONFIG_DATA, EEPROM_STREAMON_DATA, EEPROM_STREAMOFF_DATA, EEPROM_OTHER_DATA, }; /*for tof camera End*/ #endif /* _CAM_SENSOR_CMN_HEADER_ */ ================================================ FILE: selfdrive/camerad/include/media/cam_sync.h ================================================ #ifndef __UAPI_CAM_SYNC_H__ #define __UAPI_CAM_SYNC_H__ #include #include #include #include #define CAM_SYNC_DEVICE_NAME "cam_sync_device" /* V4L event which user space will subscribe to */ #define CAM_SYNC_V4L_EVENT (V4L2_EVENT_PRIVATE_START + 0) /* Specific event ids to get notified in user space */ #define CAM_SYNC_V4L_EVENT_ID_CB_TRIG 0 /* Size of opaque payload sent to kernel for safekeeping until signal time */ #define CAM_SYNC_USER_PAYLOAD_SIZE 2 /* Device type for sync device needed for device discovery */ #define CAM_SYNC_DEVICE_TYPE (MEDIA_ENT_F_OLD_BASE) #define CAM_SYNC_GET_PAYLOAD_PTR(ev, type) \ (type *)((char *)ev.u.data + sizeof(struct cam_sync_ev_header)) #define CAM_SYNC_GET_HEADER_PTR(ev) \ ((struct cam_sync_ev_header *)ev.u.data) #define CAM_SYNC_STATE_INVALID 0 #define CAM_SYNC_STATE_ACTIVE 1 #define CAM_SYNC_STATE_SIGNALED_SUCCESS 2 #define CAM_SYNC_STATE_SIGNALED_ERROR 3 /** * struct cam_sync_ev_header - Event header for sync event notification * * @sync_obj: Sync object * @status: Status of the object */ struct cam_sync_ev_header { int32_t sync_obj; int32_t status; }; /** * struct cam_sync_info - Sync object creation information * * @name: Optional string representation of the sync object * @sync_obj: Sync object returned after creation in kernel */ struct cam_sync_info { char name[64]; int32_t sync_obj; }; /** * struct cam_sync_signal - Sync object signaling struct * * @sync_obj: Sync object to be signaled * @sync_state: State of the sync object to which it should be signaled */ struct cam_sync_signal { int32_t sync_obj; uint32_t sync_state; }; /** * struct cam_sync_merge - Merge information for sync objects * * @sync_objs: Pointer to sync objects * @num_objs: Number of objects in the array * @merged: Merged sync object */ struct cam_sync_merge { __u64 sync_objs; uint32_t num_objs; int32_t merged; }; /** * struct cam_sync_userpayload_info - Payload info from user space * * @sync_obj: Sync object for which payload has to be registered for * @reserved: Reserved * @payload: Pointer to user payload */ struct cam_sync_userpayload_info { int32_t sync_obj; uint32_t reserved; __u64 payload[CAM_SYNC_USER_PAYLOAD_SIZE]; }; /** * struct cam_sync_wait - Sync object wait information * * @sync_obj: Sync object to wait on * @reserved: Reserved * @timeout_ms: Timeout in milliseconds */ struct cam_sync_wait { int32_t sync_obj; uint32_t reserved; uint64_t timeout_ms; }; /** * struct cam_private_ioctl_arg - Sync driver ioctl argument * * @id: IOCTL command id * @size: Size of command payload * @result: Result of command execution * @reserved: Reserved * @ioctl_ptr: Pointer to user data */ struct cam_private_ioctl_arg { __u32 id; __u32 size; __u32 result; __u32 reserved; __u64 ioctl_ptr; }; #define CAM_PRIVATE_IOCTL_CMD \ _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_private_ioctl_arg) #define CAM_SYNC_CREATE 0 #define CAM_SYNC_DESTROY 1 #define CAM_SYNC_SIGNAL 2 #define CAM_SYNC_MERGE 3 #define CAM_SYNC_REGISTER_PAYLOAD 4 #define CAM_SYNC_DEREGISTER_PAYLOAD 5 #define CAM_SYNC_WAIT 6 #endif /* __UAPI_CAM_SYNC_H__ */ ================================================ FILE: selfdrive/camerad/include/msm_cam_sensor.h ================================================ #ifndef __LINUX_MSM_CAM_SENSOR_H #define __LINUX_MSM_CAM_SENSOR_H #ifdef MSM_CAMERA_BIONIC #include #endif //#include #include "msm_camsensor_sdk.h" #include #include #ifdef CONFIG_COMPAT #include #endif #define I2C_SEQ_REG_SETTING_MAX 5 #define MSM_SENSOR_MCLK_8HZ 8000000 #define MSM_SENSOR_MCLK_16HZ 16000000 #define MSM_SENSOR_MCLK_24HZ 24000000 #define MAX_SENSOR_NAME 32 #define MAX_ACTUATOR_AF_TOTAL_STEPS 1024 #define MAX_OIS_MOD_NAME_SIZE 32 #define MAX_OIS_NAME_SIZE 32 #define MAX_OIS_REG_SETTINGS 800 #define MOVE_NEAR 0 #define MOVE_FAR 1 #define MSM_ACTUATOR_MOVE_SIGNED_FAR -1 #define MSM_ACTUATOR_MOVE_SIGNED_NEAR 1 #define MAX_ACTUATOR_REGION 5 #define MAX_EEPROM_NAME 32 #define MAX_AF_ITERATIONS 3 #define MAX_NUMBER_OF_STEPS 47 #define MAX_REGULATOR 5 #define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */ #define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') /* 14 BGBG.. GRGR.. */ #define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') /* 14 GBGB.. RGRG.. */ #define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4') /* 14 GRGR.. BGBG.. */ #define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') /* 14 RGRG.. GBGB.. */ enum flash_type { LED_FLASH = 1, STROBE_FLASH, GPIO_FLASH }; enum msm_sensor_resolution_t { MSM_SENSOR_RES_FULL, MSM_SENSOR_RES_QTR, MSM_SENSOR_RES_2, MSM_SENSOR_RES_3, MSM_SENSOR_RES_4, MSM_SENSOR_RES_5, MSM_SENSOR_RES_6, MSM_SENSOR_RES_7, MSM_SENSOR_INVALID_RES, }; enum msm_camera_stream_type_t { MSM_CAMERA_STREAM_PREVIEW, MSM_CAMERA_STREAM_SNAPSHOT, MSM_CAMERA_STREAM_VIDEO, MSM_CAMERA_STREAM_INVALID, }; enum sensor_sub_module_t { SUB_MODULE_SENSOR, SUB_MODULE_CHROMATIX, SUB_MODULE_ACTUATOR, SUB_MODULE_EEPROM, SUB_MODULE_LED_FLASH, SUB_MODULE_STROBE_FLASH, SUB_MODULE_CSID, SUB_MODULE_CSID_3D, SUB_MODULE_CSIPHY, SUB_MODULE_CSIPHY_3D, SUB_MODULE_OIS, SUB_MODULE_EXT, SUB_MODULE_MAX, }; enum { MSM_CAMERA_EFFECT_MODE_OFF, MSM_CAMERA_EFFECT_MODE_MONO, MSM_CAMERA_EFFECT_MODE_NEGATIVE, MSM_CAMERA_EFFECT_MODE_SOLARIZE, MSM_CAMERA_EFFECT_MODE_SEPIA, MSM_CAMERA_EFFECT_MODE_POSTERIZE, MSM_CAMERA_EFFECT_MODE_WHITEBOARD, MSM_CAMERA_EFFECT_MODE_BLACKBOARD, MSM_CAMERA_EFFECT_MODE_AQUA, MSM_CAMERA_EFFECT_MODE_EMBOSS, MSM_CAMERA_EFFECT_MODE_SKETCH, MSM_CAMERA_EFFECT_MODE_NEON, MSM_CAMERA_EFFECT_MODE_MAX }; enum { MSM_CAMERA_WB_MODE_AUTO, MSM_CAMERA_WB_MODE_CUSTOM, MSM_CAMERA_WB_MODE_INCANDESCENT, MSM_CAMERA_WB_MODE_FLUORESCENT, MSM_CAMERA_WB_MODE_WARM_FLUORESCENT, MSM_CAMERA_WB_MODE_DAYLIGHT, MSM_CAMERA_WB_MODE_CLOUDY_DAYLIGHT, MSM_CAMERA_WB_MODE_TWILIGHT, MSM_CAMERA_WB_MODE_SHADE, MSM_CAMERA_WB_MODE_OFF, MSM_CAMERA_WB_MODE_MAX }; enum { MSM_CAMERA_SCENE_MODE_OFF, MSM_CAMERA_SCENE_MODE_AUTO, MSM_CAMERA_SCENE_MODE_LANDSCAPE, MSM_CAMERA_SCENE_MODE_SNOW, MSM_CAMERA_SCENE_MODE_BEACH, MSM_CAMERA_SCENE_MODE_SUNSET, MSM_CAMERA_SCENE_MODE_NIGHT, MSM_CAMERA_SCENE_MODE_PORTRAIT, MSM_CAMERA_SCENE_MODE_BACKLIGHT, MSM_CAMERA_SCENE_MODE_SPORTS, MSM_CAMERA_SCENE_MODE_ANTISHAKE, MSM_CAMERA_SCENE_MODE_FLOWERS, MSM_CAMERA_SCENE_MODE_CANDLELIGHT, MSM_CAMERA_SCENE_MODE_FIREWORKS, MSM_CAMERA_SCENE_MODE_PARTY, MSM_CAMERA_SCENE_MODE_NIGHT_PORTRAIT, MSM_CAMERA_SCENE_MODE_THEATRE, MSM_CAMERA_SCENE_MODE_ACTION, MSM_CAMERA_SCENE_MODE_AR, MSM_CAMERA_SCENE_MODE_FACE_PRIORITY, MSM_CAMERA_SCENE_MODE_BARCODE, MSM_CAMERA_SCENE_MODE_HDR, MSM_CAMERA_SCENE_MODE_MAX }; enum csid_cfg_type_t { CSID_INIT, CSID_CFG, CSID_TESTMODE_CFG, CSID_RELEASE, }; enum csiphy_cfg_type_t { CSIPHY_INIT, CSIPHY_CFG, CSIPHY_RELEASE, }; enum camera_vreg_type { VREG_TYPE_DEFAULT, VREG_TYPE_CUSTOM, }; enum sensor_af_t { SENSOR_AF_FOCUSSED, SENSOR_AF_NOT_FOCUSSED, }; enum cci_i2c_master_t { MASTER_0, MASTER_1, MASTER_MAX, }; struct msm_camera_i2c_array_write_config { struct msm_camera_i2c_reg_setting conf_array; uint16_t slave_addr; }; struct msm_camera_i2c_read_config { uint16_t slave_addr; uint16_t reg_addr; enum msm_camera_i2c_reg_addr_type addr_type; enum msm_camera_i2c_data_type data_type; uint16_t data; }; struct msm_camera_csi2_params { struct msm_camera_csid_params csid_params; struct msm_camera_csiphy_params csiphy_params; uint8_t csi_clk_scale_enable; }; struct msm_camera_csi_lane_params { uint16_t csi_lane_assign; uint16_t csi_lane_mask; }; struct csi_lane_params_t { uint16_t csi_lane_assign; uint8_t csi_lane_mask; uint8_t csi_if; int8_t csid_core[2]; uint8_t csi_phy_sel; }; struct msm_sensor_info_t { char sensor_name[MAX_SENSOR_NAME]; uint32_t session_id; int32_t subdev_id[SUB_MODULE_MAX]; int32_t subdev_intf[SUB_MODULE_MAX]; uint8_t is_mount_angle_valid; uint32_t sensor_mount_angle; int modes_supported; enum camb_position_t position; }; struct camera_vreg_t { const char *reg_name; int min_voltage; int max_voltage; int op_mode; uint32_t delay; const char *custom_vreg_name; enum camera_vreg_type type; }; struct sensorb_cfg_data { int cfgtype; union { struct msm_sensor_info_t sensor_info; struct msm_sensor_init_params sensor_init_params; void *setting; struct msm_sensor_i2c_sync_params sensor_i2c_sync_params; } cfg; }; struct csid_cfg_data { enum csid_cfg_type_t cfgtype; union { uint32_t csid_version; struct msm_camera_csid_params *csid_params; struct msm_camera_csid_testmode_parms *csid_testmode_params; } cfg; }; struct csiphy_cfg_data { enum csiphy_cfg_type_t cfgtype; union { struct msm_camera_csiphy_params *csiphy_params; struct msm_camera_csi_lane_params *csi_lane_params; } cfg; }; enum eeprom_cfg_type_t { CFG_EEPROM_GET_INFO, CFG_EEPROM_GET_CAL_DATA, CFG_EEPROM_READ_CAL_DATA, CFG_EEPROM_WRITE_DATA, CFG_EEPROM_GET_MM_INFO, CFG_EEPROM_INIT, }; struct eeprom_get_t { uint32_t num_bytes; }; struct eeprom_read_t { uint8_t *dbuffer; uint32_t num_bytes; }; struct eeprom_write_t { uint8_t *dbuffer; uint32_t num_bytes; }; struct eeprom_get_cmm_t { uint32_t cmm_support; uint32_t cmm_compression; uint32_t cmm_size; }; struct msm_eeprom_info_t { struct msm_sensor_power_setting_array *power_setting_array; enum i2c_freq_mode_t i2c_freq_mode; struct msm_eeprom_memory_map_array *mem_map_array; }; struct msm_eeprom_cfg_data { enum eeprom_cfg_type_t cfgtype; uint8_t is_supported; union { char eeprom_name[MAX_SENSOR_NAME]; struct eeprom_get_t get_data; struct eeprom_read_t read_data; struct eeprom_write_t write_data; struct eeprom_get_cmm_t get_cmm_data; struct msm_eeprom_info_t eeprom_info; } cfg; }; #ifdef CONFIG_COMPAT struct msm_sensor_power_setting32 { enum msm_sensor_power_seq_type_t seq_type; uint16_t seq_val; compat_uint_t config_val; uint16_t delay; compat_uptr_t data[10]; }; struct msm_sensor_power_setting_array32 { struct msm_sensor_power_setting32 power_setting_a[MAX_POWER_CONFIG]; compat_uptr_t power_setting; uint16_t size; struct msm_sensor_power_setting32 power_down_setting_a[MAX_POWER_CONFIG]; compat_uptr_t power_down_setting; uint16_t size_down; }; struct msm_camera_sensor_slave_info32 { char sensor_name[32]; char eeprom_name[32]; char actuator_name[32]; char ois_name[32]; char flash_name[32]; enum msm_sensor_camera_id_t camera_id; uint16_t slave_addr; enum i2c_freq_mode_t i2c_freq_mode; enum msm_camera_i2c_reg_addr_type addr_type; struct msm_sensor_id_info_t sensor_id_info; struct msm_sensor_power_setting_array32 power_setting_array; uint8_t is_init_params_valid; struct msm_sensor_init_params sensor_init_params; enum msm_sensor_output_format_t output_format; }; struct msm_camera_csid_lut_params32 { uint8_t num_cid; struct msm_camera_csid_vc_cfg vc_cfg_a[MAX_CID]; compat_uptr_t vc_cfg[MAX_CID]; }; struct msm_camera_csid_params32 { uint8_t lane_cnt; uint16_t lane_assign; uint8_t phy_sel; uint32_t csi_clk; struct msm_camera_csid_lut_params32 lut_params; uint8_t csi_3p_sel; }; struct msm_camera_csi2_params32 { struct msm_camera_csid_params32 csid_params; struct msm_camera_csiphy_params csiphy_params; uint8_t csi_clk_scale_enable; }; struct csid_cfg_data32 { enum csid_cfg_type_t cfgtype; union { uint32_t csid_version; compat_uptr_t csid_params; compat_uptr_t csid_testmode_params; } cfg; }; struct eeprom_read_t32 { compat_uptr_t dbuffer; uint32_t num_bytes; }; struct eeprom_write_t32 { compat_uptr_t dbuffer; uint32_t num_bytes; }; struct msm_eeprom_info_t32 { compat_uptr_t power_setting_array; enum i2c_freq_mode_t i2c_freq_mode; compat_uptr_t mem_map_array; }; struct msm_eeprom_cfg_data32 { enum eeprom_cfg_type_t cfgtype; uint8_t is_supported; union { char eeprom_name[MAX_SENSOR_NAME]; struct eeprom_get_t get_data; struct eeprom_read_t32 read_data; struct eeprom_write_t32 write_data; struct msm_eeprom_info_t32 eeprom_info; } cfg; }; struct msm_camera_i2c_seq_reg_setting32 { compat_uptr_t reg_setting; uint16_t size; enum msm_camera_i2c_reg_addr_type addr_type; uint16_t delay; }; #endif enum msm_sensor_cfg_type_t { CFG_SET_SLAVE_INFO, CFG_SLAVE_READ_I2C, CFG_WRITE_I2C_ARRAY, CFG_SLAVE_WRITE_I2C_ARRAY, CFG_WRITE_I2C_SEQ_ARRAY, CFG_POWER_UP, CFG_POWER_DOWN, CFG_SET_STOP_STREAM_SETTING, CFG_GET_SENSOR_INFO, CFG_GET_SENSOR_INIT_PARAMS, CFG_SET_INIT_SETTING, CFG_SET_RESOLUTION, CFG_SET_STOP_STREAM, CFG_SET_START_STREAM, CFG_SET_SATURATION, CFG_SET_CONTRAST, CFG_SET_SHARPNESS, CFG_SET_ISO, CFG_SET_EXPOSURE_COMPENSATION, CFG_SET_ANTIBANDING, CFG_SET_BESTSHOT_MODE, CFG_SET_EFFECT, CFG_SET_WHITE_BALANCE, CFG_SET_AUTOFOCUS, CFG_CANCEL_AUTOFOCUS, CFG_SET_STREAM_TYPE, CFG_SET_I2C_SYNC_PARAM, CFG_WRITE_I2C_ARRAY_ASYNC, CFG_WRITE_I2C_ARRAY_SYNC, CFG_WRITE_I2C_ARRAY_SYNC_BLOCK, }; enum msm_actuator_cfg_type_t { CFG_GET_ACTUATOR_INFO, CFG_SET_ACTUATOR_INFO, CFG_SET_DEFAULT_FOCUS, CFG_MOVE_FOCUS, CFG_SET_POSITION, CFG_ACTUATOR_POWERDOWN, CFG_ACTUATOR_POWERUP, CFG_ACTUATOR_INIT, }; enum msm_ois_cfg_type_t { CFG_OIS_INIT, CFG_OIS_POWERDOWN, CFG_OIS_POWERUP, CFG_OIS_CONTROL, CFG_OIS_I2C_WRITE_SEQ_TABLE, }; enum msm_ois_i2c_operation { MSM_OIS_WRITE = 0, MSM_OIS_POLL, }; struct reg_settings_ois_t { uint16_t reg_addr; enum msm_camera_i2c_reg_addr_type addr_type; uint32_t reg_data; enum msm_camera_i2c_data_type data_type; enum msm_ois_i2c_operation i2c_operation; uint32_t delay; #define OIS_REG_DATA_SEQ_MAX 128 unsigned char reg_data_seq[OIS_REG_DATA_SEQ_MAX]; uint32_t reg_data_seq_size; }; struct msm_ois_params_t { uint16_t data_size; uint16_t setting_size; uint32_t i2c_addr; enum i2c_freq_mode_t i2c_freq_mode; enum msm_camera_i2c_reg_addr_type i2c_addr_type; enum msm_camera_i2c_data_type i2c_data_type; struct reg_settings_ois_t *settings; }; struct msm_ois_set_info_t { struct msm_ois_params_t ois_params; }; struct msm_actuator_move_params_t { int8_t dir; int8_t sign_dir; int16_t dest_step_pos; int32_t num_steps; uint16_t curr_lens_pos; struct damping_params_t *ringing_params; }; struct msm_actuator_tuning_params_t { int16_t initial_code; uint16_t pwd_step; uint16_t region_size; uint32_t total_steps; struct region_params_t *region_params; }; struct park_lens_data_t { uint32_t damping_step; uint32_t damping_delay; uint32_t hw_params; uint32_t max_step; }; struct msm_actuator_params_t { enum actuator_type act_type; uint8_t reg_tbl_size; uint16_t data_size; uint16_t init_setting_size; uint32_t i2c_addr; enum i2c_freq_mode_t i2c_freq_mode; enum msm_actuator_addr_type i2c_addr_type; enum msm_actuator_data_type i2c_data_type; struct msm_actuator_reg_params_t *reg_tbl_params; struct reg_settings_t *init_settings; struct park_lens_data_t park_lens; }; struct msm_actuator_set_info_t { struct msm_actuator_params_t actuator_params; struct msm_actuator_tuning_params_t af_tuning_params; }; struct msm_actuator_get_info_t { uint32_t focal_length_num; uint32_t focal_length_den; uint32_t f_number_num; uint32_t f_number_den; uint32_t f_pix_num; uint32_t f_pix_den; uint32_t total_f_dist_num; uint32_t total_f_dist_den; uint32_t hor_view_angle_num; uint32_t hor_view_angle_den; uint32_t ver_view_angle_num; uint32_t ver_view_angle_den; }; enum af_camera_name { ACTUATOR_MAIN_CAM_0, ACTUATOR_MAIN_CAM_1, ACTUATOR_MAIN_CAM_2, ACTUATOR_MAIN_CAM_3, ACTUATOR_MAIN_CAM_4, ACTUATOR_MAIN_CAM_5, ACTUATOR_WEB_CAM_0, ACTUATOR_WEB_CAM_1, ACTUATOR_WEB_CAM_2, }; struct msm_ois_cfg_data { int cfgtype; union { struct msm_ois_set_info_t set_info; struct msm_camera_i2c_seq_reg_setting *settings; } cfg; }; struct msm_actuator_set_position_t { uint16_t number_of_steps; uint32_t hw_params; uint16_t pos[MAX_NUMBER_OF_STEPS]; uint16_t delay[MAX_NUMBER_OF_STEPS]; }; struct msm_actuator_cfg_data { int cfgtype; uint8_t is_af_supported; union { struct msm_actuator_move_params_t move; struct msm_actuator_set_info_t set_info; struct msm_actuator_get_info_t get_info; struct msm_actuator_set_position_t setpos; enum af_camera_name cam_name; } cfg; }; enum msm_camera_led_config_t { MSM_CAMERA_LED_OFF, MSM_CAMERA_LED_LOW, MSM_CAMERA_LED_HIGH, MSM_CAMERA_LED_INIT, MSM_CAMERA_LED_RELEASE, }; struct msm_camera_led_cfg_t { enum msm_camera_led_config_t cfgtype; int32_t torch_current[MAX_LED_TRIGGERS]; int32_t flash_current[MAX_LED_TRIGGERS]; int32_t flash_duration[MAX_LED_TRIGGERS]; }; struct msm_flash_init_info_t { enum msm_flash_driver_type flash_driver_type; uint32_t slave_addr; enum i2c_freq_mode_t i2c_freq_mode; struct msm_sensor_power_setting_array *power_setting_array; struct msm_camera_i2c_reg_setting_array *settings; }; struct msm_flash_cfg_data_t { enum msm_flash_cfg_type_t cfg_type; int32_t flash_current[MAX_LED_TRIGGERS]; int32_t flash_duration[MAX_LED_TRIGGERS]; union { struct msm_flash_init_info_t *flash_init_info; struct msm_camera_i2c_reg_setting_array *settings; } cfg; }; /* sensor init structures and enums */ enum msm_sensor_init_cfg_type_t { CFG_SINIT_PROBE, CFG_SINIT_PROBE_DONE, CFG_SINIT_PROBE_WAIT_DONE, }; struct sensor_init_cfg_data { enum msm_sensor_init_cfg_type_t cfgtype; struct msm_sensor_info_t probed_info; char entity_name[MAX_SENSOR_NAME]; union { void *setting; } cfg; }; #define VIDIOC_MSM_SENSOR_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data) #define VIDIOC_MSM_SENSOR_RELEASE \ _IO('V', BASE_VIDIOC_PRIVATE + 2) #define VIDIOC_MSM_SENSOR_GET_SUBDEV_ID \ _IOWR('V', BASE_VIDIOC_PRIVATE + 3, uint32_t) #define VIDIOC_MSM_CSIPHY_IO_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data) #define VIDIOC_MSM_CSID_IO_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data) #define VIDIOC_MSM_ACTUATOR_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data) #define VIDIOC_MSM_FLASH_LED_DATA_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_led_cfg_t) #define VIDIOC_MSM_EEPROM_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data) #define VIDIOC_MSM_SENSOR_GET_AF_STATUS \ _IOWR('V', BASE_VIDIOC_PRIVATE + 9, uint32_t) #define VIDIOC_MSM_SENSOR_INIT_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data) #define VIDIOC_MSM_OIS_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data) #define VIDIOC_MSM_FLASH_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t) #ifdef CONFIG_COMPAT struct msm_camera_i2c_reg_setting32 { compat_uptr_t reg_setting; uint16_t size; enum msm_camera_i2c_reg_addr_type addr_type; enum msm_camera_i2c_data_type data_type; uint16_t delay; }; struct msm_camera_i2c_array_write_config32 { struct msm_camera_i2c_reg_setting32 conf_array; uint16_t slave_addr; }; struct msm_actuator_tuning_params_t32 { int16_t initial_code; uint16_t pwd_step; uint16_t region_size; uint32_t total_steps; compat_uptr_t region_params; }; struct msm_actuator_params_t32 { enum actuator_type act_type; uint8_t reg_tbl_size; uint16_t data_size; uint16_t init_setting_size; uint32_t i2c_addr; enum i2c_freq_mode_t i2c_freq_mode; enum msm_actuator_addr_type i2c_addr_type; enum msm_actuator_data_type i2c_data_type; compat_uptr_t reg_tbl_params; compat_uptr_t init_settings; struct park_lens_data_t park_lens; }; struct msm_actuator_set_info_t32 { struct msm_actuator_params_t32 actuator_params; struct msm_actuator_tuning_params_t32 af_tuning_params; }; struct sensor_init_cfg_data32 { enum msm_sensor_init_cfg_type_t cfgtype; struct msm_sensor_info_t probed_info; char entity_name[MAX_SENSOR_NAME]; union { compat_uptr_t setting; } cfg; }; struct msm_actuator_move_params_t32 { int8_t dir; int8_t sign_dir; int16_t dest_step_pos; int32_t num_steps; uint16_t curr_lens_pos; compat_uptr_t ringing_params; }; struct msm_actuator_cfg_data32 { int cfgtype; uint8_t is_af_supported; union { struct msm_actuator_move_params_t32 move; struct msm_actuator_set_info_t32 set_info; struct msm_actuator_get_info_t get_info; struct msm_actuator_set_position_t setpos; enum af_camera_name cam_name; } cfg; }; struct csiphy_cfg_data32 { enum csiphy_cfg_type_t cfgtype; union { compat_uptr_t csiphy_params; compat_uptr_t csi_lane_params; } cfg; }; struct sensorb_cfg_data32 { int cfgtype; union { struct msm_sensor_info_t sensor_info; struct msm_sensor_init_params sensor_init_params; compat_uptr_t setting; struct msm_sensor_i2c_sync_params sensor_i2c_sync_params; } cfg; }; struct msm_ois_params_t32 { uint16_t data_size; uint16_t setting_size; uint32_t i2c_addr; enum i2c_freq_mode_t i2c_freq_mode; enum msm_camera_i2c_reg_addr_type i2c_addr_type; enum msm_camera_i2c_data_type i2c_data_type; compat_uptr_t settings; }; struct msm_ois_set_info_t32 { struct msm_ois_params_t32 ois_params; }; struct msm_ois_cfg_data32 { int cfgtype; union { struct msm_ois_set_info_t32 set_info; compat_uptr_t settings; } cfg; }; struct msm_flash_init_info_t32 { enum msm_flash_driver_type flash_driver_type; uint32_t slave_addr; enum i2c_freq_mode_t i2c_freq_mode; compat_uptr_t power_setting_array; compat_uptr_t settings; }; struct msm_flash_cfg_data_t32 { enum msm_flash_cfg_type_t cfg_type; int32_t flash_current[MAX_LED_TRIGGERS]; int32_t flash_duration[MAX_LED_TRIGGERS]; union { compat_uptr_t flash_init_info; compat_uptr_t settings; } cfg; }; #define VIDIOC_MSM_ACTUATOR_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data32) #define VIDIOC_MSM_SENSOR_INIT_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data32) #define VIDIOC_MSM_CSIPHY_IO_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data32) #define VIDIOC_MSM_SENSOR_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data32) #define VIDIOC_MSM_EEPROM_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data32) #define VIDIOC_MSM_OIS_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data32) #define VIDIOC_MSM_CSID_IO_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data32) #define VIDIOC_MSM_FLASH_CFG32 \ _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t32) #endif #endif /* __LINUX_MSM_CAM_SENSOR_H */ ================================================ FILE: selfdrive/camerad/include/msm_camsensor_sdk.h ================================================ #ifndef __LINUX_MSM_CAMSENSOR_SDK_H #define __LINUX_MSM_CAMSENSOR_SDK_H #define KVERSION 0x1 #define MAX_POWER_CONFIG 12 #define GPIO_OUT_LOW (0 << 1) #define GPIO_OUT_HIGH (1 << 1) #define CSI_EMBED_DATA 0x12 #define CSI_RESERVED_DATA_0 0x13 #define CSI_YUV422_8 0x1E #define CSI_RAW8 0x2A #define CSI_RAW10 0x2B #define CSI_RAW12 0x2C #define CSI_DECODE_6BIT 0 #define CSI_DECODE_8BIT 1 #define CSI_DECODE_10BIT 2 #define CSI_DECODE_12BIT 3 #define CSI_DECODE_DPCM_10_8_10 5 #define MAX_CID 16 #define I2C_SEQ_REG_DATA_MAX 1024 #define I2C_REG_DATA_MAX (8*1024) #define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */ #define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') /* 14 BGBG.. GRGR.. */ #define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') /* 14 GBGB.. RGRG.. */ #define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4') /* 14 GRGR.. BGBG.. */ #define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') /* 14 RGRG.. GBGB.. */ #define MAX_ACTUATOR_REG_TBL_SIZE 8 #define MAX_ACTUATOR_REGION 5 #define NUM_ACTUATOR_DIR 2 #define MAX_ACTUATOR_SCENARIO 8 #define MAX_ACT_MOD_NAME_SIZE 32 #define MAX_ACT_NAME_SIZE 32 #define MAX_ACTUATOR_INIT_SET 120 #define MAX_I2C_REG_SET 12 #define MAX_LED_TRIGGERS 3 #define MSM_EEPROM_MEMORY_MAP_MAX_SIZE 80 #define MSM_EEPROM_MAX_MEM_MAP_CNT 8 enum msm_sensor_camera_id_t { CAMERA_0, CAMERA_1, CAMERA_2, CAMERA_3, MAX_CAMERAS, }; enum i2c_freq_mode_t { I2C_STANDARD_MODE, I2C_FAST_MODE, I2C_CUSTOM_MODE, I2C_FAST_PLUS_MODE, I2C_MAX_MODES, }; enum camb_position_t { BACK_CAMERA_B, FRONT_CAMERA_B, AUX_CAMERA_B = 0x100, INVALID_CAMERA_B, }; enum msm_sensor_power_seq_type_t { SENSOR_CLK, SENSOR_GPIO, SENSOR_VREG, SENSOR_I2C_MUX, SENSOR_I2C, }; enum msm_camera_i2c_reg_addr_type { MSM_CAMERA_I2C_BYTE_ADDR = 1, MSM_CAMERA_I2C_WORD_ADDR, MSM_CAMERA_I2C_3B_ADDR, MSM_CAMERA_I2C_ADDR_TYPE_MAX, }; enum msm_camera_i2c_data_type { MSM_CAMERA_I2C_BYTE_DATA = 1, MSM_CAMERA_I2C_WORD_DATA, MSM_CAMERA_I2C_DWORD_DATA, MSM_CAMERA_I2C_SET_BYTE_MASK, MSM_CAMERA_I2C_UNSET_BYTE_MASK, MSM_CAMERA_I2C_SET_WORD_MASK, MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA, MSM_CAMERA_I2C_SEQ_DATA, MSM_CAMERA_I2C_DATA_TYPE_MAX, }; enum msm_sensor_power_seq_gpio_t { SENSOR_GPIO_RESET, SENSOR_GPIO_STANDBY, SENSOR_GPIO_AF_PWDM, SENSOR_GPIO_VIO, SENSOR_GPIO_VANA, SENSOR_GPIO_VDIG, SENSOR_GPIO_VAF, SENSOR_GPIO_FL_EN, SENSOR_GPIO_FL_NOW, SENSOR_GPIO_FL_RESET, SENSOR_GPIO_CUSTOM1, SENSOR_GPIO_CUSTOM2, SENSOR_GPIO_MAX, }; enum msm_camera_vreg_name_t { CAM_VDIG, CAM_VIO, CAM_VANA, CAM_VAF, CAM_V_CUSTOM1, CAM_V_CUSTOM2, CAM_VREG_MAX, }; enum msm_sensor_clk_type_t { SENSOR_CAM_MCLK, SENSOR_CAM_CLK, SENSOR_CAM_CLK_MAX, }; enum camerab_mode_t { CAMERA_MODE_2D_B = (1<<0), CAMERA_MODE_3D_B = (1<<1), CAMERA_MODE_INVALID = (1<<2), }; enum msm_actuator_data_type { MSM_ACTUATOR_BYTE_DATA = 1, MSM_ACTUATOR_WORD_DATA, }; enum msm_actuator_addr_type { MSM_ACTUATOR_BYTE_ADDR = 1, MSM_ACTUATOR_WORD_ADDR, }; enum msm_actuator_write_type { MSM_ACTUATOR_WRITE_HW_DAMP, MSM_ACTUATOR_WRITE_DAC, MSM_ACTUATOR_WRITE, MSM_ACTUATOR_WRITE_DIR_REG, MSM_ACTUATOR_POLL, MSM_ACTUATOR_READ_WRITE, }; enum msm_actuator_i2c_operation { MSM_ACT_WRITE = 0, MSM_ACT_POLL, }; enum actuator_type { ACTUATOR_VCM, ACTUATOR_PIEZO, ACTUATOR_HVCM, ACTUATOR_BIVCM, }; enum msm_flash_driver_type { FLASH_DRIVER_PMIC, FLASH_DRIVER_I2C, FLASH_DRIVER_GPIO, FLASH_DRIVER_DEFAULT }; enum msm_flash_cfg_type_t { CFG_FLASH_INIT, CFG_FLASH_RELEASE, CFG_FLASH_OFF, CFG_FLASH_LOW, CFG_FLASH_HIGH, }; enum msm_sensor_output_format_t { MSM_SENSOR_BAYER, MSM_SENSOR_YCBCR, MSM_SENSOR_META, }; struct msm_sensor_power_setting { enum msm_sensor_power_seq_type_t seq_type; unsigned short seq_val; long config_val; unsigned short delay; void *data[10]; }; struct msm_sensor_power_setting_array { struct msm_sensor_power_setting power_setting_a[MAX_POWER_CONFIG]; struct msm_sensor_power_setting *power_setting; unsigned short size; struct msm_sensor_power_setting power_down_setting_a[MAX_POWER_CONFIG]; struct msm_sensor_power_setting *power_down_setting; unsigned short size_down; }; enum msm_camera_i2c_operation { MSM_CAM_WRITE = 0, MSM_CAM_POLL, MSM_CAM_READ, }; struct msm_sensor_i2c_sync_params { unsigned int cid; int csid; unsigned short line; unsigned short delay; }; struct msm_camera_reg_settings_t { uint16_t reg_addr; enum msm_camera_i2c_reg_addr_type addr_type; uint16_t reg_data; enum msm_camera_i2c_data_type data_type; enum msm_camera_i2c_operation i2c_operation; uint16_t delay; }; struct msm_eeprom_mem_map_t { int slave_addr; struct msm_camera_reg_settings_t mem_settings[MSM_EEPROM_MEMORY_MAP_MAX_SIZE]; int memory_map_size; }; struct msm_eeprom_memory_map_array { struct msm_eeprom_mem_map_t memory_map[MSM_EEPROM_MAX_MEM_MAP_CNT]; uint32_t msm_size_of_max_mappings; }; struct msm_sensor_init_params { /* mask of modes supported: 2D, 3D */ int modes_supported; /* sensor position: front, back */ enum camb_position_t position; /* sensor mount angle */ unsigned int sensor_mount_angle; }; struct msm_sensor_id_info_t { unsigned short sensor_id_reg_addr; unsigned short sensor_id; unsigned short sensor_id_mask; // added in LeEco unsigned char module_id; unsigned char vcm_id; }; struct msm_camera_sensor_slave_info { char sensor_name[32]; char eeprom_name[32]; char actuator_name[32]; char ois_name[32]; char flash_name[32]; enum msm_sensor_camera_id_t camera_id; unsigned short slave_addr; enum i2c_freq_mode_t i2c_freq_mode; enum msm_camera_i2c_reg_addr_type addr_type; struct msm_sensor_id_info_t sensor_id_info; struct msm_sensor_power_setting_array power_setting_array; unsigned char is_init_params_valid; struct msm_sensor_init_params sensor_init_params; enum msm_sensor_output_format_t output_format; }; struct msm_camera_i2c_reg_array { unsigned short reg_addr; unsigned short reg_data; unsigned int delay; }; struct msm_camera_i2c_reg_setting { struct msm_camera_i2c_reg_array *reg_setting; unsigned short size; enum msm_camera_i2c_reg_addr_type addr_type; enum msm_camera_i2c_data_type data_type; unsigned short delay; }; struct msm_camera_csid_vc_cfg { unsigned char cid; unsigned char dt; unsigned char decode_format; }; struct msm_camera_csid_lut_params { unsigned char num_cid; struct msm_camera_csid_vc_cfg vc_cfg_a[MAX_CID]; struct msm_camera_csid_vc_cfg *vc_cfg[MAX_CID]; }; struct msm_camera_csid_params { unsigned char lane_cnt; unsigned short lane_assign; unsigned char phy_sel; unsigned int csi_clk; struct msm_camera_csid_lut_params lut_params; unsigned char csi_3p_sel; }; struct msm_camera_csid_testmode_parms { unsigned int num_bytes_per_line; unsigned int num_lines; unsigned int h_blanking_count; unsigned int v_blanking_count; unsigned int payload_mode; }; struct msm_camera_csiphy_params { unsigned char lane_cnt; unsigned char settle_cnt; unsigned short lane_mask; unsigned char combo_mode; unsigned char csid_core; unsigned int csiphy_clk; unsigned char csi_3phase; }; struct msm_camera_i2c_seq_reg_array { unsigned short reg_addr; unsigned char reg_data[I2C_SEQ_REG_DATA_MAX]; unsigned short reg_data_size; }; struct msm_camera_i2c_seq_reg_setting { struct msm_camera_i2c_seq_reg_array *reg_setting; unsigned short size; enum msm_camera_i2c_reg_addr_type addr_type; unsigned short delay; }; struct msm_actuator_reg_params_t { enum msm_actuator_write_type reg_write_type; unsigned int hw_mask; unsigned short reg_addr; unsigned short hw_shift; unsigned short data_shift; unsigned short data_type; unsigned short addr_type; unsigned short reg_data; unsigned short delay; }; struct damping_params_t { unsigned int damping_step; unsigned int damping_delay; unsigned int hw_params; }; struct region_params_t { /* [0] = ForwardDirection Macro boundary [1] = ReverseDirection Inf boundary */ unsigned short step_bound[2]; unsigned short code_per_step; /* qvalue for converting float type numbers to integer format */ unsigned int qvalue; }; struct reg_settings_t { unsigned short reg_addr; enum msm_actuator_addr_type addr_type; unsigned short reg_data; enum msm_actuator_data_type data_type; enum msm_actuator_i2c_operation i2c_operation; unsigned int delay; }; struct msm_camera_i2c_reg_setting_array { struct msm_camera_i2c_reg_array reg_setting_a[MAX_I2C_REG_SET]; unsigned short size; enum msm_camera_i2c_reg_addr_type addr_type; enum msm_camera_i2c_data_type data_type; unsigned short delay; }; #endif /* __LINUX_MSM_CAM_SENSOR_H */ ================================================ FILE: selfdrive/camerad/include/msmb_camera.h ================================================ #ifndef __LINUX_MSMB_CAMERA_H #define __LINUX_MSMB_CAMERA_H #include #include #include #define MSM_CAM_LOGSYNC_FILE_NAME "logsync" #define MSM_CAM_LOGSYNC_FILE_BASEDIR "camera" #define MSM_CAM_V4L2_IOCTL_NOTIFY \ _IOW('V', BASE_VIDIOC_PRIVATE + 30, struct msm_v4l2_event_data) #define MSM_CAM_V4L2_IOCTL_NOTIFY_META \ _IOW('V', BASE_VIDIOC_PRIVATE + 31, struct msm_v4l2_event_data) #define MSM_CAM_V4L2_IOCTL_CMD_ACK \ _IOW('V', BASE_VIDIOC_PRIVATE + 32, struct msm_v4l2_event_data) #define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR \ _IOW('V', BASE_VIDIOC_PRIVATE + 33, struct msm_v4l2_event_data) #define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG \ _IOW('V', BASE_VIDIOC_PRIVATE + 34, struct msm_v4l2_event_data) #ifdef CONFIG_COMPAT #define MSM_CAM_V4L2_IOCTL_NOTIFY32 \ _IOW('V', BASE_VIDIOC_PRIVATE + 30, struct v4l2_event32) #define MSM_CAM_V4L2_IOCTL_NOTIFY_META32 \ _IOW('V', BASE_VIDIOC_PRIVATE + 31, struct v4l2_event32) #define MSM_CAM_V4L2_IOCTL_CMD_ACK32 \ _IOW('V', BASE_VIDIOC_PRIVATE + 32, struct v4l2_event32) #define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR32 \ _IOW('V', BASE_VIDIOC_PRIVATE + 33, struct v4l2_event32) #define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG32 \ _IOW('V', BASE_VIDIOC_PRIVATE + 34, struct v4l2_event32) #endif #define QCAMERA_DEVICE_GROUP_ID 1 #define QCAMERA_VNODE_GROUP_ID 2 #define MSM_CAMERA_NAME "msm_camera" #define MSM_CONFIGURATION_NAME "msm_config" #define MSM_CAMERA_SUBDEV_CSIPHY 0 #define MSM_CAMERA_SUBDEV_CSID 1 #define MSM_CAMERA_SUBDEV_ISPIF 2 #define MSM_CAMERA_SUBDEV_VFE 3 #define MSM_CAMERA_SUBDEV_AXI 4 #define MSM_CAMERA_SUBDEV_VPE 5 #define MSM_CAMERA_SUBDEV_SENSOR 6 #define MSM_CAMERA_SUBDEV_ACTUATOR 7 #define MSM_CAMERA_SUBDEV_EEPROM 8 #define MSM_CAMERA_SUBDEV_CPP 9 #define MSM_CAMERA_SUBDEV_CCI 10 #define MSM_CAMERA_SUBDEV_LED_FLASH 11 #define MSM_CAMERA_SUBDEV_STROBE_FLASH 12 #define MSM_CAMERA_SUBDEV_BUF_MNGR 13 #define MSM_CAMERA_SUBDEV_SENSOR_INIT 14 #define MSM_CAMERA_SUBDEV_OIS 15 #define MSM_CAMERA_SUBDEV_FLASH 16 #define MSM_CAMERA_SUBDEV_EXT 17 #define MSM_MAX_CAMERA_SENSORS 5 /* The below macro is defined to put an upper limit on maximum * number of buffer requested per stream. In case of extremely * large value for number of buffer due to data structure corruption * we return error to avoid integer overflow. Group processing * can have max of 9 groups of 8 bufs each. This value may be * configured in future*/ #define MSM_CAMERA_MAX_STREAM_BUF 72 /* Max batch size of processing */ #define MSM_CAMERA_MAX_USER_BUFF_CNT 16 /* featur base */ #define MSM_CAMERA_FEATURE_BASE 0x00010000 #define MSM_CAMERA_FEATURE_SHUTDOWN (MSM_CAMERA_FEATURE_BASE + 1) #define MSM_CAMERA_STATUS_BASE 0x00020000 #define MSM_CAMERA_STATUS_FAIL (MSM_CAMERA_STATUS_BASE + 1) #define MSM_CAMERA_STATUS_SUCCESS (MSM_CAMERA_STATUS_BASE + 2) /* event type */ #define MSM_CAMERA_V4L2_EVENT_TYPE (V4L2_EVENT_PRIVATE_START + 0x00002000) /* event id */ #define MSM_CAMERA_EVENT_MIN 0 #define MSM_CAMERA_NEW_SESSION (MSM_CAMERA_EVENT_MIN + 1) #define MSM_CAMERA_DEL_SESSION (MSM_CAMERA_EVENT_MIN + 2) #define MSM_CAMERA_SET_PARM (MSM_CAMERA_EVENT_MIN + 3) #define MSM_CAMERA_GET_PARM (MSM_CAMERA_EVENT_MIN + 4) #define MSM_CAMERA_MAPPING_CFG (MSM_CAMERA_EVENT_MIN + 5) #define MSM_CAMERA_MAPPING_SES (MSM_CAMERA_EVENT_MIN + 6) #define MSM_CAMERA_MSM_NOTIFY (MSM_CAMERA_EVENT_MIN + 7) #define MSM_CAMERA_EVENT_MAX (MSM_CAMERA_EVENT_MIN + 8) /* data.command */ #define MSM_CAMERA_PRIV_S_CROP (V4L2_CID_PRIVATE_BASE + 1) #define MSM_CAMERA_PRIV_G_CROP (V4L2_CID_PRIVATE_BASE + 2) #define MSM_CAMERA_PRIV_G_FMT (V4L2_CID_PRIVATE_BASE + 3) #define MSM_CAMERA_PRIV_S_FMT (V4L2_CID_PRIVATE_BASE + 4) #define MSM_CAMERA_PRIV_TRY_FMT (V4L2_CID_PRIVATE_BASE + 5) #define MSM_CAMERA_PRIV_METADATA (V4L2_CID_PRIVATE_BASE + 6) #define MSM_CAMERA_PRIV_QUERY_CAP (V4L2_CID_PRIVATE_BASE + 7) #define MSM_CAMERA_PRIV_STREAM_ON (V4L2_CID_PRIVATE_BASE + 8) #define MSM_CAMERA_PRIV_STREAM_OFF (V4L2_CID_PRIVATE_BASE + 9) #define MSM_CAMERA_PRIV_NEW_STREAM (V4L2_CID_PRIVATE_BASE + 10) #define MSM_CAMERA_PRIV_DEL_STREAM (V4L2_CID_PRIVATE_BASE + 11) #define MSM_CAMERA_PRIV_SHUTDOWN (V4L2_CID_PRIVATE_BASE + 12) #define MSM_CAMERA_PRIV_STREAM_INFO_SYNC \ (V4L2_CID_PRIVATE_BASE + 13) #define MSM_CAMERA_PRIV_G_SESSION_ID (V4L2_CID_PRIVATE_BASE + 14) #define MSM_CAMERA_PRIV_CMD_MAX 20 /* data.status - success */ #define MSM_CAMERA_CMD_SUCESS 0x00000001 #define MSM_CAMERA_BUF_MAP_SUCESS 0x00000002 /* data.status - error */ #define MSM_CAMERA_ERR_EVT_BASE 0x00010000 #define MSM_CAMERA_ERR_CMD_FAIL (MSM_CAMERA_ERR_EVT_BASE + 1) #define MSM_CAMERA_ERR_MAPPING (MSM_CAMERA_ERR_EVT_BASE + 2) #define MSM_CAMERA_ERR_DEVICE_BUSY (MSM_CAMERA_ERR_EVT_BASE + 3) /* The msm_v4l2_event_data structure should match the * v4l2_event.u.data field. * should not exceed 16 elements */ struct msm_v4l2_event_data { /*word 0*/ unsigned int command; /*word 1*/ unsigned int status; /*word 2*/ unsigned int session_id; /*word 3*/ unsigned int stream_id; /*word 4*/ unsigned int map_op; /*word 5*/ unsigned int map_buf_idx; /*word 6*/ unsigned int notify; /*word 7*/ unsigned int arg_value; /*word 8*/ unsigned int ret_value; /*word 9*/ unsigned int v4l2_event_type; /*word 10*/ unsigned int v4l2_event_id; /*word 11*/ unsigned int handle; /*word 12*/ unsigned int nop6; /*word 13*/ unsigned int nop7; /*word 14*/ unsigned int nop8; /*word 15*/ unsigned int nop9; }; /* map to v4l2_format.fmt.raw_data */ struct msm_v4l2_format_data { enum v4l2_buf_type type; unsigned int width; unsigned int height; unsigned int pixelformat; /* FOURCC */ unsigned char num_planes; unsigned int plane_sizes[VIDEO_MAX_PLANES]; }; /* MSM Four-character-code (FOURCC) */ #define msm_v4l2_fourcc(a, b, c, d)\ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) |\ ((__u32)(d) << 24)) /* Composite stats */ #define MSM_V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M') /* AEC stats */ #define MSM_V4L2_PIX_FMT_STATS_AE v4l2_fourcc('S', 'T', 'A', 'E') /* AF stats */ #define MSM_V4L2_PIX_FMT_STATS_AF v4l2_fourcc('S', 'T', 'A', 'F') /* AWB stats */ #define MSM_V4L2_PIX_FMT_STATS_AWB v4l2_fourcc('S', 'T', 'W', 'B') /* IHIST stats */ #define MSM_V4L2_PIX_FMT_STATS_IHST v4l2_fourcc('I', 'H', 'S', 'T') /* Column count stats */ #define MSM_V4L2_PIX_FMT_STATS_CS v4l2_fourcc('S', 'T', 'C', 'S') /* Row count stats */ #define MSM_V4L2_PIX_FMT_STATS_RS v4l2_fourcc('S', 'T', 'R', 'S') /* Bayer Grid stats */ #define MSM_V4L2_PIX_FMT_STATS_BG v4l2_fourcc('S', 'T', 'B', 'G') /* Bayer focus stats */ #define MSM_V4L2_PIX_FMT_STATS_BF v4l2_fourcc('S', 'T', 'B', 'F') /* Bayer hist stats */ #define MSM_V4L2_PIX_FMT_STATS_BHST v4l2_fourcc('B', 'H', 'S', 'T') enum smmu_attach_mode { NON_SECURE_MODE = 0x01, SECURE_MODE = 0x02, MAX_PROTECTION_MODE = 0x03, }; struct msm_camera_smmu_attach_type { enum smmu_attach_mode attach; }; struct msm_camera_user_buf_cont_t { unsigned int buf_cnt; unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT]; }; #endif /* __LINUX_MSMB_CAMERA_H */ ================================================ FILE: selfdrive/camerad/include/msmb_isp.h ================================================ #ifndef __MSMB_ISP__ #define __MSMB_ISP__ #include #define MAX_PLANES_PER_STREAM 3 #define MAX_NUM_STREAM 7 #define ISP_VERSION_47 47 #define ISP_VERSION_46 46 #define ISP_VERSION_44 44 #define ISP_VERSION_40 40 #define ISP_VERSION_32 32 #define ISP_NATIVE_BUF_BIT (0x10000 << 0) #define ISP0_BIT (0x10000 << 1) #define ISP1_BIT (0x10000 << 2) #define ISP_META_CHANNEL_BIT (0x10000 << 3) #define ISP_SCRATCH_BUF_BIT (0x10000 << 4) #define ISP_OFFLINE_STATS_BIT (0x10000 << 5) #define ISP_STATS_STREAM_BIT 0x80000000 struct msm_vfe_cfg_cmd_list; enum ISP_START_PIXEL_PATTERN { ISP_BAYER_RGRGRG, ISP_BAYER_GRGRGR, ISP_BAYER_BGBGBG, ISP_BAYER_GBGBGB, ISP_YUV_YCbYCr, ISP_YUV_YCrYCb, ISP_YUV_CbYCrY, ISP_YUV_CrYCbY, ISP_PIX_PATTERN_MAX }; enum msm_vfe_plane_fmt { Y_PLANE, CB_PLANE, CR_PLANE, CRCB_PLANE, CBCR_PLANE, VFE_PLANE_FMT_MAX }; enum msm_vfe_input_src { VFE_PIX_0, VFE_RAW_0, VFE_RAW_1, VFE_RAW_2, VFE_SRC_MAX, }; enum msm_vfe_axi_stream_src { PIX_ENCODER, PIX_VIEWFINDER, PIX_VIDEO, CAMIF_RAW, IDEAL_RAW, RDI_INTF_0, RDI_INTF_1, RDI_INTF_2, VFE_AXI_SRC_MAX }; enum msm_vfe_frame_skip_pattern { NO_SKIP, EVERY_2FRAME, EVERY_3FRAME, EVERY_4FRAME, EVERY_5FRAME, EVERY_6FRAME, EVERY_7FRAME, EVERY_8FRAME, EVERY_16FRAME, EVERY_32FRAME, SKIP_ALL, SKIP_RANGE, MAX_SKIP, }; /* * Define an unused period. When this period is set it means that the stream is * stopped(i.e the pattern is 0). We don't track the current pattern, just the * period defines what the pattern is, if period is this then pattern is 0 else * pattern is 1 */ #define MSM_VFE_STREAM_STOP_PERIOD 15 enum msm_isp_stats_type { MSM_ISP_STATS_AEC, /* legacy based AEC */ MSM_ISP_STATS_AF, /* legacy based AF */ MSM_ISP_STATS_AWB, /* legacy based AWB */ MSM_ISP_STATS_RS, /* legacy based RS */ MSM_ISP_STATS_CS, /* legacy based CS */ MSM_ISP_STATS_IHIST, /* legacy based HIST */ MSM_ISP_STATS_SKIN, /* legacy based SKIN */ MSM_ISP_STATS_BG, /* Bayer Grids */ MSM_ISP_STATS_BF, /* Bayer Focus */ MSM_ISP_STATS_BE, /* Bayer Exposure*/ MSM_ISP_STATS_BHIST, /* Bayer Hist */ MSM_ISP_STATS_BF_SCALE, /* Bayer Focus scale */ MSM_ISP_STATS_HDR_BE, /* HDR Bayer Exposure */ MSM_ISP_STATS_HDR_BHIST, /* HDR Bayer Hist */ MSM_ISP_STATS_AEC_BG, /* AEC BG */ MSM_ISP_STATS_MAX /* MAX */ }; /* * @stats_type_mask: Stats type mask (enum msm_isp_stats_type). * @stream_src_mask: Stream src mask (enum msm_vfe_axi_stream_src) * @skip_mode: skip pattern, if skip mode is range only then min/max is used * @min_frame_id: minimum frame id (valid only if skip_mode = RANGE) * @max_frame_id: maximum frame id (valid only if skip_mode = RANGE) */ struct msm_isp_sw_framskip { uint32_t stats_type_mask; uint32_t stream_src_mask; enum msm_vfe_frame_skip_pattern skip_mode; uint32_t min_frame_id; uint32_t max_frame_id; }; enum msm_vfe_testgen_color_pattern { COLOR_BAR_8_COLOR, UNICOLOR_WHITE, UNICOLOR_YELLOW, UNICOLOR_CYAN, UNICOLOR_GREEN, UNICOLOR_MAGENTA, UNICOLOR_RED, UNICOLOR_BLUE, UNICOLOR_BLACK, MAX_COLOR, }; enum msm_vfe_camif_input { CAMIF_DISABLED, CAMIF_PAD_REG_INPUT, CAMIF_MIDDI_INPUT, CAMIF_MIPI_INPUT, }; struct msm_vfe_fetch_engine_cfg { uint32_t input_format; uint32_t buf_width; uint32_t buf_height; uint32_t fetch_width; uint32_t fetch_height; uint32_t x_offset; uint32_t y_offset; uint32_t buf_stride; }; enum msm_vfe_camif_output_format { CAMIF_QCOM_RAW, CAMIF_MIPI_RAW, CAMIF_PLAIN_8, CAMIF_PLAIN_16, CAMIF_MAX_FORMAT, }; /* * Camif output general configuration */ struct msm_vfe_camif_subsample_cfg { uint32_t irq_subsample_period; uint32_t irq_subsample_pattern; uint32_t sof_counter_step; uint32_t pixel_skip; uint32_t line_skip; uint32_t first_line; uint32_t last_line; uint32_t first_pixel; uint32_t last_pixel; enum msm_vfe_camif_output_format output_format; }; /* * Camif frame and window configuration */ struct msm_vfe_camif_cfg { uint32_t lines_per_frame; uint32_t pixels_per_line; uint32_t first_pixel; uint32_t last_pixel; uint32_t first_line; uint32_t last_line; uint32_t epoch_line0; uint32_t epoch_line1; uint32_t is_split; enum msm_vfe_camif_input camif_input; struct msm_vfe_camif_subsample_cfg subsample_cfg; }; struct msm_vfe_testgen_cfg { uint32_t lines_per_frame; uint32_t pixels_per_line; uint32_t v_blank; uint32_t h_blank; enum ISP_START_PIXEL_PATTERN pixel_bayer_pattern; uint32_t rotate_period; enum msm_vfe_testgen_color_pattern color_bar_pattern; uint32_t burst_num_frame; }; enum msm_vfe_inputmux { CAMIF, TESTGEN, EXTERNAL_READ, }; enum msm_vfe_stats_composite_group { STATS_COMPOSITE_GRP_NONE, STATS_COMPOSITE_GRP_1, STATS_COMPOSITE_GRP_2, STATS_COMPOSITE_GRP_MAX, }; enum msm_vfe_hvx_streaming_cmd { HVX_DISABLE, HVX_ONE_WAY, HVX_ROUND_TRIP }; struct msm_vfe_pix_cfg { struct msm_vfe_camif_cfg camif_cfg; struct msm_vfe_testgen_cfg testgen_cfg; struct msm_vfe_fetch_engine_cfg fetch_engine_cfg; enum msm_vfe_inputmux input_mux; enum ISP_START_PIXEL_PATTERN pixel_pattern; uint32_t input_format; enum msm_vfe_hvx_streaming_cmd hvx_cmd; uint32_t is_split; }; struct msm_vfe_rdi_cfg { uint8_t cid; uint8_t frame_based; }; struct msm_vfe_input_cfg { union { struct msm_vfe_pix_cfg pix_cfg; struct msm_vfe_rdi_cfg rdi_cfg; } d; enum msm_vfe_input_src input_src; uint32_t input_pix_clk; }; struct msm_vfe_fetch_eng_start { uint32_t session_id; uint32_t stream_id; uint32_t buf_idx; uint8_t offline_mode; uint32_t fd; uint32_t buf_addr; uint32_t frame_id; }; struct msm_vfe_axi_plane_cfg { uint32_t output_width; /*Include padding*/ uint32_t output_height; uint32_t output_stride; uint32_t output_scan_lines; uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/ uint32_t plane_addr_offset; uint8_t csid_src; /*RDI 0-2*/ uint8_t rdi_cid;/*CID 1-16*/ }; enum msm_stream_memory_input_t { MEMORY_INPUT_DISABLED, MEMORY_INPUT_ENABLED }; struct msm_vfe_axi_stream_request_cmd { uint32_t session_id; uint32_t stream_id; uint32_t vt_enable; uint32_t output_format;/*Planar/RAW/Misc*/ enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/ struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM]; uint32_t burst_count; uint32_t hfr_mode; uint8_t frame_base; uint32_t init_frame_drop; /*MAX 31 Frames*/ enum msm_vfe_frame_skip_pattern frame_skip_pattern; uint8_t buf_divert; /* if TRUE no vb2 buf done. */ /*Return values*/ uint32_t axi_stream_handle; uint32_t controllable_output; uint32_t burst_len; /* Flag indicating memory input stream */ enum msm_stream_memory_input_t memory_input; }; struct msm_vfe_axi_stream_release_cmd { uint32_t stream_handle; }; enum msm_vfe_axi_stream_cmd { STOP_STREAM, START_STREAM, STOP_IMMEDIATELY, }; struct msm_vfe_axi_stream_cfg_cmd { uint8_t num_streams; uint32_t stream_handle[VFE_AXI_SRC_MAX]; enum msm_vfe_axi_stream_cmd cmd; uint8_t sync_frame_id_src; }; enum msm_vfe_axi_stream_update_type { ENABLE_STREAM_BUF_DIVERT, DISABLE_STREAM_BUF_DIVERT, UPDATE_STREAM_FRAMEDROP_PATTERN, UPDATE_STREAM_STATS_FRAMEDROP_PATTERN, UPDATE_STREAM_AXI_CONFIG, UPDATE_STREAM_REQUEST_FRAMES, UPDATE_STREAM_ADD_BUFQ, UPDATE_STREAM_REMOVE_BUFQ, UPDATE_STREAM_SW_FRAME_DROP, }; enum msm_vfe_iommu_type { IOMMU_ATTACH, IOMMU_DETACH, }; enum msm_vfe_buff_queue_id { VFE_BUF_QUEUE_DEFAULT, VFE_BUF_QUEUE_SHARED, VFE_BUF_QUEUE_MAX, }; struct msm_vfe_axi_stream_cfg_update_info { uint32_t stream_handle; uint32_t output_format; uint32_t user_stream_id; uint32_t frame_id; enum msm_vfe_frame_skip_pattern skip_pattern; struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM]; struct msm_isp_sw_framskip sw_skip_info; }; struct msm_vfe_axi_halt_cmd { uint32_t stop_camif; uint32_t overflow_detected; uint32_t blocking_halt; }; struct msm_vfe_axi_reset_cmd { uint32_t blocking; uint32_t frame_id; }; struct msm_vfe_axi_restart_cmd { uint32_t enable_camif; }; struct msm_vfe_axi_stream_update_cmd { uint32_t num_streams; enum msm_vfe_axi_stream_update_type update_type; struct msm_vfe_axi_stream_cfg_update_info update_info[MSM_ISP_STATS_MAX]; }; struct msm_vfe_smmu_attach_cmd { uint32_t security_mode; uint32_t iommu_attach_mode; }; struct msm_vfe_stats_stream_request_cmd { uint32_t session_id; uint32_t stream_id; enum msm_isp_stats_type stats_type; uint32_t composite_flag; uint32_t framedrop_pattern; uint32_t init_frame_drop; /*MAX 31 Frames*/ uint32_t irq_subsample_pattern; uint32_t buffer_offset; uint32_t stream_handle; }; struct msm_vfe_stats_stream_release_cmd { uint32_t stream_handle; }; struct msm_vfe_stats_stream_cfg_cmd { uint8_t num_streams; uint32_t stream_handle[MSM_ISP_STATS_MAX]; uint8_t enable; uint32_t stats_burst_len; }; enum msm_vfe_reg_cfg_type { VFE_WRITE, VFE_WRITE_MB, VFE_READ, VFE_CFG_MASK, VFE_WRITE_DMI_16BIT, VFE_WRITE_DMI_32BIT, VFE_WRITE_DMI_64BIT, VFE_READ_DMI_16BIT, VFE_READ_DMI_32BIT, VFE_READ_DMI_64BIT, GET_MAX_CLK_RATE, GET_CLK_RATES, GET_ISP_ID, VFE_HW_UPDATE_LOCK, VFE_HW_UPDATE_UNLOCK, SET_WM_UB_SIZE, SET_UB_POLICY, }; struct msm_vfe_cfg_cmd2 { uint16_t num_cfg; uint16_t cmd_len; void __user *cfg_data; void __user *cfg_cmd; }; struct msm_vfe_cfg_cmd_list { struct msm_vfe_cfg_cmd2 cfg_cmd; struct msm_vfe_cfg_cmd_list *next; uint32_t next_size; }; struct msm_vfe_reg_rw_info { uint32_t reg_offset; uint32_t cmd_data_offset; uint32_t len; }; struct msm_vfe_reg_mask_info { uint32_t reg_offset; uint32_t mask; uint32_t val; }; struct msm_vfe_reg_dmi_info { uint32_t hi_tbl_offset; /*Optional*/ uint32_t lo_tbl_offset; /*Required*/ uint32_t len; }; struct msm_vfe_reg_cfg_cmd { union { struct msm_vfe_reg_rw_info rw_info; struct msm_vfe_reg_mask_info mask_info; struct msm_vfe_reg_dmi_info dmi_info; } u; enum msm_vfe_reg_cfg_type cmd_type; }; enum vfe_sd_type { VFE_SD_0 = 0, VFE_SD_1, VFE_SD_COMMON, VFE_SD_MAX, }; /* When you change the value below, check for the sof event_data size. * V4l2 limits payload to 64 bytes */ #define MS_NUM_SLAVE_MAX 1 /* Usecases when 2 HW need to be related or synced */ enum msm_vfe_dual_hw_type { DUAL_NONE = 0, DUAL_HW_VFE_SPLIT = 1, DUAL_HW_MASTER_SLAVE = 2, }; /* Type for 2 INTF when used in Master-Slave mode */ enum msm_vfe_dual_hw_ms_type { MS_TYPE_NONE, MS_TYPE_MASTER, MS_TYPE_SLAVE, }; struct msm_isp_set_dual_hw_ms_cmd { uint8_t num_src; /* Each session can be only one type but multiple intf if YUV cam */ enum msm_vfe_dual_hw_ms_type dual_hw_ms_type; /* Primary intf is mostly associated with preview. * This primary intf SOF frame_id and timestamp is tracked * and used to calculate delta */ enum msm_vfe_input_src primary_intf; /* input_src array indicates other input INTF that may be Master/Slave. * For these additional intf, frame_id and timestamp are not saved. * However, if these are slaves then they will still get their * frame_id from Master */ enum msm_vfe_input_src input_src[VFE_SRC_MAX]; uint32_t sof_delta_threshold; /* In milliseconds. Sent for Master */ }; enum msm_isp_buf_type { ISP_PRIVATE_BUF, ISP_SHARE_BUF, MAX_ISP_BUF_TYPE, }; struct msm_isp_unmap_buf_req { uint32_t fd; }; struct msm_isp_buf_request { uint32_t session_id; uint32_t stream_id; uint8_t num_buf; uint32_t handle; enum msm_isp_buf_type buf_type; }; struct msm_isp_qbuf_plane { uint32_t addr; uint32_t offset; uint32_t length; }; struct msm_isp_qbuf_buffer { struct msm_isp_qbuf_plane planes[MAX_PLANES_PER_STREAM]; uint32_t num_planes; }; struct msm_isp_qbuf_info { uint32_t handle; int32_t buf_idx; /*Only used for prepare buffer*/ struct msm_isp_qbuf_buffer buffer; /*Only used for diverted buffer*/ uint32_t dirty_buf; }; struct msm_isp_clk_rates { uint32_t svs_rate; uint32_t nominal_rate; uint32_t high_rate; }; struct msm_vfe_axi_src_state { enum msm_vfe_input_src input_src; uint32_t src_active; uint32_t src_frame_id; }; enum msm_isp_event_mask_index { ISP_EVENT_MASK_INDEX_STATS_NOTIFY = 0, ISP_EVENT_MASK_INDEX_ERROR = 1, ISP_EVENT_MASK_INDEX_IOMMU_P_FAULT = 2, ISP_EVENT_MASK_INDEX_STREAM_UPDATE_DONE = 3, ISP_EVENT_MASK_INDEX_REG_UPDATE = 4, ISP_EVENT_MASK_INDEX_SOF = 5, ISP_EVENT_MASK_INDEX_BUF_DIVERT = 6, ISP_EVENT_MASK_INDEX_COMP_STATS_NOTIFY = 7, ISP_EVENT_MASK_INDEX_MASK_FE_READ_DONE = 8, ISP_EVENT_MASK_INDEX_BUF_DONE = 9, ISP_EVENT_MASK_INDEX_REG_UPDATE_MISSING = 10, ISP_EVENT_MASK_INDEX_PING_PONG_MISMATCH = 11, ISP_EVENT_MASK_INDEX_BUF_FATAL_ERROR = 12, }; #define ISP_EVENT_SUBS_MASK_NONE 0 #define ISP_EVENT_SUBS_MASK_STATS_NOTIFY \ (1 << ISP_EVENT_MASK_INDEX_STATS_NOTIFY) #define ISP_EVENT_SUBS_MASK_ERROR \ (1 << ISP_EVENT_MASK_INDEX_ERROR) #define ISP_EVENT_SUBS_MASK_IOMMU_P_FAULT \ (1 << ISP_EVENT_MASK_INDEX_IOMMU_P_FAULT) #define ISP_EVENT_SUBS_MASK_STREAM_UPDATE_DONE \ (1 << ISP_EVENT_MASK_INDEX_STREAM_UPDATE_DONE) #define ISP_EVENT_SUBS_MASK_REG_UPDATE \ (1 << ISP_EVENT_MASK_INDEX_REG_UPDATE) #define ISP_EVENT_SUBS_MASK_SOF \ (1 << ISP_EVENT_MASK_INDEX_SOF) #define ISP_EVENT_SUBS_MASK_BUF_DIVERT \ (1 << ISP_EVENT_MASK_INDEX_BUF_DIVERT) #define ISP_EVENT_SUBS_MASK_COMP_STATS_NOTIFY \ (1 << ISP_EVENT_MASK_INDEX_COMP_STATS_NOTIFY) #define ISP_EVENT_SUBS_MASK_FE_READ_DONE \ (1 << ISP_EVENT_MASK_INDEX_MASK_FE_READ_DONE) #define ISP_EVENT_SUBS_MASK_BUF_DONE \ (1 << ISP_EVENT_MASK_INDEX_BUF_DONE) #define ISP_EVENT_SUBS_MASK_REG_UPDATE_MISSING \ (1 << ISP_EVENT_MASK_INDEX_REG_UPDATE_MISSING) #define ISP_EVENT_SUBS_MASK_PING_PONG_MISMATCH \ (1 << ISP_EVENT_MASK_INDEX_PING_PONG_MISMATCH) #define ISP_EVENT_SUBS_MASK_BUF_FATAL_ERROR \ (1 << ISP_EVENT_MASK_INDEX_BUF_FATAL_ERROR) enum msm_isp_event_idx { ISP_REG_UPDATE = 0, ISP_EPOCH_0 = 1, ISP_EPOCH_1 = 2, ISP_START_ACK = 3, ISP_STOP_ACK = 4, ISP_IRQ_VIOLATION = 5, ISP_STATS_OVERFLOW = 6, ISP_BUF_DONE = 7, ISP_FE_RD_DONE = 8, ISP_IOMMU_P_FAULT = 9, ISP_ERROR = 10, ISP_HW_FATAL_ERROR = 11, ISP_PING_PONG_MISMATCH = 12, ISP_REG_UPDATE_MISSING = 13, ISP_BUF_FATAL_ERROR = 14, ISP_EVENT_MAX = 15 }; #define ISP_EVENT_OFFSET 8 #define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START) #define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET)) #define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET)) #define ISP_CAMIF_EVENT_BASE (ISP_EVENT_BASE + (3 << ISP_EVENT_OFFSET)) #define ISP_STREAM_EVENT_BASE (ISP_EVENT_BASE + (4 << ISP_EVENT_OFFSET)) #define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE) #define ISP_EVENT_EPOCH_0 (ISP_EVENT_BASE + ISP_EPOCH_0) #define ISP_EVENT_EPOCH_1 (ISP_EVENT_BASE + ISP_EPOCH_1) #define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK) #define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK) #define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION) #define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW) #define ISP_EVENT_ERROR (ISP_EVENT_BASE + ISP_ERROR) #define ISP_EVENT_SOF (ISP_CAMIF_EVENT_BASE) #define ISP_EVENT_EOF (ISP_CAMIF_EVENT_BASE + 1) #define ISP_EVENT_BUF_DONE (ISP_EVENT_BASE + ISP_BUF_DONE) #define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE) #define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE) #define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX) #define ISP_EVENT_FE_READ_DONE (ISP_EVENT_BASE + ISP_FE_RD_DONE) #define ISP_EVENT_IOMMU_P_FAULT (ISP_EVENT_BASE + ISP_IOMMU_P_FAULT) #define ISP_EVENT_HW_FATAL_ERROR (ISP_EVENT_BASE + ISP_HW_FATAL_ERROR) #define ISP_EVENT_PING_PONG_MISMATCH (ISP_EVENT_BASE + ISP_PING_PONG_MISMATCH) #define ISP_EVENT_REG_UPDATE_MISSING (ISP_EVENT_BASE + ISP_REG_UPDATE_MISSING) #define ISP_EVENT_BUF_FATAL_ERROR (ISP_EVENT_BASE + ISP_BUF_FATAL_ERROR) #define ISP_EVENT_STREAM_UPDATE_DONE (ISP_STREAM_EVENT_BASE) /* The msm_v4l2_event_data structure should match the * v4l2_event.u.data field. * should not exceed 64 bytes */ struct msm_isp_buf_event { uint32_t session_id; uint32_t stream_id; uint32_t handle; uint32_t output_format; int8_t buf_idx; }; struct msm_isp_fetch_eng_event { uint32_t session_id; uint32_t stream_id; uint32_t handle; uint32_t fd; int8_t buf_idx; int8_t offline_mode; }; struct msm_isp_stats_event { uint32_t stats_mask; /* 4 bytes */ uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */ }; struct msm_isp_stream_ack { uint32_t session_id; uint32_t stream_id; uint32_t handle; }; enum msm_vfe_error_type { ISP_ERROR_NONE, ISP_ERROR_CAMIF, ISP_ERROR_BUS_OVERFLOW, ISP_ERROR_RETURN_EMPTY_BUFFER, ISP_ERROR_FRAME_ID_MISMATCH, ISP_ERROR_MAX, }; struct msm_isp_error_info { enum msm_vfe_error_type err_type; uint32_t session_id; uint32_t stream_id; uint32_t stream_id_mask; }; /* This structure reports delta between master and slave */ struct msm_isp_ms_delta_info { uint8_t num_delta_info; uint32_t delta[MS_NUM_SLAVE_MAX]; }; /* This is sent in EPOCH irq */ struct msm_isp_output_info { uint8_t regs_not_updated; /* mask with bufq_handle for regs not updated or return empty */ uint16_t output_err_mask; /* mask with stream_idx for get_buf failed */ uint8_t stream_framedrop_mask; /* mask with stats stream_idx for get_buf failed */ uint16_t stats_framedrop_mask; /* delta between master and slave */ }; /* This structure is piggybacked with SOF event */ struct msm_isp_sof_info { uint8_t regs_not_updated; /* mask with AXI_SRC for regs not updated */ uint16_t reg_update_fail_mask; /* mask with bufq_handle for get_buf failed */ uint32_t stream_get_buf_fail_mask; /* mask with stats stream_idx for get_buf failed */ uint16_t stats_get_buf_fail_mask; /* delta between master and slave */ struct msm_isp_ms_delta_info ms_delta_info; }; struct msm_isp_event_data { /*Wall clock except for buffer divert events *which use monotonic clock */ struct timeval timestamp; /* Monotonic timestamp since bootup */ struct timeval mono_timestamp; uint32_t frame_id; union { /* Sent for Stats_Done event */ struct msm_isp_stats_event stats; /* Sent for Buf_Divert event */ struct msm_isp_buf_event buf_done; /* Sent for offline fetch done event */ struct msm_isp_fetch_eng_event fetch_done; /* Sent for Error_Event */ struct msm_isp_error_info error_info; /* * This struct needs to be removed once * userspace switches to sof_info */ struct msm_isp_output_info output_info; /* Sent for SOF event */ struct msm_isp_sof_info sof_info; } u; /* union can have max 52 bytes */ }; #ifdef CONFIG_COMPAT struct msm_isp_event_data32 { struct compat_timeval timestamp; struct compat_timeval mono_timestamp; uint32_t frame_id; union { struct msm_isp_stats_event stats; struct msm_isp_buf_event buf_done; struct msm_isp_fetch_eng_event fetch_done; struct msm_isp_error_info error_info; struct msm_isp_output_info output_info; struct msm_isp_sof_info sof_info; } u; }; #endif #define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8') #define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8') #define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8') #define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8') #define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0') #define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0') #define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0') #define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0') #define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2') #define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2') #define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2') #define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2') #define V4L2_PIX_FMT_QBGGR14 v4l2_fourcc('Q', 'B', 'G', '4') #define V4L2_PIX_FMT_QGBRG14 v4l2_fourcc('Q', 'G', 'B', '4') #define V4L2_PIX_FMT_QGRBG14 v4l2_fourcc('Q', 'G', 'R', '4') #define V4L2_PIX_FMT_QRGGB14 v4l2_fourcc('Q', 'R', 'G', '4') #define V4L2_PIX_FMT_P16BGGR10 v4l2_fourcc('P', 'B', 'G', '0') #define V4L2_PIX_FMT_P16GBRG10 v4l2_fourcc('P', 'G', 'B', '0') #define V4L2_PIX_FMT_P16GRBG10 v4l2_fourcc('P', 'G', 'R', '0') #define V4L2_PIX_FMT_P16RGGB10 v4l2_fourcc('P', 'R', 'G', '0') #define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4') #define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1') #define V4L2_PIX_FMT_META v4l2_fourcc('Q', 'M', 'E', 'T') #define V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') /* 14 BGBG.GRGR.*/ #define V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') /* 14 GBGB.RGRG.*/ #define V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4') /* 14 GRGR.BGBG.*/ #define V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') /* 14 RGRG.GBGB.*/ #define VIDIOC_MSM_VFE_REG_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2) #define VIDIOC_MSM_ISP_REQUEST_BUF \ _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request) #define VIDIOC_MSM_ISP_ENQUEUE_BUF \ _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info) #define VIDIOC_MSM_ISP_RELEASE_BUF \ _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request) #define VIDIOC_MSM_ISP_REQUEST_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd) #define VIDIOC_MSM_ISP_CFG_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd) #define VIDIOC_MSM_ISP_RELEASE_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd) #define VIDIOC_MSM_ISP_INPUT_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg) #define VIDIOC_MSM_ISP_SET_SRC_STATE \ _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state) #define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+9, \ struct msm_vfe_stats_stream_request_cmd) #define VIDIOC_MSM_ISP_CFG_STATS_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd) #define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+11, \ struct msm_vfe_stats_stream_release_cmd) #define VIDIOC_MSM_ISP_REG_UPDATE_CMD \ _IOWR('V', BASE_VIDIOC_PRIVATE+12, enum msm_vfe_input_src) #define VIDIOC_MSM_ISP_UPDATE_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd) #define VIDIOC_MSM_VFE_REG_LIST_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE+14, struct msm_vfe_cfg_cmd_list) #define VIDIOC_MSM_ISP_SMMU_ATTACH \ _IOWR('V', BASE_VIDIOC_PRIVATE+15, struct msm_vfe_smmu_attach_cmd) #define VIDIOC_MSM_ISP_UPDATE_STATS_STREAM \ _IOWR('V', BASE_VIDIOC_PRIVATE+16, struct msm_vfe_axi_stream_update_cmd) #define VIDIOC_MSM_ISP_AXI_HALT \ _IOWR('V', BASE_VIDIOC_PRIVATE+17, struct msm_vfe_axi_halt_cmd) #define VIDIOC_MSM_ISP_AXI_RESET \ _IOWR('V', BASE_VIDIOC_PRIVATE+18, struct msm_vfe_axi_reset_cmd) #define VIDIOC_MSM_ISP_AXI_RESTART \ _IOWR('V', BASE_VIDIOC_PRIVATE+19, struct msm_vfe_axi_restart_cmd) #define VIDIOC_MSM_ISP_FETCH_ENG_START \ _IOWR('V', BASE_VIDIOC_PRIVATE+20, struct msm_vfe_fetch_eng_start) #define VIDIOC_MSM_ISP_DEQUEUE_BUF \ _IOWR('V', BASE_VIDIOC_PRIVATE+21, struct msm_isp_qbuf_info) #define VIDIOC_MSM_ISP_SET_DUAL_HW_MASTER_SLAVE \ _IOWR('V', BASE_VIDIOC_PRIVATE+22, struct msm_isp_set_dual_hw_ms_cmd) #define VIDIOC_MSM_ISP_MAP_BUF_START_FE \ _IOWR('V', BASE_VIDIOC_PRIVATE+23, struct msm_vfe_fetch_eng_start) #define VIDIOC_MSM_ISP_UNMAP_BUF \ _IOWR('V', BASE_VIDIOC_PRIVATE+24, struct msm_isp_unmap_buf_req) #endif /* __MSMB_ISP__ */ ================================================ FILE: selfdrive/camerad/include/msmb_ispif.h ================================================ #ifndef MSM_CAM_ISPIF_H #define MSM_CAM_ISPIF_H #define CSID_VERSION_V20 0x02000011 #define CSID_VERSION_V22 0x02001000 #define CSID_VERSION_V30 0x30000000 #define CSID_VERSION_V3 0x30000000 enum msm_ispif_vfe_intf { VFE0, VFE1, VFE_MAX }; #define VFE0_MASK (1 << VFE0) #define VFE1_MASK (1 << VFE1) enum msm_ispif_intftype { PIX0, RDI0, PIX1, RDI1, RDI2, INTF_MAX }; #define MAX_PARAM_ENTRIES (INTF_MAX * 2) #define MAX_CID_CH 8 #define PIX0_MASK (1 << PIX0) #define PIX1_MASK (1 << PIX1) #define RDI0_MASK (1 << RDI0) #define RDI1_MASK (1 << RDI1) #define RDI2_MASK (1 << RDI2) enum msm_ispif_vc { VC0, VC1, VC2, VC3, VC_MAX }; enum msm_ispif_cid { CID0, CID1, CID2, CID3, CID4, CID5, CID6, CID7, CID8, CID9, CID10, CID11, CID12, CID13, CID14, CID15, CID_MAX }; enum msm_ispif_csid { CSID0, CSID1, CSID2, CSID3, CSID_MAX }; struct msm_ispif_params_entry { enum msm_ispif_vfe_intf vfe_intf; enum msm_ispif_intftype intftype; int num_cids; enum msm_ispif_cid cids[3]; enum msm_ispif_csid csid; int crop_enable; uint16_t crop_start_pixel; uint16_t crop_end_pixel; }; struct msm_ispif_param_data { uint32_t num; struct msm_ispif_params_entry entries[MAX_PARAM_ENTRIES]; }; struct msm_isp_info { uint32_t max_resolution; uint32_t id; uint32_t ver; }; struct msm_ispif_vfe_info { int num_vfe; struct msm_isp_info info[VFE_MAX]; }; enum ispif_cfg_type_t { ISPIF_CLK_ENABLE, ISPIF_CLK_DISABLE, ISPIF_INIT, ISPIF_CFG, ISPIF_START_FRAME_BOUNDARY, ISPIF_RESTART_FRAME_BOUNDARY, ISPIF_STOP_FRAME_BOUNDARY, ISPIF_STOP_IMMEDIATELY, ISPIF_RELEASE, ISPIF_ENABLE_REG_DUMP, ISPIF_SET_VFE_INFO, }; struct ispif_cfg_data { enum ispif_cfg_type_t cfg_type; union { int reg_dump; /* ISPIF_ENABLE_REG_DUMP */ uint32_t csid_version; /* ISPIF_INIT */ struct msm_ispif_vfe_info vfe_info; /* ISPIF_SET_VFE_INFO */ struct msm_ispif_param_data params; /* CFG, START, STOP */ }; }; #define VIDIOC_MSM_ISPIF_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE, struct ispif_cfg_data) #endif /* MSM_CAM_ISPIF_H */ ================================================ FILE: selfdrive/camerad/main.cc ================================================ #include #include #include #include #include #include #include "libyuv.h" #include "cereal/visionipc/visionipc_server.h" #include "selfdrive/common/clutil.h" #include "selfdrive/common/params.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/common/util.h" #include "selfdrive/hardware/hw.h" #ifdef QCOM #include "selfdrive/camerad/cameras/camera_qcom.h" #elif QCOM2 #include "selfdrive/camerad/cameras/camera_qcom2.h" #elif WEBCAM #include "selfdrive/camerad/cameras/camera_webcam.h" #elif MIPI #include "selfdrive/camerad/cameras/camera_mipi.h" #else #include "selfdrive/camerad/cameras/camera_frame_stream.h" #endif ExitHandler do_exit; void party(cl_device_id device_id, cl_context context) { MultiCameraState cameras = {}; VisionIpcServer vipc_server("camerad", device_id, context); cameras_init(&vipc_server, &cameras, device_id, context); cameras_open(&cameras); vipc_server.start_listener(); cameras_run(&cameras); } #ifdef QCOM #include "CL/cl_ext_qcom.h" #endif int main(int argc, char *argv[]) { set_realtime_priority(53); if (Hardware::EON()) { set_core_affinity(2); } else if (Hardware::TICI()) { set_core_affinity(6); } else if (Hardware::JETSON()) { set_core_affinity(0); } #ifdef XNX cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_GPU); #else cl_device_id device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); #endif // TODO: do this for QCOM2 too #if defined(QCOM) const cl_context_properties props[] = {CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_HIGH_QCOM, 0}; cl_context context = CL_CHECK_ERR(clCreateContext(props, 1, &device_id, NULL, NULL, &err)); #else cl_context context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); #endif party(device_id, context); CL_CHECK(clReleaseContext(context)); } ================================================ FILE: selfdrive/camerad/snapshot/__init__.py ================================================ ================================================ FILE: selfdrive/camerad/snapshot/snapshot.py ================================================ #!/usr/bin/env python3 import os import subprocess import time import numpy as np from PIL import Image from typing import List import cereal.messaging as messaging from common.params import Params from common.realtime import DT_MDL from common.transformations.camera import eon_f_frame_size, eon_d_frame_size, leon_d_frame_size, tici_f_frame_size from selfdrive.hardware import TICI from selfdrive.controls.lib.alertmanager import set_offroad_alert from selfdrive.manager.process_config import managed_processes LM_THRESH = 120 # defined in selfdrive/camerad/imgproc/utils.h def jpeg_write(fn, dat): img = Image.fromarray(dat) img.save(fn, "JPEG") def extract_image(dat, frame_sizes): img = np.frombuffer(dat, dtype=np.uint8) w, h = frame_sizes[len(img) // 3] b = img[::3].reshape(h, w) g = img[1::3].reshape(h, w) r = img[2::3].reshape(h, w) return np.dstack([r, g, b]) def rois_in_focus(lapres: List[float]) -> float: sz = len(lapres) return sum([1. / sz for sharpness in lapres if sharpness >= LM_THRESH]) def get_snapshots(frame="roadCameraState", front_frame="driverCameraState", focus_perc_threshold=0.): frame_sizes = [eon_f_frame_size, eon_d_frame_size, leon_d_frame_size, tici_f_frame_size] frame_sizes = {w * h: (w, h) for (w, h) in frame_sizes} sockets = [] if frame is not None: sockets.append(frame) if front_frame is not None: sockets.append(front_frame) # wait 4 sec from camerad startup for focus and exposure sm = messaging.SubMaster(sockets) while sm[sockets[0]].frameId < int(4. / DT_MDL): sm.update() start_t = time.monotonic() while time.monotonic() - start_t < 10: sm.update() if min(sm.rcv_frame.values()) > 1 and rois_in_focus(sm[frame].sharpnessScore) >= focus_perc_threshold: break rear = extract_image(sm[frame].image, frame_sizes) if frame is not None else None front = extract_image(sm[front_frame].image, frame_sizes) if front_frame is not None else None return rear, front def snapshot(): params = Params() front_camera_allowed = params.get_bool("RecordFront") if (not params.get_bool("IsOffroad")) or params.get_bool("IsTakingSnapshot"): print("Already taking snapshot") return None, None params.put_bool("IsTakingSnapshot", True) set_offroad_alert("Offroad_IsTakingSnapshot", True) time.sleep(2.0) # Give thermald time to read the param, or if just started give camerad time to start # Check if camerad is already started try: subprocess.check_call(["pgrep", "camerad"]) print("Camerad already running") params.put_bool("IsTakingSnapshot", False) params.delete("Offroad_IsTakingSnapshot") return None, None except subprocess.CalledProcessError: pass os.environ["SEND_ROAD"] = "1" os.environ["SEND_WIDE_ROAD"] = "1" if front_camera_allowed: os.environ["SEND_DRIVER"] = "1" managed_processes['camerad'].start() frame = "wideRoadCameraState" if TICI else "roadCameraState" front_frame = "driverCameraState" if front_camera_allowed else None focus_perc_threshold = 0. if TICI else 10 / 12. rear, front = get_snapshots(frame, front_frame, focus_perc_threshold) managed_processes['camerad'].stop() params.put_bool("IsTakingSnapshot", False) set_offroad_alert("Offroad_IsTakingSnapshot", False) if not front_camera_allowed: front = None return rear, front if __name__ == "__main__": pic, fpic = snapshot() if pic is not None: print(pic.shape) jpeg_write("/tmp/back.jpg", pic) if fpic is not None: jpeg_write("/tmp/front.jpg", fpic) else: print("Error taking snapshot") ================================================ FILE: selfdrive/camerad/transforms/rgb_to_yuv.cc ================================================ #include "selfdrive/camerad/transforms/rgb_to_yuv.h" #include #include Rgb2Yuv::Rgb2Yuv(cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride) { assert(width % 2 == 0 && height % 2 == 0); char args[1024]; snprintf(args, sizeof(args), "-cl-fast-relaxed-math -cl-denorms-are-zero " #ifdef CL_DEBUG "-DCL_DEBUG " #endif "-DWIDTH=%d -DHEIGHT=%d -DUV_WIDTH=%d -DUV_HEIGHT=%d -DRGB_STRIDE=%d -DRGB_SIZE=%d", width, height, width / 2, height / 2, rgb_stride, width * height); cl_program prg = cl_program_from_file(ctx, device_id, "transforms/rgb_to_yuv.cl", args); krnl = CL_CHECK_ERR(clCreateKernel(prg, "rgb_to_yuv", &err)); CL_CHECK(clReleaseProgram(prg)); work_size[0] = (width + (width % 4 == 0 ? 0 : (4 - width % 4))) / 4; work_size[1] = (height + (height % 4 == 0 ? 0 : (4 - height % 4))) / 4; } Rgb2Yuv::~Rgb2Yuv() { CL_CHECK(clReleaseKernel(krnl)); } void Rgb2Yuv::queue(cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl) { CL_CHECK(clSetKernelArg(krnl, 0, sizeof(cl_mem), &rgb_cl)); CL_CHECK(clSetKernelArg(krnl, 1, sizeof(cl_mem), &yuv_cl)); cl_event event; CL_CHECK(clEnqueueNDRangeKernel(q, krnl, 2, NULL, &work_size[0], NULL, 0, 0, &event)); CL_CHECK(clWaitForEvents(1, &event)); CL_CHECK(clReleaseEvent(event)); } ================================================ FILE: selfdrive/camerad/transforms/rgb_to_yuv.cl ================================================ #define RGB_TO_Y(r, g, b) ((((mul24(b, 13) + mul24(g, 65) + mul24(r, 33)) + 64) >> 7) + 16) #define RGB_TO_U(r, g, b) ((mul24(b, 56) - mul24(g, 37) - mul24(r, 19) + 0x8080) >> 8) #define RGB_TO_V(r, g, b) ((mul24(r, 56) - mul24(g, 47) - mul24(b, 9) + 0x8080) >> 8) #define AVERAGE(x, y, z, w) ((convert_ushort(x) + convert_ushort(y) + convert_ushort(z) + convert_ushort(w) + 1) >> 1) inline void convert_2_ys(__global uchar * out_yuv, int yi, const uchar8 rgbs1) { uchar2 yy = (uchar2)( RGB_TO_Y(rgbs1.s2, rgbs1.s1, rgbs1.s0), RGB_TO_Y(rgbs1.s5, rgbs1.s4, rgbs1.s3) ); #ifdef CL_DEBUG if(yi >= RGB_SIZE) printf("Y vector2 overflow, %d > %d\n", yi, RGB_SIZE); #endif vstore2(yy, 0, out_yuv + yi); } inline void convert_4_ys(__global uchar * out_yuv, int yi, const uchar8 rgbs1, const uchar8 rgbs3) { const uchar4 yy = (uchar4)( RGB_TO_Y(rgbs1.s2, rgbs1.s1, rgbs1.s0), RGB_TO_Y(rgbs1.s5, rgbs1.s4, rgbs1.s3), RGB_TO_Y(rgbs3.s0, rgbs1.s7, rgbs1.s6), RGB_TO_Y(rgbs3.s3, rgbs3.s2, rgbs3.s1) ); #ifdef CL_DEBUG if(yi > RGB_SIZE - 4) printf("Y vector4 overflow, %d > %d\n", yi, RGB_SIZE - 4); #endif vstore4(yy, 0, out_yuv + yi); } inline void convert_uv(__global uchar * out_yuv, int ui, int vi, const uchar8 rgbs1, const uchar8 rgbs2) { // U & V: average of 2x2 pixels square const short ab = AVERAGE(rgbs1.s0, rgbs1.s3, rgbs2.s0, rgbs2.s3); const short ag = AVERAGE(rgbs1.s1, rgbs1.s4, rgbs2.s1, rgbs2.s4); const short ar = AVERAGE(rgbs1.s2, rgbs1.s5, rgbs2.s2, rgbs2.s5); #ifdef CL_DEBUG if(ui >= RGB_SIZE + RGB_SIZE / 4) printf("U overflow, %d >= %d\n", ui, RGB_SIZE + RGB_SIZE / 4); if(vi >= RGB_SIZE + RGB_SIZE / 2) printf("V overflow, %d >= %d\n", vi, RGB_SIZE + RGB_SIZE / 2); #endif out_yuv[ui] = RGB_TO_U(ar, ag, ab); out_yuv[vi] = RGB_TO_V(ar, ag, ab); } inline void convert_2_uvs(__global uchar * out_yuv, int ui, int vi, const uchar8 rgbs1, const uchar8 rgbs2, const uchar8 rgbs3, const uchar8 rgbs4) { // U & V: average of 2x2 pixels square const short ab1 = AVERAGE(rgbs1.s0, rgbs1.s3, rgbs2.s0, rgbs2.s3); const short ag1 = AVERAGE(rgbs1.s1, rgbs1.s4, rgbs2.s1, rgbs2.s4); const short ar1 = AVERAGE(rgbs1.s2, rgbs1.s5, rgbs2.s2, rgbs2.s5); const short ab2 = AVERAGE(rgbs1.s6, rgbs3.s1, rgbs2.s6, rgbs4.s1); const short ag2 = AVERAGE(rgbs1.s7, rgbs3.s2, rgbs2.s7, rgbs4.s2); const short ar2 = AVERAGE(rgbs3.s0, rgbs3.s3, rgbs4.s0, rgbs4.s3); uchar2 u2 = (uchar2)( RGB_TO_U(ar1, ag1, ab1), RGB_TO_U(ar2, ag2, ab2) ); uchar2 v2 = (uchar2)( RGB_TO_V(ar1, ag1, ab1), RGB_TO_V(ar2, ag2, ab2) ); #ifdef CL_DEBUG1 if(ui > RGB_SIZE + RGB_SIZE / 4 - 2) printf("U 2 overflow, %d >= %d\n", ui, RGB_SIZE + RGB_SIZE / 4 - 2); if(vi > RGB_SIZE + RGB_SIZE / 2 - 2) printf("V 2 overflow, %d >= %d\n", vi, RGB_SIZE + RGB_SIZE / 2 - 2); #endif vstore2(u2, 0, out_yuv + ui); vstore2(v2, 0, out_yuv + vi); } __kernel void rgb_to_yuv(__global uchar const * const rgb, __global uchar * out_yuv) { const int dx = get_global_id(0); const int dy = get_global_id(1); const int col = mul24(dx, 4); // Current column in rgb image const int row = mul24(dy, 4); // Current row in rgb image const int bgri_start = mad24(row, RGB_STRIDE, mul24(col, 3)); // Start offset of rgb data being converted const int yi_start = mad24(row, WIDTH, col); // Start offset in the target yuv buffer int ui = mad24(row / 2, UV_WIDTH, RGB_SIZE + col / 2); int vi = mad24(row / 2 , UV_WIDTH, RGB_SIZE + UV_WIDTH * UV_HEIGHT + col / 2); int num_col = min(WIDTH - col, 4); int num_row = min(HEIGHT - row, 4); if(num_row == 4) { const uchar8 rgbs0_0 = vload8(0, rgb + bgri_start); const uchar8 rgbs0_1 = vload8(0, rgb + bgri_start + 8); const uchar8 rgbs1_0 = vload8(0, rgb + bgri_start + RGB_STRIDE); const uchar8 rgbs1_1 = vload8(0, rgb + bgri_start + RGB_STRIDE + 8); const uchar8 rgbs2_0 = vload8(0, rgb + bgri_start + RGB_STRIDE * 2); const uchar8 rgbs2_1 = vload8(0, rgb + bgri_start + RGB_STRIDE * 2 + 8); const uchar8 rgbs3_0 = vload8(0, rgb + bgri_start + RGB_STRIDE * 3); const uchar8 rgbs3_1 = vload8(0, rgb + bgri_start + RGB_STRIDE * 3 + 8); if(num_col == 4) { convert_4_ys(out_yuv, yi_start, rgbs0_0, rgbs0_1); convert_4_ys(out_yuv, yi_start + WIDTH, rgbs1_0, rgbs1_1); convert_4_ys(out_yuv, yi_start + WIDTH * 2, rgbs2_0, rgbs2_1); convert_4_ys(out_yuv, yi_start + WIDTH * 3, rgbs3_0, rgbs3_1); convert_2_uvs(out_yuv, ui, vi, rgbs0_0, rgbs1_0, rgbs0_1, rgbs1_1); convert_2_uvs(out_yuv, ui + UV_WIDTH, vi + UV_WIDTH, rgbs2_0, rgbs3_0, rgbs2_1, rgbs3_1); } else if(num_col == 2) { convert_2_ys(out_yuv, yi_start, rgbs0_0); convert_2_ys(out_yuv, yi_start + WIDTH, rgbs1_0); convert_2_ys(out_yuv, yi_start + WIDTH * 2, rgbs2_0); convert_2_ys(out_yuv, yi_start + WIDTH * 3, rgbs3_0); convert_uv(out_yuv, ui, vi, rgbs0_0, rgbs1_0); convert_uv(out_yuv, ui + UV_WIDTH, vi + UV_WIDTH, rgbs2_0, rgbs3_0); } } else { const uchar8 rgbs0_0 = vload8(0, rgb + bgri_start); const uchar8 rgbs0_1 = vload8(0, rgb + bgri_start + 8); const uchar8 rgbs1_0 = vload8(0, rgb + bgri_start + RGB_STRIDE); const uchar8 rgbs1_1 = vload8(0, rgb + bgri_start + RGB_STRIDE + 8); if(num_col == 4) { convert_4_ys(out_yuv, yi_start, rgbs0_0, rgbs0_1); convert_4_ys(out_yuv, yi_start + WIDTH, rgbs1_0, rgbs1_1); convert_2_uvs(out_yuv, ui, vi, rgbs0_0, rgbs1_0, rgbs0_1, rgbs1_1); } else if(num_col == 2) { convert_2_ys(out_yuv, yi_start, rgbs0_0); convert_2_ys(out_yuv, yi_start + WIDTH, rgbs1_0); convert_uv(out_yuv, ui, vi, rgbs0_0, rgbs1_0); } } } ================================================ FILE: selfdrive/camerad/transforms/rgb_to_yuv.h ================================================ #pragma once #include "selfdrive/common/clutil.h" class Rgb2Yuv { public: Rgb2Yuv(cl_context ctx, cl_device_id device_id, int width, int height, int rgb_stride); ~Rgb2Yuv(); void queue(cl_command_queue q, cl_mem rgb_cl, cl_mem yuv_cl); private: size_t work_size[2]; cl_kernel krnl; }; ================================================ FILE: selfdrive/camerad/transforms/rgb_to_yuv_test.cc ================================================ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef ANDROID #define MAXE 0 #include #else // The libyuv implementation on ARM is slightly different than on x86 // Our implementation matches the ARM version, so accept errors of 1 #define MAXE 1 #endif #include #include "libyuv.h" #include "selfdrive/camerad/transforms/rgb_to_yuv.h" #include "selfdrive/common/clutil.h" static inline double millis_since_boot() { struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); return t.tv_sec * 1000.0 + t.tv_nsec * 1e-6; } void cl_init(cl_device_id &device_id, cl_context &context) { device_id = cl_get_device_id(CL_DEVICE_TYPE_DEFAULT); context = CL_CHECK_ERR(clCreateContext(NULL, 1, &device_id, NULL, NULL, &err)); } bool compare_results(uint8_t *a, uint8_t *b, int len, int stride, int width, int height, uint8_t *rgb) { int min_diff = 0., max_diff = 0., max_e = 0.; int e1 = 0, e0 = 0; int e0y = 0, e0u = 0, e0v = 0, e1y = 0, e1u = 0, e1v = 0; int max_e_i = 0; for (int i = 0;i < len;i++) { int e = ((int)a[i]) - ((int)b[i]); if(e < min_diff) { min_diff = e; } if(e > max_diff) { max_diff = e; } int e_abs = std::abs(e); if(e_abs > max_e) { max_e = e_abs; max_e_i = i; } if(e_abs < 1) { e0++; if(i < stride * height) e0y++; else if(i < stride * height + stride * height / 4) e0u++; else e0v++; } else { e1++; if(i < stride * height) e1y++; else if(i < stride * height + stride * height / 4) e1u++; else e1v++; } } //printf("max diff : %d, min diff : %d, e < 1: %d, e >= 1: %d\n", max_diff, min_diff, e0, e1); //printf("Y: e < 1: %d, e >= 1: %d, U: e < 1: %d, e >= 1: %d, V: e < 1: %d, e >= 1: %d\n", e0y, e1y, e0u, e1u, e0v, e1v); if(max_e <= MAXE) { return true; } int row = max_e_i / stride; if(row < height) { printf("max error is Y: %d = (libyuv: %u - cl: %u), row: %d, col: %d\n", max_e, a[max_e_i], b[max_e_i], row, max_e_i % stride); } else if(row >= height && row < (height + height / 4)) { printf("max error is U: %d = %u - %u, row: %d, col: %d\n", max_e, a[max_e_i], b[max_e_i], (row - height) / 2, max_e_i % stride / 2); } else { printf("max error is V: %d = %u - %u, row: %d, col: %d\n", max_e, a[max_e_i], b[max_e_i], (row - height - height / 4) / 2, max_e_i % stride / 2); } return false; } int main(int argc, char** argv) { srand(1337); cl_device_id device_id; cl_context context; cl_init(device_id, context) ; int err; const cl_queue_properties props[] = {0}; //CL_QUEUE_PRIORITY_KHR, CL_QUEUE_PRIORITY_HIGH_KHR, 0}; cl_command_queue q = clCreateCommandQueueWithProperties(context, device_id, props, &err); if(err != 0) { std::cout << "clCreateCommandQueueWithProperties error: " << err << std::endl; } int width = 1164; int height = 874; int opt = 0; while ((opt = getopt(argc, argv, "f")) != -1) { switch (opt) { case 'f': std::cout << "Using front camera dimensions" << std::endl; int width = 1152; int height = 846; } } std::cout << "Width: " << width << " Height: " << height << std::endl; uint8_t *rgb_frame = new uint8_t[width * height * 3]; RGBToYUVState rgb_to_yuv_state; rgb_to_yuv_init(&rgb_to_yuv_state, context, device_id, width, height, width * 3); int frame_yuv_buf_size = width * height * 3 / 2; cl_mem yuv_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, frame_yuv_buf_size, (void*)NULL, &err)); uint8_t *frame_yuv_buf = new uint8_t[frame_yuv_buf_size]; uint8_t *frame_yuv_ptr_y = frame_yuv_buf; uint8_t *frame_yuv_ptr_u = frame_yuv_buf + (width * height); uint8_t *frame_yuv_ptr_v = frame_yuv_ptr_u + ((width/2) * (height/2)); cl_mem rgb_cl = CL_CHECK_ERR(clCreateBuffer(context, CL_MEM_READ_WRITE, width * height * 3, (void*)NULL, &err)); int mismatched = 0; int counter = 0; srand (time(NULL)); for (int i = 0; i < 100; i++) { for (int i = 0; i < width * height * 3; i++) { rgb_frame[i] = (uint8_t)rand(); } double t1 = millis_since_boot(); libyuv::RGB24ToI420((uint8_t*)rgb_frame, width * 3, frame_yuv_ptr_y, width, frame_yuv_ptr_u, width/2, frame_yuv_ptr_v, width/2, width, height); double t2 = millis_since_boot(); //printf("Libyuv: rgb to yuv: %.2fms\n", t2-t1); clEnqueueWriteBuffer(q, rgb_cl, CL_TRUE, 0, width * height * 3, (void *)rgb_frame, 0, NULL, NULL); t1 = millis_since_boot(); rgb_to_yuv_queue(&rgb_to_yuv_state, q, rgb_cl, yuv_cl); t2 = millis_since_boot(); //printf("OpenCL: rgb to yuv: %.2fms\n", t2-t1); uint8_t *yyy = (uint8_t *)clEnqueueMapBuffer(q, yuv_cl, CL_TRUE, CL_MAP_READ, 0, frame_yuv_buf_size, 0, NULL, NULL, &err); if(!compare_results(frame_yuv_ptr_y, yyy, frame_yuv_buf_size, width, width, height, (uint8_t*)rgb_frame)) mismatched++; clEnqueueUnmapMemObject(q, yuv_cl, yyy, 0, NULL, NULL); // std::this_thread::sleep_for(std::chrono::milliseconds(20)); if(counter++ % 100 == 0) printf("Matched: %d, Mismatched: %d\n", counter - mismatched, mismatched); } printf("Matched: %d, Mismatched: %d\n", counter - mismatched, mismatched); delete[] frame_yuv_buf; rgb_to_yuv_destroy(&rgb_to_yuv_state); clReleaseContext(context); delete[] rgb_frame; if (mismatched == 0) return 0; else return -1; } ================================================ FILE: selfdrive/car/__init__.py ================================================ # functions common among cars from common.numpy_fast import clip # kg of standard extra cargo to count for drive, gas, etc... STD_CARGO_KG = 136. def gen_empty_fingerprint(): return {i: {} for i in range(0, 4)} # FIXME: hardcoding honda civic 2016 touring params so they can be used to # scale unknown params for other cars class CivicParams: MASS = 1326. + STD_CARGO_KG WHEELBASE = 2.70 CENTER_TO_FRONT = WHEELBASE * 0.4 CENTER_TO_REAR = WHEELBASE - CENTER_TO_FRONT ROTATIONAL_INERTIA = 2500 TIRE_STIFFNESS_FRONT = 192150 TIRE_STIFFNESS_REAR = 202500 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase def scale_rot_inertia(mass, wheelbase): return CivicParams.ROTATIONAL_INERTIA * mass * wheelbase ** 2 / (CivicParams.MASS * CivicParams.WHEELBASE ** 2) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors def scale_tire_stiffness(mass, wheelbase, center_to_front, tire_stiffness_factor=1.0): center_to_rear = wheelbase - center_to_front tire_stiffness_front = (CivicParams.TIRE_STIFFNESS_FRONT * tire_stiffness_factor) * mass / CivicParams.MASS * \ (center_to_rear / wheelbase) / (CivicParams.CENTER_TO_REAR / CivicParams.WHEELBASE) tire_stiffness_rear = (CivicParams.TIRE_STIFFNESS_REAR * tire_stiffness_factor) * mass / CivicParams.MASS * \ (center_to_front / wheelbase) / (CivicParams.CENTER_TO_FRONT / CivicParams.WHEELBASE) return tire_stiffness_front, tire_stiffness_rear def dbc_dict(pt_dbc, radar_dbc, chassis_dbc=None, body_dbc=None): return {'pt': pt_dbc, 'radar': radar_dbc, 'chassis': chassis_dbc, 'body': body_dbc} def apply_std_steer_torque_limits(apply_torque, apply_torque_last, driver_torque, LIMITS): # limits due to driver torque driver_max_torque = LIMITS.STEER_MAX + (LIMITS.STEER_DRIVER_ALLOWANCE + driver_torque * LIMITS.STEER_DRIVER_FACTOR) * LIMITS.STEER_DRIVER_MULTIPLIER driver_min_torque = -LIMITS.STEER_MAX + (-LIMITS.STEER_DRIVER_ALLOWANCE + driver_torque * LIMITS.STEER_DRIVER_FACTOR) * LIMITS.STEER_DRIVER_MULTIPLIER max_steer_allowed = max(min(LIMITS.STEER_MAX, driver_max_torque), 0) min_steer_allowed = min(max(-LIMITS.STEER_MAX, driver_min_torque), 0) apply_torque = clip(apply_torque, min_steer_allowed, max_steer_allowed) # slow rate if steer torque increases in magnitude if apply_torque_last > 0: apply_torque = clip(apply_torque, max(apply_torque_last - LIMITS.STEER_DELTA_DOWN, -LIMITS.STEER_DELTA_UP), apply_torque_last + LIMITS.STEER_DELTA_UP) else: apply_torque = clip(apply_torque, apply_torque_last - LIMITS.STEER_DELTA_UP, min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP)) return int(round(float(apply_torque))) def apply_toyota_steer_torque_limits(apply_torque, apply_torque_last, motor_torque, LIMITS): # limits due to comparison of commanded torque VS motor reported torque max_lim = min(max(motor_torque + LIMITS.STEER_ERROR_MAX, LIMITS.STEER_ERROR_MAX), LIMITS.STEER_MAX) min_lim = max(min(motor_torque - LIMITS.STEER_ERROR_MAX, -LIMITS.STEER_ERROR_MAX), -LIMITS.STEER_MAX) apply_torque = clip(apply_torque, min_lim, max_lim) # slow rate if steer torque increases in magnitude if apply_torque_last > 0: apply_torque = clip(apply_torque, max(apply_torque_last - LIMITS.STEER_DELTA_DOWN, -LIMITS.STEER_DELTA_UP), apply_torque_last + LIMITS.STEER_DELTA_UP) else: apply_torque = clip(apply_torque, apply_torque_last - LIMITS.STEER_DELTA_UP, min(apply_torque_last + LIMITS.STEER_DELTA_DOWN, LIMITS.STEER_DELTA_UP)) return int(round(float(apply_torque))) def crc8_pedal(data): crc = 0xFF # standard init value poly = 0xD5 # standard crc8: x8+x7+x6+x4+x2+1 size = len(data) for i in range(size - 1, -1, -1): crc ^= data[i] for _ in range(8): if ((crc & 0x80) != 0): crc = ((crc << 1) ^ poly) & 0xFF else: crc <<= 1 return crc def create_gas_command(packer, gas_amount, idx): # Common gas pedal msg generator enable = gas_amount > 0.001 values = { "ENABLE": enable, "COUNTER_PEDAL": idx & 0xF, } if enable: values["GAS_COMMAND"] = gas_amount * 255. values["GAS_COMMAND2"] = gas_amount * 255. dat = packer.make_can_msg("GAS_COMMAND", 0, values)[2] checksum = crc8_pedal(dat[:-1]) values["CHECKSUM_PEDAL"] = checksum return packer.make_can_msg("GAS_COMMAND", 0, values) def make_can_msg(addr, dat, bus): return [addr, 0, dat, bus] ================================================ FILE: selfdrive/car/car_helpers.py ================================================ import os import json import threading import requests from common.params import Params, put_nonblocking from common.basedir import BASEDIR from selfdrive.version import comma_remote, tested_branch from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars from selfdrive.car.vin import get_vin, VIN_UNKNOWN from selfdrive.car.fw_versions import get_fw_versions, match_fw_to_car from selfdrive.swaglog import cloudlog import cereal.messaging as messaging from selfdrive.car import gen_empty_fingerprint import selfdrive.crash as crash from cereal import car EventName = car.CarEvent.EventName def get_startup_event(car_recognized, controller_available, fuzzy_fingerprint, fw_seen): if True: event = EventName.startup else: event = EventName.startupMaster if not car_recognized: if fw_seen: event = EventName.startupNoCar else: event = EventName.startupNoFw elif car_recognized and not controller_available: event = EventName.startupNoControl elif car_recognized and fuzzy_fingerprint: event = EventName.startupFuzzyFingerprint return event def get_one_can(logcan): while True: can = messaging.recv_one_retry(logcan) if len(can.can) > 0: return can def load_interfaces(brand_names): ret = {} for brand_name in brand_names: path = ('selfdrive.car.%s' % brand_name) CarInterface = __import__(path + '.interface', fromlist=['CarInterface']).CarInterface if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carstate.py'): CarState = __import__(path + '.carstate', fromlist=['CarState']).CarState else: CarState = None if os.path.exists(BASEDIR + '/' + path.replace('.', '/') + '/carcontroller.py'): CarController = __import__(path + '.carcontroller', fromlist=['CarController']).CarController else: CarController = None for model_name in brand_names[brand_name]: ret[model_name] = (CarInterface, CarController, CarState) return ret def _get_interface_names(): # read all the folders in selfdrive/car and return a dict where: # - keys are all the car names that which we have an interface for # - values are lists of spefic car models for a given car brand_names = {} for car_folder in [x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]: try: brand_name = car_folder.split('/')[-1] model_names = __import__('selfdrive.car.%s.values' % brand_name, fromlist=['CAR']).CAR model_names = [getattr(model_names, c) for c in model_names.__dict__.keys() if not c.startswith("__")] brand_names[brand_name] = model_names except (ImportError, IOError): pass return brand_names # imports from directory selfdrive/car// interface_names = _get_interface_names() interfaces = load_interfaces(interface_names) def only_toyota_left(candidate_cars): return all(("TOYOTA" in c or "LEXUS" in c) for c in candidate_cars) and len(candidate_cars) > 0 # **** for use live only **** def fingerprint(logcan, sendcan): dp_car_assigned = Params().get('dp_car_assigned', encoding='utf8') fixed_fingerprint = os.environ.get('FINGERPRINT', "" if dp_car_assigned is None else dp_car_assigned) skip_fw_query = os.environ.get('SKIP_FW_QUERY', False) if not fixed_fingerprint and not skip_fw_query: # Vin query only reliably works thorugh OBDII bus = 1 cached_params = Params().get("CarParamsCache") if cached_params is not None: cached_params = car.CarParams.from_bytes(cached_params) if cached_params.carName == "mock": cached_params = None if cached_params is not None and len(cached_params.carFw) > 0 and cached_params.carVin is not VIN_UNKNOWN: cloudlog.warning("Using cached CarParams") vin = cached_params.carVin car_fw = list(cached_params.carFw) else: cloudlog.warning("Getting VIN & FW versions") _, vin = get_vin(logcan, sendcan, bus) car_fw = get_fw_versions(logcan, sendcan, bus) exact_fw_match, fw_candidates = match_fw_to_car(car_fw) else: vin = VIN_UNKNOWN exact_fw_match, fw_candidates, car_fw = True, set(), [] cloudlog.warning("VIN %s", vin) Params().put("CarVin", vin) finger = gen_empty_fingerprint() candidate_cars = {i: all_legacy_fingerprint_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1 frame = 0 frame_fingerprint = 10 # 0.1s car_fingerprint = None done = False while not done: a = get_one_can(logcan) for can in a.can: # need to independently try to fingerprint both bus 0 and 1 to work # for the combo black_panda and honda_bosch. Ignore extended messages # and VIN query response. # Include bus 2 for toyotas to disambiguate cars using camera messages # (ideally should be done for all cars but we can't for Honda Bosch) if can.src in range(0, 4): finger[can.src][can.address] = len(can.dat) for b in candidate_cars: if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \ can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]: candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b]) # if we only have one car choice and the time since we got our first # message has elapsed, exit for b in candidate_cars: # Toyota needs higher time to fingerprint, since DSU does not broadcast immediately if only_toyota_left(candidate_cars[b]): frame_fingerprint = 100 # 1s if len(candidate_cars[b]) == 1 and frame > frame_fingerprint: # fingerprint done car_fingerprint = candidate_cars[b][0] # bail if no cars left or we've been waiting for more than 2s failed = (all(len(cc) == 0 for cc in candidate_cars.values()) and frame > frame_fingerprint) or frame > 200 succeeded = car_fingerprint is not None done = failed or succeeded frame += 1 exact_match = True source = car.CarParams.FingerprintSource.can # If FW query returns exactly 1 candidate, use it if len(fw_candidates) == 1: car_fingerprint = list(fw_candidates)[0] source = car.CarParams.FingerprintSource.fw exact_match = exact_fw_match if fixed_fingerprint: car_fingerprint = fixed_fingerprint source = car.CarParams.FingerprintSource.fixed cloudlog.event("fingerprinted", car_fingerprint=car_fingerprint, source=source, fuzzy=not exact_match, fw_count=len(car_fw)) return car_fingerprint, finger, vin, car_fw, source, exact_match def is_connected_to_internet(timeout=5): try: requests.get("https://sentry.io", timeout=timeout) return True except Exception: return False def crash_log(candidate): while True: if is_connected_to_internet(): crash.capture_warning("fingerprinted %s" % candidate) break def crash_log2(fingerprints, fw): while True: if is_connected_to_internet(): crash.capture_warning("car doesn't match any fingerprints: %s" % fingerprints) crash.capture_warning("car doesn't match any fw: %s" % fw) break def get_car(logcan, sendcan): candidate, fingerprints, vin, car_fw, source, exact_match = fingerprint(logcan, sendcan) if candidate is None: cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints) candidate = "mock" y = threading.Thread(target=crash_log2, args=(fingerprints,car_fw,)) y.start() x = threading.Thread(target=crash_log, args=(candidate,)) x.start() try: CarInterface, CarController, CarState = interfaces[candidate] car_params = CarInterface.get_params(candidate, fingerprints, car_fw) candidate_changed = Params().get('dp_last_candidate', encoding='utf8') != candidate put_nonblocking("dp_sr_stock", str(car_params.steerRatio)) # update steering_ratio init val dp_sr_custom = Params().get("dp_sr_custom", encoding='utf8') if dp_sr_custom == '' or candidate_changed or (dp_sr_custom != '' and float(dp_sr_custom) <= 9.99): put_nonblocking("dp_sr_custom", str(car_params.steerRatio)) # update last candidate put_nonblocking('dp_last_candidate', candidate) car_params.carVin = vin car_params.carFw = car_fw car_params.fingerprintSource = source car_params.fuzzyFingerprint = not exact_match return CarInterface(car_params, CarController, CarState), car_params except KeyError: put_nonblocking("dp_last_candidate", '') put_nonblocking("dp_car_assigned", '') put_nonblocking("dp_sr_custom", '9.99') put_nonblocking("dp_sr_stock", '9.99') return None, None ================================================ FILE: selfdrive/car/chrysler/__init__.py ================================================ ================================================ FILE: selfdrive/car/chrysler/carcontroller.py ================================================ from selfdrive.car import apply_toyota_steer_torque_limits from selfdrive.car.chrysler.chryslercan import create_lkas_hud, create_lkas_command, \ create_wheel_buttons from selfdrive.car.chrysler.values import CAR, CarControllerParams from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.apply_steer_last = 0 self.ccframe = 0 self.prev_frame = -1 self.hud_count = 0 self.car_fingerprint = CP.carFingerprint self.gone_fast_yet = False self.steer_rate_limited = False self.packer = CANPacker(dbc_name) def update(self, enabled, CS, actuators, pcm_cancel_cmd, hud_alert, dragonconf): # this seems needed to avoid steering faults and to force the sync with the EPS counter frame = CS.lkas_counter if self.prev_frame == frame: return [] # *** compute control surfaces *** # steer torque new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX)) apply_steer = apply_toyota_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorqueEps, CarControllerParams) self.steer_rate_limited = new_steer != apply_steer moving_fast = CS.out.vEgo > CS.CP.minSteerSpeed # for status message if CS.out.vEgo > (CS.CP.minSteerSpeed - 0.5): # for command high bit self.gone_fast_yet = True elif self.car_fingerprint in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.JEEP_CHEROKEE_2019): if CS.out.vEgo < (CS.CP.minSteerSpeed - 3.0): self.gone_fast_yet = False # < 14.5m/s stock turns off this bit, but fine down to 13.5 lkas_active = moving_fast and enabled if not lkas_active: apply_steer = 0 # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on self.apply_steer_last = apply_steer can_sends = [] #*** control msgs *** if pcm_cancel_cmd: # TODO: would be better to start from frame_2b3 new_msg = create_wheel_buttons(self.packer, self.ccframe, cancel=True) can_sends.append(new_msg) # LKAS_HEARTBIT is forwarded by Panda so no need to send it here. # frame is 100Hz (0.01s period) if (self.ccframe % 25 == 0): # 0.25s period if (CS.lkas_car_model != -1): new_msg = create_lkas_hud( self.packer, CS.out.gearShifter, lkas_active, hud_alert, self.hud_count, CS.lkas_car_model) can_sends.append(new_msg) self.hud_count += 1 new_msg = create_lkas_command(self.packer, int(apply_steer), self.gone_fast_yet, frame) can_sends.append(new_msg) self.ccframe += 1 self.prev_frame = frame return can_sends ================================================ FILE: selfdrive/car/chrysler/carstate.py ================================================ from cereal import car from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import CarStateBase from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.shifter_values = can_define.dv["GEAR"]["PRNDL"] def update(self, cp, cp_cam): ret = car.CarState.new_message() self.frame = int(cp.vl["EPS_STATUS"]["COUNTER"]) ret.doorOpen = any([cp.vl["DOORS"]["DOOR_OPEN_FL"], cp.vl["DOORS"]["DOOR_OPEN_FR"], cp.vl["DOORS"]["DOOR_OPEN_RL"], cp.vl["DOORS"]["DOOR_OPEN_RR"]]) ret.seatbeltUnlatched = cp.vl["SEATBELT_STATUS"]["SEATBELT_DRIVER_UNLATCHED"] == 1 ret.brakePressed = cp.vl["BRAKE_2"]["BRAKE_PRESSED_2"] == 5 # human-only ret.brake = 0 ret.gas = cp.vl["ACCEL_GAS_134"]["ACCEL_134"] ret.gasPressed = ret.gas > 1e-5 ret.espDisabled = (cp.vl["TRACTION_BUTTON"]["TRACTION_OFF"] == 1) ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"] ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"] ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"] ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"] ret.vEgoRaw = (cp.vl["SPEED_1"]["SPEED_LEFT"] + cp.vl["SPEED_1"]["SPEED_RIGHT"]) / 2. ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = not ret.vEgoRaw > 0.001 ret.leftBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 1 ret.rightBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 2 ret.steeringAngleDeg = cp.vl["STEERING"]["STEER_ANGLE"] ret.steeringRateDeg = cp.vl["STEERING"]["STEERING_RATE"] ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(cp.vl["GEAR"]["PRNDL"], None)) ret.cruiseState.enabled = cp.vl["ACC_2"]["ACC_STATUS_2"] == 7 # ACC is green. # dp ret.cruiseActualEnabled = ret.cruiseState.enabled ret.cruiseState.available = ret.cruiseState.enabled # FIXME: for now same as enabled ret.cruiseState.speed = cp.vl["DASHBOARD"]["ACC_SPEED_CONFIG_KPH"] * CV.KPH_TO_MS # CRUISE_STATE is a three bit msg, 0 is off, 1 and 2 are Non-ACC mode, 3 and 4 are ACC mode, find if there are other states too ret.cruiseState.nonAdaptive = cp.vl["DASHBOARD"]["CRUISE_STATE"] in [1, 2] ret.steeringTorque = cp.vl["EPS_STATUS"]["TORQUE_DRIVER"] ret.steeringTorqueEps = cp.vl["EPS_STATUS"]["TORQUE_MOTOR"] ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD steer_state = cp.vl["EPS_STATUS"]["LKAS_STATE"] ret.steerError = steer_state == 4 or (steer_state == 0 and ret.vEgo > self.CP.minSteerSpeed) ret.genericToggle = bool(cp.vl["STEERING_LEVERS"]["HIGH_BEAM_FLASH"]) if self.CP.enableBsm: ret.leftBlindspot = cp.vl["BLIND_SPOT_WARNINGS"]["BLIND_SPOT_LEFT"] == 1 ret.rightBlindspot = cp.vl["BLIND_SPOT_WARNINGS"]["BLIND_SPOT_RIGHT"] == 1 self.lkas_counter = cp_cam.vl["LKAS_COMMAND"]["COUNTER"] self.lkas_car_model = cp_cam.vl["LKAS_HUD"]["CAR_MODEL"] self.lkas_status_ok = cp_cam.vl["LKAS_HEARTBIT"]["LKAS_STATUS_OK"] # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("PRNDL", "GEAR", 0), ("DOOR_OPEN_FL", "DOORS", 0), ("DOOR_OPEN_FR", "DOORS", 0), ("DOOR_OPEN_RL", "DOORS", 0), ("DOOR_OPEN_RR", "DOORS", 0), ("BRAKE_PRESSED_2", "BRAKE_2", 0), ("ACCEL_134", "ACCEL_GAS_134", 0), ("SPEED_LEFT", "SPEED_1", 0), ("SPEED_RIGHT", "SPEED_1", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), ("STEER_ANGLE", "STEERING", 0), ("STEERING_RATE", "STEERING", 0), ("TURN_SIGNALS", "STEERING_LEVERS", 0), ("ACC_STATUS_2", "ACC_2", 0), ("HIGH_BEAM_FLASH", "STEERING_LEVERS", 0), ("ACC_SPEED_CONFIG_KPH", "DASHBOARD", 0), ("CRUISE_STATE", "DASHBOARD", 0), ("TORQUE_DRIVER", "EPS_STATUS", 0), ("TORQUE_MOTOR", "EPS_STATUS", 0), ("LKAS_STATE", "EPS_STATUS", 1), ("COUNTER", "EPS_STATUS", -1), ("TRACTION_OFF", "TRACTION_BUTTON", 0), ("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS", 0), ] checks = [ # sig_address, frequency ("BRAKE_2", 50), ("EPS_STATUS", 100), ("SPEED_1", 100), ("WHEEL_SPEEDS", 50), ("STEERING", 100), ("ACC_2", 50), ("GEAR", 50), ("ACCEL_GAS_134", 50), ("DASHBOARD", 15), ("STEERING_LEVERS", 10), ("SEATBELT_STATUS", 2), ("DOORS", 1), ("TRACTION_BUTTON", 1), ] if CP.enableBsm: signals += [ ("BLIND_SPOT_RIGHT", "BLIND_SPOT_WARNINGS", 0), ("BLIND_SPOT_LEFT", "BLIND_SPOT_WARNINGS", 0), ] checks += [("BLIND_SPOT_WARNINGS", 2)] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod def get_cam_can_parser(CP): signals = [ # sig_name, sig_address, default ("COUNTER", "LKAS_COMMAND", -1), ("CAR_MODEL", "LKAS_HUD", -1), ("LKAS_STATUS_OK", "LKAS_HEARTBIT", -1) ] checks = [ ("LKAS_COMMAND", 100), ("LKAS_HEARTBIT", 10), ("LKAS_HUD", 4), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) ================================================ FILE: selfdrive/car/chrysler/chryslercan.py ================================================ from cereal import car from selfdrive.car import make_can_msg GearShifter = car.CarState.GearShifter VisualAlert = car.CarControl.HUDControl.VisualAlert def create_lkas_hud(packer, gear, lkas_active, hud_alert, hud_count, lkas_car_model): # LKAS_HUD 0x2a6 (678) Controls what lane-keeping icon is displayed. if hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw]: msg = b'\x00\x00\x00\x03\x00\x00\x00\x00' return make_can_msg(0x2a6, msg, 0) color = 1 # default values are for park or neutral in 2017 are 0 0, but trying 1 1 for 2019 lines = 1 alerts = 0 if hud_count < (1 * 4): # first 3 seconds, 4Hz alerts = 1 # CAR.PACIFICA_2018_HYBRID and CAR.PACIFICA_2019_HYBRID # had color = 1 and lines = 1 but trying 2017 hybrid style for now. if gear in (GearShifter.drive, GearShifter.reverse, GearShifter.low): if lkas_active: color = 2 # control active, display green. lines = 6 else: color = 1 # control off, display white. lines = 1 values = { "LKAS_ICON_COLOR": color, # byte 0, last 2 bits "CAR_MODEL": lkas_car_model, # byte 1 "LKAS_LANE_LINES": lines, # byte 2, last 4 bits "LKAS_ALERTS": alerts, # byte 3, last 4 bits } return packer.make_can_msg("LKAS_HUD", 0, values) # 0x2a6 def create_lkas_command(packer, apply_steer, moving_fast, frame): # LKAS_COMMAND 0x292 (658) Lane-keeping signal to turn the wheel. values = { "LKAS_STEERING_TORQUE": apply_steer, "LKAS_HIGH_TORQUE": int(moving_fast), "COUNTER": frame % 0x10, } return packer.make_can_msg("LKAS_COMMAND", 0, values) def create_wheel_buttons(packer, frame, cancel=False): # WHEEL_BUTTONS (571) Message sent to cancel ACC. values = { "ACC_CANCEL": cancel, "COUNTER": frame % 10 } return packer.make_can_msg("WHEEL_BUTTONS", 0, values) ================================================ FILE: selfdrive/car/chrysler/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.car.chrysler.values import CAR from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr class CarInterface(CarInterfaceBase): @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "chrysler" ret.safetyModel = car.CarParams.SafetyModel.chrysler ret.lateralTuning.init('pid') # Chrysler port is a community feature, since we don't own one to test ret.communityFeature = True # Speed conversion: 20, 45 mph ret.wheelbase = 3.089 # in meters for Pacifica Hybrid 2017 ret.steerRatio = 16.2 # Pacifica Hybrid 2017 ret.mass = 2242. + STD_CARGO_KG # kg curb weight Pacifica Hybrid 2017 ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[9., 20.], [9., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15, 0.30], [0.03, 0.05]] ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 ret.steerActuatorDelay = 0.1 ret.steerRateCost = 0.7 ret.steerLimitTimer = 0.4 if candidate in (CAR.JEEP_CHEROKEE, CAR.JEEP_CHEROKEE_2019): ret.wheelbase = 2.91 # in meters ret.steerRatio = 12.7 ret.steerActuatorDelay = 0.2 # in seconds ret.centerToFront = ret.wheelbase * 0.44 ret.minSteerSpeed = 3.8 # m/s if candidate in (CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.JEEP_CHEROKEE_2019): # TODO allow 2019 cars to steer down to 13 m/s if already engaged. ret.minSteerSpeed = 17.5 # m/s 17 on the way up, 13 on the way down once engaged. # starting with reasonable value for civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) ret.enableBsm = 720 in fingerprint[0] # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): # ******************* do can recv ******************* self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid # speeds ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False # events events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], gas_resume_speed=2.) if ret.vEgo < self.CP.minSteerSpeed: events.add(car.CarEvent.EventName.belowSteerSpeed) ret.events = events.to_msg() # copy back carState packet to CS self.CS.out = ret.as_reader() return self.CS.out # pass in a car.CarControl # to be called @ 100hz def apply(self, c): if (self.CS.frame == -1): return [] # if we haven't seen a frame 220, then do not update. can_sends = self.CC.update(c.enabled, self.CS, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert, self.dragonconf) return can_sends ================================================ FILE: selfdrive/car/chrysler/radar_interface.py ================================================ #!/usr/bin/env python3 from opendbc.can.parser import CANParser from cereal import car from selfdrive.car.interfaces import RadarInterfaceBase from selfdrive.car.chrysler.values import DBC RADAR_MSGS_C = list(range(0x2c2, 0x2d4+2, 2)) # c_ messages 706,...,724 RADAR_MSGS_D = list(range(0x2a2, 0x2b4+2, 2)) # d_ messages LAST_MSG = max(RADAR_MSGS_C + RADAR_MSGS_D) NUMBER_MSGS = len(RADAR_MSGS_C) + len(RADAR_MSGS_D) def _create_radar_can_parser(car_fingerprint): msg_n = len(RADAR_MSGS_C) # list of [(signal name, message name or number, initial values), (...)] # [('RADAR_STATE', 1024, 0), # ('LONG_DIST', 1072, 255), # ('LONG_DIST', 1073, 255), # ('LONG_DIST', 1074, 255), # ('LONG_DIST', 1075, 255), # The factor and offset are applied by the dbc parsing library, so the # default values should be after the factor/offset are applied. signals = list(zip(['LONG_DIST'] * msg_n + ['LAT_DIST'] * msg_n + ['REL_SPEED'] * msg_n, RADAR_MSGS_C * 2 + # LONG_DIST, LAT_DIST RADAR_MSGS_D, # REL_SPEED [0] * msg_n + # LONG_DIST [-1000] * msg_n + # LAT_DIST [-146.278] * msg_n)) # REL_SPEED set to 0, factor/offset to this # TODO what are the checks actually used for? # honda only checks the last message, # toyota checks all the messages. Which do we want? checks = list(zip(RADAR_MSGS_C + RADAR_MSGS_D, [20]*msg_n + # 20Hz (0.05s) [20]*msg_n)) # 20Hz (0.05s) return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) def _address_to_track(address): if address in RADAR_MSGS_C: return (address - RADAR_MSGS_C[0]) // 2 if address in RADAR_MSGS_D: return (address - RADAR_MSGS_D[0]) // 2 raise ValueError("radar received unexpected address %d" % address) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.rcp = _create_radar_can_parser(CP.carFingerprint) self.updated_messages = set() self.trigger_msg = LAST_MSG def update(self, can_strings): vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None ret = car.RadarData.new_message() errors = [] if not self.rcp.can_valid: errors.append("canError") ret.errors = errors for ii in self.updated_messages: # ii should be the message ID as a number cpt = self.rcp.vl[ii] trackId = _address_to_track(ii) if trackId not in self.pts: self.pts[trackId] = car.RadarData.RadarPoint.new_message() self.pts[trackId].trackId = trackId self.pts[trackId].aRel = float('nan') self.pts[trackId].yvRel = float('nan') self.pts[trackId].measured = True if 'LONG_DIST' in cpt: # c_* message self.pts[trackId].dRel = cpt['LONG_DIST'] # from front of car # our lat_dist is positive to the right in car's frame. # TODO what does yRel want? self.pts[trackId].yRel = cpt['LAT_DIST'] # in car frame's y axis, left is positive else: # d_* message self.pts[trackId].vRel = cpt['REL_SPEED'] # We want a list, not a dictionary. Filter out LONG_DIST==0 because that means it's not valid. ret.points = [x for x in self.pts.values() if x.dRel != 0] self.updated_messages.clear() return ret ================================================ FILE: selfdrive/car/chrysler/values.py ================================================ # flake8: noqa from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu class CarControllerParams: STEER_MAX = 261 # 262 faults STEER_DELTA_UP = 3 # 3 is stock. 100 is fine. 200 is too much it seems STEER_DELTA_DOWN = 3 # no faults on the way down it seems STEER_ERROR_MAX = 80 class CAR: PACIFICA_2017_HYBRID = "CHRYSLER PACIFICA HYBRID 2017" PACIFICA_2018_HYBRID = "CHRYSLER PACIFICA HYBRID 2018" PACIFICA_2019_HYBRID = "CHRYSLER PACIFICA HYBRID 2019" PACIFICA_2018 = "CHRYSLER PACIFICA 2018" # includes 2017 Pacifica PACIFICA_2020 = "CHRYSLER PACIFICA 2020" JEEP_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # includes 2017 Trailhawk JEEP_CHEROKEE_2019 = "JEEP GRAND CHEROKEE 2019" # includes 2020 Trailhawk # Unique CAN messages: # Only the hybrids have 270: 8 # Only the gas have 55: 8, 416: 7 # For 564, All 2017 have length 4, whereas 2018-19 have length 8. # For 924, Pacifica 2017 has length 3, whereas all 2018-19 have length 8. # For 560, All 2019 have length 8, whereas all 2017-18 have length 4. # Jeep Grand Cherokee unique messages: # 2017 Trailhawk: 618: 8 # For 924, Trailhawk 2017 has length 3, whereas 2018 V6 has length 8. FINGERPRINTS = { CAR.PACIFICA_2017_HYBRID: [{ 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 788:3, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 3, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 956: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1284: 8, 1537: 8, 1538: 8, 1562: 8, 1568: 8, 1856: 8, 1858: 8, 1860: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1892: 8, 2016: 8, 2024: 8 }], CAR.PACIFICA_2018: [{ 55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 8, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8 }, { 55: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 924: 3, 926: 3, 937: 8, 947: 8, 948: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8 }], CAR.PACIFICA_2020: [{ 55: 8, 179: 8, 181: 8, 257: 5, 258: 8, 264: 8, 268: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 516: 7, 517: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 536: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 650: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 711: 8, 719: 8, 720: 6, 729: 5, 736: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 776: 8, 779: 8, 782: 8, 784: 8, 792: 8, 793: 8, 794: 8, 795: 8, 799: 8, 800: 8, 801: 8, 802: 8, 803: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 886: 8, 897: 8, 906: 8, 924: 8, 926: 3, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1223: 7, 1225: 8, 1227: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1284: 8, 1543: 8, 1568: 8, 1570: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1867: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 1898: 8, 2015: 8, 2016: 8, 2017:8, 2024: 8, 2025: 8 }], CAR.PACIFICA_2018_HYBRID: [{ 68: 8, 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8 }, # based on 9ae7821dc4e92455|2019-07-01--16-42-55 { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 969: 4, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1258: 8, 1259: 8, 1260: 8, 1262: 8, 1284: 8, 1537: 8, 1538: 8, 1562: 8, 1568: 8, 1856: 8, 1858: 8, 1860: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 1898: 8, 1899: 8, 1900: 8, 1902: 8, 2016: 8, 2018: 8, 2019: 8, 2020: 8, 2023: 8, 2024: 8, 2026: 8, 2027: 8, 2028: 8, 2031: 8 }], CAR.PACIFICA_2019_HYBRID: [{ 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1538: 8 }, # Based on 0607d2516fc2148f|2019-02-13--23-03-16 { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1537: 8 }, # Based on 3c7ce223e3571b54|2019-05-11--20-16-14 { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1562: 8, 1570: 8 }, # Based on "8190c7275a24557b|2020-02-24--09-57-23" { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 524: 8, 526: 6, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 640: 1, 650: 8, 653: 8, 654: 8, 655: 8, 656: 4, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 683: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 711: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 793: 8, 794: 8, 795: 8, 796: 8, 797: 8, 798: 8, 799: 8, 800: 8, 801: 8, 802: 8, 803: 8, 804: 8, 805: 8, 807: 8, 808: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 886: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1225: 8, 1235: 8, 1242: 8, 1246: 8, 1250: 8, 1251: 8, 1252: 8, 1258: 8, 1259: 8, 1260: 8, 1262: 8, 1284: 8, 1568: 8, 1570: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1875: 8, 1882: 8, 1886: 8, 1890: 8, 1891: 8, 1892: 8, 1898: 8, 1899: 8, 1900: 8, 1902: 8, 2015: 8, 2016: 8, 2017: 8, 2018: 8, 2019: 8, 2020: 8, 2023: 8, 2024: 8, 2026: 8, 2027: 8, 2028: 8, 2031: 8 }], CAR.JEEP_CHEROKEE: [{ 55: 8, 168: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 4, 564: 4, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 656: 4, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 785: 8, 788: 3, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 840: 8, 844: 5, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 874: 2, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 956: 8, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 975: 8, 976: 8, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8, 1543: 8, 1562: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }], CAR.JEEP_CHEROKEE_2019: [{ # Jeep Grand Cherokee 2019, including most 2020 models 55: 8, 168: 8, 179: 8, 181: 8, 256: 4, 257: 5, 258: 8, 264: 8, 268: 8, 272: 6, 273: 6, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 292: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 341: 8, 344: 8, 352: 8, 362: 8, 368: 8, 376: 3, 384: 8, 388: 4, 416: 7, 448: 6, 456: 4, 464: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 530: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 618: 8, 624: 8, 625: 8, 632: 8, 639: 8, 640: 1, 656: 4, 658: 6, 660: 8, 671: 8, 672: 8, 676: 8, 678: 8, 680: 8, 683: 8, 684: 8, 703: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 738: 8, 746: 5, 752: 2, 754: 8, 760: 8, 761: 8, 764: 8, 766: 8, 773: 8, 776: 8, 779: 8, 782: 8, 783: 8, 784: 8, 785: 8, 792: 8, 799: 8, 800: 8, 804: 8, 806: 2, 808: 8, 810: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 831: 6, 832: 8, 838: 2, 840: 8, 844: 5, 847: 1, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 882: 8, 897: 8, 906: 8, 924: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 960: 4, 968: 8, 969: 4, 970: 8, 973: 8, 974: 5, 976: 8, 977: 4, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1062: 8, 1098: 8, 1100: 8, 1216: 8, 1218: 8, 1220: 8, 1223: 8, 1225: 8, 1227: 8, 1235: 8, 1242: 8, 1250: 8, 1251: 8, 1252: 8, 1254: 8, 1264: 8, 1284: 8, 1536: 8, 1537: 8, 1543: 8, 1545: 8, 1562: 8, 1568: 8, 1570: 8, 1572: 8, 1593: 8, 1856: 8, 1858: 8, 1860: 8, 1863: 8, 1865: 8, 1867: 8, 1875: 8, 1882: 8, 1890: 8, 1891: 8, 1892: 8, 1894: 8, 1896: 8, 1904: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }], } DBC = { CAR.PACIFICA_2017_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), CAR.PACIFICA_2018: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), CAR.PACIFICA_2020: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), CAR.PACIFICA_2018_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), CAR.PACIFICA_2019_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), CAR.JEEP_CHEROKEE: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), CAR.JEEP_CHEROKEE_2019: dbc_dict('chrysler_pacifica_2017_hybrid', 'chrysler_pacifica_2017_hybrid_private_fusion'), } STEER_THRESHOLD = 120 ================================================ FILE: selfdrive/car/fingerprints.py ================================================ import os from common.basedir import BASEDIR def get_attr_from_cars(attr, result=dict, combine_brands=True): # read all the folders in selfdrive/car and return a dict where: # - keys are all the car models # - values are attr values from all car folders result = result() for car_folder in [x[0] for x in os.walk(BASEDIR + '/selfdrive/car')]: try: car_name = car_folder.split('/')[-1] values = __import__('selfdrive.car.%s.values' % car_name, fromlist=[attr]) if hasattr(values, attr): attr_values = getattr(values, attr) else: continue if isinstance(attr_values, dict): for f, v in attr_values.items(): if combine_brands: result[f] = v else: if car_name not in result: result[car_name] = {} result[car_name][f] = v elif isinstance(attr_values, list): result += attr_values except (ImportError, IOError): pass return result FW_VERSIONS = get_attr_from_cars('FW_VERSIONS') _FINGERPRINTS = get_attr_from_cars('FINGERPRINTS') _DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes def is_valid_for_fingerprint(msg, car_fingerprint): adr = msg.address # ignore addresses that are more than 11 bits return (adr in car_fingerprint and car_fingerprint[adr] == len(msg.dat)) or adr >= 0x800 def eliminate_incompatible_cars(msg, candidate_cars): """Removes cars that could not have sent msg. Inputs: msg: A cereal/log CanData message from the car. candidate_cars: A list of cars to consider. Returns: A list containing the subset of candidate_cars that could have sent msg. """ compatible_cars = [] for car_name in candidate_cars: car_fingerprints = _FINGERPRINTS[car_name] for fingerprint in car_fingerprints: fingerprint.update(_DEBUG_ADDRESS) # add alien debug address if is_valid_for_fingerprint(msg, fingerprint): compatible_cars.append(car_name) break return compatible_cars def all_known_cars(): """Returns a list of all known car strings.""" return list({*FW_VERSIONS.keys(), *_FINGERPRINTS.keys()}) def all_legacy_fingerprint_cars(): """Returns a list of all known car strings, FPv1 only.""" return list(_FINGERPRINTS.keys()) ================================================ FILE: selfdrive/car/ford/__init__.py ================================================ ================================================ FILE: selfdrive/car/ford/carcontroller.py ================================================ import math from cereal import car from selfdrive.car import make_can_msg from selfdrive.car.ford.fordcan import create_steer_command, create_lkas_ui, spam_cancel_button from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl VisualAlert = car.CarControl.HUDControl.VisualAlert MAX_STEER_DELTA = 1 TOGGLE_DEBUG = False class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.packer = CANPacker(dbc_name) self.enabled_last = False self.main_on_last = False self.vehicle_model = VM self.generic_toggle_last = 0 self.steer_alert_last = False self.lkas_action = 0 def update(self, enabled, CS, frame, actuators, visual_alert, pcm_cancel, dragonconf): can_sends = [] steer_alert = visual_alert in [VisualAlert.steerRequired, VisualAlert.ldw] apply_steer = actuators.steer # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on if pcm_cancel: #print "CANCELING!!!!" can_sends.append(spam_cancel_button(self.packer)) if (frame % 3) == 0: curvature = self.vehicle_model.calc_curvature(actuators.steeringAngleDeg*math.pi/180., CS.out.vEgo) # The use of the toggle below is handy for trying out the various LKAS modes if TOGGLE_DEBUG: self.lkas_action += int(CS.out.genericToggle and not self.generic_toggle_last) self.lkas_action &= 0xf else: self.lkas_action = 5 # 4 and 5 seem the best. 8 and 9 seem to aggressive and laggy can_sends.append(create_steer_command(self.packer, apply_steer, enabled, CS.lkas_state, CS.out.steeringAngleDeg, curvature, self.lkas_action)) self.generic_toggle_last = CS.out.genericToggle if (frame % 100) == 0: can_sends.append(make_can_msg(973, b'\x00\x00\x00\x00\x00\x00\x00\x00', 0)) #can_sends.append(make_can_msg(984, b'\x00\x00\x00\x00\x80\x45\x60\x30', 0)) if (frame % 100) == 0 or (self.enabled_last != enabled) or (self.main_on_last != CS.out.cruiseState.available) or \ (self.steer_alert_last != steer_alert): can_sends.append(create_lkas_ui(self.packer, CS.out.cruiseState.available, enabled, steer_alert)) if (frame % 200) == 0: can_sends.append(make_can_msg(1875, b'\x80\xb0\x55\x55\x78\x90\x00\x00', 1)) if (frame % 10) == 0: can_sends.append(make_can_msg(1648, b'\x00\x00\x00\x40\x00\x00\x50\x00', 1)) can_sends.append(make_can_msg(1649, b'\x10\x10\xf1\x70\x04\x00\x00\x00', 1)) can_sends.append(make_can_msg(1664, b'\x00\x00\x03\xe8\x00\x01\xa9\xb2', 1)) can_sends.append(make_can_msg(1674, b'\x08\x00\x00\xff\x0c\xfb\x6a\x08', 1)) can_sends.append(make_can_msg(1675, b'\x00\x00\x3b\x60\x37\x00\x00\x00', 1)) can_sends.append(make_can_msg(1690, b'\x70\x00\x00\x55\x86\x1c\xe0\x00', 1)) can_sends.append(make_can_msg(1910, b'\x06\x4b\x06\x4b\x42\xd3\x11\x30', 1)) can_sends.append(make_can_msg(1911, b'\x48\x53\x37\x54\x48\x53\x37\x54', 1)) can_sends.append(make_can_msg(1912, b'\x31\x34\x47\x30\x38\x31\x43\x42', 1)) can_sends.append(make_can_msg(1913, b'\x31\x34\x47\x30\x38\x32\x43\x42', 1)) can_sends.append(make_can_msg(1969, b'\xf4\x40\x00\x00\x00\x00\x00\x00', 1)) can_sends.append(make_can_msg(1971, b'\x0b\xc0\x00\x00\x00\x00\x00\x00', 1)) static_msgs = range(1653, 1658) for addr in static_msgs: cnt = (frame % 10) + 1 can_sends.append(make_can_msg(addr, (cnt << 4).to_bytes(1, 'little') + b'\x00\x00\x00\x00\x00\x00\x00', 1)) self.enabled_last = enabled self.main_on_last = CS.out.cruiseState.available self.steer_alert_last = steer_alert return can_sends ================================================ FILE: selfdrive/car/ford/carstate.py ================================================ from cereal import car from opendbc.can.parser import CANParser from common.numpy_fast import mean from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import CarStateBase from selfdrive.car.ford.values import DBC WHEEL_RADIUS = 0.33 class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) def update(self, cp): ret = car.CarState.new_message() ret.wheelSpeeds.rr = cp.vl["WheelSpeed_CG1"]["WhlRr_W_Meas"] * WHEEL_RADIUS ret.wheelSpeeds.rl = cp.vl["WheelSpeed_CG1"]["WhlRl_W_Meas"] * WHEEL_RADIUS ret.wheelSpeeds.fr = cp.vl["WheelSpeed_CG1"]["WhlFr_W_Meas"] * WHEEL_RADIUS ret.wheelSpeeds.fl = cp.vl["WheelSpeed_CG1"]["WhlFl_W_Meas"] * WHEEL_RADIUS ret.vEgoRaw = mean([ret.wheelSpeeds.rr, ret.wheelSpeeds.rl, ret.wheelSpeeds.fr, ret.wheelSpeeds.fl]) ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = not ret.vEgoRaw > 0.001 ret.steeringAngleDeg = cp.vl["Steering_Wheel_Data_CG1"]["SteWhlRelInit_An_Sns"] ret.steeringPressed = not cp.vl["Lane_Keep_Assist_Status"]["LaHandsOff_B_Actl"] ret.steerError = cp.vl["Lane_Keep_Assist_Status"]["LaActDeny_B_Actl"] == 1 ret.cruiseState.speed = cp.vl["Cruise_Status"]["Set_Speed"] * CV.MPH_TO_MS ret.cruiseState.enabled = not (cp.vl["Cruise_Status"]["Cruise_State"] in [0, 3]) # dp ret.cruiseActualEnabled = ret.cruiseState.enabled ret.cruiseState.available = cp.vl["Cruise_Status"]["Cruise_State"] != 0 ret.gas = cp.vl["EngineData_14"]["ApedPosScal_Pc_Actl"] / 100. ret.gasPressed = ret.gas > 1e-6 ret.brakePressed = bool(cp.vl["Cruise_Status"]["Brake_Drv_Appl"]) ret.genericToggle = bool(cp.vl["Steering_Buttons"]["Dist_Incr"]) # TODO: we also need raw driver torque, needed for Assisted Lane Change self.lkas_state = cp.vl["Lane_Keep_Assist_Status"]["LaActAvail_D_Actl"] # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("WhlRr_W_Meas", "WheelSpeed_CG1", 0.), ("WhlRl_W_Meas", "WheelSpeed_CG1", 0.), ("WhlFr_W_Meas", "WheelSpeed_CG1", 0.), ("WhlFl_W_Meas", "WheelSpeed_CG1", 0.), ("SteWhlRelInit_An_Sns", "Steering_Wheel_Data_CG1", 0.), ("Cruise_State", "Cruise_Status", 0.), ("Set_Speed", "Cruise_Status", 0.), ("LaActAvail_D_Actl", "Lane_Keep_Assist_Status", 0), ("LaHandsOff_B_Actl", "Lane_Keep_Assist_Status", 0), ("LaActDeny_B_Actl", "Lane_Keep_Assist_Status", 0), ("ApedPosScal_Pc_Actl", "EngineData_14", 0.), ("Dist_Incr", "Steering_Buttons", 0.), ("Brake_Drv_Appl", "Cruise_Status", 0.), ] checks = [] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0, enforce_checks=False) ================================================ FILE: selfdrive/car/ford/fordcan.py ================================================ from common.numpy_fast import clip from selfdrive.car.ford.values import MAX_ANGLE def create_steer_command(packer, angle_cmd, enabled, lkas_state, angle_steers, curvature, lkas_action): """Creates a CAN message for the Ford Steer Command.""" #if enabled and lkas available: if enabled and lkas_state in [2, 3]: # and (frame % 500) >= 3: action = lkas_action else: action = 0xf angle_cmd = angle_steers/MAX_ANGLE angle_cmd = clip(angle_cmd * MAX_ANGLE, - MAX_ANGLE, MAX_ANGLE) values = { "Lkas_Action": action, "Lkas_Alert": 0xf, # no alerts "Lane_Curvature": clip(curvature, -0.01, 0.01), # is it just for debug? #"Lane_Curvature": 0, # is it just for debug? "Steer_Angle_Req": angle_cmd } return packer.make_can_msg("Lane_Keep_Assist_Control", 0, values) def create_lkas_ui(packer, main_on, enabled, steer_alert): """Creates a CAN message for the Ford Steer Ui.""" if not main_on: lines = 0xf elif enabled: lines = 0x3 else: lines = 0x6 values = { "Set_Me_X80": 0x80, "Set_Me_X45": 0x45, "Set_Me_X30": 0x30, "Lines_Hud": lines, "Hands_Warning_W_Chime": steer_alert, } return packer.make_can_msg("Lane_Keep_Assist_Ui", 0, values) def spam_cancel_button(packer): values = { "Cancel": 1 } return packer.make_can_msg("Steering_Buttons", 0, values) ================================================ FILE: selfdrive/car/ford/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV from selfdrive.car.ford.values import MAX_ANGLE from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr class CarInterface(CarInterfaceBase): @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "ford" ret.lateralTuning.init('pid') ret.safetyModel = car.CarParams.SafetyModel.ford ret.dashcamOnly = True ret.wheelbase = 2.85 ret.steerRatio = 14.8 ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01], [0.005]] # TODO: tune this ret.lateralTuning.pid.kf = 1. / MAX_ANGLE # MAX Steer angle to normalize FF ret.steerActuatorDelay = 0.1 # Default delay, not measured yet ret.steerLimitTimer = 0.8 ret.steerRateCost = 1.0 ret.centerToFront = ret.wheelbase * 0.44 tire_stiffness_factor = 0.5328 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) ret.steerControlType = car.CarParams.SteerControlType.angle # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): # ******************* do can recv ******************* self.cp.update_strings(can_strings) ret = self.CS.update(self.cp) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid # events events = self.create_common_events(ret) if self.CS.lkas_state not in [2, 3] and ret.vEgo > 13. * CV.MPH_TO_MS and ret.cruiseState.enabled: events.add(car.CarEvent.EventName.steerTempUnavailable) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out # pass in a car.CarControl # to be called @ 100hz def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.hudControl.visualAlert, c.cruiseControl.cancel, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/ford/radar_interface.py ================================================ #!/usr/bin/env python3 from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.ford.values import DBC from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import RadarInterfaceBase RADAR_MSGS = list(range(0x500, 0x540)) def _create_radar_can_parser(car_fingerprint): msg_n = len(RADAR_MSGS) signals = list(zip(['X_Rel'] * msg_n + ['Angle'] * msg_n + ['V_Rel'] * msg_n, RADAR_MSGS * 3, [0] * msg_n + [0] * msg_n + [0] * msg_n)) checks = list(zip(RADAR_MSGS, [20]*msg_n)) return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.validCnt = {key: 0 for key in RADAR_MSGS} self.track_id = 0 self.rcp = _create_radar_can_parser(CP.carFingerprint) self.trigger_msg = 0x53f self.updated_messages = set() def update(self, can_strings): vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None ret = car.RadarData.new_message() errors = [] if not self.rcp.can_valid: errors.append("canError") ret.errors = errors for ii in sorted(self.updated_messages): cpt = self.rcp.vl[ii] if cpt['X_Rel'] > 0.00001: self.validCnt[ii] = 0 # reset counter if cpt['X_Rel'] > 0.00001: self.validCnt[ii] += 1 else: self.validCnt[ii] = max(self.validCnt[ii] - 1, 0) #print ii, self.validCnt[ii], cpt['VALID'], cpt['X_Rel'], cpt['Angle'] # radar point only valid if there have been enough valid measurements if self.validCnt[ii] > 0: if ii not in self.pts: self.pts[ii] = car.RadarData.RadarPoint.new_message() self.pts[ii].trackId = self.track_id self.track_id += 1 self.pts[ii].dRel = cpt['X_Rel'] # from front of car self.pts[ii].yRel = cpt['X_Rel'] * cpt['Angle'] * CV.DEG_TO_RAD # in car frame's y axis, left is positive self.pts[ii].vRel = cpt['V_Rel'] self.pts[ii].aRel = float('nan') self.pts[ii].yvRel = float('nan') self.pts[ii].measured = True else: if ii in self.pts: del self.pts[ii] ret.points = list(self.pts.values()) self.updated_messages.clear() return ret ================================================ FILE: selfdrive/car/ford/values.py ================================================ # flake8: noqa from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu MAX_ANGLE = 87. # make sure we never command the extremes (0xfff) which cause latching fault class CAR: FUSION = "FORD FUSION 2018" FINGERPRINTS = { CAR.FUSION: [{ 71: 8, 74: 8, 75: 8, 76: 8, 90: 8, 92: 8, 93: 8, 118: 8, 119: 8, 120: 8, 125: 8, 129: 8, 130: 8, 131: 8, 132: 8, 133: 8, 145: 8, 146: 8, 357: 8, 359: 8, 360: 8, 361: 8, 376: 8, 390: 8, 391: 8, 392: 8, 394: 8, 512: 8, 514: 8, 516: 8, 531: 8, 532: 8, 534: 8, 535: 8, 560: 8, 578: 8, 604: 8, 613: 8, 673: 8, 827: 8, 848: 8, 934: 8, 935: 8, 936: 8, 947: 8, 963: 8, 970: 8, 972: 8, 973: 8, 984: 8, 992: 8, 994: 8, 997: 8, 998: 8, 1003: 8, 1034: 8, 1045: 8, 1046: 8, 1053: 8, 1054: 8, 1058: 8, 1059: 8, 1068: 8, 1072: 8, 1073: 8, 1082: 8, 1107: 8, 1108: 8, 1109: 8, 1110: 8, 1200: 8, 1427: 8, 1430: 8, 1438: 8, 1459: 8 }], } DBC = { CAR.FUSION: dbc_dict('ford_fusion_2018_pt', 'ford_fusion_2018_adas'), } ================================================ FILE: selfdrive/car/fw_versions.py ================================================ #!/usr/bin/env python3 import struct import traceback from typing import Any from collections import defaultdict from tqdm import tqdm import panda.python.uds as uds from cereal import car from selfdrive.car.fingerprints import FW_VERSIONS, get_attr_from_cars from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery from selfdrive.car.toyota.values import CAR as TOYOTA from selfdrive.swaglog import cloudlog Ecu = car.CarParams.Ecu def p16(val): return struct.pack("!H", val) TESTER_PRESENT_REQUEST = bytes([uds.SERVICE_TYPE.TESTER_PRESENT, 0x0]) TESTER_PRESENT_RESPONSE = bytes([uds.SERVICE_TYPE.TESTER_PRESENT + 0x40, 0x0]) SHORT_TESTER_PRESENT_REQUEST = bytes([uds.SERVICE_TYPE.TESTER_PRESENT]) SHORT_TESTER_PRESENT_RESPONSE = bytes([uds.SERVICE_TYPE.TESTER_PRESENT + 0x40]) DEFAULT_DIAGNOSTIC_REQUEST = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, uds.SESSION_TYPE.DEFAULT]) DEFAULT_DIAGNOSTIC_RESPONSE = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, uds.SESSION_TYPE.DEFAULT, 0x0, 0x32, 0x1, 0xf4]) EXTENDED_DIAGNOSTIC_REQUEST = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, uds.SESSION_TYPE.EXTENDED_DIAGNOSTIC]) EXTENDED_DIAGNOSTIC_RESPONSE = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, uds.SESSION_TYPE.EXTENDED_DIAGNOSTIC, 0x0, 0x32, 0x1, 0xf4]) UDS_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) UDS_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \ p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) HYUNDAI_VERSION_REQUEST_SHORT = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ p16(0xf1a0) # 4 Byte version number HYUNDAI_VERSION_REQUEST_LONG = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ p16(0xf100) # Long description HYUNDAI_VERSION_REQUEST_MULTI = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_SPARE_PART_NUMBER) + \ p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) + \ p16(0xf100) + \ p16(0xf1a0) HYUNDAI_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) TOYOTA_VERSION_REQUEST = b'\x1a\x88\x01' TOYOTA_VERSION_RESPONSE = b'\x5a\x88\x01' VOLKSWAGEN_VERSION_REQUEST_MULTI = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_SPARE_PART_NUMBER) + \ p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_VERSION_NUMBER) + \ p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION) VOLKSWAGEN_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) OBD_VERSION_REQUEST = b'\x09\x04' OBD_VERSION_RESPONSE = b'\x49\x04' DEFAULT_RX_OFFSET = 0x8 VOLKSWAGEN_RX_OFFSET = 0x6a MAZDA_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER) MAZDA_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \ p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_ECU_SOFTWARE_NUMBER) # brand, request, response, response offset REQUESTS = [ # Hyundai ( "hyundai", [HYUNDAI_VERSION_REQUEST_SHORT], [HYUNDAI_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), ( "hyundai", [HYUNDAI_VERSION_REQUEST_LONG], [HYUNDAI_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), ( "hyundai", [HYUNDAI_VERSION_REQUEST_MULTI], [HYUNDAI_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), # Honda ( "honda", [UDS_VERSION_REQUEST], [UDS_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), # Toyota ( "toyota", [SHORT_TESTER_PRESENT_REQUEST, TOYOTA_VERSION_REQUEST], [SHORT_TESTER_PRESENT_RESPONSE, TOYOTA_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), ( "toyota", [SHORT_TESTER_PRESENT_REQUEST, OBD_VERSION_REQUEST], [SHORT_TESTER_PRESENT_RESPONSE, OBD_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), ( "toyota", [TESTER_PRESENT_REQUEST, DEFAULT_DIAGNOSTIC_REQUEST, EXTENDED_DIAGNOSTIC_REQUEST, UDS_VERSION_REQUEST], [TESTER_PRESENT_RESPONSE, DEFAULT_DIAGNOSTIC_RESPONSE, EXTENDED_DIAGNOSTIC_RESPONSE, UDS_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), # Volkswagen ( "volkswagen", [VOLKSWAGEN_VERSION_REQUEST_MULTI], [VOLKSWAGEN_VERSION_RESPONSE], VOLKSWAGEN_RX_OFFSET, ), ( "volkswagen", [VOLKSWAGEN_VERSION_REQUEST_MULTI], [VOLKSWAGEN_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ), # Mazda ( "mazda", [MAZDA_VERSION_REQUEST], [MAZDA_VERSION_RESPONSE], DEFAULT_RX_OFFSET, ) ] def chunks(l, n=128): for i in range(0, len(l), n): yield l[i:i + n] def build_fw_dict(fw_versions): fw_versions_dict = {} for fw in fw_versions: addr = fw.address sub_addr = fw.subAddress if fw.subAddress != 0 else None fw_versions_dict[(addr, sub_addr)] = fw.fwVersion return fw_versions_dict def match_fw_to_car_fuzzy(fw_versions_dict, log=True, exclude=None): """Do a fuzzy FW match. This function will return a match, and the number of firmware version that were matched uniquely to that specific car. If multiple ECUs uniquely match to different cars the match is rejected.""" # These ECUs are known to be shared between models (EPS only between hybrid/ICE version) # Getting this exactly right isn't crucial, but excluding camera and radar makes it almost # impossible to get 3 matching versions, even if two models with shared parts are released at the same # time and only one is in our database. exclude_types = [Ecu.fwdCamera, Ecu.fwdRadar, Ecu.eps] # Build lookup table from (addr, subaddr, fw) to list of candidate cars all_fw_versions = defaultdict(list) for candidate, fw_by_addr in FW_VERSIONS.items(): if candidate == exclude: continue for addr, fws in fw_by_addr.items(): if addr[0] in exclude_types: continue for f in fws: all_fw_versions[(addr[1], addr[2], f)].append(candidate) match_count = 0 candidate = None for addr, version in fw_versions_dict.items(): # All cars that have this FW response on the specified address candidates = all_fw_versions[(addr[0], addr[1], version)] if len(candidates) == 1: match_count += 1 if candidate is None: candidate = candidates[0] # We uniquely matched two different cars. No fuzzy match possible elif candidate != candidates[0]: return set() if match_count >= 2: if log: cloudlog.error(f"Fingerprinted {candidate} using fuzzy match. {match_count} matching ECUs") return set([candidate]) else: return set() def match_fw_to_car_exact(fw_versions_dict): """Do an exact FW match. Returns all cars that match the given FW versions for a list of "essential" ECUs. If an ECU is not considered essential the FW version can be missing to get a fingerprint, but if it's present it needs to match the database.""" invalid = [] candidates = FW_VERSIONS for candidate, fws in candidates.items(): for ecu, expected_versions in fws.items(): ecu_type = ecu[0] addr = ecu[1:] found_version = fw_versions_dict.get(addr, None) ESSENTIAL_ECUS = [Ecu.engine, Ecu.eps, Ecu.esp, Ecu.fwdRadar, Ecu.fwdCamera, Ecu.vsa] if ecu_type == Ecu.esp and candidate in [TOYOTA.RAV4, TOYOTA.COROLLA, TOYOTA.HIGHLANDER] and found_version is None: continue # On some Toyota models, the engine can show on two different addresses if ecu_type == Ecu.engine and candidate in [TOYOTA.CAMRY, TOYOTA.COROLLA_TSS2, TOYOTA.CHR, TOYOTA.LEXUS_IS] and found_version is None: continue # Ignore non essential ecus if ecu_type not in ESSENTIAL_ECUS and found_version is None: continue if found_version not in expected_versions: invalid.append(candidate) break return set(candidates.keys()) - set(invalid) def match_fw_to_car(fw_versions, allow_fuzzy=True): fw_versions_dict = build_fw_dict(fw_versions) matches = match_fw_to_car_exact(fw_versions_dict) exact_match = True if allow_fuzzy and len(matches) == 0: matches = match_fw_to_car_fuzzy(fw_versions_dict) # Fuzzy match found if len(matches) == 1: exact_match = False return exact_match, matches def get_fw_versions(logcan, sendcan, bus, extra=None, timeout=0.1, debug=False, progress=False): ecu_types = {} # Extract ECU addresses to query from fingerprints # ECUs using a subadress need be queried one by one, the rest can be done in parallel addrs = [] parallel_addrs = [] versions = get_attr_from_cars('FW_VERSIONS', combine_brands=False) if extra is not None: versions.update(extra) for brand, brand_versions in versions.items(): for c in brand_versions.values(): for ecu_type, addr, sub_addr in c.keys(): a = (brand, addr, sub_addr) if a not in ecu_types: ecu_types[(addr, sub_addr)] = ecu_type if sub_addr is None: if a not in parallel_addrs: parallel_addrs.append(a) else: if [a] not in addrs: addrs.append([a]) addrs.insert(0, parallel_addrs) fw_versions = {} for i, addr in enumerate(tqdm(addrs, disable=not progress)): for addr_chunk in chunks(addr): for brand, request, response, response_offset in REQUESTS: try: addrs = [(a, s) for (b, a, s) in addr_chunk if b in (brand, 'any')] if addrs: query = IsoTpParallelQuery(sendcan, logcan, bus, addrs, request, response, response_offset, debug=debug) t = 2 * timeout if i == 0 else timeout fw_versions.update(query.get_data(t)) except Exception: cloudlog.warning(f"FW query exception: {traceback.format_exc()}") # Build capnp list to put into CarParams car_fw = [] for addr, version in fw_versions.items(): f = car.CarParams.CarFw.new_message() f.ecu = ecu_types[addr] f.fwVersion = version f.address = addr[0] if addr[1] is not None: f.subAddress = addr[1] car_fw.append(f) return car_fw if __name__ == "__main__": import time import argparse import cereal.messaging as messaging from selfdrive.car.vin import get_vin import selfdrive.crash as crash parser = argparse.ArgumentParser(description='Get firmware version of ECUs') parser.add_argument('--scan', '-s', action='store_true', help='In-depth scan of ECU\'s. May cause module faults') parser.add_argument('--debug', '-d', action='store_true') parser.add_argument('--json', '-j', type=str, nargs=2, metavar=('MODEL'), help='fp."') args = parser.parse_args() logcan = messaging.sub_sock('can') sendcan = messaging.pub_sock('sendcan') extra: Any = None if args.scan: extra = {} # Honda for i in range(256): extra[(Ecu.unknown, 0x18da00f1 + (i << 8), None)] = [] extra[(Ecu.unknown, 0x700 + i, None)] = [] extra[(Ecu.unknown, 0x750, i)] = [] extra = {"any": {"debug": extra}} time.sleep(1.) t = time.time() print("Getting vin...") addr, vin = get_vin(logcan, sendcan, 1, retry=10, debug=args.debug) print(f"VIN: {vin}") print("Getting VIN took %.3f s" % (time.time() - t)) print() t = time.time() fw_vers = get_fw_versions(logcan, sendcan, 1, extra=extra, debug=args.debug, progress=True) fw_vers = get_fw_versions(logcan, sendcan, 0, extra=extra, debug=args.debug, progress=True) fw_vers += get_fw_versions(logcan, sendcan, 1, extra=extra, debug=args.debug, progress=True) _, candidates = match_fw_to_car(fw_vers) versions = [] print() print("Found FW versions") print("{") for version in fw_vers: subaddr = None if version.subAddress == 0 else hex(version.subAddress) vers = (f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") versions.append('('+vers+')') print(vers) print("}") print() print("Possible matches:", candidates) print("Getting fw took %.3f s" % (time.time() - t)) if args.json: model = args.json vers_str = ''.join(versions) crash.capture_info('Model is: '+model+'. '+vers_str) print("Uploaded JSON & Sentry to fork maintainer") ================================================ FILE: selfdrive/car/gm/__init__.py ================================================ ================================================ FILE: selfdrive/car/gm/carcontroller.py ================================================ from cereal import car from common.realtime import DT_CTRL from common.numpy_fast import interp from selfdrive.config import Conversions as CV from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.gm import gmcan from selfdrive.car.gm.values import DBC, CanBus, CarControllerParams from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl VisualAlert = car.CarControl.HUDControl.VisualAlert class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.start_time = 0. self.apply_steer_last = 0 self.lka_icon_status_last = (False, False) self.steer_rate_limited = False self.params = CarControllerParams() self.packer_pt = CANPacker(DBC[CP.carFingerprint]['pt']) self.packer_obj = CANPacker(DBC[CP.carFingerprint]['radar']) self.packer_ch = CANPacker(DBC[CP.carFingerprint]['chassis']) def update(self, enabled, CS, frame, actuators, hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert, dragonconf): P = self.params # Send CAN commands. can_sends = [] # STEER if (frame % P.STEER_STEP) == 0: lkas_enabled = enabled and not (CS.out.steerWarning or CS.out.steerError) and CS.out.vEgo > P.MIN_STEER_SPEED if lkas_enabled: new_steer = int(round(actuators.steer * P.STEER_MAX)) apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, P) self.steer_rate_limited = new_steer != apply_steer else: apply_steer = 0 # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on self.apply_steer_last = apply_steer idx = (frame // P.STEER_STEP) % 4 can_sends.append(gmcan.create_steering_control(self.packer_pt, CanBus.POWERTRAIN, apply_steer, idx, lkas_enabled)) if not enabled: # Stock ECU sends max regen when not enabled. apply_gas = P.MAX_ACC_REGEN apply_brake = 0 else: apply_gas = int(round(interp(actuators.accel, P.GAS_LOOKUP_BP, P.GAS_LOOKUP_V))) apply_brake = int(round(interp(actuators.accel, P.BRAKE_LOOKUP_BP, P.BRAKE_LOOKUP_V))) # Gas/regen and brakes - all at 25Hz if (frame % 4) == 0: idx = (frame // 4) % 4 at_full_stop = enabled and CS.out.standstill near_stop = enabled and (CS.out.vEgo < P.NEAR_STOP_BRAKE_PHASE) can_sends.append(gmcan.create_friction_brake_command(self.packer_ch, CanBus.CHASSIS, apply_brake, idx, near_stop, at_full_stop)) can_sends.append(gmcan.create_gas_regen_command(self.packer_pt, CanBus.POWERTRAIN, apply_gas, idx, enabled, at_full_stop)) # Send dashboard UI commands (ACC status), 25hz if (frame % 4) == 0: send_fcw = hud_alert == VisualAlert.fcw can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, CanBus.POWERTRAIN, enabled, hud_v_cruise * CV.MS_TO_KPH, hud_show_car, send_fcw)) # Radar needs to know current speed and yaw rate (50hz), # and that ADAS is alive (10hz) time_and_headlights_step = 10 tt = frame * DT_CTRL if frame % time_and_headlights_step == 0: idx = (frame // time_and_headlights_step) % 4 can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx)) can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE)) speed_and_accelerometer_step = 2 if frame % speed_and_accelerometer_step == 0: idx = (frame // speed_and_accelerometer_step) % 4 can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx)) can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx)) if frame % P.ADAS_KEEPALIVE_STEP == 0: can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN) # Show green icon when LKA torque is applied, and # alarming orange icon when approaching torque limit. # If not sent again, LKA icon disappears in about 5 seconds. # Conveniently, sending camera message periodically also works as a keepalive. lka_active = CS.lkas_status == 1 lka_critical = lka_active and abs(actuators.steer) > 0.9 lka_icon_status = (lka_active, lka_critical) if frame % P.CAMERA_KEEPALIVE_STEP == 0 or lka_icon_status != self.lka_icon_status_last: steer_alert = hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw] can_sends.append(gmcan.create_lka_icon_command(CanBus.SW_GMLAN, lka_active, lka_critical, steer_alert)) self.lka_icon_status_last = lka_icon_status return can_sends ================================================ FILE: selfdrive/car/gm/carstate.py ================================================ from cereal import car from common.numpy_fast import mean from selfdrive.config import Conversions as CV from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser from selfdrive.car.interfaces import CarStateBase from selfdrive.car.gm.values import DBC, CAR, AccState, CanBus, \ CruiseButtons, STEER_THRESHOLD class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.shifter_values = can_define.dv["ECMPRDNL"]["PRNDL"] def update(self, pt_cp): ret = car.CarState.new_message() self.prev_cruise_buttons = self.cruise_buttons self.cruise_buttons = pt_cp.vl["ASCMSteeringButton"]["ACCButtons"] ret.wheelSpeeds.fl = pt_cp.vl["EBCMWheelSpdFront"]["FLWheelSpd"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = pt_cp.vl["EBCMWheelSpdFront"]["FRWheelSpd"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = pt_cp.vl["EBCMWheelSpdRear"]["RLWheelSpd"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = pt_cp.vl["EBCMWheelSpdRear"]["RRWheelSpd"] * CV.KPH_TO_MS ret.vEgoRaw = mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr]) ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = ret.vEgoRaw < 0.01 ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["ECMPRDNL"]["PRNDL"], None)) ret.brake = pt_cp.vl["EBCMBrakePedalPosition"]["BrakePedalPosition"] / 0xd0 # Brake pedal's potentiometer returns near-zero reading even when pedal is not pressed. if ret.brake < 10/0xd0: ret.brake = 0. ret.gas = pt_cp.vl["AcceleratorPedal"]["AcceleratorPedal"] / 254. ret.gasPressed = ret.gas > 1e-5 ret.steeringAngleDeg = pt_cp.vl["PSCMSteeringAngle"]["SteeringWheelAngle"] ret.steeringRateDeg = pt_cp.vl["PSCMSteeringAngle"]["SteeringWheelRate"] ret.steeringTorque = pt_cp.vl["PSCMStatus"]["LKADriverAppldTrq"] ret.steeringTorqueEps = pt_cp.vl["PSCMStatus"]["LKATorqueDelivered"] ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD # 0 inactive, 1 active, 2 temporarily limited, 3 failed self.lkas_status = pt_cp.vl["PSCMStatus"]["LKATorqueDeliveredStatus"] ret.steerWarning = self.lkas_status == 2 ret.steerError = self.lkas_status == 3 # 1 - open, 0 - closed ret.doorOpen = (pt_cp.vl["BCMDoorBeltStatus"]["FrontLeftDoor"] == 1 or pt_cp.vl["BCMDoorBeltStatus"]["FrontRightDoor"] == 1 or pt_cp.vl["BCMDoorBeltStatus"]["RearLeftDoor"] == 1 or pt_cp.vl["BCMDoorBeltStatus"]["RearRightDoor"] == 1) # 1 - latched ret.seatbeltUnlatched = pt_cp.vl["BCMDoorBeltStatus"]["LeftSeatBelt"] == 0 ret.leftBlinker = pt_cp.vl["BCMTurnSignals"]["TurnSignals"] == 1 ret.rightBlinker = pt_cp.vl["BCMTurnSignals"]["TurnSignals"] == 2 self.park_brake = pt_cp.vl["EPBStatus"]["EPBClosed"] ret.cruiseState.available = bool(pt_cp.vl["ECMEngineStatus"]["CruiseMainOn"]) ret.espDisabled = pt_cp.vl["ESPStatus"]["TractionControlOn"] != 1 self.pcm_acc_status = pt_cp.vl["AcceleratorPedal2"]["CruiseState"] ret.brakePressed = ret.brake > 1e-5 # Regen braking is braking if self.car_fingerprint == CAR.VOLT: ret.brakePressed = ret.brakePressed or bool(pt_cp.vl["EBCMRegenPaddle"]["RegenPaddle"]) ret.cruiseState.enabled = self.pcm_acc_status != AccState.OFF # dp ret.cruiseActualEnabled = ret.cruiseState.enabled ret.cruiseState.standstill = self.pcm_acc_status == AccState.STANDSTILL # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("BrakePedalPosition", "EBCMBrakePedalPosition", 0), ("FrontLeftDoor", "BCMDoorBeltStatus", 0), ("FrontRightDoor", "BCMDoorBeltStatus", 0), ("RearLeftDoor", "BCMDoorBeltStatus", 0), ("RearRightDoor", "BCMDoorBeltStatus", 0), ("LeftSeatBelt", "BCMDoorBeltStatus", 0), ("RightSeatBelt", "BCMDoorBeltStatus", 0), ("TurnSignals", "BCMTurnSignals", 0), ("AcceleratorPedal", "AcceleratorPedal", 0), ("CruiseState", "AcceleratorPedal2", 0), ("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS), ("SteeringWheelAngle", "PSCMSteeringAngle", 0), ("SteeringWheelRate", "PSCMSteeringAngle", 0), ("FLWheelSpd", "EBCMWheelSpdFront", 0), ("FRWheelSpd", "EBCMWheelSpdFront", 0), ("RLWheelSpd", "EBCMWheelSpdRear", 0), ("RRWheelSpd", "EBCMWheelSpdRear", 0), ("PRNDL", "ECMPRDNL", 0), ("LKADriverAppldTrq", "PSCMStatus", 0), ("LKATorqueDelivered", "PSCMStatus", 0), ("LKATorqueDeliveredStatus", "PSCMStatus", 0), ("TractionControlOn", "ESPStatus", 0), ("EPBClosed", "EPBStatus", 0), ("CruiseMainOn", "ECMEngineStatus", 0), ] checks = [ ("BCMTurnSignals", 1), ("ECMPRDNL", 10), ("PSCMStatus", 10), ("ESPStatus", 10), ("BCMDoorBeltStatus", 10), ("EPBStatus", 20), ("EBCMWheelSpdFront", 20), ("EBCMWheelSpdRear", 20), ("AcceleratorPedal", 33), ("AcceleratorPedal2", 33), ("ASCMSteeringButton", 33), ("ECMEngineStatus", 100), ("PSCMSteeringAngle", 100), ("EBCMBrakePedalPosition", 100), ] if CP.carFingerprint == CAR.VOLT: signals += [ ("RegenPaddle", "EBCMRegenPaddle", 0), ] checks += [ ("EBCMRegenPaddle", 50), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.POWERTRAIN) ================================================ FILE: selfdrive/car/gm/gmcan.py ================================================ from selfdrive.car import make_can_msg def create_steering_control(packer, bus, apply_steer, idx, lkas_active): values = { "LKASteeringCmdActive": lkas_active, "LKASteeringCmd": apply_steer, "RollingCounter": idx, "LKASteeringCmdChecksum": 0x1000 - (lkas_active << 11) - (apply_steer & 0x7ff) - idx } return packer.make_can_msg("ASCMLKASteeringCmd", bus, values) def create_adas_keepalive(bus): dat = b"\x00\x00\x00\x00\x00\x00\x00" return [make_can_msg(0x409, dat, bus), make_can_msg(0x40a, dat, bus)] def create_gas_regen_command(packer, bus, throttle, idx, acc_engaged, at_full_stop): values = { "GasRegenCmdActive": acc_engaged, "RollingCounter": idx, "GasRegenCmdActiveInv": 1 - acc_engaged, "GasRegenCmd": throttle, "GasRegenFullStopActive": at_full_stop, "GasRegenAlwaysOne": 1, "GasRegenAlwaysOne2": 1, "GasRegenAlwaysOne3": 1, } dat = packer.make_can_msg("ASCMGasRegenCmd", bus, values)[2] values["GasRegenChecksum"] = (((0xff - dat[1]) & 0xff) << 16) | \ (((0xff - dat[2]) & 0xff) << 8) | \ ((0x100 - dat[3] - idx) & 0xff) return packer.make_can_msg("ASCMGasRegenCmd", bus, values) def create_friction_brake_command(packer, bus, apply_brake, idx, near_stop, at_full_stop): mode = 0x1 if apply_brake > 0: mode = 0xa if at_full_stop: mode = 0xd # TODO: this is to have GM bringing the car to complete stop, # but currently it conflicts with OP controls, so turned off. #elif near_stop: # mode = 0xb brake = (0x1000 - apply_brake) & 0xfff checksum = (0x10000 - (mode << 12) - brake - idx) & 0xffff values = { "RollingCounter" : idx, "FrictionBrakeMode" : mode, "FrictionBrakeChecksum": checksum, "FrictionBrakeCmd" : -apply_brake } return packer.make_can_msg("EBCMFrictionBrakeCmd", bus, values) def create_acc_dashboard_command(packer, bus, acc_engaged, target_speed_kph, lead_car_in_sight, fcw): # Not a bit shift, dash can round up based on low 4 bits. target_speed = int(target_speed_kph * 16) & 0xfff values = { "ACCAlwaysOne" : 1, "ACCResumeButton" : 0, "ACCSpeedSetpoint" : target_speed, "ACCGapLevel" : 3 * acc_engaged, # 3 "far", 0 "inactive" "ACCCmdActive" : acc_engaged, "ACCAlwaysOne2" : 1, "ACCLeadCar" : lead_car_in_sight, "FCWAlert": 0x3 if fcw else 0 } return packer.make_can_msg("ASCMActiveCruiseControlStatus", bus, values) def create_adas_time_status(bus, tt, idx): dat = [(tt >> 20) & 0xff, (tt >> 12) & 0xff, (tt >> 4) & 0xff, ((tt & 0xf) << 4) + (idx << 2)] chksum = 0x1000 - dat[0] - dat[1] - dat[2] - dat[3] chksum = chksum & 0xfff dat += [0x40 + (chksum >> 8), chksum & 0xff, 0x12] return make_can_msg(0xa1, bytes(dat), bus) def create_adas_steering_status(bus, idx): dat = [idx << 6, 0xf0, 0x20, 0, 0, 0] chksum = 0x60 + sum(dat) dat += [chksum >> 8, chksum & 0xff] return make_can_msg(0x306, bytes(dat), bus) def create_adas_accelerometer_speed_status(bus, speed_ms, idx): spd = int(speed_ms * 16) & 0xfff accel = 0 & 0xfff # 0 if in park/neutral, 0x10 if in reverse, 0x08 for D/L #stick = 0x08 near_range_cutoff = 0x27 near_range_mode = 1 if spd <= near_range_cutoff else 0 far_range_mode = 1 - near_range_mode dat = [0x08, spd >> 4, ((spd & 0xf) << 4) | (accel >> 8), accel & 0xff, 0] chksum = 0x62 + far_range_mode + (idx << 2) + dat[0] + dat[1] + dat[2] + dat[3] + dat[4] dat += [(idx << 5) + (far_range_mode << 4) + (near_range_mode << 3) + (chksum >> 8), chksum & 0xff] return make_can_msg(0x308, bytes(dat), bus) def create_adas_headlights_status(packer, bus): values = { "Always42": 0x42, "Always4": 0x4, } return packer.make_can_msg("ASCMHeadlight", bus, values) def create_lka_icon_command(bus, active, critical, steer): if active and steer == 1: if critical: dat = b"\x50\xc0\x14" else: dat = b"\x50\x40\x18" elif active: if critical: dat = b"\x40\xc0\x14" else: dat = b"\x40\x40\x18" else: dat = b"\x00\x00\x00" return make_can_msg(0x104c006c, dat, bus) ================================================ FILE: selfdrive/car/gm/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV from selfdrive.car.gm.values import CAR, CruiseButtons, \ AccState, CarControllerParams from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr ButtonType = car.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName class CarInterface(CarInterfaceBase): @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): params = CarControllerParams() return params.ACCEL_MIN, params.ACCEL_MAX @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "gm" # dp ret.lateralTuning.init('pid') ret.safetyModel = car.CarParams.SafetyModel.gm ret.pcmCruise = False # stock cruise control is kept off # GM port is a community feature # TODO: make a port that uses a car harness and it only intercepts the camera ret.communityFeature = True # Presence of a camera on the object bus is ok. # Have to go to read_only if ASCM is online (ACC-enabled cars), # or camera is on powertrain bus (LKA cars without ACC). ret.openpilotLongitudinalControl = True tire_stiffness_factor = 0.444 # not optimized yet # Start with a baseline lateral tuning for all GM vehicles. Override tuning as needed in each model section below. ret.minSteerSpeed = 7 * CV.MPH_TO_MS ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.00]] ret.lateralTuning.pid.kf = 0.00004 # full torque for 20 deg at 80mph means 0.00007818594 ret.steerRateCost = 1.0 ret.steerActuatorDelay = 0.1 # Default delay, not measured yet if candidate == CAR.VOLT: # supports stop and go, but initial engage must be above 18mph (which include conservatism) ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1607. + STD_CARGO_KG ret.wheelbase = 2.69 ret.steerRatio = 15.7 ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 # wild guess elif candidate == CAR.MALIBU: # supports stop and go, but initial engage must be above 18mph (which include conservatism) ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1496. + STD_CARGO_KG ret.wheelbase = 2.83 ret.steerRatio = 15.8 ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 # wild guess elif candidate == CAR.HOLDEN_ASTRA: ret.mass = 1363. + STD_CARGO_KG ret.wheelbase = 2.662 # Remaining parameters copied from Volt for now ret.centerToFront = ret.wheelbase * 0.4 ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.steerRatio = 15.7 ret.steerRatioRear = 0. elif candidate == CAR.ACADIA: ret.minEnableSpeed = -1. # engage speed is decided by pcm ret.mass = 4353. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.86 ret.steerRatio = 14.4 # end to end is 13.46 ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 elif candidate == CAR.BUICK_REGAL: ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 3779. * CV.LB_TO_KG + STD_CARGO_KG # (3849+3708)/2 ret.wheelbase = 2.83 # 111.4 inches in meters ret.steerRatio = 14.4 # guess for tourx ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.4 # guess for tourx elif candidate == CAR.CADILLAC_ATS: ret.minEnableSpeed = 18 * CV.MPH_TO_MS ret.mass = 1601. + STD_CARGO_KG ret.wheelbase = 2.78 ret.steerRatio = 15.3 ret.steerRatioRear = 0. ret.centerToFront = ret.wheelbase * 0.49 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) ret.longitudinalTuning.kpBP = [5., 35.] ret.longitudinalTuning.kpV = [2.4, 1.5] ret.longitudinalTuning.kiBP = [0.] ret.longitudinalTuning.kiV = [0.36] ret.startAccel = 0.8 ret.steerLimitTimer = 0.4 ret.radarTimeStep = 0.0667 # GM radar runs at 15Hz instead of standard 20Hz # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): self.cp.update_strings(can_strings) ret = self.CS.update(self.cp) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False buttonEvents = [] if self.CS.cruise_buttons != self.CS.prev_cruise_buttons and self.CS.prev_cruise_buttons != CruiseButtons.INIT: be = car.CarState.ButtonEvent.new_message() be.type = ButtonType.unknown if self.CS.cruise_buttons != CruiseButtons.UNPRESS: be.pressed = True but = self.CS.cruise_buttons else: be.pressed = False but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: if not (ret.cruiseState.enabled and ret.standstill): be.type = ButtonType.accelCruise # Suppress resume button if we're resuming from stop so we don't adjust speed. elif but == CruiseButtons.DECEL_SET: be.type = ButtonType.decelCruise elif but == CruiseButtons.CANCEL: be.type = ButtonType.cancel elif but == CruiseButtons.MAIN: be.type = ButtonType.altButton3 buttonEvents.append(be) ret.buttonEvents = buttonEvents events = self.create_common_events(ret, pcm_enable=False) if ret.vEgo < self.CP.minEnableSpeed: events.add(EventName.belowEngageSpeed) if self.CS.park_brake: events.add(EventName.parkBrake) if ret.cruiseState.standstill: events.add(EventName.resumeRequired) if self.CS.pcm_acc_status == AccState.FAULTED: events.add(EventName.accFaulted) if ret.vEgo < self.CP.minSteerSpeed: events.add(car.CarEvent.EventName.belowSteerSpeed) # handle button presses for b in ret.buttonEvents: # do enable on both accel and decel buttons if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: events.add(EventName.buttonEnable) # do disable on button down if b.type == ButtonType.cancel and b.pressed: events.add(EventName.buttonCancel) ret.events = events.to_msg() # copy back carState packet to CS self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): hud_v_cruise = c.hudControl.setSpeed if hud_v_cruise > 70: hud_v_cruise = 0 # For Openpilot, "enabled" includes pre-enable. # In GM, PCM faults out if ACC command overlaps user gas. enabled = c.enabled and not self.CS.out.gasPressed can_sends = self.CC.update(enabled, self.CS, self.frame, c.actuators, hud_v_cruise, c.hudControl.lanesVisible, c.hudControl.leadVisible, c.hudControl.visualAlert, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/gm/radar_interface.py ================================================ #!/usr/bin/env python3 from __future__ import print_function import math from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.gm.values import DBC, CAR, CanBus from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import RadarInterfaceBase RADAR_HEADER_MSG = 1120 SLOT_1_MSG = RADAR_HEADER_MSG + 1 NUM_SLOTS = 20 # Actually it's 0x47f, but can parser only reports # messages that are present in DBC LAST_RADAR_MSG = RADAR_HEADER_MSG + NUM_SLOTS def create_radar_can_parser(car_fingerprint): if car_fingerprint not in (CAR.VOLT, CAR.MALIBU, CAR.HOLDEN_ASTRA, CAR.ACADIA, CAR.CADILLAC_ATS): return None # C1A-ARS3-A by Continental radar_targets = list(range(SLOT_1_MSG, SLOT_1_MSG + NUM_SLOTS)) signals = list(zip(['FLRRNumValidTargets', 'FLRRSnsrBlckd', 'FLRRYawRtPlsblityFlt', 'FLRRHWFltPrsntInt', 'FLRRAntTngFltPrsnt', 'FLRRAlgnFltPrsnt', 'FLRRSnstvFltPrsntInt'] + ['TrkRange'] * NUM_SLOTS + ['TrkRangeRate'] * NUM_SLOTS + ['TrkRangeAccel'] * NUM_SLOTS + ['TrkAzimuth'] * NUM_SLOTS + ['TrkWidth'] * NUM_SLOTS + ['TrkObjectID'] * NUM_SLOTS, [RADAR_HEADER_MSG] * 7 + radar_targets * 6, [0] * 7 + [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + [0.0] * NUM_SLOTS + [0] * NUM_SLOTS)) checks = list({(s[1], 14) for s in signals}) return CANParser(DBC[car_fingerprint]['radar'], signals, checks, CanBus.OBSTACLE) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.rcp = create_radar_can_parser(CP.carFingerprint) self.trigger_msg = LAST_RADAR_MSG self.updated_messages = set() self.radar_ts = CP.radarTimeStep def update(self, can_strings): if self.rcp is None: return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None ret = car.RadarData.new_message() header = self.rcp.vl[RADAR_HEADER_MSG] fault = header['FLRRSnsrBlckd'] or header['FLRRSnstvFltPrsntInt'] or \ header['FLRRYawRtPlsblityFlt'] or header['FLRRHWFltPrsntInt'] or \ header['FLRRAntTngFltPrsnt'] or header['FLRRAlgnFltPrsnt'] errors = [] if not self.rcp.can_valid: errors.append("canError") if fault: errors.append("fault") ret.errors = errors currentTargets = set() num_targets = header['FLRRNumValidTargets'] # Not all radar messages describe targets, # no need to monitor all of the self.rcp.msgs_upd for ii in self.updated_messages: if ii == RADAR_HEADER_MSG: continue if num_targets == 0: break cpt = self.rcp.vl[ii] # Zero distance means it's an empty target slot if cpt['TrkRange'] > 0.0: targetId = cpt['TrkObjectID'] currentTargets.add(targetId) if targetId not in self.pts: self.pts[targetId] = car.RadarData.RadarPoint.new_message() self.pts[targetId].trackId = targetId distance = cpt['TrkRange'] self.pts[targetId].dRel = distance # from front of car # From driver's pov, left is positive self.pts[targetId].yRel = math.sin(cpt['TrkAzimuth'] * CV.DEG_TO_RAD) * distance self.pts[targetId].vRel = cpt['TrkRangeRate'] self.pts[targetId].aRel = float('nan') self.pts[targetId].yvRel = float('nan') for oldTarget in list(self.pts.keys()): if oldTarget not in currentTargets: del self.pts[oldTarget] ret.points = list(self.pts.values()) self.updated_messages.clear() return ret ================================================ FILE: selfdrive/car/gm/values.py ================================================ # flake8: noqa from cereal import car from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu class CarControllerParams(): def __init__(self): self.STEER_MAX = 300 self.STEER_STEP = 2 # how often we update the steer cmd self.STEER_DELTA_UP = 7 # ~0.75s time to peak torque (255/50hz/0.75s) self.STEER_DELTA_DOWN = 17 # ~0.3s from peak torque to zero self.MIN_STEER_SPEED = 3. self.STEER_DRIVER_ALLOWANCE = 50 # allowed driver torque before start limiting self.STEER_DRIVER_MULTIPLIER = 4 # weight driver torque heavily self.STEER_DRIVER_FACTOR = 100 # from dbc self.NEAR_STOP_BRAKE_PHASE = 0.5 # m/s, more aggressive braking near full stop # Takes case of "Service Adaptive Cruise" and "Service Front Camera" # dashboard messages. self.ADAS_KEEPALIVE_STEP = 100 self.CAMERA_KEEPALIVE_STEP = 100 # pedal lookups, only for Volt MAX_GAS = 3072 # Only a safety limit ZERO_GAS = 2048 MAX_BRAKE = 350 # Should be around 3.5m/s^2, including regen self.ACCEL_MAX = 2.0 # m/s^2 # Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we # perform the closed loop control, and might need some # to apply some more braking if we're on a downhill slope. # Our controller should still keep the 2 second average above # -3.5 m/s^2 as per planner limits self.ACCEL_MIN = -4.0 # m/s^2 self.MAX_ACC_REGEN = 1404 # ACC Regen braking is slightly less powerful than max regen paddle self.GAS_LOOKUP_BP = [-1.0, 0., self.ACCEL_MAX] self.GAS_LOOKUP_V = [self.MAX_ACC_REGEN, ZERO_GAS, MAX_GAS] self.BRAKE_LOOKUP_BP = [self.ACCEL_MIN, -1.0] self.BRAKE_LOOKUP_V = [MAX_BRAKE, 0] class CAR: HOLDEN_ASTRA = "HOLDEN ASTRA RS-V BK 2017" VOLT = "CHEVROLET VOLT PREMIER 2017" CADILLAC_ATS = "CADILLAC ATS Premium Performance 2018" MALIBU = "CHEVROLET MALIBU PREMIER 2017" ACADIA = "GMC ACADIA DENALI 2018" BUICK_REGAL = "BUICK REGAL ESSENCE 2018" class CruiseButtons: INIT = 0 UNPRESS = 1 RES_ACCEL = 2 DECEL_SET = 3 MAIN = 5 CANCEL = 6 class AccState: OFF = 0 ACTIVE = 1 FAULTED = 3 STANDSTILL = 4 class CanBus: POWERTRAIN = 0 OBSTACLE = 1 CHASSIS = 2 SW_GMLAN = 3 FINGERPRINTS = { # Astra BK MY17, ASCM unplugged CAR.HOLDEN_ASTRA: [{ 190: 8, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 8, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 393: 8, 398: 8, 401: 8, 413: 8, 417: 8, 419: 8, 422: 1, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 8, 455: 7, 456: 8, 458: 5, 479: 8, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 8, 501: 8, 508: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 647: 5, 707: 8, 715: 8, 723: 8, 753: 5, 761: 7, 806: 1, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1009: 8, 1011: 6, 1017: 8, 1019: 3, 1020: 8, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 8, 1280: 4, 1300: 8, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1908: 7, 1912: 7, 1919: 7, }], CAR.VOLT: [ # Volt Premier w/ ACC 2017 { 170: 8, 171: 8, 189: 7, 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 289: 8, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 389: 2, 390: 7, 417: 7, 419: 1, 426: 7, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 4, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 5, 567: 3, 568: 1, 573: 1, 577: 8, 647: 3, 707: 8, 711: 6, 715: 8, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 961: 8, 969: 8, 977: 8, 979: 7, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1019: 2, 1020: 8, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1275: 3, 1280: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1922: 7, 1927: 7, 1928: 7, 2016: 8, 2020: 8, 2024: 8, 2028: 8 }, # Volt Premier w/ ACC 2018 { 170: 8, 171: 8, 189: 7, 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 288: 5, 298: 8, 304: 1, 308: 4, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 389: 2, 390: 7, 417: 7, 419: 1, 426: 7, 451: 8, 452: 8, 453: 6, 454: 8, 456: 8, 479: 3, 481: 7, 485: 8, 489: 8, 493: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 528: 4, 532: 6, 546: 7, 550: 8, 554: 3, 558: 8, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 566: 5, 567: 3, 568: 1, 573: 1, 577: 8, 578: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 711: 6, 715: 8, 717: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 967: 4, 969: 8, 977: 8, 979: 7, 988: 6, 989: 8, 995: 7, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1187: 4, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1227: 4, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1273: 3, 1275: 3, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1516: 8, 1601: 8, 1618: 8, 1905: 7, 1906: 7, 1907: 7, 1910: 7, 1912: 7, 1922: 7, 1927: 7, 1930: 7, 2016: 8, 2018: 8, 2020: 8, 2024: 8, 2028: 8 }], CAR.BUICK_REGAL : [ # Regal TourX Essence w/ ACC 2018 { 190: 8, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 8, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 8, 419: 8, 422: 4, 426: 8, 431: 8, 442: 8, 451: 8, 452: 8, 453: 8, 455: 7, 456: 8, 463: 3, 479: 8, 481: 7, 485: 8, 487: 8, 489: 8, 495: 8, 497: 8, 499: 3, 500: 8, 501: 8, 508: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 569: 3, 573: 1, 577: 8, 578: 8, 579: 8, 587: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 3, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 882: 8, 884: 8, 890: 1, 892: 2, 893: 2, 894: 1, 961: 8, 967: 8, 969: 8, 977: 8, 979: 8, 985: 8, 1001: 8, 1005: 6, 1009: 8, 1011: 8, 1013: 3, 1017: 8, 1020: 8, 1024: 8, 1025: 8, 1026: 8, 1027: 8, 1028: 8, 1029: 8, 1030: 8, 1031: 8, 1032: 2, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 8, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1259: 8, 1261: 8, 1263: 8, 1265: 8, 1267: 8, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1601: 8, 1602: 8, 1603: 7, 1611: 8, 1618: 8, 1906: 8, 1907: 7, 1912: 7, 1914: 7, 1916: 7, 1919: 7, 1930: 7, 2016: 8, 2018: 8, 2019: 8, 2024: 8, 2026: 8 }], CAR.CADILLAC_ATS: [ # Cadillac ATS Coupe Premium Performance 3.6L RWD w/ ACC 2018 { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 322: 7, 328: 1, 352: 5, 368: 3, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 401: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 462: 4, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 491: 2, 493: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 719: 5, 723: 2, 753: 5, 761: 7, 801: 8, 804: 3, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 882: 8, 890: 1, 892: 2, 893: 2, 894: 1, 961: 8, 967: 4, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1011: 6, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 3, 1225: 7, 1233: 8, 1241: 3, 1249: 8, 1257: 6, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1904: 7, 1906: 7, 1907: 7, 1912: 7, 1916: 7, 1917: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8 }], CAR.MALIBU: [ # Malibu Premier w/ ACC 2017 { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 6, 384: 4, 386: 8, 388: 8, 393: 7, 398: 8, 407: 7, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 455: 7, 456: 8, 479: 3, 481: 7, 485: 8, 487: 8, 489: 8, 495: 4, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 528: 5, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 565: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 810: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1013: 3, 1017: 8, 1019: 2, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1223: 2, 1225: 7, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1323: 4, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1919: 7, 1930: 7, 2016: 8, 2024: 8, }], CAR.ACADIA: [ # Acadia Denali w/ACC 2018 { 190: 6, 192: 5, 193: 8, 197: 8, 199: 4, 201: 6, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 1, 290: 1, 298: 8, 304: 8, 309: 8, 313: 8, 320: 8, 322: 7, 328: 1, 352: 7, 368: 8, 381: 8, 384: 8, 386: 8, 388: 8, 393: 8, 398: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 458: 8, 460: 4, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 489: 5, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 512: 3, 530: 8, 532: 6, 534: 2, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 568: 2, 573: 1, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 789: 5, 800: 6, 801: 8, 803: 8, 804: 3, 805: 8, 832: 8, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1003: 5, 1005: 6, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1918: 7, 1919: 7, 1920: 7, 1930: 7 }, # Acadia Denali w/ /ACC 2018 { 190: 6, 193: 8, 197: 8, 199: 4, 201: 8, 208: 8, 209: 7, 211: 2, 241: 6, 249: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 313: 8, 320: 3, 322: 7, 328: 1, 338: 6, 340: 6, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 393: 8, 398: 8, 413: 8, 417: 7, 419: 1, 422: 4, 426: 7, 431: 8, 442: 8, 451: 8, 452: 8, 453: 6, 454: 8, 455: 7, 462: 4, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 499: 3, 500: 6, 501: 8, 508: 8, 510: 8, 532: 6, 554: 3, 560: 8, 562: 8, 563: 5, 564: 5, 567: 5, 573: 1, 577: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 647: 6, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 840: 5, 842: 5, 844: 8, 866: 4, 869: 4, 880: 6, 961: 8, 969: 8, 977: 8, 979: 8, 985: 5, 1001: 8, 1005: 6, 1009: 8, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1105: 6, 1217: 8, 1221: 5, 1225: 8, 1233: 8, 1249: 8, 1257: 6, 1265: 8, 1267: 1, 1280: 4, 1296: 4, 1300: 8, 1322: 6, 1328: 4, 1417: 8, 1601: 8, 1906: 7, 1907: 7, 1912: 7, 1914: 7, 1919: 7, 1920: 7, 1930: 7, 2016: 8, 2024: 8 }], } STEER_THRESHOLD = 1.0 DBC = { CAR.HOLDEN_ASTRA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.VOLT: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.MALIBU: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.ACADIA: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.CADILLAC_ATS: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), CAR.BUICK_REGAL: dbc_dict('gm_global_a_powertrain', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'), } ================================================ FILE: selfdrive/car/honda/__init__.py ================================================ ================================================ FILE: selfdrive/car/honda/carcontroller.py ================================================ from collections import namedtuple from cereal import car from common.realtime import DT_CTRL from selfdrive.controls.lib.drive_helpers import rate_limit from common.numpy_fast import clip, interp from selfdrive.car import create_gas_command from selfdrive.car.honda import hondacan from selfdrive.car.honda.values import CruiseButtons, VISUAL_HUD, HONDA_BOSCH, HONDA_NIDEC_ALT_PCM_ACCEL, CarControllerParams, CAR from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl VisualAlert = car.CarControl.HUDControl.VisualAlert LongCtrlState = car.CarControl.Actuators.LongControlState def compute_gb_honda_bosch(accel, speed): #TODO returns 0s, is unused return 0.0, 0.0 def compute_gb_honda_nidec(accel, speed): creep_brake = 0.0 creep_speed = 2.3 creep_brake_value = 0.15 if speed < creep_speed: creep_brake = (creep_speed - speed) / creep_speed * creep_brake_value gb = float(accel) / 4.8 - creep_brake return clip(gb, 0.0, 1.0), clip(-gb, 0.0, 1.0) def compute_gas_brake(accel, speed, fingerprint): if fingerprint in HONDA_BOSCH: return compute_gb_honda_bosch(accel, speed) else: return compute_gb_honda_nidec(accel, speed) #TODO not clear this does anything useful def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint): # hyst params brake_hyst_on = 0.02 # to activate brakes exceed this value brake_hyst_off = 0.005 # to deactivate brakes below this value brake_hyst_gap = 0.01 # don't change brake command for small oscillations within this value #*** hysteresis logic to avoid brake blinking. go above 0.1 to trigger if (brake < brake_hyst_on and not braking) or brake < brake_hyst_off: brake = 0. braking = brake > 0. # for small brake oscillations within brake_hyst_gap, don't change the brake command if brake == 0.: brake_steady = 0. elif brake > brake_steady + brake_hyst_gap: brake_steady = brake - brake_hyst_gap elif brake < brake_steady - brake_hyst_gap: brake_steady = brake + brake_hyst_gap brake = brake_steady return brake, braking, brake_steady def brake_pump_hysteresis(apply_brake, apply_brake_last, last_pump_ts, ts): pump_on = False # reset pump timer if: # - there is an increment in brake request # - we are applying steady state brakes and we haven't been running the pump # for more than 20s (to prevent pressure bleeding) if apply_brake > apply_brake_last or (ts - last_pump_ts > 20. and apply_brake > 0): last_pump_ts = ts # once the pump is on, run it for at least 0.2s if ts - last_pump_ts < 0.2 and apply_brake > 0: pump_on = True return pump_on, last_pump_ts def process_hud_alert(hud_alert): # initialize to no alert fcw_display = 0 steer_required = 0 acc_alert = 0 # priority is: FCW, steer required, all others if hud_alert == VisualAlert.fcw: fcw_display = VISUAL_HUD[hud_alert.raw] elif hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw]: steer_required = VISUAL_HUD[hud_alert.raw] else: acc_alert = VISUAL_HUD[hud_alert.raw] return fcw_display, steer_required, acc_alert HUDData = namedtuple("HUDData", ["pcm_accel", "v_cruise", "car", "lanes", "fcw", "acc_alert", "steer_required", "dashed_lanes"]) class CarController(): def rough_speed(self, lead_distance): if self.prev_lead_distance != lead_distance: self.lead_distance_counter_prev = self.lead_distance_counter self.rough_lead_speed += 0.3334 * ( (lead_distance - self.prev_lead_distance) / self.lead_distance_counter_prev - self.rough_lead_speed) self.lead_distance_counter = 0.0 elif self.lead_distance_counter >= self.lead_distance_counter_prev: self.rough_lead_speed = (self.lead_distance_counter * self.rough_lead_speed) / (self.lead_distance_counter + 1.0) self.lead_distance_counter += 1.0 self.prev_lead_distance = lead_distance return self.rough_lead_speed def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.prev_lead_distance = 0.0 self.stopped_lead_distance = 0.0 self.lead_distance_counter = 1 self.lead_distance_counter_prev = 1 self.rough_lead_speed = 0.0 self.braking = False self.brake_steady = 0. self.brake_last = 0. self.apply_brake_last = 0 self.last_pump_ts = 0. self.packer = CANPacker(dbc_name) self.params = CarControllerParams(CP) def update(self, enabled, CS, frame, actuators, pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel, hud_v_cruise, hud_show_lanes, dragonconf, hud_show_car, hud_alert): P = self.params if enabled: accel = actuators.accel gas, brake = compute_gas_brake(actuators.accel, CS.out.vEgo, CS.CP.carFingerprint) else: accel = 0.0 gas, brake = 0.0, 0.0 # *** apply brake hysteresis *** pre_limit_brake, self.braking, self.brake_steady = actuator_hystereses(brake, self.braking, self.brake_steady, CS.out.vEgo, CS.CP.carFingerprint) # *** no output if not enabled *** if not enabled and CS.out.cruiseState.enabled: # send pcm acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated pcm_cancel_cmd = True # Never send cancel command if we never enter cruise state (no cruise if pedal) # Cancel cmd causes brakes to release at a standstill causing grinding pcm_cancel_cmd = pcm_cancel_cmd and CS.CP.pcmCruise # *** rate limit after the enable check *** self.brake_last = rate_limit(pre_limit_brake, self.brake_last, -2., DT_CTRL) # vehicle hud display, wait for one update from 10Hz 0x304 msg if hud_show_lanes and CS.lkMode: hud_lanes = 1 else: hud_lanes = 0 if enabled: if hud_show_car: hud_car = 2 else: hud_car = 1 else: hud_car = 0 fcw_display, steer_required, acc_alert = process_hud_alert(hud_alert) # **** process the car messages **** # steer torque is converted back to CAN reference (positive when steering right) apply_steer = int(interp(-actuators.steer * P.STEER_MAX, P.STEER_LOOKUP_BP, P.STEER_LOOKUP_V)) lkas_active = enabled and not CS.steer_not_allowed and CS.lkMode # Send CAN commands. can_sends = [] # tester present - w/ no response (keeps radar disabled) if CS.CP.carFingerprint in HONDA_BOSCH and CS.CP.openpilotLongitudinalControl: if (frame % 10) == 0: can_sends.append((0x18DAB0F1, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", 1)) # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on # Send steering command. idx = frame % 4 can_sends.append(hondacan.create_steering_control(self.packer, apply_steer, lkas_active, CS.CP.carFingerprint, idx, CS.CP.openpilotLongitudinalControl)) stopping = actuators.longControlState == LongCtrlState.stopping starting = actuators.longControlState == LongCtrlState.starting # Prevent rolling backwards accel = -4.0 if stopping else accel # wind brake from air resistance decel at high speed wind_brake = interp(CS.out.vEgo, [0.0, 2.3, 35.0], [0.001, 0.002, 0.15]) # all of this is only relevant for HONDA NIDEC max_accel = interp(CS.out.vEgo, P.NIDEC_MAX_ACCEL_BP, P.NIDEC_MAX_ACCEL_V) # TODO this 1.44 is just to maintain previous behavior pcm_speed_BP = [-wind_brake, -wind_brake*(3/4), 0.0, 0.5] # The Honda ODYSSEY seems to have different PCM_ACCEL # msgs, is it other cars too? if CS.CP.carFingerprint in HONDA_NIDEC_ALT_PCM_ACCEL: pcm_speed_V = [0.0, clip(CS.out.vEgo - 3.0, 0.0, 100.0), clip(CS.out.vEgo + 0.0, 0.0, 100.0), clip(CS.out.vEgo + 5.0, 0.0, 100.0)] pcm_accel = int((1.0) * 0xc6) else: pcm_speed_V = [0.0, clip(CS.out.vEgo - 2.0, 0.0, 100.0), clip(CS.out.vEgo + 2.0, 0.0, 100.0), clip(CS.out.vEgo + 5.0, 0.0, 100.0)] pcm_accel = int(clip((accel/1.44)/max_accel, 0.0, 1.0) * 0xc6) pcm_speed = interp(gas-brake, pcm_speed_BP, pcm_speed_V) if not CS.CP.openpilotLongitudinalControl: if (frame % 2) == 0: idx = frame // 2 can_sends.append(hondacan.create_bosch_supplemental_1(self.packer, CS.CP.carFingerprint, idx)) # If using stock ACC, spam cancel command to kill gas when OP disengages. if not dragonconf.dpAllowGas and pcm_cancel_cmd: can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.CANCEL, idx, CS.CP.carFingerprint)) elif CS.out.cruiseState.standstill: if CS.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.INSIGHT): rough_lead_speed = self.rough_speed(CS.lead_distance) if CS.lead_distance > (self.stopped_lead_distance + 15.0) or rough_lead_speed > 0.1: self.stopped_lead_distance = 0.0 can_sends.append( hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx, CS.CP.carFingerprint)) elif CS.CP.carFingerprint in (CAR.CIVIC_BOSCH, CAR.CRV_HYBRID): if CS.hud_lead == 1: can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx, CS.CP.carFingerprint)) else: can_sends.append(hondacan.spam_buttons_command(self.packer, CruiseButtons.RES_ACCEL, idx, CS.CP.carFingerprint)) else: self.stopped_lead_distance = CS.lead_distance self.prev_lead_distance = CS.lead_distance else: # Send gas and brake commands. if (frame % 2) == 0: idx = frame // 2 ts = frame * DT_CTRL if dragonconf.dpAtl and dragonconf.dpAtlOpLong and not CS.out.cruiseActualEnabled: accel = 0. gas = 0. self.brake_last = 0. if dragonconf.dpAtl and not dragonconf.dpAtlOpLong: pass elif CS.CP.carFingerprint in HONDA_BOSCH: bosch_gas = interp(accel, P.BOSCH_GAS_LOOKUP_BP, P.BOSCH_GAS_LOOKUP_V) can_sends.extend(hondacan.create_acc_commands(self.packer, enabled, accel, bosch_gas, idx, stopping, starting, CS.CP.carFingerprint)) else: apply_brake = clip(self.brake_last - wind_brake, 0.0, 1.0) apply_brake = int(clip(apply_brake * P.BRAKE_MAX, 0, P.BRAKE_MAX - 1)) if dragonconf.dpAtl and dragonconf.dpAtlOpLong and not CS.out.cruiseActualEnabled: apply_brake = 0 pump_on, self.last_pump_ts = brake_pump_hysteresis(apply_brake, self.apply_brake_last, self.last_pump_ts, ts) can_sends.append(hondacan.create_brake_command(self.packer, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw_display, idx, CS.CP.carFingerprint, CS.stock_brake)) self.apply_brake_last = apply_brake if CS.CP.enableGasInterceptor: # way too aggressive at low speed without this gas_mult = interp(CS.out.vEgo, [0., 10.], [0.4, 1.0]) # send exactly zero if apply_gas is zero. Interceptor will send the max between read value and apply_gas. # This prevents unexpected pedal range rescaling apply_gas = clip(gas_mult * gas, 0., 1.) can_sends.append(create_gas_command(self.packer, apply_gas, idx)) hud = HUDData(int(pcm_accel), int(round(hud_v_cruise)), hud_car, hud_lanes, fcw_display, acc_alert, steer_required, CS.lkMode) # Send dashboard UI commands. if not dragonconf.dpAtl and (frame % 10) == 0: idx = (frame//10) % 4 can_sends.extend(hondacan.create_ui_commands(self.packer, pcm_speed, hud, CS.CP.carFingerprint, CS.is_metric, idx, CS.CP.openpilotLongitudinalControl, CS.stock_hud)) return can_sends ================================================ FILE: selfdrive/car/honda/carstate.py ================================================ from cereal import car from collections import defaultdict from common.numpy_fast import interp from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import CarStateBase from selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, SPEED_FACTOR, HONDA_BOSCH, HONDA_BOSCH_ALT_BRAKE_SIGNAL from common.params import Params TransmissionType = car.CarParams.TransmissionType def calc_cruise_offset(offset, speed): # heuristic formula so that speed is controlled to ~ 0.3m/s below pid_speed # constraints to solve for _K0, _K1, _K2 are: # - speed = 0m/s, out = -0.3 # - speed = 34m/s, offset = 20, out = -0.25 # - speed = 34m/s, offset = -2.5, out = -1.8 _K0 = -0.3 _K1 = -0.01879 _K2 = 0.01013 return min(_K0 + _K1 * speed + _K2 * speed * offset, 0.) def get_can_signals(CP, gearbox_msg="GEARBOX"): # this function generates lists for signal, messages and initial values signals = [ ("XMISSION_SPEED", "ENGINE_DATA", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), ("STEER_ANGLE", "STEERING_SENSORS", 0), ("STEER_ANGLE_RATE", "STEERING_SENSORS", 0), ("MOTOR_TORQUE", "STEER_MOTOR_TORQUE", 0), ("STEER_TORQUE_SENSOR", "STEER_STATUS", 0), ("LEFT_BLINKER", "SCM_FEEDBACK", 0), ("RIGHT_BLINKER", "SCM_FEEDBACK", 0), ("GEAR", gearbox_msg, 0), ("SEATBELT_DRIVER_LAMP", "SEATBELT_STATUS", 1), ("SEATBELT_DRIVER_LATCHED", "SEATBELT_STATUS", 0), ("BRAKE_PRESSED", "POWERTRAIN_DATA", 0), ("BRAKE_SWITCH", "POWERTRAIN_DATA", 0), ("CRUISE_BUTTONS", "SCM_BUTTONS", 0), ("ESP_DISABLED", "VSA_STATUS", 1), ("USER_BRAKE", "VSA_STATUS", 0), ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0), ("STEER_STATUS", "STEER_STATUS", 5), ("GEAR_SHIFTER", gearbox_msg, 0), ("PEDAL_GAS", "POWERTRAIN_DATA", 0), ("CRUISE_SETTING", "SCM_BUTTONS", 0), ("ACC_STATUS", "POWERTRAIN_DATA", 0), ("HUD_LEAD", "ACC_HUD", 0), #dp ("ENGINE_RPM", "POWERTRAIN_DATA", 0), ] checks = [ ("ENGINE_DATA", 100), ("WHEEL_SPEEDS", 50), ("STEERING_SENSORS", 100), ("SEATBELT_STATUS", 10), ("CRUISE", 10), ("POWERTRAIN_DATA", 100), ("VSA_STATUS", 50), ("STEER_STATUS", 100), ("STEER_MOTOR_TORQUE", 0), # TODO: not on every car ] if CP.carFingerprint == CAR.ODYSSEY_CHN: checks += [ ("SCM_FEEDBACK", 25), ("SCM_BUTTONS", 50), ] else: checks += [ ("SCM_FEEDBACK", 10), ("SCM_BUTTONS", 25), ] if CP.carFingerprint in (CAR.CRV_HYBRID, CAR.CIVIC_BOSCH_DIESEL, CAR.ACURA_RDX_3G, CAR.HONDA_E): checks += [ (gearbox_msg, 50), ] else: checks += [ (gearbox_msg, 100), ] if CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL: signals += [("BRAKE_PRESSED", "BRAKE_MODULE", 0)] checks += [("BRAKE_MODULE", 50)] if CP.carFingerprint in HONDA_BOSCH: signals += [ ("CAR_GAS", "GAS_PEDAL_2", 0), ("MAIN_ON", "SCM_FEEDBACK", 0), ("EPB_STATE", "EPB_STATUS", 0), ] checks += [ ("EPB_STATUS", 50), ("GAS_PEDAL_2", 100), ] if not CP.openpilotLongitudinalControl: signals += [ ("CRUISE_CONTROL_LABEL", "ACC_HUD", 0), ("CRUISE_SPEED", "ACC_HUD", 0), ("ACCEL_COMMAND", "ACC_CONTROL", 0), ("AEB_STATUS", "ACC_CONTROL", 0), #brakelights for HONDA BOSCH ("BRAKE_LIGHTS", "ACC_CONTROL", 0), ] checks += [ ("ACC_HUD", 10), ("ACC_CONTROL", 50), ] else: # Nidec signals signals += [("CRUISE_SPEED_PCM", "CRUISE", 0), ("CRUISE_SPEED_OFFSET", "CRUISE_PARAMS", 0)] if CP.carFingerprint == CAR.ODYSSEY_CHN: checks += [("CRUISE_PARAMS", 10)] else: checks += [("CRUISE_PARAMS", 50)] if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.INSIGHT): signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1), ("LEAD_DISTANCE", "RADAR_HUD", 0)] if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.ACURA_RDX_3G, CAR.HONDA_E): signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1)] elif CP.carFingerprint == CAR.ODYSSEY_CHN: signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1)] elif CP.carFingerprint in [CAR.HRV, CAR.JADE]: signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1), ("WHEELS_MOVING", "STANDSTILL", 1)] else: signals += [("DOOR_OPEN_FL", "DOORS_STATUS", 1), ("DOOR_OPEN_FR", "DOORS_STATUS", 1), ("DOOR_OPEN_RL", "DOORS_STATUS", 1), ("DOOR_OPEN_RR", "DOORS_STATUS", 1), ("WHEELS_MOVING", "STANDSTILL", 1)] checks += [ ("DOORS_STATUS", 3), ("STANDSTILL", 50), ] if CP.carFingerprint == CAR.CIVIC: signals += [("CAR_GAS", "GAS_PEDAL_2", 0), ("MAIN_ON", "SCM_FEEDBACK", 0), ("IMPERIAL_UNIT", "HUD_SETTING", 0), ("EPB_STATE", "EPB_STATUS", 0)] checks += [ ("HUD_SETTING", 50), ("EPB_STATUS", 50), ("GAS_PEDAL_2", 100), ] elif CP.carFingerprint == CAR.ACURA_ILX: signals += [("CAR_GAS", "GAS_PEDAL_2", 0), ("MAIN_ON", "SCM_BUTTONS", 0)] checks += [ ("GAS_PEDAL_2", 100), ] elif CP.carFingerprint in (CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.PILOT_2019, CAR.RIDGELINE): signals += [("MAIN_ON", "SCM_BUTTONS", 0)] elif CP.carFingerprint == CAR.FIT: signals += [("CAR_GAS", "GAS_PEDAL_2", 0), ("MAIN_ON", "SCM_BUTTONS", 0), ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)] checks += [ ("GAS_PEDAL_2", 100), ] elif CP.carFingerprint in [CAR.HRV, CAR.JADE]: signals += [("CAR_GAS", "GAS_PEDAL", 0), ("MAIN_ON", "SCM_BUTTONS", 0), ("BRAKE_HOLD_ACTIVE", "VSA_STATUS", 0)] elif CP.carFingerprint == CAR.ODYSSEY: signals += [("MAIN_ON", "SCM_FEEDBACK", 0), ("EPB_STATE", "EPB_STATUS", 0)] checks += [("EPB_STATUS", 50)] elif CP.carFingerprint == CAR.PILOT: signals += [("MAIN_ON", "SCM_BUTTONS", 0), ("CAR_GAS", "GAS_PEDAL_2", 0)] checks += [ ("GAS_PEDAL_2", 0), # TODO: fix this freq, seems this signal isn't present at all on some models ] elif CP.carFingerprint == CAR.ODYSSEY_CHN: signals += [("MAIN_ON", "SCM_BUTTONS", 0), ("EPB_STATE", "EPB_STATUS", 0)] checks += [("EPB_STATUS", 50)] # add gas interceptor reading if we are using it if CP.enableGasInterceptor: signals.append(("INTERCEPTOR_GAS", "GAS_SENSOR", 0)) signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0)) checks.append(("GAS_SENSOR", 50)) if CP.openpilotLongitudinalControl: signals += [ ("BRAKE_ERROR_1", "STANDSTILL", 1), ("BRAKE_ERROR_2", "STANDSTILL", 1) ] checks += [("STANDSTILL", 50)] return signals, checks class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.gearbox_msg = "GEARBOX" if CP.carFingerprint == CAR.ACCORD and CP.transmissionType == TransmissionType.cvt: self.gearbox_msg = "GEARBOX_15T" self.shifter_values = can_define.dv[self.gearbox_msg]["GEAR_SHIFTER"] self.steer_status_values = defaultdict(lambda: "UNKNOWN", can_define.dv["STEER_STATUS"]["STEER_STATUS"]) self.brake_switch_prev = 0 self.brake_switch_prev_ts = 0 self.cruise_setting = 0 self.v_cruise_pcm_prev = 0 #dp self.lkMode = True self.hud_lead = 0 self.lead_distance = 0. self.engineRPM = 0 self.dp_honda_kmh_display = Params().get_bool('dp_honda_kmh_display') def update(self, cp, cp_cam, cp_body): ret = car.CarState.new_message() # car params v_weight_v = [0., 1.] # don't trust smooth speed at low values to avoid premature zero snapping v_weight_bp = [1., 6.] # smooth blending, below ~0.6m/s the smooth speed snaps to zero # update prevs, update must run once per loop self.prev_cruise_buttons = self.cruise_buttons self.prev_cruise_setting = self.cruise_setting # ******************* parse out can ******************* # TODO: find wheels moving bit in dbc if self.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.INSIGHT): ret.standstill = cp.vl["ENGINE_DATA"]["XMISSION_SPEED"] < 0.1 ret.doorOpen = bool(cp.vl["SCM_FEEDBACK"]["DRIVERS_DOOR_OPEN"]) self.lead_distance = cp.vl["RADAR_HUD"]["LEAD_DISTANCE"] elif self.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.ACURA_RDX_3G, CAR.HONDA_E): ret.standstill = cp.vl["ENGINE_DATA"]["XMISSION_SPEED"] < 0.1 ret.doorOpen = bool(cp.vl["SCM_FEEDBACK"]["DRIVERS_DOOR_OPEN"]) elif self.CP.carFingerprint == CAR.ODYSSEY_CHN: ret.standstill = cp.vl["ENGINE_DATA"]["XMISSION_SPEED"] < 0.1 ret.doorOpen = bool(cp.vl["SCM_BUTTONS"]["DRIVERS_DOOR_OPEN"]) elif self.CP.carFingerprint in [CAR.HRV, CAR.JADE]: ret.doorOpen = bool(cp.vl["SCM_BUTTONS"]["DRIVERS_DOOR_OPEN"]) else: ret.standstill = not cp.vl["STANDSTILL"]["WHEELS_MOVING"] ret.doorOpen = any([cp.vl["DOORS_STATUS"]["DOOR_OPEN_FL"], cp.vl["DOORS_STATUS"]["DOOR_OPEN_FR"], cp.vl["DOORS_STATUS"]["DOOR_OPEN_RL"], cp.vl["DOORS_STATUS"]["DOOR_OPEN_RR"]]) ret.seatbeltUnlatched = bool(cp.vl["SEATBELT_STATUS"]["SEATBELT_DRIVER_LAMP"] or not cp.vl["SEATBELT_STATUS"]["SEATBELT_DRIVER_LATCHED"]) steer_status = self.steer_status_values[cp.vl["STEER_STATUS"]["STEER_STATUS"]] ret.steerError = steer_status not in ["NORMAL", "NO_TORQUE_ALERT_1", "NO_TORQUE_ALERT_2", "LOW_SPEED_LOCKOUT", "TMP_FAULT"] # NO_TORQUE_ALERT_2 can be caused by bump OR steering nudge from driver self.steer_not_allowed = steer_status not in ["NORMAL", "NO_TORQUE_ALERT_2"] # LOW_SPEED_LOCKOUT is not worth a warning ret.steerWarning = steer_status not in ["NORMAL", "LOW_SPEED_LOCKOUT", "NO_TORQUE_ALERT_2"] if not self.CP.openpilotLongitudinalControl: self.brake_error = 0 else: self.brake_error = cp.vl["STANDSTILL"]["BRAKE_ERROR_1"] or cp.vl["STANDSTILL"]["BRAKE_ERROR_2"] ret.espDisabled = cp.vl["VSA_STATUS"]["ESP_DISABLED"] != 0 speed_factor = SPEED_FACTOR.get(self.CP.carFingerprint, 1.) ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"] * CV.KPH_TO_MS * speed_factor ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"] * CV.KPH_TO_MS * speed_factor ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"] * CV.KPH_TO_MS * speed_factor ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"] * CV.KPH_TO_MS * speed_factor v_wheel = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr)/4. # blend in transmission speed at low speed, since it has more low speed accuracy v_weight = interp(v_wheel, v_weight_bp, v_weight_v) ret.vEgoRaw = (1. - v_weight) * cp.vl["ENGINE_DATA"]["XMISSION_SPEED"] * CV.KPH_TO_MS * speed_factor + v_weight * v_wheel ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.steeringAngleDeg = cp.vl["STEERING_SENSORS"]["STEER_ANGLE"] ret.steeringRateDeg = cp.vl["STEERING_SENSORS"]["STEER_ANGLE_RATE"] # dp - when user presses LKAS button on steering wheel if self.cruise_setting == 1: if cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] == 0: if self.lkMode: self.lkMode = False else: self.lkMode = True self.cruise_setting = cp.vl["SCM_BUTTONS"]["CRUISE_SETTING"] self.cruise_buttons = cp.vl["SCM_BUTTONS"]["CRUISE_BUTTONS"] ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_stalk( 250, cp.vl["SCM_FEEDBACK"]["LEFT_BLINKER"], cp.vl["SCM_FEEDBACK"]["RIGHT_BLINKER"]) self.brake_hold = cp.vl["VSA_STATUS"]["BRAKE_HOLD_ACTIVE"] #dp self.engineRPM = cp.vl["POWERTRAIN_DATA"]['ENGINE_RPM'] if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E): self.park_brake = cp.vl["EPB_STATUS"]["EPB_STATE"] != 0 main_on = cp.vl["SCM_FEEDBACK"]["MAIN_ON"] elif self.CP.carFingerprint == CAR.ODYSSEY_CHN: self.park_brake = cp.vl["EPB_STATUS"]["EPB_STATE"] != 0 main_on = cp.vl["SCM_BUTTONS"]["MAIN_ON"] else: self.park_brake = 0 # TODO main_on = cp.vl["SCM_BUTTONS"]["MAIN_ON"] gear = int(cp.vl[self.gearbox_msg]["GEAR_SHIFTER"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear, None)) pedal_gas = cp.vl["POWERTRAIN_DATA"]["PEDAL_GAS"] # crv doesn't include cruise control if self.CP.carFingerprint in (CAR.CRV, CAR.CRV_EU, CAR.HRV, CAR.ODYSSEY, CAR.ACURA_RDX, CAR.RIDGELINE, CAR.PILOT_2019, CAR.ODYSSEY_CHN, CAR.JADE): ret.gas = pedal_gas / 256. else: ret.gas = cp.vl["GAS_PEDAL_2"]["CAR_GAS"] / 256. # this is a hack for the interceptor. This is now only used in the simulation # TODO: Replace tests by toyota so this can go away if self.CP.enableGasInterceptor: user_gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2. ret.gasPressed = user_gas > 1e-5 # this works because interceptor read < 0 when pedal position is 0. Once calibrated, this will change else: ret.gasPressed = pedal_gas > 1e-5 ret.steeringTorque = cp.vl["STEER_STATUS"]["STEER_TORQUE_SENSOR"] ret.steeringTorqueEps = cp.vl["STEER_MOTOR_TORQUE"]["MOTOR_TORQUE"] ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD.get(self.CP.carFingerprint, 1200) if self.CP.carFingerprint in HONDA_BOSCH: if not self.CP.openpilotLongitudinalControl: ret.cruiseState.nonAdaptive = cp.vl["ACC_HUD"]["CRUISE_CONTROL_LABEL"] != 0 ret.cruiseState.standstill = cp.vl["ACC_HUD"]["CRUISE_SPEED"] == 252. # On set, cruise set speed pulses between 254~255 and the set speed prev is set to avoid this. ret.cruiseState.speed = self.v_cruise_pcm_prev if cp.vl["ACC_HUD"]["CRUISE_SPEED"] > 160.0 else cp.vl["ACC_HUD"]["CRUISE_SPEED"] * CV.KPH_TO_MS self.v_cruise_pcm_prev = ret.cruiseState.speed else: ret.cruiseState.speedOffset = calc_cruise_offset(cp.vl["CRUISE_PARAMS"]["CRUISE_SPEED_OFFSET"], ret.vEgo) ret.cruiseState.speed = cp.vl["CRUISE"]["CRUISE_SPEED_PCM"] * CV.KPH_TO_MS self.brake_switch = cp.vl["POWERTRAIN_DATA"]["BRAKE_SWITCH"] != 0 if self.CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL: ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0 else: # brake switch has shown some single time step noise, so only considered when # switch is on for at least 2 consecutive CAN samples # panda safety only checks BRAKE_PRESSED signal ret.brakePressed = bool(cp.vl["POWERTRAIN_DATA"]["BRAKE_PRESSED"] or (self.brake_switch and self.brake_switch_prev and cp.ts["POWERTRAIN_DATA"]["BRAKE_SWITCH"] != self.brake_switch_prev_ts)) self.brake_switch_prev = self.brake_switch self.brake_switch_prev_ts = cp.ts["POWERTRAIN_DATA"]["BRAKE_SWITCH"] ret.brake = cp.vl["VSA_STATUS"]["USER_BRAKE"] ret.cruiseState.enabled = cp.vl["POWERTRAIN_DATA"]["ACC_STATUS"] != 0 # dp ret.cruiseActualEnabled = ret.cruiseState.enabled ret.cruiseState.available = bool(main_on) # afa feature self.hud_lead = cp.vl["ACC_HUD"]['HUD_LEAD'] # Gets rid of Pedal Grinding noise when brake is pressed at slow speeds for some models if self.CP.carFingerprint in (CAR.PILOT, CAR.PILOT_2019, CAR.RIDGELINE, CAR.JADE): if ret.brake > 0.05: ret.brakePressed = True # TODO: discover the CAN msg that has the imperial unit bit for all other cars if self.CP.carFingerprint in [CAR.JADE]: self.is_metric = True else: self.is_metric = not cp.vl["HUD_SETTING"]["IMPERIAL_UNIT"] if self.CP.carFingerprint in (CAR.CIVIC) else False if self.dp_honda_kmh_display: self.is_metric = True if self.CP.carFingerprint in HONDA_BOSCH: ret.stockAeb = (not self.CP.openpilotLongitudinalControl) and bool(cp.vl["ACC_CONTROL"]["AEB_STATUS"] and cp.vl["ACC_CONTROL"]["ACCEL_COMMAND"] < -1e-5) else: ret.stockAeb = bool(cp_cam.vl["BRAKE_COMMAND"]["AEB_REQ_1"] and cp_cam.vl["BRAKE_COMMAND"]["COMPUTER_BRAKE"] > 1e-5) if self.CP.carFingerprint in HONDA_BOSCH: self.stock_hud = False ret.stockFcw = False #brakelights for HONDA BOSCH self.brake_switch = cp.vl["POWERTRAIN_DATA"]['BRAKE_SWITCH'] != 0 self.brake_lights = cp.vl["ACC_CONTROL"]['BRAKE_LIGHTS'] != 0 self.user_brake = cp.vl["VSA_STATUS"]['USER_BRAKE'] else: ret.stockFcw = cp_cam.vl["BRAKE_COMMAND"]["FCW"] != 0 self.stock_hud = cp_cam.vl["ACC_HUD"] self.stock_brake = cp_cam.vl["BRAKE_COMMAND"] if self.CP.enableBsm and self.CP.carFingerprint in (CAR.CRV_5G, CAR.CRV_HYBRID, ): # BSM messages are on B-CAN, requires a panda forwarding B-CAN messages to CAN 0 # more info here: https://github.com/commaai/openpilot/pull/1867 ret.leftBlindspot = cp_body.vl["BSM_STATUS_LEFT"]["BSM_ALERT"] == 1 ret.rightBlindspot = cp_body.vl["BSM_STATUS_RIGHT"]["BSM_ALERT"] == 1 return ret def get_can_parser(self, CP): signals, checks = get_can_signals(CP, self.gearbox_msg) bus_pt = 1 if CP.carFingerprint in HONDA_BOSCH else 0 return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, bus_pt) @staticmethod def get_cam_can_parser(CP): signals = [] # all hondas except CRV, RDX and 2019 Odyssey@China use 0xe4 for steering checks = [(0xe4, 100)] if CP.carFingerprint in [CAR.CRV, CAR.CRV_EU, CAR.ACURA_RDX, CAR.ODYSSEY_CHN]: checks = [(0x194, 100)] if CP.carFingerprint not in HONDA_BOSCH: signals += [("COMPUTER_BRAKE", "BRAKE_COMMAND", 0), ("AEB_REQ_1", "BRAKE_COMMAND", 0), ("FCW", "BRAKE_COMMAND", 0), ("CHIME", "BRAKE_COMMAND", 0), ("FCM_OFF", "ACC_HUD", 0), ("FCM_OFF_2", "ACC_HUD", 0), ("FCM_PROBLEM", "ACC_HUD", 0), ("ICONS", "ACC_HUD", 0)] checks += [ ("ACC_HUD", 10), ("BRAKE_COMMAND", 50), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) @staticmethod def get_body_can_parser(CP): if CP.enableBsm and CP.carFingerprint in (CAR.CRV_5G, CAR.CRV_HYBRID, ): signals = [("BSM_ALERT", "BSM_STATUS_RIGHT", 0), ("BSM_ALERT", "BSM_STATUS_LEFT", 0)] checks = [ ("BSM_STATUS_LEFT", 3), ("BSM_STATUS_RIGHT", 3), ] bus_body = 0 # B-CAN is forwarded to ACC-CAN radar side (CAN 0 on fake ethernet port) return CANParser(DBC[CP.carFingerprint]["body"], signals, checks, bus_body) return None ================================================ FILE: selfdrive/car/honda/hondacan.py ================================================ from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery from selfdrive.car.honda.values import HONDA_BOSCH, CAR from selfdrive.config import Conversions as CV from selfdrive.swaglog import cloudlog # CAN bus layout with relay # 0 = ACC-CAN - radar side # 1 = F-CAN B - powertrain # 2 = ACC-CAN - camera side # 3 = F-CAN A - OBDII port RADAR_ADDR = 0x18DAB0F1 EXT_DIAG_REQUEST = b'\x10\x03' EXT_DIAG_RESPONSE = b'\x50\x03' COM_CONT_REQUEST = b'\x28\x83\x03' COM_CONT_RESPONSE = b'' def get_pt_bus(car_fingerprint): return 1 if car_fingerprint in HONDA_BOSCH else 0 def get_lkas_cmd_bus(car_fingerprint, radar_disabled=False): if radar_disabled: # when radar is disabled, steering commands are sent directly to powertrain bus return get_pt_bus(car_fingerprint) # normally steering commands are sent to radar, which forwards them to powertrain bus return 0 def disable_radar(logcan, sendcan, bus=1, timeout=0.1, debug=False): """Silence the radar by disabling sending and receiving messages using UDS 0x28. The radar will stay silent as long as openpilot keeps sending Tester Present. Openpilot will emulate the radar. WARNING: THIS DISABLES AEB!""" cloudlog.warning(f"radar disable {hex(RADAR_ADDR)} ...") try: query = IsoTpParallelQuery(sendcan, logcan, bus, [RADAR_ADDR], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug) for _, _ in query.get_data(timeout).items(): cloudlog.warning("radar communication control disable tx/rx ...") query = IsoTpParallelQuery(sendcan, logcan, bus, [RADAR_ADDR], [COM_CONT_REQUEST], [COM_CONT_RESPONSE], debug=debug) query.get_data(0) cloudlog.warning("radar disabled") return except Exception: cloudlog.exception("radar disable exception") cloudlog.warning("radar disable failed") def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_cmd, fcw, idx, car_fingerprint, stock_brake): # TODO: do we loose pressure if we keep pump off for long? brakelights = apply_brake > 0 brake_rq = apply_brake > 0 pcm_fault_cmd = False values = { "COMPUTER_BRAKE": apply_brake, "BRAKE_PUMP_REQUEST": pump_on, "CRUISE_OVERRIDE": pcm_override, "CRUISE_FAULT_CMD": pcm_fault_cmd, "CRUISE_CANCEL_CMD": pcm_cancel_cmd, "COMPUTER_BRAKE_REQUEST": brake_rq, "SET_ME_1": 1, "BRAKE_LIGHTS": brakelights, "CHIME": stock_brake["CHIME"] if fcw else 0, # send the chime for stock fcw "FCW": fcw << 1, # TODO: Why are there two bits for fcw? "AEB_REQ_1": 0, "AEB_REQ_2": 0, "AEB_STATUS": 0, } bus = get_pt_bus(car_fingerprint) return packer.make_can_msg("BRAKE_COMMAND", bus, values, idx) def create_acc_commands(packer, enabled, accel, gas, idx, stopping, starting, car_fingerprint): commands = [] bus = get_pt_bus(car_fingerprint) control_on = 5 if enabled else 0 # no gas = -30000 gas_command = gas if enabled and gas > 0 else -30000 accel_command = accel if enabled else 0 braking = 1 if enabled and accel < 0 else 0 standstill = 1 if enabled and stopping else 0 standstill_release = 1 if enabled and starting else 0 acc_control_values = { # setting CONTROL_ON causes car to set POWERTRAIN_DATA->ACC_STATUS = 1 "CONTROL_ON": control_on, "GAS_COMMAND": gas_command, # used for gas "ACCEL_COMMAND": accel_command, # used for brakes "BRAKE_LIGHTS": braking, "BRAKE_REQUEST": braking, "STANDSTILL": standstill, "STANDSTILL_RELEASE": standstill_release, } commands.append(packer.make_can_msg("ACC_CONTROL", bus, acc_control_values, idx)) acc_control_on_values = { "SET_TO_3": 0x03, "CONTROL_ON": enabled, "SET_TO_FF": 0xff, "SET_TO_75": 0x75, "SET_TO_30": 0x30, } commands.append(packer.make_can_msg("ACC_CONTROL_ON", bus, acc_control_on_values, idx)) return commands def create_steering_control(packer, apply_steer, lkas_active, car_fingerprint, idx, radar_disabled): values = { "STEER_TORQUE": apply_steer if lkas_active else 0, "STEER_TORQUE_REQUEST": lkas_active, } bus = get_lkas_cmd_bus(car_fingerprint, radar_disabled) return packer.make_can_msg("STEERING_CONTROL", bus, values, idx) def create_bosch_supplemental_1(packer, car_fingerprint, idx): # non-active params values = { "SET_ME_X04": 0x04, "SET_ME_X80": 0x80, "SET_ME_X10": 0x10, } bus = get_lkas_cmd_bus(car_fingerprint) return packer.make_can_msg("BOSCH_SUPPLEMENTAL_1", bus, values, idx) def create_ui_commands(packer, pcm_speed, hud, car_fingerprint, is_metric, idx, openpilot_longitudinal_control, stock_hud): commands = [] bus_pt = get_pt_bus(car_fingerprint) radar_disabled = car_fingerprint in HONDA_BOSCH and openpilot_longitudinal_control bus_lkas = get_lkas_cmd_bus(car_fingerprint, radar_disabled) if openpilot_longitudinal_control: if car_fingerprint in HONDA_BOSCH: acc_hud_values = { 'CRUISE_SPEED': hud.v_cruise, 'ENABLE_MINI_CAR': 1, 'SET_TO_1': 1, 'HUD_LEAD': hud.car, 'HUD_DISTANCE': 3, 'ACC_ON': hud.car != 0, 'SET_TO_X1': 1, 'IMPERIAL_UNIT': int(not is_metric), } else: acc_hud_values = { 'PCM_SPEED': pcm_speed * CV.MS_TO_KPH, 'PCM_GAS': hud.pcm_accel, 'CRUISE_SPEED': hud.v_cruise, 'ENABLE_MINI_CAR': 1, 'HUD_LEAD': hud.car, 'HUD_DISTANCE': 3, # max distance setting on display 'IMPERIAL_UNIT': int(not is_metric), 'SET_ME_X01_2': 1, 'SET_ME_X01': 1, "FCM_OFF": stock_hud["FCM_OFF"], "FCM_OFF_2": stock_hud["FCM_OFF_2"], "FCM_PROBLEM": stock_hud["FCM_PROBLEM"], "ICONS": stock_hud["ICONS"], } commands.append(packer.make_can_msg("ACC_HUD", bus_pt, acc_hud_values, idx)) lkas_hud_values = { 'SET_ME_X41': 0x41, 'SET_ME_X48': 0x48, 'STEERING_REQUIRED': hud.steer_required, 'SOLID_LANES': hud.lanes, 'BEEP': 0, } commands.append(packer.make_can_msg('LKAS_HUD', bus_lkas, lkas_hud_values, idx)) if radar_disabled and car_fingerprint in HONDA_BOSCH: radar_hud_values = { 'SET_TO_1' : 0x01, } commands.append(packer.make_can_msg('RADAR_HUD', bus_pt, radar_hud_values, idx)) if car_fingerprint == CAR.CIVIC_BOSCH: commands.append(packer.make_can_msg("LEGACY_BRAKE_COMMAND", bus_pt, {}, idx)) return commands def spam_buttons_command(packer, button_val, idx, car_fingerprint): values = { 'CRUISE_BUTTONS': button_val, 'CRUISE_SETTING': 0, } bus = get_pt_bus(car_fingerprint) return packer.make_can_msg("SCM_BUTTONS", bus, values, idx) ================================================ FILE: selfdrive/car/honda/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from panda import Panda from common.numpy_fast import interp from common.params import Params from selfdrive.car.honda.values import CarControllerParams, CruiseButtons, CAR, HONDA_BOSCH, HONDA_BOSCH_ALT_BRAKE_SIGNAL from selfdrive.car.honda.hondacan import disable_radar from selfdrive.car import STD_CARGO_KG, CivicParams, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from selfdrive.config import Conversions as CV from common.dp_common import common_interface_atl, common_interface_get_params_lqr ButtonType = car.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName TransmissionType = car.CarParams.TransmissionType class CarInterface(CarInterfaceBase): @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): if CP.carFingerprint in HONDA_BOSCH: return CarControllerParams.BOSCH_ACCEL_MIN, CarControllerParams.BOSCH_ACCEL_MAX else: # NIDECs don't allow acceleration near cruise_speed, # so limit limits of pid to prevent windup ACCEL_MAX_VALS = [CarControllerParams.NIDEC_ACCEL_MAX, 0.2] ACCEL_MAX_BP = [cruise_speed - 2., cruise_speed - .2] return CarControllerParams.NIDEC_ACCEL_MIN, interp(current_speed, ACCEL_MAX_BP, ACCEL_MAX_VALS) @staticmethod def calc_accel_override(a_ego, a_target, v_ego, v_target): # normalized max accel. Allowing max accel at low speed causes speed overshoots max_accel_bp = [10, 20] # m/s max_accel_v = [0.714, 1.0] # unit of max accel max_accel = interp(v_ego, max_accel_bp, max_accel_v) # limit the pcm accel cmd if: # - v_ego exceeds v_target, or # - a_ego exceeds a_target and v_ego is close to v_target eA = a_ego - a_target valuesA = [1.0, 0.1] bpA = [0.3, 1.1] eV = v_ego - v_target valuesV = [1.0, 0.1] bpV = [0.0, 0.5] valuesRangeV = [1., 0.] bpRangeV = [-1., 0.] # only limit if v_ego is close to v_target speedLimiter = interp(eV, bpV, valuesV) accelLimiter = max(interp(eA, bpA, valuesA), interp(eV, bpRangeV, valuesRangeV)) # accelOverride is more or less the max throttle allowed to pcm: usually set to a constant # unless aTargetMax is very high and then we scale with it; this help in quicker restart return float(max(max_accel, a_target / CarControllerParams.NIDEC_ACCEL_MAX)) * min(speedLimiter, accelLimiter) @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "honda" ret.lateralTuning.init('pid') if candidate in HONDA_BOSCH: ret.safetyModel = car.CarParams.SafetyModel.hondaBoschHarness ret.radarOffCan = True # Disable the radar and let openpilot control longitudinal # WARNING: THIS DISABLES AEB! ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") ret.pcmCruise = not ret.openpilotLongitudinalControl ret.communityFeature = ret.openpilotLongitudinalControl else: ret.safetyModel = car.CarParams.SafetyModel.hondaNidec ret.enableGasInterceptor = 0x201 in fingerprint[0] ret.openpilotLongitudinalControl = True ret.pcmCruise = not ret.enableGasInterceptor ret.communityFeature = ret.enableGasInterceptor ret.enableBsm = True #if candidate in (CAR.CRV_5G, CAR.CRV_HYBRID, ): #ret.enableBsm = 0x12f8bfa7 in fingerprint[0] # Accord 1.5T CVT has different gearbox message if candidate == CAR.ACCORD and 0x191 in fingerprint[1]: ret.transmissionType = TransmissionType.cvt # Certain Hondas have an extra steering sensor at the bottom of the steering rack, # which improves controls quality as it removes the steering column torsion from feedback. # Tire stiffness factor fictitiously lower if it includes the steering column torsion effect. # For modeling details, see p.198-200 in "The Science of Vehicle Dynamics (2014), M. Guiggiani" ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0], [0]] ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward # default longitudinal tuning for all hondas ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] eps_modified = False for fw in car_fw: if fw.ecu == "eps" and b"," in fw.fwVersion: eps_modified = True if candidate == CAR.CIVIC: stop_and_go = True ret.mass = CivicParams.MASS ret.wheelbase = CivicParams.WHEELBASE ret.centerToFront = CivicParams.CENTER_TO_FRONT ret.steerRatio = 15.38 # 10.93 is end-to-end spec if eps_modified: # stock request input values: 0x0000, 0x00DE, 0x014D, 0x01EF, 0x0290, 0x0377, 0x0454, 0x0610, 0x06EE # stock request output values: 0x0000, 0x0917, 0x0DC5, 0x1017, 0x119F, 0x140B, 0x1680, 0x1680, 0x1680 # modified request output values: 0x0000, 0x0917, 0x0DC5, 0x1017, 0x119F, 0x140B, 0x1680, 0x2880, 0x3180 # stock filter output values: 0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108 # modified filter output values: 0x009F, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0400, 0x0480 # note: max request allowed is 4096, but request is capped at 3840 in firmware, so modifications result in 2x max ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 8000], [0, 2560, 3840]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.1]] else: ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560], [0, 2560]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[1.1], [0.33]] tire_stiffness_factor = 1. elif candidate in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL): stop_and_go = True ret.mass = CivicParams.MASS ret.wheelbase = CivicParams.WHEELBASE ret.centerToFront = CivicParams.CENTER_TO_FRONT ret.steerRatio = 15.38 # 10.93 is end-to-end spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 1. ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate in (CAR.ACCORD, CAR.ACCORDH): stop_and_go = True ret.mass = 3279. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.83 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 16.33 # 11.82 is spec end-to-end ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.8467 if eps_modified: ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.09]] else: ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] elif candidate == CAR.ACURA_ILX: stop_and_go = False ret.mass = 3095. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.37 ret.steerRatio = 18.61 # 15.3 is spec end-to-end ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.72 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate in (CAR.CRV, CAR.CRV_EU): stop_and_go = False ret.mass = 3572. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.62 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 16.89 # as spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 1000], [0, 1000]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate == CAR.CRV_5G: stop_and_go = True ret.mass = 3410. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.66 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 16.0 # 12.3 is spec end-to-end if eps_modified: # stock request input values: 0x0000, 0x00DB, 0x01BB, 0x0296, 0x0377, 0x0454, 0x0532, 0x0610, 0x067F # stock request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x129A, 0x134D, 0x1400 # modified request output values: 0x0000, 0x0500, 0x0A15, 0x0E6D, 0x1100, 0x1200, 0x1ACD, 0x239A, 0x2800 ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 10000], [0, 2560, 3840]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21], [0.07]] else: ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.64], [0.192]] tire_stiffness_factor = 0.677 elif candidate == CAR.CRV_HYBRID: stop_and_go = True ret.mass = 1667. + STD_CARGO_KG # mean of 4 models in kg ret.wheelbase = 2.66 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 16.0 # 12.3 is spec end-to-end ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.677 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] elif candidate == CAR.FIT: stop_and_go = False ret.mass = 2644. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.53 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 13.06 ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.75 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] elif candidate == CAR.HRV: stop_and_go = False ret.mass = 3125 * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.61 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 15.2 ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] tire_stiffness_factor = 0.5 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.025]] elif candidate == CAR.ACURA_RDX: stop_and_go = False ret.mass = 3935. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.68 ret.centerToFront = ret.wheelbase * 0.38 ret.steerRatio = 15.0 # as spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 1000], [0, 1000]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.8], [0.24]] elif candidate == CAR.ACURA_RDX_3G: stop_and_go = True ret.mass = 4068. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.75 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 11.95 # as spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 3840], [0, 3840]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] tire_stiffness_factor = 0.677 elif candidate == CAR.ODYSSEY: stop_and_go = False ret.mass = 4471. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 3.00 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 14.35 # as spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.28], [0.08]] elif candidate == CAR.ODYSSEY_CHN: stop_and_go = False ret.mass = 1849.2 + STD_CARGO_KG # mean of 4 models in kg ret.wheelbase = 2.90 ret.centerToFront = ret.wheelbase * 0.41 # from CAR.ODYSSEY ret.steerRatio = 14.35 ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 32767], [0, 32767]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.28], [0.08]] elif candidate in (CAR.PILOT, CAR.PILOT_2019): stop_and_go = False ret.mass = 4204. * CV.LB_TO_KG + STD_CARGO_KG # average weight ret.wheelbase = 2.82 ret.centerToFront = ret.wheelbase * 0.428 ret.steerRatio = 17.25 # as spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38], [0.11]] elif candidate == CAR.RIDGELINE: stop_and_go = False ret.mass = 4515. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 3.18 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 15.59 # as spec ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.38], [0.11]] elif candidate == CAR.INSIGHT: stop_and_go = True ret.mass = 2987. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.7 ret.centerToFront = ret.wheelbase * 0.39 ret.steerRatio = 15.0 # 12.58 is spec end-to-end ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] elif candidate == CAR.HONDA_E: stop_and_go = True ret.mass = 3338.8 * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.5 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 16.71 ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] # TODO: determine if there is a dead zone at the top end tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.18]] # TODO: can probably use some tuning elif candidate == CAR.JADE: stop_and_go = False ret.mass = 1557. + STD_CARGO_KG ret.wheelbase = 2.76 ret.centerToFront = ret.wheelbase * 0.41 ret.steerRatio = 15.2 ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 4096], [0, 4096]] tire_stiffness_factor = 0.5 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.025]] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kiV = [0.18, 0.12] else: raise ValueError("unsupported car %s" % candidate) # These cars use alternate user brake msg (0x1BE) if candidate in HONDA_BOSCH_ALT_BRAKE_SIGNAL: ret.safetyParam |= Panda.FLAG_HONDA_ALT_BRAKE if ret.openpilotLongitudinalControl and candidate in HONDA_BOSCH: ret.safetyParam |= Panda.FLAG_HONDA_BOSCH_LONG # min speed to enable ACC. if car can do stop and go, then set enabling speed # to a negative value, so it won't matter. Otherwise, add 0.5 mph margin to not # conflict with PCM acc if candidate in [CAR.JADE]: ret.minEnableSpeed = -1. if (ret.enableGasInterceptor) else 30 * CV.KPH_TO_MS else: ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else 25.5 * CV.MPH_TO_MS # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) ret.startAccel = 0.5 ret.steerActuatorDelay = 0.1 ret.steerRateCost = 0.5 ret.steerLimitTimer = 0.8 # dp if Params().get('dp_honda_eps_mod') == b'1': if candidate == CAR.CIVIC: ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 8000], [0, 2560, 3840]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.1]] #tuned by Comma elif candidate in (CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL): ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2564, 8000], [0, 2564, 3840]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.09]] #2.5 default mod #Tuned by TMG elif candidate in (CAR.ACCORD, CAR.ACCORDH): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.09]] elif candidate == CAR.CRV_5G: ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0, 2560, 10000], [0, 2560, 3840]] #tuned by Titanminer (8000) ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21], [0.07]] elif candidate == CAR.CRV_HYBRID: ret.lateralParams.torqueBP, ret.lateralParams.torqueV = [[0x0, 0xB5, 0x161, 0x2D6, 0x4C0, 0x70D, 0xC42, 0x1058, 0x2C00], [0x0, 0x160, 0x1F0, 0x2E0, 0x378, 0x4A0, 0x5F0, 0x804, 0xF00]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.21], [0.07]] #still needs to finish tuning for the new car ret.lateralTuning.pid.kf = 0.00004 ret = common_interface_get_params_lqr(ret) return ret @staticmethod def init(CP, logcan, sendcan): if CP.carFingerprint in HONDA_BOSCH and CP.openpilotLongitudinalControl: disable_radar(logcan, sendcan) # returns a car.CarState def update(self, c, can_strings, dragonconf): # ******************* do can recv ******************* self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) if self.cp_body: self.cp_body.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam, self.cp_body) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.lkMode = self.CS.lkMode ret.canValid = self.cp.can_valid and self.cp_cam.can_valid and (self.cp_body is None or self.cp_body.can_valid) ret.yawRate = self.VM.yaw_rate(ret.steeringAngleDeg * CV.DEG_TO_RAD, ret.vEgo) #dp ret.engineRPM = self.CS.engineRPM # dp - brake lights if self.CS.CP.carFingerprint in HONDA_BOSCH: ret.brakeLights = bool(self.CS.brake_switch or self.CS.brake_lights or self.CS.user_brake > 0.4) else: brakelights_threshold = -0.02 if self.CS.CP.carFingerprint == CAR.CIVIC else -0.1 ret.brakeLights = bool(self.CS.brake_switch or c.actuators.accel < brakelights_threshold) buttonEvents = [] if self.CS.cruise_buttons != self.CS.prev_cruise_buttons: be = car.CarState.ButtonEvent.new_message() be.type = ButtonType.unknown if self.CS.cruise_buttons != 0: be.pressed = True but = self.CS.cruise_buttons else: be.pressed = False but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: be.type = ButtonType.accelCruise elif but == CruiseButtons.DECEL_SET: be.type = ButtonType.decelCruise elif but == CruiseButtons.CANCEL: be.type = ButtonType.cancel elif but == CruiseButtons.MAIN: be.type = ButtonType.altButton3 buttonEvents.append(be) if self.CS.cruise_setting != self.CS.prev_cruise_setting: be = car.CarState.ButtonEvent.new_message() be.type = ButtonType.unknown if self.CS.cruise_setting != 0: be.pressed = True but = self.CS.cruise_setting else: be.pressed = False but = self.CS.prev_cruise_setting if but == 1: be.type = ButtonType.altButton1 # TODO: more buttons? buttonEvents.append(be) ret.buttonEvents = buttonEvents # events events = self.create_common_events(ret, pcm_enable=False) if not self.CS.lkMode or (dragonconf.dpAtl and ret.vEgo <= self.CP.minEnableSpeed): events.add(EventName.manualSteeringRequired) if self.CS.brake_error: events.add(EventName.brakeUnavailable) if self.CS.brake_hold and self.CS.CP.openpilotLongitudinalControl: events.add(EventName.brakeHold) if self.CS.park_brake: events.add(EventName.parkBrake) if self.CP.pcmCruise and ret.vEgo < self.CP.minEnableSpeed: events.add(EventName.belowEngageSpeed) if self.CP.pcmCruise: # we engage when pcm is active (rising edge) if ret.cruiseState.enabled and not self.CS.out.cruiseState.enabled: events.add(EventName.pcmEnable) elif not ret.cruiseState.enabled and (c.actuators.accel >= 0. or not self.CP.openpilotLongitudinalControl): # it can happen that car cruise disables while comma system is enabled: need to # keep braking if needed or if the speed is very low if ret.vEgo < self.CP.minEnableSpeed + 2.: # non loud alert if cruise disables below 25mph as expected (+ a little margin) # events.add(EventName.speedTooLow) # else: events.add(EventName.cruiseDisabled) if self.CS.CP.minEnableSpeed > 0 and ret.vEgo < 0.001: events.add(EventName.manualRestart) # handle button presses for b in ret.buttonEvents: # do enable on both accel and decel buttons if b.type in [ButtonType.accelCruise, ButtonType.decelCruise] and not b.pressed: if not self.CP.pcmCruise: events.add(EventName.buttonEnable) # do disable on button down if b.type == ButtonType.cancel and b.pressed: events.add(EventName.buttonCancel) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out # pass in a car.CarControl # to be called @ 100hz def apply(self, c): if c.hudControl.speedVisible: hud_v_cruise = c.hudControl.setSpeed * CV.MS_TO_KPH else: hud_v_cruise = 255 can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.cruiseControl.speedOverride, c.cruiseControl.override, c.cruiseControl.cancel, c.cruiseControl.accelOverride, hud_v_cruise, c.hudControl.lanesVisible, self.dragonconf, hud_show_car=c.hudControl.leadVisible, hud_alert=c.hudControl.visualAlert) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/honda/radar_interface.py ================================================ #!/usr/bin/env python3 from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.interfaces import RadarInterfaceBase from selfdrive.car.honda.values import DBC def _create_nidec_can_parser(car_fingerprint): radar_messages = [0x400] + list(range(0x430, 0x43A)) + list(range(0x440, 0x446)) signals = list(zip(['RADAR_STATE'] + ['LONG_DIST'] * 16 + ['NEW_TRACK'] * 16 + ['LAT_DIST'] * 16 + ['REL_SPEED'] * 16, [0x400] + radar_messages[1:] * 4, [0] + [255] * 16 + [1] * 16 + [0] * 16 + [0] * 16)) checks = [(s[1], 20) for s in signals] return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.track_id = 0 self.radar_fault = False self.radar_wrong_config = False self.radar_off_can = CP.radarOffCan self.radar_ts = CP.radarTimeStep self.delay = int(round(0.1 / CP.radarTimeStep)) # 0.1s delay of radar # Nidec if self.radar_off_can: self.rcp = None else: self.rcp = _create_nidec_can_parser(CP.carFingerprint) self.trigger_msg = 0x445 self.updated_messages = set() def update(self, can_strings): # in Bosch radar and we are only steering for now, so sleep 0.05s to keep # radard at 20Hz and return no points if self.radar_off_can: return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None rr = self._update(self.updated_messages) self.updated_messages.clear() return rr def _update(self, updated_messages): ret = car.RadarData.new_message() for ii in sorted(updated_messages): cpt = self.rcp.vl[ii] if ii == 0x400: # check for radar faults self.radar_fault = cpt['RADAR_STATE'] != 0x79 self.radar_wrong_config = cpt['RADAR_STATE'] == 0x69 elif cpt['LONG_DIST'] < 255: if ii not in self.pts or cpt['NEW_TRACK']: self.pts[ii] = car.RadarData.RadarPoint.new_message() self.pts[ii].trackId = self.track_id self.track_id += 1 self.pts[ii].dRel = cpt['LONG_DIST'] # from front of car self.pts[ii].yRel = -cpt['LAT_DIST'] # in car frame's y axis, left is positive self.pts[ii].vRel = cpt['REL_SPEED'] self.pts[ii].aRel = float('nan') self.pts[ii].yvRel = float('nan') self.pts[ii].measured = True else: if ii in self.pts: del self.pts[ii] errors = [] if not self.rcp.can_valid: errors.append("canError") if self.radar_fault: errors.append("fault") if self.radar_wrong_config: errors.append("wrongConfig") ret.errors = errors ret.points = list(self.pts.values()) return ret ================================================ FILE: selfdrive/car/honda/values.py ================================================ from cereal import car from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu VisualAlert = car.CarControl.HUDControl.VisualAlert class CarControllerParams(): # Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we # perform the closed loop control, and might need some # to apply some more braking if we're on a downhill slope. # Our controller should still keep the 2 second average above # -3.5 m/s^2 as per planner limits NIDEC_ACCEL_MIN = -4.0 # m/s^2 NIDEC_ACCEL_MAX = 1.6 # m/s^2, lower than 2.0 m/s^2 for tuning reasons BOSCH_ACCEL_MIN = -3.5 # m/s^2 BOSCH_ACCEL_MAX = 2.0 # m/s^2 def __init__(self, CP): self.BRAKE_MAX = 1024//4 self.STEER_MAX = CP.lateralParams.torqueBP[-1] # mirror of list (assuming first item is zero) for interp of signed request values assert(CP.lateralParams.torqueBP[0] == 0) assert(CP.lateralParams.torqueBP[0] == 0) self.STEER_LOOKUP_BP = [v * -1 for v in CP.lateralParams.torqueBP][1:][::-1] + list(CP.lateralParams.torqueBP) self.STEER_LOOKUP_V = [v * -1 for v in CP.lateralParams.torqueV][1:][::-1] + list(CP.lateralParams.torqueV) self.NIDEC_ACCEL_LOOKUP_BP = [-1., 0., .6] self.NIDEC_ACCEL_LOOKUP_V = [-4.8, 0., 2.0] self.NIDEC_MAX_ACCEL_V = [0.5, 2.4, 1.4, 0.6] self.NIDEC_MAX_ACCEL_BP = [0.0, 4.0, 10., 20.] self.BOSCH_GAS_LOOKUP_BP = [0., 2.0] # 2m/s^2 self.BOSCH_GAS_LOOKUP_V = [0, 2000] # Car button codes class CruiseButtons: RES_ACCEL = 4 DECEL_SET = 3 CANCEL = 2 MAIN = 1 # See dbc files for info on values VISUAL_HUD = { VisualAlert.none: 0, VisualAlert.fcw: 1, VisualAlert.steerRequired: 1, VisualAlert.ldw: 1, VisualAlert.brakePressed: 10, VisualAlert.wrongGear: 6, VisualAlert.seatbeltUnbuckled: 5, VisualAlert.speedTooHigh: 8 } class CAR: ACCORD = "HONDA ACCORD 2018" ACCORDH = "HONDA ACCORD HYBRID 2018" CIVIC = "HONDA CIVIC 2016" CIVIC_BOSCH = "HONDA CIVIC (BOSCH) 2019" CIVIC_BOSCH_DIESEL = "HONDA CIVIC SEDAN 1.6 DIESEL 2019" ACURA_ILX = "ACURA ILX 2016" CRV = "HONDA CR-V 2016" CRV_5G = "HONDA CR-V 2017" CRV_EU = "HONDA CR-V EU 2016" CRV_HYBRID = "HONDA CR-V HYBRID 2019" FIT = "HONDA FIT 2018" HRV = "HONDA HRV 2019" ODYSSEY = "HONDA ODYSSEY 2018" ODYSSEY_CHN = "HONDA ODYSSEY CHN 2019" ACURA_RDX = "ACURA RDX 2018" ACURA_RDX_3G = "ACURA RDX 2020" PILOT = "HONDA PILOT 2017" PILOT_2019 = "HONDA PILOT 2019" RIDGELINE = "HONDA RIDGELINE 2017" INSIGHT = "HONDA INSIGHT 2019" HONDA_E = "HONDA E 2020" JADE = "HONDA JADE 2017" # diag message that in some Nidec cars only appear with 1s freq if VIN query is performed DIAG_MSGS = {1600: 5, 1601: 8} FINGERPRINTS = { CAR.ACCORDH: [{ 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 387: 8, 388: 8, 399: 7, 419: 8, 420: 8, 427: 3, 432: 7, 441: 5, 450: 8, 464: 8, 477: 8, 479: 8, 495: 8, 525: 8, 545: 6, 662: 4, 773: 7, 777: 8, 780: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 927: 8, 929: 8, 1302: 8, 1600: 5, 1601: 8, 1652: 8 }], CAR.ACURA_RDX: [{ 57: 3, 145: 8, 229: 4, 308: 5, 316: 8, 342: 6, 344: 8, 380: 8, 392: 6, 398: 3, 399: 6, 404: 4, 420: 8, 422: 8, 426: 8, 432: 7, 464: 8, 474: 5, 476: 4, 487: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 4, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 800: 8, 804: 8, 808: 8, 819: 7, 821: 5, 829: 5, 882: 2, 884: 7, 887: 8, 888: 8, 892: 8, 923: 2, 929: 4, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1033: 5, 1034: 5, 1036: 8, 1039: 8, 1057: 5, 1064: 7, 1108: 8, 1365: 5, 1424: 5, 1729: 1 }], CAR.CIVIC: [{ 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 450: 8, 464: 8, 470: 2, 476: 7, 487: 4, 490: 8, 493: 5, 506: 8, 512: 6, 513: 6, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1633: 8, }], CAR.CIVIC_BOSCH: [{ 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 460: 3, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1625: 5, 1629: 5, 1633: 8, }, { 57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 815: 8, 825: 4, 829: 5, 846: 8, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 892: 8, 918: 7, 927: 8, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1092: 1, 1108: 8, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1633: 8 }], CAR.CRV_5G: [{ 57: 3, 148: 8, 199: 4, 228: 5, 231: 5, 232: 7, 304: 8, 330: 8, 340: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 446: 3, 450: 8, 464: 8, 467: 2, 469: 3, 470: 2, 474: 8, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 507: 1, 545: 6, 597: 8, 661: 4, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 814: 4, 815: 8, 817: 4, 825: 4, 829: 5, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 927: 8, 918: 7, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1108: 8, 1092: 1, 1115: 2, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1618: 5, 1633: 8, 1670: 5 }], CAR.ODYSSEY: [{ 57: 3, 148: 8, 228: 5, 229: 4, 316: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1615: 8, 1616: 5, 1619: 5, 1623: 5, 1668: 5 }, { 57: 3, 148: 8, 228: 5, 229: 4, 304: 8, 342: 6, 344: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 427: 3, 432: 7, 440: 8, 450: 8, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 507: 1, 542: 7, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 862: 8, 871: 8, 881: 8, 882: 4, 884: 8, 891: 8, 892: 8, 905: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1029: 8, 1036: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1302: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1616: 5, 1619: 5, 1623: 5, 1668: 5 }], CAR.ODYSSEY_CHN: [{ 57: 3, 145: 8, 316: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 401: 8, 404: 4, 411: 5, 420: 8, 422: 8, 423: 2, 426: 8, 432: 7, 450: 8, 464: 8, 490: 8, 506: 8, 507: 1, 512: 6, 513: 6, 597: 8, 610: 8, 611: 8, 612: 8, 617: 8, 660: 8, 661: 4, 773: 7, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 923: 2, 929: 8, 1030: 5, 1137: 8, 1302: 8, 1348: 5, 1361: 5, 1365: 5, 1600: 5, 1601: 8, 1639: 8 }], CAR.PILOT_2019: [{ 57: 3, 145: 8, 228: 5, 308: 5, 316: 8, 334: 8, 342: 6, 344: 8, 379: 8, 380: 8, 399: 7, 411: 5, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 463: 8, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 538: 3, 542: 7, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 817: 4, 819: 7, 821: 5, 825: 4, 829: 5, 837: 5, 856: 7, 871: 8, 881: 8, 882: 2, 884: 7, 891: 8, 892: 8, 923: 2, 927: 8, 929: 8, 983: 8, 985: 3, 1029: 8, 1052: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1110: 8, 1125: 8, 1296: 8, 1424: 5, 1445: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1614: 5, 1615: 8, 1616: 5, 1617: 8, 1618: 5, 1623: 5, 1668: 5 }, { 57: 3, 145: 8, 228: 5, 229: 4, 308: 5, 316: 8, 339: 7, 342: 6, 344: 8, 380: 8, 392: 6, 399: 7, 411: 5, 419: 8, 420: 8, 422: 8, 425: 8, 426: 8, 427: 3, 432: 7, 464: 8, 476: 4, 490: 8, 506: 8, 512: 6, 513: 6, 542: 7, 545: 5, 546: 3, 597: 8, 660: 8, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 808: 8, 817: 4, 819: 7, 821: 5, 829: 5, 871: 8, 881: 8, 882: 2, 884: 7, 891: 8, 892: 8, 923: 2, 927: 8, 929: 8, 963: 8, 965: 8, 966: 8, 967: 8, 983: 8, 985: 3, 1027: 5, 1029: 8, 1039: 8, 1064: 7, 1088: 8, 1089: 8, 1092: 1, 1108: 8, 1125: 8, 1296: 8, 1424: 5, 1445: 8, 1600: 5, 1601: 8, 1612: 5, 1613: 5, 1616: 5, 1617: 8, 1618: 5, 1623: 5, 1668: 5 }], CAR.JADE: [{ 57: 3, 145: 8, 228: 5, 304: 8, 342: 6, 344: 8, 380: 8, 398: 3, 399: 7, 401: 8, 420: 8, 422: 8, 428: 8, 432: 7, 464: 8, 487: 4, 490: 8, 506: 8, 507: 1, 512: 6, 513: 6, 597: 8, 660: 8, 661: 4, 773: 7, 777: 8, 780: 8, 804: 8, 808: 8, 829: 5, 862: 8, 884: 7, 892: 8, 923: 2, 929: 4, 1057: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8 }], } # add DIAG_MSGS to fingerprints for c in FINGERPRINTS: for f, _ in enumerate(FINGERPRINTS[c]): for d in DIAG_MSGS: FINGERPRINTS[c][f][d] = DIAG_MSGS[d] # TODO: Figure out what is relevant FW_VERSIONS = { CAR.ACCORD: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-6A0-A640\x00\x00', b'37805-6B2-A550\x00\x00', b'37805-6B2-A560\x00\x00', b'37805-6B2-A650\x00\x00', b'37805-6B2-A660\x00\x00', b'37805-6B2-A720\x00\x00', b'37805-6B2-A810\x00\x00', b'37805-6B2-A820\x00\x00', b'37805-6B2-A920\x00\x00', b'37805-6B2-M520\x00\x00', b'37805-6A0-9520\x00\x00', b'37805-6A0-9620\x00\x00', b'37805-6A0-9720\x00\x00', b'37805-6A0-A540\x00\x00', b'37805-6A0-A550\x00\x00', b'37805-6A0-A650\x00\x00', b'37805-6A0-A740\x00\x00', b'37805-6A0-A750\x00\x00', b'37805-6A0-A840\x00\x00', b'37805-6A0-A850\x00\x00', b'37805-6A0-C540\x00\x00', b'37805-6A1-H650\x00\x00', b'37805-6M4-B730\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TVC-A910\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28102-6B8-A560\x00\x00', b'28102-6B8-A570\x00\x00', b'28102-6B8-A700\x00\x00', b'28102-6B8-A800\x00\x00', b'28102-6B8-C560\x00\x00', b'28102-6B8-C570\x00\x00', b'28102-6B8-M520\x00\x00', b'28101-6A7-A220\x00\x00', b'28101-6A7-A230\x00\x00', b'28101-6A7-A320\x00\x00', b'28101-6A7-A330\x00\x00', b'28101-6A7-A410\x00\x00', b'28101-6A7-A510\x00\x00', b'28101-6A9-H140\x00\x00', b'28101-6A9-H420\x00\x00', ], (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ b'46114-TVA-A060\x00\x00', b'46114-TVA-A080\x00\x00', b'46114-TVA-A120\x00\x00', b'46114-TVA-A320\x00\x00', b'46114-TVA-A050\x00\x00', b'46114-TVE-H550\x00\x00', b'46114-TVE-H560\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TVA-C040\x00\x00', b'57114-TVA-C050\x00\x00', b'57114-TVA-C060\x00\x00', b'57114-TVA-C530\x00\x00', b'57114-TVA-B040\x00\x00', b'57114-TVA-B050\x00\x00', b'57114-TVA-B060\x00\x00', b'57114-TVE-H250\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TVA,A150\x00\x00', b'39990-TVA-A150\x00\x00', b'39990-TVA-A160\x00\x00', b'39990-TVA-A340\x00\x00', b'39990-TVA-X030\x00\x00', b'39990-TVA-A140\x00\x00', b'39990-TVE-H130\x00\x00', b'39990-TBX-H120\x00\x00', ], (Ecu.unknown, 0x18da3af1, None): [ b'39390-TVA-A020\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TVA-A460\x00\x00', b'77959-TVA-L420\x00\x00', b'77959-TVA-X330\x00\x00', b'77959-TVA-H230\x00\x00', b'77959-TBX-H230\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TVC-C010\x00\x00', b'78109-TVA-A210\x00\x00', b'78109-TVC-A010\x00\x00', b'78109-TVC-A020\x00\x00', b'78109-TVC-A030\x00\x00', b'78109-TVC-A110\x00\x00', b'78109-TVC-A130\x00\x00', b'78109-TVC-A210\x00\x00', b'78109-TVC-A220\x00\x00', b'78109-TVC-C110\x00\x00', b'78109-TVC-L010\x00\x00', b'78109-TVC-L210\x00\x00', b'78109-TVC-M510\x00\x00', b'78109-TBX-H310\x00\x00', b'78109-TVA-A010\x00\x00', b'78109-TVA-A020\x00\x00', b'78109-TVA-A110\x00\x00', b'78109-TVA-A120\x00\x00', b'78109-TVA-A220\x00\x00', b'78109-TVA-A310\x00\x00', b'78109-TVA-C010\x00\x00', b'78109-TVA-L010\x00\x00', b'78109-TVA-L210\x00\x00', b'78109-TVE-H610\x00\x00', b'78109-TWA-A210\x00\x00', ], (Ecu.hud, 0x18da61f1, None): [ b'78209-TVA-A010\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TVA-A160\x00\x00', b'36802-TVA-A170\x00\x00', b'36802-TVC-A330\x00\x00', b'36802-TWA-A070\x00\x00', b'36802-TVA-A150\x00\x00', b'36802-TVE-H070\x00\x00', b'36802-TBX-H140\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TVA-A060\x00\x00', b'36161-TVC-A330\x00\x00', b'36161-TWA-A070\x00\x00', b'36161-TVE-H050\x00\x00', b'36161-TBX-H130\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TVA-A010\x00\x00', b'38897-TVA-A020\x00\x00', b'38897-TVA-A230\x00\x00', ], }, CAR.ACCORDH: { (Ecu.gateway, 0x18daeff1, None): [ b'38897-TWA-A120\x00\x00', b'38897-TWD-J020\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TWA-A040\x00\x00', b'57114-TWA-A050\x00\x00', b'57114-TWA-B520\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TWA-A440\x00\x00', b'77959-TWA-L420\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TWA-A010\x00\x00', b'78109-TWA-A020\x00\x00', b'78109-TWA-A030\x00\x00', b'78109-TWA-A110\x00\x00', b'78109-TWA-A120\x00\x00', b'78109-TWA-A210\x00\x00', b'78109-TWA-A220\x00\x00', b'78109-TWA-L010\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TWA-A910\x00\x00', ], (Ecu.hud, 0x18da61f1, None): [ b'78209-TVA-A010\x00\x00', b'78209-TVA-A110\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TWA-A070\x00\x00', b'36161-TWA-A330\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TWA-A080\x00\x00', b'36802-TWA-A070\x00\x00', b'36802-TWA-A330\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TVA-A160\x00\x00', b'39990-TVA-A150\x00\x00', b'39990-TVA-A340\x00\x00', ], }, CAR.CIVIC: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-5AA-A640\x00\x00', b'37805-5AA-A650\x00\x00', b'37805-5AA-A670\x00\x00', b'37805-5AA-A680\x00\x00', b'37805-5AA-A810\x00\x00', b'37805-5AA-C640\x00\x00', b'37805-5AA-C680\x00\x00', b'37805-5AA-C820\x00\x00', b'37805-5AA-L650\x00\x00', b'37805-5AA-L660\x00\x00', b'37805-5AA-L680\x00\x00', b'37805-5AA-L690\x00\x00', b'37805-5AA-L810\000\000', b'37805-5AG-Q710\x00\x00', b'37805-5AJ-A610\x00\x00', b'37805-5AJ-A620\x00\x00', b'37805-5AJ-L610\x00\x00', b'37805-5BA-A310\x00\x00', b'37805-5BA-A510\x00\x00', b'37805-5BA-A740\x00\x00', b'37805-5BA-A760\x00\x00', b'37805-5BA-A930\x00\x00', b'37805-5BA-A960\x00\x00', b'37805-5BA-C860\x00\x00', b'37805-5BA-L410\x00\x00', b'37805-5BA-L760\x00\x00', b'37805-5BA-L930\x00\x00', b'37805-5BA-L940\x00\x00', b'37805-5BA-L960\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-5CG-A040\x00\x00', b'28101-5CG-A050\x00\x00', b'28101-5CG-A070\x00\x00', b'28101-5CG-A080\x00\x00', b'28101-5CG-A320\x00\x00', b'28101-5CG-A810\x00\x00', b'28101-5CG-A820\x00\x00', b'28101-5DJ-A040\x00\x00', b'28101-5DJ-A060\x00\x00', b'28101-5DJ-A510\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TBA-A540\x00\x00', b'57114-TBA-A550\x00\x00', b'57114-TBA-A560\x00\x00', b'57114-TBA-A570\x00\x00', b'57114-TEA-Q220\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TBA,A030\x00\x00', # modified firmware b'39990-TBA-A030\x00\x00', b'39990-TBG-A030\x00\x00', b'39990-TEA-T020\x00\x00', b'39990-TEG-A010\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TBA-A030\x00\x00', b'77959-TBA-A040\x00\x00', b'77959-TBG-A030\x00\x00', b'77959-TEA-Q820\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TBA-A510\x00\x00', b'78109-TBA-A520\x00\x00', b'78109-TBA-A530\x00\x00', b'78109-TBA-C520\x00\x00', b'78109-TBC-A310\x00\x00', b'78109-TBC-A320\x00\x00', b'78109-TBC-A510\x00\x00', b'78109-TBC-A520\x00\x00', b'78109-TBC-A530\x00\x00', b'78109-TBC-C510\x00\x00', b'78109-TBC-C520\x00\x00', b'78109-TBC-C530\x00\x00', b'78109-TBH-A510\x00\x00', b'78109-TBH-A530\x00\x00', b'78109-TED-Q510\x00\x00', b'78109-TEG-A310\x00\x00', ], (Ecu.fwdCamera, 0x18dab0f1, None): [ b'36161-TBA-A020\x00\x00', b'36161-TBA-A030\x00\x00', b'36161-TBA-A040\x00\x00', b'36161-TBC-A020\x00\x00', b'36161-TBC-A030\x00\x00', b'36161-TED-Q320\x00\x00', b'36161-TEG-A010\x00\x00', b'36161-TEG-A020\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TBA-A010\x00\x00', b'38897-TBA-A020\x00\x00', ], }, CAR.CIVIC_BOSCH: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-5AA-A940\x00\x00', b'37805-5AA-A950\x00\x00', b'37805-5AA-L940\x00\x00', b'37805-5AA-L950\x00\x00', b'37805-5AG-Z910\x00\x00', b'37805-5AJ-A750\x00\x00', b'37805-5AJ-L750\x00\x00', b'37805-5AN-A750\x00\x00', b'37805-5AN-A830\x00\x00', b'37805-5AN-A840\x00\x00', b'37805-5AN-A930\x00\x00', b'37805-5AN-A940\x00\x00', b'37805-5AN-A950\x00\x00', b'37805-5AN-AG20\x00\x00', b'37805-5AN-AH20\x00\x00', b'37805-5AN-AJ30\x00\x00', b'37805-5AN-AK20\x00\x00', b'37805-5AN-AR20\x00\x00', b'37805-5AN-CH20\x00\x00', b'37805-5AN-E630\x00\x00', b'37805-5AN-E720\x00\x00', b'37805-5AN-E820\x00\x00', b'37805-5AN-J820\x00\x00', b'37805-5AN-L840\x00\x00', b'37805-5AN-L930\x00\x00', b'37805-5AN-L940\x00\x00', b'37805-5AN-LF20\x00\x00', b'37805-5AN-LH20\x00\x00', b'37805-5AN-LJ20\x00\x00', b'37805-5AN-LR20\x00\x00', b'37805-5AN-LS20\x00\x00', b'37805-5AW-G720\x00\x00', b'37805-5AZ-E850\x00\x00', b'37805-5AZ-G740\x00\x00', b'37805-5AZ-G840\x00\x00', b'37805-5BB-A530\x00\x00', b'37805-5BB-A540\x00\x00', b'37805-5BB-A630\x00\x00', b'37805-5BB-A640\x00\x00', b'37805-5BB-C540\x00\x00', b'37805-5BB-C630\x00\x00', b'37805-5BB-C640\x00\x00', b'37805-5BB-L540\x00\x00', b'37805-5BB-L630\x00\x00', b'37805-5BB-L640\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-5CG-A920\x00\x00', b'28101-5CG-AB10\x00\x00', b'28101-5CG-C110\x00\x00', b'28101-5CG-C220\x00\x00', b'28101-5CG-C320\x00\x00', b'28101-5CG-G020\x00\x00', b'28101-5CG-L020\x00\x00', b'28101-5CK-A130\x00\x00', b'28101-5CK-A140\x00\x00', b'28101-5CK-A150\x00\x00', b'28101-5CK-C130\x00\x00', b'28101-5CK-C140\x00\x00', b'28101-5CK-C150\x00\x00', b'28101-5CK-G210\x00\x00', b'28101-5CK-J710\x00\x00', b'28101-5CK-Q610\x00\x00', b'28101-5DJ-A610\x00\x00', b'28101-5DJ-A710\x00\x00', b'28101-5DV-E330\x00\x00', b'28101-5DV-E610\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TBG-A330\x00\x00', b'57114-TBG-A340\x00\x00', b'57114-TBG-A350\x00\x00', b'57114-TGG-A340\x00\x00', b'57114-TGG-C320\x00\x00', b'57114-TGG-G320\x00\x00', b'57114-TGG-L320\x00\x00', b'57114-TGG-L330\x00\x00', b'57114-TGK-T320\x00\x00', b'57114-TGL-G330\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TBA-C020\x00\x00', b'39990-TBA-C120\x00\x00', b'39990-TEA-T820\x00\x00', b'39990-TEZ-T020\x00\x00', b'39990-TGG-A020\x00\x00', b'39990-TGG-A120\x00\x00', b'39990-TGG-J510\x00\x00', b'39990-TGL-E130\x00\x00', b'39990-TGN-E120\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TBA-A060\x00\x00', b'77959-TBG-A050\x00\x00', b'77959-TEA-G020\x00\x00', b'77959-TGG-A020\x00\x00', b'77959-TGG-A030\x00\x00', b'77959-TGG-G010\x00\x00', b'77959-TGG-J320\x00\x00', b'77959-TGG-Z820\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TBA-A110\x00\x00', b'78109-TBA-A910\x00\x00', b'78109-TBA-C340\x00\x00', b'78109-TBA-C910\x00\x00', b'78109-TBC-A740\x00\x00', b'78109-TBG-A110\x00\x00', b'78109-TEG-A720\x00\x00', b'78109-TFJ-G020\x00\x00', b'78109-TGG-9020\x00\x00', b'78109-TGG-A210\x00\x00', b'78109-TGG-A220\x00\x00', b'78109-TGG-A310\x00\x00', b'78109-TGG-A320\x00\x00', b'78109-TGG-A330\x00\x00', b'78109-TGG-A610\x00\x00', b'78109-TGG-A620\x00\x00', b'78109-TGG-A810\x00\x00', b'78109-TGG-A820\x00\x00', b'78109-TGG-C220\x00\x00', b'78109-TGG-G030\x00\x00', b'78109-TGG-G230\x00\x00', b'78109-TGG-G410\x00\x00', b'78109-TGK-Z410\x00\x00', b'78109-TGL-G120\x00\x00', b'78109-TGL-G130\x00\x00', b'78109-TGL-G230\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TBA-A150\x00\x00', b'36802-TBA-A160\x00\x00', b'36802-TFJ-G060\x00\x00', b'36802-TGG-A050\x00\x00', b'36802-TGG-A060\x00\x00', b'36802-TGG-A130\x00\x00', b'36802-TGG-G040\x00\x00', b'36802-TGG-G130\x00\x00', b'36802-TGK-Q120\x00\x00', b'36802-TGL-G040\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TBA-A130\x00\x00', b'36161-TBA-A140\x00\x00', b'36161-TFJ-G070\x00\x00', b'36161-TGG-A060\x00\x00', b'36161-TGG-A080\x00\x00', b'36161-TGG-A120\x00\x00', b'36161-TGG-G050\x00\x00', b'36161-TGG-G130\x00\x00', b'36161-TGK-Q120\x00\x00', b'36161-TGL-G050\x00\x00', b'36161-TGL-G070\x00\x00', b'36161-TGG-G070\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TBA-A110\x00\x00', b'38897-TBA-A020\x00\x00', ], (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ b'39494-TGL-G030\x00\x00', ], }, CAR.CIVIC_BOSCH_DIESEL: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-59N-G630\x00\x00', b'37805-59N-G830\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-59Y-G220\x00\x00', b'28101-59Y-G620\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TGN-E320\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TFK-G020\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TFK-G210\x00\x00', b'77959-TGN-G220\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TFK-G020\x00\x00', b'78109-TGN-G120\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TFK-G130\x00\x00', b'36802-TGN-G130\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TGN-E010\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TFK-G130\x00\x00', b'36161-TGN-G130\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TBA-A020\x00\x00', ], }, CAR.CRV: { (Ecu.vsa, 0x18da28f1, None): [ b'57114-T1W-A230\x00\x00', b'57114-T1W-A240\x00\x00', b'57114-TFF-A940\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-T0A-A230\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-T1W-A210\x00\x00', b'78109-T1W-C210\x00\x00', b'78109-T1X-A210\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36161-T1W-A830\x00\x00', b'36161-T1W-C830\x00\x00', b'36161-T1X-A830\x00\x00', ], }, CAR.CRV_5G: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-5PA-AH20\x00\x00', b'37805-5PA-3060\x00\x00', b'37805-5PA-3080\x00\x00', b'37805-5PA-3180\x00\x00', b'37805-5PA-4050\x00\x00', b'37805-5PA-4150\x00\x00', b'37805-5PA-6520\x00\x00', b'37805-5PA-6530\x00\x00', b'37805-5PA-6630\x00\x00', b'37805-5PA-6640\x00\x00', b'37805-5PA-7630\x00\x00', b'37805-5PA-9630\x00\x00', b'37805-5PA-9640\x00\x00', b'37805-5PA-9730\x00\x00', b'37805-5PA-9830\x00\x00', b'37805-5PA-9840\x00\x00', b'37805-5PA-A650\x00\x00', b'37805-5PA-A670\x00\x00', b'37805-5PA-A680\x00\x00', b'37805-5PA-A850\x00\x00', b'37805-5PA-A870\x00\x00', b'37805-5PA-A880\x00\x00', b'37805-5PA-A890\x00\x00', b'37805-5PA-AB10\x00\x00', b'37805-5PA-AD10\x00\x00', b'37805-5PA-AF20\x00\x00', b'37805-5PA-C680\x00\x00', b'37805-5PD-Q630\x00\x00', b'37805-5PF-F730\x00\x00', b'37805-5PF-M630\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-5RG-A020\x00\x00', b'28101-5RG-A030\x00\x00', b'28101-5RG-A040\x00\x00', b'28101-5RG-A120\x00\x00', b'28101-5RG-A220\x00\x00', b'28101-5RH-A020\x00\x00', b'28101-5RH-A030\x00\x00', b'28101-5RH-A040\x00\x00', b'28101-5RH-A120\x00\x00', b'28101-5RH-A220\x00\x00', b'28101-5RL-Q010\x00\x00', b'28101-5RM-F010\x00\x00', b'28101-5RM-K010\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TLA-A040\x00\x00', b'57114-TLA-A050\x00\x00', b'57114-TLA-A060\x00\x00', b'57114-TLB-A830\x00\x00', b'57114-TMC-Z040\x00\x00', b'57114-TMC-Z050\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TLA-A040\x00\x00', b'39990-TLA-A110\x00\x00', b'39990-TLA-A220\x00\x00', b'39990-TLA,A040\x00\x00', # modified firmware b'39990-TME-T030\x00\x00', b'39990-TME-T120\x00\x00', b'39990-TMT-T010\x00\x00', ], (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ b'46114-TLA-A040\x00\x00', b'46114-TLA-A050\x00\x00', b'46114-TLA-A930\x00\x00', b'46114-TMC-U020\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TLA-A110\x00\x00', b'78109-TLA-A120\x00\x00', b'78109-TLA-A210\x00\x00', b'78109-TLA-A220\x00\x00', b'78109-TLA-C110\x00\x00', b'78109-TLA-C210\x00\x00', b'78109-TLA-C310\x00\x00', b'78109-TLB-A020\x00\x00', b'78109-TLB-A110\x00\x00', b'78109-TLB-A120\x00\x00', b'78109-TLB-A210\x00\x00', b'78109-TLB-A220\x00\x00', b'78109-TMC-Q210\x00\x00', b'78109-TMM-F210\x00\x00', b'78109-TMM-M110\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TLA-A010\x00\x00', b'38897-TLA-A110\x00\x00', b'38897-TNY-G010\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TLA-A040\x00\x00', b'36802-TLA-A050\x00\x00', b'36802-TLA-A060\x00\x00', b'36802-TMC-Q040\x00\x00', b'36802-TMC-Q070\x00\x00', b'36802-TNY-A030\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TLA-A060\x00\x00', b'36161-TLA-A070\x00\x00', b'36161-TLA-A080\x00\x00', b'36161-TMC-Q020\x00\x00', b'36161-TMC-Q030\x00\x00', b'36161-TMC-Q040\x00\x00', b'36161-TNY-A020\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TLA-A240\x00\x00', b'77959-TLA-A250\x00\x00', b'77959-TLA-A320\x00\x00', b'77959-TLA-A410\x00\x00', b'77959-TLA-A420\x00\x00', b'77959-TLA-Q040\x00\x00', b'77959-TLA-Z040\x00\x00', b'77959-TMM-F040\x00\x00', ], }, CAR.CRV_EU: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-R5Z-G740\x00\x00', b'37805-R5Z-G780\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [b'57114-T1V-G920\x00\x00'], (Ecu.fwdRadar, 0x18dab0f1, None): [b'36161-T1V-G520\x00\x00'], (Ecu.shiftByWire, 0x18da0bf1, None): [b'54008-T1V-G010\x00\x00'], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-5LH-E120\x00\x00', b'28103-5LH-E100\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-T1V-G020\x00\x00', b'78109-T1B-3050\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [b'77959-T1G-G940\x00\x00'], }, CAR.CRV_HYBRID: { (Ecu.vsa, 0x18da28f1, None): [ b'57114-TPA-G020\x00\x00', b'57114-TPG-A020\x00\x00', b'57114-TMB-H030\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TPA-G030\x00\x00', b'39990-TPG-A020\x00\x00', b'39990-TMA-H020\x00\x00', b'39990-TMA,H020\x00\x00', b'39990,TMA-H020\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TMA-H110\x00\x00', b'38897-TPG-A110\x00\x00', b'38897-TPG-A210\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TMB-H510\x00\x00', b'54008-TMB-H610\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TMB-H040\x00\x00', b'36161-TPA-E050\x00\x00', b'36161-TPG-A030\x00\x00', b'36161-TPG-A040\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TMB-H220\x00\x00', b'78109-TPA-G520\x00\x00', b'78109-TPG-A110\x00\x00', b'78109-TPG-A210\x00\x00', ], (Ecu.hud, 0x18da61f1, None): [ b'78209-TLA-X010\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TPA-E040\x00\x00', b'36802-TPG-A020\x00\x00', b'36802-TMB-H040\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TLA-C320\x00\x00', b'77959-TLA-C410\x00\x00', b'77959-TLA-C420\x00\x00', b'77959-TLA-G220\x00\x00', b'77959-TLA-H240\x00\x00', ], }, CAR.FIT: { (Ecu.vsa, 0x18da28f1, None): [ b'57114-T5R-L220\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-T5R-C020\x00\x00', b'39990-T5R-C030\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-T5A-J010\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-T5A-A410\x00\x00', b'78109-T5A-A420\x00\x00', b'78109-T5A-A910\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36161-T5R-A240\x00\x00', b'36161-T5R-A520\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-T5R-A230\x00\x00', ], }, CAR.ODYSSEY: { (Ecu.gateway, 0x18daeff1, None): [ b'38897-THR-A010\x00\x00', b'38897-THR-A020\x00\x00', ], (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-5MR-A240\x00\x00', b'37805-5MR-A250\x00\x00', b'37805-5MR-A310\x00\x00', b'37805-5MR-A740\x00\x00', b'37805-5MR-A750\x00\x00', b'37805-5MR-A840\x00\x00', b'37805-5MR-C620\x00\x00', b'37805-5MR-D530\x00\x00', b'37805-5MR-K730\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-THR-A020\x00\x00', b'39990-THR-A030\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-THR-A010\x00\x00', b'77959-THR-A110\x00\x00', b'77959-THR-X010\x00\x00', ], (Ecu.fwdCamera, 0x18dab0f1, None): [ b'36161-THR-A020\x00\x00', b'36161-THR-A030\x00\x00', b'36161-THR-A110\x00\x00', b'36161-THR-A720\x00\x00', b'36161-THR-A730\x00\x00', b'36161-THR-A810\x00\x00', b'36161-THR-A910\x00\x00', b'36161-THR-C010\x00\x00', b'36161-THR-D110\x00\x00', b'36161-THR-K020\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-5NZ-A110\x00\x00', b'28101-5NZ-A310\x00\x00', b'28101-5NZ-C310\x00\x00', b'28102-5MX-A001\x00\x00', b'28102-5MX-A600\x00\x00', b'28102-5MX-A610\x00\x00', b'28102-5MX-A710\x00\x00', b'28102-5MX-A900\x00\x00', b'28102-5MX-A910\x00\x00', b'28102-5MX-C001\x00\x00', b'28102-5MX-D001\x00\x00', b'28102-5MX-D710\x00\x00', b'28102-5MX-K610\x00\x00', b'28103-5NZ-A100\x00\x00', b'28103-5NZ-A300\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-THR-A040\x00\x00', b'57114-THR-A110\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-THR-A220\x00\x00', b'78109-THR-A230\x00\x00', b'78109-THR-A420\x00\x00', b'78109-THR-A430\x00\x00', b'78109-THR-A720\x00\x00', b'78109-THR-A820\x00\x00', b'78109-THR-A830\x00\x00', b'78109-THR-AB20\x00\x00', b'78109-THR-AB30\x00\x00', b'78109-THR-AB40\x00\x00', b'78109-THR-AC20\x00\x00', b'78109-THR-AC40\x00\x00', b'78109-THR-AC50\x00\x00', b'78109-THR-AE20\x00\x00', b'78109-THR-AE40\x00\x00', b'78109-THR-AK10\x00\x00', b'78109-THR-AL10\x00\x00', b'78109-THR-AN10\x00\x00', b'78109-THR-C330\x00\x00', b'78109-THR-CE20\x00\x00', b'78109-THR-DA20\x00\x00', b'78109-THR-DA40\x00\x00', b'78109-THR-K120\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-THR-A020\x00\x00', ], }, CAR.PILOT: { (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TG7-A520\x00\x00', b'54008-TG7-A530\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28101-5EY-A050\x00\x00', b'28101-5EY-A100\x00\x00', b'28101-5EZ-A050\x00\x00', b'28101-5EZ-A060\x00\x00', b'28101-5EZ-A100\x00\x00', b'28101-5EZ-A210\x00\x00', ], (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-RLV-4060\x00\x00', b'37805-RLV-4070\x00\x00', b'37805-RLV-A830\x00\x00', b'37805-RLV-A840\x00\x00', b'37805-RLV-C430\x00\x00', b'37805-RLV-C510\x00\x00', b'37805-RLV-C520\x00\x00', b'37805-RLV-C530\x00\x00', b'37805-RLV-C910\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TG7-A030\x00\x00', b'39990-TG7-A040\x00\x00', b'39990-TG7-A060\x00\x00', ], (Ecu.fwdCamera, 0x18dab0f1, None): [ b'36161-TG7-A520\x00\x00', b'36161-TG7-A720\x00\x00', b'36161-TG7-A820\x00\x00', b'36161-TG7-C520\x00\x00', b'36161-TG7-D520\x00\x00', b'36161-TG8-A520\x00\x00', b'36161-TG8-A720\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TG7-A110\x00\x00', b'77959-TG7-A020\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TG7-A040\x00\x00', b'78109-TG7-A050\x00\x00', b'78109-TG7-A420\x00\x00', b'78109-TG7-A520\x00\x00', b'78109-TG7-A720\x00\x00', b'78109-TG7-D020\x00\x00', b'78109-TG8-A420\x00\x00', b'78109-TG8-A520\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TG7-A130\x00\x00', b'57114-TG7-A140\x00\x00', b'57114-TG7-A230\x00\x00', b'57114-TG7-A240\x00\x00', b'57114-TG8-A140\x00\x00', b'57114-TG8-A240\x00\x00', ], }, CAR.PILOT_2019: { (Ecu.eps, 0x18da30f1, None): [ b'39990-TG7-A060\x00\x00', b'39990-TG7-A070\x00\x00', b'39990-TGS-A230\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TG7-A030\x00\x00', b'38897-TG7-A040\x00\x00', b'38897-TG7-A110\x00\x00', b'38897-TG7-A210\x00\x00', ], (Ecu.fwdCamera, 0x18dab0f1, None): [ b'36161-TG7-A310\x00\x00', b'36161-TG7-A630\x00\x00', b'36161-TG7-A930\x00\x00', b'36161-TG7-D630\x00\x00', b'36161-TG7-Y630\x00\x00', b'36161-TG8-A630\x00\x00', b'36161-TG8-A830\x00\x00', b'36161-TGS-A130\x00\x00', b'36161-TGT-A030\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TG7-A210\x00\x00', b'77959-TG7-Y210\x00\x00', b'77959-TGS-A010\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TG7-AJ10\x00\x00', b'78109-TG7-AJ20\x00\x00', b'78109-TG7-AK10\x00\x00', b'78109-TG7-AK20\x00\x00', b'78109-TG7-AM20\x00\x00', b'78109-TG7-AP10\x00\x00', b'78109-TG7-AP20\x00\x00', b'78109-TG7-AS20\x00\x00', b'78109-TG7-AU20\x00\x00', b'78109-TG7-DJ10\x00\x00', b'78109-TG7-YK20\x00\x00', b'78109-TG8-AJ10\x00\x00', b'78109-TG8-AJ20\x00\x00', b'78109-TG8-AK20\x00\x00', b'78109-TGS-AK20\x00\x00', b'78109-TGS-AP20\x00\x00', b'78109-TGT-AJ20\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TG7-A630\x00\x00', b'57114-TG7-A730\x00\x00', b'57114-TG8-A630\x00\x00', b'57114-TG8-A730\x00\x00', b'57114-TGS-A530\x00\x00', b'57114-TGT-A530\x00\x00', ], }, CAR.ACURA_RDX: { (Ecu.vsa, 0x18da28f1, None): [ b'57114-TX5-A220\x00\x00', b'57114-TX4-A220\x00\x00', ], (Ecu.fwdCamera, 0x18dab0f1, None): [ b'36161-TX5-A030\x00\x00', b'36161-TX4-A030\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TX4-C010\x00\x00', b'77959-TX4-B010\x00\x00', b'77959-TX4-C020\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TX5-A310\x00\x00', b'78109-TX4-A210\x00\x00', b'78109-TX4-A310\x00\x00', ], }, CAR.ACURA_RDX_3G: { (Ecu.programmedFuelInjection, 0x18da10f1, None): [ b'37805-5YF-A230\x00\x00', b'37805-5YF-A320\x00\x00', b'37805-5YF-A330\x00\x00', b'37805-5YF-A420\x00\x00', b'37805-5YF-A430\x00\x00', b'37805-5YF-A870\x00\x00', b'37805-5YF-C210\x00\x00', b'37805-5YF-C410\000\000', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TJB-A040\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TJB-A040\x00\x00', b'36802-TJB-A050\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TJB-A040\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TJB-A520\x00\x00', ], (Ecu.transmission, 0x18da1ef1, None): [ b'28102-5YK-A630\x00\x00', b'28102-5YK-A700\x00\x00', b'28102-5YK-A711\x00\x00', b'28102-5YL-A700\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TJB-A240\x00\x00', b'78109-TJB-AB10\x00\x00', b'78109-TJB-AD10\x00\x00', b'78109-TJB-AF10\x00\x00', b'78109-TJB-AW10\x00\x00', b'78109-TJC-AA10\x00\x00', b'78109-TJC-AD10\x00\x00', b'78109-TJB-AS10\000\000', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TJB-A040\x00\x00', b'77959-TJB-A210\x00\x00', ], (Ecu.electricBrakeBooster, 0x18da2bf1, None): [ b'46114-TJB-A050\x00\x00', b'46114-TJB-A060\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TJB-A040\x00\x00', b'38897-TJB-A110\x00\x00', b'38897-TJB-A120\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-TJB-A030\x00\x00', b'39990-TJB-A040\x00\x00', b'39990-TJB-A130\x00\x00' ], }, CAR.RIDGELINE: { (Ecu.eps, 0x18da30f1, None): [ b'39990-T6Z-A020\x00\x00', b'39990-T6Z-A030\x00\x00', b'39990-T6Z-A050\x00\x00', ], (Ecu.fwdCamera, 0x18dab0f1, None): [ b'36161-T6Z-A020\x00\x00', b'36161-T6Z-A310\x00\x00', b'36161-T6Z-A420\x00\x00', b'36161-T6Z-A520\x00\x00', b'36161-T6Z-A620\x00\x00', b'36161-TJZ-A120\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-T6Z-A010\x00\x00', b'38897-T6Z-A110\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-T6Z-A420\x00\x00', b'78109-T6Z-A510\x00\x00', b'78109-T6Z-A710\x00\x00', b'78109-T6Z-A910\x00\x00', b'78109-T6Z-AA10\x00\x00', b'78109-T6Z-C620\x00\x00', b'78109-TJZ-A510\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-T6Z-A020\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-T6Z-A120\x00\x00', b'57114-T6Z-A130\x00\x00', b'57114-T6Z-A520\x00\x00', b'57114-TJZ-A520\x00\x00', ], }, CAR.INSIGHT: { (Ecu.eps, 0x18da30f1, None): [ b'39990-TXM-A040\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36802-TXM-A070\x00\x00', ], (Ecu.fwdCamera, 0x18dab5f1, None): [ b'36161-TXM-A050\x00\x00', b'36161-TXM-A060\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TXM-A230\x00\x00', ], (Ecu.vsa, 0x18da28f1, None): [ b'57114-TXM-A030\x00\x00', b'57114-TXM-A040\x00\x00', ], (Ecu.shiftByWire, 0x18da0bf1, None): [ b'54008-TWA-A910\x00\x00', ], (Ecu.gateway, 0x18daeff1, None): [ b'38897-TXM-A020\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-TXM-A010\x00\x00', b'78109-TXM-A020\x00\x00', b'78109-TXM-A110\x00\x00', b'78109-TXM-C010\x00\x00', b'78109-TXM-A030\x00\x00', ], }, CAR.HRV: { (Ecu.gateway, 0x18daeff1, None): [ b'38897-T7A-A010\x00\x00', b'38897-T7A-A110\x00\x00', ], (Ecu.eps, 0x18da30f1, None): [ b'39990-THX-A020\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36161-T7A-A140\x00\x00', b'36161-T7A-A240\x00\x00', b'36161-T7A-C440\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-T7A-A230\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-THX-A110\x00\x00', b'78109-THX-A210\x00\x00', b'78109-THX-A220\x00\x00', b'78109-THX-C220\x00\x00', ], }, CAR.ACURA_ILX: { (Ecu.gateway, 0x18daeff1, None): [ b'38897-TX6-A010\x00\x00', ], (Ecu.fwdRadar, 0x18dab0f1, None): [ b'36161-TV9-A140\x00\x00', b'36161-TX6-A030\x00\x00', ], (Ecu.srs, 0x18da53f1, None): [ b'77959-TX6-A230\x00\x00', b'77959-TX6-C210\x00\x00', ], (Ecu.combinationMeter, 0x18da60f1, None): [ b'78109-T3R-A120\x00\x00', b'78109-T3R-A410\x00\x00', b'78109-TV9-A510\x00\x00', ], }, CAR.HONDA_E:{ (Ecu.eps, 0x18DA30F1, None):[ b'39990-TYF-N030\x00\x00' ], (Ecu.gateway, 0x18DAEFF1, None):[ b'38897-TYF-E140\x00\x00' ], (Ecu.shiftByWire, 0x18DA0BF1, None):[ b'54008-TYF-E010\x00\x00' ], (Ecu.srs, 0x18DA53F1, None):[ b'77959-TYF-G430\x00\x00' ], (Ecu.combinationMeter, 0x18DA60F1, None):[ b'78108-TYF-G610\x00\x00' ], (Ecu.fwdRadar, 0x18DAB0F1, None):[ b'36802-TYF-E030\x00\x00' ], (Ecu.fwdCamera, 0x18DAB5F1, None):[ b'36161-TYF-E020\x00\x00' ], (Ecu.vsa, 0x18DA28F1, None):[ b'57114-TYF-E030\x00\x00' ], }, } DBC = { CAR.ACCORD: dbc_dict('honda_accord_2018_can_generated', None), CAR.ACCORDH: dbc_dict('honda_accord_2018_can_generated', None), CAR.ACURA_ILX: dbc_dict('acura_ilx_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.ACURA_RDX: dbc_dict('acura_rdx_2018_can_generated', 'acura_ilx_2016_nidec'), CAR.ACURA_RDX_3G: dbc_dict('acura_rdx_2020_can_generated', None), CAR.CIVIC: dbc_dict('honda_civic_touring_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.CIVIC_BOSCH: dbc_dict('honda_civic_hatchback_ex_2017_can_generated', None), CAR.CIVIC_BOSCH_DIESEL: dbc_dict('honda_civic_sedan_16_diesel_2019_can_generated', None), CAR.CRV: dbc_dict('honda_crv_touring_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.CRV_5G: dbc_dict('honda_crv_ex_2017_can_generated', None, body_dbc='honda_crv_ex_2017_body_generated'), CAR.CRV_EU: dbc_dict('honda_crv_executive_2016_can_generated', 'acura_ilx_2016_nidec'), CAR.CRV_HYBRID: dbc_dict('honda_crv_hybrid_2019_can_generated', None, body_dbc='honda_crv_ex_2017_body_generated'), CAR.FIT: dbc_dict('honda_fit_ex_2018_can_generated', 'acura_ilx_2016_nidec'), CAR.HRV: dbc_dict('honda_fit_ex_2018_can_generated', 'acura_ilx_2016_nidec'), CAR.ODYSSEY: dbc_dict('honda_odyssey_exl_2018_generated', 'acura_ilx_2016_nidec'), CAR.ODYSSEY_CHN: dbc_dict('honda_odyssey_extreme_edition_2018_china_can_generated', 'acura_ilx_2016_nidec'), CAR.PILOT: dbc_dict('honda_pilot_touring_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.PILOT_2019: dbc_dict('honda_pilot_touring_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.RIDGELINE: dbc_dict('honda_ridgeline_black_edition_2017_can_generated', 'acura_ilx_2016_nidec'), CAR.INSIGHT: dbc_dict('honda_insight_ex_2019_can_generated', None), CAR.HONDA_E: dbc_dict('acura_rdx_2020_can_generated', None), CAR.JADE: dbc_dict('honda_fit_ex_2018_can_generated', 'acura_ilx_2016_nidec'), } STEER_THRESHOLD = { # default is 1200, overrides go here CAR.ACURA_RDX: 400, CAR.CRV_EU: 400, } # TODO: is this real? SPEED_FACTOR = { # default is 1, overrides go here CAR.CRV: 1.025, CAR.CRV_5G: 1.025, CAR.CRV_EU: 1.025, CAR.CRV_HYBRID: 1.025, CAR.HRV: 1.025, CAR.JADE: 1.05, } HONDA_NIDEC_ALT_PCM_ACCEL = set([CAR.ODYSSEY]) HONDA_BOSCH = set([CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_5G, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E]) HONDA_BOSCH_ALT_BRAKE_SIGNAL = set([CAR.ACCORD, CAR.CRV_5G, CAR.ACURA_RDX_3G]) ================================================ FILE: selfdrive/car/hyundai/__init__.py ================================================ ================================================ FILE: selfdrive/car/hyundai/carcontroller.py ================================================ from cereal import car from common.realtime import DT_CTRL from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.hyundai.hyundaican import create_lkas11, create_clu11, create_lfahda_mfc from selfdrive.car.hyundai.values import Buttons, CarControllerParams, CAR from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl from common.params import Params VisualAlert = car.CarControl.HUDControl.VisualAlert def process_hud_alert(enabled, fingerprint, visual_alert, left_lane, right_lane, left_lane_depart, right_lane_depart): sys_warning = (visual_alert in [VisualAlert.steerRequired, VisualAlert.ldw]) # initialize to no line visible sys_state = 1 if left_lane and right_lane or sys_warning: # HUD alert only display when LKAS status is active sys_state = 3 if enabled or sys_warning else 4 elif left_lane: sys_state = 5 elif right_lane: sys_state = 6 # initialize to no warnings left_lane_warning = 0 right_lane_warning = 0 if left_lane_depart: left_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 if right_lane_depart: right_lane_warning = 1 if fingerprint in [CAR.GENESIS_G90, CAR.GENESIS_G80] else 2 return sys_warning, sys_state, left_lane_warning, right_lane_warning class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.dp_hkg_smart_mdps = Params().get('dp_hkg_smart_mdps') == b'1' self.p = CarControllerParams(CP) self.packer = CANPacker(dbc_name) self.apply_steer_last = 0 self.car_fingerprint = CP.carFingerprint self.steer_rate_limited = False self.last_resume_frame = 0 def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_lane, right_lane, left_lane_depart, right_lane_depart, dragonconf): # Steering Torque new_steer = int(round(actuators.steer * self.p.STEER_MAX)) apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, self.p) self.steer_rate_limited = new_steer != apply_steer # disable when temp fault is active, or below LKA minimum speed lkas_active = enabled and not CS.out.steerWarning and CS.out.vEgo >= CS.CP.minSteerSpeed # fix for Genesis hard fault at low speed if not self.dp_hkg_smart_mdps and CS.out.vEgo < 16.7 and self.car_fingerprint == CAR.HYUNDAI_GENESIS: lkas_active = False if not lkas_active: apply_steer = 0 # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on self.apply_steer_last = apply_steer sys_warning, sys_state, left_lane_warning, right_lane_warning = \ process_hud_alert(enabled, self.car_fingerprint, visual_alert, left_lane, right_lane, left_lane_depart, right_lane_depart) can_sends = [] can_sends.append(create_lkas11(self.packer, frame, self.car_fingerprint, apply_steer, lkas_active, CS.lkas11, sys_warning, sys_state, enabled, left_lane, right_lane, left_lane_warning, right_lane_warning)) if pcm_cancel_cmd: can_sends.append(create_clu11(self.packer, frame, CS.clu11, Buttons.CANCEL)) elif CS.out.cruiseState.standstill: # send resume at a max freq of 10Hz if (frame - self.last_resume_frame) * DT_CTRL > 0.1: # send 25 messages at a time to increases the likelihood of resume being accepted can_sends.extend([create_clu11(self.packer, frame, CS.clu11, Buttons.RES_ACCEL)] * 25) self.last_resume_frame = frame # 20 Hz LFA MFA message if frame % 5 == 0 and self.car_fingerprint in [CAR.SONATA, CAR.PALISADE, CAR.IONIQ, CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV_2021, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KIA_CEED, CAR.KIA_SELTOS, CAR.KONA_EV, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV]: can_sends.append(create_lfahda_mfc(self.packer, enabled)) return can_sends ================================================ FILE: selfdrive/car/hyundai/carstate.py ================================================ import copy from cereal import car from selfdrive.car.hyundai.values import DBC, STEER_THRESHOLD, FEATURES, EV_CAR, HYBRID_CAR from selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine from selfdrive.config import Conversions as CV class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"] elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: self.shifter_values = can_define.dv["TCU12"]["CUR_GR"] else: # preferred and elect gear methods use same definition self.shifter_values = can_define.dv["LVR12"]["CF_Lvr_Gear"] def update(self, cp, cp_cam): ret = car.CarState.new_message() ret.doorOpen = any([cp.vl["CGW1"]["CF_Gway_DrvDrSw"], cp.vl["CGW1"]["CF_Gway_AstDrSw"], cp.vl["CGW2"]["CF_Gway_RLDrSw"], cp.vl["CGW2"]["CF_Gway_RRDrSw"]]) ret.seatbeltUnlatched = cp.vl["CGW1"]["CF_Gway_DrvSeatBeltSw"] == 0 ret.wheelSpeeds.fl = cp.vl["WHL_SPD11"]["WHL_SPD_FL"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = cp.vl["WHL_SPD11"]["WHL_SPD_FR"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = cp.vl["WHL_SPD11"]["WHL_SPD_RL"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = cp.vl["WHL_SPD11"]["WHL_SPD_RR"] * CV.KPH_TO_MS ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = ret.vEgoRaw < 0.1 ret.steeringAngleDeg = cp.vl["SAS11"]["SAS_Angle"] ret.steeringRateDeg = cp.vl["SAS11"]["SAS_Speed"] ret.yawRate = cp.vl["ESP12"]["YAW_RATE"] ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp( 50, cp.vl["CGW1"]["CF_Gway_TurnSigLh"], cp.vl["CGW1"]["CF_Gway_TurnSigRh"]) ret.steeringTorque = cp.vl["MDPS12"]["CR_Mdps_StrColTq"] ret.steeringTorqueEps = cp.vl["MDPS12"]["CR_Mdps_OutTq"] #dp ret.engineRPM = cp.vl["TCU_DCT13"]['Cluster_Engine_RPM'] ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD ret.steerWarning = cp.vl["MDPS12"]["CF_Mdps_ToiUnavail"] != 0 or cp.vl["MDPS12"]["CF_Mdps_ToiFlt"] != 0 # cruise state if self.CP.openpilotLongitudinalControl: ret.cruiseState.available = cp.vl["TCS13"]["ACCEnable"] == 0 ret.cruiseState.enabled = cp.vl["TCS13"]["ACC_REQ"] == 1 ret.cruiseState.standstill = False else: ret.cruiseState.available = cp.vl["SCC11"]["MainMode_ACC"] == 1 ret.cruiseState.enabled = cp.vl["SCC12"]["ACCMode"] != 0 ret.cruiseState.standstill = cp.vl["SCC11"]["SCCInfoDisplay"] == 4. # dp ret.cruiseActualEnabled = ret.cruiseState.enabled if ret.cruiseState.enabled: speed_conv = CV.MPH_TO_MS if cp.vl["CLU11"]["CF_Clu_SPEED_UNIT"] else CV.KPH_TO_MS ret.cruiseState.speed = cp.vl["SCC11"]["VSetDis"] * speed_conv else: ret.cruiseState.speed = 0 # TODO: Find brake pressure ret.brake = 0 ret.brakePressed = cp.vl["TCS13"]["DriverBraking"] != 0 if self.CP.carFingerprint in (HYBRID_CAR | EV_CAR): if self.CP.carFingerprint in HYBRID_CAR: ret.gas = cp.vl["E_EMS11"]["CR_Vcu_AccPedDep_Pos"] / 254. else: ret.gas = cp.vl["E_EMS11"]["Accel_Pedal_Pos"] / 254. ret.gasPressed = ret.gas > 0 else: ret.gas = cp.vl["EMS12"]["PV_AV_CAN"] / 100. ret.gasPressed = bool(cp.vl["EMS16"]["CF_Ems_AclAct"]) # Gear Selection via Cluster - For those Kia/Hyundai which are not fully discovered, we can use the Cluster Indicator for Gear Selection, # as this seems to be standard over all cars, but is not the preferred method. if self.CP.carFingerprint in FEATURES["use_cluster_gears"]: gear = cp.vl["CLU15"]["CF_Clu_Gear"] elif self.CP.carFingerprint in FEATURES["use_tcu_gears"]: gear = cp.vl["TCU12"]["CUR_GR"] elif self.CP.carFingerprint in FEATURES["use_elect_gears"]: gear = cp.vl["ELECT_GEAR"]["Elect_Gear_Shifter"] else: gear = cp.vl["LVR12"]["CF_Lvr_Gear"] ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear)) if self.CP.carFingerprint in FEATURES["use_fca"]: ret.stockAeb = cp.vl["FCA11"]["FCA_CmdAct"] != 0 ret.stockFcw = cp.vl["FCA11"]["CF_VSM_Warn"] == 2 else: ret.stockAeb = cp.vl["SCC12"]["AEB_CmdAct"] != 0 ret.stockFcw = cp.vl["SCC12"]["CF_VSM_Warn"] == 2 if self.CP.enableBsm: ret.leftBlindspot = cp.vl["LCA11"]["CF_Lca_IndLeft"] != 0 ret.rightBlindspot = cp.vl["LCA11"]["CF_Lca_IndRight"] != 0 # save the entire LKAS11 and CLU11 self.lkas11 = copy.copy(cp_cam.vl["LKAS11"]) self.clu11 = copy.copy(cp.vl["CLU11"]) self.park_brake = cp.vl["TCS13"]["PBRAKE_ACT"] == 1 self.steer_state = cp.vl["MDPS12"]["CF_Mdps_ToiActive"] # 0 NOT ACTIVE, 1 ACTIVE self.lead_distance = cp.vl["SCC11"]["ACC_ObjDist"] self.brake_hold = cp.vl["TCS15"]["AVH_LAMP"] == 2 # 0 OFF, 1 ERROR, 2 ACTIVE, 3 READY self.brake_error = cp.vl["TCS13"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED self.prev_cruise_buttons = self.cruise_buttons self.cruise_buttons = cp.vl["CLU11"]["CF_Clu_CruiseSwState"] # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("WHL_SPD_FL", "WHL_SPD11", 0), ("WHL_SPD_FR", "WHL_SPD11", 0), ("WHL_SPD_RL", "WHL_SPD11", 0), ("WHL_SPD_RR", "WHL_SPD11", 0), ("YAW_RATE", "ESP12", 0), ("CF_Gway_DrvSeatBeltInd", "CGW4", 1), ("CF_Gway_DrvSeatBeltSw", "CGW1", 0), ("CF_Gway_DrvDrSw", "CGW1", 0), # Driver Door ("CF_Gway_AstDrSw", "CGW1", 0), # Passenger door ("CF_Gway_RLDrSw", "CGW2", 0), # Rear reft door ("CF_Gway_RRDrSw", "CGW2", 0), # Rear right door ("CF_Gway_TurnSigLh", "CGW1", 0), ("CF_Gway_TurnSigRh", "CGW1", 0), ("CF_Gway_ParkBrakeSw", "CGW1", 0), ("CYL_PRES", "ESP12", 0), ("CF_Clu_CruiseSwState", "CLU11", 0), ("CF_Clu_CruiseSwMain", "CLU11", 0), ("CF_Clu_SldMainSW", "CLU11", 0), ("CF_Clu_ParityBit1", "CLU11", 0), ("CF_Clu_VanzDecimal" , "CLU11", 0), ("CF_Clu_Vanz", "CLU11", 0), ("CF_Clu_SPEED_UNIT", "CLU11", 0), ("CF_Clu_DetentOut", "CLU11", 0), ("CF_Clu_RheostatLevel", "CLU11", 0), ("CF_Clu_CluInfo", "CLU11", 0), ("CF_Clu_AmpInfo", "CLU11", 0), ("CF_Clu_AliveCnt1", "CLU11", 0), ("ACCEnable", "TCS13", 0), ("ACC_REQ", "TCS13", 0), ("DriverBraking", "TCS13", 0), ("StandStill", "TCS13", 0), ("PBRAKE_ACT", "TCS13", 0), ("ESC_Off_Step", "TCS15", 0), ("AVH_LAMP", "TCS15", 0), ("CR_Mdps_StrColTq", "MDPS12", 0), ("CF_Mdps_ToiActive", "MDPS12", 0), ("CF_Mdps_ToiUnavail", "MDPS12", 0), ("CF_Mdps_ToiFlt", "MDPS12", 0), ("CR_Mdps_OutTq", "MDPS12", 0), ("SAS_Angle", "SAS11", 0), ("SAS_Speed", "SAS11", 0), ("MainMode_ACC", "SCC11", 0), ("VSetDis", "SCC11", 0), ("SCCInfoDisplay", "SCC11", 0), ("ACC_ObjDist", "SCC11", 0), ("ACCMode", "SCC12", 1), #dp ("Cluster_Engine_RPM", "TCU_DCT13", 0), ] checks = [ # address, frequency ("MDPS12", 50), ("TCS13", 50), ("TCS15", 10), ("CLU11", 50), ("ESP12", 100), ("CGW1", 10), ("CGW2", 5), ("CGW4", 5), ("WHL_SPD11", 50), ("SAS11", 100), ("TCU_DCT13", 100), ] if not CP.openpilotLongitudinalControl: checks += [ ("SCC11", 50), ("SCC12", 50), ] if CP.enableBsm: signals += [ ("CF_Lca_IndLeft", "LCA11", 0), ("CF_Lca_IndRight", "LCA11", 0), ] checks += [("LCA11", 50)] if CP.carFingerprint in (HYBRID_CAR | EV_CAR): if CP.carFingerprint in HYBRID_CAR: signals += [ ("CR_Vcu_AccPedDep_Pos", "E_EMS11", 0) ] else: signals += [ ("Accel_Pedal_Pos", "E_EMS11", 0) ] checks += [ ("E_EMS11", 50), ] else: signals += [ ("PV_AV_CAN", "EMS12", 0), ("CF_Ems_AclAct", "EMS16", 0), ] checks += [ ("EMS12", 100), ("EMS16", 100), ] if CP.carFingerprint in FEATURES["use_cluster_gears"]: signals += [ ("CF_Clu_Gear", "CLU15", 0), ] checks += [ ("CLU15", 5) ] elif CP.carFingerprint in FEATURES["use_tcu_gears"]: signals += [ ("CUR_GR", "TCU12", 0) ] checks += [ ("TCU12", 100) ] elif CP.carFingerprint in FEATURES["use_elect_gears"]: signals += [("Elect_Gear_Shifter", "ELECT_GEAR", 0)] checks += [("ELECT_GEAR", 20)] else: signals += [ ("CF_Lvr_Gear", "LVR12", 0) ] checks += [ ("LVR12", 100) ] if CP.carFingerprint in FEATURES["use_fca"]: signals += [ ("FCA_CmdAct", "FCA11", 0), ("CF_VSM_Warn", "FCA11", 0), ] if not CP.openpilotLongitudinalControl: checks += [("FCA11", 50)] else: signals += [ ("AEB_CmdAct", "SCC12", 0), ("CF_VSM_Warn", "SCC12", 0), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod def get_cam_can_parser(CP): signals = [ # sig_name, sig_address, default ("CF_Lkas_LdwsActivemode", "LKAS11", 0), ("CF_Lkas_LdwsSysState", "LKAS11", 0), ("CF_Lkas_SysWarning", "LKAS11", 0), ("CF_Lkas_LdwsLHWarning", "LKAS11", 0), ("CF_Lkas_LdwsRHWarning", "LKAS11", 0), ("CF_Lkas_HbaLamp", "LKAS11", 0), ("CF_Lkas_FcwBasReq", "LKAS11", 0), ("CF_Lkas_HbaSysState", "LKAS11", 0), ("CF_Lkas_FcwOpt", "LKAS11", 0), ("CF_Lkas_HbaOpt", "LKAS11", 0), ("CF_Lkas_FcwSysState", "LKAS11", 0), ("CF_Lkas_FcwCollisionWarning", "LKAS11", 0), ("CF_Lkas_FusionState", "LKAS11", 0), ("CF_Lkas_FcwOpt_USM", "LKAS11", 0), ("CF_Lkas_LdwsOpt_USM", "LKAS11", 0), ] checks = [ ("LKAS11", 100) ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) ================================================ FILE: selfdrive/car/hyundai/hyundaican.py ================================================ import crcmod from selfdrive.car.hyundai.values import CAR, CHECKSUM hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) def create_lkas11(packer, frame, car_fingerprint, apply_steer, steer_req, lkas11, sys_warning, sys_state, enabled, left_lane, right_lane, left_lane_depart, right_lane_depart): values = lkas11 values["CF_Lkas_LdwsSysState"] = sys_state values["CF_Lkas_SysWarning"] = 3 if sys_warning else 0 values["CF_Lkas_LdwsLHWarning"] = left_lane_depart values["CF_Lkas_LdwsRHWarning"] = right_lane_depart values["CR_Lkas_StrToqReq"] = apply_steer values["CF_Lkas_ActToi"] = steer_req values["CF_Lkas_MsgCount"] = frame % 0x10 if car_fingerprint in [CAR.SONATA, CAR.PALISADE, CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV_2021, CAR.SANTA_FE, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KIA_SELTOS, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_EV, CAR.KONA_HEV]: values["CF_Lkas_LdwsActivemode"] = int(left_lane) + (int(right_lane) << 1) values["CF_Lkas_LdwsOpt_USM"] = 2 # FcwOpt_USM 5 = Orange blinking car + lanes # FcwOpt_USM 4 = Orange car + lanes # FcwOpt_USM 3 = Green blinking car + lanes # FcwOpt_USM 2 = Green car + lanes # FcwOpt_USM 1 = White car + lanes # FcwOpt_USM 0 = No car + lanes values["CF_Lkas_FcwOpt_USM"] = 2 if enabled else 1 # SysWarning 4 = keep hands on wheel # SysWarning 5 = keep hands on wheel (red) # SysWarning 6 = keep hands on wheel (red) + beep # Note: the warning is hidden while the blinkers are on values["CF_Lkas_SysWarning"] = 4 if sys_warning else 0 elif car_fingerprint == CAR.HYUNDAI_GENESIS: # This field is actually LdwsActivemode # Genesis and Optima fault when forwarding while engaged values["CF_Lkas_LdwsActivemode"] = 2 elif car_fingerprint == CAR.KIA_OPTIMA: values["CF_Lkas_LdwsActivemode"] = 0 dat = packer.make_can_msg("LKAS11", 0, values)[2] if car_fingerprint in CHECKSUM["crc8"]: # CRC Checksum as seen on 2019 Hyundai Santa Fe dat = dat[:6] + dat[7:8] checksum = hyundai_checksum(dat) elif car_fingerprint in CHECKSUM["6B"]: # Checksum of first 6 Bytes, as seen on 2018 Kia Sorento checksum = sum(dat[:6]) % 256 else: # Checksum of first 6 Bytes and last Byte as seen on 2018 Kia Stinger checksum = (sum(dat[:6]) + dat[7]) % 256 values["CF_Lkas_Chksum"] = checksum return packer.make_can_msg("LKAS11", 0, values) def create_clu11(packer, frame, clu11, button): values = clu11 values["CF_Clu_CruiseSwState"] = button values["CF_Clu_AliveCnt1"] = frame % 0x10 return packer.make_can_msg("CLU11", 0, values) def create_lfahda_mfc(packer, enabled, hda_set_speed=0): values = { "LFA_Icon_State": 2 if enabled else 0, "HDA_Active": 1 if hda_set_speed else 0, "HDA_Icon_State": 2 if hda_set_speed else 0, "HDA_VSetReq": hda_set_speed, } return packer.make_can_msg("LFAHDA_MFC", 0, values) def create_acc_commands(packer, enabled, accel, idx, lead_visible, set_speed, stopping): commands = [] scc11_values = { "MainMode_ACC": 1, "TauGapSet": 4, "VSetDis": set_speed if enabled else 0, "AliveCounterACC": idx % 0x10, } commands.append(packer.make_can_msg("SCC11", 0, scc11_values)) scc12_values = { "ACCMode": 1 if enabled else 0, "StopReq": 1 if stopping else 0, "aReqRaw": accel, "aReqValue": accel, # stock ramps up at 1.0/s and down at 0.5/s until it reaches aReqRaw "CR_VSM_Alive": idx % 0xF, } scc12_dat = packer.make_can_msg("SCC12", 0, scc12_values)[2] scc12_values["CR_VSM_ChkSum"] = 0x10 - sum([sum(divmod(i, 16)) for i in scc12_dat]) % 0x10 commands.append(packer.make_can_msg("SCC12", 0, scc12_values)) scc14_values = { "ComfortBandUpper": 0.0, # stock usually is 0 but sometimes uses higher values "ComfortBandLower": 0.0, # stock usually is 0 but sometimes uses higher values "JerkUpperLimit": 1.0 if enabled else 0, # stock usually is 1.0 but sometimes uses higher values "JerkLowerLimit": 0.5 if enabled else 0, # stock usually is 0.5 but sometimes uses higher values "ACCMode": 1 if enabled else 4, # stock will always be 4 instead of 0 after first disengage "ObjGap": 3 if lead_visible else 0, # TODO: 1-5 based on distance to lead vehicle } commands.append(packer.make_can_msg("SCC14", 0, scc14_values)) fca11_values = { # seems to count 2,1,0,3,2,1,0,3,2,1,0,3,2,1,0,repeat... # (where first value is aligned to Supplemental_Counter == 0) # test: [(idx % 0xF, -((idx % 0xF) + 2) % 4) for idx in range(0x14)] "CR_FCA_Alive": ((-((idx % 0xF) + 2) % 4) << 2) + 1, "Supplemental_Counter": idx % 0xF, } fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2] fca11_values["CR_FCA_ChkSum"] = 0x10 - sum([sum(divmod(i, 16)) for i in fca11_dat]) % 0x10 commands.append(packer.make_can_msg("FCA11", 0, fca11_values)) return commands def create_acc_opt(packer): commands = [] scc13_values = { "SCCDrvModeRValue": 2, "SCC_Equip": 1, "Lead_Veh_Dep_Alert_USM": 2, } commands.append(packer.make_can_msg("SCC13", 0, scc13_values)) fca12_values = { # stock values may be needed if openpilot has vision based AEB some day # for now we are not setting these because there is no AEB for vision only # "FCA_USM": 3, # "FCA_DrvSetState": 2, } commands.append(packer.make_can_msg("FCA12", 0, fca12_values)) return commands def create_frt_radar_opt(packer): frt_radar11_values = { "CF_FCA_Equip_Front_Radar": 1, } return packer.make_can_msg("FRT_RADAR11", 0, frt_radar11_values) ================================================ FILE: selfdrive/car/hyundai/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV from selfdrive.car.hyundai.values import CAR, EV_CAR, HYBRID_CAR from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr from common.params import Params class CarInterface(CarInterfaceBase): @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "hyundai" ret.safetyModel = car.CarParams.SafetyModel.hyundai ret.radarOffCan = True ret.lateralTuning.init('pid') # Most Hyundai car ports are community features for now ret.communityFeature = candidate not in [CAR.SONATA, CAR.PALISADE] ret.steerActuatorDelay = 0.1 # Default delay ret.steerRateCost = 0.5 ret.steerLimitTimer = 0.4 tire_stiffness_factor = 1. ret.startAccel = 1.0 if candidate == CAR.SANTA_FE: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3982. * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.766 # Values from optimizer ret.steerRatio = 16.55 # 13.8 is spec end-to-end tire_stiffness_factor = 0.82 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[9., 22.], [9., 22.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.35], [0.05, 0.09]] elif candidate in [CAR.SONATA, CAR.SONATA_HYBRID]: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1513. + STD_CARGO_KG ret.wheelbase = 2.84 ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable tire_stiffness_factor = 0.65 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.SONATA_LF: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 4497. * CV.LB_TO_KG ret.wheelbase = 2.804 ret.steerRatio = 13.27 * 1.15 # 15% higher at the center seems reasonable ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.PALISADE: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1999. + STD_CARGO_KG ret.wheelbase = 2.90 ret.steerRatio = 15.6 * 1.15 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] elif candidate in [CAR.ELANTRA, CAR.ELANTRA_GT_I30]: ret.lateralTuning.pid.kf = 0.00006 ret.mass = 1275. + STD_CARGO_KG ret.wheelbase = 2.7 ret.steerRatio = 15.4 # 14 is Stock | Settled Params Learner values are steerRatio: 15.401566348670535 tire_stiffness_factor = 0.385 # stiffnessFactor settled on 1.0081302973865127 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.ELANTRA_2021: ret.lateralTuning.pid.kf = 0.00005 ret.mass = (2800. * CV.LB_TO_KG) + STD_CARGO_KG ret.wheelbase = 2.72 ret.steerRatio = 12.9 tire_stiffness_factor = 0.65 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.ELANTRA_HEV_2021: ret.lateralTuning.pid.kf = 0.00005 ret.mass = (3017. * CV.LB_TO_KG) + STD_CARGO_KG ret.wheelbase = 2.72 ret.steerRatio = 12.9 tire_stiffness_factor = 0.65 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.HYUNDAI_GENESIS: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 2060. + STD_CARGO_KG ret.wheelbase = 3.01 ret.steerRatio = 16.5 ret.lateralTuning.init('indi') ret.lateralTuning.indi.innerLoopGainBP = [0.] ret.lateralTuning.indi.innerLoopGainV = [3.5] ret.lateralTuning.indi.outerLoopGainBP = [0.] ret.lateralTuning.indi.outerLoopGainV = [2.0] ret.lateralTuning.indi.timeConstantBP = [0.] ret.lateralTuning.indi.timeConstantV = [1.4] ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] ret.lateralTuning.indi.actuatorEffectivenessV = [2.3] ret.minSteerSpeed = 60 * CV.KPH_TO_MS elif candidate in [CAR.KONA, CAR.KONA_EV, CAR.KONA_HEV]: ret.lateralTuning.pid.kf = 0.00005 ret.mass = {CAR.KONA_EV: 1685., CAR.KONA_HEV: 1425.}.get(candidate, 1275.) + STD_CARGO_KG ret.wheelbase = 2.7 ret.steerRatio = 13.73 * 1.15 # Spec tire_stiffness_factor = 0.385 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate in [CAR.IONIQ, CAR.IONIQ_EV_LTD, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV]: ret.lateralTuning.pid.kf = 0.00006 ret.mass = 1490. + STD_CARGO_KG # weight per hyundai site https://www.hyundaiusa.com/ioniq-electric/specifications.aspx ret.wheelbase = 2.7 ret.steerRatio = 13.73 # Spec tire_stiffness_factor = 0.385 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] if candidate not in [CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV]: ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.VELOSTER: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3558. * CV.LB_TO_KG ret.wheelbase = 2.80 ret.steerRatio = 13.75 * 1.15 tire_stiffness_factor = 0.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] # Kia elif candidate == CAR.KIA_SORENTO: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1985. + STD_CARGO_KG ret.wheelbase = 2.78 ret.steerRatio = 14.4 * 1.1 # 10% higher at the center seems reasonable ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate in [CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_HEV_2021]: ret.lateralTuning.pid.kf = 0.00006 ret.mass = 1737. + STD_CARGO_KG ret.wheelbase = 2.7 ret.steerRatio = 13.9 if CAR.KIA_NIRO_HEV_2021 else 13.73 # Spec tire_stiffness_factor = 0.385 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] if candidate == CAR.KIA_NIRO_HEV: ret.minSteerSpeed = 32 * CV.MPH_TO_MS elif candidate == CAR.KIA_SELTOS: ret.mass = 1337. + STD_CARGO_KG ret.wheelbase = 2.63 ret.steerRatio = 14.56 tire_stiffness_factor = 1 ret.lateralTuning.init('indi') ret.lateralTuning.indi.innerLoopGainBP = [0.] ret.lateralTuning.indi.innerLoopGainV = [4.] ret.lateralTuning.indi.outerLoopGainBP = [0.] ret.lateralTuning.indi.outerLoopGainV = [3.] ret.lateralTuning.indi.timeConstantBP = [0.] ret.lateralTuning.indi.timeConstantV = [1.4] ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] ret.lateralTuning.indi.actuatorEffectivenessV = [1.8] elif candidate in [CAR.KIA_OPTIMA, CAR.KIA_OPTIMA_H]: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3558. * CV.LB_TO_KG ret.wheelbase = 2.80 ret.steerRatio = 13.75 tire_stiffness_factor = 0.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.KIA_STINGER: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1825. + STD_CARGO_KG ret.wheelbase = 2.78 ret.steerRatio = 14.4 * 1.15 # 15% higher at the center seems reasonable ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.KIA_FORTE: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 3558. * CV.LB_TO_KG ret.wheelbase = 2.80 ret.steerRatio = 13.75 tire_stiffness_factor = 0.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] elif candidate == CAR.KIA_CEED: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 1450. + STD_CARGO_KG ret.wheelbase = 2.65 ret.steerRatio = 13.75 tire_stiffness_factor = 0.5 ret.lateralTuning.pid.kf = 0.00005 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.25], [0.05]] # Genesis elif candidate == CAR.GENESIS_G70: ret.lateralTuning.init('indi') ret.lateralTuning.indi.innerLoopGainBP = [0.] ret.lateralTuning.indi.innerLoopGainV = [2.5] ret.lateralTuning.indi.outerLoopGainBP = [0.] ret.lateralTuning.indi.outerLoopGainV = [3.5] ret.lateralTuning.indi.timeConstantBP = [0.] ret.lateralTuning.indi.timeConstantV = [1.4] ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] ret.lateralTuning.indi.actuatorEffectivenessV = [1.8] ret.steerActuatorDelay = 0.1 ret.mass = 1640.0 + STD_CARGO_KG ret.wheelbase = 2.84 ret.steerRatio = 13.56 elif candidate == CAR.GENESIS_G80: ret.lateralTuning.pid.kf = 0.00005 ret.mass = 2060. + STD_CARGO_KG ret.wheelbase = 3.01 ret.steerRatio = 16.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] ret.lateralTuning.init('indi') ret.lateralTuning.indi.innerLoopGainV = [3.5] ret.lateralTuning.indi.innerLoopGainBP = [0.] ret.lateralTuning.indi.outerLoopGainV = [2.0] ret.lateralTuning.indi.outerLoopGainBP = [0.] ret.lateralTuning.indi.timeConstantV = [1.4] ret.lateralTuning.indi.actuatorEffectivenessV = [2.3] ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] ret.minSteerSpeed = 60 * CV.KPH_TO_MS elif candidate == CAR.GENESIS_G90: ret.mass = 2200 ret.wheelbase = 3.15 ret.steerRatio = 12.069 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.16], [0.01]] # these cars require a special panda safety mode due to missing counters and checksums in the messages if candidate in [CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_NIRO_EV, CAR.KIA_OPTIMA, CAR.VELOSTER, CAR.KIA_STINGER, CAR.KIA_SELTOS, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA]: ret.safetyModel = car.CarParams.SafetyModel.hyundaiLegacy # set appropriate safety param for gas signal if candidate in HYBRID_CAR: ret.safetyParam = 2 elif candidate in EV_CAR: ret.safetyParam = 1 ret.centerToFront = ret.wheelbase * 0.4 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) ret.enableBsm = 0x58b in fingerprint[0] # dp if Params().get('dp_hkg_smart_mdps') == b'1': ret.minSteerSpeed = 0. ret = common_interface_get_params_lqr(ret) return ret def update(self, c, can_strings, dragonconf): self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam) # dp self.dragonconf = dragonconf if ret.vEgo >= self.CP.minSteerSpeed: ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False events = self.create_common_events(ret) if dragonconf.dpAtl: if ret.vEgo < self.CP.minSteerSpeed: events.add(car.CarEvent.EventName.belowSteerSpeed) else: # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s) if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.: self.low_speed_alert = True if ret.vEgo > (self.CP.minSteerSpeed + 4.): self.low_speed_alert = False if self.low_speed_alert: events.add(car.CarEvent.EventName.belowSteerSpeed) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/hyundai/radar_interface.py ================================================ #!/usr/bin/env python3 from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.interfaces import RadarInterfaceBase from selfdrive.car.hyundai.values import DBC def get_radar_can_parser(CP): signals = [ # sig_name, sig_address, default ("ACC_ObjStatus", "SCC11", 0), ("ACC_ObjLatPos", "SCC11", 0), ("ACC_ObjDist", "SCC11", 0), ("ACC_ObjRelSpd", "SCC11", 0), ] checks = [ # address, frequency ("SCC11", 50), ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.rcp = get_radar_can_parser(CP) self.updated_messages = set() self.trigger_msg = 0x420 self.track_id = 0 self.radar_off_can = CP.radarOffCan def update(self, can_strings): if self.radar_off_can: return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None rr = self._update(self.updated_messages) self.updated_messages.clear() return rr def _update(self, updated_messages): ret = car.RadarData.new_message() cpt = self.rcp.vl errors = [] if not self.rcp.can_valid: errors.append("canError") ret.errors = errors valid = cpt["SCC11"]['ACC_ObjStatus'] if valid: for ii in range(2): if ii not in self.pts: self.pts[ii] = car.RadarData.RadarPoint.new_message() self.pts[ii].trackId = self.track_id self.track_id += 1 self.pts[ii].dRel = cpt["SCC11"]['ACC_ObjDist'] # from front of car self.pts[ii].yRel = -cpt["SCC11"]['ACC_ObjLatPos'] # in car frame's y axis, left is negative self.pts[ii].vRel = cpt["SCC11"]['ACC_ObjRelSpd'] self.pts[ii].aRel = float('nan') self.pts[ii].yvRel = float('nan') self.pts[ii].measured = True ret.points = list(self.pts.values()) return ret ================================================ FILE: selfdrive/car/hyundai/values.py ================================================ # flake8: noqa from cereal import car from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu from common.params import Params # Steer torque limits class CarControllerParams: def __init__(self, CP): if Params().get('dp_hkg_smart_mdps') == b'1': self.STEER_MAX = 384 elif CP.carFingerprint in [CAR.SONATA, CAR.PALISADE, CAR.SANTA_FE, CAR.VELOSTER, CAR.GENESIS_G70, CAR.IONIQ_EV_2020, CAR.KIA_CEED, CAR.KIA_SELTOS, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV]: self.STEER_MAX = 384 else: self.STEER_MAX = 255 self.STEER_DELTA_UP = 3 self.STEER_DELTA_DOWN = 7 self.STEER_DRIVER_ALLOWANCE = 50 self.STEER_DRIVER_MULTIPLIER = 2 self.STEER_DRIVER_FACTOR = 1 class CAR: # Hyundai ELANTRA = "HYUNDAI ELANTRA 2017" ELANTRA_2021 = "HYUNDAI ELANTRA 2021" ELANTRA_HEV_2021 = "HYUNDAI ELANTRA HYBRID 2021" ELANTRA_GT_I30 = "HYUNDAI I30 N LINE 2019 & GT 2018 DCT" HYUNDAI_GENESIS = "HYUNDAI GENESIS 2015-2016" IONIQ = "HYUNDAI IONIQ HYBRID 2017-2019" IONIQ_EV_LTD = "HYUNDAI IONIQ ELECTRIC LIMITED 2019" IONIQ_EV_2020 = "HYUNDAI IONIQ ELECTRIC 2020" IONIQ_PHEV = "HYUNDAI IONIQ PHEV 2020" KONA = "HYUNDAI KONA 2020" KONA_EV = "HYUNDAI KONA ELECTRIC 2019" KONA_HEV = "HYUNDAI KONA HYBRID 2020" SANTA_FE = "HYUNDAI SANTA FE 2019" SONATA = "HYUNDAI SONATA 2020" SONATA_LF = "HYUNDAI SONATA 2019" PALISADE = "HYUNDAI PALISADE 2020" VELOSTER = "HYUNDAI VELOSTER 2019" SONATA_HYBRID = "HYUNDAI SONATA HYBRID 2021" # Kia KIA_FORTE = "KIA FORTE E 2018 & GT 2021" KIA_NIRO_EV = "KIA NIRO EV 2020" KIA_NIRO_HEV = "KIA NIRO HYBRID 2019" KIA_NIRO_HEV_2021 = "KIA NIRO HYBRID 2021" KIA_OPTIMA = "KIA OPTIMA SX 2019 & 2016" KIA_OPTIMA_H = "KIA OPTIMA HYBRID 2017 & SPORTS 2019" KIA_SELTOS = "KIA SELTOS 2021" KIA_SORENTO = "KIA SORENTO GT LINE 2018" KIA_STINGER = "KIA STINGER GT2 2018" KIA_CEED = "KIA CEED INTRO ED 2019" # Genesis GENESIS_G70 = "GENESIS G70 2018" GENESIS_G80 = "GENESIS G80 2017" GENESIS_G90 = "GENESIS G90 2017" class Buttons: NONE = 0 RES_ACCEL = 1 SET_DECEL = 2 GAP_DIST = 3 CANCEL = 4 FINGERPRINTS = { CAR.ELANTRA: [{ 66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 897: 8, 832: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1345: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2001: 8, 2003: 8, 2004: 8, 2009: 8, 2012: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }], CAR.ELANTRA_GT_I30: [{ 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1193: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1952: 8, 1960: 8, 1988: 8, 2000: 8, 2001: 8, 2005: 8, 2008: 8, 2009: 8, 2013: 8, 2017: 8, 2025: 8 }, { 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8 }, { 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 897: 8, 899: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1265: 4, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1486: 8, 1487: 8, 1491: 8, 1960: 8, 1990: 8, 1998: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2008: 8, 2009: 8, 2012: 8, 2013: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }], CAR.HYUNDAI_GENESIS: [{ 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1342: 6, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4 }, { 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1024: 2, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1456: 4 }, { 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1268: 8, 1280: 1, 1281: 3, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1427: 6, 1434: 2, 1437: 8, 1456: 4 }, { 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1378: 4, 1379: 8, 1384: 5, 1407: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4 }, { 67: 8, 68: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 7, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 5, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1287: 4, 1292: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1334: 8, 1335: 8, 1345: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 5, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4 }], CAR.SANTA_FE: [{ 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1379: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8 }, { 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 6, 764: 8, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1155: 8, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1186: 2, 1227: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8 }, { 67: 8, 68: 8, 80: 4, 160: 8, 161: 8, 272: 8, 288: 4, 339: 8, 356: 8, 357: 8, 399: 8, 544: 8, 608: 8, 672: 8, 688: 5, 704: 1, 790: 8, 809: 8, 848: 8, 880: 8, 898: 8, 900: 8, 901: 8, 904: 8, 1056: 8, 1064: 8, 1065: 8, 1072: 8, 1075: 8, 1087: 8, 1088: 8, 1151: 8, 1200: 8, 1201: 8, 1232: 4, 1264: 8, 1265: 8, 1266: 8, 1296: 8, 1306: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1348: 8, 1349: 8, 1369: 8, 1370: 8, 1371: 8, 1407: 8, 1415: 8, 1419: 8, 1440: 8, 1442: 4, 1461: 8, 1470: 8 }], CAR.SONATA: [ {67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 546: 8, 549: 8, 550: 8, 576: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 8, 865: 8, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 908: 8, 909: 8, 912: 7, 913: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1089: 5, 1096: 8, 1107: 5, 1108: 8, 1114: 8, 1136: 8, 1145: 8, 1151: 8, 1155: 8, 1156: 8, 1157: 4, 1162: 8, 1164: 8, 1168: 8, 1170: 8, 1173: 8, 1180: 8, 1183: 8, 1184: 8, 1186: 2, 1191: 2, 1193: 8, 1210: 8, 1225: 8, 1227: 8, 1265: 4, 1268: 8, 1280: 8, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1330: 8, 1339: 8, 1342: 6, 1343: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1379: 8, 1384: 8, 1394: 8, 1407: 8, 1419: 8, 1427: 6, 1446: 8, 1456: 4, 1460: 8, 1470: 8, 1485: 8, 1504: 3, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 2015: 8}, ], CAR.SONATA_LF: [ {66: 8, 67: 8, 68: 8, 127: 8, 273: 8, 274: 8, 275: 8, 339: 8, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 593: 8, 608: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1314: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1397: 8, 1407: 8, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1530: 8, 1532: 5, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2008: 8, 2009: 8, 2012: 8, 2013: 8, 2014: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8}, ], CAR.KIA_OPTIMA: [{ 64: 8, 66: 8, 67: 8, 68: 8, 127: 8, 128: 8, 129: 8, 273: 8, 274: 8, 275: 8, 339: 8, 354: 3, 356: 4, 399: 8, 447: 8, 512: 6, 544: 8, 558: 8, 593: 8, 608: 8, 640: 8, 688: 5, 790: 8, 809: 8, 832: 8, 884: 8, 897: 8, 899: 8, 902: 8, 903: 6, 909: 8, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1151: 6, 1168: 7, 1170: 8, 1186: 2, 1191: 2, 1253: 8, 1254: 8, 1255: 8, 1265: 4, 1268: 8, 1280: 1, 1282: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1349: 8, 1351: 8, 1353: 8, 1356: 8, 1363: 8, 1365: 8, 1366: 8, 1367: 8, 1369: 8, 1407: 8, 1414: 3, 1415: 8, 1419: 8, 1425: 2, 1427: 6, 1440: 8, 1456: 4, 1470: 8, 1472: 8, 1486: 8, 1487: 8, 1491: 8, 1492: 8, 1530: 8, 1532: 5, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 1996: 8, 2000: 8, 2001: 8, 2004: 8, 2008: 8, 2009: 8, 2012: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8, 1371: 8, 1397: 8, 1961: 8 }], CAR.KIA_SORENTO: [{ 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1384: 8, 1407: 8, 1411: 8, 1419: 8, 1425: 2, 1427: 6, 1444: 8, 1456: 4, 1470: 8, 1489: 1 }], CAR.KIA_STINGER: [{ 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 576: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 4, 1379: 8, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1456: 4, 1470: 8 }], CAR.GENESIS_G80: [{ 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1024: 2, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1191: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1456: 4, 1470: 8 }, { 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 546: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1437: 8, 1456: 4, 1470: 8 }, { 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1162: 8, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1193: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1437: 8, 1456: 4, 1470: 8 }], CAR.GENESIS_G90: [{ 67: 8, 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 358: 6, 359: 8, 544: 8, 593: 8, 608: 8, 688: 5, 809: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1151: 6, 1162: 4, 1168: 7, 1170: 8, 1173: 8, 1184: 8, 1265: 4, 1280: 1, 1281: 3, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1370: 8, 1371: 8, 1378: 4, 1384: 8, 1407: 8, 1419: 8, 1425: 2, 1427: 6, 1434: 2, 1456: 4, 1470: 8, 1988: 8, 2000: 8, 2003: 8, 2004: 8, 2005: 8, 2008: 8, 2011: 8, 2012: 8, 2013: 8 }], CAR.IONIQ_EV_2020: [{ 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 524: 8, 544: 7, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1157: 4, 1164: 8, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1379: 8, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2005: 8, 2008: 8, 2012: 8, 2013: 8 }], CAR.IONIQ_EV_LTD: [{ 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 7, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1168: 7, 1173: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1407: 8, 1419: 8, 1425: 2, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1507: 8, 1535: 8 }], CAR.IONIQ: [{ 68:8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 524: 8, 544: 8, 576:8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1155: 8, 1156: 8, 1157: 4, 1164: 8, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1379: 8, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1473: 8, 1476: 8, 1507: 8, 1535: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2005: 8, 2008: 8, 2012: 8, 2013: 8 }], CAR.KONA_EV: [{ 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 549: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1307: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1378: 4, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 1157: 4, 1193: 8, 1379: 8, 1988: 8, 1996: 8 }], CAR.KIA_NIRO_EV: [{ 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 516: 8, 544: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 8, 1151: 6, 1156: 8, 1157: 4, 1168: 7, 1173: 8, 1183: 8, 1186: 2, 1191: 2, 1193: 8, 1225: 8, 1260: 8, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1407: 8, 1419: 8, 1426: 8, 1427: 6, 1429: 8, 1430: 8, 1456: 4, 1470: 8, 1473: 8, 1507: 8, 1535: 8, 1990: 8, 1998: 8, 1996: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 2015: 8 }], CAR.KIA_FORTE: [{ 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 354: 3, 356: 4, 544: 8, 576: 8, 593: 8, 608: 8, 688: 5, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1078: 4, 1107: 5, 1136: 8, 1156: 8, 1170: 8, 1173: 8, 1186: 2, 1191: 2, 1225: 8, 1265: 4, 1280: 4, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1384: 8, 1394: 8, 1407: 8, 1414: 3, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2008: 8, 2012: 8, 2015: 8 }], CAR.KIA_OPTIMA_H: [{ 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 593: 8, 688: 5, 832: 8, 881: 8, 882: 8, 897: 8, 902: 8, 903: 6, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1168: 7, 1173: 8, 1236: 2, 1265: 4, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1322: 8, 1331: 8, 1332: 8, 1333: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1476: 8, 1535: 8 }, { 68: 8, 127: 8, 304: 8, 320: 8, 339: 8, 352: 8, 356: 4, 544: 8, 576: 8, 593: 8, 688: 5, 881: 8, 882: 8, 897: 8, 902: 8, 903: 8, 909: 8, 912: 7, 916: 8, 1040: 8, 1056: 8, 1057: 8, 1078: 4, 1136: 6, 1151: 6, 1168: 7, 1173: 8, 1180: 8, 1186: 2, 1191: 2, 1265: 4, 1268: 8, 1280: 1, 1287: 4, 1290: 8, 1291: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1355: 8, 1363: 8, 1369: 8, 1371: 8, 1407: 8, 1419: 8, 1420: 8, 1425: 2, 1427: 6, 1429: 8, 1430: 8, 1448: 8, 1456: 4, 1470: 8, 1476: 8, 1535: 8 }], CAR.PALISADE: [{ 67: 8, 127: 8, 304: 8, 320: 8, 339: 8, 356: 4, 544: 8, 546: 8, 547: 8, 548: 8, 549: 8, 576: 8, 593: 8, 608: 8, 688: 6, 809: 8, 832: 8, 854: 7, 870: 7, 871: 8, 872: 8, 897: 8, 902: 8, 903: 8, 905: 8, 909: 8, 913: 8, 916: 8, 1040: 8, 1042: 8, 1056: 8, 1057: 8, 1064: 8, 1078: 4, 1107: 5, 1123: 8, 1136: 8, 1151: 6, 1155: 8, 1156: 8, 1157: 4, 1162: 8, 1164: 8, 1168: 7, 1170: 8, 1173: 8, 1180: 8, 1186: 2, 1191: 2, 1193: 8, 1210: 8, 1225: 8, 1227: 8, 1265: 4, 1280: 8, 1287: 4, 1290: 8, 1292: 8, 1294: 8, 1312: 8, 1322: 8, 1342: 6, 1345: 8, 1348: 8, 1363: 8, 1369: 8, 1371: 8, 1378: 8, 1384: 8, 1407: 8, 1419: 8, 1427: 6, 1456: 4, 1470: 8, 1988: 8, 1996: 8, 2000: 8, 2004: 8, 2005: 8, 2008: 8, 2012: 8 }], } FW_VERSIONS = { CAR.IONIQ_PHEV: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\000AEhe SCC FHCUP 1.00 1.02 99110-G2100 ', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\000AE MDPS C 1.00 1.01 56310/G2510 4APHC101', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\000AEP MFC AT USA LHD 1.00 1.01 95740-G2600 190819', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x816H6F6051\000\000\000\000\000\000\000\000', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x816U3J9051\000\000\xf1\0006U3H1_C2\000\0006U3J9051\000\000PAE0G16NL0\x82zT\xd2', ], }, CAR.IONIQ_EV_2020: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00AEev SCC F-CUP 1.00 1.01 99110-G7000 ', b'\xf1\x00AEev SCC F-CUP 1.00 1.00 99110-G7200 ', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00AE MDPS C 1.00 1.01 56310/G7310 4APEC101', b'\xf1\x00AE MDPS C 1.00 1.01 56310/G7560 4APEC101', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.01 95740-G2600 190819', b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.03 95740-G2500 190516', b'\xf1\x00AEE MFC AT EUR RHD 1.00 1.01 95740-G2600 190819', ], }, CAR.IONIQ_EV_LTD: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00AEev SCC F-CUP 1.00 1.00 96400-G7000 ', b'\xf1\x00AEev SCC F-CUP 1.00 1.00 96400-G7100 ', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00AE MDPS C 1.00 1.02 56310G7300\x00 4AEEC102', b'\xf1\x00AE MDPS C 1.00 1.04 56310/G7501 4AEEC104', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00AEE MFC AT EUR LHD 1.00 1.00 95740-G7200 160418', b'\xf1\x00AEE MFC AT USA LHD 1.00 1.00 95740-G2400 180222', ], }, CAR.SONATA: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00DN8_ SCC F-CU- 1.00 1.00 99110-L0000 ', b'\xf1\x00DN8_ SCC F-CUP 1.00 1.00 99110-L0000 ', b'\xf1\x00DN8_ SCC F-CUP 1.00 1.02 99110-L1000 ', b'\xf1\x00DN8_ SCC FHCUP 1.00 1.00 99110-L0000 ', b'\xf1\x00DN8_ SCC FHCUP 1.00 1.01 99110-L1000 ', b'\xf1\x00DN89110-L0000 \xaa\xaa\xaa\xaa\xaa\xaa\xaa \xf1\xa01.00\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x00\x00\x00', b'\xf1\x00DN8 1.00 99110-L0000 \xaa\xaa\xaa\xaa\xaa\xaa\xaa \xf1\xa01.00\xaa\xaa\xaa', ], (Ecu.esp, 0x7d1, None): [ b'\xf1\x00DN ESC \a 106 \a\x01 58910-L0100', b'\xf1\x00DN ESC \x01 102\x19\x04\x13 58910-L1300\xf1\xa01.02', b'\xf1\x00DN ESC \x03 100 \x08\x01 58910-L0300', b'\xf1\x00DN ESC \x06 104\x19\x08\x01 58910-L0100', b'\xf1\x00DN ESC \x07 104\x19\x08\x01 58910-L0100', b'\xf1\x00DN ESC \x08 103\x19\x06\x01 58910-L1300\xf1\xa01.03', b'\xf1\x8758910-L0100\xf1\x00DN ESC \a 106 \a\x01 58910-L0100\xf1\xa01.06', b'\xf1\x8758910-L0100\xf1\x00DN ESC \x06 104\x19\x08\x01 58910-L0100\xf1\xa01.04', b'\xf1\x8758910-L0100\xf1\x00DN ESC \x06 106 \x07\x01 58910-L0100\xf1\xa01.06', b'\xf1\x8758910-L0100\xf1\x00DN ESC \x07 104\x19\x08\x01 58910-L0100\xf1\xa01.04', b'\xf1\x00DN ESC \x06 106 \x07\x01 58910-L0100', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81HM6M1_0a0_F00', b'\xf1\x82DNBVN5GMCCXXXDCA', b'\xf1\x82DNBWN5TMDCXXXG2E', b'\xf1\x82DNCVN5GMCCXXXG2B', b'\xf1\x87391162M003\xf1\xa0000F', b'\xf1\x87391162M003\xf1\xa00240', b'\xf1\x87391162M013\xf1\xa00240', b'HM6M1_0a0_F00', b'HM6M2_0a0_BD0', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00DN8 MDPS C 1.00 1.01 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 4DNAC101', b'\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0010 4DNAC101', b'\xf1\x00DN8 MDPS C 1.00 1.01 56310L0010\x00 4DNAC101', b'\xf1\x00DN8 MDPS R 1.00 1.00 57700-L0000 4DNAP100', b'\xf1\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\x00DN8 MDPS C 1.00 1.01 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 4DNAC101\xf1\xa01.01', b'\xf1\x8756310-L0010\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0010 4DNAC101\xf1\xa01.01', b'\xf1\x8756310-L0210\xf1\x00DN8 MDPS C 1.00 1.01 56310-L0210 4DNAC101\xf1\xa01.01', b'\xf1\x8756310-L1010\xf1\x00DN8 MDPS C 1.00 1.03 56310-L1010 4DNDC103\xf1\xa01.03', b'\xf1\x8756310-L1030\xf1\x00DN8 MDPS C 1.00 1.03 56310-L1030 4DNDC103\xf1\xa01.03', b'\xf1\x8756310L0010\x00\xf1\x00DN8 MDPS C 1.00 1.01 56310L0010\x00 4DNAC101\xf1\xa01.01', b'\xf1\x8756310L0210\x00\xf1\x00DN8 MDPS C 1.00 1.01 56310L0210\x00 4DNAC101\xf1\xa01.01', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00DN8 MFC AT KOR LHD 1.00 1.02 99211-L1000 190422', b'\xf1\x00DN8 MFC AT RUS LHD 1.00 1.03 99211-L1000 190705', b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.00 99211-L0000 190716', b'\xf1\x00DN8 MFC AT USA LHD 1.00 1.01 99211-L0000 191016', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00SDN8T16NB0z{\xd4v', b'\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB1\xe3\xc10\xa1', b'\xf1\x00bcsh8p54 U913\x00\x00\x00\x00\x00\x00SDN8T16NB2\n\xdd^\xbc', b'\xf1\x00HT6TA260BLHT6TA800A1TDN8C20KS4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x00HT6TA260BLHT6TA810A1TDN8M25GS0\x00\x00\x00\x00\x00\x00\xaa\x8c\xd9p', b'\xf1\x00HT6WA250BLHT6WA910A1SDN8G25NB1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x00HT6WA250BLHT6WA910A1SDN8G25NB1\x00\x00\x00\x00\x00\x00\x96\xa1\xf1\x92', b'\xf1\x00HT6WA280BLHT6WAD10A1SDN8G25NB2\x00\x00\x00\x00\x00\x00\x08\xc9O:', b'\xf1\x00T02601BL T02730A1 VDN8T25XXX730NS5\xf7_\x92\xf5', b'\xf1\x87SALDBA3510954GJ3ww\x87xUUuWx\x88\x87\x88\x87w\x88wvfwfc_\xf9\xff\x98wO\xffl\xe0\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA3573534GJ3\x89\x98\x89\x88EUuWgwvwwwwww\x88\x87xTo\xfa\xff\x86f\x7f\xffo\x0e\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA3601464GJ3\x88\x88\x88\x88ffvggwvwvw\x87gww\x87wvo\xfb\xff\x98\x88\x7f\xffjJ\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA3753044GJ3UUeVff\x86hwwwwvwwgvfgfvo\xf9\xfffU_\xffC\xae\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA3873834GJ3fefVwuwWx\x88\x97\x88w\x88\x97xww\x87wU_\xfb\xff\x86f\x8f\xffN\x04\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA4525334GJ3\x89\x99\x99\x99fevWh\x88\x86\x88fwvgw\x88\x87xfo\xfa\xffuDo\xff\xd1>\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA4626804GJ3wwww\x88\x87\x88xx\x88\x87\x88wwgw\x88\x88\x98\x88\x95_\xf9\xffuDo\xff|\xe7\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA4803224GJ3wwwwwvwg\x88\x88\x98\x88wwww\x87\x88\x88xu\x9f\xfc\xff\x87f\x8f\xff\xea\xea\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA6347404GJ3wwwwff\x86hx\x88\x97\x88\x88\x88\x88\x88vfgf\x88?\xfc\xff\x86Uo\xff\xec/\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA6901634GJ3UUuWVeVUww\x87wwwwwvUge\x86/\xfb\xff\xbb\x99\x7f\xff]2\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SALDBA7077724GJ3\x98\x88\x88\x88ww\x97ygwvwww\x87ww\x88\x87x\x87_\xfd\xff\xba\x99o\xff\x99\x01\xf1\x89HT6WA910A1\xf1\x82SDN8G25NB1\x00\x00\x00\x00\x00\x00', b'\xf1\x87SAMDBA8054504GJ3gw\x87xffvgffffwwwweUVUf?\xfc\xffvU_\xff\xddl\xf1\x89HT6WAD10A1\xf1\x82SDN8G25NB2\x00\x00\x00\x00\x00\x00', ], }, CAR.SONATA_LF: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00LF__ SCC F-CUP 1.00 1.00 96401-C2200 ', ], (Ecu.esp, 0x7d1, None): [ b'\xf1\x00LF ESC \f 11 \x17\x01\x13 58920-C2610', b'\xf1\x00LF ESC \t 11 \x17\x01\x13 58920-C2610', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81606D5051\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x81606D5K51\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x81606G1051\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00LFF LKAS AT USA LHD 1.00 1.01 95740-C1000 E51', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x87LAHSGN012918KF10\x98\x88x\x87\x88\x88x\x87\x88\x88\x98\x88\x87w\x88w\x88\x88\x98\x886o\xf6\xff\x98w\x7f\xff3\x00\xf1\x816W3B1051\x00\x00\xf1\x006W351_C2\x00\x006W3B1051\x00\x00TLF0T20NL2\x00\x00\x00\x00', b'\xf1\x87LAHSGN012918KF10\x98\x88x\x87\x88\x88x\x87\x88\x88\x98\x88\x87w\x88w\x88\x88\x98\x886o\xf6\xff\x98w\x7f\xff3\x00\xf1\x816W3B1051\x00\x00\xf1\x006W351_C2\x00\x006W3B1051\x00\x00TLF0T20NL2H\r\xbdm', b'\xf1\x87\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf1\x816T6B4051\x00\x00\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24NL1\xb0\x9f\xee\xf5', b'\xf1\x87\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xf1\x816T6B4051\x00\x00\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24NL1\x00\x00\x00\x00', b'\xf1\x006T6H0_C2\x00\x006T6B4051\x00\x00TLF0G24NL1\xb0\x9f\xee\xf5', ], }, CAR.SANTA_FE: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00TM__ SCC F-CUP 1.00 1.01 99110-S2000 \xf1\xa01.01', b'\xf1\x00TM__ SCC F-CUP 1.00 1.02 99110-S2000 \xf1\xa01.02', b'\xf1\x00TM__ SCC F-CUP 1.00 1.03 99110-S2000 \xf1\xa01.03', ], (Ecu.esp, 0x7d1, None): [ b'\xf1\x00TM ESC \r 100\x18\x031 58910-S2650\xf1\xa01.00', b'\xf1\x00TM ESC \r 103\x18\x11\x08 58910-S2650\xf1\xa01.03', b'\xf1\x00TM ESC \r 104\x19\a\b 58910-S2650\xf1\xa01.04', b'\xf1\x00TM ESC \x02 100\x18\x030 58910-S2600\xf1\xa01.00', b'\xf1\x00TM ESC \x02 102\x18\x07\x01 58910-S2600\xf1\xa01.02', b'\xf1\x00TM ESC \x02 103\x18\x11\x07 58910-S2600\xf1\xa01.03', b'\xf1\x00TM ESC \x02 104\x19\x07\x07 58910-S2600\xf1\xa01.04', b'\xf1\x00TM ESC \x03 103\x18\x11\x07 58910-S2600\xf1\xa01.03', b'\xf1\x00TM ESC \x0c 103\x18\x11\x08 58910-S2650', b'\xf1\x00TM ESC \x0c 103\x18\x11\x08 58910-S2650\xf1\xa01.03', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81606EA051\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x81606G1051\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x81606G3051\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8409', b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8A12', b'\xf1\x00TM MDPS C 1.00 1.01 56340-S2000 9129', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00TM MFC AT USA LHD 1.00 1.00 99211-S2000 180409', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x87LBJSGA7082574HG0\x87www\x98\x88\x88\x88\x99\xaa\xb9\x9afw\x86gx\x99\xa7\x89co\xf8\xffvU_\xffR\xaf\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2T20NS1\x00\xa6\xe0\x91', b'\xf1\x87LBKSGA0458404HG0vfvg\x87www\x89\x99\xa8\x99y\xaa\xa7\x9ax\x88\xa7\x88t_\xf9\xff\x86w\x8f\xff\x15x\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2T20NS1\x00\x00\x00\x00', b'\xf1\x87LDJUEA6010814HG1\x87w\x87x\x86gvw\x88\x88\x98\x88gw\x86wx\x88\x97\x88\x85o\xf8\xff\x86f_\xff\xd37\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4T20NS0\xf8\x19\x92g', b'\xf1\x87LDJUEA6458264HG1ww\x87x\x97x\x87\x88\x88\x99\x98\x89g\x88\x86xw\x88\x97x\x86o\xf7\xffvw\x8f\xff3\x9a\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4T20NS0\xf8\x19\x92g', b'\xf1\x87LDKUEA2045844HG1wwww\x98\x88x\x87\x88\x88\xa8\x88x\x99\x97\x89x\x88\xa7\x88U\x7f\xf8\xffvfO\xffC\x1e\xf1\x816W3E0051\x00\x00\xf1\x006W351_C2\x00\x006W3E0051\x00\x00TTM4T20NS3\x00\x00\x00\x00', b'\xf1\x87LDKUEA9993304HG1\x87www\x97x\x87\x88\x99\x99\xa9\x99x\x99\xa7\x89w\x88\x97x\x86_\xf7\xffwwO\xffl#\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4T20NS1R\x7f\x90\n', b'\xf1\x87LDLUEA6061564HG1\xa9\x99\x89\x98\x87wwwx\x88\x97\x88x\x99\xa7\x89x\x99\xa7\x89sO\xf9\xffvU_\xff<\xde\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS50\xcb\xc3\xed', b'\xf1\x87LDLUEA6159884HG1\x88\x87hv\x99\x99y\x97\x89\xaa\xb8\x9ax\x99\x87\x89y\x99\xb7\x99\xa7?\xf7\xff\x97wo\xff\xf3\x05\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS5\x00\x00\x00\x00', b'\xf1\x87LDLUEA6852664HG1\x97wWu\x97www\x89\xaa\xc8\x9ax\x99\x97\x89x\x99\xa7\x89SO\xf7\xff\xa8\x88\x7f\xff\x03z\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS50\xcb\xc3\xed', b'\xf1\x87LDLUEA6898374HG1fevW\x87wwwx\x88\x97\x88h\x88\x96\x88x\x88\xa7\x88ao\xf9\xff\x98\x99\x7f\xffD\xe2\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS5\x00\x00\x00\x00', b'\xf1\x87LDLUEA6898374HG1fevW\x87wwwx\x88\x97\x88h\x88\x96\x88x\x88\xa7\x88ao\xf9\xff\x98\x99\x7f\xffD\xe2\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4T20NS50\xcb\xc3\xed', b'\xf1\x87SBJWAA5842214GG0\x88\x87\x88xww\x87x\x89\x99\xa8\x99\x88\x99\x98\x89w\x88\x87xw_\xfa\xfffU_\xff\xd1\x8d\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x98{|\xe3', b'\xf1\x87SBJWAA5890864GG0\xa9\x99\x89\x98\x98\x87\x98y\x89\x99\xa8\x99w\x88\x87xww\x87wvo\xfb\xffuD_\xff\x9f\xb5\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x98{|\xe3', b'\xf1\x87SBJWAA6562474GG0ffvgeTeFx\x88\x97\x88ww\x87www\x87w\x84o\xfa\xff\x87fO\xff\xc2 \xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x00\x00\x00\x00', b'\xf1\x87SBJWAA6562474GG0ffvgeTeFx\x88\x97\x88ww\x87www\x87w\x84o\xfa\xff\x87fO\xff\xc2 \xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS1\x98{|\xe3', b'\xf1\x87SBJWAA7780564GG0wvwgUUeVwwwwx\x88\x87\x88wwwwd_\xfc\xff\x86f\x7f\xff\xd7*\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS2F\x84<\xc0', b'\xf1\x87SBJWAA8278284GG0ffvgUU\x85Xx\x88\x87\x88x\x88w\x88ww\x87w\x96o\xfd\xff\xa7U_\xff\xf2\xa0\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM2G24NS2F\x84<\xc0', b'\xf1\x87SBLWAA4363244GG0wvwgwv\x87hgw\x86ww\x88\x87xww\x87wdo\xfb\xff\x86f\x7f\xff3$\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS6\x00\x00\x00\x00', b'\xf1\x87SBLWAA6622844GG0wwwwff\x86hwwwwx\x88\x87\x88\x88\x88\x88\x88\x98?\xfd\xff\xa9\x88\x7f\xffn\xe5\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS7u\x1e{\x1c', b'\xf1\x87SDJXAA7656854GG1DEtWUU\x85X\x88\x88\x98\x88w\x88\x87xx\x88\x87\x88\x96o\xfb\xff\x86f\x7f\xff.\xca\xf1\x816W3C2051\x00\x00\xf1\x006W351_C2\x00\x006W3C2051\x00\x00TTM4G24NS2\x00\x00\x00\x00', b'\xf1\x87SDKXAA2443414GG1vfvgwv\x87h\x88\x88\x88\x88ww\x87wwwww\x99_\xfc\xffvD?\xffl\xd2\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM4G24NS6\x00\x00\x00\x00', b'\xf1\x87SBLWAA4899564GG0VfvgUU\x85Xx\x88\x87\x88vfgf\x87wxwvO\xfb\xff\x97f\xb1\xffSB\xf1\x816W3E1051\x00\x00\xf1\x006W351_C2\x00\x006W3E1051\x00\x00TTM2G24NS7\x00\x00\x00\x00', ], }, CAR.KIA_STINGER: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00CK__ SCC F_CUP 1.00 1.01 96400-J5100 \xf1\xa01.01', b'\xf1\x00CK__ SCC F_CUP 1.00 1.03 96400-J5100 \xf1\xa01.03', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81606DE051\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x81640E0051\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x82CKJN3TMSDE0B\x00\x00\x00\x00', b'\xf1\x82CKKN3TMD_H0A\x00\x00\x00\x00', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5200 4C2CL104', b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5220 4C2VL104', b'\xf1\x00CK MDPS R 1.00 1.04 57700-J5420 4C4VL104', b'\xf1\x00CK MDPS R 1.00 1.06 57700-J5420 4C4VL106', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00CK MFC AT USA LHD 1.00 1.03 95740-J5000 170822', b'\xf1\x00CK MFC AT USA LHD 1.00 1.04 95740-J5000 180504', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x87VCJLE17622572DK0vd6D\x99\x98y\x97vwVffUfvfC%CuT&Dx\x87o\xff{\x1c\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\x88\xa2\xe6\xf0', b'\xf1\x87VDHLG17000192DK2xdFffT\xa5VUD$DwT\x86wveVeeD&T\x99\xba\x8f\xff\xcc\x99\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\x88\xa2\xe6\xf0', b'\xf1\x87VDHLG17000192DK2xdFffT\xa5VUD$DwT\x86wveVeeD&T\x99\xba\x8f\xff\xcc\x99\xf1\x89E21\x00\x00\x00\x00\x00\x00\x00\xf1\x82SCK0T33NB0', b'\xf1\x87VDHLG17034412DK2vD6DfVvVTD$D\x99w\x88\x98EDEDeT6DgfO\xff\xc3=\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\x88\xa2\xe6\xf0', b'\xf1\x87VDHLG17118862DK2\x8awWwgu\x96wVfUVwv\x97xWvfvUTGTx\x87o\xff\xc9\xed\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00SCK0T33NB0\x88\xa2\xe6\xf0', b'\xf1\x87VDKLJ18675252DK6\x89vhgwwwwveVU\x88w\x87w\x99vgf\x97vXfgw_\xff\xc2\xfb\xf1\x89E25\x00\x00\x00\x00\x00\x00\x00\xf1\x82TCK0T33NB2', b'\xf1\x87WAJTE17552812CH4vfFffvfVeT5DwvvVVdFeegeg\x88\x88o\xff\x1a]\xf1\x81E21\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E21\x00\x00\x00\x00\x00\x00\x00TCK2T20NB1\x19\xd2\x00\x94', ], }, CAR.PALISADE: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\000LX2_ SCC F-CUP 1.00 1.05 99110-S8100 \xf1\xa01.05', b'\xf1\x00LX2 SCC FHCUP 1.00 1.04 99110-S8100 \xf1\xa01.04', b'\xf1\x00LX2_ SCC FHCUP 1.00 1.04 99110-S8100 \xf1\xa01.04', b'\xf1\x00LX2_ SCC FHCUP 1.00 1.05 99110-S8100 \xf1\xa01.05', ], (Ecu.esp, 0x7d1, None): [ b'\xf1\x00LX ESC \v 102\x19\x05\a 58910-S8330\xf1\xa01.02', b'\xf1\x00LX ESC \v 103\x19\t\x10 58910-S8360\xf1\xa01.03', b'\xf1\x00LX ESC \x01 103\x19\t\x10 58910-S8360\xf1\xa01.03', b'\xf1\x00LX ESC \x01 103\x31\t\020 58910-S8360\xf1\xa01.03', b'\xf1\x00LX ESC \x0b 101\x19\x03\x17 58910-S8330\xf1\xa01.01', b'\xf1\x00LX ESC \x0b 102\x19\x05\x07 58910-S8330', b'\xf1\x00LX ESC \x0b 103\x19\t\x07 58910-S8330\xf1\xa01.03', b'\xf1\x00LX ESC \x0b 103\x19\t\x10 58910-S8360', b'\xf1\x00LX ESC \x0b 104 \x10\x16 58910-S8360\xf1\xa01.04', b'\xf1\x00ON ESC \x0b 100\x18\x12\x18 58910-S9360\xf1\xa01.00', b'\xf1\x00ON ESC \x0b 101\x19\t\x08 58910-S9360\xf1\xa01.01', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81640J0051\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x81640K0051\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00LX2 MDPS C 1,00 1,03 56310-S8020 4LXDC103', # modified firmware b'\xf1\x00LX2 MDPS C 1.00 1.03 56310-S8020 4LXDC103', b'\xf1\x00ON MDPS C 1.00 1.00 56340-S9000 8B13', b'\xf1\x00ON MDPS C 1.00 1.01 56340-S9000 9201', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.03 99211-S8100 190125', b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.05 99211-S8100 190909', b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.07 99211-S8100 200422', b'\xf1\x00LX2 MFC AT USA LHD 1.00 1.08 99211-S8100 200903', b'\xf1\x00ON MFC AT USA LHD 1.00 1.01 99211-S9100 181105', b'\xf1\x00ON MFC AT USA LHD 1.00 1.03 99211-S9100 200720', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x00bcsh8p54 U872\x00\x00\x00\x00\x00\x00TON4G38NB1\x96z28', b'\xf1\x00bcsh8p54 U903\x00\x00\x00\x00\x00\x00TON4G38NB2[v\\\xb6', b'\xf1\x87LBLUFN650868KF36\xa9\x98\x89\x88\xa8\x88\x88\x88h\x99\xa6\x89fw\x86gw\x88\x97x\xaa\x7f\xf6\xff\xbb\xbb\x8f\xff+\x82\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8', b'\xf1\x87LBLUFN655162KF36\x98\x88\x88\x88\x98\x88\x88\x88x\x99\xa7\x89x\x99\xa7\x89x\x99\x97\x89g\x7f\xf7\xffwU_\xff\xe9!\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8', b'\xf1\x87LBLUFN731381KF36\xb9\x99\x89\x98\x98\x88\x88\x88\x89\x99\xa8\x99\x88\x99\xa8\x89\x88\x88\x98\x88V\177\xf6\xff\x99w\x8f\xff\xad\xd8\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\000bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8', b'\xf1\x87LDKVBN382172KF26\x98\x88\x88\x88\xa8\x88\x88\x88x\x99\xa7\x89\x87\x88\x98x\x98\x99\xa9\x89\xa5_\xf6\xffDDO\xff\xcd\x16\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', b'\xf1\x87LDKVBN424201KF26\xba\xaa\x9a\xa9\x99\x99\x89\x98\x89\x99\xa8\x99\x88\x99\x98\x89\x88\x99\xa8\x89v\x7f\xf7\xffwf_\xffq\xa6\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', b'\xf1\x87LDKVBN540766KF37\x87wgv\x87w\x87xx\x99\x97\x89v\x88\x97h\x88\x88\x88\x88x\x7f\xf6\xffvUo\xff\xd3\x01\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', b'\xf1\x87LDLVBN560098KF26\x86fff\x87vgfg\x88\x96xfw\x86gfw\x86g\x95\xf6\xffeU_\xff\x92c\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB2\xafL]\xe7', b'\xf1\x87LDLVBN645817KF37\x87www\x98\x87xwx\x99\x97\x89\x99\x99\x99\x99g\x88\x96x\xb6_\xf7\xff\x98fo\xff\xe2\x86\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN662115KF37\x98\x88\x88\x88\xa8\x88\x88\x88x\x99\x97\x89x\x99\xa7\x89\x88\x99\xa8\x89\x88\x7f\xf7\xfffD_\xff\xdc\x84\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN667933KF37\xb9\x99\x89\x98\xb9\x99\x99\x99x\x88\x87\x88w\x88\x87x\x88\x88\x98\x88\xcbo\xf7\xffe3/\xffQ!\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN673087KF37\x97www\x86fvgx\x99\x97\x89\x99\xaa\xa9\x9ag\x88\x86x\xe9_\xf8\xff\x98w\x7f\xff"\xad\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN681363KF37\x98\x88\x88\x88\x97x\x87\x88y\xaa\xa7\x9a\x88\x88\x98\x88\x88\x88\x88\x88vo\xf6\xffvD\x7f\xff%v\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN713890KF26\xb9\x99\x89\x98\xa9\x99\x99\x99x\x99\x97\x89\x88\x99\xa8\x89\x88\x99\xb8\x89Do\xf7\xff\xa9\x88o\xffs\r\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN733215KF37\x99\x98y\x87\x97wwwi\x99\xa6\x99x\x99\xa7\x89V\x88\x95h\x86o\xf7\xffeDO\xff\x12\xe7\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN750044KF37\xca\xa9\x8a\x98\xa7wwwy\xaa\xb7\x9ag\x88\x96x\x88\x99\xa8\x89\xb9\x7f\xf6\xff\xa8w\x7f\xff\xbe\xde\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN752612KF37\xba\xaa\x8a\xa8\x87w\x87xy\xaa\xa7\x9a\x88\x99\x98\x89x\x88\x97\x88\x96o\xf6\xffvU_\xffh\x1b\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDLVBN755553KF37\x87xw\x87\x97w\x87xy\x99\xa7\x99\x99\x99\xa9\x99Vw\x95gwo\xf6\xffwUO\xff\xb5T\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX4G38NB3X\xa8\xc08', b'\xf1\x87LDMVBN778156KF37\x87vWe\xa9\x99\x99\x99y\x99\xb7\x99\x99\x99\x99\x99x\x99\x97\x89\xa8\x7f\xf8\xffwf\x7f\xff\x82_\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', b'\xf1\x87LDMVBN780576KF37\x98\x87hv\x97x\x97\x89x\x99\xa7\x89\x88\x99\x98\x89w\x88\x97x\x98\x7f\xf7\xff\xba\x88\x8f\xff\x1e0\xf1\x81U922\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U922\x00\x00\x00\x00\x00\x00SLX4G38NB4\xd6\xe8\xd7\xa6', b"\xf1\x87LBLUFN622950KF36\xa8\x88\x88\x88\x87w\x87xh\x99\x96\x89\x88\x99\x98\x89\x88\x99\x98\x89\x87o\xf6\xff\x98\x88o\xffx'\xf1\x81U891\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 U891\x00\x00\x00\x00\x00\x00SLX2G38NB3\xd1\xc3\xf8\xa8", ], }, CAR.VELOSTER: { (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00JS__ SCC H-CUP 1.00 1.02 95650-J3200 ', b'\xf1\x00JS__ SCC HNCUP 1.00 1.02 95650-J3100 ', ], (Ecu.esp, 0x7d1, None): [b'\xf1\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x01TJS-JNU06F200H0A', b'\x01TJS-JDK06F200H0A', ], (Ecu.eps, 0x7d4, None): [b'\xf1\x00JSL MDPS C 1.00 1.03 56340-J3000 8308', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00JS LKAS AT USA LHD 1.00 1.02 95740-J3000 K32', b'\xf1\x00JS LKAS AT KOR LHD 1.00 1.03 95740-J3000 K33', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJS0T16NS1\xba\x02\xb8\x80', b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJS0T16NS1\x00\x00\x00\x00', b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJS0T16KS2\016\xba\036\xa2', ], }, CAR.GENESIS_G70: { (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00IK__ SCC F-CUP 1.00 1.02 96400-G9100 \xf1\xa01.02', ], (Ecu.engine, 0x7e0, None): [b'\xf1\x81640F0051\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7d4, None): [b'\xf1\x00IK MDPS R 1.00 1.06 57700-G9420 4I4VL106', ], (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00IK MFC AT USA LHD 1.00 1.01 95740-G9000 170920', ], (Ecu.transmission, 0x7e1, None): [b'\xf1\x87VDJLT17895112DN4\x88fVf\x99\x88\x88\x88\x87fVe\x88vhwwUFU\x97eFex\x99\xff\xb7\x82\xf1\x81E25\x00\x00\x00\x00\x00\x00\x00\xf1\x00bcsh8p54 E25\x00\x00\x00\x00\x00\x00\x00SIK0T33NB2\x11\x1am\xda', ], }, CAR.KONA: { (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00OS__ SCC F-CUP 1.00 1.00 95655-J9200 \xf1\xa01.00', ], (Ecu.esp, 0x7d1, None): [b'\xf1\x816V5RAK00018.ELF\xf1\x00\x00\x00\x00\x00\x00\x00\xf1\xa01.05', ], (Ecu.engine, 0x7e0, None): [b'"\x01TOS-0NU06F301J02', ], (Ecu.eps, 0x7d4, None): [b'\xf1\x00OS MDPS C 1.00 1.05 56310J9030\x00 4OSDC105', ], (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00OS9 LKAS AT USA LHD 1.00 1.00 95740-J9300 g21', ], (Ecu.transmission, 0x7e1, None): [b'\xf1\x816U2VE051\x00\x00\xf1\x006U2V0_C2\x00\x006U2VE051\x00\x00DOS4T16NS3\x00\x00\x00\x00', ], }, CAR.KIA_CEED: { (Ecu.fwdRadar, 0x7D0, None): [b'\xf1\000CD__ SCC F-CUP 1.00 1.02 99110-J7000 ', ], (Ecu.esp, 0x7D4, None): [b'\xf1\000CD MDPS C 1.00 1.06 56310-XX000 4CDEC106', ], (Ecu.fwdCamera, 0x7C4, None): [b'\xf1\000CD LKAS AT EUR LHD 1.00 1.01 99211-J7000 B40', ], (Ecu.engine, 0x7E0, None): [b'\001TCD-JECU4F202H0K', ], (Ecu.transmission, 0x7E1, None): [b'\xf1\x816U2V7051\000\000\xf1\0006U2V0_C2\000\0006U2V7051\000\000DCD0T14US1\000\000\000\000', ], (Ecu.esp, 0x7D1, None): [b'\xf1\000CD ESC \003 102\030\b\005 58920-J7350', ], }, CAR.KIA_FORTE: { (Ecu.eps, 0x7D4, None): [ b'\xf1\x00BD MDPS C 1.00 1.08 56310M6300\x00 4BDDC108', ], (Ecu.fwdCamera, 0x7C4, None): [ b'\xf1\x00BD LKAS AT USA LHD 1.00 1.04 95740-M6000 J33', ], (Ecu.fwdRadar, 0x7D0, None): [ b'\xf1\x00BD__ SCC H-CUP 1.00 1.02 99110-M6000 \xf1\xa01.02', ], (Ecu.engine, 0x7e0, None): [ b'\x01TBDM1NU06F200H01', ], (Ecu.esp, 0x7d1, None): [ b'\xf1\x816VGRAH00018.ELF\xf1\x00\x00\x00\x00\x00\x00\x00\xf1\xa01.04', ], (Ecu.transmission, 0x7e1, None): [ b"\xf1\x816U2VC051\x00\x00\xf1\x006U2V0_C2\x00\x006U2VC051\x00\x00DBD0T16SS0\xcf\x1e'\xc3", ], }, CAR.KONA_EV: { (Ecu.esp, 0x7D1, None): [ b'\xf1\x00OS IEB \r 105\x18\t\x18 58520-K4000\xf1\xa01.05', b'\xf1\x00OS IEB \x01 212 \x11\x13 58520-K4000\xf1\xa02.12', b'\xf1\x00OS IEB \x02 212 \x11\x13 58520-K4000\xf1\xa02.12', b'\xf1\x00OS IEB \x03 210 \x02\x14 58520-K4000\xf1\xa02.10', b'\xf1\x00OS IEB \x03 212 \x11\x13 58520-K4000\xf1\xa02.12', ], (Ecu.fwdCamera, 0x7C4, None): [ b'\xf1\x00OE2 LKAS AT EUR LHD 1.00 1.00 95740-K4200 200', b'\xf1\x00OSE LKAS AT EUR LHD 1.00 1.00 95740-K4100 W40', b'\xf1\x00OSE LKAS AT EUR RHD 1.00 1.00 95740-K4100 W40', b'\xf1\x00OSE LKAS AT KOR LHD 1.00 1.00 95740-K4100 W40', b'\xf1\x00OSE LKAS AT USA LHD 1.00 1.00 95740-K4300 W50', ], (Ecu.eps, 0x7D4, None): [ b'\xf1\x00OS MDPS C 1.00 1.03 56310/K4550 4OEDC103', b'\xf1\x00OS MDPS C 1.00 1.04 56310K4000\x00 4OEDC104', b'\xf1\x00OS MDPS C 1.00 1.04 56310K4050\x00 4OEDC104', ], (Ecu.fwdRadar, 0x7D0, None): [ b'\xf1\x00OSev SCC F-CUP 1.00 1.00 99110-K4000 \xf1\xa01.00', b'\xf1\x00OSev SCC F-CUP 1.00 1.00 99110-K4100 \xf1\xa01.00', b'\xf1\x00OSev SCC F-CUP 1.00 1.01 99110-K4000 \xf1\xa01.01', b'\xf1\x00OSev SCC FNCUP 1.00 1.01 99110-K4000 \xf1\xa01.01', ], }, CAR.KIA_NIRO_EV: { (Ecu.fwdRadar, 0x7D0, None): [ b'\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4000 ', b'\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4000 \xf1\xa01.00', b'\xf1\x00DEev SCC F-CUP 1.00 1.03 96400-Q4100 \xf1\xa01.03', b'\xf1\x00OSev SCC F-CUP 1.00 1.01 99110-K4000 \xf1\xa01.01', b'\xf1\x8799110Q4000\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4000 \xf1\xa01.00', b'\xf1\x8799110Q4100\xf1\x00DEev SCC F-CUP 1.00 1.00 99110-Q4100 \xf1\xa01.00', b'\xf1\x8799110Q4500\xf1\000DEev SCC F-CUP 1.00 1.00 99110-Q4500 \xf1\xa01.00', ], (Ecu.esp, 0x7D1, None): [ b'\xf1\x00OS IEB \r 212 \x11\x13 58520-K4000\xf1\xa02.12', b'\xf1\x00OS IEB \r 212 \x11\x13 58520-K4000', b'\xf1\xa01.06', b'\xf1\xa01.07', ], (Ecu.eps, 0x7D4, None): [ b'\xf1\x00DE MDPS C 1.00 1.05 56310Q4000\x00 4DEEC105', b'\xf1\x00DE MDPS C 1.00 1.05 56310Q4100\x00 4DEEC105', b'\xf1\x00OS MDPS C 1.00 1.04 56310K4050\x00 4OEDC104', ], (Ecu.fwdCamera, 0x7C4, None): [ b'\xf1\000DEE MFC AT EUR LHD 1.00 1.00 99211-Q4100 200706', b'\xf1\x00DEE MFC AT EUR LHD 1.00 1.00 99211-Q4000 191211', b'\xf1\x00DEE MFC AT USA LHD 1.00 1.00 99211-Q4000 191211', b'\xf1\x00DEE MFC AT USA LHD 1.00 1.03 95740-Q4000 180821', b'\xf1\x00OSE LKAS AT EUR LHD 1.00 1.00 95740-K4100 W40', ], }, CAR.KIA_NIRO_HEV: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x816H6F4051\000\000\000\000\000\000\000\000', ], (Ecu.transmission, 0x7e1, None): [ b"\xf1\x816U3J2051\000\000\xf1\0006U3H0_C2\000\0006U3J2051\000\000PDE0G16NS2\xf4\'\\\x91", b'\xf1\x816U3J2051\000\000\xf1\0006U3H0_C2\000\0006U3J2051\000\000PDE0G16NS2\000\000\000\000', ], (Ecu.eps, 0x7D4, None): [ b'\xf1\000DE MDPS C 1.00 1.09 56310G5301\000 4DEHC109', ], (Ecu.fwdCamera, 0x7C4, None): [ b'\xf1\000DEP MFC AT USA LHD 1.00 1.01 95740-G5010 170424', ], (Ecu.fwdRadar, 0x7D0, None): [ b'\xf1\000DEhe SCC H-CUP 1.01 1.02 96400-G5100 ', ], }, CAR.KIA_NIRO_HEV_2021: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x816H6G5051\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HDE0G16NL3\x00\x00\x00\x00', b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HDE0G16NL3\xb9\xd3\xfaW', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00DE MDPS C 1.00 1.01 56310G5520\x00 4DEPC101', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00DEH MFC AT USA LHD 1.00 1.07 99211-G5000 201221', ], (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00DEhe SCC FHCUP 1.00 1.00 99110-G5600 ', ], }, CAR.KIA_SELTOS: { (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x8799110Q5100\xf1\000SP2_ SCC FHCUP 1.01 1.05 99110-Q5100 \xf1\xa01.05',], (Ecu.esp, 0x7d1, None): [ b'\xf1\x8758910-Q5450\xf1\000SP ESC \a 101\031\t\005 58910-Q5450\xf1\xa01.01', b'\xf1\x8758910-Q5450\xf1\000SP ESC \t 101\031\t\005 58910-Q5450\xf1\xa01.01', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x81616D2051\000\000\000\000\000\000\000\000', b'\xf1\x81616D5051\000\000\000\000\000\000\000\000', b'\001TSP2KNL06F100J0K', b'\001TSP2KNL06F200J0K', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\000SP2 MDPS C 1.00 1.04 56300Q5200 ', b'\xf1\000SP2 MDPS C 1.01 1.05 56300Q5200 ', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\000SP2 MFC AT USA LHD 1.00 1.04 99210-Q5000 191114', b'\xf1\000SP2 MFC AT USA LHD 1.00 1.05 99210-Q5000 201012', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x87CZLUB49370612JF7h\xa8y\x87\x99\xa7hv\x99\x97fv\x88\x87x\x89x\x96O\xff\x88\xff\xff\xff.@\xf1\x816V2C2051\000\000\xf1\0006V2B0_C2\000\0006V2C2051\000\000CSP4N20NS3\000\000\000\000', b'\xf1\x87954A22D200\xf1\x81T01950A1 \xf1\000T0190XBL T01950A1 DSP2T16X4X950NS6\xd30\xa5\xb9', b'\xf1\x87954A22D200\xf1\x81T01950A1 \xf1\000T0190XBL T01950A1 DSP2T16X4X950NS8\r\xfe\x9c\x8b', ], }, CAR.KIA_OPTIMA: { (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00JF__ SCC F-CUP 1.00 1.00 96400-D4110 '], (Ecu.esp, 0x7d1, None): [b'\xf1\x00JF ESC \v 11 \x18\x030 58920-D5180',], (Ecu.engine, 0x7e0, None): [ b'\x01TJFAJNU06F201H03', b'\xf1\x89F1JF600AISEIU702\xf1\x82F1JF600AISEIU702', ], (Ecu.eps, 0x7d4, None): [b'\xf1\x00TM MDPS C 1.00 1.00 56340-S2000 8409'], (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00JFA LKAS AT USA LHD 1.00 1.02 95895-D5000 h31'], (Ecu.transmission, 0x7e1, None): [b'\xf1\x816U2V8051\x00\x00\xf1\x006U2V0_C2\x00\x006U2V8051\x00\x00DJF0T16NL0\t\xd2GW'], }, CAR.ELANTRA_2021: { (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x00CN7_ SCC FHCUP 1.00 1.01 99110-AA000 '], (Ecu.eps, 0x7d4, None): [ b'\xf1\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf1\x00CN7 MDPS C 1.00 1.06 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 4CNDC106\xf1\xa01.06', b'\xf1\x8756310AA050\x00\xf1\x00CN7 MDPS C 1.00 1.06 56310AA050\x00 4CNDC106\xf1\xa01.06', ], (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\x00CN7 MFC AT USA LHD 1.00 1.00 99210-AB000 200819'], (Ecu.esp, 0x7d1, None): [ b'\xf1\x8758910-AB800\xf1\x00CN ESC \t 101 \x10\x03 58910-AB800\xf1\xa01.01', b'\xf1\x00CN ESC \t 101 \x10\x03 58910-AB800', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x00HT6WA280BLHT6VA640A1CCN0N20NS5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'\xf1\x00HT6WA280BLHT6VA640A1CCN0N20NS5\x00\x00\x00\x00\x00\x00\xe8\xba\xce\xfa', b'\xf1\x87CXMQFM2135005JB2E\xb9\x89\x98W\xa9y\x97h\xa9\x98\x99wxvwh\x87\177\xffx\xff\xff\xff,,\xf1\x89HT6VA640A1\xf1\x82CCN0N20NS5\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [b'\xf1\x82CNCWD0AMFCXCSFFA'], }, CAR.ELANTRA_HEV_2021: { (Ecu.fwdCamera, 0x7c4, None) : [ b'\xf1\000CN7HMFC AT USA LHD 1.00 1.03 99210-AA000 200819' ], (Ecu.fwdRadar, 0x7d0, None) : [ b'\xf1\000CNhe SCC FHCUP 1.00 1.01 99110-BY000 ' ], (Ecu.eps, 0x7d4, None) :[ b'\xf1\x8756310/BY050\xf1\000CN7 MDPS C 1.00 1.02 56310/BY050 4CNHC102\xf1\xa01.02' ], (Ecu.transmission, 0x7e1, None) :[ b'\xf1\x816U3K3051\000\000\xf1\0006U3L0_C2\000\0006U3K3051\000\000HCN0G16NS0\xb9?A\xaa', b'\xf1\x816U3K3051\000\000\xf1\0006U3L0_C2\000\0006U3K3051\000\000HCN0G16NS0\000\000\000\000' ], (Ecu.engine, 0x7e0, None) : [ b'\xf1\x816H6G5051\000\000\000\000\000\000\000\000' ] }, CAR.KONA_HEV: { (Ecu.esp, 0x7d1, None): [ b'\xf1\x00OS IEB \x01 104 \x11 58520-CM000\xf1\xa01.04', ], (Ecu.fwdRadar, 0x7d0, None): [ b'\xf1\x00OShe SCC FNCUP 1.00 1.01 99110-CM000 \xf1\xa01.01', ], (Ecu.eps, 0x7d4, None): [ b'\xf1\x00OS MDPS C 1.00 1.00 56310CM030\x00 4OHDC100', ], (Ecu.fwdCamera, 0x7c4, None): [ b'\xf1\x00OSH LKAS AT KOR LHD 1.00 1.01 95740-CM000 l31', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x816U3J9051\x00\x00\xf1\x006U3H1_C2\x00\x006U3J9051\x00\x00HOS0G16DS1\x16\xc7\xb0\xd9', ], (Ecu.engine, 0x7e0, None): [ b'\xf1\x816H6F6051\x00\x00\x00\x00\x00\x00\x00\x00', ] }, CAR.SONATA_HYBRID: { (Ecu.fwdRadar, 0x7d0, None): [b'\xf1\000DNhe SCC FHCUP 1.00 1.02 99110-L5000 ',], (Ecu.eps, 0x7d4, None): [b'\xf1\x8756310-L5500\xf1\000DN8 MDPS C 1.00 1.02 56310-L5500 4DNHC102\xf1\xa01.02',], (Ecu.fwdCamera, 0x7c4, None): [b'\xf1\000DN8HMFC AT USA LHD 1.00 1.04 99211-L1000 191016',], (Ecu.transmission, 0x7e1, None): [b'\xf1\000PSBG2323 E09\000\000\000\000\000\000\000TDN2H20SA5\x97R\x88\x9e',], (Ecu.engine, 0x7e0, None): [b'\xf1\x87391162J012\xf1\xa0000R',], }, } CHECKSUM = { "crc8": [CAR.SANTA_FE, CAR.SONATA, CAR.PALISADE, CAR.KIA_SELTOS, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.SONATA_HYBRID], "6B": [CAR.KIA_SORENTO, CAR.HYUNDAI_GENESIS], } FEATURES = { # which message has the gear "use_cluster_gears": set([CAR.ELANTRA, CAR.ELANTRA_GT_I30, CAR.KONA]), "use_tcu_gears": set([CAR.KIA_OPTIMA, CAR.SONATA_LF, CAR.VELOSTER]), "use_elect_gears": set([CAR.KIA_NIRO_EV, CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_HEV_2021, CAR.KIA_OPTIMA_H, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021,CAR.SONATA_HYBRID, CAR.KONA_HEV]), # these cars use the FCA11 message for the AEB and FCW signals, all others use SCC12 "use_fca": set([CAR.SONATA, CAR.SONATA_HYBRID, CAR.ELANTRA, CAR.ELANTRA_2021, CAR.ELANTRA_HEV_2021, CAR.ELANTRA_GT_I30, CAR.KIA_STINGER, CAR.IONIQ, CAR.IONIQ_EV_2020, CAR.IONIQ_PHEV, CAR.KONA_EV, CAR.KIA_FORTE, CAR.KIA_NIRO_EV, CAR.PALISADE, CAR.GENESIS_G70, CAR.KONA, CAR.SANTA_FE, CAR.KIA_SELTOS, CAR.KONA_HEV]), } HYBRID_CAR = set([CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021, CAR.KIA_NIRO_HEV, CAR.KIA_NIRO_HEV_2021, CAR.SONATA_HYBRID, CAR.KONA_HEV]) # these cars use a different gas signal EV_CAR = set([CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_NIRO_EV]) DBC = { CAR.ELANTRA: dbc_dict('hyundai_kia_generic', None), CAR.ELANTRA_2021: dbc_dict('hyundai_kia_generic', None), CAR.ELANTRA_HEV_2021: dbc_dict('hyundai_kia_generic', None), CAR.ELANTRA_GT_I30: dbc_dict('hyundai_kia_generic', None), CAR.GENESIS_G70: dbc_dict('hyundai_kia_generic', None), CAR.GENESIS_G80: dbc_dict('hyundai_kia_generic', None), CAR.GENESIS_G90: dbc_dict('hyundai_kia_generic', None), CAR.HYUNDAI_GENESIS: dbc_dict('hyundai_kia_generic', None), CAR.IONIQ_PHEV: dbc_dict('hyundai_kia_generic', None), CAR.IONIQ_EV_2020: dbc_dict('hyundai_kia_generic', None), CAR.IONIQ_EV_LTD: dbc_dict('hyundai_kia_generic', None), CAR.IONIQ: dbc_dict('hyundai_kia_generic', None), CAR.KIA_FORTE: dbc_dict('hyundai_kia_generic', None), CAR.KIA_NIRO_EV: dbc_dict('hyundai_kia_generic', None), CAR.KIA_NIRO_HEV: dbc_dict('hyundai_kia_generic', None), CAR.KIA_NIRO_HEV_2021: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA: dbc_dict('hyundai_kia_generic', None), CAR.KIA_OPTIMA_H: dbc_dict('hyundai_kia_generic', None), CAR.KIA_SELTOS: dbc_dict('hyundai_kia_generic', None), CAR.KIA_SORENTO: dbc_dict('hyundai_kia_generic', None), CAR.KIA_STINGER: dbc_dict('hyundai_kia_generic', None), CAR.KONA: dbc_dict('hyundai_kia_generic', None), CAR.KONA_EV: dbc_dict('hyundai_kia_generic', None), CAR.KONA_HEV: dbc_dict('hyundai_kia_generic', None), CAR.SANTA_FE: dbc_dict('hyundai_kia_generic', None), CAR.SONATA: dbc_dict('hyundai_kia_generic', None), CAR.SONATA_LF: dbc_dict('hyundai_kia_generic', None), CAR.PALISADE: dbc_dict('hyundai_kia_generic', None), CAR.VELOSTER: dbc_dict('hyundai_kia_generic', None), CAR.KIA_CEED: dbc_dict('hyundai_kia_generic', None), CAR.SONATA_HYBRID: dbc_dict('hyundai_kia_generic', None), } STEER_THRESHOLD = 150 ================================================ FILE: selfdrive/car/interfaces.py ================================================ import os import time from typing import Dict from cereal import car from common.kalman.simple_kalman import KF1D from common.realtime import DT_CTRL from selfdrive.car import gen_empty_fingerprint from selfdrive.config import Conversions as CV from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX from selfdrive.controls.lib.events import Events from selfdrive.controls.lib.vehicle_model import VehicleModel GearShifter = car.CarState.GearShifter EventName = car.CarEvent.EventName # WARNING: this value was determined based on the model's training distribution, # model predictions above this speed can be unpredictable MAX_CTRL_SPEED = (V_CRUISE_MAX + 4) * CV.KPH_TO_MS # 135 + 4 = 86 mph ACCEL_MAX = 2.0 ACCEL_MIN = -3.5 # generic car and radar interfaces class CarInterfaceBase(): def __init__(self, CP, CarController, CarState): self.CP = CP self.VM = VehicleModel(CP) self.frame = 0 self.steer_warning = 0 self.steering_unpressed = 0 self.low_speed_alert = False self.dragonconf = None if CarState is not None: self.CS = CarState(CP) self.cp = self.CS.get_can_parser(CP) self.cp_cam = self.CS.get_cam_can_parser(CP) self.cp_body = self.CS.get_body_can_parser(CP) self.CC = None if CarController is not None: self.CC = CarController(self.cp.dbc_name, CP, self.VM) self.dragonconf = None @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): return ACCEL_MIN, ACCEL_MAX @staticmethod def calc_accel_override(a_ego, a_target, v_ego, v_target): return 1. @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): raise NotImplementedError @staticmethod def init(CP, logcan, sendcan): pass # returns a set of default params to avoid repetition in car specific params @staticmethod def get_std_params(candidate, fingerprint): ret = car.CarParams.new_message() ret.carFingerprint = candidate # standard ALC params ret.steerControlType = car.CarParams.SteerControlType.torque ret.steerMaxBP = [0.] ret.steerMaxV = [1.] ret.minSteerSpeed = 0. ret.pcmCruise = True # openpilot's state is tied to the PCM's cruise state on most cars ret.minEnableSpeed = -1. # enable is done by stock ACC, so ignore this ret.steerRatioRear = 0. # no rear steering, at least on the listed cars aboveA ret.openpilotLongitudinalControl = False ret.startAccel = 0.0 ret.minSpeedCan = 0.3 ret.stoppingDecelRate = 0.8 # brake_travel/s while trying to stop ret.startingAccelRate = 3.2 # brake_travel/s while releasing on restart ret.stoppingControl = True ret.longitudinalTuning.deadzoneBP = [0.] ret.longitudinalTuning.deadzoneV = [0.] ret.longitudinalTuning.kpBP = [0.] ret.longitudinalTuning.kpV = [1.] ret.longitudinalTuning.kiBP = [0.] ret.longitudinalTuning.kiV = [1.] ret.longitudinalActuatorDelay = 0.15 return ret # returns a car.CarState, pass in car.CarControl def update(self, c, can_strings, dragonconf): raise NotImplementedError # return sendcan, pass in a car.CarControl def apply(self, c): raise NotImplementedError def create_common_events(self, cs_out, extra_gears=None, gas_resume_speed=-1, pcm_enable=True): events = Events() if cs_out.doorOpen: events.add(EventName.doorOpen) if cs_out.seatbeltUnlatched: events.add(EventName.seatbeltNotLatched) if self.dragonconf.dpGearCheck and cs_out.gearShifter not in (GearShifter.drive, GearShifter.sport, GearShifter.eco, GearShifter.low) and (extra_gears is None or cs_out.gearShifter not in extra_gears): events.add(EventName.wrongGear) if cs_out.gearShifter == GearShifter.reverse: events.add(EventName.reverseGear) if not cs_out.cruiseState.available and not self.dragonconf.dpAtl: events.add(EventName.wrongCarMode) if cs_out.espDisabled: events.add(EventName.espDisabled) if cs_out.gasPressed and not self.dragonconf.dpAllowGas: events.add(EventName.gasPressed) if cs_out.stockFcw: events.add(EventName.stockFcw) if cs_out.stockAeb: events.add(EventName.stockAeb) if cs_out.vEgo > MAX_CTRL_SPEED and self.dragonconf.dpSpeedCheck: events.add(EventName.speedTooHigh) if cs_out.cruiseState.nonAdaptive and not self.dragonconf.dpAtl: events.add(EventName.wrongCruiseMode) self.steer_warning = self.steer_warning + 1 if cs_out.steerWarning else 0 self.steering_unpressed = 0 if cs_out.steeringPressed else self.steering_unpressed + 1 # Handle permanent and temporary steering faults if (cs_out.leftBlinker or cs_out.rightBlinker) and self.dragonconf.dpLateralMode == 0: events.add(EventName.manualSteeringRequiredBlinkersOn) elif cs_out.steerError: events.add(EventName.steerUnavailable) elif cs_out.steerWarning: # only escalate to the harsher alert after the condition has # persisted for 0.5s and we're certain that the user isn't overriding if self.steering_unpressed > int(0.5/DT_CTRL) and self.steer_warning > int(0.5/DT_CTRL): events.add(EventName.steerTempUnavailable) else: events.add(EventName.steerTempUnavailableSilent) # Disable on rising edge of gas or brake. Also disable on brake when speed > 0. # Optionally allow to press gas at zero speed to resume. # e.g. Chrysler does not spam the resume button yet, so resuming with gas is handy. FIXME! if self.dragonconf.dpAtl: pass elif self.dragonconf.dpAllowGas: if cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill): events.add(EventName.pedalPressed) else: if (cs_out.gasPressed and (not self.CS.out.gasPressed) and cs_out.vEgo > gas_resume_speed) or \ (cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)): events.add(EventName.pedalPressed) # we engage when pcm is active (rising edge) if pcm_enable: if cs_out.cruiseState.enabled and not self.CS.out.cruiseState.enabled: events.add(EventName.pcmEnable) elif not cs_out.cruiseState.enabled: events.add(EventName.pcmDisable) return events class RadarInterfaceBase(): def __init__(self, CP): self.pts = {} self.delay = 0 self.radar_ts = CP.radarTimeStep self.no_radar_sleep = 'NO_RADAR_SLEEP' in os.environ def update(self, can_strings): ret = car.RadarData.new_message() if not self.no_radar_sleep: time.sleep(self.radar_ts) # radard runs on RI updates return ret class CarStateBase: def __init__(self, CP): self.CP = CP self.car_fingerprint = CP.carFingerprint self.out = car.CarState.new_message() self.cruise_buttons = 0 self.left_blinker_cnt = 0 self.right_blinker_cnt = 0 self.left_blinker_prev = False self.right_blinker_prev = False # Q = np.matrix([[10.0, 0.0], [0.0, 100.0]]) # R = 1e3 self.v_ego_kf = KF1D(x0=[[0.0], [0.0]], A=[[1.0, DT_CTRL], [0.0, 1.0]], C=[1.0, 0.0], K=[[0.12287673], [0.29666309]]) def update_speed_kf(self, v_ego_raw): if abs(v_ego_raw - self.v_ego_kf.x[0][0]) > 2.0: # Prevent large accelerations when car starts at non zero speed self.v_ego_kf.x = [[v_ego_raw], [0.0]] v_ego_x = self.v_ego_kf.update(v_ego_raw) return float(v_ego_x[0]), float(v_ego_x[1]) def update_blinker_from_lamp(self, blinker_time: int, left_blinker_lamp: bool, right_blinker_lamp: bool): """Update blinkers from lights. Enable output when light was seen within the last `blinker_time` iterations""" # TODO: Handle case when switching direction. Now both blinkers can be on at the same time self.left_blinker_cnt = blinker_time if left_blinker_lamp else max(self.left_blinker_cnt - 1, 0) self.right_blinker_cnt = blinker_time if right_blinker_lamp else max(self.right_blinker_cnt - 1, 0) return self.left_blinker_cnt > 0, self.right_blinker_cnt > 0 def update_blinker_from_stalk(self, blinker_time: int, left_blinker_stalk: bool, right_blinker_stalk: bool): """Update blinkers from stalk position. When stalk is seen the blinker will be on for at least blinker_time, or until the stalk is turned off, whichever is longer. If the opposite stalk direction is seen the blinker is forced to the other side. On a rising edge of the stalk the timeout is reset.""" if left_blinker_stalk: self.right_blinker_cnt = 0 if not self.left_blinker_prev: self.left_blinker_cnt = blinker_time if right_blinker_stalk: self.left_blinker_cnt = 0 if not self.right_blinker_prev: self.right_blinker_cnt = blinker_time self.left_blinker_cnt = max(self.left_blinker_cnt - 1, 0) self.right_blinker_cnt = max(self.right_blinker_cnt - 1, 0) self.left_blinker_prev = left_blinker_stalk self.right_blinker_prev = right_blinker_stalk return bool(left_blinker_stalk or self.left_blinker_cnt > 0), bool(right_blinker_stalk or self.right_blinker_cnt > 0) @staticmethod def parse_gear_shifter(gear: str) -> car.CarState.GearShifter: d: Dict[str, car.CarState.GearShifter] = { 'P': GearShifter.park, 'R': GearShifter.reverse, 'N': GearShifter.neutral, 'E': GearShifter.eco, 'T': GearShifter.manumatic, 'D': GearShifter.drive, 'S': GearShifter.sport, 'L': GearShifter.low, 'B': GearShifter.brake } return d.get(gear, GearShifter.unknown) @staticmethod def get_cam_can_parser(CP): return None @staticmethod def get_body_can_parser(CP): return None ================================================ FILE: selfdrive/car/isotp_parallel_query.py ================================================ import time from collections import defaultdict from functools import partial from typing import Optional import cereal.messaging as messaging from selfdrive.swaglog import cloudlog from selfdrive.boardd.boardd import can_list_to_can_capnp from panda.python.uds import CanClient, IsoTpMessage, FUNCTIONAL_ADDRS, get_rx_addr_for_tx_addr class IsoTpParallelQuery: def __init__(self, sendcan, logcan, bus, addrs, request, response, response_offset=0x8, functional_addr=False, debug=False): self.sendcan = sendcan self.logcan = logcan self.bus = bus self.request = request self.response = response self.debug = debug self.functional_addr = functional_addr self.real_addrs = [] for a in addrs: if isinstance(a, tuple): self.real_addrs.append(a) else: self.real_addrs.append((a, None)) self.msg_addrs = {tx_addr: get_rx_addr_for_tx_addr(tx_addr[0], rx_offset=response_offset) for tx_addr in self.real_addrs} self.msg_buffer = defaultdict(list) def rx(self): """Drain can socket and sort messages into buffers based on address""" can_packets = messaging.drain_sock(self.logcan, wait_for_one=True) for packet in can_packets: for msg in packet.can: if msg.src == self.bus: if self.functional_addr: if (0x7E8 <= msg.address <= 0x7EF) or (0x18DAF100 <= msg.address <= 0x18DAF1FF): fn_addr = next(a for a in FUNCTIONAL_ADDRS if msg.address - a <= 32) self.msg_buffer[fn_addr].append((msg.address, msg.busTime, msg.dat, msg.src)) elif msg.address in self.msg_addrs.values(): self.msg_buffer[msg.address].append((msg.address, msg.busTime, msg.dat, msg.src)) def _can_tx(self, tx_addr, dat, bus): """Helper function to send single message""" msg = [tx_addr, 0, dat, bus] self.sendcan.send(can_list_to_can_capnp([msg], msgtype='sendcan')) def _can_rx(self, addr, sub_addr=None): """Helper function to retrieve message with specified address and subadress from buffer""" keep_msgs = [] if sub_addr is None: msgs = self.msg_buffer[addr] else: # Filter based on subadress msgs = [] for m in self.msg_buffer[addr]: first_byte = m[2][0] if first_byte == sub_addr: msgs.append(m) else: keep_msgs.append(m) self.msg_buffer[addr] = keep_msgs return msgs def _drain_rx(self): messaging.drain_sock(self.logcan) self.msg_buffer = defaultdict(list) def get_data(self, timeout): self._drain_rx() # Create message objects msgs = {} request_counter = {} request_done = {} for tx_addr, rx_addr in self.msg_addrs.items(): # rx_addr not set when using functional tx addr id_addr = rx_addr or tx_addr[0] sub_addr = tx_addr[1] can_client = CanClient(self._can_tx, partial(self._can_rx, id_addr, sub_addr=sub_addr), tx_addr[0], rx_addr, self.bus, sub_addr=sub_addr, debug=self.debug) max_len = 8 if sub_addr is None else 7 msg = IsoTpMessage(can_client, timeout=0, max_len=max_len, debug=self.debug) msg.send(self.request[0]) msgs[tx_addr] = msg request_counter[tx_addr] = 0 request_done[tx_addr] = False results = {} start_time = time.time() while True: self.rx() if all(request_done.values()): break for tx_addr, msg in msgs.items(): dat: Optional[bytes] = msg.recv() if not dat: continue counter = request_counter[tx_addr] expected_response = self.response[counter] response_valid = dat[:len(expected_response)] == expected_response if response_valid: if counter + 1 < len(self.request): msg.send(self.request[counter + 1]) request_counter[tx_addr] += 1 else: results[tx_addr] = dat[len(expected_response):] request_done[tx_addr] = True else: request_done[tx_addr] = True cloudlog.warning(f"iso-tp query bad response: 0x{dat.hex()}") if time.time() - start_time > timeout: break return results ================================================ FILE: selfdrive/car/mazda/__init__.py ================================================ ================================================ FILE: selfdrive/car/mazda/carcontroller.py ================================================ from selfdrive.car.mazda import mazdacan from selfdrive.car.mazda.values import CarControllerParams, Buttons from opendbc.can.packer import CANPacker from selfdrive.car import apply_std_steer_torque_limits from common.dp_common import common_controller_ctrl class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.apply_steer_last = 0 self.packer = CANPacker(dbc_name) self.steer_rate_limited = False def update(self, enabled, CS, frame, actuators, dragonconf): """ Controls thread """ can_sends = [] ### STEER ### if enabled: # calculate steer and also set limits due to driver torque new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX)) apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, CarControllerParams) self.steer_rate_limited = new_steer != apply_steer if CS.out.standstill and frame % 5 == 0: # Mazda Stop and Go requires a RES button (or gas) press if the car stops more than 3 seconds # Send Resume button at 20hz if we're engaged at standstill to support full stop and go! # TODO: improve the resume trigger logic by looking at actual radar data can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, Buttons.RESUME)) else: apply_steer = 0 self.steer_rate_limited = False if CS.out.cruiseState.enabled and frame % 20 == 0: # Cancel Stock ACC if it's enabled while OP is disengaged # Send at a rate of 5hz until we sync with stock ACC state can_sends.append(mazdacan.create_button_cmd(self.packer, CS.CP.carFingerprint, Buttons.CANCEL)) # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on self.apply_steer_last = apply_steer can_sends.append(mazdacan.create_steering_control(self.packer, CS.CP.carFingerprint, frame, apply_steer, CS.cam_lkas)) return can_sends ================================================ FILE: selfdrive/car/mazda/carstate.py ================================================ from cereal import car from selfdrive.config import Conversions as CV from opendbc.can.can_define import CANDefine from opendbc.can.parser import CANParser from selfdrive.car.interfaces import CarStateBase from selfdrive.car.mazda.values import DBC, LKAS_LIMITS, GEN1 class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.shifter_values = can_define.dv["GEAR"]["GEAR"] self.cruise_speed = 0 self.acc_active_last = False self.low_speed_lockout = True self.low_speed_alert = False self.lkas_allowed = False def update(self, cp, cp_cam): ret = car.CarState.new_message() ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]["FL"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]["FR"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]["RL"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]["RR"] * CV.KPH_TO_MS ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) # Match panda speed reading speed_kph = cp.vl["ENGINE_DATA"]["SPEED"] ret.standstill = speed_kph < .1 can_gear = int(cp.vl["GEAR"]["GEAR"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) ret.leftBlinker = cp.vl["BLINK_INFO"]["LEFT_BLINK"] == 1 ret.rightBlinker = cp.vl["BLINK_INFO"]["RIGHT_BLINK"] == 1 ret.steeringAngleDeg = cp.vl["STEER"]["STEER_ANGLE"] ret.steeringTorque = cp.vl["STEER_TORQUE"]["STEER_TORQUE_SENSOR"] ret.steeringPressed = abs(ret.steeringTorque) > LKAS_LIMITS.STEER_THRESHOLD ret.steeringTorqueEps = cp.vl["STEER_TORQUE"]["STEER_TORQUE_MOTOR"] ret.steeringRateDeg = cp.vl["STEER_RATE"]["STEER_ANGLE_RATE"] ret.brakePressed = cp.vl["PEDALS"]["BRAKE_ON"] == 1 ret.brake = cp.vl["BRAKE"]["BRAKE_PRESSURE"] ret.seatbeltUnlatched = cp.vl["SEATBELT"]["DRIVER_SEATBELT"] == 0 ret.doorOpen = any([cp.vl["DOORS"]["FL"], cp.vl["DOORS"]["FR"], cp.vl["DOORS"]["BL"], cp.vl["DOORS"]["BR"]]) ret.gas = cp.vl["ENGINE_DATA"]["PEDAL_GAS"] ret.gasPressed = ret.gas > 0 ret.leftBlindspot = cp.vl["BSM"]["LEFT_BS1"] == 1 ret.rightBlindspot = cp.vl["BSM"]["RIGHT_BS1"] == 1 # LKAS is enabled at 52kph going up and disabled at 45kph going down if speed_kph > LKAS_LIMITS.ENABLE_SPEED: self.lkas_allowed = True elif speed_kph < LKAS_LIMITS.DISABLE_SPEED: self.lkas_allowed = False # if any of the cruize buttons is pressed force state update if any([cp.vl["CRZ_BTNS"]["RES"], cp.vl["CRZ_BTNS"]["SET_P"], cp.vl["CRZ_BTNS"]["SET_M"]]): self.cruise_speed = ret.vEgoRaw ret.cruiseState.available = True ret.cruiseState.enabled = cp.vl["CRZ_CTRL"]["CRZ_ACTIVE"] == 1 # dp ret.cruiseActualEnabled = ret.cruiseState.enabled ret.cruiseState.speed = self.cruise_speed if ret.cruiseState.enabled: if not self.lkas_allowed: if not self.acc_active_last: self.low_speed_lockout = True else: self.low_speed_alert = True else: self.low_speed_lockout = False self.low_speed_alert = False # On if no driver torque the last 5 seconds ret.steerWarning = cp.vl["STEER_RATE"]["HANDS_OFF_5_SECONDS"] == 1 self.acc_active_last = ret.cruiseState.enabled self.cam_lkas = cp_cam.vl["CAM_LKAS"] ret.steerError = cp_cam.vl["CAM_LKAS"]["ERR_BIT_1"] == 1 # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("LEFT_BLINK", "BLINK_INFO", 0), ("RIGHT_BLINK", "BLINK_INFO", 0), ("STEER_ANGLE", "STEER", 0), ("STEER_ANGLE_RATE", "STEER_RATE", 0), ("STEER_TORQUE_SENSOR", "STEER_TORQUE", 0), ("STEER_TORQUE_MOTOR", "STEER_TORQUE", 0), ("FL", "WHEEL_SPEEDS", 0), ("FR", "WHEEL_SPEEDS", 0), ("RL", "WHEEL_SPEEDS", 0), ("RR", "WHEEL_SPEEDS", 0), ] checks = [ # sig_address, frequency ("BLINK_INFO", 10), ("STEER", 67), ("STEER_RATE", 83), ("STEER_TORQUE", 83), ("WHEEL_SPEEDS", 100), ] if CP.carFingerprint in GEN1: signals += [ ("LKAS_BLOCK", "STEER_RATE", 0), ("LKAS_TRACK_STATE", "STEER_RATE", 0), ("HANDS_OFF_5_SECONDS", "STEER_RATE", 0), ("CRZ_ACTIVE", "CRZ_CTRL", 0), ("STANDSTILL", "PEDALS", 0), ("BRAKE_ON", "PEDALS", 0), ("BRAKE_PRESSURE", "BRAKE", 0), ("GEAR", "GEAR", 0), ("DRIVER_SEATBELT", "SEATBELT", 0), ("FL", "DOORS", 0), ("FR", "DOORS", 0), ("BL", "DOORS", 0), ("BR", "DOORS", 0), ("PEDAL_GAS", "ENGINE_DATA", 0), ("SPEED", "ENGINE_DATA", 0), ("RES", "CRZ_BTNS", 0), ("SET_P", "CRZ_BTNS", 0), ("SET_M", "CRZ_BTNS", 0), ("CTR", "CRZ_BTNS", 0), ("LEFT_BS1", "BSM", 0), ("RIGHT_BS1", "BSM", 0), ] checks += [ ("ENGINE_DATA", 100), ("CRZ_CTRL", 50), ("CRZ_BTNS", 10), ("PEDALS", 50), ("BRAKE", 50), ("SEATBELT", 10), ("DOORS", 10), ("GEAR", 20), ("BSM", 10), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod def get_cam_can_parser(CP): signals = [] checks = [] if CP.carFingerprint in GEN1: signals += [ # sig_name, sig_address, default ("LKAS_REQUEST", "CAM_LKAS", 0), ("CTR", "CAM_LKAS", 0), ("ERR_BIT_1", "CAM_LKAS", 0), ("LINE_NOT_VISIBLE", "CAM_LKAS", 0), ("LDW", "CAM_LKAS", 0), ("BIT_1", "CAM_LKAS", 1), ("ERR_BIT_2", "CAM_LKAS", 0), ("STEERING_ANGLE", "CAM_LKAS", 0), ("ANGLE_ENABLED", "CAM_LKAS", 0), ("CHKSUM", "CAM_LKAS", 0), ] checks += [ # sig_address, frequency ("CAM_LKAS", 16), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) ================================================ FILE: selfdrive/car/mazda/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV from selfdrive.car.mazda.values import CAR, LKAS_LIMITS from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr ButtonType = car.CarState.ButtonEvent.Type EventName = car.CarEvent.EventName class CarInterface(CarInterfaceBase): @staticmethod def compute_gb(accel, speed): return float(accel) / 4.0 @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "mazda" ret.safetyModel = car.CarParams.SafetyModel.mazda ret.lateralTuning.init('pid') ret.radarOffCan = True ret.communityFeature = True ret.dashcamOnly = True ret.steerActuatorDelay = 0.1 ret.steerRateCost = 1.0 ret.steerLimitTimer = 0.8 tire_stiffness_factor = 0.70 # not optimized yet if candidate == CAR.CX5: ret.mass = 3655 * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.7 ret.steerRatio = 15.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] ret.lateralTuning.pid.kf = 0.00006 elif candidate in [CAR.CX9, CAR.CX9_2021]: ret.mass = 4217 * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 3.1 ret.steerRatio = 17.6 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] ret.lateralTuning.pid.kf = 0.00006 elif candidate == CAR.MAZDA3: ret.mass = 2875 * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.7 ret.steerRatio = 14.0 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] ret.lateralTuning.pid.kf = 0.00006 elif candidate == CAR.MAZDA6: ret.mass = 3443 * CV.LB_TO_KG + STD_CARGO_KG ret.wheelbase = 2.83 ret.steerRatio = 15.5 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.019]] ret.lateralTuning.pid.kf = 0.00006 # No steer below disable speed ret.minSteerSpeed = LKAS_LIMITS.DISABLE_SPEED * CV.KPH_TO_MS ret.centerToFront = ret.wheelbase * 0.41 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid # events events = self.create_common_events(ret) if self.CS.low_speed_lockout: events.add(EventName.belowEngageSpeed) if self.CS.low_speed_alert: events.add(EventName.belowSteerSpeed) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/mazda/mazdacan.py ================================================ from selfdrive.car.mazda.values import GEN1, Buttons def create_steering_control(packer, car_fingerprint, frame, apply_steer, lkas): tmp = apply_steer + 2048 lo = tmp & 0xFF hi = tmp >> 8 b1 = int(lkas["BIT_1"]) ldw = int(lkas["LDW"]) er1 = int(lkas["ERR_BIT_1"]) lnv = 0 er2 = int(lkas["ERR_BIT_2"]) # Some older models do have these, newer models don't. # Either way, they all work just fine if set to zero. steering_angle = 0 b2 = 0 tmp = steering_angle + 2048 ahi = tmp >> 10 amd = (tmp & 0x3FF) >> 2 amd = (amd >> 4) | (( amd & 0xF) << 4) alo = (tmp & 0x3) << 2 ctr = frame % 16 # bytes: [ 1 ] [ 2 ] [ 3 ] [ 4 ] csum = 249 - ctr - hi - lo - (lnv << 3) - er1 - (ldw << 7) - ( er2 << 4) - (b1 << 5) #bytes [ 5 ] [ 6 ] [ 7 ] csum = csum - ahi - amd - alo - b2 if ahi == 1: csum = csum + 15 if csum < 0: if csum < -256: csum = csum + 512 else: csum = csum + 256 csum = csum % 256 if car_fingerprint in GEN1: values = { "LKAS_REQUEST" : apply_steer, "CTR" : ctr, "ERR_BIT_1" : er1, "LINE_NOT_VISIBLE" : lnv, "LDW" : ldw, "BIT_1" : b1, "ERR_BIT_2" : er2, "STEERING_ANGLE" : steering_angle, "ANGLE_ENABLED" : b2, "CHKSUM" : csum } return packer.make_can_msg("CAM_LKAS", 0, values) def create_button_cmd(packer, car_fingerprint, button): if button == Buttons.CANCEL: can = 1 res = 0 elif button == Buttons.RESUME: can = 0 res = 1 else: can = 0 res = 0 if car_fingerprint in GEN1: values = { "CAN_OFF" : can, "CAN_OFF_INV" : (can + 1) % 2, "SET_P" : 0, "SET_P_INV" : 1, "RES" : res, "RES_INV" : (res + 1) % 2, "SET_M" : 0, "SET_M_INV" : 1, "DISTANCE_LESS" : 0, "DISTANCE_LESS_INV" : 1, "DISTANCE_MORE" : 0, "DISTANCE_MORE_INV" : 1, "MODE_X" : 0, "MODE_X_INV" : 1, "MODE_Y" : 0, "MODE_Y_INV" : 1, "BIT1" : 1, "BIT2" : 1, "BIT3" : 1, "CTR" : 0 } return packer.make_can_msg("CRZ_BTNS", 0, values) ================================================ FILE: selfdrive/car/mazda/radar_interface.py ================================================ #!/usr/bin/env python3 from selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass ================================================ FILE: selfdrive/car/mazda/values.py ================================================ # flake8: noqa from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu # Steer torque limits class CarControllerParams: STEER_MAX = 800 # theoretical max_steer 2047 STEER_DELTA_UP = 10 # torque increase per refresh STEER_DELTA_DOWN = 25 # torque decrease per refresh STEER_DRIVER_ALLOWANCE = 15 # allowed driver torque before start limiting STEER_DRIVER_MULTIPLIER = 1 # weight driver torque STEER_DRIVER_FACTOR = 1 # from dbc STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor class CAR: CX5 = "MAZDA CX-5" CX9 = "MAZDA CX-9" MAZDA3 = "MAZDA 3" MAZDA6 = "MAZDA 6" CX9_2021 = "Mazda CX-9 2021" # No Steer Lockout class LKAS_LIMITS: STEER_THRESHOLD = 15 DISABLE_SPEED = 45 # kph ENABLE_SPEED = 52 # kph class Buttons: NONE = 0 SET_PLUS = 1 SET_MINUS = 2 RESUME = 3 CANCEL = 4 FW_VERSIONS = { CAR.CX5: { (Ecu.eps, 0x730, None): [ b'KJ01-3210X-G-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KJ01-3210X-J-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KJ01-3210X-M-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K319-3210X-A-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'PA53-188K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYNF-188K2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYFA-188K2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYFC-188K2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYFD-188K2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX2G-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX2H-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX2H-188K2-D\0x0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX38-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX42-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX68-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'SHKT-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x764, None): [ b'K123-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x760, None): [ b'K123-437K2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KL2K-437K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KN0W-437K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KBJ5-437K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x706, None): [ b'B61L-67XK2-T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-R\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-V\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GSH7-67XK2-J\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GSH7-67XK2-N\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.transmission, 0x7e1, None): [ b'PA66-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX39-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB1-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB1-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX68-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYNC-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB2-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB2-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB2-21PS1-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYB2-21PS1-G\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'SH9T-21PS1-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], }, CAR.CX9 : { (Ecu.eps, 0x730, None): [ b'K070-3210X-C-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KJ01-3210X-G-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KJ01-3210X-L-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'PYFM-188K2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYD7-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX23-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX24-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PXN8-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x764, None): [ b'TK80-67XK2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K123-67XK2-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x760, None): [ b'TK79-437K2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'TM53-437K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'TN40-437K2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'TA0B-437K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x706, None): [ b'TK80-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-V\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GSH7-67XK2-K\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.transmission, 0x7e1, None): [ b'PYFM-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYD5-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYD5-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYD6-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PXM7-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], }, CAR.MAZDA3: { (Ecu.eps, 0x730, None): [ b'K070-3210X-C-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'KR11-3210X-K-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'BHN1-3210X-J-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'P5JD-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYKC-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYKE-188K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PY2P-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x764, None): [ b'GHP9-67Y10---41\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B63C-67XK2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x760, None): [ b'B45A-437AS-0-08\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x706, None): [ b'B61L-67XK2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'B61L-67XK2-T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.transmission, 0x7e1, None): [ b'PY2S-21PS1-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'P52G-21PS1-F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYKE-21PS1-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYKE-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], }, CAR.MAZDA6: { (Ecu.eps, 0x730, None): [ b'GBEF-3210X-B-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GFBC-3210X-A-00\000\000\000\000\000\000\000\000\000', ], (Ecu.engine, 0x7e0, None): [ b'PYH7-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PX4F-188K2-D\000\000\000\000\000\000\000\000\000\000\000\000', ], (Ecu.fwdRadar, 0x764, None): [ b'K131-67XK2-A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'K131-67XK2-E\000\000\000\000\000\000\000\000\000\000\000\000', ], (Ecu.esp, 0x760, None): [ b'GBVH-437K2-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GDDM-437K2-A\000\000\000\000\000\000\000\000\000\000\000\000', ], (Ecu.fwdCamera, 0x706, None): [ b'B61L-67XK2-S\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GSH7-67XK2-P\000\000\000\000\000\000\000\000\000\000\000\000', ], (Ecu.transmission, 0x7e1, None): [ b'PYH7-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PYH3-21PS1-D\000\000\000\000\000\000\000\000\000\000\000\000', ], }, CAR.CX9_2021 : { (Ecu.eps, 0x730, None): [ b'TC3M-3210X-A-00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'PXM4-188K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'PXM4-188K2-D\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x764, None): [ b'K131-67XK2-E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x760, None): [ b'TA0B-437K2-C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x706, None): [ b'GSH7-67XK2-M\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', b'GSH7-67XK2-N\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.transmission, 0x7e1, None): [ b'PXM4-21PS1-B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', ], } } DBC = { CAR.CX5: dbc_dict('mazda_2017', None), CAR.CX9: dbc_dict('mazda_2017', None), CAR.MAZDA3: dbc_dict('mazda_2017', None), CAR.MAZDA6: dbc_dict('mazda_2017', None), CAR.CX9_2021: dbc_dict('mazda_2017', None), } # Gen 1 hardware: same CAN messages and same camera GEN1 = set([CAR.CX5, CAR.CX9, CAR.CX9_2021, CAR.MAZDA3, CAR.MAZDA6]) # Cars with a steering lockout STEER_LOCKOUT_CAR = set([CAR.CX5, CAR.CX9, CAR.MAZDA3, CAR.MAZDA6]) ================================================ FILE: selfdrive/car/mock/__init__.py ================================================ ================================================ FILE: selfdrive/car/mock/interface.py ================================================ #!/usr/bin/env python3 import math from cereal import car from selfdrive.config import Conversions as CV from selfdrive.swaglog import cloudlog import cereal.messaging as messaging from selfdrive.car import gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase # mocked car interface to work with chffrplus TS = 0.01 # 100Hz YAW_FR = 0.2 # ~0.8s time constant on yaw rate filter # low pass gain LPG = 2 * math.pi * YAW_FR * TS / (1 + 2 * math.pi * YAW_FR * TS) class CarInterface(CarInterfaceBase): def __init__(self, CP, CarController, CarState): super().__init__(CP, CarController, CarState) cloudlog.debug("Using Mock Car Interface") # TODO: subscribe to phone sensor self.sensor = messaging.sub_sock('sensorEvents') self.gps = messaging.sub_sock('gpsLocationExternal') self.speed = 0. self.prev_speed = 0. self.yaw_rate = 0. self.yaw_rate_meas = 0. @staticmethod def compute_gb(accel, speed): return accel @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "mock" ret.safetyModel = car.CarParams.SafetyModel.noOutput ret.mass = 1700. ret.rotationalInertia = 2500. ret.wheelbase = 2.70 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 13. # reasonable ret.tireStiffnessFront = 1e6 # very stiff to neglect slip ret.tireStiffnessRear = 1e6 # very stiff to neglect slip return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): # get basic data from phone and gps since CAN isn't connected sensors = messaging.recv_sock(self.sensor) if sensors is not None: for sensor in sensors.sensorEvents: if sensor.type == 4: # gyro self.yaw_rate_meas = -sensor.gyro.v[0] gps = messaging.recv_sock(self.gps) if gps is not None: self.prev_speed = self.speed self.speed = gps.gpsLocationExternal.speed # create message ret = car.CarState.new_message() ret.canValid = True # speeds ret.vEgo = self.speed ret.vEgoRaw = self.speed a = self.speed - self.prev_speed ret.aEgo = a ret.brakePressed = a < -0.5 ret.standstill = self.speed < 0.01 ret.wheelSpeeds.fl = self.speed ret.wheelSpeeds.fr = self.speed ret.wheelSpeeds.rl = self.speed ret.wheelSpeeds.rr = self.speed self.yawRate = LPG * self.yaw_rate_meas + (1. - LPG) * self.yaw_rate curvature = self.yaw_rate / max(self.speed, 1.) ret.steeringAngleDeg = curvature * self.CP.steerRatio * self.CP.wheelbase * CV.RAD_TO_DEG return ret.as_reader() def apply(self, c): # in mock no carcontrols return [] ================================================ FILE: selfdrive/car/mock/radar_interface.py ================================================ #!/usr/bin/env python3 from selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass ================================================ FILE: selfdrive/car/mock/values.py ================================================ class CAR: MOCK = 'mock' ================================================ FILE: selfdrive/car/nissan/__init__.py ================================================ ================================================ FILE: selfdrive/car/nissan/carcontroller.py ================================================ from cereal import car from common.numpy_fast import clip, interp from selfdrive.car.nissan import nissancan from opendbc.can.packer import CANPacker from selfdrive.car.nissan.values import CAR, CarControllerParams from common.dp_common import common_controller_ctrl VisualAlert = car.CarControl.HUDControl.VisualAlert class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.CP = CP self.car_fingerprint = CP.carFingerprint self.lkas_max_torque = 0 self.last_angle = 0 self.packer = CANPacker(dbc_name) def update(self, enabled, CS, frame, actuators, cruise_cancel, hud_alert, left_line, right_line, left_lane_depart, right_lane_depart, dragonconf): """ Controls thread """ # Send CAN commands. can_sends = [] ### STEER ### acc_active = bool(CS.out.cruiseState.enabled) lkas_hud_msg = CS.lkas_hud_msg lkas_hud_info_msg = CS.lkas_hud_info_msg apply_angle = actuators.steeringAngleDeg steer_hud_alert = 1 if hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw] else 0 if enabled: # # windup slower if self.last_angle * apply_angle > 0. and abs(apply_angle) > abs(self.last_angle): angle_rate_lim = interp(CS.out.vEgo, CarControllerParams.ANGLE_DELTA_BP, CarControllerParams.ANGLE_DELTA_V) else: angle_rate_lim = interp(CS.out.vEgo, CarControllerParams.ANGLE_DELTA_BP, CarControllerParams.ANGLE_DELTA_VU) apply_angle = clip(apply_angle, self.last_angle - angle_rate_lim, self.last_angle + angle_rate_lim) # Max torque from driver before EPS will give up and not apply torque if not bool(CS.out.steeringPressed): self.lkas_max_torque = CarControllerParams.LKAS_MAX_TORQUE else: # Scale max torque based on how much torque the driver is applying to the wheel self.lkas_max_torque = max( # Scale max torque down to half LKAX_MAX_TORQUE as a minimum CarControllerParams.LKAS_MAX_TORQUE * 0.5, # Start scaling torque at STEER_THRESHOLD CarControllerParams.LKAS_MAX_TORQUE - 0.6 * max(0, abs(CS.out.steeringTorque) - CarControllerParams.STEER_THRESHOLD) ) else: apply_angle = CS.out.steeringAngleDeg self.lkas_max_torque = 0 # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_angle = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_angle, CS.out.vEgo) self.last_blinker_on = blinker_on self.last_angle = apply_angle if not enabled and acc_active: # send acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated cruise_cancel = 1 if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA] and cruise_cancel: can_sends.append(nissancan.create_acc_cancel_cmd(self.packer, self.car_fingerprint, CS.cruise_throttle_msg, frame)) # TODO: Find better way to cancel! # For some reason spamming the cancel button is unreliable on the Leaf # We now cancel by making propilot think the seatbelt is unlatched, # this generates a beep and a warning message every time you disengage if self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC] and frame % 2 == 0: can_sends.append(nissancan.create_cancel_msg(self.packer, CS.cancel_msg, cruise_cancel)) can_sends.append(nissancan.create_steering_control( self.packer, apply_angle, frame, enabled, self.lkas_max_torque)) if lkas_hud_msg and lkas_hud_info_msg: if frame % 2 == 0: can_sends.append(nissancan.create_lkas_hud_msg( self.packer, lkas_hud_msg, enabled, left_line, right_line, left_lane_depart, right_lane_depart)) if frame % 50 == 0: can_sends.append(nissancan.create_lkas_hud_info_msg( self.packer, lkas_hud_info_msg, steer_hud_alert )) return can_sends ================================================ FILE: selfdrive/car/nissan/carstate.py ================================================ import copy from collections import deque from cereal import car from opendbc.can.can_define import CANDefine from selfdrive.car.interfaces import CarStateBase from selfdrive.config import Conversions as CV from opendbc.can.parser import CANParser from selfdrive.car.nissan.values import CAR, DBC, CarControllerParams TORQUE_SAMPLES = 12 class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.lkas_hud_msg = None self.lkas_hud_info_msg = None self.steeringTorqueSamples = deque(TORQUE_SAMPLES*[0], TORQUE_SAMPLES) self.shifter_values = can_define.dv["GEARBOX"]["GEAR_SHIFTER"] def update(self, cp, cp_adas, cp_cam): ret = car.CarState.new_message() if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA]: ret.gas = cp.vl["GAS_PEDAL"]["GAS_PEDAL"] elif self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: ret.gas = cp.vl["CRUISE_THROTTLE"]["GAS_PEDAL"] ret.gasPressed = bool(ret.gas > 3) if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA]: ret.brakePressed = bool(cp.vl["DOORS_LIGHTS"]["USER_BRAKE_PRESSED"]) elif self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: ret.brakePressed = bool(cp.vl["BRAKE_PEDAL"]["BRAKE_PEDAL"] > 3) ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FL"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS_FRONT"]["WHEEL_SPEED_FR"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS_REAR"]["WHEEL_SPEED_RL"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS_REAR"]["WHEEL_SPEED_RR"] * CV.KPH_TO_MS ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = ret.vEgoRaw < 0.01 if self.CP.carFingerprint == CAR.ALTIMA: ret.cruiseState.enabled = bool(cp.vl["CRUISE_STATE"]["CRUISE_ENABLED"]) else: ret.cruiseState.enabled = bool(cp_adas.vl["CRUISE_STATE"]["CRUISE_ENABLED"]) # dp ret.cruiseActualEnabled = ret.cruiseState.enabled if self.CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: ret.seatbeltUnlatched = cp.vl["HUD"]["SEATBELT_DRIVER_LATCHED"] == 0 ret.cruiseState.available = bool(cp_cam.vl["PRO_PILOT"]["CRUISE_ON"]) elif self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: if self.CP.carFingerprint == CAR.LEAF: ret.seatbeltUnlatched = cp.vl["SEATBELT"]["SEATBELT_DRIVER_LATCHED"] == 0 elif self.CP.carFingerprint == CAR.LEAF_IC: ret.seatbeltUnlatched = cp.vl["CANCEL_MSG"]["CANCEL_SEATBELT"] == 1 ret.cruiseState.available = bool(cp.vl["CRUISE_THROTTLE"]["CRUISE_AVAILABLE"]) elif self.CP.carFingerprint == CAR.ALTIMA: ret.seatbeltUnlatched = cp.vl["HUD"]["SEATBELT_DRIVER_LATCHED"] == 0 ret.cruiseState.available = bool(cp_adas.vl["PRO_PILOT"]["CRUISE_ON"]) if self.CP.carFingerprint == CAR.ALTIMA: speed = cp.vl["PROPILOT_HUD"]["SET_SPEED"] else: speed = cp_adas.vl["PROPILOT_HUD"]["SET_SPEED"] if speed != 255: if self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: conversion = CV.MPH_TO_MS if cp.vl["HUD_SETTINGS"]["SPEED_MPH"] else CV.KPH_TO_MS else: conversion = CV.MPH_TO_MS if cp.vl["HUD"]["SPEED_MPH"] else CV.KPH_TO_MS speed -= 1 # Speed on HUD is always 1 lower than actually sent on can bus ret.cruiseState.speed = speed * conversion if self.CP.carFingerprint == CAR.ALTIMA: ret.steeringTorque = cp_cam.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"] else: ret.steeringTorque = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"] self.steeringTorqueSamples.append(ret.steeringTorque) # Filtering driver torque to prevent steeringPressed false positives ret.steeringPressed = bool(abs(sum(self.steeringTorqueSamples) / TORQUE_SAMPLES) > CarControllerParams.STEER_THRESHOLD) ret.steeringAngleDeg = cp.vl["STEER_ANGLE_SENSOR"]["STEER_ANGLE"] ret.leftBlinker = bool(cp.vl["LIGHTS"]["LEFT_BLINKER"]) ret.rightBlinker = bool(cp.vl["LIGHTS"]["RIGHT_BLINKER"]) ret.doorOpen = any([cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_RR"], cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_RL"], cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_FR"], cp.vl["DOORS_LIGHTS"]["DOOR_OPEN_FL"]]) ret.espDisabled = bool(cp.vl["ESP"]["ESP_DISABLED"]) can_gear = int(cp.vl["GEARBOX"]["GEAR_SHIFTER"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) if self.CP.carFingerprint == CAR.ALTIMA: self.lkas_enabled = bool(cp.vl["LKAS_SETTINGS"]["LKAS_ENABLED"]) else: self.lkas_enabled = bool(cp_adas.vl["LKAS_SETTINGS"]["LKAS_ENABLED"]) self.cruise_throttle_msg = copy.copy(cp.vl["CRUISE_THROTTLE"]) if self.CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: self.cancel_msg = copy.copy(cp.vl["CANCEL_MSG"]) if self.CP.carFingerprint != CAR.ALTIMA: self.lkas_hud_msg = copy.copy(cp_adas.vl["PROPILOT_HUD"]) self.lkas_hud_info_msg = copy.copy(cp_adas.vl["PROPILOT_HUD_INFO_MSG"]) # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("WHEEL_SPEED_FL", "WHEEL_SPEEDS_FRONT", 0), ("WHEEL_SPEED_FR", "WHEEL_SPEEDS_FRONT", 0), ("WHEEL_SPEED_RL", "WHEEL_SPEEDS_REAR", 0), ("WHEEL_SPEED_RR", "WHEEL_SPEEDS_REAR", 0), ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), ("DOOR_OPEN_FR", "DOORS_LIGHTS", 1), ("DOOR_OPEN_FL", "DOORS_LIGHTS", 1), ("DOOR_OPEN_RR", "DOORS_LIGHTS", 1), ("DOOR_OPEN_RL", "DOORS_LIGHTS", 1), ("RIGHT_BLINKER", "LIGHTS", 0), ("LEFT_BLINKER", "LIGHTS", 0), ("ESP_DISABLED", "ESP", 0), ("GEAR_SHIFTER", "GEARBOX", 0), ] checks = [ # sig_address, frequency ("STEER_ANGLE_SENSOR", 100), ("WHEEL_SPEEDS_REAR", 50), ("WHEEL_SPEEDS_FRONT", 50), ("ESP", 25), ("GEARBOX", 25), ("DOORS_LIGHTS", 10), ("LIGHTS", 10), ] if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL, CAR.ALTIMA]: signals += [ ("USER_BRAKE_PRESSED", "DOORS_LIGHTS", 1), ("GAS_PEDAL", "GAS_PEDAL", 0), ("SEATBELT_DRIVER_LATCHED", "HUD", 0), ("SPEED_MPH", "HUD", 0), ("PROPILOT_BUTTON", "CRUISE_THROTTLE", 0), ("CANCEL_BUTTON", "CRUISE_THROTTLE", 0), ("GAS_PEDAL_INVERTED", "CRUISE_THROTTLE", 0), ("SET_BUTTON", "CRUISE_THROTTLE", 0), ("RES_BUTTON", "CRUISE_THROTTLE", 0), ("FOLLOW_DISTANCE_BUTTON", "CRUISE_THROTTLE", 0), ("NO_BUTTON_PRESSED", "CRUISE_THROTTLE", 0), ("GAS_PEDAL", "CRUISE_THROTTLE", 0), ("USER_BRAKE_PRESSED", "CRUISE_THROTTLE", 0), ("NEW_SIGNAL_2", "CRUISE_THROTTLE", 0), ("GAS_PRESSED_INVERTED", "CRUISE_THROTTLE", 0), ("unsure1", "CRUISE_THROTTLE", 0), ("unsure2", "CRUISE_THROTTLE", 0), ("unsure3", "CRUISE_THROTTLE", 0), ] checks += [ ("GAS_PEDAL", 100), ("CRUISE_THROTTLE", 50), ("HUD", 25), ] elif CP.carFingerprint in [CAR.LEAF, CAR.LEAF_IC]: signals += [ ("BRAKE_PEDAL", "BRAKE_PEDAL", 0), ("GAS_PEDAL", "CRUISE_THROTTLE", 0), ("CRUISE_AVAILABLE", "CRUISE_THROTTLE", 0), ("SPEED_MPH", "HUD_SETTINGS", 0), ("SEATBELT_DRIVER_LATCHED", "SEATBELT", 0), # Copy other values, we use this to cancel ("CANCEL_SEATBELT", "CANCEL_MSG", 0), ("NEW_SIGNAL_1", "CANCEL_MSG", 0), ("NEW_SIGNAL_2", "CANCEL_MSG", 0), ("NEW_SIGNAL_3", "CANCEL_MSG", 0), ] checks += [ ("BRAKE_PEDAL", 100), ("CRUISE_THROTTLE", 50), ("CANCEL_MSG", 50), ("HUD_SETTINGS", 25), ("SEATBELT", 10), ] if CP.carFingerprint == CAR.ALTIMA: signals += [ ("LKAS_ENABLED", "LKAS_SETTINGS", 0), ("CRUISE_ENABLED", "CRUISE_STATE", 0), ("SET_SPEED", "PROPILOT_HUD", 0), ] checks += [ ("CRUISE_STATE", 10), ("LKAS_SETTINGS", 10), ("PROPILOT_HUD", 50), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 1) signals += [ ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), ] checks += [ ("STEER_TORQUE_SENSOR", 100), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod def get_adas_can_parser(CP): # this function generates lists for signal, messages and initial values if CP.carFingerprint == CAR.ALTIMA: signals = [ ("DESIRED_ANGLE", "LKAS", 0), ("SET_0x80_2", "LKAS", 0), ("MAX_TORQUE", "LKAS", 0), ("SET_0x80", "LKAS", 0), ("COUNTER", "LKAS", 0), ("LKA_ACTIVE", "LKAS", 0), ("CRUISE_ON", "PRO_PILOT", 0), ] checks = [ ("LKAS", 100), ("PRO_PILOT", 100), ] else: signals = [ # sig_name, sig_address, default ("LKAS_ENABLED", "LKAS_SETTINGS", 0), ("CRUISE_ENABLED", "CRUISE_STATE", 0), ("DESIRED_ANGLE", "LKAS", 0), ("SET_0x80_2", "LKAS", 0), ("MAX_TORQUE", "LKAS", 0), ("SET_0x80", "LKAS", 0), ("COUNTER", "LKAS", 0), ("LKA_ACTIVE", "LKAS", 0), # Below are the HUD messages. We copy the stock message and modify ("LARGE_WARNING_FLASHING", "PROPILOT_HUD", 0), ("SIDE_RADAR_ERROR_FLASHING1", "PROPILOT_HUD", 0), ("SIDE_RADAR_ERROR_FLASHING2", "PROPILOT_HUD", 0), ("LEAD_CAR", "PROPILOT_HUD", 0), ("LEAD_CAR_ERROR", "PROPILOT_HUD", 0), ("FRONT_RADAR_ERROR", "PROPILOT_HUD", 0), ("FRONT_RADAR_ERROR_FLASHING", "PROPILOT_HUD", 0), ("SIDE_RADAR_ERROR_FLASHING3", "PROPILOT_HUD", 0), ("LKAS_ERROR_FLASHING", "PROPILOT_HUD", 0), ("SAFETY_SHIELD_ACTIVE", "PROPILOT_HUD", 0), ("RIGHT_LANE_GREEN_FLASH", "PROPILOT_HUD", 0), ("LEFT_LANE_GREEN_FLASH", "PROPILOT_HUD", 0), ("FOLLOW_DISTANCE", "PROPILOT_HUD", 0), ("AUDIBLE_TONE", "PROPILOT_HUD", 0), ("SPEED_SET_ICON", "PROPILOT_HUD", 0), ("SMALL_STEERING_WHEEL_ICON", "PROPILOT_HUD", 0), ("unknown59", "PROPILOT_HUD", 0), ("unknown55", "PROPILOT_HUD", 0), ("unknown26", "PROPILOT_HUD", 0), ("unknown28", "PROPILOT_HUD", 0), ("unknown31", "PROPILOT_HUD", 0), ("SET_SPEED", "PROPILOT_HUD", 0), ("unknown43", "PROPILOT_HUD", 0), ("unknown08", "PROPILOT_HUD", 0), ("unknown05", "PROPILOT_HUD", 0), ("unknown02", "PROPILOT_HUD", 0), ("NA_HIGH_ACCEL_TEMP", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_RADAR_NA_HIGH_CABIN_TEMP", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_RADAR_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), ("LKAS_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), ("FRONT_RADAR_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_RADAR_NA_CLEAN_REAR_CAMERA", "PROPILOT_HUD_INFO_MSG", 0), ("NA_POOR_ROAD_CONDITIONS", "PROPILOT_HUD_INFO_MSG", 0), ("CURRENTLY_UNAVAILABLE", "PROPILOT_HUD_INFO_MSG", 0), ("SAFETY_SHIELD_OFF", "PROPILOT_HUD_INFO_MSG", 0), ("FRONT_COLLISION_NA_FRONT_RADAR_OBSTRUCTION", "PROPILOT_HUD_INFO_MSG", 0), ("PEDAL_MISSAPPLICATION_SYSTEM_ACTIVATED", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_IMPACT_NA_RADAR_OBSTRUCTION", "PROPILOT_HUD_INFO_MSG", 0), ("WARNING_DO_NOT_ENTER", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_IMPACT_SYSTEM_OFF", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_IMPACT_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), ("FRONT_COLLISION_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), ("SIDE_RADAR_MALFUNCTION2", "PROPILOT_HUD_INFO_MSG", 0), ("LKAS_MALFUNCTION2", "PROPILOT_HUD_INFO_MSG", 0), ("FRONT_RADAR_MALFUNCTION2", "PROPILOT_HUD_INFO_MSG", 0), ("PROPILOT_NA_MSGS", "PROPILOT_HUD_INFO_MSG", 0), ("BOTTOM_MSG", "PROPILOT_HUD_INFO_MSG", 0), ("HANDS_ON_WHEEL_WARNING", "PROPILOT_HUD_INFO_MSG", 0), ("WARNING_STEP_ON_BRAKE_NOW", "PROPILOT_HUD_INFO_MSG", 0), ("PROPILOT_NA_FRONT_CAMERA_OBSTRUCTED", "PROPILOT_HUD_INFO_MSG", 0), ("PROPILOT_NA_HIGH_CABIN_TEMP", "PROPILOT_HUD_INFO_MSG", 0), ("WARNING_PROPILOT_MALFUNCTION", "PROPILOT_HUD_INFO_MSG", 0), ("ACC_UNAVAILABLE_HIGH_CABIN_TEMP", "PROPILOT_HUD_INFO_MSG", 0), ("ACC_NA_FRONT_CAMERA_IMPARED", "PROPILOT_HUD_INFO_MSG", 0), ("unknown07", "PROPILOT_HUD_INFO_MSG", 0), ("unknown10", "PROPILOT_HUD_INFO_MSG", 0), ("unknown15", "PROPILOT_HUD_INFO_MSG", 0), ("unknown23", "PROPILOT_HUD_INFO_MSG", 0), ("unknown19", "PROPILOT_HUD_INFO_MSG", 0), ("unknown31", "PROPILOT_HUD_INFO_MSG", 0), ("unknown32", "PROPILOT_HUD_INFO_MSG", 0), ("unknown46", "PROPILOT_HUD_INFO_MSG", 0), ("unknown61", "PROPILOT_HUD_INFO_MSG", 0), ("unknown55", "PROPILOT_HUD_INFO_MSG", 0), ("unknown50", "PROPILOT_HUD_INFO_MSG", 0), ] checks = [ ("PROPILOT_HUD_INFO_MSG", 2), ("LKAS_SETTINGS", 10), ("CRUISE_STATE", 50), ("PROPILOT_HUD", 50), ("LKAS", 100), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) @staticmethod def get_cam_can_parser(CP): signals = [] checks = [] if CP.carFingerprint in [CAR.ROGUE, CAR.XTRAIL]: signals += [ ("CRUISE_ON", "PRO_PILOT", 0), ] checks += [ ("PRO_PILOT", 100), ] elif CP.carFingerprint == CAR.ALTIMA: signals += [ ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), ] checks += [ ("STEER_TORQUE_SENSOR", 100), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 1) ================================================ FILE: selfdrive/car/nissan/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.car.nissan.values import CAR from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr class CarInterface(CarInterfaceBase): def __init__(self, CP, CarController, CarState): super().__init__(CP, CarController, CarState) self.cp_adas = self.CS.get_adas_can_parser(CP) @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "nissan" ret.safetyModel = car.CarParams.SafetyModel.nissan ret.lateralTuning.init('pid') # Nissan port is a community feature, since we don't own one to test ret.communityFeature = True ret.steerLimitAlert = False ret.steerRateCost = 0.5 ret.steerActuatorDelay = 0.1 if candidate in [CAR.ROGUE, CAR.XTRAIL]: ret.mass = 1610 + STD_CARGO_KG ret.wheelbase = 2.705 ret.centerToFront = ret.wheelbase * 0.44 ret.steerRatio = 17 elif candidate in [CAR.LEAF, CAR.LEAF_IC]: ret.mass = 1610 + STD_CARGO_KG ret.wheelbase = 2.705 ret.centerToFront = ret.wheelbase * 0.44 ret.steerRatio = 17 elif candidate == CAR.ALTIMA: # Altima has EPS on C-CAN unlike the others that have it on V-CAN ret.safetyParam = 1 # EPS is on alternate bus ret.mass = 1492 + STD_CARGO_KG ret.wheelbase = 2.824 ret.centerToFront = ret.wheelbase * 0.44 ret.steerRatio = 17 ret.steerControlType = car.CarParams.SteerControlType.angle ret.radarOffCan = True # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) self.cp_adas.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_adas, self.cp_cam) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid and self.cp_adas.can_valid and self.cp_cam.can_valid buttonEvents = [] be = car.CarState.ButtonEvent.new_message() be.type = car.CarState.ButtonEvent.Type.accelCruise buttonEvents.append(be) events = self.create_common_events(ret) if self.CS.lkas_enabled: events.add(car.CarEvent.EventName.invalidLkasSetting) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/nissan/nissancan.py ================================================ import copy import crcmod from selfdrive.car.nissan.values import CAR nissan_checksum = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) def create_steering_control(packer, apply_steer, frame, steer_on, lkas_max_torque): idx = (frame % 16) values = { "DESIRED_ANGLE": apply_steer, "SET_0x80_2": 0x80, "SET_0x80": 0x80, "MAX_TORQUE": lkas_max_torque if steer_on else 0, "COUNTER": idx, "LKA_ACTIVE": steer_on, } dat = packer.make_can_msg("LKAS", 0, values)[2] values["CHECKSUM"] = nissan_checksum(dat[:7]) return packer.make_can_msg("LKAS", 0, values) def create_acc_cancel_cmd(packer, car_fingerprint, cruise_throttle_msg, frame): values = copy.copy(cruise_throttle_msg) can_bus = 2 if car_fingerprint == CAR.ALTIMA: can_bus = 1 values["CANCEL_BUTTON"] = 1 values["NO_BUTTON_PRESSED"] = 0 values["PROPILOT_BUTTON"] = 0 values["SET_BUTTON"] = 0 values["RES_BUTTON"] = 0 values["FOLLOW_DISTANCE_BUTTON"] = 0 values["COUNTER"] = (frame % 4) return packer.make_can_msg("CRUISE_THROTTLE", can_bus, values) def create_cancel_msg(packer, cancel_msg, cruise_cancel): values = copy.copy(cancel_msg) if cruise_cancel: values["CANCEL_SEATBELT"] = 1 return packer.make_can_msg("CANCEL_MSG", 2, values) def create_lkas_hud_msg(packer, lkas_hud_msg, enabled, left_line, right_line, left_lane_depart, right_lane_depart): values = lkas_hud_msg values["RIGHT_LANE_YELLOW_FLASH"] = 1 if right_lane_depart else 0 values["LEFT_LANE_YELLOW_FLASH"] = 1 if left_lane_depart else 0 values["LARGE_STEERING_WHEEL_ICON"] = 2 if enabled else 0 values["RIGHT_LANE_GREEN"] = 1 if right_line and enabled else 0 values["LEFT_LANE_GREEN"] = 1 if left_line and enabled else 0 return packer.make_can_msg("PROPILOT_HUD", 0, values) def create_lkas_hud_info_msg(packer, lkas_hud_info_msg, steer_hud_alert): values = lkas_hud_info_msg if steer_hud_alert: values["HANDS_ON_WHEEL_WARNING"] = 1 return packer.make_can_msg("PROPILOT_HUD_INFO_MSG", 0, values) ================================================ FILE: selfdrive/car/nissan/radar_interface.py ================================================ #!/usr/bin/env python3 from selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass ================================================ FILE: selfdrive/car/nissan/values.py ================================================ # flake8: noqa from selfdrive.car import dbc_dict class CarControllerParams: ANGLE_DELTA_BP = [0., 5., 15.] ANGLE_DELTA_V = [5., .8, .15] # windup limit ANGLE_DELTA_VU = [5., 3.5, 0.4] # unwind limit LKAS_MAX_TORQUE = 1 # A value of 1 is easy to overpower STEER_THRESHOLD = 1.0 class CAR: XTRAIL = "NISSAN X-TRAIL 2017" LEAF = "NISSAN LEAF 2018" # Leaf with ADAS ECU found behind instrument cluster instead of glovebox # Currently the only known difference between them is the inverted seatbelt signal. LEAF_IC = "NISSAN LEAF 2018 Instrument Cluster" ROGUE = "NISSAN ROGUE 2019" ALTIMA = "NISSAN ALTIMA 2020" FINGERPRINTS = { CAR.XTRAIL: [ { 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 548: 8, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 768: 2, 783: 3, 851: 8, 855: 8, 1041: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1111: 4, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 2, 1497: 3, 1821: 8, 1823: 8, 1837: 8, 2015: 8, 2016: 8, 2024: 8 }, { 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 527: 1, 548: 8, 637: 4, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 768: 6, 783: 3, 851: 8, 855: 8, 1041: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1111: 4, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 8, 1497: 3, 1534: 6, 1792: 8, 1821: 8, 1823: 8, 1837: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 2015: 8, 2016: 8, 2024: 8 }, ], CAR.LEAF: [ { 2: 5, 42: 6, 264: 3, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 724: 6, 758: 3, 761: 2, 783: 3, 852: 8, 853: 8, 856: 8, 861: 8, 944: 1, 976: 6, 1008: 7, 1011: 7, 1057: 3, 1227: 8, 1228: 8, 1261: 5, 1342: 1, 1354: 8, 1361: 8, 1459: 8, 1477: 8, 1497: 3, 1549: 8, 1573: 6, 1821: 8, 1837: 8, 1856: 8, 1859: 8, 1861: 8, 1864: 8, 1874: 8, 1888: 8, 1891: 8, 1893: 8, 1906: 8, 1947: 8, 1949: 8, 1979: 8, 1981: 8, 2016: 8, 2017: 8, 2021: 8, 643: 5, 1792: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8 }, # 2020 Leaf SV Plus { 2: 5, 42: 8, 264: 3, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 643: 5, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 724: 6, 758: 3, 761: 2, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 783: 3, 852: 8, 853: 8, 856: 8, 861: 8, 943: 8, 944: 1, 976: 6, 1008: 7, 1009: 8, 1010: 8, 1011: 7, 1012: 8, 1013: 8, 1019: 8, 1020: 8, 1021: 8, 1022: 8, 1057: 3, 1227: 8, 1228: 8, 1261: 5, 1342: 1, 1354: 8, 1361: 8, 1402: 8, 1459: 8, 1477: 8, 1497: 3, 1549: 8, 1573: 6, 1821: 8, 1837: 8 }, ], CAR.LEAF_IC: [ { 2: 5, 42: 6, 264: 3, 282: 8, 361: 8, 372: 8, 384: 8, 389: 8, 403: 8, 459: 7, 460: 4, 470: 8, 520: 1, 569: 8, 581: 8, 634: 7, 640: 8, 643: 5, 644: 8, 645: 8, 646: 5, 658: 8, 682: 8, 683: 8, 689: 8, 756: 5, 758: 3, 761: 2, 783: 3, 830: 2, 852: 8, 853: 8, 856: 8, 861: 8, 943: 8, 944: 1, 1001: 6, 1057: 3, 1227: 8, 1228: 8, 1229: 8, 1342: 1, 1354: 8, 1361: 8, 1459: 8, 1477: 8, 1497: 3, 1514: 6, 1549: 8, 1573: 6, 1792: 8, 1821: 8, 1822: 8, 1837: 8, 1838: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8, 2016: 8, 2017: 8 }, ], CAR.ROGUE: [ { 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 520: 2, 523: 6, 548: 8, 634: 7, 643: 5, 645: 8, 658: 8, 665: 8, 666: 8, 674: 2, 682: 8, 683: 8, 689: 8, 723: 8, 758: 3, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 783: 3, 851: 8, 855: 8, 1041: 8, 1042: 8, 1055: 2, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1110: 7, 1111: 7, 1227: 8, 1228: 8, 1247: 4, 1266: 8, 1273: 7, 1342: 1, 1376: 6, 1401: 8, 1474: 2, 1497: 3, 1534: 7, 1792: 8, 1821: 8, 1823: 8, 1837: 8, 1839: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }, ], CAR.ALTIMA: [ { 2: 5, 42: 6, 346: 6, 347: 5, 348: 8, 349: 7, 361: 8, 386: 8, 389: 8, 397: 8, 398: 8, 403: 8, 438: 8, 451: 8, 517: 8, 520: 2, 522: 8, 523: 6, 539: 8, 541: 7, 542: 8, 543: 8, 544: 8, 545: 8, 546: 8, 547: 8, 548: 8, 570: 8, 576: 8, 577: 8, 582: 8, 583: 8, 584: 8, 586: 8, 587: 8, 588: 8, 589: 8, 590: 8, 591: 8, 592: 8, 600: 8, 601: 8, 610: 8, 611: 8, 612: 8, 614: 8, 615: 8, 616: 8, 617: 8, 622: 8, 623: 8, 634: 7, 638: 8, 645: 8, 648: 5, 654: 6, 658: 8, 659: 8, 660: 8, 661: 8, 665: 8, 666: 8, 674: 2, 675: 8, 676: 8, 682: 8, 683: 8, 684: 8, 685: 8, 686: 8, 687: 8, 689: 8, 690: 8, 703: 8, 708: 7, 709: 7, 711: 7, 712: 7, 713: 7, 714: 8, 715: 8, 716: 8, 717: 7, 718: 7, 719: 7, 720: 7, 723: 8, 726: 7, 727: 7, 728: 7, 735: 8, 746: 8, 748: 6, 749: 6, 750: 8, 758: 3, 772: 8, 773: 6, 774: 7, 775: 8, 776: 6, 777: 7, 778: 6, 779: 7, 781: 7, 782: 7, 783: 3, 851: 8, 855: 5, 1001: 6, 1041: 8, 1042: 8, 1055: 3, 1100: 7, 1104: 4, 1105: 6, 1107: 4, 1108: 8, 1110: 7, 1111: 7, 1144: 7, 1145: 7, 1227: 8, 1228: 8, 1229: 8, 1232: 8, 1247: 4, 1258: 8, 1259: 8, 1266: 8, 1273: 7, 1306: 1, 1314: 8, 1323: 8, 1324: 8, 1342: 1, 1376: 8, 1401: 8, 1454: 8, 1497: 3, 1514: 6, 1526: 8, 1527: 5, 1792: 8, 1821: 8, 1823: 8, 1837: 8, 1872: 8, 1937: 8, 1953: 8, 1968: 8, 1988: 8, 2000: 8, 2001: 8, 2004: 8, 2005: 8, 2015: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }, ] } DBC = { CAR.XTRAIL: dbc_dict('nissan_x_trail_2017', None), CAR.LEAF: dbc_dict('nissan_leaf_2018', None), CAR.LEAF_IC: dbc_dict('nissan_leaf_2018', None), CAR.ROGUE: dbc_dict('nissan_x_trail_2017', None), CAR.ALTIMA: dbc_dict('nissan_x_trail_2017', None), } ================================================ FILE: selfdrive/car/subaru/__init__.py ================================================ ================================================ FILE: selfdrive/car/subaru/carcontroller.py ================================================ from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.subaru import subarucan from selfdrive.car.subaru.values import DBC, PREGLOBAL_CARS, CarControllerParams from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.apply_steer_last = 0 self.es_distance_cnt = -1 self.es_accel_cnt = -1 self.es_lkas_cnt = -1 self.cruise_button_prev = 0 self.steer_rate_limited = False self.packer = CANPacker(DBC[CP.carFingerprint]['pt']) def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart, dragonconf): can_sends = [] # *** steering *** if (frame % CarControllerParams.STEER_STEP) == 0: apply_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX)) # limits due to driver torque new_steer = int(round(apply_steer)) apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, CarControllerParams) self.steer_rate_limited = new_steer != apply_steer if not enabled: apply_steer = 0 # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on if CS.CP.carFingerprint in PREGLOBAL_CARS: can_sends.append(subarucan.create_preglobal_steering_control(self.packer, apply_steer, frame, CarControllerParams.STEER_STEP)) else: can_sends.append(subarucan.create_steering_control(self.packer, apply_steer, frame, CarControllerParams.STEER_STEP)) self.apply_steer_last = apply_steer # *** alerts and pcm cancel *** if CS.CP.carFingerprint in PREGLOBAL_CARS: if self.es_accel_cnt != CS.es_accel_msg["Counter"]: # 1 = main, 2 = set shallow, 3 = set deep, 4 = resume shallow, 5 = resume deep # disengage ACC when OP is disengaged if pcm_cancel_cmd: cruise_button = 1 # turn main on if off and past start-up state elif not CS.out.cruiseState.available and CS.ready: cruise_button = 1 else: cruise_button = CS.cruise_button # unstick previous mocked button press if cruise_button == 1 and self.cruise_button_prev == 1: cruise_button = 0 self.cruise_button_prev = cruise_button can_sends.append(subarucan.create_es_throttle_control(self.packer, cruise_button, CS.es_accel_msg)) self.es_accel_cnt = CS.es_accel_msg["Counter"] else: if self.es_distance_cnt != CS.es_distance_msg["Counter"]: can_sends.append(subarucan.create_es_distance(self.packer, CS.es_distance_msg, pcm_cancel_cmd)) self.es_distance_cnt = CS.es_distance_msg["Counter"] if self.es_lkas_cnt != CS.es_lkas_msg["Counter"]: can_sends.append(subarucan.create_es_lkas(self.packer, CS.es_lkas_msg, enabled, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart)) self.es_lkas_cnt = CS.es_lkas_msg["Counter"] return can_sends ================================================ FILE: selfdrive/car/subaru/carstate.py ================================================ import copy from cereal import car from opendbc.can.can_define import CANDefine from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from selfdrive.car.subaru.values import DBC, STEER_THRESHOLD, CAR, PREGLOBAL_CARS class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.shifter_values = can_define.dv["Transmission"]["Gear"] def update(self, cp, cp_cam): ret = car.CarState.new_message() ret.gas = cp.vl["Throttle"]["Throttle_Pedal"] / 255. ret.gasPressed = ret.gas > 1e-5 if self.car_fingerprint in PREGLOBAL_CARS: ret.brakePressed = cp.vl["Brake_Pedal"]["Brake_Pedal"] > 2 else: ret.brakePressed = cp.vl["Brake_Pedal"]["Brake_Pedal"] > 1e-5 ret.wheelSpeeds.fl = cp.vl["Wheel_Speeds"]["FL"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = cp.vl["Wheel_Speeds"]["FR"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = cp.vl["Wheel_Speeds"]["RL"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = cp.vl["Wheel_Speeds"]["RR"] * CV.KPH_TO_MS ret.vEgoRaw = (ret.wheelSpeeds.fl + ret.wheelSpeeds.fr + ret.wheelSpeeds.rl + ret.wheelSpeeds.rr) / 4. # Kalman filter, even though Subaru raw wheel speed is heaviliy filtered by default ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = ret.vEgoRaw < 0.01 # continuous blinker signals for assisted lane change ret.leftBlinker, ret.rightBlinker = self.update_blinker_from_lamp( 50, cp.vl["Dashlights"]["LEFT_BLINKER"], cp.vl["Dashlights"]["RIGHT_BLINKER"]) if self.CP.enableBsm: ret.leftBlindspot = (cp.vl["BSD_RCTA"]["L_ADJACENT"] == 1) or (cp.vl["BSD_RCTA"]["L_APPROACHING"] == 1) ret.rightBlindspot = (cp.vl["BSD_RCTA"]["R_ADJACENT"] == 1) or (cp.vl["BSD_RCTA"]["R_APPROACHING"] == 1) can_gear = int(cp.vl["Transmission"]["Gear"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) ret.steeringAngleDeg = cp.vl["Steering_Torque"]["Steering_Angle"] ret.steeringTorque = cp.vl["Steering_Torque"]["Steer_Torque_Sensor"] ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD[self.car_fingerprint] ret.cruiseState.enabled = cp.vl["CruiseControl"]["Cruise_Activated"] != 0 ret.cruiseState.available = cp.vl["CruiseControl"]["Cruise_On"] != 0 ret.cruiseState.speed = cp_cam.vl["ES_DashStatus"]["Cruise_Set_Speed"] * CV.KPH_TO_MS if (self.car_fingerprint in PREGLOBAL_CARS and cp.vl["Dash_State2"]["UNITS"] == 1) or \ (self.car_fingerprint not in PREGLOBAL_CARS and cp.vl["Dashlights"]["UNITS"] == 1): ret.cruiseState.speed *= CV.MPH_TO_KPH ret.seatbeltUnlatched = cp.vl["Dashlights"]["SEATBELT_FL"] == 1 ret.doorOpen = any([cp.vl["BodyInfo"]["DOOR_OPEN_RR"], cp.vl["BodyInfo"]["DOOR_OPEN_RL"], cp.vl["BodyInfo"]["DOOR_OPEN_FR"], cp.vl["BodyInfo"]["DOOR_OPEN_FL"]]) ret.steerError = cp.vl["Steering_Torque"]["Steer_Error_1"] == 1 if self.car_fingerprint in PREGLOBAL_CARS: self.cruise_button = cp_cam.vl["ES_CruiseThrottle"]["Cruise_Button"] self.ready = not cp_cam.vl["ES_DashStatus"]["Not_Ready_Startup"] self.es_accel_msg = copy.copy(cp_cam.vl["ES_CruiseThrottle"]) else: ret.steerWarning = cp.vl["Steering_Torque"]["Steer_Warning"] == 1 ret.cruiseState.nonAdaptive = cp_cam.vl["ES_DashStatus"]["Conventional_Cruise"] == 1 self.es_distance_msg = copy.copy(cp_cam.vl["ES_Distance"]) self.es_lkas_msg = copy.copy(cp_cam.vl["ES_LKAS_State"]) # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("Steer_Torque_Sensor", "Steering_Torque", 0), ("Steering_Angle", "Steering_Torque", 0), ("Steer_Error_1", "Steering_Torque", 0), ("Cruise_On", "CruiseControl", 0), ("Cruise_Activated", "CruiseControl", 0), ("Brake_Pedal", "Brake_Pedal", 0), ("Throttle_Pedal", "Throttle", 0), ("LEFT_BLINKER", "Dashlights", 0), ("RIGHT_BLINKER", "Dashlights", 0), ("SEATBELT_FL", "Dashlights", 0), ("FL", "Wheel_Speeds", 0), ("FR", "Wheel_Speeds", 0), ("RL", "Wheel_Speeds", 0), ("RR", "Wheel_Speeds", 0), ("DOOR_OPEN_FR", "BodyInfo", 1), ("DOOR_OPEN_FL", "BodyInfo", 1), ("DOOR_OPEN_RR", "BodyInfo", 1), ("DOOR_OPEN_RL", "BodyInfo", 1), ("Gear", "Transmission", 0), ] checks = [ # sig_address, frequency ("Throttle", 100), ("Dashlights", 10), ("Brake_Pedal", 50), ("Wheel_Speeds", 50), ("Transmission", 100), ("Steering_Torque", 50), ("BodyInfo", 1), ] if CP.enableBsm: signals += [ ("L_ADJACENT", "BSD_RCTA", 0), ("R_ADJACENT", "BSD_RCTA", 0), ("L_APPROACHING", "BSD_RCTA", 0), ("R_APPROACHING", "BSD_RCTA", 0), ] checks += [ ("BSD_RCTA", 17), ] if CP.carFingerprint not in PREGLOBAL_CARS: signals += [ ("Steer_Warning", "Steering_Torque", 0), ("UNITS", "Dashlights", 0), ] checks += [ ("Dashlights", 10), ("BodyInfo", 10), ("CruiseControl", 20), ] else: signals += [ ("UNITS", "Dash_State2", 0), ] checks += [ ("Dash_State2", 1), ] if CP.carFingerprint == CAR.FORESTER_PREGLOBAL: checks += [ ("Dashlights", 20), ("BodyInfo", 1), ("CruiseControl", 50), ] if CP.carFingerprint in [CAR.LEGACY_PREGLOBAL, CAR.OUTBACK_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018]: checks += [ ("Dashlights", 10), ("CruiseControl", 50), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod def get_cam_can_parser(CP): if CP.carFingerprint in PREGLOBAL_CARS: signals = [ ("Cruise_Set_Speed", "ES_DashStatus", 0), ("Not_Ready_Startup", "ES_DashStatus", 0), ("Throttle_Cruise", "ES_CruiseThrottle", 0), ("Signal1", "ES_CruiseThrottle", 0), ("Cruise_Activated", "ES_CruiseThrottle", 0), ("Signal2", "ES_CruiseThrottle", 0), ("Brake_On", "ES_CruiseThrottle", 0), ("Distance_Swap", "ES_CruiseThrottle", 0), ("Standstill", "ES_CruiseThrottle", 0), ("Signal3", "ES_CruiseThrottle", 0), ("Close_Distance", "ES_CruiseThrottle", 0), ("Signal4", "ES_CruiseThrottle", 0), ("Standstill_2", "ES_CruiseThrottle", 0), ("Cruise_Fault", "ES_CruiseThrottle", 0), ("Signal5", "ES_CruiseThrottle", 0), ("Counter", "ES_CruiseThrottle", 0), ("Signal6", "ES_CruiseThrottle", 0), ("Cruise_Button", "ES_CruiseThrottle", 0), ("Signal7", "ES_CruiseThrottle", 0), ] checks = [ ("ES_DashStatus", 20), ("ES_CruiseThrottle", 20), ] else: signals = [ ("Cruise_Set_Speed", "ES_DashStatus", 0), ("Conventional_Cruise", "ES_DashStatus", 0), ("Counter", "ES_Distance", 0), ("Signal1", "ES_Distance", 0), ("Cruise_Fault", "ES_Distance", 0), ("Cruise_Throttle", "ES_Distance", 0), ("Signal2", "ES_Distance", 0), ("Car_Follow", "ES_Distance", 0), ("Signal3", "ES_Distance", 0), ("Cruise_Brake_Active", "ES_Distance", 0), ("Distance_Swap", "ES_Distance", 0), ("Cruise_EPB", "ES_Distance", 0), ("Signal4", "ES_Distance", 0), ("Close_Distance", "ES_Distance", 0), ("Signal5", "ES_Distance", 0), ("Cruise_Cancel", "ES_Distance", 0), ("Cruise_Set", "ES_Distance", 0), ("Cruise_Resume", "ES_Distance", 0), ("Signal6", "ES_Distance", 0), ("Counter", "ES_LKAS_State", 0), ("LKAS_Alert_Msg", "ES_LKAS_State", 0), ("Signal1", "ES_LKAS_State", 0), ("LKAS_ACTIVE", "ES_LKAS_State", 0), ("LKAS_Dash_State", "ES_LKAS_State", 0), ("Signal2", "ES_LKAS_State", 0), ("Backward_Speed_Limit_Menu", "ES_LKAS_State", 0), ("LKAS_Left_Line_Enable", "ES_LKAS_State", 0), ("LKAS_Left_Line_Light_Blink", "ES_LKAS_State", 0), ("LKAS_Right_Line_Enable", "ES_LKAS_State", 0), ("LKAS_Right_Line_Light_Blink", "ES_LKAS_State", 0), ("LKAS_Left_Line_Visible", "ES_LKAS_State", 0), ("LKAS_Right_Line_Visible", "ES_LKAS_State", 0), ("LKAS_Alert", "ES_LKAS_State", 0), ("Signal3", "ES_LKAS_State", 0), ] checks = [ ("ES_DashStatus", 10), ("ES_Distance", 20), ("ES_LKAS_State", 10), ] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) ================================================ FILE: selfdrive/car/subaru/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.car.subaru.values import CAR, PREGLOBAL_CARS from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr class CarInterface(CarInterfaceBase): @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "subaru" ret.radarOffCan = True ret.lateralTuning.init('pid') if candidate in PREGLOBAL_CARS: ret.safetyModel = car.CarParams.SafetyModel.subaruLegacy ret.enableBsm = 0x25c in fingerprint[0] else: ret.safetyModel = car.CarParams.SafetyModel.subaru ret.enableBsm = 0x228 in fingerprint[0] # Subaru port is a community feature, since we don't own one to test ret.communityFeature = True ret.dashcamOnly = candidate in PREGLOBAL_CARS ret.steerRateCost = 0.7 ret.steerLimitTimer = 0.4 if candidate == CAR.ASCENT: ret.mass = 2031. + STD_CARGO_KG ret.wheelbase = 2.89 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 13.5 ret.steerActuatorDelay = 0.3 # end-to-end angle controller ret.lateralTuning.pid.kf = 0.00003 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.0025, 0.1], [0.00025, 0.01]] if candidate == CAR.IMPREZA: ret.mass = 1568. + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 15 ret.steerActuatorDelay = 0.4 # end-to-end angle controller ret.lateralTuning.pid.kf = 0.00005 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2, 0.3], [0.02, 0.03]] if candidate == CAR.FORESTER: ret.mass = 1568. + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 17 # learned, 14 stock ret.steerActuatorDelay = 0.1 ret.lateralTuning.pid.kf = 0.000038 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 14., 23.], [0., 14., 23.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.065, 0.2], [0.001, 0.015, 0.025]] if candidate in [CAR.FORESTER_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018]: ret.safetyParam = 1 # Outback 2018-2019 and Forester have reversed driver torque signal ret.mass = 1568 + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 20 # learned, 14 stock ret.steerActuatorDelay = 0.1 ret.lateralTuning.pid.kf = 0.000039 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 10., 20.], [0., 10., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.05, 0.2], [0.003, 0.018, 0.025]] if candidate == CAR.LEGACY_PREGLOBAL: ret.mass = 1568 + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 12.5 # 14.5 stock ret.steerActuatorDelay = 0.15 ret.lateralTuning.pid.kf = 0.00005 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 20.], [0., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.1, 0.2], [0.01, 0.02]] if candidate == CAR.OUTBACK_PREGLOBAL: ret.mass = 1568 + STD_CARGO_KG ret.wheelbase = 2.67 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 20 # learned, 14 stock ret.steerActuatorDelay = 0.1 ret.lateralTuning.pid.kf = 0.000039 ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0., 10., 20.], [0., 10., 20.]] ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.01, 0.05, 0.2], [0.003, 0.018, 0.025]] # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False ret.events = self.create_common_events(ret).to_msg() self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/subaru/radar_interface.py ================================================ #!/usr/bin/env python3 from selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass ================================================ FILE: selfdrive/car/subaru/subarucan.py ================================================ import copy from cereal import car VisualAlert = car.CarControl.HUDControl.VisualAlert def create_steering_control(packer, apply_steer, frame, steer_step): idx = (frame / steer_step) % 16 values = { "Counter": idx, "LKAS_Output": apply_steer, "LKAS_Request": 1 if apply_steer != 0 else 0, "SET_1": 1 } return packer.make_can_msg("ES_LKAS", 0, values) def create_steering_status(packer, apply_steer, frame, steer_step): return packer.make_can_msg("ES_LKAS_State", 0, {}) def create_es_distance(packer, es_distance_msg, pcm_cancel_cmd): values = copy.copy(es_distance_msg) if pcm_cancel_cmd: values["Cruise_Cancel"] = 1 return packer.make_can_msg("ES_Distance", 0, values) def create_es_lkas(packer, es_lkas_msg, enabled, visual_alert, left_line, right_line, left_lane_depart, right_lane_depart): values = copy.copy(es_lkas_msg) # Filter the stock LKAS "Keep hands on wheel" alert if values["LKAS_Alert_Msg"] == 1: values["LKAS_Alert_Msg"] = 0 # Filter the stock LKAS sending an audible alert when it turns off LKAS if values["LKAS_Alert"] == 27: values["LKAS_Alert"] = 0 # Show Keep hands on wheel alert for openpilot steerRequired alert if visual_alert == VisualAlert.steerRequired: values["LKAS_Alert_Msg"] = 1 # Ensure we don't overwrite potentially more important alerts from stock (e.g. FCW) if visual_alert == VisualAlert.ldw and values["LKAS_Alert"] == 0: if left_lane_depart: values["LKAS_Alert"] = 12 # Left lane departure dash alert elif right_lane_depart: values["LKAS_Alert"] = 11 # Right lane departure dash alert if enabled: values["LKAS_ACTIVE"] = 1 # Show LKAS lane lines values["LKAS_Dash_State"] = 2 # Green enabled indicator else: values["LKAS_Dash_State"] = 0 # LKAS Not enabled values["LKAS_Left_Line_Visible"] = int(left_line) values["LKAS_Right_Line_Visible"] = int(right_line) return packer.make_can_msg("ES_LKAS_State", 0, values) # *** Subaru Pre-global *** def subaru_preglobal_checksum(packer, values, addr): dat = packer.make_can_msg(addr, 0, values)[2] return (sum(dat[:7])) % 256 def create_preglobal_steering_control(packer, apply_steer, frame, steer_step): idx = (frame / steer_step) % 8 values = { "Counter": idx, "LKAS_Command": apply_steer, "LKAS_Active": 1 if apply_steer != 0 else 0 } values["Checksum"] = subaru_preglobal_checksum(packer, values, "ES_LKAS") return packer.make_can_msg("ES_LKAS", 0, values) def create_es_throttle_control(packer, cruise_button, es_accel_msg): values = copy.copy(es_accel_msg) values["Cruise_Button"] = cruise_button values["Checksum"] = subaru_preglobal_checksum(packer, values, "ES_CruiseThrottle") return packer.make_can_msg("ES_CruiseThrottle", 0, values) ================================================ FILE: selfdrive/car/subaru/values.py ================================================ # flake8: noqa from selfdrive.car import dbc_dict from cereal import car Ecu = car.CarParams.Ecu class CarControllerParams: STEER_MAX = 2047 # max_steer 4095 STEER_STEP = 2 # how often we update the steer cmd STEER_DELTA_UP = 50 # torque increase per refresh, 0.8s to max STEER_DELTA_DOWN = 70 # torque decrease per refresh STEER_DRIVER_ALLOWANCE = 60 # allowed driver torque before start limiting STEER_DRIVER_MULTIPLIER = 10 # weight driver torque heavily STEER_DRIVER_FACTOR = 1 # from dbc class CAR: ASCENT = "SUBARU ASCENT LIMITED 2019" IMPREZA = "SUBARU IMPREZA LIMITED 2019" FORESTER = "SUBARU FORESTER 2019" FORESTER_PREGLOBAL = "SUBARU FORESTER 2017 - 2018" LEGACY_PREGLOBAL = "SUBARU LEGACY 2015 - 2018" OUTBACK_PREGLOBAL = "SUBARU OUTBACK 2015 - 2017" OUTBACK_PREGLOBAL_2018 = "SUBARU OUTBACK 2018 - 2019" FINGERPRINTS = { CAR.ASCENT: [{ # SUBARU ASCENT LIMITED 2019 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 816: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1722: 8, 1743: 8, 1759: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8 }], CAR.IMPREZA: [{ 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 805: 8, 808: 8, 811: 8, 816: 8, 826: 8, 827: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1722: 8, 1743: 8, 1759: 8, 1786: 5, 1787: 5, 1788: 8, 1809: 8, 1813: 8, 1817: 8, 1821: 8, 1840: 8, 1848: 8, 1924: 8, 1932: 8, 1952: 8, 1960: 8 }], CAR.FORESTER: [{ # Forester 2019-2020 2: 8, 64: 8, 65: 8, 72: 8, 73: 8, 280: 8, 281: 8, 282: 8, 290: 8, 312: 8, 313: 8, 314: 8, 315: 8, 316: 8, 326: 8, 372: 8, 544: 8, 545: 8, 546: 8, 552: 8, 554: 8, 557: 8, 576: 8, 577: 8, 722: 8, 801: 8, 802: 8, 803: 8, 805: 8, 808: 8, 811: 8, 816: 8, 826: 8, 837: 8, 838: 8, 839: 8, 842: 8, 912: 8, 915: 8, 940: 8, 961: 8, 984: 8, 1614: 8, 1617: 8, 1632: 8, 1650: 8, 1651: 8, 1657: 8, 1658: 8, 1677: 8, 1697: 8, 1698: 8, 1722: 8, 1743: 8, 1759: 8, 1787: 5, 1788: 8, 1809: 8, 1813: 8, 1817: 8, 1821: 8, 1840: 8, 1848: 8, 1924: 8, 1932: 8, 1952: 8, 1960: 8 }], CAR.OUTBACK_PREGLOBAL: [{ # OUTBACK PREMIUM 2.5i 2015 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 346: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 640: 8, 642: 8, 644: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 977: 8, 1632: 8, 1745: 8, 1786: 5, 1882: 8, 2015: 8, 2016: 8, 2024: 8, 604: 8, 885: 8, 1788: 8, 316: 8, 1614: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1743: 8, 1785: 5, 1787: 5 }, # OUTBACK PREMIUM 3.6i 2015 { 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 392: 8, 604: 8, 640: 8, 642: 8, 644: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 977: 8, 1632: 8, 1745: 8, 1779: 8, 1786: 5 }, # OUTBACK LIMITED 2.5i 2018 { 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 644: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1614: 8, 1632: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1736: 8, 1743: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8 }], CAR.OUTBACK_PREGLOBAL_2018: [{ # OUTBACK LIMITED 3.6R 2019 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 644: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 886: 2, 977: 8, 1614: 8, 1632: 8, 1657: 8, 1658: 8, 1672: 8, 1736: 8, 1743: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 1862: 8, 1870: 8, 1920: 8, 1927: 8, 1928: 8, 1935: 8, 1968: 8, 1976: 8, 2016: 8, 2017: 8, 2024: 8, 2025: 8 }, # OUTBACK 2.5i-ES 2019 - Taiwan { 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 346: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 644: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 886: 2, 977: 8, 1614: 8, 1632: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1736: 8, 1745: 8, 1786: 5, 1787: 5 }], CAR.FORESTER_PREGLOBAL: [{ # FORESTER PREMIUM 2.5i 2017 2: 8, 112: 8, 117: 8, 128: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 340: 7, 342: 8, 352: 8, 353: 8, 354: 8, 355: 8, 356: 8, 554: 8, 604: 8, 640: 8, 641: 8, 642: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 886: 1, 888: 8, 977: 8, 1398: 8, 1632: 8, 1743: 8, 1744: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 1882: 8, 1895: 8, 1903: 8, 1986: 8, 1994: 8, 2015: 8, 2016: 8, 2024: 8, 644:8, 890:8, 1736:8 }], CAR.LEGACY_PREGLOBAL: [{ # LEGACY 2.5i 2017 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 392: 8, 604: 8, 640: 8, 642: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1632: 8, 1640: 8, 1736: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 644: 8 }, # LEGACY 2018 { 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 392: 8, 604: 8, 640: 8, 642: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1614: 8, 1632: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1743: 8, 1745: 8, 1778: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 2015: 8, 2016: 8, 2024: 8 }, # LEGACY 2018 { 2: 8, 208: 8, 209: 4, 210: 8, 211: 7, 212: 8, 316: 8, 320: 8, 321: 8, 324: 8, 328: 8, 329: 8, 336: 2, 338: 8, 342: 8, 352: 8, 353: 8, 354: 8, 356: 8, 358: 8, 359: 8, 392: 8, 554: 8, 604: 8, 640: 8, 642: 8, 805: 8, 864: 8, 865: 8, 866: 8, 872: 8, 880: 8, 881: 8, 882: 8, 884: 8, 885: 8, 977: 8, 1614: 8, 1632: 8, 1640: 8, 1657: 8, 1658: 8, 1672: 8, 1722: 8, 1743: 8, 1745: 8, 1785: 5, 1786: 5, 1787: 5, 1788: 8, 2015: 8, 2016: 8, 2024: 8 }], } STEER_THRESHOLD = { CAR.ASCENT: 80, CAR.IMPREZA: 80, CAR.FORESTER: 80, CAR.FORESTER_PREGLOBAL: 75, CAR.LEGACY_PREGLOBAL: 75, CAR.OUTBACK_PREGLOBAL: 75, CAR.OUTBACK_PREGLOBAL_2018: 75, } DBC = { CAR.ASCENT: dbc_dict('subaru_global_2017_generated', None), CAR.IMPREZA: dbc_dict('subaru_global_2017_generated', None), CAR.FORESTER: dbc_dict('subaru_global_2017_generated', None), CAR.FORESTER_PREGLOBAL: dbc_dict('subaru_forester_2017_generated', None), CAR.LEGACY_PREGLOBAL: dbc_dict('subaru_outback_2015_generated', None), CAR.OUTBACK_PREGLOBAL: dbc_dict('subaru_outback_2015_generated', None), CAR.OUTBACK_PREGLOBAL_2018: dbc_dict('subaru_outback_2019_generated', None), } PREGLOBAL_CARS = [CAR.FORESTER_PREGLOBAL, CAR.LEGACY_PREGLOBAL, CAR.OUTBACK_PREGLOBAL, CAR.OUTBACK_PREGLOBAL_2018] ================================================ FILE: selfdrive/car/tesla/__init__.py ================================================ ================================================ FILE: selfdrive/car/tesla/carcontroller.py ================================================ from common.numpy_fast import clip, interp from selfdrive.car.tesla.teslacan import TeslaCAN from opendbc.can.packer import CANPacker from selfdrive.car.tesla.values import CANBUS, CarControllerParams class CarController(): def __init__(self, dbc_name, CP, VM): self.CP = CP self.last_angle = 0 self.packer = CANPacker(dbc_name) self.tesla_can = TeslaCAN(dbc_name, self.packer) def update(self, enabled, CS, frame, actuators, cruise_cancel): can_sends = [] # Temp disable steering on a hands_on_fault, and allow for user override hands_on_fault = (CS.steer_warning == "EAC_ERROR_HANDS_ON" and CS.hands_on_level >= 3) lkas_enabled = enabled and (not hands_on_fault) if lkas_enabled: apply_angle = actuators.steeringAngleDeg # Angular rate limit based on speed steer_up = (self.last_angle * apply_angle > 0. and abs(apply_angle) > abs(self.last_angle)) rate_limit = CarControllerParams.RATE_LIMIT_UP if steer_up else CarControllerParams.RATE_LIMIT_DOWN max_angle_diff = interp(CS.out.vEgo, rate_limit.speed_points, rate_limit.max_angle_diff_points) apply_angle = clip(apply_angle, (self.last_angle - max_angle_diff), (self.last_angle + max_angle_diff)) # To not fault the EPS apply_angle = clip(apply_angle, (CS.out.steeringAngleDeg - 20), (CS.out.steeringAngleDeg + 20)) else: apply_angle = CS.out.steeringAngleDeg self.last_angle = apply_angle can_sends.append(self.tesla_can.create_steering_control(apply_angle, lkas_enabled, frame)) # Cancel on user steering override, since there is no steering torque blending if hands_on_fault: cruise_cancel = True # Cancel when openpilot is not enabled anymore if not enabled and bool(CS.out.cruiseState.enabled): cruise_cancel = True if ((frame % 10) == 0 and cruise_cancel): # Spam every possible counter value, otherwise it might not be accepted for counter in range(16): can_sends.append(self.tesla_can.create_action_request(CS.msg_stw_actn_req, cruise_cancel, CANBUS.chassis, counter)) can_sends.append(self.tesla_can.create_action_request(CS.msg_stw_actn_req, cruise_cancel, CANBUS.autopilot, counter)) # TODO: HUD control return can_sends ================================================ FILE: selfdrive/car/tesla/carstate.py ================================================ import copy from cereal import car from selfdrive.car.tesla.values import DBC, CANBUS, GEAR_MAP, DOORS, BUTTONS from selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine from selfdrive.config import Conversions as CV class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) self.button_states = {button.event_type: False for button in BUTTONS} self.can_define = CANDefine(DBC[CP.carFingerprint]['chassis']) # Needed by carcontroller self.msg_stw_actn_req = None self.hands_on_level = 0 self.steer_warning = None def update(self, cp, cp_cam): ret = car.CarState.new_message() # Vehicle speed ret.vEgoRaw = cp.vl["ESP_B"]["ESP_vehicleSpeed"] * CV.KPH_TO_MS ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = (ret.vEgo < 0.1) # Gas pedal ret.gas = cp.vl["DI_torque1"]["DI_pedalPos"] / 100.0 ret.gasPressed = (ret.gas > 0) # Brake pedal ret.brake = 0 ret.brakePressed = bool(cp.vl["BrakeMessage"]["driverBrakeStatus"] != 1) # Steering wheel self.hands_on_level = cp.vl["EPAS_sysStatus"]["EPAS_handsOnLevel"] self.steer_warning = self.can_define.dv["EPAS_sysStatus"]["EPAS_eacErrorCode"].get(int(cp.vl["EPAS_sysStatus"]["EPAS_eacErrorCode"]), None) steer_status = self.can_define.dv["EPAS_sysStatus"]["EPAS_eacStatus"].get(int(cp.vl["EPAS_sysStatus"]["EPAS_eacStatus"]), None) ret.steeringAngleDeg = -cp.vl["EPAS_sysStatus"]["EPAS_internalSAS"] ret.steeringRateDeg = -cp.vl["STW_ANGLHP_STAT"]["StW_AnglHP_Spd"] # This is from a different angle sensor, and at different rate ret.steeringTorque = -cp.vl["EPAS_sysStatus"]["EPAS_torsionBarTorque"] ret.steeringPressed = (self.hands_on_level > 0) ret.steerError = steer_status == "EAC_FAULT" ret.steerWarning = self.steer_warning in ["EAC_ERROR_MAX_SPEED", "EAC_ERROR_MIN_SPEED", "EAC_ERROR_TMP_FAULT", "SNA"] # TODO: not sure if this list is complete # Cruise state cruise_state = self.can_define.dv["DI_state"]["DI_cruiseState"].get(int(cp.vl["DI_state"]["DI_cruiseState"]), None) speed_units = self.can_define.dv["DI_state"]["DI_speedUnits"].get(int(cp.vl["DI_state"]["DI_speedUnits"]), None) acc_enabled = (cruise_state in ["ENABLED", "STANDSTILL", "OVERRIDE", "PRE_FAULT", "PRE_CANCEL"]) ret.cruiseState.enabled = acc_enabled # dp ret.cruiseActualEnabled = ret.cruiseState.enabled if speed_units == "KPH": ret.cruiseState.speed = cp.vl["DI_state"]["DI_digitalSpeed"] * CV.KPH_TO_MS elif speed_units == "MPH": ret.cruiseState.speed = cp.vl["DI_state"]["DI_digitalSpeed"] * CV.MPH_TO_MS ret.cruiseState.available = ((cruise_state == "STANDBY") or ret.cruiseState.enabled) ret.cruiseState.standstill = (cruise_state == "STANDSTILL") # Gear ret.gearShifter = GEAR_MAP[self.can_define.dv["DI_torque2"]["DI_gear"].get(int(cp.vl["DI_torque2"]["DI_gear"]), "DI_GEAR_INVALID")] # Buttons buttonEvents = [] for button in BUTTONS: state = (cp.vl[button.can_addr][button.can_msg] in button.values) if self.button_states[button.event_type] != state: event = car.CarState.ButtonEvent.new_message() event.type = button.event_type event.pressed = state buttonEvents.append(event) self.button_states[button.event_type] = state ret.buttonEvents = buttonEvents # Doors ret.doorOpen = any([(self.can_define.dv["GTW_carState"][door].get(int(cp.vl["GTW_carState"][door]), "OPEN") == "OPEN") for door in DOORS]) # Blinkers ret.leftBlinker = (cp.vl["GTW_carState"]["BC_indicatorLStatus"] == 1) ret.rightBlinker = (cp.vl["GTW_carState"]["BC_indicatorRStatus"] == 1) # Seatbelt ret.seatbeltUnlatched = (cp.vl["SDM1"]["SDM_bcklDrivStatus"] != 1) # TODO: blindspot # Messages needed by carcontroller self.msg_stw_actn_req = copy.copy(cp.vl["STW_ACTN_RQ"]) # dp - brake lights ret.brakeLights = ret.brakePressed return ret @staticmethod def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("ESP_vehicleSpeed", "ESP_B", 0), ("DI_pedalPos", "DI_torque1", 0), ("DI_brakePedal", "DI_torque2", 0), ("StW_AnglHP", "STW_ANGLHP_STAT", 0), ("StW_AnglHP_Spd", "STW_ANGLHP_STAT", 0), ("EPAS_handsOnLevel", "EPAS_sysStatus", 0), ("EPAS_torsionBarTorque", "EPAS_sysStatus", 0), ("EPAS_internalSAS", "EPAS_sysStatus", 0), ("EPAS_eacStatus", "EPAS_sysStatus", 1), ("EPAS_eacErrorCode", "EPAS_sysStatus", 0), ("DI_cruiseState", "DI_state", 0), ("DI_digitalSpeed", "DI_state", 0), ("DI_speedUnits", "DI_state", 0), ("DI_gear", "DI_torque2", 0), ("DOOR_STATE_FL", "GTW_carState", 1), ("DOOR_STATE_FR", "GTW_carState", 1), ("DOOR_STATE_RL", "GTW_carState", 1), ("DOOR_STATE_RR", "GTW_carState", 1), ("DOOR_STATE_FrontTrunk", "GTW_carState", 1), ("BOOT_STATE", "GTW_carState", 1), ("BC_indicatorLStatus", "GTW_carState", 1), ("BC_indicatorRStatus", "GTW_carState", 1), ("SDM_bcklDrivStatus", "SDM1", 0), ("driverBrakeStatus", "BrakeMessage", 0), # We copy this whole message when spamming cancel ("SpdCtrlLvr_Stat", "STW_ACTN_RQ", 0), ("VSL_Enbl_Rq", "STW_ACTN_RQ", 0), ("SpdCtrlLvrStat_Inv", "STW_ACTN_RQ", 0), ("DTR_Dist_Rq", "STW_ACTN_RQ", 0), ("TurnIndLvr_Stat", "STW_ACTN_RQ", 0), ("HiBmLvr_Stat", "STW_ACTN_RQ", 0), ("WprWashSw_Psd", "STW_ACTN_RQ", 0), ("WprWash_R_Sw_Posn_V2", "STW_ACTN_RQ", 0), ("StW_Lvr_Stat", "STW_ACTN_RQ", 0), ("StW_Cond_Flt", "STW_ACTN_RQ", 0), ("StW_Cond_Psd", "STW_ACTN_RQ", 0), ("HrnSw_Psd", "STW_ACTN_RQ", 0), ("StW_Sw00_Psd", "STW_ACTN_RQ", 0), ("StW_Sw01_Psd", "STW_ACTN_RQ", 0), ("StW_Sw02_Psd", "STW_ACTN_RQ", 0), ("StW_Sw03_Psd", "STW_ACTN_RQ", 0), ("StW_Sw04_Psd", "STW_ACTN_RQ", 0), ("StW_Sw05_Psd", "STW_ACTN_RQ", 0), ("StW_Sw06_Psd", "STW_ACTN_RQ", 0), ("StW_Sw07_Psd", "STW_ACTN_RQ", 0), ("StW_Sw08_Psd", "STW_ACTN_RQ", 0), ("StW_Sw09_Psd", "STW_ACTN_RQ", 0), ("StW_Sw10_Psd", "STW_ACTN_RQ", 0), ("StW_Sw11_Psd", "STW_ACTN_RQ", 0), ("StW_Sw12_Psd", "STW_ACTN_RQ", 0), ("StW_Sw13_Psd", "STW_ACTN_RQ", 0), ("StW_Sw14_Psd", "STW_ACTN_RQ", 0), ("StW_Sw15_Psd", "STW_ACTN_RQ", 0), ("WprSw6Posn", "STW_ACTN_RQ", 0), ("MC_STW_ACTN_RQ", "STW_ACTN_RQ", 0), ("CRC_STW_ACTN_RQ", "STW_ACTN_RQ", 0), ] checks = [ # sig_address, frequency ("ESP_B", 50), ("DI_torque1", 100), ("DI_torque2", 100), ("STW_ANGLHP_STAT", 100), ("EPAS_sysStatus", 25), ("DI_state", 10), ("STW_ACTN_RQ", 10), ("GTW_carState", 10), ("SDM1", 10), ("BrakeMessage", 50), ] return CANParser(DBC[CP.carFingerprint]['chassis'], signals, checks, CANBUS.chassis) @staticmethod def get_cam_can_parser(CP): signals = [ # sig_name, sig_address, default ] checks = [ # sig_address, frequency ] return CANParser(DBC[CP.carFingerprint]['chassis'], signals, checks, CANBUS.autopilot) ================================================ FILE: selfdrive/car/tesla/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.car.tesla.values import CAR from selfdrive.car import STD_CARGO_KG, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness from selfdrive.car.interfaces import CarInterfaceBase class CarInterface(CarInterfaceBase): @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "tesla" ret.safetyModel = car.CarParams.SafetyModel.tesla # There is no safe way to do steer blending with user torque, # so the steering behaves like autopilot. This is not # how openpilot should be, hence dashcamOnly ret.dashcamOnly = True ret.steerControlType = car.CarParams.SteerControlType.angle ret.openpilotLongitudinalControl = False ret.communityFeature = True ret.steerActuatorDelay = 0.1 ret.steerRateCost = 0.5 if candidate in [CAR.AP2_MODELS, CAR.AP1_MODELS]: ret.mass = 2100. + STD_CARGO_KG ret.wheelbase = 2.959 ret.centerToFront = ret.wheelbase * 0.5 ret.steerRatio = 13.5 else: raise ValueError(f"Unsupported car: {candidate}") ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront) return ret def update(self, c, can_strings): self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid events = self.create_common_events(ret) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.cruiseControl.cancel) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/tesla/radar_interface.py ================================================ #!/usr/bin/env python3 from cereal import car from opendbc.can.parser import CANParser from selfdrive.car.tesla.values import DBC, CANBUS from selfdrive.car.interfaces import RadarInterfaceBase RADAR_MSGS_A = list(range(0x310, 0x36E, 3)) RADAR_MSGS_B = list(range(0x311, 0x36F, 3)) NUM_POINTS = len(RADAR_MSGS_A) def get_radar_can_parser(CP): # Status messages signals = [ ('RADC_HWFail', 'TeslaRadarSguInfo', 0), ('RADC_SGUFail', 'TeslaRadarSguInfo', 0), ('RADC_SensorDirty', 'TeslaRadarSguInfo', 0), ] checks = [ ('TeslaRadarSguInfo', 10), ] # Radar tracks. There are also raw point clouds available, # we don't use those. for i in range(NUM_POINTS): msg_id_a = RADAR_MSGS_A[i] msg_id_b = RADAR_MSGS_B[i] # There is a bunch more info in the messages, # but these are the only things actually used in openpilot signals.extend([ ('LongDist', msg_id_a, 255), ('LongSpeed', msg_id_a, 0), ('LatDist', msg_id_a, 0), ('LongAccel', msg_id_a, 0), ('Meas', msg_id_a, 0), ('Tracked', msg_id_a, 0), ('Index', msg_id_a, 0), ('LatSpeed', msg_id_b, 0), ('Index2', msg_id_b, 0), ]) checks.extend([ (msg_id_a, 8), (msg_id_b, 8), ]) return CANParser(DBC[CP.carFingerprint]['radar'], signals, checks, CANBUS.radar) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.rcp = get_radar_can_parser(CP) self.updated_messages = set() self.track_id = 0 self.trigger_msg = RADAR_MSGS_B[-1] def update(self, can_strings): if self.rcp is None: return super().update(None) values = self.rcp.update_strings(can_strings) self.updated_messages.update(values) if self.trigger_msg not in self.updated_messages: return None ret = car.RadarData.new_message() # Errors errors = [] sgu_info = self.rcp.vl['TeslaRadarSguInfo'] if not self.rcp.can_valid: errors.append('canError') if sgu_info['RADC_HWFail'] or sgu_info['RADC_SGUFail'] or sgu_info['RADC_SensorDirty']: errors.append('fault') ret.errors = errors # Radar tracks for i in range(NUM_POINTS): msg_a = self.rcp.vl[RADAR_MSGS_A[i]] msg_b = self.rcp.vl[RADAR_MSGS_B[i]] # Make sure msg A and B are together if msg_a['Index'] != msg_b['Index2']: continue # Check if it's a valid track if not msg_a['Tracked']: if i in self.pts: del self.pts[i] continue # New track! if i not in self.pts: self.pts[i] = car.RadarData.RadarPoint.new_message() self.pts[i].trackId = self.track_id self.track_id += 1 # Parse track data self.pts[i].dRel = msg_a['LongDist'] self.pts[i].yRel = msg_a['LatDist'] self.pts[i].vRel = msg_a['LongSpeed'] self.pts[i].aRel = msg_a['LongAccel'] self.pts[i].yvRel = msg_b['LatSpeed'] self.pts[i].measured = bool(msg_a['Meas']) ret.points = list(self.pts.values()) self.updated_messages.clear() return ret ================================================ FILE: selfdrive/car/tesla/teslacan.py ================================================ import copy import crcmod from opendbc.can.can_define import CANDefine from selfdrive.car.tesla.values import CANBUS class TeslaCAN: def __init__(self, dbc_name, packer): self.can_define = CANDefine(dbc_name) self.packer = packer self.crc = crcmod.mkCrcFun(0x11d, initCrc=0x00, rev=False, xorOut=0xff) @staticmethod def checksum(msg_id, dat): # TODO: get message ID from name instead ret = (msg_id & 0xFF) + ((msg_id >> 8) & 0xFF) ret += sum(dat) return ret & 0xFF def create_steering_control(self, angle, enabled, frame): values = { "DAS_steeringAngleRequest": -angle, "DAS_steeringHapticRequest": 0, "DAS_steeringControlType": 1 if enabled else 0, "DAS_steeringControlCounter": (frame % 16), } data = self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values)[2] values["DAS_steeringControlChecksum"] = self.checksum(0x488, data[:3]) return self.packer.make_can_msg("DAS_steeringControl", CANBUS.chassis, values) def create_action_request(self, msg_stw_actn_req, cancel, bus, counter): values = copy.copy(msg_stw_actn_req) if cancel: values["SpdCtrlLvr_Stat"] = 1 values["MC_STW_ACTN_RQ"] = counter data = self.packer.make_can_msg("STW_ACTN_RQ", bus, values)[2] values["CRC_STW_ACTN_RQ"] = self.crc(data[:7]) return self.packer.make_can_msg("STW_ACTN_RQ", bus, values) ================================================ FILE: selfdrive/car/tesla/values.py ================================================ # flake8: noqa from collections import namedtuple from selfdrive.car import dbc_dict from cereal import car Button = namedtuple('Button', ['event_type', 'can_addr', 'can_msg', 'values']) AngleRateLimit = namedtuple('AngleRateLimit', ['speed_points', 'max_angle_diff_points']) class CAR: AP1_MODELS = 'TESLA AP1 MODEL S' AP2_MODELS = 'TESLA AP2 MODEL S' FINGERPRINTS = { CAR.AP2_MODELS: [ { 1: 8, 3: 8, 14: 8, 21: 4, 69: 8, 109: 4, 257: 3, 264: 8, 277: 6, 280: 6, 293: 4, 296: 4, 309: 5, 325: 8, 328: 5, 336: 8, 341: 8, 360: 7, 373: 8, 389: 8, 415: 8, 513: 5, 516: 8, 518: 8, 520: 4, 522: 8, 524: 8, 526: 8, 532: 3, 536: 8, 537: 3, 542: 8, 551: 5, 552: 2, 556: 8, 558: 8, 568: 8, 569: 8, 574: 8, 577: 8, 582: 5, 583: 8, 584: 4, 585: 8, 590: 8, 601: 8, 606: 8, 608: 1, 622: 8, 627: 6, 638: 8, 641: 8, 643: 8, 692: 8, 693: 8, 695: 8, 696: 8, 697: 8, 699: 8, 700: 8, 701: 8, 702: 8, 703: 8, 704: 8, 708: 8, 709: 8, 710: 8, 711: 8, 712: 8, 728: 8, 744: 8, 760: 8, 772: 8, 775: 8, 776: 8, 777: 8, 778: 8, 782: 8, 788: 8, 791: 8, 792: 8, 796: 2, 797: 8, 798: 6, 799: 8, 804: 8, 805: 8, 807: 8, 808: 1, 811: 8, 812: 8, 813: 8, 814: 5, 815: 8, 820: 8, 823: 8, 824: 8, 829: 8, 830: 5, 836: 8, 840: 8, 845: 8, 846: 5, 848: 8, 852: 8, 853: 8, 856: 4, 857: 6, 861: 8, 862: 5, 872: 8, 876: 8, 877: 8, 879: 8, 880: 8, 882: 8, 884: 8, 888: 8, 893: 8, 894: 8, 901: 6, 904: 3, 905: 8, 906: 8, 908: 2, 909: 8, 910: 8, 912: 8, 920: 8, 921: 8, 925: 4, 926: 6, 936: 8, 941: 8, 949: 8, 952: 8, 953: 6, 968: 8, 969: 6, 970: 8, 971: 8, 977: 8, 984: 8, 987: 8, 990: 8, 1000: 8, 1001: 8, 1006: 8, 1007: 8, 1008: 8, 1010: 6, 1014: 1, 1015: 8, 1016: 8, 1017: 8, 1018: 8, 1020: 8, 1026: 8, 1028: 8, 1029: 8, 1030: 8, 1032: 1, 1033: 1, 1034: 8, 1048: 1, 1049: 8, 1061: 8, 1064: 8, 1065: 8, 1070: 8, 1080: 8, 1081: 8, 1097: 8, 1113: 8, 1129: 8, 1145: 8, 1160: 4, 1177: 8, 1281: 8, 1328: 8, 1329: 8, 1332: 8, 1335: 8, 1337: 8, 1353: 8, 1368: 8, 1412: 8, 1436: 8, 1476: 8, 1481: 8, 1497: 8, 1513: 8, 1519: 8, 1601: 8, 1605: 8, 1617: 8, 1621: 8, 1800: 4, 1804: 8, 1812: 8, 1815: 8, 1816: 8, 1824: 8, 1828: 8, 1831: 8, 1832: 8, 1864: 8, 1880: 8, 1892: 8, 1896: 8, 1912: 8, 1960: 8, 1992: 8, 2008: 3, 2043: 5, 2045: 4 }, ], CAR.AP1_MODELS: [ { 1: 8, 3: 8, 14: 8, 21: 4, 69: 8, 109: 4, 257: 3, 264: 8, 267: 5, 277: 6, 280: 6, 283: 5, 293: 4, 296: 4, 309: 5, 325: 8, 328: 5, 336: 8, 341: 8, 360: 7, 373: 8, 389: 8, 415: 8, 513: 5, 516: 8, 520: 4, 522: 8, 524: 8, 526: 8, 532: 3, 536: 8, 537: 3, 542: 8, 551: 5, 552: 2, 556: 8, 558: 8, 568: 8, 569: 8, 574: 8, 577: 8, 582: 5, 584: 4, 585: 8, 590: 8, 606: 8, 622: 8, 627: 6, 638: 8, 641: 8, 643: 8, 660: 5, 693: 8, 696: 8, 697: 8, 712: 8, 728: 8, 744: 8, 760: 8, 772: 8, 775: 8, 776: 8, 777: 8, 778: 8, 782: 8, 788: 8, 791: 8, 792: 8, 796: 2, 797: 8, 798: 6, 799: 8, 804: 8, 805: 8, 807: 8, 808: 1, 809: 8, 812: 8, 813: 8, 814: 5, 815: 8, 820: 8, 823: 8, 824: 8, 829: 8, 830: 5, 836: 8, 840: 8, 841: 8, 845: 8, 846: 5, 852: 8, 856: 4, 857: 6, 861: 8, 862: 5, 872: 8, 873: 8, 877: 8, 878: 8, 879: 8, 880: 8, 884: 8, 888: 8, 889: 8, 893: 8, 896: 8, 901: 6, 904: 3, 905: 8, 908: 2, 909: 8, 920: 8, 921: 8, 925: 4, 936: 8, 937: 8, 941: 8, 949: 8, 952: 8, 953: 6, 957: 8, 968: 8, 973: 8, 984: 8, 987: 8, 989: 8, 990: 8, 1000: 8, 1001: 8, 1006: 8, 1016: 8, 1026: 8, 1028: 8, 1029: 8, 1030: 8, 1032: 1, 1033: 1, 1034: 8, 1048: 1, 1064: 8, 1070: 8, 1080: 8, 1160: 4, 1281: 8, 1329: 8, 1332: 8, 1335: 8, 1337: 8, 1368: 8, 1412: 8, 1436: 8, 1465: 8, 1476: 8, 1497: 8, 1524: 8, 1527: 8, 1601: 8, 1605: 8, 1611: 8, 1614: 8, 1617: 8, 1621: 8, 1627: 8, 1630: 8, 1800: 4, 1804: 8, 1812: 8, 1815: 8, 1816: 8, 1828: 8, 1831: 8, 1832: 8, 1840: 8, 1848: 8, 1864: 8, 1880: 8, 1892: 8, 1896: 8, 1912: 8, 1960: 8, 1992: 8, 2008: 3, 2043: 5, 2045: 4 }, ], } DBC = { CAR.AP2_MODELS: dbc_dict(None, 'tesla_radar', chassis_dbc='tesla_can'), CAR.AP1_MODELS: dbc_dict(None, 'tesla_radar', chassis_dbc='tesla_can'), } class CANBUS: chassis = 0 autopilot = 2 radar = 1 GEAR_MAP = { "DI_GEAR_INVALID": car.CarState.GearShifter.unknown, "DI_GEAR_P": car.CarState.GearShifter.park, "DI_GEAR_R": car.CarState.GearShifter.reverse, "DI_GEAR_N": car.CarState.GearShifter.neutral, "DI_GEAR_D": car.CarState.GearShifter.drive, "DI_GEAR_SNA": car.CarState.GearShifter.unknown, } DOORS = ["DOOR_STATE_FL", "DOOR_STATE_FR", "DOOR_STATE_RL", "DOOR_STATE_RR", "DOOR_STATE_FrontTrunk", "BOOT_STATE"] # Make sure the message and addr is also in the CAN parser! BUTTONS = [ Button(car.CarState.ButtonEvent.Type.leftBlinker, "STW_ACTN_RQ", "TurnIndLvr_Stat", [1]), Button(car.CarState.ButtonEvent.Type.rightBlinker, "STW_ACTN_RQ", "TurnIndLvr_Stat", [2]), Button(car.CarState.ButtonEvent.Type.accelCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [4, 16]), Button(car.CarState.ButtonEvent.Type.decelCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [8, 32]), Button(car.CarState.ButtonEvent.Type.cancel, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [2]), Button(car.CarState.ButtonEvent.Type.resumeCruise, "STW_ACTN_RQ", "SpdCtrlLvr_Stat", [1]), ] class CarControllerParams: RATE_LIMIT_UP = AngleRateLimit(speed_points=[0., 5., 15.], max_angle_diff_points=[5., .8, .15]) RATE_LIMIT_DOWN = AngleRateLimit(speed_points=[0., 5., 15.], max_angle_diff_points=[5., 3.5, 0.4]) ================================================ FILE: selfdrive/car/tests/__init__.py ================================================ ================================================ FILE: selfdrive/car/tests/test_car_interfaces.py ================================================ #!/usr/bin/env python3 import unittest import importlib from parameterized import parameterized from cereal import car from selfdrive.car.fingerprints import all_known_cars from selfdrive.car.car_helpers import interfaces from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS class TestCarInterfaces(unittest.TestCase): @parameterized.expand([(car,) for car in all_known_cars()]) def test_car_interfaces(self, car_name): print(car_name) if car_name in FINGERPRINTS: fingerprint = FINGERPRINTS[car_name][0] else: fingerprint = {} CarInterface, CarController, CarState = interfaces[car_name] fingerprints = { 0: fingerprint, 1: fingerprint, 2: fingerprint, } car_fw = [] car_params = CarInterface.get_params(car_name, fingerprints, car_fw) car_interface = CarInterface(car_params, CarController, CarState) assert car_params assert car_interface self.assertGreater(car_params.mass, 1) self.assertGreater(car_params.steerRateCost, 1e-3) if car_params.steerControlType != car.CarParams.SteerControlType.angle: tuning = car_params.lateralTuning.which() if tuning == 'pid': self.assertTrue(len(car_params.lateralTuning.pid.kpV)) elif tuning == 'lqr': self.assertTrue(len(car_params.lateralTuning.lqr.a)) elif tuning == 'indi': self.assertTrue(len(car_params.lateralTuning.indi.outerLoopGainV)) # Run car interface CC = car.CarControl.new_message() for _ in range(10): car_interface.update(CC, []) car_interface.apply(CC) car_interface.apply(CC) CC = car.CarControl.new_message() CC.enabled = True for _ in range(10): car_interface.update(CC, []) car_interface.apply(CC) car_interface.apply(CC) # Test radar interface RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % car_params.carName).RadarInterface radar_interface = RadarInterface(car_params) assert radar_interface # Run radar interface once radar_interface.update([]) if not car_params.radarOffCan and hasattr(radar_interface, '_update') and hasattr(radar_interface, 'trigger_msg'): radar_interface._update([radar_interface.trigger_msg]) if __name__ == "__main__": unittest.main() ================================================ FILE: selfdrive/car/toyota/__init__.py ================================================ ================================================ FILE: selfdrive/car/toyota/carcontroller.py ================================================ from cereal import car from common.numpy_fast import clip, interp from selfdrive.car import apply_toyota_steer_torque_limits, create_gas_command, make_can_msg from selfdrive.car.toyota.toyotacan import create_steer_command, create_ui_command, \ create_accel_command, create_acc_cancel_command, \ create_fcw_command, create_lta_steer_command from selfdrive.car.toyota.values import CAR, STATIC_DSU_MSGS, NO_STOP_TIMER_CAR, TSS2_CAR, \ MIN_ACC_SPEED, PEDAL_HYST_GAP, PEDAL_SCALE, CarControllerParams from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl VisualAlert = car.CarControl.HUDControl.VisualAlert def accel_hysteresis(accel, accel_steady, enabled): # for small accel oscillations within ACCEL_HYST_GAP, don't change the accel command if not enabled: # send 0 when disabled, otherwise acc faults accel_steady = 0. elif accel > accel_steady + CarControllerParams.ACCEL_HYST_GAP: accel_steady = accel - CarControllerParams.ACCEL_HYST_GAP elif accel < accel_steady - CarControllerParams.ACCEL_HYST_GAP: accel_steady = accel + CarControllerParams.ACCEL_HYST_GAP accel = accel_steady return accel, accel_steady class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.last_steer = 0 self.accel_steady = 0. self.alert_active = False self.last_standstill = False self.standstill_req = False self.steer_rate_limited = False self.use_interceptor = False self.packer = CANPacker(dbc_name) def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert, left_line, right_line, lead, left_lane_depart, right_lane_depart, dragonconf): # *** compute control surfaces *** # gas and brake interceptor_gas_cmd = 0. pcm_accel_cmd = actuators.accel if CS.CP.enableGasInterceptor: # handle hysteresis when around the minimum acc speed if CS.out.vEgo < MIN_ACC_SPEED: self.use_interceptor = True elif CS.out.vEgo > MIN_ACC_SPEED + PEDAL_HYST_GAP: self.use_interceptor = False if self.use_interceptor and enabled: # only send negative accel when using interceptor. gas handles acceleration # +0.18 m/s^2 offset to reduce ABS pump usage when OP is engaged MAX_INTERCEPTOR_GAS = interp(CS.out.vEgo, [0.0, MIN_ACC_SPEED], [0.2, 0.5]) interceptor_gas_cmd = clip(actuators.accel / PEDAL_SCALE, 0., MAX_INTERCEPTOR_GAS) pcm_accel_cmd = 0.18 - max(0, -actuators.accel) pcm_accel_cmd, self.accel_steady = accel_hysteresis(pcm_accel_cmd, self.accel_steady, enabled) pcm_accel_cmd = clip(pcm_accel_cmd, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) # steer torque new_steer = int(round(actuators.steer * CarControllerParams.STEER_MAX)) apply_steer = apply_toyota_steer_torque_limits(new_steer, self.last_steer, CS.out.steeringTorqueEps, CarControllerParams) self.steer_rate_limited = new_steer != apply_steer # Cut steering while we're in a known fault state (2s) if not enabled or CS.steer_state in [9, 25] or abs(CS.out.steeringRateDeg) > 100 or (abs(CS.out.steeringAngleDeg) > 150 and CS.CP.carFingerprint in [CAR.RAV4H, CAR.PRIUS]): apply_steer = 0 apply_steer_req = 0 else: apply_steer_req = 1 if not enabled and CS.pcm_acc_status: # send pcm acc cancel cmd if drive is disabled but pcm is still on, or if the system can't be activated pcm_cancel_cmd = 1 # on entering standstill, send standstill request if not dragonconf.dpToyotaSng and CS.out.standstill and not self.last_standstill and CS.CP.carFingerprint not in NO_STOP_TIMER_CAR: self.standstill_req = True if CS.pcm_acc_status != 8: # pcm entered standstill or it's disabled self.standstill_req = False # dp blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on self.last_steer = apply_steer self.last_accel = pcm_accel_cmd self.last_standstill = CS.out.standstill can_sends = [] #*** control msgs *** #print("steer {0} {1} {2} {3}".format(apply_steer, min_lim, max_lim, CS.steer_torque_motor) # toyota can trace shows this message at 42Hz, with counter adding alternatively 1 and 2; # sending it at 100Hz seem to allow a higher rate limit, as the rate limit seems imposed # on consecutive messages can_sends.append(create_steer_command(self.packer, apply_steer, apply_steer_req, frame)) if frame % 2 == 0 and CS.CP.carFingerprint in TSS2_CAR: can_sends.append(create_lta_steer_command(self.packer, 0, 0, frame // 2)) # LTA mode. Set ret.steerControlType = car.CarParams.SteerControlType.angle and whitelist 0x191 in the panda # if frame % 2 == 0: # can_sends.append(create_steer_command(self.packer, 0, 0, frame // 2)) # can_sends.append(create_lta_steer_command(self.packer, actuators.steeringAngleDeg, apply_steer_req, frame // 2)) if dragonconf.dpAtl and dragonconf.dpAtlOpLong and not CS.out.cruiseActualEnabled: pcm_accel_cmd = 0. if CS.CP.enableGasInterceptor: interceptor_gas_cmd = 0. # we can spam can to cancel the system even if we are using lat only control if (frame % 3 == 0 and CS.CP.openpilotLongitudinalControl) or pcm_cancel_cmd: lead = lead or CS.out.vEgo < 12. # at low speed we always assume the lead is present do ACC can be engaged if dragonconf.dpAtl and not dragonconf.dpAtlOpLong: pass # Lexus IS uses a different cancellation message elif pcm_cancel_cmd and CS.CP.carFingerprint == CAR.LEXUS_IS: can_sends.append(create_acc_cancel_command(self.packer)) elif CS.CP.openpilotLongitudinalControl: can_sends.append(create_accel_command(self.packer, pcm_accel_cmd, pcm_cancel_cmd, self.standstill_req, lead, CS.acc_type, CS.distance)) else: can_sends.append(create_accel_command(self.packer, 0, pcm_cancel_cmd, False, lead, CS.acc_type, CS.distance)) if frame % 2 == 0 and CS.CP.enableGasInterceptor: # send exactly zero if gas cmd is zero. Interceptor will send the max between read value and gas cmd. # This prevents unexpected pedal range rescaling can_sends.append(create_gas_command(self.packer, interceptor_gas_cmd, frame // 2)) # ui mesg is at 100Hz but we send asap if: # - there is something to display # - there is something to stop displaying fcw_alert = hud_alert == VisualAlert.fcw steer_alert = hud_alert in [VisualAlert.steerRequired, VisualAlert.ldw] send_ui = False if ((fcw_alert or steer_alert) and not self.alert_active) or \ (not (fcw_alert or steer_alert) and self.alert_active): send_ui = True self.alert_active = not self.alert_active elif pcm_cancel_cmd: # forcing the pcm to disengage causes a bad fault sound so play a good sound instead send_ui = True # dp if not dragonconf.dpToyotaLdw: left_lane_depart = False right_lane_depart = False if (frame % 100 == 0 or send_ui): can_sends.append(create_ui_command(self.packer, steer_alert, pcm_cancel_cmd, left_line, right_line, left_lane_depart, right_lane_depart)) if frame % 100 == 0 and CS.CP.enableDsu: can_sends.append(create_fcw_command(self.packer, fcw_alert)) #*** static msgs *** for (addr, cars, bus, fr_step, vl) in STATIC_DSU_MSGS: if frame % fr_step == 0 and CS.CP.enableDsu and CS.CP.carFingerprint in cars: can_sends.append(make_can_msg(addr, vl, bus)) return can_sends ================================================ FILE: selfdrive/car/toyota/carstate.py ================================================ import time from math import floor from cereal import car from common.numpy_fast import mean from opendbc.can.can_define import CANDefine from selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from selfdrive.config import Conversions as CV from selfdrive.car.toyota.values import CAR, DBC, STEER_THRESHOLD, NO_STOP_TIMER_CAR, TSS2_CAR from common.params import Params, put_nonblocking # dp DP_ACCEL_ECO = 0 DP_ACCEL_NORMAL = 1 DP_ACCEL_SPORT = 2 _TRAFFIC_SINGAL_MAP = { 1: "kph", 36: "mph", 65: "No overtake", 66: "No overtake" } class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC[CP.carFingerprint]["pt"]) self.shifter_values = can_define.dv["GEAR_PACKET"]["GEAR"] # On cars with cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"] # the signal is zeroed to where the steering angle is at start. # Need to apply an offset as soon as the steering angle measurements are both received self.needs_angle_offset = True self.accurate_steer_angle_seen = False self.angle_offset = 0. self._init_traffic_signals() # dp self.read_distance_lines = 0 self.read_distance_lines_init = False self.distance = 0 self.dp_toyota_zss = Params().get_bool('dp_toyota_zss') self.dp_accel_profile = None self.dp_accel_profile_prev = None self.dp_accel_profile_init = False self.low_speed_lockout = False self.acc_type = 1 self.dp_toyota_fp_btn_link = Params().get_bool('dp_toyota_fp_btn_link') self.dp_toyota_ap_btn_link = Params().get_bool('dp_toyota_ap_btn_link') def update(self, cp, cp_cam): ret = car.CarState.new_message() ret.doorOpen = any([cp.vl["SEATS_DOORS"]["DOOR_OPEN_FL"], cp.vl["SEATS_DOORS"]["DOOR_OPEN_FR"], cp.vl["SEATS_DOORS"]["DOOR_OPEN_RL"], cp.vl["SEATS_DOORS"]["DOOR_OPEN_RR"]]) ret.seatbeltUnlatched = cp.vl["SEATS_DOORS"]["SEATBELT_DRIVER_UNLATCHED"] != 0 ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0 ret.brakeLights = bool(cp.vl["ESP_CONTROL"]['BRAKE_LIGHTS_ACC'] or cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0) if self.CP.enableGasInterceptor: ret.gas = (cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS"] + cp.vl["GAS_SENSOR"]["INTERCEPTOR_GAS2"]) / 2. ret.gasPressed = ret.gas > 15 else: if self.CP.carFingerprint == CAR.LEXUS_ISH: ret.gas = cp.vl["GAS_PEDAL_ALT"]['GAS_PEDAL'] else: ret.gas = cp.vl["GAS_PEDAL"]['GAS_PEDAL'] ret.gasPressed = cp.vl["PCM_CRUISE"]["GAS_RELEASED"] == 0 ret.wheelSpeeds.fl = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FL"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_FR"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RL"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = cp.vl["WHEEL_SPEEDS"]["WHEEL_SPEED_RR"] * CV.KPH_TO_MS ret.vEgoRaw = mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr]) ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) ret.standstill = ret.vEgoRaw < 0.001 # Some newer models have a more accurate angle measurement in the TORQUE_SENSOR message. Use if non-zero if self.dp_toyota_zss or abs(cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"]) > 1e-3: self.accurate_steer_angle_seen = True if self.accurate_steer_angle_seen: if self.dp_toyota_zss: ret.steeringAngleDeg = cp.vl["SECONDARY_STEER_ANGLE"]["ZORRO_STEER"] - self.angle_offset else: ret.steeringAngleDeg = cp.vl["STEER_TORQUE_SENSOR"]["STEER_ANGLE"] - self.angle_offset if self.needs_angle_offset: angle_wheel = cp.vl["STEER_ANGLE_SENSOR"]["STEER_ANGLE"] + cp.vl["STEER_ANGLE_SENSOR"]["STEER_FRACTION"] if abs(angle_wheel) > 1e-3: self.needs_angle_offset = False self.angle_offset = ret.steeringAngleDeg - angle_wheel else: ret.steeringAngleDeg = cp.vl["STEER_ANGLE_SENSOR"]["STEER_ANGLE"] + cp.vl["STEER_ANGLE_SENSOR"]["STEER_FRACTION"] ret.steeringRateDeg = cp.vl["STEER_ANGLE_SENSOR"]["STEER_RATE"] can_gear = int(cp.vl["GEAR_PACKET"]["GEAR"]) ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(can_gear, None)) #dp: Thank you Arne (acceleration) if self.dp_toyota_ap_btn_link: if self.CP.carFingerprint in [CAR.LEXUS_ESH_TSS2, CAR.RAV4H_TSS2, CAR.CHRH, CAR.PRIUS_TSS2, CAR.HIGHLANDERH_TSS2]: sport_on = cp.vl["GEAR_PACKET2"]['SPORT_ON'] econ_on = cp.vl["GEAR_PACKET2"]['ECON_ON'] else: try: econ_on = cp.vl["GEAR_PACKET"]['ECON_ON'] except KeyError: econ_on = 0 if self.CP.carFingerprint == CAR.RAV4_TSS2: sport_on = cp.vl["GEAR_PACKET"]['SPORT_ON_2'] else: try: sport_on = cp.vl["GEAR_PACKET"]['SPORT_ON'] except KeyError: sport_on = 0 if sport_on == 0 and econ_on == 0: self.dp_accel_profile = DP_ACCEL_NORMAL elif sport_on == 1: self.dp_accel_profile = DP_ACCEL_SPORT elif econ_on == 1: self.dp_accel_profile = DP_ACCEL_ECO # if init is false, we sync profile with whatever mode we have on car if not self.dp_accel_profile_init or self.dp_accel_profile != self.dp_accel_profile_prev: put_nonblocking('dp_accel_profile', str(self.dp_accel_profile)) put_nonblocking('dp_last_modified',str(floor(time.time()))) self.dp_accel_profile_init = True self.dp_accel_profile_prev = self.dp_accel_profile #dp: Thank you Arne (distance button) if self.dp_toyota_fp_btn_link: if not self.read_distance_lines_init or self.read_distance_lines != cp.vl["PCM_CRUISE_SM"]['DISTANCE_LINES']: self.read_distance_lines_init = True self.read_distance_lines = cp.vl["PCM_CRUISE_SM"]['DISTANCE_LINES'] put_nonblocking('dp_following_profile', str(int(max(self.read_distance_lines - 1, 0)))) put_nonblocking('dp_last_modified',str(floor(time.time()))) ret.leftBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 1 ret.rightBlinker = cp.vl["STEERING_LEVERS"]["TURN_SIGNALS"] == 2 ret.steeringTorque = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_DRIVER"] ret.steeringTorqueEps = cp.vl["STEER_TORQUE_SENSOR"]["STEER_TORQUE_EPS"] #dp ret.engineRPM = cp.vl["ENGINE_RPM"]['RPM'] # we could use the override bit from dbc, but it's triggered at too high torque values ret.steeringPressed = abs(ret.steeringTorque) > STEER_THRESHOLD ret.steerWarning = cp.vl["EPS_STATUS"]["LKA_STATE"] not in [1, 5] if self.CP.carFingerprint in [CAR.LEXUS_IS, CAR.LEXUS_ISH]: ret.cruiseState.available = cp.vl["DSU_CRUISE"]["MAIN_ON"] != 0 ret.cruiseState.speed = cp.vl["DSU_CRUISE"]["SET_SPEED"] * CV.KPH_TO_MS else: ret.cruiseState.available = cp.vl["PCM_CRUISE_2"]["MAIN_ON"] != 0 ret.cruiseState.speed = cp.vl["PCM_CRUISE_2"]["SET_SPEED"] * CV.KPH_TO_MS if self.CP.carFingerprint in TSS2_CAR: self.acc_type = cp_cam.vl["ACC_CONTROL"]["ACC_TYPE"] # some TSS2 cars have low speed lockout permanently set, so ignore on those cars # these cars are identified by an ACC_TYPE value of 2. # TODO: it may be possible to avoid the lockout and gain stop and go if you # send your own ACC_CONTROL msg on startup with ACC_TYPE set to 1 if (self.CP.carFingerprint not in TSS2_CAR and self.CP.carFingerprint not in [CAR.LEXUS_IS, CAR.LEXUS_ISH]) or \ (self.CP.carFingerprint in TSS2_CAR and self.acc_type == 1): self.low_speed_lockout = cp.vl["PCM_CRUISE_2"]["LOW_SPEED_LOCKOUT"] == 2 self.pcm_acc_status = cp.vl["PCM_CRUISE"]["CRUISE_STATE"] if self.CP.carFingerprint in NO_STOP_TIMER_CAR or self.CP.enableGasInterceptor: # ignore standstill in hybrid vehicles, since pcm allows to restart without # receiving any special command. Also if interceptor is detected ret.cruiseState.standstill = False else: ret.cruiseState.standstill = self.pcm_acc_status == 7 ret.cruiseState.enabled = bool(cp.vl["PCM_CRUISE"]["CRUISE_ACTIVE"]) # dp ret.cruiseActualEnabled = ret.cruiseState.enabled ret.cruiseState.nonAdaptive = cp.vl["PCM_CRUISE"]["CRUISE_STATE"] in [1, 2, 3, 4, 5, 6] ret.genericToggle = bool(cp.vl["LIGHT_STALK"]["AUTO_HIGH_BEAM"]) ret.stockAeb = bool(cp_cam.vl["PRE_COLLISION"]["PRECOLLISION_ACTIVE"] and cp_cam.vl["PRE_COLLISION"]["FORCE"] < -1e-5) ret.espDisabled = cp.vl["ESP_CONTROL"]["TC_DISABLED"] != 0 # 2 is standby, 10 is active. TODO: check that everything else is really a faulty state self.steer_state = cp.vl["EPS_STATUS"]["LKA_STATE"] if self.CP.enableBsm: ret.leftBlindspot = (cp.vl["BSM"]["L_ADJACENT"] == 1) or (cp.vl["BSM"]["L_APPROACHING"] == 1) ret.rightBlindspot = (cp.vl["BSM"]["R_ADJACENT"] == 1) or (cp.vl["BSM"]["R_APPROACHING"] == 1) # dp # distance button self.distance = cp_cam.vl["ACC_CONTROL"]['DISTANCE'] self._update_traffic_signals(cp_cam) ret.cruiseState.speedLimit = self._calculate_speed_limit() return ret def _init_traffic_signals(self): self._tsgn1 = None self._spdval1 = None self._splsgn1 = None self._tsgn2 = None self._splsgn2 = None self._tsgn3 = None self._splsgn3 = None self._tsgn4 = None self._splsgn4 = None def _update_traffic_signals(self, cp_cam): # Print out car signals for traffic signal detection tsgn1 = cp_cam.vl["RSA1"]['TSGN1'] spdval1 = cp_cam.vl["RSA1"]['SPDVAL1'] splsgn1 = cp_cam.vl["RSA1"]['SPLSGN1'] tsgn2 = cp_cam.vl["RSA1"]['TSGN2'] splsgn2 = cp_cam.vl["RSA1"]['SPLSGN2'] tsgn3 = cp_cam.vl["RSA2"]['TSGN3'] splsgn3 = cp_cam.vl["RSA2"]['SPLSGN3'] tsgn4 = cp_cam.vl["RSA2"]['TSGN4'] splsgn4 = cp_cam.vl["RSA2"]['SPLSGN4'] has_changed = tsgn1 != self._tsgn1 \ or spdval1 != self._spdval1 \ or splsgn1 != self._splsgn1 \ or tsgn2 != self._tsgn2 \ or splsgn2 != self._splsgn2 \ or tsgn3 != self._tsgn3 \ or splsgn3 != self._splsgn3 \ or tsgn4 != self._tsgn4 \ or splsgn4 != self._splsgn4 self._tsgn1 = tsgn1 self._spdval1 = spdval1 self._splsgn1 = splsgn1 self._tsgn2 = tsgn2 self._splsgn2 = splsgn2 self._tsgn3 = tsgn3 self._splsgn3 = splsgn3 self._tsgn4 = tsgn4 self._splsgn4 = splsgn4 if not has_changed: return print('---- TRAFFIC SIGNAL UPDATE -----') if tsgn1 is not None and tsgn1 != 0: print(f'TSGN1: {self._traffic_signal_description(tsgn1)}') if spdval1 is not None and spdval1 != 0: print(f'SPDVAL1: {spdval1}') if splsgn1 is not None and splsgn1 != 0: print(f'SPLSGN1: {splsgn1}') if tsgn2 is not None and tsgn2 != 0: print(f'TSGN2: {self._traffic_signal_description(tsgn2)}') if splsgn2 is not None and splsgn2 != 0: print(f'SPLSGN2: {splsgn2}') if tsgn3 is not None and tsgn3 != 0: print(f'TSGN3: {self._traffic_signal_description(tsgn3)}') if splsgn3 is not None and splsgn3 != 0: print(f'SPLSGN3: {splsgn3}') if tsgn4 is not None and tsgn4 != 0: print(f'TSGN4: {self._traffic_signal_description(tsgn4)}') if splsgn4 is not None and splsgn4 != 0: print(f'SPLSGN4: {splsgn4}') print('------------------------') def _traffic_signal_description(self, tsgn): desc = _TRAFFIC_SINGAL_MAP.get(int(tsgn)) return f'{tsgn}: {desc}' if desc is not None else f'{tsgn}' def _calculate_speed_limit(self): if self._tsgn1 == 1: return self._spdval1 * CV.KPH_TO_MS if self._tsgn1 == 36: return self._spdval1 * CV.MPH_TO_MS return 0 @staticmethod def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0), ("GEAR", "GEAR_PACKET", 0), ("BRAKE_PRESSED", "BRAKE_MODULE", 0), ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0), ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0), ("DOOR_OPEN_FL", "SEATS_DOORS", 1), ("DOOR_OPEN_FR", "SEATS_DOORS", 1), ("DOOR_OPEN_RL", "SEATS_DOORS", 1), ("DOOR_OPEN_RR", "SEATS_DOORS", 1), ("SEATBELT_DRIVER_UNLATCHED", "SEATS_DOORS", 1), ("TC_DISABLED", "ESP_CONTROL", 1), ("STEER_FRACTION", "STEER_ANGLE_SENSOR", 0), ("STEER_RATE", "STEER_ANGLE_SENSOR", 0), ("CRUISE_ACTIVE", "PCM_CRUISE", 0), ("CRUISE_STATE", "PCM_CRUISE", 0), ("GAS_RELEASED", "PCM_CRUISE", 1), ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0), ("STEER_TORQUE_EPS", "STEER_TORQUE_SENSOR", 0), ("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0), ("TURN_SIGNALS", "STEERING_LEVERS", 3), # 3 is no blinkers ("LKA_STATE", "EPS_STATUS", 0), ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0), #dp ("SPORT_ON", "GEAR_PACKET", 0), ("ECON_ON", "GEAR_PACKET", 1), ("DISTANCE_LINES", "PCM_CRUISE_SM", 0), ("RPM", "ENGINE_RPM", 0), ("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0), ] checks = [ ("GEAR_PACKET", 1), ("LIGHT_STALK", 1), ("STEERING_LEVERS", 0.15), ("SEATS_DOORS", 3), ("ESP_CONTROL", 3), ("EPS_STATUS", 25), ("BRAKE_MODULE", 40), ("WHEEL_SPEEDS", 80), ("STEER_ANGLE_SENSOR", 80), ("PCM_CRUISE", 33), ("STEER_TORQUE_SENSOR", 50), #dp ("ENGINE_RPM", 100), ] #dp acceleration if CP.carFingerprint == CAR.RAV4_TSS2: signals.append(("SPORT_ON_2", "GEAR_PACKET", 0)) if CP.carFingerprint in [CAR.LEXUS_ESH_TSS2, CAR.RAV4H_TSS2, CAR.CHRH, CAR.PRIUS_TSS2, CAR.HIGHLANDERH_TSS2]: signals.append(("SPORT_ON", "GEAR_PACKET2", 0)) signals.append(("ECON_ON", "GEAR_PACKET2", 0)) if CP.carFingerprint in [CAR.LEXUS_IS, CAR.LEXUS_ISH]: signals.append(("MAIN_ON", "DSU_CRUISE", 0)) signals.append(("SET_SPEED", "DSU_CRUISE", 0)) checks.append(("DSU_CRUISE", 5)) else: signals.append(("MAIN_ON", "PCM_CRUISE_2", 0)) signals.append(("SET_SPEED", "PCM_CRUISE_2", 0)) signals.append(("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 0)) checks.append(("PCM_CRUISE_2", 33)) if CP.carFingerprint == CAR.LEXUS_ISH: signals.append(("GAS_PEDAL", "GAS_PEDAL_ALT", 0)) checks.append(("GAS_PEDAL_ALT", 33)) else: signals.append(("GAS_PEDAL", "GAS_PEDAL", 0)) checks.append(("GAS_PEDAL", 33)) # add gas interceptor reading if we are using it if CP.enableGasInterceptor: signals.append(("INTERCEPTOR_GAS", "GAS_SENSOR", 0)) signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0)) checks.append(("GAS_SENSOR", 50)) if CP.enableBsm: signals += [ ("L_ADJACENT", "BSM", 0), ("L_APPROACHING", "BSM", 0), ("R_ADJACENT", "BSM", 0), ("R_APPROACHING", "BSM", 0), ] checks += [ ("BSM", 1) ] if Params().get('dp_toyota_zss') == b'1': signals += [("ZORRO_STEER", "SECONDARY_STEER_ANGLE", 0)] return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0) @staticmethod def get_cam_can_parser(CP): signals = [ ("FORCE", "PRE_COLLISION", 0), ("PRECOLLISION_ACTIVE", "PRE_COLLISION", 0), #dp ("DISTANCE", "ACC_CONTROL", 0), ] # Include traffic singal signals. signals += [ ("TSGN1", "RSA1", 0), ("SPDVAL1", "RSA1", 0), ("SPLSGN1", "RSA1", 0), ("TSGN2", "RSA1", 0), ("SPLSGN2", "RSA1", 0), ("TSGN3", "RSA2", 0), ("SPLSGN3", "RSA2", 0), ("TSGN4", "RSA2", 0), ("SPLSGN4", "RSA2", 0), ] # use steering message to check if panda is connected to frc checks = [ ("STEERING_LKA", 42), ("RSA1", 0), ("RSA2", 0), ("PRE_COLLISION", 0), # TODO: figure out why freq is inconsistent ] if CP.carFingerprint in TSS2_CAR: signals.append(("ACC_TYPE", "ACC_CONTROL", 0)) checks.append(("ACC_CONTROL", 33)) return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 2) ================================================ FILE: selfdrive/car/toyota/interface.py ================================================ #!/usr/bin/env python3 from cereal import car from selfdrive.config import Conversions as CV from selfdrive.car.toyota.values import Ecu, CAR, TSS2_CAR, NO_DSU_CAR, MIN_ACC_SPEED, PEDAL_HYST_GAP, CarControllerParams from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr from common.params import Params EventName = car.CarEvent.EventName GearShifter = car.CarState.GearShifter class CarInterface(CarInterfaceBase): def __init__(self, CP, CarController, CarState): super().__init__(CP, CarController, CarState) # dp self.dp_cruise_speed = 0. @staticmethod def get_pid_accel_limits(CP, current_speed, cruise_speed): return CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=[]): # pylint: disable=dangerous-default-value ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "toyota" ret.safetyModel = car.CarParams.SafetyModel.toyota ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay ret.steerLimitTimer = 0.4 ret.stoppingControl = False # Toyota starts braking more when it thinks you want to stop if candidate not in [CAR.PRIUS, CAR.RAV4, CAR.RAV4H]: # These cars use LQR/INDI ret.lateralTuning.init('pid') ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] if candidate == CAR.PRIUS: stop_and_go = True ret.safetyParam = 66 # see conversion factor for STEER_TORQUE_EPS in dbc file ret.wheelbase = 2.70 ret.steerRatio = 15.74 # unknown end-to-end spec tire_stiffness_factor = 0.6371 # hand-tune ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.init('indi') ret.lateralTuning.indi.innerLoopGainBP = [0.] ret.lateralTuning.indi.innerLoopGainV = [4.0] ret.lateralTuning.indi.outerLoopGainBP = [0.] ret.lateralTuning.indi.outerLoopGainV = [3.0] ret.lateralTuning.indi.timeConstantBP = [0.] ret.lateralTuning.indi.timeConstantV = [1.0] ret.lateralTuning.indi.actuatorEffectivenessBP = [0.] ret.lateralTuning.indi.actuatorEffectivenessV = [1.0] ret.steerActuatorDelay = 0.3 elif candidate in [CAR.RAV4, CAR.RAV4H]: stop_and_go = True if (candidate in CAR.RAV4H) else False ret.safetyParam = 73 ret.wheelbase = 2.65 ret.steerRatio = 16.88 # 14.5 is spec end-to-end tire_stiffness_factor = 0.5533 ret.mass = 3650. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid if ret.enableGasInterceptor: ret.longitudinalTuning.kpV = [0.4, 0.36, 0.325] # arne's tune. ret.longitudinalTuning.kiV = [0.195, 0.10] ret.lateralTuning.init('lqr') ret.lateralTuning.lqr.scale = 1500.0 ret.lateralTuning.lqr.ki = 0.05 ret.lateralTuning.lqr.a = [0., 1., -0.22619643, 1.21822268] ret.lateralTuning.lqr.b = [-1.92006585e-04, 3.95603032e-05] ret.lateralTuning.lqr.c = [1., 0.] ret.lateralTuning.lqr.k = [-110.73572306, 451.22718255] ret.lateralTuning.lqr.l = [0.3233671, 0.3185757] ret.lateralTuning.lqr.dcGain = 0.002237852961363602 elif candidate == CAR.COROLLA: stop_and_go = False ret.safetyParam = 88 ret.wheelbase = 2.70 ret.steerRatio = 18.27 tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] ret.lateralTuning.pid.kf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594 elif candidate == CAR.LEXUS_RX: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.79 ret.steerRatio = 14.8 tire_stiffness_factor = 0.5533 ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.05]] ret.lateralTuning.pid.kf = 0.00006 elif candidate == CAR.LEXUS_RXH: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.79 ret.steerRatio = 16. # 14.8 is spec end-to-end tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 4481. * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00006 # full torque for 10 deg at 80mph means 0.00007818594 elif candidate == CAR.LEXUS_RX_TSS2: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.79 ret.steerRatio = 14.8 tire_stiffness_factor = 0.5533 # not optimized yet ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 elif candidate == CAR.LEXUS_RXH_TSS2: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.79 ret.steerRatio = 16.0 # 14.8 is spec end-to-end tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 4481.0 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.15]] ret.lateralTuning.pid.kf = 0.00007818594 elif candidate in [CAR.CHR, CAR.CHRH]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.63906 ret.steerRatio = 13.6 tire_stiffness_factor = 0.7933 ret.mass = 3300. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.723], [0.0428]] ret.lateralTuning.pid.kf = 0.00006 elif candidate in [CAR.CAMRY, CAR.CAMRYH, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.82448 ret.steerRatio = 13.7 tire_stiffness_factor = 0.7933 ret.mass = 3400. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00006 elif candidate in [CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.84988 # 112.2 in = 2.84988 m ret.steerRatio = 16.0 tire_stiffness_factor = 0.8 ret.mass = 4700. * CV.LB_TO_KG + STD_CARGO_KG # 4260 + 4-5 people ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning ret.lateralTuning.pid.kf = 0.00012 # community tuning elif candidate in [CAR.HIGHLANDER, CAR.HIGHLANDERH]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.78 ret.steerRatio = 16.0 tire_stiffness_factor = 0.8 ret.mass = 4607. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid limited ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.18], [0.015]] # community tuning ret.lateralTuning.pid.kf = 0.00012 # community tuning elif candidate in [CAR.AVALON, CAR.AVALON_2019, CAR.AVALONH_2019]: stop_and_go = False ret.safetyParam = 73 ret.wheelbase = 2.82 ret.steerRatio = 14.8 # Found at https://pressroom.toyota.com/releases/2016+avalon+product+specs.download tire_stiffness_factor = 0.7983 ret.mass = 3505. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.17], [0.03]] ret.lateralTuning.pid.kf = 0.00006 elif candidate in [CAR.RAV4_TSS2, CAR.RAV4H_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.68986 ret.steerRatio = 14.3 tire_stiffness_factor = 0.7933 ret.mass = 3585. * CV.LB_TO_KG + STD_CARGO_KG # Average between ICE and Hybrid ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 # 2019+ Rav4 TSS2 uses two different steering racks and specific tuning seems to be necessary. # See https://github.com/commaai/openpilot/pull/21429#issuecomment-873652891 for fw in car_fw: if fw.ecu == "eps" and (fw.fwVersion.startswith(b'\x02') or fw.fwVersion in [b'8965B42181\x00\x00\x00\x00\x00\x00']): ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15], [0.05]] ret.lateralTuning.pid.kf = 0.00004 break elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.67 # Average between 2.70 for sedan and 2.64 for hatchback ret.steerRatio = 13.9 tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 3060. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 elif candidate in [CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.8702 ret.steerRatio = 16.0 # not optimized tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 3704. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 elif candidate == CAR.LEXUS_ESH: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.8190 ret.steerRatio = 16.06 tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 3682. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00007818594 elif candidate == CAR.SIENNA: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 3.03 ret.steerRatio = 15.5 tire_stiffness_factor = 0.444 ret.mass = 4590. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.02]] ret.lateralTuning.pid.kf = 0.00007818594 elif candidate == CAR.LEXUS_IS: stop_and_go = False ret.safetyParam = 77 ret.wheelbase = 2.79908 ret.steerRatio = 13.3 tire_stiffness_factor = 0.444 ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] ret.lateralTuning.pid.kf = 0.00006 elif candidate == CAR.LEXUS_CTH: stop_and_go = True ret.safetyParam = 100 ret.wheelbase = 2.60 ret.steerRatio = 18.6 tire_stiffness_factor = 0.517 ret.mass = 3108 * CV.LB_TO_KG + STD_CARGO_KG # mean between min and max ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] ret.lateralTuning.pid.kf = 0.00007 elif candidate in [CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.LEXUS_NX_TSS2]: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.66 ret.steerRatio = 14.7 tire_stiffness_factor = 0.444 # not optimized yet ret.mass = 4070 * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00006 elif candidate == CAR.PRIUS_TSS2: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.70002 # from toyota online sepc. ret.steerRatio = 13.4 # True steerRation from older prius tire_stiffness_factor = 0.6371 # hand-tune ret.mass = 3115. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.init('indi') ret.lateralTuning.indi.innerLoopGainBP = [20, 24, 30] ret.lateralTuning.indi.innerLoopGainV = [7.25, 7.5, 9] ret.lateralTuning.indi.outerLoopGainBP = [20, 24, 30] ret.lateralTuning.indi.outerLoopGainV = [6, 7.25, 6] ret.lateralTuning.indi.timeConstantBP = [20, 24] ret.lateralTuning.indi.timeConstantV = [2.0, 2.2] ret.lateralTuning.indi.actuatorEffectivenessBP = [20, 24] ret.lateralTuning.indi.actuatorEffectivenessV = [2, 3] ret.steerActuatorDelay = 0.3 ret.steerRateCost = 1.25 ret.steerLimitTimer = 0.5 elif candidate == CAR.MIRAI: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 2.91 ret.steerRatio = 14.8 tire_stiffness_factor = 0.8 ret.mass = 4300. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]] ret.lateralTuning.pid.kf = 0.00006 elif candidate == CAR.ALPHARD_TSS2: stop_and_go = True ret.safetyParam = 73 ret.wheelbase = 3.00 ret.steerRatio = 14.2 tire_stiffness_factor = 0.444 ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.19], [0.02]] ret.mass = 4305. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kf = 0.00007818594 elif candidate == CAR.LEXUS_ISH: stop_and_go = True ret.safetyParam = 130 ret.wheelbase = 2.79908 ret.steerRatio = 13.3 tire_stiffness_factor = 0.444 ret.mass = 3736.8 * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.3], [0.05]] ret.lateralTuning.pid.kf = 0.00006 elif candidate in [CAR.PRIUS_ALPHA]: stop_and_go = False ret.safetyParam = 73 ret.wheelbase = 2.78 ret.steerRatio = 18 tire_stiffness_factor = 0.5533 ret.mass = 4387. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]] ret.lateralTuning.pid.kf = 0.00006 ret.steerRateCost = 1. ret.centerToFront = ret.wheelbase * 0.44 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) ret.enableBsm = 0x3F6 in fingerprint[0] and candidate in TSS2_CAR # Detect smartDSU, which intercepts ACC_CMD from the DSU allowing openpilot to send it smartDsu = 0x2FF in fingerprint[0] # In TSS2 cars the camera does long control found_ecus = [fw.ecu for fw in car_fw] ret.enableDsu = (len(found_ecus) > 0) and (Ecu.dsu not in found_ecus) and (candidate not in NO_DSU_CAR) ret.enableGasInterceptor = 0x201 in fingerprint[0] # if the smartDSU is detected, openpilot can send ACC_CMD (and the smartDSU will block it from the DSU) or not (the DSU is "connected") ret.openpilotLongitudinalControl = smartDsu or ret.enableDsu or candidate in TSS2_CAR if Params().get_bool('dp_atl') and not Params().get_bool('dp_atl_op_long'): ret.openpilotLongitudinalControl = False # min speed to enable ACC. if car can do stop and go, then set enabling speed # to a negative value, so it won't matter. ret.minEnableSpeed = -1. if (stop_and_go or ret.enableGasInterceptor) else MIN_ACC_SPEED # removing the DSU disables AEB and it's considered a community maintained feature # intercepting the DSU is a community feature since it requires unofficial hardware ret.communityFeature = ret.enableGasInterceptor or ret.enableDsu or smartDsu if ret.enableGasInterceptor: ret.longitudinalTuning.kpBP = [0., 5., MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_HYST_GAP, 35.] ret.longitudinalTuning.kpV = [1.2, 0.8, 0.765, 2.255, 1.5] ret.longitudinalTuning.kiBP = [0., MIN_ACC_SPEED, MIN_ACC_SPEED + PEDAL_HYST_GAP, 35.] ret.longitudinalTuning.kiV = [0.18, 0.165, 0.489, 0.36] elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.RAV4_TSS2, CAR.RAV4H_TSS2, CAR.LEXUS_NX_TSS2, CAR.PRIUS_TSS2]: # Improved longitudinal tune ret.longitudinalTuning.deadzoneBP = [0., 8.05] ret.longitudinalTuning.deadzoneV = [.0, .14] ret.longitudinalTuning.kpBP = [0., 5., 20.] ret.longitudinalTuning.kpV = [1.3, 1.0, 0.7] ret.longitudinalTuning.kiBP = [0., 5., 12., 20., 27.] ret.longitudinalTuning.kiV = [.35, .23, .20, .17, .1] ret.stoppingDecelRate = 0.3 # reach stopping target smoothly ret.startingAccelRate = 6.0 # release brakes fast ret.startAccel = 1.2 # Accelerate from 0 faster else: # Default longitudinal tune ret.longitudinalTuning.deadzoneBP = [0., 9.] ret.longitudinalTuning.deadzoneV = [0., .15] ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalTuning.kpV = [3.6, 2.4, 1.5] ret.longitudinalTuning.kiV = [0.54, 0.36] # dp ret = common_interface_get_params_lqr(ret) if candidate == CAR.PRIUS and Params().get('dp_toyota_zss') == b'1': ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG ret.lateralTuning.indi.timeConstantV = [0.1] ret.lateralTuning.indi.timeConstantBP = [0.] ret.steerRateCost = 0.5 return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): # ******************* do can recv ******************* self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) # low speed re-write if ret.cruiseState.enabled and dragonconf.dpToyotaCruiseOverride and ret.cruiseState.speed < dragonconf.dpToyotaCruiseOverrideAt * CV.KPH_TO_MS: if dragonconf.dpToyotaCruiseOverrideVego: if self.dp_cruise_speed == 0.: ret.cruiseState.speed = self.dp_cruise_speed = max( dragonconf.dpToyotaCruiseOverrideSpeed * CV.KPH_TO_MS,ret.vEgo) else: ret.cruiseState.speed = self.dp_cruise_speed else: ret.cruiseState.speed = dragonconf.dpToyotaCruiseOverrideSpeed * CV.KPH_TO_MS else: self.dp_cruise_speed = 0. ret.canValid = self.cp.can_valid and self.cp_cam.can_valid ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False # gear except P, R extra_gears = [GearShifter.neutral, GearShifter.eco, GearShifter.manumatic, GearShifter.drive, GearShifter.sport, GearShifter.low, GearShifter.brake, GearShifter.unknown] # events events = self.create_common_events(ret, extra_gears) if self.CS.low_speed_lockout and self.CP.openpilotLongitudinalControl: events.add(EventName.lowSpeedLockout) if ret.vEgo < self.CP.minEnableSpeed and self.CP.openpilotLongitudinalControl: events.add(EventName.belowEngageSpeed) if c.actuators.accel > 0.3: # some margin on the actuator to not false trigger cancellation while stopping events.add(EventName.speedTooLow) if ret.vEgo < 0.001: # while in standstill, send a user alert events.add(EventName.manualRestart) ret.events = events.to_msg() self.CS.out = ret.as_reader() return self.CS.out # pass in a car.CarControl # to be called @ 100hz def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, c.actuators, c.cruiseControl.cancel, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leadVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/toyota/radar_interface.py ================================================ #!/usr/bin/env python3 from opendbc.can.parser import CANParser from cereal import car from selfdrive.car.toyota.values import NO_DSU_CAR, DBC, TSS2_CAR from selfdrive.car.interfaces import RadarInterfaceBase def _create_radar_can_parser(car_fingerprint): if car_fingerprint in TSS2_CAR: RADAR_A_MSGS = list(range(0x180, 0x190)) RADAR_B_MSGS = list(range(0x190, 0x1a0)) else: RADAR_A_MSGS = list(range(0x210, 0x220)) RADAR_B_MSGS = list(range(0x220, 0x230)) msg_a_n = len(RADAR_A_MSGS) msg_b_n = len(RADAR_B_MSGS) signals = list(zip(['LONG_DIST'] * msg_a_n + ['NEW_TRACK'] * msg_a_n + ['LAT_DIST'] * msg_a_n + ['REL_SPEED'] * msg_a_n + ['VALID'] * msg_a_n + ['SCORE'] * msg_b_n, RADAR_A_MSGS * 5 + RADAR_B_MSGS, [255] * msg_a_n + [1] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_b_n)) checks = list(zip(RADAR_A_MSGS + RADAR_B_MSGS, [20]*(msg_a_n + msg_b_n))) return CANParser(DBC[car_fingerprint]['radar'], signals, checks, 1) class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) self.track_id = 0 self.radar_ts = CP.radarTimeStep if CP.carFingerprint in TSS2_CAR: self.RADAR_A_MSGS = list(range(0x180, 0x190)) self.RADAR_B_MSGS = list(range(0x190, 0x1a0)) else: self.RADAR_A_MSGS = list(range(0x210, 0x220)) self.RADAR_B_MSGS = list(range(0x220, 0x230)) self.valid_cnt = {key: 0 for key in self.RADAR_A_MSGS} self.rcp = _create_radar_can_parser(CP.carFingerprint) self.trigger_msg = self.RADAR_B_MSGS[-1] self.updated_messages = set() # No radar dbc for cars without DSU which are not TSS 2.0 # TODO: make a adas dbc file for dsu-less models self.no_radar = CP.carFingerprint in NO_DSU_CAR and CP.carFingerprint not in TSS2_CAR def update(self, can_strings): if self.no_radar: return super().update(None) vls = self.rcp.update_strings(can_strings) self.updated_messages.update(vls) if self.trigger_msg not in self.updated_messages: return None rr = self._update(self.updated_messages) self.updated_messages.clear() return rr def _update(self, updated_messages): ret = car.RadarData.new_message() errors = [] if not self.rcp.can_valid: errors.append("canError") ret.errors = errors for ii in sorted(updated_messages): if ii in self.RADAR_A_MSGS: cpt = self.rcp.vl[ii] if cpt['LONG_DIST'] >= 255 or cpt['NEW_TRACK']: self.valid_cnt[ii] = 0 # reset counter if cpt['VALID'] and cpt['LONG_DIST'] < 255: self.valid_cnt[ii] += 1 else: self.valid_cnt[ii] = max(self.valid_cnt[ii] - 1, 0) score = self.rcp.vl[ii+16]['SCORE'] # print ii, self.valid_cnt[ii], score, cpt['VALID'], cpt['LONG_DIST'], cpt['LAT_DIST'] # radar point only valid if it's a valid measurement and score is above 50 if cpt['VALID'] or (score > 50 and cpt['LONG_DIST'] < 255 and self.valid_cnt[ii] > 0): if ii not in self.pts or cpt['NEW_TRACK']: self.pts[ii] = car.RadarData.RadarPoint.new_message() self.pts[ii].trackId = self.track_id self.track_id += 1 self.pts[ii].dRel = cpt['LONG_DIST'] # from front of car self.pts[ii].yRel = -cpt['LAT_DIST'] # in car frame's y axis, left is positive self.pts[ii].vRel = cpt['REL_SPEED'] self.pts[ii].aRel = float('nan') self.pts[ii].yvRel = float('nan') self.pts[ii].measured = bool(cpt['VALID']) else: if ii in self.pts: del self.pts[ii] ret.points = list(self.pts.values()) return ret ================================================ FILE: selfdrive/car/toyota/toyotacan.py ================================================ def create_steer_command(packer, steer, steer_req, raw_cnt): """Creates a CAN message for the Toyota Steer Command.""" values = { "STEER_REQUEST": steer_req, "STEER_TORQUE_CMD": steer, "COUNTER": raw_cnt, "SET_ME_1": 1, } return packer.make_can_msg("STEERING_LKA", 0, values) def create_lta_steer_command(packer, steer, steer_req, raw_cnt): """Creates a CAN message for the Toyota LTA Steer Command.""" values = { "COUNTER": raw_cnt + 128, "SETME_X1": 1, "SETME_X3": 3, "PERCENTAGE": 100, "SETME_X64": 0x64, "ANGLE": 0, # Rate limit? Lower values seeem to work better, but needs more testing "STEER_ANGLE_CMD": steer, "STEER_REQUEST": steer_req, "STEER_REQUEST_2": steer_req, "BIT": 0, } return packer.make_can_msg("STEERING_LTA", 0, values) def create_accel_command(packer, accel, pcm_cancel, standstill_req, lead, acc_type, distance): # TODO: find the exact canceling bit that does not create a chime values = { "ACCEL_CMD": accel, "ACC_TYPE": acc_type, "DISTANCE": distance, "MINI_CAR": lead, "SET_ME_X3": 3, "PERMIT_BRAKING": 1, "RELEASE_STANDSTILL": not standstill_req, "CANCEL_REQ": pcm_cancel, } return packer.make_can_msg("ACC_CONTROL", 0, values) def create_acc_cancel_command(packer): values = { "GAS_RELEASED": 0, "CRUISE_ACTIVE": 0, "STANDSTILL_ON": 0, "ACCEL_NET": 0, "CRUISE_STATE": 0, "CANCEL_REQ": 1, } return packer.make_can_msg("PCM_CRUISE", 0, values) def create_fcw_command(packer, fcw): values = { "FCW": fcw, "SET_ME_X20": 0x20, "SET_ME_X10": 0x10, "SET_ME_X80": 0x80, } return packer.make_can_msg("ACC_HUD", 0, values) def create_ui_command(packer, steer, chime, left_line, right_line, left_lane_depart, right_lane_depart): values = { "RIGHT_LINE": 3 if right_lane_depart else 1 if right_line else 2, "LEFT_LINE": 3 if left_lane_depart else 1 if left_line else 2, "BARRIERS" : 3 if left_lane_depart else 2 if right_lane_depart else 0, "SET_ME_X0C": 0x0c, "SET_ME_X2C": 0x2c, "SET_ME_X38": 0x38, "SET_ME_X02": 0x02, "SET_ME_X01": 1, "SET_ME_X01_2": 1, "REPEATED_BEEPS": 0, "TWO_BEEPS": chime, "LDA_ALERT": steer, } return packer.make_can_msg("LKAS_HUD", 0, values) ================================================ FILE: selfdrive/car/toyota/values.py ================================================ # flake8: noqa from cereal import car from selfdrive.car import dbc_dict from selfdrive.config import Conversions as CV Ecu = car.CarParams.Ecu MIN_ACC_SPEED = 19. * CV.MPH_TO_MS PEDAL_HYST_GAP = 3. * CV.MPH_TO_MS PEDAL_SCALE = 3.0 class CarControllerParams: ACCEL_HYST_GAP = 0.06 # don't change accel command for small oscilalitons within this value ACCEL_MAX = 1.5 # m/s2, lower than allowed 2.0 m/s2 for tuning reasons ACCEL_MIN = -3.5 # m/s2 STEER_MAX = 1500 STEER_DELTA_UP = 10 # 1.5s time to peak torque STEER_DELTA_DOWN = 25 # always lower than 45 otherwise the Rav4 faults (Prius seems ok with 50) STEER_ERROR_MAX = 350 # max delta between torque cmd and torque motor class CAR: PRIUS = "TOYOTA PRIUS 2017" PRIUS_TSS2 = "TOYOTA PRIUS TSS2 2021" RAV4H = "TOYOTA RAV4 HYBRID 2017" RAV4 = "TOYOTA RAV4 2017" COROLLA = "TOYOTA COROLLA 2017" LEXUS_RX = "LEXUS RX 2016" LEXUS_RXH = "LEXUS RX HYBRID 2017" LEXUS_RX_TSS2 = "LEXUS RX 2020" LEXUS_RXH_TSS2 = "LEXUS RX HYBRID 2020" CHR = "TOYOTA C-HR 2018" CHRH = "TOYOTA C-HR HYBRID 2018" CAMRY = "TOYOTA CAMRY 2018" CAMRYH = "TOYOTA CAMRY HYBRID 2018" CAMRY_TSS2 = "TOYOTA CAMRY 2021" # TSS 2.5 CAMRYH_TSS2 = "TOYOTA CAMRY HYBRID 2021" HIGHLANDER = "TOYOTA HIGHLANDER 2017" HIGHLANDER_TSS2 = "TOYOTA HIGHLANDER 2020" HIGHLANDERH = "TOYOTA HIGHLANDER HYBRID 2018" HIGHLANDERH_TSS2 = "TOYOTA HIGHLANDER HYBRID 2020" AVALON = "TOYOTA AVALON 2016" AVALON_2019 = "TOYOTA AVALON 2019" AVALONH_2019 = "TOYOTA AVALON HYBRID 2019" RAV4_TSS2 = "TOYOTA RAV4 2019" COROLLA_TSS2 = "TOYOTA COROLLA TSS2 2019" # LSS2 Lexus UX Hybrid is same as a TSS2 Corolla Hybrid COROLLAH_TSS2 = "TOYOTA COROLLA HYBRID TSS2 2019" LEXUS_ES_TSS2 = "LEXUS ES 2019" LEXUS_ESH_TSS2 = "LEXUS ES HYBRID 2019" LEXUS_ESH = "LEXUS ES HYBRID 2018" SIENNA = "TOYOTA SIENNA 2018" LEXUS_IS = "LEXUS IS 2018" LEXUS_CTH = "LEXUS CT HYBRID 2018" RAV4H_TSS2 = "TOYOTA RAV4 HYBRID 2019" LEXUS_NXH = "LEXUS NX HYBRID 2018" LEXUS_NX = "LEXUS NX 2018" LEXUS_NX_TSS2 = "LEXUS NX 2020" MIRAI = "TOYOTA MIRAI 2021" # TSS 2.5 ALPHARD_TSS2 = "TOYOTA ALPHARD 2020" LEXUS_ISH = "LEXUS ISH 2017" PRIUS_ALPHA = "TOYOTA PRIUS ALPHA 2017" # (addr, cars, bus, 1/freq*100, vl) STATIC_DSU_MSGS = [ (0x128, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.AVALON), 1, 3, b'\xf4\x01\x90\x83\x00\x37'), (0x128, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH), 1, 3, b'\x03\x00\x20\x00\x00\x52'), (0x141, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 1, 2, b'\x00\x00\x00\x46'), (0x160, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 1, 7, b'\x00\x00\x08\x12\x01\x31\x9c\x51'), (0x161, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.AVALON, CAR.LEXUS_RX), 1, 7, b'\x00\x1e\x00\x00\x00\x80\x07'), (0X161, (CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH), 1, 7, b'\x00\x1e\x00\xd4\x00\x00\x5b'), (0x283, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 3, b'\x00\x00\x00\x00\x00\x00\x8c'), (0x2E6, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, b'\xff\xf8\x00\x08\x7f\xe0\x00\x4e'), (0x2E7, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 3, b'\xa8\x9c\x31\x9c\x00\x00\x00\x02'), (0x33E, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH), 0, 20, b'\x0f\xff\x26\x40\x00\x1f\x00'), (0x344, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 5, b'\x00\x00\x01\x00\x00\x00\x00\x50'), (0x365, (CAR.PRIUS, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.HIGHLANDERH), 0, 20, b'\x00\x00\x00\x80\x03\x00\x08'), (0x365, (CAR.RAV4, CAR.RAV4H, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 20, b'\x00\x00\x00\x80\xfc\x00\x08'), (0x366, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.HIGHLANDERH), 0, 20, b'\x00\x00\x4d\x82\x40\x02\x00'), (0x366, (CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 20, b'\x00\x72\x07\xff\x09\xfe\x00'), (0x470, (CAR.PRIUS, CAR.LEXUS_RXH), 1, 100, b'\x00\x00\x02\x7a'), (0x470, (CAR.HIGHLANDER, CAR.HIGHLANDERH, CAR.RAV4H, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH), 1, 100, b'\x00\x00\x01\x79'), (0x4CB, (CAR.PRIUS, CAR.RAV4H, CAR.LEXUS_RXH, CAR.LEXUS_NXH, CAR.LEXUS_NX, CAR.RAV4, CAR.COROLLA, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.AVALON, CAR.SIENNA, CAR.LEXUS_CTH, CAR.LEXUS_ESH, CAR.LEXUS_RX), 0, 100, b'\x0c\x00\x00\x00\x00\x00\x00\x00'), ] FINGERPRINTS = { CAR.RAV4: [{ 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8 }], CAR.RAV4H: [{ 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 296: 8, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 547: 8, 548: 8, 550: 8, 552: 4, 560: 7, 562: 4, 581: 5, 608: 8, 610: 5, 643: 7, 705: 8, 713: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1212: 8, 1227: 8, 1228: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1656: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # Chinese RAV4 { 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 830: 7, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1207: 8, 1227: 8, 1235: 8, 1263: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1745: 8, 1779: 8 }], CAR.PRIUS: [{ 35: 8, 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 512: 6, 513: 6, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #2019 LE { 35: 8, 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # 2020 Prius Prime LE { 35: 8, 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 767: 4, 800: 8, 810: 2, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #2020 Prius Prime Limited { 35: 8, 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 824: 2, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1649: 8, 1777: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2015: 8, 2024: 8, 2026: 8, 2027: 8, 2029: 8, 2030: 8, 2031: 8 }, #2020 Central Europe Prime { 35: 8, 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 767: 4, 800: 8, 810: 2, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 8, 974: 8, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1595: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8 }, #2017 German Prius { 35: 8, 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 767: 4, 800: 8, 810: 2, 814: 8, 829: 2, 830: 7, 835: 8, 836: 8, 845: 5, 863: 8, 869: 7, 870: 7, 871: 2, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1175: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1777: 8, 1779: 8, 1792: 8, 1767: 4, 1863: 8, 1904: 8, 1912: 8, 1984: 8, 1988: 8, 1990: 8, 1992: 8, 1996: 8, 1998: 8, 2002: 8, 2010: 8, 2015: 8, 2016: 8, 2018: 8, 2024: 8, 2026: 8, 2030: 8 }], CAR.PRIUS_TSS2: [{ 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 614: 8, 643: 7, 658: 8, 713: 8, 740: 5, 742: 8, 743: 8, 764: 8, 765: 8, 800: 8, 810: 2, 814: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 863: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 882: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1083: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1172: 8, 1175: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1593: 8, 1595: 8, 1649: 8, 1653: 8, 1654: 8, 1655: 8, 1775: 8, 1777: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], #Corolla w/ added Pedal Support (512L and 513L) CAR.COROLLA: [{ 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 512: 6, 513: 6, 547: 8, 548: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 2, 921: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 4, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1196: 8, 1227: 8, 1235: 8, 1279: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1596: 8, 1597: 8, 1600: 8, 1664: 8, 1728: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8, 2016: 8, 2017: 8, 2018: 8, 2019: 8, 2020: 8, 2021: 8, 2022: 8, 2023: 8, 2024: 8 }], CAR.CAMRY: [ #XLE and LE { 36: 8, 37: 8, 119: 6, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #XSE and SE # TODO: get proper fingerprint in stock mode { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 888: 8, 889: 8, 891: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1816: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, { # 2019 XSE 36: 8, 37: 8, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 550: 8, 552: 4, 562: 6, 608: 8, 610: 8, 643: 7, 658: 8, 705: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 822: 8, 824: 8, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 891: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 942: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 976: 1, 983: 8, 984: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1082: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1412: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1792: 8, 1767: 4, 1808: 8, 1816: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1937: 8, 1945: 8, 1953: 8, 1961: 8, 1968: 8, 1976: 8, 1990: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 }], CAR.CAMRYH: [ #SE, LE and LE with Blindspot Monitor { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 889: 8, 896: 8, 898: 8, 900: 6, 902: 6, 905: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1649: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1808: 8, 1810: 8, 1816: 8, 1818: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #SL { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, #XLE { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 658: 8, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 767: 4, 800: 8, 810: 2, 812: 8, 814: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 983: 8, 984: 8, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1011: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1082: 8, 1084: 8, 1085: 8, 1086: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1228: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # 2018 Chinese Camry Hybrid { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 761: 8, 764: 8, 800: 8, 810: 2, 812: 8, 818: 8, 824: 8, 829: 2, 830: 7, 835: 8, 836: 8, 869: 7, 870: 7, 871: 2, 888: 8, 889: 8, 898: 8, 900: 6, 902: 6, 905: 8, 913: 8, 918: 8, 921: 8, 933: 8, 934: 8, 935: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1076: 8, 1077: 8, 1084: 8, 1085: 8, 1086: 8, 1112: 8, 1114: 8, 1132: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1235: 8, 1264: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1595: 8, 1745: 8, 1779: 8, 1786: 8, 1787: 8, 1788: 8, 1789: 8 }], CAR.HIGHLANDER: [{ 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1984: 8, 1988: 8, 1992: 8, 1996: 8, 1990: 8, 1998: 8 }, # 2019 Highlander XLE { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # 2017 Highlander Limited { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1264: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # 2018 Highlander Limited Platinum { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 355: 5, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 550: 8, 552: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 922: 8, 933: 8, 944: 8, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1008: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1207: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1263: 8, 1279: 8, 1408: 8, 1409: 8, 1410: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1585: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1872: 8, 1880: 8, 1904: 8, 1912: 8, 1988: 8, 1990: 8, 1996: 8, 1998: 8, 2015: 8, 2016: 8, 2024: 8 }], CAR.HIGHLANDERH: [{ 36: 8, 37: 8, 170: 8, 180: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 998: 5, 999: 7, 1000: 8, 1001: 8, 1005: 2, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1059: 1, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1264: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, { # 2019 Highlander Hybrid Limited Platinum 36: 8, 37: 8, 170: 8, 180: 8, 296: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 581: 5, 608: 8, 610: 5, 643: 7, 713: 8, 740: 5, 767: 4, 800: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 897: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 3, 918: 7, 921: 8, 933: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 3, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1043: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1076: 8, 1077: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1184: 8, 1185: 8, 1186: 8, 1189: 8, 1190: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1206: 8, 1212: 8, 1227: 8, 1232: 8, 1235: 8, 1237: 8, 1263: 8, 1279: 8, 1552: 8, 1553: 8, 1554: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1599: 8, 1656: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], CAR.COROLLAH_TSS2: [ # 2019 Taiwan Altis Hybrid { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 767: 4, 800: 8, 810: 2, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 918: 7, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 987: 8, 993: 8, 1002: 8, 1014: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1082: 8, 1112: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1237: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1745: 8, 1775: 8, 1779: 8 }, # 2019 Chinese Levin Hybrid { 36: 8, 37: 8, 166: 8, 170: 8, 180: 8, 295: 8, 296: 8, 401: 8, 426: 6, 452: 8, 466: 8, 467: 8, 550: 8, 552: 4, 560: 7, 562: 6, 581: 5, 608: 8, 610: 8, 643: 7, 713: 8, 728: 8, 740: 5, 742: 8, 743: 8, 761: 8, 765: 8, 767: 4, 800: 8, 810: 2, 812: 8, 829: 2, 830: 7, 835: 8, 836: 8, 865: 8, 869: 7, 870: 7, 871: 2, 877: 8, 881: 8, 885: 8, 896: 8, 898: 8, 921: 8, 944: 8, 945: 8, 950: 8, 951: 8, 953: 8, 955: 8, 956: 8, 971: 7, 975: 5, 993: 8, 1002: 8, 1017: 8, 1020: 8, 1041: 8, 1042: 8, 1044: 8, 1056: 8, 1057: 8, 1059: 1, 1071: 8, 1114: 8, 1161: 8, 1162: 8, 1163: 8, 1172: 8, 1235: 8, 1279: 8, 1541: 8, 1552: 8, 1553: 8, 1556: 8, 1557: 8, 1568: 8, 1570: 8, 1571: 8, 1572: 8, 1592: 8, 1594: 8, 1595: 8, 1600: 8, 1649: 8, 1745: 8, 1775: 8, 1779: 8 } ], CAR.SIENNA: [ { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 548: 8, 550: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 764: 8, 767: 4, 800: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 888: 8, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 918: 7, 921: 8, 933: 8, 944: 6, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1212: 8, 1227: 8, 1228: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1656: 8, 1664: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }, # XLE AWD 2018 { 36: 8, 37: 8, 114: 5, 119: 6, 120: 4, 170: 8, 180: 8, 186: 4, 238: 4, 426: 6, 452: 8, 464: 8, 466: 8, 467: 8, 544: 4, 545: 5, 548: 8, 550: 8, 552: 4, 562: 4, 608: 8, 610: 5, 643: 7, 705: 8, 725: 2, 740: 5, 764: 8, 767: 4, 800: 8, 824: 8, 835: 8, 836: 8, 849: 4, 869: 7, 870: 7, 871: 2, 896: 8, 900: 6, 902: 6, 905: 8, 911: 8, 916: 1, 921: 8, 933: 8, 944: 6, 945: 8, 951: 8, 955: 8, 956: 8, 979: 2, 992: 8, 998: 5, 999: 7, 1000: 8, 1001: 8, 1002: 8, 1008: 2, 1014: 8, 1017: 8, 1041: 8, 1042: 8, 1043: 8, 1056: 8, 1059: 1, 1076: 8, 1077: 8, 1114: 8, 1160: 8, 1161: 8, 1162: 8, 1163: 8, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1176: 8, 1177: 8, 1178: 8, 1179: 8, 1180: 8, 1181: 8, 1182: 8, 1183: 8, 1191: 8, 1192: 8, 1196: 8, 1197: 8, 1198: 8, 1199: 8, 1200: 8, 1201: 8, 1202: 8, 1203: 8, 1212: 8, 1227: 8, 1235: 8, 1237: 8, 1279: 8, 1552: 8, 1553: 8, 1555: 8, 1556: 8, 1557: 8, 1561: 8, 1562: 8, 1568: 8, 1569: 8, 1570: 8, 1571: 8, 1572: 8, 1584: 8, 1589: 8, 1592: 8, 1593: 8, 1595: 8, 1656: 8, 1664: 8, 1666: 8, 1667: 8, 1728: 8, 1745: 8, 1779: 8, 1904: 8, 1912: 8, 1990: 8, 1998: 8 }], # dp - fake values, for generate car selection CAR.LEXUS_ISH: [{ 65535: 1 }], CAR.PRIUS_ALPHA: [{ 65535: 1 }], } FW_VERSIONS = { CAR.AVALON: { (Ecu.esp, 0x7b0, None): [ b'F152607060\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881510701300\x00\x00\x00\x00', b'881510705100\x00\x00\x00\x00', b'881510705200\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B41051\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0230721100\x00\x00\x00\x00\x00\x00\x00\x00A0C01000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230721200\x00\x00\x00\x00\x00\x00\x00\x00A0C01000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702000\x00\x00\x00\x00', b'8821F4702100\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0701100\x00\x00\x00\x00', b'8646F0703000\x00\x00\x00\x00', ], }, CAR.AVALON_2019: { (Ecu.esp, 0x7b0, None): [ b'F152607140\x00\x00\x00\x00\x00\x00', b'F152607171\x00\x00\x00\x00\x00\x00', b'F152607110\x00\x00\x00\x00\x00\x00', b'F152607180\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881510703200\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B41080\x00\x00\x00\x00\x00\x00', b'8965B07010\x00\x00\x00\x00\x00\x00', b'8965B41090\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x700, None): [ b'\x01896630735100\x00\x00\x00\x00', b'\x01896630725300\x00\x00\x00\x00', b'\x01896630738000\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0702100\x00\x00\x00\x00', ], }, CAR.AVALONH_2019: { (Ecu.esp, 0x7b0, None): [ b'F152641040\x00\x00\x00\x00\x00\x00', b'F152641061\x00\x00\x00\x00\x00\x00', b'F152641050\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881510704200\x00\x00\x00\x00', b'881514107100\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B07010\x00\x00\x00\x00\x00\x00', b'8965B41090\x00\x00\x00\x00\x00\x00', b'8965B41070\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x700, None): [ b'\x02896630724000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x02896630737000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x02896630728000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0702100\x00\x00\x00\x00', ], }, CAR.CAMRY: { (Ecu.engine, 0x700, None): [ b'\x018966306L3100\x00\x00\x00\x00', b'\x018966306L4200\x00\x00\x00\x00', b'\x018966306L5200\x00\x00\x00\x00', b'\x018966306P8000\x00\x00\x00\x00', b'\x018966306Q3100\x00\x00\x00\x00', b'\x018966306Q4000\x00\x00\x00\x00', b'\x018966306Q4100\x00\x00\x00\x00', b'\x018966306Q4200\x00\x00\x00\x00', b'\x018966333Q9200\x00\x00\x00\x00', b'\x018966333P3100\x00\x00\x00\x00', b'\x018966333P3200\x00\x00\x00\x00', b'\x018966333P4200\x00\x00\x00\x00', b'\x018966333P4300\x00\x00\x00\x00', b'\x018966333P4400\x00\x00\x00\x00', b'\x018966333P4500\x00\x00\x00\x00', b'\x018966333P4700\x00\x00\x00\x00', b'\x018966333Q6000\x00\x00\x00\x00', b'\x018966333Q6200\x00\x00\x00\x00', b'\x018966333Q6300\x00\x00\x00\x00', b'\x018966333W6000\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x02333P1100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'8821F0601200 ', b'8821F0601300 ', b'8821F0602000 ', b'8821F0603300 ', b'8821F0604100 ', b'8821F0605200 ', b'8821F0607200 ', b'8821F0608000 ', b'8821F0608200 ', b'8821F0609100 ', ], (Ecu.esp, 0x7b0, None): [ b'F152606210\x00\x00\x00\x00\x00\x00', b'F152606230\x00\x00\x00\x00\x00\x00', b'F152606270\x00\x00\x00\x00\x00\x00', b'F152606290\x00\x00\x00\x00\x00\x00', b'F152606410\x00\x00\x00\x00\x00\x00', b'F152633540\x00\x00\x00\x00\x00\x00', b'F152633A10\x00\x00\x00\x00\x00\x00', b'F152633A20\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B33540\x00\x00\x00\x00\x00\x00', b'8965B33542\x00\x00\x00\x00\x00\x00', b'8965B33580\x00\x00\x00\x00\x00\x00', b'8965B33581\x00\x00\x00\x00\x00\x00', b'8965B33621\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ # Same as 0x791 b'8821F0601200 ', b'8821F0601300 ', b'8821F0602000 ', b'8821F0603300 ', b'8821F0604100 ', b'8821F0605200 ', b'8821F0607200 ', b'8821F0608000 ', b'8821F0608200 ', b'8821F0609100 ', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0601200 ', b'8646F0601300 ', b'8646F0601400 ', b'8646F0603400 ', b'8646F0604100 ', b'8646F0605000 ', b'8646F0606000 ', b'8646F0606100 ', b'8646F0607100 ', ], }, CAR.CAMRYH: { (Ecu.engine, 0x700, None): [ b'\x018966306Q6000\x00\x00\x00\x00', b'\x018966333N1100\x00\x00\x00\x00', b'\x018966333N4300\x00\x00\x00\x00', b'\x018966333X0000\x00\x00\x00\x00', b'\x018966333X4000\x00\x00\x00\x00', b'\x01896633T16000\x00\x00\x00\x00', b'\x028966306B2100\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306B2300\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306N8100\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306N8200\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306N8300\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306N8400\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306R5000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306R5000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x028966306R6000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966306R6000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x028966306S0000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x028966306S0100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x028966306S1100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152633214\x00\x00\x00\x00\x00\x00', b'F152633660\x00\x00\x00\x00\x00\x00', b'F152633712\x00\x00\x00\x00\x00\x00', b'F152633713\x00\x00\x00\x00\x00\x00', b'F152633B51\x00\x00\x00\x00\x00\x00', b'F152633B60\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'8821F0601200 ', b'8821F0601300 ', b'8821F0603400 ', b'8821F0604000 ', b'8821F0604200 ', b'8821F0605200 ', b'8821F0606200 ', b'8821F0607200 ', b'8821F0608000 ', b'8821F0608200 ', b'8821F0609000 ', b'8821F0609100 ', ], (Ecu.eps, 0x7a1, None): [ b'8965B33540\x00\x00\x00\x00\x00\x00', b'8965B33542\x00\x00\x00\x00\x00\x00', b'8965B33550\x00\x00\x00\x00\x00\x00', b'8965B33551\x00\x00\x00\x00\x00\x00', b'8965B33580\x00\x00\x00\x00\x00\x00', b'8965B33581\x00\x00\x00\x00\x00\x00', b'8965B33611\x00\x00\x00\x00\x00\x00', b'8965B33621\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ # Same as 0x791 b'8821F0601200 ', b'8821F0601300 ', b'8821F0603400 ', b'8821F0604000 ', b'8821F0604200 ', b'8821F0605200 ', b'8821F0606200 ', b'8821F0607200 ', b'8821F0608000 ', b'8821F0608200 ', b'8821F0609000 ', b'8821F0609100 ', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0601200 ', b'8646F0601300 ', b'8646F0601400 ', b'8646F0603400 ', b'8646F0603500 ', b'8646F0604100 ', b'8646F0605000 ', b'8646F0606000 ', b'8646F0606100 ', b'8646F0607000 ', b'8646F0607100 ', ], }, CAR.CAMRY_TSS2: { (Ecu.eps, 0x7a1, None): [ b'8965B33630\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F152606370\x00\x00\x00\x00\x00\x00', b'\x01F152606390\x00\x00\x00\x00\x00\x00', b'\x01F152606400\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x700, None): [ b'\x018966306Q5000\x00\x00\x00\x00', b'\x018966306T3100\x00\x00\x00\x00', b'\x018966306T3200\x00\x00\x00\x00', b'\x018966306T4100\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 15): [ b'\x018821F6201200\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 109): [ b'\x028646F3305200\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', b'\x028646F3305300\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', ], }, CAR.CAMRYH_TSS2: { (Ecu.eps, 0x7a1, None): [ b'8965B33630\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152633D00\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x700, None): [ b'\x018966306Q6000\x00\x00\x00\x00', b'\x018966306Q7000\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 15): [ b'\x018821F6201200\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 109): [ b'\x028646F3305200\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', b'\x028646F3305300\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', ], }, CAR.CHR: { (Ecu.engine, 0x700, None): [ b'\x01896631017100\x00\x00\x00\x00', b'\x01896631017200\x00\x00\x00\x00', b'\x0189663F413100\x00\x00\x00\x00', b'\x0189663F414100\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'8821F0W01000 ', b'8821F0W01100 ', b'8821FF401600 ', b'8821FF404000 ', b'8821FF404100 ', b'8821FF405100 ', b'8821FF406000 ', b'8821FF407100 ', ], (Ecu.esp, 0x7b0, None): [ b'F152610020\x00\x00\x00\x00\x00\x00', b'F152610153\x00\x00\x00\x00\x00\x00', b'F152610210\x00\x00\x00\x00\x00\x00', b'F1526F4034\x00\x00\x00\x00\x00\x00', b'F1526F4044\x00\x00\x00\x00\x00\x00', b'F1526F4073\x00\x00\x00\x00\x00\x00', b'F1526F4121\x00\x00\x00\x00\x00\x00', b'F1526F4122\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B10011\x00\x00\x00\x00\x00\x00', b'8965B10040\x00\x00\x00\x00\x00\x00', b'8965B10070\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0331024000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', b'\x0331024000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', b'\x0331036000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', b'\x033F401100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203102\x00\x00\x00\x00', b'\x033F424000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F0W01000 ', b'8821FF401600 ', b'8821FF404000 ', b'8821FF404100 ', b'8821FF405100 ', b'8821FF406000 ', b'8821FF407100 ', b'8821F0W01100 ', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646FF401800 ', b'8646FF404000 ', b'8646FF406000 ', b'8646FF407000 ', ], }, CAR.CHRH: { (Ecu.engine, 0x700, None): [ b'\x02896631013200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x0289663F405000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x0289663F418000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x0289663F423000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x0289663F431000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x0189663F438000\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152610013\x00\x00\x00\x00\x00\x00', b'F152610014\x00\x00\x00\x00\x00\x00', b'F152610040\x00\x00\x00\x00\x00\x00', b'F152610190\x00\x00\x00\x00\x00\x00', b'F152610200\x00\x00\x00\x00\x00\x00', b'F152610230\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'8821F0W01000 ', b'8821FF402300 ', b'8821FF402400 ', b'8821FF404000 ', b'8821FF406000 ', b'8821FF407100 ', ], (Ecu.eps, 0x7a1, None): [ b'8965B10011\x00\x00\x00\x00\x00\x00', b'8965B10020\x00\x00\x00\x00\x00\x00', b'8965B10040\x00\x00\x00\x00\x00\x00', b'8965B10050\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F0W01000 ', b'8821FF402300 ', b'8821FF402400 ', b'8821FF404000 ', b'8821FF406000 ', b'8821FF407100 ', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646FF402100 ', b'8646FF404000 ', b'8646FF406000 ', b'8646FF407000 ', ], }, CAR.COROLLA: { (Ecu.engine, 0x7e0, None): [ b'\x0230ZC2000\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC2100\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC2200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC2300\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC3000\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC3100\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC3200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230ZC3300\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0330ZC1200\x00\x00\x00\x00\x00\x00\x00\x0050212000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881510201100\x00\x00\x00\x00', b'881510201200\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152602190\x00\x00\x00\x00\x00\x00', b'F152602191\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B02181\x00\x00\x00\x00\x00\x00', b'8965B02191\x00\x00\x00\x00\x00\x00', b'8965B48150\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0201101\x00\x00\x00\x00', b'8646F0201200\x00\x00\x00\x00', ], }, CAR.COROLLA_TSS2: { (Ecu.engine, 0x700, None): [ b'\x01896630ZG2000\x00\x00\x00\x00', b'\x01896630ZG5000\x00\x00\x00\x00', b'\x01896630ZG5100\x00\x00\x00\x00', b'\x01896630ZG5200\x00\x00\x00\x00', b'\x01896630ZG5300\x00\x00\x00\x00', b'\x01896630ZP2000\x00\x00\x00\x00', b'\x01896630ZQ5000\x00\x00\x00\x00', b'\x018966312L8000\x00\x00\x00\x00', b'\x018966312M0000\x00\x00\x00\x00', b'\x018966312M9000\x00\x00\x00\x00', b'\x018966312P9000\x00\x00\x00\x00', b'\x018966312P9100\x00\x00\x00\x00', b'\x018966312P9200\x00\x00\x00\x00', b'\x018966312Q2300\x00\x00\x00\x00', b'\x018966312R0000\x00\x00\x00\x00', b'\x018966312R0100\x00\x00\x00\x00', b'\x018966312R1000\x00\x00\x00\x00', b'\x018966312R1100\x00\x00\x00\x00', b'\x018966312R3100\x00\x00\x00\x00', b'\x018966312S5000\x00\x00\x00\x00', b'\x018966312S7000\x00\x00\x00\x00', b'\x018966312W3000\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0230ZN4000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x03312M3000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203402\x00\x00\x00\x00', b'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203202\x00\x00\x00\x00', b'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', b'\x03312N6000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203402\x00\x00\x00\x00', b'\x03312N6100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203302\x00\x00\x00\x00', b'\x03312N6100\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00895231203402\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'\x018965B12350\x00\x00\x00\x00\x00\x00', b'\x018965B12470\x00\x00\x00\x00\x00\x00', b'\x018965B12490\x00\x00\x00\x00\x00\x00', b'\x018965B12500\x00\x00\x00\x00\x00\x00', b'\x018965B12520\x00\x00\x00\x00\x00\x00', b'\x018965B12530\x00\x00\x00\x00\x00\x00', b'\x018965B1255000\x00\x00\x00\x00', b'8965B12361\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F152602280\x00\x00\x00\x00\x00\x00', b'\x01F152602560\x00\x00\x00\x00\x00\x00', b'\x01F152602590\x00\x00\x00\x00\x00\x00', b'\x01F152602650\x00\x00\x00\x00\x00\x00', b'\x01F152612641\x00\x00\x00\x00\x00\x00', b'\x01F152612651\x00\x00\x00\x00\x00\x00', b'\x01F152612B10\x00\x00\x00\x00\x00\x00', b'\x01F152612B51\x00\x00\x00\x00\x00\x00', b'\x01F152612B60\x00\x00\x00\x00\x00\x00', b'\x01F152612B61\x00\x00\x00\x00\x00\x00', b'\x01F152612B90\x00\x00\x00\x00\x00\x00', b'\x01F152612C00\x00\x00\x00\x00\x00\x00', b'F152602191\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301200\x00\x00\x00\x00', b'\x018821F3301300\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F12010D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F1201200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F1201300\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F1201400\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', b'\x028646F1202000\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F1202100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F1202200\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', ], }, CAR.COROLLAH_TSS2: { (Ecu.engine, 0x700, None): [ b'\x01896630ZJ1000\x00\x00\x00\x00', b'\x01896630ZU8000\x00\x00\x00\x00', b'\x01896637621000\x00\x00\x00\x00', b'\x01896637624000\x00\x00\x00\x00', b'\x01896637626000\x00\x00\x00\x00', b'\x01896637648000\x00\x00\x00\x00', b'\x02896630ZJ5000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896630ZN8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896630ZQ3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896630ZR2000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896630ZT8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896630ZT9000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x028966312Q3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x028966312Q4000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x038966312L7000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF1205001\x00\x00\x00\x00', b'\x038966312N1000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B12361\x00\x00\x00\x00\x00\x00', b'8965B12451\x00\x00\x00\x00\x00\x00', b'8965B76012\x00\x00\x00\x00\x00\x00', b'8965B76050\x00\x00\x00\x00\x00\x00', b'\x018965B12350\x00\x00\x00\x00\x00\x00', b'\x018965B12470\x00\x00\x00\x00\x00\x00', b'\x018965B12490\x00\x00\x00\x00\x00\x00', b'\x018965B12500\x00\x00\x00\x00\x00\x00', b'\x018965B12520\x00\x00\x00\x00\x00\x00', b'\x018965B12530\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152612590\x00\x00\x00\x00\x00\x00', b'F152612691\x00\x00\x00\x00\x00\x00', b'F152612692\x00\x00\x00\x00\x00\x00', b'F152612700\x00\x00\x00\x00\x00\x00', b'F152612710\x00\x00\x00\x00\x00\x00', b'F152612790\x00\x00\x00\x00\x00\x00', b'F152612800\x00\x00\x00\x00\x00\x00', b'F152612820\x00\x00\x00\x00\x00\x00', b'F152612840\x00\x00\x00\x00\x00\x00', b'F152612A00\x00\x00\x00\x00\x00\x00', b'F152612A10\x00\x00\x00\x00\x00\x00', b'F152642540\x00\x00\x00\x00\x00\x00', b'F152676293\x00\x00\x00\x00\x00\x00', b'F152676303\x00\x00\x00\x00\x00\x00', b'F152676304\x00\x00\x00\x00\x00\x00', b'F152612D00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301200\x00\x00\x00\x00', b'\x018821F3301300\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F12010D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F1201300\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F1201400\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', b'\x028646F1202000\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F1202100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F76020C0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F7603100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F7603200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', ], }, CAR.HIGHLANDER: { (Ecu.engine, 0x700, None): [ b'\x01896630E09000\x00\x00\x00\x00', b'\x01896630E43000\x00\x00\x00\x00', b'\x01896630E43100\x00\x00\x00\x00', b'\x01896630E43200\x00\x00\x00\x00', b'\x01896630E44200\x00\x00\x00\x00', b'\x01896630E45000\x00\x00\x00\x00', b'\x01896630E45100\x00\x00\x00\x00', b'\x01896630E45200\x00\x00\x00\x00', b'\x01896630E46200\x00\x00\x00\x00', b'\x01896630E74000\x00\x00\x00\x00', b'\x01896630E75000\x00\x00\x00\x00', b'\x01896630E76000\x00\x00\x00\x00', b'\x01896630E77000\x00\x00\x00\x00', b'\x01896630E83000\x00\x00\x00\x00', b'\x01896630E84000\x00\x00\x00\x00', b'\x01896630E85000\x00\x00\x00\x00', b'\x01896630E86000\x00\x00\x00\x00', b'\x01896630E88000\x00\x00\x00\x00', b'\x01896630EA0000\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B48140\x00\x00\x00\x00\x00\x00', b'8965B48150\x00\x00\x00\x00\x00\x00', b'8965B48210\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [b'F15260E011\x00\x00\x00\x00\x00\x00'], (Ecu.dsu, 0x791, None): [ b'881510E01100\x00\x00\x00\x00', b'881510E01200\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0E01200\x00\x00\x00\x00', b'8646F0E01300\x00\x00\x00\x00', ], }, CAR.HIGHLANDERH: { (Ecu.eps, 0x7a1, None): [ b'8965B48160\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152648541\x00\x00\x00\x00\x00\x00', b'F152648542\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0230E40000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230E40100\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230EA2000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0230EA2100\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0E01200\x00\x00\x00\x00', b'8646F0E01300\x00\x00\x00\x00', ], }, CAR.HIGHLANDER_TSS2: { (Ecu.eps, 0x7a1, None): [ b'8965B48241\x00\x00\x00\x00\x00\x00', b'8965B48310\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F15260E051\x00\x00\x00\x00\x00\x00', b'\x01F15260E110\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x700, None): [ b'\x01896630E62100\x00\x00\x00\x00', b'\x01896630E62200\x00\x00\x00\x00', b'\x01896630E64100\x00\x00\x00\x00', b'\x01896630E64200\x00\x00\x00\x00', b'\x01896630EB1000\x00\x00\x00\x00', b'\x01896630EB1100\x00\x00\x00\x00', b'\x01896630EB1200\x00\x00\x00\x00', b'\x01896630EB2000\x00\x00\x00\x00', b'\x01896630EB2100\x00\x00\x00\x00', b'\x01896630EB2200\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301400\x00\x00\x00\x00', b'\x018821F6201200\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F0E02100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4803000\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', ], }, CAR.HIGHLANDERH_TSS2: { (Ecu.eps, 0x7a1, None): [ b'8965B48241\x00\x00\x00\x00\x00\x00', b'8965B48310\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F15264872300\x00\x00\x00\x00', b'\x01F15264872400\x00\x00\x00\x00', b'\x01F15264872500\x00\x00\x00\x00', b'\x01F152648C6300\x00\x00\x00\x00', ], (Ecu.engine, 0x700, None): [ b'\x01896630EA1000\000\000\000\000', b'\x01896630EA1000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896630E66000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896630EB3000\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896630EB3100\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301400\x00\x00\x00\x00', b'\x018821F6201200\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F0E02100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4803000\x00\x00\x00\x008646G5301200\x00\x00\x00\x00', ], }, CAR.LEXUS_IS: { (Ecu.engine, 0x700, None): [ b'\x018966353M7100\x00\x00\x00\x00', b'\x018966353Q2000\x00\x00\x00\x00', b'\x018966353Q2300\x00\x00\x00\x00', b'\x018966353R1100\x00\x00\x00\x00', b'\x018966353R7100\x00\x00\x00\x00', b'\x018966353R8100\x00\x00\x00\x00', b'\x018966353Q4000\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0232480000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02353P7000\x00\x00\x00\x00\x00\x00\x00\x00530J5000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02353P9000\x00\x00\x00\x00\x00\x00\x00\x00553C1000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152653301\x00\x00\x00\x00\x00\x00', b'F152653310\x00\x00\x00\x00\x00\x00', b'F152653330\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881515306200\x00\x00\x00\x00', b'881515306400\x00\x00\x00\x00', b'881515306500\x00\x00\x00\x00', b'881515307400\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B53270\x00\x00\x00\x00\x00\x00', b'8965B53271\x00\x00\x00\x00\x00\x00', b'8965B53280\x00\x00\x00\x00\x00\x00', b'8965B53281\x00\x00\x00\x00\x00\x00', b'8965B53311\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', b'8821F4702100\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F5301300\x00\x00\x00\x00', b'8646F5301400\x00\x00\x00\x00', b'8646F5301200\x00\x00\x00\x00', ], }, CAR.PRIUS: { (Ecu.engine, 0x700, None): [ b'\x02896634761000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634761100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634761200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634762000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634763000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634763100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634765000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634765100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634769100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634769200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634770000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634774000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634774100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634774200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634782000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x02896634784000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x028966347A0000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x028966347A5000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x028966347A8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x028966347B0000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x03896634759100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', b'\x03896634759200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', b'\x03896634759200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', b'\x03896634759300\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', b'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701002\x00\x00\x00\x00', b'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', b'\x03896634760000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', b'\x03896634760100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', b'\x03896634760200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', b'\x03896634760200\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', b'\x03896634760300\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701004\x00\x00\x00\x00', b'\x03896634768000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703001\x00\x00\x00\x00', b'\x03896634768000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', b'\x03896634768100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', b'\x03896634785000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4705001\x00\x00\x00\x00', b'\x03896634785000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', b'\x03896634786000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4705001\x00\x00\x00\x00', b'\x03896634786000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', b'\x03896634789000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4703002\x00\x00\x00\x00', b'\x038966347A3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4701003\x00\x00\x00\x00', b'\x038966347A3000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707001\x00\x00\x00\x00', b'\x038966347B6000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', b'\x038966347B7000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710001\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B47021\x00\x00\x00\x00\x00\x00', b'8965B47022\x00\x00\x00\x00\x00\x00', b'8965B47023\x00\x00\x00\x00\x00\x00', b'8965B47050\x00\x00\x00\x00\x00\x00', b'8965B47060\x00\x00\x00\x00\x00\x00', # This is the EPS with good angle sensor ], (Ecu.esp, 0x7b0, None): [ b'F152647290\x00\x00\x00\x00\x00\x00', b'F152647300\x00\x00\x00\x00\x00\x00', b'F152647310\x00\x00\x00\x00\x00\x00', b'F152647414\x00\x00\x00\x00\x00\x00', b'F152647415\x00\x00\x00\x00\x00\x00', b'F152647416\x00\x00\x00\x00\x00\x00', b'F152647417\x00\x00\x00\x00\x00\x00', b'F152647470\x00\x00\x00\x00\x00\x00', b'F152647490\x00\x00\x00\x00\x00\x00', b'F152647683\x00\x00\x00\x00\x00\x00', b'F152647684\x00\x00\x00\x00\x00\x00', b'F152647862\x00\x00\x00\x00\x00\x00', b'F152647863\x00\x00\x00\x00\x00\x00', b'F152647864\x00\x00\x00\x00\x00\x00', b'F152647865\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881514702300\x00\x00\x00\x00', b'881514703100\x00\x00\x00\x00', b'881514704100\x00\x00\x00\x00', b'881514706000\x00\x00\x00\x00', b'881514706100\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702000\x00\x00\x00\x00', b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F4701300\x00\x00\x00\x00', b'8646F4702001\x00\x00\x00\x00', b'8646F4702100\x00\x00\x00\x00', b'8646F4702200\x00\x00\x00\x00', b'8646F4705000\x00\x00\x00\x00', b'8646F4705200\x00\x00\x00\x00', ], }, CAR.RAV4: { (Ecu.engine, 0x7e0, None): [ b'\x02342Q1000\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q1100\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q1200\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q1300\x00\x00\x00\x00\x00\x00\x00\x0054212000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q2000\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q2100\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q2200\x00\x00\x00\x00\x00\x00\x00\x0054213000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342Q4000\x00\x00\x00\x00\x00\x00\x00\x0054215000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B42063\x00\x00\x00\x00\x00\x00', b'8965B42073\x00\x00\x00\x00\x00\x00', b'8965B42082\x00\x00\x00\x00\x00\x00', b'8965B42083\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F15260R102\x00\x00\x00\x00\x00\x00', b'F15260R103\x00\x00\x00\x00\x00\x00', b'F152642493\x00\x00\x00\x00\x00\x00', b'F152642492\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881514201200\x00\x00\x00\x00', b'881514201300\x00\x00\x00\x00', b'881514201400\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702000\x00\x00\x00\x00', b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F4201200\x00\x00\x00\x00', b'8646F4202001\x00\x00\x00\x00', b'8646F4202100\x00\x00\x00\x00', b'8646F4204000\x00\x00\x00\x00', ], }, CAR.RAV4H: { (Ecu.engine, 0x7e0, None): [ b'\x02342N9000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342N9100\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02342P0000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B42102\x00\x00\x00\x00\x00\x00', b'8965B42103\x00\x00\x00\x00\x00\x00', b'8965B42112\x00\x00\x00\x00\x00\x00', b'8965B42162\x00\x00\x00\x00\x00\x00', b'8965B42163\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152642090\x00\x00\x00\x00\x00\x00', b'F152642110\x00\x00\x00\x00\x00\x00', b'F152642120\x00\x00\x00\x00\x00\x00', b'F152642400\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881514202200\x00\x00\x00\x00', b'881514202300\x00\x00\x00\x00', b'881514202400\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702000\x00\x00\x00\x00', b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F4201100\x00\x00\x00\x00', b'8646F4201200\x00\x00\x00\x00', b'8646F4202001\x00\x00\x00\x00', b'8646F4202100\x00\x00\x00\x00', b'8646F4204000\x00\x00\x00\x00', ], }, CAR.RAV4_TSS2: { (Ecu.engine, 0x700, None): [ b'\x01896630R58000\x00\x00\x00\x00', b'\x01896630R58100\x00\x00\x00\x00', b'\x018966342E2000\x00\x00\x00\x00', b'\x018966342M8000\x00\x00\x00\x00', b'\x018966342S9000\x00\x00\x00\x00', b'\x018966342T1000\x00\x00\x00\x00', b'\x018966342T6000\x00\x00\x00\x00', b'\x018966342T9000\x00\x00\x00\x00', b'\x018966342U4000\x00\x00\x00\x00', b'\x018966342U4100\x00\x00\x00\x00', b'\x018966342V3000\x00\x00\x00\x00', b'\x018966342V3100\x00\x00\x00\x00', b'\x018966342V3200\x00\x00\x00\x00', b'\x01896634A05000\x00\x00\x00\x00', b'\x01896634A19000\x00\x00\x00\x00', b'\x01896634A19100\x00\x00\x00\x00', b'\x01896634A20000\x00\x00\x00\x00', b'\x01896634A20100\x00\x00\x00\x00', b'\x01896634A22000\x00\x00\x00\x00', b'\x01896634A22100\x00\x00\x00\x00', b'\x01896634A30000\x00\x00\x00\x00', b'\x01896634A44000\x00\x00\x00\x00', b'\x01896634A45000\x00\x00\x00\x00', b'\x01896634A46000\x00\x00\x00\x00', b'\x028966342M7000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', b'\x028966342T0000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', b'\x028966342V1000\x00\x00\x00\x00897CF1202001\x00\x00\x00\x00', b'\x028966342Y8000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', b'\x02896634A18000\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', b'\x02896634A18100\x00\x00\x00\x00897CF1201001\x00\x00\x00\x00', b'\x02896634A43000\x00\x00\x00\x00897CF4201001\x00\x00\x00\x00', b'\x02896634A47000\x00\x00\x00\x00897CF4201001\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F15260R210\x00\x00\x00\x00\x00\x00', b'\x01F15260R220\x00\x00\x00\x00\x00\x00', b'\x01F15260R290\x00\x00\x00\x00\x00\x00', b'\x01F15260R300\x00\x00\x00\x00\x00\x00', b'\x01F152642551\x00\x00\x00\x00\x00\x00', b'\x01F152642561\x00\x00\x00\x00\x00\x00', b'\x01F152642700\x00\x00\x00\x00\x00\x00', b'\x01F152642701\x00\x00\x00\x00\x00\x00', b'\x01F152642710\x00\x00\x00\x00\x00\x00', b'\x01F152642711\x00\x00\x00\x00\x00\x00', b'\x01F152642750\x00\x00\x00\x00\x00\x00', b'\x01F152642751\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B42170\x00\x00\x00\x00\x00\x00', b'8965B42171\x00\x00\x00\x00\x00\x00', b'8965B42180\x00\x00\x00\x00\x00\x00', b'8965B42181\x00\x00\x00\x00\x00\x00', b'\x028965B0R01200\x00\x00\x00\x008965B0R02200\x00\x00\x00\x00', b'\x028965B0R01300\x00\x00\x00\x008965B0R02300\x00\x00\x00\x00', b'\x028965B0R01400\x00\x00\x00\x008965B0R02400\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301200\x00\x00\x00\x00', b'\x018821F3301300\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F4203200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F4203300\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4203500\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4203700\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F4203800\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', ], }, CAR.RAV4H_TSS2: { (Ecu.engine, 0x700, None): [ b'\x01896634A15000\x00\x00\x00\x00', b'\x018966342M5000\x00\x00\x00\x00', b'\x018966342W8000\x00\x00\x00\x00', b'\x018966342X5000\x00\x00\x00\x00', b'\x018966342X6000\x00\x00\x00\x00', b'\x01896634A25000\x00\x00\x00\x00', b'\x018966342W5000\x00\x00\x00\x00', b'\x028966342W4001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', b'\x02896634A13001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896634A13101\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896634A14001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', b'\x02896634A23001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00', b'\x02896634A14001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', b'\x02896634A14101\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152642291\x00\x00\x00\x00\x00\x00', b'F152642290\x00\x00\x00\x00\x00\x00', b'F152642330\x00\x00\x00\x00\x00\x00', b'F152642331\x00\x00\x00\x00\x00\x00', b'F152642531\x00\x00\x00\x00\x00\x00', b'F152642532\x00\x00\x00\x00\x00\x00', b'F152642520\x00\x00\x00\x00\x00\x00', b'F152642521\x00\x00\x00\x00\x00\x00', b'F152642540\x00\x00\x00\x00\x00\x00', b'F152642541\x00\x00\x00\x00\x00\x00', b'F152642542\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B42170\x00\x00\x00\x00\x00\x00', b'8965B42171\x00\x00\x00\x00\x00\x00', b'8965B42180\x00\x00\x00\x00\x00\x00', b'8965B42181\x00\x00\x00\x00\x00\x00', b'\x028965B0R01200\x00\x00\x00\x008965B0R02200\x00\x00\x00\x00', b'\x028965B0R01300\x00\x00\x00\x008965B0R02300\x00\x00\x00\x00', b'\x028965B0R01400\x00\x00\x00\x008965B0R02400\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301200\x00\x00\x00\x00', b'\x018821F3301300\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F4203200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F4203300\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F4203400\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4203500\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4203700\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F4203800\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', ], }, CAR.LEXUS_ES_TSS2: { (Ecu.engine, 0x700, None): [ b'\x01896630EC9100\x00\x00\x00\x00', b'\x018966333T5000\x00\x00\x00\x00', b'\x018966333T5100\x00\x00\x00\x00', b'\x018966333X6000\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F152606281\x00\x00\x00\x00\x00\x00', b'\x01F152606340\x00\x00\x00\x00\x00\x00', b'\x01F15260E031\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B33252\x00\x00\x00\x00\x00\x00', b'8965B33590\x00\x00\x00\x00\x00\x00', b'8965B48271\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301200\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F33030D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F3303200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F3304100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F4810200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', ], }, CAR.SIENNA: { (Ecu.engine, 0x700, None): [ b'\x01896630832100\x00\x00\x00\x00', b'\x01896630832200\x00\x00\x00\x00', b'\x01896630838000\x00\x00\x00\x00', b'\x01896630838100\x00\x00\x00\x00', b'\x01896630842000\x00\x00\x00\x00', b'\x01896630843000\x00\x00\x00\x00', b'\x01896630851000\x00\x00\x00\x00', b'\x01896630851100\x00\x00\x00\x00', b'\x01896630852100\x00\x00\x00\x00', b'\x01896630859000\x00\x00\x00\x00', b'\x01896630860000\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B45070\x00\x00\x00\x00\x00\x00', b'8965B45080\x00\x00\x00\x00\x00\x00', b'8965B45082\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152608130\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881510801100\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702100\x00\x00\x00\x00', b'8821F4702200\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F0801100\x00\x00\x00\x00', ], }, CAR.LEXUS_CTH: { (Ecu.dsu, 0x791, None): [ b'881517601100\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152676144\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0237635000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F7601100\x00\x00\x00\x00', ], }, CAR.LEXUS_ESH_TSS2: { (Ecu.engine, 0x700, None): [ b'\x028966333S8000\x00\x00\x00\x00897CF3302002\x00\x00\x00\x00', b'\x028966333T0100\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x028966333V4000\x00\x00\x00\x00897CF3305001\x00\x00\x00\x00', b'\x02896633T09000\x00\x00\x00\x00897CF3307001\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152633423\x00\x00\x00\x00\x00\x00', b'F152633680\x00\x00\x00\x00\x00\x00', b'F152633681\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B33252\x00\x00\x00\x00\x00\x00', b'8965B33590\x00\x00\x00\x00\x00\x00', b'8965B33690\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301200\x00\x00\x00\x00', b'\x018821F3301300\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F33030D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F3303100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00', b'\x028646F3304100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F3304200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', ], }, CAR.LEXUS_ESH: { (Ecu.engine, 0x7e0, None): [ b'\x02333M4200\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152633171\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881513310400\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B33512\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4701100\x00\x00\x00\x00', b'8821F4701300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F3302001\x00\x00\x00\x00', b'8646F3302200\x00\x00\x00\x00', ], }, CAR.LEXUS_NX: { (Ecu.engine, 0x700, None): [ b'\x01896637851000\x00\x00\x00\x00', b'\x01896637852000\x00\x00\x00\x00', b'\x01896637854000\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152678130\x00\x00\x00\x00\x00\x00', b'F152678140\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881517803100\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B78060\x00\x00\x00\x00\x00\x00', b'8965B78080\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702100\x00\x00\x00\x00', b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F7801100\x00\x00\x00\x00', ], }, CAR.LEXUS_NX_TSS2: { (Ecu.engine, 0x700, None): [ b'\x018966378B2100\x00\x00\x00\x00', b'\x018966378G3000\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F152678221\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B78120\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b"\x018821F3301400\x00\x00\x00\x00", ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F78030A0\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', b'\x028646F7803100\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', ], }, CAR.PRIUS_ALPHA: { (Ecu.esp, 0x7b0, None): [ b'F152647280\x00\x00\x00\x00\x00\x00', ], (Ecu.engine, 0x7e0, None): [ b'\x0234781000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881514705100\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F4703300\x00\x00\x00\x00', ], }, CAR.LEXUS_NXH: { (Ecu.engine, 0x7e0, None): [ b'\x0237882000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0237841000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0237886000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0237880000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152678160\x00\x00\x00\x00\x00\x00', b'F152678170\x00\x00\x00\x00\x00\x00', b'F152678171\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881517804300\x00\x00\x00\x00', b'881517804100\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B78060\x00\x00\x00\x00\x00\x00', b'8965B78080\x00\x00\x00\x00\x00\x00', b'8965B78100\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4702300\x00\x00\x00\x00', b'8821F4702100\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F7801300\x00\x00\x00\x00', b'8646F7801100\x00\x00\x00\x00', ], }, CAR.LEXUS_RX: { (Ecu.engine, 0x700, None): [ b'\x01896630E36200\x00\x00\x00\x00', b'\x01896630E36300\x00\x00\x00\x00', b'\x01896630E37200\x00\x00\x00\x00', b'\x01896630E37300\x00\x00\x00\x00', b'\x01896630E41000\x00\x00\x00\x00', b'\x01896630E41100\x00\x00\x00\x00', b'\x01896630E41200\x00\x00\x00\x00', b'\x01896630EA3100\x00\x00\x00\x00', b'\x01896630EA4100\x00\x00\x00\x00', b'\x01896630EA4300\x00\x00\x00\x00', b'\x01896630EA6300\x00\x00\x00\x00', b'\x018966348R1300\x00\x00\x00\x00', b'\x018966348R8500\x00\x00\x00\x00', b'\x018966348W1300\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152648472\x00\x00\x00\x00\x00\x00', b'F152648473\x00\x00\x00\x00\x00\x00', b'F152648492\x00\x00\x00\x00\x00\x00', b'F152648493\x00\x00\x00\x00\x00\x00', b'F152648474\x00\x00\x00\x00\x00\x00', b'F152648630\x00\x00\x00\x00\x00\x00', b'F152648494\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881514810300\x00\x00\x00\x00', b'881514810500\x00\x00\x00\x00', b'881514810700\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B0E011\x00\x00\x00\x00\x00\x00', b'8965B0E012\x00\x00\x00\x00\x00\x00', b'8965B48102\x00\x00\x00\x00\x00\x00', b'8965B48112\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4701000\x00\x00\x00\x00', b'8821F4701100\x00\x00\x00\x00', b'8821F4701200\x00\x00\x00\x00', b'8821F4701300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F4801100\x00\x00\x00\x00', b'8646F4801200\x00\x00\x00\x00', b'8646F4802001\x00\x00\x00\x00', b'8646F4802100\x00\x00\x00\x00', b'8646F4802200\x00\x00\x00\x00', b'8646F4809000\x00\x00\x00\x00', ], }, CAR.LEXUS_RXH: { (Ecu.engine, 0x7e0, None): [ b'\x02348J7000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348N0000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348Q4000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348Q4100\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348T1100\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348T3000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348V6000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x02348Z3000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152648361\x00\x00\x00\x00\x00\x00', b'F152648501\x00\x00\x00\x00\x00\x00', b'F152648502\x00\x00\x00\x00\x00\x00', b'F152648504\x00\x00\x00\x00\x00\x00', b'F152648740\x00\x00\x00\x00\x00\x00', b'F152648A30\x00\x00\x00\x00\x00\x00', ], (Ecu.dsu, 0x791, None): [ b'881514811300\x00\x00\x00\x00', b'881514811500\x00\x00\x00\x00', b'881514811700\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B0E011\x00\x00\x00\x00\x00\x00', b'8965B0E012\x00\x00\x00\x00\x00\x00', b'8965B48111\x00\x00\x00\x00\x00\x00', b'8965B48112\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'8821F4701000\x00\x00\x00\x00', b'8821F4701100\x00\x00\x00\x00', b'8821F4701200\x00\x00\x00\x00', b'8821F4701300\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'8646F4801200\x00\x00\x00\x00', b'8646F4802001\x00\x00\x00\x00', b'8646F4802100\x00\x00\x00\x00', b'8646F4802200\x00\x00\x00\x00', b'8646F4809000\x00\x00\x00\x00', ], }, CAR.LEXUS_RX_TSS2: { (Ecu.engine, 0x700, None): [ b'\x01896630EC9000\x00\x00\x00\x00', b'\x01896634D12000\x00\x00\x00\x00', b'\x01896630EB0000\x00\x00\x00\x00', b'\x01896630EA9000\x00\x00\x00\x00', b'\x01896630ED0000\x00\x00\x00\x00', b'\x018966348W9000\x00\x00\x00\x00', b'\x01896634D12100\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'\x01F152648801\x00\x00\x00\x00\x00\x00', b'\x01F15260E031\x00\x00\x00\x00\x00\x00', b'\x01F15260E041\x00\x00\x00\x00\x00\x00', b'\x01F152648781\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B48271\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301100\x00\x00\x00\x00', b'\x018821F3301300\x00\x00\x00\x00', b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F4810200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F4810100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', ], }, CAR.LEXUS_RXH_TSS2: { (Ecu.engine, 0x7e0, None): [ b'\x02348X8000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0234D14000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', b'\x0234D16000\x00\x00\x00\x00\x00\x00\x00\x00A4802000\x00\x00\x00\x00\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152648831\x00\x00\x00\x00\x00\x00', b'F152648D00\x00\x00\x00\x00\x00\x00', b'F152648D60\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B48271\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F4810200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F4810100\x00\x00\x00\x008646G2601200\x00\x00\x00\x00', ], }, CAR.PRIUS_TSS2: { (Ecu.engine, 0x700, None): [ b'\x028966347C8000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00', b'\x038966347C0000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710101\x00\x00\x00\x00', b'\x038966347C1000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4710101\x00\x00\x00\x00', b'\x038966347C5000\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707101\x00\x00\x00\x00', b'\x038966347C5100\x00\x00\x00\x008966A4703000\x00\x00\x00\x00897CF4707101\x00\x00\x00\x00', ], (Ecu.esp, 0x7b0, None): [ b'F152647500\x00\x00\x00\x00\x00\x00', b'F152647510\x00\x00\x00\x00\x00\x00', b'F152647520\x00\x00\x00\x00\x00\x00', b'F152647521\x00\x00\x00\x00\x00\x00', ], (Ecu.eps, 0x7a1, None): [ b'8965B47070\x00\x00\x00\x00\x00\x00', ], (Ecu.fwdRadar, 0x750, 0xf): [ b'\x018821F3301400\x00\x00\x00\x00', ], (Ecu.fwdCamera, 0x750, 0x6d): [ b'\x028646F4707000\x00\x00\x00\x008646G2601400\x00\x00\x00\x00', b'\x028646F4710000\x00\x00\x00\x008646G2601500\x00\x00\x00\x00', ], }, CAR.MIRAI: { (Ecu.esp, 0x7D1, None): [b'\x01898A36203000\x00\x00\x00\x00',], (Ecu.esp, 0x7B0, None): [b'\x01F15266203200\x00\x00\x00\x00',], # a second ESP ECU (Ecu.eps, 0x7A1, None): [b'\x028965B6204100\x00\x00\x00\x008965B6203100\x00\x00\x00\x00',], (Ecu.fwdRadar, 0x750, 0xf): [b'\x018821F6201200\x00\x00\x00\x00',], (Ecu.fwdCamera, 0x750, 0x6d): [b'\x028646F6201400\x00\x00\x00\x008646G5301200\x00\x00\x00\x00',], }, CAR.ALPHARD_TSS2: { (Ecu.engine, 0x7e0, None): [b'\x0235883000\x00\x00\x00\x00\x00\x00\x00\x00A0202000\x00\x00\x00\x00\x00\x00\x00\x00',], (Ecu.eps, 0x7a1, None): [b'8965B58040\x00\x00\x00\x00\x00\x00',], (Ecu.fwdRadar, 0x750, 0xf): [b'\x018821F3301400\x00\x00\x00\x00',], (Ecu.fwdCamera, 0x750, 0x6d): [b'\x028646F5803200\x00\x00\x00\x008646G2601400\x00\x00\x00\x00',], }, } STEER_THRESHOLD = 100 DBC = { CAR.RAV4H: dbc_dict('toyota_rav4_hybrid_2017_pt_generated', 'toyota_adas'), CAR.RAV4: dbc_dict('toyota_rav4_2017_pt_generated', 'toyota_adas'), CAR.PRIUS: dbc_dict('toyota_prius_2017_pt_generated', 'toyota_adas'), CAR.COROLLA: dbc_dict('toyota_corolla_2017_pt_generated', 'toyota_adas'), CAR.LEXUS_RX: dbc_dict('lexus_rx_350_2016_pt_generated', 'toyota_adas'), CAR.LEXUS_RXH: dbc_dict('lexus_rx_hybrid_2017_pt_generated', 'toyota_adas'), CAR.LEXUS_RX_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_RXH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.CHR: dbc_dict('toyota_nodsu_pt_generated', 'toyota_adas'), CAR.CHRH: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_adas'), CAR.CAMRY: dbc_dict('toyota_nodsu_pt_generated', 'toyota_adas'), CAR.CAMRYH: dbc_dict('toyota_camry_hybrid_2018_pt_generated', 'toyota_adas'), CAR.CAMRY_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.CAMRYH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.HIGHLANDER: dbc_dict('toyota_highlander_2017_pt_generated', 'toyota_adas'), CAR.HIGHLANDER_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.HIGHLANDERH: dbc_dict('toyota_highlander_hybrid_2018_pt_generated', 'toyota_adas'), CAR.HIGHLANDERH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.AVALON: dbc_dict('toyota_avalon_2017_pt_generated', 'toyota_adas'), CAR.AVALON_2019: dbc_dict('toyota_nodsu_pt_generated', 'toyota_adas'), CAR.AVALONH_2019: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_adas'), CAR.RAV4_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.COROLLA_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.COROLLAH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_ES_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_ESH_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_ESH: dbc_dict('lexus_ct200h_2018_pt_generated', 'toyota_adas'), CAR.SIENNA: dbc_dict('toyota_sienna_xle_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_IS: dbc_dict('lexus_is_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_CTH: dbc_dict('lexus_ct200h_2018_pt_generated', 'toyota_adas'), CAR.RAV4H_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_NXH: dbc_dict('lexus_nx300h_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_NX: dbc_dict('lexus_nx300_2018_pt_generated', 'toyota_adas'), CAR.LEXUS_NX_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.PRIUS_TSS2: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.MIRAI: dbc_dict('toyota_nodsu_hybrid_pt_generated', 'toyota_tss2_adas'), CAR.ALPHARD_TSS2: dbc_dict('toyota_nodsu_pt_generated', 'toyota_tss2_adas'), CAR.LEXUS_ISH: dbc_dict('lexus_is300h_2017_pt_generated', 'toyota_adas'), CAR.PRIUS_ALPHA: dbc_dict('toyota_prius_alpha_2017_pt_generated', 'toyota_adas'), } # Toyota/Lexus Safety Sense 2.0 and 2.5 TSS2_CAR = set([CAR.RAV4_TSS2, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, CAR.LEXUS_ES_TSS2, CAR.LEXUS_ESH_TSS2, CAR.RAV4H_TSS2, CAR.LEXUS_RX_TSS2, CAR.LEXUS_RXH_TSS2, CAR.HIGHLANDER_TSS2, CAR.HIGHLANDERH_TSS2, CAR.PRIUS_TSS2, CAR.CAMRY_TSS2, CAR.CAMRYH_TSS2, CAR.MIRAI, CAR.LEXUS_NX_TSS2, CAR.ALPHARD_TSS2]) NO_DSU_CAR = TSS2_CAR | set([CAR.CHR, CAR.CHRH, CAR.CAMRY, CAR.CAMRYH]) # no resume button press required NO_STOP_TIMER_CAR = TSS2_CAR | set([CAR.PRIUS_ALPHA, CAR.RAV4H, CAR.HIGHLANDERH, CAR.HIGHLANDER, CAR.SIENNA, CAR.LEXUS_ESH]) ================================================ FILE: selfdrive/car/vin.py ================================================ #!/usr/bin/env python3 import traceback import cereal.messaging as messaging from panda.python.uds import FUNCTIONAL_ADDRS from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery from selfdrive.swaglog import cloudlog VIN_REQUEST = b'\x09\x02' VIN_RESPONSE = b'\x49\x02\x01' VIN_UNKNOWN = "0" * 17 def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False): for i in range(retry): try: query = IsoTpParallelQuery(sendcan, logcan, bus, FUNCTIONAL_ADDRS, [VIN_REQUEST], [VIN_RESPONSE], functional_addr=True, debug=debug) for addr, vin in query.get_data(timeout).items(): return addr[0], vin.decode() print(f"vin query retry ({i+1}) ...") except Exception: cloudlog.warning(f"VIN query exception: {traceback.format_exc()}") return 0, VIN_UNKNOWN if __name__ == "__main__": import time sendcan = messaging.pub_sock('sendcan') logcan = messaging.sub_sock('can') time.sleep(1) addr, vin = get_vin(logcan, sendcan, 1, debug=False) print(hex(addr), vin) ================================================ FILE: selfdrive/car/volkswagen/__init__.py ================================================ ================================================ FILE: selfdrive/car/volkswagen/carcontroller.py ================================================ from cereal import car from selfdrive.car import apply_std_steer_torque_limits from selfdrive.car.volkswagen import volkswagencan from selfdrive.car.volkswagen.values import DBC_FILES, CANBUS, MQB_LDW_MESSAGES, BUTTON_STATES, CarControllerParams as P from opendbc.can.packer import CANPacker from common.dp_common import common_controller_ctrl VisualAlert = car.CarControl.HUDControl.VisualAlert class CarController(): def __init__(self, dbc_name, CP, VM): # dp self.last_blinker_on = False self.blinker_end_frame = 0. self.apply_steer_last = 0 self.packer_pt = CANPacker(DBC_FILES.mqb) self.hcaSameTorqueCount = 0 self.hcaEnabledFrameCount = 0 self.graButtonStatesToSend = None self.graMsgSentCount = 0 self.graMsgStartFramePrev = 0 self.graMsgBusCounterPrev = 0 self.steer_rate_limited = False def update(self, enabled, CS, frame, ext_bus, actuators, visual_alert, left_lane_visible, right_lane_visible, left_lane_depart, right_lane_depart, dragonconf): """ Controls thread """ can_sends = [] # **** Steering Controls ************************************************ # if frame % P.HCA_STEP == 0: # Logic to avoid HCA state 4 "refused": # * Don't steer unless HCA is in state 3 "ready" or 5 "active" # * Don't steer at standstill # * Don't send > 3.00 Newton-meters torque # * Don't send the same torque for > 6 seconds # * Don't send uninterrupted steering for > 360 seconds # One frame of HCA disabled is enough to reset the timer, without zeroing the # torque value. Do that anytime we happen to have 0 torque, or failing that, # when exceeding ~1/3 the 360 second timer. if enabled and not (CS.out.standstill or CS.out.steerError or CS.out.steerWarning): new_steer = int(round(actuators.steer * P.STEER_MAX)) apply_steer = apply_std_steer_torque_limits(new_steer, self.apply_steer_last, CS.out.steeringTorque, P) self.steer_rate_limited = new_steer != apply_steer if apply_steer == 0: hcaEnabled = False self.hcaEnabledFrameCount = 0 else: self.hcaEnabledFrameCount += 1 if self.hcaEnabledFrameCount >= 118 * (100 / P.HCA_STEP): # 118s hcaEnabled = False self.hcaEnabledFrameCount = 0 else: hcaEnabled = True if self.apply_steer_last == apply_steer: self.hcaSameTorqueCount += 1 if self.hcaSameTorqueCount > 1.9 * (100 / P.HCA_STEP): # 1.9s apply_steer -= (1, -1)[apply_steer < 0] self.hcaSameTorqueCount = 0 else: self.hcaSameTorqueCount = 0 else: hcaEnabled = False apply_steer = 0 # dp if CS.out.stopSteering: apply_steer = 0 blinker_on = CS.out.leftBlinker or CS.out.rightBlinker if not enabled: self.blinker_end_frame = 0 if self.last_blinker_on and not blinker_on: self.blinker_end_frame = frame + dragonconf.dpSignalOffDelay apply_steer = common_controller_ctrl(enabled, dragonconf, blinker_on or frame < self.blinker_end_frame, apply_steer, CS.out.vEgo) self.last_blinker_on = blinker_on self.apply_steer_last = apply_steer idx = (frame / P.HCA_STEP) % 16 can_sends.append(volkswagencan.create_mqb_steering_control(self.packer_pt, CANBUS.pt, apply_steer, idx, hcaEnabled)) # **** HUD Controls ***************************************************** # if frame % P.LDW_STEP == 0: if visual_alert in [VisualAlert.steerRequired, VisualAlert.ldw]: hud_alert = MQB_LDW_MESSAGES["laneAssistTakeOverSilent"] else: hud_alert = MQB_LDW_MESSAGES["none"] can_sends.append(volkswagencan.create_mqb_hud_control(self.packer_pt, CANBUS.pt, enabled, CS.out.steeringPressed, hud_alert, left_lane_visible, right_lane_visible, CS.ldw_lane_warning_left, CS.ldw_lane_warning_right, CS.ldw_side_dlc_tlc, CS.ldw_dlc, CS.ldw_tlc, CS.out.standstill, left_lane_depart, right_lane_depart)) # **** ACC Button Controls ********************************************** # # FIXME: this entire section is in desperate need of refactoring if frame > self.graMsgStartFramePrev + P.GRA_VBP_STEP: if not enabled and CS.out.cruiseState.enabled: # Cancel ACC if it's engaged with OP disengaged. self.graButtonStatesToSend = BUTTON_STATES.copy() self.graButtonStatesToSend["cancel"] = True elif enabled and CS.out.standstill: # Blip the Resume button if we're engaged at standstill. # FIXME: This is a naive implementation, improve with visiond or radar input. # A subset of MQBs like to "creep" too aggressively with this implementation. self.graButtonStatesToSend = BUTTON_STATES.copy() self.graButtonStatesToSend["resumeCruise"] = True if CS.graMsgBusCounter != self.graMsgBusCounterPrev: self.graMsgBusCounterPrev = CS.graMsgBusCounter if self.graButtonStatesToSend is not None: if self.graMsgSentCount == 0: self.graMsgStartFramePrev = frame idx = (CS.graMsgBusCounter + 1) % 16 can_sends.append(volkswagencan.create_mqb_acc_buttons_control(self.packer_pt, ext_bus, self.graButtonStatesToSend, CS, idx)) self.graMsgSentCount += 1 if self.graMsgSentCount >= P.GRA_VBP_COUNT: self.graButtonStatesToSend = None self.graMsgSentCount = 0 return can_sends ================================================ FILE: selfdrive/car/volkswagen/carstate.py ================================================ import numpy as np from cereal import car from selfdrive.config import Conversions as CV from selfdrive.car.interfaces import CarStateBase from opendbc.can.parser import CANParser from opendbc.can.can_define import CANDefine from selfdrive.car.volkswagen.values import DBC_FILES, CANBUS, NetworkLocation, TransmissionType, GearShifter, BUTTON_STATES, CarControllerParams class CarState(CarStateBase): def __init__(self, CP): super().__init__(CP) can_define = CANDefine(DBC_FILES.mqb) if CP.transmissionType == TransmissionType.automatic: self.shifter_values = can_define.dv["Getriebe_11"]["GE_Fahrstufe"] elif CP.transmissionType == TransmissionType.direct: self.shifter_values = can_define.dv["EV_Gearshift"]["GearPosition"] self.hca_status_values = can_define.dv["LH_EPS_03"]["EPS_HCA_Status"] self.buttonStates = BUTTON_STATES.copy() def update(self, pt_cp, cam_cp, ext_cp, trans_type): ret = car.CarState.new_message() # Update vehicle speed and acceleration from ABS wheel speeds. ret.wheelSpeeds.fl = pt_cp.vl["ESP_19"]["ESP_VL_Radgeschw_02"] * CV.KPH_TO_MS ret.wheelSpeeds.fr = pt_cp.vl["ESP_19"]["ESP_VR_Radgeschw_02"] * CV.KPH_TO_MS ret.wheelSpeeds.rl = pt_cp.vl["ESP_19"]["ESP_HL_Radgeschw_02"] * CV.KPH_TO_MS ret.wheelSpeeds.rr = pt_cp.vl["ESP_19"]["ESP_HR_Radgeschw_02"] * CV.KPH_TO_MS ret.vEgoRaw = float(np.mean([ret.wheelSpeeds.fl, ret.wheelSpeeds.fr, ret.wheelSpeeds.rl, ret.wheelSpeeds.rr])) ret.vEgo, ret.aEgo = self.update_speed_kf(ret.vEgoRaw) # dp addition - Fix stop and go acc self-resume +1 ret.standstill = bool(pt_cp.vl["ESP_21"]["ESP_Haltebestaetigung"]) and ret.vEgoRaw < 0.01 # Update steering angle, rate, yaw rate, and driver input torque. VW send # the sign/direction in a separate signal so they must be recombined. ret.steeringAngleDeg = pt_cp.vl["LH_EPS_03"]["EPS_Berechneter_LW"] * (1, -1)[int(pt_cp.vl["LH_EPS_03"]["EPS_VZ_BLW"])] ret.steeringRateDeg = pt_cp.vl["LWI_01"]["LWI_Lenkradw_Geschw"] * (1, -1)[int(pt_cp.vl["LWI_01"]["LWI_VZ_Lenkradw_Geschw"])] ret.steeringTorque = pt_cp.vl["LH_EPS_03"]["EPS_Lenkmoment"] * (1, -1)[int(pt_cp.vl["LH_EPS_03"]["EPS_VZ_Lenkmoment"])] ret.steeringPressed = abs(ret.steeringTorque) > CarControllerParams.STEER_DRIVER_ALLOWANCE ret.yawRate = pt_cp.vl["ESP_02"]["ESP_Gierrate"] * (1, -1)[int(pt_cp.vl["ESP_02"]["ESP_VZ_Gierrate"])] * CV.DEG_TO_RAD # Verify EPS readiness to accept steering commands hca_status = self.hca_status_values.get(pt_cp.vl["LH_EPS_03"]["EPS_HCA_Status"]) ret.steerError = hca_status in ["DISABLED", "FAULT"] ret.steerWarning = hca_status in ["INITIALIZING", "REJECTED"] # Update gas, brakes, and gearshift. ret.gas = pt_cp.vl["Motor_20"]["MO_Fahrpedalrohwert_01"] / 100.0 ret.gasPressed = ret.gas > 0 ret.brake = pt_cp.vl["ESP_05"]["ESP_Bremsdruck"] / 250.0 # FIXME: this is pressure in Bar, not sure what OP expects ret.brakePressed = bool(pt_cp.vl["ESP_05"]["ESP_Fahrer_bremst"]) ret.brakeLights = bool(pt_cp.vl["ESP_05"]['ESP_Status_Bremsdruck']) # Update gear and/or clutch position data. if trans_type == TransmissionType.automatic: ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["Getriebe_11"]["GE_Fahrstufe"], None)) elif trans_type == TransmissionType.direct: ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(pt_cp.vl["EV_Gearshift"]["GearPosition"], None)) elif trans_type == TransmissionType.manual: ret.clutchPressed = not pt_cp.vl["Motor_14"]["MO_Kuppl_schalter"] if bool(pt_cp.vl["Gateway_72"]["BCM1_Rueckfahrlicht_Schalter"]): ret.gearShifter = GearShifter.reverse else: ret.gearShifter = GearShifter.drive # Update door and trunk/hatch lid open status. ret.doorOpen = any([pt_cp.vl["Gateway_72"]["ZV_FT_offen"], pt_cp.vl["Gateway_72"]["ZV_BT_offen"], pt_cp.vl["Gateway_72"]["ZV_HFS_offen"], pt_cp.vl["Gateway_72"]["ZV_HBFS_offen"], pt_cp.vl["Gateway_72"]["ZV_HD_offen"]]) # Update seatbelt fastened status. ret.seatbeltUnlatched = pt_cp.vl["Airbag_02"]["AB_Gurtschloss_FA"] != 3 # Update driver preference for metric. VW stores many different unit # preferences, including separate units for for distance vs. speed. # We use the speed preference for OP. self.displayMetricUnits = not pt_cp.vl["Einheiten_01"]["KBI_MFA_v_Einheit_02"] # Consume blind-spot monitoring info/warning LED states, if available. # Infostufe: BSM LED on, Warnung: BSM LED flashing if self.CP.enableBsm: ret.leftBlindspot = bool(ext_cp.vl["SWA_01"]["SWA_Infostufe_SWA_li"]) or bool(ext_cp.vl["SWA_01"]["SWA_Warnung_SWA_li"]) ret.rightBlindspot = bool(ext_cp.vl["SWA_01"]["SWA_Infostufe_SWA_re"]) or bool(ext_cp.vl["SWA_01"]["SWA_Warnung_SWA_re"]) # Consume factory LDW data relevant for factory SWA (Lane Change Assist) # and capture it for forwarding to the blind spot radar controller self.ldw_lane_warning_left = bool(cam_cp.vl["LDW_02"]["LDW_SW_Warnung_links"]) self.ldw_lane_warning_right = bool(cam_cp.vl["LDW_02"]["LDW_SW_Warnung_rechts"]) self.ldw_side_dlc_tlc = bool(cam_cp.vl["LDW_02"]["LDW_Seite_DLCTLC"]) self.ldw_dlc = cam_cp.vl["LDW_02"]["LDW_DLC"] self.ldw_tlc = cam_cp.vl["LDW_02"]["LDW_TLC"] # Stock FCW is considered active if the release bit for brake-jerk warning # is set. Stock AEB considered active if the partial braking or target # braking release bits are set. # Refer to VW Self Study Program 890253: Volkswagen Driver Assistance # Systems, chapter on Front Assist with Braking: Golf Family for all MQB ret.stockFcw = bool(ext_cp.vl["ACC_10"]["AWV2_Freigabe"]) ret.stockAeb = bool(ext_cp.vl["ACC_10"]["ANB_Teilbremsung_Freigabe"]) or bool(ext_cp.vl["ACC_10"]["ANB_Zielbremsung_Freigabe"]) # Update ACC radar status. accStatus = pt_cp.vl["TSK_06"]["TSK_Status"] if accStatus == 2: # ACC okay and enabled, but not currently engaged ret.cruiseState.available = True ret.cruiseState.enabled = False elif accStatus in [3, 4, 5]: # ACC okay and enabled, currently engaged and regulating speed (3) or engaged with driver accelerating (4) or overrun (5) ret.cruiseState.available = True ret.cruiseState.enabled = True else: # ACC okay but disabled (1), or a radar visibility or other fault/disruption (6 or 7) ret.cruiseState.available = False ret.cruiseState.enabled = False # dp ret.cruiseActualEnabled = ret.cruiseState.enabled # Update ACC setpoint. When the setpoint is zero or there's an error, the # radar sends a set-speed of ~90.69 m/s / 203mph. ret.cruiseState.speed = ext_cp.vl["ACC_02"]["ACC_Wunschgeschw"] * CV.KPH_TO_MS if ret.cruiseState.speed > 90: ret.cruiseState.speed = 0 # Update control button states for turn signals and ACC controls. self.buttonStates["accelCruise"] = bool(pt_cp.vl["GRA_ACC_01"]["GRA_Tip_Hoch"]) self.buttonStates["decelCruise"] = bool(pt_cp.vl["GRA_ACC_01"]["GRA_Tip_Runter"]) self.buttonStates["cancel"] = bool(pt_cp.vl["GRA_ACC_01"]["GRA_Abbrechen"]) self.buttonStates["setCruise"] = bool(pt_cp.vl["GRA_ACC_01"]["GRA_Tip_Setzen"]) self.buttonStates["resumeCruise"] = bool(pt_cp.vl["GRA_ACC_01"]["GRA_Tip_Wiederaufnahme"]) self.buttonStates["gapAdjustCruise"] = bool(pt_cp.vl["GRA_ACC_01"]["GRA_Verstellung_Zeitluecke"]) ret.leftBlinker = bool(pt_cp.vl["Blinkmodi_02"]["Comfort_Signal_Left"]) ret.rightBlinker = bool(pt_cp.vl["Blinkmodi_02"]["Comfort_Signal_Right"]) # Read ACC hardware button type configuration info that has to pass thru # to the radar. Ends up being different for steering wheel buttons vs # third stalk type controls. self.graHauptschalter = pt_cp.vl["GRA_ACC_01"]["GRA_Hauptschalter"] self.graTypHauptschalter = pt_cp.vl["GRA_ACC_01"]["GRA_Typ_Hauptschalter"] self.graButtonTypeInfo = pt_cp.vl["GRA_ACC_01"]["GRA_ButtonTypeInfo"] self.graTipStufe2 = pt_cp.vl["GRA_ACC_01"]["GRA_Tip_Stufe_2"] # Pick up the GRA_ACC_01 CAN message counter so we can sync to it for # later cruise-control button spamming. self.graMsgBusCounter = pt_cp.vl["GRA_ACC_01"]["COUNTER"] # Additional safety checks performed in CarInterface. self.parkingBrakeSet = bool(pt_cp.vl["Kombi_01"]["KBI_Handbremse"]) # FIXME: need to include an EPB check as well ret.espDisabled = pt_cp.vl["ESP_21"]["ESP_Tastung_passiv"] != 0 return ret @staticmethod def get_can_parser(CP): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("EPS_Berechneter_LW", "LH_EPS_03", 0), # Absolute steering angle ("EPS_VZ_BLW", "LH_EPS_03", 0), # Steering angle sign ("LWI_Lenkradw_Geschw", "LWI_01", 0), # Absolute steering rate ("LWI_VZ_Lenkradw_Geschw", "LWI_01", 0), # Steering rate sign ("ESP_VL_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, front left ("ESP_VR_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, front right ("ESP_HL_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, rear left ("ESP_HR_Radgeschw_02", "ESP_19", 0), # ABS wheel speed, rear right ("ESP_Gierrate", "ESP_02", 0), # Absolute yaw rate ("ESP_VZ_Gierrate", "ESP_02", 0), # Yaw rate sign ("ZV_FT_offen", "Gateway_72", 0), # Door open, driver ("ZV_BT_offen", "Gateway_72", 0), # Door open, passenger ("ZV_HFS_offen", "Gateway_72", 0), # Door open, rear left ("ZV_HBFS_offen", "Gateway_72", 0), # Door open, rear right ("ZV_HD_offen", "Gateway_72", 0), # Trunk or hatch open ("Comfort_Signal_Left", "Blinkmodi_02", 0), # Left turn signal including comfort blink interval ("Comfort_Signal_Right", "Blinkmodi_02", 0), # Right turn signal including comfort blink interval ("AB_Gurtschloss_FA", "Airbag_02", 0), # Seatbelt status, driver ("AB_Gurtschloss_BF", "Airbag_02", 0), # Seatbelt status, passenger ("ESP_Fahrer_bremst", "ESP_05", 0), # Brake pedal pressed ("ESP_Status_Bremsdruck", "ESP_05", 0), # Brakes applied ("ESP_Bremsdruck", "ESP_05", 0), # Brake pressure applied ("MO_Fahrpedalrohwert_01", "Motor_20", 0), # Accelerator pedal value ("EPS_Lenkmoment", "LH_EPS_03", 0), # Absolute driver torque input ("EPS_VZ_Lenkmoment", "LH_EPS_03", 0), # Driver torque input sign ("EPS_HCA_Status", "LH_EPS_03", 3), # EPS HCA control status ("ESP_Tastung_passiv", "ESP_21", 0), # Stability control disabled ("ESP_Haltebestaetigung", "ESP_21", 0), # prevents set point creep ("KBI_MFA_v_Einheit_02", "Einheiten_01", 0), # MPH vs KMH speed display ("KBI_Handbremse", "Kombi_01", 0), # Manual handbrake applied ("TSK_Status", "TSK_06", 0), # ACC engagement status from drivetrain coordinator ("GRA_Hauptschalter", "GRA_ACC_01", 0), # ACC button, on/off ("GRA_Abbrechen", "GRA_ACC_01", 0), # ACC button, cancel ("GRA_Tip_Setzen", "GRA_ACC_01", 0), # ACC button, set ("GRA_Tip_Hoch", "GRA_ACC_01", 0), # ACC button, increase or accel ("GRA_Tip_Runter", "GRA_ACC_01", 0), # ACC button, decrease or decel ("GRA_Tip_Wiederaufnahme", "GRA_ACC_01", 0), # ACC button, resume ("GRA_Verstellung_Zeitluecke", "GRA_ACC_01", 0), # ACC button, time gap adj ("GRA_Typ_Hauptschalter", "GRA_ACC_01", 0), # ACC main button type ("GRA_Tip_Stufe_2", "GRA_ACC_01", 0), # unknown related to stalk type ("GRA_ButtonTypeInfo", "GRA_ACC_01", 0), # unknown related to stalk type ("COUNTER", "GRA_ACC_01", 0), # GRA_ACC_01 CAN message counter ] checks = [ # sig_address, frequency ("LWI_01", 100), # From J500 Steering Assist with integrated sensors ("LH_EPS_03", 100), # From J500 Steering Assist with integrated sensors ("ESP_19", 100), # From J104 ABS/ESP controller ("ESP_05", 50), # From J104 ABS/ESP controller ("ESP_21", 50), # From J104 ABS/ESP controller ("Motor_20", 50), # From J623 Engine control module ("TSK_06", 50), # From J623 Engine control module ("ESP_02", 50), # From J104 ABS/ESP controller ("GRA_ACC_01", 33), # From J533 CAN gateway (via LIN from steering wheel controls) ("Gateway_72", 10), # From J533 CAN gateway (aggregated data) ("Airbag_02", 5), # From J234 Airbag control module ("Kombi_01", 2), # From J285 Instrument cluster ("Blinkmodi_02", 1), # From J519 BCM (sent at 1Hz when no lights active, 50Hz when active) ("Einheiten_01", 1), # From J??? not known if gateway, cluster, or BCM ] if CP.transmissionType == TransmissionType.automatic: signals += [("GE_Fahrstufe", "Getriebe_11", 0)] # Auto trans gear selector position checks += [("Getriebe_11", 20)] # From J743 Auto transmission control module elif CP.transmissionType == TransmissionType.direct: signals += [("GearPosition", "EV_Gearshift", 0)] # EV gear selector position checks += [("EV_Gearshift", 10)] # From J??? unknown EV control module elif CP.transmissionType == TransmissionType.manual: signals += [("MO_Kuppl_schalter", "Motor_14", 0), # Clutch switch ("BCM1_Rueckfahrlicht_Schalter", "Gateway_72", 0)] # Reverse light from BCM checks += [("Motor_14", 10)] # From J623 Engine control module if CP.networkLocation == NetworkLocation.fwdCamera: # Radars are here on CANBUS.pt signals += MqbExtraSignals.fwd_radar_signals checks += MqbExtraSignals.fwd_radar_checks if CP.enableBsm: signals += MqbExtraSignals.bsm_radar_signals checks += MqbExtraSignals.bsm_radar_checks return CANParser(DBC_FILES.mqb, signals, checks, CANBUS.pt) @staticmethod def get_cam_can_parser(CP): signals = [ # sig_name, sig_address, default ("LDW_SW_Warnung_links", "LDW_02", 0), # Blind spot in warning mode on left side due to lane departure ("LDW_SW_Warnung_rechts", "LDW_02", 0), # Blind spot in warning mode on right side due to lane departure ("LDW_Seite_DLCTLC", "LDW_02", 0), # Direction of most likely lane departure (left or right) ("LDW_DLC", "LDW_02", 0), # Lane departure, distance to line crossing ("LDW_TLC", "LDW_02", 0), # Lane departure, time to line crossing ] checks = [ # sig_address, frequency ("LDW_02", 10) # From R242 Driver assistance camera ] if CP.networkLocation == NetworkLocation.gateway: # Radars are here on CANBUS.cam signals += MqbExtraSignals.fwd_radar_signals checks += MqbExtraSignals.fwd_radar_checks if CP.enableBsm: signals += MqbExtraSignals.bsm_radar_signals checks += MqbExtraSignals.bsm_radar_checks return CANParser(DBC_FILES.mqb, signals, checks, CANBUS.cam) class MqbExtraSignals: # Additional signal and message lists for optional or bus-portable controllers fwd_radar_signals = [ ("ACC_Wunschgeschw", "ACC_02", 0), # ACC set speed ("AWV2_Freigabe", "ACC_10", 0), # FCW brake jerk release ("ANB_Teilbremsung_Freigabe", "ACC_10", 0), # AEB partial braking release ("ANB_Zielbremsung_Freigabe", "ACC_10", 0), # AEB target braking release ] fwd_radar_checks = [ ("ACC_10", 50), # From J428 ACC radar control module ("ACC_02", 17), # From J428 ACC radar control module ] bsm_radar_signals = [ ("SWA_Infostufe_SWA_li", "SWA_01", 0), # Blind spot object info, left ("SWA_Warnung_SWA_li", "SWA_01", 0), # Blind spot object warning, left ("SWA_Infostufe_SWA_re", "SWA_01", 0), # Blind spot object info, right ("SWA_Warnung_SWA_re", "SWA_01", 0), # Blind spot object warning, right ] bsm_radar_checks = [ ("SWA_01", 20), # From J1086 Lane Change Assist ] ================================================ FILE: selfdrive/car/volkswagen/interface.py ================================================ from cereal import car from selfdrive.car.volkswagen.values import CAR, BUTTON_STATES, CANBUS, NetworkLocation, TransmissionType, GearShifter from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint from selfdrive.car.interfaces import CarInterfaceBase from common.dp_common import common_interface_atl, common_interface_get_params_lqr EventName = car.CarEvent.EventName class CarInterface(CarInterfaceBase): def __init__(self, CP, CarController, CarState): super().__init__(CP, CarController, CarState) self.displayMetricUnitsPrev = None self.buttonStatesPrev = BUTTON_STATES.copy() if CP.networkLocation == NetworkLocation.fwdCamera: self.ext_bus = CANBUS.pt self.cp_ext = self.cp else: self.ext_bus = CANBUS.cam self.cp_ext = self.cp_cam # timebomb_counter mod self.cruise_enabled_prev = False self.timebomb_counter = 0 self.wheel_grabbed = False self.timebomb_bypass_counter = 0 @staticmethod def get_params(candidate, fingerprint=gen_empty_fingerprint(), car_fw=None): ret = CarInterfaceBase.get_std_params(candidate, fingerprint) ret.carName = "volkswagen" ret.communityFeature = True ret.radarOffCan = True if True: # pylint: disable=using-constant-test # Set global MQB parameters ret.safetyModel = car.CarParams.SafetyModel.volkswagen ret.enableBsm = 0x30F in fingerprint[0] if 0xAD in fingerprint[0]: # Getriebe_11 ret.transmissionType = TransmissionType.automatic elif 0x187 in fingerprint[0]: # EV_Gearshift ret.transmissionType = TransmissionType.direct else: # No trans message at all, must be a true stick-shift manual ret.transmissionType = TransmissionType.manual if 0x86 in fingerprint[1]: # LWI_01 seen on bus 1, we're wired to the CAN gateway ret.networkLocation = NetworkLocation.gateway # dp - we need this for chinese vw? if 0xFD in fingerprint[1]: ret.networkLocation = NetworkLocation.gateway else: # We're wired to the LKAS camera ret.networkLocation = NetworkLocation.fwdCamera # Global tuning defaults, can be overridden per-vehicle ret.steerActuatorDelay = 0.05 ret.steerRateCost = 1.0 ret.steerLimitTimer = 0.4 ret.steerRatio = 15.6 # Let the params learner figure this out tire_stiffness_factor = 1.0 # Let the params learner figure this out ret.lateralTuning.pid.kpBP = [0.] ret.lateralTuning.pid.kiBP = [0.] ret.lateralTuning.pid.kf = 0.00006 ret.lateralTuning.pid.kpV = [0.6] ret.lateralTuning.pid.kiV = [0.2] # Per-chassis tuning values, override tuning defaults here if desired if candidate == CAR.ATLAS_MK1: ret.mass = 2011 + STD_CARGO_KG ret.wheelbase = 2.98 elif candidate == CAR.GOLF_MK7: ret.mass = 1397 + STD_CARGO_KG ret.wheelbase = 2.62 elif candidate == CAR.JETTA_MK7: ret.mass = 1328 + STD_CARGO_KG ret.wheelbase = 2.71 elif candidate == CAR.PASSAT_MK8: ret.mass = 1551 + STD_CARGO_KG ret.wheelbase = 2.79 elif candidate == CAR.TCROSS_MK1: ret.mass = 1150 + STD_CARGO_KG ret.wheelbase = 2.60 elif candidate == CAR.TIGUAN_MK2: ret.mass = 1715 + STD_CARGO_KG ret.wheelbase = 2.74 elif candidate == CAR.TOURAN_MK2: ret.mass = 1516 + STD_CARGO_KG ret.wheelbase = 2.79 elif candidate == CAR.AUDI_A3_MK3: ret.mass = 1335 + STD_CARGO_KG ret.wheelbase = 2.61 elif candidate == CAR.AUDI_Q2_MK1: ret.mass = 1205 + STD_CARGO_KG ret.wheelbase = 2.61 elif candidate == CAR.SEAT_ATECA_MK1: ret.mass = 1900 + STD_CARGO_KG ret.wheelbase = 2.64 elif candidate == CAR.SEAT_LEON_MK3: ret.mass = 1227 + STD_CARGO_KG ret.wheelbase = 2.64 elif candidate == CAR.SKODA_KODIAQ_MK1: ret.mass = 1569 + STD_CARGO_KG ret.wheelbase = 2.79 elif candidate == CAR.SKODA_OCTAVIA_MK3: ret.mass = 1388 + STD_CARGO_KG ret.wheelbase = 2.68 elif candidate == CAR.SKODA_SCALA_MK1: ret.mass = 1192 + STD_CARGO_KG ret.wheelbase = 2.65 elif candidate == CAR.SKODA_SUPERB_MK3: ret.mass = 1505 + STD_CARGO_KG ret.wheelbase = 2.84 # TODO: get actual value, for now starting with reasonable value for # civic and scaling by mass and wheelbase ret.rotationalInertia = scale_rot_inertia(ret.mass, ret.wheelbase) # TODO: start from empirically derived lateral slip stiffness for the civic and scale by # mass and CG position, so all cars will have approximately similar dyn behaviors ret.centerToFront = ret.wheelbase * 0.45 ret.tireStiffnessFront, ret.tireStiffnessRear = scale_tire_stiffness(ret.mass, ret.wheelbase, ret.centerToFront, tire_stiffness_factor=tire_stiffness_factor) # dp ret = common_interface_get_params_lqr(ret) return ret # returns a car.CarState def update(self, c, can_strings, dragonconf): buttonEvents = [] # Process the most recent CAN message traffic, and check for validity # The camera CAN has no signals we use at this time, but we process it # anyway so we can test connectivity with can_valid self.cp.update_strings(can_strings) self.cp_cam.update_strings(can_strings) ret = self.CS.update(self.cp, self.cp_cam, self.cp_ext, self.CP.transmissionType) # dp self.dragonconf = dragonconf ret.cruiseState.enabled = common_interface_atl(ret, dragonconf.dpAtl) ret.canValid = self.cp.can_valid and self.cp_cam.can_valid ret.steeringRateLimited = self.CC.steer_rate_limited if self.CC is not None else False # TODO: add a field for this to carState, car interface code shouldn't write params # Update the device metric configuration to match the car at first startup, # or if there's been a change. #if self.CS.displayMetricUnits != self.displayMetricUnitsPrev: # put_nonblocking("IsMetric", "1" if self.CS.displayMetricUnits else "0") # Check for and process state-change events (button press or release) from # the turn stalk switch or ACC steering wheel/control stalk buttons. for button in self.CS.buttonStates: if self.CS.buttonStates[button] != self.buttonStatesPrev[button]: be = car.CarState.ButtonEvent.new_message() be.type = button be.pressed = self.CS.buttonStates[button] buttonEvents.append(be) events = self.create_common_events(ret, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic]) # Vehicle health and operation safety checks if self.CS.parkingBrakeSet: events.add(EventName.parkBrake) if dragonconf.dpVwTimebombAssist: ret.stopSteering = False if ret.cruiseState.enabled: self.timebomb_counter += 1 else: self.timebomb_counter = 0 self.timebomb_bypass_counter = 0 if self.timebomb_counter >= 33000: # 330*100 time in seconds until counter threshold for timebombWarn alert if not self.wheel_grabbed: events.add(EventName.timebombWarn) if self.wheel_grabbed or ret.steeringPressed: self.wheel_grabbed = True ret.stopSteering = True self.timebomb_bypass_counter += 1 if self.timebomb_bypass_counter >= 300: # 3*100 time alloted for bypass self.wheel_grabbed = False self.timebomb_counter = 0 self.timebomb_bypass_counter = 0 events.add(EventName.timebombBypassed) else: events.add(EventName.timebombBypassing) ret.events = events.to_msg() ret.buttonEvents = buttonEvents # update previous car states self.displayMetricUnitsPrev = self.CS.displayMetricUnits self.buttonStatesPrev = self.CS.buttonStates.copy() self.CS.out = ret.as_reader() return self.CS.out def apply(self, c): can_sends = self.CC.update(c.enabled, self.CS, self.frame, self.ext_bus, c.actuators, c.hudControl.visualAlert, c.hudControl.leftLaneVisible, c.hudControl.rightLaneVisible, c.hudControl.leftLaneDepart, c.hudControl.rightLaneDepart, self.dragonconf) self.frame += 1 return can_sends ================================================ FILE: selfdrive/car/volkswagen/radar_interface.py ================================================ #!/usr/bin/env python3 from selfdrive.car.interfaces import RadarInterfaceBase class RadarInterface(RadarInterfaceBase): pass ================================================ FILE: selfdrive/car/volkswagen/values.py ================================================ # flake8: noqa from collections import defaultdict from typing import Dict from cereal import car from selfdrive.car import dbc_dict Ecu = car.CarParams.Ecu NetworkLocation = car.CarParams.NetworkLocation TransmissionType = car.CarParams.TransmissionType GearShifter = car.CarState.GearShifter class CarControllerParams: HCA_STEP = 2 # HCA_01 message frequency 50Hz LDW_STEP = 10 # LDW_02 message frequency 10Hz GRA_ACC_STEP = 3 # GRA_ACC_01 message frequency 33Hz GRA_VBP_STEP = 100 # Send ACC virtual button presses once a second GRA_VBP_COUNT = 16 # Send VBP messages for ~0.5s (GRA_ACC_STEP * 16) # Observed documented MQB limits: 3.00 Nm max, rate of change 5.00 Nm/sec. # Limiting rate-of-change based on real-world testing and Comma's safety # requirements for minimum time to lane departure. STEER_MAX = 300 # Max heading control assist torque 3.00 Nm STEER_DELTA_UP = 4 # Max HCA reached in 1.50s (STEER_MAX / (50Hz * 1.50)) STEER_DELTA_DOWN = 10 # Min HCA reached in 0.60s (STEER_MAX / (50Hz * 0.60)) STEER_DRIVER_ALLOWANCE = 80 STEER_DRIVER_MULTIPLIER = 3 # weight driver torque heavily STEER_DRIVER_FACTOR = 1 # from dbc class CANBUS: pt = 0 cam = 2 class DBC_FILES: mqb = "vw_mqb_2010" # Used for all cars with MQB-style CAN messaging DBC = defaultdict(lambda: dbc_dict(DBC_FILES.mqb, None)) # type: Dict[str, Dict[str, str]] BUTTON_STATES = { "accelCruise": False, "decelCruise": False, "cancel": False, "setCruise": False, "resumeCruise": False, "gapAdjustCruise": False } MQB_LDW_MESSAGES = { "none": 0, # Nothing to display "laneAssistUnavailChime": 1, # "Lane Assist currently not available." with chime "laneAssistUnavailNoSensorChime": 3, # "Lane Assist not available. No sensor view." with chime "laneAssistTakeOverUrgent": 4, # "Lane Assist: Please Take Over Steering" with urgent beep "emergencyAssistUrgent": 6, # "Emergency Assist: Please Take Over Steering" with urgent beep "laneAssistTakeOverChime": 7, # "Lane Assist: Please Take Over Steering" with chime "laneAssistTakeOverSilent": 8, # "Lane Assist: Please Take Over Steering" silent "emergencyAssistChangingLanes": 9, # "Emergency Assist: Changing lanes..." with urgent beep "laneAssistDeactivated": 10, # "Lane Assist deactivated." silent with persistent icon afterward } # Check the 7th and 8th characters of the VIN before adding a new CAR. If the # chassis code is already listed below, don't add a new CAR, just add to the # FW_VERSIONS for that existing CAR. # Exception: SEAT Leon and SEAT Ateca share a chassis code class CAR: ATLAS_MK1 = "VOLKSWAGEN ATLAS 1ST GEN" # Chassis CA, Mk1 VW Atlas and Atlas Cross Sport GOLF_MK7 = "VOLKSWAGEN GOLF 7TH GEN" # Chassis 5G/AU/BA/BE, Mk7 VW Golf and variants JETTA_MK7 = "VOLKSWAGEN JETTA 7TH GEN" # Chassis BU, Mk7 Jetta PASSAT_MK8 = "VOLKSWAGEN PASSAT 8TH GEN" # Chassis 3G, Mk8 Passat and variants TCROSS_MK1 = "VOLKSWAGEN T-CROSS 1ST GEN" # Chassis C1, Mk1 VW T-Cross SWB and LWB variants TIGUAN_MK2 = "VOLKSWAGEN TIGUAN 2ND GEN" # Chassis AD/BW, Mk2 VW Tiguan and variants TOURAN_MK2 = "VOLKSWAGEN TOURAN 2ND GEN" # Chassis 1T, Mk2 VW Touran and variants AUDI_A3_MK3 = "AUDI A3 3RD GEN" # Chassis 8V/FF, Mk3 Audi A3 and variants AUDI_Q2_MK1 = "AUDI Q2 1ST GEN" # Chassis GA, Mk1 Audi Q2 (RoW) and Q2L (China only) SEAT_ATECA_MK1 = "SEAT ATECA 1ST GEN" # Chassis 5F, Mk1 SEAT Ateca and CUPRA Ateca SEAT_LEON_MK3 = "SEAT LEON 3RD GEN" # Chassis 5F, Mk3 SEAT Leon and variants SKODA_KODIAQ_MK1 = "SKODA KODIAQ 1ST GEN" # Chassis NS, Mk1 Skoda Kodiaq SKODA_SCALA_MK1 = "SKODA SCALA 1ST GEN" # Chassis NW, Mk1 Skoda Scala and Skoda Kamiq SKODA_SUPERB_MK3 = "SKODA SUPERB 3RD GEN" # Chassis 3V/NP, Mk3 Skoda Superb and variants SKODA_OCTAVIA_MK3 = "SKODA OCTAVIA 3RD GEN" # Chassis NE, Mk3 Skoda Octavia and variants # All supported cars should return FW from the engine, srs, eps, and fwdRadar. Cars # with a manual trans won't return transmission firmware, but all other cars will. # # The 0xF187 SW part number query should return in the form of N[NX][NX] NNN NNN [X[X]], # where N=number, X=letter, and the trailing two letters are optional. Performance # tuners sometimes tamper with that field (e.g. 8V0 9C0 BB0 1 from COBB/EQT). Tampered # ECU SW part numbers are invalid for vehicle ID and compatibility checks. Try to have # them repaired by the tuner before including them in openpilot. FW_VERSIONS = { CAR.ATLAS_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8703H906026AA\xf1\x899970', b'\xf1\x8703H906026F \xf1\x896696', b'\xf1\x8703H906026F \xf1\x899970', b'\xf1\x8703H906026S \xf1\x896693', b'\xf1\x8703H906026S \xf1\x899970', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x8709G927158A \xf1\x893387', b'\xf1\x8709G927158DR\xf1\x893536', ], (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655BC\xf1\x890503\xf1\x82\0161914151912001103111122031200', b'\xf1\x873Q0959655BN\xf1\x890713\xf1\x82\0162214152212001105141122052900', b'\xf1\x873Q0959655DB\xf1\x890720\xf1\x82\0162214152212001105141122052900', ], (Ecu.eps, 0x712, None): [ b'\xf1\x873QF909144B \xf1\x891582\xf1\x82\00571B60924A1', b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820528B6090105', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x875Q0907572H \xf1\x890620', b'\xf1\x875Q0907572J \xf1\x890654', b'\xf1\x875Q0907572P \xf1\x890682', ], }, CAR.GOLF_MK7: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906016A \xf1\x897697', b'\xf1\x8704E906016AD\xf1\x895758', b'\xf1\x8704E906023AG\xf1\x891726', b'\xf1\x8704E906023BN\xf1\x894518', b'\xf1\x8704E906024K \xf1\x896811', b'\xf1\x8704E906027GR\xf1\x892394', b'\xf1\x8704E906027HD\xf1\x893742', b'\xf1\x8704E906027MA\xf1\x894958', b'\xf1\x8704L906026BP\xf1\x897608', b'\xf1\x8704L906026NF\xf1\x899528', b'\xf1\x8704L906056CL\xf1\x893823', b'\xf1\x8704L906056CR\xf1\x895813', b'\xf1\x8704L906056HE\xf1\x893758', b'\xf1\x870EA906016A \xf1\x898343', b'\xf1\x870EA906016F \xf1\x895002', b'\xf1\x870EA906016S \xf1\x897207', b'\xf1\x875G0906259 \xf1\x890007', b'\xf1\x875G0906259J \xf1\x890002', b'\xf1\x875G0906259L \xf1\x890002', b'\xf1\x875G0906259N \xf1\x890003', b'\xf1\x875G0906259Q \xf1\x890002', b'\xf1\x875G0906259Q \xf1\x892313', b'\xf1\x878V0906259H \xf1\x890002', b'\xf1\x878V0906259J \xf1\x890003', b'\xf1\x878V0906259K \xf1\x890001', b'\xf1\x878V0906259P \xf1\x890001', b'\xf1\x878V0906259Q \xf1\x890002', b'\xf1\x878V0906264F \xf1\x890003', b'\xf1\x878V0906264L \xf1\x890002', b'\xf1\x878V0906264M \xf1\x890001', b'\xf1\x878V09C0BB01 \xf1\x890001', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x8709G927749AP\xf1\x892943', b'\xf1\x8709S927158A \xf1\x893585', b'\xf1\x870CW300041H \xf1\x891010', b'\xf1\x870CW300042F \xf1\x891604', b'\xf1\x870CW300043B \xf1\x891601', b'\xf1\x870CW300045 \xf1\x894531', b'\xf1\x870CW300047D \xf1\x895261', b'\xf1\x870CW300048J \xf1\x890611', b'\xf1\x870D9300012 \xf1\x894904', b'\xf1\x870D9300012 \xf1\x894913', b'\xf1\x870D9300012 \xf1\x894937', b'\xf1\x870D9300012 \xf1\x895045', b'\xf1\x870D9300014M \xf1\x895004', b'\xf1\x870D9300020S \xf1\x895201', b'\xf1\x870D9300040S \xf1\x894311', b'\xf1\x870D9300041H \xf1\x895220', b'\xf1\x870DD300045K \xf1\x891120', b'\xf1\x870DD300046F \xf1\x891601', b'\xf1\x870GC300012A \xf1\x891403', b'\xf1\x870GC300014B \xf1\x892401', b'\xf1\x870GC300014B \xf1\x892405', b'\xf1\x870GC300020G \xf1\x892401', b'\xf1\x870GC300020G \xf1\x892403', b'\xf1\x870GC300020G \xf1\x892404', b'\xf1\x870GC300043T \xf1\x899999', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655AA\xf1\x890386\xf1\x82\0211413001113120043114317121C111C9113', b'\xf1\x875Q0959655AA\xf1\x890386\xf1\x82\0211413001113120053114317121C111C9113', b'\xf1\x875Q0959655AA\xf1\x890388\xf1\x82\0211413001113120043114317121C111C9113', b'\xf1\x875Q0959655AA\xf1\x890388\xf1\x82\0211413001113120043114417121411149113', b'\xf1\x875Q0959655AA\xf1\x890388\xf1\x82\0211413001113120053114317121C111C9113', b'\xf1\x875Q0959655BH\xf1\x890336\xf1\x82\02314160011123300314211012230229333463100', b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\023141600111233003142404A2252229333463100', b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\023141600111233003142405A2252229333463100', b'\xf1\x875Q0959655D \xf1\x890388\xf1\x82\0211413001113120006110417121A101A9113', b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023271112111312--071104171825102591131211', b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023271212111312--071104171838103891131211', b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023341512112212--071104172328102891131211', b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\x13272512111312--07110417182C102C91131211', b'\xf1\x875Q0959655M \xf1\x890361\xf1\x82\0211413001112120041114115121611169112', b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02315120011211200621143171717111791132111', b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02324230011211200061104171724102491132111', b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02324230011211200621143171724112491132111', b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\x1315120011211200061104171717101791132111', b'\xf1\x875Q0959655T \xf1\x890825\xf1\x82\023271200111312--071104171837103791132111', b'\xf1\x875Q0959655T \xf1\x890830\xf1\x82\x13271100111312--071104171826102691131211', b'\xf1\x875QD959655 \xf1\x890388\xf1\x82\x111413001113120006110417121D101D9112', ], (Ecu.eps, 0x712, None): [ b'\xf1\x873Q0909144F \xf1\x895043\xf1\x82\00561A01612A0', b'\xf1\x873Q0909144H \xf1\x895061\xf1\x82\00566A0J612A1', b'\xf1\x873Q0909144J \xf1\x895063\xf1\x82\00566A00514A1', b'\xf1\x873Q0909144J \xf1\x895063\xf1\x82\00566A0J712A1', b'\xf1\x873Q0909144K \xf1\x895072\xf1\x82\00571A0J714A1', b'\xf1\x873Q0909144L \xf1\x895081\xf1\x82\x0571A0JA15A1', b'\xf1\x873Q0909144M \xf1\x895082\xf1\x82\00571A01A18A1', b'\xf1\x873Q0909144M \xf1\x895082\xf1\x82\00571A0JA16A1', b'\xf1\x875Q0909143K \xf1\x892033\xf1\x820519A9040203', b'\xf1\x875Q0909144AA\xf1\x891081\xf1\x82\00521A00441A1', b'\xf1\x875Q0909144AA\xf1\x891081\xf1\x82\x0521A00641A1', b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521A00442A1', b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521A00642A1', b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521A07B05A1', b'\xf1\x875Q0909144L \xf1\x891021\xf1\x82\00522A00402A0', b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00511A00403A0', b'\xf1\x875Q0909144R \xf1\x891061\xf1\x82\00516A00604A1', b'\xf1\x875Q0909144S \xf1\x891063\xf1\x82\00516A00604A1', b'\xf1\x875Q0909144S \xf1\x891063\xf1\x82\00516A07A02A1', b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521A00507A1', b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521A20B03A1', b'\xf1\x875QD909144B \xf1\x891072\xf1\x82\x0521A00507A1', b'\xf1\x875QM909144A \xf1\x891072\xf1\x82\x0521A20B03A1', b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\00521A00442A1', b'\xf1\x875QN909144A \xf1\x895081\xf1\x82\00571A01A16A1', b'\xf1\x875QN909144A \xf1\x895081\xf1\x82\00571A01A18A1', b'\xf1\x875QN909144A \xf1\x895081\xf1\x82\x0571A01A17A1', b'\xf1\x875QN909144B \xf1\x895082\xf1\x82\00571A01A18A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x875Q0907572A \xf1\x890141\xf1\x82\00101', b'\xf1\x875Q0907572B \xf1\x890200\xf1\x82\00101', b'\xf1\x875Q0907572C \xf1\x890210\xf1\x82\00101', b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\00101', b'\xf1\x875Q0907572F \xf1\x890400\xf1\x82\00101', b'\xf1\x875Q0907572G \xf1\x890571', b'\xf1\x875Q0907572H \xf1\x890620', b'\xf1\x875Q0907572J \xf1\x890654', b'\xf1\x875Q0907572P \xf1\x890682', b'\xf1\x875Q0907572R \xf1\x890771', ], }, CAR.JETTA_MK7: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906024AK\xf1\x899937', b'\xf1\x8704E906024AS\xf1\x899912', b'\xf1\x8704E906024B \xf1\x895594', b'\xf1\x8704E906024L \xf1\x895595', b'\xf1\x8704E906027MS\xf1\x896223', b'\xf1\x875G0906259T \xf1\x890003', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x8709G927158BQ\xf1\x893545', b'\xf1\x8709S927158BS\xf1\x893642', b'\xf1\x8709S927158R \xf1\x893552', b'\xf1\x8709S927158R \xf1\x893587', b'\xf1\x870GC300020N \xf1\x892803', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655AG\xf1\x890336\xf1\x82\02314171231313500314611011630169333463100', b'\xf1\x875Q0959655BM\xf1\x890403\xf1\x82\02314171231313500314642011650169333463100', b'\xf1\x875Q0959655BM\xf1\x890403\xf1\x82\02314171231313500314643011650169333463100', b'\xf1\x875Q0959655BR\xf1\x890403\xf1\x82\02311170031313300314240011150119333433100', b'\xf1\x875Q0959655BR\xf1\x890403\xf1\x82\02319170031313300314240011550159333463100', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\00521A10A01A1', b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\x0521B00404A1', b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\00521A00642A1', b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\00521A10A01A1', b'\xf1\x875QN909144B \xf1\x895082\xf1\x82\00571A10A11A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x875Q0907572N \xf1\x890681', b'\xf1\x875Q0907572R \xf1\x890771', ], }, CAR.PASSAT_MK8: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906023AH\xf1\x893379', b'\xf1\x8704L906026GA\xf1\x892013', b'\xf1\x873G0906264 \xf1\x890004', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300048R \xf1\x890610', b'\xf1\x870D9300014L \xf1\x895002', b'\xf1\x870DD300045T \xf1\x891601', ], (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655AN\xf1\x890306\xf1\x82\r58160058140013036914110311', b'\xf1\x873Q0959655BB\xf1\x890195\xf1\x82\r56140056130012026612120211', b'\xf1\x875Q0959655S \xf1\x890870\xf1\x82\02315120011111200631145171716121691132111', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820522B0080803', b'\xf1\x875Q0909144S \xf1\x891063\xf1\x82\00516B00501A1', b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521B00703A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x873Q0907572B \xf1\x890192', b'\xf1\x873Q0907572C \xf1\x890195', b'\xf1\x875Q0907572R \xf1\x890771', ], }, CAR.TCROSS_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704C906025AK\xf1\x897053', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300050E \xf1\x891903', ], (Ecu.srs, 0x715, None): [ b'\xf1\x872Q0959655AJ\xf1\x890250\xf1\x82\02212130411110411--04041104141311152H14', ], (Ecu.eps, 0x712, None): [ b'\xf1\x872Q1909144M \xf1\x896041', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x872Q0907572T \xf1\x890383', ], }, CAR.TIGUAN_MK2: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704L906026EJ\xf1\x893661', b'\xf1\x8704L906027G \xf1\x899893', b'\xf1\x875N0906259 \xf1\x890002', b'\xf1\x8783A907115B \xf1\x890005', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x8709G927158DT\xf1\x893698', b'\xf1\x870DL300011N \xf1\x892001', b'\xf1\x870DL300011N \xf1\x892012', b'\xf1\x870DL300013A \xf1\x893005', b'\xf1\x870DL300013G \xf1\x892120', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655AR\xf1\x890317\xf1\x82\02331310031333334313132573732379333313100', b'\xf1\x875Q0959655BM\xf1\x890403\xf1\x82\02316143231313500314641011750179333423100', b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\02312110031333300314240583752379333423100', b'\xf1\x875Q0959655BT\xf1\x890403\xf1\x82\02331310031333336313140013950399333423100', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820529A6060603', b'\xf1\x875QF909144B \xf1\x895582\xf1\x82\00571A60634A1', b'\xf1\x875QM909144B \xf1\x891081\xf1\x82\x0521A60604A1', b'\xf1\x875QM909144C \xf1\x891082\xf1\x82\00521A60804A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x872Q0907572J \xf1\x890156', b'\xf1\x872Q0907572Q \xf1\x890342', b'\xf1\x872Q0907572R \xf1\x890372', ], }, CAR.TOURAN_MK2: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704L906026HM\xf1\x893017', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300041E \xf1\x891005', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655AS\xf1\x890318\xf1\x82\023363500213533353141324C4732479333313100', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820531B0062105', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x873Q0907572C \xf1\x890195', ], }, CAR.AUDI_A3_MK3: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906023AN\xf1\x893695', b'\xf1\x8704E906023AR\xf1\x893440', b'\xf1\x8704E906023BL\xf1\x895190', b'\xf1\x8704E906027CJ\xf1\x897798', b'\xf1\x8704L997022N \xf1\x899459', b'\xf1\x875G0906259L \xf1\x890002', b'\xf1\x875G0906259Q \xf1\x890002', b'\xf1\x878V0906264B \xf1\x890003', b'\xf1\x878V0907115B \xf1\x890007', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300044T \xf1\x895245', b'\xf1\x870CW300048 \xf1\x895201', b'\xf1\x870D9300013B \xf1\x894931', b'\xf1\x870D9300041N \xf1\x894512', b'\xf1\x870DD300046A \xf1\x891602', b'\xf1\x870DD300046F \xf1\x891602', b'\xf1\x870DD300046G \xf1\x891601', b'\xf1\x870GC300013M \xf1\x892402', b'\xf1\x870GC300042J \xf1\x891402', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655AM\xf1\x890315\xf1\x82\x1311111111111111311411011231129321212100', b'\xf1\x875Q0959655J \xf1\x890825\xf1\x82\023111112111111--171115141112221291163221', b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\023121111111211--261117141112231291163221', b'\xf1\x875Q0959655J \xf1\x890830\xf1\x82\x13121111111111--341117141212231291163221', b'\xf1\x875Q0959655N \xf1\x890361\xf1\x82\0211212001112110004110411111421149114', b'\xf1\x875Q0959655N \xf1\x890361\xf1\x82\0211212001112111104110411111521159114', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521G0G809A1', b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00503G00303A0', b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00503G00803A0', b'\xf1\x875Q0909144R \xf1\x891061\xf1\x82\00516G00804A1', b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521G00807A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\00101', b'\xf1\x875Q0907572G \xf1\x890571', b'\xf1\x875Q0907572H \xf1\x890620', b'\xf1\x875Q0907572P \xf1\x890682', ], }, CAR.AUDI_Q2_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906027JT\xf1\x894145', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300041F \xf1\x891006', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655BD\xf1\x890336\xf1\x82\x1311111111111100311211011231129321312111', ], (Ecu.eps, 0x712, None): [ b'\xf1\x873Q0909144K \xf1\x895072\xf1\x82\x0571F60511A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x872Q0907572M \xf1\x890233', ], }, CAR.SEAT_ATECA_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906027KA\xf1\x893749', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870D9300014S \xf1\x895202', ], (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655BH\xf1\x890703\xf1\x82\0161212001211001305121211052900', ], (Ecu.eps, 0x712, None): [ b'\xf1\x873Q0909144L \xf1\x895081\xf1\x82\00571N60511A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x872Q0907572M \xf1\x890233', ], }, CAR.SEAT_LEON_MK3: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704L906021EL\xf1\x897542', b'\xf1\x8704L906026BP\xf1\x891198', b'\xf1\x8704L906026BP\xf1\x897608', b'\xf1\x8705E906018AS\xf1\x899596', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300050J \xf1\x891908', b'\xf1\x870D9300042M \xf1\x895016', ], (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655AC\xf1\x890189\xf1\x82\r11110011110011021511110200', b'\xf1\x873Q0959655AS\xf1\x890200\xf1\x82\r12110012120012021612110200', b'\xf1\x873Q0959655CM\xf1\x890720\xf1\x82\0161312001313001305171311052900', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\00521N01342A1', b'\xf1\x875Q0909144P \xf1\x891043\xf1\x82\00511N01805A0', b'\xf1\x875Q0909144T \xf1\x891072\xf1\x82\00521N05808A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x875Q0907572B \xf1\x890200\xf1\x82\00101', b'\xf1\x875Q0907572H \xf1\x890620', b'\xf1\x875Q0907572P \xf1\x890682', ], }, CAR.SKODA_KODIAQ_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906027DD\xf1\x893123', b'\xf1\x8704L906026DE\xf1\x895418', b'\xf1\x875NA907115E \xf1\x890003', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870D9300043 \xf1\x895202', b'\xf1\x870DL300012M \xf1\x892107', b'\xf1\x870DL300012N \xf1\x892110', b'\xf1\x870DL300013G \xf1\x892119', ], (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655BJ\xf1\x890703\xf1\x82\0161213001211001205212111052100', b'\xf1\x873Q0959655CN\xf1\x890720\xf1\x82\0161213001211001205212112052100', b'\xf1\x873Q0959655CQ\xf1\x890720\xf1\x82\x0e1213111211001205212112052111', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820527T6050405', b'\xf1\x875Q0909143P \xf1\x892051\xf1\x820527T6060405', b'\xf1\x875Q0910143C \xf1\x892211\xf1\x82\x0567T600G600', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x872Q0907572Q \xf1\x890342', b'\xf1\x872Q0907572R \xf1\x890372', ], }, CAR.SKODA_OCTAVIA_MK3: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704E906016ER\xf1\x895823', b'\xf1\x8704E906027HD\xf1\x893742', b'\xf1\x8704L906021DT\xf1\x898127', b'\xf1\x8704L906026BS\xf1\x891541', b'\xf1\x875G0906259C \xf1\x890002', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300041N \xf1\x891605', b'\xf1\x870CW300043B \xf1\x891601', b'\xf1\x870D9300041C \xf1\x894936', b'\xf1\x870D9300041J \xf1\x894902', b'\xf1\x870D9300041P \xf1\x894507', ], (Ecu.srs, 0x715, None): [ b'\xf1\x873Q0959655AC\xf1\x890200\xf1\x82\r11120011100010022212110200', b'\xf1\x873Q0959655AQ\xf1\x890200\xf1\x82\r11120011100010312212113100', b'\xf1\x873Q0959655AS\xf1\x890200\xf1\x82\r11120011100010022212110200', b'\xf1\x873Q0959655BH\xf1\x890703\xf1\x82\0163221003221002105755331052100', b'\xf1\x873Q0959655CN\xf1\x890720\xf1\x82\x0e3221003221002105755331052100', ], (Ecu.eps, 0x712, None): [ b'\xf1\x873Q0909144J \xf1\x895063\xf1\x82\00566A01513A1', b'\xf1\x875Q0909144AA\xf1\x891081\xf1\x82\00521T00403A1', b'\xf1\x875Q0909144AB\xf1\x891082\xf1\x82\x0521T00403A1', b'\xf1\x875Q0909144R \xf1\x891061\xf1\x82\x0516A00604A1', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x875Q0907572D \xf1\x890304\xf1\x82\x0101', b'\xf1\x875Q0907572F \xf1\x890400\xf1\x82\00101', b'\xf1\x875Q0907572J \xf1\x890654', b'\xf1\x875Q0907572P \xf1\x890682', ], }, CAR.SKODA_SCALA_MK1: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704C906025AK\xf1\x897053', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300050 \xf1\x891709', ], (Ecu.srs, 0x715, None): [ b'\xf1\x872Q0959655AM\xf1\x890351\xf1\x82\022111104111104112104040404111111112H14', ], (Ecu.eps, 0x712, None): [ b'\xf1\x872Q1909144M \xf1\x896041', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x872Q0907572R \xf1\x890372', ], }, CAR.SKODA_SUPERB_MK3: { (Ecu.engine, 0x7e0, None): [ b'\xf1\x8704L906026FP\xf1\x891196', b'\xf1\x8704L906026KB\xf1\x894071', b'\xf1\x873G0906259B \xf1\x890002', b'\xf1\x873G0906264A \xf1\x890002', ], (Ecu.transmission, 0x7e1, None): [ b'\xf1\x870CW300042H \xf1\x891601', b'\xf1\x870D9300011T \xf1\x894801', b'\xf1\x870D9300012 \xf1\x894940', ], (Ecu.srs, 0x715, None): [ b'\xf1\x875Q0959655AE\xf1\x890130\xf1\x82\022111200111121001121118112231292221111', b'\xf1\x875Q0959655AK\xf1\x890130\xf1\x82\022111200111121001121110012211292221111', b'\xf1\x875Q0959655BH\xf1\x890336\xf1\x82\02331310031313100313131013141319331413100', ], (Ecu.eps, 0x712, None): [ b'\xf1\x875Q0909143K \xf1\x892033\xf1\x820514UZ070203', b'\xf1\x875Q0909143M \xf1\x892041\xf1\x820522UZ070303', b'\xf1\x875Q0910143B \xf1\x892201\xf1\x82\00563UZ060700', b'\xf1\x875Q0910143B \xf1\x892201\xf1\x82\x0563UZ060600', ], (Ecu.fwdRadar, 0x757, None): [ b'\xf1\x873Q0907572B \xf1\x890192', b'\xf1\x873Q0907572B \xf1\x890194', b'\xf1\x873Q0907572C \xf1\x890195', ], }, } ================================================ FILE: selfdrive/car/volkswagen/volkswagencan.py ================================================ # CAN controls for MQB platform Volkswagen, Audi, Skoda and SEAT. # PQ35/PQ46/NMS, and any future MLB, to come later. def create_mqb_steering_control(packer, bus, apply_steer, idx, lkas_enabled): values = { "SET_ME_0X3": 0x3, "Assist_Torque": abs(apply_steer), "Assist_Requested": lkas_enabled, "Assist_VZ": 1 if apply_steer < 0 else 0, "HCA_Available": 1, "HCA_Standby": not lkas_enabled, "HCA_Active": lkas_enabled, "SET_ME_0XFE": 0xFE, "SET_ME_0X07": 0x07, } return packer.make_can_msg("HCA_01", bus, values, idx) def create_mqb_hud_control(packer, bus, enabled, steering_pressed, hud_alert, left_lane_visible, right_lane_visible, ldw_lane_warning_left, ldw_lane_warning_right, ldw_side_dlc_tlc, ldw_dlc, ldw_tlc, standstill, left_lane_depart, right_lane_depart): # Lane color reference: # 0 (LKAS disabled) - off # 1 (LKAS enabled, no lane detected) - dark gray # 2 (LKAS enabled, lane detected) - light gray on VW, green or white on Audi depending on year or virtual cockpit. On a color MFD on a 2015 A3 TDI it is white, virtual cockpit on a 2018 A3 e-Tron its green. # 3 (LKAS enabled, lane departure detected) - white on VW, red on Audi values = { "LDW_Status_LED_gelb": 1 if enabled and steering_pressed else 0, "LDW_Status_LED_gruen": 1 if enabled and not steering_pressed else 0, "LDW_Lernmodus_links": 3 if enabled and left_lane_visible else 1 + left_lane_visible, "LDW_Lernmodus_rechts": 3 if enabled and right_lane_visible else 1 + right_lane_visible, "LDW_Texte": hud_alert, "LDW_SW_Warnung_links": ldw_lane_warning_left, "LDW_SW_Warnung_rechts": ldw_lane_warning_right, "LDW_Seite_DLCTLC": ldw_side_dlc_tlc, "LDW_DLC": ldw_dlc, "LDW_TLC": ldw_tlc } return packer.make_can_msg("LDW_02", bus, values) def create_mqb_acc_buttons_control(packer, bus, buttonStatesToSend, CS, idx): values = { "GRA_Hauptschalter": CS.graHauptschalter, "GRA_Abbrechen": buttonStatesToSend["cancel"], "GRA_Tip_Setzen": buttonStatesToSend["setCruise"], "GRA_Tip_Hoch": buttonStatesToSend["accelCruise"], "GRA_Tip_Runter": buttonStatesToSend["decelCruise"], "GRA_Tip_Wiederaufnahme": buttonStatesToSend["resumeCruise"], "GRA_Verstellung_Zeitluecke": 3 if buttonStatesToSend["gapAdjustCruise"] else 0, "GRA_Typ_Hauptschalter": CS.graTypHauptschalter, "GRA_Codierung": 2, "GRA_Tip_Stufe_2": CS.graTipStufe2, "GRA_ButtonTypeInfo": CS.graButtonTypeInfo } return packer.make_can_msg("GRA_ACC_01", bus, values, idx) ================================================ FILE: selfdrive/common/SConscript ================================================ Import('env', 'arch', 'SHARED') if SHARED: fxn = env.SharedLibrary else: fxn = env.Library common_libs = [ 'params.cc', 'swaglog.cc', 'util.cc', 'gpio.cc', 'i2c.cc', 'watchdog.cc', ] _common = fxn('common', common_libs, LIBS="json11") files = [ 'clutil.cc', 'glutil.cc', 'visionimg.cc', ] if arch == "aarch64": files += [ 'framebuffer.cc', 'touch.c', ] _gpu_libs = ['gui', 'adreno_utils'] elif arch == "larch64" or arch == "jarch64": _gpu_libs = ["GLESv2"] else: _gpu_libs = ["GL"] _gpucommon = fxn('gpucommon', files, LIBS=_gpu_libs) Export('_common', '_gpucommon', '_gpu_libs') if GetOption('test'): env.Program('tests/test_util', ['tests/test_util.cc'], LIBS=[_common]) ================================================ FILE: selfdrive/common/clutil.cc ================================================ #include "selfdrive/common/clutil.h" #include #include #include #include #include #include #include "selfdrive/common/util.h" namespace { // helper functions template std::string get_info(Func get_info_func, Id id, Name param_name) { size_t size = 0; CL_CHECK(get_info_func(id, param_name, 0, NULL, &size)); std::string info(size, '\0'); CL_CHECK(get_info_func(id, param_name, size, info.data(), NULL)); return info; } inline std::string get_platform_info(cl_platform_id id, cl_platform_info name) { return get_info(&clGetPlatformInfo, id, name); } inline std::string get_device_info(cl_device_id id, cl_device_info name) { return get_info(&clGetDeviceInfo, id, name); } void cl_print_info(cl_platform_id platform, cl_device_id device) { size_t work_group_size = 0; cl_device_type device_type = 0; clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(work_group_size), &work_group_size, NULL); clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(device_type), &device_type, NULL); const char *type_str = "Other..."; switch (device_type) { case CL_DEVICE_TYPE_CPU: type_str ="CL_DEVICE_TYPE_CPU"; break; case CL_DEVICE_TYPE_GPU: type_str = "CL_DEVICE_TYPE_GPU"; break; case CL_DEVICE_TYPE_ACCELERATOR: type_str = "CL_DEVICE_TYPE_ACCELERATOR"; break; } std::cout << "vendor: " << get_platform_info(platform, CL_PLATFORM_VENDOR) << std::endl << "platform version: " << get_platform_info(platform, CL_PLATFORM_VERSION) << std::endl << "profile: " << get_platform_info(platform, CL_PLATFORM_PROFILE) << std::endl << "extensions: " << get_platform_info(platform, CL_PLATFORM_EXTENSIONS) << std::endl << "name :" << get_device_info(device, CL_DEVICE_NAME) << std::endl << "device version :" << get_device_info(device, CL_DEVICE_VERSION) << std::endl << "max work group size :" << work_group_size << std::endl << "type = " << device_type << " = " << type_str << std::endl; } void cl_print_build_errors(cl_program program, cl_device_id device) { cl_build_status status; clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(status), &status, NULL); size_t log_size; clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); std::string log(log_size, '\0'); clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size, &log[0], NULL); std::cout << "build failed; status=" << status << ", log:" << std::endl << log << std::endl; } } // namespace cl_device_id cl_get_device_id(cl_device_type device_type) { cl_uint num_platforms = 0; CL_CHECK(clGetPlatformIDs(0, NULL, &num_platforms)); std::unique_ptr platform_ids = std::make_unique(num_platforms); CL_CHECK(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL)); for (size_t i = 0; i < num_platforms; ++i) { std::cout << "platform[" << i << "] CL_PLATFORM_NAME: " << get_platform_info(platform_ids[i], CL_PLATFORM_NAME) << std::endl; // Get first device if (cl_device_id device_id = NULL; clGetDeviceIDs(platform_ids[i], device_type, 1, &device_id, NULL) == 0 && device_id) { cl_print_info(platform_ids[i], device_id); return device_id; } } std::cout << "No valid openCL platform found" << std::endl; assert(0); return nullptr; } cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args) { std::string src = util::read_file(path); assert(src.length() > 0); cl_program prg = CL_CHECK_ERR(clCreateProgramWithSource(ctx, 1, (const char*[]){src.c_str()}, NULL, &err)); if (int err = clBuildProgram(prg, 1, &device_id, args, NULL, NULL); err != 0) { cl_print_build_errors(prg, device_id); assert(0); } return prg; } // Given a cl code and return a string representation #define CL_ERR_TO_STR(err) case err: return #err const char* cl_get_error_string(int err) { switch (err) { CL_ERR_TO_STR(CL_SUCCESS); CL_ERR_TO_STR(CL_DEVICE_NOT_FOUND); CL_ERR_TO_STR(CL_DEVICE_NOT_AVAILABLE); CL_ERR_TO_STR(CL_COMPILER_NOT_AVAILABLE); CL_ERR_TO_STR(CL_MEM_OBJECT_ALLOCATION_FAILURE); CL_ERR_TO_STR(CL_OUT_OF_RESOURCES); CL_ERR_TO_STR(CL_OUT_OF_HOST_MEMORY); CL_ERR_TO_STR(CL_PROFILING_INFO_NOT_AVAILABLE); CL_ERR_TO_STR(CL_MEM_COPY_OVERLAP); CL_ERR_TO_STR(CL_IMAGE_FORMAT_MISMATCH); CL_ERR_TO_STR(CL_IMAGE_FORMAT_NOT_SUPPORTED); CL_ERR_TO_STR(CL_MAP_FAILURE); CL_ERR_TO_STR(CL_MISALIGNED_SUB_BUFFER_OFFSET); CL_ERR_TO_STR(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST); CL_ERR_TO_STR(CL_COMPILE_PROGRAM_FAILURE); CL_ERR_TO_STR(CL_LINKER_NOT_AVAILABLE); CL_ERR_TO_STR(CL_LINK_PROGRAM_FAILURE); CL_ERR_TO_STR(CL_DEVICE_PARTITION_FAILED); CL_ERR_TO_STR(CL_KERNEL_ARG_INFO_NOT_AVAILABLE); CL_ERR_TO_STR(CL_INVALID_VALUE); CL_ERR_TO_STR(CL_INVALID_DEVICE_TYPE); CL_ERR_TO_STR(CL_INVALID_PLATFORM); CL_ERR_TO_STR(CL_INVALID_DEVICE); CL_ERR_TO_STR(CL_INVALID_CONTEXT); CL_ERR_TO_STR(CL_INVALID_QUEUE_PROPERTIES); CL_ERR_TO_STR(CL_INVALID_COMMAND_QUEUE); CL_ERR_TO_STR(CL_INVALID_HOST_PTR); CL_ERR_TO_STR(CL_INVALID_MEM_OBJECT); CL_ERR_TO_STR(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR); CL_ERR_TO_STR(CL_INVALID_IMAGE_SIZE); CL_ERR_TO_STR(CL_INVALID_SAMPLER); CL_ERR_TO_STR(CL_INVALID_BINARY); CL_ERR_TO_STR(CL_INVALID_BUILD_OPTIONS); CL_ERR_TO_STR(CL_INVALID_PROGRAM); CL_ERR_TO_STR(CL_INVALID_PROGRAM_EXECUTABLE); CL_ERR_TO_STR(CL_INVALID_KERNEL_NAME); CL_ERR_TO_STR(CL_INVALID_KERNEL_DEFINITION); CL_ERR_TO_STR(CL_INVALID_KERNEL); CL_ERR_TO_STR(CL_INVALID_ARG_INDEX); CL_ERR_TO_STR(CL_INVALID_ARG_VALUE); CL_ERR_TO_STR(CL_INVALID_ARG_SIZE); CL_ERR_TO_STR(CL_INVALID_KERNEL_ARGS); CL_ERR_TO_STR(CL_INVALID_WORK_DIMENSION); CL_ERR_TO_STR(CL_INVALID_WORK_GROUP_SIZE); CL_ERR_TO_STR(CL_INVALID_WORK_ITEM_SIZE); CL_ERR_TO_STR(CL_INVALID_GLOBAL_OFFSET); CL_ERR_TO_STR(CL_INVALID_EVENT_WAIT_LIST); CL_ERR_TO_STR(CL_INVALID_EVENT); CL_ERR_TO_STR(CL_INVALID_OPERATION); CL_ERR_TO_STR(CL_INVALID_GL_OBJECT); CL_ERR_TO_STR(CL_INVALID_BUFFER_SIZE); CL_ERR_TO_STR(CL_INVALID_MIP_LEVEL); CL_ERR_TO_STR(CL_INVALID_GLOBAL_WORK_SIZE); CL_ERR_TO_STR(CL_INVALID_PROPERTY); CL_ERR_TO_STR(CL_INVALID_IMAGE_DESCRIPTOR); CL_ERR_TO_STR(CL_INVALID_COMPILER_OPTIONS); CL_ERR_TO_STR(CL_INVALID_LINKER_OPTIONS); CL_ERR_TO_STR(CL_INVALID_DEVICE_PARTITION_COUNT); case -69: return "CL_INVALID_PIPE_SIZE"; case -70: return "CL_INVALID_DEVICE_QUEUE"; case -71: return "CL_INVALID_SPEC_ID"; case -72: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED"; case -1002: return "CL_INVALID_D3D10_DEVICE_KHR"; case -1003: return "CL_INVALID_D3D10_RESOURCE_KHR"; case -1004: return "CL_D3D10_RESOURCE_ALREADY_ACQUIRED_KHR"; case -1005: return "CL_D3D10_RESOURCE_NOT_ACQUIRED_KHR"; case -1006: return "CL_INVALID_D3D11_DEVICE_KHR"; case -1007: return "CL_INVALID_D3D11_RESOURCE_KHR"; case -1008: return "CL_D3D11_RESOURCE_ALREADY_ACQUIRED_KHR"; case -1009: return "CL_D3D11_RESOURCE_NOT_ACQUIRED_KHR"; case -1010: return "CL_INVALID_DX9_MEDIA_ADAPTER_KHR"; case -1011: return "CL_INVALID_DX9_MEDIA_SURFACE_KHR"; case -1012: return "CL_DX9_MEDIA_SURFACE_ALREADY_ACQUIRED_KHR"; case -1013: return "CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR"; case -1093: return "CL_INVALID_EGL_OBJECT_KHR"; case -1092: return "CL_EGL_RESOURCE_NOT_ACQUIRED_KHR"; case -1001: return "CL_PLATFORM_NOT_FOUND_KHR"; case -1057: return "CL_DEVICE_PARTITION_FAILED_EXT"; case -1058: return "CL_INVALID_PARTITION_COUNT_EXT"; case -1059: return "CL_INVALID_PARTITION_NAME_EXT"; case -1094: return "CL_INVALID_ACCELERATOR_INTEL"; case -1095: return "CL_INVALID_ACCELERATOR_TYPE_INTEL"; case -1096: return "CL_INVALID_ACCELERATOR_DESCRIPTOR_INTEL"; case -1097: return "CL_ACCELERATOR_TYPE_NOT_SUPPORTED_INTEL"; case -1000: return "CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR"; case -1098: return "CL_INVALID_VA_API_MEDIA_ADAPTER_INTEL"; case -1099: return "CL_INVALID_VA_API_MEDIA_SURFACE_INTEL"; case -1100: return "CL_VA_API_MEDIA_SURFACE_ALREADY_ACQUIRED_INTEL"; case -1101: return "CL_VA_API_MEDIA_SURFACE_NOT_ACQUIRED_INTEL"; default: return "CL_UNKNOWN_ERROR"; } } ================================================ FILE: selfdrive/common/clutil.h ================================================ #pragma once #include #include #ifdef __APPLE__ #include #else #include #endif #define CL_CHECK(_expr) \ do { \ assert(CL_SUCCESS == (_expr)); \ } while (0) #define CL_CHECK_ERR(_expr) \ ({ \ cl_int err = CL_INVALID_VALUE; \ __typeof__(_expr) _ret = _expr; \ assert(_ret&& err == CL_SUCCESS); \ _ret; \ }) cl_device_id cl_get_device_id(cl_device_type device_type); cl_program cl_program_from_file(cl_context ctx, cl_device_id device_id, const char* path, const char* args); const char* cl_get_error_string(int err); ================================================ FILE: selfdrive/common/framebuffer.cc ================================================ #include "selfdrive/common/framebuffer.h" #include #include #include "selfdrive/common/util.h" #include #include #include #include #include #include #define BACKLIGHT_LEVEL 205 using namespace android; struct FramebufferState { sp session; sp dtoken; DisplayInfo dinfo; sp control; sp s; EGLDisplay display; EGLint egl_major, egl_minor; EGLConfig config; EGLSurface surface; EGLContext context; }; void FrameBuffer::swap() { eglSwapBuffers(s->display, s->surface); assert(glGetError() == GL_NO_ERROR); } bool set_brightness(int brightness) { char bright[64]; snprintf(bright, sizeof(bright), "%d", brightness); return 0 == util::write_file("/sys/class/leds/lcd-backlight/brightness", bright, strlen(bright)); } void FrameBuffer::set_power(int mode) { SurfaceComposerClient::setDisplayPowerMode(s->dtoken, mode); } FrameBuffer::FrameBuffer(const char *name, uint32_t layer, int alpha, int *out_w, int *out_h) { s = new FramebufferState; s->session = new SurfaceComposerClient(); assert(s->session != NULL); s->dtoken = SurfaceComposerClient::getBuiltInDisplay( ISurfaceComposer::eDisplayIdMain); assert(s->dtoken != NULL); status_t status = SurfaceComposerClient::getDisplayInfo(s->dtoken, &s->dinfo); assert(status == 0); //int orientation = 3; // rotate framebuffer 270 degrees int orientation = 1; // rotate framebuffer 90 degrees if(orientation == 1 || orientation == 3) { int temp = s->dinfo.h; s->dinfo.h = s->dinfo.w; s->dinfo.w = temp; } printf("dinfo %dx%d\n", s->dinfo.w, s->dinfo.h); Rect destRect(s->dinfo.w, s->dinfo.h); s->session->setDisplayProjection(s->dtoken, orientation, destRect, destRect); s->control = s->session->createSurface(String8(name), s->dinfo.w, s->dinfo.h, PIXEL_FORMAT_RGBX_8888); assert(s->control != NULL); SurfaceComposerClient::openGlobalTransaction(); status = s->control->setLayer(layer); SurfaceComposerClient::closeGlobalTransaction(); assert(status == 0); s->s = s->control->getSurface(); assert(s->s != NULL); // init opengl and egl const EGLint attribs[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, alpha ? 8 : 0, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR, // enable MSAA EGL_SAMPLE_BUFFERS, 1, EGL_SAMPLES, 4, EGL_NONE, }; s->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(s->display != EGL_NO_DISPLAY); int success = eglInitialize(s->display, &s->egl_major, &s->egl_minor); assert(success); printf("egl version %d.%d\n", s->egl_major, s->egl_minor); EGLint num_configs; success = eglChooseConfig(s->display, attribs, &s->config, 1, &num_configs); assert(success); s->surface = eglCreateWindowSurface(s->display, s->config, s->s.get(), NULL); assert(s->surface != EGL_NO_SURFACE); const EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, }; s->context = eglCreateContext(s->display, s->config, NULL, context_attribs); assert(s->context != EGL_NO_CONTEXT); EGLint w, h; eglQuerySurface(s->display, s->surface, EGL_WIDTH, &w); eglQuerySurface(s->display, s->surface, EGL_HEIGHT, &h); printf("egl w %d h %d\n", w, h); success = eglMakeCurrent(s->display, s->surface, s->surface, s->context); assert(success); printf("gl version %s\n", glGetString(GL_VERSION)); set_brightness(BACKLIGHT_LEVEL); if (out_w) *out_w = w; if (out_h) *out_h = h; } FrameBuffer::~FrameBuffer() { eglDestroyContext(s->display, s->context); eglDestroySurface(s->display, s->surface); eglTerminate(s->display); delete s; } ================================================ FILE: selfdrive/common/framebuffer.h ================================================ #pragma once #include #include "hardware/hwcomposer_defs.h" bool set_brightness(int brightness); struct FramebufferState; class FrameBuffer { public: FrameBuffer(const char *name, uint32_t layer, int alpha, int *out_w, int *out_h); ~FrameBuffer(); void set_power(int mode); void swap(); private: FramebufferState *s; }; ================================================ FILE: selfdrive/common/glutil.cc ================================================ #include "selfdrive/common/glutil.h" #include #include #include #include static GLuint load_shader(GLenum shaderType, const char *src) { GLint status = 0, len = 0; GLuint shader = glCreateShader(shaderType); assert(shader != 0); glShaderSource(shader, 1, &src, NULL); glCompileShader(shader); glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (!status) { glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len); if (len) { std::string msg(len, '\0'); glGetShaderInfoLog(shader, len, NULL, msg.data()); fprintf(stderr, "error compiling shader:\n%s\n", msg.c_str()); } assert(0); } return shader; } GLShader::GLShader(const char *vert_src, const char *frag_src) { GLint status = 0, len = 0; prog = glCreateProgram(); assert(prog != 0); vert = load_shader(GL_VERTEX_SHADER, vert_src); frag = load_shader(GL_FRAGMENT_SHADER, frag_src); glAttachShader(prog, vert); glAttachShader(prog, frag); glLinkProgram(prog); glGetProgramiv(prog, GL_LINK_STATUS, &status); if (!status) { glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &len); if (len) { std::string msg(len, '\0'); glGetProgramInfoLog(prog, len, NULL, msg.data()); fprintf(stderr, "error linking program:\n%s\n", msg.c_str()); } assert(0); } } GLShader::~GLShader() { glDeleteProgram(prog); glDeleteShader(frag); glDeleteShader(vert); } GLuint GLShader::getUniformLocation(const char *name) { auto it = uniform_loc_map.find(name); if (it == uniform_loc_map.end()) { it = uniform_loc_map.insert(it, {name, glGetUniformLocation(prog, name)}); } return it->second; } ================================================ FILE: selfdrive/common/glutil.h ================================================ #pragma once #include #ifdef __APPLE__ #include #else #include #endif class GLShader { public: GLShader(const char *vert_src, const char *frag_src); ~GLShader(); GLuint getUniformLocation(const char * name); GLuint prog = 0; private: GLuint vert = 0, frag = 0; std::map uniform_loc_map; }; ================================================ FILE: selfdrive/common/gpio.cc ================================================ #include "selfdrive/common/gpio.h" #include #include #include #include "selfdrive/common/util.h" // We assume that all pins have already been exported on boot, // and that we have permission to write to them. int gpio_init(int pin_nr, bool output) { char pin_dir_path[50]; int pin_dir_path_len = snprintf(pin_dir_path, sizeof(pin_dir_path), "/sys/class/gpio/gpio%d/direction", pin_nr); if(pin_dir_path_len <= 0) { return -1; } const char *value = output ? "out" : "in"; return util::write_file(pin_dir_path, (void*)value, strlen(value)); } int gpio_set(int pin_nr, bool high) { char pin_val_path[50]; int pin_val_path_len = snprintf(pin_val_path, sizeof(pin_val_path), "/sys/class/gpio/gpio%d/value", pin_nr); if(pin_val_path_len <= 0) { return -1; } return util::write_file(pin_val_path, (void*)(high ? "1" : "0"), 1); } ================================================ FILE: selfdrive/common/gpio.h ================================================ #pragma once // Pin definitions #ifdef QCOM2 #define GPIO_HUB_RST_N 30 #define GPIO_UBLOX_RST_N 32 #define GPIO_UBLOX_SAFEBOOT_N 33 #define GPIO_UBLOX_PWR_EN 34 #define GPIO_STM_RST_N 124 #define GPIO_STM_BOOT0 134 #else #define GPIO_HUB_RST_N 0 #define GPIO_UBLOX_RST_N 0 #define GPIO_UBLOX_SAFEBOOT_N 0 #define GPIO_UBLOX_PWR_EN 0 #define GPIO_STM_RST_N 0 #define GPIO_STM_BOOT0 0 #endif int gpio_init(int pin_nr, bool output); int gpio_set(int pin_nr, bool high); ================================================ FILE: selfdrive/common/i2c.cc ================================================ #include "selfdrive/common/i2c.h" #include #include #include #include #include #include #include "selfdrive/common/util.h" #include "selfdrive/common/swaglog.h" #include "selfdrive/common/util.h" #define UNUSED(x) (void)(x) #ifdef QCOM2 // TODO: decide if we want to isntall libi2c-dev everywhere extern "C" { #include #include } I2CBus::I2CBus(uint8_t bus_id) { char bus_name[20]; snprintf(bus_name, 20, "/dev/i2c-%d", bus_id); i2c_fd = HANDLE_EINTR(open(bus_name, O_RDWR)); if(i2c_fd < 0) { throw std::runtime_error("Failed to open I2C bus"); } } I2CBus::~I2CBus() { if(i2c_fd >= 0) { close(i2c_fd); } } int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len) { int ret = 0; ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address)); if(ret < 0) { goto fail; } ret = i2c_smbus_read_i2c_block_data(i2c_fd, register_address, len, buffer); if((ret < 0) || (ret != len)) { goto fail; } fail: return ret; } int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t data) { int ret = 0; ret = HANDLE_EINTR(ioctl(i2c_fd, I2C_SLAVE, device_address)); if(ret < 0) { goto fail; } ret = i2c_smbus_write_byte_data(i2c_fd, register_address, data); if(ret < 0) { goto fail; } fail: return ret; } #else I2CBus::I2CBus(uint8_t bus_id) { UNUSED(bus_id); i2c_fd = -1; } I2CBus::~I2CBus() {} int I2CBus::read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len) { UNUSED(device_address); UNUSED(register_address); UNUSED(buffer); UNUSED(len); return -1; } int I2CBus::set_register(uint8_t device_address, uint register_address, uint8_t data) { UNUSED(device_address); UNUSED(register_address); UNUSED(data); return -1; } #endif ================================================ FILE: selfdrive/common/i2c.h ================================================ #pragma once #include #include class I2CBus { private: int i2c_fd; public: I2CBus(uint8_t bus_id); ~I2CBus(); int read_register(uint8_t device_address, uint register_address, uint8_t *buffer, uint8_t len); int set_register(uint8_t device_address, uint register_address, uint8_t data); }; ================================================ FILE: selfdrive/common/mat.h ================================================ #pragma once typedef struct vec3 { float v[3]; } vec3; typedef struct vec4 { float v[4]; } vec4; typedef struct mat3 { float v[3*3]; } mat3; typedef struct mat4 { float v[4*4]; } mat4; static inline mat3 matmul3(const mat3 &a, const mat3 &b) { mat3 ret = {{0.0}}; for (int r=0; r<3; r++) { for (int c=0; c<3; c++) { float v = 0.0; for (int k=0; k<3; k++) { v += a.v[r*3+k] * b.v[k*3+c]; } ret.v[r*3+c] = v; } } return ret; } static inline vec3 matvecmul3(const mat3 &a, const vec3 &b) { vec3 ret = {{0.0}}; for (int r=0; r<3; r++) { for (int c=0; c<3; c++) { ret.v[r] += a.v[r*3+c] * b.v[c]; } } return ret; } static inline mat4 matmul(const mat4 &a, const mat4 &b) { mat4 ret = {{0.0}}; for (int r=0; r<4; r++) { for (int c=0; c<4; c++) { float v = 0.0; for (int k=0; k<4; k++) { v += a.v[r*4+k] * b.v[k*4+c]; } ret.v[r*4+c] = v; } } return ret; } static inline vec4 matvecmul(const mat4 &a, const vec4 &b) { vec4 ret = {{0.0}}; for (int r=0; r<4; r++) { for (int c=0; c<4; c++) { ret.v[r] += a.v[r*4+c] * b.v[c]; } } return ret; } // scales the input and output space of a transformation matrix // that assumes pixel-center origin. static inline mat3 transform_scale_buffer(const mat3 &in, float s) { // in_pt = ( transform(out_pt/s + 0.5) - 0.5) * s mat3 transform_out = {{ 1.0f/s, 0.0f, 0.5f, 0.0f, 1.0f/s, 0.5f, 0.0f, 0.0f, 1.0f, }}; mat3 transform_in = {{ s, 0.0f, -0.5f*s, 0.0f, s, -0.5f*s, 0.0f, 0.0f, 1.0f, }}; return matmul3(transform_in, matmul3(in, transform_out)); } ================================================ FILE: selfdrive/common/modeldata.h ================================================ #pragma once const int TRAJECTORY_SIZE = 33; const int LAT_MPC_N = 16; const int LON_MPC_N = 32; const float MIN_DRAW_DISTANCE = 10.0; const float MAX_DRAW_DISTANCE = 100.0; const double T_IDXS[TRAJECTORY_SIZE] = { 0. , 0.00976562, 0.0390625 , 0.08789062, 0.15625 , 0.24414062, 0.3515625 , 0.47851562, 0.625 , 0.79101562, 0.9765625 , 1.18164062, 1.40625 , 1.65039062, 1.9140625 , 2.19726562, 2.5 , 2.82226562, 3.1640625 , 3.52539062, 3.90625 , 4.30664062, 4.7265625 , 5.16601562, 5.625 , 6.10351562, 6.6015625 , 7.11914062, 7.65625 , 8.21289062, 8.7890625 , 9.38476562, 10.}; const double X_IDXS[TRAJECTORY_SIZE] = { 0. , 0.1875, 0.75 , 1.6875, 3. , 4.6875, 6.75 , 9.1875, 12. , 15.1875, 18.75 , 22.6875, 27. , 31.6875, 36.75 , 42.1875, 48. , 54.1875, 60.75 , 67.6875, 75. , 82.6875, 90.75 , 99.1875, 108. , 117.1875, 126.75 , 136.6875, 147. , 157.6875, 168.75 , 180.1875, 192.}; #ifdef __cplusplus #include "selfdrive/common/mat.h" #include "selfdrive/hardware/hw.h" const mat3 fcam_intrinsic_matrix = Hardware::TICI() ? (mat3){{2648.0, 0.0, 1928.0 / 2, 0.0, 2648.0, 1208.0 / 2, 0.0, 0.0, 1.0}} : (mat3){{910., 0., 1164.0 / 2, 0., 910., 874.0 / 2, 0., 0., 1.}}; // without unwarp, focal length is for center portion only const mat3 ecam_intrinsic_matrix = (mat3){{620.0, 0.0, 1928.0 / 2, 0.0, 620.0, 1208.0 / 2, 0.0, 0.0, 1.0}}; static inline mat3 get_model_yuv_transform(bool bayer = true) { float db_s = Hardware::TICI() ? 1.0 : 0.5; // debayering does a 2x downscale on EON const mat3 transform = (mat3){{ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }}; return bayer ? transform_scale_buffer(transform, db_s) : transform; } #endif ================================================ FILE: selfdrive/common/params.cc ================================================ #include "selfdrive/common/params.h" #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif // _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "selfdrive/common/swaglog.h" #include "selfdrive/common/util.h" #include "selfdrive/hardware/hw.h" namespace { volatile sig_atomic_t params_do_exit = 0; void params_sig_handler(int signal) { params_do_exit = 1; } int fsync_dir(const char* path) { int fd = HANDLE_EINTR(open(path, O_RDONLY, 0755)); if (fd < 0) { return -1; } int result = fsync(fd); int result_close = close(fd); if (result_close < 0) { result = result_close; } return result; } int mkdir_p(std::string path) { char * _path = (char *)path.c_str(); for (char *p = _path + 1; *p; p++) { if (*p == '/') { *p = '\0'; // Temporarily truncate if (mkdir(_path, 0777) != 0) { if (errno != EEXIST) return -1; } *p = '/'; } } if (mkdir(_path, 0777) != 0) { if (errno != EEXIST) return -1; } return 0; } bool create_params_path(const std::string ¶m_path, const std::string &key_path) { // Make sure params path exists if (!util::file_exists(param_path) && mkdir_p(param_path) != 0) { return false; } // See if the symlink exists, otherwise create it if (!util::file_exists(key_path)) { // 1) Create temp folder // 2) Set permissions // 3) Symlink it to temp link // 4) Move symlink to /d std::string tmp_path = param_path + "/.tmp_XXXXXX"; // this should be OK since mkdtemp just replaces characters in place char *tmp_dir = mkdtemp((char *)tmp_path.c_str()); if (tmp_dir == NULL) { return false; } std::string link_path = std::string(tmp_dir) + ".link"; if (symlink(tmp_dir, link_path.c_str()) != 0) { return false; } // don't return false if it has been created by other if (rename(link_path.c_str(), key_path.c_str()) != 0 && errno != EEXIST) { return false; } } return true; } void ensure_params_path(const std::string ¶ms_path) { if (!create_params_path(params_path, params_path + "/d")) { throw std::runtime_error(util::string_format("Failed to ensure params path, errno=%d", errno)); } } class FileLock { public: FileLock(const std::string& file_name, int op) : fn_(file_name), op_(op) {} void lock() { fd_ = HANDLE_EINTR(open(fn_.c_str(), O_CREAT, 0777)); if (fd_ < 0) { LOGE("Failed to open lock file %s, errno=%d", fn_.c_str(), errno); return; } if (HANDLE_EINTR(flock(fd_, op_)) < 0) { LOGE("Failed to lock file %s, errno=%d", fn_.c_str(), errno); } } void unlock() { close(fd_); } private: int fd_ = -1, op_; std::string fn_; }; std::unordered_map keys = { {"AccessToken", CLEAR_ON_MANAGER_START | DONT_LOG}, {"ApiCache_DriveStats", PERSISTENT}, {"ApiCache_Device", PERSISTENT}, {"ApiCache_Owner", PERSISTENT}, {"ApiCache_NavDestinations", PERSISTENT}, {"AthenadPid", PERSISTENT}, {"CalibrationParams", PERSISTENT}, {"CarBatteryCapacity", PERSISTENT}, {"CarParams", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, {"CarParamsCache", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"CarVin", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, {"CommunityFeaturesToggle", PERSISTENT}, {"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON}, {"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON}, {"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB {"EndToEndToggle", PERSISTENT}, {"CompletedTrainingVersion", PERSISTENT}, {"DisablePowerDown", PERSISTENT}, {"DisableUpdates", PERSISTENT}, {"EnableWideCamera", CLEAR_ON_MANAGER_START}, {"DoUninstall", CLEAR_ON_MANAGER_START}, {"DongleId", PERSISTENT}, {"GitDiff", PERSISTENT}, {"GitBranch", PERSISTENT}, {"GitCommit", PERSISTENT}, {"GitRemote", PERSISTENT}, {"GithubSshKeys", PERSISTENT}, {"GithubUsername", PERSISTENT}, {"GsmRoaming", PERSISTENT}, {"HardwareSerial", PERSISTENT}, {"HasAcceptedTerms", PERSISTENT}, {"IsDriverViewEnabled", CLEAR_ON_MANAGER_START}, {"IMEI", PERSISTENT}, {"IsLdwEnabled", PERSISTENT}, {"IsMetric", PERSISTENT}, {"IsOffroad", CLEAR_ON_MANAGER_START}, {"IsOnroad", PERSISTENT}, {"IsRHD", PERSISTENT}, {"IsTakingSnapshot", CLEAR_ON_MANAGER_START}, {"IsUpdateAvailable", CLEAR_ON_MANAGER_START}, {"UploadRaw", PERSISTENT}, {"LastAthenaPingTime", CLEAR_ON_MANAGER_START}, {"LastGPSPosition", PERSISTENT}, {"LastUpdateException", PERSISTENT}, {"LastUpdateTime", PERSISTENT}, {"LiveParameters", PERSISTENT}, {"MapboxToken", PERSISTENT | DONT_LOG}, {"NavDestination", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, {"NavSettingTime24h", PERSISTENT}, {"OpenpilotEnabledToggle", PERSISTENT}, {"PandaFirmware", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"PandaFirmwareHex", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"PandaDongleId", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"PandaHeartbeatLost", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, {"Passive", PERSISTENT}, {"PrimeRedirected", PERSISTENT}, {"RecordFront", PERSISTENT}, {"RecordFrontLock", PERSISTENT}, // for the internal fleet {"ReleaseNotes", PERSISTENT}, {"ShouldDoUpdate", CLEAR_ON_MANAGER_START}, {"ShowDebugUI", PERSISTENT}, {"SpeedLimitControl", PERSISTENT}, {"SpeedLimitPercOffset", PERSISTENT}, {"SubscriberInfo", PERSISTENT}, {"SshEnabled", PERSISTENT}, {"TermsVersion", PERSISTENT}, {"Timezone", PERSISTENT}, {"TrainingVersion", PERSISTENT}, {"TurnSpeedControl", PERSISTENT}, {"TurnVisionControl", PERSISTENT}, {"UpdateAvailable", CLEAR_ON_MANAGER_START}, {"UpdateFailedCount", CLEAR_ON_MANAGER_START}, {"Version", PERSISTENT}, {"VisionRadarToggle", PERSISTENT}, {"Offroad_ChargeDisabled", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"Offroad_ConnectivityNeeded", CLEAR_ON_MANAGER_START}, {"Offroad_ConnectivityNeededPrompt", CLEAR_ON_MANAGER_START}, {"Offroad_TemperatureTooHigh", CLEAR_ON_MANAGER_START}, {"Offroad_PandaFirmwareMismatch", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT}, {"Offroad_InvalidTime", CLEAR_ON_MANAGER_START}, {"Offroad_IsTakingSnapshot", CLEAR_ON_MANAGER_START}, {"Offroad_NeosUpdate", CLEAR_ON_MANAGER_START}, {"Offroad_UpdateFailed", CLEAR_ON_MANAGER_START}, {"Offroad_HardwareUnsupported", CLEAR_ON_MANAGER_START}, {"Offroad_UnofficialHardware", CLEAR_ON_MANAGER_START}, {"Offroad_NvmeMissing", CLEAR_ON_MANAGER_START}, {"ForcePowerDown", CLEAR_ON_MANAGER_START}, {"JoystickDebugMode", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, // dp {"dp_api_custom", PERSISTENT}, {"dp_api_custom_url", PERSISTENT}, {"dp_atl", PERSISTENT}, {"dp_atl_op_long", PERSISTENT}, {"dp_dashcamd", PERSISTENT}, {"dp_auto_shutdown", PERSISTENT}, {"dp_auto_shutdown_in", PERSISTENT}, {"dp_updated", PERSISTENT}, {"dp_logger", PERSISTENT}, {"dp_athenad", PERSISTENT}, {"dp_uploader", PERSISTENT}, {"dp_hotspot_on_boot", PERSISTENT}, {"dp_lateral_mode", PERSISTENT}, {"dp_signal_off_delay", PERSISTENT}, {"dp_lc_min_mph", PERSISTENT}, {"dp_lc_auto_min_mph", PERSISTENT}, {"dp_lc_auto_delay", PERSISTENT}, {"dp_lane_less_mode_ctrl", PERSISTENT}, {"dp_lane_less_mode", PERSISTENT}, {"dp_allow_gas", PERSISTENT}, {"dp_following_profile_ctrl", PERSISTENT}, {"dp_following_profile", PERSISTENT}, {"dp_accel_profile_ctrl", PERSISTENT}, {"dp_accel_profile", PERSISTENT}, {"dp_gear_check", PERSISTENT}, {"dp_speed_check", PERSISTENT}, {"dp_temp_monitor", PERSISTENT}, {"dp_ui_display_mode", PERSISTENT}, {"dp_ui_speed", PERSISTENT}, {"dp_ui_event", PERSISTENT}, {"dp_ui_max_speed", PERSISTENT}, {"dp_ui_face", PERSISTENT}, {"dp_ui_lane", PERSISTENT}, {"dp_ui_lead", PERSISTENT}, {"dp_ui_side", PERSISTENT}, {"dp_ui_top", PERSISTENT}, {"dp_ui_blinker", PERSISTENT}, {"dp_ui_brightness", PERSISTENT}, {"dp_ui_volume", PERSISTENT}, {"dp_lexus_rx_rpm_fix", PERSISTENT}, {"dp_toyota_ldw", PERSISTENT}, {"dp_toyota_sng", PERSISTENT}, {"dp_toyota_zss", PERSISTENT}, {"dp_toyota_fp_btn_link", PERSISTENT}, {"dp_toyota_ap_btn_link", PERSISTENT}, {"dp_toyota_disable_relay", PERSISTENT}, {"dp_toyota_cruise_override", PERSISTENT}, {"dp_toyota_cruise_override_vego", PERSISTENT}, {"dp_toyota_cruise_override_at", PERSISTENT}, {"dp_toyota_cruise_override_speed", PERSISTENT}, {"dp_hkg_smart_mdps", PERSISTENT}, {"dp_honda_eps_mod", PERSISTENT}, {"dp_honda_kmh_display", PERSISTENT}, {"dp_vw_panda", PERSISTENT}, {"dp_vw_timebomb_assist", PERSISTENT}, {"dp_fan_mode", PERSISTENT}, {"dp_last_modified", PERSISTENT}, {"dp_camera_offset", PERSISTENT}, {"dp_path_offset", PERSISTENT}, {"dp_locale", PERSISTENT}, {"dp_reg", PERSISTENT}, {"dp_sr_learner", PERSISTENT}, {"dp_sr_custom", PERSISTENT}, {"dp_sr_stock", PERSISTENT}, {"dp_lqr", PERSISTENT}, {"dp_reset_live_param_on_start", PERSISTENT}, {"dp_appd", PERSISTENT}, {"dp_jetson", PERSISTENT}, {"dp_car_assigned", PERSISTENT}, {"dp_car_list", PERSISTENT}, {"dp_no_batt", PERSISTENT}, {"dp_last_candidate", PERSISTENT}, {"dp_prebuilt", PERSISTENT}, {"dp_gpxd", PERSISTENT}, {"dp_mapd", PERSISTENT}, {"dp_otisserv", PERSISTENT}, {"dp_mapbox_token_pk", PERSISTENT}, {"dp_mapbox_token_sk", PERSISTENT}, {"dp_mapbox_full_screen", PERSISTENT}, {"dp_mapbox_traffic", PERSISTENT}, {"dp_mapbox_gmap_enable", PERSISTENT}, {"dp_mapbox_gmap_key", PERSISTENT}, }; } // namespace Params::Params() : params_path(Path::params()) { static std::once_flag once_flag; std::call_once(once_flag, ensure_params_path, params_path); } Params::Params(const std::string &path) : params_path(path) { ensure_params_path(params_path); } bool Params::checkKey(const std::string &key) { return keys.find(key) != keys.end(); } ParamKeyType Params::getKeyType(const std::string &key) { return static_cast(keys[key]); } int Params::put(const char* key, const char* value, size_t value_size) { // Information about safely and atomically writing a file: https://lwn.net/Articles/457667/ // 1) Create temp file // 2) Write data to temp file // 3) fsync() the temp file // 4) rename the temp file to the real name // 5) fsync() the containing directory std::string tmp_path = params_path + "/.tmp_value_XXXXXX"; int tmp_fd = mkstemp((char*)tmp_path.c_str()); if (tmp_fd < 0) return -1; int result = -1; do { // Write value to temp. ssize_t bytes_written = HANDLE_EINTR(write(tmp_fd, value, value_size)); if (bytes_written < 0 || (size_t)bytes_written != value_size) { result = -20; break; } // fsync to force persist the changes. if ((result = fsync(tmp_fd)) < 0) break; FileLock file_lock(params_path + "/.lock", LOCK_EX); std::lock_guard lk(file_lock); // Move temp into place. std::string path = params_path + "/d/" + std::string(key); if ((result = rename(tmp_path.c_str(), path.c_str())) < 0) break; // fsync parent directory path = params_path + "/d"; result = fsync_dir(path.c_str()); } while (false); close(tmp_fd); ::unlink(tmp_path.c_str()); return result; } int Params::remove(const char *key) { FileLock file_lock(params_path + "/.lock", LOCK_EX); std::lock_guard lk(file_lock); // Delete value. std::string path = params_path + "/d/" + key; int result = unlink(path.c_str()); if (result != 0) { return result; } // fsync parent directory path = params_path + "/d"; return fsync_dir(path.c_str()); } std::string Params::get(const char *key, bool block) { std::string path = params_path + "/d/" + key; if (!block) { return util::read_file(path); } else { // blocking read until successful params_do_exit = 0; void (*prev_handler_sigint)(int) = std::signal(SIGINT, params_sig_handler); void (*prev_handler_sigterm)(int) = std::signal(SIGTERM, params_sig_handler); std::string value; while (!params_do_exit) { if (value = util::read_file(path); !value.empty()) { break; } util::sleep_for(100); // 0.1 s } std::signal(SIGINT, prev_handler_sigint); std::signal(SIGTERM, prev_handler_sigterm); return value; } } std::map Params::readAll() { FileLock file_lock(params_path + "/.lock", LOCK_SH); std::lock_guard lk(file_lock); std::string key_path = params_path + "/d"; return util::read_files_in_dir(key_path); } void Params::clearAll(ParamKeyType key_type) { FileLock file_lock(params_path + "/.lock", LOCK_EX); std::lock_guard lk(file_lock); std::string path; for (auto &[key, type] : keys) { if (type & key_type) { path = params_path + "/d/" + key; unlink(path.c_str()); } } // fsync parent directory path = params_path + "/d"; fsync_dir(path.c_str()); } std::string Params::get_params_path() { return params_path; } ================================================ FILE: selfdrive/common/params.h ================================================ #pragma once #include #include #include enum ParamKeyType { PERSISTENT = 0x02, CLEAR_ON_MANAGER_START = 0x04, CLEAR_ON_PANDA_DISCONNECT = 0x08, CLEAR_ON_IGNITION_ON = 0x10, CLEAR_ON_IGNITION_OFF = 0x20, DONT_LOG = 0x40, ALL = 0xFFFFFFFF }; class Params { public: Params(); Params(const std::string &path); bool checkKey(const std::string &key); ParamKeyType getKeyType(const std::string &key); // Delete a value int remove(const char *key); inline int remove(const std::string &key) { return remove (key.c_str()); } void clearAll(ParamKeyType type); // read all values std::map readAll(); // helpers for reading values std::string get(const char *key, bool block = false); inline std::string get(const std::string &key, bool block = false) { return get(key.c_str(), block); } inline std::string getParamsPath() { return params_path; } inline std::string getParamPath(std::string key) { return params_path + "/d/" + key; } template std::optional get(const char *key, bool block = false) { std::istringstream iss(get(key, block)); T value{}; iss >> value; return iss.fail() ? std::nullopt : std::optional(value); } inline bool getBool(const std::string &key) { return getBool(key.c_str()); } inline bool getBool(const char *key) { return get(key) == "1"; } // helpers for writing values int put(const char* key, const char* val, size_t value_size); inline int put(const std::string &key, const std::string &val) { return put(key.c_str(), val.data(), val.size()); } inline int putBool(const char *key, bool val) { return put(key, val ? "1" : "0", 1); } inline int putBool(const std::string &key, bool val) { return putBool(key.c_str(), val); } inline std::string get_params_path(); private: const std::string params_path; }; ================================================ FILE: selfdrive/common/queue.h ================================================ #pragma once #include #include #include template class SafeQueue { public: SafeQueue() = default; void push(const T& v) { { std::unique_lock lk(m); q.push(v); } cv.notify_one(); } T pop() { std::unique_lock lk(m); cv.wait(lk, [this] { return !q.empty(); }); T v = q.front(); q.pop(); return v; } bool try_pop(T& v, int timeout_ms = 0) { std::unique_lock lk(m); if (!cv.wait_for(lk, std::chrono::milliseconds(timeout_ms), [this] { return !q.empty(); })) { return false; } v = q.front(); q.pop(); return true; } bool empty() const { std::scoped_lock lk(m); return q.empty(); } size_t size() const { std::scoped_lock lk(m); return q.size(); } private: mutable std::mutex m; std::condition_variable cv; std::queue q; }; ================================================ FILE: selfdrive/common/swaglog.cc ================================================ #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include "selfdrive/common/swaglog.h" #include #include #include #include #include #include "json11.hpp" #include "selfdrive/common/util.h" #include "selfdrive/common/version.h" #include "selfdrive/hardware/hw.h" class LogState { public: LogState() = default; ~LogState(); std::mutex lock; bool inited; json11::Json::object ctx_j; void *zctx; void *sock; int print_level; }; LogState::~LogState() { zmq_close(sock); zmq_ctx_destroy(zctx); } static LogState s = {}; static void cloudlog_bind_locked(const char* k, const char* v) { s.ctx_j[k] = v; } static void cloudlog_init() { if (s.inited) return; s.ctx_j = json11::Json::object {}; s.zctx = zmq_ctx_new(); s.sock = zmq_socket(s.zctx, ZMQ_PUSH); int timeout = 100; // 100 ms timeout on shutdown for messages to be received by logmessaged zmq_setsockopt(s.sock, ZMQ_LINGER, &timeout, sizeof(timeout)); zmq_connect(s.sock, "ipc:///tmp/logmessage"); s.print_level = CLOUDLOG_WARNING; const char* print_level = getenv("LOGPRINT"); if (print_level) { if (strcmp(print_level, "debug") == 0) { s.print_level = CLOUDLOG_DEBUG; } else if (strcmp(print_level, "info") == 0) { s.print_level = CLOUDLOG_INFO; } else if (strcmp(print_level, "warning") == 0) { s.print_level = CLOUDLOG_WARNING; } } // openpilot bindings char* dongle_id = getenv("DONGLE_ID"); if (dongle_id) { cloudlog_bind_locked("dongle_id", dongle_id); } cloudlog_bind_locked("version", COMMA_VERSION); s.ctx_j["dirty"] = !getenv("CLEAN"); // device type if (Hardware::EON()) { cloudlog_bind_locked("device", "eon"); } else if (Hardware::TICI()) { cloudlog_bind_locked("device", "tici"); } else if (Hardware::JETSON()) { cloudlog_bind_locked("device", "jetson"); } else { cloudlog_bind_locked("device", "pc"); } s.inited = true; } void log(int levelnum, const char* filename, int lineno, const char* func, const char* msg, const std::string& log_s) { std::lock_guard lk(s.lock); cloudlog_init(); if (levelnum >= s.print_level) { printf("%s: %s\n", filename, msg); } char levelnum_c = levelnum; zmq_send(s.sock, (levelnum_c + log_s).c_str(), log_s.length() + 1, ZMQ_NOBLOCK); } void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func, const char* fmt, ...) { char* msg_buf = nullptr; va_list args; va_start(args, fmt); vasprintf(&msg_buf, fmt, args); va_end(args); if (!msg_buf) return; json11::Json log_j = json11::Json::object { {"msg", msg_buf}, {"ctx", s.ctx_j}, {"levelnum", levelnum}, {"filename", filename}, {"lineno", lineno}, {"funcname", func}, {"created", seconds_since_epoch()} }; std::string log_s = log_j.dump(); log(levelnum, filename, lineno, func, msg_buf, log_s); free(msg_buf); } void cloudlog_bind(const char* k, const char* v) { std::lock_guard lk(s.lock); cloudlog_init(); cloudlog_bind_locked(k, v); } ================================================ FILE: selfdrive/common/swaglog.h ================================================ #pragma once #include "selfdrive/common/timing.h" #define CLOUDLOG_DEBUG 10 #define CLOUDLOG_INFO 20 #define CLOUDLOG_WARNING 30 #define CLOUDLOG_ERROR 40 #define CLOUDLOG_CRITICAL 50 void cloudlog_e(int levelnum, const char* filename, int lineno, const char* func, const char* fmt, ...) /*__attribute__ ((format (printf, 6, 7)))*/; void cloudlog_bind(const char* k, const char* v); #define cloudlog(lvl, fmt, ...) cloudlog_e(lvl, __FILE__, __LINE__, \ __func__, \ fmt, ## __VA_ARGS__) #define cloudlog_rl(burst, millis, lvl, fmt, ...) \ { \ static uint64_t __begin = 0; \ static int __printed = 0; \ static int __missed = 0; \ \ int __burst = (burst); \ int __millis = (millis); \ uint64_t __ts = nanos_since_boot(); \ \ if (!__begin) __begin = __ts; \ \ if (__begin + __millis*1000000ULL < __ts) { \ if (__missed) { \ cloudlog(CLOUDLOG_WARNING, "cloudlog: %d messages suppressed", __missed); \ } \ __begin = 0; \ __printed = 0; \ __missed = 0; \ } \ \ if (__printed < __burst) { \ cloudlog(lvl, fmt, ## __VA_ARGS__); \ __printed++; \ } else { \ __missed++; \ } \ } #define LOGD(fmt, ...) cloudlog(CLOUDLOG_DEBUG, fmt, ## __VA_ARGS__) #define LOG(fmt, ...) cloudlog(CLOUDLOG_INFO, fmt, ## __VA_ARGS__) #define LOGW(fmt, ...) cloudlog(CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) #define LOGE(fmt, ...) cloudlog(CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) #define LOGD_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_DEBUG, fmt, ## __VA_ARGS__) #define LOG_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_INFO, fmt, ## __VA_ARGS__) #define LOGW_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_WARNING, fmt, ## __VA_ARGS__) #define LOGE_100(fmt, ...) cloudlog_rl(2, 100, CLOUDLOG_ERROR, fmt, ## __VA_ARGS__) ================================================ FILE: selfdrive/common/timing.h ================================================ #pragma once #include #include #ifdef __APPLE__ #define CLOCK_BOOTTIME CLOCK_MONOTONIC #endif static inline uint64_t nanos_since_boot() { struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); return t.tv_sec * 1000000000ULL + t.tv_nsec; } static inline double millis_since_boot() { struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); return t.tv_sec * 1000.0 + t.tv_nsec * 1e-6; } static inline double seconds_since_boot() { struct timespec t; clock_gettime(CLOCK_BOOTTIME, &t); return (double)t.tv_sec + t.tv_nsec * 1e-9; } static inline uint64_t nanos_since_epoch() { struct timespec t; clock_gettime(CLOCK_REALTIME, &t); return t.tv_sec * 1000000000ULL + t.tv_nsec; } static inline double seconds_since_epoch() { struct timespec t; clock_gettime(CLOCK_REALTIME, &t); return (double)t.tv_sec + t.tv_nsec * 1e-9; } // you probably should use nanos_since_boot instead static inline uint64_t nanos_monotonic() { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * 1000000000ULL + t.tv_nsec; } static inline uint64_t nanos_monotonic_raw() { struct timespec t; clock_gettime(CLOCK_MONOTONIC_RAW, &t); return t.tv_sec * 1000000000ULL + t.tv_nsec; } ================================================ FILE: selfdrive/common/touch.c ================================================ #include "selfdrive/common/touch.h" #include #include #include #include #include #include #include #include #include /* this macro is used to tell if "bit" is set in "array" * it selects a byte from the array, and does a boolean AND * operation with a byte that only has the relevant bit set. * eg. to check for the 12th bit, we do (array[1] & 1<<4) */ #define test_bit(bit, array) (array[bit/8] & (1<<(bit%8))) static int find_dev() { int err; int ret = -1; DIR *dir = opendir("/dev/input"); assert(dir); struct dirent* de = NULL; while ((de = readdir(dir))) { if (strncmp(de->d_name, "event", 5)) continue; int fd = openat(dirfd(dir), de->d_name, O_RDONLY); assert(fd >= 0); unsigned char ev_bits[KEY_MAX / 8 + 1]; err = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(ev_bits)), ev_bits); assert(err >= 0); if (test_bit(ABS_MT_POSITION_X, ev_bits) && test_bit(ABS_MT_POSITION_Y, ev_bits)) { ret = fd; break; } close(fd); } closedir(dir); return ret; } void touch_init(TouchState *s) { s->fd = find_dev(); assert(s->fd >= 0); } int touch_poll(TouchState *s, int* out_x, int* out_y, int timeout) { assert(out_x && out_y); bool up = false; while (true) { struct pollfd polls[] = {{ .fd = s->fd, .events = POLLIN, }}; int err = poll(polls, 1, timeout); if (err < 0) { return -1; } if (!(polls[0].revents & POLLIN)) { break; } struct input_event event; err = read(polls[0].fd, &event, sizeof(event)); if (err < sizeof(event)) { return -1; } switch (event.type) { case EV_ABS: if (event.code == ABS_MT_POSITION_X) { s->last_x = event.value; } else if (event.code == ABS_MT_POSITION_Y) { s->last_y = event.value; } else if (event.code == ABS_MT_TRACKING_ID && event.value != -1) { up = true; } break; default: break; } } if (up) { // adjust for flippening *out_x = s->last_y; *out_y = 1080 - s->last_x; } return up; } ================================================ FILE: selfdrive/common/touch.h ================================================ #pragma once #ifdef __cplusplus extern "C" { #endif typedef struct TouchState { int fd; int last_x, last_y; } TouchState; void touch_init(TouchState *s); int touch_poll(TouchState *s, int *out_x, int *out_y, int timeout); #ifdef __cplusplus } #endif ================================================ FILE: selfdrive/common/util.cc ================================================ #include "selfdrive/common/util.h" #include #include #include #include #include #include #include #include #ifdef __linux__ #include #include #ifndef __USE_GNU #define __USE_GNU #endif #include #endif // __linux__ void set_thread_name(const char* name) { #ifdef __linux__ // pthread_setname_np is dumb (fails instead of truncates) prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0); #endif } int set_realtime_priority(int level) { #ifdef __linux__ long tid = syscall(SYS_gettid); // should match python using chrt struct sched_param sa; memset(&sa, 0, sizeof(sa)); sa.sched_priority = level; return sched_setscheduler(tid, SCHED_FIFO, &sa); #else return -1; #endif } int set_core_affinity(int core) { #ifdef __linux__ long tid = syscall(SYS_gettid); cpu_set_t rt_cpu; CPU_ZERO(&rt_cpu); CPU_SET(core, &rt_cpu); return sched_setaffinity(tid, sizeof(rt_cpu), &rt_cpu); #else return -1; #endif } namespace util { std::string read_file(const std::string& fn) { std::ifstream f(fn, std::ios::binary | std::ios::in); if (f.is_open()) { f.seekg(0, std::ios::end); int size = f.tellg(); if (f.good() && size > 0) { std::string result(size, '\0'); f.seekg(0, std::ios::beg); f.read(result.data(), size); // return either good() or has reached end-of-file (e.g. /sys/power/wakeup_count) if (f.good() || f.eof()) { result.resize(f.gcount()); return result; } } // fallback for files created on read, e.g. procfs std::stringstream buffer; buffer << f.rdbuf(); return buffer.str(); } return std::string(); } std::map read_files_in_dir(const std::string &path) { std::map ret; DIR *d = opendir(path.c_str()); if (!d) return ret; struct dirent *de = NULL; while ((de = readdir(d))) { if (de->d_type != DT_DIR) { ret[de->d_name] = util::read_file(path + "/" + de->d_name); } } closedir(d); return ret; } int write_file(const char* path, const void* data, size_t size, int flags, mode_t mode) { int fd = HANDLE_EINTR(open(path, flags, mode)); if (fd == -1) { return -1; } ssize_t n = HANDLE_EINTR(write(fd, data, size)); close(fd); return (n >= 0 && (size_t)n == size) ? 0 : -1; } std::string readlink(const std::string &path) { char buff[4096]; ssize_t len = ::readlink(path.c_str(), buff, sizeof(buff)-1); if (len != -1) { buff[len] = '\0'; return std::string(buff); } return ""; } bool file_exists(const std::string& fn) { struct stat st = {}; return stat(fn.c_str(), &st) != -1; } std::string getenv(const char* key, const char* default_val) { const char* val = ::getenv(key); return val ? val : default_val; } int getenv(const char* key, int default_val) { const char* val = ::getenv(key); return val ? atoi(val) : default_val; } float getenv(const char* key, float default_val) { const char* val = ::getenv(key); return val ? atof(val) : default_val; } std::string tohex(const uint8_t *buf, size_t buf_size) { std::unique_ptr hexbuf(new char[buf_size * 2 + 1]); for (size_t i = 0; i < buf_size; i++) { sprintf(&hexbuf[i * 2], "%02x", buf[i]); } hexbuf[buf_size * 2] = 0; return std::string(hexbuf.get(), hexbuf.get() + buf_size * 2); } std::string hexdump(const std::string& in) { std::stringstream ss; ss << std::hex << std::setfill('0'); for (size_t i = 0; i < in.size(); i++) { ss << std::setw(2) << static_cast(static_cast(in[i])); } return ss.str(); } std::string base_name(std::string const &path) { size_t pos = path.find_last_of("/"); if (pos == std::string::npos) return path; return path.substr(pos + 1); } std::string dir_name(std::string const &path) { size_t pos = path.find_last_of("/"); if (pos == std::string::npos) return ""; return path.substr(0, pos); } struct tm get_time() { time_t rawtime; time(&rawtime); struct tm sys_time; gmtime_r(&rawtime, &sys_time); return sys_time; } bool time_valid(struct tm sys_time) { int year = 1900 + sys_time.tm_year; int month = 1 + sys_time.tm_mon; return (year > 2021) || (year == 2021 && month >= 6); } } // namespace util ================================================ FILE: selfdrive/common/util.h ================================================ #pragma once #include #include #include #include #include #include #include #include #include #include #include // keep trying if x gets interrupted by a signal #define HANDLE_EINTR(x) \ ({ \ decltype(x) ret; \ int try_cnt = 0; \ do { \ ret = (x); \ } while (ret == -1 && errno == EINTR && try_cnt++ < 100); \ ret; \ }) #ifndef sighandler_t typedef void (*sighandler_t)(int sig); #endif void set_thread_name(const char* name); int set_realtime_priority(int level); int set_core_affinity(int core); namespace util { // ***** Time helpers ***** struct tm get_time(); bool time_valid(struct tm sys_time); // ***** math helpers ***** // map x from [a1, a2] to [b1, b2] template T map_val(T x, T a1, T a2, T b1, T b2) { x = std::clamp(x, a1, a2); T ra = a2 - a1; T rb = b2 - b1; return (x - a1) * rb / ra + b1; } // ***** string helpers ***** template std::string string_format(const std::string& format, Args... args) { size_t size = snprintf(nullptr, 0, format.c_str(), args...) + 1; std::unique_ptr buf(new char[size]); snprintf(buf.get(), size, format.c_str(), args...); return std::string(buf.get(), buf.get() + size - 1); } std::string getenv(const char* key, const char* default_val = ""); int getenv(const char* key, int default_val); float getenv(const char* key, float default_val); std::string tohex(const uint8_t* buf, size_t buf_size); std::string hexdump(const std::string& in); std::string base_name(std::string const& path); std::string dir_name(std::string const& path); // **** file fhelpers ***** std::string read_file(const std::string& fn); std::map read_files_in_dir(const std::string& path); int write_file(const char* path, const void* data, size_t size, int flags = O_WRONLY, mode_t mode = 0664); std::string readlink(const std::string& path); bool file_exists(const std::string& fn); inline void sleep_for(const int milliseconds) { std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); } } // namespace util class ExitHandler { public: ExitHandler() { std::signal(SIGINT, (sighandler_t)set_do_exit); std::signal(SIGTERM, (sighandler_t)set_do_exit); #ifndef __APPLE__ std::signal(SIGPWR, (sighandler_t)set_do_exit); #endif }; inline static std::atomic power_failure = false; inline static std::atomic signal = 0; inline operator bool() { return do_exit; } inline ExitHandler& operator=(bool v) { signal = 0; do_exit = v; return *this; } private: static void set_do_exit(int sig) { #ifndef __APPLE__ power_failure = (sig == SIGPWR); #endif signal = sig; do_exit = true; } inline static std::atomic do_exit = false; }; struct unique_fd { unique_fd(int fd = -1) : fd_(fd) {} unique_fd& operator=(unique_fd&& uf) { fd_ = uf.fd_; uf.fd_ = -1; return *this; } ~unique_fd() { if (fd_ != -1) close(fd_); } operator int() const { return fd_; } int fd_; }; class FirstOrderFilter { public: FirstOrderFilter(float x0, float ts, float dt) { k_ = (dt / ts) / (1.0 + dt / ts); x_ = x0; } inline float update(float x) { x_ = (1. - k_) * x_ + k_ * x; return x_; } inline void reset(float x) { x_ = x; } inline float x(){ return x_; } private: float x_, k_; }; template void update_max_atomic(std::atomic& max, T const& value) { T prev = max; while(prev < value && !max.compare_exchange_weak(prev, value)) {} } ================================================ FILE: selfdrive/common/version.h ================================================ #define COMMA_VERSION "0.8.9-xnxpilot" ================================================ FILE: selfdrive/common/visionimg.cc ================================================ #include "selfdrive/common/visionimg.h" #include #ifdef QCOM #include #include #include #include #define GL_GLEXT_PROTOTYPES #include using namespace android; EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { const int bpp = 3; assert((buf->len % buf->stride) == 0); assert((buf->stride % bpp) == 0); const int format = HAL_PIXEL_FORMAT_RGB_888; private_handle = new private_handle_t(buf->fd, buf->len, private_handle_t::PRIV_FLAGS_USES_ION|private_handle_t::PRIV_FLAGS_FRAMEBUFFER, 0, format, buf->stride/bpp, buf->len/buf->stride, buf->width, buf->height); // GraphicBuffer is ref counted by EGLClientBuffer(ANativeWindowBuffer), no need and not possible to release. GraphicBuffer* gb = new GraphicBuffer(buf->width, buf->height, (PixelFormat)format, GraphicBuffer::USAGE_HW_TEXTURE, buf->stride/bpp, (private_handle_t*)private_handle, false); EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(display != EGL_NO_DISPLAY); EGLint img_attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; img_khr = eglCreateImageKHR(display, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, gb->getNativeBuffer(), img_attrs); assert(img_khr != EGL_NO_IMAGE_KHR); glGenTextures(1, &frame_tex); glBindTexture(GL_TEXTURE_2D, frame_tex); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, img_khr); } EGLImageTexture::~EGLImageTexture() { glDeleteTextures(1, &frame_tex); EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(display != EGL_NO_DISPLAY); eglDestroyImageKHR(display, img_khr); delete (private_handle_t*)private_handle; } #else // ifdef QCOM EGLImageTexture::EGLImageTexture(const VisionBuf *buf) { glGenTextures(1, &frame_tex); glBindTexture(GL_TEXTURE_2D, frame_tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, buf->width, buf->height, 0, GL_RGB, GL_UNSIGNED_BYTE, buf->addr); glGenerateMipmap(GL_TEXTURE_2D); } EGLImageTexture::~EGLImageTexture() { glDeleteTextures(1, &frame_tex); } #endif // ifdef QCOM ================================================ FILE: selfdrive/common/visionimg.h ================================================ #pragma once #include "cereal/visionipc/visionbuf.h" #ifdef __APPLE__ #include #else #include #endif #ifdef QCOM #include #define EGL_EGLEXT_PROTOTYPES #include #undef Status #endif class EGLImageTexture { public: EGLImageTexture(const VisionBuf *buf); ~EGLImageTexture(); GLuint frame_tex = 0; #ifdef QCOM void *private_handle = nullptr; EGLImageKHR img_khr = 0; #endif }; ================================================ FILE: selfdrive/common/watchdog.cc ================================================ #include "selfdrive/common/watchdog.h" #include #include #include #include "selfdrive/common/timing.h" #include "selfdrive/common/util.h" const std::string watchdog_fn_prefix = "/dev/shm/wd_"; // + bool watchdog_kick() { std::string fn = watchdog_fn_prefix + std::to_string(getpid()); std::string cur_t = std::to_string(nanos_since_boot()); int r = util::write_file(fn.c_str(), cur_t.data(), cur_t.length(), O_WRONLY | O_CREAT); return r == 0; } ================================================ FILE: selfdrive/common/watchdog.h ================================================ #pragma once bool watchdog_kick(); ================================================ FILE: selfdrive/config.py ================================================ import numpy as np class Conversions: #Speed MPH_TO_KPH = 1.609344 KPH_TO_MPH = 1. / MPH_TO_KPH MS_TO_KPH = 3.6 KPH_TO_MS = 1. / MS_TO_KPH MS_TO_MPH = MS_TO_KPH * KPH_TO_MPH MPH_TO_MS = MPH_TO_KPH * KPH_TO_MS MS_TO_KNOTS = 1.9438 KNOTS_TO_MS = 1. / MS_TO_KNOTS #Angle DEG_TO_RAD = np.pi / 180. RAD_TO_DEG = 1. / DEG_TO_RAD #Mass LB_TO_KG = 0.453592 #Distance MT_TO_FT = 3.28084 RADAR_TO_CENTER = 2.7 # (deprecated) RADAR is ~ 2.7m ahead from center of car RADAR_TO_CAMERA = 1.52 # RADAR is ~ 1.5m ahead from center of mesh frame class UIParams: lidar_x, lidar_y, lidar_zoom = 384, 960, 6 lidar_car_x, lidar_car_y = lidar_x / 2., lidar_y / 1.1 car_hwidth = 1.7272 / 2 * lidar_zoom car_front = 2.6924 * lidar_zoom car_back = 1.8796 * lidar_zoom car_color = 110 ================================================ FILE: selfdrive/controls/__init__.py ================================================ ================================================ FILE: selfdrive/controls/controlsd.py ================================================ #!/usr/bin/env python3 import os import math from numbers import Number from cereal import car, log from common.numpy_fast import clip from common.realtime import sec_since_boot, config_realtime_process, Priority, Ratekeeper, DT_CTRL from common.profiler import Profiler from common.params import Params, put_nonblocking import cereal.messaging as messaging from selfdrive.config import Conversions as CV from selfdrive.swaglog import cloudlog from selfdrive.boardd.boardd import can_list_to_can_capnp from selfdrive.car.car_helpers import get_car, get_startup_event, get_one_can from selfdrive.controls.lib.lane_planner import CAMERA_OFFSET from selfdrive.controls.lib.drive_helpers import update_v_cruise, initialize_v_cruise from selfdrive.controls.lib.drive_helpers import get_lag_adjusted_curvature from selfdrive.controls.lib.longcontrol import LongControl, STARTING_TARGET_SPEED from selfdrive.controls.lib.latcontrol_pid import LatControlPID from selfdrive.controls.lib.latcontrol_indi import LatControlINDI from selfdrive.controls.lib.latcontrol_lqr import LatControlLQR from selfdrive.controls.lib.latcontrol_angle import LatControlAngle from selfdrive.controls.lib.events import Events, ET from selfdrive.controls.lib.alertmanager import AlertManager from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.locationd.calibrationd import Calibration from selfdrive.hardware import HARDWARE, TICI, EON, JETSON from selfdrive.manager.process_config import managed_processes LDW_MIN_SPEED = 31 * CV.MPH_TO_MS LANE_DEPARTURE_THRESHOLD = 0.1 STEER_ANGLE_SATURATION_TIMEOUT = 1.0 / DT_CTRL STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees SIMULATION = "SIMULATION" in os.environ NOSENSOR = "NOSENSOR" in os.environ IGNORE_PROCESSES = {"rtshield", "uploader", "deleter", "loggerd", "logmessaged", "tombstoned", "logcatd", "proclogd", "clocksd", "updated", "timezoned", "manage_athenad", "dragonConf"} | \ {k for k, v in managed_processes.items() if not v.enabled} ACTUATOR_FIELDS = set(car.CarControl.Actuators.schema.fields.keys()) ThermalStatus = log.DeviceState.ThermalStatus State = log.ControlsState.OpenpilotState PandaType = log.PandaState.PandaType Desire = log.LateralPlan.Desire LaneChangeState = log.LateralPlan.LaneChangeState LaneChangeDirection = log.LateralPlan.LaneChangeDirection EventName = car.CarEvent.EventName class Controls: def __init__(self, sm=None, pm=None, can_sock=None): params = Params() self.dp_jetson = params.get_bool('dp_jetson') self.dp_lexus_rx_rpm_fix = params.get_bool('dp_lexus_rx_rpm_fix') config_realtime_process(4 if TICI else 3, Priority.CTRL_HIGH) # Setup sockets self.pm = pm if self.pm is None: self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState', 'carControl', 'carEvents', 'carParams']) self.camera_packets = ["roadCameraState", "driverCameraState"] if TICI: self.camera_packets.append("wideRoadCameraState") params = Params() self.joystick_mode = params.get_bool("JoystickDebugMode") joystick_packet = ['testJoystick'] if self.joystick_mode else [] self.sm = sm if self.sm is None: ignore = ['driverCameraState', 'managerState'] if SIMULATION else None if self.dp_jetson: ignore = ['driverCameraState', 'driverMonitoringState'] if ignore is None else ignore + ['driverCameraState', 'driverMonitoringState'] self.sm = messaging.SubMaster(['deviceState', 'pandaState', 'modelV2', 'liveCalibration', 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman', 'managerState', 'liveParameters', 'radarState', 'dragonConf'] + self.camera_packets + joystick_packet, ignore_alive=ignore, ignore_avg_freq=['radarState', 'longitudinalPlan']) self.can_sock = can_sock if can_sock is None: can_timeout = None if os.environ.get('NO_CAN_TIMEOUT', False) else 100 self.can_sock = messaging.sub_sock('can', timeout=can_timeout) if TICI: self.log_sock = messaging.sub_sock('androidLog') # wait for one pandaState and one CAN packet print("Waiting for CAN messages...") get_one_can(self.can_sock) self.CI, self.CP = get_car(self.can_sock, self.pm.sock['sendcan']) # read params self.is_metric = params.get_bool("IsMetric") self.is_ldw_enabled = params.get_bool("IsLdwEnabled") community_feature_toggle = params.get_bool("CommunityFeaturesToggle") openpilot_enabled_toggle = params.get_bool("OpenpilotEnabledToggle") passive = params.get_bool("Passive") or not openpilot_enabled_toggle # detect sound card presence and ensure successful init sounds_available = HARDWARE.get_sound_card_online() car_recognized = self.CP.carName != 'mock' controller_available = self.CI.CC is not None and not passive and not self.CP.dashcamOnly community_feature = self.CP.communityFeature or \ self.CP.fingerprintSource == car.CarParams.FingerprintSource.can community_feature_disallowed = community_feature and (not community_feature_toggle) self.read_only = not car_recognized or not controller_available or \ self.CP.dashcamOnly or community_feature_disallowed if self.read_only: self.CP.safetyModel = car.CarParams.SafetyModel.noOutput # Write CarParams for radard cp_bytes = self.CP.to_bytes() params.put("CarParams", cp_bytes) put_nonblocking("CarParamsCache", cp_bytes) self.CC = car.CarControl.new_message() self.AM = AlertManager() self.events = Events() self.LoC = LongControl(self.CP) self.VM = VehicleModel(self.CP) if params.get_bool('dp_lqr'): self.LaC = LatControlLQR(self.CP) elif self.CP.steerControlType == car.CarParams.SteerControlType.angle: self.LaC = LatControlAngle(self.CP) elif self.CP.lateralTuning.which() == 'pid': self.LaC = LatControlPID(self.CP) elif self.CP.lateralTuning.which() == 'indi': self.LaC = LatControlINDI(self.CP) elif self.CP.lateralTuning.which() == 'lqr': self.LaC = LatControlLQR(self.CP) self.initialized = False self.state = State.disabled self.enabled = False self.active = False self.can_rcv_error = False self.soft_disable_timer = 0 self.v_cruise_kph = 255 self.v_cruise_kph_last = 0 self.mismatch_counter = 0 self.can_error_counter = 0 self.last_blinker_frame = 0 self.saturated_count = 0 self.distance_traveled = 0 self.last_functional_fan_frame = 0 self.events_prev = [] self.current_alert_types = [ET.PERMANENT] self.logged_comm_issue = False self.v_target = 0.0 self.a_target = 0.0 self.led_state = False self.led_state_prev = False # TODO: no longer necessary, aside from process replay self.sm['liveParameters'].valid = True self.startup_event = get_startup_event(car_recognized, controller_available, self.CP.fuzzyFingerprint, len(self.CP.carFw) > 0) # if not sounds_available: # self.events.add(EventName.soundsUnavailable, static=True) if community_feature_disallowed and car_recognized and not self.CP.dashcamOnly: self.events.add(EventName.communityFeatureDisallowed, static=True) if not car_recognized: self.events.add(EventName.carUnrecognized, static=True) elif self.read_only: self.events.add(EventName.dashcamMode, static=True) elif self.joystick_mode: self.events.add(EventName.joystickDebug, static=True) self.startup_event = None # controlsd is driven by can recv, expected at 100Hz self.rk = Ratekeeper(100, print_delay_threshold=None) self.prof = Profiler(False) # off by default # dp self.sm['dragonConf'].dpAtl = False self.sm['dragonConf'].dpSrCustom = self.CP.steerRatio self.sm['dragonConf'].dpSrLearner = True def update_events(self, CS): """Compute carEvents from carState""" self.events.clear() self.events.add_from_msg(CS.events) if not self.dp_jetson: self.events.add_from_msg(self.sm['driverMonitoringState'].events) self.events.add_from_msg(self.sm['longitudinalPlan'].eventsDEPRECATED) # Handle startup event if self.startup_event is not None: self.events.add(self.startup_event) self.startup_event = None # Don't add any more events if not initialized if not self.initialized: self.events.add(EventName.controlsInitializing) return # Create events for battery, temperature, disk space, and memory # if self.sm['deviceState'].batteryPercent < 1 and self.sm['deviceState'].chargingError: # # at zero percent battery, while discharging, OP should not allowed # self.events.add(EventName.lowBattery) if self.sm['deviceState'].thermalStatus >= ThermalStatus.red: self.events.add(EventName.overheat) if self.sm['deviceState'].freeSpacePercent < 7 and not SIMULATION: # under 7% of space free no enable allowed self.events.add(EventName.outOfSpace) # TODO: make tici threshold the same if self.sm['deviceState'].memoryUsagePercent > (90 if TICI or JETSON else 65) and not SIMULATION: self.events.add(EventName.lowMemory) cpus = list(self.sm['deviceState'].cpuUsagePercent)[:(-1 if EON else None)] if max(cpus, default=0) > 95 and not SIMULATION: self.events.add(EventName.highCpuUsage) # Alert if fan isn't spinning for 5 seconds if self.sm['pandaState'].pandaType in [PandaType.uno, PandaType.dos]: if self.sm['pandaState'].fanSpeedRpm == 0 and self.sm['deviceState'].fanSpeedPercentDesired > 50: if (self.sm.frame - self.last_functional_fan_frame) * DT_CTRL > 5.0: self.events.add(EventName.fanMalfunction) else: self.last_functional_fan_frame = self.sm.frame # Handle calibration status cal_status = self.sm['liveCalibration'].calStatus if cal_status != Calibration.CALIBRATED: if cal_status == Calibration.UNCALIBRATED: self.events.add(EventName.calibrationIncomplete) else: self.events.add(EventName.calibrationInvalid) # Handle lane change if self.sm['lateralPlan'].laneChangeState == LaneChangeState.preLaneChange: direction = self.sm['lateralPlan'].laneChangeDirection if (CS.leftBlindspot and direction == LaneChangeDirection.left) or \ (CS.rightBlindspot and direction == LaneChangeDirection.right): self.events.add(EventName.laneChangeBlocked) elif self.sm['lateralPlan'].dpALCAStartIn > 0: self.events.add(EventName.autoLaneChange) else: if direction == LaneChangeDirection.left: self.events.add(EventName.preLaneChangeLeft) else: self.events.add(EventName.preLaneChangeRight) elif self.sm['lateralPlan'].laneChangeState in [LaneChangeState.laneChangeStarting, LaneChangeState.laneChangeFinishing]: self.events.add(EventName.laneChange) if self.can_rcv_error or not CS.canValid: self.events.add(EventName.pcmDisable if self.sm['dragonConf'].dpAtl else EventName.canError) safety_mismatch = self.sm['pandaState'].safetyModel != self.CP.safetyModel or self.sm['pandaState'].safetyParam != self.CP.safetyParam if safety_mismatch or self.mismatch_counter >= 200: self.events.add(EventName.controlsMismatch) if not self.sm['liveParameters'].valid: self.events.add(EventName.vehicleModelInvalid) if len(self.sm['radarState'].radarErrors): self.events.add(EventName.radarFault) elif not self.sm.valid["pandaState"]: self.events.add(EventName.usbError) elif not self.dp_jetson and not self.sm.all_alive_and_valid(): self.events.add(EventName.commIssue) if not self.logged_comm_issue: invalid = [s for s, valid in self.sm.valid.items() if not valid] not_alive = [s for s, alive in self.sm.alive.items() if not alive] cloudlog.event("commIssue", invalid=invalid, not_alive=not_alive) self.logged_comm_issue = True else: self.logged_comm_issue = False if not self.sm['lateralPlan'].mpcSolutionValid: self.events.add(EventName.steerTempUnavailable if self.sm['dragonConf'].dpAtl else EventName.plannerError) if not self.sm['liveLocationKalman'].sensorsOK and not NOSENSOR: if self.sm.frame > 5 / DT_CTRL: # Give locationd some time to receive all the inputs self.events.add(EventName.sensorDataInvalid) if not self.sm['liveLocationKalman'].posenetOK: self.events.add(EventName.posenetInvalid) if not self.sm['liveLocationKalman'].deviceStable: self.events.add(EventName.deviceFalling) if log.PandaState.FaultType.relayMalfunction in self.sm['pandaState'].faults: self.events.add(EventName.relayMalfunction) if self.sm['longitudinalPlan'].fcw or (self.enabled and self.sm['modelV2'].meta.hardBrakePredicted): self.events.add(EventName.fcw) if TICI: logs = messaging.drain_sock(self.log_sock, wait_for_one=False) messages = [] for m in logs: try: messages.append(m.androidLog.message) except UnicodeDecodeError: pass for err in ["ERROR_CRC", "ERROR_ECC", "ERROR_STREAM_UNDERFLOW", "APPLY FAILED"]: for m in messages: if err not in m: continue csid = m.split("CSID:")[-1].split(" ")[0] evt = {"0": EventName.roadCameraError, "1": EventName.wideRoadCameraError, "2": EventName.driverCameraError}.get(csid, None) if evt is not None: self.events.add(evt) # TODO: fix simulator if not SIMULATION: # if not NOSENSOR: # if not self.sm['liveLocationKalman'].gpsOK and (self.distance_traveled > 1000): # # Not show in first 1 km to allow for driving out of garage. This event shows after 5 minutes # self.events.add(EventName.noGps) if not self.dp_jetson and not self.sm.all_alive(self.camera_packets): self.events.add(EventName.cameraMalfunction) if self.sm['modelV2'].frameDropPerc > 20: self.events.add(EventName.modeldLagging) if self.sm['liveLocationKalman'].excessiveResets: self.events.add(EventName.localizerMalfunction) # Check if all manager processes are running # not_running = set(p.name for p in self.sm['managerState'].processes if not p.running) # if self.sm.rcv_frame['managerState'] and (not_running - IGNORE_PROCESSES): # self.events.add(EventName.processNotRunning) # Only allow engagement with brake pressed when stopped behind another stopped car speeds = self.sm['longitudinalPlan'].speeds if len(speeds) > 1: v_future = speeds[-1] else: v_future = 100.0 if not self.sm['dragonConf'].dpAtl and CS.brakePressed and v_future >= STARTING_TARGET_SPEED \ and self.CP.openpilotLongitudinalControl and CS.vEgo < 0.3: self.events.add(EventName.noTarget) def data_sample(self): """Receive data from sockets and update carState""" # Update carState from CAN can_strs = messaging.drain_sock_raw(self.can_sock, wait_for_one=True) CS = self.CI.update(self.CC, can_strs, self.sm['dragonConf']) self.sm.update(0) all_valid = CS.canValid and self.sm.all_alive_and_valid() if not self.initialized and (all_valid or self.sm.frame * DT_CTRL > 3.5 or SIMULATION): self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan']) self.initialized = True Params().put_bool("ControlsReady", True) # Check for CAN timeout if not can_strs: self.can_error_counter += 1 self.can_rcv_error = True else: self.can_rcv_error = False # When the panda and controlsd do not agree on controls_allowed # we want to disengage openpilot. However the status from the panda goes through # another socket other than the CAN messages and one can arrive earlier than the other. # Therefore we allow a mismatch for two samples, then we trigger the disengagement. if not self.enabled: self.mismatch_counter = 0 if not self.sm['dragonConf'].dpAtl and not self.sm['pandaState'].controlsAllowed and self.enabled: self.mismatch_counter += 1 self.distance_traveled += CS.vEgo * DT_CTRL return CS def state_transition(self, CS): """Compute conditional state transitions and execute actions on state transitions""" self.v_cruise_kph_last = self.v_cruise_kph # if stock cruise is completely disabled, then we can use our own set speed logic if not self.CP.pcmCruise: self.v_cruise_kph = update_v_cruise(self.v_cruise_kph, CS.buttonEvents, self.enabled) elif self.CP.pcmCruise and CS.cruiseState.enabled: self.v_cruise_kph = CS.cruiseState.speed * CV.MS_TO_KPH # decrease the soft disable timer at every step, as it's reset on # entrance in SOFT_DISABLING state self.soft_disable_timer = max(0, self.soft_disable_timer - 1) self.current_alert_types = [ET.PERMANENT] # ENABLED, PRE ENABLING, SOFT DISABLING if self.state != State.disabled: # user and immediate disable always have priority in a non-disabled state if self.events.any(ET.USER_DISABLE): self.state = State.disabled self.current_alert_types.append(ET.USER_DISABLE) elif self.events.any(ET.IMMEDIATE_DISABLE): self.state = State.disabled self.current_alert_types.append(ET.IMMEDIATE_DISABLE) else: # ENABLED if self.state == State.enabled: if self.events.any(ET.SOFT_DISABLE): self.state = State.softDisabling self.soft_disable_timer = 300 # 3s self.current_alert_types.append(ET.SOFT_DISABLE) # SOFT DISABLING elif self.state == State.softDisabling: if not self.events.any(ET.SOFT_DISABLE): # no more soft disabling condition, so go back to ENABLED self.state = State.enabled elif self.events.any(ET.SOFT_DISABLE) and self.soft_disable_timer > 0: self.current_alert_types.append(ET.SOFT_DISABLE) elif self.soft_disable_timer <= 0: self.state = State.disabled # PRE ENABLING elif self.state == State.preEnabled: if not self.events.any(ET.PRE_ENABLE): self.state = State.enabled else: self.current_alert_types.append(ET.PRE_ENABLE) # DISABLED elif self.state == State.disabled: if self.events.any(ET.ENABLE): if self.events.any(ET.NO_ENTRY): self.current_alert_types.append(ET.NO_ENTRY) else: if self.events.any(ET.PRE_ENABLE): self.state = State.preEnabled else: self.state = State.enabled self.current_alert_types.append(ET.ENABLE) self.v_cruise_kph = initialize_v_cruise(CS.vEgo, CS.buttonEvents, self.v_cruise_kph_last) # Check if actuators are enabled self.active = self.state == State.enabled or self.state == State.softDisabling if self.active: self.current_alert_types.append(ET.WARNING) # Check if openpilot is engaged self.enabled = self.active or self.state == State.preEnabled def state_control(self, CS): """Given the state, this function returns an actuators packet""" # Update VehicleModel params = self.sm['liveParameters'] x = max(params.stiffnessFactor, 0.1) sr = max(params.steerRatio, 0.1) if not self.sm['dragonConf'].dpSrLearner: if self.sm['dragonConf'].dpSrCustom >= 10: sr = self.sm['dragonConf'].dpSrCustom else: sr = self.CP.steerRatio self.VM.update_params(x, sr) lat_plan = self.sm['lateralPlan'] long_plan = self.sm['longitudinalPlan'] actuators = car.CarControl.Actuators.new_message() actuators.longControlState = self.LoC.long_control_state if CS.leftBlinker or CS.rightBlinker: self.last_blinker_frame = self.sm.frame # State specific actions if not self.active: self.LaC.reset() self.LoC.reset(v_pid=CS.vEgo) if not self.joystick_mode: # accel PID loop pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, self.v_cruise_kph * CV.KPH_TO_MS) actuators.accel, self.v_target, self.a_target = self.LoC.update(self.active, CS, self.CP, long_plan, pid_accel_limits) # Steering PID loop and lateral MPC desired_curvature, desired_curvature_rate = get_lag_adjusted_curvature(self.CP, CS.vEgo, lat_plan.psis, lat_plan.curvatures, lat_plan.curvatureRates) actuators.steer, actuators.steeringAngleDeg, lac_log = self.LaC.update(self.active, CS, self.CP, self.VM, params, desired_curvature, desired_curvature_rate) else: lac_log = log.ControlsState.LateralDebugState.new_message() if self.sm.rcv_frame['testJoystick'] > 0 and self.active: actuators.accel = 4.0*clip(self.sm['testJoystick'].axes[0], -1, 1) steer = clip(self.sm['testJoystick'].axes[1], -1, 1) # max angle is 45 for angle-based cars actuators.steer, actuators.steeringAngleDeg = steer, steer * 45. lac_log.active = True lac_log.steeringAngleDeg = CS.steeringAngleDeg lac_log.output = steer lac_log.saturated = abs(steer) >= 0.9 # Check for difference between desired angle and angle for angle based control angle_control_saturated = self.CP.steerControlType == car.CarParams.SteerControlType.angle and \ abs(actuators.steeringAngleDeg - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD if angle_control_saturated and not CS.steeringPressed and self.active: self.saturated_count += 1 else: self.saturated_count = 0 # Send a "steering required alert" if saturation count has reached the limit if (lac_log.saturated and not CS.steeringPressed) or \ (self.saturated_count > STEER_ANGLE_SATURATION_TIMEOUT): if len(lat_plan.dPathPoints): # Check if we deviated from the path left_deviation = actuators.steer > 0 and lat_plan.dPathPoints[0] < -0.1 right_deviation = actuators.steer < 0 and lat_plan.dPathPoints[0] > 0.1 if left_deviation or right_deviation: self.events.add(EventName.steerSaturated) # Ensure no NaNs/Infs for p in ACTUATOR_FIELDS: attr = getattr(actuators, p) if not isinstance(attr, Number): continue if not math.isfinite(attr): cloudlog.error(f"actuators.{p} not finite {actuators.to_dict()}") setattr(actuators, p, 0.0) return actuators, lac_log def publish_logs(self, CS, start_time, actuators, lac_log): """Send actuators and hud commands to the car, send controlsstate and MPC logging""" CC = car.CarControl.new_message() CC.enabled = self.enabled CC.actuators = actuators CC.cruiseControl.override = True CC.cruiseControl.cancel = not self.CP.pcmCruise or (not self.enabled and CS.cruiseState.enabled) if self.joystick_mode and self.sm.rcv_frame['testJoystick'] > 0 and self.sm['testJoystick'].buttons[0]: CC.cruiseControl.cancel = True # TODO remove car specific stuff in controls # Some override values for Honda # brake discount removes a sharp nonlinearity brake_discount = (1.0 - clip(-actuators.accel * (3.0/4.0), 0.0, 1.0)) speed_override = max(0.0, (self.LoC.v_pid + CS.cruiseState.speedOffset) * brake_discount) CC.cruiseControl.speedOverride = float(speed_override if self.CP.pcmCruise else 0.0) CC.cruiseControl.accelOverride = float(self.CI.calc_accel_override(CS.aEgo, self.a_target, CS.vEgo, self.v_target)) CC.hudControl.setSpeed = float(self.v_cruise_kph * CV.KPH_TO_MS) CC.hudControl.speedVisible = self.enabled CC.hudControl.lanesVisible = self.enabled CC.hudControl.leadVisible = self.sm['longitudinalPlan'].hasLead right_lane_visible = self.sm['lateralPlan'].rProb > 0.5 left_lane_visible = self.sm['lateralPlan'].lProb > 0.5 CC.hudControl.rightLaneVisible = bool(right_lane_visible) CC.hudControl.leftLaneVisible = bool(left_lane_visible) recent_blinker = (self.sm.frame - self.last_blinker_frame) * DT_CTRL < 5.0 # 5s blinker cooldown ldw_allowed = self.is_ldw_enabled and CS.vEgo > LDW_MIN_SPEED and not recent_blinker \ and not self.active and self.sm['liveCalibration'].calStatus == Calibration.CALIBRATED meta = self.sm['modelV2'].meta if len(meta.desirePrediction) and ldw_allowed: l_lane_change_prob = meta.desirePrediction[Desire.laneChangeLeft - 1] r_lane_change_prob = meta.desirePrediction[Desire.laneChangeRight - 1] l_lane_close = left_lane_visible and (self.sm['modelV2'].laneLines[1].y[0] > -(1.08 + CAMERA_OFFSET)) r_lane_close = right_lane_visible and (self.sm['modelV2'].laneLines[2].y[0] < (1.08 - CAMERA_OFFSET)) CC.hudControl.leftLaneDepart = bool(l_lane_change_prob > LANE_DEPARTURE_THRESHOLD and l_lane_close) CC.hudControl.rightLaneDepart = bool(r_lane_change_prob > LANE_DEPARTURE_THRESHOLD and r_lane_close) if CC.hudControl.rightLaneDepart or CC.hudControl.leftLaneDepart: self.events.add(EventName.ldw) clear_event = ET.WARNING if ET.WARNING not in self.current_alert_types else None alerts = self.events.create_alerts(self.current_alert_types, [self.CP, self.sm, self.is_metric]) self.AM.add_many(self.sm.frame, alerts, self.enabled) self.AM.process_alerts(self.sm.frame, clear_event) CC.hudControl.visualAlert = self.AM.visual_alert if not self.read_only and self.initialized: # send car controls over can can_sends = self.CI.apply(CC) self.pm.send('sendcan', can_list_to_can_capnp(can_sends, msgtype='sendcan', valid=CS.canValid)) force_decel = False if self.dp_jetson else (self.sm['driverMonitoringState'].awarenessStatus < 0.) or \ (self.state == State.softDisabling) # Curvature & Steering angle params = self.sm['liveParameters'] steer_angle_without_offset = math.radians(CS.steeringAngleDeg - params.angleOffsetAverageDeg) curvature = -self.VM.calc_curvature(steer_angle_without_offset, CS.vEgo) # controlsState dat = messaging.new_message('controlsState') dat.valid = CS.canValid controlsState = dat.controlsState controlsState.alertText1 = self.AM.alert_text_1 controlsState.alertText2 = self.AM.alert_text_2 controlsState.alertSize = self.AM.alert_size controlsState.alertStatus = self.AM.alert_status controlsState.alertBlinkingRate = self.AM.alert_rate controlsState.alertType = self.AM.alert_type controlsState.alertSound = self.AM.audible_alert controlsState.canMonoTimes = list(CS.canMonoTimes) controlsState.longitudinalPlanMonoTime = self.sm.logMonoTime['longitudinalPlan'] controlsState.lateralPlanMonoTime = self.sm.logMonoTime['lateralPlan'] controlsState.enabled = self.enabled controlsState.active = self.active controlsState.curvature = curvature controlsState.state = self.state controlsState.engageable = not self.events.any(ET.NO_ENTRY) controlsState.longControlState = self.LoC.long_control_state controlsState.vPid = float(self.LoC.v_pid) controlsState.vCruise = float(self.v_cruise_kph) controlsState.upAccelCmd = float(self.LoC.pid.p) controlsState.uiAccelCmd = float(self.LoC.pid.i) controlsState.ufAccelCmd = float(self.LoC.pid.f) controlsState.cumLagMs = -self.rk.remaining * 1000. controlsState.startMonoTime = int(start_time * 1e9) controlsState.forceDecel = bool(force_decel) controlsState.canErrorCounter = self.can_error_counter # dp - RX Patch: https://github.com/LexusRXopenpilotUG/openpilot if self.dp_lexus_rx_rpm_fix: # Hack for reasonable gears/reasonable RPMs on Lexus RX. No upstreaming! # Setting speed may be iffy still if self.v_cruise_kph != 255: controlsState.vCruise = controlsState.vCruise * 0.974 # dp - for ui controlsState.angleSteers = CS.steeringAngleDeg controlsState.steeringAngleDesiredDeg = actuators.steeringAngleDeg if self.joystick_mode: controlsState.lateralControlState.debugState = lac_log elif self.CP.steerControlType == car.CarParams.SteerControlType.angle: controlsState.lateralControlState.angleState = lac_log elif self.CP.lateralTuning.which() == 'pid': controlsState.lateralControlState.pidState = lac_log elif self.CP.lateralTuning.which() == 'lqr': controlsState.lateralControlState.lqrState = lac_log elif self.CP.lateralTuning.which() == 'indi': controlsState.lateralControlState.indiState = lac_log self.pm.send('controlsState', dat) # carState car_events = self.events.to_msg() cs_send = messaging.new_message('carState') cs_send.valid = CS.canValid cs_send.carState = CS cs_send.carState.events = car_events self.pm.send('carState', cs_send) # carEvents - logged every second or on change if (self.sm.frame % int(1. / DT_CTRL) == 0) or (self.events.names != self.events_prev): ce_send = messaging.new_message('carEvents', len(self.events)) ce_send.carEvents = car_events self.pm.send('carEvents', ce_send) self.events_prev = self.events.names.copy() # carParams - logged every 50 seconds (> 1 per segment) if (self.sm.frame % int(50. / DT_CTRL) == 0): cp_send = messaging.new_message('carParams') cp_send.carParams = self.CP self.pm.send('carParams', cp_send) # carControl cc_send = messaging.new_message('carControl') cc_send.valid = CS.canValid cc_send.carControl = CC self.pm.send('carControl', cc_send) # copy CarControl to pass to CarInterface on the next iteration self.CC = CC def step(self): start_time = sec_since_boot() self.prof.checkpoint("Ratekeeper", ignore=True) # Sample data from sockets and get a carState CS = self.data_sample() self.prof.checkpoint("Sample") self.update_events(CS) if not self.read_only and self.initialized: # Update control state self.state_transition(CS) self.prof.checkpoint("State transition") # Compute actuators (runs PID loops and lateral MPC) actuators, lac_log = self.state_control(CS) self.prof.checkpoint("State Control") # Publish data self.publish_logs(CS, start_time, actuators, lac_log) self.prof.checkpoint("Sent") def controlsd_thread(self): while True: self.step() self.rk.monitor_time() self.prof.display() def main(sm=None, pm=None, logcan=None): controls = Controls(sm, pm, logcan) controls.controlsd_thread() if __name__ == "__main__": main() ================================================ FILE: selfdrive/controls/lib/__init__.py ================================================ ================================================ FILE: selfdrive/controls/lib/alertmanager.py ================================================ import os import copy import json from typing import List, Optional from cereal import car, log from common.basedir import BASEDIR from common.params import Params from common.realtime import DT_CTRL from selfdrive.controls.lib.events import Alert from selfdrive.swaglog import cloudlog with open(os.path.join(BASEDIR, "selfdrive/controls/lib/alerts_offroad.json")) as f: OFFROAD_ALERTS = json.load(f) def set_offroad_alert(alert: str, show_alert: bool, extra_text: Optional[str] = None) -> None: if show_alert: a = OFFROAD_ALERTS[alert] if extra_text is not None: a = copy.copy(OFFROAD_ALERTS[alert]) a['text'] += extra_text Params().put(alert, json.dumps(a)) else: Params().delete(alert) class AlertManager: def __init__(self): self.activealerts: List[Alert] = [] self.clear_current_alert() def clear_current_alert(self) -> None: self.alert_type: str = "" self.alert_text_1: str = "" self.alert_text_2: str = "" self.alert_status = log.ControlsState.AlertStatus.normal self.alert_size = log.ControlsState.AlertSize.none self.visual_alert = car.CarControl.HUDControl.VisualAlert.none self.audible_alert = car.CarControl.HUDControl.AudibleAlert.none self.alert_rate: float = 0. def add_many(self, frame: int, alerts: List[Alert], enabled: bool = True) -> None: for alert in alerts: added_alert = copy.copy(alert) added_alert.start_time = frame * DT_CTRL # if new alert is higher priority, log it if not len(self.activealerts) or added_alert.alert_priority > self.activealerts[0].alert_priority: cloudlog.event('alert_add', alert_type=added_alert.alert_type, enabled=enabled) self.activealerts.append(added_alert) def process_alerts(self, frame: int, clear_event_type=None) -> None: cur_time = frame * DT_CTRL # first get rid of all the expired alerts self.activealerts = [a for a in self.activealerts if a.event_type != clear_event_type and a.start_time + max(a.duration_sound, a.duration_hud_alert, a.duration_text) > cur_time] # sort by priority first and then by start_time self.activealerts.sort(key=lambda k: (k.alert_priority, k.start_time), reverse=True) # start with assuming no alerts self.clear_current_alert() if len(self.activealerts): current_alert = self.activealerts[0] self.alert_type = current_alert.alert_type if current_alert.start_time + current_alert.duration_sound > cur_time: self.audible_alert = current_alert.audible_alert if current_alert.start_time + current_alert.duration_hud_alert > cur_time: self.visual_alert = current_alert.visual_alert if current_alert.start_time + current_alert.duration_text > cur_time: self.alert_text_1 = current_alert.alert_text_1 self.alert_text_2 = current_alert.alert_text_2 self.alert_status = current_alert.alert_status self.alert_size = current_alert.alert_size self.alert_rate = current_alert.alert_rate ================================================ FILE: selfdrive/controls/lib/alerts_offroad.json ================================================ { "Offroad_ChargeDisabled": { "text": "EON charging disabled after car being off for more than 30 hours. Turn ignition on to start charging again.", "severity": 0 }, "Offroad_TemperatureTooHigh": { "text": "Device temperature too high. System won't start.", "severity": 1 }, "Offroad_ConnectivityNeededPrompt": { "text": "Immediately connect to the internet to check for updates. If you do not connect to the internet, openpilot won't engage in ", "severity": 0, "_comment": "Append the number of days at the end of the text" }, "Offroad_ConnectivityNeeded": { "text": "Connect to internet to check for updates. openpilot won't start until it connects to internet to check for updates.", "severity": 1 }, "Offroad_UpdateFailed": { "text": "Unable to download updates\n", "severity": 1, "_comment": "Append the command and error to the text." }, "Offroad_PandaFirmwareMismatch": { "text": "Unexpected panda firmware version. System won't start. Reboot your device to reflash panda.", "severity": 1 }, "Offroad_InvalidTime": { "text": "Invalid date and time settings, system won't start. Connect to internet to set time.", "severity": 1 }, "Offroad_IsTakingSnapshot": { "text": "Taking camera snapshots. System won't start until finished.", "severity": 0 }, "Offroad_NeosUpdate": { "text": "An update to your device's operating system is downloading in the background. You will be prompted to update when it's ready to install.", "severity": 0 }, "Offroad_HardwareUnsupported": { "text": "White and grey panda are unsupported. Upgrade to comma two or black panda.", "severity": 0 }, "Offroad_UnofficialHardware": { "text": "Device failed to register. It will not connect to or upload to comma.ai servers, and receives no support from comma.ai. If this is an official device, contact support@comma.ai.", "severity": 1 }, "Offroad_NvmeMissing": { "text": "NVME drive not mounted.", "severity": 1 } } ================================================ FILE: selfdrive/controls/lib/cluster/LICENSE ================================================ Copyright: * fastcluster_dm.cpp & fastcluster_R_dm.cpp: © 2011 Daniel Müllner * fastcluster.(h|cpp) & demo.cpp & plotresult.r: © 2018 Christoph Dalitz All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: selfdrive/controls/lib/cluster/README ================================================ C++ interface to fast hierarchical clustering algorithms ======================================================== This is a simplified C++ interface to fast implementations of hierarchical clustering by Daniel Müllner. The original library with interfaces to R and Python is described in: Daniel Müllner: "fastcluster: Fast Hierarchical, Agglomerative Clustering Routines for R and Python." Journal of Statistical Software 53 (2013), no. 9, pp. 1–18, http://www.jstatsoft.org/v53/i09/ Usage of the library -------------------- For using the library, the following source files are needed: fastcluster_dm.cpp, fastcluster_R_dm.cpp original code by Daniel Müllner these are included by fastcluster.cpp via #include, and therefore need not be compiled to object code fastcluster.[h|cpp] simplified C++ interface fastcluster.cpp is the only file that must be compiled The library provides the clustering function *hclust_fast* for creating the dendrogram information in an encoding as used by the R function *hclust*. For a description of the parameters, see fastcluster.h. Its parameter *method* can be one of HCLUST_METHOD_SINGLE single link with the minimum spanning tree algorithm (Rohlf, 1973) HHCLUST_METHOD_COMPLETE complete link with the nearest-neighbor-chain algorithm (Murtagh, 1984) HCLUST_METHOD_AVERAGE complete link with the nearest-neighbor-chain algorithm (Murtagh, 1984) HCLUST_METHOD_MEDIAN median link with the generic algorithm (Müllner, 2011) For splitting the dendrogram into clusters, the two functions *cutree_k* and *cutree_cdist* are provided. Note that output parameters must be allocated beforehand, e.g. int* merge = new int[2*(npoints-1)]; For a complete usage example, see lines 135-142 of demo.cpp. Demonstration program --------------------- A simple demo is implemented in demo.cpp, which can be compiled and run with make ./hclust-demo -m complete lines.csv It creates two clusters of line segments such that the segment angle between line segments of different clusters have a maximum (cosine) dissimilarity. For visualizing the result, plotresult.r can be used as follows (requires R to be installed): ./hclust-demo -m complete lines.csv | Rscript plotresult.r Authors & Copyright ------------------- Daniel Müllner, 2011, Christoph Dalitz, 2018, License ------- This code is provided under a BSD-style license. See the file LICENSE for details. ================================================ FILE: selfdrive/controls/lib/cluster/SConscript ================================================ Import('env') fc = env.SharedLibrary("fastcluster", "fastcluster.cpp") # TODO: how do I gate on test #env.Program("test", ["test.cpp"], LIBS=[fc]) #valgrind --leak-check=full ./test ================================================ FILE: selfdrive/controls/lib/cluster/__init__.py ================================================ ================================================ FILE: selfdrive/controls/lib/cluster/fastcluster.cpp ================================================ // // C++ standalone verion of fastcluster by Daniel Müllner // // Copyright: Christoph Dalitz, 2018 // Daniel Müllner, 2011 // License: BSD style license // (see the file LICENSE for details) // #include #include #include extern "C" { #include "fastcluster.h" } // Code by Daniel Müllner // workaround to make it usable as a standalone version (without R) bool fc_isnan(double x) { return false; } #include "fastcluster_dm.cpp" #include "fastcluster_R_dm.cpp" extern "C" { // // Assigns cluster labels (0, ..., nclust-1) to the n points such // that the cluster result is split into nclust clusters. // // Input arguments: // n = number of observables // merge = clustering result in R format // nclust = number of clusters // Output arguments: // labels = allocated integer array of size n for result // void cutree_k(int n, const int* merge, int nclust, int* labels) { int k,m1,m2,j,l; if (nclust > n || nclust < 2) { for (j=0; j last_merge(n, 0); for (k=1; k<=(n-nclust); k++) { // (m1,m2) = merge[k,] m1 = merge[k-1]; m2 = merge[n-1+k-1]; if (m1 < 0 && m2 < 0) { // both single observables last_merge[-m1-1] = last_merge[-m2-1] = k; } else if (m1 < 0 || m2 < 0) { // one is a cluster if(m1 < 0) { j = -m1; m1 = m2; } else j = -m2; // merging single observable and cluster for(l = 0; l < n; l++) if (last_merge[l] == m1) last_merge[l] = k; last_merge[j-1] = k; } else { // both cluster for(l=0; l < n; l++) { if( last_merge[l] == m1 || last_merge[l] == m2 ) last_merge[l] = k; } } } // assign cluster labels int label = 0; std::vector z(n,-1); for (j=0; j= cdist // // Input arguments: // n = number of observables // merge = clustering result in R format // height = cluster distance at each merge step // cdist = cutoff cluster distance // Output arguments: // labels = allocated integer array of size n for result // void cutree_cdist(int n, const int* merge, double* height, double cdist, int* labels) { int k; for (k=0; k<(n-1); k++) { if (height[k] >= cdist) { break; } } cutree_k(n, merge, n-k, labels); } // // Hierarchical clustering with one of Daniel Muellner's fast algorithms // // Input arguments: // n = number of observables // distmat = condensed distance matrix, i.e. an n*(n-1)/2 array representing // the upper triangle (without diagonal elements) of the distance // matrix, e.g. for n=4: // d00 d01 d02 d03 // d10 d11 d12 d13 -> d01 d02 d03 d12 d13 d23 // d20 d21 d22 d23 // d30 d31 d32 d33 // method = cluster metric (see enum method_code) // Output arguments: // merge = allocated (n-1)x2 matrix (2*(n-1) array) for storing result. // Result follows R hclust convention: // - observabe indices start with one // - merge[i][] contains the merged nodes in step i // - merge[i][j] is negative when the node is an atom // height = allocated (n-1) array with distances at each merge step // Return code: // 0 = ok // 1 = invalid method // int hclust_fast(int n, double* distmat, int method, int* merge, double* height) { // call appropriate culstering function cluster_result Z2(n-1); if (method == HCLUST_METHOD_SINGLE) { // single link MST_linkage_core(n, distmat, Z2); } else if (method == HCLUST_METHOD_COMPLETE) { // complete link NN_chain_core(n, distmat, NULL, Z2); } else if (method == HCLUST_METHOD_AVERAGE) { // best average distance double* members = new double[n]; for (int i=0; i(n, distmat, members, Z2); delete[] members; } else if (method == HCLUST_METHOD_MEDIAN) { // best median distance (beware: O(n^3)) generic_linkage(n, distmat, NULL, Z2); } else if (method == HCLUST_METHOD_CENTROID) { // best centroid distance (beware: O(n^3)) double* members = new double[n]; for (int i=0; i(n, distmat, members, Z2); delete[] members; } else { return 1; } int* order = new int[n]; if (method == HCLUST_METHOD_MEDIAN || method == HCLUST_METHOD_CENTROID) { generate_R_dendrogram(merge, height, order, Z2, n); } else { generate_R_dendrogram(merge, height, order, Z2, n); } delete[] order; // only needed for visualization return 0; } // Build condensed distance matrix // Input arguments: // n = number of observables // m = dimension of observable // Output arguments: // out = allocated integer array of size n * (n - 1) / 2 for result void hclust_pdist(int n, int m, double* pts, double* out) { int ii = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { // Compute euclidian distance double d = 0; for (int k = 0; k < m; k ++) { double error = pts[i * m + k] - pts[j * m + k]; d += (error * error); } out[ii] = d;//sqrt(d); ii++; } } } void cluster_points_centroid(int n, int m, double* pts, double dist, int* idx) { double* pdist = new double[n * (n - 1) / 2]; int* merge = new int[2 * (n - 1)]; double* height = new double[n - 1]; hclust_pdist(n, m, pts, pdist); hclust_fast(n, pdist, HCLUST_METHOD_CENTROID, merge, height); cutree_cdist(n, merge, height, dist, idx); delete[] pdist; delete[] merge; delete[] height; } } ================================================ FILE: selfdrive/controls/lib/cluster/fastcluster.h ================================================ // // C++ standalone verion of fastcluster by Daniel Muellner // // Copyright: Daniel Muellner, 2011 // Christoph Dalitz, 2018 // License: BSD style license // (see the file LICENSE for details) // #ifndef fastclustercpp_H #define fastclustercpp_H // // Assigns cluster labels (0, ..., nclust-1) to the n points such // that the cluster result is split into nclust clusters. // // Input arguments: // n = number of observables // merge = clustering result in R format // nclust = number of clusters // Output arguments: // labels = allocated integer array of size n for result // void cutree_k(int n, const int* merge, int nclust, int* labels); // // Assigns cluster labels (0, ..., nclust-1) to the n points such // that the hierarchical clsutering is stopped at cluster distance cdist // // Input arguments: // n = number of observables // merge = clustering result in R format // height = cluster distance at each merge step // cdist = cutoff cluster distance // Output arguments: // labels = allocated integer array of size n for result // void cutree_cdist(int n, const int* merge, double* height, double cdist, int* labels); // // Hierarchical clustering with one of Daniel Muellner's fast algorithms // // Input arguments: // n = number of observables // distmat = condensed distance matrix, i.e. an n*(n-1)/2 array representing // the upper triangle (without diagonal elements) of the distance // matrix, e.g. for n=4: // d00 d01 d02 d03 // d10 d11 d12 d13 -> d01 d02 d03 d12 d13 d23 // d20 d21 d22 d23 // d30 d31 d32 d33 // method = cluster metric (see enum method_code) // Output arguments: // merge = allocated (n-1)x2 matrix (2*(n-1) array) for storing result. // Result follows R hclust convention: // - observabe indices start with one // - merge[i][] contains the merged nodes in step i // - merge[i][j] is negative when the node is an atom // height = allocated (n-1) array with distances at each merge step // Return code: // 0 = ok // 1 = invalid method // int hclust_fast(int n, double* distmat, int method, int* merge, double* height); enum hclust_fast_methods { HCLUST_METHOD_SINGLE = 0, HCLUST_METHOD_COMPLETE = 1, HCLUST_METHOD_AVERAGE = 2, HCLUST_METHOD_MEDIAN = 3, HCLUST_METHOD_CENTROID = 5, }; void hclust_pdist(int n, int m, double* pts, double* out); void cluster_points_centroid(int n, int m, double* pts, double dist, int* idx); #endif ================================================ FILE: selfdrive/controls/lib/cluster/fastcluster_R_dm.cpp ================================================ // // Excerpt from fastcluster_R.cpp // // Copyright: Daniel Müllner, 2011 // struct pos_node { t_index pos; int node; }; void order_nodes(const int N, const int * const merge, const t_index * const node_size, int * const order) { /* Parameters: N : number of data points merge : (N-1)×2 array which specifies the node indices which are merged in each step of the clustering procedure. Negative entries -1...-N point to singleton nodes, while positive entries 1...(N-1) point to nodes which are themselves parents of other nodes. node_size : array of node sizes - makes it easier order : output array of size N Runtime: Θ(N) */ auto_array_ptr queue(N/2); int parent; int child; t_index pos = 0; queue[0].pos = 0; queue[0].node = N-2; t_index idx = 1; do { --idx; pos = queue[idx].pos; parent = queue[idx].node; // First child child = merge[parent]; if (child<0) { // singleton node, write this into the 'order' array. order[pos] = -child; ++pos; } else { /* compound node: put it on top of the queue and decompose it in a later iteration. */ queue[idx].pos = pos; queue[idx].node = child-1; // convert index-1 based to index-0 based ++idx; pos += node_size[child-1]; } // Second child child = merge[parent+N-1]; if (child<0) { order[pos] = -child; } else { queue[idx].pos = pos; queue[idx].node = child-1; ++idx; } } while (idx>0); } #define size_(r_) ( ((r_ void generate_R_dendrogram(int * const merge, double * const height, int * const order, cluster_result & Z2, const int N) { // The array "nodes" is a union-find data structure for the cluster // identites (only needed for unsorted cluster_result input). union_find nodes(sorted ? 0 : N); if (!sorted) { std::stable_sort(Z2[0], Z2[N-1]); } t_index node1, node2; auto_array_ptr node_size(N-1); for (t_index i=0; inode1; node2 = Z2[i]->node2; } else { node1 = nodes.Find(Z2[i]->node1); node2 = nodes.Find(Z2[i]->node2); // Merge the nodes in the union-find data structure by making them // children of a new node. nodes.Union(node1, node2); } // Sort the nodes in the output array. if (node1>node2) { t_index tmp = node1; node1 = node2; node2 = tmp; } /* Conversion between labeling conventions. Input: singleton nodes 0,...,N-1 compound nodes N,...,2N-2 Output: singleton nodes -1,...,-N compound nodes 1,...,N */ merge[i] = (node1(node1)-1 : static_cast(node1)-N+1; merge[i+N-1] = (node2(node2)-1 : static_cast(node2)-N+1; height[i] = Z2[i]->dist; node_size[i] = size_(node1) + size_(node2); } order_nodes(N, merge, node_size, order); } ================================================ FILE: selfdrive/controls/lib/cluster/fastcluster_dm.cpp ================================================ /* fastcluster: Fast hierarchical clustering routines for R and Python Copyright © 2011 Daniel Müllner This library implements various fast algorithms for hierarchical, agglomerative clustering methods: (1) Algorithms for the "stored matrix approach": the input is the array of pairwise dissimilarities. MST_linkage_core: single linkage clustering with the "minimum spanning tree algorithm (Rohlfs) NN_chain_core: nearest-neighbor-chain algorithm, suitable for single, complete, average, weighted and Ward linkage (Murtagh) generic_linkage: generic algorithm, suitable for all distance update formulas (Müllner) (2) Algorithms for the "stored data approach": the input are points in a vector space. MST_linkage_core_vector: single linkage clustering for vector data generic_linkage_vector: generic algorithm for vector data, suitable for the Ward, centroid and median methods. generic_linkage_vector_alternative: alternative scheme for updating the nearest neighbors. This method seems faster than "generic_linkage_vector" for the centroid and median methods but slower for the Ward method. All these implementation treat infinity values correctly. They throw an exception if a NaN distance value occurs. */ // Older versions of Microsoft Visual Studio do not have the fenv header. #ifdef _MSC_VER #if (_MSC_VER == 1500 || _MSC_VER == 1600) #define NO_INCLUDE_FENV #endif #endif // NaN detection via fenv might not work on systems with software // floating-point emulation (bug report for Debian armel). #ifdef __SOFTFP__ #define NO_INCLUDE_FENV #endif #ifdef NO_INCLUDE_FENV #pragma message("Do not use fenv header.") #else //#pragma message("Use fenv header. If there is a warning about unknown #pragma STDC FENV_ACCESS, this can be ignored.") //#pragma STDC FENV_ACCESS on #include #endif #include // for std::pow, std::sqrt #include // for std::ptrdiff_t #include // for std::numeric_limits<...>::infinity() #include // for std::fill_n #include // for std::runtime_error #include // for std::string #include // also for DBL_MAX, DBL_MIN #ifndef DBL_MANT_DIG #error The constant DBL_MANT_DIG could not be defined. #endif #define T_FLOAT_MANT_DIG DBL_MANT_DIG #ifndef LONG_MAX #include #endif #ifndef LONG_MAX #error The constant LONG_MAX could not be defined. #endif #ifndef INT_MAX #error The constant INT_MAX could not be defined. #endif #ifndef INT32_MAX #ifdef _MSC_VER #if _MSC_VER >= 1600 #define __STDC_LIMIT_MACROS #include #else typedef __int32 int_fast32_t; typedef __int64 int64_t; #endif #else #define __STDC_LIMIT_MACROS #include #endif #endif #define FILL_N std::fill_n #ifdef _MSC_VER #if _MSC_VER < 1600 #undef FILL_N #define FILL_N stdext::unchecked_fill_n #endif #endif // Suppress warnings about (potentially) uninitialized variables. #ifdef _MSC_VER #pragma warning (disable:4700) #endif #ifndef HAVE_DIAGNOSTIC #if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6)) #define HAVE_DIAGNOSTIC 1 #endif #endif #ifndef HAVE_VISIBILITY #if __GNUC__ >= 4 #define HAVE_VISIBILITY 1 #endif #endif /* Since the public interface is given by the Python respectively R interface, * we do not want other symbols than the interface initalization routines to be * visible in the shared object file. The "visibility" switch is a GCC concept. * Hiding symbols keeps the relocation table small and decreases startup time. * See http://gcc.gnu.org/wiki/Visibility */ #if HAVE_VISIBILITY #pragma GCC visibility push(hidden) #endif typedef int_fast32_t t_index; #ifndef INT32_MAX #define MAX_INDEX 0x7fffffffL #else #define MAX_INDEX INT32_MAX #endif #if (LONG_MAX < MAX_INDEX) #error The integer format "t_index" must not have a greater range than "long int". #endif #if (INT_MAX > MAX_INDEX) #error The integer format "int" must not have a greater range than "t_index". #endif typedef double t_float; /* Method codes. These codes must agree with the METHODS array in fastcluster.R and the dictionary mthidx in fastcluster.py. */ enum method_codes { // non-Euclidean methods METHOD_METR_SINGLE = 0, METHOD_METR_COMPLETE = 1, METHOD_METR_AVERAGE = 2, METHOD_METR_WEIGHTED = 3, METHOD_METR_WARD = 4, METHOD_METR_WARD_D = METHOD_METR_WARD, METHOD_METR_CENTROID = 5, METHOD_METR_MEDIAN = 6, METHOD_METR_WARD_D2 = 7, MIN_METHOD_CODE = 0, MAX_METHOD_CODE = 7 }; enum method_codes_vector { // Euclidean methods METHOD_VECTOR_SINGLE = 0, METHOD_VECTOR_WARD = 1, METHOD_VECTOR_CENTROID = 2, METHOD_VECTOR_MEDIAN = 3, MIN_METHOD_VECTOR_CODE = 0, MAX_METHOD_VECTOR_CODE = 3 }; // self-destructing array pointer template class auto_array_ptr{ private: type * ptr; auto_array_ptr(auto_array_ptr const &); // non construction-copyable auto_array_ptr& operator=(auto_array_ptr const &); // non copyable public: auto_array_ptr() : ptr(NULL) { } template auto_array_ptr(index const size) : ptr(new type[size]) { } template auto_array_ptr(index const size, value const val) : ptr(new type[size]) { FILL_N(ptr, size, val); } ~auto_array_ptr() { delete [] ptr; } void free() { delete [] ptr; ptr = NULL; } template void init(index const size) { ptr = new type [size]; } template void init(index const size, value const val) { init(size); FILL_N(ptr, size, val); } inline operator type *() const { return ptr; } }; struct node { t_index node1, node2; t_float dist; }; inline bool operator< (const node a, const node b) { return (a.dist < b.dist); } class cluster_result { private: auto_array_ptr Z; t_index pos; public: cluster_result(const t_index size) : Z(size) , pos(0) {} void append(const t_index node1, const t_index node2, const t_float dist) { Z[pos].node1 = node1; Z[pos].node2 = node2; Z[pos].dist = dist; ++pos; } node * operator[] (const t_index idx) const { return Z + idx; } /* Define several methods to postprocess the distances. All these functions are monotone, so they do not change the sorted order of distances. */ void sqrt() const { for (node * ZZ=Z; ZZ!=Z+pos; ++ZZ) { ZZ->dist = std::sqrt(ZZ->dist); } } void sqrt(const t_float) const { // ignore the argument sqrt(); } void sqrtdouble(const t_float) const { // ignore the argument for (node * ZZ=Z; ZZ!=Z+pos; ++ZZ) { ZZ->dist = std::sqrt(2*ZZ->dist); } } #ifdef R_pow #define my_pow R_pow #else #define my_pow std::pow #endif void power(const t_float p) const { t_float const q = 1/p; for (node * ZZ=Z; ZZ!=Z+pos; ++ZZ) { ZZ->dist = my_pow(ZZ->dist,q); } } void plusone(const t_float) const { // ignore the argument for (node * ZZ=Z; ZZ!=Z+pos; ++ZZ) { ZZ->dist += 1; } } void divide(const t_float denom) const { for (node * ZZ=Z; ZZ!=Z+pos; ++ZZ) { ZZ->dist /= denom; } } }; class doubly_linked_list { /* Class for a doubly linked list. Initially, the list is the integer range [0, size]. We provide a forward iterator and a method to delete an index from the list. Typical use: for (i=L.start; L succ; private: auto_array_ptr pred; // Not necessarily private, we just do not need it in this instance. public: doubly_linked_list(const t_index size) // Initialize to the given size. : start(0) , succ(size+1) , pred(size+1) { for (t_index i=0; i(2*N-3-(r_))*(r_)>>1)+(c_)-1] ) // Z is an ((N-1)x4)-array #define Z_(_r, _c) (Z[(_r)*4 + (_c)]) /* Lookup function for a union-find data structure. The function finds the root of idx by going iteratively through all parent elements until a root is found. An element i is a root if nodes[i] is zero. To make subsequent searches faster, the entry for idx and all its parents is updated with the root element. */ class union_find { private: auto_array_ptr parent; t_index nextparent; public: union_find(const t_index size) : parent(size>0 ? 2*size-1 : 0, 0) , nextparent(size) { } t_index Find (t_index idx) const { if (parent[idx] != 0 ) { // a → b t_index p = idx; idx = parent[idx]; if (parent[idx] != 0 ) { // a → b → c do { idx = parent[idx]; } while (parent[idx] != 0); do { t_index tmp = parent[p]; parent[p] = idx; p = tmp; } while (parent[p] != idx); } } return idx; } void Union (const t_index node1, const t_index node2) { parent[node1] = parent[node2] = nextparent++; } }; class nan_error{}; #ifdef FE_INVALID class fenv_error{}; #endif static void MST_linkage_core(const t_index N, const t_float * const D, cluster_result & Z2) { /* N: integer, number of data points D: condensed distance matrix N*(N-1)/2 Z2: output data structure The basis of this algorithm is an algorithm by Rohlf: F. James Rohlf, Hierarchical clustering using the minimum spanning tree, The Computer Journal, vol. 16, 1973, p. 93–95. */ t_index i; t_index idx2; doubly_linked_list active_nodes(N); auto_array_ptr d(N); t_index prev_node; t_float min; // first iteration idx2 = 1; min = std::numeric_limits::infinity(); for (i=1; i tmp) d[i] = tmp; else if (fc_isnan(tmp)) throw (nan_error()); #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif if (d[i] < min) { min = d[i]; idx2 = i; } } Z2.append(prev_node, idx2, min); } } /* Functions for the update of the dissimilarity array */ inline static void f_single( t_float * const b, const t_float a ) { if (*b > a) *b = a; } inline static void f_complete( t_float * const b, const t_float a ) { if (*b < a) *b = a; } inline static void f_average( t_float * const b, const t_float a, const t_float s, const t_float t) { *b = s*a + t*(*b); #ifndef FE_INVALID #if HAVE_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif if (fc_isnan(*b)) { throw(nan_error()); } #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif #endif } inline static void f_weighted( t_float * const b, const t_float a) { *b = (a+*b)*.5; #ifndef FE_INVALID #if HAVE_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif if (fc_isnan(*b)) { throw(nan_error()); } #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif #endif } inline static void f_ward( t_float * const b, const t_float a, const t_float c, const t_float s, const t_float t, const t_float v) { *b = ( (v+s)*a - v*c + (v+t)*(*b) ) / (s+t+v); //*b = a+(*b)-(t*a+s*(*b)+v*c)/(s+t+v); #ifndef FE_INVALID #if HAVE_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif if (fc_isnan(*b)) { throw(nan_error()); } #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif #endif } inline static void f_centroid( t_float * const b, const t_float a, const t_float stc, const t_float s, const t_float t) { *b = s*a - stc + t*(*b); #ifndef FE_INVALID if (fc_isnan(*b)) { throw(nan_error()); } #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif #endif } inline static void f_median( t_float * const b, const t_float a, const t_float c_4) { *b = (a+(*b))*.5 - c_4; #ifndef FE_INVALID #if HAVE_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif if (fc_isnan(*b)) { throw(nan_error()); } #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif #endif } template static void NN_chain_core(const t_index N, t_float * const D, t_members * const members, cluster_result & Z2) { /* N: integer D: condensed distance matrix N*(N-1)/2 Z2: output data structure This is the NN-chain algorithm, described on page 86 in the following book: Fionn Murtagh, Multidimensional Clustering Algorithms, Vienna, Würzburg: Physica-Verlag, 1985. */ t_index i; auto_array_ptr NN_chain(N); t_index NN_chain_tip = 0; t_index idx1, idx2; t_float size1, size2; doubly_linked_list active_nodes(N); t_float min; for (t_float const * DD=D; DD!=D+(static_cast(N)*(N-1)>>1); ++DD) { #if HAVE_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif if (fc_isnan(*DD)) { throw(nan_error()); } #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif } #ifdef FE_INVALID if (feclearexcept(FE_INVALID)) throw fenv_error(); #endif for (t_index j=0; jidx2) { t_index tmp = idx1; idx1 = idx2; idx2 = tmp; } if (method==METHOD_METR_AVERAGE || method==METHOD_METR_WARD) { size1 = static_cast(members[idx1]); size2 = static_cast(members[idx2]); members[idx2] += members[idx1]; } // Remove the smaller index from the valid indices (active_nodes). active_nodes.remove(idx1); switch (method) { case METHOD_METR_SINGLE: /* Single linkage. Characteristic: new distances are never longer than the old distances. */ // Update the distance matrix in the range [start, idx1). for (i=active_nodes.start; i(members[i]); for (i=active_nodes.start; i(members[i]) ); // Update the distance matrix in the range (idx1, idx2). for (; i(members[i]) ); // Update the distance matrix in the range (idx2, N). for (i=active_nodes.succ[idx2]; i(members[i]) ); break; default: throw std::runtime_error(std::string("Invalid method.")); } } #ifdef FE_INVALID if (fetestexcept(FE_INVALID)) throw fenv_error(); #endif } class binary_min_heap { /* Class for a binary min-heap. The data resides in an array A. The elements of A are not changed but two lists I and R of indices are generated which point to elements of A and backwards. The heap tree structure is H[2*i+1] H[2*i+2] \ / \ / ≤ ≤ \ / \ / H[i] where the children must be less or equal than their parent. Thus, H[0] contains the minimum. The lists I and R are made such that H[i] = A[I[i]] and R[I[i]] = i. This implementation is not designed to handle NaN values. */ private: t_float * const A; t_index size; auto_array_ptr I; auto_array_ptr R; // no default constructor binary_min_heap(); // noncopyable binary_min_heap(binary_min_heap const &); binary_min_heap & operator=(binary_min_heap const &); public: binary_min_heap(t_float * const A_, const t_index size_) : A(A_), size(size_), I(size), R(size) { // Allocate memory and initialize the lists I and R to the identity. This // does not make it a heap. Call heapify afterwards! for (t_index i=0; i>1); idx>0; ) { --idx; update_geq_(idx); } } inline t_index argmin() const { // Return the minimal element. return I[0]; } void heap_pop() { // Remove the minimal element from the heap. --size; I[0] = I[size]; R[I[0]] = 0; update_geq_(0); } void remove(t_index idx) { // Remove an element from the heap. --size; R[I[size]] = R[idx]; I[R[idx]] = I[size]; if ( H(size)<=A[idx] ) { update_leq_(R[idx]); } else { update_geq_(R[idx]); } } void replace ( const t_index idxold, const t_index idxnew, const t_float val) { R[idxnew] = R[idxold]; I[R[idxnew]] = idxnew; if (val<=A[idxold]) update_leq(idxnew, val); else update_geq(idxnew, val); } void update ( const t_index idx, const t_float val ) const { // Update the element A[i] with val and re-arrange the indices to preserve // the heap condition. if (val<=A[idx]) update_leq(idx, val); else update_geq(idx, val); } void update_leq ( const t_index idx, const t_float val ) const { // Use this when the new value is not more than the old value. A[idx] = val; update_leq_(R[idx]); } void update_geq ( const t_index idx, const t_float val ) const { // Use this when the new value is not less than the old value. A[idx] = val; update_geq_(R[idx]); } private: void update_leq_ (t_index i) const { t_index j; for ( ; (i>0) && ( H(i)>1) ); i=j) heap_swap(i,j); } void update_geq_ (t_index i) const { t_index j; for ( ; (j=2*i+1)=H(i) ) { ++j; if ( j>=size || H(j)>=H(i) ) break; } else if ( j+1 static void generic_linkage(const t_index N, t_float * const D, t_members * const members, cluster_result & Z2) { /* N: integer, number of data points D: condensed distance matrix N*(N-1)/2 Z2: output data structure */ const t_index N_1 = N-1; t_index i, j; // loop variables t_index idx1, idx2; // row and column indices auto_array_ptr n_nghbr(N_1); // array of nearest neighbors auto_array_ptr mindist(N_1); // distances to the nearest neighbors auto_array_ptr row_repr(N); // row_repr[i]: node number that the // i-th row represents doubly_linked_list active_nodes(N); binary_min_heap nn_distances(&*mindist, N_1); // minimum heap structure for // the distance to the nearest neighbor of each point t_index node1, node2; // node numbers in the output t_float size1, size2; // and their cardinalities t_float min; // minimum and row index for nearest-neighbor search t_index idx; for (i=0; ii} D(i,j) for i in range(N-1) t_float const * DD = D; for (i=0; i::infinity(); for (idx=j=i+1; ji} D(i,j) Normally, we have equality. However, this minimum may become invalid due to the updates in the distance matrix. The rules are: 1) If mindist[i] is equal to D(i, n_nghbr[i]), this is the correct minimum and n_nghbr[i] is a nearest neighbor. 2) If mindist[i] is smaller than D(i, n_nghbr[i]), this might not be the correct minimum. The minimum needs to be recomputed. 3) mindist[i] is never bigger than the true minimum. Hence, we never miss the true minimum if we take the smallest mindist entry, re-compute the value if necessary (thus maybe increasing it) and looking for the now smallest mindist entry until a valid minimal entry is found. This step is done in the lines below. The update process for D below takes care that these rules are fulfilled. This makes sure that the minima in the rows D(i,i+1:)of D are re-calculated when necessary but re-calculation is avoided whenever possible. The re-calculation of the minima makes the worst-case runtime of this algorithm cubic in N. We avoid this whenever possible, and in most cases the runtime appears to be quadratic. */ idx1 = nn_distances.argmin(); if (method != METHOD_METR_SINGLE) { while ( mindist[idx1] < D_(idx1, n_nghbr[idx1]) ) { // Recompute the minimum mindist[idx1] and n_nghbr[idx1]. n_nghbr[idx1] = j = active_nodes.succ[idx1]; // exists, maximally N-1 min = D_(idx1,j); for (j=active_nodes.succ[j]; j(members[idx1]); size2 = static_cast(members[idx2]); members[idx2] += members[idx1]; } Z2.append(node1, node2, mindist[idx1]); // Remove idx1 from the list of active indices (active_nodes). active_nodes.remove(idx1); // Index idx2 now represents the new (merged) node with label N+i. row_repr[idx2] = N+i; // Update the distance matrix switch (method) { case METHOD_METR_SINGLE: /* Single linkage. Characteristic: new distances are never longer than the old distances. */ // Update the distance matrix in the range [start, idx1). for (j=active_nodes.start; j(members[j]) ); if (n_nghbr[j] == idx1) n_nghbr[j] = idx2; } // Update the distance matrix in the range (idx1, idx2). for (; j(members[j]) ); if (D_(j, idx2) < mindist[j]) { nn_distances.update_leq(j, D_(j, idx2)); n_nghbr[j] = idx2; } } // Update the distance matrix in the range (idx2, N). if (idx2(members[j]) ); min = D_(idx2,j); for (j=active_nodes.succ[j]; j(members[j]) ); if (D_(idx2,j) < min) { min = D_(idx2,j); n_nghbr[idx2] = j; } } nn_distances.update(idx2, min); } break; case METHOD_METR_CENTROID: { /* Centroid linkage. Shorter and longer distances can occur, not bigger than max(d1,d2) but maybe smaller than min(d1,d2). */ // Update the distance matrix in the range [start, idx1). t_float s = size1/(size1+size2); t_float t = size2/(size1+size2); t_float stc = s*t*mindist[idx1]; for (j=active_nodes.start; j static void MST_linkage_core_vector(const t_index N, t_dissimilarity & dist, cluster_result & Z2) { /* N: integer, number of data points dist: function pointer to the metric Z2: output data structure The basis of this algorithm is an algorithm by Rohlf: F. James Rohlf, Hierarchical clustering using the minimum spanning tree, The Computer Journal, vol. 16, 1973, p. 93–95. */ t_index i; t_index idx2; doubly_linked_list active_nodes(N); auto_array_ptr d(N); t_index prev_node; t_float min; // first iteration idx2 = 1; min = std::numeric_limits::infinity(); for (i=1; i tmp) d[i] = tmp; else if (fc_isnan(tmp)) throw (nan_error()); #if HAVE_DIAGNOSTIC #pragma GCC diagnostic pop #endif if (d[i] < min) { min = d[i]; idx2 = i; } } Z2.append(prev_node, idx2, min); } } template static void generic_linkage_vector(const t_index N, t_dissimilarity & dist, cluster_result & Z2) { /* N: integer, number of data points dist: function pointer to the metric Z2: output data structure This algorithm is valid for the distance update methods "Ward", "centroid" and "median" only! */ const t_index N_1 = N-1; t_index i, j; // loop variables t_index idx1, idx2; // row and column indices auto_array_ptr n_nghbr(N_1); // array of nearest neighbors auto_array_ptr mindist(N_1); // distances to the nearest neighbors auto_array_ptr row_repr(N); // row_repr[i]: node number that the // i-th row represents doubly_linked_list active_nodes(N); binary_min_heap nn_distances(&*mindist, N_1); // minimum heap structure for // the distance to the nearest neighbor of each point t_index node1, node2; // node numbers in the output t_float min; // minimum and row index for nearest-neighbor search for (i=0; ii} D(i,j) for i in range(N-1) for (i=0; i::infinity(); t_index idx; for (idx=j=i+1; j(i,j); } if (tmp(idx1,j); for (j=active_nodes.succ[j]; j(idx1,j); if (tmp(j, idx2); if (tmp < mindist[j]) { nn_distances.update_leq(j, tmp); n_nghbr[j] = idx2; } else if (n_nghbr[j] == idx2) n_nghbr[j] = idx1; // invalidate } // Find the nearest neighbor for idx2. if (idx2(idx2,j); for (j=active_nodes.succ[j]; j(idx2, j); if (tmp < min) { min = tmp; n_nghbr[idx2] = j; } } nn_distances.update(idx2, min); } } } } template static void generic_linkage_vector_alternative(const t_index N, t_dissimilarity & dist, cluster_result & Z2) { /* N: integer, number of data points dist: function pointer to the metric Z2: output data structure This algorithm is valid for the distance update methods "Ward", "centroid" and "median" only! */ const t_index N_1 = N-1; t_index i, j=0; // loop variables t_index idx1, idx2; // row and column indices auto_array_ptr n_nghbr(2*N-2); // array of nearest neighbors auto_array_ptr mindist(2*N-2); // distances to the nearest neighbors doubly_linked_list active_nodes(N+N_1); binary_min_heap nn_distances(&*mindist, N_1, 2*N-2, 1); // minimum heap // structure for the distance to the nearest neighbor of each point t_float min; // minimum for nearest-neighbor searches // Initialize the minimal distances: // Find the nearest neighbor of each point. // n_nghbr[i] = argmin_{j>i} D(i,j) for i in range(N-1) for (i=1; i::infinity(); t_index idx; for (idx=j=0; j(i,j); } if (tmp extern "C" { #include "fastcluster.h" } int main(int argc, const char* argv[]) { const int n = 11; const int m = 3; double* pts = new double[n*m]{59.26000137, -9.35999966, -5.42500019, 91.61999817, -0.31999999, -2.75, 31.38000031, 0.40000001, -0.2, 89.57999725, -8.07999992, -18.04999924, 53.42000122, 0.63999999, -0.175, 31.38000031, 0.47999999, -0.2, 36.33999939, 0.16, -0.2, 53.33999939, 0.95999998, -0.175, 59.26000137, -9.76000023, -5.44999981, 33.93999977, 0.40000001, -0.22499999, 106.74000092, -5.76000023, -18.04999924}; int * idx = new int[n]; int * correct_idx = new int[n]{0, 1, 2, 3, 4, 2, 5, 4, 0, 5, 6}; cluster_points_centroid(n, m, pts, 2.5 * 2.5, idx); for (int i = 0; i < n; i++) { assert(idx[i] == correct_idx[i]); } delete[] idx; delete[] correct_idx; delete[] pts; } ================================================ FILE: selfdrive/controls/lib/drive_helpers.py ================================================ from cereal import car from common.numpy_fast import clip, interp from common.realtime import DT_MDL from selfdrive.config import Conversions as CV from selfdrive.modeld.constants import T_IDXS # kph V_CRUISE_MAX = 135 V_CRUISE_MIN = 8 V_CRUISE_DELTA = 8 V_CRUISE_ENABLE_MIN = 40 LAT_MPC_N = 16 LON_MPC_N = 32 CONTROL_N = 17 CAR_ROTATION_RADIUS = 0.0 # this corresponds to 80deg/s and 20deg/s steering angle in a toyota corolla MAX_CURVATURE_RATES = [0.03762194918267951, 0.003441203371932992] MAX_CURVATURE_RATE_SPEEDS = [0, 35] # Constants for Limit controllers. LIMIT_ADAPT_ACC = -0.6 # (closer to zero ealier it decel) m/s^2 Ideal acceleration for the adapting (braking) phase when approaching speed limits. LIMIT_MIN_ACC = -1.0 # m/s^2 Maximum deceleration allowed for limit controllers to provide. LIMIT_MAX_ACC = 1.0 # m/s^2 Maximum acelration allowed for limit controllers to provide while active. LIMIT_MIN_SPEED = 8.33 # m/s, Minimum speed limit to provide as solution on limit controllers. LIMIT_SPEED_OFFSET_TH = -1. # m/s Maximum offset between speed limit and current speed for adapting state. LIMIT_MAX_MAP_DATA_AGE = 10. # s Maximum time to hold to map data, then consider it invalid inside limits controllers. class MPC_COST_LAT: PATH = 1.0 HEADING = 1.0 STEER_RATE = 1.0 class MPC_COST_LONG: TTC = 5.5 DISTANCE = 0.1 ACCELERATION = 10.0 JERK = 20.0 def rate_limit(new_value, last_value, dw_step, up_step): return clip(new_value, last_value + dw_step, last_value + up_step) def get_steer_max(CP, v_ego): return interp(v_ego, CP.steerMaxBP, CP.steerMaxV) def update_v_cruise(v_cruise_kph, buttonEvents, enabled): # handle button presses. TODO: this should be in state_control, but a decelCruise press # would have the effect of both enabling and changing speed is checked after the state transition for b in buttonEvents: if enabled and not b.pressed: if b.type == car.CarState.ButtonEvent.Type.accelCruise: v_cruise_kph += V_CRUISE_DELTA - (v_cruise_kph % V_CRUISE_DELTA) elif b.type == car.CarState.ButtonEvent.Type.decelCruise: v_cruise_kph -= V_CRUISE_DELTA - ((V_CRUISE_DELTA - v_cruise_kph) % V_CRUISE_DELTA) v_cruise_kph = clip(v_cruise_kph, V_CRUISE_MIN, V_CRUISE_MAX) return v_cruise_kph def initialize_v_cruise(v_ego, buttonEvents, v_cruise_last): for b in buttonEvents: # 250kph or above probably means we never had a set speed if b.type == car.CarState.ButtonEvent.Type.accelCruise and v_cruise_last < 250: return v_cruise_last return int(round(clip(v_ego * CV.MS_TO_KPH, V_CRUISE_ENABLE_MIN, V_CRUISE_MAX))) def get_lag_adjusted_curvature(CP, v_ego, psis, curvatures, curvature_rates): if len(psis) != CONTROL_N: psis = [0.0 for i in range(CONTROL_N)] curvatures = [0.0 for i in range(CONTROL_N)] curvature_rates = [0.0 for i in range(CONTROL_N)] # TODO this needs more thought, use .2s extra for now to estimate other delays delay = CP.steerActuatorDelay + .2 current_curvature = curvatures[0] psi = interp(delay, T_IDXS[:CONTROL_N], psis) desired_curvature_rate = curvature_rates[0] # MPC can plan to turn the wheel and turn back before t_delay. This means # in high delay cases some corrections never even get commanded. So just use # psi to calculate a simple linearization of desired curvature curvature_diff_from_psi = psi / (max(v_ego, 1e-1) * delay) - current_curvature desired_curvature = current_curvature + 2 * curvature_diff_from_psi max_curvature_rate = interp(v_ego, MAX_CURVATURE_RATE_SPEEDS, MAX_CURVATURE_RATES) safe_desired_curvature_rate = clip(desired_curvature_rate, -max_curvature_rate, max_curvature_rate) safe_desired_curvature = clip(desired_curvature, current_curvature - max_curvature_rate/DT_MDL, current_curvature + max_curvature_rate/DT_MDL) return safe_desired_curvature, safe_desired_curvature_rate ================================================ FILE: selfdrive/controls/lib/events.py ================================================ # This Python file uses the following encoding: utf-8 # -*- coding: utf-8 -*- from enum import IntEnum from typing import Dict, Union, Callable, Any from cereal import log, car import cereal.messaging as messaging from common.realtime import DT_CTRL from selfdrive.config import Conversions as CV from selfdrive.locationd.calibrationd import MIN_SPEED_FILTER from common.i18n import events _ = events() AlertSize = log.ControlsState.AlertSize AlertStatus = log.ControlsState.AlertStatus VisualAlert = car.CarControl.HUDControl.VisualAlert AudibleAlert = car.CarControl.HUDControl.AudibleAlert EventName = car.CarEvent.EventName # Alert priorities class Priority(IntEnum): LOWEST = 0 LOWER = 1 LOW = 2 MID = 3 HIGH = 4 HIGHEST = 5 # Event types class ET: ENABLE = 'enable' PRE_ENABLE = 'preEnable' NO_ENTRY = 'noEntry' WARNING = 'warning' USER_DISABLE = 'userDisable' SOFT_DISABLE = 'softDisable' IMMEDIATE_DISABLE = 'immediateDisable' PERMANENT = 'permanent' # get event name from enum EVENT_NAME = {v: k for k, v in EventName.schema.enumerants.items()} class Events: def __init__(self): self.events = [] self.static_events = [] self.events_prev = dict.fromkeys(EVENTS.keys(), 0) @property def names(self): return self.events def __len__(self): return len(self.events) def add(self, event_name, static=False): if static: self.static_events.append(event_name) self.events.append(event_name) def clear(self): self.events_prev = {k: (v + 1 if k in self.events else 0) for k, v in self.events_prev.items()} self.events = self.static_events.copy() def any(self, event_type): for e in self.events: if event_type in EVENTS.get(e, {}).keys(): return True return False def create_alerts(self, event_types, callback_args=None): if callback_args is None: callback_args = [] ret = [] for e in self.events: types = EVENTS[e].keys() for et in event_types: if et in types: alert = EVENTS[e][et] if not isinstance(alert, Alert): alert = alert(*callback_args) if DT_CTRL * (self.events_prev[e] + 1) >= alert.creation_delay: alert.alert_type = f"{EVENT_NAME[e]}/{et}" alert.event_type = et ret.append(alert) return ret def add_from_msg(self, events): for e in events: self.events.append(e.name.raw) def to_msg(self): ret = [] for event_name in self.events: event = car.CarEvent.new_message() event.name = event_name for event_type in EVENTS.get(event_name, {}).keys(): setattr(event, event_type, True) ret.append(event) return ret class Alert: def __init__(self, alert_text_1: str, alert_text_2: str, alert_status: log.ControlsState.AlertStatus, alert_size: log.ControlsState.AlertSize, alert_priority: Priority, visual_alert: car.CarControl.HUDControl.VisualAlert, audible_alert: car.CarControl.HUDControl.AudibleAlert, duration_sound: float, duration_hud_alert: float, duration_text: float, alert_rate: float = 0., creation_delay: float = 0.): self.alert_text_1 = alert_text_1 self.alert_text_2 = alert_text_2 self.alert_status = alert_status self.alert_size = alert_size self.alert_priority = alert_priority self.visual_alert = visual_alert self.audible_alert = audible_alert self.duration_sound = duration_sound self.duration_hud_alert = duration_hud_alert self.duration_text = duration_text self.alert_rate = alert_rate self.creation_delay = creation_delay self.start_time = 0. self.alert_type = "" self.event_type = None def __str__(self) -> str: return f"{self.alert_text_1}/{self.alert_text_2} {self.alert_priority} {self.visual_alert} {self.audible_alert}" def __gt__(self, alert2) -> bool: return self.alert_priority > alert2.alert_priority class NoEntryAlert(Alert): def __init__(self, alert_text_2, audible_alert=AudibleAlert.chimeError, visual_alert=VisualAlert.none, duration_hud_alert=2.): super().__init__(_("openpilot Unavailable"), alert_text_2, AlertStatus.normal, AlertSize.mid, Priority.LOW, visual_alert, audible_alert, .4, duration_hud_alert, 3.) class SoftDisableAlert(Alert): def __init__(self, alert_text_2): super().__init__(_("TAKE CONTROL IMMEDIATELY"), alert_text_2, AlertStatus.critical, AlertSize.full, Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, 2., 2.), class ImmediateDisableAlert(Alert): def __init__(self, alert_text_2, alert_text_1=_("TAKE CONTROL IMMEDIATELY")): super().__init__(alert_text_1, alert_text_2, AlertStatus.critical, AlertSize.full, Priority.HIGHEST, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, 2.2, 3., 4.), class EngagementAlert(Alert): def __init__(self, audible_alert=True): super().__init__("", "", AlertStatus.normal, AlertSize.none, Priority.MID, VisualAlert.none, audible_alert, 1., 0., 0.), class NormalPermanentAlert(Alert): def __init__(self, alert_text_1: str, alert_text_2: str, duration_text: float = 0.2): super().__init__(alert_text_1, alert_text_2, AlertStatus.normal, AlertSize.mid if len(alert_text_2) else AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., duration_text), # ********** alert callback functions ********** def below_steer_speed_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: speed = int(round(CP.minSteerSpeed * (CV.MS_TO_KPH if metric else CV.MS_TO_MPH))) unit = "km/h" if metric else "mph" return Alert( _("TAKE CONTROL"), _("Steer Unavailable Below %(speed)d %(unit)s") % ({"speed": speed, "unit": unit}), AlertStatus.userPrompt, AlertSize.mid, Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 0., 0.4, .3) def calibration_incomplete_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: speed = int(MIN_SPEED_FILTER * (CV.MS_TO_KPH if metric else CV.MS_TO_MPH)) unit = "km/h" if metric else "mph" return Alert( _("Calibration in Progress: %d%%") % sm['liveCalibration'].calPerc, _("Drive Above %(speed)d %(unit)s") % ({"speed": speed, "unit": unit}), AlertStatus.normal, AlertSize.mid, Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2) def no_gps_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: gps_integrated = sm['pandaState'].pandaType in [log.PandaState.PandaType.uno, log.PandaState.PandaType.dos] return Alert( _("Poor GPS reception"), _("If sky is visible, contact support") if gps_integrated else _("Check GPS antenna placement"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=300.) def wrong_car_mode_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: text = _("Cruise Mode Disabled") if CP.carName == "honda": text = _("Main Switch Off") return NoEntryAlert(text, duration_hud_alert=0.) def startup_fuzzy_fingerprint_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: return Alert( _("WARNING: No Exact Match on Car Model"), f"Closest Match: {CP.carFingerprint.title()[:40]}", AlertStatus.userPrompt, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.) def joystick_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: axes = sm['testJoystick'].axes gb, steer = list(axes)[:2] if len(axes) else (0., 0.) return Alert( _("Joystick Mode"), f"Gas: {round(gb * 100.)}%, Steer: {round(steer * 100.)}%", AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .1) def alca_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: return Alert( _("Auto Lane Change starts in %.1f secs") % float(sm['lateralPlan'].dpALCAStartIn), _("Monitor Other Vehicles"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.steerRequired, AudibleAlert.none, 0., .1, .1, alert_rate=0.1) def speed_limit_adjust_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: bool) -> Alert: speedLimit = sm['longitudinalPlan'].speedLimit speed = round(speedLimit * (CV.MS_TO_KPH if metric else CV.MS_TO_MPH)) message = f'Adjusting to {speed} {"km/h" if metric else "mph"} speed limit' return Alert( message, "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., 4.) EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, bool], Alert]]]] = { # ********** events with no alerts ********** EventName.stockFcw: {}, # ********** events only containing alerts displayed in all states ********** EventName.joystickDebug: { ET.WARNING: joystick_alert, ET.PERMANENT: Alert( _("Joystick Mode"), "", AlertStatus.normal, AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 0.1), }, EventName.controlsInitializing: { ET.NO_ENTRY: NoEntryAlert("Controls Initializing"), }, EventName.startup: { ET.PERMANENT: Alert( _("Be ready to take over at any time"), _("Always keep hands on wheel and eyes on road"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 5.), }, EventName.startupMaster: { ET.PERMANENT: Alert( _("WARNING: This branch is not tested"), _("Always keep hands on wheel and eyes on road"), AlertStatus.userPrompt, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), }, # Car is recognized, but marked as dashcam only EventName.startupNoControl: { ET.PERMANENT: Alert( _("Dashcam mode"), _("Always keep hands on wheel and eyes on road"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), }, # Car is not recognized EventName.startupNoCar: { ET.PERMANENT: Alert( _("Dashcam mode for unsupported car"), _("Always keep hands on wheel and eyes on road"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), }, # openpilot uses the version strings from various ECUs to detect the correct car model. # Usually all ECUs are recognized and an exact match to a car model can be made. Sometimes # one or two ECUs have unrecognized versions, but the others are present in the database. # If openpilot is confident about the match to a car model, it fingerprints anyway. # In this case an alert is thrown since there is a small chance the wrong car was detected # and the user should pay extra attention. # This alert can be prevented by adding all ECU firmware version to openpilot: # https://github.com/commaai/openpilot/wiki/Fingerprinting EventName.startupFuzzyFingerprint: { ET.PERMANENT: startup_fuzzy_fingerprint_alert, }, EventName.startupNoFw: { ET.PERMANENT: Alert( _("Car Unrecognized"), _("Check All Connections"), AlertStatus.userPrompt, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., 10.), }, EventName.dashcamMode: { ET.PERMANENT: Alert( _("Dashcam Mode"), "", AlertStatus.normal, AlertSize.small, Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, EventName.invalidLkasSetting: { ET.PERMANENT: Alert( _("Stock LKAS is turned on"), _("Turn off stock LKAS to engage"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, # Some features or cars are marked as community features. If openpilot # detects the use of a community feature it switches to dashcam mode # until these features are allowed using a toggle in settings. EventName.communityFeatureDisallowed: { # LOW priority to overcome Cruise Error ET.PERMANENT: Alert( _("openpilot Not Available"), _("Enable Community Features in Settings to Engage"), AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, # openpilot doesn't recognize the car. This switches openpilot into a # read-only mode. This can be solved by adding your fingerprint. # See https://github.com/commaai/openpilot/wiki/Fingerprinting for more information EventName.carUnrecognized: { ET.PERMANENT: Alert( _("Dashcam Mode"), _("Car Unrecognized"), AlertStatus.normal, AlertSize.mid, Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, EventName.stockAeb: { ET.PERMANENT: Alert( _("BRAKE!"), _("Stock AEB: Risk of Collision"), AlertStatus.critical, AlertSize.full, Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.none, 1., 2., 2.), ET.NO_ENTRY: NoEntryAlert("Stock AEB: Risk of Collision"), }, EventName.fcw: { ET.PERMANENT: Alert( _("BRAKE!"), _("Risk of Collision"), AlertStatus.critical, AlertSize.full, Priority.HIGHEST, VisualAlert.fcw, AudibleAlert.chimeWarningRepeat, 1., 2., 2.), }, EventName.ldw: { ET.PERMANENT: Alert( _("TAKE CONTROL"), _("Lane Departure Detected"), AlertStatus.userPrompt, AlertSize.mid, Priority.LOW, VisualAlert.ldw, AudibleAlert.chimePrompt, 1., 2., 3.), }, # ********** events only containing alerts that display while engaged ********** EventName.gasPressed: { ET.PRE_ENABLE: Alert( _("openpilot will not brake while gas pressed"), "", AlertStatus.normal, AlertSize.small, Priority.LOWEST, VisualAlert.none, AudibleAlert.none, .0, .0, .1, creation_delay=1.), }, # openpilot tries to learn certain parameters about your car by observing # how the car behaves to steering inputs from both human and openpilot driving. # This includes: # - steer ratio: gear ratio of the steering rack. Steering angle divided by tire angle # - tire stiffness: how much grip your tires have # - angle offset: most steering angle sensors are offset and measure a non zero angle when driving straight # This alert is thrown when any of these values exceed a sanity check. This can be caused by # bad alignment or bad sensor data. If this happens consistently consider creating an issue on GitHub EventName.vehicleModelInvalid: { ET.NO_ENTRY: NoEntryAlert("Vehicle Parameter Identification Failed"), ET.SOFT_DISABLE: SoftDisableAlert("Vehicle Parameter Identification Failed"), ET.WARNING: Alert( _("Vehicle Parameter Identification Failed"), "", AlertStatus.normal, AlertSize.small, Priority.LOWEST, VisualAlert.steerRequired, AudibleAlert.none, .0, .0, .1), }, EventName.steerTempUnavailableSilent: { ET.WARNING: Alert( _("Steering Temporarily Unavailable"), "", AlertStatus.userPrompt, AlertSize.small, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 1., 1.), }, EventName.preDriverDistracted: { ET.WARNING: Alert( _("KEEP EYES ON ROAD: Driver Distracted"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1), }, EventName.promptDriverDistracted: { ET.WARNING: Alert( _("KEEP EYES ON ROAD"), _("Driver Distracted"), AlertStatus.userPrompt, AlertSize.mid, Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2Repeat, 1., .1, .1), }, EventName.driverDistracted: { ET.WARNING: Alert( _("DISENGAGE IMMEDIATELY"), _("Driver Distracted"), AlertStatus.critical, AlertSize.full, Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), }, EventName.preDriverUnresponsive: { ET.WARNING: Alert( _("TOUCH STEERING WHEEL: No Face Detected"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), }, EventName.promptDriverUnresponsive: { ET.WARNING: Alert( _("TOUCH STEERING WHEEL"), _("Driver Unresponsive"), AlertStatus.userPrompt, AlertSize.mid, Priority.MID, VisualAlert.steerRequired, AudibleAlert.chimeWarning2Repeat, 1., .1, .1), }, EventName.driverUnresponsive: { ET.WARNING: Alert( _("DISENGAGE IMMEDIATELY"), _("Driver Unresponsive"), AlertStatus.critical, AlertSize.full, Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarningRepeat, .1, .1, .1), }, EventName.manualRestart: { ET.WARNING: Alert( _("TAKE CONTROL"), _("Resume Driving Manually"), AlertStatus.userPrompt, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, EventName.resumeRequired: { ET.WARNING: Alert( _("STOPPED"), _("Press Resume to Move"), AlertStatus.userPrompt, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, EventName.belowSteerSpeed: { ET.WARNING: below_steer_speed_alert, }, EventName.preLaneChangeLeft: { ET.WARNING: Alert( _("Steer Left to Start Lane Change Once Safe"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), }, EventName.preLaneChangeRight: { ET.WARNING: Alert( _("Steer Right to Start Lane Change Once Safe"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.75), }, EventName.laneChangeBlocked: { ET.WARNING: Alert( _("Car Detected in Blindspot"), "", AlertStatus.userPrompt, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.chimePrompt, .1, .1, .1), }, EventName.laneChange: { ET.WARNING: Alert( _("Changing Lanes"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1), }, EventName.steerSaturated: { ET.WARNING: Alert( _("TAKE CONTROL"), _("Turn Exceeds Steering Limit"), AlertStatus.userPrompt, AlertSize.mid, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 1., 1.), }, # Thrown when the fan is driven at >50% but is not rotating EventName.fanMalfunction: { ET.PERMANENT: NormalPermanentAlert(_("Fan Malfunction"), _("Contact Support")), }, # Camera is not outputting frames at a constant framerate EventName.cameraMalfunction: { ET.PERMANENT: NormalPermanentAlert(_("Camera Malfunction"), _("Contact Support")), }, # Unused EventName.gpsMalfunction: { ET.PERMANENT: NormalPermanentAlert(_("GPS Malfunction"), _("Contact Support")), }, # When the GPS position and localizer diverge the localizer is reset to the # current GPS position. This alert is thrown when the localizer is reset # more often than expected. EventName.localizerMalfunction: { ET.PERMANENT: NormalPermanentAlert(_("Sensor Malfunction"), _("Contact Support")), }, EventName.speedLimitActive: { ET.WARNING: Alert( "Cruise set to speed limit", "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, 1., 0., 2.), }, EventName.speedLimitValueChange: { ET.WARNING: speed_limit_adjust_alert, }, # ********** events that affect controls state transitions ********** EventName.pcmEnable: { ET.ENABLE: EngagementAlert(AudibleAlert.chimeEngage), }, EventName.buttonEnable: { ET.ENABLE: EngagementAlert(AudibleAlert.chimeEngage), }, EventName.pcmDisable: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), }, EventName.buttonCancel: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), }, EventName.brakeHold: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), ET.NO_ENTRY: NoEntryAlert(_("Brake Hold Active")), }, EventName.parkBrake: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), ET.NO_ENTRY: NoEntryAlert(_("Park Brake Engaged")), }, EventName.pedalPressed: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), ET.NO_ENTRY: NoEntryAlert(_("Pedal Pressed During Attempt"), visual_alert=VisualAlert.brakePressed), }, EventName.wrongCarMode: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), ET.NO_ENTRY: wrong_car_mode_alert, }, EventName.wrongCruiseMode: { ET.USER_DISABLE: EngagementAlert(AudibleAlert.chimeDisengage), ET.NO_ENTRY: NoEntryAlert(_("Enable Adaptive Cruise")), }, EventName.steerTempUnavailable: { ET.SOFT_DISABLE: SoftDisableAlert(_("Steering Temporarily Unavailable")), ET.NO_ENTRY: NoEntryAlert(_("Steering Temporarily Unavailable"), duration_hud_alert=0.), }, EventName.outOfSpace: { ET.PERMANENT: Alert( _("Out of Storage"), "", AlertStatus.normal, AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), ET.NO_ENTRY: NoEntryAlert(_("Out of Storage Space"), duration_hud_alert=0.), }, EventName.belowEngageSpeed: { ET.NO_ENTRY: NoEntryAlert(_("Speed Too Low")), }, EventName.sensorDataInvalid: { ET.PERMANENT: Alert( _("No Data from Device Sensors"), _("Reboot your Device"), AlertStatus.normal, AlertSize.mid, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), ET.NO_ENTRY: NoEntryAlert(_("No Data from Device Sensors")), }, EventName.noGps: { ET.PERMANENT: no_gps_alert, }, EventName.soundsUnavailable: { ET.PERMANENT: NormalPermanentAlert(_("Speaker not found"), _("Reboot your Device")), ET.NO_ENTRY: NoEntryAlert(_("Speaker not found")), }, EventName.tooDistracted: { ET.NO_ENTRY: NoEntryAlert(_("Distraction Level Too High")), }, EventName.overheat: { ET.PERMANENT: Alert( _("System Overheated"), "", AlertStatus.normal, AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), ET.SOFT_DISABLE: SoftDisableAlert(_("System Overheated")), ET.NO_ENTRY: NoEntryAlert(_("System Overheated")), }, EventName.wrongGear: { ET.SOFT_DISABLE: SoftDisableAlert(_("Gear not D")), ET.NO_ENTRY: NoEntryAlert(_("Gear not D")), }, # This alert is thrown when the calibration angles are outside of the acceptable range. # For example if the device is pointed too much to the left or the right. # Usually this can only be solved by removing the mount from the windshield completely, # and attaching while making sure the device is pointed straight forward and is level. # See https://comma.ai/setup for more information EventName.calibrationInvalid: { ET.PERMANENT: NormalPermanentAlert(_("Calibration Invalid"), _("Remount Device and Recalibrate")), ET.SOFT_DISABLE: SoftDisableAlert(_("Calibration Invalid: Remount Device & Recalibrate")), ET.NO_ENTRY: NoEntryAlert(_("Calibration Invalid: Remount Device & Recalibrate")), }, EventName.calibrationIncomplete: { ET.PERMANENT: calibration_incomplete_alert, ET.SOFT_DISABLE: SoftDisableAlert(_("Calibration in Progress")), ET.NO_ENTRY: NoEntryAlert(_("Calibration in Progress")), }, EventName.doorOpen: { ET.SOFT_DISABLE: SoftDisableAlert(_("Door Open")), ET.NO_ENTRY: NoEntryAlert(_("Door Open")), }, EventName.seatbeltNotLatched: { ET.SOFT_DISABLE: SoftDisableAlert(_("Seatbelt Unlatched")), ET.NO_ENTRY: NoEntryAlert(_("Seatbelt Unlatched")), }, EventName.espDisabled: { ET.SOFT_DISABLE: SoftDisableAlert(_("ESP Off")), ET.NO_ENTRY: NoEntryAlert(_("ESP Off")), }, EventName.lowBattery: { ET.SOFT_DISABLE: SoftDisableAlert(_("Low Battery")), ET.NO_ENTRY: NoEntryAlert(_("Low Battery")), }, # Different openpilot services communicate between each other at a certain # interval. If communication does not follow the regular schedule this alert # is thrown. This can mean a service crashed, did not broadcast a message for # ten times the regular interval, or the average interval is more than 10% too high. EventName.commIssue: { ET.SOFT_DISABLE: SoftDisableAlert(_("Communication Issue between Processes")), ET.NO_ENTRY: NoEntryAlert(_("Communication Issue between Processes"), audible_alert=AudibleAlert.chimeDisengage), }, # Thrown when manager detects a service exited unexpectedly while driving EventName.processNotRunning: { ET.NO_ENTRY: NoEntryAlert(_("System Malfunction: Reboot Your Device"), audible_alert=AudibleAlert.chimeDisengage), }, EventName.radarFault: { ET.SOFT_DISABLE: SoftDisableAlert(_("Radar Error: Restart the Car")), ET.NO_ENTRY: NoEntryAlert(_("Radar Error: Restart the Car")), }, # Every frame from the camera should be processed by the model. If modeld # is not processing frames fast enough they have to be dropped. This alert is # thrown when over 20% of frames are dropped. EventName.modeldLagging: { ET.SOFT_DISABLE: SoftDisableAlert(_("Driving model lagging")), ET.NO_ENTRY: NoEntryAlert(_("Driving model lagging")), }, # Besides predicting the path, lane lines and lead car data the model also # predicts the current velocity and rotation speed of the car. If the model is # very uncertain about the current velocity while the car is moving, this # usually means the model has trouble understanding the scene. This is used # as a heuristic to warn the driver. EventName.posenetInvalid: { ET.SOFT_DISABLE: SoftDisableAlert(_("Model Output Uncertain")), ET.NO_ENTRY: NoEntryAlert(_("Model Output Uncertain")), }, # When the localizer detects an acceleration of more than 40 m/s^2 (~4G) we # alert the driver the device might have fallen from the windshield. EventName.deviceFalling: { ET.SOFT_DISABLE: SoftDisableAlert(_("Device Fell Off Mount")), ET.NO_ENTRY: NoEntryAlert(_("Device Fell Off Mount")), }, EventName.lowMemory: { ET.SOFT_DISABLE: SoftDisableAlert(_("Low Memory: Reboot Your Device")), ET.PERMANENT: NormalPermanentAlert(_("Low Memory"), _("Reboot your Device")), ET.NO_ENTRY: NoEntryAlert(_("Low Memory: Reboot Your Device"), audible_alert=AudibleAlert.chimeDisengage), }, EventName.highCpuUsage: { #ET.SOFT_DISABLE: SoftDisableAlert("System Malfunction: Reboot Your Device"), #ET.PERMANENT: NormalPermanentAlert("System Malfunction", "Reboot your Device"), ET.NO_ENTRY: NoEntryAlert("System Malfunction: Reboot Your Device", audible_alert=AudibleAlert.chimeDisengage), }, EventName.accFaulted: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Cruise Faulted")), ET.PERMANENT: NormalPermanentAlert(_("Cruise Faulted"), ""), ET.NO_ENTRY: NoEntryAlert(_("Cruise Faulted")), }, EventName.controlsMismatch: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Controls Mismatch")), }, EventName.roadCameraError: { ET.PERMANENT: NormalPermanentAlert(_("Road Camera Error"), "", duration_text=10.), }, EventName.driverCameraError: { ET.PERMANENT: NormalPermanentAlert(_("Driver Camera Error"), "", duration_text=10.), }, EventName.wideRoadCameraError: { ET.PERMANENT: NormalPermanentAlert(_("Wide Road Camera Error"), "", duration_text=10.), }, # Sometimes the USB stack on the device can get into a bad state # causing the connection to the panda to be lost EventName.usbError: { ET.SOFT_DISABLE: SoftDisableAlert(_("USB Error: Reboot Your Device")), ET.PERMANENT: NormalPermanentAlert(_("USB Error: Reboot Your Device"), ""), ET.NO_ENTRY: NoEntryAlert(_("USB Error: Reboot Your Device")), }, # This alert can be thrown for the following reasons: # - No CAN data received at all # - CAN data is received, but some message are not received at the right frequency # If you're not writing a new car port, this is usually cause by faulty wiring EventName.canError: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("CAN Error: Check Connections")), ET.PERMANENT: Alert( _("CAN Error: Check Connections"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=1.), ET.NO_ENTRY: NoEntryAlert(_("CAN Error: Check Connections")), }, EventName.steerUnavailable: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("LKAS Fault: Restart the Car")), ET.PERMANENT: Alert( _("LKAS Fault: Restart the car to engage"), "", AlertStatus.normal, AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), ET.NO_ENTRY: NoEntryAlert(_("LKAS Fault: Restart the Car")), }, EventName.brakeUnavailable: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Cruise Fault: Restart the Car")), ET.PERMANENT: Alert( _("Cruise Fault: Restart the car to engage"), "", AlertStatus.normal, AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), ET.NO_ENTRY: NoEntryAlert(_("Cruise Fault: Restart the Car")), }, EventName.reverseGear: { ET.PERMANENT: Alert( _("Reverse\nGear"), "", AlertStatus.normal, AlertSize.full, Priority.LOWEST, VisualAlert.none, AudibleAlert.none, 0., 0., .2, creation_delay=0.5), ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Reverse Gear")), ET.NO_ENTRY: NoEntryAlert(_("Reverse Gear")), }, # On cars that use stock ACC the car can decide to cancel ACC for various reasons. # When this happens we can no long control the car so the user needs to be warned immediately. EventName.cruiseDisabled: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Cruise Is Off")), }, # For planning the trajectory Model Predictive Control (MPC) is used. This is # an optimization algorithm that is not guaranteed to find a feasible solution. # If no solution is found or the solution has a very high cost this alert is thrown. EventName.plannerError: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Planner Solution Error")), ET.NO_ENTRY: NoEntryAlert(_("Planner Solution Error")), }, # When the relay in the harness box opens the CAN bus between the LKAS camera # and the rest of the car is separated. When messages from the LKAS camera # are received on the car side this usually means the relay hasn't opened correctly # and this alert is thrown. EventName.relayMalfunction: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert(_("Harness Malfunction")), ET.PERMANENT: NormalPermanentAlert(_("Harness Malfunction"), _("Check Hardware")), ET.NO_ENTRY: NoEntryAlert(_("Harness Malfunction")), }, EventName.noTarget: { ET.IMMEDIATE_DISABLE: Alert( _("openpilot Canceled"), _("No close lead car"), AlertStatus.normal, AlertSize.mid, Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), ET.NO_ENTRY: NoEntryAlert(_("No Close Lead Car")), }, EventName.speedTooLow: { ET.IMMEDIATE_DISABLE: Alert( _("openpilot Canceled"), _("Speed too low"), AlertStatus.normal, AlertSize.mid, Priority.HIGH, VisualAlert.none, AudibleAlert.chimeDisengage, .4, 2., 3.), }, # When the car is driving faster than most cars in the training data the model outputs can be unpredictable EventName.speedTooHigh: { ET.WARNING: Alert( _("Speed Too High"), _("Model uncertain at this speed"), AlertStatus.userPrompt, AlertSize.mid, Priority.HIGH, VisualAlert.steerRequired, AudibleAlert.chimeWarning2Repeat, 2.2, 3., 4.), ET.NO_ENTRY: Alert( _("Speed Too High"), _("Slow down to engage"), AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.chimeError, .4, 2., 3.), }, EventName.lowSpeedLockout: { ET.PERMANENT: Alert( _("Cruise Fault: Restart the car to engage"), "", AlertStatus.normal, AlertSize.small, Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2), ET.NO_ENTRY: NoEntryAlert(_("Cruise Fault: Restart the Car")), }, # dp EventName.autoLaneChange: { ET.WARNING: alca_alert, }, EventName.manualSteeringRequired: { ET.WARNING: Alert( _("STEERING REQUIRED: Lane Keeping OFF"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.25), }, EventName.manualSteeringRequiredBlinkersOn: { ET.WARNING: Alert( _("STEERING REQUIRED: Blinkers ON"), "", AlertStatus.normal, AlertSize.small, Priority.LOW, VisualAlert.none, AudibleAlert.none, .0, .1, .1, alert_rate=0.25), }, # timebomb EventName.timebombWarn: { ET.WARNING: Alert( _("WARNING"), _("Grab wheel to start bypass"), AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, .4, 2., 3.), }, EventName.timebombBypassing: { ET.WARNING: Alert( _("BYPASSING"), _("HOLD WHEEL"), AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, .4, 2., 3.), }, EventName.timebombBypassed: { ET.WARNING: Alert( _("Bypassed!"), _("Release wheel when ready"), AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, 3., 2., 3.), }, } ================================================ FILE: selfdrive/controls/lib/fcw.py ================================================ import math from collections import defaultdict from common.numpy_fast import interp _FCW_A_ACT_V = [-3., -2.] _FCW_A_ACT_BP = [0., 30.] class FCWChecker(): def __init__(self): self.reset_lead(0.0) self.common_counters = defaultdict(lambda: 0) def reset_lead(self, cur_time): self.last_fcw_a = 0.0 self.v_lead_max = 0.0 self.lead_seen_t = cur_time self.last_fcw_time = 0.0 self.last_min_a = 0.0 self.counters = defaultdict(lambda: 0) @staticmethod def calc_ttc(v_ego, a_ego, x_lead, v_lead, a_lead): max_ttc = 5.0 v_rel = v_ego - v_lead a_rel = a_ego - a_lead # assuming that closing gap ARel comes from lead vehicle decel, # then limit ARel so that v_lead will get to zero in no sooner than t_decel. # This helps underweighting ARel when v_lead is close to zero. t_decel = 2. a_rel = min(a_rel, v_lead / t_decel) # delta of the quadratic equation to solve for ttc delta = v_rel**2 + 2 * x_lead * a_rel # assign an arbitrary high ttc value if there is no solution to ttc if delta < 0.1 or (math.sqrt(delta) + v_rel < 0.1): ttc = max_ttc else: ttc = min(2 * x_lead / (math.sqrt(delta) + v_rel), max_ttc) return ttc def update(self, mpc_solution, cur_time, active, v_ego, a_ego, x_lead, v_lead, a_lead, y_lead, vlat_lead, fcw_lead, blinkers): mpc_solution_a = list(mpc_solution[0].a_ego) self.last_min_a = min(mpc_solution_a) self.v_lead_max = max(self.v_lead_max, v_lead) self.common_counters['blinkers'] = self.common_counters['blinkers'] + 10.0 / (20 * 3.0) if not blinkers else 0 self.common_counters['v_ego'] = self.common_counters['v_ego'] + 1 if v_ego > 5.0 else 0 if (fcw_lead > 0.99): ttc = self.calc_ttc(v_ego, a_ego, x_lead, v_lead, a_lead) self.counters['ttc'] = self.counters['ttc'] + 1 if ttc < 2.5 else 0 self.counters['v_lead_max'] = self.counters['v_lead_max'] + 1 if self.v_lead_max > 2.5 else 0 self.counters['v_ego_lead'] = self.counters['v_ego_lead'] + 1 if v_ego > v_lead else 0 self.counters['lead_seen'] = self.counters['lead_seen'] + 0.33 self.counters['y_lead'] = self.counters['y_lead'] + 1 if abs(y_lead) < 1.0 else 0 self.counters['vlat_lead'] = self.counters['vlat_lead'] + 1 if abs(vlat_lead) < 0.4 else 0 a_thr = interp(v_lead, _FCW_A_ACT_BP, _FCW_A_ACT_V) a_delta = min(mpc_solution_a[:15]) - min(0.0, a_ego) future_fcw_allowed = all(c >= 10 for c in self.counters.values()) future_fcw_allowed = future_fcw_allowed and all(c >= 10 for c in self.common_counters.values()) future_fcw = (self.last_min_a < -3.0 or a_delta < a_thr) and future_fcw_allowed if future_fcw and (self.last_fcw_time + 5.0 < cur_time): self.last_fcw_time = cur_time self.last_fcw_a = self.last_min_a return True return False ================================================ FILE: selfdrive/controls/lib/lane_planner.py ================================================ import numpy as np from cereal import log from common.filter_simple import FirstOrderFilter from common.numpy_fast import interp from common.realtime import DT_MDL from selfdrive.hardware import EON, TICI from selfdrive.swaglog import cloudlog TRAJECTORY_SIZE = 33 # camera offset is meters from center car to camera if EON: CAMERA_OFFSET = 0.06 PATH_OFFSET = 0.0 elif TICI: CAMERA_OFFSET = -0.04 PATH_OFFSET = -0.04 else: CAMERA_OFFSET = 0.0 PATH_OFFSET = 0.0 class LanePlanner: def __init__(self, wide_camera=False): self.ll_t = np.zeros((TRAJECTORY_SIZE,)) self.ll_x = np.zeros((TRAJECTORY_SIZE,)) self.lll_y = np.zeros((TRAJECTORY_SIZE,)) self.rll_y = np.zeros((TRAJECTORY_SIZE,)) self.lane_width_estimate = FirstOrderFilter(3.7, 9.95, DT_MDL) self.lane_width_certainty = FirstOrderFilter(1.0, 0.95, DT_MDL) self.lane_width = 3.7 self.lll_prob = 0. self.rll_prob = 0. self.d_prob = 0. self.lll_std = 0. self.rll_std = 0. self.l_lane_change_prob = 0. self.r_lane_change_prob = 0. self.camera_offset = -CAMERA_OFFSET if wide_camera else CAMERA_OFFSET self.path_offset = -PATH_OFFSET if wide_camera else PATH_OFFSET self.dp_camera_offset = None self.dp_path_offset = None def update_dp_set_offsets(self, camera_offset, path_offset): if self.dp_camera_offset != camera_offset: self.dp_camera_offset = camera_offset self.camera_offset = camera_offset / 100 if self.dp_path_offset != path_offset: self.dp_path_offset = path_offset self.path_offset = path_offset / 100 def parse_model(self, md): if len(md.laneLines) == 4 and len(md.laneLines[0].t) == TRAJECTORY_SIZE: self.ll_t = (np.array(md.laneLines[1].t) + np.array(md.laneLines[2].t))/2 # left and right ll x is the same self.ll_x = md.laneLines[1].x # only offset left and right lane lines; offsetting path does not make sense self.lll_y = np.array(md.laneLines[1].y) - self.camera_offset self.rll_y = np.array(md.laneLines[2].y) - self.camera_offset self.lll_prob = md.laneLineProbs[1] self.rll_prob = md.laneLineProbs[2] self.lll_std = md.laneLineStds[1] self.rll_std = md.laneLineStds[2] if len(md.meta.desireState): self.l_lane_change_prob = md.meta.desireState[log.LateralPlan.Desire.laneChangeLeft] self.r_lane_change_prob = md.meta.desireState[log.LateralPlan.Desire.laneChangeRight] def get_d_path(self, v_ego, path_t, path_xyz): # Reduce reliance on lanelines that are too far apart or # will be in a few seconds path_xyz[:, 1] -= self.path_offset l_prob, r_prob = self.lll_prob, self.rll_prob width_pts = self.rll_y - self.lll_y prob_mods = [] for t_check in [0.0, 1.5, 3.0]: width_at_t = interp(t_check * (v_ego + 7), self.ll_x, width_pts) prob_mods.append(interp(width_at_t, [4.0, 5.0], [1.0, 0.0])) mod = min(prob_mods) l_prob *= mod r_prob *= mod # Reduce reliance on uncertain lanelines l_std_mod = interp(self.lll_std, [.15, .3], [1.0, 0.0]) r_std_mod = interp(self.rll_std, [.15, .3], [1.0, 0.0]) l_prob *= l_std_mod r_prob *= r_std_mod # Find current lanewidth self.lane_width_certainty.update(l_prob * r_prob) current_lane_width = abs(self.rll_y[0] - self.lll_y[0]) self.lane_width_estimate.update(current_lane_width) speed_lane_width = interp(v_ego, [0., 31.], [2.8, 3.5]) self.lane_width = self.lane_width_certainty.x * self.lane_width_estimate.x + \ (1 - self.lane_width_certainty.x) * speed_lane_width clipped_lane_width = min(4.0, self.lane_width) path_from_left_lane = self.lll_y + clipped_lane_width / 2.0 path_from_right_lane = self.rll_y - clipped_lane_width / 2.0 self.d_prob = l_prob + r_prob - l_prob * r_prob lane_path_y = (l_prob * path_from_left_lane + r_prob * path_from_right_lane) / (l_prob + r_prob + 0.0001) safe_idxs = np.isfinite(self.ll_t) if safe_idxs[0]: lane_path_y_interp = np.interp(path_t, self.ll_t[safe_idxs], lane_path_y[safe_idxs]) path_xyz[:,1] = self.d_prob * lane_path_y_interp + (1.0 - self.d_prob) * path_xyz[:,1] else: cloudlog.warning("Lateral mpc - NaNs in laneline times, ignoring") return path_xyz ================================================ FILE: selfdrive/controls/lib/latcontrol_angle.py ================================================ import math from cereal import log class LatControlAngle(): def __init__(self, CP): pass def reset(self): pass def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate): angle_log = log.ControlsState.LateralAngleState.new_message() if CS.vEgo < 0.3 or not active: angle_log.active = False angle_steers_des = float(CS.steeringAngleDeg) else: angle_log.active = True angle_steers_des = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo)) angle_steers_des += params.angleOffsetDeg angle_log.saturated = False angle_log.steeringAngleDeg = angle_steers_des return 0, float(angle_steers_des), angle_log ================================================ FILE: selfdrive/controls/lib/latcontrol_indi.py ================================================ import math import numpy as np from cereal import log from common.filter_simple import FirstOrderFilter from common.numpy_fast import clip, interp from common.realtime import DT_CTRL from selfdrive.car import apply_toyota_steer_torque_limits from selfdrive.car.toyota.values import CarControllerParams from selfdrive.controls.lib.drive_helpers import get_steer_max class LatControlINDI(): def __init__(self, CP): self.angle_steers_des = 0. A = np.array([[1.0, DT_CTRL, 0.0], [0.0, 1.0, DT_CTRL], [0.0, 0.0, 1.0]]) C = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) # Q = np.matrix([[1e-2, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 10.0]]) # R = np.matrix([[1e-2, 0.0], [0.0, 1e3]]) # (x, l, K) = control.dare(np.transpose(A), np.transpose(C), Q, R) # K = np.transpose(K) K = np.array([[7.30262179e-01, 2.07003658e-04], [7.29394177e+00, 1.39159419e-02], [1.71022442e+01, 3.38495381e-02]]) self.speed = 0. self.K = K self.A_K = A - np.dot(K, C) self.x = np.array([[0.], [0.], [0.]]) self.enforce_rate_limit = CP.carName == "toyota" self._RC = (CP.lateralTuning.indi.timeConstantBP, CP.lateralTuning.indi.timeConstantV) self._G = (CP.lateralTuning.indi.actuatorEffectivenessBP, CP.lateralTuning.indi.actuatorEffectivenessV) self._outer_loop_gain = (CP.lateralTuning.indi.outerLoopGainBP, CP.lateralTuning.indi.outerLoopGainV) self._inner_loop_gain = (CP.lateralTuning.indi.innerLoopGainBP, CP.lateralTuning.indi.innerLoopGainV) self.sat_count_rate = 1.0 * DT_CTRL self.sat_limit = CP.steerLimitTimer self.steer_filter = FirstOrderFilter(0., self.RC, DT_CTRL) self.reset() @property def RC(self): return interp(self.speed, self._RC[0], self._RC[1]) @property def G(self): return interp(self.speed, self._G[0], self._G[1]) @property def outer_loop_gain(self): return interp(self.speed, self._outer_loop_gain[0], self._outer_loop_gain[1]) @property def inner_loop_gain(self): return interp(self.speed, self._inner_loop_gain[0], self._inner_loop_gain[1]) def reset(self): self.steer_filter.x = 0. self.output_steer = 0. self.sat_count = 0. self.speed = 0. def _check_saturation(self, control, check_saturation, limit): saturated = abs(control) == limit if saturated and check_saturation: self.sat_count += self.sat_count_rate else: self.sat_count -= self.sat_count_rate self.sat_count = clip(self.sat_count, 0.0, 1.0) return self.sat_count > self.sat_limit def update(self, active, CS, CP, VM, params, curvature, curvature_rate): self.speed = CS.vEgo # Update Kalman filter y = np.array([[math.radians(CS.steeringAngleDeg)], [math.radians(CS.steeringRateDeg)]]) self.x = np.dot(self.A_K, self.x) + np.dot(self.K, y) indi_log = log.ControlsState.LateralINDIState.new_message() indi_log.steeringAngleDeg = math.degrees(self.x[0]) indi_log.steeringRateDeg = math.degrees(self.x[1]) indi_log.steeringAccelDeg = math.degrees(self.x[2]) steers_des = VM.get_steer_from_curvature(-curvature, CS.vEgo) steers_des += math.radians(params.angleOffsetDeg) if CS.vEgo < 0.3 or not active: indi_log.active = False self.output_steer = 0.0 self.steer_filter.x = 0.0 else: rate_des = VM.get_steer_from_curvature(-curvature_rate, CS.vEgo) # Expected actuator value self.steer_filter.update_alpha(self.RC) self.steer_filter.update(self.output_steer) # Compute acceleration error rate_sp = self.outer_loop_gain * (steers_des - self.x[0]) + rate_des accel_sp = self.inner_loop_gain * (rate_sp - self.x[1]) accel_error = accel_sp - self.x[2] # Compute change in actuator g_inv = 1. / self.G delta_u = g_inv * accel_error # If steering pressed, only allow wind down if CS.steeringPressed and (delta_u * self.output_steer > 0): delta_u = 0 # Enforce rate limit if self.enforce_rate_limit: steer_max = float(CarControllerParams.STEER_MAX) new_output_steer_cmd = steer_max * (self.steer_filter.x + delta_u) prev_output_steer_cmd = steer_max * self.output_steer new_output_steer_cmd = apply_toyota_steer_torque_limits(new_output_steer_cmd, prev_output_steer_cmd, prev_output_steer_cmd, CarControllerParams) self.output_steer = new_output_steer_cmd / steer_max else: self.output_steer = self.steer_filter.x + delta_u steers_max = get_steer_max(CP, CS.vEgo) self.output_steer = clip(self.output_steer, -steers_max, steers_max) indi_log.active = True indi_log.rateSetPoint = float(rate_sp) indi_log.accelSetPoint = float(accel_sp) indi_log.accelError = float(accel_error) indi_log.delayedOutput = float(self.steer_filter.x) indi_log.delta = float(delta_u) indi_log.output = float(self.output_steer) check_saturation = (CS.vEgo > 10.) and not CS.steeringRateLimited and not CS.steeringPressed indi_log.saturated = self._check_saturation(self.output_steer, check_saturation, steers_max) return float(self.output_steer), float(steers_des), indi_log ================================================ FILE: selfdrive/controls/lib/latcontrol_lqr.py ================================================ import math import numpy as np from common.numpy_fast import clip from common.realtime import DT_CTRL from cereal import log from selfdrive.controls.lib.drive_helpers import get_steer_max class LatControlLQR(): def __init__(self, CP): self.scale = CP.lateralTuning.lqr.scale self.ki = CP.lateralTuning.lqr.ki self.A = np.array(CP.lateralTuning.lqr.a).reshape((2, 2)) self.B = np.array(CP.lateralTuning.lqr.b).reshape((2, 1)) self.C = np.array(CP.lateralTuning.lqr.c).reshape((1, 2)) self.K = np.array(CP.lateralTuning.lqr.k).reshape((1, 2)) self.L = np.array(CP.lateralTuning.lqr.l).reshape((2, 1)) self.dc_gain = CP.lateralTuning.lqr.dcGain self.x_hat = np.array([[0], [0]]) self.i_unwind_rate = 0.3 * DT_CTRL self.i_rate = 1.0 * DT_CTRL self.sat_count_rate = 1.0 * DT_CTRL self.sat_limit = CP.steerLimitTimer self.reset() def reset(self): self.i_lqr = 0.0 self.sat_count = 0.0 def _check_saturation(self, control, check_saturation, limit): saturated = abs(control) == limit if saturated and check_saturation: self.sat_count += self.sat_count_rate else: self.sat_count -= self.sat_count_rate self.sat_count = clip(self.sat_count, 0.0, 1.0) return self.sat_count > self.sat_limit def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate): lqr_log = log.ControlsState.LateralLQRState.new_message() steers_max = get_steer_max(CP, CS.vEgo) torque_scale = (0.45 + CS.vEgo / 60.0)**2 # Scale actuator model with speed # Subtract offset. Zero angle should correspond to zero torque steering_angle_no_offset = CS.steeringAngleDeg - params.angleOffsetAverageDeg desired_angle = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo)) instant_offset = params.angleOffsetDeg - params.angleOffsetAverageDeg desired_angle += instant_offset # Only add offset that originates from vehicle model errors # Update Kalman filter angle_steers_k = float(self.C.dot(self.x_hat)) e = steering_angle_no_offset - angle_steers_k self.x_hat = self.A.dot(self.x_hat) + self.B.dot(CS.steeringTorqueEps / torque_scale) + self.L.dot(e) if CS.vEgo < 0.3 or not active: lqr_log.active = False lqr_output = 0. output_steer = 0. self.reset() else: lqr_log.active = True # LQR u_lqr = float(desired_angle / self.dc_gain - self.K.dot(self.x_hat)) lqr_output = torque_scale * u_lqr / self.scale # Integrator if CS.steeringPressed: self.i_lqr -= self.i_unwind_rate * float(np.sign(self.i_lqr)) else: error = desired_angle - angle_steers_k i = self.i_lqr + self.ki * self.i_rate * error control = lqr_output + i if (error >= 0 and (control <= steers_max or i < 0.0)) or \ (error <= 0 and (control >= -steers_max or i > 0.0)): self.i_lqr = i output_steer = lqr_output + self.i_lqr output_steer = clip(output_steer, -steers_max, steers_max) check_saturation = (CS.vEgo > 10) and not CS.steeringRateLimited and not CS.steeringPressed saturated = self._check_saturation(output_steer, check_saturation, steers_max) lqr_log.steeringAngleDeg = angle_steers_k + params.angleOffsetAverageDeg lqr_log.i = self.i_lqr lqr_log.output = output_steer lqr_log.lqrOutput = lqr_output lqr_log.saturated = saturated return output_steer, desired_angle, lqr_log ================================================ FILE: selfdrive/controls/lib/latcontrol_pid.py ================================================ import math from selfdrive.controls.lib.pid import PIController from selfdrive.controls.lib.drive_helpers import get_steer_max from cereal import log class LatControlPID(): def __init__(self, CP): self.pid = PIController((CP.lateralTuning.pid.kpBP, CP.lateralTuning.pid.kpV), (CP.lateralTuning.pid.kiBP, CP.lateralTuning.pid.kiV), k_f=CP.lateralTuning.pid.kf, pos_limit=1.0, neg_limit=-1.0, sat_limit=CP.steerLimitTimer) def reset(self): self.pid.reset() def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate): pid_log = log.ControlsState.LateralPIDState.new_message() pid_log.steeringAngleDeg = float(CS.steeringAngleDeg) pid_log.steeringRateDeg = float(CS.steeringRateDeg) angle_steers_des_no_offset = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo)) angle_steers_des = angle_steers_des_no_offset + params.angleOffsetDeg pid_log.angleError = angle_steers_des - CS.steeringAngleDeg if CS.vEgo < 0.3 or not active: output_steer = 0.0 pid_log.active = False self.pid.reset() else: steers_max = get_steer_max(CP, CS.vEgo) self.pid.pos_limit = steers_max self.pid.neg_limit = -steers_max # TODO: feedforward something based on lat_plan.rateSteers steer_feedforward = angle_steers_des_no_offset # offset does not contribute to resistive torque steer_feedforward *= CS.vEgo**2 # proportional to realigning tire momentum (~ lateral accel) deadzone = 0.0 check_saturation = (CS.vEgo > 10) and not CS.steeringRateLimited and not CS.steeringPressed output_steer = self.pid.update(angle_steers_des, CS.steeringAngleDeg, check_saturation=check_saturation, override=CS.steeringPressed, feedforward=steer_feedforward, speed=CS.vEgo, deadzone=deadzone) pid_log.active = True pid_log.p = self.pid.p pid_log.i = self.pid.i pid_log.f = self.pid.f pid_log.output = output_steer pid_log.saturated = bool(self.pid.saturated) return output_steer, angle_steers_des, pid_log ================================================ FILE: selfdrive/controls/lib/lateral_mpc/.gitignore ================================================ generator lib_qp/ ================================================ FILE: selfdrive/controls/lib/lateral_mpc/SConscript ================================================ Import('env', 'arch') cpp_path = [ "#", "#selfdrive", "#phonelibs/acado/include", "#phonelibs/acado/include/acado", "#phonelibs/qpoases/INCLUDE", "#phonelibs/qpoases/INCLUDE/EXTRAS", "#phonelibs/qpoases/SRC/", "#phonelibs/qpoases", "lib_mpc_export", ] generated_c = [ 'lib_mpc_export/acado_auxiliary_functions.c', 'lib_mpc_export/acado_qpoases_interface.cpp', 'lib_mpc_export/acado_integrator.c', 'lib_mpc_export/acado_solver.c', ] generated_h = [ 'lib_mpc_export/acado_common.h', 'lib_mpc_export/acado_auxiliary_functions.h', 'lib_mpc_export/acado_qpoases_interface.hpp', ] interface_dir = Dir('lib_mpc_export') SConscript(['#phonelibs/qpoases/SConscript'], variant_dir='lib_qp', exports=['interface_dir']) if GetOption('mpc_generate'): generator_cpp = File('generator.cpp') acado_libs = [File(f"#phonelibs/acado/{arch}/lib/libacado_toolkit.a"), File(f"#phonelibs/acado/{arch}/lib/libacado_casadi.a"), File(f"#phonelibs/acado/{arch}/lib/libacado_csparse.a")] generator = env.Program('generator', generator_cpp, LIBS=acado_libs, CPPPATH=cpp_path, CCFLAGS=env['CCFLAGS'] + ["-Wno-deprecated", "-Wno-overloaded-shift-op-parentheses"]) cmd = f"cd {Dir('.').get_abspath()} && {generator[0].get_abspath()}" env.Command(generated_c + generated_h, generator, cmd) mpc_files = ["lateral_mpc.c"] + generated_c env.SharedLibrary('mpc', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) ================================================ FILE: selfdrive/controls/lib/lateral_mpc/__init__.py ================================================ ================================================ FILE: selfdrive/controls/lib/lateral_mpc/generator.cpp ================================================ #include #include #include "selfdrive/common/modeldata.h" #define deg2rad(d) (d/180.0*M_PI) using namespace std; int main( ) { USING_NAMESPACE_ACADO DifferentialEquation f; DifferentialState xx; // x position DifferentialState yy; // y position DifferentialState psi; // vehicle heading DifferentialState curvature; OnlineData v_ego; OnlineData rotation_radius; Control curvature_rate; // Equations of motion f << dot(xx) == v_ego * cos(psi); f << dot(yy) == v_ego * sin(psi); // disable rotation radius for now //f << dot(xx) == v_ego * cos(psi) - rotation_radius * sin(psi) * (v_ego * curvature); //f << dot(yy) == v_ego * sin(psi) + rotation_radius * cos(psi) * (v_ego * curvature); f << dot(psi) == v_ego * curvature; f << dot(curvature) == curvature_rate; // Running cost Function h; // Distance errors h << yy; // Heading error h << (v_ego + 5.0 ) * psi; // Angular rate error h << (v_ego + 5.0) * 4 * curvature_rate; BMatrix Q(3,3); Q.setAll(true); // Q(0,0) = 1.0; // Q(1,1) = 1.0; // Q(2,2) = 1.0; // Q(3,3) = 1.0; // Q(4,4) = 2.0; // Terminal cost Function hN; // Distance errors hN << yy; // Heading errors hN << (2.0 * v_ego + 5.0 ) * psi; BMatrix QN(2,2); QN.setAll(true); // QN(0,0) = 1.0; // QN(1,1) = 1.0; // QN(2,2) = 1.0; // QN(3,3) = 1.0; double T_IDXS_ARR[LAT_MPC_N + 1]; memcpy(T_IDXS_ARR, T_IDXS, (LAT_MPC_N + 1) * sizeof(double)); Grid times(LAT_MPC_N + 1, T_IDXS_ARR); OCP ocp(times); ocp.subjectTo(f); ocp.minimizeLSQ(Q, h); ocp.minimizeLSQEndTerm(QN, hN); // car can't go backward to avoid "circles" ocp.subjectTo( deg2rad(-90) <= psi <= deg2rad(90)); // more than absolute max steer angle ocp.subjectTo( deg2rad(-50) <= curvature <= deg2rad(50)); ocp.setNOD(2); OCPexport mpc(ocp); mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON ); mpc.set( DISCRETIZATION_TYPE, MULTIPLE_SHOOTING ); mpc.set( INTEGRATOR_TYPE, INT_RK4 ); mpc.set( NUM_INTEGRATOR_STEPS, 1000); mpc.set( MAX_NUM_QP_ITERATIONS, 50); mpc.set( CG_USE_VARIABLE_WEIGHTING_MATRIX, YES); mpc.set( SPARSE_QP_SOLUTION, CONDENSING ); mpc.set( QP_SOLVER, QP_QPOASES ); mpc.set( HOTSTART_QP, YES ); mpc.set( GENERATE_TEST_FILE, NO); mpc.set( GENERATE_MAKE_FILE, NO ); mpc.set( GENERATE_MATLAB_INTERFACE, NO ); mpc.set( GENERATE_SIMULINK_INTERFACE, NO ); if (mpc.exportCode( "lib_mpc_export" ) != SUCCESSFUL_RETURN) exit( EXIT_FAILURE ); mpc.printDimensionsQP( ); return EXIT_SUCCESS; } ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lateral_mpc.c ================================================ #include "acado_common.h" #include "acado_auxiliary_functions.h" #include "common/modeldata.h" #include #define NX ACADO_NX /* Number of differential state variables. */ #define NXA ACADO_NXA /* Number of algebraic variables. */ #define NU ACADO_NU /* Number of control inputs. */ #define NOD ACADO_NOD /* Number of online data values. */ #define NY ACADO_NY /* Number of measurements/references on nodes 0..N - 1. */ #define NYN ACADO_NYN /* Number of measurements/references on node N. */ #define N ACADO_N /* Number of intervals in the horizon. */ ACADOvariables acadoVariables; ACADOworkspace acadoWorkspace; typedef struct { double x, y, psi, tire_angle, tire_angle_rate; } state_t; typedef struct { double x[N+1]; double y[N+1]; double psi[N+1]; double curvature[N+1]; double curvature_rate[N]; double cost; } log_t; void set_weights(double pathCost, double headingCost, double steerRateCost){ int i; const int STEP_MULTIPLIER = 3.0; for (i = 0; i < N; i++) { double f = 20 * (T_IDXS[i+1] - T_IDXS[i]); // Setup diagonal entries acadoVariables.W[NY*NY*i + (NY+1)*0] = pathCost * f; acadoVariables.W[NY*NY*i + (NY+1)*1] = headingCost * f; acadoVariables.W[NY*NY*i + (NY+1)*2] = steerRateCost * f; } acadoVariables.WN[(NYN+1)*0] = pathCost * STEP_MULTIPLIER; acadoVariables.WN[(NYN+1)*1] = headingCost * STEP_MULTIPLIER; } void init(){ acado_initializeSolver(); int i; /* Initialize the states and controls. */ for (i = 0; i < NX * (N + 1); ++i) acadoVariables.x[ i ] = 0.0; for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.0; /* Initialize the measurements/reference. */ for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; /* MPC: initialize the current state feedback. */ for (i = 0; i < NX; ++i) acadoVariables.x0[ i ] = 0.0; } int run_mpc(state_t * x0, log_t * solution, double v_ego, double rotation_radius, double target_y[N+1], double target_psi[N+1]){ int i; for (i = 0; i <= NOD * N; i+= NOD){ acadoVariables.od[i] = v_ego; acadoVariables.od[i+1] = rotation_radius; } for (i = 0; i < N; i+= 1){ acadoVariables.y[NY*i + 0] = target_y[i]; acadoVariables.y[NY*i + 1] = (v_ego + 5.0) * target_psi[i]; acadoVariables.y[NY*i + 2] = 0.0; } acadoVariables.yN[0] = target_y[N]; acadoVariables.yN[1] = (2.0 * v_ego + 5.0) * target_psi[N]; acadoVariables.x0[0] = x0->x; acadoVariables.x0[1] = x0->y; acadoVariables.x0[2] = x0->psi; acadoVariables.x0[3] = x0->tire_angle; acado_preparationStep(); acado_feedbackStep(); /* printf("lat its: %d\n", acado_getNWSR()); // n iterations printf("Objective: %.6f\n", acado_getObjective()); // solution cost */ for (i = 0; i <= N; i++){ solution->x[i] = acadoVariables.x[i*NX]; solution->y[i] = acadoVariables.x[i*NX+1]; solution->psi[i] = acadoVariables.x[i*NX+2]; solution->curvature[i] = acadoVariables.x[i*NX+3]; if (i < N){ solution->curvature_rate[i] = acadoVariables.u[i]; } } solution->cost = acado_getObjective(); // Dont shift states here. Current solution is closer to next timestep than if // we use the old solution as a starting point //acado_shiftStates(2, 0, 0); //acado_shiftControls( 0 ); return acado_getNWSR(); } ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_auxiliary_functions.h" #include real_t* acado_getVariablesX( ) { return acadoVariables.x; } real_t* acado_getVariablesU( ) { return acadoVariables.u; } #if ACADO_NY > 0 real_t* acado_getVariablesY( ) { return acadoVariables.y; } #endif #if ACADO_NYN > 0 real_t* acado_getVariablesYN( ) { return acadoVariables.yN; } #endif real_t* acado_getVariablesX0( ) { #if ACADO_INITIAL_VALUE_FIXED return acadoVariables.x0; #else return 0; #endif } /** Print differential variables. */ void acado_printDifferentialVariables( ) { int i, j; printf("\nDifferential variables:\n[\n"); for (i = 0; i < ACADO_N + 1; ++i) { for (j = 0; j < ACADO_NX; ++j) printf("\t%e", acadoVariables.x[i * ACADO_NX + j]); printf("\n"); } printf("]\n\n"); } /** Print control variables. */ void acado_printControlVariables( ) { int i, j; printf("\nControl variables:\n[\n"); for (i = 0; i < ACADO_N; ++i) { for (j = 0; j < ACADO_NU; ++j) printf("\t%e", acadoVariables.u[i * ACADO_NU + j]); printf("\n"); } printf("]\n\n"); } /** Print ACADO code generation notice. */ void acado_printHeader( ) { printf( "\nACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.\n" "Copyright (C) 2008-2015 by Boris Houska, Hans Joachim Ferreau,\n" "Milan Vukov and Rien Quirynen, KU Leuven.\n" ); printf( "Developed within the Optimization in Engineering Center (OPTEC) under\n" "supervision of Moritz Diehl. All rights reserved.\n\n" "ACADO Toolkit is distributed under the terms of the GNU Lesser\n" "General Public License 3 in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU Lesser General Public License for more details.\n\n" ); } #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) void acado_tic( acado_timer* t ) { QueryPerformanceFrequency(&t->freq); QueryPerformanceCounter(&t->tic); } real_t acado_toc( acado_timer* t ) { QueryPerformanceCounter(&t->toc); return ((t->toc.QuadPart - t->tic.QuadPart) / (real_t)t->freq.QuadPart); } #elif (defined __APPLE__) void acado_tic( acado_timer* t ) { /* read current clock cycles */ t->tic = mach_absolute_time(); } real_t acado_toc( acado_timer* t ) { uint64_t duration; /* elapsed time in clock cycles*/ t->toc = mach_absolute_time(); duration = t->toc - t->tic; /*conversion from clock cycles to nanoseconds*/ mach_timebase_info(&(t->tinfo)); duration *= t->tinfo.numer; duration /= t->tinfo.denom; return (real_t)duration / 1e9; } #else #if __STDC_VERSION__ >= 199901L /* C99 mode */ /* read current time */ void acado_tic( acado_timer* t ) { gettimeofday(&t->tic, 0); } /* return time passed since last call to tic on this timer */ real_t acado_toc( acado_timer* t ) { struct timeval temp; gettimeofday(&t->toc, 0); if ((t->toc.tv_usec - t->tic.tv_usec) < 0) { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; temp.tv_usec = 1000000 + t->toc.tv_usec - t->tic.tv_usec; } else { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; temp.tv_usec = t->toc.tv_usec - t->tic.tv_usec; } return (real_t)temp.tv_sec + (real_t)temp.tv_usec / 1e6; } #else /* ANSI */ /* read current time */ void acado_tic( acado_timer* t ) { clock_gettime(CLOCK_MONOTONIC, &t->tic); } /* return time passed since last call to tic on this timer */ real_t acado_toc( acado_timer* t ) { struct timespec temp; clock_gettime(CLOCK_MONOTONIC, &t->toc); if ((t->toc.tv_nsec - t->tic.tv_nsec) < 0) { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; temp.tv_nsec = 1000000000+t->toc.tv_nsec - t->tic.tv_nsec; } else { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; temp.tv_nsec = t->toc.tv_nsec - t->tic.tv_nsec; } return (real_t)temp.tv_sec + (real_t)temp.tv_nsec / 1e9; } #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || _WIN64) */ #endif ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_auxiliary_functions.h ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef ACADO_AUXILIARY_FUNCTIONS_H #define ACADO_AUXILIARY_FUNCTIONS_H #include "acado_common.h" #ifndef __MATLAB__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __MATLAB__ */ /** Get pointer to the matrix with differential variables. */ real_t* acado_getVariablesX( ); /** Get pointer to the matrix with control variables. */ real_t* acado_getVariablesU( ); #if ACADO_NY > 0 /** Get pointer to the matrix with references/measurements. */ real_t* acado_getVariablesY( ); #endif #if ACADO_NYN > 0 /** Get pointer to the vector with references/measurement on the last node. */ real_t* acado_getVariablesYN( ); #endif /** Get pointer to the current state feedback vector. Only applicable for NMPC. */ real_t* acado_getVariablesX0( ); /** Print differential variables. */ void acado_printDifferentialVariables( ); /** Print control variables. */ void acado_printControlVariables( ); /** Print ACADO code generation notice. */ void acado_printHeader( ); /* * A huge thanks goes to Alexander Domahidi from ETHZ, Switzerland, for * providing us with the following timing routines. */ #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) /* Use Windows QueryPerformanceCounter for timing. */ #include /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { LARGE_INTEGER tic; LARGE_INTEGER toc; LARGE_INTEGER freq; } acado_timer; #elif (defined __APPLE__) #include "unistd.h" #include /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { uint64_t tic; uint64_t toc; mach_timebase_info_data_t tinfo; } acado_timer; #else /* Use POSIX clock_gettime() for timing on non-Windows machines. */ #include #if __STDC_VERSION__ >= 199901L /* C99 mode of operation. */ #include #include typedef struct acado_timer_ { struct timeval tic; struct timeval toc; } acado_timer; #else /* ANSI C */ /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { struct timespec tic; struct timespec toc; } acado_timer; #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || defined _WIN64) */ /** A function for measurement of the current time. */ void acado_tic( acado_timer* t ); /** A function which returns the elapsed time. */ real_t acado_toc( acado_timer* t ); #endif #ifndef __MATLAB__ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* __MATLAB__ */ #endif /* ACADO_AUXILIARY_FUNCTIONS_H */ ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_common.h ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef ACADO_COMMON_H #define ACADO_COMMON_H #include #include #ifndef __MATLAB__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __MATLAB__ */ /** \defgroup ACADO ACADO CGT generated module. */ /** @{ */ /** qpOASES QP solver indicator. */ #define ACADO_QPOASES 0 #define ACADO_QPOASES3 1 /** FORCES QP solver indicator.*/ #define ACADO_FORCES 2 /** qpDUNES QP solver indicator.*/ #define ACADO_QPDUNES 3 /** HPMPC QP solver indicator. */ #define ACADO_HPMPC 4 #define ACADO_GENERIC 5 /** Indicator for determining the QP solver used by the ACADO solver code. */ #define ACADO_QP_SOLVER ACADO_QPOASES #include "acado_qpoases_interface.hpp" /* * Common definitions */ /** User defined block based condensing. */ #define ACADO_BLOCK_CONDENSING 0 /** Compute covariance matrix of the last state estimate. */ #define ACADO_COMPUTE_COVARIANCE_MATRIX 0 /** Flag indicating whether constraint values are hard-coded or not. */ #define ACADO_HARDCODED_CONSTRAINT_VALUES 1 /** Indicator for fixed initial state. */ #define ACADO_INITIAL_STATE_FIXED 1 /** Number of control/estimation intervals. */ #define ACADO_N 16 /** Number of online data values. */ #define ACADO_NOD 2 /** Number of path constraints. */ #define ACADO_NPAC 0 /** Number of control variables. */ #define ACADO_NU 1 /** Number of differential variables. */ #define ACADO_NX 4 /** Number of algebraic variables. */ #define ACADO_NXA 0 /** Number of differential derivative variables. */ #define ACADO_NXD 0 /** Number of references/measurements per node on the first N nodes. */ #define ACADO_NY 3 /** Number of references/measurements on the last (N + 1)st node. */ #define ACADO_NYN 2 /** Total number of QP optimization variables. */ #define ACADO_QP_NV 20 /** Number of Runge-Kutta stages per integration step. */ #define ACADO_RK_NSTAGES 4 /** Providing interface for arrival cost. */ #define ACADO_USE_ARRIVAL_COST 0 /** Indicator for usage of non-hard-coded linear terms in the objective. */ #define ACADO_USE_LINEAR_TERMS 0 /** Indicator for type of fixed weighting matrices. */ #define ACADO_WEIGHTING_MATRICES_TYPE 2 /* * Globally used structure definitions */ /** The structure containing the user data. * * Via this structure the user "communicates" with the solver code. */ typedef struct ACADOvariables_ { int dummy; /** Matrix of size: 17 x 4 (row major format) * * Matrix containing 17 differential variable vectors. */ real_t x[ 68 ]; /** Column vector of size: 16 * * Matrix containing 16 control variable vectors. */ real_t u[ 16 ]; /** Matrix of size: 17 x 2 (row major format) * * Matrix containing 17 online data vectors. */ real_t od[ 34 ]; /** Column vector of size: 48 * * Matrix containing 16 reference/measurement vectors of size 3 for first 16 nodes. */ real_t y[ 48 ]; /** Column vector of size: 2 * * Reference/measurement vector for the 17. node. */ real_t yN[ 2 ]; /** Matrix of size: 48 x 3 (row major format) */ real_t W[ 144 ]; /** Matrix of size: 2 x 2 (row major format) */ real_t WN[ 4 ]; /** Column vector of size: 4 * * Current state feedback vector. */ real_t x0[ 4 ]; } ACADOvariables; /** Private workspace used by the auto-generated code. * * Data members of this structure are private to the solver. * In other words, the user code should not modify values of this * structure. */ typedef struct ACADOworkspace_ { /** Column vector of size: 14 */ real_t rhs_aux[ 14 ]; real_t rk_ttt; /** Row vector of size: 27 */ real_t rk_xxx[ 27 ]; /** Matrix of size: 4 x 24 (row major format) */ real_t rk_kkk[ 96 ]; /** Row vector of size: 27 */ real_t state[ 27 ]; /** Column vector of size: 64 */ real_t d[ 64 ]; /** Column vector of size: 48 */ real_t Dy[ 48 ]; /** Column vector of size: 2 */ real_t DyN[ 2 ]; /** Matrix of size: 64 x 4 (row major format) */ real_t evGx[ 256 ]; /** Column vector of size: 64 */ real_t evGu[ 64 ]; /** Row vector of size: 7 */ real_t objValueIn[ 7 ]; /** Row vector of size: 18 */ real_t objValueOut[ 18 ]; /** Matrix of size: 64 x 4 (row major format) */ real_t Q1[ 256 ]; /** Matrix of size: 64 x 3 (row major format) */ real_t Q2[ 192 ]; /** Column vector of size: 16 */ real_t R1[ 16 ]; /** Matrix of size: 16 x 3 (row major format) */ real_t R2[ 48 ]; /** Column vector of size: 64 */ real_t S1[ 64 ]; /** Matrix of size: 4 x 4 (row major format) */ real_t QN1[ 16 ]; /** Matrix of size: 4 x 2 (row major format) */ real_t QN2[ 8 ]; /** Column vector of size: 4 */ real_t Dx0[ 4 ]; /** Matrix of size: 4 x 4 (row major format) */ real_t T[ 16 ]; /** Column vector of size: 544 */ real_t E[ 544 ]; /** Column vector of size: 544 */ real_t QE[ 544 ]; /** Matrix of size: 64 x 4 (row major format) */ real_t QGx[ 256 ]; /** Column vector of size: 64 */ real_t Qd[ 64 ]; /** Column vector of size: 68 */ real_t QDy[ 68 ]; /** Matrix of size: 16 x 4 (row major format) */ real_t H10[ 64 ]; /** Matrix of size: 20 x 20 (row major format) */ real_t H[ 400 ]; /** Matrix of size: 32 x 20 (row major format) */ real_t A[ 640 ]; /** Column vector of size: 20 */ real_t g[ 20 ]; /** Column vector of size: 20 */ real_t lb[ 20 ]; /** Column vector of size: 20 */ real_t ub[ 20 ]; /** Column vector of size: 32 */ real_t lbA[ 32 ]; /** Column vector of size: 32 */ real_t ubA[ 32 ]; /** Column vector of size: 20 */ real_t x[ 20 ]; /** Column vector of size: 52 */ real_t y[ 52 ]; } ACADOworkspace; /* * Forward function declarations. */ /** Performs the integration and sensitivity propagation for one shooting interval. * * \param rk_eta Working array to pass the input values and return the results. * \param resetIntegrator The internal memory of the integrator can be reset. * \param rk_index Number of the shooting interval. * * \return Status code of the integrator. */ int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ); /** Export of an ACADO symbolic function. * * \param in Input to the exported function. * \param out Output of the exported function. */ void acado_rhs_forw(const real_t* in, real_t* out); /** Preparation step of the RTI scheme. * * \return Status of the integration module. =0: OK, otherwise the error code. */ int acado_preparationStep( ); /** Feedback/estimation step of the RTI scheme. * * \return Status code of the qpOASES QP solver. */ int acado_feedbackStep( ); /** Solver initialization. Must be called once before any other function call. * * \return =0: OK, otherwise an error code of a QP solver. */ int acado_initializeSolver( ); /** Initialize shooting nodes by a forward simulation starting from the first node. */ void acado_initializeNodesByForwardSimulation( ); /** Shift differential variables vector by one interval. * * \param strategy Shifting strategy: 1. Initialize node 17 with xEnd. 2. Initialize node 17 by forward simulation. * \param xEnd Value for the x vector on the last node. If =0 the old value is used. * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. */ void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ); /** Shift controls vector by one interval. * * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. */ void acado_shiftControls( real_t* const uEnd ); /** Get the KKT tolerance of the current iterate. * * \return The KKT tolerance value. */ real_t acado_getKKT( ); /** Calculate the objective value. * * \return Value of the objective function. */ real_t acado_getObjective( ); /* * Extern declarations. */ extern ACADOworkspace acadoWorkspace; extern ACADOvariables acadoVariables; /** @} */ #ifndef __MATLAB__ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* __MATLAB__ */ #endif /* ACADO_COMMON_H */ ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_integrator.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_common.h" void acado_rhs_forw(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* u = in + 24; const real_t* od = in + 25; /* Vector of auxiliary variables; number of elements: 14. */ real_t* a = acadoWorkspace.rhs_aux; /* Compute intermediate quantities: */ a[0] = (cos(xd[2])); a[1] = (sin(xd[2])); a[2] = ((real_t)(-1.0000000000000000e+00)*(sin(xd[2]))); a[3] = (xd[12]*a[2]); a[4] = (xd[13]*a[2]); a[5] = (xd[14]*a[2]); a[6] = (xd[15]*a[2]); a[7] = (cos(xd[2])); a[8] = (xd[12]*a[7]); a[9] = (xd[13]*a[7]); a[10] = (xd[14]*a[7]); a[11] = (xd[15]*a[7]); a[12] = (xd[22]*a[2]); a[13] = (xd[22]*a[7]); /* Compute outputs: */ out[0] = (od[0]*a[0]); out[1] = (od[0]*a[1]); out[2] = (od[0]*xd[3]); out[3] = u[0]; out[4] = (od[0]*a[3]); out[5] = (od[0]*a[4]); out[6] = (od[0]*a[5]); out[7] = (od[0]*a[6]); out[8] = (od[0]*a[8]); out[9] = (od[0]*a[9]); out[10] = (od[0]*a[10]); out[11] = (od[0]*a[11]); out[12] = (od[0]*xd[16]); out[13] = (od[0]*xd[17]); out[14] = (od[0]*xd[18]); out[15] = (od[0]*xd[19]); out[16] = (real_t)(0.0000000000000000e+00); out[17] = (real_t)(0.0000000000000000e+00); out[18] = (real_t)(0.0000000000000000e+00); out[19] = (real_t)(0.0000000000000000e+00); out[20] = (od[0]*a[12]); out[21] = (od[0]*a[13]); out[22] = (od[0]*xd[23]); out[23] = (real_t)(1.0000000000000000e+00); } /* Fixed step size:0.0025 */ int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ) { int error; int run1; int numSteps[16] = {4, 12, 20, 27, 35, 43, 51, 59, 66, 74, 82, 90, 98, 105, 113, 121}; int numInts = numSteps[rk_index]; acadoWorkspace.rk_ttt = 0.0000000000000000e+00; rk_eta[4] = 1.0000000000000000e+00; rk_eta[5] = 0.0000000000000000e+00; rk_eta[6] = 0.0000000000000000e+00; rk_eta[7] = 0.0000000000000000e+00; rk_eta[8] = 0.0000000000000000e+00; rk_eta[9] = 1.0000000000000000e+00; rk_eta[10] = 0.0000000000000000e+00; rk_eta[11] = 0.0000000000000000e+00; rk_eta[12] = 0.0000000000000000e+00; rk_eta[13] = 0.0000000000000000e+00; rk_eta[14] = 1.0000000000000000e+00; rk_eta[15] = 0.0000000000000000e+00; rk_eta[16] = 0.0000000000000000e+00; rk_eta[17] = 0.0000000000000000e+00; rk_eta[18] = 0.0000000000000000e+00; rk_eta[19] = 1.0000000000000000e+00; rk_eta[20] = 0.0000000000000000e+00; rk_eta[21] = 0.0000000000000000e+00; rk_eta[22] = 0.0000000000000000e+00; rk_eta[23] = 0.0000000000000000e+00; acadoWorkspace.rk_xxx[24] = rk_eta[24]; acadoWorkspace.rk_xxx[25] = rk_eta[25]; acadoWorkspace.rk_xxx[26] = rk_eta[26]; for (run1 = 0; run1 < 1; ++run1) { for(run1 = 0; run1 < numInts; run1++ ) { acadoWorkspace.rk_xxx[0] = + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + rk_eta[23]; acado_rhs_forw( acadoWorkspace.rk_xxx, acadoWorkspace.rk_kkk ); acadoWorkspace.rk_xxx[0] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[0] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[1] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[2] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[3] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[4] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[5] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[6] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[7] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[8] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[9] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[10] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[11] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[12] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[13] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[14] + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[15] + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[16] + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[17] + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[18] + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[19] + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[20] + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[21] + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[22] + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[23] + rk_eta[23]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 24 ]) ); acadoWorkspace.rk_xxx[0] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[24] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[25] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[26] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[27] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[28] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[29] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[30] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[31] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[32] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[33] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[34] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[35] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[36] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[37] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[38] + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[39] + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[40] + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[41] + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[42] + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[43] + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[44] + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[45] + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[46] + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + (real_t)1.2500000000000000e-03*acadoWorkspace.rk_kkk[47] + rk_eta[23]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 48 ]) ); acadoWorkspace.rk_xxx[0] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[48] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[49] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[50] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[51] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[52] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[53] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[54] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[55] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[56] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[57] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[58] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[59] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[60] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[61] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[62] + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[63] + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[64] + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[65] + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[66] + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[67] + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[68] + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[69] + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[70] + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + (real_t)2.5000000000000001e-03*acadoWorkspace.rk_kkk[71] + rk_eta[23]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 72 ]) ); rk_eta[0] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[0] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[24] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[48] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[72]; rk_eta[1] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[1] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[25] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[49] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[73]; rk_eta[2] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[2] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[26] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[50] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[74]; rk_eta[3] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[3] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[27] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[51] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[75]; rk_eta[4] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[4] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[28] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[52] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[76]; rk_eta[5] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[5] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[29] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[53] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[77]; rk_eta[6] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[6] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[30] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[54] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[78]; rk_eta[7] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[7] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[31] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[55] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[79]; rk_eta[8] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[8] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[32] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[56] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[80]; rk_eta[9] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[9] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[33] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[57] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[81]; rk_eta[10] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[10] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[34] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[58] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[82]; rk_eta[11] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[11] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[35] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[59] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[83]; rk_eta[12] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[12] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[36] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[60] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[84]; rk_eta[13] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[13] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[37] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[61] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[85]; rk_eta[14] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[14] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[38] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[62] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[86]; rk_eta[15] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[15] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[39] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[63] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[87]; rk_eta[16] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[16] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[40] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[64] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[88]; rk_eta[17] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[17] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[41] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[65] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[89]; rk_eta[18] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[18] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[42] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[66] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[90]; rk_eta[19] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[19] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[43] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[67] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[91]; rk_eta[20] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[20] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[44] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[68] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[92]; rk_eta[21] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[21] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[45] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[69] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[93]; rk_eta[22] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[22] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[46] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[70] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[94]; rk_eta[23] += + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[23] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[47] + (real_t)8.3333333333333328e-04*acadoWorkspace.rk_kkk[71] + (real_t)4.1666666666666664e-04*acadoWorkspace.rk_kkk[95]; acadoWorkspace.rk_ttt += 1.0000000000000000e+00; } } error = 0; return error; } ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.cpp ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ extern "C" { #include "acado_common.h" } #include "INCLUDE/QProblem.hpp" #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 #include "INCLUDE/EXTRAS/SolutionAnalysis.hpp" #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ static int acado_nWSR; #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 static SolutionAnalysis acado_sa; #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ int acado_solve( void ) { acado_nWSR = QPOASES_NWSRMAX; QProblem qp(20, 32); returnValue retVal = qp.init(acadoWorkspace.H, acadoWorkspace.g, acadoWorkspace.A, acadoWorkspace.lb, acadoWorkspace.ub, acadoWorkspace.lbA, acadoWorkspace.ubA, acado_nWSR, acadoWorkspace.y); qp.getPrimalSolution( acadoWorkspace.x ); qp.getDualSolution( acadoWorkspace.y ); #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 if (retVal != SUCCESSFUL_RETURN) return (int)retVal; retVal = acado_sa.getHessianInverse( &qp,var ); #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ return (int)retVal; } int acado_getNWSR( void ) { return acado_nWSR; } const char* acado_getErrorString( int error ) { return MessageHandling::getErrorString( error ); } ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_qpoases_interface.hpp ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef QPOASES_HEADER #define QPOASES_HEADER #ifdef PC_DEBUG #include #endif /* PC_DEBUG */ #include #ifdef __cplusplus #define EXTERNC extern "C" #else #define EXTERNC #endif /* * A set of options for qpOASES */ /** Maximum number of optimization variables. */ #define QPOASES_NVMAX 20 /** Maximum number of constraints. */ #define QPOASES_NCMAX 32 /** Maximum number of working set recalculations. */ #define QPOASES_NWSRMAX 50 /** Print level for qpOASES. */ #define QPOASES_PRINTLEVEL PL_NONE /** The value of EPS */ #define QPOASES_EPS 2.221e-16 /** Internally used floating point type */ typedef double real_t; /* * Forward function declarations */ /** A function that calls the QP solver */ EXTERNC int acado_solve( void ); /** Get the number of active set changes */ EXTERNC int acado_getNWSR( void ); /** Get the error string. */ const char* acado_getErrorString( int error ); #endif /* QPOASES_HEADER */ ================================================ FILE: selfdrive/controls/lib/lateral_mpc/lib_mpc_export/acado_solver.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_common.h" /******************************************************************************/ /* */ /* ACADO code generation */ /* */ /******************************************************************************/ int acado_modelSimulation( ) { int ret; int lRun1; ret = 0; for (lRun1 = 0; lRun1 < 16; ++lRun1) { acadoWorkspace.state[0] = acadoVariables.x[lRun1 * 4]; acadoWorkspace.state[1] = acadoVariables.x[lRun1 * 4 + 1]; acadoWorkspace.state[2] = acadoVariables.x[lRun1 * 4 + 2]; acadoWorkspace.state[3] = acadoVariables.x[lRun1 * 4 + 3]; acadoWorkspace.state[24] = acadoVariables.u[lRun1]; acadoWorkspace.state[25] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.state[26] = acadoVariables.od[lRun1 * 2 + 1]; ret = acado_integrate(acadoWorkspace.state, 1, lRun1); acadoWorkspace.d[lRun1 * 4] = acadoWorkspace.state[0] - acadoVariables.x[lRun1 * 4 + 4]; acadoWorkspace.d[lRun1 * 4 + 1] = acadoWorkspace.state[1] - acadoVariables.x[lRun1 * 4 + 5]; acadoWorkspace.d[lRun1 * 4 + 2] = acadoWorkspace.state[2] - acadoVariables.x[lRun1 * 4 + 6]; acadoWorkspace.d[lRun1 * 4 + 3] = acadoWorkspace.state[3] - acadoVariables.x[lRun1 * 4 + 7]; acadoWorkspace.evGx[lRun1 * 16] = acadoWorkspace.state[4]; acadoWorkspace.evGx[lRun1 * 16 + 1] = acadoWorkspace.state[5]; acadoWorkspace.evGx[lRun1 * 16 + 2] = acadoWorkspace.state[6]; acadoWorkspace.evGx[lRun1 * 16 + 3] = acadoWorkspace.state[7]; acadoWorkspace.evGx[lRun1 * 16 + 4] = acadoWorkspace.state[8]; acadoWorkspace.evGx[lRun1 * 16 + 5] = acadoWorkspace.state[9]; acadoWorkspace.evGx[lRun1 * 16 + 6] = acadoWorkspace.state[10]; acadoWorkspace.evGx[lRun1 * 16 + 7] = acadoWorkspace.state[11]; acadoWorkspace.evGx[lRun1 * 16 + 8] = acadoWorkspace.state[12]; acadoWorkspace.evGx[lRun1 * 16 + 9] = acadoWorkspace.state[13]; acadoWorkspace.evGx[lRun1 * 16 + 10] = acadoWorkspace.state[14]; acadoWorkspace.evGx[lRun1 * 16 + 11] = acadoWorkspace.state[15]; acadoWorkspace.evGx[lRun1 * 16 + 12] = acadoWorkspace.state[16]; acadoWorkspace.evGx[lRun1 * 16 + 13] = acadoWorkspace.state[17]; acadoWorkspace.evGx[lRun1 * 16 + 14] = acadoWorkspace.state[18]; acadoWorkspace.evGx[lRun1 * 16 + 15] = acadoWorkspace.state[19]; acadoWorkspace.evGu[lRun1 * 4] = acadoWorkspace.state[20]; acadoWorkspace.evGu[lRun1 * 4 + 1] = acadoWorkspace.state[21]; acadoWorkspace.evGu[lRun1 * 4 + 2] = acadoWorkspace.state[22]; acadoWorkspace.evGu[lRun1 * 4 + 3] = acadoWorkspace.state[23]; } return ret; } void acado_evaluateLSQ(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* u = in + 4; const real_t* od = in + 5; /* Compute outputs: */ out[0] = xd[1]; out[1] = ((od[0]+(real_t)(5.0000000000000000e+00))*xd[2]); out[2] = (((od[0]+(real_t)(5.0000000000000000e+00))*(real_t)(4.0000000000000000e+00))*u[0]); out[3] = (real_t)(0.0000000000000000e+00); out[4] = (real_t)(1.0000000000000000e+00); out[5] = (real_t)(0.0000000000000000e+00); out[6] = (real_t)(0.0000000000000000e+00); out[7] = (real_t)(0.0000000000000000e+00); out[8] = (real_t)(0.0000000000000000e+00); out[9] = (od[0]+(real_t)(5.0000000000000000e+00)); out[10] = (real_t)(0.0000000000000000e+00); out[11] = (real_t)(0.0000000000000000e+00); out[12] = (real_t)(0.0000000000000000e+00); out[13] = (real_t)(0.0000000000000000e+00); out[14] = (real_t)(0.0000000000000000e+00); out[15] = (real_t)(0.0000000000000000e+00); out[16] = (real_t)(0.0000000000000000e+00); out[17] = ((od[0]+(real_t)(5.0000000000000000e+00))*(real_t)(4.0000000000000000e+00)); } void acado_evaluateLSQEndTerm(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* od = in + 4; /* Compute outputs: */ out[0] = xd[1]; out[1] = ((((real_t)(2.0000000000000000e+00)*od[0])+(real_t)(5.0000000000000000e+00))*xd[2]); out[2] = (real_t)(0.0000000000000000e+00); out[3] = (real_t)(1.0000000000000000e+00); out[4] = (real_t)(0.0000000000000000e+00); out[5] = (real_t)(0.0000000000000000e+00); out[6] = (real_t)(0.0000000000000000e+00); out[7] = (real_t)(0.0000000000000000e+00); out[8] = (((real_t)(2.0000000000000000e+00)*od[0])+(real_t)(5.0000000000000000e+00)); out[9] = (real_t)(0.0000000000000000e+00); } void acado_setObjQ1Q2( real_t* const tmpFx, real_t* const tmpObjS, real_t* const tmpQ1, real_t* const tmpQ2 ) { tmpQ2[0] = + tmpFx[0]*tmpObjS[0] + tmpFx[4]*tmpObjS[3] + tmpFx[8]*tmpObjS[6]; tmpQ2[1] = + tmpFx[0]*tmpObjS[1] + tmpFx[4]*tmpObjS[4] + tmpFx[8]*tmpObjS[7]; tmpQ2[2] = + tmpFx[0]*tmpObjS[2] + tmpFx[4]*tmpObjS[5] + tmpFx[8]*tmpObjS[8]; tmpQ2[3] = + tmpFx[1]*tmpObjS[0] + tmpFx[5]*tmpObjS[3] + tmpFx[9]*tmpObjS[6]; tmpQ2[4] = + tmpFx[1]*tmpObjS[1] + tmpFx[5]*tmpObjS[4] + tmpFx[9]*tmpObjS[7]; tmpQ2[5] = + tmpFx[1]*tmpObjS[2] + tmpFx[5]*tmpObjS[5] + tmpFx[9]*tmpObjS[8]; tmpQ2[6] = + tmpFx[2]*tmpObjS[0] + tmpFx[6]*tmpObjS[3] + tmpFx[10]*tmpObjS[6]; tmpQ2[7] = + tmpFx[2]*tmpObjS[1] + tmpFx[6]*tmpObjS[4] + tmpFx[10]*tmpObjS[7]; tmpQ2[8] = + tmpFx[2]*tmpObjS[2] + tmpFx[6]*tmpObjS[5] + tmpFx[10]*tmpObjS[8]; tmpQ2[9] = + tmpFx[3]*tmpObjS[0] + tmpFx[7]*tmpObjS[3] + tmpFx[11]*tmpObjS[6]; tmpQ2[10] = + tmpFx[3]*tmpObjS[1] + tmpFx[7]*tmpObjS[4] + tmpFx[11]*tmpObjS[7]; tmpQ2[11] = + tmpFx[3]*tmpObjS[2] + tmpFx[7]*tmpObjS[5] + tmpFx[11]*tmpObjS[8]; tmpQ1[0] = + tmpQ2[0]*tmpFx[0] + tmpQ2[1]*tmpFx[4] + tmpQ2[2]*tmpFx[8]; tmpQ1[1] = + tmpQ2[0]*tmpFx[1] + tmpQ2[1]*tmpFx[5] + tmpQ2[2]*tmpFx[9]; tmpQ1[2] = + tmpQ2[0]*tmpFx[2] + tmpQ2[1]*tmpFx[6] + tmpQ2[2]*tmpFx[10]; tmpQ1[3] = + tmpQ2[0]*tmpFx[3] + tmpQ2[1]*tmpFx[7] + tmpQ2[2]*tmpFx[11]; tmpQ1[4] = + tmpQ2[3]*tmpFx[0] + tmpQ2[4]*tmpFx[4] + tmpQ2[5]*tmpFx[8]; tmpQ1[5] = + tmpQ2[3]*tmpFx[1] + tmpQ2[4]*tmpFx[5] + tmpQ2[5]*tmpFx[9]; tmpQ1[6] = + tmpQ2[3]*tmpFx[2] + tmpQ2[4]*tmpFx[6] + tmpQ2[5]*tmpFx[10]; tmpQ1[7] = + tmpQ2[3]*tmpFx[3] + tmpQ2[4]*tmpFx[7] + tmpQ2[5]*tmpFx[11]; tmpQ1[8] = + tmpQ2[6]*tmpFx[0] + tmpQ2[7]*tmpFx[4] + tmpQ2[8]*tmpFx[8]; tmpQ1[9] = + tmpQ2[6]*tmpFx[1] + tmpQ2[7]*tmpFx[5] + tmpQ2[8]*tmpFx[9]; tmpQ1[10] = + tmpQ2[6]*tmpFx[2] + tmpQ2[7]*tmpFx[6] + tmpQ2[8]*tmpFx[10]; tmpQ1[11] = + tmpQ2[6]*tmpFx[3] + tmpQ2[7]*tmpFx[7] + tmpQ2[8]*tmpFx[11]; tmpQ1[12] = + tmpQ2[9]*tmpFx[0] + tmpQ2[10]*tmpFx[4] + tmpQ2[11]*tmpFx[8]; tmpQ1[13] = + tmpQ2[9]*tmpFx[1] + tmpQ2[10]*tmpFx[5] + tmpQ2[11]*tmpFx[9]; tmpQ1[14] = + tmpQ2[9]*tmpFx[2] + tmpQ2[10]*tmpFx[6] + tmpQ2[11]*tmpFx[10]; tmpQ1[15] = + tmpQ2[9]*tmpFx[3] + tmpQ2[10]*tmpFx[7] + tmpQ2[11]*tmpFx[11]; } void acado_setObjR1R2( real_t* const tmpFu, real_t* const tmpObjS, real_t* const tmpR1, real_t* const tmpR2 ) { tmpR2[0] = + tmpFu[0]*tmpObjS[0] + tmpFu[1]*tmpObjS[3] + tmpFu[2]*tmpObjS[6]; tmpR2[1] = + tmpFu[0]*tmpObjS[1] + tmpFu[1]*tmpObjS[4] + tmpFu[2]*tmpObjS[7]; tmpR2[2] = + tmpFu[0]*tmpObjS[2] + tmpFu[1]*tmpObjS[5] + tmpFu[2]*tmpObjS[8]; tmpR1[0] = + tmpR2[0]*tmpFu[0] + tmpR2[1]*tmpFu[1] + tmpR2[2]*tmpFu[2]; } void acado_setObjQN1QN2( real_t* const tmpFx, real_t* const tmpObjSEndTerm, real_t* const tmpQN1, real_t* const tmpQN2 ) { tmpQN2[0] = + tmpFx[0]*tmpObjSEndTerm[0] + tmpFx[4]*tmpObjSEndTerm[2]; tmpQN2[1] = + tmpFx[0]*tmpObjSEndTerm[1] + tmpFx[4]*tmpObjSEndTerm[3]; tmpQN2[2] = + tmpFx[1]*tmpObjSEndTerm[0] + tmpFx[5]*tmpObjSEndTerm[2]; tmpQN2[3] = + tmpFx[1]*tmpObjSEndTerm[1] + tmpFx[5]*tmpObjSEndTerm[3]; tmpQN2[4] = + tmpFx[2]*tmpObjSEndTerm[0] + tmpFx[6]*tmpObjSEndTerm[2]; tmpQN2[5] = + tmpFx[2]*tmpObjSEndTerm[1] + tmpFx[6]*tmpObjSEndTerm[3]; tmpQN2[6] = + tmpFx[3]*tmpObjSEndTerm[0] + tmpFx[7]*tmpObjSEndTerm[2]; tmpQN2[7] = + tmpFx[3]*tmpObjSEndTerm[1] + tmpFx[7]*tmpObjSEndTerm[3]; tmpQN1[0] = + tmpQN2[0]*tmpFx[0] + tmpQN2[1]*tmpFx[4]; tmpQN1[1] = + tmpQN2[0]*tmpFx[1] + tmpQN2[1]*tmpFx[5]; tmpQN1[2] = + tmpQN2[0]*tmpFx[2] + tmpQN2[1]*tmpFx[6]; tmpQN1[3] = + tmpQN2[0]*tmpFx[3] + tmpQN2[1]*tmpFx[7]; tmpQN1[4] = + tmpQN2[2]*tmpFx[0] + tmpQN2[3]*tmpFx[4]; tmpQN1[5] = + tmpQN2[2]*tmpFx[1] + tmpQN2[3]*tmpFx[5]; tmpQN1[6] = + tmpQN2[2]*tmpFx[2] + tmpQN2[3]*tmpFx[6]; tmpQN1[7] = + tmpQN2[2]*tmpFx[3] + tmpQN2[3]*tmpFx[7]; tmpQN1[8] = + tmpQN2[4]*tmpFx[0] + tmpQN2[5]*tmpFx[4]; tmpQN1[9] = + tmpQN2[4]*tmpFx[1] + tmpQN2[5]*tmpFx[5]; tmpQN1[10] = + tmpQN2[4]*tmpFx[2] + tmpQN2[5]*tmpFx[6]; tmpQN1[11] = + tmpQN2[4]*tmpFx[3] + tmpQN2[5]*tmpFx[7]; tmpQN1[12] = + tmpQN2[6]*tmpFx[0] + tmpQN2[7]*tmpFx[4]; tmpQN1[13] = + tmpQN2[6]*tmpFx[1] + tmpQN2[7]*tmpFx[5]; tmpQN1[14] = + tmpQN2[6]*tmpFx[2] + tmpQN2[7]*tmpFx[6]; tmpQN1[15] = + tmpQN2[6]*tmpFx[3] + tmpQN2[7]*tmpFx[7]; } void acado_evaluateObjective( ) { int runObj; for (runObj = 0; runObj < 16; ++runObj) { acadoWorkspace.objValueIn[0] = acadoVariables.x[runObj * 4]; acadoWorkspace.objValueIn[1] = acadoVariables.x[runObj * 4 + 1]; acadoWorkspace.objValueIn[2] = acadoVariables.x[runObj * 4 + 2]; acadoWorkspace.objValueIn[3] = acadoVariables.x[runObj * 4 + 3]; acadoWorkspace.objValueIn[4] = acadoVariables.u[runObj]; acadoWorkspace.objValueIn[5] = acadoVariables.od[runObj * 2]; acadoWorkspace.objValueIn[6] = acadoVariables.od[runObj * 2 + 1]; acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.Dy[runObj * 3] = acadoWorkspace.objValueOut[0]; acadoWorkspace.Dy[runObj * 3 + 1] = acadoWorkspace.objValueOut[1]; acadoWorkspace.Dy[runObj * 3 + 2] = acadoWorkspace.objValueOut[2]; acado_setObjQ1Q2( &(acadoWorkspace.objValueOut[ 3 ]), &(acadoVariables.W[ runObj * 9 ]), &(acadoWorkspace.Q1[ runObj * 16 ]), &(acadoWorkspace.Q2[ runObj * 12 ]) ); acado_setObjR1R2( &(acadoWorkspace.objValueOut[ 15 ]), &(acadoVariables.W[ runObj * 9 ]), &(acadoWorkspace.R1[ runObj ]), &(acadoWorkspace.R2[ runObj * 3 ]) ); } acadoWorkspace.objValueIn[0] = acadoVariables.x[64]; acadoWorkspace.objValueIn[1] = acadoVariables.x[65]; acadoWorkspace.objValueIn[2] = acadoVariables.x[66]; acadoWorkspace.objValueIn[3] = acadoVariables.x[67]; acadoWorkspace.objValueIn[4] = acadoVariables.od[32]; acadoWorkspace.objValueIn[5] = acadoVariables.od[33]; acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0]; acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1]; acado_setObjQN1QN2( &(acadoWorkspace.objValueOut[ 2 ]), acadoVariables.WN, acadoWorkspace.QN1, acadoWorkspace.QN2 ); } void acado_multGxd( real_t* const dOld, real_t* const Gx1, real_t* const dNew ) { dNew[0] += + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2] + Gx1[3]*dOld[3]; dNew[1] += + Gx1[4]*dOld[0] + Gx1[5]*dOld[1] + Gx1[6]*dOld[2] + Gx1[7]*dOld[3]; dNew[2] += + Gx1[8]*dOld[0] + Gx1[9]*dOld[1] + Gx1[10]*dOld[2] + Gx1[11]*dOld[3]; dNew[3] += + Gx1[12]*dOld[0] + Gx1[13]*dOld[1] + Gx1[14]*dOld[2] + Gx1[15]*dOld[3]; } void acado_moveGxT( real_t* const Gx1, real_t* const Gx2 ) { Gx2[0] = Gx1[0]; Gx2[1] = Gx1[1]; Gx2[2] = Gx1[2]; Gx2[3] = Gx1[3]; Gx2[4] = Gx1[4]; Gx2[5] = Gx1[5]; Gx2[6] = Gx1[6]; Gx2[7] = Gx1[7]; Gx2[8] = Gx1[8]; Gx2[9] = Gx1[9]; Gx2[10] = Gx1[10]; Gx2[11] = Gx1[11]; Gx2[12] = Gx1[12]; Gx2[13] = Gx1[13]; Gx2[14] = Gx1[14]; Gx2[15] = Gx1[15]; } void acado_multGxGx( real_t* const Gx1, real_t* const Gx2, real_t* const Gx3 ) { Gx3[0] = + Gx1[0]*Gx2[0] + Gx1[1]*Gx2[4] + Gx1[2]*Gx2[8] + Gx1[3]*Gx2[12]; Gx3[1] = + Gx1[0]*Gx2[1] + Gx1[1]*Gx2[5] + Gx1[2]*Gx2[9] + Gx1[3]*Gx2[13]; Gx3[2] = + Gx1[0]*Gx2[2] + Gx1[1]*Gx2[6] + Gx1[2]*Gx2[10] + Gx1[3]*Gx2[14]; Gx3[3] = + Gx1[0]*Gx2[3] + Gx1[1]*Gx2[7] + Gx1[2]*Gx2[11] + Gx1[3]*Gx2[15]; Gx3[4] = + Gx1[4]*Gx2[0] + Gx1[5]*Gx2[4] + Gx1[6]*Gx2[8] + Gx1[7]*Gx2[12]; Gx3[5] = + Gx1[4]*Gx2[1] + Gx1[5]*Gx2[5] + Gx1[6]*Gx2[9] + Gx1[7]*Gx2[13]; Gx3[6] = + Gx1[4]*Gx2[2] + Gx1[5]*Gx2[6] + Gx1[6]*Gx2[10] + Gx1[7]*Gx2[14]; Gx3[7] = + Gx1[4]*Gx2[3] + Gx1[5]*Gx2[7] + Gx1[6]*Gx2[11] + Gx1[7]*Gx2[15]; Gx3[8] = + Gx1[8]*Gx2[0] + Gx1[9]*Gx2[4] + Gx1[10]*Gx2[8] + Gx1[11]*Gx2[12]; Gx3[9] = + Gx1[8]*Gx2[1] + Gx1[9]*Gx2[5] + Gx1[10]*Gx2[9] + Gx1[11]*Gx2[13]; Gx3[10] = + Gx1[8]*Gx2[2] + Gx1[9]*Gx2[6] + Gx1[10]*Gx2[10] + Gx1[11]*Gx2[14]; Gx3[11] = + Gx1[8]*Gx2[3] + Gx1[9]*Gx2[7] + Gx1[10]*Gx2[11] + Gx1[11]*Gx2[15]; Gx3[12] = + Gx1[12]*Gx2[0] + Gx1[13]*Gx2[4] + Gx1[14]*Gx2[8] + Gx1[15]*Gx2[12]; Gx3[13] = + Gx1[12]*Gx2[1] + Gx1[13]*Gx2[5] + Gx1[14]*Gx2[9] + Gx1[15]*Gx2[13]; Gx3[14] = + Gx1[12]*Gx2[2] + Gx1[13]*Gx2[6] + Gx1[14]*Gx2[10] + Gx1[15]*Gx2[14]; Gx3[15] = + Gx1[12]*Gx2[3] + Gx1[13]*Gx2[7] + Gx1[14]*Gx2[11] + Gx1[15]*Gx2[15]; } void acado_multGxGu( real_t* const Gx1, real_t* const Gu1, real_t* const Gu2 ) { Gu2[0] = + Gx1[0]*Gu1[0] + Gx1[1]*Gu1[1] + Gx1[2]*Gu1[2] + Gx1[3]*Gu1[3]; Gu2[1] = + Gx1[4]*Gu1[0] + Gx1[5]*Gu1[1] + Gx1[6]*Gu1[2] + Gx1[7]*Gu1[3]; Gu2[2] = + Gx1[8]*Gu1[0] + Gx1[9]*Gu1[1] + Gx1[10]*Gu1[2] + Gx1[11]*Gu1[3]; Gu2[3] = + Gx1[12]*Gu1[0] + Gx1[13]*Gu1[1] + Gx1[14]*Gu1[2] + Gx1[15]*Gu1[3]; } void acado_moveGuE( real_t* const Gu1, real_t* const Gu2 ) { Gu2[0] = Gu1[0]; Gu2[1] = Gu1[1]; Gu2[2] = Gu1[2]; Gu2[3] = Gu1[3]; } void acado_setBlockH11( int iRow, int iCol, real_t* const Gu1, real_t* const Gu2 ) { acadoWorkspace.H[(iRow * 20 + 80) + (iCol + 4)] += + Gu1[0]*Gu2[0] + Gu1[1]*Gu2[1] + Gu1[2]*Gu2[2] + Gu1[3]*Gu2[3]; } void acado_setBlockH11_R1( int iRow, int iCol, real_t* const R11 ) { acadoWorkspace.H[(iRow * 20 + 80) + (iCol + 4)] = R11[0]; } void acado_zeroBlockH11( int iRow, int iCol ) { acadoWorkspace.H[(iRow * 20 + 80) + (iCol + 4)] = 0.0000000000000000e+00; } void acado_copyHTH( int iRow, int iCol ) { acadoWorkspace.H[(iRow * 20 + 80) + (iCol + 4)] = acadoWorkspace.H[(iCol * 20 + 80) + (iRow + 4)]; } void acado_multQ1d( real_t* const Gx1, real_t* const dOld, real_t* const dNew ) { dNew[0] = + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2] + Gx1[3]*dOld[3]; dNew[1] = + Gx1[4]*dOld[0] + Gx1[5]*dOld[1] + Gx1[6]*dOld[2] + Gx1[7]*dOld[3]; dNew[2] = + Gx1[8]*dOld[0] + Gx1[9]*dOld[1] + Gx1[10]*dOld[2] + Gx1[11]*dOld[3]; dNew[3] = + Gx1[12]*dOld[0] + Gx1[13]*dOld[1] + Gx1[14]*dOld[2] + Gx1[15]*dOld[3]; } void acado_multQN1d( real_t* const QN1, real_t* const dOld, real_t* const dNew ) { dNew[0] = + acadoWorkspace.QN1[0]*dOld[0] + acadoWorkspace.QN1[1]*dOld[1] + acadoWorkspace.QN1[2]*dOld[2] + acadoWorkspace.QN1[3]*dOld[3]; dNew[1] = + acadoWorkspace.QN1[4]*dOld[0] + acadoWorkspace.QN1[5]*dOld[1] + acadoWorkspace.QN1[6]*dOld[2] + acadoWorkspace.QN1[7]*dOld[3]; dNew[2] = + acadoWorkspace.QN1[8]*dOld[0] + acadoWorkspace.QN1[9]*dOld[1] + acadoWorkspace.QN1[10]*dOld[2] + acadoWorkspace.QN1[11]*dOld[3]; dNew[3] = + acadoWorkspace.QN1[12]*dOld[0] + acadoWorkspace.QN1[13]*dOld[1] + acadoWorkspace.QN1[14]*dOld[2] + acadoWorkspace.QN1[15]*dOld[3]; } void acado_multRDy( real_t* const R2, real_t* const Dy1, real_t* const RDy1 ) { RDy1[0] = + R2[0]*Dy1[0] + R2[1]*Dy1[1] + R2[2]*Dy1[2]; } void acado_multQDy( real_t* const Q2, real_t* const Dy1, real_t* const QDy1 ) { QDy1[0] = + Q2[0]*Dy1[0] + Q2[1]*Dy1[1] + Q2[2]*Dy1[2]; QDy1[1] = + Q2[3]*Dy1[0] + Q2[4]*Dy1[1] + Q2[5]*Dy1[2]; QDy1[2] = + Q2[6]*Dy1[0] + Q2[7]*Dy1[1] + Q2[8]*Dy1[2]; QDy1[3] = + Q2[9]*Dy1[0] + Q2[10]*Dy1[1] + Q2[11]*Dy1[2]; } void acado_multEQDy( real_t* const E1, real_t* const QDy1, real_t* const U1 ) { U1[0] += + E1[0]*QDy1[0] + E1[1]*QDy1[1] + E1[2]*QDy1[2] + E1[3]*QDy1[3]; } void acado_multQETGx( real_t* const E1, real_t* const Gx1, real_t* const H101 ) { H101[0] += + E1[0]*Gx1[0] + E1[1]*Gx1[4] + E1[2]*Gx1[8] + E1[3]*Gx1[12]; H101[1] += + E1[0]*Gx1[1] + E1[1]*Gx1[5] + E1[2]*Gx1[9] + E1[3]*Gx1[13]; H101[2] += + E1[0]*Gx1[2] + E1[1]*Gx1[6] + E1[2]*Gx1[10] + E1[3]*Gx1[14]; H101[3] += + E1[0]*Gx1[3] + E1[1]*Gx1[7] + E1[2]*Gx1[11] + E1[3]*Gx1[15]; } void acado_zeroBlockH10( real_t* const H101 ) { { int lCopy; for (lCopy = 0; lCopy < 4; lCopy++) H101[ lCopy ] = 0; } } void acado_multEDu( real_t* const E1, real_t* const U1, real_t* const dNew ) { dNew[0] += + E1[0]*U1[0]; dNew[1] += + E1[1]*U1[0]; dNew[2] += + E1[2]*U1[0]; dNew[3] += + E1[3]*U1[0]; } void acado_zeroBlockH00( ) { acadoWorkspace.H[0] = 0.0000000000000000e+00; acadoWorkspace.H[1] = 0.0000000000000000e+00; acadoWorkspace.H[2] = 0.0000000000000000e+00; acadoWorkspace.H[3] = 0.0000000000000000e+00; acadoWorkspace.H[20] = 0.0000000000000000e+00; acadoWorkspace.H[21] = 0.0000000000000000e+00; acadoWorkspace.H[22] = 0.0000000000000000e+00; acadoWorkspace.H[23] = 0.0000000000000000e+00; acadoWorkspace.H[40] = 0.0000000000000000e+00; acadoWorkspace.H[41] = 0.0000000000000000e+00; acadoWorkspace.H[42] = 0.0000000000000000e+00; acadoWorkspace.H[43] = 0.0000000000000000e+00; acadoWorkspace.H[60] = 0.0000000000000000e+00; acadoWorkspace.H[61] = 0.0000000000000000e+00; acadoWorkspace.H[62] = 0.0000000000000000e+00; acadoWorkspace.H[63] = 0.0000000000000000e+00; } void acado_multCTQC( real_t* const Gx1, real_t* const Gx2 ) { acadoWorkspace.H[0] += + Gx1[0]*Gx2[0] + Gx1[4]*Gx2[4] + Gx1[8]*Gx2[8] + Gx1[12]*Gx2[12]; acadoWorkspace.H[1] += + Gx1[0]*Gx2[1] + Gx1[4]*Gx2[5] + Gx1[8]*Gx2[9] + Gx1[12]*Gx2[13]; acadoWorkspace.H[2] += + Gx1[0]*Gx2[2] + Gx1[4]*Gx2[6] + Gx1[8]*Gx2[10] + Gx1[12]*Gx2[14]; acadoWorkspace.H[3] += + Gx1[0]*Gx2[3] + Gx1[4]*Gx2[7] + Gx1[8]*Gx2[11] + Gx1[12]*Gx2[15]; acadoWorkspace.H[20] += + Gx1[1]*Gx2[0] + Gx1[5]*Gx2[4] + Gx1[9]*Gx2[8] + Gx1[13]*Gx2[12]; acadoWorkspace.H[21] += + Gx1[1]*Gx2[1] + Gx1[5]*Gx2[5] + Gx1[9]*Gx2[9] + Gx1[13]*Gx2[13]; acadoWorkspace.H[22] += + Gx1[1]*Gx2[2] + Gx1[5]*Gx2[6] + Gx1[9]*Gx2[10] + Gx1[13]*Gx2[14]; acadoWorkspace.H[23] += + Gx1[1]*Gx2[3] + Gx1[5]*Gx2[7] + Gx1[9]*Gx2[11] + Gx1[13]*Gx2[15]; acadoWorkspace.H[40] += + Gx1[2]*Gx2[0] + Gx1[6]*Gx2[4] + Gx1[10]*Gx2[8] + Gx1[14]*Gx2[12]; acadoWorkspace.H[41] += + Gx1[2]*Gx2[1] + Gx1[6]*Gx2[5] + Gx1[10]*Gx2[9] + Gx1[14]*Gx2[13]; acadoWorkspace.H[42] += + Gx1[2]*Gx2[2] + Gx1[6]*Gx2[6] + Gx1[10]*Gx2[10] + Gx1[14]*Gx2[14]; acadoWorkspace.H[43] += + Gx1[2]*Gx2[3] + Gx1[6]*Gx2[7] + Gx1[10]*Gx2[11] + Gx1[14]*Gx2[15]; acadoWorkspace.H[60] += + Gx1[3]*Gx2[0] + Gx1[7]*Gx2[4] + Gx1[11]*Gx2[8] + Gx1[15]*Gx2[12]; acadoWorkspace.H[61] += + Gx1[3]*Gx2[1] + Gx1[7]*Gx2[5] + Gx1[11]*Gx2[9] + Gx1[15]*Gx2[13]; acadoWorkspace.H[62] += + Gx1[3]*Gx2[2] + Gx1[7]*Gx2[6] + Gx1[11]*Gx2[10] + Gx1[15]*Gx2[14]; acadoWorkspace.H[63] += + Gx1[3]*Gx2[3] + Gx1[7]*Gx2[7] + Gx1[11]*Gx2[11] + Gx1[15]*Gx2[15]; } void acado_macCTSlx( real_t* const C0, real_t* const g0 ) { g0[0] += 0.0; ; g0[1] += 0.0; ; g0[2] += 0.0; ; g0[3] += 0.0; ; } void acado_macETSlu( real_t* const E0, real_t* const g1 ) { g1[0] += 0.0; ; } void acado_condensePrep( ) { int lRun1; int lRun2; int lRun3; int lRun4; int lRun5; /** Row vector of size: 32 */ static const int xBoundIndices[ 32 ] = { 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31, 34, 35, 38, 39, 42, 43, 46, 47, 50, 51, 54, 55, 58, 59, 62, 63, 66, 67 }; acado_moveGuE( acadoWorkspace.evGu, acadoWorkspace.E ); acado_moveGxT( &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.T ); acado_multGxd( acadoWorkspace.d, &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.d[ 4 ]) ); acado_multGxGx( acadoWorkspace.T, acadoWorkspace.evGx, &(acadoWorkspace.evGx[ 16 ]) ); acado_multGxGu( acadoWorkspace.T, acadoWorkspace.E, &(acadoWorkspace.E[ 4 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 4 ]), &(acadoWorkspace.E[ 8 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 4 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.d[ 8 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.evGx[ 32 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.E[ 12 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.E[ 16 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 8 ]), &(acadoWorkspace.E[ 20 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 8 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.d[ 12 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.evGx[ 48 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.E[ 24 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.E[ 28 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.E[ 32 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 12 ]), &(acadoWorkspace.E[ 36 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.d[ 16 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.evGx[ 64 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.E[ 40 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.E[ 44 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.E[ 48 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.E[ 52 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 16 ]), &(acadoWorkspace.E[ 56 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 16 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.d[ 20 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.evGx[ 80 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.E[ 60 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.E[ 64 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.E[ 68 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.E[ 72 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.E[ 76 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 20 ]), &(acadoWorkspace.E[ 80 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 20 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.d[ 24 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.evGx[ 96 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.E[ 84 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.E[ 88 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.E[ 92 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.E[ 96 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.E[ 100 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.E[ 104 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 24 ]), &(acadoWorkspace.E[ 108 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.d[ 28 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.evGx[ 112 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.E[ 112 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.E[ 116 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.E[ 120 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.E[ 124 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.E[ 128 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.E[ 132 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.E[ 136 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 28 ]), &(acadoWorkspace.E[ 140 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 28 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.d[ 32 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.evGx[ 128 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.E[ 144 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.E[ 148 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.E[ 152 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.E[ 156 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.E[ 160 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.E[ 164 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.E[ 168 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.E[ 172 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 32 ]), &(acadoWorkspace.E[ 176 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 32 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.d[ 36 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.evGx[ 144 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.E[ 180 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.E[ 184 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.E[ 188 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.E[ 192 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.E[ 196 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.E[ 200 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.E[ 204 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.E[ 208 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.E[ 212 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 36 ]), &(acadoWorkspace.E[ 216 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.d[ 40 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.evGx[ 160 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.E[ 220 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.E[ 224 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.E[ 228 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.E[ 232 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.E[ 236 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.E[ 240 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.E[ 244 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.E[ 248 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.E[ 252 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.E[ 256 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 40 ]), &(acadoWorkspace.E[ 260 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 40 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.d[ 44 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.evGx[ 176 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.E[ 264 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.E[ 268 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.E[ 272 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.E[ 276 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.E[ 280 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.E[ 284 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.E[ 288 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.E[ 292 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.E[ 296 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.E[ 300 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.E[ 304 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 44 ]), &(acadoWorkspace.E[ 308 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 44 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.d[ 48 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.evGx[ 192 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.E[ 312 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.E[ 316 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.E[ 320 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.E[ 324 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.E[ 328 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.E[ 332 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.E[ 336 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.E[ 340 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.E[ 344 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.E[ 348 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.E[ 352 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.E[ 356 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 48 ]), &(acadoWorkspace.E[ 360 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.d[ 52 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.evGx[ 208 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.E[ 364 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.E[ 368 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.E[ 372 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.E[ 376 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.E[ 380 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.E[ 384 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.E[ 388 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.E[ 392 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.E[ 396 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.E[ 400 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.E[ 404 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.E[ 408 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.E[ 412 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 52 ]), &(acadoWorkspace.E[ 416 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 52 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.d[ 56 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.evGx[ 224 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.E[ 420 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.E[ 424 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.E[ 428 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.E[ 432 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.E[ 436 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.E[ 440 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.E[ 444 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.E[ 448 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.E[ 452 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.E[ 456 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.E[ 460 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.E[ 464 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.E[ 468 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.E[ 472 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 56 ]), &(acadoWorkspace.E[ 476 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 56 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.d[ 60 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.evGx[ 240 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.E[ 480 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.E[ 484 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.E[ 488 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.E[ 492 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.E[ 496 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.E[ 500 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.E[ 504 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.E[ 508 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.E[ 512 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.E[ 516 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.E[ 520 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.E[ 524 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.E[ 528 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.E[ 532 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.E[ 536 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 60 ]), &(acadoWorkspace.E[ 540 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.evGx, acadoWorkspace.QGx ); acado_multGxGx( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.QGx[ 16 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.QGx[ 32 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.QGx[ 48 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.QGx[ 64 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.QGx[ 80 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.QGx[ 96 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.QGx[ 112 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.QGx[ 128 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.QGx[ 160 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.QGx[ 176 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.QGx[ 192 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.QGx[ 208 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.QGx[ 224 ]) ); acado_multGxGx( acadoWorkspace.QN1, &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.QGx[ 240 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.E, acadoWorkspace.QE ); acado_multGxGu( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QE[ 4 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.QE[ 8 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QE[ 16 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.QE[ 20 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 28 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QE[ 32 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 40 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 44 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QE[ 52 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.QE[ 56 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 64 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 68 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QE[ 76 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 88 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 92 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 100 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 112 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 116 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 124 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 128 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 148 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 152 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 160 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 184 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 188 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 196 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 220 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 224 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 232 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 236 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 268 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 272 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 280 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 316 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 320 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 328 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 364 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 368 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 376 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 380 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 424 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 428 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 436 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 484 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 488 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 496 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_zeroBlockH00( ); acado_multCTQC( acadoWorkspace.evGx, acadoWorkspace.QGx ); acado_multCTQC( &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.QGx[ 16 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.QGx[ 32 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.QGx[ 48 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.QGx[ 64 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.QGx[ 80 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.QGx[ 96 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.QGx[ 112 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.QGx[ 128 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.QGx[ 160 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.QGx[ 176 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.QGx[ 192 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.QGx[ 208 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.QGx[ 224 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.QGx[ 240 ]) ); acado_zeroBlockH10( acadoWorkspace.H10 ); acado_multQETGx( acadoWorkspace.QE, acadoWorkspace.evGx, acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 4 ]), &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 40 ]), &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 112 ]), &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 220 ]), &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 364 ]), &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.H10 ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 8 ]), &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 16 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 28 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 44 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 64 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 88 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 116 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 148 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 184 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 224 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 268 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 316 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 368 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 424 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 484 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 4 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 20 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 32 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 68 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 92 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 152 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 188 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 272 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 320 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 428 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 488 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 8 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 52 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 124 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 232 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 376 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 56 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 76 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 100 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 128 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 160 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 196 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 236 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 280 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 328 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 380 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 436 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 496 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 16 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 80 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 104 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 164 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 200 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 284 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 332 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 440 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 500 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 20 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 136 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 244 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 388 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 140 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 172 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 208 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 248 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 292 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 340 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 392 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 448 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 508 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 28 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 176 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 212 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 296 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 344 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 452 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 512 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 32 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 256 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 400 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 40 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 260 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.H10[ 40 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 304 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 40 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 352 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 40 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 404 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 40 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 460 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 40 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 520 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 40 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 44 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 308 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.H10[ 44 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 356 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 44 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 44 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 464 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 44 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 524 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 44 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 412 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 52 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 416 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.H10[ 52 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 472 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 52 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 532 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 52 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 56 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 476 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.H10[ 56 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 536 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 56 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 60 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.H10[ 60 ]) ); acadoWorkspace.H[4] = acadoWorkspace.H10[0]; acadoWorkspace.H[5] = acadoWorkspace.H10[4]; acadoWorkspace.H[6] = acadoWorkspace.H10[8]; acadoWorkspace.H[7] = acadoWorkspace.H10[12]; acadoWorkspace.H[8] = acadoWorkspace.H10[16]; acadoWorkspace.H[9] = acadoWorkspace.H10[20]; acadoWorkspace.H[10] = acadoWorkspace.H10[24]; acadoWorkspace.H[11] = acadoWorkspace.H10[28]; acadoWorkspace.H[12] = acadoWorkspace.H10[32]; acadoWorkspace.H[13] = acadoWorkspace.H10[36]; acadoWorkspace.H[14] = acadoWorkspace.H10[40]; acadoWorkspace.H[15] = acadoWorkspace.H10[44]; acadoWorkspace.H[16] = acadoWorkspace.H10[48]; acadoWorkspace.H[17] = acadoWorkspace.H10[52]; acadoWorkspace.H[18] = acadoWorkspace.H10[56]; acadoWorkspace.H[19] = acadoWorkspace.H10[60]; acadoWorkspace.H[24] = acadoWorkspace.H10[1]; acadoWorkspace.H[25] = acadoWorkspace.H10[5]; acadoWorkspace.H[26] = acadoWorkspace.H10[9]; acadoWorkspace.H[27] = acadoWorkspace.H10[13]; acadoWorkspace.H[28] = acadoWorkspace.H10[17]; acadoWorkspace.H[29] = acadoWorkspace.H10[21]; acadoWorkspace.H[30] = acadoWorkspace.H10[25]; acadoWorkspace.H[31] = acadoWorkspace.H10[29]; acadoWorkspace.H[32] = acadoWorkspace.H10[33]; acadoWorkspace.H[33] = acadoWorkspace.H10[37]; acadoWorkspace.H[34] = acadoWorkspace.H10[41]; acadoWorkspace.H[35] = acadoWorkspace.H10[45]; acadoWorkspace.H[36] = acadoWorkspace.H10[49]; acadoWorkspace.H[37] = acadoWorkspace.H10[53]; acadoWorkspace.H[38] = acadoWorkspace.H10[57]; acadoWorkspace.H[39] = acadoWorkspace.H10[61]; acadoWorkspace.H[44] = acadoWorkspace.H10[2]; acadoWorkspace.H[45] = acadoWorkspace.H10[6]; acadoWorkspace.H[46] = acadoWorkspace.H10[10]; acadoWorkspace.H[47] = acadoWorkspace.H10[14]; acadoWorkspace.H[48] = acadoWorkspace.H10[18]; acadoWorkspace.H[49] = acadoWorkspace.H10[22]; acadoWorkspace.H[50] = acadoWorkspace.H10[26]; acadoWorkspace.H[51] = acadoWorkspace.H10[30]; acadoWorkspace.H[52] = acadoWorkspace.H10[34]; acadoWorkspace.H[53] = acadoWorkspace.H10[38]; acadoWorkspace.H[54] = acadoWorkspace.H10[42]; acadoWorkspace.H[55] = acadoWorkspace.H10[46]; acadoWorkspace.H[56] = acadoWorkspace.H10[50]; acadoWorkspace.H[57] = acadoWorkspace.H10[54]; acadoWorkspace.H[58] = acadoWorkspace.H10[58]; acadoWorkspace.H[59] = acadoWorkspace.H10[62]; acadoWorkspace.H[64] = acadoWorkspace.H10[3]; acadoWorkspace.H[65] = acadoWorkspace.H10[7]; acadoWorkspace.H[66] = acadoWorkspace.H10[11]; acadoWorkspace.H[67] = acadoWorkspace.H10[15]; acadoWorkspace.H[68] = acadoWorkspace.H10[19]; acadoWorkspace.H[69] = acadoWorkspace.H10[23]; acadoWorkspace.H[70] = acadoWorkspace.H10[27]; acadoWorkspace.H[71] = acadoWorkspace.H10[31]; acadoWorkspace.H[72] = acadoWorkspace.H10[35]; acadoWorkspace.H[73] = acadoWorkspace.H10[39]; acadoWorkspace.H[74] = acadoWorkspace.H10[43]; acadoWorkspace.H[75] = acadoWorkspace.H10[47]; acadoWorkspace.H[76] = acadoWorkspace.H10[51]; acadoWorkspace.H[77] = acadoWorkspace.H10[55]; acadoWorkspace.H[78] = acadoWorkspace.H10[59]; acadoWorkspace.H[79] = acadoWorkspace.H10[63]; acado_setBlockH11_R1( 0, 0, acadoWorkspace.R1 ); acado_setBlockH11( 0, 0, acadoWorkspace.E, acadoWorkspace.QE ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QE[ 4 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 40 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 112 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 220 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 364 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_zeroBlockH11( 0, 1 ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QE[ 8 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 16 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 28 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 44 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 64 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 88 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 116 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 148 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 184 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 224 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 268 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 316 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 368 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 424 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 484 ]) ); acado_zeroBlockH11( 0, 2 ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 20 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 32 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 68 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 92 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 152 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 188 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 272 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 320 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 428 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 488 ]) ); acado_zeroBlockH11( 0, 3 ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 52 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 124 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 232 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 376 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_zeroBlockH11( 0, 4 ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QE[ 56 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 76 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 100 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 128 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 160 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 196 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 236 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 280 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 328 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 380 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 436 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 496 ]) ); acado_zeroBlockH11( 0, 5 ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_zeroBlockH11( 0, 6 ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 0, 7 ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 0, 8 ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 0, 9 ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 0, 10 ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 0, 11 ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 0, 12 ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 0, 13 ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 0, 14 ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 0, 15 ); acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 1, 1, &(acadoWorkspace.R1[ 1 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.QE[ 8 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QE[ 16 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 28 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 44 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 64 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 88 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 116 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 148 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 184 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 224 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 268 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 316 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 368 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 424 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 484 ]) ); acado_zeroBlockH11( 1, 2 ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QE[ 20 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 32 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 68 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 92 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 152 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 188 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 272 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 320 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 428 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 488 ]) ); acado_zeroBlockH11( 1, 3 ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 52 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 124 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 232 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 376 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_zeroBlockH11( 1, 4 ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QE[ 56 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 76 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 100 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 128 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 160 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 196 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 236 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 280 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 328 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 380 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 436 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 496 ]) ); acado_zeroBlockH11( 1, 5 ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_zeroBlockH11( 1, 6 ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 1, 7 ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 1, 8 ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 1, 9 ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 1, 10 ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 1, 11 ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 1, 12 ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 1, 13 ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 1, 14 ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 1, 15 ); acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 2, 2, &(acadoWorkspace.R1[ 2 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.QE[ 20 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QE[ 32 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 68 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 92 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 152 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 188 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 272 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 320 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 428 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 488 ]) ); acado_zeroBlockH11( 2, 3 ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 52 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 124 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 232 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 376 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_zeroBlockH11( 2, 4 ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 56 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 76 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 100 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 128 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 160 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 196 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 236 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 280 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 328 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 380 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 436 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 496 ]) ); acado_zeroBlockH11( 2, 5 ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_zeroBlockH11( 2, 6 ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 2, 7 ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 2, 8 ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 2, 9 ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 2, 10 ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 2, 11 ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 2, 12 ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 2, 13 ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 2, 14 ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 2, 15 ); acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 3, 3, &(acadoWorkspace.R1[ 3 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QE[ 52 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 124 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 232 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 376 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_zeroBlockH11( 3, 4 ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QE[ 56 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 76 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 100 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 128 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 160 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 196 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 236 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 280 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 328 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 380 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 436 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 496 ]) ); acado_zeroBlockH11( 3, 5 ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_zeroBlockH11( 3, 6 ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 3, 7 ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 3, 8 ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 3, 9 ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 3, 10 ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 3, 11 ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 3, 12 ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 3, 13 ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 3, 14 ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 3, 15 ); acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 4, 4, &(acadoWorkspace.R1[ 4 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.QE[ 56 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QE[ 76 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 100 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 128 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 160 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 196 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 236 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 280 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 328 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 380 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 436 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 496 ]) ); acado_zeroBlockH11( 4, 5 ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_zeroBlockH11( 4, 6 ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 4, 7 ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 4, 8 ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 4, 9 ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 4, 10 ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 4, 11 ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 4, 12 ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 4, 13 ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 4, 14 ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 4, 15 ); acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 5, 5, &(acadoWorkspace.R1[ 5 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.QE[ 80 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QE[ 104 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 164 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 200 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 284 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 332 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 440 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 500 ]) ); acado_zeroBlockH11( 5, 6 ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 5, 7 ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 5, 8 ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 5, 9 ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 5, 10 ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 5, 11 ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 5, 12 ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 5, 13 ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 5, 14 ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 5, 15 ); acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 6, 6, &(acadoWorkspace.R1[ 6 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QE[ 136 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 244 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 388 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_zeroBlockH11( 6, 7 ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 6, 8 ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 6, 9 ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 6, 10 ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 6, 11 ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 6, 12 ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 6, 13 ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 6, 14 ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 6, 15 ); acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 7, 7, &(acadoWorkspace.R1[ 7 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.QE[ 140 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QE[ 172 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 208 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 248 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 292 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 340 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 392 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 448 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 508 ]) ); acado_zeroBlockH11( 7, 8 ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 7, 9 ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 7, 10 ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 7, 11 ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 7, 12 ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 7, 13 ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 7, 14 ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 7, 15 ); acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 8, 8, &(acadoWorkspace.R1[ 8 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.QE[ 176 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QE[ 212 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 296 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 344 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 452 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 512 ]) ); acado_zeroBlockH11( 8, 9 ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 8, 10 ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 8, 11 ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 8, 12 ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 8, 13 ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 8, 14 ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 8, 15 ); acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 9, 9, &(acadoWorkspace.R1[ 9 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QE[ 256 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 400 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_zeroBlockH11( 9, 10 ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 9, 11 ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 9, 12 ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 9, 13 ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 9, 14 ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 9, 15 ); acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 10, 10, &(acadoWorkspace.R1[ 10 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.QE[ 260 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QE[ 304 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 352 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 404 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 460 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 520 ]) ); acado_zeroBlockH11( 10, 11 ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 10, 12 ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 10, 13 ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 10, 14 ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 10, 15 ); acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 11, 11, &(acadoWorkspace.R1[ 11 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.QE[ 308 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QE[ 356 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 464 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 524 ]) ); acado_zeroBlockH11( 11, 12 ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 11, 13 ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 11, 14 ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 11, 15 ); acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 12, 12, &(acadoWorkspace.R1[ 12 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QE[ 412 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_zeroBlockH11( 12, 13 ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 12, 14 ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 12, 15 ); acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 13, 13, &(acadoWorkspace.R1[ 13 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.QE[ 416 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QE[ 472 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 532 ]) ); acado_zeroBlockH11( 13, 14 ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 13, 15 ); acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 14, 14, &(acadoWorkspace.R1[ 14 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.QE[ 476 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QE[ 536 ]) ); acado_zeroBlockH11( 14, 15 ); acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11_R1( 15, 15, &(acadoWorkspace.R1[ 15 ]) ); acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_copyHTH( 1, 0 ); acado_copyHTH( 2, 0 ); acado_copyHTH( 2, 1 ); acado_copyHTH( 3, 0 ); acado_copyHTH( 3, 1 ); acado_copyHTH( 3, 2 ); acado_copyHTH( 4, 0 ); acado_copyHTH( 4, 1 ); acado_copyHTH( 4, 2 ); acado_copyHTH( 4, 3 ); acado_copyHTH( 5, 0 ); acado_copyHTH( 5, 1 ); acado_copyHTH( 5, 2 ); acado_copyHTH( 5, 3 ); acado_copyHTH( 5, 4 ); acado_copyHTH( 6, 0 ); acado_copyHTH( 6, 1 ); acado_copyHTH( 6, 2 ); acado_copyHTH( 6, 3 ); acado_copyHTH( 6, 4 ); acado_copyHTH( 6, 5 ); acado_copyHTH( 7, 0 ); acado_copyHTH( 7, 1 ); acado_copyHTH( 7, 2 ); acado_copyHTH( 7, 3 ); acado_copyHTH( 7, 4 ); acado_copyHTH( 7, 5 ); acado_copyHTH( 7, 6 ); acado_copyHTH( 8, 0 ); acado_copyHTH( 8, 1 ); acado_copyHTH( 8, 2 ); acado_copyHTH( 8, 3 ); acado_copyHTH( 8, 4 ); acado_copyHTH( 8, 5 ); acado_copyHTH( 8, 6 ); acado_copyHTH( 8, 7 ); acado_copyHTH( 9, 0 ); acado_copyHTH( 9, 1 ); acado_copyHTH( 9, 2 ); acado_copyHTH( 9, 3 ); acado_copyHTH( 9, 4 ); acado_copyHTH( 9, 5 ); acado_copyHTH( 9, 6 ); acado_copyHTH( 9, 7 ); acado_copyHTH( 9, 8 ); acado_copyHTH( 10, 0 ); acado_copyHTH( 10, 1 ); acado_copyHTH( 10, 2 ); acado_copyHTH( 10, 3 ); acado_copyHTH( 10, 4 ); acado_copyHTH( 10, 5 ); acado_copyHTH( 10, 6 ); acado_copyHTH( 10, 7 ); acado_copyHTH( 10, 8 ); acado_copyHTH( 10, 9 ); acado_copyHTH( 11, 0 ); acado_copyHTH( 11, 1 ); acado_copyHTH( 11, 2 ); acado_copyHTH( 11, 3 ); acado_copyHTH( 11, 4 ); acado_copyHTH( 11, 5 ); acado_copyHTH( 11, 6 ); acado_copyHTH( 11, 7 ); acado_copyHTH( 11, 8 ); acado_copyHTH( 11, 9 ); acado_copyHTH( 11, 10 ); acado_copyHTH( 12, 0 ); acado_copyHTH( 12, 1 ); acado_copyHTH( 12, 2 ); acado_copyHTH( 12, 3 ); acado_copyHTH( 12, 4 ); acado_copyHTH( 12, 5 ); acado_copyHTH( 12, 6 ); acado_copyHTH( 12, 7 ); acado_copyHTH( 12, 8 ); acado_copyHTH( 12, 9 ); acado_copyHTH( 12, 10 ); acado_copyHTH( 12, 11 ); acado_copyHTH( 13, 0 ); acado_copyHTH( 13, 1 ); acado_copyHTH( 13, 2 ); acado_copyHTH( 13, 3 ); acado_copyHTH( 13, 4 ); acado_copyHTH( 13, 5 ); acado_copyHTH( 13, 6 ); acado_copyHTH( 13, 7 ); acado_copyHTH( 13, 8 ); acado_copyHTH( 13, 9 ); acado_copyHTH( 13, 10 ); acado_copyHTH( 13, 11 ); acado_copyHTH( 13, 12 ); acado_copyHTH( 14, 0 ); acado_copyHTH( 14, 1 ); acado_copyHTH( 14, 2 ); acado_copyHTH( 14, 3 ); acado_copyHTH( 14, 4 ); acado_copyHTH( 14, 5 ); acado_copyHTH( 14, 6 ); acado_copyHTH( 14, 7 ); acado_copyHTH( 14, 8 ); acado_copyHTH( 14, 9 ); acado_copyHTH( 14, 10 ); acado_copyHTH( 14, 11 ); acado_copyHTH( 14, 12 ); acado_copyHTH( 14, 13 ); acado_copyHTH( 15, 0 ); acado_copyHTH( 15, 1 ); acado_copyHTH( 15, 2 ); acado_copyHTH( 15, 3 ); acado_copyHTH( 15, 4 ); acado_copyHTH( 15, 5 ); acado_copyHTH( 15, 6 ); acado_copyHTH( 15, 7 ); acado_copyHTH( 15, 8 ); acado_copyHTH( 15, 9 ); acado_copyHTH( 15, 10 ); acado_copyHTH( 15, 11 ); acado_copyHTH( 15, 12 ); acado_copyHTH( 15, 13 ); acado_copyHTH( 15, 14 ); acadoWorkspace.H[80] = acadoWorkspace.H10[0]; acadoWorkspace.H[81] = acadoWorkspace.H10[1]; acadoWorkspace.H[82] = acadoWorkspace.H10[2]; acadoWorkspace.H[83] = acadoWorkspace.H10[3]; acadoWorkspace.H[100] = acadoWorkspace.H10[4]; acadoWorkspace.H[101] = acadoWorkspace.H10[5]; acadoWorkspace.H[102] = acadoWorkspace.H10[6]; acadoWorkspace.H[103] = acadoWorkspace.H10[7]; acadoWorkspace.H[120] = acadoWorkspace.H10[8]; acadoWorkspace.H[121] = acadoWorkspace.H10[9]; acadoWorkspace.H[122] = acadoWorkspace.H10[10]; acadoWorkspace.H[123] = acadoWorkspace.H10[11]; acadoWorkspace.H[140] = acadoWorkspace.H10[12]; acadoWorkspace.H[141] = acadoWorkspace.H10[13]; acadoWorkspace.H[142] = acadoWorkspace.H10[14]; acadoWorkspace.H[143] = acadoWorkspace.H10[15]; acadoWorkspace.H[160] = acadoWorkspace.H10[16]; acadoWorkspace.H[161] = acadoWorkspace.H10[17]; acadoWorkspace.H[162] = acadoWorkspace.H10[18]; acadoWorkspace.H[163] = acadoWorkspace.H10[19]; acadoWorkspace.H[180] = acadoWorkspace.H10[20]; acadoWorkspace.H[181] = acadoWorkspace.H10[21]; acadoWorkspace.H[182] = acadoWorkspace.H10[22]; acadoWorkspace.H[183] = acadoWorkspace.H10[23]; acadoWorkspace.H[200] = acadoWorkspace.H10[24]; acadoWorkspace.H[201] = acadoWorkspace.H10[25]; acadoWorkspace.H[202] = acadoWorkspace.H10[26]; acadoWorkspace.H[203] = acadoWorkspace.H10[27]; acadoWorkspace.H[220] = acadoWorkspace.H10[28]; acadoWorkspace.H[221] = acadoWorkspace.H10[29]; acadoWorkspace.H[222] = acadoWorkspace.H10[30]; acadoWorkspace.H[223] = acadoWorkspace.H10[31]; acadoWorkspace.H[240] = acadoWorkspace.H10[32]; acadoWorkspace.H[241] = acadoWorkspace.H10[33]; acadoWorkspace.H[242] = acadoWorkspace.H10[34]; acadoWorkspace.H[243] = acadoWorkspace.H10[35]; acadoWorkspace.H[260] = acadoWorkspace.H10[36]; acadoWorkspace.H[261] = acadoWorkspace.H10[37]; acadoWorkspace.H[262] = acadoWorkspace.H10[38]; acadoWorkspace.H[263] = acadoWorkspace.H10[39]; acadoWorkspace.H[280] = acadoWorkspace.H10[40]; acadoWorkspace.H[281] = acadoWorkspace.H10[41]; acadoWorkspace.H[282] = acadoWorkspace.H10[42]; acadoWorkspace.H[283] = acadoWorkspace.H10[43]; acadoWorkspace.H[300] = acadoWorkspace.H10[44]; acadoWorkspace.H[301] = acadoWorkspace.H10[45]; acadoWorkspace.H[302] = acadoWorkspace.H10[46]; acadoWorkspace.H[303] = acadoWorkspace.H10[47]; acadoWorkspace.H[320] = acadoWorkspace.H10[48]; acadoWorkspace.H[321] = acadoWorkspace.H10[49]; acadoWorkspace.H[322] = acadoWorkspace.H10[50]; acadoWorkspace.H[323] = acadoWorkspace.H10[51]; acadoWorkspace.H[340] = acadoWorkspace.H10[52]; acadoWorkspace.H[341] = acadoWorkspace.H10[53]; acadoWorkspace.H[342] = acadoWorkspace.H10[54]; acadoWorkspace.H[343] = acadoWorkspace.H10[55]; acadoWorkspace.H[360] = acadoWorkspace.H10[56]; acadoWorkspace.H[361] = acadoWorkspace.H10[57]; acadoWorkspace.H[362] = acadoWorkspace.H10[58]; acadoWorkspace.H[363] = acadoWorkspace.H10[59]; acadoWorkspace.H[380] = acadoWorkspace.H10[60]; acadoWorkspace.H[381] = acadoWorkspace.H10[61]; acadoWorkspace.H[382] = acadoWorkspace.H10[62]; acadoWorkspace.H[383] = acadoWorkspace.H10[63]; acado_multQ1d( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.d, acadoWorkspace.Qd ); acado_multQ1d( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.d[ 4 ]), &(acadoWorkspace.Qd[ 4 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.d[ 8 ]), &(acadoWorkspace.Qd[ 8 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.Qd[ 12 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.d[ 16 ]), &(acadoWorkspace.Qd[ 16 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.d[ 20 ]), &(acadoWorkspace.Qd[ 20 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.Qd[ 24 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.d[ 28 ]), &(acadoWorkspace.Qd[ 28 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.d[ 32 ]), &(acadoWorkspace.Qd[ 32 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.Qd[ 36 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.d[ 40 ]), &(acadoWorkspace.Qd[ 40 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.d[ 44 ]), &(acadoWorkspace.Qd[ 44 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.Qd[ 48 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.d[ 52 ]), &(acadoWorkspace.Qd[ 52 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.d[ 56 ]), &(acadoWorkspace.Qd[ 56 ]) ); acado_multQN1d( acadoWorkspace.QN1, &(acadoWorkspace.d[ 60 ]), &(acadoWorkspace.Qd[ 60 ]) ); acado_macCTSlx( acadoWorkspace.evGx, acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.g ); acado_macETSlu( acadoWorkspace.QE, &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 4 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 40 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 112 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 220 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 364 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 8 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 16 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 28 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 44 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 64 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 88 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 116 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 148 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 184 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 224 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 268 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 316 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 368 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 424 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 484 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 20 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 32 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 68 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 92 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 152 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 188 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 272 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 320 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 428 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 488 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 52 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 124 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 232 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 376 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 56 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 76 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 100 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 128 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 160 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 196 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 236 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 280 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 328 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 380 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 436 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 496 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 80 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 104 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 164 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 200 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 284 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 332 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 440 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 500 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 136 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 244 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 388 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 140 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 172 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 208 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 248 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 292 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 340 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 392 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 448 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 508 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 176 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 212 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 296 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 344 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 452 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 512 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 256 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 400 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 260 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 304 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 352 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 404 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 460 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 520 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 308 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 356 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 464 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 524 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 412 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 416 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 472 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 532 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 476 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 536 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.g[ 19 ]) ); acadoWorkspace.lb[4] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[0]; acadoWorkspace.lb[5] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[1]; acadoWorkspace.lb[6] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[2]; acadoWorkspace.lb[7] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[3]; acadoWorkspace.lb[8] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[4]; acadoWorkspace.lb[9] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[5]; acadoWorkspace.lb[10] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[6]; acadoWorkspace.lb[11] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[7]; acadoWorkspace.lb[12] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[8]; acadoWorkspace.lb[13] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[9]; acadoWorkspace.lb[14] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[10]; acadoWorkspace.lb[15] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[11]; acadoWorkspace.lb[16] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[12]; acadoWorkspace.lb[17] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[13]; acadoWorkspace.lb[18] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[14]; acadoWorkspace.lb[19] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[15]; acadoWorkspace.ub[4] = (real_t)1.0000000000000000e+12 - acadoVariables.u[0]; acadoWorkspace.ub[5] = (real_t)1.0000000000000000e+12 - acadoVariables.u[1]; acadoWorkspace.ub[6] = (real_t)1.0000000000000000e+12 - acadoVariables.u[2]; acadoWorkspace.ub[7] = (real_t)1.0000000000000000e+12 - acadoVariables.u[3]; acadoWorkspace.ub[8] = (real_t)1.0000000000000000e+12 - acadoVariables.u[4]; acadoWorkspace.ub[9] = (real_t)1.0000000000000000e+12 - acadoVariables.u[5]; acadoWorkspace.ub[10] = (real_t)1.0000000000000000e+12 - acadoVariables.u[6]; acadoWorkspace.ub[11] = (real_t)1.0000000000000000e+12 - acadoVariables.u[7]; acadoWorkspace.ub[12] = (real_t)1.0000000000000000e+12 - acadoVariables.u[8]; acadoWorkspace.ub[13] = (real_t)1.0000000000000000e+12 - acadoVariables.u[9]; acadoWorkspace.ub[14] = (real_t)1.0000000000000000e+12 - acadoVariables.u[10]; acadoWorkspace.ub[15] = (real_t)1.0000000000000000e+12 - acadoVariables.u[11]; acadoWorkspace.ub[16] = (real_t)1.0000000000000000e+12 - acadoVariables.u[12]; acadoWorkspace.ub[17] = (real_t)1.0000000000000000e+12 - acadoVariables.u[13]; acadoWorkspace.ub[18] = (real_t)1.0000000000000000e+12 - acadoVariables.u[14]; acadoWorkspace.ub[19] = (real_t)1.0000000000000000e+12 - acadoVariables.u[15]; for (lRun1 = 0; lRun1 < 32; ++lRun1) { lRun3 = xBoundIndices[ lRun1 ] - 4; lRun4 = ((lRun3) / (4)) + (1); acadoWorkspace.A[lRun1 * 20] = acadoWorkspace.evGx[lRun3 * 4]; acadoWorkspace.A[lRun1 * 20 + 1] = acadoWorkspace.evGx[lRun3 * 4 + 1]; acadoWorkspace.A[lRun1 * 20 + 2] = acadoWorkspace.evGx[lRun3 * 4 + 2]; acadoWorkspace.A[lRun1 * 20 + 3] = acadoWorkspace.evGx[lRun3 * 4 + 3]; for (lRun2 = 0; lRun2 < lRun4; ++lRun2) { lRun5 = (((((lRun4) * (lRun4-1)) / (2)) + (lRun2)) * (4)) + ((lRun3) % (4)); acadoWorkspace.A[(lRun1 * 20) + (lRun2 + 4)] = acadoWorkspace.E[lRun5]; } } } void acado_condenseFdb( ) { real_t tmp; acadoWorkspace.Dx0[0] = acadoVariables.x0[0] - acadoVariables.x[0]; acadoWorkspace.Dx0[1] = acadoVariables.x0[1] - acadoVariables.x[1]; acadoWorkspace.Dx0[2] = acadoVariables.x0[2] - acadoVariables.x[2]; acadoWorkspace.Dx0[3] = acadoVariables.x0[3] - acadoVariables.x[3]; acadoWorkspace.Dy[0] -= acadoVariables.y[0]; acadoWorkspace.Dy[1] -= acadoVariables.y[1]; acadoWorkspace.Dy[2] -= acadoVariables.y[2]; acadoWorkspace.Dy[3] -= acadoVariables.y[3]; acadoWorkspace.Dy[4] -= acadoVariables.y[4]; acadoWorkspace.Dy[5] -= acadoVariables.y[5]; acadoWorkspace.Dy[6] -= acadoVariables.y[6]; acadoWorkspace.Dy[7] -= acadoVariables.y[7]; acadoWorkspace.Dy[8] -= acadoVariables.y[8]; acadoWorkspace.Dy[9] -= acadoVariables.y[9]; acadoWorkspace.Dy[10] -= acadoVariables.y[10]; acadoWorkspace.Dy[11] -= acadoVariables.y[11]; acadoWorkspace.Dy[12] -= acadoVariables.y[12]; acadoWorkspace.Dy[13] -= acadoVariables.y[13]; acadoWorkspace.Dy[14] -= acadoVariables.y[14]; acadoWorkspace.Dy[15] -= acadoVariables.y[15]; acadoWorkspace.Dy[16] -= acadoVariables.y[16]; acadoWorkspace.Dy[17] -= acadoVariables.y[17]; acadoWorkspace.Dy[18] -= acadoVariables.y[18]; acadoWorkspace.Dy[19] -= acadoVariables.y[19]; acadoWorkspace.Dy[20] -= acadoVariables.y[20]; acadoWorkspace.Dy[21] -= acadoVariables.y[21]; acadoWorkspace.Dy[22] -= acadoVariables.y[22]; acadoWorkspace.Dy[23] -= acadoVariables.y[23]; acadoWorkspace.Dy[24] -= acadoVariables.y[24]; acadoWorkspace.Dy[25] -= acadoVariables.y[25]; acadoWorkspace.Dy[26] -= acadoVariables.y[26]; acadoWorkspace.Dy[27] -= acadoVariables.y[27]; acadoWorkspace.Dy[28] -= acadoVariables.y[28]; acadoWorkspace.Dy[29] -= acadoVariables.y[29]; acadoWorkspace.Dy[30] -= acadoVariables.y[30]; acadoWorkspace.Dy[31] -= acadoVariables.y[31]; acadoWorkspace.Dy[32] -= acadoVariables.y[32]; acadoWorkspace.Dy[33] -= acadoVariables.y[33]; acadoWorkspace.Dy[34] -= acadoVariables.y[34]; acadoWorkspace.Dy[35] -= acadoVariables.y[35]; acadoWorkspace.Dy[36] -= acadoVariables.y[36]; acadoWorkspace.Dy[37] -= acadoVariables.y[37]; acadoWorkspace.Dy[38] -= acadoVariables.y[38]; acadoWorkspace.Dy[39] -= acadoVariables.y[39]; acadoWorkspace.Dy[40] -= acadoVariables.y[40]; acadoWorkspace.Dy[41] -= acadoVariables.y[41]; acadoWorkspace.Dy[42] -= acadoVariables.y[42]; acadoWorkspace.Dy[43] -= acadoVariables.y[43]; acadoWorkspace.Dy[44] -= acadoVariables.y[44]; acadoWorkspace.Dy[45] -= acadoVariables.y[45]; acadoWorkspace.Dy[46] -= acadoVariables.y[46]; acadoWorkspace.Dy[47] -= acadoVariables.y[47]; acadoWorkspace.DyN[0] -= acadoVariables.yN[0]; acadoWorkspace.DyN[1] -= acadoVariables.yN[1]; acado_multRDy( acadoWorkspace.R2, acadoWorkspace.Dy, &(acadoWorkspace.g[ 4 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 3 ]), &(acadoWorkspace.Dy[ 3 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 6 ]), &(acadoWorkspace.Dy[ 6 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 9 ]), &(acadoWorkspace.Dy[ 9 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 12 ]), &(acadoWorkspace.Dy[ 12 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 15 ]), &(acadoWorkspace.Dy[ 15 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 18 ]), &(acadoWorkspace.Dy[ 18 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 21 ]), &(acadoWorkspace.Dy[ 21 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 24 ]), &(acadoWorkspace.Dy[ 24 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 27 ]), &(acadoWorkspace.Dy[ 27 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 30 ]), &(acadoWorkspace.Dy[ 30 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 33 ]), &(acadoWorkspace.Dy[ 33 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 36 ]), &(acadoWorkspace.Dy[ 36 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 39 ]), &(acadoWorkspace.Dy[ 39 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 42 ]), &(acadoWorkspace.Dy[ 42 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 45 ]), &(acadoWorkspace.Dy[ 45 ]), &(acadoWorkspace.g[ 19 ]) ); acado_multQDy( acadoWorkspace.Q2, acadoWorkspace.Dy, acadoWorkspace.QDy ); acado_multQDy( &(acadoWorkspace.Q2[ 12 ]), &(acadoWorkspace.Dy[ 3 ]), &(acadoWorkspace.QDy[ 4 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 24 ]), &(acadoWorkspace.Dy[ 6 ]), &(acadoWorkspace.QDy[ 8 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 36 ]), &(acadoWorkspace.Dy[ 9 ]), &(acadoWorkspace.QDy[ 12 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 48 ]), &(acadoWorkspace.Dy[ 12 ]), &(acadoWorkspace.QDy[ 16 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 60 ]), &(acadoWorkspace.Dy[ 15 ]), &(acadoWorkspace.QDy[ 20 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 72 ]), &(acadoWorkspace.Dy[ 18 ]), &(acadoWorkspace.QDy[ 24 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 84 ]), &(acadoWorkspace.Dy[ 21 ]), &(acadoWorkspace.QDy[ 28 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 96 ]), &(acadoWorkspace.Dy[ 24 ]), &(acadoWorkspace.QDy[ 32 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 108 ]), &(acadoWorkspace.Dy[ 27 ]), &(acadoWorkspace.QDy[ 36 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 120 ]), &(acadoWorkspace.Dy[ 30 ]), &(acadoWorkspace.QDy[ 40 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 132 ]), &(acadoWorkspace.Dy[ 33 ]), &(acadoWorkspace.QDy[ 44 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 144 ]), &(acadoWorkspace.Dy[ 36 ]), &(acadoWorkspace.QDy[ 48 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 156 ]), &(acadoWorkspace.Dy[ 39 ]), &(acadoWorkspace.QDy[ 52 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 168 ]), &(acadoWorkspace.Dy[ 42 ]), &(acadoWorkspace.QDy[ 56 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 180 ]), &(acadoWorkspace.Dy[ 45 ]), &(acadoWorkspace.QDy[ 60 ]) ); acadoWorkspace.QDy[64] = + acadoWorkspace.QN2[0]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[1]*acadoWorkspace.DyN[1]; acadoWorkspace.QDy[65] = + acadoWorkspace.QN2[2]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[3]*acadoWorkspace.DyN[1]; acadoWorkspace.QDy[66] = + acadoWorkspace.QN2[4]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[5]*acadoWorkspace.DyN[1]; acadoWorkspace.QDy[67] = + acadoWorkspace.QN2[6]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[7]*acadoWorkspace.DyN[1]; acadoWorkspace.QDy[4] += acadoWorkspace.Qd[0]; acadoWorkspace.QDy[5] += acadoWorkspace.Qd[1]; acadoWorkspace.QDy[6] += acadoWorkspace.Qd[2]; acadoWorkspace.QDy[7] += acadoWorkspace.Qd[3]; acadoWorkspace.QDy[8] += acadoWorkspace.Qd[4]; acadoWorkspace.QDy[9] += acadoWorkspace.Qd[5]; acadoWorkspace.QDy[10] += acadoWorkspace.Qd[6]; acadoWorkspace.QDy[11] += acadoWorkspace.Qd[7]; acadoWorkspace.QDy[12] += acadoWorkspace.Qd[8]; acadoWorkspace.QDy[13] += acadoWorkspace.Qd[9]; acadoWorkspace.QDy[14] += acadoWorkspace.Qd[10]; acadoWorkspace.QDy[15] += acadoWorkspace.Qd[11]; acadoWorkspace.QDy[16] += acadoWorkspace.Qd[12]; acadoWorkspace.QDy[17] += acadoWorkspace.Qd[13]; acadoWorkspace.QDy[18] += acadoWorkspace.Qd[14]; acadoWorkspace.QDy[19] += acadoWorkspace.Qd[15]; acadoWorkspace.QDy[20] += acadoWorkspace.Qd[16]; acadoWorkspace.QDy[21] += acadoWorkspace.Qd[17]; acadoWorkspace.QDy[22] += acadoWorkspace.Qd[18]; acadoWorkspace.QDy[23] += acadoWorkspace.Qd[19]; acadoWorkspace.QDy[24] += acadoWorkspace.Qd[20]; acadoWorkspace.QDy[25] += acadoWorkspace.Qd[21]; acadoWorkspace.QDy[26] += acadoWorkspace.Qd[22]; acadoWorkspace.QDy[27] += acadoWorkspace.Qd[23]; acadoWorkspace.QDy[28] += acadoWorkspace.Qd[24]; acadoWorkspace.QDy[29] += acadoWorkspace.Qd[25]; acadoWorkspace.QDy[30] += acadoWorkspace.Qd[26]; acadoWorkspace.QDy[31] += acadoWorkspace.Qd[27]; acadoWorkspace.QDy[32] += acadoWorkspace.Qd[28]; acadoWorkspace.QDy[33] += acadoWorkspace.Qd[29]; acadoWorkspace.QDy[34] += acadoWorkspace.Qd[30]; acadoWorkspace.QDy[35] += acadoWorkspace.Qd[31]; acadoWorkspace.QDy[36] += acadoWorkspace.Qd[32]; acadoWorkspace.QDy[37] += acadoWorkspace.Qd[33]; acadoWorkspace.QDy[38] += acadoWorkspace.Qd[34]; acadoWorkspace.QDy[39] += acadoWorkspace.Qd[35]; acadoWorkspace.QDy[40] += acadoWorkspace.Qd[36]; acadoWorkspace.QDy[41] += acadoWorkspace.Qd[37]; acadoWorkspace.QDy[42] += acadoWorkspace.Qd[38]; acadoWorkspace.QDy[43] += acadoWorkspace.Qd[39]; acadoWorkspace.QDy[44] += acadoWorkspace.Qd[40]; acadoWorkspace.QDy[45] += acadoWorkspace.Qd[41]; acadoWorkspace.QDy[46] += acadoWorkspace.Qd[42]; acadoWorkspace.QDy[47] += acadoWorkspace.Qd[43]; acadoWorkspace.QDy[48] += acadoWorkspace.Qd[44]; acadoWorkspace.QDy[49] += acadoWorkspace.Qd[45]; acadoWorkspace.QDy[50] += acadoWorkspace.Qd[46]; acadoWorkspace.QDy[51] += acadoWorkspace.Qd[47]; acadoWorkspace.QDy[52] += acadoWorkspace.Qd[48]; acadoWorkspace.QDy[53] += acadoWorkspace.Qd[49]; acadoWorkspace.QDy[54] += acadoWorkspace.Qd[50]; acadoWorkspace.QDy[55] += acadoWorkspace.Qd[51]; acadoWorkspace.QDy[56] += acadoWorkspace.Qd[52]; acadoWorkspace.QDy[57] += acadoWorkspace.Qd[53]; acadoWorkspace.QDy[58] += acadoWorkspace.Qd[54]; acadoWorkspace.QDy[59] += acadoWorkspace.Qd[55]; acadoWorkspace.QDy[60] += acadoWorkspace.Qd[56]; acadoWorkspace.QDy[61] += acadoWorkspace.Qd[57]; acadoWorkspace.QDy[62] += acadoWorkspace.Qd[58]; acadoWorkspace.QDy[63] += acadoWorkspace.Qd[59]; acadoWorkspace.QDy[64] += acadoWorkspace.Qd[60]; acadoWorkspace.QDy[65] += acadoWorkspace.Qd[61]; acadoWorkspace.QDy[66] += acadoWorkspace.Qd[62]; acadoWorkspace.QDy[67] += acadoWorkspace.Qd[63]; acadoWorkspace.g[0] = + acadoWorkspace.evGx[0]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[4]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[8]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[12]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[16]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[20]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[24]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[28]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[32]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[36]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[40]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[44]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[48]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[52]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[56]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[60]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[64]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[68]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[72]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[76]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[80]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[84]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[88]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[92]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[96]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[100]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[104]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[108]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[112]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[116]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[120]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[124]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[128]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[132]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[136]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[140]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[144]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[148]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[152]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[156]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[160]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[164]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[168]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[172]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[176]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[180]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[184]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[188]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[192]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[196]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[200]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[204]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[208]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[212]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[216]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[220]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[224]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[228]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[232]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[236]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[240]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[244]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[248]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[252]*acadoWorkspace.QDy[67]; acadoWorkspace.g[1] = + acadoWorkspace.evGx[1]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[5]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[9]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[13]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[17]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[21]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[25]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[29]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[33]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[37]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[41]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[45]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[49]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[53]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[57]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[61]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[65]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[69]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[73]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[77]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[81]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[85]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[89]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[93]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[97]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[101]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[105]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[109]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[113]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[117]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[121]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[125]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[129]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[133]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[137]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[141]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[145]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[149]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[153]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[157]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[161]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[165]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[169]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[173]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[177]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[181]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[185]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[189]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[193]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[197]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[201]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[205]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[209]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[213]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[217]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[221]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[225]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[229]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[233]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[237]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[241]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[245]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[249]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[253]*acadoWorkspace.QDy[67]; acadoWorkspace.g[2] = + acadoWorkspace.evGx[2]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[6]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[10]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[14]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[18]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[22]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[26]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[30]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[34]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[38]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[42]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[46]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[50]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[54]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[58]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[62]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[66]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[70]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[74]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[78]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[82]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[86]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[90]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[94]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[98]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[102]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[106]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[110]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[114]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[118]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[122]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[126]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[130]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[134]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[138]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[142]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[146]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[150]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[154]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[158]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[162]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[166]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[170]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[174]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[178]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[182]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[186]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[190]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[194]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[198]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[202]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[206]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[210]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[214]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[218]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[222]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[226]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[230]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[234]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[238]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[242]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[246]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[250]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[254]*acadoWorkspace.QDy[67]; acadoWorkspace.g[3] = + acadoWorkspace.evGx[3]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[7]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[11]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[15]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[19]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[23]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[27]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[31]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[35]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[39]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[43]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[47]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[51]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[55]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[59]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[63]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[67]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[71]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[75]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[79]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[83]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[87]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[91]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[95]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[99]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[103]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[107]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[111]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[115]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[119]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[123]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[127]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[131]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[135]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[139]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[143]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[147]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[151]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[155]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[159]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[163]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[167]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[171]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[175]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[179]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[183]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[187]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[191]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[195]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[199]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[203]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[207]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[211]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[215]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[219]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[223]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[227]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[231]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[235]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[239]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[243]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[247]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[251]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[255]*acadoWorkspace.QDy[67]; acado_multEQDy( acadoWorkspace.E, &(acadoWorkspace.QDy[ 4 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.QDy[ 8 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.QDy[ 8 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QDy[ 16 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.QDy[ 20 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QDy[ 28 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.QDy[ 32 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QDy[ 40 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.QDy[ 44 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QDy[ 52 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.QDy[ 56 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QDy[ 64 ]), &(acadoWorkspace.g[ 19 ]) ); acadoWorkspace.lb[0] = acadoWorkspace.Dx0[0]; acadoWorkspace.lb[1] = acadoWorkspace.Dx0[1]; acadoWorkspace.lb[2] = acadoWorkspace.Dx0[2]; acadoWorkspace.lb[3] = acadoWorkspace.Dx0[3]; acadoWorkspace.ub[0] = acadoWorkspace.Dx0[0]; acadoWorkspace.ub[1] = acadoWorkspace.Dx0[1]; acadoWorkspace.ub[2] = acadoWorkspace.Dx0[2]; acadoWorkspace.ub[3] = acadoWorkspace.Dx0[3]; tmp = acadoVariables.x[6] + acadoWorkspace.d[2]; acadoWorkspace.lbA[0] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[0] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[7] + acadoWorkspace.d[3]; acadoWorkspace.lbA[1] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[1] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[10] + acadoWorkspace.d[6]; acadoWorkspace.lbA[2] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[2] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[11] + acadoWorkspace.d[7]; acadoWorkspace.lbA[3] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[3] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[14] + acadoWorkspace.d[10]; acadoWorkspace.lbA[4] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[4] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[15] + acadoWorkspace.d[11]; acadoWorkspace.lbA[5] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[5] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[18] + acadoWorkspace.d[14]; acadoWorkspace.lbA[6] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[6] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[19] + acadoWorkspace.d[15]; acadoWorkspace.lbA[7] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[7] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[22] + acadoWorkspace.d[18]; acadoWorkspace.lbA[8] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[8] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[23] + acadoWorkspace.d[19]; acadoWorkspace.lbA[9] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[9] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[26] + acadoWorkspace.d[22]; acadoWorkspace.lbA[10] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[10] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[27] + acadoWorkspace.d[23]; acadoWorkspace.lbA[11] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[11] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[30] + acadoWorkspace.d[26]; acadoWorkspace.lbA[12] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[12] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[31] + acadoWorkspace.d[27]; acadoWorkspace.lbA[13] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[13] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[34] + acadoWorkspace.d[30]; acadoWorkspace.lbA[14] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[14] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[35] + acadoWorkspace.d[31]; acadoWorkspace.lbA[15] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[15] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[38] + acadoWorkspace.d[34]; acadoWorkspace.lbA[16] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[16] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[39] + acadoWorkspace.d[35]; acadoWorkspace.lbA[17] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[17] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[42] + acadoWorkspace.d[38]; acadoWorkspace.lbA[18] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[18] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[43] + acadoWorkspace.d[39]; acadoWorkspace.lbA[19] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[19] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[46] + acadoWorkspace.d[42]; acadoWorkspace.lbA[20] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[20] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[47] + acadoWorkspace.d[43]; acadoWorkspace.lbA[21] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[21] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[50] + acadoWorkspace.d[46]; acadoWorkspace.lbA[22] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[22] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[51] + acadoWorkspace.d[47]; acadoWorkspace.lbA[23] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[23] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[54] + acadoWorkspace.d[50]; acadoWorkspace.lbA[24] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[24] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[55] + acadoWorkspace.d[51]; acadoWorkspace.lbA[25] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[25] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[58] + acadoWorkspace.d[54]; acadoWorkspace.lbA[26] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[26] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[59] + acadoWorkspace.d[55]; acadoWorkspace.lbA[27] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[27] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[62] + acadoWorkspace.d[58]; acadoWorkspace.lbA[28] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[28] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[63] + acadoWorkspace.d[59]; acadoWorkspace.lbA[29] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[29] = (real_t)8.7266462599716477e-01 - tmp; tmp = acadoVariables.x[66] + acadoWorkspace.d[62]; acadoWorkspace.lbA[30] = (real_t)-1.5707963267948966e+00 - tmp; acadoWorkspace.ubA[30] = (real_t)1.5707963267948966e+00 - tmp; tmp = acadoVariables.x[67] + acadoWorkspace.d[63]; acadoWorkspace.lbA[31] = (real_t)-8.7266462599716477e-01 - tmp; acadoWorkspace.ubA[31] = (real_t)8.7266462599716477e-01 - tmp; } void acado_expand( ) { acadoVariables.x[0] += acadoWorkspace.x[0]; acadoVariables.x[1] += acadoWorkspace.x[1]; acadoVariables.x[2] += acadoWorkspace.x[2]; acadoVariables.x[3] += acadoWorkspace.x[3]; acadoVariables.u[0] += acadoWorkspace.x[4]; acadoVariables.u[1] += acadoWorkspace.x[5]; acadoVariables.u[2] += acadoWorkspace.x[6]; acadoVariables.u[3] += acadoWorkspace.x[7]; acadoVariables.u[4] += acadoWorkspace.x[8]; acadoVariables.u[5] += acadoWorkspace.x[9]; acadoVariables.u[6] += acadoWorkspace.x[10]; acadoVariables.u[7] += acadoWorkspace.x[11]; acadoVariables.u[8] += acadoWorkspace.x[12]; acadoVariables.u[9] += acadoWorkspace.x[13]; acadoVariables.u[10] += acadoWorkspace.x[14]; acadoVariables.u[11] += acadoWorkspace.x[15]; acadoVariables.u[12] += acadoWorkspace.x[16]; acadoVariables.u[13] += acadoWorkspace.x[17]; acadoVariables.u[14] += acadoWorkspace.x[18]; acadoVariables.u[15] += acadoWorkspace.x[19]; acadoVariables.x[4] += + acadoWorkspace.evGx[0]*acadoWorkspace.x[0] + acadoWorkspace.evGx[1]*acadoWorkspace.x[1] + acadoWorkspace.evGx[2]*acadoWorkspace.x[2] + acadoWorkspace.evGx[3]*acadoWorkspace.x[3] + acadoWorkspace.d[0]; acadoVariables.x[5] += + acadoWorkspace.evGx[4]*acadoWorkspace.x[0] + acadoWorkspace.evGx[5]*acadoWorkspace.x[1] + acadoWorkspace.evGx[6]*acadoWorkspace.x[2] + acadoWorkspace.evGx[7]*acadoWorkspace.x[3] + acadoWorkspace.d[1]; acadoVariables.x[6] += + acadoWorkspace.evGx[8]*acadoWorkspace.x[0] + acadoWorkspace.evGx[9]*acadoWorkspace.x[1] + acadoWorkspace.evGx[10]*acadoWorkspace.x[2] + acadoWorkspace.evGx[11]*acadoWorkspace.x[3] + acadoWorkspace.d[2]; acadoVariables.x[7] += + acadoWorkspace.evGx[12]*acadoWorkspace.x[0] + acadoWorkspace.evGx[13]*acadoWorkspace.x[1] + acadoWorkspace.evGx[14]*acadoWorkspace.x[2] + acadoWorkspace.evGx[15]*acadoWorkspace.x[3] + acadoWorkspace.d[3]; acadoVariables.x[8] += + acadoWorkspace.evGx[16]*acadoWorkspace.x[0] + acadoWorkspace.evGx[17]*acadoWorkspace.x[1] + acadoWorkspace.evGx[18]*acadoWorkspace.x[2] + acadoWorkspace.evGx[19]*acadoWorkspace.x[3] + acadoWorkspace.d[4]; acadoVariables.x[9] += + acadoWorkspace.evGx[20]*acadoWorkspace.x[0] + acadoWorkspace.evGx[21]*acadoWorkspace.x[1] + acadoWorkspace.evGx[22]*acadoWorkspace.x[2] + acadoWorkspace.evGx[23]*acadoWorkspace.x[3] + acadoWorkspace.d[5]; acadoVariables.x[10] += + acadoWorkspace.evGx[24]*acadoWorkspace.x[0] + acadoWorkspace.evGx[25]*acadoWorkspace.x[1] + acadoWorkspace.evGx[26]*acadoWorkspace.x[2] + acadoWorkspace.evGx[27]*acadoWorkspace.x[3] + acadoWorkspace.d[6]; acadoVariables.x[11] += + acadoWorkspace.evGx[28]*acadoWorkspace.x[0] + acadoWorkspace.evGx[29]*acadoWorkspace.x[1] + acadoWorkspace.evGx[30]*acadoWorkspace.x[2] + acadoWorkspace.evGx[31]*acadoWorkspace.x[3] + acadoWorkspace.d[7]; acadoVariables.x[12] += + acadoWorkspace.evGx[32]*acadoWorkspace.x[0] + acadoWorkspace.evGx[33]*acadoWorkspace.x[1] + acadoWorkspace.evGx[34]*acadoWorkspace.x[2] + acadoWorkspace.evGx[35]*acadoWorkspace.x[3] + acadoWorkspace.d[8]; acadoVariables.x[13] += + acadoWorkspace.evGx[36]*acadoWorkspace.x[0] + acadoWorkspace.evGx[37]*acadoWorkspace.x[1] + acadoWorkspace.evGx[38]*acadoWorkspace.x[2] + acadoWorkspace.evGx[39]*acadoWorkspace.x[3] + acadoWorkspace.d[9]; acadoVariables.x[14] += + acadoWorkspace.evGx[40]*acadoWorkspace.x[0] + acadoWorkspace.evGx[41]*acadoWorkspace.x[1] + acadoWorkspace.evGx[42]*acadoWorkspace.x[2] + acadoWorkspace.evGx[43]*acadoWorkspace.x[3] + acadoWorkspace.d[10]; acadoVariables.x[15] += + acadoWorkspace.evGx[44]*acadoWorkspace.x[0] + acadoWorkspace.evGx[45]*acadoWorkspace.x[1] + acadoWorkspace.evGx[46]*acadoWorkspace.x[2] + acadoWorkspace.evGx[47]*acadoWorkspace.x[3] + acadoWorkspace.d[11]; acadoVariables.x[16] += + acadoWorkspace.evGx[48]*acadoWorkspace.x[0] + acadoWorkspace.evGx[49]*acadoWorkspace.x[1] + acadoWorkspace.evGx[50]*acadoWorkspace.x[2] + acadoWorkspace.evGx[51]*acadoWorkspace.x[3] + acadoWorkspace.d[12]; acadoVariables.x[17] += + acadoWorkspace.evGx[52]*acadoWorkspace.x[0] + acadoWorkspace.evGx[53]*acadoWorkspace.x[1] + acadoWorkspace.evGx[54]*acadoWorkspace.x[2] + acadoWorkspace.evGx[55]*acadoWorkspace.x[3] + acadoWorkspace.d[13]; acadoVariables.x[18] += + acadoWorkspace.evGx[56]*acadoWorkspace.x[0] + acadoWorkspace.evGx[57]*acadoWorkspace.x[1] + acadoWorkspace.evGx[58]*acadoWorkspace.x[2] + acadoWorkspace.evGx[59]*acadoWorkspace.x[3] + acadoWorkspace.d[14]; acadoVariables.x[19] += + acadoWorkspace.evGx[60]*acadoWorkspace.x[0] + acadoWorkspace.evGx[61]*acadoWorkspace.x[1] + acadoWorkspace.evGx[62]*acadoWorkspace.x[2] + acadoWorkspace.evGx[63]*acadoWorkspace.x[3] + acadoWorkspace.d[15]; acadoVariables.x[20] += + acadoWorkspace.evGx[64]*acadoWorkspace.x[0] + acadoWorkspace.evGx[65]*acadoWorkspace.x[1] + acadoWorkspace.evGx[66]*acadoWorkspace.x[2] + acadoWorkspace.evGx[67]*acadoWorkspace.x[3] + acadoWorkspace.d[16]; acadoVariables.x[21] += + acadoWorkspace.evGx[68]*acadoWorkspace.x[0] + acadoWorkspace.evGx[69]*acadoWorkspace.x[1] + acadoWorkspace.evGx[70]*acadoWorkspace.x[2] + acadoWorkspace.evGx[71]*acadoWorkspace.x[3] + acadoWorkspace.d[17]; acadoVariables.x[22] += + acadoWorkspace.evGx[72]*acadoWorkspace.x[0] + acadoWorkspace.evGx[73]*acadoWorkspace.x[1] + acadoWorkspace.evGx[74]*acadoWorkspace.x[2] + acadoWorkspace.evGx[75]*acadoWorkspace.x[3] + acadoWorkspace.d[18]; acadoVariables.x[23] += + acadoWorkspace.evGx[76]*acadoWorkspace.x[0] + acadoWorkspace.evGx[77]*acadoWorkspace.x[1] + acadoWorkspace.evGx[78]*acadoWorkspace.x[2] + acadoWorkspace.evGx[79]*acadoWorkspace.x[3] + acadoWorkspace.d[19]; acadoVariables.x[24] += + acadoWorkspace.evGx[80]*acadoWorkspace.x[0] + acadoWorkspace.evGx[81]*acadoWorkspace.x[1] + acadoWorkspace.evGx[82]*acadoWorkspace.x[2] + acadoWorkspace.evGx[83]*acadoWorkspace.x[3] + acadoWorkspace.d[20]; acadoVariables.x[25] += + acadoWorkspace.evGx[84]*acadoWorkspace.x[0] + acadoWorkspace.evGx[85]*acadoWorkspace.x[1] + acadoWorkspace.evGx[86]*acadoWorkspace.x[2] + acadoWorkspace.evGx[87]*acadoWorkspace.x[3] + acadoWorkspace.d[21]; acadoVariables.x[26] += + acadoWorkspace.evGx[88]*acadoWorkspace.x[0] + acadoWorkspace.evGx[89]*acadoWorkspace.x[1] + acadoWorkspace.evGx[90]*acadoWorkspace.x[2] + acadoWorkspace.evGx[91]*acadoWorkspace.x[3] + acadoWorkspace.d[22]; acadoVariables.x[27] += + acadoWorkspace.evGx[92]*acadoWorkspace.x[0] + acadoWorkspace.evGx[93]*acadoWorkspace.x[1] + acadoWorkspace.evGx[94]*acadoWorkspace.x[2] + acadoWorkspace.evGx[95]*acadoWorkspace.x[3] + acadoWorkspace.d[23]; acadoVariables.x[28] += + acadoWorkspace.evGx[96]*acadoWorkspace.x[0] + acadoWorkspace.evGx[97]*acadoWorkspace.x[1] + acadoWorkspace.evGx[98]*acadoWorkspace.x[2] + acadoWorkspace.evGx[99]*acadoWorkspace.x[3] + acadoWorkspace.d[24]; acadoVariables.x[29] += + acadoWorkspace.evGx[100]*acadoWorkspace.x[0] + acadoWorkspace.evGx[101]*acadoWorkspace.x[1] + acadoWorkspace.evGx[102]*acadoWorkspace.x[2] + acadoWorkspace.evGx[103]*acadoWorkspace.x[3] + acadoWorkspace.d[25]; acadoVariables.x[30] += + acadoWorkspace.evGx[104]*acadoWorkspace.x[0] + acadoWorkspace.evGx[105]*acadoWorkspace.x[1] + acadoWorkspace.evGx[106]*acadoWorkspace.x[2] + acadoWorkspace.evGx[107]*acadoWorkspace.x[3] + acadoWorkspace.d[26]; acadoVariables.x[31] += + acadoWorkspace.evGx[108]*acadoWorkspace.x[0] + acadoWorkspace.evGx[109]*acadoWorkspace.x[1] + acadoWorkspace.evGx[110]*acadoWorkspace.x[2] + acadoWorkspace.evGx[111]*acadoWorkspace.x[3] + acadoWorkspace.d[27]; acadoVariables.x[32] += + acadoWorkspace.evGx[112]*acadoWorkspace.x[0] + acadoWorkspace.evGx[113]*acadoWorkspace.x[1] + acadoWorkspace.evGx[114]*acadoWorkspace.x[2] + acadoWorkspace.evGx[115]*acadoWorkspace.x[3] + acadoWorkspace.d[28]; acadoVariables.x[33] += + acadoWorkspace.evGx[116]*acadoWorkspace.x[0] + acadoWorkspace.evGx[117]*acadoWorkspace.x[1] + acadoWorkspace.evGx[118]*acadoWorkspace.x[2] + acadoWorkspace.evGx[119]*acadoWorkspace.x[3] + acadoWorkspace.d[29]; acadoVariables.x[34] += + acadoWorkspace.evGx[120]*acadoWorkspace.x[0] + acadoWorkspace.evGx[121]*acadoWorkspace.x[1] + acadoWorkspace.evGx[122]*acadoWorkspace.x[2] + acadoWorkspace.evGx[123]*acadoWorkspace.x[3] + acadoWorkspace.d[30]; acadoVariables.x[35] += + acadoWorkspace.evGx[124]*acadoWorkspace.x[0] + acadoWorkspace.evGx[125]*acadoWorkspace.x[1] + acadoWorkspace.evGx[126]*acadoWorkspace.x[2] + acadoWorkspace.evGx[127]*acadoWorkspace.x[3] + acadoWorkspace.d[31]; acadoVariables.x[36] += + acadoWorkspace.evGx[128]*acadoWorkspace.x[0] + acadoWorkspace.evGx[129]*acadoWorkspace.x[1] + acadoWorkspace.evGx[130]*acadoWorkspace.x[2] + acadoWorkspace.evGx[131]*acadoWorkspace.x[3] + acadoWorkspace.d[32]; acadoVariables.x[37] += + acadoWorkspace.evGx[132]*acadoWorkspace.x[0] + acadoWorkspace.evGx[133]*acadoWorkspace.x[1] + acadoWorkspace.evGx[134]*acadoWorkspace.x[2] + acadoWorkspace.evGx[135]*acadoWorkspace.x[3] + acadoWorkspace.d[33]; acadoVariables.x[38] += + acadoWorkspace.evGx[136]*acadoWorkspace.x[0] + acadoWorkspace.evGx[137]*acadoWorkspace.x[1] + acadoWorkspace.evGx[138]*acadoWorkspace.x[2] + acadoWorkspace.evGx[139]*acadoWorkspace.x[3] + acadoWorkspace.d[34]; acadoVariables.x[39] += + acadoWorkspace.evGx[140]*acadoWorkspace.x[0] + acadoWorkspace.evGx[141]*acadoWorkspace.x[1] + acadoWorkspace.evGx[142]*acadoWorkspace.x[2] + acadoWorkspace.evGx[143]*acadoWorkspace.x[3] + acadoWorkspace.d[35]; acadoVariables.x[40] += + acadoWorkspace.evGx[144]*acadoWorkspace.x[0] + acadoWorkspace.evGx[145]*acadoWorkspace.x[1] + acadoWorkspace.evGx[146]*acadoWorkspace.x[2] + acadoWorkspace.evGx[147]*acadoWorkspace.x[3] + acadoWorkspace.d[36]; acadoVariables.x[41] += + acadoWorkspace.evGx[148]*acadoWorkspace.x[0] + acadoWorkspace.evGx[149]*acadoWorkspace.x[1] + acadoWorkspace.evGx[150]*acadoWorkspace.x[2] + acadoWorkspace.evGx[151]*acadoWorkspace.x[3] + acadoWorkspace.d[37]; acadoVariables.x[42] += + acadoWorkspace.evGx[152]*acadoWorkspace.x[0] + acadoWorkspace.evGx[153]*acadoWorkspace.x[1] + acadoWorkspace.evGx[154]*acadoWorkspace.x[2] + acadoWorkspace.evGx[155]*acadoWorkspace.x[3] + acadoWorkspace.d[38]; acadoVariables.x[43] += + acadoWorkspace.evGx[156]*acadoWorkspace.x[0] + acadoWorkspace.evGx[157]*acadoWorkspace.x[1] + acadoWorkspace.evGx[158]*acadoWorkspace.x[2] + acadoWorkspace.evGx[159]*acadoWorkspace.x[3] + acadoWorkspace.d[39]; acadoVariables.x[44] += + acadoWorkspace.evGx[160]*acadoWorkspace.x[0] + acadoWorkspace.evGx[161]*acadoWorkspace.x[1] + acadoWorkspace.evGx[162]*acadoWorkspace.x[2] + acadoWorkspace.evGx[163]*acadoWorkspace.x[3] + acadoWorkspace.d[40]; acadoVariables.x[45] += + acadoWorkspace.evGx[164]*acadoWorkspace.x[0] + acadoWorkspace.evGx[165]*acadoWorkspace.x[1] + acadoWorkspace.evGx[166]*acadoWorkspace.x[2] + acadoWorkspace.evGx[167]*acadoWorkspace.x[3] + acadoWorkspace.d[41]; acadoVariables.x[46] += + acadoWorkspace.evGx[168]*acadoWorkspace.x[0] + acadoWorkspace.evGx[169]*acadoWorkspace.x[1] + acadoWorkspace.evGx[170]*acadoWorkspace.x[2] + acadoWorkspace.evGx[171]*acadoWorkspace.x[3] + acadoWorkspace.d[42]; acadoVariables.x[47] += + acadoWorkspace.evGx[172]*acadoWorkspace.x[0] + acadoWorkspace.evGx[173]*acadoWorkspace.x[1] + acadoWorkspace.evGx[174]*acadoWorkspace.x[2] + acadoWorkspace.evGx[175]*acadoWorkspace.x[3] + acadoWorkspace.d[43]; acadoVariables.x[48] += + acadoWorkspace.evGx[176]*acadoWorkspace.x[0] + acadoWorkspace.evGx[177]*acadoWorkspace.x[1] + acadoWorkspace.evGx[178]*acadoWorkspace.x[2] + acadoWorkspace.evGx[179]*acadoWorkspace.x[3] + acadoWorkspace.d[44]; acadoVariables.x[49] += + acadoWorkspace.evGx[180]*acadoWorkspace.x[0] + acadoWorkspace.evGx[181]*acadoWorkspace.x[1] + acadoWorkspace.evGx[182]*acadoWorkspace.x[2] + acadoWorkspace.evGx[183]*acadoWorkspace.x[3] + acadoWorkspace.d[45]; acadoVariables.x[50] += + acadoWorkspace.evGx[184]*acadoWorkspace.x[0] + acadoWorkspace.evGx[185]*acadoWorkspace.x[1] + acadoWorkspace.evGx[186]*acadoWorkspace.x[2] + acadoWorkspace.evGx[187]*acadoWorkspace.x[3] + acadoWorkspace.d[46]; acadoVariables.x[51] += + acadoWorkspace.evGx[188]*acadoWorkspace.x[0] + acadoWorkspace.evGx[189]*acadoWorkspace.x[1] + acadoWorkspace.evGx[190]*acadoWorkspace.x[2] + acadoWorkspace.evGx[191]*acadoWorkspace.x[3] + acadoWorkspace.d[47]; acadoVariables.x[52] += + acadoWorkspace.evGx[192]*acadoWorkspace.x[0] + acadoWorkspace.evGx[193]*acadoWorkspace.x[1] + acadoWorkspace.evGx[194]*acadoWorkspace.x[2] + acadoWorkspace.evGx[195]*acadoWorkspace.x[3] + acadoWorkspace.d[48]; acadoVariables.x[53] += + acadoWorkspace.evGx[196]*acadoWorkspace.x[0] + acadoWorkspace.evGx[197]*acadoWorkspace.x[1] + acadoWorkspace.evGx[198]*acadoWorkspace.x[2] + acadoWorkspace.evGx[199]*acadoWorkspace.x[3] + acadoWorkspace.d[49]; acadoVariables.x[54] += + acadoWorkspace.evGx[200]*acadoWorkspace.x[0] + acadoWorkspace.evGx[201]*acadoWorkspace.x[1] + acadoWorkspace.evGx[202]*acadoWorkspace.x[2] + acadoWorkspace.evGx[203]*acadoWorkspace.x[3] + acadoWorkspace.d[50]; acadoVariables.x[55] += + acadoWorkspace.evGx[204]*acadoWorkspace.x[0] + acadoWorkspace.evGx[205]*acadoWorkspace.x[1] + acadoWorkspace.evGx[206]*acadoWorkspace.x[2] + acadoWorkspace.evGx[207]*acadoWorkspace.x[3] + acadoWorkspace.d[51]; acadoVariables.x[56] += + acadoWorkspace.evGx[208]*acadoWorkspace.x[0] + acadoWorkspace.evGx[209]*acadoWorkspace.x[1] + acadoWorkspace.evGx[210]*acadoWorkspace.x[2] + acadoWorkspace.evGx[211]*acadoWorkspace.x[3] + acadoWorkspace.d[52]; acadoVariables.x[57] += + acadoWorkspace.evGx[212]*acadoWorkspace.x[0] + acadoWorkspace.evGx[213]*acadoWorkspace.x[1] + acadoWorkspace.evGx[214]*acadoWorkspace.x[2] + acadoWorkspace.evGx[215]*acadoWorkspace.x[3] + acadoWorkspace.d[53]; acadoVariables.x[58] += + acadoWorkspace.evGx[216]*acadoWorkspace.x[0] + acadoWorkspace.evGx[217]*acadoWorkspace.x[1] + acadoWorkspace.evGx[218]*acadoWorkspace.x[2] + acadoWorkspace.evGx[219]*acadoWorkspace.x[3] + acadoWorkspace.d[54]; acadoVariables.x[59] += + acadoWorkspace.evGx[220]*acadoWorkspace.x[0] + acadoWorkspace.evGx[221]*acadoWorkspace.x[1] + acadoWorkspace.evGx[222]*acadoWorkspace.x[2] + acadoWorkspace.evGx[223]*acadoWorkspace.x[3] + acadoWorkspace.d[55]; acadoVariables.x[60] += + acadoWorkspace.evGx[224]*acadoWorkspace.x[0] + acadoWorkspace.evGx[225]*acadoWorkspace.x[1] + acadoWorkspace.evGx[226]*acadoWorkspace.x[2] + acadoWorkspace.evGx[227]*acadoWorkspace.x[3] + acadoWorkspace.d[56]; acadoVariables.x[61] += + acadoWorkspace.evGx[228]*acadoWorkspace.x[0] + acadoWorkspace.evGx[229]*acadoWorkspace.x[1] + acadoWorkspace.evGx[230]*acadoWorkspace.x[2] + acadoWorkspace.evGx[231]*acadoWorkspace.x[3] + acadoWorkspace.d[57]; acadoVariables.x[62] += + acadoWorkspace.evGx[232]*acadoWorkspace.x[0] + acadoWorkspace.evGx[233]*acadoWorkspace.x[1] + acadoWorkspace.evGx[234]*acadoWorkspace.x[2] + acadoWorkspace.evGx[235]*acadoWorkspace.x[3] + acadoWorkspace.d[58]; acadoVariables.x[63] += + acadoWorkspace.evGx[236]*acadoWorkspace.x[0] + acadoWorkspace.evGx[237]*acadoWorkspace.x[1] + acadoWorkspace.evGx[238]*acadoWorkspace.x[2] + acadoWorkspace.evGx[239]*acadoWorkspace.x[3] + acadoWorkspace.d[59]; acadoVariables.x[64] += + acadoWorkspace.evGx[240]*acadoWorkspace.x[0] + acadoWorkspace.evGx[241]*acadoWorkspace.x[1] + acadoWorkspace.evGx[242]*acadoWorkspace.x[2] + acadoWorkspace.evGx[243]*acadoWorkspace.x[3] + acadoWorkspace.d[60]; acadoVariables.x[65] += + acadoWorkspace.evGx[244]*acadoWorkspace.x[0] + acadoWorkspace.evGx[245]*acadoWorkspace.x[1] + acadoWorkspace.evGx[246]*acadoWorkspace.x[2] + acadoWorkspace.evGx[247]*acadoWorkspace.x[3] + acadoWorkspace.d[61]; acadoVariables.x[66] += + acadoWorkspace.evGx[248]*acadoWorkspace.x[0] + acadoWorkspace.evGx[249]*acadoWorkspace.x[1] + acadoWorkspace.evGx[250]*acadoWorkspace.x[2] + acadoWorkspace.evGx[251]*acadoWorkspace.x[3] + acadoWorkspace.d[62]; acadoVariables.x[67] += + acadoWorkspace.evGx[252]*acadoWorkspace.x[0] + acadoWorkspace.evGx[253]*acadoWorkspace.x[1] + acadoWorkspace.evGx[254]*acadoWorkspace.x[2] + acadoWorkspace.evGx[255]*acadoWorkspace.x[3] + acadoWorkspace.d[63]; acado_multEDu( acadoWorkspace.E, &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 4 ]) ); acado_multEDu( &(acadoWorkspace.E[ 4 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 8 ]) ); acado_multEDu( &(acadoWorkspace.E[ 8 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 8 ]) ); acado_multEDu( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 16 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 20 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 16 ]) ); acado_multEDu( &(acadoWorkspace.E[ 28 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 16 ]) ); acado_multEDu( &(acadoWorkspace.E[ 32 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 16 ]) ); acado_multEDu( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 16 ]) ); acado_multEDu( &(acadoWorkspace.E[ 40 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 20 ]) ); acado_multEDu( &(acadoWorkspace.E[ 44 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 20 ]) ); acado_multEDu( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 20 ]) ); acado_multEDu( &(acadoWorkspace.E[ 52 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 20 ]) ); acado_multEDu( &(acadoWorkspace.E[ 56 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 20 ]) ); acado_multEDu( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 64 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 68 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 76 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 80 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 88 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 92 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 100 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 104 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 28 ]) ); acado_multEDu( &(acadoWorkspace.E[ 112 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 116 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 124 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 128 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 136 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 140 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 32 ]) ); acado_multEDu( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 148 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 152 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 160 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 164 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 172 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 176 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 184 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 188 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 196 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 200 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 208 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 212 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 40 ]) ); acado_multEDu( &(acadoWorkspace.E[ 220 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 224 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 232 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 236 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 244 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 248 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 256 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 260 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 44 ]) ); acado_multEDu( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 268 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 272 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 280 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 284 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 292 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 296 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 304 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 308 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 316 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 320 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 328 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 332 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 340 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 344 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 352 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 356 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 52 ]) ); acado_multEDu( &(acadoWorkspace.E[ 364 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 368 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 376 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 380 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 388 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 392 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 400 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 404 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 412 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 416 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 56 ]) ); acado_multEDu( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 424 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 428 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 436 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 440 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 448 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 452 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 460 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 464 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 472 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 476 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 484 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 488 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 496 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 500 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 508 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 512 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 520 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 524 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 532 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 536 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 64 ]) ); acado_multEDu( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 64 ]) ); } int acado_preparationStep( ) { int ret; ret = acado_modelSimulation(); acado_evaluateObjective( ); acado_condensePrep( ); return ret; } int acado_feedbackStep( ) { int tmp; acado_condenseFdb( ); tmp = acado_solve( ); acado_expand( ); return tmp; } int acado_initializeSolver( ) { int ret; /* This is a function which must be called once before any other function call! */ ret = 0; memset(&acadoWorkspace, 0, sizeof( acadoWorkspace )); return ret; } void acado_initializeNodesByForwardSimulation( ) { int index; for (index = 0; index < 16; ++index) { acadoWorkspace.state[0] = acadoVariables.x[index * 4]; acadoWorkspace.state[1] = acadoVariables.x[index * 4 + 1]; acadoWorkspace.state[2] = acadoVariables.x[index * 4 + 2]; acadoWorkspace.state[3] = acadoVariables.x[index * 4 + 3]; acadoWorkspace.state[24] = acadoVariables.u[index]; acadoWorkspace.state[25] = acadoVariables.od[index * 2]; acadoWorkspace.state[26] = acadoVariables.od[index * 2 + 1]; acado_integrate(acadoWorkspace.state, index == 0, index); acadoVariables.x[index * 4 + 4] = acadoWorkspace.state[0]; acadoVariables.x[index * 4 + 5] = acadoWorkspace.state[1]; acadoVariables.x[index * 4 + 6] = acadoWorkspace.state[2]; acadoVariables.x[index * 4 + 7] = acadoWorkspace.state[3]; } } void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ) { int index; for (index = 0; index < 16; ++index) { acadoVariables.x[index * 4] = acadoVariables.x[index * 4 + 4]; acadoVariables.x[index * 4 + 1] = acadoVariables.x[index * 4 + 5]; acadoVariables.x[index * 4 + 2] = acadoVariables.x[index * 4 + 6]; acadoVariables.x[index * 4 + 3] = acadoVariables.x[index * 4 + 7]; } if (strategy == 1 && xEnd != 0) { acadoVariables.x[64] = xEnd[0]; acadoVariables.x[65] = xEnd[1]; acadoVariables.x[66] = xEnd[2]; acadoVariables.x[67] = xEnd[3]; } else if (strategy == 2) { acadoWorkspace.state[0] = acadoVariables.x[64]; acadoWorkspace.state[1] = acadoVariables.x[65]; acadoWorkspace.state[2] = acadoVariables.x[66]; acadoWorkspace.state[3] = acadoVariables.x[67]; if (uEnd != 0) { acadoWorkspace.state[24] = uEnd[0]; } else { acadoWorkspace.state[24] = acadoVariables.u[15]; } acadoWorkspace.state[25] = acadoVariables.od[32]; acadoWorkspace.state[26] = acadoVariables.od[33]; acado_integrate(acadoWorkspace.state, 1, 15); acadoVariables.x[64] = acadoWorkspace.state[0]; acadoVariables.x[65] = acadoWorkspace.state[1]; acadoVariables.x[66] = acadoWorkspace.state[2]; acadoVariables.x[67] = acadoWorkspace.state[3]; } } void acado_shiftControls( real_t* const uEnd ) { int index; for (index = 0; index < 15; ++index) { acadoVariables.u[index] = acadoVariables.u[index + 1]; } if (uEnd != 0) { acadoVariables.u[15] = uEnd[0]; } } real_t acado_getKKT( ) { real_t kkt; int index; real_t prd; kkt = + acadoWorkspace.g[0]*acadoWorkspace.x[0] + acadoWorkspace.g[1]*acadoWorkspace.x[1] + acadoWorkspace.g[2]*acadoWorkspace.x[2] + acadoWorkspace.g[3]*acadoWorkspace.x[3] + acadoWorkspace.g[4]*acadoWorkspace.x[4] + acadoWorkspace.g[5]*acadoWorkspace.x[5] + acadoWorkspace.g[6]*acadoWorkspace.x[6] + acadoWorkspace.g[7]*acadoWorkspace.x[7] + acadoWorkspace.g[8]*acadoWorkspace.x[8] + acadoWorkspace.g[9]*acadoWorkspace.x[9] + acadoWorkspace.g[10]*acadoWorkspace.x[10] + acadoWorkspace.g[11]*acadoWorkspace.x[11] + acadoWorkspace.g[12]*acadoWorkspace.x[12] + acadoWorkspace.g[13]*acadoWorkspace.x[13] + acadoWorkspace.g[14]*acadoWorkspace.x[14] + acadoWorkspace.g[15]*acadoWorkspace.x[15] + acadoWorkspace.g[16]*acadoWorkspace.x[16] + acadoWorkspace.g[17]*acadoWorkspace.x[17] + acadoWorkspace.g[18]*acadoWorkspace.x[18] + acadoWorkspace.g[19]*acadoWorkspace.x[19]; kkt = fabs( kkt ); for (index = 0; index < 20; ++index) { prd = acadoWorkspace.y[index]; if (prd > 1e-12) kkt += fabs(acadoWorkspace.lb[index] * prd); else if (prd < -1e-12) kkt += fabs(acadoWorkspace.ub[index] * prd); } for (index = 0; index < 32; ++index) { prd = acadoWorkspace.y[index + 20]; if (prd > 1e-12) kkt += fabs(acadoWorkspace.lbA[index] * prd); else if (prd < -1e-12) kkt += fabs(acadoWorkspace.ubA[index] * prd); } return kkt; } real_t acado_getObjective( ) { real_t objVal; int lRun1; /** Row vector of size: 3 */ real_t tmpDy[ 3 ]; /** Row vector of size: 2 */ real_t tmpDyN[ 2 ]; for (lRun1 = 0; lRun1 < 16; ++lRun1) { acadoWorkspace.objValueIn[0] = acadoVariables.x[lRun1 * 4]; acadoWorkspace.objValueIn[1] = acadoVariables.x[lRun1 * 4 + 1]; acadoWorkspace.objValueIn[2] = acadoVariables.x[lRun1 * 4 + 2]; acadoWorkspace.objValueIn[3] = acadoVariables.x[lRun1 * 4 + 3]; acadoWorkspace.objValueIn[4] = acadoVariables.u[lRun1]; acadoWorkspace.objValueIn[5] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.objValueIn[6] = acadoVariables.od[lRun1 * 2 + 1]; acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.Dy[lRun1 * 3] = acadoWorkspace.objValueOut[0] - acadoVariables.y[lRun1 * 3]; acadoWorkspace.Dy[lRun1 * 3 + 1] = acadoWorkspace.objValueOut[1] - acadoVariables.y[lRun1 * 3 + 1]; acadoWorkspace.Dy[lRun1 * 3 + 2] = acadoWorkspace.objValueOut[2] - acadoVariables.y[lRun1 * 3 + 2]; } acadoWorkspace.objValueIn[0] = acadoVariables.x[64]; acadoWorkspace.objValueIn[1] = acadoVariables.x[65]; acadoWorkspace.objValueIn[2] = acadoVariables.x[66]; acadoWorkspace.objValueIn[3] = acadoVariables.x[67]; acadoWorkspace.objValueIn[4] = acadoVariables.od[32]; acadoWorkspace.objValueIn[5] = acadoVariables.od[33]; acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0] - acadoVariables.yN[0]; acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1] - acadoVariables.yN[1]; objVal = 0.0000000000000000e+00; for (lRun1 = 0; lRun1 < 16; ++lRun1) { tmpDy[0] = + acadoWorkspace.Dy[lRun1 * 3]*acadoVariables.W[lRun1 * 9] + acadoWorkspace.Dy[lRun1 * 3 + 1]*acadoVariables.W[lRun1 * 9 + 3] + acadoWorkspace.Dy[lRun1 * 3 + 2]*acadoVariables.W[lRun1 * 9 + 6]; tmpDy[1] = + acadoWorkspace.Dy[lRun1 * 3]*acadoVariables.W[lRun1 * 9 + 1] + acadoWorkspace.Dy[lRun1 * 3 + 1]*acadoVariables.W[lRun1 * 9 + 4] + acadoWorkspace.Dy[lRun1 * 3 + 2]*acadoVariables.W[lRun1 * 9 + 7]; tmpDy[2] = + acadoWorkspace.Dy[lRun1 * 3]*acadoVariables.W[lRun1 * 9 + 2] + acadoWorkspace.Dy[lRun1 * 3 + 1]*acadoVariables.W[lRun1 * 9 + 5] + acadoWorkspace.Dy[lRun1 * 3 + 2]*acadoVariables.W[lRun1 * 9 + 8]; objVal += + acadoWorkspace.Dy[lRun1 * 3]*tmpDy[0] + acadoWorkspace.Dy[lRun1 * 3 + 1]*tmpDy[1] + acadoWorkspace.Dy[lRun1 * 3 + 2]*tmpDy[2]; } tmpDyN[0] = + acadoWorkspace.DyN[0]*acadoVariables.WN[0] + acadoWorkspace.DyN[1]*acadoVariables.WN[2]; tmpDyN[1] = + acadoWorkspace.DyN[0]*acadoVariables.WN[1] + acadoWorkspace.DyN[1]*acadoVariables.WN[3]; objVal += + acadoWorkspace.DyN[0]*tmpDyN[0] + acadoWorkspace.DyN[1]*tmpDyN[1]; objVal *= 0.5; return objVal; } ================================================ FILE: selfdrive/controls/lib/lateral_mpc/libmpc_py.py ================================================ import os from cffi import FFI from common.ffi_wrapper import suffix mpc_dir = os.path.dirname(os.path.abspath(__file__)) libmpc_fn = os.path.join(mpc_dir, "libmpc"+suffix()) ffi = FFI() ffi.cdef(""" typedef struct { double x, y, psi, curvature, curvature_rate; } state_t; int N = 16; typedef struct { double x[N+1]; double y[N+1]; double psi[N+1]; double curvature[N+1]; double curvature_rate[N]; double cost; } log_t; void init(); void set_weights(double pathCost, double headingCost, double steerRateCost); int run_mpc(state_t * x0, log_t * solution, double v_ego, double rotation_radius, double target_y[N+1], double target_psi[N+1]); """) libmpc = ffi.dlopen(libmpc_fn) ================================================ FILE: selfdrive/controls/lib/lateral_planner.py ================================================ import math import numpy as np from common.realtime import sec_since_boot, DT_MDL from common.numpy_fast import interp from selfdrive.swaglog import cloudlog from selfdrive.controls.lib.lateral_mpc import libmpc_py from selfdrive.controls.lib.drive_helpers import CONTROL_N, MPC_COST_LAT, LAT_MPC_N, CAR_ROTATION_RADIUS from selfdrive.controls.lib.lane_planner import LanePlanner, TRAJECTORY_SIZE from selfdrive.config import Conversions as CV import cereal.messaging as messaging from cereal import log LaneChangeState = log.LateralPlan.LaneChangeState LaneChangeDirection = log.LateralPlan.LaneChangeDirection LANE_CHANGE_SPEED_MIN = 30 * CV.MPH_TO_MS LANE_CHANGE_TIME_MAX = 10. DESIRES = { LaneChangeDirection.none: { LaneChangeState.off: log.LateralPlan.Desire.none, LaneChangeState.preLaneChange: log.LateralPlan.Desire.none, LaneChangeState.laneChangeStarting: log.LateralPlan.Desire.none, LaneChangeState.laneChangeFinishing: log.LateralPlan.Desire.none, }, LaneChangeDirection.left: { LaneChangeState.off: log.LateralPlan.Desire.none, LaneChangeState.preLaneChange: log.LateralPlan.Desire.none, LaneChangeState.laneChangeStarting: log.LateralPlan.Desire.laneChangeLeft, LaneChangeState.laneChangeFinishing: log.LateralPlan.Desire.laneChangeLeft, }, LaneChangeDirection.right: { LaneChangeState.off: log.LateralPlan.Desire.none, LaneChangeState.preLaneChange: log.LateralPlan.Desire.none, LaneChangeState.laneChangeStarting: log.LateralPlan.Desire.laneChangeRight, LaneChangeState.laneChangeFinishing: log.LateralPlan.Desire.laneChangeRight, }, } class LateralPlanner(): def __init__(self, CP, use_lanelines=True, wide_camera=False): self.use_lanelines = use_lanelines self.LP = LanePlanner(wide_camera) self.last_cloudlog_t = 0 self.steer_rate_cost = CP.steerRateCost self.setup_mpc() self.solution_invalid_cnt = 0 self.lane_change_state = LaneChangeState.off self.lane_change_direction = LaneChangeDirection.none self.lane_change_timer = 0.0 self.lane_change_ll_prob = 1.0 self.keep_pulse_timer = 0.0 self.prev_one_blinker = False self.desire = log.LateralPlan.Desire.none self.path_xyz = np.zeros((TRAJECTORY_SIZE,3)) self.path_xyz_stds = np.ones((TRAJECTORY_SIZE,3)) self.plan_yaw = np.zeros((TRAJECTORY_SIZE,)) self.t_idxs = np.arange(TRAJECTORY_SIZE) self.y_pts = np.zeros(TRAJECTORY_SIZE) self.d_path_w_lines_xyz = np.zeros((TRAJECTORY_SIZE, 3)) # dp self.dp_torque_apply_length = 1.5 # secs of torque we apply for self.dp_lc_auto_start = 0. # time to start alc self.dp_lc_auto_start_in = 0. # remaining time to start alc self.dp_lc_auto_torque_end = 0. # time to end applying torque self.dp_torque_apply = False # should we apply torque? self.laneless_mode = 2 # AUTO self.laneless_mode_status = False self.laneless_mode_status_buffer = False def setup_mpc(self): self.libmpc = libmpc_py.libmpc self.libmpc.init() self.mpc_solution = libmpc_py.ffi.new("log_t *") self.cur_state = libmpc_py.ffi.new("state_t *") self.cur_state[0].x = 0.0 self.cur_state[0].y = 0.0 self.cur_state[0].psi = 0.0 self.cur_state[0].curvature = 0.0 self.desired_curvature = 0.0 self.safe_desired_curvature = 0.0 self.desired_curvature_rate = 0.0 self.safe_desired_curvature_rate = 0.0 def update(self, sm, CP): self.use_lanelines = not sm['dragonConf'].dpLaneLessModeCtrl self.laneless_mode = sm['dragonConf'].dpLaneLessMode v_ego = sm['carState'].vEgo active = sm['controlsState'].active measured_curvature = sm['controlsState'].curvature self.LP.update_dp_set_offsets(sm['dragonConf'].dpCameraOffset, sm['dragonConf'].dpPathOffset) md = sm['modelV2'] self.LP.parse_model(sm['modelV2']) if len(md.position.x) == TRAJECTORY_SIZE and len(md.orientation.x) == TRAJECTORY_SIZE: self.path_xyz = np.column_stack([md.position.x, md.position.y, md.position.z]) self.t_idxs = np.array(md.position.t) self.plan_yaw = list(md.orientation.z) if len(md.orientation.xStd) == TRAJECTORY_SIZE: self.path_xyz_stds = np.column_stack([md.position.xStd, md.position.yStd, md.position.zStd]) # Lane change logic one_blinker = sm['carState'].leftBlinker != sm['carState'].rightBlinker below_lane_change_speed = v_ego < (sm['dragonConf'].dpLcMinMph * CV.MPH_TO_MS) if (not active) or (self.lane_change_timer > LANE_CHANGE_TIME_MAX): self.lane_change_state = LaneChangeState.off self.lane_change_direction = LaneChangeDirection.none else: reset = False if one_blinker: cur_time = sec_since_boot() # reach auto lc condition if not below_lane_change_speed and sm['dragonConf'].dpLateralMode == 2 and v_ego >= (sm['dragonConf'].dpLcAutoMinMph * CV.MPH_TO_MS): # work out alc start time and torque apply end time if self.dp_lc_auto_start == 0.: self.dp_lc_auto_start = cur_time + sm['dragonConf'].dpLcAutoDelay self.dp_lc_auto_torque_end = self.dp_lc_auto_start + self.dp_torque_apply_length else: # work out how long til alc start # for display only self.dp_lc_auto_start_in = self.dp_lc_auto_start - cur_time self.dp_torque_apply = True if self.dp_lc_auto_start < cur_time <= self.dp_lc_auto_torque_end else False else: reset = True # reset all vals if not active or reset: self.dp_lc_auto_start = 0. self.dp_lc_auto_start_in = 0. self.dp_lc_auto_torque_end = 0. self.dp_torque_apply = False # LaneChangeState.off if self.lane_change_state == LaneChangeState.off and one_blinker and not self.prev_one_blinker and not below_lane_change_speed: self.lane_change_state = LaneChangeState.preLaneChange self.lane_change_ll_prob = 1.0 # LaneChangeState.preLaneChange elif self.lane_change_state == LaneChangeState.preLaneChange: # Set lane change direction if sm['carState'].leftBlinker: self.lane_change_direction = LaneChangeDirection.left elif sm['carState'].rightBlinker: self.lane_change_direction = LaneChangeDirection.right else: # If there are no blinkers we will go back to LaneChangeState.off self.lane_change_direction = LaneChangeDirection.none torque_applied = sm['carState'].steeringPressed and \ ((sm['carState'].steeringTorque > 0 and self.lane_change_direction == LaneChangeDirection.left) or (sm['carState'].steeringTorque < 0 and self.lane_change_direction == LaneChangeDirection.right)) blindspot_detected = ((sm['carState'].leftBlindspot and self.lane_change_direction == LaneChangeDirection.left) or (sm['carState'].rightBlindspot and self.lane_change_direction == LaneChangeDirection.right)) # if human made lane change prior alca, we should stop alca until new blinker (off -> on) self.dp_lc_auto_start = self.dp_lc_auto_torque_end if torque_applied else self.dp_lc_auto_start torque_applied = self.dp_torque_apply if self.dp_torque_apply else torque_applied if not one_blinker or below_lane_change_speed: self.lane_change_state = LaneChangeState.off elif torque_applied and not blindspot_detected: self.lane_change_state = LaneChangeState.laneChangeStarting # LaneChangeState.laneChangeStarting elif self.lane_change_state == LaneChangeState.laneChangeStarting: # fade out over .5s self.lane_change_ll_prob = max(self.lane_change_ll_prob - 2*DT_MDL, 0.0) # 98% certainty lane_change_prob = self.LP.l_lane_change_prob + self.LP.r_lane_change_prob if lane_change_prob < 0.02 and self.lane_change_ll_prob < 0.01: self.lane_change_state = LaneChangeState.laneChangeFinishing # LaneChangeState.laneChangeFinishing elif self.lane_change_state == LaneChangeState.laneChangeFinishing: # fade in laneline over 1s self.lane_change_ll_prob = min(self.lane_change_ll_prob + DT_MDL, 1.0) if one_blinker and self.lane_change_ll_prob > 0.99: self.lane_change_state = LaneChangeState.preLaneChange elif self.lane_change_ll_prob > 0.99: self.lane_change_state = LaneChangeState.off if self.lane_change_state in [LaneChangeState.off, LaneChangeState.preLaneChange]: self.lane_change_timer = 0.0 else: self.lane_change_timer += DT_MDL self.prev_one_blinker = one_blinker self.desire = DESIRES[self.lane_change_direction][self.lane_change_state] # Send keep pulse once per second during LaneChangeStart.preLaneChange if self.lane_change_state in [LaneChangeState.off, LaneChangeState.laneChangeStarting]: self.keep_pulse_timer = 0.0 elif self.lane_change_state == LaneChangeState.preLaneChange: self.keep_pulse_timer += DT_MDL if self.keep_pulse_timer > 1.0: self.keep_pulse_timer = 0.0 elif self.desire in [log.LateralPlan.Desire.keepLeft, log.LateralPlan.Desire.keepRight]: self.desire = log.LateralPlan.Desire.none # Turn off lanes during lane change if self.desire == log.LateralPlan.Desire.laneChangeRight or self.desire == log.LateralPlan.Desire.laneChangeLeft: self.LP.lll_prob *= self.lane_change_ll_prob self.LP.rll_prob *= self.lane_change_ll_prob self.d_path_w_lines_xyz = self.LP.get_d_path(v_ego, self.t_idxs, self.path_xyz) if self.use_lanelines: d_path_xyz = self.d_path_w_lines_xyz self.libmpc.set_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.HEADING, CP.steerRateCost) self.laneless_mode_status = False elif self.laneless_mode == 0: d_path_xyz = self.LP.get_d_path(v_ego, self.t_idxs, self.path_xyz) self.libmpc.set_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.HEADING, CP.steerRateCost) self.laneless_mode_status = False elif self.laneless_mode == 1: d_path_xyz = self.path_xyz path_cost = np.clip(abs(self.path_xyz[0,1]/self.path_xyz_stds[0,1]), 0.5, 5.0) * MPC_COST_LAT.PATH # Heading cost is useful at low speed, otherwise end of plan can be off-heading heading_cost = interp(v_ego, [5.0, 10.0], [MPC_COST_LAT.HEADING, 0.0]) self.libmpc.set_weights(path_cost, heading_cost, CP.steerRateCost) self.laneless_mode_status = True elif self.laneless_mode == 2 and ((self.LP.lll_prob + self.LP.rll_prob)/2 < 0.3) and self.lane_change_state == LaneChangeState.off: d_path_xyz = self.path_xyz path_cost = np.clip(abs(self.path_xyz[0,1]/self.path_xyz_stds[0,1]), 0.5, 5.0) * MPC_COST_LAT.PATH # Heading cost is useful at low speed, otherwise end of plan can be off-heading heading_cost = interp(v_ego, [5.0, 10.0], [MPC_COST_LAT.HEADING, 0.0]) self.libmpc.set_weights(path_cost, heading_cost, CP.steerRateCost) self.laneless_mode_status = True self.laneless_mode_status_buffer = True elif self.laneless_mode == 2 and ((self.LP.lll_prob + self.LP.rll_prob)/2 > 0.5) and \ self.laneless_mode_status_buffer and self.lane_change_state == LaneChangeState.off: d_path_xyz = self.LP.get_d_path(v_ego, self.t_idxs, self.path_xyz) self.libmpc.set_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.HEADING, CP.steerRateCost) self.laneless_mode_status = False self.laneless_mode_status_buffer = False elif self.laneless_mode == 2 and self.laneless_mode_status_buffer == True and self.lane_change_state == LaneChangeState.off: d_path_xyz = self.path_xyz path_cost = np.clip(abs(self.path_xyz[0,1]/self.path_xyz_stds[0,1]), 0.5, 5.0) * MPC_COST_LAT.PATH # Heading cost is useful at low speed, otherwise end of plan can be off-heading heading_cost = interp(v_ego, [5.0, 10.0], [MPC_COST_LAT.HEADING, 0.0]) self.libmpc.set_weights(path_cost, heading_cost, CP.steerRateCost) self.laneless_mode_status = True else: d_path_xyz = self.LP.get_d_path(v_ego, self.t_idxs, self.path_xyz) self.libmpc.set_weights(MPC_COST_LAT.PATH, MPC_COST_LAT.HEADING, CP.steerRateCost) self.laneless_mode_status = False self.laneless_mode_status_buffer = False y_pts = np.interp(v_ego * self.t_idxs[:LAT_MPC_N + 1], np.linalg.norm(d_path_xyz, axis=1), d_path_xyz[:,1]) heading_pts = np.interp(v_ego * self.t_idxs[:LAT_MPC_N + 1], np.linalg.norm(self.path_xyz, axis=1), self.plan_yaw) self.y_pts = y_pts assert len(y_pts) == LAT_MPC_N + 1 assert len(heading_pts) == LAT_MPC_N + 1 # for now CAR_ROTATION_RADIUS is disabled # to use it, enable it in the MPC assert abs(CAR_ROTATION_RADIUS) < 1e-3 self.libmpc.run_mpc(self.cur_state, self.mpc_solution, float(v_ego), CAR_ROTATION_RADIUS, list(y_pts), list(heading_pts)) # init state for next self.cur_state.x = 0.0 self.cur_state.y = 0.0 self.cur_state.psi = 0.0 self.cur_state.curvature = interp(DT_MDL, self.t_idxs[:LAT_MPC_N + 1], self.mpc_solution.curvature) # Check for infeasable MPC solution mpc_nans = any(math.isnan(x) for x in self.mpc_solution.curvature) t = sec_since_boot() if mpc_nans: self.libmpc.init() self.cur_state.curvature = measured_curvature if t > self.last_cloudlog_t + 5.0: self.last_cloudlog_t = t cloudlog.warning("Lateral mpc - nan: True") if self.mpc_solution[0].cost > 20000. or mpc_nans: # TODO: find a better way to detect when MPC did not converge self.solution_invalid_cnt += 1 else: self.solution_invalid_cnt = 0 def publish(self, sm, pm): plan_solution_valid = self.solution_invalid_cnt < 2 plan_send = messaging.new_message('lateralPlan') plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState', 'modelV2', 'dragonConf']) plan_send.lateralPlan.laneWidth = float(self.LP.lane_width) plan_send.lateralPlan.dPathPoints = [float(x) for x in self.y_pts] plan_send.lateralPlan.psis = [float(x) for x in self.mpc_solution.psi[0:CONTROL_N]] plan_send.lateralPlan.curvatures = [float(x) for x in self.mpc_solution.curvature[0:CONTROL_N]] plan_send.lateralPlan.curvatureRates = [float(x) for x in self.mpc_solution.curvature_rate[0:CONTROL_N-1]] +[0.0] plan_send.lateralPlan.lProb = float(self.LP.lll_prob) plan_send.lateralPlan.rProb = float(self.LP.rll_prob) plan_send.lateralPlan.dProb = float(self.LP.d_prob) plan_send.lateralPlan.mpcSolutionValid = bool(plan_solution_valid) plan_send.lateralPlan.desire = self.desire plan_send.lateralPlan.laneChangeState = self.lane_change_state plan_send.lateralPlan.laneChangeDirection = self.lane_change_direction plan_send.lateralPlan.dpALCAStartIn = self.dp_lc_auto_start_in plan_send.lateralPlan.dPathWLinesX = [float(x) for x in self.d_path_w_lines_xyz[:, 0]] plan_send.lateralPlan.dPathWLinesY = [float(y) for y in self.d_path_w_lines_xyz[:, 1]] plan_send.lateralPlan.dpLaneLessModeStatus = bool(self.laneless_mode_status) plan_send.lateralPlan.dPathWLinesX = [float(x) for x in self.d_path_w_lines_xyz[:, 0]] plan_send.lateralPlan.dPathWLinesY = [float(y) for y in self.d_path_w_lines_xyz[:, 1]] pm.send('lateralPlan', plan_send) ================================================ FILE: selfdrive/controls/lib/lead_mpc.py ================================================ import math import numpy as np from common.numpy_fast import interp from common.realtime import sec_since_boot from selfdrive.modeld.constants import T_IDXS from selfdrive.controls.lib.radar_helpers import _LEAD_ACCEL_TAU from selfdrive.controls.lib.lead_mpc_lib import libmpc_py from selfdrive.controls.lib.drive_helpers import MPC_COST_LONG, CONTROL_N from selfdrive.swaglog import cloudlog MPC_T = list(np.arange(0,1.,.2)) + list(np.arange(1.,10.6,.6)) class LeadMpc(): def __init__(self, mpc_id): self.lead_id = mpc_id self.reset_mpc() self.prev_lead_status = False self.prev_lead_x = 0.0 self.new_lead = False self.last_cloudlog_t = 0.0 self.n_its = 0 self.duration = 0 self.status = False self.v_solution = np.zeros(CONTROL_N) self.a_solution = np.zeros(CONTROL_N) self.j_solution = np.zeros(CONTROL_N) # dp self.following_distance = 1.8 self.following_distance_last = None def set_following_distance(self, following_distance): self.following_distance = following_distance if self.following_distance != self.following_distance_last: self.reset_mpc() self.following_distance_last = self.following_distance def reset_mpc(self): ffi, self.libmpc = libmpc_py.get_libmpc(self.lead_id) self.libmpc.init(MPC_COST_LONG.TTC, MPC_COST_LONG.DISTANCE, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK) self.mpc_solution = ffi.new("log_t *") self.cur_state = ffi.new("state_t *") self.cur_state[0].v_ego = 0 self.cur_state[0].a_ego = 0 self.a_lead_tau = _LEAD_ACCEL_TAU def set_cur_state(self, v, a): v_safe = max(v, 1e-3) a_safe = a self.cur_state[0].v_ego = v_safe self.cur_state[0].a_ego = a_safe def update(self, CS, radarstate, v_cruise, a_target, active): v_ego = CS.vEgo if self.lead_id == 0: lead = radarstate.leadOne else: lead = radarstate.leadTwo self.status = lead.status # Setup current mpc state self.cur_state[0].x_ego = 0.0 if lead is not None and lead.status: x_lead = lead.dRel v_lead = max(0.0, lead.vLead) a_lead = lead.aLeadK if (v_lead < 0.1 or -a_lead / 2.0 > v_lead): v_lead = 0.0 a_lead = 0.0 self.a_lead_tau = lead.aLeadTau self.new_lead = False if not self.prev_lead_status or abs(x_lead - self.prev_lead_x) > 2.5: self.libmpc.init_with_simulation(v_ego, x_lead, v_lead, a_lead, self.a_lead_tau) self.new_lead = True self.prev_lead_status = True self.prev_lead_x = x_lead self.cur_state[0].x_l = x_lead self.cur_state[0].v_l = v_lead else: self.prev_lead_status = False # Fake a fast lead car, so mpc keeps running self.cur_state[0].x_l = 50.0 self.cur_state[0].v_l = v_ego + 10.0 a_lead = 0.0 self.a_lead_tau = _LEAD_ACCEL_TAU # Calculate mpc t = sec_since_boot() self.n_its = self.libmpc.run_mpc(self.cur_state, self.mpc_solution, self.a_lead_tau, a_lead, self.following_distance) self.v_solution = interp(T_IDXS[:CONTROL_N], MPC_T, self.mpc_solution.v_ego) self.a_solution = interp(T_IDXS[:CONTROL_N], MPC_T, self.mpc_solution.a_ego) self.j_solution = interp(T_IDXS[:CONTROL_N], MPC_T[:-1], self.mpc_solution.j_ego) self.duration = int((sec_since_boot() - t) * 1e9) # Reset if NaN or goes through lead car crashing = any(lead - ego < -50 for (lead, ego) in zip(self.mpc_solution[0].x_l, self.mpc_solution[0].x_ego)) nans = any(math.isnan(x) for x in self.mpc_solution[0].v_ego) backwards = min(self.mpc_solution[0].v_ego) < -0.15 if ((backwards or crashing) and self.prev_lead_status) or nans: if t > self.last_cloudlog_t + 5.0: self.last_cloudlog_t = t cloudlog.warning("Longitudinal mpc %d reset - backwards: %s crashing: %s nan: %s" % ( self.lead_id, backwards, crashing, nans)) self.libmpc.init(MPC_COST_LONG.TTC, MPC_COST_LONG.DISTANCE, MPC_COST_LONG.ACCELERATION, MPC_COST_LONG.JERK) self.cur_state[0].v_ego = v_ego self.cur_state[0].a_ego = 0.0 self.a_mpc = CS.aEgo self.prev_lead_status = False ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/.gitignore ================================================ generator lib_qp/ ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/SConscript ================================================ Import('env', 'arch') cpp_path = [ "#phonelibs/acado/include", "#phonelibs/acado/include/acado", "#phonelibs/qpoases/INCLUDE", "#phonelibs/qpoases/INCLUDE/EXTRAS", "#phonelibs/qpoases/SRC/", "#phonelibs/qpoases", "lib_mpc_export", ] generated_c = [ 'lib_mpc_export/acado_auxiliary_functions.c', 'lib_mpc_export/acado_qpoases_interface.cpp', 'lib_mpc_export/acado_integrator.c', 'lib_mpc_export/acado_solver.c', ] generated_h = [ 'lib_mpc_export/acado_common.h', 'lib_mpc_export/acado_auxiliary_functions.h', 'lib_mpc_export/acado_qpoases_interface.hpp', ] interface_dir = Dir('lib_mpc_export') SConscript(['#phonelibs/qpoases/SConscript'], variant_dir='lib_qp', exports=['interface_dir']) if GetOption('mpc_generate'): generator_cpp = File('generator.cpp') acado_libs = [File(f"#phonelibs/acado/{arch}/lib/libacado_toolkit.a"), File(f"#phonelibs/acado/{arch}/lib/libacado_casadi.a"), File(f"#phonelibs/acado/{arch}/lib/libacado_csparse.a")] generator = env.Program('generator', generator_cpp, LIBS=acado_libs, CPPPATH=cpp_path, CCFLAGS=env['CCFLAGS'] + ["-Wno-deprecated", "-Wno-overloaded-shift-op-parentheses"]) cmd = f"cd {Dir('.').get_abspath()} && {generator[0].get_abspath()}" env.Command(generated_c + generated_h, generator, cmd) mpc_files = ["longitudinal_mpc.c"] + generated_c env.SharedLibrary('mpc0', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) env.SharedLibrary('mpc1', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/__init__.py ================================================ ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/generator.cpp ================================================ #include const int controlHorizon = 50; using namespace std; #define G 9.81 #define TR 1.8 #define RW(v_ego, v_l) (v_ego * TR - (v_l - v_ego) * TR + v_ego*v_ego/(2*G) - v_l*v_l / (2*G)) #define NORM_RW_ERROR(v_ego, v_l, p) ((RW(v_ego, v_l) + 4.0 - p)/(sqrt(v_ego + 0.5) + 0.1)) int main( ) { USING_NAMESPACE_ACADO DifferentialEquation f; DifferentialState x_ego, v_ego, a_ego; OnlineData x_l, v_l; Control j_ego; auto desired = 4.0 + RW(v_ego, v_l); auto d_l = x_l - x_ego; // Equations of motion f << dot(x_ego) == v_ego; f << dot(v_ego) == a_ego; f << dot(a_ego) == j_ego; // Running cost Function h; h << exp(0.3 * NORM_RW_ERROR(v_ego, v_l, d_l)) - 1; h << (d_l - desired) / (0.05 * v_ego + 0.5); h << a_ego * (0.1 * v_ego + 1.0); h << j_ego * (0.1 * v_ego + 1.0); // Weights are defined in mpc. BMatrix Q(4,4); Q.setAll(true); // Terminal cost Function hN; hN << exp(0.3 * NORM_RW_ERROR(v_ego, v_l, d_l)) - 1; hN << (d_l - desired) / (0.05 * v_ego + 0.5); hN << a_ego * (0.1 * v_ego + 1.0); // Weights are defined in mpc. BMatrix QN(3,3); QN.setAll(true); // Non uniform time grid // First 5 timesteps are 0.2, after that it's 0.6 DMatrix numSteps(20, 1); for (int i = 0; i < 5; i++){ numSteps(i) = 1; } for (int i = 5; i < 20; i++){ numSteps(i) = 3; } // Setup Optimal Control Problem const double tStart = 0.0; const double tEnd = 10.0; OCP ocp( tStart, tEnd, numSteps); ocp.subjectTo(f); ocp.minimizeLSQ(Q, h); ocp.minimizeLSQEndTerm(QN, hN); ocp.subjectTo( -0.1 <= v_ego); ocp.setNOD(2); OCPexport mpc(ocp); mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON ); mpc.set( DISCRETIZATION_TYPE, MULTIPLE_SHOOTING ); mpc.set( INTEGRATOR_TYPE, INT_RK4 ); mpc.set( NUM_INTEGRATOR_STEPS, controlHorizon); mpc.set( MAX_NUM_QP_ITERATIONS, 50); mpc.set( CG_USE_VARIABLE_WEIGHTING_MATRIX, YES); mpc.set( SPARSE_QP_SOLUTION, CONDENSING ); mpc.set( QP_SOLVER, QP_QPOASES ); mpc.set( HOTSTART_QP, YES ); mpc.set( GENERATE_TEST_FILE, NO); mpc.set( GENERATE_MAKE_FILE, NO ); mpc.set( GENERATE_MATLAB_INTERFACE, NO ); mpc.set( GENERATE_SIMULINK_INTERFACE, NO ); if (mpc.exportCode( "lib_mpc_export" ) != SUCCESSFUL_RETURN) exit( EXIT_FAILURE ); mpc.printDimensionsQP( ); return EXIT_SUCCESS; } ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_auxiliary_functions.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_auxiliary_functions.h" #include real_t* acado_getVariablesX( ) { return acadoVariables.x; } real_t* acado_getVariablesU( ) { return acadoVariables.u; } #if ACADO_NY > 0 real_t* acado_getVariablesY( ) { return acadoVariables.y; } #endif #if ACADO_NYN > 0 real_t* acado_getVariablesYN( ) { return acadoVariables.yN; } #endif real_t* acado_getVariablesX0( ) { #if ACADO_INITIAL_VALUE_FIXED return acadoVariables.x0; #else return 0; #endif } /** Print differential variables. */ void acado_printDifferentialVariables( ) { int i, j; printf("\nDifferential variables:\n[\n"); for (i = 0; i < ACADO_N + 1; ++i) { for (j = 0; j < ACADO_NX; ++j) printf("\t%e", acadoVariables.x[i * ACADO_NX + j]); printf("\n"); } printf("]\n\n"); } /** Print control variables. */ void acado_printControlVariables( ) { int i, j; printf("\nControl variables:\n[\n"); for (i = 0; i < ACADO_N; ++i) { for (j = 0; j < ACADO_NU; ++j) printf("\t%e", acadoVariables.u[i * ACADO_NU + j]); printf("\n"); } printf("]\n\n"); } /** Print ACADO code generation notice. */ void acado_printHeader( ) { printf( "\nACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.\n" "Copyright (C) 2008-2015 by Boris Houska, Hans Joachim Ferreau,\n" "Milan Vukov and Rien Quirynen, KU Leuven.\n" ); printf( "Developed within the Optimization in Engineering Center (OPTEC) under\n" "supervision of Moritz Diehl. All rights reserved.\n\n" "ACADO Toolkit is distributed under the terms of the GNU Lesser\n" "General Public License 3 in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU Lesser General Public License for more details.\n\n" ); } #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) void acado_tic( acado_timer* t ) { QueryPerformanceFrequency(&t->freq); QueryPerformanceCounter(&t->tic); } real_t acado_toc( acado_timer* t ) { QueryPerformanceCounter(&t->toc); return ((t->toc.QuadPart - t->tic.QuadPart) / (real_t)t->freq.QuadPart); } #elif (defined __APPLE__) void acado_tic( acado_timer* t ) { /* read current clock cycles */ t->tic = mach_absolute_time(); } real_t acado_toc( acado_timer* t ) { uint64_t duration; /* elapsed time in clock cycles*/ t->toc = mach_absolute_time(); duration = t->toc - t->tic; /*conversion from clock cycles to nanoseconds*/ mach_timebase_info(&(t->tinfo)); duration *= t->tinfo.numer; duration /= t->tinfo.denom; return (real_t)duration / 1e9; } #else #if __STDC_VERSION__ >= 199901L /* C99 mode */ /* read current time */ void acado_tic( acado_timer* t ) { gettimeofday(&t->tic, 0); } /* return time passed since last call to tic on this timer */ real_t acado_toc( acado_timer* t ) { struct timeval temp; gettimeofday(&t->toc, 0); if ((t->toc.tv_usec - t->tic.tv_usec) < 0) { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; temp.tv_usec = 1000000 + t->toc.tv_usec - t->tic.tv_usec; } else { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; temp.tv_usec = t->toc.tv_usec - t->tic.tv_usec; } return (real_t)temp.tv_sec + (real_t)temp.tv_usec / 1e6; } #else /* ANSI */ /* read current time */ void acado_tic( acado_timer* t ) { clock_gettime(CLOCK_MONOTONIC, &t->tic); } /* return time passed since last call to tic on this timer */ real_t acado_toc( acado_timer* t ) { struct timespec temp; clock_gettime(CLOCK_MONOTONIC, &t->toc); if ((t->toc.tv_nsec - t->tic.tv_nsec) < 0) { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; temp.tv_nsec = 1000000000+t->toc.tv_nsec - t->tic.tv_nsec; } else { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; temp.tv_nsec = t->toc.tv_nsec - t->tic.tv_nsec; } return (real_t)temp.tv_sec + (real_t)temp.tv_nsec / 1e9; } #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || _WIN64) */ #endif ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_auxiliary_functions.h ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef ACADO_AUXILIARY_FUNCTIONS_H #define ACADO_AUXILIARY_FUNCTIONS_H #include "acado_common.h" #ifndef __MATLAB__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __MATLAB__ */ /** Get pointer to the matrix with differential variables. */ real_t* acado_getVariablesX( ); /** Get pointer to the matrix with control variables. */ real_t* acado_getVariablesU( ); #if ACADO_NY > 0 /** Get pointer to the matrix with references/measurements. */ real_t* acado_getVariablesY( ); #endif #if ACADO_NYN > 0 /** Get pointer to the vector with references/measurement on the last node. */ real_t* acado_getVariablesYN( ); #endif /** Get pointer to the current state feedback vector. Only applicable for NMPC. */ real_t* acado_getVariablesX0( ); /** Print differential variables. */ void acado_printDifferentialVariables( ); /** Print control variables. */ void acado_printControlVariables( ); /** Print ACADO code generation notice. */ void acado_printHeader( ); /* * A huge thanks goes to Alexander Domahidi from ETHZ, Switzerland, for * providing us with the following timing routines. */ #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) /* Use Windows QueryPerformanceCounter for timing. */ #include /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { LARGE_INTEGER tic; LARGE_INTEGER toc; LARGE_INTEGER freq; } acado_timer; #elif (defined __APPLE__) #include "unistd.h" #include /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { uint64_t tic; uint64_t toc; mach_timebase_info_data_t tinfo; } acado_timer; #else /* Use POSIX clock_gettime() for timing on non-Windows machines. */ #include #if __STDC_VERSION__ >= 199901L /* C99 mode of operation. */ #include #include typedef struct acado_timer_ { struct timeval tic; struct timeval toc; } acado_timer; #else /* ANSI C */ /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { struct timespec tic; struct timespec toc; } acado_timer; #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || defined _WIN64) */ /** A function for measurement of the current time. */ void acado_tic( acado_timer* t ); /** A function which returns the elapsed time. */ real_t acado_toc( acado_timer* t ); #endif #ifndef __MATLAB__ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* __MATLAB__ */ #endif /* ACADO_AUXILIARY_FUNCTIONS_H */ ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_common.h ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef ACADO_COMMON_H #define ACADO_COMMON_H #include #include #ifndef __MATLAB__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __MATLAB__ */ /** \defgroup ACADO ACADO CGT generated module. */ /** @{ */ /** qpOASES QP solver indicator. */ #define ACADO_QPOASES 0 #define ACADO_QPOASES3 1 /** FORCES QP solver indicator.*/ #define ACADO_FORCES 2 /** qpDUNES QP solver indicator.*/ #define ACADO_QPDUNES 3 /** HPMPC QP solver indicator. */ #define ACADO_HPMPC 4 #define ACADO_GENERIC 5 /** Indicator for determining the QP solver used by the ACADO solver code. */ #define ACADO_QP_SOLVER ACADO_QPOASES #include "acado_qpoases_interface.hpp" /* * Common definitions */ /** User defined block based condensing. */ #define ACADO_BLOCK_CONDENSING 0 /** Compute covariance matrix of the last state estimate. */ #define ACADO_COMPUTE_COVARIANCE_MATRIX 0 /** Flag indicating whether constraint values are hard-coded or not. */ #define ACADO_HARDCODED_CONSTRAINT_VALUES 1 /** Indicator for fixed initial state. */ #define ACADO_INITIAL_STATE_FIXED 1 /** Number of control/estimation intervals. */ #define ACADO_N 20 /** Number of online data values. */ #define ACADO_NOD 2 /** Number of path constraints. */ #define ACADO_NPAC 0 /** Number of control variables. */ #define ACADO_NU 1 /** Number of differential variables. */ #define ACADO_NX 3 /** Number of algebraic variables. */ #define ACADO_NXA 0 /** Number of differential derivative variables. */ #define ACADO_NXD 0 /** Number of references/measurements per node on the first N nodes. */ #define ACADO_NY 4 /** Number of references/measurements on the last (N + 1)st node. */ #define ACADO_NYN 3 /** Total number of QP optimization variables. */ #define ACADO_QP_NV 23 /** Number of Runge-Kutta stages per integration step. */ #define ACADO_RK_NSTAGES 4 /** Providing interface for arrival cost. */ #define ACADO_USE_ARRIVAL_COST 0 /** Indicator for usage of non-hard-coded linear terms in the objective. */ #define ACADO_USE_LINEAR_TERMS 0 /** Indicator for type of fixed weighting matrices. */ #define ACADO_WEIGHTING_MATRICES_TYPE 2 /* * Globally used structure definitions */ /** The structure containing the user data. * * Via this structure the user "communicates" with the solver code. */ typedef struct ACADOvariables_ { int dummy; /** Matrix of size: 21 x 3 (row major format) * * Matrix containing 21 differential variable vectors. */ real_t x[ 63 ]; /** Column vector of size: 20 * * Matrix containing 20 control variable vectors. */ real_t u[ 20 ]; /** Matrix of size: 21 x 2 (row major format) * * Matrix containing 21 online data vectors. */ real_t od[ 42 ]; /** Column vector of size: 80 * * Matrix containing 20 reference/measurement vectors of size 4 for first 20 nodes. */ real_t y[ 80 ]; /** Column vector of size: 3 * * Reference/measurement vector for the 21. node. */ real_t yN[ 3 ]; /** Matrix of size: 80 x 4 (row major format) */ real_t W[ 320 ]; /** Matrix of size: 3 x 3 (row major format) */ real_t WN[ 9 ]; /** Column vector of size: 3 * * Current state feedback vector. */ real_t x0[ 3 ]; } ACADOvariables; /** Private workspace used by the auto-generated code. * * Data members of this structure are private to the solver. * In other words, the user code should not modify values of this * structure. */ typedef struct ACADOworkspace_ { real_t rk_ttt; /** Row vector of size: 18 */ real_t rk_xxx[ 18 ]; /** Matrix of size: 4 x 15 (row major format) */ real_t rk_kkk[ 60 ]; /** Row vector of size: 18 */ real_t state[ 18 ]; /** Column vector of size: 60 */ real_t d[ 60 ]; /** Column vector of size: 80 */ real_t Dy[ 80 ]; /** Column vector of size: 3 */ real_t DyN[ 3 ]; /** Matrix of size: 60 x 3 (row major format) */ real_t evGx[ 180 ]; /** Column vector of size: 60 */ real_t evGu[ 60 ]; /** Column vector of size: 13 */ real_t objAuxVar[ 13 ]; /** Row vector of size: 6 */ real_t objValueIn[ 6 ]; /** Row vector of size: 20 */ real_t objValueOut[ 20 ]; /** Matrix of size: 60 x 3 (row major format) */ real_t Q1[ 180 ]; /** Matrix of size: 60 x 4 (row major format) */ real_t Q2[ 240 ]; /** Column vector of size: 20 */ real_t R1[ 20 ]; /** Matrix of size: 20 x 4 (row major format) */ real_t R2[ 80 ]; /** Column vector of size: 60 */ real_t S1[ 60 ]; /** Matrix of size: 3 x 3 (row major format) */ real_t QN1[ 9 ]; /** Matrix of size: 3 x 3 (row major format) */ real_t QN2[ 9 ]; /** Column vector of size: 3 */ real_t Dx0[ 3 ]; /** Matrix of size: 3 x 3 (row major format) */ real_t T[ 9 ]; /** Column vector of size: 630 */ real_t E[ 630 ]; /** Column vector of size: 630 */ real_t QE[ 630 ]; /** Matrix of size: 60 x 3 (row major format) */ real_t QGx[ 180 ]; /** Column vector of size: 60 */ real_t Qd[ 60 ]; /** Column vector of size: 63 */ real_t QDy[ 63 ]; /** Matrix of size: 20 x 3 (row major format) */ real_t H10[ 60 ]; /** Matrix of size: 23 x 23 (row major format) */ real_t H[ 529 ]; /** Matrix of size: 20 x 23 (row major format) */ real_t A[ 460 ]; /** Column vector of size: 23 */ real_t g[ 23 ]; /** Column vector of size: 23 */ real_t lb[ 23 ]; /** Column vector of size: 23 */ real_t ub[ 23 ]; /** Column vector of size: 20 */ real_t lbA[ 20 ]; /** Column vector of size: 20 */ real_t ubA[ 20 ]; /** Column vector of size: 23 */ real_t x[ 23 ]; /** Column vector of size: 43 */ real_t y[ 43 ]; } ACADOworkspace; /* * Forward function declarations. */ /** Performs the integration and sensitivity propagation for one shooting interval. * * \param rk_eta Working array to pass the input values and return the results. * \param resetIntegrator The internal memory of the integrator can be reset. * \param rk_index Number of the shooting interval. * * \return Status code of the integrator. */ int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ); /** Export of an ACADO symbolic function. * * \param in Input to the exported function. * \param out Output of the exported function. */ void acado_rhs_forw(const real_t* in, real_t* out); /** Preparation step of the RTI scheme. * * \return Status of the integration module. =0: OK, otherwise the error code. */ int acado_preparationStep( ); /** Feedback/estimation step of the RTI scheme. * * \return Status code of the qpOASES QP solver. */ int acado_feedbackStep( ); /** Solver initialization. Must be called once before any other function call. * * \return =0: OK, otherwise an error code of a QP solver. */ int acado_initializeSolver( ); /** Initialize shooting nodes by a forward simulation starting from the first node. */ void acado_initializeNodesByForwardSimulation( ); /** Shift differential variables vector by one interval. * * \param strategy Shifting strategy: 1. Initialize node 21 with xEnd. 2. Initialize node 21 by forward simulation. * \param xEnd Value for the x vector on the last node. If =0 the old value is used. * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. */ void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ); /** Shift controls vector by one interval. * * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. */ void acado_shiftControls( real_t* const uEnd ); /** Get the KKT tolerance of the current iterate. * * \return The KKT tolerance value. */ real_t acado_getKKT( ); /** Calculate the objective value. * * \return Value of the objective function. */ real_t acado_getObjective( ); /* * Extern declarations. */ extern ACADOworkspace acadoWorkspace; extern ACADOvariables acadoVariables; /** @} */ #ifndef __MATLAB__ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* __MATLAB__ */ #endif /* ACADO_COMMON_H */ ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_integrator.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_common.h" void acado_rhs_forw(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* u = in + 15; /* Compute outputs: */ out[0] = xd[1]; out[1] = xd[2]; out[2] = u[0]; out[3] = xd[6]; out[4] = xd[7]; out[5] = xd[8]; out[6] = xd[9]; out[7] = xd[10]; out[8] = xd[11]; out[9] = (real_t)(0.0000000000000000e+00); out[10] = (real_t)(0.0000000000000000e+00); out[11] = (real_t)(0.0000000000000000e+00); out[12] = xd[13]; out[13] = xd[14]; out[14] = (real_t)(1.0000000000000000e+00); } /* Fixed step size:0.2 */ int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ) { int error; int run1; int numSteps[20] = {1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; int numInts = numSteps[rk_index]; acadoWorkspace.rk_ttt = 0.0000000000000000e+00; rk_eta[3] = 1.0000000000000000e+00; rk_eta[4] = 0.0000000000000000e+00; rk_eta[5] = 0.0000000000000000e+00; rk_eta[6] = 0.0000000000000000e+00; rk_eta[7] = 1.0000000000000000e+00; rk_eta[8] = 0.0000000000000000e+00; rk_eta[9] = 0.0000000000000000e+00; rk_eta[10] = 0.0000000000000000e+00; rk_eta[11] = 1.0000000000000000e+00; rk_eta[12] = 0.0000000000000000e+00; rk_eta[13] = 0.0000000000000000e+00; rk_eta[14] = 0.0000000000000000e+00; acadoWorkspace.rk_xxx[15] = rk_eta[15]; acadoWorkspace.rk_xxx[16] = rk_eta[16]; acadoWorkspace.rk_xxx[17] = rk_eta[17]; for (run1 = 0; run1 < 1; ++run1) { for(run1 = 0; run1 < numInts; run1++ ) { acadoWorkspace.rk_xxx[0] = + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + rk_eta[14]; acado_rhs_forw( acadoWorkspace.rk_xxx, acadoWorkspace.rk_kkk ); acadoWorkspace.rk_xxx[0] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[0] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[1] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[2] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[3] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[4] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[5] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[6] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[7] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[8] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[9] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[10] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[11] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[12] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[13] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[14] + rk_eta[14]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 15 ]) ); acadoWorkspace.rk_xxx[0] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[15] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[16] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[17] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[18] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[19] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[20] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[21] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[22] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[23] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[24] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[25] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[26] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[27] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[28] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)9.9999999999999964e-02*acadoWorkspace.rk_kkk[29] + rk_eta[14]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 30 ]) ); acadoWorkspace.rk_xxx[0] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[30] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[31] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[32] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[33] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[34] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[35] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[36] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[37] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[38] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[39] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[40] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[41] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[42] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[43] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)1.9999999999999993e-01*acadoWorkspace.rk_kkk[44] + rk_eta[14]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 45 ]) ); rk_eta[0] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[0] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[15] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[30] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[45]; rk_eta[1] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[1] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[16] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[31] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[46]; rk_eta[2] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[2] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[17] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[32] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[47]; rk_eta[3] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[3] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[18] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[33] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[48]; rk_eta[4] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[4] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[19] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[34] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[49]; rk_eta[5] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[5] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[20] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[35] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[50]; rk_eta[6] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[6] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[21] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[36] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[51]; rk_eta[7] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[7] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[22] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[37] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[52]; rk_eta[8] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[8] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[23] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[38] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[53]; rk_eta[9] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[9] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[24] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[39] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[54]; rk_eta[10] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[10] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[25] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[40] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[55]; rk_eta[11] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[11] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[26] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[41] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[56]; rk_eta[12] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[12] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[27] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[42] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[57]; rk_eta[13] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[13] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[28] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[43] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[58]; rk_eta[14] += + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[14] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[29] + (real_t)6.6666666666666638e-02*acadoWorkspace.rk_kkk[44] + (real_t)3.3333333333333319e-02*acadoWorkspace.rk_kkk[59]; acadoWorkspace.rk_ttt += 1.0000000000000000e+00; } } error = 0; return error; } ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_qpoases_interface.cpp ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ extern "C" { #include "acado_common.h" } #include "INCLUDE/QProblem.hpp" #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 #include "INCLUDE/EXTRAS/SolutionAnalysis.hpp" #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ static int acado_nWSR; #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 static SolutionAnalysis acado_sa; #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ int acado_solve( void ) { acado_nWSR = QPOASES_NWSRMAX; QProblem qp(23, 20); returnValue retVal = qp.init(acadoWorkspace.H, acadoWorkspace.g, acadoWorkspace.A, acadoWorkspace.lb, acadoWorkspace.ub, acadoWorkspace.lbA, acadoWorkspace.ubA, acado_nWSR, acadoWorkspace.y); qp.getPrimalSolution( acadoWorkspace.x ); qp.getDualSolution( acadoWorkspace.y ); #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 if (retVal != SUCCESSFUL_RETURN) return (int)retVal; retVal = acado_sa.getHessianInverse( &qp,var ); #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ return (int)retVal; } int acado_getNWSR( void ) { return acado_nWSR; } const char* acado_getErrorString( int error ) { return MessageHandling::getErrorString( error ); } ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_qpoases_interface.hpp ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef QPOASES_HEADER #define QPOASES_HEADER #ifdef PC_DEBUG #include #endif /* PC_DEBUG */ #include #ifdef __cplusplus #define EXTERNC extern "C" #else #define EXTERNC #endif /* * A set of options for qpOASES */ /** Maximum number of optimization variables. */ #define QPOASES_NVMAX 23 /** Maximum number of constraints. */ #define QPOASES_NCMAX 20 /** Maximum number of working set recalculations. */ #define QPOASES_NWSRMAX 50 /** Print level for qpOASES. */ #define QPOASES_PRINTLEVEL PL_NONE /** The value of EPS */ #define QPOASES_EPS 2.221e-16 /** Internally used floating point type */ typedef double real_t; /* * Forward function declarations */ /** A function that calls the QP solver */ EXTERNC int acado_solve( void ); /** Get the number of active set changes */ EXTERNC int acado_getNWSR( void ); /** Get the error string. */ const char* acado_getErrorString( int error ); #endif /* QPOASES_HEADER */ ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/lib_mpc_export/acado_solver.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_common.h" /******************************************************************************/ /* */ /* ACADO code generation */ /* */ /******************************************************************************/ int acado_modelSimulation( ) { int ret; int lRun1; ret = 0; for (lRun1 = 0; lRun1 < 20; ++lRun1) { acadoWorkspace.state[0] = acadoVariables.x[lRun1 * 3]; acadoWorkspace.state[1] = acadoVariables.x[lRun1 * 3 + 1]; acadoWorkspace.state[2] = acadoVariables.x[lRun1 * 3 + 2]; acadoWorkspace.state[15] = acadoVariables.u[lRun1]; acadoWorkspace.state[16] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.state[17] = acadoVariables.od[lRun1 * 2 + 1]; ret = acado_integrate(acadoWorkspace.state, 1, lRun1); acadoWorkspace.d[lRun1 * 3] = acadoWorkspace.state[0] - acadoVariables.x[lRun1 * 3 + 3]; acadoWorkspace.d[lRun1 * 3 + 1] = acadoWorkspace.state[1] - acadoVariables.x[lRun1 * 3 + 4]; acadoWorkspace.d[lRun1 * 3 + 2] = acadoWorkspace.state[2] - acadoVariables.x[lRun1 * 3 + 5]; acadoWorkspace.evGx[lRun1 * 9] = acadoWorkspace.state[3]; acadoWorkspace.evGx[lRun1 * 9 + 1] = acadoWorkspace.state[4]; acadoWorkspace.evGx[lRun1 * 9 + 2] = acadoWorkspace.state[5]; acadoWorkspace.evGx[lRun1 * 9 + 3] = acadoWorkspace.state[6]; acadoWorkspace.evGx[lRun1 * 9 + 4] = acadoWorkspace.state[7]; acadoWorkspace.evGx[lRun1 * 9 + 5] = acadoWorkspace.state[8]; acadoWorkspace.evGx[lRun1 * 9 + 6] = acadoWorkspace.state[9]; acadoWorkspace.evGx[lRun1 * 9 + 7] = acadoWorkspace.state[10]; acadoWorkspace.evGx[lRun1 * 9 + 8] = acadoWorkspace.state[11]; acadoWorkspace.evGu[lRun1 * 3] = acadoWorkspace.state[12]; acadoWorkspace.evGu[lRun1 * 3 + 1] = acadoWorkspace.state[13]; acadoWorkspace.evGu[lRun1 * 3 + 2] = acadoWorkspace.state[14]; } return ret; } void acado_evaluateLSQ(const real_t* in, real_t* out, double TR) { const real_t* xd = in; const real_t* u = in + 3; const real_t* od = in + 4; /* Vector of auxiliary variables; number of elements: 13. */ real_t* a = acadoWorkspace.objAuxVar; /* Compute intermediate quantities: */ a[0] = (sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); a[1] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); a[2] = ((real_t)(1.0000000000000000e+00)/(a[0]+(real_t)(1.0000000000000001e-01))); a[3] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); a[4] = (((real_t)(2.9999999999999999e-01)*(((real_t)(0.0000000000000000e+00)-((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)))*a[2]))*a[3]); a[5] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); a[6] = (1.0/sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); a[7] = (a[6]*(real_t)(5.0000000000000000e-01)); a[8] = (a[2]*a[2]); a[9] = (((real_t)(2.9999999999999999e-01)*(((((real_t)(TR)-((real_t)(-TR)))+((xd[1]+xd[1])*a[5]))*a[2])-((((((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))*a[7])*a[8])))*a[3]); a[10] = ((real_t)(1.0000000000000000e+00)/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); a[11] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); a[12] = (a[10]*a[10]); /* Compute outputs: */ out[0] = (a[1]-(real_t)(1.0000000000000000e+00)); out[1] = (((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); out[2] = (xd[2]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); out[3] = (u[0]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); out[4] = a[4]; out[5] = a[9]; out[6] = (real_t)(0.0000000000000000e+00); out[7] = (((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))*a[10]); out[8] = ((((real_t)(0.0000000000000000e+00)-(((real_t)(TR)-((real_t)(-TR)))+((xd[1]+xd[1])*a[11])))*a[10])-((((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))*(real_t)(5.0000000000000003e-02))*a[12])); out[9] = (real_t)(0.0000000000000000e+00); out[10] = (real_t)(0.0000000000000000e+00); out[11] = (xd[2]*(real_t)(1.0000000000000001e-01)); out[12] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); out[13] = (real_t)(0.0000000000000000e+00); out[14] = (u[0]*(real_t)(1.0000000000000001e-01)); out[15] = (real_t)(0.0000000000000000e+00); out[16] = (real_t)(0.0000000000000000e+00); out[17] = (real_t)(0.0000000000000000e+00); out[18] = (real_t)(0.0000000000000000e+00); out[19] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); } void acado_evaluateLSQEndTerm(const real_t* in, real_t* out, double TR) { const real_t* xd = in; const real_t* od = in + 3; /* Vector of auxiliary variables; number of elements: 13. */ real_t* a = acadoWorkspace.objAuxVar; /* Compute intermediate quantities: */ a[0] = (sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); a[1] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); a[2] = ((real_t)(1.0000000000000000e+00)/(a[0]+(real_t)(1.0000000000000001e-01))); a[3] = (exp(((real_t)(2.9999999999999999e-01)*(((((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))/(a[0]+(real_t)(1.0000000000000001e-01)))))); a[4] = (((real_t)(2.9999999999999999e-01)*(((real_t)(0.0000000000000000e+00)-((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00)))*a[2]))*a[3]); a[5] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); a[6] = (1.0/sqrt((xd[1]+(real_t)(5.0000000000000000e-01)))); a[7] = (a[6]*(real_t)(5.0000000000000000e-01)); a[8] = (a[2]*a[2]); a[9] = (((real_t)(2.9999999999999999e-01)*(((((real_t)(TR)-((real_t)(-TR)))+((xd[1]+xd[1])*a[5]))*a[2])-((((((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))+(real_t)(4.0000000000000000e+00))-(od[0]-xd[0]))*a[7])*a[8])))*a[3]); a[10] = ((real_t)(1.0000000000000000e+00)/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); a[11] = ((real_t)(1.0000000000000000e+00)/(real_t)(1.9620000000000001e+01)); a[12] = (a[10]*a[10]); /* Compute outputs: */ out[0] = (a[1]-(real_t)(1.0000000000000000e+00)); out[1] = (((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))/(((real_t)(5.0000000000000003e-02)*xd[1])+(real_t)(5.0000000000000000e-01))); out[2] = (xd[2]*(((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00))); out[3] = a[4]; out[4] = a[9]; out[5] = (real_t)(0.0000000000000000e+00); out[6] = (((real_t)(0.0000000000000000e+00)-(real_t)(1.0000000000000000e+00))*a[10]); out[7] = ((((real_t)(0.0000000000000000e+00)-(((real_t)(TR)-((real_t)(-TR)))+((xd[1]+xd[1])*a[11])))*a[10])-((((od[0]-xd[0])-((real_t)(4.0000000000000000e+00)+((((xd[1]*(real_t)(TR))-((od[1]-xd[1])*(real_t)(TR)))+((xd[1]*xd[1])/(real_t)(1.9620000000000001e+01)))-((od[1]*od[1])/(real_t)(1.9620000000000001e+01)))))*(real_t)(5.0000000000000003e-02))*a[12])); out[8] = (real_t)(0.0000000000000000e+00); out[9] = (real_t)(0.0000000000000000e+00); out[10] = (xd[2]*(real_t)(1.0000000000000001e-01)); out[11] = (((real_t)(1.0000000000000001e-01)*xd[1])+(real_t)(1.0000000000000000e+00)); } void acado_setObjQ1Q2( real_t* const tmpFx, real_t* const tmpObjS, real_t* const tmpQ1, real_t* const tmpQ2 ) { tmpQ2[0] = + tmpFx[0]*tmpObjS[0] + tmpFx[3]*tmpObjS[4] + tmpFx[6]*tmpObjS[8] + tmpFx[9]*tmpObjS[12]; tmpQ2[1] = + tmpFx[0]*tmpObjS[1] + tmpFx[3]*tmpObjS[5] + tmpFx[6]*tmpObjS[9] + tmpFx[9]*tmpObjS[13]; tmpQ2[2] = + tmpFx[0]*tmpObjS[2] + tmpFx[3]*tmpObjS[6] + tmpFx[6]*tmpObjS[10] + tmpFx[9]*tmpObjS[14]; tmpQ2[3] = + tmpFx[0]*tmpObjS[3] + tmpFx[3]*tmpObjS[7] + tmpFx[6]*tmpObjS[11] + tmpFx[9]*tmpObjS[15]; tmpQ2[4] = + tmpFx[1]*tmpObjS[0] + tmpFx[4]*tmpObjS[4] + tmpFx[7]*tmpObjS[8] + tmpFx[10]*tmpObjS[12]; tmpQ2[5] = + tmpFx[1]*tmpObjS[1] + tmpFx[4]*tmpObjS[5] + tmpFx[7]*tmpObjS[9] + tmpFx[10]*tmpObjS[13]; tmpQ2[6] = + tmpFx[1]*tmpObjS[2] + tmpFx[4]*tmpObjS[6] + tmpFx[7]*tmpObjS[10] + tmpFx[10]*tmpObjS[14]; tmpQ2[7] = + tmpFx[1]*tmpObjS[3] + tmpFx[4]*tmpObjS[7] + tmpFx[7]*tmpObjS[11] + tmpFx[10]*tmpObjS[15]; tmpQ2[8] = + tmpFx[2]*tmpObjS[0] + tmpFx[5]*tmpObjS[4] + tmpFx[8]*tmpObjS[8] + tmpFx[11]*tmpObjS[12]; tmpQ2[9] = + tmpFx[2]*tmpObjS[1] + tmpFx[5]*tmpObjS[5] + tmpFx[8]*tmpObjS[9] + tmpFx[11]*tmpObjS[13]; tmpQ2[10] = + tmpFx[2]*tmpObjS[2] + tmpFx[5]*tmpObjS[6] + tmpFx[8]*tmpObjS[10] + tmpFx[11]*tmpObjS[14]; tmpQ2[11] = + tmpFx[2]*tmpObjS[3] + tmpFx[5]*tmpObjS[7] + tmpFx[8]*tmpObjS[11] + tmpFx[11]*tmpObjS[15]; tmpQ1[0] = + tmpQ2[0]*tmpFx[0] + tmpQ2[1]*tmpFx[3] + tmpQ2[2]*tmpFx[6] + tmpQ2[3]*tmpFx[9]; tmpQ1[1] = + tmpQ2[0]*tmpFx[1] + tmpQ2[1]*tmpFx[4] + tmpQ2[2]*tmpFx[7] + tmpQ2[3]*tmpFx[10]; tmpQ1[2] = + tmpQ2[0]*tmpFx[2] + tmpQ2[1]*tmpFx[5] + tmpQ2[2]*tmpFx[8] + tmpQ2[3]*tmpFx[11]; tmpQ1[3] = + tmpQ2[4]*tmpFx[0] + tmpQ2[5]*tmpFx[3] + tmpQ2[6]*tmpFx[6] + tmpQ2[7]*tmpFx[9]; tmpQ1[4] = + tmpQ2[4]*tmpFx[1] + tmpQ2[5]*tmpFx[4] + tmpQ2[6]*tmpFx[7] + tmpQ2[7]*tmpFx[10]; tmpQ1[5] = + tmpQ2[4]*tmpFx[2] + tmpQ2[5]*tmpFx[5] + tmpQ2[6]*tmpFx[8] + tmpQ2[7]*tmpFx[11]; tmpQ1[6] = + tmpQ2[8]*tmpFx[0] + tmpQ2[9]*tmpFx[3] + tmpQ2[10]*tmpFx[6] + tmpQ2[11]*tmpFx[9]; tmpQ1[7] = + tmpQ2[8]*tmpFx[1] + tmpQ2[9]*tmpFx[4] + tmpQ2[10]*tmpFx[7] + tmpQ2[11]*tmpFx[10]; tmpQ1[8] = + tmpQ2[8]*tmpFx[2] + tmpQ2[9]*tmpFx[5] + tmpQ2[10]*tmpFx[8] + tmpQ2[11]*tmpFx[11]; } void acado_setObjR1R2( real_t* const tmpFu, real_t* const tmpObjS, real_t* const tmpR1, real_t* const tmpR2 ) { tmpR2[0] = + tmpFu[0]*tmpObjS[0] + tmpFu[1]*tmpObjS[4] + tmpFu[2]*tmpObjS[8] + tmpFu[3]*tmpObjS[12]; tmpR2[1] = + tmpFu[0]*tmpObjS[1] + tmpFu[1]*tmpObjS[5] + tmpFu[2]*tmpObjS[9] + tmpFu[3]*tmpObjS[13]; tmpR2[2] = + tmpFu[0]*tmpObjS[2] + tmpFu[1]*tmpObjS[6] + tmpFu[2]*tmpObjS[10] + tmpFu[3]*tmpObjS[14]; tmpR2[3] = + tmpFu[0]*tmpObjS[3] + tmpFu[1]*tmpObjS[7] + tmpFu[2]*tmpObjS[11] + tmpFu[3]*tmpObjS[15]; tmpR1[0] = + tmpR2[0]*tmpFu[0] + tmpR2[1]*tmpFu[1] + tmpR2[2]*tmpFu[2] + tmpR2[3]*tmpFu[3]; } void acado_setObjQN1QN2( real_t* const tmpFx, real_t* const tmpObjSEndTerm, real_t* const tmpQN1, real_t* const tmpQN2 ) { tmpQN2[0] = + tmpFx[0]*tmpObjSEndTerm[0] + tmpFx[3]*tmpObjSEndTerm[3] + tmpFx[6]*tmpObjSEndTerm[6]; tmpQN2[1] = + tmpFx[0]*tmpObjSEndTerm[1] + tmpFx[3]*tmpObjSEndTerm[4] + tmpFx[6]*tmpObjSEndTerm[7]; tmpQN2[2] = + tmpFx[0]*tmpObjSEndTerm[2] + tmpFx[3]*tmpObjSEndTerm[5] + tmpFx[6]*tmpObjSEndTerm[8]; tmpQN2[3] = + tmpFx[1]*tmpObjSEndTerm[0] + tmpFx[4]*tmpObjSEndTerm[3] + tmpFx[7]*tmpObjSEndTerm[6]; tmpQN2[4] = + tmpFx[1]*tmpObjSEndTerm[1] + tmpFx[4]*tmpObjSEndTerm[4] + tmpFx[7]*tmpObjSEndTerm[7]; tmpQN2[5] = + tmpFx[1]*tmpObjSEndTerm[2] + tmpFx[4]*tmpObjSEndTerm[5] + tmpFx[7]*tmpObjSEndTerm[8]; tmpQN2[6] = + tmpFx[2]*tmpObjSEndTerm[0] + tmpFx[5]*tmpObjSEndTerm[3] + tmpFx[8]*tmpObjSEndTerm[6]; tmpQN2[7] = + tmpFx[2]*tmpObjSEndTerm[1] + tmpFx[5]*tmpObjSEndTerm[4] + tmpFx[8]*tmpObjSEndTerm[7]; tmpQN2[8] = + tmpFx[2]*tmpObjSEndTerm[2] + tmpFx[5]*tmpObjSEndTerm[5] + tmpFx[8]*tmpObjSEndTerm[8]; tmpQN1[0] = + tmpQN2[0]*tmpFx[0] + tmpQN2[1]*tmpFx[3] + tmpQN2[2]*tmpFx[6]; tmpQN1[1] = + tmpQN2[0]*tmpFx[1] + tmpQN2[1]*tmpFx[4] + tmpQN2[2]*tmpFx[7]; tmpQN1[2] = + tmpQN2[0]*tmpFx[2] + tmpQN2[1]*tmpFx[5] + tmpQN2[2]*tmpFx[8]; tmpQN1[3] = + tmpQN2[3]*tmpFx[0] + tmpQN2[4]*tmpFx[3] + tmpQN2[5]*tmpFx[6]; tmpQN1[4] = + tmpQN2[3]*tmpFx[1] + tmpQN2[4]*tmpFx[4] + tmpQN2[5]*tmpFx[7]; tmpQN1[5] = + tmpQN2[3]*tmpFx[2] + tmpQN2[4]*tmpFx[5] + tmpQN2[5]*tmpFx[8]; tmpQN1[6] = + tmpQN2[6]*tmpFx[0] + tmpQN2[7]*tmpFx[3] + tmpQN2[8]*tmpFx[6]; tmpQN1[7] = + tmpQN2[6]*tmpFx[1] + tmpQN2[7]*tmpFx[4] + tmpQN2[8]*tmpFx[7]; tmpQN1[8] = + tmpQN2[6]*tmpFx[2] + tmpQN2[7]*tmpFx[5] + tmpQN2[8]*tmpFx[8]; } void acado_evaluateObjective( double TR ) { int runObj; for (runObj = 0; runObj < 20; ++runObj) { acadoWorkspace.objValueIn[0] = acadoVariables.x[runObj * 3]; acadoWorkspace.objValueIn[1] = acadoVariables.x[runObj * 3 + 1]; acadoWorkspace.objValueIn[2] = acadoVariables.x[runObj * 3 + 2]; acadoWorkspace.objValueIn[3] = acadoVariables.u[runObj]; acadoWorkspace.objValueIn[4] = acadoVariables.od[runObj * 2]; acadoWorkspace.objValueIn[5] = acadoVariables.od[runObj * 2 + 1]; acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut, TR ); acadoWorkspace.Dy[runObj * 4] = acadoWorkspace.objValueOut[0]; acadoWorkspace.Dy[runObj * 4 + 1] = acadoWorkspace.objValueOut[1]; acadoWorkspace.Dy[runObj * 4 + 2] = acadoWorkspace.objValueOut[2]; acadoWorkspace.Dy[runObj * 4 + 3] = acadoWorkspace.objValueOut[3]; acado_setObjQ1Q2( &(acadoWorkspace.objValueOut[ 4 ]), &(acadoVariables.W[ runObj * 16 ]), &(acadoWorkspace.Q1[ runObj * 9 ]), &(acadoWorkspace.Q2[ runObj * 12 ]) ); acado_setObjR1R2( &(acadoWorkspace.objValueOut[ 16 ]), &(acadoVariables.W[ runObj * 16 ]), &(acadoWorkspace.R1[ runObj ]), &(acadoWorkspace.R2[ runObj * 4 ]) ); } acadoWorkspace.objValueIn[0] = acadoVariables.x[60]; acadoWorkspace.objValueIn[1] = acadoVariables.x[61]; acadoWorkspace.objValueIn[2] = acadoVariables.x[62]; acadoWorkspace.objValueIn[3] = acadoVariables.od[40]; acadoWorkspace.objValueIn[4] = acadoVariables.od[41]; acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut, TR ); acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0]; acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1]; acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2]; acado_setObjQN1QN2( &(acadoWorkspace.objValueOut[ 3 ]), acadoVariables.WN, acadoWorkspace.QN1, acadoWorkspace.QN2 ); } void acado_multGxd( real_t* const dOld, real_t* const Gx1, real_t* const dNew ) { dNew[0] += + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2]; dNew[1] += + Gx1[3]*dOld[0] + Gx1[4]*dOld[1] + Gx1[5]*dOld[2]; dNew[2] += + Gx1[6]*dOld[0] + Gx1[7]*dOld[1] + Gx1[8]*dOld[2]; } void acado_moveGxT( real_t* const Gx1, real_t* const Gx2 ) { Gx2[0] = Gx1[0]; Gx2[1] = Gx1[1]; Gx2[2] = Gx1[2]; Gx2[3] = Gx1[3]; Gx2[4] = Gx1[4]; Gx2[5] = Gx1[5]; Gx2[6] = Gx1[6]; Gx2[7] = Gx1[7]; Gx2[8] = Gx1[8]; } void acado_multGxGx( real_t* const Gx1, real_t* const Gx2, real_t* const Gx3 ) { Gx3[0] = + Gx1[0]*Gx2[0] + Gx1[1]*Gx2[3] + Gx1[2]*Gx2[6]; Gx3[1] = + Gx1[0]*Gx2[1] + Gx1[1]*Gx2[4] + Gx1[2]*Gx2[7]; Gx3[2] = + Gx1[0]*Gx2[2] + Gx1[1]*Gx2[5] + Gx1[2]*Gx2[8]; Gx3[3] = + Gx1[3]*Gx2[0] + Gx1[4]*Gx2[3] + Gx1[5]*Gx2[6]; Gx3[4] = + Gx1[3]*Gx2[1] + Gx1[4]*Gx2[4] + Gx1[5]*Gx2[7]; Gx3[5] = + Gx1[3]*Gx2[2] + Gx1[4]*Gx2[5] + Gx1[5]*Gx2[8]; Gx3[6] = + Gx1[6]*Gx2[0] + Gx1[7]*Gx2[3] + Gx1[8]*Gx2[6]; Gx3[7] = + Gx1[6]*Gx2[1] + Gx1[7]*Gx2[4] + Gx1[8]*Gx2[7]; Gx3[8] = + Gx1[6]*Gx2[2] + Gx1[7]*Gx2[5] + Gx1[8]*Gx2[8]; } void acado_multGxGu( real_t* const Gx1, real_t* const Gu1, real_t* const Gu2 ) { Gu2[0] = + Gx1[0]*Gu1[0] + Gx1[1]*Gu1[1] + Gx1[2]*Gu1[2]; Gu2[1] = + Gx1[3]*Gu1[0] + Gx1[4]*Gu1[1] + Gx1[5]*Gu1[2]; Gu2[2] = + Gx1[6]*Gu1[0] + Gx1[7]*Gu1[1] + Gx1[8]*Gu1[2]; } void acado_moveGuE( real_t* const Gu1, real_t* const Gu2 ) { Gu2[0] = Gu1[0]; Gu2[1] = Gu1[1]; Gu2[2] = Gu1[2]; } void acado_setBlockH11( int iRow, int iCol, real_t* const Gu1, real_t* const Gu2 ) { acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] += + Gu1[0]*Gu2[0] + Gu1[1]*Gu2[1] + Gu1[2]*Gu2[2]; } void acado_setBlockH11_R1( int iRow, int iCol, real_t* const R11 ) { acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] = R11[0]; } void acado_zeroBlockH11( int iRow, int iCol ) { acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] = 0.0000000000000000e+00; } void acado_copyHTH( int iRow, int iCol ) { acadoWorkspace.H[(iRow * 23 + 69) + (iCol + 3)] = acadoWorkspace.H[(iCol * 23 + 69) + (iRow + 3)]; } void acado_multQ1d( real_t* const Gx1, real_t* const dOld, real_t* const dNew ) { dNew[0] = + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2]; dNew[1] = + Gx1[3]*dOld[0] + Gx1[4]*dOld[1] + Gx1[5]*dOld[2]; dNew[2] = + Gx1[6]*dOld[0] + Gx1[7]*dOld[1] + Gx1[8]*dOld[2]; } void acado_multQN1d( real_t* const QN1, real_t* const dOld, real_t* const dNew ) { dNew[0] = + acadoWorkspace.QN1[0]*dOld[0] + acadoWorkspace.QN1[1]*dOld[1] + acadoWorkspace.QN1[2]*dOld[2]; dNew[1] = + acadoWorkspace.QN1[3]*dOld[0] + acadoWorkspace.QN1[4]*dOld[1] + acadoWorkspace.QN1[5]*dOld[2]; dNew[2] = + acadoWorkspace.QN1[6]*dOld[0] + acadoWorkspace.QN1[7]*dOld[1] + acadoWorkspace.QN1[8]*dOld[2]; } void acado_multRDy( real_t* const R2, real_t* const Dy1, real_t* const RDy1 ) { RDy1[0] = + R2[0]*Dy1[0] + R2[1]*Dy1[1] + R2[2]*Dy1[2] + R2[3]*Dy1[3]; } void acado_multQDy( real_t* const Q2, real_t* const Dy1, real_t* const QDy1 ) { QDy1[0] = + Q2[0]*Dy1[0] + Q2[1]*Dy1[1] + Q2[2]*Dy1[2] + Q2[3]*Dy1[3]; QDy1[1] = + Q2[4]*Dy1[0] + Q2[5]*Dy1[1] + Q2[6]*Dy1[2] + Q2[7]*Dy1[3]; QDy1[2] = + Q2[8]*Dy1[0] + Q2[9]*Dy1[1] + Q2[10]*Dy1[2] + Q2[11]*Dy1[3]; } void acado_multEQDy( real_t* const E1, real_t* const QDy1, real_t* const U1 ) { U1[0] += + E1[0]*QDy1[0] + E1[1]*QDy1[1] + E1[2]*QDy1[2]; } void acado_multQETGx( real_t* const E1, real_t* const Gx1, real_t* const H101 ) { H101[0] += + E1[0]*Gx1[0] + E1[1]*Gx1[3] + E1[2]*Gx1[6]; H101[1] += + E1[0]*Gx1[1] + E1[1]*Gx1[4] + E1[2]*Gx1[7]; H101[2] += + E1[0]*Gx1[2] + E1[1]*Gx1[5] + E1[2]*Gx1[8]; } void acado_zeroBlockH10( real_t* const H101 ) { { int lCopy; for (lCopy = 0; lCopy < 3; lCopy++) H101[ lCopy ] = 0; } } void acado_multEDu( real_t* const E1, real_t* const U1, real_t* const dNew ) { dNew[0] += + E1[0]*U1[0]; dNew[1] += + E1[1]*U1[0]; dNew[2] += + E1[2]*U1[0]; } void acado_zeroBlockH00( ) { acadoWorkspace.H[0] = 0.0000000000000000e+00; acadoWorkspace.H[1] = 0.0000000000000000e+00; acadoWorkspace.H[2] = 0.0000000000000000e+00; acadoWorkspace.H[23] = 0.0000000000000000e+00; acadoWorkspace.H[24] = 0.0000000000000000e+00; acadoWorkspace.H[25] = 0.0000000000000000e+00; acadoWorkspace.H[46] = 0.0000000000000000e+00; acadoWorkspace.H[47] = 0.0000000000000000e+00; acadoWorkspace.H[48] = 0.0000000000000000e+00; } void acado_multCTQC( real_t* const Gx1, real_t* const Gx2 ) { acadoWorkspace.H[0] += + Gx1[0]*Gx2[0] + Gx1[3]*Gx2[3] + Gx1[6]*Gx2[6]; acadoWorkspace.H[1] += + Gx1[0]*Gx2[1] + Gx1[3]*Gx2[4] + Gx1[6]*Gx2[7]; acadoWorkspace.H[2] += + Gx1[0]*Gx2[2] + Gx1[3]*Gx2[5] + Gx1[6]*Gx2[8]; acadoWorkspace.H[23] += + Gx1[1]*Gx2[0] + Gx1[4]*Gx2[3] + Gx1[7]*Gx2[6]; acadoWorkspace.H[24] += + Gx1[1]*Gx2[1] + Gx1[4]*Gx2[4] + Gx1[7]*Gx2[7]; acadoWorkspace.H[25] += + Gx1[1]*Gx2[2] + Gx1[4]*Gx2[5] + Gx1[7]*Gx2[8]; acadoWorkspace.H[46] += + Gx1[2]*Gx2[0] + Gx1[5]*Gx2[3] + Gx1[8]*Gx2[6]; acadoWorkspace.H[47] += + Gx1[2]*Gx2[1] + Gx1[5]*Gx2[4] + Gx1[8]*Gx2[7]; acadoWorkspace.H[48] += + Gx1[2]*Gx2[2] + Gx1[5]*Gx2[5] + Gx1[8]*Gx2[8]; } void acado_macCTSlx( real_t* const C0, real_t* const g0 ) { g0[0] += 0.0; ; g0[1] += 0.0; ; g0[2] += 0.0; ; } void acado_macETSlu( real_t* const E0, real_t* const g1 ) { g1[0] += 0.0; ; } void acado_condensePrep( ) { int lRun1; int lRun2; int lRun3; int lRun4; int lRun5; /** Row vector of size: 20 */ static const int xBoundIndices[ 20 ] = { 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61 }; acado_moveGuE( acadoWorkspace.evGu, acadoWorkspace.E ); acado_moveGxT( &(acadoWorkspace.evGx[ 9 ]), acadoWorkspace.T ); acado_multGxd( acadoWorkspace.d, &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.d[ 3 ]) ); acado_multGxGx( acadoWorkspace.T, acadoWorkspace.evGx, &(acadoWorkspace.evGx[ 9 ]) ); acado_multGxGu( acadoWorkspace.T, acadoWorkspace.E, &(acadoWorkspace.E[ 3 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 3 ]), &(acadoWorkspace.E[ 6 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 18 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 3 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.d[ 6 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.evGx[ 18 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.E[ 9 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.E[ 12 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 6 ]), &(acadoWorkspace.E[ 15 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 27 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 6 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.d[ 9 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.evGx[ 27 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.E[ 18 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.E[ 21 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.E[ 24 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 9 ]), &(acadoWorkspace.E[ 27 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 36 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 9 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.d[ 12 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.evGx[ 36 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.E[ 30 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.E[ 33 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.E[ 36 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.E[ 39 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 12 ]), &(acadoWorkspace.E[ 42 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 45 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.d[ 15 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.evGx[ 45 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.E[ 45 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.E[ 48 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.E[ 51 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.E[ 54 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.E[ 57 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 15 ]), &(acadoWorkspace.E[ 60 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 54 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 15 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.d[ 18 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.evGx[ 54 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.E[ 63 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.E[ 66 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.E[ 69 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.E[ 72 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.E[ 75 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.E[ 78 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 18 ]), &(acadoWorkspace.E[ 81 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 63 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 18 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.d[ 21 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.evGx[ 63 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.E[ 84 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.E[ 87 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.E[ 90 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.E[ 93 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.E[ 96 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.E[ 99 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.E[ 102 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 21 ]), &(acadoWorkspace.E[ 105 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 72 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 21 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.d[ 24 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.evGx[ 72 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.E[ 108 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.E[ 111 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.E[ 114 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.E[ 117 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.E[ 120 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.E[ 123 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.E[ 126 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.E[ 129 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 24 ]), &(acadoWorkspace.E[ 132 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 81 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.d[ 27 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.evGx[ 81 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.E[ 135 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.E[ 138 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.E[ 141 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.E[ 144 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.E[ 147 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.E[ 150 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.E[ 153 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.E[ 156 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.E[ 159 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 27 ]), &(acadoWorkspace.E[ 162 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 90 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 27 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.d[ 30 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.evGx[ 90 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.E[ 165 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.E[ 168 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.E[ 171 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.E[ 174 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.E[ 177 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.E[ 180 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.E[ 183 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.E[ 186 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.E[ 189 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.E[ 192 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 30 ]), &(acadoWorkspace.E[ 195 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 99 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 30 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.d[ 33 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.evGx[ 99 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.E[ 198 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.E[ 201 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.E[ 204 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.E[ 207 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.E[ 210 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.E[ 213 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.E[ 216 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.E[ 219 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.E[ 222 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.E[ 225 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.E[ 228 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 33 ]), &(acadoWorkspace.E[ 231 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 108 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 33 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.d[ 36 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.evGx[ 108 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.E[ 234 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.E[ 237 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.E[ 240 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.E[ 243 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.E[ 246 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.E[ 249 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.E[ 252 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.E[ 255 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.E[ 258 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.E[ 261 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.E[ 264 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.E[ 267 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 36 ]), &(acadoWorkspace.E[ 270 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 117 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.d[ 39 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.evGx[ 117 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.E[ 273 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.E[ 276 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.E[ 279 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.E[ 282 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.E[ 285 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.E[ 288 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.E[ 291 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.E[ 294 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.E[ 297 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.E[ 300 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.E[ 303 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.E[ 306 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.E[ 309 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 39 ]), &(acadoWorkspace.E[ 312 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 126 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 39 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.d[ 42 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.evGx[ 126 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.E[ 315 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.E[ 318 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.E[ 321 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.E[ 324 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.E[ 327 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.E[ 330 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.E[ 333 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.E[ 336 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.E[ 339 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.E[ 342 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.E[ 345 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.E[ 348 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.E[ 351 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.E[ 354 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 42 ]), &(acadoWorkspace.E[ 357 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 135 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 42 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.d[ 45 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.evGx[ 135 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.E[ 360 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.E[ 363 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.E[ 366 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.E[ 369 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.E[ 372 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.E[ 375 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.E[ 378 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.E[ 381 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.E[ 384 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.E[ 387 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.E[ 390 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.E[ 393 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.E[ 396 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.E[ 399 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.E[ 402 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 45 ]), &(acadoWorkspace.E[ 405 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 45 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.d[ 48 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.evGx[ 144 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.E[ 408 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.E[ 411 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.E[ 414 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.E[ 417 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.E[ 420 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.E[ 423 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.E[ 426 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.E[ 429 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.E[ 432 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.E[ 435 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.E[ 438 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.E[ 441 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.E[ 444 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.E[ 447 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.E[ 450 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.E[ 453 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 48 ]), &(acadoWorkspace.E[ 456 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 153 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.d[ 51 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.evGx[ 153 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.E[ 459 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.E[ 462 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.E[ 465 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.E[ 468 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.E[ 471 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.E[ 474 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.E[ 477 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.E[ 480 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.E[ 483 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.E[ 486 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.E[ 489 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.E[ 492 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.E[ 495 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.E[ 498 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.E[ 501 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.E[ 504 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.E[ 507 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 51 ]), &(acadoWorkspace.E[ 510 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 162 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 51 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.d[ 54 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.evGx[ 162 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.E[ 513 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.E[ 516 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.E[ 519 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.E[ 522 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.E[ 525 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.E[ 528 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.E[ 531 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.E[ 534 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.E[ 537 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.E[ 540 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.E[ 543 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.E[ 546 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.E[ 549 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.E[ 552 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.E[ 555 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.E[ 558 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.E[ 561 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.E[ 564 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 54 ]), &(acadoWorkspace.E[ 567 ]) ); acado_moveGxT( &(acadoWorkspace.evGx[ 171 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ 54 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.d[ 57 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.evGx[ 171 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.E[ 570 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.E[ 573 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.E[ 576 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.E[ 579 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.E[ 582 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.E[ 585 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.E[ 588 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.E[ 591 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.E[ 594 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.E[ 597 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.E[ 600 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.E[ 603 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.E[ 606 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.E[ 609 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.E[ 612 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.E[ 615 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.E[ 618 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.E[ 621 ]) ); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.E[ 624 ]) ); acado_moveGuE( &(acadoWorkspace.evGu[ 57 ]), &(acadoWorkspace.E[ 627 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 9 ]), acadoWorkspace.evGx, acadoWorkspace.QGx ); acado_multGxGx( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.QGx[ 9 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.QGx[ 18 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.QGx[ 27 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.QGx[ 36 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.QGx[ 45 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.QGx[ 54 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.QGx[ 63 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.QGx[ 72 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.QGx[ 81 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.QGx[ 90 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.QGx[ 99 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.QGx[ 108 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.QGx[ 117 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.QGx[ 126 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.QGx[ 135 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.QGx[ 153 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.QGx[ 162 ]) ); acado_multGxGx( acadoWorkspace.QN1, &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.QGx[ 171 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 9 ]), acadoWorkspace.E, acadoWorkspace.QE ); acado_multGxGu( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QE[ 3 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.QE[ 6 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 9 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.QE[ 15 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 18 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 21 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.QE[ 27 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 30 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 33 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QE[ 39 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.QE[ 42 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 45 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 51 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 54 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QE[ 57 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 63 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 66 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 69 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 75 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 87 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 90 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 93 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 111 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 114 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 117 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 135 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 138 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 141 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 147 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 165 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 171 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 174 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 177 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 198 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 201 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 207 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 210 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 234 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 237 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 243 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 246 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 273 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 279 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 282 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 285 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 315 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 318 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 321 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 327 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 363 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 366 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 369 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 411 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 414 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 417 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 459 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 462 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 465 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 471 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 513 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 519 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 522 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 525 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_multGxGu( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 570 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 573 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 576 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 579 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 582 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_zeroBlockH00( ); acado_multCTQC( acadoWorkspace.evGx, acadoWorkspace.QGx ); acado_multCTQC( &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.QGx[ 9 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.QGx[ 18 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.QGx[ 27 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.QGx[ 36 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.QGx[ 45 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.QGx[ 54 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.QGx[ 63 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.QGx[ 72 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.QGx[ 81 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.QGx[ 90 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.QGx[ 99 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.QGx[ 108 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.QGx[ 117 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.QGx[ 126 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.QGx[ 135 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.QGx[ 153 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.QGx[ 162 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.QGx[ 171 ]) ); acado_zeroBlockH10( acadoWorkspace.H10 ); acado_multQETGx( acadoWorkspace.QE, acadoWorkspace.evGx, acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 3 ]), &(acadoWorkspace.evGx[ 9 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 9 ]), &(acadoWorkspace.evGx[ 18 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 18 ]), &(acadoWorkspace.evGx[ 27 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 30 ]), &(acadoWorkspace.evGx[ 36 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 45 ]), &(acadoWorkspace.evGx[ 45 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 63 ]), &(acadoWorkspace.evGx[ 54 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.evGx[ 63 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.evGx[ 72 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 135 ]), &(acadoWorkspace.evGx[ 81 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 165 ]), &(acadoWorkspace.evGx[ 90 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 198 ]), &(acadoWorkspace.evGx[ 99 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 234 ]), &(acadoWorkspace.evGx[ 108 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 273 ]), &(acadoWorkspace.evGx[ 117 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 315 ]), &(acadoWorkspace.evGx[ 126 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.evGx[ 135 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 459 ]), &(acadoWorkspace.evGx[ 153 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 513 ]), &(acadoWorkspace.evGx[ 162 ]), acadoWorkspace.H10 ); acado_multQETGx( &(acadoWorkspace.QE[ 570 ]), &(acadoWorkspace.evGx[ 171 ]), acadoWorkspace.H10 ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 6 ]), &(acadoWorkspace.evGx[ 9 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 21 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 33 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 66 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 87 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 111 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 138 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 201 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 237 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 318 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 363 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 411 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 462 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 573 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 3 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 15 ]), &(acadoWorkspace.evGx[ 18 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 51 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 69 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 90 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 114 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 141 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 171 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 279 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 321 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 366 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 414 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 465 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 519 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 576 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 6 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 27 ]), &(acadoWorkspace.evGx[ 27 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 39 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 54 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 93 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 117 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 174 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 207 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 243 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 282 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 369 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 417 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 522 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 579 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 9 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 42 ]), &(acadoWorkspace.evGx[ 36 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 57 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 75 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 147 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 177 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 210 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 246 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 285 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 327 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 471 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 525 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 582 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 12 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.evGx[ 45 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 78 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 99 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 123 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 150 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 213 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 249 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 330 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 375 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 423 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 474 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 585 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 15 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 81 ]), &(acadoWorkspace.evGx[ 54 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 102 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 126 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 153 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 183 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 291 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 333 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 378 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 426 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 477 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 531 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 588 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 18 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 105 ]), &(acadoWorkspace.evGx[ 63 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 129 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 186 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 219 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 255 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 294 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 381 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 429 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 534 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 591 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 21 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.evGx[ 72 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 159 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 189 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 222 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 258 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 297 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 339 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 483 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 537 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 594 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 24 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 162 ]), &(acadoWorkspace.evGx[ 81 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 225 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 261 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 342 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 387 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 435 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 486 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 597 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 27 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 195 ]), &(acadoWorkspace.evGx[ 90 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 303 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 345 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 390 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 438 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 489 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 543 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 600 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 30 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 231 ]), &(acadoWorkspace.evGx[ 99 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 267 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 306 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 393 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 441 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 546 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 603 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 33 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 270 ]), &(acadoWorkspace.evGx[ 108 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 309 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 351 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 495 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 549 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 606 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 36 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.evGx[ 117 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 354 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 399 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 447 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 498 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 552 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 609 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 39 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 42 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 357 ]), &(acadoWorkspace.evGx[ 126 ]), &(acadoWorkspace.H10[ 42 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 402 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 42 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 450 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 42 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 501 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 42 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 555 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 42 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 612 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 42 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 45 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 405 ]), &(acadoWorkspace.evGx[ 135 ]), &(acadoWorkspace.H10[ 45 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 453 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 45 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 45 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 558 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 45 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 615 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 45 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 507 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 561 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 618 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 48 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 51 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 510 ]), &(acadoWorkspace.evGx[ 153 ]), &(acadoWorkspace.H10[ 51 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 564 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 51 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 621 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 51 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 54 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 567 ]), &(acadoWorkspace.evGx[ 162 ]), &(acadoWorkspace.H10[ 54 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 624 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 54 ]) ); acado_zeroBlockH10( &(acadoWorkspace.H10[ 57 ]) ); acado_multQETGx( &(acadoWorkspace.QE[ 627 ]), &(acadoWorkspace.evGx[ 171 ]), &(acadoWorkspace.H10[ 57 ]) ); acadoWorkspace.H[3] = acadoWorkspace.H10[0]; acadoWorkspace.H[4] = acadoWorkspace.H10[3]; acadoWorkspace.H[5] = acadoWorkspace.H10[6]; acadoWorkspace.H[6] = acadoWorkspace.H10[9]; acadoWorkspace.H[7] = acadoWorkspace.H10[12]; acadoWorkspace.H[8] = acadoWorkspace.H10[15]; acadoWorkspace.H[9] = acadoWorkspace.H10[18]; acadoWorkspace.H[10] = acadoWorkspace.H10[21]; acadoWorkspace.H[11] = acadoWorkspace.H10[24]; acadoWorkspace.H[12] = acadoWorkspace.H10[27]; acadoWorkspace.H[13] = acadoWorkspace.H10[30]; acadoWorkspace.H[14] = acadoWorkspace.H10[33]; acadoWorkspace.H[15] = acadoWorkspace.H10[36]; acadoWorkspace.H[16] = acadoWorkspace.H10[39]; acadoWorkspace.H[17] = acadoWorkspace.H10[42]; acadoWorkspace.H[18] = acadoWorkspace.H10[45]; acadoWorkspace.H[19] = acadoWorkspace.H10[48]; acadoWorkspace.H[20] = acadoWorkspace.H10[51]; acadoWorkspace.H[21] = acadoWorkspace.H10[54]; acadoWorkspace.H[22] = acadoWorkspace.H10[57]; acadoWorkspace.H[26] = acadoWorkspace.H10[1]; acadoWorkspace.H[27] = acadoWorkspace.H10[4]; acadoWorkspace.H[28] = acadoWorkspace.H10[7]; acadoWorkspace.H[29] = acadoWorkspace.H10[10]; acadoWorkspace.H[30] = acadoWorkspace.H10[13]; acadoWorkspace.H[31] = acadoWorkspace.H10[16]; acadoWorkspace.H[32] = acadoWorkspace.H10[19]; acadoWorkspace.H[33] = acadoWorkspace.H10[22]; acadoWorkspace.H[34] = acadoWorkspace.H10[25]; acadoWorkspace.H[35] = acadoWorkspace.H10[28]; acadoWorkspace.H[36] = acadoWorkspace.H10[31]; acadoWorkspace.H[37] = acadoWorkspace.H10[34]; acadoWorkspace.H[38] = acadoWorkspace.H10[37]; acadoWorkspace.H[39] = acadoWorkspace.H10[40]; acadoWorkspace.H[40] = acadoWorkspace.H10[43]; acadoWorkspace.H[41] = acadoWorkspace.H10[46]; acadoWorkspace.H[42] = acadoWorkspace.H10[49]; acadoWorkspace.H[43] = acadoWorkspace.H10[52]; acadoWorkspace.H[44] = acadoWorkspace.H10[55]; acadoWorkspace.H[45] = acadoWorkspace.H10[58]; acadoWorkspace.H[49] = acadoWorkspace.H10[2]; acadoWorkspace.H[50] = acadoWorkspace.H10[5]; acadoWorkspace.H[51] = acadoWorkspace.H10[8]; acadoWorkspace.H[52] = acadoWorkspace.H10[11]; acadoWorkspace.H[53] = acadoWorkspace.H10[14]; acadoWorkspace.H[54] = acadoWorkspace.H10[17]; acadoWorkspace.H[55] = acadoWorkspace.H10[20]; acadoWorkspace.H[56] = acadoWorkspace.H10[23]; acadoWorkspace.H[57] = acadoWorkspace.H10[26]; acadoWorkspace.H[58] = acadoWorkspace.H10[29]; acadoWorkspace.H[59] = acadoWorkspace.H10[32]; acadoWorkspace.H[60] = acadoWorkspace.H10[35]; acadoWorkspace.H[61] = acadoWorkspace.H10[38]; acadoWorkspace.H[62] = acadoWorkspace.H10[41]; acadoWorkspace.H[63] = acadoWorkspace.H10[44]; acadoWorkspace.H[64] = acadoWorkspace.H10[47]; acadoWorkspace.H[65] = acadoWorkspace.H10[50]; acadoWorkspace.H[66] = acadoWorkspace.H10[53]; acadoWorkspace.H[67] = acadoWorkspace.H10[56]; acadoWorkspace.H[68] = acadoWorkspace.H10[59]; acado_setBlockH11_R1( 0, 0, acadoWorkspace.R1 ); acado_setBlockH11( 0, 0, acadoWorkspace.E, acadoWorkspace.QE ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QE[ 3 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 9 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 18 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 30 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 45 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 63 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 84 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 108 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 135 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 165 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 198 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 234 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 273 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 315 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 360 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 408 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 459 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 513 ]) ); acado_setBlockH11( 0, 0, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 570 ]) ); acado_zeroBlockH11( 0, 1 ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QE[ 6 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 12 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 21 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 33 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 66 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 87 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 111 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 138 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 201 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 237 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 318 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 363 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 411 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 462 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_setBlockH11( 0, 1, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 573 ]) ); acado_zeroBlockH11( 0, 2 ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QE[ 15 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 24 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 51 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 69 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 90 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 114 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 141 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 171 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 279 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 321 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 366 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 414 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 465 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 519 ]) ); acado_setBlockH11( 0, 2, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 576 ]) ); acado_zeroBlockH11( 0, 3 ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QE[ 27 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 39 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 54 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 93 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 117 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 174 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 207 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 243 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 282 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 369 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 417 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 522 ]) ); acado_setBlockH11( 0, 3, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 579 ]) ); acado_zeroBlockH11( 0, 4 ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QE[ 42 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 57 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 75 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 147 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 177 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 210 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 246 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 285 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 327 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 471 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 525 ]) ); acado_setBlockH11( 0, 4, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 582 ]) ); acado_zeroBlockH11( 0, 5 ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_setBlockH11( 0, 5, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_zeroBlockH11( 0, 6 ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 0, 6, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 0, 7 ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 0, 7, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 0, 8 ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 0, 8, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 0, 9 ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 0, 9, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 0, 10 ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 0, 10, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 0, 11 ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 0, 11, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 0, 12 ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 0, 12, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 0, 13 ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 0, 13, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 0, 14 ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 0, 14, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 0, 15 ); acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 0, 15, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 0, 16 ); acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 0, 16, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 0, 17 ); acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 0, 17, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 0, 18 ); acado_setBlockH11( 0, 18, &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 0, 18, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 0, 19 ); acado_setBlockH11( 0, 19, &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 1, 1, &(acadoWorkspace.R1[ 1 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.QE[ 6 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 12 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 21 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 33 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 48 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 66 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 87 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 111 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 138 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 168 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 201 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 237 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 276 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 318 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 363 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 411 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 462 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 516 ]) ); acado_setBlockH11( 1, 1, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 573 ]) ); acado_zeroBlockH11( 1, 2 ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QE[ 15 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 24 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 51 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 69 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 90 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 114 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 141 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 171 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 279 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 321 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 366 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 414 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 465 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 519 ]) ); acado_setBlockH11( 1, 2, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 576 ]) ); acado_zeroBlockH11( 1, 3 ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QE[ 27 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 39 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 54 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 93 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 117 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 174 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 207 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 243 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 282 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 369 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 417 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 522 ]) ); acado_setBlockH11( 1, 3, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 579 ]) ); acado_zeroBlockH11( 1, 4 ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QE[ 42 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 57 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 75 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 147 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 177 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 210 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 246 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 285 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 327 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 471 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 525 ]) ); acado_setBlockH11( 1, 4, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 582 ]) ); acado_zeroBlockH11( 1, 5 ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_setBlockH11( 1, 5, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_zeroBlockH11( 1, 6 ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 1, 6, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 1, 7 ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 1, 7, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 1, 8 ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 1, 8, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 1, 9 ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 1, 9, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 1, 10 ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 1, 10, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 1, 11 ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 1, 11, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 1, 12 ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 1, 12, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 1, 13 ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 1, 13, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 1, 14 ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 1, 14, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 1, 15 ); acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 1, 15, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 1, 16 ); acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 1, 16, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 1, 17 ); acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 1, 17, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 1, 18 ); acado_setBlockH11( 1, 18, &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 1, 18, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 1, 19 ); acado_setBlockH11( 1, 19, &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 2, 2, &(acadoWorkspace.R1[ 2 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.QE[ 15 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 24 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 36 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 51 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 69 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 90 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 114 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 141 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 171 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 204 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 240 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 279 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 321 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 366 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 414 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 465 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 519 ]) ); acado_setBlockH11( 2, 2, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 576 ]) ); acado_zeroBlockH11( 2, 3 ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QE[ 27 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 39 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 54 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 93 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 117 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 174 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 207 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 243 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 282 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 369 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 417 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 522 ]) ); acado_setBlockH11( 2, 3, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 579 ]) ); acado_zeroBlockH11( 2, 4 ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QE[ 42 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 57 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 75 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 147 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 177 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 210 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 246 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 285 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 327 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 471 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 525 ]) ); acado_setBlockH11( 2, 4, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 582 ]) ); acado_zeroBlockH11( 2, 5 ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_setBlockH11( 2, 5, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_zeroBlockH11( 2, 6 ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 2, 6, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 2, 7 ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 2, 7, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 2, 8 ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 2, 8, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 2, 9 ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 2, 9, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 2, 10 ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 2, 10, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 2, 11 ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 2, 11, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 2, 12 ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 2, 12, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 2, 13 ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 2, 13, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 2, 14 ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 2, 14, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 2, 15 ); acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 2, 15, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 2, 16 ); acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 2, 16, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 2, 17 ); acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 2, 17, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 2, 18 ); acado_setBlockH11( 2, 18, &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 2, 18, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 2, 19 ); acado_setBlockH11( 2, 19, &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 3, 3, &(acadoWorkspace.R1[ 3 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.QE[ 27 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QE[ 39 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 54 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 72 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 93 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 117 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 144 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 174 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 207 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 243 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 282 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 324 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 369 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 417 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 468 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 522 ]) ); acado_setBlockH11( 3, 3, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 579 ]) ); acado_zeroBlockH11( 3, 4 ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QE[ 42 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 57 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 75 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 147 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 177 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 210 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 246 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 285 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 327 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 471 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 525 ]) ); acado_setBlockH11( 3, 4, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 582 ]) ); acado_zeroBlockH11( 3, 5 ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_setBlockH11( 3, 5, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_zeroBlockH11( 3, 6 ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 3, 6, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 3, 7 ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 3, 7, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 3, 8 ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 3, 8, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 3, 9 ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 3, 9, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 3, 10 ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 3, 10, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 3, 11 ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 3, 11, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 3, 12 ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 3, 12, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 3, 13 ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 3, 13, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 3, 14 ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 3, 14, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 3, 15 ); acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 3, 15, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 3, 16 ); acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 3, 16, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 3, 17 ); acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 3, 17, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 3, 18 ); acado_setBlockH11( 3, 18, &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 3, 18, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 3, 19 ); acado_setBlockH11( 3, 19, &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 4, 4, &(acadoWorkspace.R1[ 4 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.QE[ 42 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QE[ 57 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 75 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 96 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 120 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 147 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 177 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 210 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 246 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 285 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 327 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 372 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 420 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 471 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 525 ]) ); acado_setBlockH11( 4, 4, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 582 ]) ); acado_zeroBlockH11( 4, 5 ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_setBlockH11( 4, 5, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_zeroBlockH11( 4, 6 ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 4, 6, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 4, 7 ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 4, 7, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 4, 8 ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 4, 8, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 4, 9 ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 4, 9, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 4, 10 ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 4, 10, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 4, 11 ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 4, 11, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 4, 12 ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 4, 12, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 4, 13 ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 4, 13, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 4, 14 ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 4, 14, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 4, 15 ); acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 4, 15, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 4, 16 ); acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 4, 16, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 4, 17 ); acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 4, 17, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 4, 18 ); acado_setBlockH11( 4, 18, &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 4, 18, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 4, 19 ); acado_setBlockH11( 4, 19, &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 5, 5, &(acadoWorkspace.R1[ 5 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QE[ 60 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QE[ 78 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 99 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 123 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 150 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 180 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 213 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 249 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 288 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 330 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 375 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 423 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 474 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 528 ]) ); acado_setBlockH11( 5, 5, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 585 ]) ); acado_zeroBlockH11( 5, 6 ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 5, 6, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 5, 7 ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 5, 7, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 5, 8 ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 5, 8, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 5, 9 ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 5, 9, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 5, 10 ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 5, 10, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 5, 11 ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 5, 11, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 5, 12 ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 5, 12, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 5, 13 ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 5, 13, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 5, 14 ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 5, 14, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 5, 15 ); acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 5, 15, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 5, 16 ); acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 5, 16, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 5, 17 ); acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 5, 17, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 5, 18 ); acado_setBlockH11( 5, 18, &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 5, 18, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 5, 19 ); acado_setBlockH11( 5, 19, &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 6, 6, &(acadoWorkspace.R1[ 6 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.QE[ 81 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QE[ 102 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 126 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 153 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 183 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 216 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 252 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 291 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 333 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 378 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 426 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 477 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 531 ]) ); acado_setBlockH11( 6, 6, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 588 ]) ); acado_zeroBlockH11( 6, 7 ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 6, 7, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 6, 8 ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 6, 8, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 6, 9 ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 6, 9, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 6, 10 ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 6, 10, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 6, 11 ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 6, 11, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 6, 12 ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 6, 12, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 6, 13 ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 6, 13, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 6, 14 ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 6, 14, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 6, 15 ); acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 6, 15, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 6, 16 ); acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 6, 16, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 6, 17 ); acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 6, 17, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 6, 18 ); acado_setBlockH11( 6, 18, &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 6, 18, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 6, 19 ); acado_setBlockH11( 6, 19, &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 7, 7, &(acadoWorkspace.R1[ 7 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.QE[ 105 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QE[ 129 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 156 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 186 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 219 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 255 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 294 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 336 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 381 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 429 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 480 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 534 ]) ); acado_setBlockH11( 7, 7, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 591 ]) ); acado_zeroBlockH11( 7, 8 ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 7, 8, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 7, 9 ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 7, 9, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 7, 10 ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 7, 10, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 7, 11 ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 7, 11, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 7, 12 ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 7, 12, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 7, 13 ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 7, 13, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 7, 14 ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 7, 14, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 7, 15 ); acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 7, 15, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 7, 16 ); acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 7, 16, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 7, 17 ); acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 7, 17, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 7, 18 ); acado_setBlockH11( 7, 18, &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 7, 18, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 7, 19 ); acado_setBlockH11( 7, 19, &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 8, 8, &(acadoWorkspace.R1[ 8 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QE[ 132 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QE[ 159 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 189 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 222 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 258 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 297 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 339 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 384 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 432 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 483 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 537 ]) ); acado_setBlockH11( 8, 8, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 594 ]) ); acado_zeroBlockH11( 8, 9 ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 8, 9, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 8, 10 ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 8, 10, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 8, 11 ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 8, 11, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 8, 12 ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 8, 12, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 8, 13 ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 8, 13, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 8, 14 ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 8, 14, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 8, 15 ); acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 8, 15, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 8, 16 ); acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 8, 16, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 8, 17 ); acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 8, 17, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 8, 18 ); acado_setBlockH11( 8, 18, &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 8, 18, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 8, 19 ); acado_setBlockH11( 8, 19, &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 9, 9, &(acadoWorkspace.R1[ 9 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.QE[ 162 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 192 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 225 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 261 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 300 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 342 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 387 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 435 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 486 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 540 ]) ); acado_setBlockH11( 9, 9, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 597 ]) ); acado_zeroBlockH11( 9, 10 ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 9, 10, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 9, 11 ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 9, 11, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 9, 12 ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 9, 12, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 9, 13 ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 9, 13, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 9, 14 ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 9, 14, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 9, 15 ); acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 9, 15, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 9, 16 ); acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 9, 16, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 9, 17 ); acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 9, 17, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 9, 18 ); acado_setBlockH11( 9, 18, &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 9, 18, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 9, 19 ); acado_setBlockH11( 9, 19, &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 10, 10, &(acadoWorkspace.R1[ 10 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.QE[ 195 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 228 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 264 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 303 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 345 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 390 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 438 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 489 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 543 ]) ); acado_setBlockH11( 10, 10, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 600 ]) ); acado_zeroBlockH11( 10, 11 ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 10, 11, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 10, 12 ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 10, 12, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 10, 13 ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 10, 13, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 10, 14 ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 10, 14, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 10, 15 ); acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 10, 15, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 10, 16 ); acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 10, 16, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 10, 17 ); acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 10, 17, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 10, 18 ); acado_setBlockH11( 10, 18, &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 10, 18, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 10, 19 ); acado_setBlockH11( 10, 19, &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 11, 11, &(acadoWorkspace.R1[ 11 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.QE[ 231 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QE[ 267 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 306 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 348 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 393 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 441 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 492 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 546 ]) ); acado_setBlockH11( 11, 11, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 603 ]) ); acado_zeroBlockH11( 11, 12 ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 11, 12, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 11, 13 ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 11, 13, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 11, 14 ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 11, 14, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 11, 15 ); acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 11, 15, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 11, 16 ); acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 11, 16, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 11, 17 ); acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 11, 17, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 11, 18 ); acado_setBlockH11( 11, 18, &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 11, 18, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 11, 19 ); acado_setBlockH11( 11, 19, &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 12, 12, &(acadoWorkspace.R1[ 12 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.QE[ 270 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QE[ 309 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 351 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 396 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 444 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 495 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 549 ]) ); acado_setBlockH11( 12, 12, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 606 ]) ); acado_zeroBlockH11( 12, 13 ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 12, 13, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 12, 14 ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 12, 14, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 12, 15 ); acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 12, 15, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 12, 16 ); acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 12, 16, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 12, 17 ); acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 12, 17, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 12, 18 ); acado_setBlockH11( 12, 18, &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 12, 18, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 12, 19 ); acado_setBlockH11( 12, 19, &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 13, 13, &(acadoWorkspace.R1[ 13 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QE[ 312 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QE[ 354 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 399 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 447 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 498 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 552 ]) ); acado_setBlockH11( 13, 13, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 609 ]) ); acado_zeroBlockH11( 13, 14 ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 13, 14, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 13, 15 ); acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 13, 15, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 13, 16 ); acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 13, 16, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 13, 17 ); acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 13, 17, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 13, 18 ); acado_setBlockH11( 13, 18, &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 13, 18, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 13, 19 ); acado_setBlockH11( 13, 19, &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 14, 14, &(acadoWorkspace.R1[ 14 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.QE[ 357 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QE[ 402 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 450 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 501 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 555 ]) ); acado_setBlockH11( 14, 14, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 612 ]) ); acado_zeroBlockH11( 14, 15 ); acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 14, 15, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 14, 16 ); acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 14, 16, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 14, 17 ); acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 14, 17, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 14, 18 ); acado_setBlockH11( 14, 18, &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 14, 18, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 14, 19 ); acado_setBlockH11( 14, 19, &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 15, 15, &(acadoWorkspace.R1[ 15 ]) ); acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.QE[ 405 ]) ); acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QE[ 453 ]) ); acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 504 ]) ); acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 558 ]) ); acado_setBlockH11( 15, 15, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 615 ]) ); acado_zeroBlockH11( 15, 16 ); acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 15, 16, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 15, 17 ); acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 15, 17, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 15, 18 ); acado_setBlockH11( 15, 18, &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 15, 18, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 15, 19 ); acado_setBlockH11( 15, 19, &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 16, 16, &(acadoWorkspace.R1[ 16 ]) ); acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QE[ 456 ]) ); acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QE[ 507 ]) ); acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 561 ]) ); acado_setBlockH11( 16, 16, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 618 ]) ); acado_zeroBlockH11( 16, 17 ); acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 16, 17, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 16, 18 ); acado_setBlockH11( 16, 18, &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 16, 18, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 16, 19 ); acado_setBlockH11( 16, 19, &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 17, 17, &(acadoWorkspace.R1[ 17 ]) ); acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.QE[ 510 ]) ); acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 564 ]) ); acado_setBlockH11( 17, 17, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 621 ]) ); acado_zeroBlockH11( 17, 18 ); acado_setBlockH11( 17, 18, &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 17, 18, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 17, 19 ); acado_setBlockH11( 17, 19, &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 18, 18, &(acadoWorkspace.R1[ 18 ]) ); acado_setBlockH11( 18, 18, &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.QE[ 567 ]) ); acado_setBlockH11( 18, 18, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 624 ]) ); acado_zeroBlockH11( 18, 19 ); acado_setBlockH11( 18, 19, &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_setBlockH11_R1( 19, 19, &(acadoWorkspace.R1[ 19 ]) ); acado_setBlockH11( 19, 19, &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.QE[ 627 ]) ); acado_copyHTH( 1, 0 ); acado_copyHTH( 2, 0 ); acado_copyHTH( 2, 1 ); acado_copyHTH( 3, 0 ); acado_copyHTH( 3, 1 ); acado_copyHTH( 3, 2 ); acado_copyHTH( 4, 0 ); acado_copyHTH( 4, 1 ); acado_copyHTH( 4, 2 ); acado_copyHTH( 4, 3 ); acado_copyHTH( 5, 0 ); acado_copyHTH( 5, 1 ); acado_copyHTH( 5, 2 ); acado_copyHTH( 5, 3 ); acado_copyHTH( 5, 4 ); acado_copyHTH( 6, 0 ); acado_copyHTH( 6, 1 ); acado_copyHTH( 6, 2 ); acado_copyHTH( 6, 3 ); acado_copyHTH( 6, 4 ); acado_copyHTH( 6, 5 ); acado_copyHTH( 7, 0 ); acado_copyHTH( 7, 1 ); acado_copyHTH( 7, 2 ); acado_copyHTH( 7, 3 ); acado_copyHTH( 7, 4 ); acado_copyHTH( 7, 5 ); acado_copyHTH( 7, 6 ); acado_copyHTH( 8, 0 ); acado_copyHTH( 8, 1 ); acado_copyHTH( 8, 2 ); acado_copyHTH( 8, 3 ); acado_copyHTH( 8, 4 ); acado_copyHTH( 8, 5 ); acado_copyHTH( 8, 6 ); acado_copyHTH( 8, 7 ); acado_copyHTH( 9, 0 ); acado_copyHTH( 9, 1 ); acado_copyHTH( 9, 2 ); acado_copyHTH( 9, 3 ); acado_copyHTH( 9, 4 ); acado_copyHTH( 9, 5 ); acado_copyHTH( 9, 6 ); acado_copyHTH( 9, 7 ); acado_copyHTH( 9, 8 ); acado_copyHTH( 10, 0 ); acado_copyHTH( 10, 1 ); acado_copyHTH( 10, 2 ); acado_copyHTH( 10, 3 ); acado_copyHTH( 10, 4 ); acado_copyHTH( 10, 5 ); acado_copyHTH( 10, 6 ); acado_copyHTH( 10, 7 ); acado_copyHTH( 10, 8 ); acado_copyHTH( 10, 9 ); acado_copyHTH( 11, 0 ); acado_copyHTH( 11, 1 ); acado_copyHTH( 11, 2 ); acado_copyHTH( 11, 3 ); acado_copyHTH( 11, 4 ); acado_copyHTH( 11, 5 ); acado_copyHTH( 11, 6 ); acado_copyHTH( 11, 7 ); acado_copyHTH( 11, 8 ); acado_copyHTH( 11, 9 ); acado_copyHTH( 11, 10 ); acado_copyHTH( 12, 0 ); acado_copyHTH( 12, 1 ); acado_copyHTH( 12, 2 ); acado_copyHTH( 12, 3 ); acado_copyHTH( 12, 4 ); acado_copyHTH( 12, 5 ); acado_copyHTH( 12, 6 ); acado_copyHTH( 12, 7 ); acado_copyHTH( 12, 8 ); acado_copyHTH( 12, 9 ); acado_copyHTH( 12, 10 ); acado_copyHTH( 12, 11 ); acado_copyHTH( 13, 0 ); acado_copyHTH( 13, 1 ); acado_copyHTH( 13, 2 ); acado_copyHTH( 13, 3 ); acado_copyHTH( 13, 4 ); acado_copyHTH( 13, 5 ); acado_copyHTH( 13, 6 ); acado_copyHTH( 13, 7 ); acado_copyHTH( 13, 8 ); acado_copyHTH( 13, 9 ); acado_copyHTH( 13, 10 ); acado_copyHTH( 13, 11 ); acado_copyHTH( 13, 12 ); acado_copyHTH( 14, 0 ); acado_copyHTH( 14, 1 ); acado_copyHTH( 14, 2 ); acado_copyHTH( 14, 3 ); acado_copyHTH( 14, 4 ); acado_copyHTH( 14, 5 ); acado_copyHTH( 14, 6 ); acado_copyHTH( 14, 7 ); acado_copyHTH( 14, 8 ); acado_copyHTH( 14, 9 ); acado_copyHTH( 14, 10 ); acado_copyHTH( 14, 11 ); acado_copyHTH( 14, 12 ); acado_copyHTH( 14, 13 ); acado_copyHTH( 15, 0 ); acado_copyHTH( 15, 1 ); acado_copyHTH( 15, 2 ); acado_copyHTH( 15, 3 ); acado_copyHTH( 15, 4 ); acado_copyHTH( 15, 5 ); acado_copyHTH( 15, 6 ); acado_copyHTH( 15, 7 ); acado_copyHTH( 15, 8 ); acado_copyHTH( 15, 9 ); acado_copyHTH( 15, 10 ); acado_copyHTH( 15, 11 ); acado_copyHTH( 15, 12 ); acado_copyHTH( 15, 13 ); acado_copyHTH( 15, 14 ); acado_copyHTH( 16, 0 ); acado_copyHTH( 16, 1 ); acado_copyHTH( 16, 2 ); acado_copyHTH( 16, 3 ); acado_copyHTH( 16, 4 ); acado_copyHTH( 16, 5 ); acado_copyHTH( 16, 6 ); acado_copyHTH( 16, 7 ); acado_copyHTH( 16, 8 ); acado_copyHTH( 16, 9 ); acado_copyHTH( 16, 10 ); acado_copyHTH( 16, 11 ); acado_copyHTH( 16, 12 ); acado_copyHTH( 16, 13 ); acado_copyHTH( 16, 14 ); acado_copyHTH( 16, 15 ); acado_copyHTH( 17, 0 ); acado_copyHTH( 17, 1 ); acado_copyHTH( 17, 2 ); acado_copyHTH( 17, 3 ); acado_copyHTH( 17, 4 ); acado_copyHTH( 17, 5 ); acado_copyHTH( 17, 6 ); acado_copyHTH( 17, 7 ); acado_copyHTH( 17, 8 ); acado_copyHTH( 17, 9 ); acado_copyHTH( 17, 10 ); acado_copyHTH( 17, 11 ); acado_copyHTH( 17, 12 ); acado_copyHTH( 17, 13 ); acado_copyHTH( 17, 14 ); acado_copyHTH( 17, 15 ); acado_copyHTH( 17, 16 ); acado_copyHTH( 18, 0 ); acado_copyHTH( 18, 1 ); acado_copyHTH( 18, 2 ); acado_copyHTH( 18, 3 ); acado_copyHTH( 18, 4 ); acado_copyHTH( 18, 5 ); acado_copyHTH( 18, 6 ); acado_copyHTH( 18, 7 ); acado_copyHTH( 18, 8 ); acado_copyHTH( 18, 9 ); acado_copyHTH( 18, 10 ); acado_copyHTH( 18, 11 ); acado_copyHTH( 18, 12 ); acado_copyHTH( 18, 13 ); acado_copyHTH( 18, 14 ); acado_copyHTH( 18, 15 ); acado_copyHTH( 18, 16 ); acado_copyHTH( 18, 17 ); acado_copyHTH( 19, 0 ); acado_copyHTH( 19, 1 ); acado_copyHTH( 19, 2 ); acado_copyHTH( 19, 3 ); acado_copyHTH( 19, 4 ); acado_copyHTH( 19, 5 ); acado_copyHTH( 19, 6 ); acado_copyHTH( 19, 7 ); acado_copyHTH( 19, 8 ); acado_copyHTH( 19, 9 ); acado_copyHTH( 19, 10 ); acado_copyHTH( 19, 11 ); acado_copyHTH( 19, 12 ); acado_copyHTH( 19, 13 ); acado_copyHTH( 19, 14 ); acado_copyHTH( 19, 15 ); acado_copyHTH( 19, 16 ); acado_copyHTH( 19, 17 ); acado_copyHTH( 19, 18 ); acadoWorkspace.H[69] = acadoWorkspace.H10[0]; acadoWorkspace.H[70] = acadoWorkspace.H10[1]; acadoWorkspace.H[71] = acadoWorkspace.H10[2]; acadoWorkspace.H[92] = acadoWorkspace.H10[3]; acadoWorkspace.H[93] = acadoWorkspace.H10[4]; acadoWorkspace.H[94] = acadoWorkspace.H10[5]; acadoWorkspace.H[115] = acadoWorkspace.H10[6]; acadoWorkspace.H[116] = acadoWorkspace.H10[7]; acadoWorkspace.H[117] = acadoWorkspace.H10[8]; acadoWorkspace.H[138] = acadoWorkspace.H10[9]; acadoWorkspace.H[139] = acadoWorkspace.H10[10]; acadoWorkspace.H[140] = acadoWorkspace.H10[11]; acadoWorkspace.H[161] = acadoWorkspace.H10[12]; acadoWorkspace.H[162] = acadoWorkspace.H10[13]; acadoWorkspace.H[163] = acadoWorkspace.H10[14]; acadoWorkspace.H[184] = acadoWorkspace.H10[15]; acadoWorkspace.H[185] = acadoWorkspace.H10[16]; acadoWorkspace.H[186] = acadoWorkspace.H10[17]; acadoWorkspace.H[207] = acadoWorkspace.H10[18]; acadoWorkspace.H[208] = acadoWorkspace.H10[19]; acadoWorkspace.H[209] = acadoWorkspace.H10[20]; acadoWorkspace.H[230] = acadoWorkspace.H10[21]; acadoWorkspace.H[231] = acadoWorkspace.H10[22]; acadoWorkspace.H[232] = acadoWorkspace.H10[23]; acadoWorkspace.H[253] = acadoWorkspace.H10[24]; acadoWorkspace.H[254] = acadoWorkspace.H10[25]; acadoWorkspace.H[255] = acadoWorkspace.H10[26]; acadoWorkspace.H[276] = acadoWorkspace.H10[27]; acadoWorkspace.H[277] = acadoWorkspace.H10[28]; acadoWorkspace.H[278] = acadoWorkspace.H10[29]; acadoWorkspace.H[299] = acadoWorkspace.H10[30]; acadoWorkspace.H[300] = acadoWorkspace.H10[31]; acadoWorkspace.H[301] = acadoWorkspace.H10[32]; acadoWorkspace.H[322] = acadoWorkspace.H10[33]; acadoWorkspace.H[323] = acadoWorkspace.H10[34]; acadoWorkspace.H[324] = acadoWorkspace.H10[35]; acadoWorkspace.H[345] = acadoWorkspace.H10[36]; acadoWorkspace.H[346] = acadoWorkspace.H10[37]; acadoWorkspace.H[347] = acadoWorkspace.H10[38]; acadoWorkspace.H[368] = acadoWorkspace.H10[39]; acadoWorkspace.H[369] = acadoWorkspace.H10[40]; acadoWorkspace.H[370] = acadoWorkspace.H10[41]; acadoWorkspace.H[391] = acadoWorkspace.H10[42]; acadoWorkspace.H[392] = acadoWorkspace.H10[43]; acadoWorkspace.H[393] = acadoWorkspace.H10[44]; acadoWorkspace.H[414] = acadoWorkspace.H10[45]; acadoWorkspace.H[415] = acadoWorkspace.H10[46]; acadoWorkspace.H[416] = acadoWorkspace.H10[47]; acadoWorkspace.H[437] = acadoWorkspace.H10[48]; acadoWorkspace.H[438] = acadoWorkspace.H10[49]; acadoWorkspace.H[439] = acadoWorkspace.H10[50]; acadoWorkspace.H[460] = acadoWorkspace.H10[51]; acadoWorkspace.H[461] = acadoWorkspace.H10[52]; acadoWorkspace.H[462] = acadoWorkspace.H10[53]; acadoWorkspace.H[483] = acadoWorkspace.H10[54]; acadoWorkspace.H[484] = acadoWorkspace.H10[55]; acadoWorkspace.H[485] = acadoWorkspace.H10[56]; acadoWorkspace.H[506] = acadoWorkspace.H10[57]; acadoWorkspace.H[507] = acadoWorkspace.H10[58]; acadoWorkspace.H[508] = acadoWorkspace.H10[59]; acado_multQ1d( &(acadoWorkspace.Q1[ 9 ]), acadoWorkspace.d, acadoWorkspace.Qd ); acado_multQ1d( &(acadoWorkspace.Q1[ 18 ]), &(acadoWorkspace.d[ 3 ]), &(acadoWorkspace.Qd[ 3 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 27 ]), &(acadoWorkspace.d[ 6 ]), &(acadoWorkspace.Qd[ 6 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 36 ]), &(acadoWorkspace.d[ 9 ]), &(acadoWorkspace.Qd[ 9 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 45 ]), &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.Qd[ 12 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 54 ]), &(acadoWorkspace.d[ 15 ]), &(acadoWorkspace.Qd[ 15 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 63 ]), &(acadoWorkspace.d[ 18 ]), &(acadoWorkspace.Qd[ 18 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 72 ]), &(acadoWorkspace.d[ 21 ]), &(acadoWorkspace.Qd[ 21 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 81 ]), &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.Qd[ 24 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 90 ]), &(acadoWorkspace.d[ 27 ]), &(acadoWorkspace.Qd[ 27 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 99 ]), &(acadoWorkspace.d[ 30 ]), &(acadoWorkspace.Qd[ 30 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 108 ]), &(acadoWorkspace.d[ 33 ]), &(acadoWorkspace.Qd[ 33 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 117 ]), &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.Qd[ 36 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 126 ]), &(acadoWorkspace.d[ 39 ]), &(acadoWorkspace.Qd[ 39 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 135 ]), &(acadoWorkspace.d[ 42 ]), &(acadoWorkspace.Qd[ 42 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.d[ 45 ]), &(acadoWorkspace.Qd[ 45 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 153 ]), &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.Qd[ 48 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 162 ]), &(acadoWorkspace.d[ 51 ]), &(acadoWorkspace.Qd[ 51 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 171 ]), &(acadoWorkspace.d[ 54 ]), &(acadoWorkspace.Qd[ 54 ]) ); acado_multQN1d( acadoWorkspace.QN1, &(acadoWorkspace.d[ 57 ]), &(acadoWorkspace.Qd[ 57 ]) ); acado_macCTSlx( acadoWorkspace.evGx, acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 9 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 18 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 27 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 36 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 45 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 54 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 63 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 72 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 81 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 90 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 99 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 108 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 117 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 126 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 135 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 153 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 162 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 171 ]), acadoWorkspace.g ); acado_macETSlu( acadoWorkspace.QE, &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 3 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 9 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 18 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 30 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 45 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 63 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 84 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 108 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 135 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 165 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 198 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 234 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 273 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 315 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 360 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 408 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 459 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 513 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 570 ]), &(acadoWorkspace.g[ 3 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 6 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 21 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 33 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 48 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 66 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 87 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 111 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 138 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 168 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 201 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 237 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 276 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 318 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 363 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 411 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 462 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 516 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 573 ]), &(acadoWorkspace.g[ 4 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 15 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 24 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 36 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 51 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 69 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 90 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 114 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 141 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 171 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 204 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 240 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 279 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 321 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 366 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 414 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 465 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 519 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 576 ]), &(acadoWorkspace.g[ 5 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 27 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 39 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 54 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 72 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 93 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 117 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 144 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 174 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 207 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 243 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 282 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 324 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 369 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 417 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 468 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 522 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 579 ]), &(acadoWorkspace.g[ 6 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 42 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 57 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 75 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 96 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 120 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 147 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 177 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 210 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 246 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 285 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 327 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 372 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 420 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 471 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 525 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 582 ]), &(acadoWorkspace.g[ 7 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 60 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 78 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 99 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 123 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 150 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 180 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 213 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 249 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 288 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 330 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 375 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 423 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 474 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 528 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 585 ]), &(acadoWorkspace.g[ 8 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 81 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 102 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 126 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 153 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 183 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 216 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 252 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 291 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 333 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 378 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 426 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 477 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 531 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 588 ]), &(acadoWorkspace.g[ 9 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 105 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 129 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 156 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 186 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 219 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 255 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 294 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 336 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 381 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 429 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 480 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 534 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 591 ]), &(acadoWorkspace.g[ 10 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 132 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 159 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 189 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 222 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 258 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 297 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 339 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 384 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 432 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 483 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 537 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 594 ]), &(acadoWorkspace.g[ 11 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 162 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 192 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 225 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 261 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 300 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 342 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 387 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 435 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 486 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 540 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 597 ]), &(acadoWorkspace.g[ 12 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 195 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 228 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 264 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 303 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 345 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 390 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 438 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 489 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 543 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 600 ]), &(acadoWorkspace.g[ 13 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 231 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 267 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 306 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 348 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 393 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 441 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 492 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 546 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 603 ]), &(acadoWorkspace.g[ 14 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 270 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 309 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 351 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 396 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 444 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 495 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 549 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 606 ]), &(acadoWorkspace.g[ 15 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 312 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 354 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 399 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 447 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 498 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 552 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 609 ]), &(acadoWorkspace.g[ 16 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 357 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 402 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 450 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 501 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 555 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 612 ]), &(acadoWorkspace.g[ 17 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 405 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 453 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 504 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 558 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 615 ]), &(acadoWorkspace.g[ 18 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 456 ]), &(acadoWorkspace.g[ 19 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 507 ]), &(acadoWorkspace.g[ 19 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 561 ]), &(acadoWorkspace.g[ 19 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 618 ]), &(acadoWorkspace.g[ 19 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 510 ]), &(acadoWorkspace.g[ 20 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 564 ]), &(acadoWorkspace.g[ 20 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 621 ]), &(acadoWorkspace.g[ 20 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 567 ]), &(acadoWorkspace.g[ 21 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 624 ]), &(acadoWorkspace.g[ 21 ]) ); acado_macETSlu( &(acadoWorkspace.QE[ 627 ]), &(acadoWorkspace.g[ 22 ]) ); acadoWorkspace.lb[3] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[0]; acadoWorkspace.lb[4] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[1]; acadoWorkspace.lb[5] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[2]; acadoWorkspace.lb[6] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[3]; acadoWorkspace.lb[7] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[4]; acadoWorkspace.lb[8] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[5]; acadoWorkspace.lb[9] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[6]; acadoWorkspace.lb[10] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[7]; acadoWorkspace.lb[11] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[8]; acadoWorkspace.lb[12] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[9]; acadoWorkspace.lb[13] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[10]; acadoWorkspace.lb[14] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[11]; acadoWorkspace.lb[15] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[12]; acadoWorkspace.lb[16] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[13]; acadoWorkspace.lb[17] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[14]; acadoWorkspace.lb[18] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[15]; acadoWorkspace.lb[19] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[16]; acadoWorkspace.lb[20] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[17]; acadoWorkspace.lb[21] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[18]; acadoWorkspace.lb[22] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[19]; acadoWorkspace.ub[3] = (real_t)1.0000000000000000e+12 - acadoVariables.u[0]; acadoWorkspace.ub[4] = (real_t)1.0000000000000000e+12 - acadoVariables.u[1]; acadoWorkspace.ub[5] = (real_t)1.0000000000000000e+12 - acadoVariables.u[2]; acadoWorkspace.ub[6] = (real_t)1.0000000000000000e+12 - acadoVariables.u[3]; acadoWorkspace.ub[7] = (real_t)1.0000000000000000e+12 - acadoVariables.u[4]; acadoWorkspace.ub[8] = (real_t)1.0000000000000000e+12 - acadoVariables.u[5]; acadoWorkspace.ub[9] = (real_t)1.0000000000000000e+12 - acadoVariables.u[6]; acadoWorkspace.ub[10] = (real_t)1.0000000000000000e+12 - acadoVariables.u[7]; acadoWorkspace.ub[11] = (real_t)1.0000000000000000e+12 - acadoVariables.u[8]; acadoWorkspace.ub[12] = (real_t)1.0000000000000000e+12 - acadoVariables.u[9]; acadoWorkspace.ub[13] = (real_t)1.0000000000000000e+12 - acadoVariables.u[10]; acadoWorkspace.ub[14] = (real_t)1.0000000000000000e+12 - acadoVariables.u[11]; acadoWorkspace.ub[15] = (real_t)1.0000000000000000e+12 - acadoVariables.u[12]; acadoWorkspace.ub[16] = (real_t)1.0000000000000000e+12 - acadoVariables.u[13]; acadoWorkspace.ub[17] = (real_t)1.0000000000000000e+12 - acadoVariables.u[14]; acadoWorkspace.ub[18] = (real_t)1.0000000000000000e+12 - acadoVariables.u[15]; acadoWorkspace.ub[19] = (real_t)1.0000000000000000e+12 - acadoVariables.u[16]; acadoWorkspace.ub[20] = (real_t)1.0000000000000000e+12 - acadoVariables.u[17]; acadoWorkspace.ub[21] = (real_t)1.0000000000000000e+12 - acadoVariables.u[18]; acadoWorkspace.ub[22] = (real_t)1.0000000000000000e+12 - acadoVariables.u[19]; for (lRun1 = 0; lRun1 < 20; ++lRun1) { lRun3 = xBoundIndices[ lRun1 ] - 3; lRun4 = ((lRun3) / (3)) + (1); acadoWorkspace.A[lRun1 * 23] = acadoWorkspace.evGx[lRun3 * 3]; acadoWorkspace.A[lRun1 * 23 + 1] = acadoWorkspace.evGx[lRun3 * 3 + 1]; acadoWorkspace.A[lRun1 * 23 + 2] = acadoWorkspace.evGx[lRun3 * 3 + 2]; for (lRun2 = 0; lRun2 < lRun4; ++lRun2) { lRun5 = (((((lRun4) * (lRun4-1)) / (2)) + (lRun2)) * (3)) + ((lRun3) % (3)); acadoWorkspace.A[(lRun1 * 23) + (lRun2 + 3)] = acadoWorkspace.E[lRun5]; } } } void acado_condenseFdb( ) { real_t tmp; acadoWorkspace.Dx0[0] = acadoVariables.x0[0] - acadoVariables.x[0]; acadoWorkspace.Dx0[1] = acadoVariables.x0[1] - acadoVariables.x[1]; acadoWorkspace.Dx0[2] = acadoVariables.x0[2] - acadoVariables.x[2]; acadoWorkspace.Dy[0] -= acadoVariables.y[0]; acadoWorkspace.Dy[1] -= acadoVariables.y[1]; acadoWorkspace.Dy[2] -= acadoVariables.y[2]; acadoWorkspace.Dy[3] -= acadoVariables.y[3]; acadoWorkspace.Dy[4] -= acadoVariables.y[4]; acadoWorkspace.Dy[5] -= acadoVariables.y[5]; acadoWorkspace.Dy[6] -= acadoVariables.y[6]; acadoWorkspace.Dy[7] -= acadoVariables.y[7]; acadoWorkspace.Dy[8] -= acadoVariables.y[8]; acadoWorkspace.Dy[9] -= acadoVariables.y[9]; acadoWorkspace.Dy[10] -= acadoVariables.y[10]; acadoWorkspace.Dy[11] -= acadoVariables.y[11]; acadoWorkspace.Dy[12] -= acadoVariables.y[12]; acadoWorkspace.Dy[13] -= acadoVariables.y[13]; acadoWorkspace.Dy[14] -= acadoVariables.y[14]; acadoWorkspace.Dy[15] -= acadoVariables.y[15]; acadoWorkspace.Dy[16] -= acadoVariables.y[16]; acadoWorkspace.Dy[17] -= acadoVariables.y[17]; acadoWorkspace.Dy[18] -= acadoVariables.y[18]; acadoWorkspace.Dy[19] -= acadoVariables.y[19]; acadoWorkspace.Dy[20] -= acadoVariables.y[20]; acadoWorkspace.Dy[21] -= acadoVariables.y[21]; acadoWorkspace.Dy[22] -= acadoVariables.y[22]; acadoWorkspace.Dy[23] -= acadoVariables.y[23]; acadoWorkspace.Dy[24] -= acadoVariables.y[24]; acadoWorkspace.Dy[25] -= acadoVariables.y[25]; acadoWorkspace.Dy[26] -= acadoVariables.y[26]; acadoWorkspace.Dy[27] -= acadoVariables.y[27]; acadoWorkspace.Dy[28] -= acadoVariables.y[28]; acadoWorkspace.Dy[29] -= acadoVariables.y[29]; acadoWorkspace.Dy[30] -= acadoVariables.y[30]; acadoWorkspace.Dy[31] -= acadoVariables.y[31]; acadoWorkspace.Dy[32] -= acadoVariables.y[32]; acadoWorkspace.Dy[33] -= acadoVariables.y[33]; acadoWorkspace.Dy[34] -= acadoVariables.y[34]; acadoWorkspace.Dy[35] -= acadoVariables.y[35]; acadoWorkspace.Dy[36] -= acadoVariables.y[36]; acadoWorkspace.Dy[37] -= acadoVariables.y[37]; acadoWorkspace.Dy[38] -= acadoVariables.y[38]; acadoWorkspace.Dy[39] -= acadoVariables.y[39]; acadoWorkspace.Dy[40] -= acadoVariables.y[40]; acadoWorkspace.Dy[41] -= acadoVariables.y[41]; acadoWorkspace.Dy[42] -= acadoVariables.y[42]; acadoWorkspace.Dy[43] -= acadoVariables.y[43]; acadoWorkspace.Dy[44] -= acadoVariables.y[44]; acadoWorkspace.Dy[45] -= acadoVariables.y[45]; acadoWorkspace.Dy[46] -= acadoVariables.y[46]; acadoWorkspace.Dy[47] -= acadoVariables.y[47]; acadoWorkspace.Dy[48] -= acadoVariables.y[48]; acadoWorkspace.Dy[49] -= acadoVariables.y[49]; acadoWorkspace.Dy[50] -= acadoVariables.y[50]; acadoWorkspace.Dy[51] -= acadoVariables.y[51]; acadoWorkspace.Dy[52] -= acadoVariables.y[52]; acadoWorkspace.Dy[53] -= acadoVariables.y[53]; acadoWorkspace.Dy[54] -= acadoVariables.y[54]; acadoWorkspace.Dy[55] -= acadoVariables.y[55]; acadoWorkspace.Dy[56] -= acadoVariables.y[56]; acadoWorkspace.Dy[57] -= acadoVariables.y[57]; acadoWorkspace.Dy[58] -= acadoVariables.y[58]; acadoWorkspace.Dy[59] -= acadoVariables.y[59]; acadoWorkspace.Dy[60] -= acadoVariables.y[60]; acadoWorkspace.Dy[61] -= acadoVariables.y[61]; acadoWorkspace.Dy[62] -= acadoVariables.y[62]; acadoWorkspace.Dy[63] -= acadoVariables.y[63]; acadoWorkspace.Dy[64] -= acadoVariables.y[64]; acadoWorkspace.Dy[65] -= acadoVariables.y[65]; acadoWorkspace.Dy[66] -= acadoVariables.y[66]; acadoWorkspace.Dy[67] -= acadoVariables.y[67]; acadoWorkspace.Dy[68] -= acadoVariables.y[68]; acadoWorkspace.Dy[69] -= acadoVariables.y[69]; acadoWorkspace.Dy[70] -= acadoVariables.y[70]; acadoWorkspace.Dy[71] -= acadoVariables.y[71]; acadoWorkspace.Dy[72] -= acadoVariables.y[72]; acadoWorkspace.Dy[73] -= acadoVariables.y[73]; acadoWorkspace.Dy[74] -= acadoVariables.y[74]; acadoWorkspace.Dy[75] -= acadoVariables.y[75]; acadoWorkspace.Dy[76] -= acadoVariables.y[76]; acadoWorkspace.Dy[77] -= acadoVariables.y[77]; acadoWorkspace.Dy[78] -= acadoVariables.y[78]; acadoWorkspace.Dy[79] -= acadoVariables.y[79]; acadoWorkspace.DyN[0] -= acadoVariables.yN[0]; acadoWorkspace.DyN[1] -= acadoVariables.yN[1]; acadoWorkspace.DyN[2] -= acadoVariables.yN[2]; acado_multRDy( acadoWorkspace.R2, acadoWorkspace.Dy, &(acadoWorkspace.g[ 3 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 4 ]), &(acadoWorkspace.Dy[ 4 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 8 ]), &(acadoWorkspace.Dy[ 8 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 12 ]), &(acadoWorkspace.Dy[ 12 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 16 ]), &(acadoWorkspace.Dy[ 16 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 20 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 24 ]), &(acadoWorkspace.Dy[ 24 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 28 ]), &(acadoWorkspace.Dy[ 28 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 32 ]), &(acadoWorkspace.Dy[ 32 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 36 ]), &(acadoWorkspace.Dy[ 36 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 40 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 44 ]), &(acadoWorkspace.Dy[ 44 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 48 ]), &(acadoWorkspace.Dy[ 48 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 52 ]), &(acadoWorkspace.Dy[ 52 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 56 ]), &(acadoWorkspace.Dy[ 56 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 60 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 64 ]), &(acadoWorkspace.Dy[ 64 ]), &(acadoWorkspace.g[ 19 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 68 ]), &(acadoWorkspace.Dy[ 68 ]), &(acadoWorkspace.g[ 20 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 72 ]), &(acadoWorkspace.Dy[ 72 ]), &(acadoWorkspace.g[ 21 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 76 ]), &(acadoWorkspace.Dy[ 76 ]), &(acadoWorkspace.g[ 22 ]) ); acado_multQDy( acadoWorkspace.Q2, acadoWorkspace.Dy, acadoWorkspace.QDy ); acado_multQDy( &(acadoWorkspace.Q2[ 12 ]), &(acadoWorkspace.Dy[ 4 ]), &(acadoWorkspace.QDy[ 3 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 24 ]), &(acadoWorkspace.Dy[ 8 ]), &(acadoWorkspace.QDy[ 6 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 36 ]), &(acadoWorkspace.Dy[ 12 ]), &(acadoWorkspace.QDy[ 9 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 48 ]), &(acadoWorkspace.Dy[ 16 ]), &(acadoWorkspace.QDy[ 12 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 60 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.QDy[ 15 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 72 ]), &(acadoWorkspace.Dy[ 24 ]), &(acadoWorkspace.QDy[ 18 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 84 ]), &(acadoWorkspace.Dy[ 28 ]), &(acadoWorkspace.QDy[ 21 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 96 ]), &(acadoWorkspace.Dy[ 32 ]), &(acadoWorkspace.QDy[ 24 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 108 ]), &(acadoWorkspace.Dy[ 36 ]), &(acadoWorkspace.QDy[ 27 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 120 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.QDy[ 30 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 132 ]), &(acadoWorkspace.Dy[ 44 ]), &(acadoWorkspace.QDy[ 33 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 144 ]), &(acadoWorkspace.Dy[ 48 ]), &(acadoWorkspace.QDy[ 36 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 156 ]), &(acadoWorkspace.Dy[ 52 ]), &(acadoWorkspace.QDy[ 39 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 168 ]), &(acadoWorkspace.Dy[ 56 ]), &(acadoWorkspace.QDy[ 42 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 180 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.QDy[ 45 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 192 ]), &(acadoWorkspace.Dy[ 64 ]), &(acadoWorkspace.QDy[ 48 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 204 ]), &(acadoWorkspace.Dy[ 68 ]), &(acadoWorkspace.QDy[ 51 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 216 ]), &(acadoWorkspace.Dy[ 72 ]), &(acadoWorkspace.QDy[ 54 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 228 ]), &(acadoWorkspace.Dy[ 76 ]), &(acadoWorkspace.QDy[ 57 ]) ); acadoWorkspace.QDy[60] = + acadoWorkspace.QN2[0]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[1]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[2]*acadoWorkspace.DyN[2]; acadoWorkspace.QDy[61] = + acadoWorkspace.QN2[3]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[4]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[5]*acadoWorkspace.DyN[2]; acadoWorkspace.QDy[62] = + acadoWorkspace.QN2[6]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[7]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[8]*acadoWorkspace.DyN[2]; acadoWorkspace.QDy[3] += acadoWorkspace.Qd[0]; acadoWorkspace.QDy[4] += acadoWorkspace.Qd[1]; acadoWorkspace.QDy[5] += acadoWorkspace.Qd[2]; acadoWorkspace.QDy[6] += acadoWorkspace.Qd[3]; acadoWorkspace.QDy[7] += acadoWorkspace.Qd[4]; acadoWorkspace.QDy[8] += acadoWorkspace.Qd[5]; acadoWorkspace.QDy[9] += acadoWorkspace.Qd[6]; acadoWorkspace.QDy[10] += acadoWorkspace.Qd[7]; acadoWorkspace.QDy[11] += acadoWorkspace.Qd[8]; acadoWorkspace.QDy[12] += acadoWorkspace.Qd[9]; acadoWorkspace.QDy[13] += acadoWorkspace.Qd[10]; acadoWorkspace.QDy[14] += acadoWorkspace.Qd[11]; acadoWorkspace.QDy[15] += acadoWorkspace.Qd[12]; acadoWorkspace.QDy[16] += acadoWorkspace.Qd[13]; acadoWorkspace.QDy[17] += acadoWorkspace.Qd[14]; acadoWorkspace.QDy[18] += acadoWorkspace.Qd[15]; acadoWorkspace.QDy[19] += acadoWorkspace.Qd[16]; acadoWorkspace.QDy[20] += acadoWorkspace.Qd[17]; acadoWorkspace.QDy[21] += acadoWorkspace.Qd[18]; acadoWorkspace.QDy[22] += acadoWorkspace.Qd[19]; acadoWorkspace.QDy[23] += acadoWorkspace.Qd[20]; acadoWorkspace.QDy[24] += acadoWorkspace.Qd[21]; acadoWorkspace.QDy[25] += acadoWorkspace.Qd[22]; acadoWorkspace.QDy[26] += acadoWorkspace.Qd[23]; acadoWorkspace.QDy[27] += acadoWorkspace.Qd[24]; acadoWorkspace.QDy[28] += acadoWorkspace.Qd[25]; acadoWorkspace.QDy[29] += acadoWorkspace.Qd[26]; acadoWorkspace.QDy[30] += acadoWorkspace.Qd[27]; acadoWorkspace.QDy[31] += acadoWorkspace.Qd[28]; acadoWorkspace.QDy[32] += acadoWorkspace.Qd[29]; acadoWorkspace.QDy[33] += acadoWorkspace.Qd[30]; acadoWorkspace.QDy[34] += acadoWorkspace.Qd[31]; acadoWorkspace.QDy[35] += acadoWorkspace.Qd[32]; acadoWorkspace.QDy[36] += acadoWorkspace.Qd[33]; acadoWorkspace.QDy[37] += acadoWorkspace.Qd[34]; acadoWorkspace.QDy[38] += acadoWorkspace.Qd[35]; acadoWorkspace.QDy[39] += acadoWorkspace.Qd[36]; acadoWorkspace.QDy[40] += acadoWorkspace.Qd[37]; acadoWorkspace.QDy[41] += acadoWorkspace.Qd[38]; acadoWorkspace.QDy[42] += acadoWorkspace.Qd[39]; acadoWorkspace.QDy[43] += acadoWorkspace.Qd[40]; acadoWorkspace.QDy[44] += acadoWorkspace.Qd[41]; acadoWorkspace.QDy[45] += acadoWorkspace.Qd[42]; acadoWorkspace.QDy[46] += acadoWorkspace.Qd[43]; acadoWorkspace.QDy[47] += acadoWorkspace.Qd[44]; acadoWorkspace.QDy[48] += acadoWorkspace.Qd[45]; acadoWorkspace.QDy[49] += acadoWorkspace.Qd[46]; acadoWorkspace.QDy[50] += acadoWorkspace.Qd[47]; acadoWorkspace.QDy[51] += acadoWorkspace.Qd[48]; acadoWorkspace.QDy[52] += acadoWorkspace.Qd[49]; acadoWorkspace.QDy[53] += acadoWorkspace.Qd[50]; acadoWorkspace.QDy[54] += acadoWorkspace.Qd[51]; acadoWorkspace.QDy[55] += acadoWorkspace.Qd[52]; acadoWorkspace.QDy[56] += acadoWorkspace.Qd[53]; acadoWorkspace.QDy[57] += acadoWorkspace.Qd[54]; acadoWorkspace.QDy[58] += acadoWorkspace.Qd[55]; acadoWorkspace.QDy[59] += acadoWorkspace.Qd[56]; acadoWorkspace.QDy[60] += acadoWorkspace.Qd[57]; acadoWorkspace.QDy[61] += acadoWorkspace.Qd[58]; acadoWorkspace.QDy[62] += acadoWorkspace.Qd[59]; acadoWorkspace.g[0] = + acadoWorkspace.evGx[0]*acadoWorkspace.QDy[3] + acadoWorkspace.evGx[3]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[6]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[9]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[12]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[15]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[18]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[21]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[24]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[27]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[30]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[33]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[36]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[39]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[42]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[45]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[48]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[51]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[54]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[57]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[60]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[63]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[66]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[69]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[72]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[75]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[78]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[81]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[84]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[87]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[90]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[93]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[96]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[99]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[102]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[105]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[108]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[111]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[114]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[117]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[120]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[123]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[126]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[129]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[132]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[135]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[138]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[141]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[144]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[147]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[150]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[153]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[156]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[159]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[162]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[165]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[168]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[171]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[174]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[177]*acadoWorkspace.QDy[62]; acadoWorkspace.g[1] = + acadoWorkspace.evGx[1]*acadoWorkspace.QDy[3] + acadoWorkspace.evGx[4]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[7]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[10]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[13]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[16]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[19]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[22]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[25]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[28]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[31]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[34]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[37]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[40]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[43]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[46]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[49]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[52]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[55]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[58]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[61]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[64]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[67]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[70]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[73]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[76]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[79]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[82]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[85]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[88]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[91]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[94]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[97]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[100]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[103]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[106]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[109]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[112]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[115]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[118]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[121]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[124]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[127]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[130]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[133]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[136]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[139]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[142]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[145]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[148]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[151]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[154]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[157]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[160]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[163]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[166]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[169]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[172]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[175]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[178]*acadoWorkspace.QDy[62]; acadoWorkspace.g[2] = + acadoWorkspace.evGx[2]*acadoWorkspace.QDy[3] + acadoWorkspace.evGx[5]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[8]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[11]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[14]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[17]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[20]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[23]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[26]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[29]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[32]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[35]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[38]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[41]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[44]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[47]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[50]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[53]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[56]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[59]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[62]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[65]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[68]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[71]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[74]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[77]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[80]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[83]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[86]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[89]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[92]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[95]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[98]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[101]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[104]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[107]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[110]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[113]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[116]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[119]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[122]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[125]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[128]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[131]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[134]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[137]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[140]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[143]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[146]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[149]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[152]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[155]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[158]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[161]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[164]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[167]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[170]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[173]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[176]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[179]*acadoWorkspace.QDy[62]; acado_multEQDy( acadoWorkspace.E, &(acadoWorkspace.QDy[ 3 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.QDy[ 6 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.QDy[ 9 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 3 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.QDy[ 6 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.QDy[ 9 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 4 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.QDy[ 9 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 5 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.QDy[ 12 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.QDy[ 15 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 7 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.QDy[ 18 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.QDy[ 21 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 9 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.QDy[ 24 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.QDy[ 27 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 11 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.QDy[ 30 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.QDy[ 33 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 13 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.QDy[ 36 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.QDy[ 39 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 15 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.QDy[ 42 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.QDy[ 45 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 17 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.QDy[ 48 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.QDy[ 51 ]), &(acadoWorkspace.g[ 19 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 19 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 19 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 19 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.QDy[ 54 ]), &(acadoWorkspace.g[ 20 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 20 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 20 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.QDy[ 57 ]), &(acadoWorkspace.g[ 21 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 21 ]) ); acado_multEQDy( &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.QDy[ 60 ]), &(acadoWorkspace.g[ 22 ]) ); acadoWorkspace.lb[0] = acadoWorkspace.Dx0[0]; acadoWorkspace.lb[1] = acadoWorkspace.Dx0[1]; acadoWorkspace.lb[2] = acadoWorkspace.Dx0[2]; acadoWorkspace.ub[0] = acadoWorkspace.Dx0[0]; acadoWorkspace.ub[1] = acadoWorkspace.Dx0[1]; acadoWorkspace.ub[2] = acadoWorkspace.Dx0[2]; tmp = acadoVariables.x[4] + acadoWorkspace.d[1]; acadoWorkspace.lbA[0] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[0] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[7] + acadoWorkspace.d[4]; acadoWorkspace.lbA[1] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[1] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[10] + acadoWorkspace.d[7]; acadoWorkspace.lbA[2] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[2] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[13] + acadoWorkspace.d[10]; acadoWorkspace.lbA[3] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[3] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[16] + acadoWorkspace.d[13]; acadoWorkspace.lbA[4] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[4] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[19] + acadoWorkspace.d[16]; acadoWorkspace.lbA[5] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[5] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[22] + acadoWorkspace.d[19]; acadoWorkspace.lbA[6] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[6] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[25] + acadoWorkspace.d[22]; acadoWorkspace.lbA[7] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[7] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[28] + acadoWorkspace.d[25]; acadoWorkspace.lbA[8] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[8] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[31] + acadoWorkspace.d[28]; acadoWorkspace.lbA[9] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[9] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[34] + acadoWorkspace.d[31]; acadoWorkspace.lbA[10] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[10] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[37] + acadoWorkspace.d[34]; acadoWorkspace.lbA[11] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[11] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[40] + acadoWorkspace.d[37]; acadoWorkspace.lbA[12] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[12] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[43] + acadoWorkspace.d[40]; acadoWorkspace.lbA[13] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[13] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[46] + acadoWorkspace.d[43]; acadoWorkspace.lbA[14] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[14] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[49] + acadoWorkspace.d[46]; acadoWorkspace.lbA[15] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[15] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[52] + acadoWorkspace.d[49]; acadoWorkspace.lbA[16] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[16] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[55] + acadoWorkspace.d[52]; acadoWorkspace.lbA[17] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[17] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[58] + acadoWorkspace.d[55]; acadoWorkspace.lbA[18] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[18] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[61] + acadoWorkspace.d[58]; acadoWorkspace.lbA[19] = (real_t)-1.0000000000000001e-01 - tmp; acadoWorkspace.ubA[19] = (real_t)1.0000000000000000e+12 - tmp; } void acado_expand( ) { acadoVariables.x[0] += acadoWorkspace.x[0]; acadoVariables.x[1] += acadoWorkspace.x[1]; acadoVariables.x[2] += acadoWorkspace.x[2]; acadoVariables.u[0] += acadoWorkspace.x[3]; acadoVariables.u[1] += acadoWorkspace.x[4]; acadoVariables.u[2] += acadoWorkspace.x[5]; acadoVariables.u[3] += acadoWorkspace.x[6]; acadoVariables.u[4] += acadoWorkspace.x[7]; acadoVariables.u[5] += acadoWorkspace.x[8]; acadoVariables.u[6] += acadoWorkspace.x[9]; acadoVariables.u[7] += acadoWorkspace.x[10]; acadoVariables.u[8] += acadoWorkspace.x[11]; acadoVariables.u[9] += acadoWorkspace.x[12]; acadoVariables.u[10] += acadoWorkspace.x[13]; acadoVariables.u[11] += acadoWorkspace.x[14]; acadoVariables.u[12] += acadoWorkspace.x[15]; acadoVariables.u[13] += acadoWorkspace.x[16]; acadoVariables.u[14] += acadoWorkspace.x[17]; acadoVariables.u[15] += acadoWorkspace.x[18]; acadoVariables.u[16] += acadoWorkspace.x[19]; acadoVariables.u[17] += acadoWorkspace.x[20]; acadoVariables.u[18] += acadoWorkspace.x[21]; acadoVariables.u[19] += acadoWorkspace.x[22]; acadoVariables.x[3] += + acadoWorkspace.evGx[0]*acadoWorkspace.x[0] + acadoWorkspace.evGx[1]*acadoWorkspace.x[1] + acadoWorkspace.evGx[2]*acadoWorkspace.x[2] + acadoWorkspace.d[0]; acadoVariables.x[4] += + acadoWorkspace.evGx[3]*acadoWorkspace.x[0] + acadoWorkspace.evGx[4]*acadoWorkspace.x[1] + acadoWorkspace.evGx[5]*acadoWorkspace.x[2] + acadoWorkspace.d[1]; acadoVariables.x[5] += + acadoWorkspace.evGx[6]*acadoWorkspace.x[0] + acadoWorkspace.evGx[7]*acadoWorkspace.x[1] + acadoWorkspace.evGx[8]*acadoWorkspace.x[2] + acadoWorkspace.d[2]; acadoVariables.x[6] += + acadoWorkspace.evGx[9]*acadoWorkspace.x[0] + acadoWorkspace.evGx[10]*acadoWorkspace.x[1] + acadoWorkspace.evGx[11]*acadoWorkspace.x[2] + acadoWorkspace.d[3]; acadoVariables.x[7] += + acadoWorkspace.evGx[12]*acadoWorkspace.x[0] + acadoWorkspace.evGx[13]*acadoWorkspace.x[1] + acadoWorkspace.evGx[14]*acadoWorkspace.x[2] + acadoWorkspace.d[4]; acadoVariables.x[8] += + acadoWorkspace.evGx[15]*acadoWorkspace.x[0] + acadoWorkspace.evGx[16]*acadoWorkspace.x[1] + acadoWorkspace.evGx[17]*acadoWorkspace.x[2] + acadoWorkspace.d[5]; acadoVariables.x[9] += + acadoWorkspace.evGx[18]*acadoWorkspace.x[0] + acadoWorkspace.evGx[19]*acadoWorkspace.x[1] + acadoWorkspace.evGx[20]*acadoWorkspace.x[2] + acadoWorkspace.d[6]; acadoVariables.x[10] += + acadoWorkspace.evGx[21]*acadoWorkspace.x[0] + acadoWorkspace.evGx[22]*acadoWorkspace.x[1] + acadoWorkspace.evGx[23]*acadoWorkspace.x[2] + acadoWorkspace.d[7]; acadoVariables.x[11] += + acadoWorkspace.evGx[24]*acadoWorkspace.x[0] + acadoWorkspace.evGx[25]*acadoWorkspace.x[1] + acadoWorkspace.evGx[26]*acadoWorkspace.x[2] + acadoWorkspace.d[8]; acadoVariables.x[12] += + acadoWorkspace.evGx[27]*acadoWorkspace.x[0] + acadoWorkspace.evGx[28]*acadoWorkspace.x[1] + acadoWorkspace.evGx[29]*acadoWorkspace.x[2] + acadoWorkspace.d[9]; acadoVariables.x[13] += + acadoWorkspace.evGx[30]*acadoWorkspace.x[0] + acadoWorkspace.evGx[31]*acadoWorkspace.x[1] + acadoWorkspace.evGx[32]*acadoWorkspace.x[2] + acadoWorkspace.d[10]; acadoVariables.x[14] += + acadoWorkspace.evGx[33]*acadoWorkspace.x[0] + acadoWorkspace.evGx[34]*acadoWorkspace.x[1] + acadoWorkspace.evGx[35]*acadoWorkspace.x[2] + acadoWorkspace.d[11]; acadoVariables.x[15] += + acadoWorkspace.evGx[36]*acadoWorkspace.x[0] + acadoWorkspace.evGx[37]*acadoWorkspace.x[1] + acadoWorkspace.evGx[38]*acadoWorkspace.x[2] + acadoWorkspace.d[12]; acadoVariables.x[16] += + acadoWorkspace.evGx[39]*acadoWorkspace.x[0] + acadoWorkspace.evGx[40]*acadoWorkspace.x[1] + acadoWorkspace.evGx[41]*acadoWorkspace.x[2] + acadoWorkspace.d[13]; acadoVariables.x[17] += + acadoWorkspace.evGx[42]*acadoWorkspace.x[0] + acadoWorkspace.evGx[43]*acadoWorkspace.x[1] + acadoWorkspace.evGx[44]*acadoWorkspace.x[2] + acadoWorkspace.d[14]; acadoVariables.x[18] += + acadoWorkspace.evGx[45]*acadoWorkspace.x[0] + acadoWorkspace.evGx[46]*acadoWorkspace.x[1] + acadoWorkspace.evGx[47]*acadoWorkspace.x[2] + acadoWorkspace.d[15]; acadoVariables.x[19] += + acadoWorkspace.evGx[48]*acadoWorkspace.x[0] + acadoWorkspace.evGx[49]*acadoWorkspace.x[1] + acadoWorkspace.evGx[50]*acadoWorkspace.x[2] + acadoWorkspace.d[16]; acadoVariables.x[20] += + acadoWorkspace.evGx[51]*acadoWorkspace.x[0] + acadoWorkspace.evGx[52]*acadoWorkspace.x[1] + acadoWorkspace.evGx[53]*acadoWorkspace.x[2] + acadoWorkspace.d[17]; acadoVariables.x[21] += + acadoWorkspace.evGx[54]*acadoWorkspace.x[0] + acadoWorkspace.evGx[55]*acadoWorkspace.x[1] + acadoWorkspace.evGx[56]*acadoWorkspace.x[2] + acadoWorkspace.d[18]; acadoVariables.x[22] += + acadoWorkspace.evGx[57]*acadoWorkspace.x[0] + acadoWorkspace.evGx[58]*acadoWorkspace.x[1] + acadoWorkspace.evGx[59]*acadoWorkspace.x[2] + acadoWorkspace.d[19]; acadoVariables.x[23] += + acadoWorkspace.evGx[60]*acadoWorkspace.x[0] + acadoWorkspace.evGx[61]*acadoWorkspace.x[1] + acadoWorkspace.evGx[62]*acadoWorkspace.x[2] + acadoWorkspace.d[20]; acadoVariables.x[24] += + acadoWorkspace.evGx[63]*acadoWorkspace.x[0] + acadoWorkspace.evGx[64]*acadoWorkspace.x[1] + acadoWorkspace.evGx[65]*acadoWorkspace.x[2] + acadoWorkspace.d[21]; acadoVariables.x[25] += + acadoWorkspace.evGx[66]*acadoWorkspace.x[0] + acadoWorkspace.evGx[67]*acadoWorkspace.x[1] + acadoWorkspace.evGx[68]*acadoWorkspace.x[2] + acadoWorkspace.d[22]; acadoVariables.x[26] += + acadoWorkspace.evGx[69]*acadoWorkspace.x[0] + acadoWorkspace.evGx[70]*acadoWorkspace.x[1] + acadoWorkspace.evGx[71]*acadoWorkspace.x[2] + acadoWorkspace.d[23]; acadoVariables.x[27] += + acadoWorkspace.evGx[72]*acadoWorkspace.x[0] + acadoWorkspace.evGx[73]*acadoWorkspace.x[1] + acadoWorkspace.evGx[74]*acadoWorkspace.x[2] + acadoWorkspace.d[24]; acadoVariables.x[28] += + acadoWorkspace.evGx[75]*acadoWorkspace.x[0] + acadoWorkspace.evGx[76]*acadoWorkspace.x[1] + acadoWorkspace.evGx[77]*acadoWorkspace.x[2] + acadoWorkspace.d[25]; acadoVariables.x[29] += + acadoWorkspace.evGx[78]*acadoWorkspace.x[0] + acadoWorkspace.evGx[79]*acadoWorkspace.x[1] + acadoWorkspace.evGx[80]*acadoWorkspace.x[2] + acadoWorkspace.d[26]; acadoVariables.x[30] += + acadoWorkspace.evGx[81]*acadoWorkspace.x[0] + acadoWorkspace.evGx[82]*acadoWorkspace.x[1] + acadoWorkspace.evGx[83]*acadoWorkspace.x[2] + acadoWorkspace.d[27]; acadoVariables.x[31] += + acadoWorkspace.evGx[84]*acadoWorkspace.x[0] + acadoWorkspace.evGx[85]*acadoWorkspace.x[1] + acadoWorkspace.evGx[86]*acadoWorkspace.x[2] + acadoWorkspace.d[28]; acadoVariables.x[32] += + acadoWorkspace.evGx[87]*acadoWorkspace.x[0] + acadoWorkspace.evGx[88]*acadoWorkspace.x[1] + acadoWorkspace.evGx[89]*acadoWorkspace.x[2] + acadoWorkspace.d[29]; acadoVariables.x[33] += + acadoWorkspace.evGx[90]*acadoWorkspace.x[0] + acadoWorkspace.evGx[91]*acadoWorkspace.x[1] + acadoWorkspace.evGx[92]*acadoWorkspace.x[2] + acadoWorkspace.d[30]; acadoVariables.x[34] += + acadoWorkspace.evGx[93]*acadoWorkspace.x[0] + acadoWorkspace.evGx[94]*acadoWorkspace.x[1] + acadoWorkspace.evGx[95]*acadoWorkspace.x[2] + acadoWorkspace.d[31]; acadoVariables.x[35] += + acadoWorkspace.evGx[96]*acadoWorkspace.x[0] + acadoWorkspace.evGx[97]*acadoWorkspace.x[1] + acadoWorkspace.evGx[98]*acadoWorkspace.x[2] + acadoWorkspace.d[32]; acadoVariables.x[36] += + acadoWorkspace.evGx[99]*acadoWorkspace.x[0] + acadoWorkspace.evGx[100]*acadoWorkspace.x[1] + acadoWorkspace.evGx[101]*acadoWorkspace.x[2] + acadoWorkspace.d[33]; acadoVariables.x[37] += + acadoWorkspace.evGx[102]*acadoWorkspace.x[0] + acadoWorkspace.evGx[103]*acadoWorkspace.x[1] + acadoWorkspace.evGx[104]*acadoWorkspace.x[2] + acadoWorkspace.d[34]; acadoVariables.x[38] += + acadoWorkspace.evGx[105]*acadoWorkspace.x[0] + acadoWorkspace.evGx[106]*acadoWorkspace.x[1] + acadoWorkspace.evGx[107]*acadoWorkspace.x[2] + acadoWorkspace.d[35]; acadoVariables.x[39] += + acadoWorkspace.evGx[108]*acadoWorkspace.x[0] + acadoWorkspace.evGx[109]*acadoWorkspace.x[1] + acadoWorkspace.evGx[110]*acadoWorkspace.x[2] + acadoWorkspace.d[36]; acadoVariables.x[40] += + acadoWorkspace.evGx[111]*acadoWorkspace.x[0] + acadoWorkspace.evGx[112]*acadoWorkspace.x[1] + acadoWorkspace.evGx[113]*acadoWorkspace.x[2] + acadoWorkspace.d[37]; acadoVariables.x[41] += + acadoWorkspace.evGx[114]*acadoWorkspace.x[0] + acadoWorkspace.evGx[115]*acadoWorkspace.x[1] + acadoWorkspace.evGx[116]*acadoWorkspace.x[2] + acadoWorkspace.d[38]; acadoVariables.x[42] += + acadoWorkspace.evGx[117]*acadoWorkspace.x[0] + acadoWorkspace.evGx[118]*acadoWorkspace.x[1] + acadoWorkspace.evGx[119]*acadoWorkspace.x[2] + acadoWorkspace.d[39]; acadoVariables.x[43] += + acadoWorkspace.evGx[120]*acadoWorkspace.x[0] + acadoWorkspace.evGx[121]*acadoWorkspace.x[1] + acadoWorkspace.evGx[122]*acadoWorkspace.x[2] + acadoWorkspace.d[40]; acadoVariables.x[44] += + acadoWorkspace.evGx[123]*acadoWorkspace.x[0] + acadoWorkspace.evGx[124]*acadoWorkspace.x[1] + acadoWorkspace.evGx[125]*acadoWorkspace.x[2] + acadoWorkspace.d[41]; acadoVariables.x[45] += + acadoWorkspace.evGx[126]*acadoWorkspace.x[0] + acadoWorkspace.evGx[127]*acadoWorkspace.x[1] + acadoWorkspace.evGx[128]*acadoWorkspace.x[2] + acadoWorkspace.d[42]; acadoVariables.x[46] += + acadoWorkspace.evGx[129]*acadoWorkspace.x[0] + acadoWorkspace.evGx[130]*acadoWorkspace.x[1] + acadoWorkspace.evGx[131]*acadoWorkspace.x[2] + acadoWorkspace.d[43]; acadoVariables.x[47] += + acadoWorkspace.evGx[132]*acadoWorkspace.x[0] + acadoWorkspace.evGx[133]*acadoWorkspace.x[1] + acadoWorkspace.evGx[134]*acadoWorkspace.x[2] + acadoWorkspace.d[44]; acadoVariables.x[48] += + acadoWorkspace.evGx[135]*acadoWorkspace.x[0] + acadoWorkspace.evGx[136]*acadoWorkspace.x[1] + acadoWorkspace.evGx[137]*acadoWorkspace.x[2] + acadoWorkspace.d[45]; acadoVariables.x[49] += + acadoWorkspace.evGx[138]*acadoWorkspace.x[0] + acadoWorkspace.evGx[139]*acadoWorkspace.x[1] + acadoWorkspace.evGx[140]*acadoWorkspace.x[2] + acadoWorkspace.d[46]; acadoVariables.x[50] += + acadoWorkspace.evGx[141]*acadoWorkspace.x[0] + acadoWorkspace.evGx[142]*acadoWorkspace.x[1] + acadoWorkspace.evGx[143]*acadoWorkspace.x[2] + acadoWorkspace.d[47]; acadoVariables.x[51] += + acadoWorkspace.evGx[144]*acadoWorkspace.x[0] + acadoWorkspace.evGx[145]*acadoWorkspace.x[1] + acadoWorkspace.evGx[146]*acadoWorkspace.x[2] + acadoWorkspace.d[48]; acadoVariables.x[52] += + acadoWorkspace.evGx[147]*acadoWorkspace.x[0] + acadoWorkspace.evGx[148]*acadoWorkspace.x[1] + acadoWorkspace.evGx[149]*acadoWorkspace.x[2] + acadoWorkspace.d[49]; acadoVariables.x[53] += + acadoWorkspace.evGx[150]*acadoWorkspace.x[0] + acadoWorkspace.evGx[151]*acadoWorkspace.x[1] + acadoWorkspace.evGx[152]*acadoWorkspace.x[2] + acadoWorkspace.d[50]; acadoVariables.x[54] += + acadoWorkspace.evGx[153]*acadoWorkspace.x[0] + acadoWorkspace.evGx[154]*acadoWorkspace.x[1] + acadoWorkspace.evGx[155]*acadoWorkspace.x[2] + acadoWorkspace.d[51]; acadoVariables.x[55] += + acadoWorkspace.evGx[156]*acadoWorkspace.x[0] + acadoWorkspace.evGx[157]*acadoWorkspace.x[1] + acadoWorkspace.evGx[158]*acadoWorkspace.x[2] + acadoWorkspace.d[52]; acadoVariables.x[56] += + acadoWorkspace.evGx[159]*acadoWorkspace.x[0] + acadoWorkspace.evGx[160]*acadoWorkspace.x[1] + acadoWorkspace.evGx[161]*acadoWorkspace.x[2] + acadoWorkspace.d[53]; acadoVariables.x[57] += + acadoWorkspace.evGx[162]*acadoWorkspace.x[0] + acadoWorkspace.evGx[163]*acadoWorkspace.x[1] + acadoWorkspace.evGx[164]*acadoWorkspace.x[2] + acadoWorkspace.d[54]; acadoVariables.x[58] += + acadoWorkspace.evGx[165]*acadoWorkspace.x[0] + acadoWorkspace.evGx[166]*acadoWorkspace.x[1] + acadoWorkspace.evGx[167]*acadoWorkspace.x[2] + acadoWorkspace.d[55]; acadoVariables.x[59] += + acadoWorkspace.evGx[168]*acadoWorkspace.x[0] + acadoWorkspace.evGx[169]*acadoWorkspace.x[1] + acadoWorkspace.evGx[170]*acadoWorkspace.x[2] + acadoWorkspace.d[56]; acadoVariables.x[60] += + acadoWorkspace.evGx[171]*acadoWorkspace.x[0] + acadoWorkspace.evGx[172]*acadoWorkspace.x[1] + acadoWorkspace.evGx[173]*acadoWorkspace.x[2] + acadoWorkspace.d[57]; acadoVariables.x[61] += + acadoWorkspace.evGx[174]*acadoWorkspace.x[0] + acadoWorkspace.evGx[175]*acadoWorkspace.x[1] + acadoWorkspace.evGx[176]*acadoWorkspace.x[2] + acadoWorkspace.d[58]; acadoVariables.x[62] += + acadoWorkspace.evGx[177]*acadoWorkspace.x[0] + acadoWorkspace.evGx[178]*acadoWorkspace.x[1] + acadoWorkspace.evGx[179]*acadoWorkspace.x[2] + acadoWorkspace.d[59]; acado_multEDu( acadoWorkspace.E, &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 3 ]) ); acado_multEDu( &(acadoWorkspace.E[ 3 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 6 ]) ); acado_multEDu( &(acadoWorkspace.E[ 6 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 6 ]) ); acado_multEDu( &(acadoWorkspace.E[ 9 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 9 ]) ); acado_multEDu( &(acadoWorkspace.E[ 12 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 9 ]) ); acado_multEDu( &(acadoWorkspace.E[ 15 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 9 ]) ); acado_multEDu( &(acadoWorkspace.E[ 18 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 21 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 24 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 27 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 12 ]) ); acado_multEDu( &(acadoWorkspace.E[ 30 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 15 ]) ); acado_multEDu( &(acadoWorkspace.E[ 33 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 15 ]) ); acado_multEDu( &(acadoWorkspace.E[ 36 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 15 ]) ); acado_multEDu( &(acadoWorkspace.E[ 39 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 15 ]) ); acado_multEDu( &(acadoWorkspace.E[ 42 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 15 ]) ); acado_multEDu( &(acadoWorkspace.E[ 45 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 18 ]) ); acado_multEDu( &(acadoWorkspace.E[ 48 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 18 ]) ); acado_multEDu( &(acadoWorkspace.E[ 51 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 18 ]) ); acado_multEDu( &(acadoWorkspace.E[ 54 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 18 ]) ); acado_multEDu( &(acadoWorkspace.E[ 57 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 18 ]) ); acado_multEDu( &(acadoWorkspace.E[ 60 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 18 ]) ); acado_multEDu( &(acadoWorkspace.E[ 63 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 66 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 69 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 72 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 75 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 78 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 81 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 21 ]) ); acado_multEDu( &(acadoWorkspace.E[ 84 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 87 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 90 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 93 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 96 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 99 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 102 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 105 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 24 ]) ); acado_multEDu( &(acadoWorkspace.E[ 108 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 111 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 114 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 117 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 120 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 123 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 126 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 129 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 132 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 27 ]) ); acado_multEDu( &(acadoWorkspace.E[ 135 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 138 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 141 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 144 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 147 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 150 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 153 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 156 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 159 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 162 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 30 ]) ); acado_multEDu( &(acadoWorkspace.E[ 165 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 168 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 171 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 174 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 177 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 180 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 183 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 186 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 189 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 192 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 195 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 33 ]) ); acado_multEDu( &(acadoWorkspace.E[ 198 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 201 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 204 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 207 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 210 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 213 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 216 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 219 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 222 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 225 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 228 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 231 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 36 ]) ); acado_multEDu( &(acadoWorkspace.E[ 234 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 237 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 240 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 243 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 246 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 249 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 252 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 255 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 258 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 261 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 264 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 267 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 270 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 39 ]) ); acado_multEDu( &(acadoWorkspace.E[ 273 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 276 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 279 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 282 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 285 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 288 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 291 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 294 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 297 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 300 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 303 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 306 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 309 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 312 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 42 ]) ); acado_multEDu( &(acadoWorkspace.E[ 315 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 318 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 321 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 324 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 327 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 330 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 333 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 336 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 339 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 342 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 345 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 348 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 351 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 354 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 357 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 45 ]) ); acado_multEDu( &(acadoWorkspace.E[ 360 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 363 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 366 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 369 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 372 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 375 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 378 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 381 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 384 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 387 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 390 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 393 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 396 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 399 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 402 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 405 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 48 ]) ); acado_multEDu( &(acadoWorkspace.E[ 408 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 411 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 414 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 417 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 420 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 423 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 426 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 429 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 432 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 435 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 438 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 441 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 444 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 447 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 450 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 453 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 456 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 51 ]) ); acado_multEDu( &(acadoWorkspace.E[ 459 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 462 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 465 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 468 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 471 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 474 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 477 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 480 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 483 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 486 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 489 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 492 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 495 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 498 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 501 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 504 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 507 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 510 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 54 ]) ); acado_multEDu( &(acadoWorkspace.E[ 513 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 516 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 519 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 522 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 525 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 528 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 531 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 534 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 537 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 540 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 543 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 546 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 549 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 552 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 555 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 558 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 561 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 564 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 567 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 57 ]) ); acado_multEDu( &(acadoWorkspace.E[ 570 ]), &(acadoWorkspace.x[ 3 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 573 ]), &(acadoWorkspace.x[ 4 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 576 ]), &(acadoWorkspace.x[ 5 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 579 ]), &(acadoWorkspace.x[ 6 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 582 ]), &(acadoWorkspace.x[ 7 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 585 ]), &(acadoWorkspace.x[ 8 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 588 ]), &(acadoWorkspace.x[ 9 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 591 ]), &(acadoWorkspace.x[ 10 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 594 ]), &(acadoWorkspace.x[ 11 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 597 ]), &(acadoWorkspace.x[ 12 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 600 ]), &(acadoWorkspace.x[ 13 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 603 ]), &(acadoWorkspace.x[ 14 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 606 ]), &(acadoWorkspace.x[ 15 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 609 ]), &(acadoWorkspace.x[ 16 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 612 ]), &(acadoWorkspace.x[ 17 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 615 ]), &(acadoWorkspace.x[ 18 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 618 ]), &(acadoWorkspace.x[ 19 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 621 ]), &(acadoWorkspace.x[ 20 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 624 ]), &(acadoWorkspace.x[ 21 ]), &(acadoVariables.x[ 60 ]) ); acado_multEDu( &(acadoWorkspace.E[ 627 ]), &(acadoWorkspace.x[ 22 ]), &(acadoVariables.x[ 60 ]) ); } int acado_preparationStep( double TR ) { int ret; ret = acado_modelSimulation(); acado_evaluateObjective( TR ); acado_condensePrep( ); return ret; } int acado_feedbackStep( ) { int tmp; acado_condenseFdb( ); tmp = acado_solve( ); acado_expand( ); return tmp; } int acado_initializeSolver( ) { int ret; /* This is a function which must be called once before any other function call! */ ret = 0; memset(&acadoWorkspace, 0, sizeof( acadoWorkspace )); return ret; } void acado_initializeNodesByForwardSimulation( ) { int index; for (index = 0; index < 20; ++index) { acadoWorkspace.state[0] = acadoVariables.x[index * 3]; acadoWorkspace.state[1] = acadoVariables.x[index * 3 + 1]; acadoWorkspace.state[2] = acadoVariables.x[index * 3 + 2]; acadoWorkspace.state[15] = acadoVariables.u[index]; acadoWorkspace.state[16] = acadoVariables.od[index * 2]; acadoWorkspace.state[17] = acadoVariables.od[index * 2 + 1]; acado_integrate(acadoWorkspace.state, index == 0, index); acadoVariables.x[index * 3 + 3] = acadoWorkspace.state[0]; acadoVariables.x[index * 3 + 4] = acadoWorkspace.state[1]; acadoVariables.x[index * 3 + 5] = acadoWorkspace.state[2]; } } void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ) { int index; for (index = 0; index < 20; ++index) { acadoVariables.x[index * 3] = acadoVariables.x[index * 3 + 3]; acadoVariables.x[index * 3 + 1] = acadoVariables.x[index * 3 + 4]; acadoVariables.x[index * 3 + 2] = acadoVariables.x[index * 3 + 5]; } if (strategy == 1 && xEnd != 0) { acadoVariables.x[60] = xEnd[0]; acadoVariables.x[61] = xEnd[1]; acadoVariables.x[62] = xEnd[2]; } else if (strategy == 2) { acadoWorkspace.state[0] = acadoVariables.x[60]; acadoWorkspace.state[1] = acadoVariables.x[61]; acadoWorkspace.state[2] = acadoVariables.x[62]; if (uEnd != 0) { acadoWorkspace.state[15] = uEnd[0]; } else { acadoWorkspace.state[15] = acadoVariables.u[19]; } acadoWorkspace.state[16] = acadoVariables.od[40]; acadoWorkspace.state[17] = acadoVariables.od[41]; acado_integrate(acadoWorkspace.state, 1, 19); acadoVariables.x[60] = acadoWorkspace.state[0]; acadoVariables.x[61] = acadoWorkspace.state[1]; acadoVariables.x[62] = acadoWorkspace.state[2]; } } void acado_shiftControls( real_t* const uEnd ) { int index; for (index = 0; index < 19; ++index) { acadoVariables.u[index] = acadoVariables.u[index + 1]; } if (uEnd != 0) { acadoVariables.u[19] = uEnd[0]; } } real_t acado_getKKT( ) { real_t kkt; int index; real_t prd; kkt = + acadoWorkspace.g[0]*acadoWorkspace.x[0] + acadoWorkspace.g[1]*acadoWorkspace.x[1] + acadoWorkspace.g[2]*acadoWorkspace.x[2] + acadoWorkspace.g[3]*acadoWorkspace.x[3] + acadoWorkspace.g[4]*acadoWorkspace.x[4] + acadoWorkspace.g[5]*acadoWorkspace.x[5] + acadoWorkspace.g[6]*acadoWorkspace.x[6] + acadoWorkspace.g[7]*acadoWorkspace.x[7] + acadoWorkspace.g[8]*acadoWorkspace.x[8] + acadoWorkspace.g[9]*acadoWorkspace.x[9] + acadoWorkspace.g[10]*acadoWorkspace.x[10] + acadoWorkspace.g[11]*acadoWorkspace.x[11] + acadoWorkspace.g[12]*acadoWorkspace.x[12] + acadoWorkspace.g[13]*acadoWorkspace.x[13] + acadoWorkspace.g[14]*acadoWorkspace.x[14] + acadoWorkspace.g[15]*acadoWorkspace.x[15] + acadoWorkspace.g[16]*acadoWorkspace.x[16] + acadoWorkspace.g[17]*acadoWorkspace.x[17] + acadoWorkspace.g[18]*acadoWorkspace.x[18] + acadoWorkspace.g[19]*acadoWorkspace.x[19] + acadoWorkspace.g[20]*acadoWorkspace.x[20] + acadoWorkspace.g[21]*acadoWorkspace.x[21] + acadoWorkspace.g[22]*acadoWorkspace.x[22]; kkt = fabs( kkt ); for (index = 0; index < 23; ++index) { prd = acadoWorkspace.y[index]; if (prd > 1e-12) kkt += fabs(acadoWorkspace.lb[index] * prd); else if (prd < -1e-12) kkt += fabs(acadoWorkspace.ub[index] * prd); } for (index = 0; index < 20; ++index) { prd = acadoWorkspace.y[index + 23]; if (prd > 1e-12) kkt += fabs(acadoWorkspace.lbA[index] * prd); else if (prd < -1e-12) kkt += fabs(acadoWorkspace.ubA[index] * prd); } return kkt; } real_t acado_getObjective( TR ) { real_t objVal; int lRun1; /** Row vector of size: 4 */ real_t tmpDy[ 4 ]; /** Row vector of size: 3 */ real_t tmpDyN[ 3 ]; for (lRun1 = 0; lRun1 < 20; ++lRun1) { acadoWorkspace.objValueIn[0] = acadoVariables.x[lRun1 * 3]; acadoWorkspace.objValueIn[1] = acadoVariables.x[lRun1 * 3 + 1]; acadoWorkspace.objValueIn[2] = acadoVariables.x[lRun1 * 3 + 2]; acadoWorkspace.objValueIn[3] = acadoVariables.u[lRun1]; acadoWorkspace.objValueIn[4] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.objValueIn[5] = acadoVariables.od[lRun1 * 2 + 1]; acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut, TR ); acadoWorkspace.Dy[lRun1 * 4] = acadoWorkspace.objValueOut[0] - acadoVariables.y[lRun1 * 4]; acadoWorkspace.Dy[lRun1 * 4 + 1] = acadoWorkspace.objValueOut[1] - acadoVariables.y[lRun1 * 4 + 1]; acadoWorkspace.Dy[lRun1 * 4 + 2] = acadoWorkspace.objValueOut[2] - acadoVariables.y[lRun1 * 4 + 2]; acadoWorkspace.Dy[lRun1 * 4 + 3] = acadoWorkspace.objValueOut[3] - acadoVariables.y[lRun1 * 4 + 3]; } acadoWorkspace.objValueIn[0] = acadoVariables.x[60]; acadoWorkspace.objValueIn[1] = acadoVariables.x[61]; acadoWorkspace.objValueIn[2] = acadoVariables.x[62]; acadoWorkspace.objValueIn[3] = acadoVariables.od[40]; acadoWorkspace.objValueIn[4] = acadoVariables.od[41]; acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut, TR ); acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0] - acadoVariables.yN[0]; acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1] - acadoVariables.yN[1]; acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2] - acadoVariables.yN[2]; objVal = 0.0000000000000000e+00; for (lRun1 = 0; lRun1 < 20; ++lRun1) { tmpDy[0] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 4] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 8] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 12]; tmpDy[1] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16 + 1] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 5] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 9] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 13]; tmpDy[2] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16 + 2] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 6] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 10] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 14]; tmpDy[3] = + acadoWorkspace.Dy[lRun1 * 4]*acadoVariables.W[lRun1 * 16 + 3] + acadoWorkspace.Dy[lRun1 * 4 + 1]*acadoVariables.W[lRun1 * 16 + 7] + acadoWorkspace.Dy[lRun1 * 4 + 2]*acadoVariables.W[lRun1 * 16 + 11] + acadoWorkspace.Dy[lRun1 * 4 + 3]*acadoVariables.W[lRun1 * 16 + 15]; objVal += + acadoWorkspace.Dy[lRun1 * 4]*tmpDy[0] + acadoWorkspace.Dy[lRun1 * 4 + 1]*tmpDy[1] + acadoWorkspace.Dy[lRun1 * 4 + 2]*tmpDy[2] + acadoWorkspace.Dy[lRun1 * 4 + 3]*tmpDy[3]; } tmpDyN[0] = + acadoWorkspace.DyN[0]*acadoVariables.WN[0] + acadoWorkspace.DyN[1]*acadoVariables.WN[3] + acadoWorkspace.DyN[2]*acadoVariables.WN[6]; tmpDyN[1] = + acadoWorkspace.DyN[0]*acadoVariables.WN[1] + acadoWorkspace.DyN[1]*acadoVariables.WN[4] + acadoWorkspace.DyN[2]*acadoVariables.WN[7]; tmpDyN[2] = + acadoWorkspace.DyN[0]*acadoVariables.WN[2] + acadoWorkspace.DyN[1]*acadoVariables.WN[5] + acadoWorkspace.DyN[2]*acadoVariables.WN[8]; objVal += + acadoWorkspace.DyN[0]*tmpDyN[0] + acadoWorkspace.DyN[1]*tmpDyN[1] + acadoWorkspace.DyN[2]*tmpDyN[2]; objVal *= 0.5; return objVal; } ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/libmpc_py.py ================================================ import os from cffi import FFI from common.ffi_wrapper import suffix mpc_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) def _get_libmpc(mpc_id): libmpc_fn = os.path.join(mpc_dir, "libmpc%d%s" % (mpc_id, suffix())) ffi = FFI() ffi.cdef(""" typedef struct { double x_ego, v_ego, a_ego, x_l, v_l, a_l; } state_t; typedef struct { double x_ego[21]; double v_ego[21]; double a_ego[21]; double j_ego[20]; double x_l[21]; double v_l[21]; double a_l[21]; double t[21]; double cost; } log_t; void init(double ttcCost, double distanceCost, double accelerationCost, double jerkCost); void init_with_simulation(double v_ego, double x_l, double v_l, double a_l, double l); void change_tr(double ttcCost, double distanceCost, double accelerationCost, double jerkCost); int run_mpc(state_t * x0, log_t * solution, double l, double a_l_0, double TR); """) return (ffi, ffi.dlopen(libmpc_fn)) mpcs = [_get_libmpc(0), _get_libmpc(1)] def get_libmpc(mpc_id): return mpcs[mpc_id] ================================================ FILE: selfdrive/controls/lib/lead_mpc_lib/longitudinal_mpc.c ================================================ #include "acado_common.h" #include "acado_auxiliary_functions.h" #include #include #define NX ACADO_NX /* Number of differential state variables. */ #define NXA ACADO_NXA /* Number of algebraic variables. */ #define NU ACADO_NU /* Number of control inputs. */ #define NOD ACADO_NOD /* Number of online data values. */ #define NY ACADO_NY /* Number of measurements/references on nodes 0..N - 1. */ #define NYN ACADO_NYN /* Number of measurements/references on node N. */ #define N ACADO_N /* Number of intervals in the horizon. */ ACADOvariables acadoVariables; ACADOworkspace acadoWorkspace; typedef struct { double x_ego, v_ego, a_ego, x_l, v_l, a_l; } state_t; typedef struct { double x_ego[N+1]; double v_ego[N+1]; double a_ego[N+1]; double j_ego[N]; double x_l[N+1]; double v_l[N+1]; double a_l[N+1]; double t[N+1]; double cost; } log_t; void init(double ttcCost, double distanceCost, double accelerationCost, double jerkCost){ acado_initializeSolver(); int i; const int STEP_MULTIPLIER = 3; /* Initialize the states and controls. */ for (i = 0; i < NX * (N + 1); ++i) acadoVariables.x[ i ] = 0.0; for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.0; /* Initialize the measurements/reference. */ for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; /* MPC: initialize the current state feedback. */ for (i = 0; i < NX; ++i) acadoVariables.x0[ i ] = 0.0; // Set weights for (i = 0; i < N; i++) { int f = 1; if (i > 4){ f = STEP_MULTIPLIER; } // Setup diagonal entries acadoVariables.W[NY*NY*i + (NY+1)*0] = ttcCost * f; // exponential cost for time-to-collision (ttc) acadoVariables.W[NY*NY*i + (NY+1)*1] = distanceCost * f; // desired distance acadoVariables.W[NY*NY*i + (NY+1)*2] = accelerationCost * f; // acceleration acadoVariables.W[NY*NY*i + (NY+1)*3] = jerkCost * f; // jerk } acadoVariables.WN[(NYN+1)*0] = ttcCost * STEP_MULTIPLIER; // exponential cost for danger zone acadoVariables.WN[(NYN+1)*1] = distanceCost * STEP_MULTIPLIER; // desired distance acadoVariables.WN[(NYN+1)*2] = accelerationCost * STEP_MULTIPLIER; // acceleration } void change_tr(double ttcCost, double distanceCost, double accelerationCost, double jerkCost){ int i; const int STEP_MULTIPLIER = 3; for (i = 0; i < N; i++) { int f = 1; if (i > 4){ f = STEP_MULTIPLIER; } acadoVariables.W[16 * i + 0] = ttcCost * f; // exponential cost for time-to-collision (ttc) acadoVariables.W[16 * i + 5] = distanceCost * f; // desired distance acadoVariables.W[16 * i + 10] = accelerationCost * f; // acceleration acadoVariables.W[16 * i + 15] = jerkCost * f; // jerk } acadoVariables.WN[0] = ttcCost * STEP_MULTIPLIER; // exponential cost for danger zone acadoVariables.WN[4] = distanceCost * STEP_MULTIPLIER; // desired distance acadoVariables.WN[8] = accelerationCost * STEP_MULTIPLIER; // acceleration } void init_with_simulation(double v_ego, double x_l_0, double v_l_0, double a_l_0, double l){ int i; double x_l = x_l_0; double v_l = v_l_0; double a_l = a_l_0; double x_ego = 0.0; double a_ego = -(v_ego - v_l) * (v_ego - v_l) / (2.0 * x_l + 0.01) + a_l; if (a_ego > 0){ a_ego = 0.0; } double dt = 0.2; double t = 0.; for (i = 0; i < N + 1; ++i){ if (i > 4){ dt = 0.6; } /* printf("%.2f\t%.2f\t%.2f\t%.2f\n", t, x_ego, v_ego, a_l); */ acadoVariables.x[i*NX] = x_ego; acadoVariables.x[i*NX+1] = v_ego; acadoVariables.x[i*NX+2] = a_ego; v_ego += a_ego * dt; if (v_ego <= 0.0) { v_ego = 0.0; a_ego = 0.0; } x_ego += v_ego * dt; t += dt; } for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.0; for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; } int run_mpc(state_t * x0, log_t * solution, double l, double a_l_0, double TR){ // Calculate lead vehicle predictions int i; double t = 0.; double dt = 0.2; double x_l = x0->x_l; double v_l = x0->v_l; double a_l = a_l_0; /* printf("t\tx_l\t_v_l\t_al\n"); */ for (i = 0; i < N + 1; ++i){ if (i > 4){ dt = 0.6; } /* printf("%.2f\t%.2f\t%.2f\t%.2f\n", t, x_l, v_l, a_l); */ acadoVariables.od[i*NOD] = x_l; acadoVariables.od[i*NOD+1] = v_l; solution->x_l[i] = x_l; solution->v_l[i] = v_l; solution->a_l[i] = a_l; solution->t[i] = t; a_l = a_l_0 * exp(-l * t * t / 2); x_l += v_l * dt; v_l += a_l * dt; if (v_l < 0.0){ a_l = 0.0; v_l = 0.0; } t += dt; } acadoVariables.x[0] = acadoVariables.x0[0] = x0->x_ego; acadoVariables.x[1] = acadoVariables.x0[1] = x0->v_ego; acadoVariables.x[2] = acadoVariables.x0[2] = x0->a_ego; acado_preparationStep(TR); acado_feedbackStep(); for (i = 0; i <= N; i++){ solution->x_ego[i] = acadoVariables.x[i*NX]; solution->v_ego[i] = acadoVariables.x[i*NX+1]; solution->a_ego[i] = acadoVariables.x[i*NX+2]; if (i < N){ solution->j_ego[i] = acadoVariables.u[i]; } } solution->cost = acado_getObjective(TR); // Dont shift states here. Current solution is closer to next timestep than if // we shift by 0.2 seconds. return acado_getNWSR(); } ================================================ FILE: selfdrive/controls/lib/limits_long_mpc.py ================================================ import numpy as np import math from selfdrive.swaglog import cloudlog from common.realtime import sec_since_boot from selfdrive.controls.lib.longitudinal_mpc_lib import libmpc_py from selfdrive.controls.lib.drive_helpers import LON_MPC_N from selfdrive.modeld.constants import T_IDXS class LimitsLongitudinalMpc(): def __init__(self): self.reset_mpc() self.last_cloudlog_t = 0.0 self.ts = list(range(10)) self.status = True self.min_a = -1.2 self.max_a = 1.2 def reset_mpc(self): self.libmpc = libmpc_py.libmpc self.libmpc.init(0.0, 10.0, 0.0, 50.0, 10000.0) self.mpc_solution = libmpc_py.ffi.new("log_t *") self.cur_state = libmpc_py.ffi.new("state_t *") self.cur_state[0].x_ego = 0 self.cur_state[0].v_ego = 0 self.cur_state[0].a_ego = 0 self.v_solution = [0.0 for i in range(len(T_IDXS))] self.a_solution = [0.0 for i in range(len(T_IDXS))] self.j_solution = [0.0 for i in range(len(T_IDXS) - 1)] def set_accel_limits(self, min_a, max_a): self.min_a = min_a self.max_a = max_a def set_cur_state(self, v, a): v_safe = max(v, 1e-2) a_safe = min(a, self.max_a - 1e-2) a_safe = max(a_safe, self.min_a + 1e-2) self.cur_state[0].x_ego = 0.0 self.cur_state[0].v_ego = v_safe self.cur_state[0].a_ego = a_safe def update(self, carstate, model, v_cruise, a_target, active): t = np.array(T_IDXS[:LON_MPC_N + 1]) v_ego = self.cur_state[0].v_ego # If active, provide targets for a constant acceleration following a_target # otherwise just target cruising at current speed if active: poss = v_ego * t + a_target * t**2 / 2. speeds = v_ego + a_target * t accels = a_target + np.ones(LON_MPC_N + 1) else: poss = v_ego * t speeds = v_ego * np.ones(LON_MPC_N + 1) accels = np.zeros(LON_MPC_N + 1) # Calculate mpc self.libmpc.run_mpc(self.cur_state, self.mpc_solution, list(poss), list(speeds), list(accels), self.min_a, self.max_a) self.v_solution = list(self.mpc_solution.v_ego) self.a_solution = list(self.mpc_solution.a_ego) self.j_solution = list(self.mpc_solution.j_ego) # Reset if NaN or goes through lead car nans = any(math.isnan(x) for x in self.mpc_solution[0].v_ego) t = sec_since_boot() if nans: if t > self.last_cloudlog_t + 5.0: self.last_cloudlog_t = t cloudlog.warning("Longitudinal model mpc reset - nans") self.reset_mpc() ================================================ FILE: selfdrive/controls/lib/long_mpc.py ================================================ import numpy as np import math from selfdrive.swaglog import cloudlog from common.realtime import sec_since_boot from selfdrive.controls.lib.longitudinal_mpc_lib import libmpc_py from selfdrive.controls.lib.drive_helpers import LON_MPC_N from selfdrive.modeld.constants import T_IDXS class LongitudinalMpc(): def __init__(self): self.reset_mpc() self.last_cloudlog_t = 0.0 self.ts = list(range(10)) self.status = True self.min_a = -1.2 self.max_a = 1.2 def reset_mpc(self): self.libmpc = libmpc_py.libmpc self.libmpc.init(0.0, 1.0, 0.0, 50.0, 10000.0) self.mpc_solution = libmpc_py.ffi.new("log_t *") self.cur_state = libmpc_py.ffi.new("state_t *") self.cur_state[0].x_ego = 0 self.cur_state[0].v_ego = 0 self.cur_state[0].a_ego = 0 self.v_solution = [0.0 for i in range(len(T_IDXS))] self.a_solution = [0.0 for i in range(len(T_IDXS))] self.j_solution = [0.0 for i in range(len(T_IDXS)-1)] def set_accel_limits(self, min_a, max_a): self.min_a = min_a self.max_a = max_a def set_cur_state(self, v, a): v_safe = max(v, 1e-2) a_safe = min(a, self.max_a - 1e-2) a_safe = max(a_safe, self.min_a + 1e-2) self.cur_state[0].x_ego = 0.0 self.cur_state[0].v_ego = v_safe self.cur_state[0].a_ego = a_safe def update(self, carstate, radarstate, v_cruise, a_target, active): v_cruise_clipped = np.clip(v_cruise, self.cur_state[0].v_ego - 10., self.cur_state[0].v_ego + 10.0) poss = v_cruise_clipped * np.array(T_IDXS[:LON_MPC_N+1]) speeds = v_cruise_clipped * np.ones(LON_MPC_N+1) accels = np.zeros(LON_MPC_N+1) self.update_with_xva(poss, speeds, accels) def update_with_xva(self, poss, speeds, accels): # Calculate mpc self.libmpc.run_mpc(self.cur_state, self.mpc_solution, list(poss), list(speeds), list(accels), self.min_a, self.max_a) self.v_solution = list(self.mpc_solution.v_ego) self.a_solution = list(self.mpc_solution.a_ego) self.j_solution = list(self.mpc_solution.j_ego) # Reset if NaN or goes through lead car nans = any(math.isnan(x) for x in self.mpc_solution[0].v_ego) t = sec_since_boot() if nans: if t > self.last_cloudlog_t + 5.0: self.last_cloudlog_t = t cloudlog.warning("Longitudinal model mpc reset - nans") self.reset_mpc() ================================================ FILE: selfdrive/controls/lib/longcontrol.py ================================================ from cereal import car from common.numpy_fast import clip, interp from selfdrive.controls.lib.pid import PIController from selfdrive.controls.lib.drive_helpers import CONTROL_N from selfdrive.modeld.constants import T_IDXS LongCtrlState = car.CarControl.Actuators.LongControlState STOPPING_EGO_SPEED = 0.5 STOPPING_TARGET_SPEED_OFFSET = 0.01 STARTING_TARGET_SPEED = 0.5 DECEL_THRESHOLD_TO_PID = 0.8 DECEL_STOPPING_TARGET = 2.0 # apply at least this amount of brake to maintain the vehicle stationary RATE = 100.0 # As per ISO 15622:2018 for all speeds ACCEL_MIN_ISO = -3.5 # m/s^2 ACCEL_MAX_ISO = 2.0 # m/s^2 # TODO this logic isn't really car independent, does not belong here def long_control_state_trans(active, long_control_state, v_ego, v_target, v_pid, output_accel, brake_pressed, cruise_standstill, min_speed_can): """Update longitudinal control state machine""" stopping_target_speed = min_speed_can + STOPPING_TARGET_SPEED_OFFSET stopping_condition = (v_ego < 2.0 and cruise_standstill) or \ (v_ego < STOPPING_EGO_SPEED and ((v_pid < stopping_target_speed and v_target < stopping_target_speed) or brake_pressed)) starting_condition = v_target > STARTING_TARGET_SPEED and not cruise_standstill if not active: long_control_state = LongCtrlState.off else: if long_control_state == LongCtrlState.off: if active: long_control_state = LongCtrlState.pid elif long_control_state == LongCtrlState.pid: if stopping_condition: long_control_state = LongCtrlState.stopping elif long_control_state == LongCtrlState.stopping: if starting_condition: long_control_state = LongCtrlState.starting elif long_control_state == LongCtrlState.starting: if stopping_condition: long_control_state = LongCtrlState.stopping elif output_accel >= -DECEL_THRESHOLD_TO_PID: long_control_state = LongCtrlState.pid return long_control_state class LongControl(): def __init__(self, CP): self.long_control_state = LongCtrlState.off # initialized to off self.pid = PIController((CP.longitudinalTuning.kpBP, CP.longitudinalTuning.kpV), (CP.longitudinalTuning.kiBP, CP.longitudinalTuning.kiV), rate=RATE, sat_limit=0.8) self.v_pid = 0.0 self.last_output_accel = 0.0 def reset(self, v_pid): """Reset PID controller and change setpoint""" self.pid.reset() self.v_pid = v_pid def update(self, active, CS, CP, long_plan, accel_limits): """Update longitudinal control. This updates the state machine and runs a PID loop""" # Interp control trajectory # TODO estimate car specific lag, use .15s for now if len(long_plan.speeds) == CONTROL_N: v_target = interp(CP.longitudinalActuatorDelay, T_IDXS[:CONTROL_N], long_plan.speeds) v_target_future = long_plan.speeds[-1] a_target = 2 * (v_target - long_plan.speeds[0])/CP.longitudinalActuatorDelay - long_plan.accels[0] else: v_target = 0.0 v_target_future = 0.0 a_target = 0.0 # TODO: This check is not complete and needs to be enforced by MPC a_target = clip(a_target, ACCEL_MIN_ISO, ACCEL_MAX_ISO) self.pid.neg_limit = accel_limits[0] self.pid.pos_limit = accel_limits[1] # Update state machine output_accel = self.last_output_accel self.long_control_state = long_control_state_trans(active, self.long_control_state, CS.vEgo, v_target_future, self.v_pid, output_accel, CS.brakePressed, CS.cruiseState.standstill, CP.minSpeedCan) v_ego_pid = max(CS.vEgo, CP.minSpeedCan) # Without this we get jumps, CAN bus reports 0 when speed < 0.3 if self.long_control_state == LongCtrlState.off or CS.gasPressed: self.reset(v_ego_pid) output_accel = 0. # tracking objects and driving elif self.long_control_state == LongCtrlState.pid: self.v_pid = v_target # Toyota starts braking more when it thinks you want to stop # Freeze the integrator so we don't accelerate to compensate, and don't allow positive acceleration prevent_overshoot = not CP.stoppingControl and CS.vEgo < 1.5 and v_target_future < 0.7 deadzone = interp(v_ego_pid, CP.longitudinalTuning.deadzoneBP, CP.longitudinalTuning.deadzoneV) freeze_integrator = prevent_overshoot output_accel = self.pid.update(self.v_pid, v_ego_pid, speed=v_ego_pid, deadzone=deadzone, feedforward=a_target, freeze_integrator=freeze_integrator) if prevent_overshoot: output_accel = min(output_accel, 0.0) # Intention is to stop, switch to a different brake control until we stop elif self.long_control_state == LongCtrlState.stopping: # Keep applying brakes until the car is stopped if not CS.standstill or output_accel > -DECEL_STOPPING_TARGET: output_accel -= CP.stoppingDecelRate / RATE output_accel = clip(output_accel, accel_limits[0], accel_limits[1]) self.reset(CS.vEgo) # Intention is to move again, release brake fast before handing control to PID elif self.long_control_state == LongCtrlState.starting: if output_accel < -DECEL_THRESHOLD_TO_PID: output_accel += CP.startingAccelRate / RATE self.reset(CS.vEgo) self.last_output_accel = output_accel final_accel = clip(output_accel, accel_limits[0], accel_limits[1]) return final_accel, v_target, a_target ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/.gitignore ================================================ generator lib_qp/ ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/SConscript ================================================ Import('env', 'arch') cpp_path = [ "#", "#selfdrive", "#phonelibs/acado/include", "#phonelibs/acado/include/acado", "#phonelibs/qpoases/INCLUDE", "#phonelibs/qpoases/INCLUDE/EXTRAS", "#phonelibs/qpoases/SRC/", "#phonelibs/qpoases", "lib_mpc_export", ] generated_c = [ 'lib_mpc_export/acado_auxiliary_functions.c', 'lib_mpc_export/acado_qpoases_interface.cpp', 'lib_mpc_export/acado_integrator.c', 'lib_mpc_export/acado_solver.c', ] generated_h = [ 'lib_mpc_export/acado_common.h', 'lib_mpc_export/acado_auxiliary_functions.h', 'lib_mpc_export/acado_qpoases_interface.hpp', ] interface_dir = Dir('lib_mpc_export') SConscript(['#phonelibs/qpoases/SConscript'], variant_dir='lib_qp', exports=['interface_dir']) if GetOption('mpc_generate'): generator_cpp = File('generator.cpp') acado_libs = [File(f"#phonelibs/acado/{arch}/lib/libacado_toolkit.a"), File(f"#phonelibs/acado/{arch}/lib/libacado_casadi.a"), File(f"#phonelibs/acado/{arch}/lib/libacado_csparse.a")] generator = env.Program('generator', generator_cpp, LIBS=acado_libs, CPPPATH=cpp_path, CCFLAGS=env['CCFLAGS'] + ["-Wno-deprecated", "-Wno-overloaded-shift-op-parentheses"]) cmd = f"cd {Dir('.').get_abspath()} && {generator[0].get_abspath()}" env.Command(generated_c + generated_h, generator, cmd) mpc_files = ["longitudinal_mpc.c"] + generated_c env.SharedLibrary('mpc', mpc_files, LIBS=['m', 'qpoases'], LIBPATH=['lib_qp'], CPPPATH=cpp_path) ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/__init__.py ================================================ ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/generator.cpp ================================================ #include #include "selfdrive/common/modeldata.h" using namespace std; int main( ) { USING_NAMESPACE_ACADO DifferentialEquation f; DifferentialState x_ego, v_ego, a_ego; DifferentialState dummy_0; OnlineData min_a, max_a; Control j_ego, accel_slack; // Equations of motion f << dot(x_ego) == v_ego; f << dot(v_ego) == a_ego; f << dot(a_ego) == j_ego; f << dot(dummy_0) == accel_slack; // Running cost Function h; h << x_ego; h << v_ego; h << a_ego; h << j_ego; h << accel_slack; // Weights are defined in mpc. BMatrix Q(5,5); Q.setAll(true); // Terminal cost Function hN; hN << x_ego; hN << v_ego; hN << a_ego; // Weights are defined in mpc. BMatrix QN(3,3); QN.setAll(true); double T_IDXS_ARR[LON_MPC_N + 1]; memcpy(T_IDXS_ARR, T_IDXS, (LON_MPC_N + 1) * sizeof(double)); Grid times(LON_MPC_N + 1, T_IDXS_ARR); OCP ocp(times); ocp.subjectTo(f); ocp.minimizeLSQ(Q, h); ocp.minimizeLSQEndTerm(QN, hN); ocp.subjectTo( 0.0 <= v_ego); ocp.subjectTo( 0.0 <= a_ego - min_a + accel_slack); ocp.subjectTo( a_ego - max_a + accel_slack <= 0.0); ocp.setNOD(2); OCPexport mpc(ocp); mpc.set( HESSIAN_APPROXIMATION, GAUSS_NEWTON ); mpc.set( DISCRETIZATION_TYPE, MULTIPLE_SHOOTING ); mpc.set( INTEGRATOR_TYPE, INT_RK4 ); mpc.set( NUM_INTEGRATOR_STEPS, 1000); mpc.set( MAX_NUM_QP_ITERATIONS, 50); mpc.set( CG_USE_VARIABLE_WEIGHTING_MATRIX, YES); mpc.set( SPARSE_QP_SOLUTION, CONDENSING ); mpc.set( QP_SOLVER, QP_QPOASES ); mpc.set( HOTSTART_QP, YES ); mpc.set( GENERATE_TEST_FILE, NO); mpc.set( GENERATE_MAKE_FILE, NO ); mpc.set( GENERATE_MATLAB_INTERFACE, NO ); mpc.set( GENERATE_SIMULINK_INTERFACE, NO ); if (mpc.exportCode( "lib_mpc_export" ) != SUCCESSFUL_RETURN) exit( EXIT_FAILURE ); mpc.printDimensionsQP( ); return EXIT_SUCCESS; } ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_auxiliary_functions.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_auxiliary_functions.h" #include real_t* acado_getVariablesX( ) { return acadoVariables.x; } real_t* acado_getVariablesU( ) { return acadoVariables.u; } #if ACADO_NY > 0 real_t* acado_getVariablesY( ) { return acadoVariables.y; } #endif #if ACADO_NYN > 0 real_t* acado_getVariablesYN( ) { return acadoVariables.yN; } #endif real_t* acado_getVariablesX0( ) { #if ACADO_INITIAL_VALUE_FIXED return acadoVariables.x0; #else return 0; #endif } /** Print differential variables. */ void acado_printDifferentialVariables( ) { int i, j; printf("\nDifferential variables:\n[\n"); for (i = 0; i < ACADO_N + 1; ++i) { for (j = 0; j < ACADO_NX; ++j) printf("\t%e", acadoVariables.x[i * ACADO_NX + j]); printf("\n"); } printf("]\n\n"); } /** Print control variables. */ void acado_printControlVariables( ) { int i, j; printf("\nControl variables:\n[\n"); for (i = 0; i < ACADO_N; ++i) { for (j = 0; j < ACADO_NU; ++j) printf("\t%e", acadoVariables.u[i * ACADO_NU + j]); printf("\n"); } printf("]\n\n"); } /** Print ACADO code generation notice. */ void acado_printHeader( ) { printf( "\nACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.\n" "Copyright (C) 2008-2015 by Boris Houska, Hans Joachim Ferreau,\n" "Milan Vukov and Rien Quirynen, KU Leuven.\n" ); printf( "Developed within the Optimization in Engineering Center (OPTEC) under\n" "supervision of Moritz Diehl. All rights reserved.\n\n" "ACADO Toolkit is distributed under the terms of the GNU Lesser\n" "General Public License 3 in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU Lesser General Public License for more details.\n\n" ); } #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) void acado_tic( acado_timer* t ) { QueryPerformanceFrequency(&t->freq); QueryPerformanceCounter(&t->tic); } real_t acado_toc( acado_timer* t ) { QueryPerformanceCounter(&t->toc); return ((t->toc.QuadPart - t->tic.QuadPart) / (real_t)t->freq.QuadPart); } #elif (defined __APPLE__) void acado_tic( acado_timer* t ) { /* read current clock cycles */ t->tic = mach_absolute_time(); } real_t acado_toc( acado_timer* t ) { uint64_t duration; /* elapsed time in clock cycles*/ t->toc = mach_absolute_time(); duration = t->toc - t->tic; /*conversion from clock cycles to nanoseconds*/ mach_timebase_info(&(t->tinfo)); duration *= t->tinfo.numer; duration /= t->tinfo.denom; return (real_t)duration / 1e9; } #else #if __STDC_VERSION__ >= 199901L /* C99 mode */ /* read current time */ void acado_tic( acado_timer* t ) { gettimeofday(&t->tic, 0); } /* return time passed since last call to tic on this timer */ real_t acado_toc( acado_timer* t ) { struct timeval temp; gettimeofday(&t->toc, 0); if ((t->toc.tv_usec - t->tic.tv_usec) < 0) { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; temp.tv_usec = 1000000 + t->toc.tv_usec - t->tic.tv_usec; } else { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; temp.tv_usec = t->toc.tv_usec - t->tic.tv_usec; } return (real_t)temp.tv_sec + (real_t)temp.tv_usec / 1e6; } #else /* ANSI */ /* read current time */ void acado_tic( acado_timer* t ) { clock_gettime(CLOCK_MONOTONIC, &t->tic); } /* return time passed since last call to tic on this timer */ real_t acado_toc( acado_timer* t ) { struct timespec temp; clock_gettime(CLOCK_MONOTONIC, &t->toc); if ((t->toc.tv_nsec - t->tic.tv_nsec) < 0) { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec - 1; temp.tv_nsec = 1000000000+t->toc.tv_nsec - t->tic.tv_nsec; } else { temp.tv_sec = t->toc.tv_sec - t->tic.tv_sec; temp.tv_nsec = t->toc.tv_nsec - t->tic.tv_nsec; } return (real_t)temp.tv_sec + (real_t)temp.tv_nsec / 1e9; } #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || _WIN64) */ #endif ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_auxiliary_functions.h ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef ACADO_AUXILIARY_FUNCTIONS_H #define ACADO_AUXILIARY_FUNCTIONS_H #include "acado_common.h" #ifndef __MATLAB__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __MATLAB__ */ /** Get pointer to the matrix with differential variables. */ real_t* acado_getVariablesX( ); /** Get pointer to the matrix with control variables. */ real_t* acado_getVariablesU( ); #if ACADO_NY > 0 /** Get pointer to the matrix with references/measurements. */ real_t* acado_getVariablesY( ); #endif #if ACADO_NYN > 0 /** Get pointer to the vector with references/measurement on the last node. */ real_t* acado_getVariablesYN( ); #endif /** Get pointer to the current state feedback vector. Only applicable for NMPC. */ real_t* acado_getVariablesX0( ); /** Print differential variables. */ void acado_printDifferentialVariables( ); /** Print control variables. */ void acado_printControlVariables( ); /** Print ACADO code generation notice. */ void acado_printHeader( ); /* * A huge thanks goes to Alexander Domahidi from ETHZ, Switzerland, for * providing us with the following timing routines. */ #if !(defined _DSPACE) #if (defined _WIN32 || defined _WIN64) && !(defined __MINGW32__ || defined __MINGW64__) /* Use Windows QueryPerformanceCounter for timing. */ #include /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { LARGE_INTEGER tic; LARGE_INTEGER toc; LARGE_INTEGER freq; } acado_timer; #elif (defined __APPLE__) #include "unistd.h" #include /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { uint64_t tic; uint64_t toc; mach_timebase_info_data_t tinfo; } acado_timer; #else /* Use POSIX clock_gettime() for timing on non-Windows machines. */ #include #if __STDC_VERSION__ >= 199901L /* C99 mode of operation. */ #include #include typedef struct acado_timer_ { struct timeval tic; struct timeval toc; } acado_timer; #else /* ANSI C */ /** A structure for keeping internal timer data. */ typedef struct acado_timer_ { struct timespec tic; struct timespec toc; } acado_timer; #endif /* __STDC_VERSION__ >= 199901L */ #endif /* (defined _WIN32 || defined _WIN64) */ /** A function for measurement of the current time. */ void acado_tic( acado_timer* t ); /** A function which returns the elapsed time. */ real_t acado_toc( acado_timer* t ); #endif #ifndef __MATLAB__ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* __MATLAB__ */ #endif /* ACADO_AUXILIARY_FUNCTIONS_H */ ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_common.h ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef ACADO_COMMON_H #define ACADO_COMMON_H #include #include #ifndef __MATLAB__ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #endif /* __MATLAB__ */ /** \defgroup ACADO ACADO CGT generated module. */ /** @{ */ /** qpOASES QP solver indicator. */ #define ACADO_QPOASES 0 #define ACADO_QPOASES3 1 /** FORCES QP solver indicator.*/ #define ACADO_FORCES 2 /** qpDUNES QP solver indicator.*/ #define ACADO_QPDUNES 3 /** HPMPC QP solver indicator. */ #define ACADO_HPMPC 4 #define ACADO_GENERIC 5 /** Indicator for determining the QP solver used by the ACADO solver code. */ #define ACADO_QP_SOLVER ACADO_QPOASES #include "acado_qpoases_interface.hpp" /* * Common definitions */ /** User defined block based condensing. */ #define ACADO_BLOCK_CONDENSING 0 /** Compute covariance matrix of the last state estimate. */ #define ACADO_COMPUTE_COVARIANCE_MATRIX 0 /** Flag indicating whether constraint values are hard-coded or not. */ #define ACADO_HARDCODED_CONSTRAINT_VALUES 1 /** Indicator for fixed initial state. */ #define ACADO_INITIAL_STATE_FIXED 1 /** Number of control/estimation intervals. */ #define ACADO_N 32 /** Number of online data values. */ #define ACADO_NOD 2 /** Number of path constraints. */ #define ACADO_NPAC 2 /** Number of control variables. */ #define ACADO_NU 2 /** Number of differential variables. */ #define ACADO_NX 4 /** Number of algebraic variables. */ #define ACADO_NXA 0 /** Number of differential derivative variables. */ #define ACADO_NXD 0 /** Number of references/measurements per node on the first N nodes. */ #define ACADO_NY 5 /** Number of references/measurements on the last (N + 1)st node. */ #define ACADO_NYN 3 /** Total number of QP optimization variables. */ #define ACADO_QP_NV 68 /** Number of Runge-Kutta stages per integration step. */ #define ACADO_RK_NSTAGES 4 /** Providing interface for arrival cost. */ #define ACADO_USE_ARRIVAL_COST 0 /** Indicator for usage of non-hard-coded linear terms in the objective. */ #define ACADO_USE_LINEAR_TERMS 0 /** Indicator for type of fixed weighting matrices. */ #define ACADO_WEIGHTING_MATRICES_TYPE 2 /* * Globally used structure definitions */ /** The structure containing the user data. * * Via this structure the user "communicates" with the solver code. */ typedef struct ACADOvariables_ { int dummy; /** Matrix of size: 33 x 4 (row major format) * * Matrix containing 33 differential variable vectors. */ real_t x[ 132 ]; /** Matrix of size: 32 x 2 (row major format) * * Matrix containing 32 control variable vectors. */ real_t u[ 64 ]; /** Matrix of size: 33 x 2 (row major format) * * Matrix containing 33 online data vectors. */ real_t od[ 66 ]; /** Column vector of size: 160 * * Matrix containing 32 reference/measurement vectors of size 5 for first 32 nodes. */ real_t y[ 160 ]; /** Column vector of size: 3 * * Reference/measurement vector for the 33. node. */ real_t yN[ 3 ]; /** Matrix of size: 160 x 5 (row major format) */ real_t W[ 800 ]; /** Matrix of size: 3 x 3 (row major format) */ real_t WN[ 9 ]; /** Column vector of size: 4 * * Current state feedback vector. */ real_t x0[ 4 ]; } ACADOvariables; /** Private workspace used by the auto-generated code. * * Data members of this structure are private to the solver. * In other words, the user code should not modify values of this * structure. */ typedef struct ACADOworkspace_ { real_t rk_ttt; /** Row vector of size: 32 */ real_t rk_xxx[ 32 ]; /** Matrix of size: 4 x 28 (row major format) */ real_t rk_kkk[ 112 ]; /** Row vector of size: 32 */ real_t state[ 32 ]; /** Column vector of size: 128 */ real_t d[ 128 ]; /** Column vector of size: 160 */ real_t Dy[ 160 ]; /** Column vector of size: 3 */ real_t DyN[ 3 ]; /** Matrix of size: 128 x 4 (row major format) */ real_t evGx[ 512 ]; /** Matrix of size: 128 x 2 (row major format) */ real_t evGu[ 256 ]; /** Row vector of size: 8 */ real_t objValueIn[ 8 ]; /** Row vector of size: 5 */ real_t objValueOut[ 5 ]; /** Matrix of size: 128 x 4 (row major format) */ real_t Q1[ 512 ]; /** Matrix of size: 128 x 5 (row major format) */ real_t Q2[ 640 ]; /** Matrix of size: 64 x 2 (row major format) */ real_t R1[ 128 ]; /** Matrix of size: 64 x 5 (row major format) */ real_t R2[ 320 ]; /** Matrix of size: 128 x 2 (row major format) */ real_t S1[ 256 ]; /** Matrix of size: 4 x 4 (row major format) */ real_t QN1[ 16 ]; /** Matrix of size: 4 x 3 (row major format) */ real_t QN2[ 12 ]; /** Column vector of size: 12 */ real_t conAuxVar[ 12 ]; /** Row vector of size: 8 */ real_t conValueIn[ 8 ]; /** Row vector of size: 14 */ real_t conValueOut[ 14 ]; /** Column vector of size: 64 */ real_t evH[ 64 ]; /** Matrix of size: 64 x 4 (row major format) */ real_t evHx[ 256 ]; /** Matrix of size: 64 x 2 (row major format) */ real_t evHu[ 128 ]; /** Column vector of size: 2 */ real_t evHxd[ 2 ]; /** Column vector of size: 4 */ real_t Dx0[ 4 ]; /** Matrix of size: 4 x 4 (row major format) */ real_t T[ 16 ]; /** Matrix of size: 2112 x 2 (row major format) */ real_t E[ 4224 ]; /** Matrix of size: 2112 x 2 (row major format) */ real_t QE[ 4224 ]; /** Matrix of size: 128 x 4 (row major format) */ real_t QGx[ 512 ]; /** Column vector of size: 128 */ real_t Qd[ 128 ]; /** Column vector of size: 132 */ real_t QDy[ 132 ]; /** Matrix of size: 64 x 4 (row major format) */ real_t H10[ 256 ]; /** Matrix of size: 68 x 68 (row major format) */ real_t H[ 4624 ]; /** Matrix of size: 96 x 68 (row major format) */ real_t A[ 6528 ]; /** Column vector of size: 68 */ real_t g[ 68 ]; /** Column vector of size: 68 */ real_t lb[ 68 ]; /** Column vector of size: 68 */ real_t ub[ 68 ]; /** Column vector of size: 96 */ real_t lbA[ 96 ]; /** Column vector of size: 96 */ real_t ubA[ 96 ]; /** Column vector of size: 68 */ real_t x[ 68 ]; /** Column vector of size: 164 */ real_t y[ 164 ]; } ACADOworkspace; /* * Forward function declarations. */ /** Performs the integration and sensitivity propagation for one shooting interval. * * \param rk_eta Working array to pass the input values and return the results. * \param resetIntegrator The internal memory of the integrator can be reset. * \param rk_index Number of the shooting interval. * * \return Status code of the integrator. */ int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ); /** Export of an ACADO symbolic function. * * \param in Input to the exported function. * \param out Output of the exported function. */ void acado_rhs_forw(const real_t* in, real_t* out); /** Preparation step of the RTI scheme. * * \return Status of the integration module. =0: OK, otherwise the error code. */ int acado_preparationStep( ); /** Feedback/estimation step of the RTI scheme. * * \return Status code of the qpOASES QP solver. */ int acado_feedbackStep( ); /** Solver initialization. Must be called once before any other function call. * * \return =0: OK, otherwise an error code of a QP solver. */ int acado_initializeSolver( ); /** Initialize shooting nodes by a forward simulation starting from the first node. */ void acado_initializeNodesByForwardSimulation( ); /** Shift differential variables vector by one interval. * * \param strategy Shifting strategy: 1. Initialize node 33 with xEnd. 2. Initialize node 33 by forward simulation. * \param xEnd Value for the x vector on the last node. If =0 the old value is used. * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. */ void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ); /** Shift controls vector by one interval. * * \param uEnd Value for the u vector on the second to last node. If =0 the old value is used. */ void acado_shiftControls( real_t* const uEnd ); /** Get the KKT tolerance of the current iterate. * * \return The KKT tolerance value. */ real_t acado_getKKT( ); /** Calculate the objective value. * * \return Value of the objective function. */ real_t acado_getObjective( ); /* * Extern declarations. */ extern ACADOworkspace acadoWorkspace; extern ACADOvariables acadoVariables; /** @} */ #ifndef __MATLAB__ #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ #endif /* __MATLAB__ */ #endif /* ACADO_COMMON_H */ ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_integrator.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_common.h" void acado_rhs_forw(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* u = in + 28; /* Compute outputs: */ out[0] = xd[1]; out[1] = xd[2]; out[2] = u[0]; out[3] = u[1]; out[4] = xd[8]; out[5] = xd[9]; out[6] = xd[10]; out[7] = xd[11]; out[8] = xd[12]; out[9] = xd[13]; out[10] = xd[14]; out[11] = xd[15]; out[12] = (real_t)(0.0000000000000000e+00); out[13] = (real_t)(0.0000000000000000e+00); out[14] = (real_t)(0.0000000000000000e+00); out[15] = (real_t)(0.0000000000000000e+00); out[16] = (real_t)(0.0000000000000000e+00); out[17] = (real_t)(0.0000000000000000e+00); out[18] = (real_t)(0.0000000000000000e+00); out[19] = (real_t)(0.0000000000000000e+00); out[20] = xd[22]; out[21] = xd[23]; out[22] = xd[24]; out[23] = xd[25]; out[24] = (real_t)(1.0000000000000000e+00); out[25] = (real_t)(0.0000000000000000e+00); out[26] = (real_t)(0.0000000000000000e+00); out[27] = (real_t)(1.0000000000000000e+00); } /* Fixed step size:0.01 */ int acado_integrate( real_t* const rk_eta, int resetIntegrator, int rk_index ) { int error; int run1; int numSteps[32] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62}; int numInts = numSteps[rk_index]; acadoWorkspace.rk_ttt = 0.0000000000000000e+00; rk_eta[4] = 1.0000000000000000e+00; rk_eta[5] = 0.0000000000000000e+00; rk_eta[6] = 0.0000000000000000e+00; rk_eta[7] = 0.0000000000000000e+00; rk_eta[8] = 0.0000000000000000e+00; rk_eta[9] = 1.0000000000000000e+00; rk_eta[10] = 0.0000000000000000e+00; rk_eta[11] = 0.0000000000000000e+00; rk_eta[12] = 0.0000000000000000e+00; rk_eta[13] = 0.0000000000000000e+00; rk_eta[14] = 1.0000000000000000e+00; rk_eta[15] = 0.0000000000000000e+00; rk_eta[16] = 0.0000000000000000e+00; rk_eta[17] = 0.0000000000000000e+00; rk_eta[18] = 0.0000000000000000e+00; rk_eta[19] = 1.0000000000000000e+00; rk_eta[20] = 0.0000000000000000e+00; rk_eta[21] = 0.0000000000000000e+00; rk_eta[22] = 0.0000000000000000e+00; rk_eta[23] = 0.0000000000000000e+00; rk_eta[24] = 0.0000000000000000e+00; rk_eta[25] = 0.0000000000000000e+00; rk_eta[26] = 0.0000000000000000e+00; rk_eta[27] = 0.0000000000000000e+00; acadoWorkspace.rk_xxx[28] = rk_eta[28]; acadoWorkspace.rk_xxx[29] = rk_eta[29]; acadoWorkspace.rk_xxx[30] = rk_eta[30]; acadoWorkspace.rk_xxx[31] = rk_eta[31]; for (run1 = 0; run1 < 1; ++run1) { for(run1 = 0; run1 < numInts; run1++ ) { acadoWorkspace.rk_xxx[0] = + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + rk_eta[23]; acadoWorkspace.rk_xxx[24] = + rk_eta[24]; acadoWorkspace.rk_xxx[25] = + rk_eta[25]; acadoWorkspace.rk_xxx[26] = + rk_eta[26]; acadoWorkspace.rk_xxx[27] = + rk_eta[27]; acado_rhs_forw( acadoWorkspace.rk_xxx, acadoWorkspace.rk_kkk ); acadoWorkspace.rk_xxx[0] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[0] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[1] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[2] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[3] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[4] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[5] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[6] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[7] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[8] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[9] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[10] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[11] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[12] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[13] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[14] + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[15] + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[16] + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[17] + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[18] + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[19] + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[20] + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[21] + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[22] + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[23] + rk_eta[23]; acadoWorkspace.rk_xxx[24] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[24] + rk_eta[24]; acadoWorkspace.rk_xxx[25] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[25] + rk_eta[25]; acadoWorkspace.rk_xxx[26] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[26] + rk_eta[26]; acadoWorkspace.rk_xxx[27] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[27] + rk_eta[27]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 28 ]) ); acadoWorkspace.rk_xxx[0] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[28] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[29] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[30] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[31] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[32] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[33] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[34] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[35] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[36] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[37] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[38] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[39] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[40] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[41] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[42] + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[43] + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[44] + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[45] + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[46] + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[47] + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[48] + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[49] + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[50] + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[51] + rk_eta[23]; acadoWorkspace.rk_xxx[24] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[52] + rk_eta[24]; acadoWorkspace.rk_xxx[25] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[53] + rk_eta[25]; acadoWorkspace.rk_xxx[26] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[54] + rk_eta[26]; acadoWorkspace.rk_xxx[27] = + (real_t)5.0000000000000001e-03*acadoWorkspace.rk_kkk[55] + rk_eta[27]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 56 ]) ); acadoWorkspace.rk_xxx[0] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[56] + rk_eta[0]; acadoWorkspace.rk_xxx[1] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[57] + rk_eta[1]; acadoWorkspace.rk_xxx[2] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[58] + rk_eta[2]; acadoWorkspace.rk_xxx[3] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[59] + rk_eta[3]; acadoWorkspace.rk_xxx[4] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[60] + rk_eta[4]; acadoWorkspace.rk_xxx[5] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[61] + rk_eta[5]; acadoWorkspace.rk_xxx[6] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[62] + rk_eta[6]; acadoWorkspace.rk_xxx[7] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[63] + rk_eta[7]; acadoWorkspace.rk_xxx[8] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[64] + rk_eta[8]; acadoWorkspace.rk_xxx[9] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[65] + rk_eta[9]; acadoWorkspace.rk_xxx[10] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[66] + rk_eta[10]; acadoWorkspace.rk_xxx[11] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[67] + rk_eta[11]; acadoWorkspace.rk_xxx[12] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[68] + rk_eta[12]; acadoWorkspace.rk_xxx[13] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[69] + rk_eta[13]; acadoWorkspace.rk_xxx[14] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[70] + rk_eta[14]; acadoWorkspace.rk_xxx[15] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[71] + rk_eta[15]; acadoWorkspace.rk_xxx[16] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[72] + rk_eta[16]; acadoWorkspace.rk_xxx[17] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[73] + rk_eta[17]; acadoWorkspace.rk_xxx[18] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[74] + rk_eta[18]; acadoWorkspace.rk_xxx[19] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[75] + rk_eta[19]; acadoWorkspace.rk_xxx[20] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[76] + rk_eta[20]; acadoWorkspace.rk_xxx[21] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[77] + rk_eta[21]; acadoWorkspace.rk_xxx[22] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[78] + rk_eta[22]; acadoWorkspace.rk_xxx[23] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[79] + rk_eta[23]; acadoWorkspace.rk_xxx[24] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[80] + rk_eta[24]; acadoWorkspace.rk_xxx[25] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[81] + rk_eta[25]; acadoWorkspace.rk_xxx[26] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[82] + rk_eta[26]; acadoWorkspace.rk_xxx[27] = + (real_t)1.0000000000000000e-02*acadoWorkspace.rk_kkk[83] + rk_eta[27]; acado_rhs_forw( acadoWorkspace.rk_xxx, &(acadoWorkspace.rk_kkk[ 84 ]) ); rk_eta[0] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[0] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[28] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[56] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[84]; rk_eta[1] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[1] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[29] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[57] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[85]; rk_eta[2] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[2] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[30] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[58] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[86]; rk_eta[3] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[3] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[31] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[59] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[87]; rk_eta[4] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[4] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[32] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[60] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[88]; rk_eta[5] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[5] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[33] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[61] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[89]; rk_eta[6] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[6] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[34] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[62] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[90]; rk_eta[7] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[7] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[35] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[63] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[91]; rk_eta[8] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[8] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[36] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[64] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[92]; rk_eta[9] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[9] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[37] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[65] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[93]; rk_eta[10] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[10] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[38] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[66] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[94]; rk_eta[11] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[11] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[39] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[67] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[95]; rk_eta[12] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[12] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[40] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[68] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[96]; rk_eta[13] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[13] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[41] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[69] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[97]; rk_eta[14] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[14] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[42] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[70] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[98]; rk_eta[15] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[15] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[43] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[71] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[99]; rk_eta[16] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[16] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[44] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[72] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[100]; rk_eta[17] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[17] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[45] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[73] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[101]; rk_eta[18] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[18] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[46] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[74] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[102]; rk_eta[19] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[19] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[47] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[75] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[103]; rk_eta[20] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[20] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[48] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[76] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[104]; rk_eta[21] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[21] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[49] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[77] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[105]; rk_eta[22] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[22] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[50] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[78] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[106]; rk_eta[23] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[23] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[51] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[79] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[107]; rk_eta[24] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[24] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[52] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[80] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[108]; rk_eta[25] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[25] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[53] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[81] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[109]; rk_eta[26] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[26] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[54] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[82] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[110]; rk_eta[27] += + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[27] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[55] + (real_t)3.3333333333333331e-03*acadoWorkspace.rk_kkk[83] + (real_t)1.6666666666666666e-03*acadoWorkspace.rk_kkk[111]; acadoWorkspace.rk_ttt += 1.0000000000000000e+00; } } error = 0; return error; } ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_qpoases_interface.cpp ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ extern "C" { #include "acado_common.h" } #include "INCLUDE/QProblem.hpp" #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 #include "INCLUDE/EXTRAS/SolutionAnalysis.hpp" #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ static int acado_nWSR; #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 static SolutionAnalysis acado_sa; #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ int acado_solve( void ) { acado_nWSR = QPOASES_NWSRMAX; QProblem qp(68, 96); returnValue retVal = qp.init(acadoWorkspace.H, acadoWorkspace.g, acadoWorkspace.A, acadoWorkspace.lb, acadoWorkspace.ub, acadoWorkspace.lbA, acadoWorkspace.ubA, acado_nWSR, acadoWorkspace.y); qp.getPrimalSolution( acadoWorkspace.x ); qp.getDualSolution( acadoWorkspace.y ); #if ACADO_COMPUTE_COVARIANCE_MATRIX == 1 if (retVal != SUCCESSFUL_RETURN) return (int)retVal; retVal = acado_sa.getHessianInverse( &qp,var ); #endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */ return (int)retVal; } int acado_getNWSR( void ) { return acado_nWSR; } const char* acado_getErrorString( int error ) { return MessageHandling::getErrorString( error ); } ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_qpoases_interface.hpp ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef QPOASES_HEADER #define QPOASES_HEADER #ifdef PC_DEBUG #include #endif /* PC_DEBUG */ #include #ifdef __cplusplus #define EXTERNC extern "C" #else #define EXTERNC #endif /* * A set of options for qpOASES */ /** Maximum number of optimization variables. */ #define QPOASES_NVMAX 68 /** Maximum number of constraints. */ #define QPOASES_NCMAX 96 /** Maximum number of working set recalculations. */ #define QPOASES_NWSRMAX 50 /** Print level for qpOASES. */ #define QPOASES_PRINTLEVEL PL_NONE /** The value of EPS */ #define QPOASES_EPS 2.221e-16 /** Internally used floating point type */ typedef double real_t; /* * Forward function declarations */ /** A function that calls the QP solver */ EXTERNC int acado_solve( void ); /** Get the number of active set changes */ EXTERNC int acado_getNWSR( void ); /** Get the error string. */ const char* acado_getErrorString( int error ); #endif /* QPOASES_HEADER */ ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/lib_mpc_export/acado_solver.c ================================================ /* * This file was auto-generated using the ACADO Toolkit. * * While ACADO Toolkit is free software released under the terms of * the GNU Lesser General Public License (LGPL), the generated code * as such remains the property of the user who used ACADO Toolkit * to generate this code. In particular, user dependent data of the code * do not inherit the GNU LGPL license. On the other hand, parts of the * generated code that are a direct copy of source code from the * ACADO Toolkit or the software tools it is based on, remain, as derived * work, automatically covered by the LGPL license. * * ACADO Toolkit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include "acado_common.h" /******************************************************************************/ /* */ /* ACADO code generation */ /* */ /******************************************************************************/ int acado_modelSimulation( ) { int ret; int lRun1; ret = 0; for (lRun1 = 0; lRun1 < 32; ++lRun1) { acadoWorkspace.state[0] = acadoVariables.x[lRun1 * 4]; acadoWorkspace.state[1] = acadoVariables.x[lRun1 * 4 + 1]; acadoWorkspace.state[2] = acadoVariables.x[lRun1 * 4 + 2]; acadoWorkspace.state[3] = acadoVariables.x[lRun1 * 4 + 3]; acadoWorkspace.state[28] = acadoVariables.u[lRun1 * 2]; acadoWorkspace.state[29] = acadoVariables.u[lRun1 * 2 + 1]; acadoWorkspace.state[30] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.state[31] = acadoVariables.od[lRun1 * 2 + 1]; ret = acado_integrate(acadoWorkspace.state, 1, lRun1); acadoWorkspace.d[lRun1 * 4] = acadoWorkspace.state[0] - acadoVariables.x[lRun1 * 4 + 4]; acadoWorkspace.d[lRun1 * 4 + 1] = acadoWorkspace.state[1] - acadoVariables.x[lRun1 * 4 + 5]; acadoWorkspace.d[lRun1 * 4 + 2] = acadoWorkspace.state[2] - acadoVariables.x[lRun1 * 4 + 6]; acadoWorkspace.d[lRun1 * 4 + 3] = acadoWorkspace.state[3] - acadoVariables.x[lRun1 * 4 + 7]; acadoWorkspace.evGx[lRun1 * 16] = acadoWorkspace.state[4]; acadoWorkspace.evGx[lRun1 * 16 + 1] = acadoWorkspace.state[5]; acadoWorkspace.evGx[lRun1 * 16 + 2] = acadoWorkspace.state[6]; acadoWorkspace.evGx[lRun1 * 16 + 3] = acadoWorkspace.state[7]; acadoWorkspace.evGx[lRun1 * 16 + 4] = acadoWorkspace.state[8]; acadoWorkspace.evGx[lRun1 * 16 + 5] = acadoWorkspace.state[9]; acadoWorkspace.evGx[lRun1 * 16 + 6] = acadoWorkspace.state[10]; acadoWorkspace.evGx[lRun1 * 16 + 7] = acadoWorkspace.state[11]; acadoWorkspace.evGx[lRun1 * 16 + 8] = acadoWorkspace.state[12]; acadoWorkspace.evGx[lRun1 * 16 + 9] = acadoWorkspace.state[13]; acadoWorkspace.evGx[lRun1 * 16 + 10] = acadoWorkspace.state[14]; acadoWorkspace.evGx[lRun1 * 16 + 11] = acadoWorkspace.state[15]; acadoWorkspace.evGx[lRun1 * 16 + 12] = acadoWorkspace.state[16]; acadoWorkspace.evGx[lRun1 * 16 + 13] = acadoWorkspace.state[17]; acadoWorkspace.evGx[lRun1 * 16 + 14] = acadoWorkspace.state[18]; acadoWorkspace.evGx[lRun1 * 16 + 15] = acadoWorkspace.state[19]; acadoWorkspace.evGu[lRun1 * 8] = acadoWorkspace.state[20]; acadoWorkspace.evGu[lRun1 * 8 + 1] = acadoWorkspace.state[21]; acadoWorkspace.evGu[lRun1 * 8 + 2] = acadoWorkspace.state[22]; acadoWorkspace.evGu[lRun1 * 8 + 3] = acadoWorkspace.state[23]; acadoWorkspace.evGu[lRun1 * 8 + 4] = acadoWorkspace.state[24]; acadoWorkspace.evGu[lRun1 * 8 + 5] = acadoWorkspace.state[25]; acadoWorkspace.evGu[lRun1 * 8 + 6] = acadoWorkspace.state[26]; acadoWorkspace.evGu[lRun1 * 8 + 7] = acadoWorkspace.state[27]; } return ret; } void acado_evaluateLSQ(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* u = in + 4; /* Compute outputs: */ out[0] = xd[0]; out[1] = xd[1]; out[2] = xd[2]; out[3] = u[0]; out[4] = u[1]; } void acado_evaluateLSQEndTerm(const real_t* in, real_t* out) { const real_t* xd = in; /* Compute outputs: */ out[0] = xd[0]; out[1] = xd[1]; out[2] = xd[2]; } void acado_setObjQ1Q2( real_t* const tmpObjS, real_t* const tmpQ1, real_t* const tmpQ2 ) { tmpQ2[0] = +tmpObjS[0]; tmpQ2[1] = +tmpObjS[1]; tmpQ2[2] = +tmpObjS[2]; tmpQ2[3] = +tmpObjS[3]; tmpQ2[4] = +tmpObjS[4]; tmpQ2[5] = +tmpObjS[5]; tmpQ2[6] = +tmpObjS[6]; tmpQ2[7] = +tmpObjS[7]; tmpQ2[8] = +tmpObjS[8]; tmpQ2[9] = +tmpObjS[9]; tmpQ2[10] = +tmpObjS[10]; tmpQ2[11] = +tmpObjS[11]; tmpQ2[12] = +tmpObjS[12]; tmpQ2[13] = +tmpObjS[13]; tmpQ2[14] = +tmpObjS[14]; tmpQ2[15] = 0.0; ; tmpQ2[16] = 0.0; ; tmpQ2[17] = 0.0; ; tmpQ2[18] = 0.0; ; tmpQ2[19] = 0.0; ; tmpQ1[0] = + tmpQ2[0]; tmpQ1[1] = + tmpQ2[1]; tmpQ1[2] = + tmpQ2[2]; tmpQ1[3] = 0.0; ; tmpQ1[4] = + tmpQ2[5]; tmpQ1[5] = + tmpQ2[6]; tmpQ1[6] = + tmpQ2[7]; tmpQ1[7] = 0.0; ; tmpQ1[8] = + tmpQ2[10]; tmpQ1[9] = + tmpQ2[11]; tmpQ1[10] = + tmpQ2[12]; tmpQ1[11] = 0.0; ; tmpQ1[12] = + tmpQ2[15]; tmpQ1[13] = + tmpQ2[16]; tmpQ1[14] = + tmpQ2[17]; tmpQ1[15] = 0.0; ; } void acado_setObjR1R2( real_t* const tmpObjS, real_t* const tmpR1, real_t* const tmpR2 ) { tmpR2[0] = +tmpObjS[15]; tmpR2[1] = +tmpObjS[16]; tmpR2[2] = +tmpObjS[17]; tmpR2[3] = +tmpObjS[18]; tmpR2[4] = +tmpObjS[19]; tmpR2[5] = +tmpObjS[20]; tmpR2[6] = +tmpObjS[21]; tmpR2[7] = +tmpObjS[22]; tmpR2[8] = +tmpObjS[23]; tmpR2[9] = +tmpObjS[24]; tmpR1[0] = + tmpR2[3]; tmpR1[1] = + tmpR2[4]; tmpR1[2] = + tmpR2[8]; tmpR1[3] = + tmpR2[9]; } void acado_setObjQN1QN2( real_t* const tmpObjSEndTerm, real_t* const tmpQN1, real_t* const tmpQN2 ) { tmpQN2[0] = +tmpObjSEndTerm[0]; tmpQN2[1] = +tmpObjSEndTerm[1]; tmpQN2[2] = +tmpObjSEndTerm[2]; tmpQN2[3] = +tmpObjSEndTerm[3]; tmpQN2[4] = +tmpObjSEndTerm[4]; tmpQN2[5] = +tmpObjSEndTerm[5]; tmpQN2[6] = +tmpObjSEndTerm[6]; tmpQN2[7] = +tmpObjSEndTerm[7]; tmpQN2[8] = +tmpObjSEndTerm[8]; tmpQN2[9] = 0.0; ; tmpQN2[10] = 0.0; ; tmpQN2[11] = 0.0; ; tmpQN1[0] = + tmpQN2[0]; tmpQN1[1] = + tmpQN2[1]; tmpQN1[2] = + tmpQN2[2]; tmpQN1[3] = 0.0; ; tmpQN1[4] = + tmpQN2[3]; tmpQN1[5] = + tmpQN2[4]; tmpQN1[6] = + tmpQN2[5]; tmpQN1[7] = 0.0; ; tmpQN1[8] = + tmpQN2[6]; tmpQN1[9] = + tmpQN2[7]; tmpQN1[10] = + tmpQN2[8]; tmpQN1[11] = 0.0; ; tmpQN1[12] = + tmpQN2[9]; tmpQN1[13] = + tmpQN2[10]; tmpQN1[14] = + tmpQN2[11]; tmpQN1[15] = 0.0; ; } void acado_evaluateObjective( ) { int runObj; for (runObj = 0; runObj < 32; ++runObj) { acadoWorkspace.objValueIn[0] = acadoVariables.x[runObj * 4]; acadoWorkspace.objValueIn[1] = acadoVariables.x[runObj * 4 + 1]; acadoWorkspace.objValueIn[2] = acadoVariables.x[runObj * 4 + 2]; acadoWorkspace.objValueIn[3] = acadoVariables.x[runObj * 4 + 3]; acadoWorkspace.objValueIn[4] = acadoVariables.u[runObj * 2]; acadoWorkspace.objValueIn[5] = acadoVariables.u[runObj * 2 + 1]; acadoWorkspace.objValueIn[6] = acadoVariables.od[runObj * 2]; acadoWorkspace.objValueIn[7] = acadoVariables.od[runObj * 2 + 1]; acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.Dy[runObj * 5] = acadoWorkspace.objValueOut[0]; acadoWorkspace.Dy[runObj * 5 + 1] = acadoWorkspace.objValueOut[1]; acadoWorkspace.Dy[runObj * 5 + 2] = acadoWorkspace.objValueOut[2]; acadoWorkspace.Dy[runObj * 5 + 3] = acadoWorkspace.objValueOut[3]; acadoWorkspace.Dy[runObj * 5 + 4] = acadoWorkspace.objValueOut[4]; acado_setObjQ1Q2( &(acadoVariables.W[ runObj * 25 ]), &(acadoWorkspace.Q1[ runObj * 16 ]), &(acadoWorkspace.Q2[ runObj * 20 ]) ); acado_setObjR1R2( &(acadoVariables.W[ runObj * 25 ]), &(acadoWorkspace.R1[ runObj * 4 ]), &(acadoWorkspace.R2[ runObj * 10 ]) ); } acadoWorkspace.objValueIn[0] = acadoVariables.x[128]; acadoWorkspace.objValueIn[1] = acadoVariables.x[129]; acadoWorkspace.objValueIn[2] = acadoVariables.x[130]; acadoWorkspace.objValueIn[3] = acadoVariables.x[131]; acadoWorkspace.objValueIn[4] = acadoVariables.od[64]; acadoWorkspace.objValueIn[5] = acadoVariables.od[65]; acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0]; acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1]; acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2]; acado_setObjQN1QN2( acadoVariables.WN, acadoWorkspace.QN1, acadoWorkspace.QN2 ); } void acado_multGxd( real_t* const dOld, real_t* const Gx1, real_t* const dNew ) { dNew[0] += + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2] + Gx1[3]*dOld[3]; dNew[1] += + Gx1[4]*dOld[0] + Gx1[5]*dOld[1] + Gx1[6]*dOld[2] + Gx1[7]*dOld[3]; dNew[2] += + Gx1[8]*dOld[0] + Gx1[9]*dOld[1] + Gx1[10]*dOld[2] + Gx1[11]*dOld[3]; dNew[3] += + Gx1[12]*dOld[0] + Gx1[13]*dOld[1] + Gx1[14]*dOld[2] + Gx1[15]*dOld[3]; } void acado_moveGxT( real_t* const Gx1, real_t* const Gx2 ) { Gx2[0] = Gx1[0]; Gx2[1] = Gx1[1]; Gx2[2] = Gx1[2]; Gx2[3] = Gx1[3]; Gx2[4] = Gx1[4]; Gx2[5] = Gx1[5]; Gx2[6] = Gx1[6]; Gx2[7] = Gx1[7]; Gx2[8] = Gx1[8]; Gx2[9] = Gx1[9]; Gx2[10] = Gx1[10]; Gx2[11] = Gx1[11]; Gx2[12] = Gx1[12]; Gx2[13] = Gx1[13]; Gx2[14] = Gx1[14]; Gx2[15] = Gx1[15]; } void acado_multGxGx( real_t* const Gx1, real_t* const Gx2, real_t* const Gx3 ) { Gx3[0] = + Gx1[0]*Gx2[0] + Gx1[1]*Gx2[4] + Gx1[2]*Gx2[8] + Gx1[3]*Gx2[12]; Gx3[1] = + Gx1[0]*Gx2[1] + Gx1[1]*Gx2[5] + Gx1[2]*Gx2[9] + Gx1[3]*Gx2[13]; Gx3[2] = + Gx1[0]*Gx2[2] + Gx1[1]*Gx2[6] + Gx1[2]*Gx2[10] + Gx1[3]*Gx2[14]; Gx3[3] = + Gx1[0]*Gx2[3] + Gx1[1]*Gx2[7] + Gx1[2]*Gx2[11] + Gx1[3]*Gx2[15]; Gx3[4] = + Gx1[4]*Gx2[0] + Gx1[5]*Gx2[4] + Gx1[6]*Gx2[8] + Gx1[7]*Gx2[12]; Gx3[5] = + Gx1[4]*Gx2[1] + Gx1[5]*Gx2[5] + Gx1[6]*Gx2[9] + Gx1[7]*Gx2[13]; Gx3[6] = + Gx1[4]*Gx2[2] + Gx1[5]*Gx2[6] + Gx1[6]*Gx2[10] + Gx1[7]*Gx2[14]; Gx3[7] = + Gx1[4]*Gx2[3] + Gx1[5]*Gx2[7] + Gx1[6]*Gx2[11] + Gx1[7]*Gx2[15]; Gx3[8] = + Gx1[8]*Gx2[0] + Gx1[9]*Gx2[4] + Gx1[10]*Gx2[8] + Gx1[11]*Gx2[12]; Gx3[9] = + Gx1[8]*Gx2[1] + Gx1[9]*Gx2[5] + Gx1[10]*Gx2[9] + Gx1[11]*Gx2[13]; Gx3[10] = + Gx1[8]*Gx2[2] + Gx1[9]*Gx2[6] + Gx1[10]*Gx2[10] + Gx1[11]*Gx2[14]; Gx3[11] = + Gx1[8]*Gx2[3] + Gx1[9]*Gx2[7] + Gx1[10]*Gx2[11] + Gx1[11]*Gx2[15]; Gx3[12] = + Gx1[12]*Gx2[0] + Gx1[13]*Gx2[4] + Gx1[14]*Gx2[8] + Gx1[15]*Gx2[12]; Gx3[13] = + Gx1[12]*Gx2[1] + Gx1[13]*Gx2[5] + Gx1[14]*Gx2[9] + Gx1[15]*Gx2[13]; Gx3[14] = + Gx1[12]*Gx2[2] + Gx1[13]*Gx2[6] + Gx1[14]*Gx2[10] + Gx1[15]*Gx2[14]; Gx3[15] = + Gx1[12]*Gx2[3] + Gx1[13]*Gx2[7] + Gx1[14]*Gx2[11] + Gx1[15]*Gx2[15]; } void acado_multGxGu( real_t* const Gx1, real_t* const Gu1, real_t* const Gu2 ) { Gu2[0] = + Gx1[0]*Gu1[0] + Gx1[1]*Gu1[2] + Gx1[2]*Gu1[4] + Gx1[3]*Gu1[6]; Gu2[1] = + Gx1[0]*Gu1[1] + Gx1[1]*Gu1[3] + Gx1[2]*Gu1[5] + Gx1[3]*Gu1[7]; Gu2[2] = + Gx1[4]*Gu1[0] + Gx1[5]*Gu1[2] + Gx1[6]*Gu1[4] + Gx1[7]*Gu1[6]; Gu2[3] = + Gx1[4]*Gu1[1] + Gx1[5]*Gu1[3] + Gx1[6]*Gu1[5] + Gx1[7]*Gu1[7]; Gu2[4] = + Gx1[8]*Gu1[0] + Gx1[9]*Gu1[2] + Gx1[10]*Gu1[4] + Gx1[11]*Gu1[6]; Gu2[5] = + Gx1[8]*Gu1[1] + Gx1[9]*Gu1[3] + Gx1[10]*Gu1[5] + Gx1[11]*Gu1[7]; Gu2[6] = + Gx1[12]*Gu1[0] + Gx1[13]*Gu1[2] + Gx1[14]*Gu1[4] + Gx1[15]*Gu1[6]; Gu2[7] = + Gx1[12]*Gu1[1] + Gx1[13]*Gu1[3] + Gx1[14]*Gu1[5] + Gx1[15]*Gu1[7]; } void acado_moveGuE( real_t* const Gu1, real_t* const Gu2 ) { Gu2[0] = Gu1[0]; Gu2[1] = Gu1[1]; Gu2[2] = Gu1[2]; Gu2[3] = Gu1[3]; Gu2[4] = Gu1[4]; Gu2[5] = Gu1[5]; Gu2[6] = Gu1[6]; Gu2[7] = Gu1[7]; } void acado_setBlockH11( int iRow, int iCol, real_t* const Gu1, real_t* const Gu2 ) { acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 4)] += + Gu1[0]*Gu2[0] + Gu1[2]*Gu2[2] + Gu1[4]*Gu2[4] + Gu1[6]*Gu2[6]; acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 5)] += + Gu1[0]*Gu2[1] + Gu1[2]*Gu2[3] + Gu1[4]*Gu2[5] + Gu1[6]*Gu2[7]; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 4)] += + Gu1[1]*Gu2[0] + Gu1[3]*Gu2[2] + Gu1[5]*Gu2[4] + Gu1[7]*Gu2[6]; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 5)] += + Gu1[1]*Gu2[1] + Gu1[3]*Gu2[3] + Gu1[5]*Gu2[5] + Gu1[7]*Gu2[7]; } void acado_setBlockH11_R1( int iRow, int iCol, real_t* const R11 ) { acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 4)] = R11[0]; acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 5)] = R11[1]; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 4)] = R11[2]; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 5)] = R11[3]; } void acado_zeroBlockH11( int iRow, int iCol ) { acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 4)] = 0.0000000000000000e+00; acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 5)] = 0.0000000000000000e+00; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 4)] = 0.0000000000000000e+00; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 5)] = 0.0000000000000000e+00; } void acado_copyHTH( int iRow, int iCol ) { acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 4)] = acadoWorkspace.H[(iCol * 136 + 272) + (iRow * 2 + 4)]; acadoWorkspace.H[(iRow * 136 + 272) + (iCol * 2 + 5)] = acadoWorkspace.H[(iCol * 136 + 340) + (iRow * 2 + 4)]; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 4)] = acadoWorkspace.H[(iCol * 136 + 272) + (iRow * 2 + 5)]; acadoWorkspace.H[(iRow * 136 + 340) + (iCol * 2 + 5)] = acadoWorkspace.H[(iCol * 136 + 340) + (iRow * 2 + 5)]; } void acado_multQ1d( real_t* const Gx1, real_t* const dOld, real_t* const dNew ) { dNew[0] = + Gx1[0]*dOld[0] + Gx1[1]*dOld[1] + Gx1[2]*dOld[2] + Gx1[3]*dOld[3]; dNew[1] = + Gx1[4]*dOld[0] + Gx1[5]*dOld[1] + Gx1[6]*dOld[2] + Gx1[7]*dOld[3]; dNew[2] = + Gx1[8]*dOld[0] + Gx1[9]*dOld[1] + Gx1[10]*dOld[2] + Gx1[11]*dOld[3]; dNew[3] = + Gx1[12]*dOld[0] + Gx1[13]*dOld[1] + Gx1[14]*dOld[2] + Gx1[15]*dOld[3]; } void acado_multQN1d( real_t* const QN1, real_t* const dOld, real_t* const dNew ) { dNew[0] = + acadoWorkspace.QN1[0]*dOld[0] + acadoWorkspace.QN1[1]*dOld[1] + acadoWorkspace.QN1[2]*dOld[2] + acadoWorkspace.QN1[3]*dOld[3]; dNew[1] = + acadoWorkspace.QN1[4]*dOld[0] + acadoWorkspace.QN1[5]*dOld[1] + acadoWorkspace.QN1[6]*dOld[2] + acadoWorkspace.QN1[7]*dOld[3]; dNew[2] = + acadoWorkspace.QN1[8]*dOld[0] + acadoWorkspace.QN1[9]*dOld[1] + acadoWorkspace.QN1[10]*dOld[2] + acadoWorkspace.QN1[11]*dOld[3]; dNew[3] = + acadoWorkspace.QN1[12]*dOld[0] + acadoWorkspace.QN1[13]*dOld[1] + acadoWorkspace.QN1[14]*dOld[2] + acadoWorkspace.QN1[15]*dOld[3]; } void acado_multRDy( real_t* const R2, real_t* const Dy1, real_t* const RDy1 ) { RDy1[0] = + R2[0]*Dy1[0] + R2[1]*Dy1[1] + R2[2]*Dy1[2] + R2[3]*Dy1[3] + R2[4]*Dy1[4]; RDy1[1] = + R2[5]*Dy1[0] + R2[6]*Dy1[1] + R2[7]*Dy1[2] + R2[8]*Dy1[3] + R2[9]*Dy1[4]; } void acado_multQDy( real_t* const Q2, real_t* const Dy1, real_t* const QDy1 ) { QDy1[0] = + Q2[0]*Dy1[0] + Q2[1]*Dy1[1] + Q2[2]*Dy1[2] + Q2[3]*Dy1[3] + Q2[4]*Dy1[4]; QDy1[1] = + Q2[5]*Dy1[0] + Q2[6]*Dy1[1] + Q2[7]*Dy1[2] + Q2[8]*Dy1[3] + Q2[9]*Dy1[4]; QDy1[2] = + Q2[10]*Dy1[0] + Q2[11]*Dy1[1] + Q2[12]*Dy1[2] + Q2[13]*Dy1[3] + Q2[14]*Dy1[4]; QDy1[3] = + Q2[15]*Dy1[0] + Q2[16]*Dy1[1] + Q2[17]*Dy1[2] + Q2[18]*Dy1[3] + Q2[19]*Dy1[4]; } void acado_multEQDy( real_t* const E1, real_t* const QDy1, real_t* const U1 ) { U1[0] += + E1[0]*QDy1[0] + E1[2]*QDy1[1] + E1[4]*QDy1[2] + E1[6]*QDy1[3]; U1[1] += + E1[1]*QDy1[0] + E1[3]*QDy1[1] + E1[5]*QDy1[2] + E1[7]*QDy1[3]; } void acado_multQETGx( real_t* const E1, real_t* const Gx1, real_t* const H101 ) { H101[0] += + E1[0]*Gx1[0] + E1[2]*Gx1[4] + E1[4]*Gx1[8] + E1[6]*Gx1[12]; H101[1] += + E1[0]*Gx1[1] + E1[2]*Gx1[5] + E1[4]*Gx1[9] + E1[6]*Gx1[13]; H101[2] += + E1[0]*Gx1[2] + E1[2]*Gx1[6] + E1[4]*Gx1[10] + E1[6]*Gx1[14]; H101[3] += + E1[0]*Gx1[3] + E1[2]*Gx1[7] + E1[4]*Gx1[11] + E1[6]*Gx1[15]; H101[4] += + E1[1]*Gx1[0] + E1[3]*Gx1[4] + E1[5]*Gx1[8] + E1[7]*Gx1[12]; H101[5] += + E1[1]*Gx1[1] + E1[3]*Gx1[5] + E1[5]*Gx1[9] + E1[7]*Gx1[13]; H101[6] += + E1[1]*Gx1[2] + E1[3]*Gx1[6] + E1[5]*Gx1[10] + E1[7]*Gx1[14]; H101[7] += + E1[1]*Gx1[3] + E1[3]*Gx1[7] + E1[5]*Gx1[11] + E1[7]*Gx1[15]; } void acado_zeroBlockH10( real_t* const H101 ) { { int lCopy; for (lCopy = 0; lCopy < 8; lCopy++) H101[ lCopy ] = 0; } } void acado_multEDu( real_t* const E1, real_t* const U1, real_t* const dNew ) { dNew[0] += + E1[0]*U1[0] + E1[1]*U1[1]; dNew[1] += + E1[2]*U1[0] + E1[3]*U1[1]; dNew[2] += + E1[4]*U1[0] + E1[5]*U1[1]; dNew[3] += + E1[6]*U1[0] + E1[7]*U1[1]; } void acado_zeroBlockH00( ) { acadoWorkspace.H[0] = 0.0000000000000000e+00; acadoWorkspace.H[1] = 0.0000000000000000e+00; acadoWorkspace.H[2] = 0.0000000000000000e+00; acadoWorkspace.H[3] = 0.0000000000000000e+00; acadoWorkspace.H[68] = 0.0000000000000000e+00; acadoWorkspace.H[69] = 0.0000000000000000e+00; acadoWorkspace.H[70] = 0.0000000000000000e+00; acadoWorkspace.H[71] = 0.0000000000000000e+00; acadoWorkspace.H[136] = 0.0000000000000000e+00; acadoWorkspace.H[137] = 0.0000000000000000e+00; acadoWorkspace.H[138] = 0.0000000000000000e+00; acadoWorkspace.H[139] = 0.0000000000000000e+00; acadoWorkspace.H[204] = 0.0000000000000000e+00; acadoWorkspace.H[205] = 0.0000000000000000e+00; acadoWorkspace.H[206] = 0.0000000000000000e+00; acadoWorkspace.H[207] = 0.0000000000000000e+00; } void acado_multCTQC( real_t* const Gx1, real_t* const Gx2 ) { acadoWorkspace.H[0] += + Gx1[0]*Gx2[0] + Gx1[4]*Gx2[4] + Gx1[8]*Gx2[8] + Gx1[12]*Gx2[12]; acadoWorkspace.H[1] += + Gx1[0]*Gx2[1] + Gx1[4]*Gx2[5] + Gx1[8]*Gx2[9] + Gx1[12]*Gx2[13]; acadoWorkspace.H[2] += + Gx1[0]*Gx2[2] + Gx1[4]*Gx2[6] + Gx1[8]*Gx2[10] + Gx1[12]*Gx2[14]; acadoWorkspace.H[3] += + Gx1[0]*Gx2[3] + Gx1[4]*Gx2[7] + Gx1[8]*Gx2[11] + Gx1[12]*Gx2[15]; acadoWorkspace.H[68] += + Gx1[1]*Gx2[0] + Gx1[5]*Gx2[4] + Gx1[9]*Gx2[8] + Gx1[13]*Gx2[12]; acadoWorkspace.H[69] += + Gx1[1]*Gx2[1] + Gx1[5]*Gx2[5] + Gx1[9]*Gx2[9] + Gx1[13]*Gx2[13]; acadoWorkspace.H[70] += + Gx1[1]*Gx2[2] + Gx1[5]*Gx2[6] + Gx1[9]*Gx2[10] + Gx1[13]*Gx2[14]; acadoWorkspace.H[71] += + Gx1[1]*Gx2[3] + Gx1[5]*Gx2[7] + Gx1[9]*Gx2[11] + Gx1[13]*Gx2[15]; acadoWorkspace.H[136] += + Gx1[2]*Gx2[0] + Gx1[6]*Gx2[4] + Gx1[10]*Gx2[8] + Gx1[14]*Gx2[12]; acadoWorkspace.H[137] += + Gx1[2]*Gx2[1] + Gx1[6]*Gx2[5] + Gx1[10]*Gx2[9] + Gx1[14]*Gx2[13]; acadoWorkspace.H[138] += + Gx1[2]*Gx2[2] + Gx1[6]*Gx2[6] + Gx1[10]*Gx2[10] + Gx1[14]*Gx2[14]; acadoWorkspace.H[139] += + Gx1[2]*Gx2[3] + Gx1[6]*Gx2[7] + Gx1[10]*Gx2[11] + Gx1[14]*Gx2[15]; acadoWorkspace.H[204] += + Gx1[3]*Gx2[0] + Gx1[7]*Gx2[4] + Gx1[11]*Gx2[8] + Gx1[15]*Gx2[12]; acadoWorkspace.H[205] += + Gx1[3]*Gx2[1] + Gx1[7]*Gx2[5] + Gx1[11]*Gx2[9] + Gx1[15]*Gx2[13]; acadoWorkspace.H[206] += + Gx1[3]*Gx2[2] + Gx1[7]*Gx2[6] + Gx1[11]*Gx2[10] + Gx1[15]*Gx2[14]; acadoWorkspace.H[207] += + Gx1[3]*Gx2[3] + Gx1[7]*Gx2[7] + Gx1[11]*Gx2[11] + Gx1[15]*Gx2[15]; } void acado_multHxC( real_t* const Hx, real_t* const Gx, real_t* const A01 ) { A01[0] = + Hx[0]*Gx[0] + Hx[1]*Gx[4] + Hx[2]*Gx[8] + Hx[3]*Gx[12]; A01[1] = + Hx[0]*Gx[1] + Hx[1]*Gx[5] + Hx[2]*Gx[9] + Hx[3]*Gx[13]; A01[2] = + Hx[0]*Gx[2] + Hx[1]*Gx[6] + Hx[2]*Gx[10] + Hx[3]*Gx[14]; A01[3] = + Hx[0]*Gx[3] + Hx[1]*Gx[7] + Hx[2]*Gx[11] + Hx[3]*Gx[15]; A01[68] = + Hx[4]*Gx[0] + Hx[5]*Gx[4] + Hx[6]*Gx[8] + Hx[7]*Gx[12]; A01[69] = + Hx[4]*Gx[1] + Hx[5]*Gx[5] + Hx[6]*Gx[9] + Hx[7]*Gx[13]; A01[70] = + Hx[4]*Gx[2] + Hx[5]*Gx[6] + Hx[6]*Gx[10] + Hx[7]*Gx[14]; A01[71] = + Hx[4]*Gx[3] + Hx[5]*Gx[7] + Hx[6]*Gx[11] + Hx[7]*Gx[15]; } void acado_multHxE( real_t* const Hx, real_t* const E, int row, int col ) { acadoWorkspace.A[(row * 136 + 2176) + (col * 2 + 4)] = + Hx[0]*E[0] + Hx[1]*E[2] + Hx[2]*E[4] + Hx[3]*E[6]; acadoWorkspace.A[(row * 136 + 2176) + (col * 2 + 5)] = + Hx[0]*E[1] + Hx[1]*E[3] + Hx[2]*E[5] + Hx[3]*E[7]; acadoWorkspace.A[(row * 136 + 2244) + (col * 2 + 4)] = + Hx[4]*E[0] + Hx[5]*E[2] + Hx[6]*E[4] + Hx[7]*E[6]; acadoWorkspace.A[(row * 136 + 2244) + (col * 2 + 5)] = + Hx[4]*E[1] + Hx[5]*E[3] + Hx[6]*E[5] + Hx[7]*E[7]; } void acado_macHxd( real_t* const Hx, real_t* const tmpd, real_t* const lbA, real_t* const ubA ) { acadoWorkspace.evHxd[0] = + Hx[0]*tmpd[0] + Hx[1]*tmpd[1] + Hx[2]*tmpd[2] + Hx[3]*tmpd[3]; acadoWorkspace.evHxd[1] = + Hx[4]*tmpd[0] + Hx[5]*tmpd[1] + Hx[6]*tmpd[2] + Hx[7]*tmpd[3]; lbA[0] -= acadoWorkspace.evHxd[0]; lbA[1] -= acadoWorkspace.evHxd[1]; ubA[0] -= acadoWorkspace.evHxd[0]; ubA[1] -= acadoWorkspace.evHxd[1]; } void acado_evaluatePathConstraints(const real_t* in, real_t* out) { const real_t* xd = in; const real_t* u = in + 4; const real_t* od = in + 6; /* Vector of auxiliary variables; number of elements: 12. */ real_t* a = acadoWorkspace.conAuxVar; /* Compute intermediate quantities: */ a[0] = (real_t)(0.0000000000000000e+00); a[1] = (real_t)(0.0000000000000000e+00); a[2] = (real_t)(1.0000000000000000e+00); a[3] = (real_t)(0.0000000000000000e+00); a[4] = (real_t)(0.0000000000000000e+00); a[5] = (real_t)(0.0000000000000000e+00); a[6] = (real_t)(1.0000000000000000e+00); a[7] = (real_t)(0.0000000000000000e+00); a[8] = (real_t)(0.0000000000000000e+00); a[9] = (real_t)(1.0000000000000000e+00); a[10] = (real_t)(0.0000000000000000e+00); a[11] = (real_t)(1.0000000000000000e+00); /* Compute outputs: */ out[0] = ((xd[2]-od[0])+u[1]); out[1] = ((xd[2]-od[1])+u[1]); out[2] = a[0]; out[3] = a[1]; out[4] = a[2]; out[5] = a[3]; out[6] = a[4]; out[7] = a[5]; out[8] = a[6]; out[9] = a[7]; out[10] = a[8]; out[11] = a[9]; out[12] = a[10]; out[13] = a[11]; } void acado_macCTSlx( real_t* const C0, real_t* const g0 ) { g0[0] += 0.0; ; g0[1] += 0.0; ; g0[2] += 0.0; ; g0[3] += 0.0; ; } void acado_macETSlu( real_t* const E0, real_t* const g1 ) { g1[0] += 0.0; ; g1[1] += 0.0; ; } void acado_condensePrep( ) { int lRun1; int lRun2; int lRun3; int lRun4; int lRun5; /** Row vector of size: 32 */ static const int xBoundIndices[ 32 ] = { 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129 }; acado_moveGuE( acadoWorkspace.evGu, acadoWorkspace.E ); for (lRun1 = 1; lRun1 < 32; ++lRun1) { acado_moveGxT( &(acadoWorkspace.evGx[ lRun1 * 16 ]), acadoWorkspace.T ); acado_multGxd( &(acadoWorkspace.d[ lRun1 * 4-4 ]), &(acadoWorkspace.evGx[ lRun1 * 16 ]), &(acadoWorkspace.d[ lRun1 * 4 ]) ); acado_multGxGx( acadoWorkspace.T, &(acadoWorkspace.evGx[ lRun1 * 16-16 ]), &(acadoWorkspace.evGx[ lRun1 * 16 ]) ); for (lRun2 = 0; lRun2 < lRun1; ++lRun2) { lRun4 = (((lRun1) * (lRun1-1)) / (2)) + (lRun2); lRun3 = (((lRun1 + 1) * (lRun1)) / (2)) + (lRun2); acado_multGxGu( acadoWorkspace.T, &(acadoWorkspace.E[ lRun4 * 8 ]), &(acadoWorkspace.E[ lRun3 * 8 ]) ); } lRun3 = (((lRun1 + 1) * (lRun1)) / (2)) + (lRun2); acado_moveGuE( &(acadoWorkspace.evGu[ lRun1 * 8 ]), &(acadoWorkspace.E[ lRun3 * 8 ]) ); } acado_multGxGx( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.evGx, acadoWorkspace.QGx ); acado_multGxGx( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.QGx[ 16 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.QGx[ 32 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.QGx[ 48 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.QGx[ 64 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.QGx[ 80 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.QGx[ 96 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.QGx[ 112 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.QGx[ 128 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.QGx[ 160 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.QGx[ 176 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.QGx[ 192 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.QGx[ 208 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.QGx[ 224 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.QGx[ 240 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.QGx[ 256 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.QGx[ 272 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.QGx[ 288 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 320 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.QGx[ 304 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 336 ]), &(acadoWorkspace.evGx[ 320 ]), &(acadoWorkspace.QGx[ 320 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 352 ]), &(acadoWorkspace.evGx[ 336 ]), &(acadoWorkspace.QGx[ 336 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 368 ]), &(acadoWorkspace.evGx[ 352 ]), &(acadoWorkspace.QGx[ 352 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 384 ]), &(acadoWorkspace.evGx[ 368 ]), &(acadoWorkspace.QGx[ 368 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 400 ]), &(acadoWorkspace.evGx[ 384 ]), &(acadoWorkspace.QGx[ 384 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 416 ]), &(acadoWorkspace.evGx[ 400 ]), &(acadoWorkspace.QGx[ 400 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 432 ]), &(acadoWorkspace.evGx[ 416 ]), &(acadoWorkspace.QGx[ 416 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 448 ]), &(acadoWorkspace.evGx[ 432 ]), &(acadoWorkspace.QGx[ 432 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 464 ]), &(acadoWorkspace.evGx[ 448 ]), &(acadoWorkspace.QGx[ 448 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 480 ]), &(acadoWorkspace.evGx[ 464 ]), &(acadoWorkspace.QGx[ 464 ]) ); acado_multGxGx( &(acadoWorkspace.Q1[ 496 ]), &(acadoWorkspace.evGx[ 480 ]), &(acadoWorkspace.QGx[ 480 ]) ); acado_multGxGx( acadoWorkspace.QN1, &(acadoWorkspace.evGx[ 496 ]), &(acadoWorkspace.QGx[ 496 ]) ); for (lRun1 = 0; lRun1 < 31; ++lRun1) { for (lRun2 = 0; lRun2 < lRun1 + 1; ++lRun2) { lRun3 = (((lRun1 + 1) * (lRun1)) / (2)) + (lRun2); acado_multGxGu( &(acadoWorkspace.Q1[ lRun1 * 16 + 16 ]), &(acadoWorkspace.E[ lRun3 * 8 ]), &(acadoWorkspace.QE[ lRun3 * 8 ]) ); } } for (lRun2 = 0; lRun2 < lRun1 + 1; ++lRun2) { lRun3 = (((lRun1 + 1) * (lRun1)) / (2)) + (lRun2); acado_multGxGu( acadoWorkspace.QN1, &(acadoWorkspace.E[ lRun3 * 8 ]), &(acadoWorkspace.QE[ lRun3 * 8 ]) ); } acado_zeroBlockH00( ); acado_multCTQC( acadoWorkspace.evGx, acadoWorkspace.QGx ); acado_multCTQC( &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.QGx[ 16 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.QGx[ 32 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.QGx[ 48 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.QGx[ 64 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.QGx[ 80 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.QGx[ 96 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.QGx[ 112 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.QGx[ 128 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.QGx[ 144 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.QGx[ 160 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.QGx[ 176 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.QGx[ 192 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.QGx[ 208 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.QGx[ 224 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.QGx[ 240 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.QGx[ 256 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.QGx[ 272 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.QGx[ 288 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.QGx[ 304 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 320 ]), &(acadoWorkspace.QGx[ 320 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 336 ]), &(acadoWorkspace.QGx[ 336 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 352 ]), &(acadoWorkspace.QGx[ 352 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 368 ]), &(acadoWorkspace.QGx[ 368 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 384 ]), &(acadoWorkspace.QGx[ 384 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 400 ]), &(acadoWorkspace.QGx[ 400 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 416 ]), &(acadoWorkspace.QGx[ 416 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 432 ]), &(acadoWorkspace.QGx[ 432 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 448 ]), &(acadoWorkspace.QGx[ 448 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 464 ]), &(acadoWorkspace.QGx[ 464 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 480 ]), &(acadoWorkspace.QGx[ 480 ]) ); acado_multCTQC( &(acadoWorkspace.evGx[ 496 ]), &(acadoWorkspace.QGx[ 496 ]) ); for (lRun1 = 0; lRun1 < 32; ++lRun1) { acado_zeroBlockH10( &(acadoWorkspace.H10[ lRun1 * 8 ]) ); for (lRun2 = lRun1; lRun2 < 32; ++lRun2) { lRun3 = (((lRun2 + 1) * (lRun2)) / (2)) + (lRun1); acado_multQETGx( &(acadoWorkspace.QE[ lRun3 * 8 ]), &(acadoWorkspace.evGx[ lRun2 * 16 ]), &(acadoWorkspace.H10[ lRun1 * 8 ]) ); } } for (lRun2 = 0;lRun2 < 4; ++lRun2) for (lRun3 = 0;lRun3 < 64; ++lRun3) acadoWorkspace.H[(lRun2 * 68) + (lRun3 + 4)] = acadoWorkspace.H10[(lRun3 * 4) + (lRun2)]; for (lRun1 = 0; lRun1 < 32; ++lRun1) { acado_setBlockH11_R1( lRun1, lRun1, &(acadoWorkspace.R1[ lRun1 * 4 ]) ); lRun2 = lRun1; for (lRun3 = lRun1; lRun3 < 32; ++lRun3) { lRun4 = (((lRun3 + 1) * (lRun3)) / (2)) + (lRun1); lRun5 = (((lRun3 + 1) * (lRun3)) / (2)) + (lRun2); acado_setBlockH11( lRun1, lRun2, &(acadoWorkspace.E[ lRun4 * 8 ]), &(acadoWorkspace.QE[ lRun5 * 8 ]) ); } for (lRun2 = lRun1 + 1; lRun2 < 32; ++lRun2) { acado_zeroBlockH11( lRun1, lRun2 ); for (lRun3 = lRun2; lRun3 < 32; ++lRun3) { lRun4 = (((lRun3 + 1) * (lRun3)) / (2)) + (lRun1); lRun5 = (((lRun3 + 1) * (lRun3)) / (2)) + (lRun2); acado_setBlockH11( lRun1, lRun2, &(acadoWorkspace.E[ lRun4 * 8 ]), &(acadoWorkspace.QE[ lRun5 * 8 ]) ); } } } for (lRun1 = 0; lRun1 < 32; ++lRun1) { for (lRun2 = 0; lRun2 < lRun1; ++lRun2) { acado_copyHTH( lRun1, lRun2 ); } } for (lRun2 = 0;lRun2 < 64; ++lRun2) for (lRun3 = 0;lRun3 < 4; ++lRun3) acadoWorkspace.H[(lRun2 * 68 + 272) + (lRun3)] = acadoWorkspace.H10[(lRun2 * 4) + (lRun3)]; acado_multQ1d( &(acadoWorkspace.Q1[ 16 ]), acadoWorkspace.d, acadoWorkspace.Qd ); acado_multQ1d( &(acadoWorkspace.Q1[ 32 ]), &(acadoWorkspace.d[ 4 ]), &(acadoWorkspace.Qd[ 4 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 48 ]), &(acadoWorkspace.d[ 8 ]), &(acadoWorkspace.Qd[ 8 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 64 ]), &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.Qd[ 12 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 80 ]), &(acadoWorkspace.d[ 16 ]), &(acadoWorkspace.Qd[ 16 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 96 ]), &(acadoWorkspace.d[ 20 ]), &(acadoWorkspace.Qd[ 20 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 112 ]), &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.Qd[ 24 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 128 ]), &(acadoWorkspace.d[ 28 ]), &(acadoWorkspace.Qd[ 28 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 144 ]), &(acadoWorkspace.d[ 32 ]), &(acadoWorkspace.Qd[ 32 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 160 ]), &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.Qd[ 36 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 176 ]), &(acadoWorkspace.d[ 40 ]), &(acadoWorkspace.Qd[ 40 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 192 ]), &(acadoWorkspace.d[ 44 ]), &(acadoWorkspace.Qd[ 44 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 208 ]), &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.Qd[ 48 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 224 ]), &(acadoWorkspace.d[ 52 ]), &(acadoWorkspace.Qd[ 52 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 240 ]), &(acadoWorkspace.d[ 56 ]), &(acadoWorkspace.Qd[ 56 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 256 ]), &(acadoWorkspace.d[ 60 ]), &(acadoWorkspace.Qd[ 60 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 272 ]), &(acadoWorkspace.d[ 64 ]), &(acadoWorkspace.Qd[ 64 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 288 ]), &(acadoWorkspace.d[ 68 ]), &(acadoWorkspace.Qd[ 68 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 304 ]), &(acadoWorkspace.d[ 72 ]), &(acadoWorkspace.Qd[ 72 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 320 ]), &(acadoWorkspace.d[ 76 ]), &(acadoWorkspace.Qd[ 76 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 336 ]), &(acadoWorkspace.d[ 80 ]), &(acadoWorkspace.Qd[ 80 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 352 ]), &(acadoWorkspace.d[ 84 ]), &(acadoWorkspace.Qd[ 84 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 368 ]), &(acadoWorkspace.d[ 88 ]), &(acadoWorkspace.Qd[ 88 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 384 ]), &(acadoWorkspace.d[ 92 ]), &(acadoWorkspace.Qd[ 92 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 400 ]), &(acadoWorkspace.d[ 96 ]), &(acadoWorkspace.Qd[ 96 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 416 ]), &(acadoWorkspace.d[ 100 ]), &(acadoWorkspace.Qd[ 100 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 432 ]), &(acadoWorkspace.d[ 104 ]), &(acadoWorkspace.Qd[ 104 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 448 ]), &(acadoWorkspace.d[ 108 ]), &(acadoWorkspace.Qd[ 108 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 464 ]), &(acadoWorkspace.d[ 112 ]), &(acadoWorkspace.Qd[ 112 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 480 ]), &(acadoWorkspace.d[ 116 ]), &(acadoWorkspace.Qd[ 116 ]) ); acado_multQ1d( &(acadoWorkspace.Q1[ 496 ]), &(acadoWorkspace.d[ 120 ]), &(acadoWorkspace.Qd[ 120 ]) ); acado_multQN1d( acadoWorkspace.QN1, &(acadoWorkspace.d[ 124 ]), &(acadoWorkspace.Qd[ 124 ]) ); acado_macCTSlx( acadoWorkspace.evGx, acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 16 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 32 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 48 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 64 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 80 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 96 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 112 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 128 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 144 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 160 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 176 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 192 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 208 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 224 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 240 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 256 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 272 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 288 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 304 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 320 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 336 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 352 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 368 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 384 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 400 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 416 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 432 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 448 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 464 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 480 ]), acadoWorkspace.g ); acado_macCTSlx( &(acadoWorkspace.evGx[ 496 ]), acadoWorkspace.g ); for (lRun1 = 0; lRun1 < 32; ++lRun1) { for (lRun2 = lRun1; lRun2 < 32; ++lRun2) { lRun3 = (((lRun2 + 1) * (lRun2)) / (2)) + (lRun1); acado_macETSlu( &(acadoWorkspace.QE[ lRun3 * 8 ]), &(acadoWorkspace.g[ lRun1 * 2 + 4 ]) ); } } acadoWorkspace.lb[4] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[0]; acadoWorkspace.lb[5] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[1]; acadoWorkspace.lb[6] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[2]; acadoWorkspace.lb[7] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[3]; acadoWorkspace.lb[8] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[4]; acadoWorkspace.lb[9] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[5]; acadoWorkspace.lb[10] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[6]; acadoWorkspace.lb[11] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[7]; acadoWorkspace.lb[12] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[8]; acadoWorkspace.lb[13] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[9]; acadoWorkspace.lb[14] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[10]; acadoWorkspace.lb[15] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[11]; acadoWorkspace.lb[16] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[12]; acadoWorkspace.lb[17] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[13]; acadoWorkspace.lb[18] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[14]; acadoWorkspace.lb[19] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[15]; acadoWorkspace.lb[20] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[16]; acadoWorkspace.lb[21] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[17]; acadoWorkspace.lb[22] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[18]; acadoWorkspace.lb[23] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[19]; acadoWorkspace.lb[24] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[20]; acadoWorkspace.lb[25] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[21]; acadoWorkspace.lb[26] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[22]; acadoWorkspace.lb[27] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[23]; acadoWorkspace.lb[28] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[24]; acadoWorkspace.lb[29] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[25]; acadoWorkspace.lb[30] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[26]; acadoWorkspace.lb[31] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[27]; acadoWorkspace.lb[32] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[28]; acadoWorkspace.lb[33] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[29]; acadoWorkspace.lb[34] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[30]; acadoWorkspace.lb[35] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[31]; acadoWorkspace.lb[36] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[32]; acadoWorkspace.lb[37] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[33]; acadoWorkspace.lb[38] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[34]; acadoWorkspace.lb[39] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[35]; acadoWorkspace.lb[40] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[36]; acadoWorkspace.lb[41] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[37]; acadoWorkspace.lb[42] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[38]; acadoWorkspace.lb[43] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[39]; acadoWorkspace.lb[44] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[40]; acadoWorkspace.lb[45] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[41]; acadoWorkspace.lb[46] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[42]; acadoWorkspace.lb[47] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[43]; acadoWorkspace.lb[48] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[44]; acadoWorkspace.lb[49] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[45]; acadoWorkspace.lb[50] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[46]; acadoWorkspace.lb[51] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[47]; acadoWorkspace.lb[52] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[48]; acadoWorkspace.lb[53] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[49]; acadoWorkspace.lb[54] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[50]; acadoWorkspace.lb[55] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[51]; acadoWorkspace.lb[56] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[52]; acadoWorkspace.lb[57] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[53]; acadoWorkspace.lb[58] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[54]; acadoWorkspace.lb[59] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[55]; acadoWorkspace.lb[60] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[56]; acadoWorkspace.lb[61] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[57]; acadoWorkspace.lb[62] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[58]; acadoWorkspace.lb[63] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[59]; acadoWorkspace.lb[64] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[60]; acadoWorkspace.lb[65] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[61]; acadoWorkspace.lb[66] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[62]; acadoWorkspace.lb[67] = (real_t)-1.0000000000000000e+12 - acadoVariables.u[63]; acadoWorkspace.ub[4] = (real_t)1.0000000000000000e+12 - acadoVariables.u[0]; acadoWorkspace.ub[5] = (real_t)1.0000000000000000e+12 - acadoVariables.u[1]; acadoWorkspace.ub[6] = (real_t)1.0000000000000000e+12 - acadoVariables.u[2]; acadoWorkspace.ub[7] = (real_t)1.0000000000000000e+12 - acadoVariables.u[3]; acadoWorkspace.ub[8] = (real_t)1.0000000000000000e+12 - acadoVariables.u[4]; acadoWorkspace.ub[9] = (real_t)1.0000000000000000e+12 - acadoVariables.u[5]; acadoWorkspace.ub[10] = (real_t)1.0000000000000000e+12 - acadoVariables.u[6]; acadoWorkspace.ub[11] = (real_t)1.0000000000000000e+12 - acadoVariables.u[7]; acadoWorkspace.ub[12] = (real_t)1.0000000000000000e+12 - acadoVariables.u[8]; acadoWorkspace.ub[13] = (real_t)1.0000000000000000e+12 - acadoVariables.u[9]; acadoWorkspace.ub[14] = (real_t)1.0000000000000000e+12 - acadoVariables.u[10]; acadoWorkspace.ub[15] = (real_t)1.0000000000000000e+12 - acadoVariables.u[11]; acadoWorkspace.ub[16] = (real_t)1.0000000000000000e+12 - acadoVariables.u[12]; acadoWorkspace.ub[17] = (real_t)1.0000000000000000e+12 - acadoVariables.u[13]; acadoWorkspace.ub[18] = (real_t)1.0000000000000000e+12 - acadoVariables.u[14]; acadoWorkspace.ub[19] = (real_t)1.0000000000000000e+12 - acadoVariables.u[15]; acadoWorkspace.ub[20] = (real_t)1.0000000000000000e+12 - acadoVariables.u[16]; acadoWorkspace.ub[21] = (real_t)1.0000000000000000e+12 - acadoVariables.u[17]; acadoWorkspace.ub[22] = (real_t)1.0000000000000000e+12 - acadoVariables.u[18]; acadoWorkspace.ub[23] = (real_t)1.0000000000000000e+12 - acadoVariables.u[19]; acadoWorkspace.ub[24] = (real_t)1.0000000000000000e+12 - acadoVariables.u[20]; acadoWorkspace.ub[25] = (real_t)1.0000000000000000e+12 - acadoVariables.u[21]; acadoWorkspace.ub[26] = (real_t)1.0000000000000000e+12 - acadoVariables.u[22]; acadoWorkspace.ub[27] = (real_t)1.0000000000000000e+12 - acadoVariables.u[23]; acadoWorkspace.ub[28] = (real_t)1.0000000000000000e+12 - acadoVariables.u[24]; acadoWorkspace.ub[29] = (real_t)1.0000000000000000e+12 - acadoVariables.u[25]; acadoWorkspace.ub[30] = (real_t)1.0000000000000000e+12 - acadoVariables.u[26]; acadoWorkspace.ub[31] = (real_t)1.0000000000000000e+12 - acadoVariables.u[27]; acadoWorkspace.ub[32] = (real_t)1.0000000000000000e+12 - acadoVariables.u[28]; acadoWorkspace.ub[33] = (real_t)1.0000000000000000e+12 - acadoVariables.u[29]; acadoWorkspace.ub[34] = (real_t)1.0000000000000000e+12 - acadoVariables.u[30]; acadoWorkspace.ub[35] = (real_t)1.0000000000000000e+12 - acadoVariables.u[31]; acadoWorkspace.ub[36] = (real_t)1.0000000000000000e+12 - acadoVariables.u[32]; acadoWorkspace.ub[37] = (real_t)1.0000000000000000e+12 - acadoVariables.u[33]; acadoWorkspace.ub[38] = (real_t)1.0000000000000000e+12 - acadoVariables.u[34]; acadoWorkspace.ub[39] = (real_t)1.0000000000000000e+12 - acadoVariables.u[35]; acadoWorkspace.ub[40] = (real_t)1.0000000000000000e+12 - acadoVariables.u[36]; acadoWorkspace.ub[41] = (real_t)1.0000000000000000e+12 - acadoVariables.u[37]; acadoWorkspace.ub[42] = (real_t)1.0000000000000000e+12 - acadoVariables.u[38]; acadoWorkspace.ub[43] = (real_t)1.0000000000000000e+12 - acadoVariables.u[39]; acadoWorkspace.ub[44] = (real_t)1.0000000000000000e+12 - acadoVariables.u[40]; acadoWorkspace.ub[45] = (real_t)1.0000000000000000e+12 - acadoVariables.u[41]; acadoWorkspace.ub[46] = (real_t)1.0000000000000000e+12 - acadoVariables.u[42]; acadoWorkspace.ub[47] = (real_t)1.0000000000000000e+12 - acadoVariables.u[43]; acadoWorkspace.ub[48] = (real_t)1.0000000000000000e+12 - acadoVariables.u[44]; acadoWorkspace.ub[49] = (real_t)1.0000000000000000e+12 - acadoVariables.u[45]; acadoWorkspace.ub[50] = (real_t)1.0000000000000000e+12 - acadoVariables.u[46]; acadoWorkspace.ub[51] = (real_t)1.0000000000000000e+12 - acadoVariables.u[47]; acadoWorkspace.ub[52] = (real_t)1.0000000000000000e+12 - acadoVariables.u[48]; acadoWorkspace.ub[53] = (real_t)1.0000000000000000e+12 - acadoVariables.u[49]; acadoWorkspace.ub[54] = (real_t)1.0000000000000000e+12 - acadoVariables.u[50]; acadoWorkspace.ub[55] = (real_t)1.0000000000000000e+12 - acadoVariables.u[51]; acadoWorkspace.ub[56] = (real_t)1.0000000000000000e+12 - acadoVariables.u[52]; acadoWorkspace.ub[57] = (real_t)1.0000000000000000e+12 - acadoVariables.u[53]; acadoWorkspace.ub[58] = (real_t)1.0000000000000000e+12 - acadoVariables.u[54]; acadoWorkspace.ub[59] = (real_t)1.0000000000000000e+12 - acadoVariables.u[55]; acadoWorkspace.ub[60] = (real_t)1.0000000000000000e+12 - acadoVariables.u[56]; acadoWorkspace.ub[61] = (real_t)1.0000000000000000e+12 - acadoVariables.u[57]; acadoWorkspace.ub[62] = (real_t)1.0000000000000000e+12 - acadoVariables.u[58]; acadoWorkspace.ub[63] = (real_t)1.0000000000000000e+12 - acadoVariables.u[59]; acadoWorkspace.ub[64] = (real_t)1.0000000000000000e+12 - acadoVariables.u[60]; acadoWorkspace.ub[65] = (real_t)1.0000000000000000e+12 - acadoVariables.u[61]; acadoWorkspace.ub[66] = (real_t)1.0000000000000000e+12 - acadoVariables.u[62]; acadoWorkspace.ub[67] = (real_t)1.0000000000000000e+12 - acadoVariables.u[63]; for (lRun1 = 0; lRun1 < 32; ++lRun1) { lRun3 = xBoundIndices[ lRun1 ] - 4; lRun4 = ((lRun3) / (4)) + (1); acadoWorkspace.A[lRun1 * 68] = acadoWorkspace.evGx[lRun3 * 4]; acadoWorkspace.A[lRun1 * 68 + 1] = acadoWorkspace.evGx[lRun3 * 4 + 1]; acadoWorkspace.A[lRun1 * 68 + 2] = acadoWorkspace.evGx[lRun3 * 4 + 2]; acadoWorkspace.A[lRun1 * 68 + 3] = acadoWorkspace.evGx[lRun3 * 4 + 3]; for (lRun2 = 0; lRun2 < lRun4; ++lRun2) { lRun5 = (((((lRun4) * (lRun4-1)) / (2)) + (lRun2)) * (4)) + ((lRun3) % (4)); acadoWorkspace.A[(lRun1 * 68) + (lRun2 * 2 + 4)] = acadoWorkspace.E[lRun5 * 2]; acadoWorkspace.A[(lRun1 * 68) + (lRun2 * 2 + 5)] = acadoWorkspace.E[lRun5 * 2 + 1]; } } for (lRun1 = 0; lRun1 < 32; ++lRun1) { acadoWorkspace.conValueIn[0] = acadoVariables.x[lRun1 * 4]; acadoWorkspace.conValueIn[1] = acadoVariables.x[lRun1 * 4 + 1]; acadoWorkspace.conValueIn[2] = acadoVariables.x[lRun1 * 4 + 2]; acadoWorkspace.conValueIn[3] = acadoVariables.x[lRun1 * 4 + 3]; acadoWorkspace.conValueIn[4] = acadoVariables.u[lRun1 * 2]; acadoWorkspace.conValueIn[5] = acadoVariables.u[lRun1 * 2 + 1]; acadoWorkspace.conValueIn[6] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.conValueIn[7] = acadoVariables.od[lRun1 * 2 + 1]; acado_evaluatePathConstraints( acadoWorkspace.conValueIn, acadoWorkspace.conValueOut ); acadoWorkspace.evH[lRun1 * 2] = acadoWorkspace.conValueOut[0]; acadoWorkspace.evH[lRun1 * 2 + 1] = acadoWorkspace.conValueOut[1]; acadoWorkspace.evHx[lRun1 * 8] = acadoWorkspace.conValueOut[2]; acadoWorkspace.evHx[lRun1 * 8 + 1] = acadoWorkspace.conValueOut[3]; acadoWorkspace.evHx[lRun1 * 8 + 2] = acadoWorkspace.conValueOut[4]; acadoWorkspace.evHx[lRun1 * 8 + 3] = acadoWorkspace.conValueOut[5]; acadoWorkspace.evHx[lRun1 * 8 + 4] = acadoWorkspace.conValueOut[6]; acadoWorkspace.evHx[lRun1 * 8 + 5] = acadoWorkspace.conValueOut[7]; acadoWorkspace.evHx[lRun1 * 8 + 6] = acadoWorkspace.conValueOut[8]; acadoWorkspace.evHx[lRun1 * 8 + 7] = acadoWorkspace.conValueOut[9]; acadoWorkspace.evHu[lRun1 * 4] = acadoWorkspace.conValueOut[10]; acadoWorkspace.evHu[lRun1 * 4 + 1] = acadoWorkspace.conValueOut[11]; acadoWorkspace.evHu[lRun1 * 4 + 2] = acadoWorkspace.conValueOut[12]; acadoWorkspace.evHu[lRun1 * 4 + 3] = acadoWorkspace.conValueOut[13]; } acadoWorkspace.A[2176] = acadoWorkspace.evHx[0]; acadoWorkspace.A[2177] = acadoWorkspace.evHx[1]; acadoWorkspace.A[2178] = acadoWorkspace.evHx[2]; acadoWorkspace.A[2179] = acadoWorkspace.evHx[3]; acadoWorkspace.A[2244] = acadoWorkspace.evHx[4]; acadoWorkspace.A[2245] = acadoWorkspace.evHx[5]; acadoWorkspace.A[2246] = acadoWorkspace.evHx[6]; acadoWorkspace.A[2247] = acadoWorkspace.evHx[7]; acado_multHxC( &(acadoWorkspace.evHx[ 8 ]), acadoWorkspace.evGx, &(acadoWorkspace.A[ 2312 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 16 ]), &(acadoWorkspace.evGx[ 16 ]), &(acadoWorkspace.A[ 2448 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 24 ]), &(acadoWorkspace.evGx[ 32 ]), &(acadoWorkspace.A[ 2584 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 32 ]), &(acadoWorkspace.evGx[ 48 ]), &(acadoWorkspace.A[ 2720 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 40 ]), &(acadoWorkspace.evGx[ 64 ]), &(acadoWorkspace.A[ 2856 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 48 ]), &(acadoWorkspace.evGx[ 80 ]), &(acadoWorkspace.A[ 2992 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 56 ]), &(acadoWorkspace.evGx[ 96 ]), &(acadoWorkspace.A[ 3128 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 64 ]), &(acadoWorkspace.evGx[ 112 ]), &(acadoWorkspace.A[ 3264 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 72 ]), &(acadoWorkspace.evGx[ 128 ]), &(acadoWorkspace.A[ 3400 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 80 ]), &(acadoWorkspace.evGx[ 144 ]), &(acadoWorkspace.A[ 3536 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 88 ]), &(acadoWorkspace.evGx[ 160 ]), &(acadoWorkspace.A[ 3672 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 96 ]), &(acadoWorkspace.evGx[ 176 ]), &(acadoWorkspace.A[ 3808 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 104 ]), &(acadoWorkspace.evGx[ 192 ]), &(acadoWorkspace.A[ 3944 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 112 ]), &(acadoWorkspace.evGx[ 208 ]), &(acadoWorkspace.A[ 4080 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 120 ]), &(acadoWorkspace.evGx[ 224 ]), &(acadoWorkspace.A[ 4216 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 128 ]), &(acadoWorkspace.evGx[ 240 ]), &(acadoWorkspace.A[ 4352 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 136 ]), &(acadoWorkspace.evGx[ 256 ]), &(acadoWorkspace.A[ 4488 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 144 ]), &(acadoWorkspace.evGx[ 272 ]), &(acadoWorkspace.A[ 4624 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 152 ]), &(acadoWorkspace.evGx[ 288 ]), &(acadoWorkspace.A[ 4760 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 160 ]), &(acadoWorkspace.evGx[ 304 ]), &(acadoWorkspace.A[ 4896 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 168 ]), &(acadoWorkspace.evGx[ 320 ]), &(acadoWorkspace.A[ 5032 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 176 ]), &(acadoWorkspace.evGx[ 336 ]), &(acadoWorkspace.A[ 5168 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 184 ]), &(acadoWorkspace.evGx[ 352 ]), &(acadoWorkspace.A[ 5304 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 192 ]), &(acadoWorkspace.evGx[ 368 ]), &(acadoWorkspace.A[ 5440 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 200 ]), &(acadoWorkspace.evGx[ 384 ]), &(acadoWorkspace.A[ 5576 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 208 ]), &(acadoWorkspace.evGx[ 400 ]), &(acadoWorkspace.A[ 5712 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 216 ]), &(acadoWorkspace.evGx[ 416 ]), &(acadoWorkspace.A[ 5848 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 224 ]), &(acadoWorkspace.evGx[ 432 ]), &(acadoWorkspace.A[ 5984 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 232 ]), &(acadoWorkspace.evGx[ 448 ]), &(acadoWorkspace.A[ 6120 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 240 ]), &(acadoWorkspace.evGx[ 464 ]), &(acadoWorkspace.A[ 6256 ]) ); acado_multHxC( &(acadoWorkspace.evHx[ 248 ]), &(acadoWorkspace.evGx[ 480 ]), &(acadoWorkspace.A[ 6392 ]) ); for (lRun2 = 0; lRun2 < 31; ++lRun2) { for (lRun3 = 0; lRun3 < lRun2 + 1; ++lRun3) { lRun4 = (((lRun2 + 1) * (lRun2)) / (2)) + (lRun3); lRun5 = lRun2 + 1; acado_multHxE( &(acadoWorkspace.evHx[ lRun2 * 8 + 8 ]), &(acadoWorkspace.E[ lRun4 * 8 ]), lRun5, lRun3 ); } } acadoWorkspace.A[2180] = acadoWorkspace.evHu[0]; acadoWorkspace.A[2181] = acadoWorkspace.evHu[1]; acadoWorkspace.A[2248] = acadoWorkspace.evHu[2]; acadoWorkspace.A[2249] = acadoWorkspace.evHu[3]; acadoWorkspace.A[2318] = acadoWorkspace.evHu[4]; acadoWorkspace.A[2319] = acadoWorkspace.evHu[5]; acadoWorkspace.A[2386] = acadoWorkspace.evHu[6]; acadoWorkspace.A[2387] = acadoWorkspace.evHu[7]; acadoWorkspace.A[2456] = acadoWorkspace.evHu[8]; acadoWorkspace.A[2457] = acadoWorkspace.evHu[9]; acadoWorkspace.A[2524] = acadoWorkspace.evHu[10]; acadoWorkspace.A[2525] = acadoWorkspace.evHu[11]; acadoWorkspace.A[2594] = acadoWorkspace.evHu[12]; acadoWorkspace.A[2595] = acadoWorkspace.evHu[13]; acadoWorkspace.A[2662] = acadoWorkspace.evHu[14]; acadoWorkspace.A[2663] = acadoWorkspace.evHu[15]; acadoWorkspace.A[2732] = acadoWorkspace.evHu[16]; acadoWorkspace.A[2733] = acadoWorkspace.evHu[17]; acadoWorkspace.A[2800] = acadoWorkspace.evHu[18]; acadoWorkspace.A[2801] = acadoWorkspace.evHu[19]; acadoWorkspace.A[2870] = acadoWorkspace.evHu[20]; acadoWorkspace.A[2871] = acadoWorkspace.evHu[21]; acadoWorkspace.A[2938] = acadoWorkspace.evHu[22]; acadoWorkspace.A[2939] = acadoWorkspace.evHu[23]; acadoWorkspace.A[3008] = acadoWorkspace.evHu[24]; acadoWorkspace.A[3009] = acadoWorkspace.evHu[25]; acadoWorkspace.A[3076] = acadoWorkspace.evHu[26]; acadoWorkspace.A[3077] = acadoWorkspace.evHu[27]; acadoWorkspace.A[3146] = acadoWorkspace.evHu[28]; acadoWorkspace.A[3147] = acadoWorkspace.evHu[29]; acadoWorkspace.A[3214] = acadoWorkspace.evHu[30]; acadoWorkspace.A[3215] = acadoWorkspace.evHu[31]; acadoWorkspace.A[3284] = acadoWorkspace.evHu[32]; acadoWorkspace.A[3285] = acadoWorkspace.evHu[33]; acadoWorkspace.A[3352] = acadoWorkspace.evHu[34]; acadoWorkspace.A[3353] = acadoWorkspace.evHu[35]; acadoWorkspace.A[3422] = acadoWorkspace.evHu[36]; acadoWorkspace.A[3423] = acadoWorkspace.evHu[37]; acadoWorkspace.A[3490] = acadoWorkspace.evHu[38]; acadoWorkspace.A[3491] = acadoWorkspace.evHu[39]; acadoWorkspace.A[3560] = acadoWorkspace.evHu[40]; acadoWorkspace.A[3561] = acadoWorkspace.evHu[41]; acadoWorkspace.A[3628] = acadoWorkspace.evHu[42]; acadoWorkspace.A[3629] = acadoWorkspace.evHu[43]; acadoWorkspace.A[3698] = acadoWorkspace.evHu[44]; acadoWorkspace.A[3699] = acadoWorkspace.evHu[45]; acadoWorkspace.A[3766] = acadoWorkspace.evHu[46]; acadoWorkspace.A[3767] = acadoWorkspace.evHu[47]; acadoWorkspace.A[3836] = acadoWorkspace.evHu[48]; acadoWorkspace.A[3837] = acadoWorkspace.evHu[49]; acadoWorkspace.A[3904] = acadoWorkspace.evHu[50]; acadoWorkspace.A[3905] = acadoWorkspace.evHu[51]; acadoWorkspace.A[3974] = acadoWorkspace.evHu[52]; acadoWorkspace.A[3975] = acadoWorkspace.evHu[53]; acadoWorkspace.A[4042] = acadoWorkspace.evHu[54]; acadoWorkspace.A[4043] = acadoWorkspace.evHu[55]; acadoWorkspace.A[4112] = acadoWorkspace.evHu[56]; acadoWorkspace.A[4113] = acadoWorkspace.evHu[57]; acadoWorkspace.A[4180] = acadoWorkspace.evHu[58]; acadoWorkspace.A[4181] = acadoWorkspace.evHu[59]; acadoWorkspace.A[4250] = acadoWorkspace.evHu[60]; acadoWorkspace.A[4251] = acadoWorkspace.evHu[61]; acadoWorkspace.A[4318] = acadoWorkspace.evHu[62]; acadoWorkspace.A[4319] = acadoWorkspace.evHu[63]; acadoWorkspace.A[4388] = acadoWorkspace.evHu[64]; acadoWorkspace.A[4389] = acadoWorkspace.evHu[65]; acadoWorkspace.A[4456] = acadoWorkspace.evHu[66]; acadoWorkspace.A[4457] = acadoWorkspace.evHu[67]; acadoWorkspace.A[4526] = acadoWorkspace.evHu[68]; acadoWorkspace.A[4527] = acadoWorkspace.evHu[69]; acadoWorkspace.A[4594] = acadoWorkspace.evHu[70]; acadoWorkspace.A[4595] = acadoWorkspace.evHu[71]; acadoWorkspace.A[4664] = acadoWorkspace.evHu[72]; acadoWorkspace.A[4665] = acadoWorkspace.evHu[73]; acadoWorkspace.A[4732] = acadoWorkspace.evHu[74]; acadoWorkspace.A[4733] = acadoWorkspace.evHu[75]; acadoWorkspace.A[4802] = acadoWorkspace.evHu[76]; acadoWorkspace.A[4803] = acadoWorkspace.evHu[77]; acadoWorkspace.A[4870] = acadoWorkspace.evHu[78]; acadoWorkspace.A[4871] = acadoWorkspace.evHu[79]; acadoWorkspace.A[4940] = acadoWorkspace.evHu[80]; acadoWorkspace.A[4941] = acadoWorkspace.evHu[81]; acadoWorkspace.A[5008] = acadoWorkspace.evHu[82]; acadoWorkspace.A[5009] = acadoWorkspace.evHu[83]; acadoWorkspace.A[5078] = acadoWorkspace.evHu[84]; acadoWorkspace.A[5079] = acadoWorkspace.evHu[85]; acadoWorkspace.A[5146] = acadoWorkspace.evHu[86]; acadoWorkspace.A[5147] = acadoWorkspace.evHu[87]; acadoWorkspace.A[5216] = acadoWorkspace.evHu[88]; acadoWorkspace.A[5217] = acadoWorkspace.evHu[89]; acadoWorkspace.A[5284] = acadoWorkspace.evHu[90]; acadoWorkspace.A[5285] = acadoWorkspace.evHu[91]; acadoWorkspace.A[5354] = acadoWorkspace.evHu[92]; acadoWorkspace.A[5355] = acadoWorkspace.evHu[93]; acadoWorkspace.A[5422] = acadoWorkspace.evHu[94]; acadoWorkspace.A[5423] = acadoWorkspace.evHu[95]; acadoWorkspace.A[5492] = acadoWorkspace.evHu[96]; acadoWorkspace.A[5493] = acadoWorkspace.evHu[97]; acadoWorkspace.A[5560] = acadoWorkspace.evHu[98]; acadoWorkspace.A[5561] = acadoWorkspace.evHu[99]; acadoWorkspace.A[5630] = acadoWorkspace.evHu[100]; acadoWorkspace.A[5631] = acadoWorkspace.evHu[101]; acadoWorkspace.A[5698] = acadoWorkspace.evHu[102]; acadoWorkspace.A[5699] = acadoWorkspace.evHu[103]; acadoWorkspace.A[5768] = acadoWorkspace.evHu[104]; acadoWorkspace.A[5769] = acadoWorkspace.evHu[105]; acadoWorkspace.A[5836] = acadoWorkspace.evHu[106]; acadoWorkspace.A[5837] = acadoWorkspace.evHu[107]; acadoWorkspace.A[5906] = acadoWorkspace.evHu[108]; acadoWorkspace.A[5907] = acadoWorkspace.evHu[109]; acadoWorkspace.A[5974] = acadoWorkspace.evHu[110]; acadoWorkspace.A[5975] = acadoWorkspace.evHu[111]; acadoWorkspace.A[6044] = acadoWorkspace.evHu[112]; acadoWorkspace.A[6045] = acadoWorkspace.evHu[113]; acadoWorkspace.A[6112] = acadoWorkspace.evHu[114]; acadoWorkspace.A[6113] = acadoWorkspace.evHu[115]; acadoWorkspace.A[6182] = acadoWorkspace.evHu[116]; acadoWorkspace.A[6183] = acadoWorkspace.evHu[117]; acadoWorkspace.A[6250] = acadoWorkspace.evHu[118]; acadoWorkspace.A[6251] = acadoWorkspace.evHu[119]; acadoWorkspace.A[6320] = acadoWorkspace.evHu[120]; acadoWorkspace.A[6321] = acadoWorkspace.evHu[121]; acadoWorkspace.A[6388] = acadoWorkspace.evHu[122]; acadoWorkspace.A[6389] = acadoWorkspace.evHu[123]; acadoWorkspace.A[6458] = acadoWorkspace.evHu[124]; acadoWorkspace.A[6459] = acadoWorkspace.evHu[125]; acadoWorkspace.A[6526] = acadoWorkspace.evHu[126]; acadoWorkspace.A[6527] = acadoWorkspace.evHu[127]; acadoWorkspace.lbA[32] = - acadoWorkspace.evH[0]; acadoWorkspace.lbA[33] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[1]; acadoWorkspace.lbA[34] = - acadoWorkspace.evH[2]; acadoWorkspace.lbA[35] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[3]; acadoWorkspace.lbA[36] = - acadoWorkspace.evH[4]; acadoWorkspace.lbA[37] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[5]; acadoWorkspace.lbA[38] = - acadoWorkspace.evH[6]; acadoWorkspace.lbA[39] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[7]; acadoWorkspace.lbA[40] = - acadoWorkspace.evH[8]; acadoWorkspace.lbA[41] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[9]; acadoWorkspace.lbA[42] = - acadoWorkspace.evH[10]; acadoWorkspace.lbA[43] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[11]; acadoWorkspace.lbA[44] = - acadoWorkspace.evH[12]; acadoWorkspace.lbA[45] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[13]; acadoWorkspace.lbA[46] = - acadoWorkspace.evH[14]; acadoWorkspace.lbA[47] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[15]; acadoWorkspace.lbA[48] = - acadoWorkspace.evH[16]; acadoWorkspace.lbA[49] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[17]; acadoWorkspace.lbA[50] = - acadoWorkspace.evH[18]; acadoWorkspace.lbA[51] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[19]; acadoWorkspace.lbA[52] = - acadoWorkspace.evH[20]; acadoWorkspace.lbA[53] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[21]; acadoWorkspace.lbA[54] = - acadoWorkspace.evH[22]; acadoWorkspace.lbA[55] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[23]; acadoWorkspace.lbA[56] = - acadoWorkspace.evH[24]; acadoWorkspace.lbA[57] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[25]; acadoWorkspace.lbA[58] = - acadoWorkspace.evH[26]; acadoWorkspace.lbA[59] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[27]; acadoWorkspace.lbA[60] = - acadoWorkspace.evH[28]; acadoWorkspace.lbA[61] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[29]; acadoWorkspace.lbA[62] = - acadoWorkspace.evH[30]; acadoWorkspace.lbA[63] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[31]; acadoWorkspace.lbA[64] = - acadoWorkspace.evH[32]; acadoWorkspace.lbA[65] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[33]; acadoWorkspace.lbA[66] = - acadoWorkspace.evH[34]; acadoWorkspace.lbA[67] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[35]; acadoWorkspace.lbA[68] = - acadoWorkspace.evH[36]; acadoWorkspace.lbA[69] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[37]; acadoWorkspace.lbA[70] = - acadoWorkspace.evH[38]; acadoWorkspace.lbA[71] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[39]; acadoWorkspace.lbA[72] = - acadoWorkspace.evH[40]; acadoWorkspace.lbA[73] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[41]; acadoWorkspace.lbA[74] = - acadoWorkspace.evH[42]; acadoWorkspace.lbA[75] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[43]; acadoWorkspace.lbA[76] = - acadoWorkspace.evH[44]; acadoWorkspace.lbA[77] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[45]; acadoWorkspace.lbA[78] = - acadoWorkspace.evH[46]; acadoWorkspace.lbA[79] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[47]; acadoWorkspace.lbA[80] = - acadoWorkspace.evH[48]; acadoWorkspace.lbA[81] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[49]; acadoWorkspace.lbA[82] = - acadoWorkspace.evH[50]; acadoWorkspace.lbA[83] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[51]; acadoWorkspace.lbA[84] = - acadoWorkspace.evH[52]; acadoWorkspace.lbA[85] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[53]; acadoWorkspace.lbA[86] = - acadoWorkspace.evH[54]; acadoWorkspace.lbA[87] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[55]; acadoWorkspace.lbA[88] = - acadoWorkspace.evH[56]; acadoWorkspace.lbA[89] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[57]; acadoWorkspace.lbA[90] = - acadoWorkspace.evH[58]; acadoWorkspace.lbA[91] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[59]; acadoWorkspace.lbA[92] = - acadoWorkspace.evH[60]; acadoWorkspace.lbA[93] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[61]; acadoWorkspace.lbA[94] = - acadoWorkspace.evH[62]; acadoWorkspace.lbA[95] = (real_t)-1.0000000000000000e+12 - acadoWorkspace.evH[63]; acadoWorkspace.ubA[32] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[0]; acadoWorkspace.ubA[33] = - acadoWorkspace.evH[1]; acadoWorkspace.ubA[34] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[2]; acadoWorkspace.ubA[35] = - acadoWorkspace.evH[3]; acadoWorkspace.ubA[36] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[4]; acadoWorkspace.ubA[37] = - acadoWorkspace.evH[5]; acadoWorkspace.ubA[38] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[6]; acadoWorkspace.ubA[39] = - acadoWorkspace.evH[7]; acadoWorkspace.ubA[40] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[8]; acadoWorkspace.ubA[41] = - acadoWorkspace.evH[9]; acadoWorkspace.ubA[42] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[10]; acadoWorkspace.ubA[43] = - acadoWorkspace.evH[11]; acadoWorkspace.ubA[44] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[12]; acadoWorkspace.ubA[45] = - acadoWorkspace.evH[13]; acadoWorkspace.ubA[46] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[14]; acadoWorkspace.ubA[47] = - acadoWorkspace.evH[15]; acadoWorkspace.ubA[48] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[16]; acadoWorkspace.ubA[49] = - acadoWorkspace.evH[17]; acadoWorkspace.ubA[50] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[18]; acadoWorkspace.ubA[51] = - acadoWorkspace.evH[19]; acadoWorkspace.ubA[52] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[20]; acadoWorkspace.ubA[53] = - acadoWorkspace.evH[21]; acadoWorkspace.ubA[54] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[22]; acadoWorkspace.ubA[55] = - acadoWorkspace.evH[23]; acadoWorkspace.ubA[56] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[24]; acadoWorkspace.ubA[57] = - acadoWorkspace.evH[25]; acadoWorkspace.ubA[58] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[26]; acadoWorkspace.ubA[59] = - acadoWorkspace.evH[27]; acadoWorkspace.ubA[60] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[28]; acadoWorkspace.ubA[61] = - acadoWorkspace.evH[29]; acadoWorkspace.ubA[62] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[30]; acadoWorkspace.ubA[63] = - acadoWorkspace.evH[31]; acadoWorkspace.ubA[64] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[32]; acadoWorkspace.ubA[65] = - acadoWorkspace.evH[33]; acadoWorkspace.ubA[66] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[34]; acadoWorkspace.ubA[67] = - acadoWorkspace.evH[35]; acadoWorkspace.ubA[68] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[36]; acadoWorkspace.ubA[69] = - acadoWorkspace.evH[37]; acadoWorkspace.ubA[70] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[38]; acadoWorkspace.ubA[71] = - acadoWorkspace.evH[39]; acadoWorkspace.ubA[72] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[40]; acadoWorkspace.ubA[73] = - acadoWorkspace.evH[41]; acadoWorkspace.ubA[74] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[42]; acadoWorkspace.ubA[75] = - acadoWorkspace.evH[43]; acadoWorkspace.ubA[76] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[44]; acadoWorkspace.ubA[77] = - acadoWorkspace.evH[45]; acadoWorkspace.ubA[78] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[46]; acadoWorkspace.ubA[79] = - acadoWorkspace.evH[47]; acadoWorkspace.ubA[80] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[48]; acadoWorkspace.ubA[81] = - acadoWorkspace.evH[49]; acadoWorkspace.ubA[82] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[50]; acadoWorkspace.ubA[83] = - acadoWorkspace.evH[51]; acadoWorkspace.ubA[84] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[52]; acadoWorkspace.ubA[85] = - acadoWorkspace.evH[53]; acadoWorkspace.ubA[86] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[54]; acadoWorkspace.ubA[87] = - acadoWorkspace.evH[55]; acadoWorkspace.ubA[88] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[56]; acadoWorkspace.ubA[89] = - acadoWorkspace.evH[57]; acadoWorkspace.ubA[90] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[58]; acadoWorkspace.ubA[91] = - acadoWorkspace.evH[59]; acadoWorkspace.ubA[92] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[60]; acadoWorkspace.ubA[93] = - acadoWorkspace.evH[61]; acadoWorkspace.ubA[94] = (real_t)1.0000000000000000e+12 - acadoWorkspace.evH[62]; acadoWorkspace.ubA[95] = - acadoWorkspace.evH[63]; acado_macHxd( &(acadoWorkspace.evHx[ 8 ]), acadoWorkspace.d, &(acadoWorkspace.lbA[ 34 ]), &(acadoWorkspace.ubA[ 34 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 16 ]), &(acadoWorkspace.d[ 4 ]), &(acadoWorkspace.lbA[ 36 ]), &(acadoWorkspace.ubA[ 36 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 24 ]), &(acadoWorkspace.d[ 8 ]), &(acadoWorkspace.lbA[ 38 ]), &(acadoWorkspace.ubA[ 38 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 32 ]), &(acadoWorkspace.d[ 12 ]), &(acadoWorkspace.lbA[ 40 ]), &(acadoWorkspace.ubA[ 40 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 40 ]), &(acadoWorkspace.d[ 16 ]), &(acadoWorkspace.lbA[ 42 ]), &(acadoWorkspace.ubA[ 42 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 48 ]), &(acadoWorkspace.d[ 20 ]), &(acadoWorkspace.lbA[ 44 ]), &(acadoWorkspace.ubA[ 44 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 56 ]), &(acadoWorkspace.d[ 24 ]), &(acadoWorkspace.lbA[ 46 ]), &(acadoWorkspace.ubA[ 46 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 64 ]), &(acadoWorkspace.d[ 28 ]), &(acadoWorkspace.lbA[ 48 ]), &(acadoWorkspace.ubA[ 48 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 72 ]), &(acadoWorkspace.d[ 32 ]), &(acadoWorkspace.lbA[ 50 ]), &(acadoWorkspace.ubA[ 50 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 80 ]), &(acadoWorkspace.d[ 36 ]), &(acadoWorkspace.lbA[ 52 ]), &(acadoWorkspace.ubA[ 52 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 88 ]), &(acadoWorkspace.d[ 40 ]), &(acadoWorkspace.lbA[ 54 ]), &(acadoWorkspace.ubA[ 54 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 96 ]), &(acadoWorkspace.d[ 44 ]), &(acadoWorkspace.lbA[ 56 ]), &(acadoWorkspace.ubA[ 56 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 104 ]), &(acadoWorkspace.d[ 48 ]), &(acadoWorkspace.lbA[ 58 ]), &(acadoWorkspace.ubA[ 58 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 112 ]), &(acadoWorkspace.d[ 52 ]), &(acadoWorkspace.lbA[ 60 ]), &(acadoWorkspace.ubA[ 60 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 120 ]), &(acadoWorkspace.d[ 56 ]), &(acadoWorkspace.lbA[ 62 ]), &(acadoWorkspace.ubA[ 62 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 128 ]), &(acadoWorkspace.d[ 60 ]), &(acadoWorkspace.lbA[ 64 ]), &(acadoWorkspace.ubA[ 64 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 136 ]), &(acadoWorkspace.d[ 64 ]), &(acadoWorkspace.lbA[ 66 ]), &(acadoWorkspace.ubA[ 66 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 144 ]), &(acadoWorkspace.d[ 68 ]), &(acadoWorkspace.lbA[ 68 ]), &(acadoWorkspace.ubA[ 68 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 152 ]), &(acadoWorkspace.d[ 72 ]), &(acadoWorkspace.lbA[ 70 ]), &(acadoWorkspace.ubA[ 70 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 160 ]), &(acadoWorkspace.d[ 76 ]), &(acadoWorkspace.lbA[ 72 ]), &(acadoWorkspace.ubA[ 72 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 168 ]), &(acadoWorkspace.d[ 80 ]), &(acadoWorkspace.lbA[ 74 ]), &(acadoWorkspace.ubA[ 74 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 176 ]), &(acadoWorkspace.d[ 84 ]), &(acadoWorkspace.lbA[ 76 ]), &(acadoWorkspace.ubA[ 76 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 184 ]), &(acadoWorkspace.d[ 88 ]), &(acadoWorkspace.lbA[ 78 ]), &(acadoWorkspace.ubA[ 78 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 192 ]), &(acadoWorkspace.d[ 92 ]), &(acadoWorkspace.lbA[ 80 ]), &(acadoWorkspace.ubA[ 80 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 200 ]), &(acadoWorkspace.d[ 96 ]), &(acadoWorkspace.lbA[ 82 ]), &(acadoWorkspace.ubA[ 82 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 208 ]), &(acadoWorkspace.d[ 100 ]), &(acadoWorkspace.lbA[ 84 ]), &(acadoWorkspace.ubA[ 84 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 216 ]), &(acadoWorkspace.d[ 104 ]), &(acadoWorkspace.lbA[ 86 ]), &(acadoWorkspace.ubA[ 86 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 224 ]), &(acadoWorkspace.d[ 108 ]), &(acadoWorkspace.lbA[ 88 ]), &(acadoWorkspace.ubA[ 88 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 232 ]), &(acadoWorkspace.d[ 112 ]), &(acadoWorkspace.lbA[ 90 ]), &(acadoWorkspace.ubA[ 90 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 240 ]), &(acadoWorkspace.d[ 116 ]), &(acadoWorkspace.lbA[ 92 ]), &(acadoWorkspace.ubA[ 92 ]) ); acado_macHxd( &(acadoWorkspace.evHx[ 248 ]), &(acadoWorkspace.d[ 120 ]), &(acadoWorkspace.lbA[ 94 ]), &(acadoWorkspace.ubA[ 94 ]) ); } void acado_condenseFdb( ) { int lRun1; int lRun2; int lRun3; real_t tmp; acadoWorkspace.Dx0[0] = acadoVariables.x0[0] - acadoVariables.x[0]; acadoWorkspace.Dx0[1] = acadoVariables.x0[1] - acadoVariables.x[1]; acadoWorkspace.Dx0[2] = acadoVariables.x0[2] - acadoVariables.x[2]; acadoWorkspace.Dx0[3] = acadoVariables.x0[3] - acadoVariables.x[3]; for (lRun2 = 0; lRun2 < 160; ++lRun2) acadoWorkspace.Dy[lRun2] -= acadoVariables.y[lRun2]; acadoWorkspace.DyN[0] -= acadoVariables.yN[0]; acadoWorkspace.DyN[1] -= acadoVariables.yN[1]; acadoWorkspace.DyN[2] -= acadoVariables.yN[2]; acado_multRDy( acadoWorkspace.R2, acadoWorkspace.Dy, &(acadoWorkspace.g[ 4 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 10 ]), &(acadoWorkspace.Dy[ 5 ]), &(acadoWorkspace.g[ 6 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 20 ]), &(acadoWorkspace.Dy[ 10 ]), &(acadoWorkspace.g[ 8 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 30 ]), &(acadoWorkspace.Dy[ 15 ]), &(acadoWorkspace.g[ 10 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 40 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.g[ 12 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 50 ]), &(acadoWorkspace.Dy[ 25 ]), &(acadoWorkspace.g[ 14 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 60 ]), &(acadoWorkspace.Dy[ 30 ]), &(acadoWorkspace.g[ 16 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 70 ]), &(acadoWorkspace.Dy[ 35 ]), &(acadoWorkspace.g[ 18 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 80 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.g[ 20 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 90 ]), &(acadoWorkspace.Dy[ 45 ]), &(acadoWorkspace.g[ 22 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 100 ]), &(acadoWorkspace.Dy[ 50 ]), &(acadoWorkspace.g[ 24 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 110 ]), &(acadoWorkspace.Dy[ 55 ]), &(acadoWorkspace.g[ 26 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 120 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.g[ 28 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 130 ]), &(acadoWorkspace.Dy[ 65 ]), &(acadoWorkspace.g[ 30 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 140 ]), &(acadoWorkspace.Dy[ 70 ]), &(acadoWorkspace.g[ 32 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 150 ]), &(acadoWorkspace.Dy[ 75 ]), &(acadoWorkspace.g[ 34 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 160 ]), &(acadoWorkspace.Dy[ 80 ]), &(acadoWorkspace.g[ 36 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 170 ]), &(acadoWorkspace.Dy[ 85 ]), &(acadoWorkspace.g[ 38 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 180 ]), &(acadoWorkspace.Dy[ 90 ]), &(acadoWorkspace.g[ 40 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 190 ]), &(acadoWorkspace.Dy[ 95 ]), &(acadoWorkspace.g[ 42 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 200 ]), &(acadoWorkspace.Dy[ 100 ]), &(acadoWorkspace.g[ 44 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 210 ]), &(acadoWorkspace.Dy[ 105 ]), &(acadoWorkspace.g[ 46 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 220 ]), &(acadoWorkspace.Dy[ 110 ]), &(acadoWorkspace.g[ 48 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 230 ]), &(acadoWorkspace.Dy[ 115 ]), &(acadoWorkspace.g[ 50 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 240 ]), &(acadoWorkspace.Dy[ 120 ]), &(acadoWorkspace.g[ 52 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 250 ]), &(acadoWorkspace.Dy[ 125 ]), &(acadoWorkspace.g[ 54 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 260 ]), &(acadoWorkspace.Dy[ 130 ]), &(acadoWorkspace.g[ 56 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 270 ]), &(acadoWorkspace.Dy[ 135 ]), &(acadoWorkspace.g[ 58 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 280 ]), &(acadoWorkspace.Dy[ 140 ]), &(acadoWorkspace.g[ 60 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 290 ]), &(acadoWorkspace.Dy[ 145 ]), &(acadoWorkspace.g[ 62 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 300 ]), &(acadoWorkspace.Dy[ 150 ]), &(acadoWorkspace.g[ 64 ]) ); acado_multRDy( &(acadoWorkspace.R2[ 310 ]), &(acadoWorkspace.Dy[ 155 ]), &(acadoWorkspace.g[ 66 ]) ); acado_multQDy( acadoWorkspace.Q2, acadoWorkspace.Dy, acadoWorkspace.QDy ); acado_multQDy( &(acadoWorkspace.Q2[ 20 ]), &(acadoWorkspace.Dy[ 5 ]), &(acadoWorkspace.QDy[ 4 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 40 ]), &(acadoWorkspace.Dy[ 10 ]), &(acadoWorkspace.QDy[ 8 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 60 ]), &(acadoWorkspace.Dy[ 15 ]), &(acadoWorkspace.QDy[ 12 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 80 ]), &(acadoWorkspace.Dy[ 20 ]), &(acadoWorkspace.QDy[ 16 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 100 ]), &(acadoWorkspace.Dy[ 25 ]), &(acadoWorkspace.QDy[ 20 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 120 ]), &(acadoWorkspace.Dy[ 30 ]), &(acadoWorkspace.QDy[ 24 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 140 ]), &(acadoWorkspace.Dy[ 35 ]), &(acadoWorkspace.QDy[ 28 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 160 ]), &(acadoWorkspace.Dy[ 40 ]), &(acadoWorkspace.QDy[ 32 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 180 ]), &(acadoWorkspace.Dy[ 45 ]), &(acadoWorkspace.QDy[ 36 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 200 ]), &(acadoWorkspace.Dy[ 50 ]), &(acadoWorkspace.QDy[ 40 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 220 ]), &(acadoWorkspace.Dy[ 55 ]), &(acadoWorkspace.QDy[ 44 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 240 ]), &(acadoWorkspace.Dy[ 60 ]), &(acadoWorkspace.QDy[ 48 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 260 ]), &(acadoWorkspace.Dy[ 65 ]), &(acadoWorkspace.QDy[ 52 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 280 ]), &(acadoWorkspace.Dy[ 70 ]), &(acadoWorkspace.QDy[ 56 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 300 ]), &(acadoWorkspace.Dy[ 75 ]), &(acadoWorkspace.QDy[ 60 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 320 ]), &(acadoWorkspace.Dy[ 80 ]), &(acadoWorkspace.QDy[ 64 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 340 ]), &(acadoWorkspace.Dy[ 85 ]), &(acadoWorkspace.QDy[ 68 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 360 ]), &(acadoWorkspace.Dy[ 90 ]), &(acadoWorkspace.QDy[ 72 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 380 ]), &(acadoWorkspace.Dy[ 95 ]), &(acadoWorkspace.QDy[ 76 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 400 ]), &(acadoWorkspace.Dy[ 100 ]), &(acadoWorkspace.QDy[ 80 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 420 ]), &(acadoWorkspace.Dy[ 105 ]), &(acadoWorkspace.QDy[ 84 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 440 ]), &(acadoWorkspace.Dy[ 110 ]), &(acadoWorkspace.QDy[ 88 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 460 ]), &(acadoWorkspace.Dy[ 115 ]), &(acadoWorkspace.QDy[ 92 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 480 ]), &(acadoWorkspace.Dy[ 120 ]), &(acadoWorkspace.QDy[ 96 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 500 ]), &(acadoWorkspace.Dy[ 125 ]), &(acadoWorkspace.QDy[ 100 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 520 ]), &(acadoWorkspace.Dy[ 130 ]), &(acadoWorkspace.QDy[ 104 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 540 ]), &(acadoWorkspace.Dy[ 135 ]), &(acadoWorkspace.QDy[ 108 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 560 ]), &(acadoWorkspace.Dy[ 140 ]), &(acadoWorkspace.QDy[ 112 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 580 ]), &(acadoWorkspace.Dy[ 145 ]), &(acadoWorkspace.QDy[ 116 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 600 ]), &(acadoWorkspace.Dy[ 150 ]), &(acadoWorkspace.QDy[ 120 ]) ); acado_multQDy( &(acadoWorkspace.Q2[ 620 ]), &(acadoWorkspace.Dy[ 155 ]), &(acadoWorkspace.QDy[ 124 ]) ); acadoWorkspace.QDy[128] = + acadoWorkspace.QN2[0]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[1]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[2]*acadoWorkspace.DyN[2]; acadoWorkspace.QDy[129] = + acadoWorkspace.QN2[3]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[4]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[5]*acadoWorkspace.DyN[2]; acadoWorkspace.QDy[130] = + acadoWorkspace.QN2[6]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[7]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[8]*acadoWorkspace.DyN[2]; acadoWorkspace.QDy[131] = + acadoWorkspace.QN2[9]*acadoWorkspace.DyN[0] + acadoWorkspace.QN2[10]*acadoWorkspace.DyN[1] + acadoWorkspace.QN2[11]*acadoWorkspace.DyN[2]; for (lRun2 = 0; lRun2 < 128; ++lRun2) acadoWorkspace.QDy[lRun2 + 4] += acadoWorkspace.Qd[lRun2]; acadoWorkspace.g[0] = + acadoWorkspace.evGx[0]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[4]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[8]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[12]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[16]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[20]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[24]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[28]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[32]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[36]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[40]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[44]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[48]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[52]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[56]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[60]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[64]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[68]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[72]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[76]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[80]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[84]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[88]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[92]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[96]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[100]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[104]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[108]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[112]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[116]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[120]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[124]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[128]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[132]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[136]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[140]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[144]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[148]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[152]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[156]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[160]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[164]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[168]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[172]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[176]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[180]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[184]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[188]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[192]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[196]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[200]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[204]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[208]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[212]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[216]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[220]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[224]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[228]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[232]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[236]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[240]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[244]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[248]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[252]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[256]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[260]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[264]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[268]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[272]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[276]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[280]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[284]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[288]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[292]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[296]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[300]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[304]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[308]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[312]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[316]*acadoWorkspace.QDy[83] + acadoWorkspace.evGx[320]*acadoWorkspace.QDy[84] + acadoWorkspace.evGx[324]*acadoWorkspace.QDy[85] + acadoWorkspace.evGx[328]*acadoWorkspace.QDy[86] + acadoWorkspace.evGx[332]*acadoWorkspace.QDy[87] + acadoWorkspace.evGx[336]*acadoWorkspace.QDy[88] + acadoWorkspace.evGx[340]*acadoWorkspace.QDy[89] + acadoWorkspace.evGx[344]*acadoWorkspace.QDy[90] + acadoWorkspace.evGx[348]*acadoWorkspace.QDy[91] + acadoWorkspace.evGx[352]*acadoWorkspace.QDy[92] + acadoWorkspace.evGx[356]*acadoWorkspace.QDy[93] + acadoWorkspace.evGx[360]*acadoWorkspace.QDy[94] + acadoWorkspace.evGx[364]*acadoWorkspace.QDy[95] + acadoWorkspace.evGx[368]*acadoWorkspace.QDy[96] + acadoWorkspace.evGx[372]*acadoWorkspace.QDy[97] + acadoWorkspace.evGx[376]*acadoWorkspace.QDy[98] + acadoWorkspace.evGx[380]*acadoWorkspace.QDy[99] + acadoWorkspace.evGx[384]*acadoWorkspace.QDy[100] + acadoWorkspace.evGx[388]*acadoWorkspace.QDy[101] + acadoWorkspace.evGx[392]*acadoWorkspace.QDy[102] + acadoWorkspace.evGx[396]*acadoWorkspace.QDy[103] + acadoWorkspace.evGx[400]*acadoWorkspace.QDy[104] + acadoWorkspace.evGx[404]*acadoWorkspace.QDy[105] + acadoWorkspace.evGx[408]*acadoWorkspace.QDy[106] + acadoWorkspace.evGx[412]*acadoWorkspace.QDy[107] + acadoWorkspace.evGx[416]*acadoWorkspace.QDy[108] + acadoWorkspace.evGx[420]*acadoWorkspace.QDy[109] + acadoWorkspace.evGx[424]*acadoWorkspace.QDy[110] + acadoWorkspace.evGx[428]*acadoWorkspace.QDy[111] + acadoWorkspace.evGx[432]*acadoWorkspace.QDy[112] + acadoWorkspace.evGx[436]*acadoWorkspace.QDy[113] + acadoWorkspace.evGx[440]*acadoWorkspace.QDy[114] + acadoWorkspace.evGx[444]*acadoWorkspace.QDy[115] + acadoWorkspace.evGx[448]*acadoWorkspace.QDy[116] + acadoWorkspace.evGx[452]*acadoWorkspace.QDy[117] + acadoWorkspace.evGx[456]*acadoWorkspace.QDy[118] + acadoWorkspace.evGx[460]*acadoWorkspace.QDy[119] + acadoWorkspace.evGx[464]*acadoWorkspace.QDy[120] + acadoWorkspace.evGx[468]*acadoWorkspace.QDy[121] + acadoWorkspace.evGx[472]*acadoWorkspace.QDy[122] + acadoWorkspace.evGx[476]*acadoWorkspace.QDy[123] + acadoWorkspace.evGx[480]*acadoWorkspace.QDy[124] + acadoWorkspace.evGx[484]*acadoWorkspace.QDy[125] + acadoWorkspace.evGx[488]*acadoWorkspace.QDy[126] + acadoWorkspace.evGx[492]*acadoWorkspace.QDy[127] + acadoWorkspace.evGx[496]*acadoWorkspace.QDy[128] + acadoWorkspace.evGx[500]*acadoWorkspace.QDy[129] + acadoWorkspace.evGx[504]*acadoWorkspace.QDy[130] + acadoWorkspace.evGx[508]*acadoWorkspace.QDy[131]; acadoWorkspace.g[1] = + acadoWorkspace.evGx[1]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[5]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[9]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[13]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[17]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[21]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[25]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[29]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[33]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[37]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[41]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[45]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[49]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[53]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[57]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[61]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[65]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[69]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[73]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[77]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[81]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[85]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[89]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[93]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[97]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[101]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[105]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[109]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[113]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[117]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[121]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[125]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[129]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[133]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[137]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[141]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[145]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[149]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[153]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[157]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[161]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[165]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[169]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[173]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[177]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[181]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[185]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[189]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[193]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[197]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[201]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[205]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[209]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[213]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[217]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[221]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[225]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[229]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[233]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[237]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[241]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[245]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[249]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[253]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[257]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[261]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[265]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[269]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[273]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[277]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[281]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[285]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[289]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[293]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[297]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[301]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[305]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[309]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[313]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[317]*acadoWorkspace.QDy[83] + acadoWorkspace.evGx[321]*acadoWorkspace.QDy[84] + acadoWorkspace.evGx[325]*acadoWorkspace.QDy[85] + acadoWorkspace.evGx[329]*acadoWorkspace.QDy[86] + acadoWorkspace.evGx[333]*acadoWorkspace.QDy[87] + acadoWorkspace.evGx[337]*acadoWorkspace.QDy[88] + acadoWorkspace.evGx[341]*acadoWorkspace.QDy[89] + acadoWorkspace.evGx[345]*acadoWorkspace.QDy[90] + acadoWorkspace.evGx[349]*acadoWorkspace.QDy[91] + acadoWorkspace.evGx[353]*acadoWorkspace.QDy[92] + acadoWorkspace.evGx[357]*acadoWorkspace.QDy[93] + acadoWorkspace.evGx[361]*acadoWorkspace.QDy[94] + acadoWorkspace.evGx[365]*acadoWorkspace.QDy[95] + acadoWorkspace.evGx[369]*acadoWorkspace.QDy[96] + acadoWorkspace.evGx[373]*acadoWorkspace.QDy[97] + acadoWorkspace.evGx[377]*acadoWorkspace.QDy[98] + acadoWorkspace.evGx[381]*acadoWorkspace.QDy[99] + acadoWorkspace.evGx[385]*acadoWorkspace.QDy[100] + acadoWorkspace.evGx[389]*acadoWorkspace.QDy[101] + acadoWorkspace.evGx[393]*acadoWorkspace.QDy[102] + acadoWorkspace.evGx[397]*acadoWorkspace.QDy[103] + acadoWorkspace.evGx[401]*acadoWorkspace.QDy[104] + acadoWorkspace.evGx[405]*acadoWorkspace.QDy[105] + acadoWorkspace.evGx[409]*acadoWorkspace.QDy[106] + acadoWorkspace.evGx[413]*acadoWorkspace.QDy[107] + acadoWorkspace.evGx[417]*acadoWorkspace.QDy[108] + acadoWorkspace.evGx[421]*acadoWorkspace.QDy[109] + acadoWorkspace.evGx[425]*acadoWorkspace.QDy[110] + acadoWorkspace.evGx[429]*acadoWorkspace.QDy[111] + acadoWorkspace.evGx[433]*acadoWorkspace.QDy[112] + acadoWorkspace.evGx[437]*acadoWorkspace.QDy[113] + acadoWorkspace.evGx[441]*acadoWorkspace.QDy[114] + acadoWorkspace.evGx[445]*acadoWorkspace.QDy[115] + acadoWorkspace.evGx[449]*acadoWorkspace.QDy[116] + acadoWorkspace.evGx[453]*acadoWorkspace.QDy[117] + acadoWorkspace.evGx[457]*acadoWorkspace.QDy[118] + acadoWorkspace.evGx[461]*acadoWorkspace.QDy[119] + acadoWorkspace.evGx[465]*acadoWorkspace.QDy[120] + acadoWorkspace.evGx[469]*acadoWorkspace.QDy[121] + acadoWorkspace.evGx[473]*acadoWorkspace.QDy[122] + acadoWorkspace.evGx[477]*acadoWorkspace.QDy[123] + acadoWorkspace.evGx[481]*acadoWorkspace.QDy[124] + acadoWorkspace.evGx[485]*acadoWorkspace.QDy[125] + acadoWorkspace.evGx[489]*acadoWorkspace.QDy[126] + acadoWorkspace.evGx[493]*acadoWorkspace.QDy[127] + acadoWorkspace.evGx[497]*acadoWorkspace.QDy[128] + acadoWorkspace.evGx[501]*acadoWorkspace.QDy[129] + acadoWorkspace.evGx[505]*acadoWorkspace.QDy[130] + acadoWorkspace.evGx[509]*acadoWorkspace.QDy[131]; acadoWorkspace.g[2] = + acadoWorkspace.evGx[2]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[6]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[10]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[14]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[18]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[22]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[26]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[30]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[34]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[38]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[42]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[46]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[50]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[54]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[58]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[62]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[66]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[70]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[74]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[78]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[82]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[86]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[90]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[94]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[98]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[102]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[106]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[110]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[114]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[118]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[122]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[126]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[130]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[134]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[138]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[142]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[146]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[150]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[154]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[158]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[162]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[166]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[170]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[174]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[178]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[182]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[186]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[190]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[194]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[198]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[202]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[206]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[210]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[214]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[218]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[222]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[226]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[230]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[234]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[238]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[242]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[246]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[250]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[254]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[258]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[262]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[266]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[270]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[274]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[278]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[282]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[286]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[290]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[294]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[298]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[302]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[306]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[310]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[314]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[318]*acadoWorkspace.QDy[83] + acadoWorkspace.evGx[322]*acadoWorkspace.QDy[84] + acadoWorkspace.evGx[326]*acadoWorkspace.QDy[85] + acadoWorkspace.evGx[330]*acadoWorkspace.QDy[86] + acadoWorkspace.evGx[334]*acadoWorkspace.QDy[87] + acadoWorkspace.evGx[338]*acadoWorkspace.QDy[88] + acadoWorkspace.evGx[342]*acadoWorkspace.QDy[89] + acadoWorkspace.evGx[346]*acadoWorkspace.QDy[90] + acadoWorkspace.evGx[350]*acadoWorkspace.QDy[91] + acadoWorkspace.evGx[354]*acadoWorkspace.QDy[92] + acadoWorkspace.evGx[358]*acadoWorkspace.QDy[93] + acadoWorkspace.evGx[362]*acadoWorkspace.QDy[94] + acadoWorkspace.evGx[366]*acadoWorkspace.QDy[95] + acadoWorkspace.evGx[370]*acadoWorkspace.QDy[96] + acadoWorkspace.evGx[374]*acadoWorkspace.QDy[97] + acadoWorkspace.evGx[378]*acadoWorkspace.QDy[98] + acadoWorkspace.evGx[382]*acadoWorkspace.QDy[99] + acadoWorkspace.evGx[386]*acadoWorkspace.QDy[100] + acadoWorkspace.evGx[390]*acadoWorkspace.QDy[101] + acadoWorkspace.evGx[394]*acadoWorkspace.QDy[102] + acadoWorkspace.evGx[398]*acadoWorkspace.QDy[103] + acadoWorkspace.evGx[402]*acadoWorkspace.QDy[104] + acadoWorkspace.evGx[406]*acadoWorkspace.QDy[105] + acadoWorkspace.evGx[410]*acadoWorkspace.QDy[106] + acadoWorkspace.evGx[414]*acadoWorkspace.QDy[107] + acadoWorkspace.evGx[418]*acadoWorkspace.QDy[108] + acadoWorkspace.evGx[422]*acadoWorkspace.QDy[109] + acadoWorkspace.evGx[426]*acadoWorkspace.QDy[110] + acadoWorkspace.evGx[430]*acadoWorkspace.QDy[111] + acadoWorkspace.evGx[434]*acadoWorkspace.QDy[112] + acadoWorkspace.evGx[438]*acadoWorkspace.QDy[113] + acadoWorkspace.evGx[442]*acadoWorkspace.QDy[114] + acadoWorkspace.evGx[446]*acadoWorkspace.QDy[115] + acadoWorkspace.evGx[450]*acadoWorkspace.QDy[116] + acadoWorkspace.evGx[454]*acadoWorkspace.QDy[117] + acadoWorkspace.evGx[458]*acadoWorkspace.QDy[118] + acadoWorkspace.evGx[462]*acadoWorkspace.QDy[119] + acadoWorkspace.evGx[466]*acadoWorkspace.QDy[120] + acadoWorkspace.evGx[470]*acadoWorkspace.QDy[121] + acadoWorkspace.evGx[474]*acadoWorkspace.QDy[122] + acadoWorkspace.evGx[478]*acadoWorkspace.QDy[123] + acadoWorkspace.evGx[482]*acadoWorkspace.QDy[124] + acadoWorkspace.evGx[486]*acadoWorkspace.QDy[125] + acadoWorkspace.evGx[490]*acadoWorkspace.QDy[126] + acadoWorkspace.evGx[494]*acadoWorkspace.QDy[127] + acadoWorkspace.evGx[498]*acadoWorkspace.QDy[128] + acadoWorkspace.evGx[502]*acadoWorkspace.QDy[129] + acadoWorkspace.evGx[506]*acadoWorkspace.QDy[130] + acadoWorkspace.evGx[510]*acadoWorkspace.QDy[131]; acadoWorkspace.g[3] = + acadoWorkspace.evGx[3]*acadoWorkspace.QDy[4] + acadoWorkspace.evGx[7]*acadoWorkspace.QDy[5] + acadoWorkspace.evGx[11]*acadoWorkspace.QDy[6] + acadoWorkspace.evGx[15]*acadoWorkspace.QDy[7] + acadoWorkspace.evGx[19]*acadoWorkspace.QDy[8] + acadoWorkspace.evGx[23]*acadoWorkspace.QDy[9] + acadoWorkspace.evGx[27]*acadoWorkspace.QDy[10] + acadoWorkspace.evGx[31]*acadoWorkspace.QDy[11] + acadoWorkspace.evGx[35]*acadoWorkspace.QDy[12] + acadoWorkspace.evGx[39]*acadoWorkspace.QDy[13] + acadoWorkspace.evGx[43]*acadoWorkspace.QDy[14] + acadoWorkspace.evGx[47]*acadoWorkspace.QDy[15] + acadoWorkspace.evGx[51]*acadoWorkspace.QDy[16] + acadoWorkspace.evGx[55]*acadoWorkspace.QDy[17] + acadoWorkspace.evGx[59]*acadoWorkspace.QDy[18] + acadoWorkspace.evGx[63]*acadoWorkspace.QDy[19] + acadoWorkspace.evGx[67]*acadoWorkspace.QDy[20] + acadoWorkspace.evGx[71]*acadoWorkspace.QDy[21] + acadoWorkspace.evGx[75]*acadoWorkspace.QDy[22] + acadoWorkspace.evGx[79]*acadoWorkspace.QDy[23] + acadoWorkspace.evGx[83]*acadoWorkspace.QDy[24] + acadoWorkspace.evGx[87]*acadoWorkspace.QDy[25] + acadoWorkspace.evGx[91]*acadoWorkspace.QDy[26] + acadoWorkspace.evGx[95]*acadoWorkspace.QDy[27] + acadoWorkspace.evGx[99]*acadoWorkspace.QDy[28] + acadoWorkspace.evGx[103]*acadoWorkspace.QDy[29] + acadoWorkspace.evGx[107]*acadoWorkspace.QDy[30] + acadoWorkspace.evGx[111]*acadoWorkspace.QDy[31] + acadoWorkspace.evGx[115]*acadoWorkspace.QDy[32] + acadoWorkspace.evGx[119]*acadoWorkspace.QDy[33] + acadoWorkspace.evGx[123]*acadoWorkspace.QDy[34] + acadoWorkspace.evGx[127]*acadoWorkspace.QDy[35] + acadoWorkspace.evGx[131]*acadoWorkspace.QDy[36] + acadoWorkspace.evGx[135]*acadoWorkspace.QDy[37] + acadoWorkspace.evGx[139]*acadoWorkspace.QDy[38] + acadoWorkspace.evGx[143]*acadoWorkspace.QDy[39] + acadoWorkspace.evGx[147]*acadoWorkspace.QDy[40] + acadoWorkspace.evGx[151]*acadoWorkspace.QDy[41] + acadoWorkspace.evGx[155]*acadoWorkspace.QDy[42] + acadoWorkspace.evGx[159]*acadoWorkspace.QDy[43] + acadoWorkspace.evGx[163]*acadoWorkspace.QDy[44] + acadoWorkspace.evGx[167]*acadoWorkspace.QDy[45] + acadoWorkspace.evGx[171]*acadoWorkspace.QDy[46] + acadoWorkspace.evGx[175]*acadoWorkspace.QDy[47] + acadoWorkspace.evGx[179]*acadoWorkspace.QDy[48] + acadoWorkspace.evGx[183]*acadoWorkspace.QDy[49] + acadoWorkspace.evGx[187]*acadoWorkspace.QDy[50] + acadoWorkspace.evGx[191]*acadoWorkspace.QDy[51] + acadoWorkspace.evGx[195]*acadoWorkspace.QDy[52] + acadoWorkspace.evGx[199]*acadoWorkspace.QDy[53] + acadoWorkspace.evGx[203]*acadoWorkspace.QDy[54] + acadoWorkspace.evGx[207]*acadoWorkspace.QDy[55] + acadoWorkspace.evGx[211]*acadoWorkspace.QDy[56] + acadoWorkspace.evGx[215]*acadoWorkspace.QDy[57] + acadoWorkspace.evGx[219]*acadoWorkspace.QDy[58] + acadoWorkspace.evGx[223]*acadoWorkspace.QDy[59] + acadoWorkspace.evGx[227]*acadoWorkspace.QDy[60] + acadoWorkspace.evGx[231]*acadoWorkspace.QDy[61] + acadoWorkspace.evGx[235]*acadoWorkspace.QDy[62] + acadoWorkspace.evGx[239]*acadoWorkspace.QDy[63] + acadoWorkspace.evGx[243]*acadoWorkspace.QDy[64] + acadoWorkspace.evGx[247]*acadoWorkspace.QDy[65] + acadoWorkspace.evGx[251]*acadoWorkspace.QDy[66] + acadoWorkspace.evGx[255]*acadoWorkspace.QDy[67] + acadoWorkspace.evGx[259]*acadoWorkspace.QDy[68] + acadoWorkspace.evGx[263]*acadoWorkspace.QDy[69] + acadoWorkspace.evGx[267]*acadoWorkspace.QDy[70] + acadoWorkspace.evGx[271]*acadoWorkspace.QDy[71] + acadoWorkspace.evGx[275]*acadoWorkspace.QDy[72] + acadoWorkspace.evGx[279]*acadoWorkspace.QDy[73] + acadoWorkspace.evGx[283]*acadoWorkspace.QDy[74] + acadoWorkspace.evGx[287]*acadoWorkspace.QDy[75] + acadoWorkspace.evGx[291]*acadoWorkspace.QDy[76] + acadoWorkspace.evGx[295]*acadoWorkspace.QDy[77] + acadoWorkspace.evGx[299]*acadoWorkspace.QDy[78] + acadoWorkspace.evGx[303]*acadoWorkspace.QDy[79] + acadoWorkspace.evGx[307]*acadoWorkspace.QDy[80] + acadoWorkspace.evGx[311]*acadoWorkspace.QDy[81] + acadoWorkspace.evGx[315]*acadoWorkspace.QDy[82] + acadoWorkspace.evGx[319]*acadoWorkspace.QDy[83] + acadoWorkspace.evGx[323]*acadoWorkspace.QDy[84] + acadoWorkspace.evGx[327]*acadoWorkspace.QDy[85] + acadoWorkspace.evGx[331]*acadoWorkspace.QDy[86] + acadoWorkspace.evGx[335]*acadoWorkspace.QDy[87] + acadoWorkspace.evGx[339]*acadoWorkspace.QDy[88] + acadoWorkspace.evGx[343]*acadoWorkspace.QDy[89] + acadoWorkspace.evGx[347]*acadoWorkspace.QDy[90] + acadoWorkspace.evGx[351]*acadoWorkspace.QDy[91] + acadoWorkspace.evGx[355]*acadoWorkspace.QDy[92] + acadoWorkspace.evGx[359]*acadoWorkspace.QDy[93] + acadoWorkspace.evGx[363]*acadoWorkspace.QDy[94] + acadoWorkspace.evGx[367]*acadoWorkspace.QDy[95] + acadoWorkspace.evGx[371]*acadoWorkspace.QDy[96] + acadoWorkspace.evGx[375]*acadoWorkspace.QDy[97] + acadoWorkspace.evGx[379]*acadoWorkspace.QDy[98] + acadoWorkspace.evGx[383]*acadoWorkspace.QDy[99] + acadoWorkspace.evGx[387]*acadoWorkspace.QDy[100] + acadoWorkspace.evGx[391]*acadoWorkspace.QDy[101] + acadoWorkspace.evGx[395]*acadoWorkspace.QDy[102] + acadoWorkspace.evGx[399]*acadoWorkspace.QDy[103] + acadoWorkspace.evGx[403]*acadoWorkspace.QDy[104] + acadoWorkspace.evGx[407]*acadoWorkspace.QDy[105] + acadoWorkspace.evGx[411]*acadoWorkspace.QDy[106] + acadoWorkspace.evGx[415]*acadoWorkspace.QDy[107] + acadoWorkspace.evGx[419]*acadoWorkspace.QDy[108] + acadoWorkspace.evGx[423]*acadoWorkspace.QDy[109] + acadoWorkspace.evGx[427]*acadoWorkspace.QDy[110] + acadoWorkspace.evGx[431]*acadoWorkspace.QDy[111] + acadoWorkspace.evGx[435]*acadoWorkspace.QDy[112] + acadoWorkspace.evGx[439]*acadoWorkspace.QDy[113] + acadoWorkspace.evGx[443]*acadoWorkspace.QDy[114] + acadoWorkspace.evGx[447]*acadoWorkspace.QDy[115] + acadoWorkspace.evGx[451]*acadoWorkspace.QDy[116] + acadoWorkspace.evGx[455]*acadoWorkspace.QDy[117] + acadoWorkspace.evGx[459]*acadoWorkspace.QDy[118] + acadoWorkspace.evGx[463]*acadoWorkspace.QDy[119] + acadoWorkspace.evGx[467]*acadoWorkspace.QDy[120] + acadoWorkspace.evGx[471]*acadoWorkspace.QDy[121] + acadoWorkspace.evGx[475]*acadoWorkspace.QDy[122] + acadoWorkspace.evGx[479]*acadoWorkspace.QDy[123] + acadoWorkspace.evGx[483]*acadoWorkspace.QDy[124] + acadoWorkspace.evGx[487]*acadoWorkspace.QDy[125] + acadoWorkspace.evGx[491]*acadoWorkspace.QDy[126] + acadoWorkspace.evGx[495]*acadoWorkspace.QDy[127] + acadoWorkspace.evGx[499]*acadoWorkspace.QDy[128] + acadoWorkspace.evGx[503]*acadoWorkspace.QDy[129] + acadoWorkspace.evGx[507]*acadoWorkspace.QDy[130] + acadoWorkspace.evGx[511]*acadoWorkspace.QDy[131]; for (lRun1 = 0; lRun1 < 32; ++lRun1) { for (lRun2 = lRun1; lRun2 < 32; ++lRun2) { lRun3 = (((lRun2 + 1) * (lRun2)) / (2)) + (lRun1); acado_multEQDy( &(acadoWorkspace.E[ lRun3 * 8 ]), &(acadoWorkspace.QDy[ lRun2 * 4 + 4 ]), &(acadoWorkspace.g[ lRun1 * 2 + 4 ]) ); } } acadoWorkspace.lb[0] = acadoWorkspace.Dx0[0]; acadoWorkspace.lb[1] = acadoWorkspace.Dx0[1]; acadoWorkspace.lb[2] = acadoWorkspace.Dx0[2]; acadoWorkspace.lb[3] = acadoWorkspace.Dx0[3]; acadoWorkspace.ub[0] = acadoWorkspace.Dx0[0]; acadoWorkspace.ub[1] = acadoWorkspace.Dx0[1]; acadoWorkspace.ub[2] = acadoWorkspace.Dx0[2]; acadoWorkspace.ub[3] = acadoWorkspace.Dx0[3]; tmp = acadoVariables.x[5] + acadoWorkspace.d[1]; acadoWorkspace.lbA[0] = - tmp; acadoWorkspace.ubA[0] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[9] + acadoWorkspace.d[5]; acadoWorkspace.lbA[1] = - tmp; acadoWorkspace.ubA[1] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[13] + acadoWorkspace.d[9]; acadoWorkspace.lbA[2] = - tmp; acadoWorkspace.ubA[2] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[17] + acadoWorkspace.d[13]; acadoWorkspace.lbA[3] = - tmp; acadoWorkspace.ubA[3] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[21] + acadoWorkspace.d[17]; acadoWorkspace.lbA[4] = - tmp; acadoWorkspace.ubA[4] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[25] + acadoWorkspace.d[21]; acadoWorkspace.lbA[5] = - tmp; acadoWorkspace.ubA[5] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[29] + acadoWorkspace.d[25]; acadoWorkspace.lbA[6] = - tmp; acadoWorkspace.ubA[6] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[33] + acadoWorkspace.d[29]; acadoWorkspace.lbA[7] = - tmp; acadoWorkspace.ubA[7] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[37] + acadoWorkspace.d[33]; acadoWorkspace.lbA[8] = - tmp; acadoWorkspace.ubA[8] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[41] + acadoWorkspace.d[37]; acadoWorkspace.lbA[9] = - tmp; acadoWorkspace.ubA[9] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[45] + acadoWorkspace.d[41]; acadoWorkspace.lbA[10] = - tmp; acadoWorkspace.ubA[10] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[49] + acadoWorkspace.d[45]; acadoWorkspace.lbA[11] = - tmp; acadoWorkspace.ubA[11] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[53] + acadoWorkspace.d[49]; acadoWorkspace.lbA[12] = - tmp; acadoWorkspace.ubA[12] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[57] + acadoWorkspace.d[53]; acadoWorkspace.lbA[13] = - tmp; acadoWorkspace.ubA[13] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[61] + acadoWorkspace.d[57]; acadoWorkspace.lbA[14] = - tmp; acadoWorkspace.ubA[14] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[65] + acadoWorkspace.d[61]; acadoWorkspace.lbA[15] = - tmp; acadoWorkspace.ubA[15] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[69] + acadoWorkspace.d[65]; acadoWorkspace.lbA[16] = - tmp; acadoWorkspace.ubA[16] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[73] + acadoWorkspace.d[69]; acadoWorkspace.lbA[17] = - tmp; acadoWorkspace.ubA[17] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[77] + acadoWorkspace.d[73]; acadoWorkspace.lbA[18] = - tmp; acadoWorkspace.ubA[18] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[81] + acadoWorkspace.d[77]; acadoWorkspace.lbA[19] = - tmp; acadoWorkspace.ubA[19] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[85] + acadoWorkspace.d[81]; acadoWorkspace.lbA[20] = - tmp; acadoWorkspace.ubA[20] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[89] + acadoWorkspace.d[85]; acadoWorkspace.lbA[21] = - tmp; acadoWorkspace.ubA[21] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[93] + acadoWorkspace.d[89]; acadoWorkspace.lbA[22] = - tmp; acadoWorkspace.ubA[22] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[97] + acadoWorkspace.d[93]; acadoWorkspace.lbA[23] = - tmp; acadoWorkspace.ubA[23] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[101] + acadoWorkspace.d[97]; acadoWorkspace.lbA[24] = - tmp; acadoWorkspace.ubA[24] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[105] + acadoWorkspace.d[101]; acadoWorkspace.lbA[25] = - tmp; acadoWorkspace.ubA[25] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[109] + acadoWorkspace.d[105]; acadoWorkspace.lbA[26] = - tmp; acadoWorkspace.ubA[26] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[113] + acadoWorkspace.d[109]; acadoWorkspace.lbA[27] = - tmp; acadoWorkspace.ubA[27] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[117] + acadoWorkspace.d[113]; acadoWorkspace.lbA[28] = - tmp; acadoWorkspace.ubA[28] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[121] + acadoWorkspace.d[117]; acadoWorkspace.lbA[29] = - tmp; acadoWorkspace.ubA[29] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[125] + acadoWorkspace.d[121]; acadoWorkspace.lbA[30] = - tmp; acadoWorkspace.ubA[30] = (real_t)1.0000000000000000e+12 - tmp; tmp = acadoVariables.x[129] + acadoWorkspace.d[125]; acadoWorkspace.lbA[31] = - tmp; acadoWorkspace.ubA[31] = (real_t)1.0000000000000000e+12 - tmp; } void acado_expand( ) { int lRun1; int lRun2; int lRun3; acadoVariables.x[0] += acadoWorkspace.x[0]; acadoVariables.x[1] += acadoWorkspace.x[1]; acadoVariables.x[2] += acadoWorkspace.x[2]; acadoVariables.x[3] += acadoWorkspace.x[3]; acadoVariables.u[0] += acadoWorkspace.x[4]; acadoVariables.u[1] += acadoWorkspace.x[5]; acadoVariables.u[2] += acadoWorkspace.x[6]; acadoVariables.u[3] += acadoWorkspace.x[7]; acadoVariables.u[4] += acadoWorkspace.x[8]; acadoVariables.u[5] += acadoWorkspace.x[9]; acadoVariables.u[6] += acadoWorkspace.x[10]; acadoVariables.u[7] += acadoWorkspace.x[11]; acadoVariables.u[8] += acadoWorkspace.x[12]; acadoVariables.u[9] += acadoWorkspace.x[13]; acadoVariables.u[10] += acadoWorkspace.x[14]; acadoVariables.u[11] += acadoWorkspace.x[15]; acadoVariables.u[12] += acadoWorkspace.x[16]; acadoVariables.u[13] += acadoWorkspace.x[17]; acadoVariables.u[14] += acadoWorkspace.x[18]; acadoVariables.u[15] += acadoWorkspace.x[19]; acadoVariables.u[16] += acadoWorkspace.x[20]; acadoVariables.u[17] += acadoWorkspace.x[21]; acadoVariables.u[18] += acadoWorkspace.x[22]; acadoVariables.u[19] += acadoWorkspace.x[23]; acadoVariables.u[20] += acadoWorkspace.x[24]; acadoVariables.u[21] += acadoWorkspace.x[25]; acadoVariables.u[22] += acadoWorkspace.x[26]; acadoVariables.u[23] += acadoWorkspace.x[27]; acadoVariables.u[24] += acadoWorkspace.x[28]; acadoVariables.u[25] += acadoWorkspace.x[29]; acadoVariables.u[26] += acadoWorkspace.x[30]; acadoVariables.u[27] += acadoWorkspace.x[31]; acadoVariables.u[28] += acadoWorkspace.x[32]; acadoVariables.u[29] += acadoWorkspace.x[33]; acadoVariables.u[30] += acadoWorkspace.x[34]; acadoVariables.u[31] += acadoWorkspace.x[35]; acadoVariables.u[32] += acadoWorkspace.x[36]; acadoVariables.u[33] += acadoWorkspace.x[37]; acadoVariables.u[34] += acadoWorkspace.x[38]; acadoVariables.u[35] += acadoWorkspace.x[39]; acadoVariables.u[36] += acadoWorkspace.x[40]; acadoVariables.u[37] += acadoWorkspace.x[41]; acadoVariables.u[38] += acadoWorkspace.x[42]; acadoVariables.u[39] += acadoWorkspace.x[43]; acadoVariables.u[40] += acadoWorkspace.x[44]; acadoVariables.u[41] += acadoWorkspace.x[45]; acadoVariables.u[42] += acadoWorkspace.x[46]; acadoVariables.u[43] += acadoWorkspace.x[47]; acadoVariables.u[44] += acadoWorkspace.x[48]; acadoVariables.u[45] += acadoWorkspace.x[49]; acadoVariables.u[46] += acadoWorkspace.x[50]; acadoVariables.u[47] += acadoWorkspace.x[51]; acadoVariables.u[48] += acadoWorkspace.x[52]; acadoVariables.u[49] += acadoWorkspace.x[53]; acadoVariables.u[50] += acadoWorkspace.x[54]; acadoVariables.u[51] += acadoWorkspace.x[55]; acadoVariables.u[52] += acadoWorkspace.x[56]; acadoVariables.u[53] += acadoWorkspace.x[57]; acadoVariables.u[54] += acadoWorkspace.x[58]; acadoVariables.u[55] += acadoWorkspace.x[59]; acadoVariables.u[56] += acadoWorkspace.x[60]; acadoVariables.u[57] += acadoWorkspace.x[61]; acadoVariables.u[58] += acadoWorkspace.x[62]; acadoVariables.u[59] += acadoWorkspace.x[63]; acadoVariables.u[60] += acadoWorkspace.x[64]; acadoVariables.u[61] += acadoWorkspace.x[65]; acadoVariables.u[62] += acadoWorkspace.x[66]; acadoVariables.u[63] += acadoWorkspace.x[67]; acadoVariables.x[4] += + acadoWorkspace.evGx[0]*acadoWorkspace.x[0] + acadoWorkspace.evGx[1]*acadoWorkspace.x[1] + acadoWorkspace.evGx[2]*acadoWorkspace.x[2] + acadoWorkspace.evGx[3]*acadoWorkspace.x[3] + acadoWorkspace.d[0]; acadoVariables.x[5] += + acadoWorkspace.evGx[4]*acadoWorkspace.x[0] + acadoWorkspace.evGx[5]*acadoWorkspace.x[1] + acadoWorkspace.evGx[6]*acadoWorkspace.x[2] + acadoWorkspace.evGx[7]*acadoWorkspace.x[3] + acadoWorkspace.d[1]; acadoVariables.x[6] += + acadoWorkspace.evGx[8]*acadoWorkspace.x[0] + acadoWorkspace.evGx[9]*acadoWorkspace.x[1] + acadoWorkspace.evGx[10]*acadoWorkspace.x[2] + acadoWorkspace.evGx[11]*acadoWorkspace.x[3] + acadoWorkspace.d[2]; acadoVariables.x[7] += + acadoWorkspace.evGx[12]*acadoWorkspace.x[0] + acadoWorkspace.evGx[13]*acadoWorkspace.x[1] + acadoWorkspace.evGx[14]*acadoWorkspace.x[2] + acadoWorkspace.evGx[15]*acadoWorkspace.x[3] + acadoWorkspace.d[3]; acadoVariables.x[8] += + acadoWorkspace.evGx[16]*acadoWorkspace.x[0] + acadoWorkspace.evGx[17]*acadoWorkspace.x[1] + acadoWorkspace.evGx[18]*acadoWorkspace.x[2] + acadoWorkspace.evGx[19]*acadoWorkspace.x[3] + acadoWorkspace.d[4]; acadoVariables.x[9] += + acadoWorkspace.evGx[20]*acadoWorkspace.x[0] + acadoWorkspace.evGx[21]*acadoWorkspace.x[1] + acadoWorkspace.evGx[22]*acadoWorkspace.x[2] + acadoWorkspace.evGx[23]*acadoWorkspace.x[3] + acadoWorkspace.d[5]; acadoVariables.x[10] += + acadoWorkspace.evGx[24]*acadoWorkspace.x[0] + acadoWorkspace.evGx[25]*acadoWorkspace.x[1] + acadoWorkspace.evGx[26]*acadoWorkspace.x[2] + acadoWorkspace.evGx[27]*acadoWorkspace.x[3] + acadoWorkspace.d[6]; acadoVariables.x[11] += + acadoWorkspace.evGx[28]*acadoWorkspace.x[0] + acadoWorkspace.evGx[29]*acadoWorkspace.x[1] + acadoWorkspace.evGx[30]*acadoWorkspace.x[2] + acadoWorkspace.evGx[31]*acadoWorkspace.x[3] + acadoWorkspace.d[7]; acadoVariables.x[12] += + acadoWorkspace.evGx[32]*acadoWorkspace.x[0] + acadoWorkspace.evGx[33]*acadoWorkspace.x[1] + acadoWorkspace.evGx[34]*acadoWorkspace.x[2] + acadoWorkspace.evGx[35]*acadoWorkspace.x[3] + acadoWorkspace.d[8]; acadoVariables.x[13] += + acadoWorkspace.evGx[36]*acadoWorkspace.x[0] + acadoWorkspace.evGx[37]*acadoWorkspace.x[1] + acadoWorkspace.evGx[38]*acadoWorkspace.x[2] + acadoWorkspace.evGx[39]*acadoWorkspace.x[3] + acadoWorkspace.d[9]; acadoVariables.x[14] += + acadoWorkspace.evGx[40]*acadoWorkspace.x[0] + acadoWorkspace.evGx[41]*acadoWorkspace.x[1] + acadoWorkspace.evGx[42]*acadoWorkspace.x[2] + acadoWorkspace.evGx[43]*acadoWorkspace.x[3] + acadoWorkspace.d[10]; acadoVariables.x[15] += + acadoWorkspace.evGx[44]*acadoWorkspace.x[0] + acadoWorkspace.evGx[45]*acadoWorkspace.x[1] + acadoWorkspace.evGx[46]*acadoWorkspace.x[2] + acadoWorkspace.evGx[47]*acadoWorkspace.x[3] + acadoWorkspace.d[11]; acadoVariables.x[16] += + acadoWorkspace.evGx[48]*acadoWorkspace.x[0] + acadoWorkspace.evGx[49]*acadoWorkspace.x[1] + acadoWorkspace.evGx[50]*acadoWorkspace.x[2] + acadoWorkspace.evGx[51]*acadoWorkspace.x[3] + acadoWorkspace.d[12]; acadoVariables.x[17] += + acadoWorkspace.evGx[52]*acadoWorkspace.x[0] + acadoWorkspace.evGx[53]*acadoWorkspace.x[1] + acadoWorkspace.evGx[54]*acadoWorkspace.x[2] + acadoWorkspace.evGx[55]*acadoWorkspace.x[3] + acadoWorkspace.d[13]; acadoVariables.x[18] += + acadoWorkspace.evGx[56]*acadoWorkspace.x[0] + acadoWorkspace.evGx[57]*acadoWorkspace.x[1] + acadoWorkspace.evGx[58]*acadoWorkspace.x[2] + acadoWorkspace.evGx[59]*acadoWorkspace.x[3] + acadoWorkspace.d[14]; acadoVariables.x[19] += + acadoWorkspace.evGx[60]*acadoWorkspace.x[0] + acadoWorkspace.evGx[61]*acadoWorkspace.x[1] + acadoWorkspace.evGx[62]*acadoWorkspace.x[2] + acadoWorkspace.evGx[63]*acadoWorkspace.x[3] + acadoWorkspace.d[15]; acadoVariables.x[20] += + acadoWorkspace.evGx[64]*acadoWorkspace.x[0] + acadoWorkspace.evGx[65]*acadoWorkspace.x[1] + acadoWorkspace.evGx[66]*acadoWorkspace.x[2] + acadoWorkspace.evGx[67]*acadoWorkspace.x[3] + acadoWorkspace.d[16]; acadoVariables.x[21] += + acadoWorkspace.evGx[68]*acadoWorkspace.x[0] + acadoWorkspace.evGx[69]*acadoWorkspace.x[1] + acadoWorkspace.evGx[70]*acadoWorkspace.x[2] + acadoWorkspace.evGx[71]*acadoWorkspace.x[3] + acadoWorkspace.d[17]; acadoVariables.x[22] += + acadoWorkspace.evGx[72]*acadoWorkspace.x[0] + acadoWorkspace.evGx[73]*acadoWorkspace.x[1] + acadoWorkspace.evGx[74]*acadoWorkspace.x[2] + acadoWorkspace.evGx[75]*acadoWorkspace.x[3] + acadoWorkspace.d[18]; acadoVariables.x[23] += + acadoWorkspace.evGx[76]*acadoWorkspace.x[0] + acadoWorkspace.evGx[77]*acadoWorkspace.x[1] + acadoWorkspace.evGx[78]*acadoWorkspace.x[2] + acadoWorkspace.evGx[79]*acadoWorkspace.x[3] + acadoWorkspace.d[19]; acadoVariables.x[24] += + acadoWorkspace.evGx[80]*acadoWorkspace.x[0] + acadoWorkspace.evGx[81]*acadoWorkspace.x[1] + acadoWorkspace.evGx[82]*acadoWorkspace.x[2] + acadoWorkspace.evGx[83]*acadoWorkspace.x[3] + acadoWorkspace.d[20]; acadoVariables.x[25] += + acadoWorkspace.evGx[84]*acadoWorkspace.x[0] + acadoWorkspace.evGx[85]*acadoWorkspace.x[1] + acadoWorkspace.evGx[86]*acadoWorkspace.x[2] + acadoWorkspace.evGx[87]*acadoWorkspace.x[3] + acadoWorkspace.d[21]; acadoVariables.x[26] += + acadoWorkspace.evGx[88]*acadoWorkspace.x[0] + acadoWorkspace.evGx[89]*acadoWorkspace.x[1] + acadoWorkspace.evGx[90]*acadoWorkspace.x[2] + acadoWorkspace.evGx[91]*acadoWorkspace.x[3] + acadoWorkspace.d[22]; acadoVariables.x[27] += + acadoWorkspace.evGx[92]*acadoWorkspace.x[0] + acadoWorkspace.evGx[93]*acadoWorkspace.x[1] + acadoWorkspace.evGx[94]*acadoWorkspace.x[2] + acadoWorkspace.evGx[95]*acadoWorkspace.x[3] + acadoWorkspace.d[23]; acadoVariables.x[28] += + acadoWorkspace.evGx[96]*acadoWorkspace.x[0] + acadoWorkspace.evGx[97]*acadoWorkspace.x[1] + acadoWorkspace.evGx[98]*acadoWorkspace.x[2] + acadoWorkspace.evGx[99]*acadoWorkspace.x[3] + acadoWorkspace.d[24]; acadoVariables.x[29] += + acadoWorkspace.evGx[100]*acadoWorkspace.x[0] + acadoWorkspace.evGx[101]*acadoWorkspace.x[1] + acadoWorkspace.evGx[102]*acadoWorkspace.x[2] + acadoWorkspace.evGx[103]*acadoWorkspace.x[3] + acadoWorkspace.d[25]; acadoVariables.x[30] += + acadoWorkspace.evGx[104]*acadoWorkspace.x[0] + acadoWorkspace.evGx[105]*acadoWorkspace.x[1] + acadoWorkspace.evGx[106]*acadoWorkspace.x[2] + acadoWorkspace.evGx[107]*acadoWorkspace.x[3] + acadoWorkspace.d[26]; acadoVariables.x[31] += + acadoWorkspace.evGx[108]*acadoWorkspace.x[0] + acadoWorkspace.evGx[109]*acadoWorkspace.x[1] + acadoWorkspace.evGx[110]*acadoWorkspace.x[2] + acadoWorkspace.evGx[111]*acadoWorkspace.x[3] + acadoWorkspace.d[27]; acadoVariables.x[32] += + acadoWorkspace.evGx[112]*acadoWorkspace.x[0] + acadoWorkspace.evGx[113]*acadoWorkspace.x[1] + acadoWorkspace.evGx[114]*acadoWorkspace.x[2] + acadoWorkspace.evGx[115]*acadoWorkspace.x[3] + acadoWorkspace.d[28]; acadoVariables.x[33] += + acadoWorkspace.evGx[116]*acadoWorkspace.x[0] + acadoWorkspace.evGx[117]*acadoWorkspace.x[1] + acadoWorkspace.evGx[118]*acadoWorkspace.x[2] + acadoWorkspace.evGx[119]*acadoWorkspace.x[3] + acadoWorkspace.d[29]; acadoVariables.x[34] += + acadoWorkspace.evGx[120]*acadoWorkspace.x[0] + acadoWorkspace.evGx[121]*acadoWorkspace.x[1] + acadoWorkspace.evGx[122]*acadoWorkspace.x[2] + acadoWorkspace.evGx[123]*acadoWorkspace.x[3] + acadoWorkspace.d[30]; acadoVariables.x[35] += + acadoWorkspace.evGx[124]*acadoWorkspace.x[0] + acadoWorkspace.evGx[125]*acadoWorkspace.x[1] + acadoWorkspace.evGx[126]*acadoWorkspace.x[2] + acadoWorkspace.evGx[127]*acadoWorkspace.x[3] + acadoWorkspace.d[31]; acadoVariables.x[36] += + acadoWorkspace.evGx[128]*acadoWorkspace.x[0] + acadoWorkspace.evGx[129]*acadoWorkspace.x[1] + acadoWorkspace.evGx[130]*acadoWorkspace.x[2] + acadoWorkspace.evGx[131]*acadoWorkspace.x[3] + acadoWorkspace.d[32]; acadoVariables.x[37] += + acadoWorkspace.evGx[132]*acadoWorkspace.x[0] + acadoWorkspace.evGx[133]*acadoWorkspace.x[1] + acadoWorkspace.evGx[134]*acadoWorkspace.x[2] + acadoWorkspace.evGx[135]*acadoWorkspace.x[3] + acadoWorkspace.d[33]; acadoVariables.x[38] += + acadoWorkspace.evGx[136]*acadoWorkspace.x[0] + acadoWorkspace.evGx[137]*acadoWorkspace.x[1] + acadoWorkspace.evGx[138]*acadoWorkspace.x[2] + acadoWorkspace.evGx[139]*acadoWorkspace.x[3] + acadoWorkspace.d[34]; acadoVariables.x[39] += + acadoWorkspace.evGx[140]*acadoWorkspace.x[0] + acadoWorkspace.evGx[141]*acadoWorkspace.x[1] + acadoWorkspace.evGx[142]*acadoWorkspace.x[2] + acadoWorkspace.evGx[143]*acadoWorkspace.x[3] + acadoWorkspace.d[35]; acadoVariables.x[40] += + acadoWorkspace.evGx[144]*acadoWorkspace.x[0] + acadoWorkspace.evGx[145]*acadoWorkspace.x[1] + acadoWorkspace.evGx[146]*acadoWorkspace.x[2] + acadoWorkspace.evGx[147]*acadoWorkspace.x[3] + acadoWorkspace.d[36]; acadoVariables.x[41] += + acadoWorkspace.evGx[148]*acadoWorkspace.x[0] + acadoWorkspace.evGx[149]*acadoWorkspace.x[1] + acadoWorkspace.evGx[150]*acadoWorkspace.x[2] + acadoWorkspace.evGx[151]*acadoWorkspace.x[3] + acadoWorkspace.d[37]; acadoVariables.x[42] += + acadoWorkspace.evGx[152]*acadoWorkspace.x[0] + acadoWorkspace.evGx[153]*acadoWorkspace.x[1] + acadoWorkspace.evGx[154]*acadoWorkspace.x[2] + acadoWorkspace.evGx[155]*acadoWorkspace.x[3] + acadoWorkspace.d[38]; acadoVariables.x[43] += + acadoWorkspace.evGx[156]*acadoWorkspace.x[0] + acadoWorkspace.evGx[157]*acadoWorkspace.x[1] + acadoWorkspace.evGx[158]*acadoWorkspace.x[2] + acadoWorkspace.evGx[159]*acadoWorkspace.x[3] + acadoWorkspace.d[39]; acadoVariables.x[44] += + acadoWorkspace.evGx[160]*acadoWorkspace.x[0] + acadoWorkspace.evGx[161]*acadoWorkspace.x[1] + acadoWorkspace.evGx[162]*acadoWorkspace.x[2] + acadoWorkspace.evGx[163]*acadoWorkspace.x[3] + acadoWorkspace.d[40]; acadoVariables.x[45] += + acadoWorkspace.evGx[164]*acadoWorkspace.x[0] + acadoWorkspace.evGx[165]*acadoWorkspace.x[1] + acadoWorkspace.evGx[166]*acadoWorkspace.x[2] + acadoWorkspace.evGx[167]*acadoWorkspace.x[3] + acadoWorkspace.d[41]; acadoVariables.x[46] += + acadoWorkspace.evGx[168]*acadoWorkspace.x[0] + acadoWorkspace.evGx[169]*acadoWorkspace.x[1] + acadoWorkspace.evGx[170]*acadoWorkspace.x[2] + acadoWorkspace.evGx[171]*acadoWorkspace.x[3] + acadoWorkspace.d[42]; acadoVariables.x[47] += + acadoWorkspace.evGx[172]*acadoWorkspace.x[0] + acadoWorkspace.evGx[173]*acadoWorkspace.x[1] + acadoWorkspace.evGx[174]*acadoWorkspace.x[2] + acadoWorkspace.evGx[175]*acadoWorkspace.x[3] + acadoWorkspace.d[43]; acadoVariables.x[48] += + acadoWorkspace.evGx[176]*acadoWorkspace.x[0] + acadoWorkspace.evGx[177]*acadoWorkspace.x[1] + acadoWorkspace.evGx[178]*acadoWorkspace.x[2] + acadoWorkspace.evGx[179]*acadoWorkspace.x[3] + acadoWorkspace.d[44]; acadoVariables.x[49] += + acadoWorkspace.evGx[180]*acadoWorkspace.x[0] + acadoWorkspace.evGx[181]*acadoWorkspace.x[1] + acadoWorkspace.evGx[182]*acadoWorkspace.x[2] + acadoWorkspace.evGx[183]*acadoWorkspace.x[3] + acadoWorkspace.d[45]; acadoVariables.x[50] += + acadoWorkspace.evGx[184]*acadoWorkspace.x[0] + acadoWorkspace.evGx[185]*acadoWorkspace.x[1] + acadoWorkspace.evGx[186]*acadoWorkspace.x[2] + acadoWorkspace.evGx[187]*acadoWorkspace.x[3] + acadoWorkspace.d[46]; acadoVariables.x[51] += + acadoWorkspace.evGx[188]*acadoWorkspace.x[0] + acadoWorkspace.evGx[189]*acadoWorkspace.x[1] + acadoWorkspace.evGx[190]*acadoWorkspace.x[2] + acadoWorkspace.evGx[191]*acadoWorkspace.x[3] + acadoWorkspace.d[47]; acadoVariables.x[52] += + acadoWorkspace.evGx[192]*acadoWorkspace.x[0] + acadoWorkspace.evGx[193]*acadoWorkspace.x[1] + acadoWorkspace.evGx[194]*acadoWorkspace.x[2] + acadoWorkspace.evGx[195]*acadoWorkspace.x[3] + acadoWorkspace.d[48]; acadoVariables.x[53] += + acadoWorkspace.evGx[196]*acadoWorkspace.x[0] + acadoWorkspace.evGx[197]*acadoWorkspace.x[1] + acadoWorkspace.evGx[198]*acadoWorkspace.x[2] + acadoWorkspace.evGx[199]*acadoWorkspace.x[3] + acadoWorkspace.d[49]; acadoVariables.x[54] += + acadoWorkspace.evGx[200]*acadoWorkspace.x[0] + acadoWorkspace.evGx[201]*acadoWorkspace.x[1] + acadoWorkspace.evGx[202]*acadoWorkspace.x[2] + acadoWorkspace.evGx[203]*acadoWorkspace.x[3] + acadoWorkspace.d[50]; acadoVariables.x[55] += + acadoWorkspace.evGx[204]*acadoWorkspace.x[0] + acadoWorkspace.evGx[205]*acadoWorkspace.x[1] + acadoWorkspace.evGx[206]*acadoWorkspace.x[2] + acadoWorkspace.evGx[207]*acadoWorkspace.x[3] + acadoWorkspace.d[51]; acadoVariables.x[56] += + acadoWorkspace.evGx[208]*acadoWorkspace.x[0] + acadoWorkspace.evGx[209]*acadoWorkspace.x[1] + acadoWorkspace.evGx[210]*acadoWorkspace.x[2] + acadoWorkspace.evGx[211]*acadoWorkspace.x[3] + acadoWorkspace.d[52]; acadoVariables.x[57] += + acadoWorkspace.evGx[212]*acadoWorkspace.x[0] + acadoWorkspace.evGx[213]*acadoWorkspace.x[1] + acadoWorkspace.evGx[214]*acadoWorkspace.x[2] + acadoWorkspace.evGx[215]*acadoWorkspace.x[3] + acadoWorkspace.d[53]; acadoVariables.x[58] += + acadoWorkspace.evGx[216]*acadoWorkspace.x[0] + acadoWorkspace.evGx[217]*acadoWorkspace.x[1] + acadoWorkspace.evGx[218]*acadoWorkspace.x[2] + acadoWorkspace.evGx[219]*acadoWorkspace.x[3] + acadoWorkspace.d[54]; acadoVariables.x[59] += + acadoWorkspace.evGx[220]*acadoWorkspace.x[0] + acadoWorkspace.evGx[221]*acadoWorkspace.x[1] + acadoWorkspace.evGx[222]*acadoWorkspace.x[2] + acadoWorkspace.evGx[223]*acadoWorkspace.x[3] + acadoWorkspace.d[55]; acadoVariables.x[60] += + acadoWorkspace.evGx[224]*acadoWorkspace.x[0] + acadoWorkspace.evGx[225]*acadoWorkspace.x[1] + acadoWorkspace.evGx[226]*acadoWorkspace.x[2] + acadoWorkspace.evGx[227]*acadoWorkspace.x[3] + acadoWorkspace.d[56]; acadoVariables.x[61] += + acadoWorkspace.evGx[228]*acadoWorkspace.x[0] + acadoWorkspace.evGx[229]*acadoWorkspace.x[1] + acadoWorkspace.evGx[230]*acadoWorkspace.x[2] + acadoWorkspace.evGx[231]*acadoWorkspace.x[3] + acadoWorkspace.d[57]; acadoVariables.x[62] += + acadoWorkspace.evGx[232]*acadoWorkspace.x[0] + acadoWorkspace.evGx[233]*acadoWorkspace.x[1] + acadoWorkspace.evGx[234]*acadoWorkspace.x[2] + acadoWorkspace.evGx[235]*acadoWorkspace.x[3] + acadoWorkspace.d[58]; acadoVariables.x[63] += + acadoWorkspace.evGx[236]*acadoWorkspace.x[0] + acadoWorkspace.evGx[237]*acadoWorkspace.x[1] + acadoWorkspace.evGx[238]*acadoWorkspace.x[2] + acadoWorkspace.evGx[239]*acadoWorkspace.x[3] + acadoWorkspace.d[59]; acadoVariables.x[64] += + acadoWorkspace.evGx[240]*acadoWorkspace.x[0] + acadoWorkspace.evGx[241]*acadoWorkspace.x[1] + acadoWorkspace.evGx[242]*acadoWorkspace.x[2] + acadoWorkspace.evGx[243]*acadoWorkspace.x[3] + acadoWorkspace.d[60]; acadoVariables.x[65] += + acadoWorkspace.evGx[244]*acadoWorkspace.x[0] + acadoWorkspace.evGx[245]*acadoWorkspace.x[1] + acadoWorkspace.evGx[246]*acadoWorkspace.x[2] + acadoWorkspace.evGx[247]*acadoWorkspace.x[3] + acadoWorkspace.d[61]; acadoVariables.x[66] += + acadoWorkspace.evGx[248]*acadoWorkspace.x[0] + acadoWorkspace.evGx[249]*acadoWorkspace.x[1] + acadoWorkspace.evGx[250]*acadoWorkspace.x[2] + acadoWorkspace.evGx[251]*acadoWorkspace.x[3] + acadoWorkspace.d[62]; acadoVariables.x[67] += + acadoWorkspace.evGx[252]*acadoWorkspace.x[0] + acadoWorkspace.evGx[253]*acadoWorkspace.x[1] + acadoWorkspace.evGx[254]*acadoWorkspace.x[2] + acadoWorkspace.evGx[255]*acadoWorkspace.x[3] + acadoWorkspace.d[63]; acadoVariables.x[68] += + acadoWorkspace.evGx[256]*acadoWorkspace.x[0] + acadoWorkspace.evGx[257]*acadoWorkspace.x[1] + acadoWorkspace.evGx[258]*acadoWorkspace.x[2] + acadoWorkspace.evGx[259]*acadoWorkspace.x[3] + acadoWorkspace.d[64]; acadoVariables.x[69] += + acadoWorkspace.evGx[260]*acadoWorkspace.x[0] + acadoWorkspace.evGx[261]*acadoWorkspace.x[1] + acadoWorkspace.evGx[262]*acadoWorkspace.x[2] + acadoWorkspace.evGx[263]*acadoWorkspace.x[3] + acadoWorkspace.d[65]; acadoVariables.x[70] += + acadoWorkspace.evGx[264]*acadoWorkspace.x[0] + acadoWorkspace.evGx[265]*acadoWorkspace.x[1] + acadoWorkspace.evGx[266]*acadoWorkspace.x[2] + acadoWorkspace.evGx[267]*acadoWorkspace.x[3] + acadoWorkspace.d[66]; acadoVariables.x[71] += + acadoWorkspace.evGx[268]*acadoWorkspace.x[0] + acadoWorkspace.evGx[269]*acadoWorkspace.x[1] + acadoWorkspace.evGx[270]*acadoWorkspace.x[2] + acadoWorkspace.evGx[271]*acadoWorkspace.x[3] + acadoWorkspace.d[67]; acadoVariables.x[72] += + acadoWorkspace.evGx[272]*acadoWorkspace.x[0] + acadoWorkspace.evGx[273]*acadoWorkspace.x[1] + acadoWorkspace.evGx[274]*acadoWorkspace.x[2] + acadoWorkspace.evGx[275]*acadoWorkspace.x[3] + acadoWorkspace.d[68]; acadoVariables.x[73] += + acadoWorkspace.evGx[276]*acadoWorkspace.x[0] + acadoWorkspace.evGx[277]*acadoWorkspace.x[1] + acadoWorkspace.evGx[278]*acadoWorkspace.x[2] + acadoWorkspace.evGx[279]*acadoWorkspace.x[3] + acadoWorkspace.d[69]; acadoVariables.x[74] += + acadoWorkspace.evGx[280]*acadoWorkspace.x[0] + acadoWorkspace.evGx[281]*acadoWorkspace.x[1] + acadoWorkspace.evGx[282]*acadoWorkspace.x[2] + acadoWorkspace.evGx[283]*acadoWorkspace.x[3] + acadoWorkspace.d[70]; acadoVariables.x[75] += + acadoWorkspace.evGx[284]*acadoWorkspace.x[0] + acadoWorkspace.evGx[285]*acadoWorkspace.x[1] + acadoWorkspace.evGx[286]*acadoWorkspace.x[2] + acadoWorkspace.evGx[287]*acadoWorkspace.x[3] + acadoWorkspace.d[71]; acadoVariables.x[76] += + acadoWorkspace.evGx[288]*acadoWorkspace.x[0] + acadoWorkspace.evGx[289]*acadoWorkspace.x[1] + acadoWorkspace.evGx[290]*acadoWorkspace.x[2] + acadoWorkspace.evGx[291]*acadoWorkspace.x[3] + acadoWorkspace.d[72]; acadoVariables.x[77] += + acadoWorkspace.evGx[292]*acadoWorkspace.x[0] + acadoWorkspace.evGx[293]*acadoWorkspace.x[1] + acadoWorkspace.evGx[294]*acadoWorkspace.x[2] + acadoWorkspace.evGx[295]*acadoWorkspace.x[3] + acadoWorkspace.d[73]; acadoVariables.x[78] += + acadoWorkspace.evGx[296]*acadoWorkspace.x[0] + acadoWorkspace.evGx[297]*acadoWorkspace.x[1] + acadoWorkspace.evGx[298]*acadoWorkspace.x[2] + acadoWorkspace.evGx[299]*acadoWorkspace.x[3] + acadoWorkspace.d[74]; acadoVariables.x[79] += + acadoWorkspace.evGx[300]*acadoWorkspace.x[0] + acadoWorkspace.evGx[301]*acadoWorkspace.x[1] + acadoWorkspace.evGx[302]*acadoWorkspace.x[2] + acadoWorkspace.evGx[303]*acadoWorkspace.x[3] + acadoWorkspace.d[75]; acadoVariables.x[80] += + acadoWorkspace.evGx[304]*acadoWorkspace.x[0] + acadoWorkspace.evGx[305]*acadoWorkspace.x[1] + acadoWorkspace.evGx[306]*acadoWorkspace.x[2] + acadoWorkspace.evGx[307]*acadoWorkspace.x[3] + acadoWorkspace.d[76]; acadoVariables.x[81] += + acadoWorkspace.evGx[308]*acadoWorkspace.x[0] + acadoWorkspace.evGx[309]*acadoWorkspace.x[1] + acadoWorkspace.evGx[310]*acadoWorkspace.x[2] + acadoWorkspace.evGx[311]*acadoWorkspace.x[3] + acadoWorkspace.d[77]; acadoVariables.x[82] += + acadoWorkspace.evGx[312]*acadoWorkspace.x[0] + acadoWorkspace.evGx[313]*acadoWorkspace.x[1] + acadoWorkspace.evGx[314]*acadoWorkspace.x[2] + acadoWorkspace.evGx[315]*acadoWorkspace.x[3] + acadoWorkspace.d[78]; acadoVariables.x[83] += + acadoWorkspace.evGx[316]*acadoWorkspace.x[0] + acadoWorkspace.evGx[317]*acadoWorkspace.x[1] + acadoWorkspace.evGx[318]*acadoWorkspace.x[2] + acadoWorkspace.evGx[319]*acadoWorkspace.x[3] + acadoWorkspace.d[79]; acadoVariables.x[84] += + acadoWorkspace.evGx[320]*acadoWorkspace.x[0] + acadoWorkspace.evGx[321]*acadoWorkspace.x[1] + acadoWorkspace.evGx[322]*acadoWorkspace.x[2] + acadoWorkspace.evGx[323]*acadoWorkspace.x[3] + acadoWorkspace.d[80]; acadoVariables.x[85] += + acadoWorkspace.evGx[324]*acadoWorkspace.x[0] + acadoWorkspace.evGx[325]*acadoWorkspace.x[1] + acadoWorkspace.evGx[326]*acadoWorkspace.x[2] + acadoWorkspace.evGx[327]*acadoWorkspace.x[3] + acadoWorkspace.d[81]; acadoVariables.x[86] += + acadoWorkspace.evGx[328]*acadoWorkspace.x[0] + acadoWorkspace.evGx[329]*acadoWorkspace.x[1] + acadoWorkspace.evGx[330]*acadoWorkspace.x[2] + acadoWorkspace.evGx[331]*acadoWorkspace.x[3] + acadoWorkspace.d[82]; acadoVariables.x[87] += + acadoWorkspace.evGx[332]*acadoWorkspace.x[0] + acadoWorkspace.evGx[333]*acadoWorkspace.x[1] + acadoWorkspace.evGx[334]*acadoWorkspace.x[2] + acadoWorkspace.evGx[335]*acadoWorkspace.x[3] + acadoWorkspace.d[83]; acadoVariables.x[88] += + acadoWorkspace.evGx[336]*acadoWorkspace.x[0] + acadoWorkspace.evGx[337]*acadoWorkspace.x[1] + acadoWorkspace.evGx[338]*acadoWorkspace.x[2] + acadoWorkspace.evGx[339]*acadoWorkspace.x[3] + acadoWorkspace.d[84]; acadoVariables.x[89] += + acadoWorkspace.evGx[340]*acadoWorkspace.x[0] + acadoWorkspace.evGx[341]*acadoWorkspace.x[1] + acadoWorkspace.evGx[342]*acadoWorkspace.x[2] + acadoWorkspace.evGx[343]*acadoWorkspace.x[3] + acadoWorkspace.d[85]; acadoVariables.x[90] += + acadoWorkspace.evGx[344]*acadoWorkspace.x[0] + acadoWorkspace.evGx[345]*acadoWorkspace.x[1] + acadoWorkspace.evGx[346]*acadoWorkspace.x[2] + acadoWorkspace.evGx[347]*acadoWorkspace.x[3] + acadoWorkspace.d[86]; acadoVariables.x[91] += + acadoWorkspace.evGx[348]*acadoWorkspace.x[0] + acadoWorkspace.evGx[349]*acadoWorkspace.x[1] + acadoWorkspace.evGx[350]*acadoWorkspace.x[2] + acadoWorkspace.evGx[351]*acadoWorkspace.x[3] + acadoWorkspace.d[87]; acadoVariables.x[92] += + acadoWorkspace.evGx[352]*acadoWorkspace.x[0] + acadoWorkspace.evGx[353]*acadoWorkspace.x[1] + acadoWorkspace.evGx[354]*acadoWorkspace.x[2] + acadoWorkspace.evGx[355]*acadoWorkspace.x[3] + acadoWorkspace.d[88]; acadoVariables.x[93] += + acadoWorkspace.evGx[356]*acadoWorkspace.x[0] + acadoWorkspace.evGx[357]*acadoWorkspace.x[1] + acadoWorkspace.evGx[358]*acadoWorkspace.x[2] + acadoWorkspace.evGx[359]*acadoWorkspace.x[3] + acadoWorkspace.d[89]; acadoVariables.x[94] += + acadoWorkspace.evGx[360]*acadoWorkspace.x[0] + acadoWorkspace.evGx[361]*acadoWorkspace.x[1] + acadoWorkspace.evGx[362]*acadoWorkspace.x[2] + acadoWorkspace.evGx[363]*acadoWorkspace.x[3] + acadoWorkspace.d[90]; acadoVariables.x[95] += + acadoWorkspace.evGx[364]*acadoWorkspace.x[0] + acadoWorkspace.evGx[365]*acadoWorkspace.x[1] + acadoWorkspace.evGx[366]*acadoWorkspace.x[2] + acadoWorkspace.evGx[367]*acadoWorkspace.x[3] + acadoWorkspace.d[91]; acadoVariables.x[96] += + acadoWorkspace.evGx[368]*acadoWorkspace.x[0] + acadoWorkspace.evGx[369]*acadoWorkspace.x[1] + acadoWorkspace.evGx[370]*acadoWorkspace.x[2] + acadoWorkspace.evGx[371]*acadoWorkspace.x[3] + acadoWorkspace.d[92]; acadoVariables.x[97] += + acadoWorkspace.evGx[372]*acadoWorkspace.x[0] + acadoWorkspace.evGx[373]*acadoWorkspace.x[1] + acadoWorkspace.evGx[374]*acadoWorkspace.x[2] + acadoWorkspace.evGx[375]*acadoWorkspace.x[3] + acadoWorkspace.d[93]; acadoVariables.x[98] += + acadoWorkspace.evGx[376]*acadoWorkspace.x[0] + acadoWorkspace.evGx[377]*acadoWorkspace.x[1] + acadoWorkspace.evGx[378]*acadoWorkspace.x[2] + acadoWorkspace.evGx[379]*acadoWorkspace.x[3] + acadoWorkspace.d[94]; acadoVariables.x[99] += + acadoWorkspace.evGx[380]*acadoWorkspace.x[0] + acadoWorkspace.evGx[381]*acadoWorkspace.x[1] + acadoWorkspace.evGx[382]*acadoWorkspace.x[2] + acadoWorkspace.evGx[383]*acadoWorkspace.x[3] + acadoWorkspace.d[95]; acadoVariables.x[100] += + acadoWorkspace.evGx[384]*acadoWorkspace.x[0] + acadoWorkspace.evGx[385]*acadoWorkspace.x[1] + acadoWorkspace.evGx[386]*acadoWorkspace.x[2] + acadoWorkspace.evGx[387]*acadoWorkspace.x[3] + acadoWorkspace.d[96]; acadoVariables.x[101] += + acadoWorkspace.evGx[388]*acadoWorkspace.x[0] + acadoWorkspace.evGx[389]*acadoWorkspace.x[1] + acadoWorkspace.evGx[390]*acadoWorkspace.x[2] + acadoWorkspace.evGx[391]*acadoWorkspace.x[3] + acadoWorkspace.d[97]; acadoVariables.x[102] += + acadoWorkspace.evGx[392]*acadoWorkspace.x[0] + acadoWorkspace.evGx[393]*acadoWorkspace.x[1] + acadoWorkspace.evGx[394]*acadoWorkspace.x[2] + acadoWorkspace.evGx[395]*acadoWorkspace.x[3] + acadoWorkspace.d[98]; acadoVariables.x[103] += + acadoWorkspace.evGx[396]*acadoWorkspace.x[0] + acadoWorkspace.evGx[397]*acadoWorkspace.x[1] + acadoWorkspace.evGx[398]*acadoWorkspace.x[2] + acadoWorkspace.evGx[399]*acadoWorkspace.x[3] + acadoWorkspace.d[99]; acadoVariables.x[104] += + acadoWorkspace.evGx[400]*acadoWorkspace.x[0] + acadoWorkspace.evGx[401]*acadoWorkspace.x[1] + acadoWorkspace.evGx[402]*acadoWorkspace.x[2] + acadoWorkspace.evGx[403]*acadoWorkspace.x[3] + acadoWorkspace.d[100]; acadoVariables.x[105] += + acadoWorkspace.evGx[404]*acadoWorkspace.x[0] + acadoWorkspace.evGx[405]*acadoWorkspace.x[1] + acadoWorkspace.evGx[406]*acadoWorkspace.x[2] + acadoWorkspace.evGx[407]*acadoWorkspace.x[3] + acadoWorkspace.d[101]; acadoVariables.x[106] += + acadoWorkspace.evGx[408]*acadoWorkspace.x[0] + acadoWorkspace.evGx[409]*acadoWorkspace.x[1] + acadoWorkspace.evGx[410]*acadoWorkspace.x[2] + acadoWorkspace.evGx[411]*acadoWorkspace.x[3] + acadoWorkspace.d[102]; acadoVariables.x[107] += + acadoWorkspace.evGx[412]*acadoWorkspace.x[0] + acadoWorkspace.evGx[413]*acadoWorkspace.x[1] + acadoWorkspace.evGx[414]*acadoWorkspace.x[2] + acadoWorkspace.evGx[415]*acadoWorkspace.x[3] + acadoWorkspace.d[103]; acadoVariables.x[108] += + acadoWorkspace.evGx[416]*acadoWorkspace.x[0] + acadoWorkspace.evGx[417]*acadoWorkspace.x[1] + acadoWorkspace.evGx[418]*acadoWorkspace.x[2] + acadoWorkspace.evGx[419]*acadoWorkspace.x[3] + acadoWorkspace.d[104]; acadoVariables.x[109] += + acadoWorkspace.evGx[420]*acadoWorkspace.x[0] + acadoWorkspace.evGx[421]*acadoWorkspace.x[1] + acadoWorkspace.evGx[422]*acadoWorkspace.x[2] + acadoWorkspace.evGx[423]*acadoWorkspace.x[3] + acadoWorkspace.d[105]; acadoVariables.x[110] += + acadoWorkspace.evGx[424]*acadoWorkspace.x[0] + acadoWorkspace.evGx[425]*acadoWorkspace.x[1] + acadoWorkspace.evGx[426]*acadoWorkspace.x[2] + acadoWorkspace.evGx[427]*acadoWorkspace.x[3] + acadoWorkspace.d[106]; acadoVariables.x[111] += + acadoWorkspace.evGx[428]*acadoWorkspace.x[0] + acadoWorkspace.evGx[429]*acadoWorkspace.x[1] + acadoWorkspace.evGx[430]*acadoWorkspace.x[2] + acadoWorkspace.evGx[431]*acadoWorkspace.x[3] + acadoWorkspace.d[107]; acadoVariables.x[112] += + acadoWorkspace.evGx[432]*acadoWorkspace.x[0] + acadoWorkspace.evGx[433]*acadoWorkspace.x[1] + acadoWorkspace.evGx[434]*acadoWorkspace.x[2] + acadoWorkspace.evGx[435]*acadoWorkspace.x[3] + acadoWorkspace.d[108]; acadoVariables.x[113] += + acadoWorkspace.evGx[436]*acadoWorkspace.x[0] + acadoWorkspace.evGx[437]*acadoWorkspace.x[1] + acadoWorkspace.evGx[438]*acadoWorkspace.x[2] + acadoWorkspace.evGx[439]*acadoWorkspace.x[3] + acadoWorkspace.d[109]; acadoVariables.x[114] += + acadoWorkspace.evGx[440]*acadoWorkspace.x[0] + acadoWorkspace.evGx[441]*acadoWorkspace.x[1] + acadoWorkspace.evGx[442]*acadoWorkspace.x[2] + acadoWorkspace.evGx[443]*acadoWorkspace.x[3] + acadoWorkspace.d[110]; acadoVariables.x[115] += + acadoWorkspace.evGx[444]*acadoWorkspace.x[0] + acadoWorkspace.evGx[445]*acadoWorkspace.x[1] + acadoWorkspace.evGx[446]*acadoWorkspace.x[2] + acadoWorkspace.evGx[447]*acadoWorkspace.x[3] + acadoWorkspace.d[111]; acadoVariables.x[116] += + acadoWorkspace.evGx[448]*acadoWorkspace.x[0] + acadoWorkspace.evGx[449]*acadoWorkspace.x[1] + acadoWorkspace.evGx[450]*acadoWorkspace.x[2] + acadoWorkspace.evGx[451]*acadoWorkspace.x[3] + acadoWorkspace.d[112]; acadoVariables.x[117] += + acadoWorkspace.evGx[452]*acadoWorkspace.x[0] + acadoWorkspace.evGx[453]*acadoWorkspace.x[1] + acadoWorkspace.evGx[454]*acadoWorkspace.x[2] + acadoWorkspace.evGx[455]*acadoWorkspace.x[3] + acadoWorkspace.d[113]; acadoVariables.x[118] += + acadoWorkspace.evGx[456]*acadoWorkspace.x[0] + acadoWorkspace.evGx[457]*acadoWorkspace.x[1] + acadoWorkspace.evGx[458]*acadoWorkspace.x[2] + acadoWorkspace.evGx[459]*acadoWorkspace.x[3] + acadoWorkspace.d[114]; acadoVariables.x[119] += + acadoWorkspace.evGx[460]*acadoWorkspace.x[0] + acadoWorkspace.evGx[461]*acadoWorkspace.x[1] + acadoWorkspace.evGx[462]*acadoWorkspace.x[2] + acadoWorkspace.evGx[463]*acadoWorkspace.x[3] + acadoWorkspace.d[115]; acadoVariables.x[120] += + acadoWorkspace.evGx[464]*acadoWorkspace.x[0] + acadoWorkspace.evGx[465]*acadoWorkspace.x[1] + acadoWorkspace.evGx[466]*acadoWorkspace.x[2] + acadoWorkspace.evGx[467]*acadoWorkspace.x[3] + acadoWorkspace.d[116]; acadoVariables.x[121] += + acadoWorkspace.evGx[468]*acadoWorkspace.x[0] + acadoWorkspace.evGx[469]*acadoWorkspace.x[1] + acadoWorkspace.evGx[470]*acadoWorkspace.x[2] + acadoWorkspace.evGx[471]*acadoWorkspace.x[3] + acadoWorkspace.d[117]; acadoVariables.x[122] += + acadoWorkspace.evGx[472]*acadoWorkspace.x[0] + acadoWorkspace.evGx[473]*acadoWorkspace.x[1] + acadoWorkspace.evGx[474]*acadoWorkspace.x[2] + acadoWorkspace.evGx[475]*acadoWorkspace.x[3] + acadoWorkspace.d[118]; acadoVariables.x[123] += + acadoWorkspace.evGx[476]*acadoWorkspace.x[0] + acadoWorkspace.evGx[477]*acadoWorkspace.x[1] + acadoWorkspace.evGx[478]*acadoWorkspace.x[2] + acadoWorkspace.evGx[479]*acadoWorkspace.x[3] + acadoWorkspace.d[119]; acadoVariables.x[124] += + acadoWorkspace.evGx[480]*acadoWorkspace.x[0] + acadoWorkspace.evGx[481]*acadoWorkspace.x[1] + acadoWorkspace.evGx[482]*acadoWorkspace.x[2] + acadoWorkspace.evGx[483]*acadoWorkspace.x[3] + acadoWorkspace.d[120]; acadoVariables.x[125] += + acadoWorkspace.evGx[484]*acadoWorkspace.x[0] + acadoWorkspace.evGx[485]*acadoWorkspace.x[1] + acadoWorkspace.evGx[486]*acadoWorkspace.x[2] + acadoWorkspace.evGx[487]*acadoWorkspace.x[3] + acadoWorkspace.d[121]; acadoVariables.x[126] += + acadoWorkspace.evGx[488]*acadoWorkspace.x[0] + acadoWorkspace.evGx[489]*acadoWorkspace.x[1] + acadoWorkspace.evGx[490]*acadoWorkspace.x[2] + acadoWorkspace.evGx[491]*acadoWorkspace.x[3] + acadoWorkspace.d[122]; acadoVariables.x[127] += + acadoWorkspace.evGx[492]*acadoWorkspace.x[0] + acadoWorkspace.evGx[493]*acadoWorkspace.x[1] + acadoWorkspace.evGx[494]*acadoWorkspace.x[2] + acadoWorkspace.evGx[495]*acadoWorkspace.x[3] + acadoWorkspace.d[123]; acadoVariables.x[128] += + acadoWorkspace.evGx[496]*acadoWorkspace.x[0] + acadoWorkspace.evGx[497]*acadoWorkspace.x[1] + acadoWorkspace.evGx[498]*acadoWorkspace.x[2] + acadoWorkspace.evGx[499]*acadoWorkspace.x[3] + acadoWorkspace.d[124]; acadoVariables.x[129] += + acadoWorkspace.evGx[500]*acadoWorkspace.x[0] + acadoWorkspace.evGx[501]*acadoWorkspace.x[1] + acadoWorkspace.evGx[502]*acadoWorkspace.x[2] + acadoWorkspace.evGx[503]*acadoWorkspace.x[3] + acadoWorkspace.d[125]; acadoVariables.x[130] += + acadoWorkspace.evGx[504]*acadoWorkspace.x[0] + acadoWorkspace.evGx[505]*acadoWorkspace.x[1] + acadoWorkspace.evGx[506]*acadoWorkspace.x[2] + acadoWorkspace.evGx[507]*acadoWorkspace.x[3] + acadoWorkspace.d[126]; acadoVariables.x[131] += + acadoWorkspace.evGx[508]*acadoWorkspace.x[0] + acadoWorkspace.evGx[509]*acadoWorkspace.x[1] + acadoWorkspace.evGx[510]*acadoWorkspace.x[2] + acadoWorkspace.evGx[511]*acadoWorkspace.x[3] + acadoWorkspace.d[127]; for (lRun1 = 0; lRun1 < 32; ++lRun1) { for (lRun2 = 0; lRun2 < lRun1 + 1; ++lRun2) { lRun3 = (((lRun1 + 1) * (lRun1)) / (2)) + (lRun2); acado_multEDu( &(acadoWorkspace.E[ lRun3 * 8 ]), &(acadoWorkspace.x[ lRun2 * 2 + 4 ]), &(acadoVariables.x[ lRun1 * 4 + 4 ]) ); } } } int acado_preparationStep( ) { int ret; ret = acado_modelSimulation(); acado_evaluateObjective( ); acado_condensePrep( ); return ret; } int acado_feedbackStep( ) { int tmp; acado_condenseFdb( ); tmp = acado_solve( ); acado_expand( ); return tmp; } int acado_initializeSolver( ) { int ret; /* This is a function which must be called once before any other function call! */ ret = 0; memset(&acadoWorkspace, 0, sizeof( acadoWorkspace )); return ret; } void acado_initializeNodesByForwardSimulation( ) { int index; for (index = 0; index < 32; ++index) { acadoWorkspace.state[0] = acadoVariables.x[index * 4]; acadoWorkspace.state[1] = acadoVariables.x[index * 4 + 1]; acadoWorkspace.state[2] = acadoVariables.x[index * 4 + 2]; acadoWorkspace.state[3] = acadoVariables.x[index * 4 + 3]; acadoWorkspace.state[28] = acadoVariables.u[index * 2]; acadoWorkspace.state[29] = acadoVariables.u[index * 2 + 1]; acadoWorkspace.state[30] = acadoVariables.od[index * 2]; acadoWorkspace.state[31] = acadoVariables.od[index * 2 + 1]; acado_integrate(acadoWorkspace.state, index == 0, index); acadoVariables.x[index * 4 + 4] = acadoWorkspace.state[0]; acadoVariables.x[index * 4 + 5] = acadoWorkspace.state[1]; acadoVariables.x[index * 4 + 6] = acadoWorkspace.state[2]; acadoVariables.x[index * 4 + 7] = acadoWorkspace.state[3]; } } void acado_shiftStates( int strategy, real_t* const xEnd, real_t* const uEnd ) { int index; for (index = 0; index < 32; ++index) { acadoVariables.x[index * 4] = acadoVariables.x[index * 4 + 4]; acadoVariables.x[index * 4 + 1] = acadoVariables.x[index * 4 + 5]; acadoVariables.x[index * 4 + 2] = acadoVariables.x[index * 4 + 6]; acadoVariables.x[index * 4 + 3] = acadoVariables.x[index * 4 + 7]; } if (strategy == 1 && xEnd != 0) { acadoVariables.x[128] = xEnd[0]; acadoVariables.x[129] = xEnd[1]; acadoVariables.x[130] = xEnd[2]; acadoVariables.x[131] = xEnd[3]; } else if (strategy == 2) { acadoWorkspace.state[0] = acadoVariables.x[128]; acadoWorkspace.state[1] = acadoVariables.x[129]; acadoWorkspace.state[2] = acadoVariables.x[130]; acadoWorkspace.state[3] = acadoVariables.x[131]; if (uEnd != 0) { acadoWorkspace.state[28] = uEnd[0]; acadoWorkspace.state[29] = uEnd[1]; } else { acadoWorkspace.state[28] = acadoVariables.u[62]; acadoWorkspace.state[29] = acadoVariables.u[63]; } acadoWorkspace.state[30] = acadoVariables.od[64]; acadoWorkspace.state[31] = acadoVariables.od[65]; acado_integrate(acadoWorkspace.state, 1, 31); acadoVariables.x[128] = acadoWorkspace.state[0]; acadoVariables.x[129] = acadoWorkspace.state[1]; acadoVariables.x[130] = acadoWorkspace.state[2]; acadoVariables.x[131] = acadoWorkspace.state[3]; } } void acado_shiftControls( real_t* const uEnd ) { int index; for (index = 0; index < 31; ++index) { acadoVariables.u[index * 2] = acadoVariables.u[index * 2 + 2]; acadoVariables.u[index * 2 + 1] = acadoVariables.u[index * 2 + 3]; } if (uEnd != 0) { acadoVariables.u[62] = uEnd[0]; acadoVariables.u[63] = uEnd[1]; } } real_t acado_getKKT( ) { real_t kkt; int index; real_t prd; kkt = + acadoWorkspace.g[0]*acadoWorkspace.x[0] + acadoWorkspace.g[1]*acadoWorkspace.x[1] + acadoWorkspace.g[2]*acadoWorkspace.x[2] + acadoWorkspace.g[3]*acadoWorkspace.x[3] + acadoWorkspace.g[4]*acadoWorkspace.x[4] + acadoWorkspace.g[5]*acadoWorkspace.x[5] + acadoWorkspace.g[6]*acadoWorkspace.x[6] + acadoWorkspace.g[7]*acadoWorkspace.x[7] + acadoWorkspace.g[8]*acadoWorkspace.x[8] + acadoWorkspace.g[9]*acadoWorkspace.x[9] + acadoWorkspace.g[10]*acadoWorkspace.x[10] + acadoWorkspace.g[11]*acadoWorkspace.x[11] + acadoWorkspace.g[12]*acadoWorkspace.x[12] + acadoWorkspace.g[13]*acadoWorkspace.x[13] + acadoWorkspace.g[14]*acadoWorkspace.x[14] + acadoWorkspace.g[15]*acadoWorkspace.x[15] + acadoWorkspace.g[16]*acadoWorkspace.x[16] + acadoWorkspace.g[17]*acadoWorkspace.x[17] + acadoWorkspace.g[18]*acadoWorkspace.x[18] + acadoWorkspace.g[19]*acadoWorkspace.x[19] + acadoWorkspace.g[20]*acadoWorkspace.x[20] + acadoWorkspace.g[21]*acadoWorkspace.x[21] + acadoWorkspace.g[22]*acadoWorkspace.x[22] + acadoWorkspace.g[23]*acadoWorkspace.x[23] + acadoWorkspace.g[24]*acadoWorkspace.x[24] + acadoWorkspace.g[25]*acadoWorkspace.x[25] + acadoWorkspace.g[26]*acadoWorkspace.x[26] + acadoWorkspace.g[27]*acadoWorkspace.x[27] + acadoWorkspace.g[28]*acadoWorkspace.x[28] + acadoWorkspace.g[29]*acadoWorkspace.x[29] + acadoWorkspace.g[30]*acadoWorkspace.x[30] + acadoWorkspace.g[31]*acadoWorkspace.x[31] + acadoWorkspace.g[32]*acadoWorkspace.x[32] + acadoWorkspace.g[33]*acadoWorkspace.x[33] + acadoWorkspace.g[34]*acadoWorkspace.x[34] + acadoWorkspace.g[35]*acadoWorkspace.x[35] + acadoWorkspace.g[36]*acadoWorkspace.x[36] + acadoWorkspace.g[37]*acadoWorkspace.x[37] + acadoWorkspace.g[38]*acadoWorkspace.x[38] + acadoWorkspace.g[39]*acadoWorkspace.x[39] + acadoWorkspace.g[40]*acadoWorkspace.x[40] + acadoWorkspace.g[41]*acadoWorkspace.x[41] + acadoWorkspace.g[42]*acadoWorkspace.x[42] + acadoWorkspace.g[43]*acadoWorkspace.x[43] + acadoWorkspace.g[44]*acadoWorkspace.x[44] + acadoWorkspace.g[45]*acadoWorkspace.x[45] + acadoWorkspace.g[46]*acadoWorkspace.x[46] + acadoWorkspace.g[47]*acadoWorkspace.x[47] + acadoWorkspace.g[48]*acadoWorkspace.x[48] + acadoWorkspace.g[49]*acadoWorkspace.x[49] + acadoWorkspace.g[50]*acadoWorkspace.x[50] + acadoWorkspace.g[51]*acadoWorkspace.x[51] + acadoWorkspace.g[52]*acadoWorkspace.x[52] + acadoWorkspace.g[53]*acadoWorkspace.x[53] + acadoWorkspace.g[54]*acadoWorkspace.x[54] + acadoWorkspace.g[55]*acadoWorkspace.x[55] + acadoWorkspace.g[56]*acadoWorkspace.x[56] + acadoWorkspace.g[57]*acadoWorkspace.x[57] + acadoWorkspace.g[58]*acadoWorkspace.x[58] + acadoWorkspace.g[59]*acadoWorkspace.x[59] + acadoWorkspace.g[60]*acadoWorkspace.x[60] + acadoWorkspace.g[61]*acadoWorkspace.x[61] + acadoWorkspace.g[62]*acadoWorkspace.x[62] + acadoWorkspace.g[63]*acadoWorkspace.x[63] + acadoWorkspace.g[64]*acadoWorkspace.x[64] + acadoWorkspace.g[65]*acadoWorkspace.x[65] + acadoWorkspace.g[66]*acadoWorkspace.x[66] + acadoWorkspace.g[67]*acadoWorkspace.x[67]; kkt = fabs( kkt ); for (index = 0; index < 68; ++index) { prd = acadoWorkspace.y[index]; if (prd > 1e-12) kkt += fabs(acadoWorkspace.lb[index] * prd); else if (prd < -1e-12) kkt += fabs(acadoWorkspace.ub[index] * prd); } for (index = 0; index < 96; ++index) { prd = acadoWorkspace.y[index + 68]; if (prd > 1e-12) kkt += fabs(acadoWorkspace.lbA[index] * prd); else if (prd < -1e-12) kkt += fabs(acadoWorkspace.ubA[index] * prd); } return kkt; } real_t acado_getObjective( ) { real_t objVal; int lRun1; /** Row vector of size: 5 */ real_t tmpDy[ 5 ]; /** Row vector of size: 3 */ real_t tmpDyN[ 3 ]; for (lRun1 = 0; lRun1 < 32; ++lRun1) { acadoWorkspace.objValueIn[0] = acadoVariables.x[lRun1 * 4]; acadoWorkspace.objValueIn[1] = acadoVariables.x[lRun1 * 4 + 1]; acadoWorkspace.objValueIn[2] = acadoVariables.x[lRun1 * 4 + 2]; acadoWorkspace.objValueIn[3] = acadoVariables.x[lRun1 * 4 + 3]; acadoWorkspace.objValueIn[4] = acadoVariables.u[lRun1 * 2]; acadoWorkspace.objValueIn[5] = acadoVariables.u[lRun1 * 2 + 1]; acadoWorkspace.objValueIn[6] = acadoVariables.od[lRun1 * 2]; acadoWorkspace.objValueIn[7] = acadoVariables.od[lRun1 * 2 + 1]; acado_evaluateLSQ( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.Dy[lRun1 * 5] = acadoWorkspace.objValueOut[0] - acadoVariables.y[lRun1 * 5]; acadoWorkspace.Dy[lRun1 * 5 + 1] = acadoWorkspace.objValueOut[1] - acadoVariables.y[lRun1 * 5 + 1]; acadoWorkspace.Dy[lRun1 * 5 + 2] = acadoWorkspace.objValueOut[2] - acadoVariables.y[lRun1 * 5 + 2]; acadoWorkspace.Dy[lRun1 * 5 + 3] = acadoWorkspace.objValueOut[3] - acadoVariables.y[lRun1 * 5 + 3]; acadoWorkspace.Dy[lRun1 * 5 + 4] = acadoWorkspace.objValueOut[4] - acadoVariables.y[lRun1 * 5 + 4]; } acadoWorkspace.objValueIn[0] = acadoVariables.x[128]; acadoWorkspace.objValueIn[1] = acadoVariables.x[129]; acadoWorkspace.objValueIn[2] = acadoVariables.x[130]; acadoWorkspace.objValueIn[3] = acadoVariables.x[131]; acadoWorkspace.objValueIn[4] = acadoVariables.od[64]; acadoWorkspace.objValueIn[5] = acadoVariables.od[65]; acado_evaluateLSQEndTerm( acadoWorkspace.objValueIn, acadoWorkspace.objValueOut ); acadoWorkspace.DyN[0] = acadoWorkspace.objValueOut[0] - acadoVariables.yN[0]; acadoWorkspace.DyN[1] = acadoWorkspace.objValueOut[1] - acadoVariables.yN[1]; acadoWorkspace.DyN[2] = acadoWorkspace.objValueOut[2] - acadoVariables.yN[2]; objVal = 0.0000000000000000e+00; for (lRun1 = 0; lRun1 < 32; ++lRun1) { tmpDy[0] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 5] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 10] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 15] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 20]; tmpDy[1] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 1] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 6] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 11] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 16] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 21]; tmpDy[2] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 2] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 7] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 12] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 17] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 22]; tmpDy[3] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 3] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 8] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 13] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 18] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 23]; tmpDy[4] = + acadoWorkspace.Dy[lRun1 * 5]*acadoVariables.W[lRun1 * 25 + 4] + acadoWorkspace.Dy[lRun1 * 5 + 1]*acadoVariables.W[lRun1 * 25 + 9] + acadoWorkspace.Dy[lRun1 * 5 + 2]*acadoVariables.W[lRun1 * 25 + 14] + acadoWorkspace.Dy[lRun1 * 5 + 3]*acadoVariables.W[lRun1 * 25 + 19] + acadoWorkspace.Dy[lRun1 * 5 + 4]*acadoVariables.W[lRun1 * 25 + 24]; objVal += + acadoWorkspace.Dy[lRun1 * 5]*tmpDy[0] + acadoWorkspace.Dy[lRun1 * 5 + 1]*tmpDy[1] + acadoWorkspace.Dy[lRun1 * 5 + 2]*tmpDy[2] + acadoWorkspace.Dy[lRun1 * 5 + 3]*tmpDy[3] + acadoWorkspace.Dy[lRun1 * 5 + 4]*tmpDy[4]; } tmpDyN[0] = + acadoWorkspace.DyN[0]*acadoVariables.WN[0] + acadoWorkspace.DyN[1]*acadoVariables.WN[3] + acadoWorkspace.DyN[2]*acadoVariables.WN[6]; tmpDyN[1] = + acadoWorkspace.DyN[0]*acadoVariables.WN[1] + acadoWorkspace.DyN[1]*acadoVariables.WN[4] + acadoWorkspace.DyN[2]*acadoVariables.WN[7]; tmpDyN[2] = + acadoWorkspace.DyN[0]*acadoVariables.WN[2] + acadoWorkspace.DyN[1]*acadoVariables.WN[5] + acadoWorkspace.DyN[2]*acadoVariables.WN[8]; objVal += + acadoWorkspace.DyN[0]*tmpDyN[0] + acadoWorkspace.DyN[1]*tmpDyN[1] + acadoWorkspace.DyN[2]*tmpDyN[2]; objVal *= 0.5; return objVal; } ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/libmpc_py.py ================================================ import os from cffi import FFI from common.ffi_wrapper import suffix mpc_dir = os.path.join(os.path.dirname(os.path.abspath(__file__))) libmpc_fn = os.path.join(mpc_dir, "libmpc"+suffix()) ffi = FFI() ffi.cdef(""" const int MPC_N = 32; typedef struct { double x_ego, v_ego, a_ego; } state_t; typedef struct { double x_ego[MPC_N+1]; double v_ego[MPC_N+1]; double a_ego[MPC_N+1]; double t[MPC_N+1]; double j_ego[MPC_N]; double cost; } log_t; void init(double xCost, double vCost, double aCost, double jerkCost, double constraintCost); int run_mpc(state_t * x0, log_t * solution, double target_x[MPC_N+1], double target_v[MPC_N+1], double target_a[MPC_N+1], double min_a, double max_a); """) libmpc = ffi.dlopen(libmpc_fn) ================================================ FILE: selfdrive/controls/lib/longitudinal_mpc_lib/longitudinal_mpc.c ================================================ #include "acado_common.h" #include "acado_auxiliary_functions.h" #include "common/modeldata.h" #include #include #define NX ACADO_NX /* Number of differential state variables. */ #define NXA ACADO_NXA /* Number of algebraic variables. */ #define NU ACADO_NU /* Number of control inputs. */ #define NOD ACADO_NOD /* Number of online data values. */ #define NY ACADO_NY /* Number of measurements/references on nodes 0..N - 1. */ #define NYN ACADO_NYN /* Number of measurements/references on node N. */ #define N ACADO_N /* Number of intervals in the horizon. */ ACADOvariables acadoVariables; ACADOworkspace acadoWorkspace; typedef struct { double x_ego, v_ego, a_ego; } state_t; typedef struct { double x_ego[N+1]; double v_ego[N+1]; double a_ego[N+1]; double t[N+1]; double j_ego[N]; double cost; } log_t; void init(double xCost, double vCost, double aCost, double jerkCost, double constraintCost){ acado_initializeSolver(); int i; const int STEP_MULTIPLIER = 3; /* Initialize the states and controls. */ for (i = 0; i < NX * (N + 1); ++i) acadoVariables.x[ i ] = 0.0; for (i = 0; i < NU * N; ++i) acadoVariables.u[ i ] = 0.0; /* Initialize the measurements/reference. */ for (i = 0; i < NY * N; ++i) acadoVariables.y[ i ] = 0.0; for (i = 0; i < NYN; ++i) acadoVariables.yN[ i ] = 0.0; /* MPC: initialize the current state feedback. */ for (i = 0; i < NX; ++i) acadoVariables.x0[ i ] = 0.0; // Set weights for (i = 0; i < N; i++) { double f = 20 * (T_IDXS[i+1] - T_IDXS[i]); // Setup diagonal entries acadoVariables.W[NY*NY*i + (NY+1)*0] = xCost * f; acadoVariables.W[NY*NY*i + (NY+1)*1] = vCost * f; acadoVariables.W[NY*NY*i + (NY+1)*2] = aCost * f; acadoVariables.W[NY*NY*i + (NY+1)*3] = jerkCost * f; acadoVariables.W[NY*NY*i + (NY+1)*4] = constraintCost * f; } acadoVariables.WN[(NYN+1)*0] = xCost * STEP_MULTIPLIER; acadoVariables.WN[(NYN+1)*1] = vCost * STEP_MULTIPLIER; acadoVariables.WN[(NYN+1)*2] = aCost * STEP_MULTIPLIER; } int run_mpc(state_t * x0, log_t * solution, double target_x[N+1], double target_v[N+1], double target_a[N+1], double min_a, double max_a){ int i; for (i = 0; i < N + 1; ++i){ acadoVariables.od[i*NOD] = min_a; acadoVariables.od[i*NOD+1] = max_a; } for (i = 0; i < N; i+= 1){ acadoVariables.y[NY*i + 0] = target_x[i]; acadoVariables.y[NY*i + 1] = target_v[i]; acadoVariables.y[NY*i + 2] = target_a[i]; acadoVariables.y[NY*i + 3] = 0.0; acadoVariables.y[NY*i + 4] = 0.0; } acadoVariables.yN[0] = target_x[N]; acadoVariables.yN[1] = target_v[N]; acadoVariables.yN[2] = target_a[N]; acadoVariables.x0[0] = x0->x_ego; acadoVariables.x0[1] = x0->v_ego; acadoVariables.x0[2] = x0->a_ego; acado_preparationStep(); acado_feedbackStep(); for (i = 0; i <= N; i++) { solution->x_ego[i] = acadoVariables.x[i*NX]; solution->v_ego[i] = acadoVariables.x[i*NX+1]; solution->a_ego[i] = acadoVariables.x[i*NX+2]; if (i < N) { solution->j_ego[i] = acadoVariables.u[i*NU]; } } solution->cost = acado_getObjective(); // Dont shift states here. Current solution is closer to next timestep than if // we shift by 0.1 seconds. return acado_getNWSR(); } ================================================ FILE: selfdrive/controls/lib/longitudinal_planner.py ================================================ #!/usr/bin/env python3 import math import numpy as np from common.numpy_fast import interp import cereal.messaging as messaging from cereal import log from common.realtime import DT_MDL from common.realtime import sec_since_boot from selfdrive.modeld.constants import T_IDXS from selfdrive.config import Conversions as CV from selfdrive.controls.lib.fcw import FCWChecker from selfdrive.controls.lib.longcontrol import LongCtrlState from selfdrive.controls.lib.lead_mpc import LeadMpc from selfdrive.controls.lib.long_mpc import LongitudinalMpc from selfdrive.controls.lib.limits_long_mpc import LimitsLongitudinalMpc from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, CONTROL_N from selfdrive.controls.lib.vision_turn_controller import VisionTurnController from selfdrive.controls.lib.speed_limit_controller import SpeedLimitController, SpeedLimitResolver from selfdrive.controls.lib.turn_speed_controller import TurnSpeedController from selfdrive.controls.lib.events import Events from selfdrive.swaglog import cloudlog LON_MPC_STEP = 0.2 # first step is 0.2s AWARENESS_DECEL = -0.2 # car smoothly decel at .2m/s^2 when user is distracted A_CRUISE_MIN = -1.2 A_CRUISE_MAX_VALS = [1.2, 1.2, 0.8, 0.6] A_CRUISE_MAX_BP = [0., 15., 25., 40.] # Lookup table for turns _A_TOTAL_MAX_V = [1.7, 3.2] _A_TOTAL_MAX_BP = [20., 40.] DP_FOLLOWING_DIST = { 0: 1.2, 1: 1.5, 2: 1.8, 3: 2.2, } DP_ACCEL_ECO = 0 DP_ACCEL_NORMAL = 1 DP_ACCEL_SPORT = 2 # accel profile by @arne182 modified by @wer5lcy _DP_CRUISE_MIN_V = [-2.0, -1.8, -1.6, -1.4, -1.2] _DP_CRUISE_MIN_V_ECO = [-2.0, -1.6, -1.4, -1.2, -1.0] _DP_CRUISE_MIN_V_SPORT = [-3.0, -2.6, -2.3, -2.0, -1.0] _DP_CRUISE_MIN_BP = [0.0, 5.0, 10.0, 20.0, 55.0] _DP_CRUISE_MAX_V = [1.6, 1.4, 1.0, 0.6, 0.3] _DP_CRUISE_MAX_V_ECO = [1.5, 1.3, 0.8, 0.4, 0.2] _DP_CRUISE_MAX_V_SPORT = [3.0, 3.5, 3.0, 2.0, 2.0] _DP_CRUISE_MAX_BP = [0., 5., 10., 20., 55.] def dp_calc_cruise_accel_limits(v_ego, dp_profile): if dp_profile == DP_ACCEL_ECO: a_cruise_min = interp(v_ego, _DP_CRUISE_MIN_BP, _DP_CRUISE_MIN_V_ECO) a_cruise_max = interp(v_ego, _DP_CRUISE_MAX_BP, _DP_CRUISE_MAX_V_ECO) elif dp_profile == DP_ACCEL_SPORT: a_cruise_min = interp(v_ego, _DP_CRUISE_MIN_BP, _DP_CRUISE_MIN_V_SPORT) a_cruise_max = interp(v_ego, _DP_CRUISE_MAX_BP, _DP_CRUISE_MAX_V_SPORT) else: a_cruise_min = interp(v_ego, _DP_CRUISE_MIN_BP, _DP_CRUISE_MIN_V) a_cruise_max = interp(v_ego, _DP_CRUISE_MAX_BP, _DP_CRUISE_MAX_V) return a_cruise_min, a_cruise_max def get_max_accel(v_ego): return interp(v_ego, A_CRUISE_MAX_BP, A_CRUISE_MAX_VALS) def limit_accel_in_turns(v_ego, angle_steers, a_target, CP): """ This function returns a limited long acceleration allowed, depending on the existing lateral acceleration this should avoid accelerating when losing the target in turns """ a_total_max = interp(v_ego, _A_TOTAL_MAX_BP, _A_TOTAL_MAX_V) a_y = v_ego**2 * angle_steers * CV.DEG_TO_RAD / (CP.steerRatio * CP.wheelbase) a_x_allowed = math.sqrt(max(a_total_max**2 - a_y**2, 0.)) return [a_target[0], min(a_target[1], a_x_allowed)] class Planner(): def __init__(self, CP): self.CP = CP self.mpcs = {} self.mpcs['lead0'] = LeadMpc(0) self.mpcs['lead1'] = LeadMpc(1) self.mpcs['cruise'] = LongitudinalMpc() self.mpcs['custom'] = LimitsLongitudinalMpc() self.fcw = False self.fcw_checker = FCWChecker() self.v_desired = 0.0 self.a_desired = 0.0 self.longitudinalPlanSource = 'cruise' self.alpha = np.exp(-DT_MDL/2.0) self.lead_0 = log.ModelDataV2.LeadDataV3.new_message() self.lead_1 = log.ModelDataV2.LeadDataV3.new_message() self.v_desired_trajectory = np.zeros(CONTROL_N) self.a_desired_trajectory = np.zeros(CONTROL_N) # dp self.dp_accel_profile_ctrl = False self.dp_accel_profile = DP_ACCEL_ECO self.dp_following_profile_ctrl = False self.dp_following_profile = 3 self.dp_following_dist = 2.2 # default val self.vision_turn_controller = VisionTurnController(CP) self.speed_limit_controller = SpeedLimitController() self.events = Events() self.turn_speed_controller = TurnSpeedController() def update(self, sm, CP): # dp self.dp_accel_profile_ctrl = sm['dragonConf'].dpAccelProfileCtrl self.dp_accel_profile = sm['dragonConf'].dpAccelProfile self.dp_following_profile_ctrl = sm['dragonConf'].dpFollowingProfileCtrl self.dp_following_profile = sm['dragonConf'].dpFollowingProfile self.dp_following_dist = DP_FOLLOWING_DIST[0 if not self.dp_following_profile_ctrl else self.dp_following_profile] self.mpcs['lead0'].set_following_distance(self.dp_following_dist) self.mpcs['lead1'].set_following_distance(self.dp_following_dist) cur_time = sec_since_boot() v_ego = sm['carState'].vEgo a_ego = sm['carState'].aEgo v_cruise_kph = sm['controlsState'].vCruise v_cruise_kph = min(v_cruise_kph, V_CRUISE_MAX) v_cruise = v_cruise_kph * CV.KPH_TO_MS long_control_state = sm['controlsState'].longControlState force_slow_decel = sm['controlsState'].forceDecel self.lead_0 = sm['radarState'].leadOne self.lead_1 = sm['radarState'].leadTwo enabled = (long_control_state == LongCtrlState.pid) or (long_control_state == LongCtrlState.stopping) if not enabled or sm['carState'].gasPressed: self.v_desired = v_ego self.a_desired = a_ego # Prevent divergence, smooth in current v_ego self.v_desired = self.alpha * self.v_desired + (1 - self.alpha) * v_ego self.v_desired = max(0.0, self.v_desired) # Get acceleration and active solutions for custom long mpc. a_mpc, active_mpc, c_source = self.mpc_solutions(enabled, self.v_desired, self.a_desired, v_cruise, sm) if not self.dp_accel_profile_ctrl: accel_limits = [A_CRUISE_MIN, get_max_accel(v_ego)] else: accel_limits = dp_calc_cruise_accel_limits(v_cruise, self.dp_accel_profile) accel_limits_turns = limit_accel_in_turns(v_ego, sm['carState'].steeringAngleDeg, accel_limits, self.CP) if force_slow_decel: # if required so, force a smooth deceleration accel_limits_turns[1] = min(accel_limits_turns[1], AWARENESS_DECEL) accel_limits_turns[0] = min(accel_limits_turns[0], accel_limits_turns[1]) # clip limits, cannot init MPC outside of bounds accel_limits_turns[0] = min(accel_limits_turns[0], self.a_desired) accel_limits_turns[1] = max(accel_limits_turns[1], self.a_desired) self.mpcs['cruise'].set_accel_limits(accel_limits_turns[0], accel_limits_turns[1]) # ensure lower accel limit (for braking) is lower than target acc for custom controllers. accel_limits = [min(accel_limits_turns[0], a_mpc['custom']), accel_limits_turns[1]] self.mpcs['custom'].set_accel_limits(accel_limits[0], accel_limits[1]) next_a = np.inf for key in self.mpcs: self.mpcs[key].set_cur_state(self.v_desired, self.a_desired) self.mpcs[key].update(sm['carState'], sm['radarState'], v_cruise, a_mpc[key], active_mpc[key]) # picks slowest solution from accel in ~0.2 seconds if self.mpcs[key].status and active_mpc[key] and self.mpcs[key].a_solution[5] < next_a: self.longitudinalPlanSource = c_source if key == 'custom' else key self.v_desired_trajectory = self.mpcs[key].v_solution[:CONTROL_N] self.a_desired_trajectory = self.mpcs[key].a_solution[:CONTROL_N] self.j_desired_trajectory = self.mpcs[key].j_solution[:CONTROL_N] next_a = self.mpcs[key].a_solution[5] # determine fcw if self.mpcs['lead0'].new_lead: self.fcw_checker.reset_lead(cur_time) blinkers = sm['carState'].leftBlinker or sm['carState'].rightBlinker self.fcw = self.fcw_checker.update(self.mpcs['lead0'].mpc_solution, cur_time, sm['controlsState'].active, v_ego, sm['carState'].aEgo, self.lead_1.dRel, self.lead_1.vLead, self.lead_1.aLeadK, self.lead_1.yRel, self.lead_1.vLat, self.lead_1.fcw, blinkers) and not sm['carState'].brakePressed if self.fcw: cloudlog.info("FCW triggered %s", self.fcw_checker.counters) # Interpolate 0.05 seconds and save as starting point for next iteration a_prev = self.a_desired self.a_desired = float(interp(DT_MDL, T_IDXS[:CONTROL_N], self.a_desired_trajectory)) self.v_desired = self.v_desired + DT_MDL * (self.a_desired + a_prev)/2.0 def publish(self, sm, pm): plan_send = messaging.new_message('longitudinalPlan') plan_send.valid = sm.all_alive_and_valid(service_list=['carState', 'controlsState']) longitudinalPlan = plan_send.longitudinalPlan longitudinalPlan.modelMonoTime = sm.logMonoTime['modelV2'] longitudinalPlan.processingDelay = (plan_send.logMonoTime / 1e9) - sm.logMonoTime['modelV2'] longitudinalPlan.speeds = [float(x) for x in self.v_desired_trajectory] longitudinalPlan.accels = [float(x) for x in self.a_desired_trajectory] longitudinalPlan.jerks = [float(x) for x in self.j_desired_trajectory] longitudinalPlan.hasLead = self.mpcs['lead0'].status longitudinalPlan.longitudinalPlanSource = self.longitudinalPlanSource longitudinalPlan.fcw = self.fcw longitudinalPlan.visionTurnControllerState = self.vision_turn_controller.state longitudinalPlan.visionTurnSpeed = float(self.vision_turn_controller.v_turn) longitudinalPlan.speedLimitControlState = self.speed_limit_controller.state longitudinalPlan.speedLimit = float(self.speed_limit_controller.speed_limit) longitudinalPlan.speedLimitOffset = float(self.speed_limit_controller.speed_limit_offset) longitudinalPlan.distToSpeedLimit = float(self.speed_limit_controller.distance) longitudinalPlan.isMapSpeedLimit = bool(self.speed_limit_controller.source == SpeedLimitResolver.Source.map_data) longitudinalPlan.eventsDEPRECATED = self.events.to_msg() longitudinalPlan.turnSpeedControlState = self.turn_speed_controller.state longitudinalPlan.turnSpeed = float(self.turn_speed_controller.speed_limit) longitudinalPlan.distToTurn = float(self.turn_speed_controller.distance) longitudinalPlan.turnSign = int(self.turn_speed_controller.turn_sign) pm.send('longitudinalPlan', plan_send) def mpc_solutions(self, enabled, v_ego, a_ego, v_cruise, sm): # Update controllers self.vision_turn_controller.update(enabled, v_ego, a_ego, v_cruise, sm) self.events = Events() self.speed_limit_controller.update(enabled, v_ego, a_ego, sm, v_cruise, self.events) self.turn_speed_controller.update(enabled, v_ego, a_ego, sm) # Pick solution with lowest acceleration target. a_solutions = {None: float("inf")} if self.vision_turn_controller.is_active: a_solutions['turn'] = self.vision_turn_controller.a_target if self.speed_limit_controller.is_active: a_solutions['limit'] = self.speed_limit_controller.a_target if self.turn_speed_controller.is_active: a_solutions['turnlimit'] = self.turn_speed_controller.a_target source = min(a_solutions, key=a_solutions.get) a_sol = { 'cruise': a_ego, # Irrelevant 'lead0': a_ego, # Irrelevant 'lead1': a_ego, # Irrelevant 'custom': 0. if source is None else a_solutions[source], } active_sol = { 'cruise': True, # Irrelevant 'lead0': True, # Irrelevant 'lead1': True, # Irrelevant 'custom': source is not None, } return a_sol, active_sol, source ================================================ FILE: selfdrive/controls/lib/pid.py ================================================ import numpy as np from numbers import Number from common.numpy_fast import clip, interp def apply_deadzone(error, deadzone): if error > deadzone: error -= deadzone elif error < - deadzone: error += deadzone else: error = 0. return error class PIController(): def __init__(self, k_p, k_i, k_f=1., pos_limit=None, neg_limit=None, rate=100, sat_limit=0.8): self._k_p = k_p # proportional gain self._k_i = k_i # integral gain self.k_f = k_f # feedforward gain if isinstance(self._k_p, Number): self._k_p = [[0], [self._k_p]] if isinstance(self._k_i, Number): self._k_i = [[0], [self._k_i]] self.pos_limit = pos_limit self.neg_limit = neg_limit self.sat_count_rate = 1.0 / rate self.i_unwind_rate = 0.3 / rate self.i_rate = 1.0 / rate self.sat_limit = sat_limit self.reset() @property def k_p(self): return interp(self.speed, self._k_p[0], self._k_p[1]) @property def k_i(self): return interp(self.speed, self._k_i[0], self._k_i[1]) def _check_saturation(self, control, check_saturation, error): saturated = (control < self.neg_limit) or (control > self.pos_limit) if saturated and check_saturation and abs(error) > 0.1: self.sat_count += self.sat_count_rate else: self.sat_count -= self.sat_count_rate self.sat_count = clip(self.sat_count, 0.0, 1.0) return self.sat_count > self.sat_limit def reset(self): self.p = 0.0 self.i = 0.0 self.f = 0.0 self.sat_count = 0.0 self.saturated = False self.control = 0 def update(self, setpoint, measurement, speed=0.0, check_saturation=True, override=False, feedforward=0., deadzone=0., freeze_integrator=False): self.speed = speed error = float(apply_deadzone(setpoint - measurement, deadzone)) self.p = error * self.k_p self.f = feedforward * self.k_f if override: self.i -= self.i_unwind_rate * float(np.sign(self.i)) else: i = self.i + error * self.k_i * self.i_rate control = self.p + self.f + i # Update when changing i will move the control away from the limits # or when i will move towards the sign of the error if ((error >= 0 and (control <= self.pos_limit or i < 0.0)) or (error <= 0 and (control >= self.neg_limit or i > 0.0))) and \ not freeze_integrator: self.i = i control = self.p + self.f + self.i self.saturated = self._check_saturation(control, check_saturation, error) self.control = clip(control, self.neg_limit, self.pos_limit) return self.control ================================================ FILE: selfdrive/controls/lib/radar_helpers.py ================================================ from common.numpy_fast import mean from common.kalman.simple_kalman import KF1D from selfdrive.config import RADAR_TO_CAMERA # the longer lead decels, the more likely it will keep decelerating # TODO is this a good default? _LEAD_ACCEL_TAU = 1.5 # radar tracks SPEED, ACCEL = 0, 1 # Kalman filter states enum # stationary qualification parameters v_ego_stationary = 4. # no stationary object flag below this speed class Track(): def __init__(self, v_lead, kalman_params): self.cnt = 0 self.aLeadTau = _LEAD_ACCEL_TAU self.K_A = kalman_params.A self.K_C = kalman_params.C self.K_K = kalman_params.K self.kf = KF1D([[v_lead], [0.0]], self.K_A, self.K_C, self.K_K) def update(self, d_rel, y_rel, v_rel, v_lead, measured): # relative values, copy self.dRel = d_rel # LONG_DIST self.yRel = y_rel # -LAT_DIST self.vRel = v_rel # REL_SPEED self.vLead = v_lead self.measured = measured # measured or estimate # computed velocity and accelerations if self.cnt > 0: self.kf.update(self.vLead) self.vLeadK = float(self.kf.x[SPEED][0]) self.aLeadK = float(self.kf.x[ACCEL][0]) # Learn if constant acceleration if abs(self.aLeadK) < 0.5: self.aLeadTau = _LEAD_ACCEL_TAU else: self.aLeadTau *= 0.9 self.cnt += 1 def get_key_for_cluster(self): # Weigh y higher since radar is inaccurate in this dimension return [self.dRel, self.yRel*2, self.vRel] def reset_a_lead(self, aLeadK, aLeadTau): self.kf = KF1D([[self.vLead], [aLeadK]], self.K_A, self.K_C, self.K_K) self.aLeadK = aLeadK self.aLeadTau = aLeadTau class Cluster(): def __init__(self): self.tracks = set() def add(self, t): # add the first track self.tracks.add(t) # TODO: make generic @property def dRel(self): return mean([t.dRel for t in self.tracks]) @property def yRel(self): return mean([t.yRel for t in self.tracks]) @property def vRel(self): return mean([t.vRel for t in self.tracks]) @property def aRel(self): return mean([t.aRel for t in self.tracks]) @property def vLead(self): return mean([t.vLead for t in self.tracks]) @property def dPath(self): return mean([t.dPath for t in self.tracks]) @property def vLat(self): return mean([t.vLat for t in self.tracks]) @property def vLeadK(self): return mean([t.vLeadK for t in self.tracks]) @property def aLeadK(self): if all(t.cnt <= 1 for t in self.tracks): return 0. else: return mean([t.aLeadK for t in self.tracks if t.cnt > 1]) @property def aLeadTau(self): if all(t.cnt <= 1 for t in self.tracks): return _LEAD_ACCEL_TAU else: return mean([t.aLeadTau for t in self.tracks if t.cnt > 1]) @property def measured(self): return any(t.measured for t in self.tracks) def get_RadarState(self, model_prob=0.0): return { "dRel": float(self.dRel), "yRel": float(self.yRel), "vRel": float(self.vRel), "vLead": float(self.vLead), "vLeadK": float(self.vLeadK), "aLeadK": float(self.aLeadK), "status": True, "fcw": self.is_potential_fcw(model_prob), "modelProb": model_prob, "radar": True, "aLeadTau": float(self.aLeadTau) } def get_RadarState_from_vision(self, lead_msg, v_ego): return { "dRel": float(lead_msg.x[0] - RADAR_TO_CAMERA), "yRel": float(-lead_msg.y[0]), "vRel": float(lead_msg.v[0] - v_ego), "vLead": float(lead_msg.v[0]), "vLeadK": float(lead_msg.v[0]), "aLeadK": float(0), "aLeadTau": _LEAD_ACCEL_TAU, "fcw": False, "modelProb": float(lead_msg.prob), "radar": False, "status": True } def __str__(self): ret = "x: %4.1f y: %4.1f v: %4.1f a: %4.1f" % (self.dRel, self.yRel, self.vRel, self.aLeadK) return ret def potential_low_speed_lead(self, v_ego): # stop for stuff in front of you and low speed, even without model confirmation return abs(self.yRel) < 1.5 and (v_ego < v_ego_stationary) and self.dRel < 25 def is_potential_fcw(self, model_prob): return model_prob > .9 ================================================ FILE: selfdrive/controls/lib/speed_limit_controller.py ================================================ import numpy as np import time from common.numpy_fast import interp from enum import IntEnum from cereal import log, car from common.params import Params from common.realtime import sec_since_boot from selfdrive.controls.lib.drive_helpers import LIMIT_ADAPT_ACC, LIMIT_MIN_ACC, LIMIT_MAX_ACC, LIMIT_SPEED_OFFSET_TH, \ LIMIT_MAX_MAP_DATA_AGE, CONTROL_N from selfdrive.controls.lib.events import Events from selfdrive.modeld.constants import T_IDXS _PARAMS_UPDATE_PERIOD = 2. # secs. Time between parameter updates. _TEMP_INACTIVE_GUARD_PERIOD = 1. # secs. Time to wait after activation before considering temp deactivation signal. # Lookup table for speed limit percent offset depending on speed. _LIMIT_PERC_OFFSET_V = [0.0, 0.1, 0.125, 0.2, 0.21, 0.23] # 25, 33, 45, 60, 67, 70 mph _LIMIT_PERC_OFFSET_BP = [11.0, 13.4, 20.1, 22.3, 24.58, 29.0] # 25, 30, 40 50, 55, 65 mph #_LIMIT_PERC_OFFSET_V = [0.28, 0.038] # 55, 105, 135 km/h 96, 129 #_LIMIT_PERC_OFFSET_BP = [13.9, 36.1] # 50, 100, 130 km/h SpeedLimitControlState = log.LongitudinalPlan.SpeedLimitControlState EventName = car.CarEvent.EventName _DEBUG = False def _debug(msg): if not _DEBUG: return print(msg) def _description_for_state(speed_limit_control_state): if speed_limit_control_state == SpeedLimitControlState.inactive: return 'INACTIVE' if speed_limit_control_state == SpeedLimitControlState.tempInactive: return 'TEMP_INACTIVE' if speed_limit_control_state == SpeedLimitControlState.adapting: return 'ADAPTING' if speed_limit_control_state == SpeedLimitControlState.active: return 'ACTIVE' class SpeedLimitResolver(): class Source(IntEnum): none = 0 car_state = 1 map_data = 2 class Policy(IntEnum): car_state_only = 0 map_data_only = 1 car_state_priority = 2 map_data_priority = 3 combined = 4 def __init__(self, policy=Policy.map_data_priority): self._limit_solutions = {} # Store for speed limit solutions from different sources self._distance_solutions = {} # Store for distance to current speed limit start for different sources self._v_ego = 0. self._current_speed_limit = 0. self._policy = policy self._next_speed_limit_prev = 0. self.speed_limit = 0. self.distance = 0. self.source = SpeedLimitResolver.Source.none def resolve(self, v_ego, current_speed_limit, sm): self._v_ego = v_ego self._current_speed_limit = current_speed_limit self._sm = sm self._get_from_car_state() self._get_from_map_data() self._consolidate() return self.speed_limit, self.distance, self.source def _get_from_car_state(self): self._limit_solutions[SpeedLimitResolver.Source.car_state] = self._sm['carState'].cruiseState.speedLimit self._distance_solutions[SpeedLimitResolver.Source.car_state] = 0. def _get_from_map_data(self): # Ignore if no live map data sock = 'liveMapData' if self._sm.logMonoTime[sock] is None: self._limit_solutions[SpeedLimitResolver.Source.map_data] = 0. self._distance_solutions[SpeedLimitResolver.Source.map_data] = 0. _debug('SL: No map data for speed limit') return # Load limits from map_data map_data = self._sm[sock] speed_limit = map_data.speedLimit if map_data.speedLimitValid else 0. next_speed_limit = map_data.speedLimitAhead if map_data.speedLimitAheadValid else 0. # Calculate the age of the gps fix. Ignore if too old. gps_fix_age = time.time() - map_data.lastGpsTimestamp * 1e-3 if gps_fix_age > LIMIT_MAX_MAP_DATA_AGE: self._limit_solutions[SpeedLimitResolver.Source.map_data] = 0. self._distance_solutions[SpeedLimitResolver.Source.map_data] = 0. _debug(f'SL: Ignoring map data as is too old. Age: {gps_fix_age}') return # When we have no ahead speed limit to consider or it is greater than current speed limit # or car has stopped, then provide current value and reset tracking. if next_speed_limit == 0. or self._v_ego <= 0. or next_speed_limit > self._current_speed_limit: self._limit_solutions[SpeedLimitResolver.Source.map_data] = speed_limit self._distance_solutions[SpeedLimitResolver.Source.map_data] = 0. self._next_speed_limit_prev = 0. return # Calculate the actual distance to the speed limit ahead corrected by gps_fix_age distance_since_fix = self._v_ego * gps_fix_age distance_to_speed_limit_ahead = max(0., map_data.speedLimitAheadDistance - distance_since_fix) # When we have a next_speed_limit value that has not changed from a provided next speed limit value # in previous resolutions, we keep providing it. if next_speed_limit == self._next_speed_limit_prev: self._limit_solutions[SpeedLimitResolver.Source.map_data] = next_speed_limit self._distance_solutions[SpeedLimitResolver.Source.map_data] = distance_to_speed_limit_ahead return # Reset tracking self._next_speed_limit_prev = 0. # Calculated the time needed to adapt to the new limit and the corresponding distance. adapt_time = (next_speed_limit - self._v_ego) / LIMIT_ADAPT_ACC adapt_distance = self._v_ego * adapt_time + 0.5 * LIMIT_ADAPT_ACC * adapt_time**2 # When we detect we are close enough, we provide the next limit value and track it. if distance_to_speed_limit_ahead <= adapt_distance: self._limit_solutions[SpeedLimitResolver.Source.map_data] = next_speed_limit self._distance_solutions[SpeedLimitResolver.Source.map_data] = distance_to_speed_limit_ahead self._next_speed_limit_prev = next_speed_limit return # Otherwise we just provide the map data speed limit. self.distance_to_map_speed_limit = 0. self._limit_solutions[SpeedLimitResolver.Source.map_data] = speed_limit self._distance_solutions[SpeedLimitResolver.Source.map_data] = 0. def _consolidate(self): limits = np.array([], dtype=float) distances = np.array([], dtype=float) sources = np.array([], dtype=int) if self._policy == SpeedLimitResolver.Policy.car_state_only or \ self._policy == SpeedLimitResolver.Policy.car_state_priority or \ self._policy == SpeedLimitResolver.Policy.combined: limits = np.append(limits, self._limit_solutions[SpeedLimitResolver.Source.car_state]) distances = np.append(distances, self._distance_solutions[SpeedLimitResolver.Source.car_state]) sources = np.append(sources, SpeedLimitResolver.Source.car_state.value) if self._policy == SpeedLimitResolver.Policy.map_data_only or \ self._policy == SpeedLimitResolver.Policy.map_data_priority or \ self._policy == SpeedLimitResolver.Policy.combined: limits = np.append(limits, self._limit_solutions[SpeedLimitResolver.Source.map_data]) distances = np.append(distances, self._distance_solutions[SpeedLimitResolver.Source.map_data]) sources = np.append(sources, SpeedLimitResolver.Source.map_data.value) if np.amax(limits) == 0.: if self._policy == SpeedLimitResolver.Policy.car_state_priority: limits = np.append(limits, self._limit_solutions[SpeedLimitResolver.Source.map_data]) distances = np.append(distances, self._distance_solutions[SpeedLimitResolver.Source.map_data]) sources = np.append(sources, SpeedLimitResolver.Source.map_data.value) elif self._policy == SpeedLimitResolver.Policy.map_data_priority: limits = np.append(limits, self._limit_solutions[SpeedLimitResolver.Source.car_state]) distances = np.append(distances, self._distance_solutions[SpeedLimitResolver.Source.car_state]) sources = np.append(sources, SpeedLimitResolver.Source.car_state.value) # Get all non-zero values and set the minimum if any, otherwise 0. mask = limits > 0. limits = limits[mask] distances = distances[mask] sources = sources[mask] if len(limits) > 0: min_idx = np.argmin(limits) self.speed_limit = limits[min_idx] self.distance = distances[min_idx] self.source = SpeedLimitResolver.Source(sources[min_idx]) else: self.speed_limit = 0. self.distance = 0. self.source = SpeedLimitResolver.Source.none _debug(f'SL: *** Speed Limit set: {self.speed_limit}, distance: {self.distance}, source: {self.source}') class SpeedLimitController(): def __init__(self): self._params = Params() self._resolver = SpeedLimitResolver() self._last_params_update = 0.0 self._last_op_enabled_time = 0.0 self._is_metric = self._params.get_bool("IsMetric") self._is_enabled = self._params.get_bool("SpeedLimitControl") self._offset_enabled = self._params.get_bool("SpeedLimitPercOffset") self._op_enabled = False self._op_enabled_prev = False self._v_ego = 0. self._a_ego = 0. self._v_offset = 0. self._v_cruise_setpoint = 0. self._v_cruise_setpoint_prev = 0. self._v_cruise_setpoint_changed = False self._speed_limit = 0. self._speed_limit_prev = 0. self._speed_limit_changed = False self._distance = 0. self._source = SpeedLimitResolver.Source.none self._state = SpeedLimitControlState.inactive self._state_prev = SpeedLimitControlState.inactive self._gas_pressed = False self._a_target = 0. @property def a_target(self): return self._a_target if self.is_active else self._a_ego @property def state(self): return self._state @state.setter def state(self, value): if value != self._state: _debug(f'Speed Limit Controller state: {_description_for_state(value)}') if value == SpeedLimitControlState.tempInactive: # Reset previous speed limit to current value as to prevent going out of tempInactive in # a single cycle when the speed limit changes at the same time the user has temporarily deactivate it. self._speed_limit_prev = self._speed_limit self._state = value @property def is_active(self): return self.state > SpeedLimitControlState.tempInactive @property def speed_limit_offseted(self): return self._speed_limit + self.speed_limit_offset @property def speed_limit_offset(self): if self._offset_enabled: return interp(self._speed_limit, _LIMIT_PERC_OFFSET_BP, _LIMIT_PERC_OFFSET_V) * self._speed_limit return 0. @property def speed_limit(self): return self._speed_limit @property def distance(self): return self._distance @property def source(self): return self._source def _update_params(self): time = sec_since_boot() if time > self._last_params_update + _PARAMS_UPDATE_PERIOD: self._is_enabled = self._params.get_bool("SpeedLimitControl") self._offset_enabled = self._params.get_bool("SpeedLimitPercOffset") _debug(f'Updated Speed limit params. enabled: {self._is_enabled}, with offset: {self._offset_enabled}') self._last_params_update = time def _update_calculations(self): # Update current velocity offset (error) self._v_offset = self.speed_limit_offseted - self._v_ego # Track the time op becomes active to prevent going to tempInactive right away after # op enabling since controlsd will change the cruise speed every time on enabling and this will # cause a temp inactive transition if the controller is updated before controlsd sets actual cruise # speed. if not self._op_enabled_prev and self._op_enabled: self._last_op_enabled_time = sec_since_boot() # Update change tracking variables self._speed_limit_changed = self._speed_limit != self._speed_limit_prev self._v_cruise_setpoint_changed = self._v_cruise_setpoint != self._v_cruise_setpoint_prev self._speed_limit_prev = self._speed_limit self._v_cruise_setpoint_prev = self._v_cruise_setpoint self._op_enabled_prev = self._op_enabled def _state_transition(self): self._state_prev = self._state # In any case, if op is disabled, or speed limit control is disabled # or the reported speed limit is 0 or gas is pressed, deactivate. if not self._op_enabled or not self._is_enabled or self._speed_limit == 0 or self._gas_pressed: self.state = SpeedLimitControlState.inactive return # In any case, we deactivate the speed limit controller temporarily if the user changes the cruise speed. # Ignore if a minimum ammount of time has not passed since activation. This is to prevent temp inactivations # due to controlsd logic changing cruise setpoint when going active. if self._v_cruise_setpoint_changed and \ sec_since_boot() > (self._last_op_enabled_time + _TEMP_INACTIVE_GUARD_PERIOD): self.state = SpeedLimitControlState.tempInactive return # inactive if self.state == SpeedLimitControlState.inactive: # If the limit speed offset is negative (i.e. reduce speed) and lower than threshold # we go to adapting state to quickly reduce speed, otherwise we go directly to active if self._v_offset < LIMIT_SPEED_OFFSET_TH: self.state = SpeedLimitControlState.adapting else: self.state = SpeedLimitControlState.active # tempInactive elif self.state == SpeedLimitControlState.tempInactive: # if speed limit changes, transition to inactive, # proper active state will be set on next iteration. if self._speed_limit_changed: self.state = SpeedLimitControlState.inactive # adapting elif self.state == SpeedLimitControlState.adapting: # Go to active once the speed offset is over threshold. if self._v_offset >= LIMIT_SPEED_OFFSET_TH: self.state = SpeedLimitControlState.active # active elif self.state == SpeedLimitControlState.active: # Go to adapting if the speed offset goes below threshold. if self._v_offset < LIMIT_SPEED_OFFSET_TH: self.state = SpeedLimitControlState.adapting def _update_solution(self): # inactive or tempInactive state if self.state <= SpeedLimitControlState.tempInactive: # Preserve current values a_target = self._a_ego # adapting elif self.state == SpeedLimitControlState.adapting: # When adapting we target to achieve the speed limit on the distance if not there yet, # otherwise try to keep the speed constant around the control time horizon. if self.distance > 0: a_target = (self.speed_limit_offseted**2 - self._v_ego**2) / (2. * self.distance) else: a_target = self._v_offset / T_IDXS[CONTROL_N] # active elif self.state == SpeedLimitControlState.active: # When active we are trying to keep the speed constant around the control time horizon. a_target = self._v_offset / T_IDXS[CONTROL_N] # Keep solution limited. self._a_target = np.clip(a_target, LIMIT_MIN_ACC, LIMIT_MAX_ACC) def _update_events(self, events): if not self.is_active: # no event while inactive return if self._state_prev <= SpeedLimitControlState.tempInactive: events.add(EventName.speedLimitActive) elif self._speed_limit_changed != 0: events.add(EventName.speedLimitValueChange) def update(self, enabled, v_ego, a_ego, sm, v_cruise_setpoint, events=Events()): self._op_enabled = enabled self._v_ego = v_ego self._a_ego = a_ego self._v_cruise_setpoint = v_cruise_setpoint self._gas_pressed = sm['carState'].gasPressed self._speed_limit, self._distance, self._source = self._resolver.resolve(v_ego, self.speed_limit, sm) self._update_params() self._update_calculations() self._state_transition() self._update_solution() self._update_events(events) ================================================ FILE: selfdrive/controls/lib/turn_speed_controller.py ================================================ import numpy as np import time from common.params import Params from cereal import log from common.realtime import sec_since_boot from selfdrive.controls.lib.drive_helpers import LIMIT_ADAPT_ACC, LIMIT_MIN_SPEED, LIMIT_MAX_MAP_DATA_AGE, \ LIMIT_SPEED_OFFSET_TH, CONTROL_N, LIMIT_MIN_ACC, LIMIT_MAX_ACC from selfdrive.modeld.constants import T_IDXS _ACTIVE_LIMIT_MIN_ACC = -0.5 # m/s^2 Maximum deceleration allowed while active. _ACTIVE_LIMIT_MAX_ACC = 0.5 # m/s^2 Maximum acelration allowed while active. _DEBUG = False TurnSpeedControlState = log.LongitudinalPlan.SpeedLimitControlState def _debug(msg): if not _DEBUG: return print(msg) def _description_for_state(turn_speed_control_state): if turn_speed_control_state == TurnSpeedControlState.inactive: return 'INACTIVE' if turn_speed_control_state == TurnSpeedControlState.tempInactive: return 'TEMP INACTIVE' if turn_speed_control_state == TurnSpeedControlState.adapting: return 'ADAPTING' if turn_speed_control_state == TurnSpeedControlState.active: return 'ACTIVE' class TurnSpeedController(): def __init__(self): self._params = Params() self._last_params_update = 0. self._is_enabled = self._params.get_bool("TurnSpeedControl") self._op_enabled = False self._v_ego = 0. self._a_ego = 0. self._v_cruise_setpoint = 0. self._v_offset = 0. self._speed_limit = 0. self._speed_limit_temp_inactive = 0. self._distance = 0. self._turn_sign = 0 self._state = TurnSpeedControlState.inactive self._next_speed_limit_prev = 0. self._a_target = 0. @property def a_target(self): return self._a_target if self.is_active else self._a_ego @property def state(self): return self._state @state.setter def state(self, value): if value != self._state: _debug(f'Turn Speed Controller state: {_description_for_state(value)}') if value == TurnSpeedControlState.adapting: _debug('TSC: Enteriing Adapting as speed offset is below threshold') _debug(f'_v_offset: {self._v_offset * 3.6}\nspeed_limit: {self.speed_limit * 3.6}') _debug(f'_v_ego: {self._v_ego * 3.6}\ndistance: {self.distance}') if value == TurnSpeedControlState.tempInactive: # Track the speed limit value when controller was set to temp inactive. self._speed_limit_temp_inactive = self._speed_limit self._state = value @property def is_active(self): return self.state > TurnSpeedControlState.tempInactive @property def speed_limit(self): return max(self._speed_limit, LIMIT_MIN_SPEED) if self._speed_limit > 0. else 0. @property def distance(self): return max(self._distance, 0.) @property def turn_sign(self): return self._turn_sign def _get_limit_from_map_data(self, sm): """Provides the speed limit, distance and turn sign to it for turns based on map data. """ # Ignore if no live map data sock = 'liveMapData' if sm.logMonoTime[sock] is None: _debug('TS: No map data for turn speed limit') return 0., 0., 0 # Load map_data and initialize map_data = sm[sock] speed_limit = 0. # Calculate the age of the gps fix. Ignore if too old. gps_fix_age = time.time() - map_data.lastGpsTimestamp * 1e-3 if gps_fix_age > LIMIT_MAX_MAP_DATA_AGE: _debug(f'TS: Ignoring map data as is too old. Age: {gps_fix_age}') return 0., 0., 0 # Load turn ahead sections info from map_data with distances corrected by gps_fix_age distance_since_fix = self._v_ego * gps_fix_age distances_to_sections_ahead = np.maximum(0., np.array(map_data.turnSpeedLimitsAheadDistances) - distance_since_fix) speed_limit_in_sections_ahead = map_data.turnSpeedLimitsAhead turn_signs_in_sections_ahead = map_data.turnSpeedLimitsAheadSigns # Ensure current speed limit is considered only if we are inside the section. if map_data.turnSpeedLimitValid and self._v_ego > 0.: speed_limit_end_time = (map_data.turnSpeedLimitEndDistance / self._v_ego) - gps_fix_age if speed_limit_end_time > 0.: speed_limit = map_data.turnSpeedLimit # When we have no ahead speed limit to consider or all are greater than current speed limit # or car has stopped, then provide current value and reset tracking. turn_sign = map_data.turnSpeedLimitSign if map_data.turnSpeedLimitValid else 0 if len(speed_limit_in_sections_ahead) == 0 or self._v_ego <= 0. or \ (speed_limit > 0 and np.amin(speed_limit_in_sections_ahead) > speed_limit): self._next_speed_limit_prev = 0. return speed_limit, 0., turn_sign # Calculated the time needed to adapt to the limits ahead and the corresponding distances. adapt_times = (np.maximum(speed_limit_in_sections_ahead, LIMIT_MIN_SPEED) - self._v_ego) / LIMIT_ADAPT_ACC adapt_distances = self._v_ego * adapt_times + 0.5 * LIMIT_ADAPT_ACC * adapt_times**2 distance_gaps = distances_to_sections_ahead - adapt_distances # We select as next speed limit, the one that have the lowest distance gap. next_idx = np.argmin(distance_gaps) next_speed_limit = speed_limit_in_sections_ahead[next_idx] distance_to_section_ahead = distances_to_sections_ahead[next_idx] next_turn_sign = turn_signs_in_sections_ahead[next_idx] distance_gap = distance_gaps[next_idx] # When we have a next_speed_limit value that has not changed from a provided next speed limit value # in previous resolutions, we keep providing it along with the udpated distance to it. if next_speed_limit == self._next_speed_limit_prev: return next_speed_limit, distance_to_section_ahead, next_turn_sign # Reset tracking self._next_speed_limit_prev = 0. # When we detect we are close enough, we provide the next limit value and track it. if distance_gap <= 0.: self._next_speed_limit_prev = next_speed_limit return next_speed_limit, distance_to_section_ahead, next_turn_sign # Otherwise we just provide the calculated speed_limit return speed_limit, 0., turn_sign def _update_params(self): time = sec_since_boot() if time > self._last_params_update + 5.0: self._is_enabled = self._params.get_bool("TurnSpeedControl") self._last_params_update = time def _update_calculations(self): # Update current velocity offset (error) self._v_offset = self.speed_limit - self._v_ego def _state_transition(self, sm): # In any case, if op is disabled, or turn speed limit control is disabled # or the reported speed limit is 0, deactivate. if not self._op_enabled or not self._is_enabled or self.speed_limit == 0.: self.state = TurnSpeedControlState.inactive return # In any case, we deactivate the speed limit controller temporarily # if gas is pressed (to support gas override implementations). if sm['carState'].gasPressed: self.state = TurnSpeedControlState.tempInactive return # inactive if self.state == TurnSpeedControlState.inactive: # If the limit speed offset is negative (i.e. reduce speed) and lower than threshold and distanct to turn limit # is positive (not in turn yet) we go to adapting state to reduce speed, otherwise we go directly to active if self._v_offset < LIMIT_SPEED_OFFSET_TH and self.distance > 0.: self.state = TurnSpeedControlState.adapting else: self.state = TurnSpeedControlState.active # tempInactive elif self.state == TurnSpeedControlState.tempInactive: # if the speed limit recorded when going to temp Inactive changes # then set to inactive, activation will happen on next cycle if self._speed_limit != self._speed_limit_temp_inactive: self.state = TurnSpeedControlState.inactive # adapting elif self.state == TurnSpeedControlState.adapting: # Go to active once the speed offset is over threshold or the distance to turn is now 0. if self._v_offset >= LIMIT_SPEED_OFFSET_TH or self.distance == 0.: self.state = TurnSpeedControlState.active # active elif self.state == TurnSpeedControlState.active: # Go to adapting if the speed offset goes below threshold as long as the distance to turn is still positive. if self._v_offset < LIMIT_SPEED_OFFSET_TH and self.distance > 0.: self.state = TurnSpeedControlState.adapting def _update_solution(self): # inactive or tempInactive state if self.state <= TurnSpeedControlState.tempInactive: # Preserve current values a_target = self._a_ego # adapting elif self.state == TurnSpeedControlState.adapting: # When adapting we target to achieve the speed limit on the distance. a_target = (self.speed_limit**2 - self._v_ego**2) / (2. * self.distance) a_target = np.clip(a_target, LIMIT_MIN_ACC, LIMIT_MAX_ACC) # active elif self.state == TurnSpeedControlState.active: # When active we are trying to keep the speed constant around the control time horizon. # but under constrained acceleration limits since we are in a turn. a_target = self._v_offset / T_IDXS[CONTROL_N] a_target = np.clip(a_target, _ACTIVE_LIMIT_MIN_ACC, _ACTIVE_LIMIT_MAX_ACC) # update solution values. self._a_target = a_target def update(self, enabled, v_ego, a_ego, sm): self._op_enabled = enabled self._v_ego = v_ego self._a_ego = a_ego # Get the speed limit from Map Data self._speed_limit, self._distance, self._turn_sign = self._get_limit_from_map_data(sm) self._update_params() self._update_calculations() self._state_transition(sm) self._update_solution() ================================================ FILE: selfdrive/controls/lib/vehicle_model.py ================================================ #!/usr/bin/env python3 """ Dynamic bicycle model from "The Science of Vehicle Dynamics (2014), M. Guiggiani" The state is x = [v, r]^T with v lateral speed [m/s], and r rotational speed [rad/s] The input u is the steering angle [rad] The system is defined by x_dot = A*x + B*u A depends on longitudinal speed, u [m/s], and vehicle parameters CP """ from typing import Tuple import numpy as np from numpy.linalg import solve from cereal import car from common.params import Params class VehicleModel: def __init__(self, CP: car.CarParams): """ Args: CP: Car Parameters """ # for math readability, convert long names car params into short names self.m = CP.mass self.j = CP.rotationalInertia self.l = CP.wheelbase self.aF = CP.centerToFront self.aR = CP.wheelbase - CP.centerToFront self.chi = CP.steerRatioRear self.cF_orig = CP.tireStiffnessFront self.cR_orig = CP.tireStiffnessRear self.update_params(1.0, CP.steerRatio) def update_params(self, stiffness_factor: float, steer_ratio: float) -> None: """Update the vehicle model with a new stiffness factor and steer ratio""" self.cF = stiffness_factor * self.cF_orig self.cR = stiffness_factor * self.cR_orig self.sR = steer_ratio def steady_state_sol(self, sa: float, u: float) -> np.ndarray: """Returns the steady state solution. If the speed is too low we can't use the dynamic model (tire slip is undefined), we then have to use the kinematic model Args: sa: Steering wheel angle [rad] u: Speed [m/s] Returns: 2x1 matrix with steady state solution (lateral speed, rotational speed) """ if u > 0.1: return dyn_ss_sol(sa, u, self) else: return kin_ss_sol(sa, u, self) def calc_curvature(self, sa: float, u: float) -> float: """Returns the curvature. Multiplied by the speed this will give the yaw rate. Args: sa: Steering wheel angle [rad] u: Speed [m/s] Returns: Curvature factor [1/m] """ return self.curvature_factor(u) * sa / self.sR def curvature_factor(self, u: float) -> float: """Returns the curvature factor. Multiplied by wheel angle (not steering wheel angle) this will give the curvature. Args: u: Speed [m/s] Returns: Curvature factor [1/m] """ sf = calc_slip_factor(self) return (1. - self.chi) / (1. - sf * u**2) / self.l def get_steer_from_curvature(self, curv: float, u: float) -> float: """Calculates the required steering wheel angle for a given curvature Args: curv: Desired curvature [1/m] u: Speed [m/s] Returns: Steering wheel angle [rad] """ return curv * self.sR * 1.0 / self.curvature_factor(u) def get_steer_from_yaw_rate(self, yaw_rate: float, u: float) -> float: """Calculates the required steering wheel angle for a given yaw_rate Args: yaw_rate: Desired yaw rate [rad/s] u: Speed [m/s] Returns: Steering wheel angle [rad] """ curv = yaw_rate / u return self.get_steer_from_curvature(curv, u) def yaw_rate(self, sa: float, u: float) -> float: """Calculate yaw rate Args: sa: Steering wheel angle [rad] u: Speed [m/s] Returns: Yaw rate [rad/s] """ return self.calc_curvature(sa, u) * u def kin_ss_sol(sa: float, u: float, VM: VehicleModel) -> np.ndarray: """Calculate the steady state solution at low speeds At low speeds the tire slip is undefined, so a kinematic model is used. Args: sa: Steering angle [rad] u: Speed [m/s] VM: Vehicle model Returns: 2x1 matrix with steady state solution """ K = np.zeros((2, 1)) K[0, 0] = VM.aR / VM.sR / VM.l * u K[1, 0] = 1. / VM.sR / VM.l * u return K * sa def create_dyn_state_matrices(u: float, VM: VehicleModel) -> Tuple[np.ndarray, np.ndarray]: """Returns the A and B matrix for the dynamics system Args: u: Vehicle speed [m/s] VM: Vehicle model Returns: A tuple with the 2x2 A matrix, and 2x1 B matrix Parameters in the vehicle model: cF: Tire stiffness Front [N/rad] cR: Tire stiffness Front [N/rad] aF: Distance from CG to front wheels [m] aR: Distance from CG to rear wheels [m] m: Mass [kg] j: Rotational inertia [kg m^2] sR: Steering ratio [-] chi: Steer ratio rear [-] """ A = np.zeros((2, 2)) B = np.zeros((2, 1)) A[0, 0] = - (VM.cF + VM.cR) / (VM.m * u) A[0, 1] = - (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.m * u) - u A[1, 0] = - (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.j * u) A[1, 1] = - (VM.cF * VM.aF**2 + VM.cR * VM.aR**2) / (VM.j * u) B[0, 0] = (VM.cF + VM.chi * VM.cR) / VM.m / VM.sR B[1, 0] = (VM.cF * VM.aF - VM.chi * VM.cR * VM.aR) / VM.j / VM.sR return A, B def dyn_ss_sol(sa: float, u: float, VM: VehicleModel) -> np.ndarray: """Calculate the steady state solution when x_dot = 0, Ax + Bu = 0 => x = -A^{-1} B u Args: sa: Steering angle [rad] u: Speed [m/s] VM: Vehicle model Returns: 2x1 matrix with steady state solution """ A, B = create_dyn_state_matrices(u, VM) return -solve(A, B) * sa def calc_slip_factor(VM): """The slip factor is a measure of how the curvature changes with speed it's positive for Oversteering vehicle, negative (usual case) otherwise. """ return VM.m * (VM.cF * VM.aF - VM.cR * VM.aR) / (VM.l**2 * VM.cF * VM.cR) ================================================ FILE: selfdrive/controls/lib/vision_turn_controller.py ================================================ import numpy as np import math from cereal import log from common.numpy_fast import interp from common.params import Params from common.realtime import sec_since_boot from selfdrive.config import Conversions as CV from selfdrive.controls.lib.lane_planner import TRAJECTORY_SIZE from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX _MIN_V = 5.6 # Do not operate under 20km/h _ENTERING_PRED_LAT_ACC_TH = 1.3 # Predicted Lat Acc threshold to trigger entering turn state. _ABORT_ENTERING_PRED_LAT_ACC_TH = 1.1 # Predicted Lat Acc threshold to abort entering state if speed drops. _TURNING_LAT_ACC_TH = 1.6 # Lat Acc threshold to trigger turning turn state. _LEAVING_LAT_ACC_TH = 1.3 # Lat Acc threshold to trigger leaving turn state. _FINISH_LAT_ACC_TH = 1.1 # Lat Acc threshold to trigger end of turn cycle. _EVAL_STEP = 5. # mts. Resolution of the curvature evaluation. _EVAL_START = 20. # mts. Distance ahead where to start evaluating vision curvature. _EVAL_LENGHT = 150. # mts. Distance ahead where to stop evaluating vision curvature. _EVAL_RANGE = np.arange(_EVAL_START, _EVAL_LENGHT, _EVAL_STEP) _A_LAT_REG_MAX = 2. # Maximum lateral acceleration # Lookup table for the minimum smooth deceleration during the ENTERING state # depending on the actual maximum absolute lateral acceleration predicted on the turn ahead. _ENTERING_SMOOTH_DECEL_V = [-0.2, -1.] # min decel value allowed on ENTERING state _ENTERING_SMOOTH_DECEL_BP = [1.3, 3.] # absolute value of lat acc ahead # Lookup table for the acceleration for the TURNING state # depending on the current lateral acceleration of the vehicle. _TURNING_ACC_V = [0.5, 0., -0.4] # acc value _TURNING_ACC_BP = [1.5, 2.3, 3.] # absolute value of current lat acc _LEAVING_ACC = 0.5 # Confortble acceleration to regain speed while leaving a turn. _MIN_LANE_PROB = 0.6 # Minimum lanes probability to allow curvature prediction based on lanes. _DEBUG = False def _debug(msg): if not _DEBUG: return print(msg) VisionTurnControllerState = log.LongitudinalPlan.VisionTurnControllerState def eval_curvature(poly, x_vals): """ This function returns a vector with the curvature based on path defined by `poly` evaluated on distance vector `x_vals` """ # https://en.wikipedia.org/wiki/Curvature# Local_expressions def curvature(x): a = abs(2 * poly[1] + 6 * poly[0] * x) / (1 + (3 * poly[0] * x**2 + 2 * poly[1] * x + poly[2])**2)**(1.5) return a return np.vectorize(curvature)(x_vals) def eval_lat_acc(v_ego, x_curv): """ This function returns a vector with the lateral acceleration based for the provided speed `v_ego` evaluated over curvature vector `x_curv` """ def lat_acc(curv): a = v_ego**2 * curv return a return np.vectorize(lat_acc)(x_curv) def _description_for_state(turn_controller_state): if turn_controller_state == VisionTurnControllerState.disabled: return 'DISABLED' if turn_controller_state == VisionTurnControllerState.entering: return 'ENTERING' if turn_controller_state == VisionTurnControllerState.turning: return 'TURNING' if turn_controller_state == VisionTurnControllerState.leaving: return 'LEAVING' class VisionTurnController(): def __init__(self, CP): self._params = Params() self._CP = CP self._op_enabled = False self._gas_pressed = False self._is_enabled = self._params.get_bool("TurnVisionControl") self._last_params_update = 0. self._v_cruise_setpoint = 0. self._v_ego = 0. self._a_ego = 0. self._a_target = 0. self._v_overshoot = 0. self._state = VisionTurnControllerState.disabled self._reset() @property def state(self): return self._state @state.setter def state(self, value): if value != self._state: _debug(f'TVC: TurnVisionController state: {_description_for_state(value)}') if value == VisionTurnControllerState.disabled: self._reset() self._state = value @property def a_target(self): return self._a_target if self.is_active else self._a_ego @property def v_turn(self): return self._v_overshoot if self.is_active and self._lat_acc_overshoot_ahead else self._v_ego @property def is_active(self): return self._state != VisionTurnControllerState.disabled def _reset(self): self._current_lat_acc = 0. self._max_v_for_current_curvature = 0. self._max_pred_lat_acc = 0. self._v_overshoot_distance = 200. self._lat_acc_overshoot_ahead = False def _update_params(self): time = sec_since_boot() if time > self._last_params_update + 5.0: self._is_enabled = self._params.get_bool("TurnVisionControl") self._last_params_update = time def _update_calculations(self, sm): # Get path polynomial aproximation for curvature estimation from model data. path_poly = None model_data = sm['modelV2'] if sm.valid.get('modelV2', False) else None lat_planner_data = sm['lateralPlan'] if sm.valid.get('lateralPlan', False) else None # 1. When the probability of lanes is good enough, compute polynomial from lanes as they are way more stable # on current mode than drving path. if model_data is not None and len(model_data.laneLines) == 4 and len(model_data.laneLines[0].t) == TRAJECTORY_SIZE: ll_x = model_data.laneLines[1].x # left and right ll x is the same lll_y = np.array(model_data.laneLines[1].y) rll_y = np.array(model_data.laneLines[2].y) l_prob = model_data.laneLineProbs[1] r_prob = model_data.laneLineProbs[2] lll_std = model_data.laneLineStds[1] rll_std = model_data.laneLineStds[2] # Reduce reliance on lanelines that are too far apart or will be in a few seconds width_pts = rll_y - lll_y prob_mods = [] for t_check in [0.0, 1.5, 3.0]: width_at_t = interp(t_check * (self._v_ego + 7), ll_x, width_pts) prob_mods.append(interp(width_at_t, [4.0, 5.0], [1.0, 0.0])) mod = min(prob_mods) l_prob *= mod r_prob *= mod # Reduce reliance on uncertain lanelines l_std_mod = interp(lll_std, [.15, .3], [1.0, 0.0]) r_std_mod = interp(rll_std, [.15, .3], [1.0, 0.0]) l_prob *= l_std_mod r_prob *= r_std_mod # Find path from lanes as the average center lane only if min probability on both lanes is above threshold. if l_prob > _MIN_LANE_PROB and r_prob > _MIN_LANE_PROB: c_y = width_pts / 2 + lll_y path_poly = np.polyfit(ll_x, c_y, 3) # 2. If not polynomial derived from lanes, then derive it from compensated driving path with lanes as # provided by `lateralPlanner`. if path_poly is None and lat_planner_data is not None and len(lat_planner_data.dPathWLinesX) > 0 \ and lat_planner_data.dPathWLinesX[0] > 0: path_poly = np.polyfit(lat_planner_data.dPathWLinesX, lat_planner_data.dPathWLinesY, 3) # 3. If no polynomial derived from lanes or driving path, then provide a straight line poly. if path_poly is None: path_poly = np.array([0., 0., 0., 0.]) current_curvature = abs( sm['carState'].steeringAngleDeg * CV.DEG_TO_RAD / (self._CP.steerRatio * self._CP.wheelbase)) self._current_lat_acc = current_curvature * self._v_ego**2 self._max_v_for_current_curvature = math.sqrt(_A_LAT_REG_MAX / current_curvature) if current_curvature > 0 \ else V_CRUISE_MAX * CV.KPH_TO_MS pred_curvatures = eval_curvature(path_poly, _EVAL_RANGE) max_pred_curvature = np.amax(pred_curvatures) self._max_pred_lat_acc = self._v_ego**2 * max_pred_curvature max_curvature_for_vego = _A_LAT_REG_MAX / max(self._v_ego, 0.1)**2 lat_acc_overshoot_idxs = np.nonzero(pred_curvatures >= max_curvature_for_vego)[0] self._lat_acc_overshoot_ahead = len(lat_acc_overshoot_idxs) > 0 if self._lat_acc_overshoot_ahead: self._v_overshoot = min(math.sqrt(_A_LAT_REG_MAX / max_pred_curvature), self._v_cruise_setpoint) self._v_overshoot_distance = max(lat_acc_overshoot_idxs[0] * _EVAL_STEP + _EVAL_START, _EVAL_STEP) _debug(f'TVC: High LatAcc. Dist: {self._v_overshoot_distance:.2f}, v: {self._v_overshoot * CV.MS_TO_KPH:.2f}') def _state_transition(self): # In any case, if system is disabled or the feature is disabeld or gas is pressed, disable. if not self._op_enabled or not self._is_enabled or self._gas_pressed: self.state = VisionTurnControllerState.disabled return # DISABLED if self.state == VisionTurnControllerState.disabled: # Do not enter a turn control cycle if speed is low. if self._v_ego <= _MIN_V: pass # If substantial lateral acceleration is predicted ahead, then move to Entering turn state. elif self._max_pred_lat_acc >= _ENTERING_PRED_LAT_ACC_TH: self.state = VisionTurnControllerState.entering # ENTERING elif self.state == VisionTurnControllerState.entering: # Transition to Turning if current lateral acceleration is over the threshold. if self._current_lat_acc >= _TURNING_LAT_ACC_TH: self.state = VisionTurnControllerState.turning # Abort if the predicted lateral acceleration drops elif self._max_pred_lat_acc < _ABORT_ENTERING_PRED_LAT_ACC_TH: self.state = VisionTurnControllerState.disabled # TURNING elif self.state == VisionTurnControllerState.turning: # Transition to Leaving if current lateral acceleration drops drops below threshold. if self._current_lat_acc <= _LEAVING_LAT_ACC_TH: self.state = VisionTurnControllerState.leaving # LEAVING elif self.state == VisionTurnControllerState.leaving: # Transition back to Turning if current lateral acceleration goes back over the threshold. if self._current_lat_acc >= _TURNING_LAT_ACC_TH: self.state = VisionTurnControllerState.turning # Finish if current lateral acceleration goes below threshold. elif self._current_lat_acc < _FINISH_LAT_ACC_TH: self.state = VisionTurnControllerState.disabled def _update_solution(self): # DISABLED if self.state == VisionTurnControllerState.disabled: # when not overshooting, calculate v_turn as the speed at the prediction horizon when following # the smooth deceleration. a_target = self._a_ego # ENTERING elif self.state == VisionTurnControllerState.entering: # when not overshooting, target a smooth deceleration in preparation for a sharp turn to come. a_target = interp(self._max_pred_lat_acc, _ENTERING_SMOOTH_DECEL_BP, _ENTERING_SMOOTH_DECEL_V) if self._lat_acc_overshoot_ahead: # when overshooting, target the acceleration needed to achieve the overshoot speed at # the required distance a_target = min((self._v_overshoot**2 - self._v_ego**2) / (2 * self._v_overshoot_distance), a_target) _debug(f'TVC Entering: Overshooting: {self._lat_acc_overshoot_ahead}') _debug(f' Decel: {a_target:.2f}, target v: {self.v_turn * CV.MS_TO_KPH}') # TURNING elif self.state == VisionTurnControllerState.turning: # When turning we provide a target acceleration that is confortable for the lateral accelearation felt. a_target = interp(self._current_lat_acc, _TURNING_ACC_BP, _TURNING_ACC_V) # LEAVING elif self.state == VisionTurnControllerState.leaving: # When leaving we provide a confortable acceleration to regain speed. a_target = _LEAVING_ACC # update solution values. self._a_target = a_target def update(self, enabled, v_ego, a_ego, v_cruise_setpoint, sm): self._op_enabled = enabled self._gas_pressed = sm['carState'].gasPressed self._v_ego = v_ego self._a_ego = a_ego self._v_cruise_setpoint = v_cruise_setpoint self._update_params() self._update_calculations(sm) self._state_transition() self._update_solution() ================================================ FILE: selfdrive/controls/plannerd.py ================================================ #!/usr/bin/env python3 from cereal import car from common.params import Params from common.realtime import Priority, config_realtime_process from selfdrive.swaglog import cloudlog from selfdrive.controls.lib.longitudinal_planner import Planner from selfdrive.controls.lib.lateral_planner import LateralPlanner from selfdrive.hardware import TICI, JETSON import cereal.messaging as messaging def plannerd_thread(sm=None, pm=None): config_realtime_process(5 if TICI else 4 if JETSON else 2, Priority.CTRL_LOW) cloudlog.info("plannerd is waiting for CarParams") params = Params() CP = car.CarParams.from_bytes(params.get("CarParams", block=True)) cloudlog.info("plannerd got CarParams: %s", CP.carName) use_lanelines = not params.get_bool('EndToEndToggle') wide_camera = params.get_bool('EnableWideCamera') if TICI else False cloudlog.event("e2e mode", on=use_lanelines) longitudinal_planner = Planner(CP) lateral_planner = LateralPlanner(CP, use_lanelines=use_lanelines, wide_camera=wide_camera) if sm is None: sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'modelV2', 'dragonConf', 'liveMapData'], poll=['radarState', 'modelV2'], ignore_avg_freq=['radarState']) if pm is None: pm = messaging.PubMaster(['longitudinalPlan', 'liveLongitudinalMpc', 'lateralPlan', 'liveMpc']) while True: sm.update() if sm.updated['modelV2']: lateral_planner.update(sm, CP) lateral_planner.publish(sm, pm) if sm.updated['radarState']: longitudinal_planner.update(sm, CP) longitudinal_planner.publish(sm, pm) def main(sm=None, pm=None): plannerd_thread(sm, pm) if __name__ == "__main__": main() ================================================ FILE: selfdrive/controls/radard.py ================================================ #!/usr/bin/env python3 import importlib import math from collections import defaultdict, deque import cereal.messaging as messaging from cereal import car from common.numpy_fast import interp from common.params import Params from common.realtime import Ratekeeper, Priority, config_realtime_process from selfdrive.config import RADAR_TO_CAMERA from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid from selfdrive.controls.lib.radar_helpers import Cluster, Track from selfdrive.swaglog import cloudlog from selfdrive.hardware import TICI, JETSON class KalmanParams(): def __init__(self, dt): # Lead Kalman Filter params, calculating K from A, C, Q, R requires the control library. # hardcoding a lookup table to compute K for values of radar_ts between 0.1s and 1.0s assert dt > .01 and dt < .1, "Radar time step must be between .01s and 0.1s" self.A = [[1.0, dt], [0.0, 1.0]] self.C = [1.0, 0.0] #Q = np.matrix([[10., 0.0], [0.0, 100.]]) #R = 1e3 #K = np.matrix([[ 0.05705578], [ 0.03073241]]) dts = [dt * 0.01 for dt in range(1, 11)] K0 = [0.12288, 0.14557, 0.16523, 0.18282, 0.19887, 0.21372, 0.22761, 0.24069, 0.2531, 0.26491] K1 = [0.29666, 0.29331, 0.29043, 0.28787, 0.28555, 0.28342, 0.28144, 0.27958, 0.27783, 0.27617] self.K = [[interp(dt, dts, K0)], [interp(dt, dts, K1)]] def laplacian_cdf(x, mu, b): b = max(b, 1e-4) return math.exp(-abs(x-mu)/b) def match_vision_to_cluster(v_ego, lead, clusters): # match vision point to best statistical cluster match offset_vision_dist = lead.x[0] - RADAR_TO_CAMERA def prob(c): prob_d = laplacian_cdf(c.dRel, offset_vision_dist, lead.xStd[0]) prob_y = laplacian_cdf(c.yRel, -lead.y[0], lead.yStd[0]) prob_v = laplacian_cdf(c.vRel + v_ego, lead.v[0], lead.vStd[0]) # This is isn't exactly right, but good heuristic return prob_d * prob_y * prob_v cluster = max(clusters, key=prob) # if no 'sane' match is found return -1 # stationary radar points can be false positives dist_sane = abs(cluster.dRel - offset_vision_dist) < max([(offset_vision_dist)*.25, 5.0]) vel_sane = (abs(cluster.vRel + v_ego - lead.v[0]) < 10) or (v_ego + cluster.vRel > 3) if dist_sane and vel_sane: return cluster else: return None def get_lead(v_ego, ready, clusters, lead_msg, low_speed_override=True): # Determine leads, this is where the essential logic happens if len(clusters) > 0 and ready and lead_msg.prob > .5: cluster = match_vision_to_cluster(v_ego, lead_msg, clusters) else: cluster = None lead_dict = {'status': False} if cluster is not None: lead_dict = cluster.get_RadarState(lead_msg.prob) elif (cluster is None) and ready and (lead_msg.prob > .5): lead_dict = Cluster().get_RadarState_from_vision(lead_msg, v_ego) if low_speed_override: low_speed_clusters = [c for c in clusters if c.potential_low_speed_lead(v_ego)] if len(low_speed_clusters) > 0: closest_cluster = min(low_speed_clusters, key=lambda c: c.dRel) # Only choose new cluster if it is actually closer than the previous one if (not lead_dict['status']) or (closest_cluster.dRel < lead_dict['dRel']): lead_dict = closest_cluster.get_RadarState() return lead_dict class RadarD(): def __init__(self, radar_ts, delay=0): self.current_time = 0 self.tracks = defaultdict(dict) self.kalman_params = KalmanParams(radar_ts) # v_ego self.v_ego = 0. self.v_ego_hist = deque([0], maxlen=delay+1) self.ready = False def update(self, sm, rr, enable_lead): self.current_time = 1e-9*max(sm.logMonoTime.values()) if sm.updated['carState']: self.v_ego = sm['carState'].vEgo self.v_ego_hist.append(self.v_ego) if sm.updated['modelV2']: self.ready = True ar_pts = {} for pt in rr.points: ar_pts[pt.trackId] = [pt.dRel, pt.yRel, pt.vRel, pt.measured] # *** remove missing points from meta data *** for ids in list(self.tracks.keys()): if ids not in ar_pts: self.tracks.pop(ids, None) # *** compute the tracks *** for ids in ar_pts: rpt = ar_pts[ids] # align v_ego by a fixed time to align it with the radar measurement v_lead = rpt[2] + self.v_ego_hist[0] # create the track if it doesn't exist or it's a new track if ids not in self.tracks: self.tracks[ids] = Track(v_lead, self.kalman_params) self.tracks[ids].update(rpt[0], rpt[1], rpt[2], v_lead, rpt[3]) idens = list(sorted(self.tracks.keys())) track_pts = list([self.tracks[iden].get_key_for_cluster() for iden in idens]) # If we have multiple points, cluster them if len(track_pts) > 1: cluster_idxs = cluster_points_centroid(track_pts, 2.5) clusters = [None] * (max(cluster_idxs) + 1) for idx in range(len(track_pts)): cluster_i = cluster_idxs[idx] if clusters[cluster_i] is None: clusters[cluster_i] = Cluster() clusters[cluster_i].add(self.tracks[idens[idx]]) elif len(track_pts) == 1: # FIXME: cluster_point_centroid hangs forever if len(track_pts) == 1 cluster_idxs = [0] clusters = [Cluster()] clusters[0].add(self.tracks[idens[0]]) else: clusters = [] # if a new point, reset accel to the rest of the cluster for idx in range(len(track_pts)): if self.tracks[idens[idx]].cnt <= 1: aLeadK = clusters[cluster_idxs[idx]].aLeadK aLeadTau = clusters[cluster_idxs[idx]].aLeadTau self.tracks[idens[idx]].reset_a_lead(aLeadK, aLeadTau) # *** publish radarState *** dat = messaging.new_message('radarState') dat.valid = sm.all_alive_and_valid() and len(rr.errors) == 0 radarState = dat.radarState radarState.mdMonoTime = sm.logMonoTime['modelV2'] radarState.canMonoTimes = list(rr.canMonoTimes) radarState.radarErrors = list(rr.errors) radarState.carStateMonoTime = sm.logMonoTime['carState'] if enable_lead: if len(sm['modelV2'].leadsV3) > 1: radarState.leadOne = get_lead(self.v_ego, self.ready, clusters, sm['modelV2'].leadsV3[0], low_speed_override=True) radarState.leadTwo = get_lead(self.v_ego, self.ready, clusters, sm['modelV2'].leadsV3[1], low_speed_override=False) return dat # fuses camera and radar data for best lead detection def radard_thread(sm=None, pm=None, can_sock=None): config_realtime_process(5 if TICI else 4 if JETSON else 2, Priority.CTRL_LOW) # wait for stats about the car to come in from controls cloudlog.info("radard is waiting for CarParams") CP = car.CarParams.from_bytes(Params().get("CarParams", block=True)) cloudlog.info("radard got CarParams") # import the radar from the fingerprint cloudlog.info("radard is importing %s", CP.carName) RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % CP.carName).RadarInterface # *** setup messaging if can_sock is None: can_sock = messaging.sub_sock('can') if sm is None: sm = messaging.SubMaster(['modelV2', 'carState'], ignore_avg_freq=['modelV2', 'carState']) # Can't check average frequency, since radar determines timing if pm is None: pm = messaging.PubMaster(['radarState', 'liveTracks']) RI = RadarInterface(CP) rk = Ratekeeper(1.0 / CP.radarTimeStep, print_delay_threshold=None) RD = RadarD(CP.radarTimeStep, RI.delay) # TODO: always log leads once we can hide them conditionally enable_lead = True #CP.openpilotLongitudinalControl or not CP.radarOffCan while 1: can_strings = messaging.drain_sock_raw(can_sock, wait_for_one=True) rr = RI.update(can_strings) if rr is None: continue sm.update(0) dat = RD.update(sm, rr, enable_lead) dat.radarState.cumLagMs = -rk.remaining*1000. pm.send('radarState', dat) # *** publish tracks for UI debugging (keep last) *** tracks = RD.tracks dat = messaging.new_message('liveTracks', len(tracks)) for cnt, ids in enumerate(sorted(tracks.keys())): dat.liveTracks[cnt] = { "trackId": ids, "dRel": float(tracks[ids].dRel), "yRel": float(tracks[ids].yRel), "vRel": float(tracks[ids].vRel), } pm.send('liveTracks', dat) rk.monitor_time() def main(sm=None, pm=None, can_sock=None): radard_thread(sm, pm, can_sock) if __name__ == "__main__": main() ================================================ FILE: selfdrive/crash.py ================================================ """Install exception handler for process crash.""" import os import sys import capnp import traceback import requests from cereal import car from datetime import datetime from selfdrive.swaglog import cloudlog from selfdrive.version import version from selfdrive.version import version, branch, origin, branch, dirty, commit, get_git_commit from common.params import Params import sentry_sdk from sentry_sdk import set_tag from sentry_sdk.integrations.threading import ThreadingIntegration CRASHES_DIR = '/data/community/crashes' def save_exception(exc_text): if not os.path.exists(CRASHES_DIR): os.makedirs(CRASHES_DIR) log_file = '{}/{}'.format(CRASHES_DIR, datetime.now().strftime('%m-%d-%Y--%I:%M.%S-%p.log')) with open(log_file, 'w') as f: f.write(exc_text) print('Logged current crash to {}'.format(log_file)) ret = car.CarParams.new_message() candidate = ret.carFingerprint params = Params() #uniqueID = op_params.get('uniqueID') try: dongle_id = params.get("DongleId").decode('utf8') except AttributeError: dongle_id = "None" try: gitname = Params().get("GithubUsername", encoding='utf-8') except: gitname = "" try: ip = requests.get('https://checkip.amazonaws.com/').text.strip() except Exception: ip = "255.255.255.255" error_tags = {'dirty': dirty, 'dongle_id': dongle_id, 'branch': branch, 'remote': origin, 'fingerprintedAs': candidate, 'gitname':gitname} dongle_id = Params().get("DongleId", encoding='utf-8') def capture_exception(*args, **kwargs): save_exception(traceback.format_exc()) exc_info = sys.exc_info() if not exc_info[0] is capnp.lib.capnp.KjException: save_exception(traceback.format_exc()) sentry_sdk.capture_exception(*args, **kwargs) sentry_sdk.flush() # https://github.com/getsentry/sentry-python/issues/291 cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1)) def bind_user(**kwargs) -> None: sentry_sdk.set_user(kwargs) def capture_warning(warning_string): bind_user(id=dongle_id, ip_address=ip, name=gitname) sentry_sdk.capture_message(warning_string, level='warning') def capture_info(info_string): bind_user(id=dongle_id, ip_address=ip, name=gitname) sentry_sdk.capture_message(info_string, level='info') def bind_extra(**kwargs) -> None: for k, v in kwargs.items(): sentry_sdk.set_tag(k, v) def init() -> None: sentry_sdk.init("https://980a0cba712a4c3593c33c78a12446e1:fecab286bcaf4dba8b04f7cff0188e2d@sentry.io/1488600", default_integrations=False, integrations=[ThreadingIntegration(propagate_hub=True)], release=version) sentry_sdk.set_user({"id": dongle_id}) sentry_sdk.set_user({"name": gitname}) sentry_sdk.set_tag("dirty", dirty) sentry_sdk.set_tag("origin", origin) sentry_sdk.set_tag("branch", branch) sentry_sdk.set_tag("commit", commit) ================================================ FILE: selfdrive/debug/__init__.py ================================================ ================================================ FILE: selfdrive/debug/can_print_changes.py ================================================ #!/usr/bin/env python3 import binascii import sys from collections import defaultdict import cereal.messaging as messaging from common.realtime import sec_since_boot def can_printer(bus=0): """Collects messages and prints when a new bit transition is observed. This is very useful to find signals based on user triggered actions, such as blinkers and seatbelt. Leave the script running until no new transitions are seen, then perform the action.""" logcan = messaging.sub_sock('can') low_to_high = defaultdict(int) high_to_low = defaultdict(int) while 1: can_recv = messaging.drain_sock(logcan, wait_for_one=True) for x in can_recv: for y in x.can: if y.src == bus: i = int.from_bytes(y.dat, byteorder='big') l_h = low_to_high[y.address] h_l = high_to_low[y.address] change = None if (i | l_h) != l_h: low_to_high[y.address] = i | l_h change = "+" if (~i | h_l) != h_l: high_to_low[y.address] = ~i | h_l change = "-" if change: print(f"{sec_since_boot():.2f}\t{hex(y.address)} ({y.address})\t{change}{binascii.hexlify(y.dat)}") if __name__ == "__main__": if len(sys.argv) > 1: can_printer(int(sys.argv[1])) else: can_printer() ================================================ FILE: selfdrive/debug/can_printer.py ================================================ #!/usr/bin/env python3 import binascii import os import sys from collections import defaultdict import cereal.messaging as messaging from common.realtime import sec_since_boot def can_printer(bus=0, max_msg=None, addr="127.0.0.1"): logcan = messaging.sub_sock('can', addr=addr) start = sec_since_boot() lp = sec_since_boot() msgs = defaultdict(list) canbus = int(os.getenv("CAN", bus)) while 1: can_recv = messaging.drain_sock(logcan, wait_for_one=True) for x in can_recv: for y in x.can: if y.src == canbus: msgs[y.address].append(y.dat) if sec_since_boot() - lp > 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) for k, v in sorted(zip(msgs.keys(), map(lambda x: binascii.hexlify(x[-1]), msgs.values()))): if max_msg is None or k < max_msg: dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k, k), len(msgs[k]), v.decode('ascii')) print(dd) lp = sec_since_boot() if __name__ == "__main__": if len(sys.argv) > 3: can_printer(int(sys.argv[1]), int(sys.argv[2]), sys.argv[3]) elif len(sys.argv) > 2: can_printer(int(sys.argv[1]), int(sys.argv[2])) elif len(sys.argv) > 1: can_printer(int(sys.argv[1])) else: can_printer() ================================================ FILE: selfdrive/debug/check_freq.py ================================================ #!/usr/bin/env python3 # type: ignore import argparse import numpy as np from collections import defaultdict, deque from common.realtime import sec_since_boot import cereal.messaging as messaging if __name__ == "__main__": context = messaging.Context() poller = messaging.Poller() parser = argparse.ArgumentParser() parser.add_argument("socket", type=str, nargs='*', help="socket name") args = parser.parse_args() socket_names = args.socket sockets = {} rcv_times = defaultdict(lambda: deque(maxlen=100)) valids = defaultdict(lambda: deque(maxlen=100)) t = sec_since_boot() for name in socket_names: sock = messaging.sub_sock(name, poller=poller) sockets[sock] = name prev_print = t while True: for socket in poller.poll(100): msg = messaging.recv_one(socket) name = msg.which() t = sec_since_boot() rcv_times[name].append(msg.logMonoTime / 1e9) valids[name].append(msg.valid) if t - prev_print > 1: print() for name in socket_names: dts = np.diff(rcv_times[name]) mean = np.mean(dts) print("%s: Freq %.2f Hz, Min %.2f%%, Max %.2f%%, valid " % (name, 1.0 / mean, np.min(dts) / mean * 100, np.max(dts) / mean * 100), all(valids[name])) prev_print = t ================================================ FILE: selfdrive/debug/check_lag.py ================================================ #!/usr/bin/env python3 # type: ignore import cereal.messaging as messaging from cereal.services import service_list TO_CHECK = ['carState'] if __name__ == "__main__": sm = messaging.SubMaster(TO_CHECK) prev_t = {} while True: sm.update() for s in TO_CHECK: if sm.updated[s]: t = sm.logMonoTime[s] / 1e9 if s in prev_t: expected = 1.0 / (service_list[s].frequency) dt = t - prev_t[s] if dt > 10 * expected: print(t, s, dt) prev_t[s] = t ================================================ FILE: selfdrive/debug/check_timings.py ================================================ #!/usr/bin/env python3 # type: ignore import sys import time import numpy as np from collections import defaultdict, deque import cereal.messaging as messaging socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]} ts = defaultdict(lambda: deque(maxlen=100)) if __name__ == "__main__": while True: print() for s, sock in socks.items(): msgs = messaging.drain_sock(sock) for m in msgs: ts[s].append(m.logMonoTime / 1e6) if len(ts[s]) == ts[s].maxlen: d = np.diff(ts[s]) print(f"{s:17} {np.mean(d):.2f} {np.std(d):.2f} {np.max(d):.2f} {np.min(d):.2f}") time.sleep(1) ================================================ FILE: selfdrive/debug/compare_fingerprints.py ================================================ #!/usr/bin/env python3 # flake8: noqa # put 2 fingeprints and print the diffs f1 = { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 520: 8, 528: 8, 532: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8, 1537: 8, 1538: 8, 1562: 8 } f2 = { 168: 8, 257: 5, 258: 8, 264: 8, 268: 8, 270: 8, 274: 2, 280: 8, 284: 8, 288: 7, 290: 6, 291: 8, 292: 8, 294: 8, 300: 8, 308: 8, 320: 8, 324: 8, 331: 8, 332: 8, 344: 8, 368: 8, 376: 3, 384: 8, 388: 4, 448: 6, 456: 4, 464: 8, 469: 8, 480: 8, 500: 8, 501: 8, 512: 8, 514: 8, 515: 7, 516: 7, 517: 7, 518: 7, 520: 8, 528: 8, 532: 8, 542: 8, 544: 8, 557: 8, 559: 8, 560: 8, 564: 8, 571: 3, 579: 8, 584: 8, 608: 8, 624: 8, 625: 8, 632: 8, 639: 8, 653: 8, 654: 8, 655: 8, 658: 6, 660: 8, 669: 3, 671: 8, 672: 8, 678: 8, 680: 8, 701: 8, 703: 8, 704: 8, 705: 8, 706: 8, 709: 8, 710: 8, 719: 8, 720: 6, 729: 5, 736: 8, 737: 8, 746: 5, 752: 2, 754: 8, 760: 8, 764: 8, 766: 8, 770: 8, 773: 8, 779: 8, 782: 8, 784: 8, 792: 8, 799: 8, 800: 8, 804: 8, 816: 8, 817: 8, 820: 8, 825: 2, 826: 8, 832: 8, 838: 2, 848: 8, 853: 8, 856: 4, 860: 6, 863: 8, 878: 8, 882: 8, 897: 8, 906: 8, 908: 8, 924: 8, 926: 3, 929: 8, 937: 8, 938: 8, 939: 8, 940: 8, 941: 8, 942: 8, 943: 8, 947: 8, 948: 8, 958: 8, 959: 8, 962: 8, 969: 4, 973: 8, 974: 5, 979: 8, 980: 8, 981: 8, 982: 8, 983: 8, 984: 8, 992: 8, 993: 7, 995: 8, 996: 8, 1000: 8, 1001: 8, 1002: 8, 1003: 8, 1008: 8, 1009: 8, 1010: 8, 1011: 8, 1012: 8, 1013: 8, 1014: 8, 1015: 8, 1024: 8, 1025: 8, 1026: 8, 1031: 8, 1033: 8, 1050: 8, 1059: 8, 1082: 8, 1083: 8, 1098: 8, 1100: 8 } for k in f1: if k not in f2 or f1[k] != f2[k]: print(k, "not in f2") for k in f2: if k not in f1 or f2[k] != f1[k]: print(k, "not in f1") ================================================ FILE: selfdrive/debug/count_events.py ================================================ #!/usr/bin/env python3 import sys from collections import Counter from pprint import pprint from tqdm import tqdm from tools.lib.route import Route from tools.lib.logreader import LogReader if __name__ == "__main__": r = Route(sys.argv[1]) cnt_valid: Counter = Counter() cnt_events: Counter = Counter() for q in tqdm(r.qlog_paths()): lr = list(LogReader(q)) for msg in lr: if msg.which() == 'carEvents': for e in msg.carEvents: cnt_events[e.name] += 1 if not msg.valid: cnt_valid[msg.which()] += 1 print("Events") pprint(cnt_events) print("\n\n") print("Not valid") pprint(cnt_valid) ================================================ FILE: selfdrive/debug/cpu_usage_stat.py ================================================ #!/usr/bin/env python3 # type: ignore ''' System tools like top/htop can only show current cpu usage values, so I write this script to do statistics jobs. Features: Use psutil library to sample cpu usage(avergage for all cores) of openpilot processes, at a rate of 5 samples/sec. Do cpu usage statistics periodically, 5 seconds as a cycle. Caculate the average cpu usage within this cycle. Caculate minumium/maximium/accumulated_average cpu usage as long term inspections. Monitor multiple processes simuteneously. Sample usage: root@localhost:/data/openpilot$ python selfdrive/debug/cpu_usage_stat.py boardd,ubloxd ('Add monitored proc:', './boardd') ('Add monitored proc:', 'python locationd/ubloxd.py') boardd: 1.96%, min: 1.96%, max: 1.96%, acc: 1.96% ubloxd.py: 0.39%, min: 0.39%, max: 0.39%, acc: 0.39% ''' import psutil import time import os import sys import numpy as np import argparse import re from collections import defaultdict from selfdrive.manager.process_config import managed_processes # Do statistics every 5 seconds PRINT_INTERVAL = 5 SLEEP_INTERVAL = 0.2 monitored_proc_names = [ # android procs 'SurfaceFlinger', 'sensors.qcom' ] + list(managed_processes.keys()) cpu_time_names = ['user', 'system', 'children_user', 'children_system'] timer = getattr(time, 'monotonic', time.time) def get_arg_parser(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("proc_names", nargs="?", default='', help="Process names to be monitored, comma separated") parser.add_argument("--list_all", action='store_true', help="Show all running processes' cmdline") parser.add_argument("--detailed_times", action='store_true', help="show cpu time details (split by user, system, child user, child system)") return parser if __name__ == "__main__": args = get_arg_parser().parse_args(sys.argv[1:]) if args.list_all: for p in psutil.process_iter(): print('cmdline', p.cmdline(), 'name', p.name()) sys.exit(0) if len(args.proc_names) > 0: monitored_proc_names = args.proc_names.split(',') monitored_procs = [] stats = {} for p in psutil.process_iter(): if p == psutil.Process(): continue matched = any([l for l in p.cmdline() if any([pn for pn in monitored_proc_names if re.match(r'.*{}.*'.format(pn), l, re.M | re.I)])]) if matched: k = ' '.join(p.cmdline()) print('Add monitored proc:', k) stats[k] = {'cpu_samples': defaultdict(list), 'min': defaultdict(lambda: None), 'max': defaultdict(lambda: None), 'avg': defaultdict(lambda: 0.0), 'last_cpu_times': None, 'last_sys_time': None} stats[k]['last_sys_time'] = timer() stats[k]['last_cpu_times'] = p.cpu_times() monitored_procs.append(p) i = 0 interval_int = int(PRINT_INTERVAL / SLEEP_INTERVAL) while True: for p in monitored_procs: k = ' '.join(p.cmdline()) cur_sys_time = timer() cur_cpu_times = p.cpu_times() cpu_times = np.subtract(cur_cpu_times, stats[k]['last_cpu_times']) / (cur_sys_time - stats[k]['last_sys_time']) stats[k]['last_sys_time'] = cur_sys_time stats[k]['last_cpu_times'] = cur_cpu_times cpu_percent = 0 for num, name in enumerate(cpu_time_names): stats[k]['cpu_samples'][name].append(cpu_times[num]) cpu_percent += cpu_times[num] stats[k]['cpu_samples']['total'].append(cpu_percent) time.sleep(SLEEP_INTERVAL) i += 1 if i % interval_int == 0: l = [] for k, stat in stats.items(): if len(stat['cpu_samples']) <= 0: continue for name, samples in stat['cpu_samples'].items(): samples = np.array(samples) avg = samples.mean() c = samples.size min_cpu = np.amin(samples) max_cpu = np.amax(samples) if stat['min'][name] is None or min_cpu < stat['min'][name]: stat['min'][name] = min_cpu if stat['max'][name] is None or max_cpu > stat['max'][name]: stat['max'][name] = max_cpu stat['avg'][name] = (stat['avg'][name] * (i - c) + avg * c) / (i) stat['cpu_samples'][name] = [] msg = 'avg: {1:.2%}, min: {2:.2%}, max: {3:.2%} {0}'.format(os.path.basename(k), stat['avg']['total'], stat['min']['total'], stat['max']['total']) if args.detailed_times: for stat_type in ['avg', 'min', 'max']: msg += '\n {}: {}'.format(stat_type, [name + ':' + str(round(stat[stat_type][name]*100, 2)) for name in cpu_time_names]) l.append((os.path.basename(k), stat['avg']['total'], msg)) l.sort(key=lambda x: -x[1]) for x in l: print(x[2]) print('avg sum: {0:.2%} over {1} samples {2} seconds\n'.format( sum([stat['avg']['total'] for k, stat in stats.items()]), i, i * SLEEP_INTERVAL )) ================================================ FILE: selfdrive/debug/cycle_alerts.py ================================================ #!/usr/bin/env python3 # flake8: noqa # pylint: skip-file # type: ignore import time from cereal import car import cereal.messaging as messaging from selfdrive.car.honda.interface import CarInterface from selfdrive.controls.lib.events import ET, EVENTS, Events from selfdrive.controls.lib.alertmanager import AlertManager EventName = car.CarEvent.EventName def cycle_alerts(duration=2000, is_metric=False): alerts = list(EVENTS.keys()) print(alerts) #alerts = [EventName.preDriverDistracted, EventName.promptDriverDistracted, EventName.driverDistracted] alerts = [EventName.preLaneChangeLeft, EventName.preLaneChangeRight] CP = CarInterface.get_params("HONDA CIVIC 2016") sm = messaging.SubMaster(['deviceState', 'pandaState', 'roadCameraState', 'modelV2', 'liveCalibration', 'driverMonitoringState', 'longitudinalPlan', 'lateralPlan', 'liveLocationKalman']) pm = messaging.PubMaster(['controlsState', 'pandaState', 'deviceState']) events = Events() AM = AlertManager() frame = 0 idx, last_alert_millis = 0, 0 while 1: if frame % duration == 0: idx = (idx + 1) % len(alerts) events.clear() events.add(alerts[idx]) current_alert_types = [ET.PERMANENT, ET.USER_DISABLE, ET.IMMEDIATE_DISABLE, ET.SOFT_DISABLE, ET.PRE_ENABLE, ET.NO_ENTRY, ET.ENABLE, ET.WARNING] a = events.create_alerts(current_alert_types, [CP, sm, is_metric]) AM.add_many(frame, a) AM.process_alerts(frame) dat = messaging.new_message() dat.init('controlsState') dat.controlsState.alertText1 = AM.alert_text_1 dat.controlsState.alertText2 = AM.alert_text_2 dat.controlsState.alertSize = AM.alert_size dat.controlsState.alertStatus = AM.alert_status dat.controlsState.alertBlinkingRate = AM.alert_rate dat.controlsState.alertType = AM.alert_type dat.controlsState.alertSound = AM.audible_alert pm.send('controlsState', dat) dat = messaging.new_message() dat.init('deviceState') dat.deviceState.started = True pm.send('deviceState', dat) dat = messaging.new_message() dat.init('pandaState') dat.pandaState.ignitionLine = True pm.send('pandaState', dat) time.sleep(0.01) if __name__ == '__main__': cycle_alerts() ================================================ FILE: selfdrive/debug/disable_ecu.py ================================================ #!/usr/bin/env python3 import traceback import cereal.messaging as messaging from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery from selfdrive.swaglog import cloudlog EXT_DIAG_REQUEST = b'\x10\x03' EXT_DIAG_RESPONSE = b'\x50\x03' COM_CONT_REQUEST = b'\x28\x83\x03' COM_CONT_RESPONSE = b'' def disable_ecu(ecu_addr, logcan, sendcan, bus, timeout=0.1, retry=5, debug=False): print(f"ecu disable {hex(ecu_addr)} ...") for i in range(retry): try: # enter extended diagnostic session query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug) for addr, dat in query.get_data(timeout).items(): # pylint: disable=unused-variable print("ecu communication control disable tx/rx ...") # communication control disable tx and rx query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [COM_CONT_REQUEST], [COM_CONT_RESPONSE], debug=debug) query.get_data(0) return True print(f"ecu disable retry ({i+1}) ...") except Exception: cloudlog.warning(f"ecu disable exception: {traceback.format_exc()}") return False if __name__ == "__main__": import time sendcan = messaging.pub_sock('sendcan') logcan = messaging.sub_sock('can') time.sleep(1) # honda bosch radar disable disabled = disable_ecu(0x18DAB0F1, logcan, sendcan, 1, debug=False) print(f"disabled: {disabled}") ================================================ FILE: selfdrive/debug/dump.py ================================================ #!/usr/bin/env python3 import os import sys import argparse import json from hexdump import hexdump import codecs codecs.register_error("strict", codecs.backslashreplace_errors) from cereal import log import cereal.messaging as messaging from cereal.services import service_list if __name__ == "__main__": parser = argparse.ArgumentParser(description='Sniff a communcation socket') parser.add_argument('--pipe', action='store_true') parser.add_argument('--raw', action='store_true') parser.add_argument('--json', action='store_true') parser.add_argument('--dump-json', action='store_true') parser.add_argument('--no-print', action='store_true') parser.add_argument('--addr', default='127.0.0.1') parser.add_argument('--values', help='values to monitor (instead of entire event)') parser.add_argument("socket", type=str, nargs='*', help="socket name") args = parser.parse_args() if args.addr != "127.0.0.1": os.environ["ZMQ"] = "1" messaging.context = messaging.Context() poller = messaging.Poller() for m in args.socket if len(args.socket) > 0 else service_list: messaging.sub_sock(m, poller, addr=args.addr) values = None if args.values: values = [s.strip().split(".") for s in args.values.split(",")] while 1: polld = poller.poll(100) for sock in polld: msg = sock.receive() evt = log.Event.from_bytes(msg) if not args.no_print: if args.pipe: sys.stdout.write(msg) sys.stdout.flush() elif args.raw: hexdump(msg) elif args.json: print(json.loads(msg)) elif args.dump_json: print(json.dumps(evt.to_dict())) elif values: print("logMonotime = {}".format(evt.logMonoTime)) for value in values: if hasattr(evt, value[0]): item = evt for key in value: item = getattr(item, key) print("{} = {}".format(".".join(value), item)) print("") else: try: print(evt) except UnicodeDecodeError: w = evt.which() s = f"( logMonoTime {evt.logMonoTime} \n {w} = " s += str(evt.__getattr__(w)) s += f"\n valid = {evt.valid} )" print(s) ================================================ FILE: selfdrive/debug/filter_log_message.py ================================================ #!/usr/bin/env python3 import argparse import json import cereal.messaging as messaging from tools.lib.logreader import LogReader from tools.lib.route import Route LEVELS = { "DEBUG": 10, "INFO": 20, "WARNING": 30, "ERROR": 40, "CRITICAL": 50, } ANDROID_LOG_SOURCE = { 0: "MAIN", 1: "RADIO", 2: "EVENTS", 3: "SYSTEM", 4: "CRASH", 5: "KERNEL", } def print_logmessage(t, msg, min_level): try: log = json.loads(msg) if log['levelnum'] >= min_level: print(f"[{t / 1e9:.6f}] {log['filename']}:{log.get('lineno', '')} - {log.get('funcname', '')}: {log['msg']}") if 'exc_info' in log: print(log['exc_info']) except json.decoder.JSONDecodeError: print(f"[{t / 1e9:.6f}] decode error: {msg}") def print_androidlog(t, msg): source = ANDROID_LOG_SOURCE[msg.id] try: m = json.loads(msg.message)['MESSAGE'] except Exception: m = msg.message print(f"[{t / 1e9:.6f}] {source} {msg.pid} {msg.tag} - {m}") if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--level', default='DEBUG') parser.add_argument('--addr', default='127.0.0.1') parser.add_argument("route", type=str, nargs='*', help="route name + segment number for offline usage") args = parser.parse_args() logs = None if len(args.route): r = Route(args.route[0]) logs = [q if r is None else r for (q, r) in zip(r.qlog_paths(), r.log_paths())] if len(args.route) == 2 and logs: n = int(args.route[1]) logs = [logs[n]] min_level = LEVELS[args.level] if logs: for log in logs: if log: lr = LogReader(log) for m in lr: if m.which() == 'logMessage': print_logmessage(m.logMonoTime, m.logMessage, min_level) elif m.which() == 'androidLog': print_androidlog(m.logMonoTime, m.androidLog) else: sm = messaging.SubMaster(['logMessage', 'androidLog'], addr=args.addr) while True: sm.update() if sm.updated['logMessage']: print_logmessage(sm.logMonoTime['logMessage'], sm['logMessage'], min_level) if sm.updated['androidLog']: print_androidlog(sm.logMonoTime['androidLog'], sm['androidLog']) ================================================ FILE: selfdrive/debug/fingerprint_from_route.py ================================================ #!/usr/bin/env python3 import sys from tools.lib.route import Route from tools.lib.logreader import MultiLogIterator def get_fingerprint(lr): # TODO: make this a nice tool for car ports. should also work with qlogs for FW fw = None msgs = {} for msg in lr: if msg.which() == 'carParams': fw = msg.carParams.carFw elif msg.which() == 'can': for c in msg.can: # read also msgs sent by EON on CAN bus 0x80 and filter out the # addr with more than 11 bits if c.src % 0x80 == 0 and c.address < 0x800: msgs[c.address] = len(c.dat) # show CAN fingerprint fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items())) print(f"\nfound {len(msgs)} messages. CAN fingerprint:\n") print(fingerprint) # TODO: also print the fw fingerprint merged with the existing ones # show FW fingerprint print("\nFW fingerprint:\n") for f in fw: print(f" (Ecu.{f.ecu}, {hex(f.address)}, {None if f.subAddress == 0 else f.subAddress}): [") print(f" {f.fwVersion},") print(" ],") print() if __name__ == "__main__": if len(sys.argv) < 2: print("Usage: ./fingerprint_from_route.py ") sys.exit(1) route = Route(sys.argv[1]) lr = MultiLogIterator(route.log_paths()[:5], wraparound=False) get_fingerprint(lr) ================================================ FILE: selfdrive/debug/get_fingerprint.py ================================================ #!/usr/bin/env python3 # simple script to get a vehicle fingerprint. # Instructions: # - connect to a Panda # - run selfdrive/boardd/boardd # - launching this script # Note: it's very important that the car is in stock mode, in order to collect a complete fingerprint # - since some messages are published at low frequency, keep this script running for at least 30s, # until all messages are received at least once import cereal.messaging as messaging logcan = messaging.sub_sock('can') msgs = {} while True: lc = messaging.recv_sock(logcan, True) if lc is None: continue for c in lc.can: # read also msgs sent by EON on CAN bus 0x80 and filter out the # addr with more than 11 bits if c.src in [0, 2] and c.address < 0x800: msgs[c.address] = len(c.dat) fingerprint = ', '.join("%d: %d" % v for v in sorted(msgs.items())) print("number of messages {0}:".format(len(msgs))) print("fingerprint {0}".format(fingerprint)) ================================================ FILE: selfdrive/debug/live_cpu_and_temp.py ================================================ #!/usr/bin/env python3 import argparse from cereal.messaging import SubMaster from common.numpy_fast import mean def cputime_total(ct): return ct.user + ct.nice + ct.system + ct.idle + ct.iowait + ct.irq + ct.softirq def cputime_busy(ct): return ct.user + ct.nice + ct.system + ct.irq + ct.softirq def proc_cputime_total(ct): return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem def proc_name(proc): name = proc.name if len(proc.cmdline): name = proc.cmdline[0] if len(proc.exe): name = proc.exe + " - " + name return name if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--mem', action='store_true') parser.add_argument('--cpu', action='store_true') args = parser.parse_args() sm = SubMaster(['deviceState', 'procLog']) last_temp = 0.0 last_mem = 0.0 total_times = [0., 0., 0., 0.] busy_times = [0., 0., 0.0, 0.] prev_proclog = None prev_proclog_t = None while True: sm.update() if sm.updated['deviceState']: t = sm['deviceState'] last_temp = mean(t.cpuTempC) last_mem = t.memoryUsagePercent if sm.updated['procLog']: m = sm['procLog'] cores = [0., 0., 0., 0.] total_times_new = [0., 0., 0., 0.] busy_times_new = [0., 0., 0.0, 0.] for c in m.cpuTimes: n = c.cpuNum total_times_new[n] = cputime_total(c) busy_times_new[n] = cputime_busy(c) for n in range(4): t_busy = busy_times_new[n] - busy_times[n] t_total = total_times_new[n] - total_times[n] cores[n] = t_busy / t_total total_times = total_times_new[:] busy_times = busy_times_new[:] print("CPU %.2f%% - RAM: %.2f - Temp %.2f" % (100. * mean(cores), last_mem, last_temp)) if args.cpu and prev_proclog is not None: procs = {} dt = (sm.logMonoTime['procLog'] - prev_proclog_t) / 1e9 for proc in m.procs: try: name = proc_name(proc) prev_proc = [p for p in prev_proclog.procs if proc.pid == p.pid][0] cpu_time = proc_cputime_total(proc) - proc_cputime_total(prev_proc) cpu_usage = cpu_time / dt * 100. procs[name] = cpu_usage except IndexError: pass print("Top CPU usage:") for k, v in sorted(procs.items(), key=lambda item: item[1], reverse=True)[:10]: print(f"{k.rjust(70)} {v:.2f} %") print() if args.mem: mems = {} for proc in m.procs: name = proc_name(proc) mems[name] = float(proc.memRss) / 1e6 print("Top memory usage:") for k, v in sorted(mems.items(), key=lambda item: item[1], reverse=True)[:10]: print(f"{k.rjust(70)} {v:.2f} MB") print() prev_proclog = m prev_proclog_t = sm.logMonoTime['procLog'] ================================================ FILE: selfdrive/debug/run_process_on_route.py ================================================ #!/usr/bin/env python3 import argparse from selfdrive.test.process_replay.compare_logs import save_log from selfdrive.test.process_replay.process_replay import CONFIGS, replay_process from tools.lib.logreader import MultiLogIterator from tools.lib.route import Route if __name__ == "__main__": parser = argparse.ArgumentParser(description="Run process on route and create new logs", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("route", help="The route name to use") parser.add_argument("process", help="The process to run") args = parser.parse_args() cfg = [c for c in CONFIGS if c.proc_name == args.process][0] route = Route(args.route) lr = MultiLogIterator(route.log_paths(), wraparound=False) inputs = list(lr) outputs = replay_process(cfg, inputs) # Remove message generated by the process under test and merge in the new messages produces = set(o.which() for o in outputs) inputs = [i for i in inputs if i.which() not in produces] outputs = sorted(inputs + outputs, key=lambda x: x.logMonoTime) fn = f"{args.route}_{args.process}.bz2" save_log(fn, outputs) ================================================ FILE: selfdrive/debug/set_car_params.py ================================================ #!/usr/bin/env python3 import sys from common.params import Params from tools.lib.route import Route from tools.lib.logreader import LogReader if __name__ == "__main__": r = Route(sys.argv[1]) cp = [m for m in LogReader(r.qlog_paths()[0]) if m.which() == 'carParams'] Params().put("CarParams", cp[0].carParams.as_builder().to_bytes()) ================================================ FILE: selfdrive/debug/show_matching_cars.py ================================================ #!/usr/bin/env python3 from selfdrive.car.fingerprints import eliminate_incompatible_cars, all_legacy_fingerprint_cars import cereal.messaging as messaging # rav4 2019 and corolla tss2 fingerprint = {896: 8, 898: 8, 900: 6, 976: 1, 1541: 8, 902: 6, 905: 8, 810: 2, 1164: 8, 1165: 8, 1166: 8, 1167: 8, 1552: 8, 1553: 8, 1556: 8, 1571: 8, 921: 8, 1056: 8, 544: 4, 1570: 8, 1059: 1, 36: 8, 37: 8, 550: 8, 935: 8, 552: 4, 170: 8, 812: 8, 944: 8, 945: 8, 562: 6, 180: 8, 1077: 8, 951: 8, 1592: 8, 1076: 8, 186: 4, 955: 8, 956: 8, 1001: 8, 705: 8, 452: 8, 1788: 8, 464: 8, 824: 8, 466: 8, 467: 8, 761: 8, 728: 8, 1572: 8, 1114: 8, 933: 8, 800: 8, 608: 8, 865: 8, 610: 8, 1595: 8, 934: 8, 998: 5, 1745: 8, 1000: 8, 764: 8, 1002: 8, 999: 7, 1789: 8, 1649: 8, 1779: 8, 1568: 8, 1017: 8, 1786: 8, 1787: 8, 1020: 8, 426: 6, 1279: 8} candidate_cars = all_legacy_fingerprint_cars() for addr, l in fingerprint.items(): dat = messaging.new_message('can', 1) msg = dat.can[0] msg.address = addr msg.dat = " " * l candidate_cars = eliminate_incompatible_cars(msg, candidate_cars) print(candidate_cars) ================================================ FILE: selfdrive/debug/test_fw_query_on_routes.py ================================================ #!/usr/bin/env python3 # type: ignore from collections import defaultdict import argparse import os import traceback from tqdm import tqdm from tools.lib.logreader import LogReader from tools.lib.route import Route from selfdrive.car.car_helpers import interface_names from selfdrive.car.fw_versions import match_fw_to_car_exact, match_fw_to_car_fuzzy, build_fw_dict from selfdrive.car.toyota.values import FW_VERSIONS as TOYOTA_FW_VERSIONS from selfdrive.car.honda.values import FW_VERSIONS as HONDA_FW_VERSIONS from selfdrive.car.hyundai.values import FW_VERSIONS as HYUNDAI_FW_VERSIONS from selfdrive.car.volkswagen.values import FW_VERSIONS as VW_FW_VERSIONS from selfdrive.car.mazda.values import FW_VERSIONS as MAZDA_FW_VERSIONS NO_API = "NO_API" in os.environ SUPPORTED_CARS = set(interface_names['toyota']) SUPPORTED_CARS |= set(interface_names['honda']) SUPPORTED_CARS |= set(interface_names['hyundai']) SUPPORTED_CARS |= set(interface_names['volkswagen']) SUPPORTED_CARS |= set(interface_names['mazda']) try: from xx.pipeline.c.CarState import migration except ImportError: migration = {} if __name__ == "__main__": parser = argparse.ArgumentParser(description='Run FW fingerprint on Qlog of route or list of routes') parser.add_argument('route', help='Route or file with list of routes') parser.add_argument('--car', help='Force comparison fingerprint to known car') args = parser.parse_args() if os.path.exists(args.route): routes = list(open(args.route)) else: routes = [args.route] mismatches = defaultdict(list) not_fingerprinted = 0 solved_by_fuzzy = 0 good_exact = 0 wrong_fuzzy = 0 good_fuzzy = 0 dongles = [] for route in tqdm(routes): route = route.rstrip() dongle_id, time = route.split('|') if dongle_id in dongles: continue if NO_API: qlog_path = f"cd:/{dongle_id}/{time}/0/qlog.bz2" else: route = Route(route) qlog_path = route.qlog_paths()[0] if qlog_path is None: continue try: lr = LogReader(qlog_path) dongles.append(dongle_id) for msg in lr: if msg.which() == "pandaState": if msg.pandaState.pandaType not in ['uno', 'blackPanda', 'dos']: break elif msg.which() == "carParams": bts = msg.carParams.as_builder().to_bytes() car_fw = msg.carParams.carFw if len(car_fw) == 0: break live_fingerprint = msg.carParams.carFingerprint live_fingerprint = migration.get(live_fingerprint, live_fingerprint) if args.car is not None: live_fingerprint = args.car if live_fingerprint not in SUPPORTED_CARS: break fw_versions_dict = build_fw_dict(car_fw) exact_matches = match_fw_to_car_exact(fw_versions_dict) fuzzy_matches = match_fw_to_car_fuzzy(fw_versions_dict) if (len(exact_matches) == 1) and (list(exact_matches)[0] == live_fingerprint): good_exact += 1 print(f"Correct! Live: {live_fingerprint} - Fuzzy: {fuzzy_matches}") # Check if fuzzy match was correct if len(fuzzy_matches) == 1: if list(fuzzy_matches)[0] != live_fingerprint: wrong_fuzzy += 1 print(f"{dongle_id}|{time}") print("Fuzzy match wrong! Fuzzy:", fuzzy_matches, "Live:", live_fingerprint) else: good_fuzzy += 1 break print(f"{dongle_id}|{time}") print("Old style:", live_fingerprint, "Vin", msg.carParams.carVin) print("New style (exact):", exact_matches) print("New style (fuzzy):", fuzzy_matches) for version in car_fw: subaddr = None if version.subAddress == 0 else hex(version.subAddress) print(f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}],") print("Mismatches") found = False for car_fws in [TOYOTA_FW_VERSIONS, HONDA_FW_VERSIONS, HYUNDAI_FW_VERSIONS, VW_FW_VERSIONS, MAZDA_FW_VERSIONS]: if live_fingerprint in car_fws: found = True expected = car_fws[live_fingerprint] for (_, expected_addr, expected_sub_addr), v in expected.items(): for version in car_fw: sub_addr = None if version.subAddress == 0 else version.subAddress addr = version.address if (addr, sub_addr) == (expected_addr, expected_sub_addr): if version.fwVersion not in v: print(f"({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}) - {version.fwVersion}") # Add to global list of mismatches mismatch = (addr, sub_addr, version.fwVersion) if mismatch not in mismatches[live_fingerprint]: mismatches[live_fingerprint].append(mismatch) # No FW versions for this car yet, add them all to mismatch list if not found: for version in car_fw: sub_addr = None if version.subAddress == 0 else version.subAddress addr = version.address mismatch = (addr, sub_addr, version.fwVersion) if mismatch not in mismatches[live_fingerprint]: mismatches[live_fingerprint].append(mismatch) print() not_fingerprinted += 1 if len(fuzzy_matches) == 1: if list(fuzzy_matches)[0] == live_fingerprint: solved_by_fuzzy += 1 else: wrong_fuzzy += 1 print("Fuzzy match wrong! Fuzzy:", fuzzy_matches, "Live:", live_fingerprint) break except Exception: traceback.print_exc() except KeyboardInterrupt: break print() # Print FW versions that need to be added seperated out by car and address for car, m in sorted(mismatches.items()): print(car) addrs = defaultdict(list) for (addr, sub_addr, version) in m: addrs[(addr, sub_addr)].append(version) for (addr, sub_addr), versions in addrs.items(): print(f" ({hex(addr)}, {'None' if sub_addr is None else hex(sub_addr)}): [") for v in versions: print(f" {v},") print(" ]") print() print() print(f"Number of dongle ids checked: {len(dongles)}") print(f"Fingerprinted: {good_exact}") print(f"Not fingerprinted: {not_fingerprinted}") print(f" of which had a fuzzy match: {solved_by_fuzzy}") print() print(f"Correct fuzzy matches: {good_fuzzy}") print(f"Wrong fuzzy matches: {wrong_fuzzy}") print() ================================================ FILE: selfdrive/debug/toyota_eps_factor.py ================================================ #!/usr/bin/env python3 import sys import numpy as np import matplotlib.pyplot as plt from sklearn import linear_model # pylint: disable=import-error from selfdrive.car.toyota.values import STEER_THRESHOLD from tools.lib.route import Route from tools.lib.logreader import MultiLogIterator MIN_SAMPLES = 30 * 100 def to_signed(n, bits): if n >= (1 << max((bits - 1), 0)): n = n - (1 << max(bits, 0)) return n def get_eps_factor(lr, plot=False): engaged = False steering_pressed = False torque_cmd, eps_torque = None, None cmds, eps = [], [] for msg in lr: if msg.which() != 'can': continue for m in msg.can: if m.address == 0x2e4 and m.src == 128: engaged = bool(m.dat[0] & 1) torque_cmd = to_signed((m.dat[1] << 8) | m.dat[2], 16) elif m.address == 0x260 and m.src == 0: eps_torque = to_signed((m.dat[5] << 8) | m.dat[6], 16) steering_pressed = abs(to_signed((m.dat[1] << 8) | m.dat[2], 16)) > STEER_THRESHOLD if engaged and torque_cmd is not None and eps_torque is not None and not steering_pressed: cmds.append(torque_cmd) eps.append(eps_torque) else: if len(cmds) > MIN_SAMPLES: break cmds, eps = [], [] if len(cmds) < MIN_SAMPLES: raise Exception("too few samples found in route") lm = linear_model.LinearRegression(fit_intercept=False) lm.fit(np.array(cmds).reshape(-1, 1), eps) scale_factor = 1. / lm.coef_[0] if plot: plt.plot(np.array(eps) * scale_factor) plt.plot(cmds) plt.show() return scale_factor if __name__ == "__main__": r = Route(sys.argv[1]) lr = MultiLogIterator(r.log_paths(), wraparound=False) n = get_eps_factor(lr, plot="--plot" in sys.argv) print("EPS torque factor: ", n) ================================================ FILE: selfdrive/debug/uiview.py ================================================ #!/usr/bin/env python3 import time import cereal.messaging as messaging from selfdrive.manager.process_config import managed_processes if __name__ == "__main__": services = ['controlsState', 'deviceState', 'pandaState'] # the services needed to be spoofed to start ui offroad procs = ['camerad', 'ui', 'modeld', 'calibrationd'] for p in procs: managed_processes[p].start() pm = messaging.PubMaster(services) msgs = {s: messaging.new_message(s) for s in services} msgs['deviceState'].deviceState.started = True msgs['pandaState'].pandaState.ignitionLine = True try: while True: time.sleep(1 / 100) # continually send, rate doesn't matter for s in msgs: pm.send(s, msgs[s]) except KeyboardInterrupt: for p in procs: managed_processes[p].stop() ================================================ FILE: selfdrive/dragonpilot/HOWTO-APPD.md ================================================ What is appd ------ Appd is a service that runs specific android apps when on road, and then close the when offroad. How to use appd ------ 1. Create a folder: /data/media/0/appd/ 2. Place apks in /data/media/0/appd/ 3. Copy /data/openpilot/dragonpilot/appd_example.json over to /data/media/0/appd/ and rename to appd.json 4. Update appd.json as per example. ================================================ FILE: selfdrive/dragonpilot/LICENSE.md ================================================ The MIT License Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: selfdrive/dragonpilot/appd.py ================================================ #!/usr/bin/env python3.8 # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import subprocess import os import json FILE = '/data/media/0/appd/appd.json' class Appd(): def __init__(self): self.started = False if os.path.exists(FILE): with open(FILE) as f: self.app_data = json.load(f) else: self.app_data = None def update(self, started): if self.app_data is not None: if started: if not self.started: self.started = True self.onroad() else: if self.started: self.started = False self.offroad() def onroad(self): for app in self.app_data: if app['app'] == 'lan.rick.pandagpsservice' and self.installed(app['app']): self.system('pm uninstall lan.rick.pandagpsservice') pass if not self.installed(app['app']) and os.path.exists(app['apk']): self.system("pm install -r %s" % app['apk']) for cmd in app['onroad_cmd']: self.system(cmd) def offroad(self): for app in self.app_data: if self.installed(app['app']): for cmd in app['offroad_cmd']: self.system(cmd) def installed(self, app_name): try: result = subprocess.check_output(["dumpsys", "package", app_name, "|", "grep", "versionName"], encoding='utf8') if len(result) > 12: return True except: pass return False def system(self, cmd): try: subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) except: pass ================================================ FILE: selfdrive/dragonpilot/appd_example.json ================================================ [ { "app": "com.tomtom.speedcams.android.map", "apk": "/data/media/0/appd/com.tomtom.speedcams.android.map.apk", "offroad_cmd": [ "pm disable com.tomtom.speedcams.android.map" ], "onroad_cmd": [ "pm enable com.tomtom.speedcams.android.map", "LD_LIBRARY_PATH= appops set com.tomtom.speedcams.android.map android.permission.ACCESS_FINE_LOCATION allow", "LD_LIBRARY_PATH= appops set com.tomtom.speedcams.android.map android.permission.ACCESS_COARSE_LOCATION allow", "LD_LIBRARY_PATH= appops set com.tomtom.speedcams.android.map android.permission.READ_EXTERNAL_STORAGE allow", "LD_LIBRARY_PATH= appops set com.tomtom.speedcams.android.map android.permission.WRITE_EXTERNAL_STORAGE allow", "am start -n com.tomtom.speedcams.android.map/com.tomtom.speedcams.android.activities.SpeedCamActivity" ] } ] ================================================ FILE: selfdrive/dragonpilot/dashcamd.py ================================================ #!/usr/bin/env python3.7 # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import os import datetime from common.realtime import sec_since_boot DASHCAM_VIDEOS_PATH = '/data/media/0/dashcam/' DASHCAM_DURATION = 180 # max is 180 DASHCAM_BIT_RATES = 4000000 # max is 4000000 DASHCAM_MAX_SIZE_PER_FILE = DASHCAM_BIT_RATES/8*DASHCAM_DURATION # 4Mbps / 8 * 180 = 90MB per 180 seconds DASHCAM_FREESPACE_LIMIT = 0.15 # we start cleaning up footage when freespace is below 15% DASHCAM_KEPT = DASHCAM_MAX_SIZE_PER_FILE * 240 # 12 hrs of video = 21GB class Dashcamd(): def __init__(self): self.dashcam_folder_exists = False self.dashcam_mkdir_retry = 0 self.dashcam_next_time = 0 self.started = False self.free_space = 1. def run(self, started, free_space): self.free_space = free_space if self.started and not started: self.stop() self.started = started self.make_folder() if self.dashcam_folder_exists: self.start() self.clean_up() def stop(self): os.system("killall -SIGINT screenrecord") self.dashcam_next_time = 0 def make_folder(self): if not self.dashcam_folder_exists and self.dashcam_mkdir_retry <= 5: # create dashcam folder if not exist try: if not os.path.exists(DASHCAM_VIDEOS_PATH): os.makedirs(DASHCAM_VIDEOS_PATH) else: self.dashcam_folder_exists = True except OSError: self.dashcam_folder_exists = False self.dashcam_mkdir_retry += 1 def start(self): # start recording if self.started: ts = sec_since_boot() if ts >= self.dashcam_next_time: now = datetime.datetime.now() file_name = now.strftime("%Y-%m-%d_%H-%M-%S") os.system("LD_LIBRARY_PATH= screenrecord --bit-rate %s --time-limit %s %s%s.mp4 &" % (DASHCAM_BIT_RATES, DASHCAM_DURATION, DASHCAM_VIDEOS_PATH, file_name)) self.dashcam_next_time = ts + DASHCAM_DURATION - 1 else: self.dashcam_next_time = 0 def clean_up(self): # clean up if (self.free_space < DASHCAM_FREESPACE_LIMIT) or (self.get_used_spaces() > DASHCAM_KEPT): try: files = [f for f in sorted(os.listdir(DASHCAM_VIDEOS_PATH)) if os.path.isfile(DASHCAM_VIDEOS_PATH + f)] os.system("rm -fr %s &" % (DASHCAM_VIDEOS_PATH + files[0])) except (IndexError, FileNotFoundError, OSError): pass def get_used_spaces(self): try: val = sum(os.path.getsize(DASHCAM_VIDEOS_PATH + f) for f in os.listdir(DASHCAM_VIDEOS_PATH) if os.path.isfile(DASHCAM_VIDEOS_PATH + f)) except (IndexError, FileNotFoundError, OSError): val = 0 return val ================================================ FILE: selfdrive/dragonpilot/fonts.xml ================================================ Roboto-Thin.ttf Roboto-ThinItalic.ttf Roboto-Light.ttf Roboto-LightItalic.ttf Roboto-Regular.ttf Roboto-Italic.ttf Roboto-Medium.ttf Roboto-MediumItalic.ttf Roboto-Black.ttf Roboto-BlackItalic.ttf Roboto-Bold.ttf Roboto-BoldItalic.ttf RobotoCondensed-Light.ttf RobotoCondensed-LightItalic.ttf RobotoCondensed-Regular.ttf RobotoCondensed-Italic.ttf RobotoCondensed-Bold.ttf RobotoCondensed-BoldItalic.ttf NotoSerif-Regular.ttf NotoSerif-Bold.ttf NotoSerif-Italic.ttf NotoSerif-BoldItalic.ttf DroidSansMono.ttf CutiveMono.ttf ComingSoon.ttf DancingScript-Regular.ttf DancingScript-Bold.ttf CarroisGothicSC-Regular.ttf NotoNaskhArabic-Regular.ttf NotoNaskhArabic-Bold.ttf NotoNaskhArabicUI-Regular.ttf NotoNaskhArabicUI-Bold.ttf NotoSansEthiopic-Regular.ttf NotoSansEthiopic-Bold.ttf NotoSansHebrew-Regular.ttf NotoSansHebrew-Bold.ttf NotoSansThai-Regular.ttf NotoSansThai-Bold.ttf NotoSansThaiUI-Regular.ttf NotoSansThaiUI-Bold.ttf NotoSansArmenian-Regular.ttf NotoSansArmenian-Bold.ttf NotoSansGeorgian-Regular.ttf NotoSansGeorgian-Bold.ttf NotoSansDevanagari-Regular.ttf NotoSansDevanagari-Bold.ttf NotoSansDevanagariUI-Regular.ttf NotoSansDevanagariUI-Bold.ttf NotoSansGujarati-Regular.ttf NotoSansGujarati-Bold.ttf NotoSansGujaratiUI-Regular.ttf NotoSansGujaratiUI-Bold.ttf NotoSansGurmukhi-Regular.ttf NotoSansGurmukhi-Bold.ttf NotoSansGurmukhiUI-Regular.ttf NotoSansGurmukhiUI-Bold.ttf NotoSansTamil-Regular.ttf NotoSansTamil-Bold.ttf NotoSansTamilUI-Regular.ttf NotoSansTamilUI-Bold.ttf NotoSansMalayalam-Regular.ttf NotoSansMalayalam-Bold.ttf NotoSansMalayalamUI-Regular.ttf NotoSansMalayalamUI-Bold.ttf NotoSansBengali-Regular.ttf NotoSansBengali-Bold.ttf NotoSansBengaliUI-Regular.ttf NotoSansBengaliUI-Bold.ttf NotoSansTelugu-Regular.ttf NotoSansTelugu-Bold.ttf NotoSansTeluguUI-Regular.ttf NotoSansTeluguUI-Bold.ttf NotoSansKannada-Regular.ttf NotoSansKannada-Bold.ttf NotoSansKannadaUI-Regular.ttf NotoSansKannadaUI-Bold.ttf NotoSansOriya-Regular.ttf NotoSansOriya-Bold.ttf NotoSansOriyaUI-Regular.ttf NotoSansOriyaUI-Bold.ttf NotoSansSinhala-Regular.ttf NotoSansSinhala-Bold.ttf NotoSansKhmer-Regular.ttf NotoSansKhmer-Bold.ttf NotoSansKhmerUI-Regular.ttf NotoSansKhmerUI-Bold.ttf NotoSansLao-Regular.ttf NotoSansLao-Bold.ttf NotoSansLaoUI-Regular.ttf NotoSansLaoUI-Bold.ttf NotoSansMyanmar-Regular.ttf NotoSansMyanmar-Bold.ttf NotoSansMyanmarUI-Regular.ttf NotoSansMyanmarUI-Bold.ttf NotoSansThaana-Regular.ttf NotoSansThaana-Bold.ttf NotoSansCham-Regular.ttf NotoSansCham-Bold.ttf NotoSansBalinese-Regular.ttf NotoSansBamum-Regular.ttf NotoSansBatak-Regular.ttf NotoSansBuginese-Regular.ttf NotoSansBuhid-Regular.ttf NotoSansCanadianAboriginal-Regular.ttf NotoSansCherokee-Regular.ttf NotoSansCoptic-Regular.ttf NotoSansGlagolitic-Regular.ttf NotoSansHanunoo-Regular.ttf NotoSansJavanese-Regular.ttf NotoSansKayahLi-Regular.ttf NotoSansLepcha-Regular.ttf NotoSansLimbu-Regular.ttf NotoSansLisu-Regular.ttf NotoSansMandaic-Regular.ttf NotoSansMeeteiMayek-Regular.ttf NotoSansNewTaiLue-Regular.ttf NotoSansNKo-Regular.ttf NotoSansOlChiki-Regular.ttf NotoSansRejang-Regular.ttf NotoSansSaurashtra-Regular.ttf NotoSansSundanese-Regular.ttf NotoSansSylotiNagri-Regular.ttf NotoSansSyriacEstrangela-Regular.ttf NotoSansTagbanwa-Regular.ttf NotoSansTaiTham-Regular.ttf NotoSansTaiViet-Regular.ttf NotoSansTibetan-Regular.ttf NotoSansTifinagh-Regular.ttf NotoSansVai-Regular.ttf NotoSansYi-Regular.ttf NotoSansSymbols-Regular-Subsetted.ttf NotoSansJP-Regular.otf NotoSansKR-Regular.otf NanumGothic.ttf NotoColorEmoji.ttf NotoSansSC-Light.otf NotoSansSC-Regular.otf NotoSansSC-Bold.otf NotoSansTC-Light.otf NotoSansTC-Regular.otf NotoSansTC-Bold.otf NotoSansJP-Light.otf NotoSansJP-Regular.otf NotoSansJP-Bold.otf NotoSansKR-Light.otf NotoSansKR-Regular.otf NotoSansKR-Bold.otf NotoSansTaiLe-Regular.ttf NotoSansMongolian-Regular.ttf ================================================ FILE: selfdrive/dragonpilot/gpx_uploader.py ================================================ #!/usr/bin/env python3 # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import os import time from common.params import Params # for uploader from selfdrive.loggerd.xattr_cache import getxattr, setxattr import glob import requests # customisable values GPX_LOG_PATH = '/data/media/0/gpx_logs/' LOG_HERTZ = 1/10 # 0.1 Hz = 10 sec, higher for higher accuracy, 10hz seems fine # uploader UPLOAD_ATTR_NAME = 'user.upload' UPLOAD_ATTR_VALUE = b'1' LOG_PATH = '/data/media/0/gpx_logs/' # osm api API_HEADER = {'Authorization': 'Bearer 2pvUyXfk9vizuh7PwQFSEYBtFWcM-Pu7vxApUjSA0fc'} VERSION_URL = 'https://api.openstreetmap.org/api/versions' UPLOAD_URL = 'https://api.openstreetmap.org/api/0.6/gpx/create' _DEBUG = False def _debug(msg): if not _DEBUG: return print(msg, flush=True) class GpxUploader(): def __init__(self): self._delete_after_upload = not Params().get_bool('dp_gpxd') self._car_model = Params().get("dp_last_candidate", encoding='utf8') _debug("GpxUploader init - _delete_after_upload = %s" % self._delete_after_upload) _debug("GpxUploader init - _car_model = %s" % self._car_model) def _is_online(self): try: r = requests.get(VERSION_URL, headers=API_HEADER) _debug("is_online? status_code = %s" % r.status_code) return r.status_code >= 200 except: return False def _get_is_uploaded(self, filename): _debug("%s is uploaded: %s" % (filename, getxattr(filename, UPLOAD_ATTR_NAME) is not None)) return getxattr(filename, UPLOAD_ATTR_NAME) is not None def _set_is_uploaded(self, filename): _debug("%s set to uploaded" % filename) setxattr(filename, UPLOAD_ATTR_NAME, UPLOAD_ATTR_VALUE) def _get_files(self): return sorted( filter( os.path.isfile, glob.glob(LOG_PATH + '*') ) ) def _get_files_to_be_uploaded(self): files = self._get_files() files_to_be_uploaded = [] for file in files: if not self._get_is_uploaded(file): files_to_be_uploaded.append(file) return files_to_be_uploaded def _do_upload(self, filename): fn = os.path.basename(filename) data = { 'description': "Routes from dragonpilot (%s)." % self._car_model, 'visibility': 'identifiable' } files = { "file": (fn, open(filename, 'rb')) } try: r = requests.post(UPLOAD_URL, files=files, data=data, headers=API_HEADER) _debug("do_upload - %s - %s" % (filename, r.status_code)) return r.status_code == 200 except: return False def run(self): while True: files = self._get_files_to_be_uploaded() if len(files) == 0 or not self._is_online(): _debug("run - not online or no files") else: for file in files: if self._do_upload(file): if self._delete_after_upload: _debug("run - _delete_after_upload") os.remove(file) else: _debug("run - set_is_uploaded") self._set_is_uploaded(file) # sleep for 300 secs if offroad # otherwise sleep 60 secs time.sleep(300 if Params().get_bool("IsOffroad") else 60) def gpx_uploader_thread(): gpx_uploader = GpxUploader() gpx_uploader.run() def main(): gpx_uploader_thread() if __name__ == "__main__": main() ================================================ FILE: selfdrive/dragonpilot/gpxd.py ================================================ #!/usr/bin/env python3 # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import cereal.messaging as messaging import os import datetime import signal import threading from common.realtime import Ratekeeper # customisable values GPX_LOG_PATH = '/data/media/0/gpx_logs/' LOG_HERTZ = 10 # 10 hz = 0.1 sec, higher for higher accuracy, 10hz seems fine LOG_LENGTH = 10 # mins, higher means it keeps more data in the memory, will take more time to write into a file too. LOST_SIGNAL_COUNT_LENGTH = 30 # secs, output log file if we lost signal for this long # do not change LOST_SIGNAL_COUNT_MAX = LOST_SIGNAL_COUNT_LENGTH * LOG_HERTZ # secs, LOGS_PER_FILE = LOG_LENGTH * 60 * LOG_HERTZ # e.g. 10 * 60 * 10 = 6000 points per file class WaitTimeHelper: ready_event = threading.Event() shutdown = False def __init__(self): signal.signal(signal.SIGTERM, self.graceful_shutdown) signal.signal(signal.SIGINT, self.graceful_shutdown) signal.signal(signal.SIGHUP, self.graceful_shutdown) def graceful_shutdown(self, signum, frame): self.shutdown = True self.ready_event.set() class GpxD(): def __init__(self): self.log_count = 0 self.logs = list() self.lost_signal_count = 0 self.wait_helper = WaitTimeHelper() self.started_time = datetime.datetime.utcnow().isoformat() self.v_ego_prev = 0. self.pause = False def log(self, sm): gps = sm['gpsLocationExternal'] v_ego = sm['carState'].vEgo if abs(v_ego) > 0.: self.pause = False # do not log when no fix or accuracy is too low, add lost_signal_count if gps.flags % 2 == 0 or gps.accuracy > 5.: if self.log_count > 0: self.lost_signal_count += 1 elif self.pause: pass else: self.logs.append([datetime.datetime.utcfromtimestamp(gps.timestamp*0.001).isoformat(), str(gps.latitude), str(gps.longitude), str(gps.altitude)]) self.log_count += 1 self.lost_signal_count = 0 if v_ego == 0. and abs(self.v_ego_prev) > 0.: self.pause = True self.v_ego_prev = v_ego def write_log(self, force = False): if self.log_count == 0: return if force or (self.log_count >= LOGS_PER_FILE or self.lost_signal_count >= LOST_SIGNAL_COUNT_MAX): self._write_gpx() self.lost_signal_count = 0 self.log_count = 0 self.logs.clear() self.started_time = datetime.datetime.utcnow().isoformat() def _write_gpx(self): if len(self.logs) > 1: if not os.path.exists(GPX_LOG_PATH): os.makedirs(GPX_LOG_PATH) filename = self.started_time.replace(':','-') str = '' str += "\n" str += "\n" str += "\n" str += " " + self.started_time + "" str += " \n" for trkpt in self.logs: str += self._trkpt_template(trkpt[1], trkpt[2], trkpt[3], trkpt[0]) str += " \n" str += "\n" str += "\n" try: f = open('%s%sZ.gpx' % (GPX_LOG_PATH, filename), 'w') f.write(str) f.close() except: pass def _trkpt_template(self, lat, lon, ele, time): str = "" str += " \n" str += " " + ele + "\n" str += " \n" str += " \n" return str def gpxd_thread(sm=None, pm=None): if sm is None: sm = messaging.SubMaster(['gpsLocationExternal', 'carState']) wait_helper = WaitTimeHelper() gpxd = GpxD() rk = Ratekeeper(LOG_HERTZ, print_delay_threshold=None) while True: sm.update(0) gpxd.log(sm) gpxd.write_log() if wait_helper.shutdown: gpxd.write_log(True) break rk.keep_time() def main(sm=None, pm=None): gpxd_thread(sm, pm) if __name__ == "__main__": main() ================================================ FILE: selfdrive/dragonpilot/otisserv.py ================================================ #!/usr/bin/env python3.8 # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from http.server import BaseHTTPRequestHandler, HTTPServer from cgi import parse_header, parse_multipart from urllib.parse import parse_qs, unquote import json import requests from common.basedir import BASEDIR from common.params import Params params = Params() hostName = "" serverPort = 8082 class OtisServ(BaseHTTPRequestHandler): def do_GET(self): use_gmap = params.get_bool('dp_mapbox_gmap_enable') if self.path == '/logo.png': self.get_logo() return if self.path == '/?reset=1': params.put("NavDestination", "") if use_gmap: if self.path == '/style.css': self.send_response(200) self.send_header("Content-type", "text/css") self.end_headers() self.get_gmap_css() return elif self.path == '/index.js': self.send_response(200) self.send_header("Content-type", "text/javascript") self.end_headers() self.get_gmap_js() return else: self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() if self.get_gmap_key() is None: self.display_page_gmap_key() return if self.get_app_token() is None: self.display_page_app_token() return self.display_page_gmap() else: self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() if self.get_public_token() is None: self.display_page_public_token() return if self.get_app_token() is None: self.display_page_app_token() return self.display_page_addr_input() def do_POST(self): use_gmap = params.get_bool('dp_mapbox_gmap_enable') postvars = self.parse_POST() self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() if use_gmap: # gmap token if self.get_gmap_key() is None: if postvars is None or "gmap_key_val" not in postvars or postvars.get("gmap_key_val")[0] == "": self.display_page_gmap_key() return params.put('dp_mapbox_gmap_key', postvars.get("gmap_key_val")[0]) else: # mapbox public key if self.get_public_token() is None: if postvars is None or "pk_token_val" not in postvars or postvars.get("pk_token_val")[0] == "": self.display_page_public_token() return token = postvars.get("pk_token_val")[0] if "pk." not in token: self.display_page_public_token("Your token was incorrect!") return params.put('dp_mapbox_token_pk', token) # app key if self.get_app_token() is None: if postvars is None or "sk_token_val" not in postvars or postvars.get("sk_token_val")[0] == "": self.display_page_app_token() return token = postvars.get("sk_token_val")[0] if "sk." not in token: self.display_page_app_token("Your token was incorrect!") return params.put('dp_mapbox_token_sk', token) # nav confirmed if postvars is not None: if "lat" in postvars and postvars.get("lat")[0] != "" and "lon" in postvars and postvars.get("lon")[0] != "": params.put('NavDestination', "{\"latitude\": %f, \"longitude\": %f}" % (float(postvars.get("lat")[0]), float(postvars.get("lon")[0]))) # search if not use_gmap and "addr_val" in postvars: addr = postvars.get("addr_val")[0] if addr != "": real_addr, lat, lon = self.query_addr(addr) if real_addr is not None: self.display_page_nav_confirmation(real_addr, lon, lat) return else: self.display_page_addr_input("Place Not Found") return if not use_gmap: # display addr input self.display_page_addr_input() else: self.display_page_gmap() def get_logo(self): self.send_response(200) self.send_header('Content-type','image/png') self.end_headers() f = open("%s/selfdrive/assets/img_spinner_comma.png" % BASEDIR, "rb") self.wfile.write(f.read()) f.close() def get_gmap_css(self): self.wfile.write(bytes(self.get_parsed_template("gmap_style.css"), "utf-8")) def get_gmap_js(self): lon, lat = self.get_last_lon_lat() self.wfile.write(bytes(self.get_parsed_template("gmap_index.js", {"{{lat}}": lat, "{{lon}}": lon}), "utf-8")) def display_page_gmap(self): self.wfile.write(bytes(self.get_parsed_template("gmap_index.html", {"{{gmap_key}}": self.get_gmap_key()}), "utf-8")) def get_gmap_key(self): token = params.get("dp_mapbox_gmap_key", encoding='utf8') if token is not None and token != "": return token.rstrip('\x00') return None def get_public_token(self): token = params.get("dp_mapbox_token_pk", encoding='utf8') if token is not None and token != "": return token.rstrip('\x00') return None def get_app_token(self): token = params.get("dp_mapbox_token_sk", encoding='utf8') if token is not None and token != "": return token.rstrip('\x00') return None def get_last_lon_lat(self): last_pos = Params().get("LastGPSPosition") if last_pos is not None and last_pos != "": l = json.loads(last_pos) return l["longitude"], l["latitude"] return "", "" def display_page_gmap_key(self): self.wfile.write(bytes(self.get_parsed_template("body", {"{{content}}": self.get_parsed_template("gmap_key_input")}), "utf-8")) def display_page_public_token(self, msg = ""): self.wfile.write(bytes(self.get_parsed_template("body", {"{{content}}": self.get_parsed_template("public_token_input", {"{{msg}}": msg})}), "utf-8")) def display_page_app_token(self, msg = ""): self.wfile.write(bytes(self.get_parsed_template("body", {"{{content}}": self.get_parsed_template("app_token_input", {"{{msg}}": msg})}), "utf-8")) def display_page_addr_input(self, msg = ""): self.wfile.write(bytes(self.get_parsed_template("body", {"{{content}}": self.get_parsed_template("addr_input", {"{{msg}}": msg})}), "utf-8")) def display_page_nav_confirmation(self, addr, lon, lat): content = self.get_parsed_template("addr_input", {"{{msg}}": ""}) + self.get_parsed_template("nav_confirmation", {"{{token}}": self.get_public_token(), "{{lon}}": lon, "{{lat}}": lat, "{{addr}}": addr}) self.wfile.write(bytes(self.get_parsed_template("body", {"{{content}}": content }), "utf-8")) def get_parsed_template(self, name, replace = {}): f = open('%s/selfdrive/dragonpilot/tpl/%s.tpl' % (BASEDIR, name), mode='r', encoding='utf-8') content = f.read() for key in replace: content = content.replace(key, str(replace[key])) f.close() return content def query_addr(self, addr): if addr == "": return None, None, None query = "https://api.mapbox.com/geocoding/v5/mapbox.places/" + unquote(addr) + ".json?access_token=" + self.get_public_token() + "&limit=1" # focus on place around last gps position last_pos = Params().get("LastGPSPosition") if last_pos is not None and last_pos != "": l = json.loads(last_pos) query += "&proximity=%s,%s" % (l["longitude"], l["latitude"]) r = requests.get(query) if r.status_code != 200: return None, None, None j = json.loads(r.text) if not j["features"]: return None, None, None feature = j["features"][0] return feature["place_name"], feature["center"][1], feature["center"][0] def parse_POST(self): ctype, pdict = parse_header(self.headers['content-type']) if ctype == 'application/x-www-form-urlencoded': length = int(self.headers['content-length']) postvars = parse_qs( self.rfile.read(length).decode('utf-8'), keep_blank_values=1) else: postvars = {} return postvars def main(): webServer = HTTPServer((hostName, serverPort), OtisServ) try: webServer.serve_forever() except KeyboardInterrupt: pass webServer.server_close() if __name__ == "__main__": main() ================================================ FILE: selfdrive/dragonpilot/systemd.py ================================================ #!/usr/bin/env python3 # The MIT License # # Copyright (c) 2019-, Rick Lan, dragonpilot community, and a number of other of contributors. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. ''' This is a service that broadcast dp config values to openpilot's messaging queues ''' import cereal.messaging as messaging from common.dp_conf import confs, get_struct_name, to_struct_val from common.params import Params, put_nonblocking import os from selfdrive.hardware import HARDWARE params = Params() from common.dp_common import param_get, get_last_modified from common.dp_time import LAST_MODIFIED_SYSTEMD from selfdrive.dragonpilot.dashcamd import Dashcamd from selfdrive.dragonpilot.appd import Appd from selfdrive.hardware import EON import socket from common.realtime import Ratekeeper import threading from selfdrive.dragonpilot.gpx_uploader import gpx_uploader_thread PARAM_PATH = params.get_params_path() + '/d/' HERTZ = 1 last_modified_confs = {} def confd_thread(): sm = messaging.SubMaster(['deviceState']) pm = messaging.PubMaster(['dragonConf']) last_dp_msg = None frame = 0 update_params = False modified = None last_modified = None last_modified_check = None started = False free_space = 1 battery_percent = 0 overheat = False last_started = False dashcamd = Dashcamd() appd = Appd() is_eon = EON rk = Ratekeeper(HERTZ, print_delay_threshold=None) # Keeps rate at 2 hz uploader_thread = None while True: if uploader_thread is None: uploader_thread = threading.Thread(target=gpx_uploader_thread) uploader_thread.start() msg = messaging.new_message('dragonConf') if last_dp_msg is not None: msg.dragonConf = last_dp_msg ''' =================================================== load thermald data every 3 seconds =================================================== ''' if frame % (HERTZ * 3) == 0: started, free_space, battery_percent, overheat = pull_thermald(frame, sm, started, free_space, battery_percent, overheat) setattr(msg.dragonConf, get_struct_name('dp_thermal_started'), started) setattr(msg.dragonConf, get_struct_name('dp_thermal_overheat'), overheat) ''' =================================================== hotspot on boot we do it after 30 secs just in case =================================================== ''' if is_eon and frame == (HERTZ * 30) and param_get("dp_hotspot_on_boot", "bool", False): os.system("service call wifi 37 i32 0 i32 1 &") ''' =================================================== check dp_last_modified every second =================================================== ''' if not update_params: last_modified_check, modified = get_last_modified(LAST_MODIFIED_SYSTEMD, last_modified_check, modified) if last_modified != modified: update_params = True last_modified = modified ''' =================================================== conditionally set update_params to true =================================================== ''' # force updating param when `started` changed if last_started != started: update_params = True if frame == 0: update_params = True ''' =================================================== push param vals to message =================================================== ''' if update_params: msg = update_conf_all(confs, msg, frame == 0) update_params = False ''' =================================================== push once =================================================== ''' if frame == 0: setattr(msg.dragonConf, get_struct_name('dp_locale'), params.get("dp_locale")) # mirror EndToEndToggle to dp_lane_less_model_ctrl first time, after all put_nonblocking('dp_lane_less_mode_ctrl', params.get('EndToEndToggle')) ''' =================================================== push ip addr every 10 secs =================================================== ''' if frame % (HERTZ * 10) == 0: msg = update_ip(msg) ''' =================================================== update msg based on some custom logic =================================================== ''' msg = update_custom_logic(msg) ''' =================================================== battery ctrl every 30 secs PowerMonitor in thermald turns back on every mins so lets turn it off more frequent =================================================== ''' # if frame % (HERTZ * 30) == 0: # last_charging_ctrl = process_charging_ctrl(msg, last_charging_ctrl, battery_percent) ''' =================================================== dashcam =================================================== ''' if msg.dragonConf.dpDashcamd and frame % HERTZ == 0: dashcamd.run(started, free_space) ''' =================================================== appd =================================================== ''' if msg.dragonConf.dpAppd: appd.update(started) ''' =================================================== finalise =================================================== ''' last_dp_msg = msg.dragonConf last_started = started pm.send('dragonConf', msg) frame += 1 rk.keep_time() def update_conf(msg, conf, first_run = False): conf_type = conf.get('conf_type') # skip checking since modified date time hasn't been changed. if (last_modified_confs.get(conf['name'])) is not None and last_modified_confs.get(conf['name']) == os.stat(PARAM_PATH + conf['name']).st_mtime: return msg if 'param' in conf_type and 'struct' in conf_type: update_this_conf = True if not first_run: update_once = conf.get('update_once') if update_once is not None and update_once is True: return msg if update_this_conf: update_this_conf = check_dependencies(msg, conf) if update_this_conf: msg = set_message(msg, conf) if os.path.isfile(PARAM_PATH + conf['name']): last_modified_confs[conf['name']] = os.stat(PARAM_PATH + conf['name']).st_mtime return msg def update_conf_all(confs, msg, first_run = False): for conf in confs: msg = update_conf(msg, conf, first_run) return msg def process_charging_ctrl(msg, last_charging_ctrl, battery_percent): charging_ctrl = msg.dragonConf.dpChargingCtrl if last_charging_ctrl != charging_ctrl: HARDWARE.set_battery_charging(True) if charging_ctrl: if battery_percent >= msg.dragonConf.dpDischargingAt and HARDWARE.get_battery_charging(): HARDWARE.set_battery_charging(False) elif battery_percent <= msg.dragonConf.dpChargingAt and not HARDWARE.get_battery_charging(): HARDWARE.set_battery_charging(True) return charging_ctrl def pull_thermald(frame, sm, started, free_space, battery_percent, overheat): sm.update(0) if sm.updated['deviceState']: started = sm['deviceState'].started free_space = sm['deviceState'].freeSpacePercent battery_percent = sm['deviceState'].batteryPercent overheat = sm['deviceState'].thermalStatus >= 2 return started, free_space, battery_percent, overheat def update_custom_logic(msg): if msg.dragonConf.dpAtl: msg.dragonConf.dpAllowGas = True msg.dragonConf.dpGearCheck = False if not msg.dragonConf.dpAtlOpLong: msg.dragonConf.dpFollowingProfileCtrl = False msg.dragonConf.dpAccelProfileCtrl = False if msg.dragonConf.dpLcMinMph > msg.dragonConf.dpLcAutoMinMph: put_nonblocking('dp_lc_auto_min_mph', str(msg.dragonConf.dpLcMinMph)) msg.dragonConf.dpLcAutoMinMph = msg.dragonConf.dpLcMinMph # if msg.dragonConf.dpSrCustom <= 4.99 and msg.dragonConf.dpSrStock > 0: # put_nonblocking('dp_sr_custom', str(msg.dragonConf.dpSrStock)) # msg.dragonConf.dpSrCustom = msg.dragonConf.dpSrStock # if msg.dragonConf.dpAppWaze or msg.dragonConf.dpAppHr: # msg.dragonConf.dpDrivingUi = False # if not msg.dragonConf.dpDriverMonitor: # msg.dragonConf.dpUiFace = False return msg def update_ip(msg): val = 'N/A' s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) try: # doesn't even have to be reachable s.connect(('10.255.255.255', 1)) IP = s.getsockname()[0] except: IP = 'N/A' finally: s.close() setattr(msg.dragonConf, get_struct_name('dp_ip_addr'), IP) return msg def set_message(msg, conf): val = params.get(conf['name'], encoding='utf8') if val is not None: val = val.rstrip('\x00') else: val = conf.get('default') params.put(conf['name'], str(val)) struct_val = to_struct_val(conf['name'], val) orig_val = struct_val if struct_val is not None: if conf.get('min') is not None: struct_val = max(struct_val, conf.get('min')) if conf.get('max') is not None: struct_val = min(struct_val, conf.get('max')) if orig_val != struct_val: params.put(conf['name'], str(struct_val)) setattr(msg.dragonConf, get_struct_name(conf['name']), struct_val) return msg def check_dependencies(msg, conf): passed = True # if has dependency and the depend param val is not in depend_vals, we dont update that conf val # this should reduce chance of reading unnecessary params dependencies = conf.get('depends') if dependencies is not None: for dependency in dependencies: if getattr(msg.dragonConf, get_struct_name(dependency['name'])) not in dependency['vals']: passed = False break return passed def main(): confd_thread() if __name__ == "__main__": main() ================================================ FILE: selfdrive/dragonpilot/tpl/addr_input.tpl ================================================
{{msg}}
================================================ FILE: selfdrive/dragonpilot/tpl/app_token_input.tpl ================================================
Set your mapbox APP TOKEN
(begin with sk.)
{{msg}}
================================================ FILE: selfdrive/dragonpilot/tpl/body.tpl ================================================ dragonpilot
{{content}}
================================================ FILE: selfdrive/dragonpilot/tpl/gmap_index.html.tpl ================================================ dragonpilot
================================================ FILE: selfdrive/dragonpilot/tpl/gmap_index.js.tpl ================================================ // This example adds a search box to a map, using the Google Place Autocomplete // feature. People can enter geographical searches. The search box will return a // pick list containing a mix of places and predicted search terms. // This example requires the Places library. Include the libraries=places // parameter when you first load the API. For example: //